diff --git a/.changeset/popular-ducks-rush.md b/.changeset/popular-ducks-rush.md new file mode 100644 index 000000000..e02bd304c --- /dev/null +++ b/.changeset/popular-ducks-rush.md @@ -0,0 +1,6 @@ +--- +"@osdk/client": patch +"@osdk/api": patch +--- + +Cleaning up where clause types. diff --git a/etc/api.report.api.md b/etc/api.report.api.md index c41d214be..3a0426df5 100644 --- a/etc/api.report.api.md +++ b/etc/api.report.api.md @@ -432,6 +432,37 @@ export type GeoFilter_Within = { } | Polygon; }; +// @public (undocumented) +export interface GeoFilterOptions { + // (undocumented) + "$intersects": { + $bbox: BBox; + $polygon?: never; + } | BBox | { + $polygon: Polygon["coordinates"]; + $bbox?: never; + } | Polygon; + // (undocumented) + "$isNull": boolean; + // (undocumented) + "$within": { + $distance: [number, keyof typeof DistanceUnitMapping]; + $of: [number, number] | Readonly; + $bbox?: never; + $polygon?: never; + } | { + $bbox: BBox; + $distance?: never; + $of?: never; + $polygon?: never; + } | BBox | { + $polygon: Polygon["coordinates"]; + $bbox?: never; + $distance?: never; + $of?: never; + } | Polygon; +} + // @public (undocumented) export interface GeotimeSeriesProperty { // Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@" diff --git a/packages/api/src/aggregate/GeoFilter.ts b/packages/api/src/aggregate/GeoFilter.ts index c9cb06d76..1aa1a4f55 100644 --- a/packages/api/src/aggregate/GeoFilter.ts +++ b/packages/api/src/aggregate/GeoFilter.ts @@ -18,7 +18,7 @@ import type { BBox, Point, Polygon } from "geojson"; import type { Just } from "./Just.js"; import type { DistanceUnitMapping } from "./WhereClause.js"; -interface GeoFilterOptions { +export interface GeoFilterOptions { "$within": | { $distance: [number, keyof typeof DistanceUnitMapping]; diff --git a/packages/api/src/index.ts b/packages/api/src/index.ts index 690d7a1c8..1c68eac6b 100644 --- a/packages/api/src/index.ts +++ b/packages/api/src/index.ts @@ -29,6 +29,7 @@ export type { AggregationResultsWithGroups } from "./aggregate/AggregationResult export type { AggregationResultsWithoutGroups } from "./aggregate/AggregationResultsWithoutGroups.js"; export type { AggregationClause } from "./aggregate/AggregationsClause.js"; export type { AggregationsResults } from "./aggregate/AggregationsResults.js"; +export type { GeoFilterOptions } from "./aggregate/GeoFilter.js"; export { DistanceUnitMapping } from "./aggregate/WhereClause.js"; export type { GeoFilter_Intersects, diff --git a/packages/client/src/internal/conversions/modernToLegacyWhereClause.ts b/packages/client/src/internal/conversions/modernToLegacyWhereClause.ts index 82cd1b09d..7573e3e1d 100644 --- a/packages/client/src/internal/conversions/modernToLegacyWhereClause.ts +++ b/packages/client/src/internal/conversions/modernToLegacyWhereClause.ts @@ -15,8 +15,7 @@ */ import type { - GeoFilter_Intersects, - GeoFilter_Within, + GeoFilterOptions, ObjectOrInterfaceDefinition, PossibleWhereClauseFilters, WhereClause, @@ -182,7 +181,7 @@ function handleWherePair( } if (firstKey === "$within") { - const withinBody = filter[firstKey] as GeoFilter_Within["$within"]; + const withinBody = filter[firstKey] as GeoFilterOptions["$within"]; if (Array.isArray(withinBody)) { return makeGeoFilterBbox(field, withinBody, firstKey); @@ -217,8 +216,7 @@ function handleWherePair( } } if (firstKey === "$intersects") { - const intersectsBody = - filter[firstKey] as GeoFilter_Intersects["$intersects"]; + const intersectsBody = filter[firstKey] as GeoFilterOptions["$intersects"]; if (Array.isArray(intersectsBody)) { return makeGeoFilterBbox(field, intersectsBody, firstKey); } else if ("$bbox" in intersectsBody && intersectsBody.$bbox != null) {