@@ -7,17 +7,15 @@ import type { JSONFetchResponse, SDKOptions, ServiceMethodOptions } from '../../
77import type { OpenAPI } from '../index.js' ;
88import type { ResultFormatVersion } from '../types.js' ;
99
10- type Content = NonNullable < OpenAPI . components [ 'schemas' ] [ 'ResultEntry' ] [ 'content' ] > ;
11- export type MatchedPrincipalSets =
12- OpenAPI . components [ 'schemas' ] [ 'ResultEntry' ] [ 'matched_principal_sets' ] ;
10+ type Schemas = OpenAPI . components [ 'schemas' ] ;
11+
12+ type Content = NonNullable < Schemas [ 'ResultEntry' ] [ 'content' ] > ;
13+ export type MatchedPrincipalSets = Schemas [ 'ResultEntry' ] [ 'matched_principal_sets' ] ;
1314/**
1415 * @see https://docs.globus.org/api/search/reference/post_query/#gmetaresult
1516 */
16- export type GMetaResult < C extends Content = Content > = Omit <
17- OpenAPI . components [ 'schemas' ] [ 'GMetaResult' ] ,
18- 'entries'
19- > & {
20- entries : ( Omit < OpenAPI . components [ 'schemas' ] [ 'ResultEntry' ] , 'content' > & { content : C } ) [ ] ;
17+ export type GMetaResult < C extends Content = Content > = Omit < Schemas [ 'GMetaResult' ] , 'entries' > & {
18+ entries : ( Omit < Schemas [ 'ResultEntry' ] , 'content' > & { content : C } ) [ ] ;
2119} ;
2220
2321/**
@@ -33,7 +31,13 @@ export type GFacetResult = {
3331 * @see https://docs.globus.org/api/search/reference/post_query/#gbucket
3432 */
3533export type GBucket = {
36- value : string | GFilter ;
34+ value :
35+ | string
36+ | number
37+ | {
38+ to : string ;
39+ from : string ;
40+ } ;
3741 count : number ;
3842} ;
3943
@@ -137,32 +141,22 @@ export const post = function <C extends Content = Content>(
137141 ) ;
138142} ;
139143
144+ type OptionalKeys < T , K extends keyof T > = Omit < T , K > & Partial < Pick < T , K > > ;
145+
140146/**
141- * @see https://docs.globus.org/api/search/reference/post_query/#gfilter
147+ * Utility type to make specific keys in a union of objects optional.
148+ * This is used to account for `defaultNonNullable: true` when generating types.
149+ * @see file://./../../../../scripts/open-api/generate-types.mjs#L54-L55
142150 */
143- export type GFilter = GFilterMatch | GFilterRange | GFilterExists | GFilterNot ;
151+ type OptionalKeysInUnion < T , K extends string > = T extends object ? OptionalKeys < T , K & keyof T > : T ;
144152
145- type GFilterTypeMatch = 'match_any' | 'match_all' ;
146- type GFilterTypeRange = 'range' ;
147-
148- type GFilterMatch = {
149- type : GFilterTypeMatch ;
150- field_name : string ;
151- values : Array < string > ;
152- } ;
153- type GFilterRange = {
154- type : GFilterTypeRange ;
155- field_name : string ;
156- values : Array < { from : string ; to : string } > ;
157- } ;
158- type GFilterExists = {
159- type : 'exists' ;
160- field_name : string ;
161- } ;
162- type GFilterNot = {
163- type : 'not' ;
164- filter : GFilter ;
165- } ;
153+ /**
154+ * @see https://docs.globus.org/api/search/reference/post_query/#gfilter
155+ *
156+ * @privateRemarks
157+ * The `GFilter` type includes `@version` and `post_filter` with `"default"` values.
158+ */
159+ export type GFilter = OptionalKeysInUnion < Schemas [ 'GFilter' ] , '@version' | 'post_filter' > ;
166160
167161type HistogramRange = { low : number | string ; high : number | string } ;
168162
0 commit comments