Skip to content

Commit ba009d1

Browse files
authored
chore(Search, Typescript): improves the GFacet types (more accurate) (#788)
1 parent 36d7425 commit ba009d1

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

src/services/search/service/query.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ type OptionalKeysInUnion<T, K extends string> = T extends object ? OptionalKeys<
158158
*/
159159
export type GFilter = OptionalKeysInUnion<Schemas['GFilter'], '@version' | 'post_filter'>;
160160

161-
type HistogramRange = { low: number | string; high: number | string };
162-
163161
/**
164162
* @see https://docs.globus.org/api/search/reference/post_query/#gfacet
165163
*/
@@ -176,19 +174,32 @@ export type GFacet = {
176174
missing?: number;
177175
}
178176
| {
177+
/**
178+
* `date_histogram` faceting requires that the field was detected as a date type.
179+
* @see https://docs.globus.org/api/search/mapped_data_types/#date-formats
180+
*/
179181
type: 'date_histogram';
180-
date_interval: DateInterval;
181-
histogram_range?: HistogramRange;
182+
date_interval: Schemas['DateHistogramFacet']['date_interval'];
183+
/**
184+
* `histogram_range` is optional for `date_histogram`, but when provided,
185+
* the `low` and `high` values must be one of the supported date formats.
186+
* @see https://docs.globus.org/api/search/mapped_data_types/#date-formats
187+
*/
188+
histogram_range?: {
189+
low: string;
190+
high: string;
191+
};
182192
}
183193
| {
184194
type: 'numeric_histogram';
185-
size: string;
186-
histogram_range: HistogramRange;
195+
size: number;
196+
histogram_range: {
197+
low: number;
198+
high: number;
199+
};
187200
}
188201
);
189202

190-
type DateInterval = 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second';
191-
192203
/**
193204
* @see https://docs.globus.org/api/search/reference/post_query/#gboost
194205
*/

0 commit comments

Comments
 (0)