-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Alternate idea for single use (#899)
* Alternate idea for single use * Cleanup * Restore $in * Add type sanity checks * saurav changes * fix more tests * remove extraneous files * add changeset * fix test * add new report --------- Co-authored-by: Saurav <[email protected]>
- Loading branch information
1 parent
009650f
commit 11088aa
Showing
15 changed files
with
519 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@osdk/client": patch | ||
"@osdk/api": patch | ||
--- | ||
|
||
Fix where clause types so we don't accept more than one key in the clauses. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2024 Palantir Technologies, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import type { Just } from "./Just.js"; | ||
|
||
interface ArrayFilterOptions<T> { | ||
"$contains": T; | ||
"$isNull": boolean; | ||
} | ||
namespace ArrayFilter { | ||
export interface $contains<T> | ||
extends Just<"$contains", ArrayFilterOptions<T>> | ||
{} | ||
export interface $isNull<T> extends Just<"$isNull", ArrayFilterOptions<T>> {} | ||
} | ||
|
||
export type ArrayFilter<T> = | ||
| ArrayFilter.$contains<T> | ||
| ArrayFilter.$isNull<T>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2024 Palantir Technologies, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import type { Just } from "./Just.js"; | ||
|
||
export type BaseFilterOptions<T> = { | ||
"$eq": T; | ||
"$ne": T; | ||
"$isNull": boolean; | ||
"$in": ReadonlyArray<T>; | ||
}; | ||
|
||
export namespace BaseFilter { | ||
export interface $eq<T> extends Just<"$eq", BaseFilterOptions<T>> {} | ||
export interface $ne<T> extends Just<"$ne", BaseFilterOptions<T>> {} | ||
export interface $in<T> extends Just<"$in", BaseFilterOptions<T>> {} | ||
export interface $isNull<T> extends Just<"$isNull", BaseFilterOptions<T>> {} | ||
} | ||
|
||
export type BaseFilter<T> = | ||
| BaseFilter.$eq<T> | ||
| BaseFilter.$ne<T> | ||
| BaseFilter.$in<T> | ||
| BaseFilter.$isNull<T>; | ||
|
||
/** @internal */ | ||
export type CatchThemAll<T> = CatchThemAllInternal<T, keyof T>; | ||
|
||
// extends for union distribution | ||
/** @internal */ | ||
type CatchThemAllInternal<T, K extends keyof T> = K extends keyof T | ||
? { [k in K]: T[k] } | ||
: never; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2024 Palantir Technologies, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import type { BaseFilterOptions, CatchThemAll } from "./BaseFilter.js"; | ||
import type { Just } from "./Just.js"; | ||
|
||
interface BooleanFilterOptions extends BaseFilterOptions<boolean> {} | ||
|
||
export namespace BooleanFilter { | ||
export interface $eq extends Just<"$eq", BooleanFilterOptions> {} | ||
export interface $ne extends Just<"$ne", BooleanFilterOptions> {} | ||
export interface $isNull extends Just<"$isNull", BooleanFilterOptions> {} | ||
export interface $in extends Just<"$in", BooleanFilterOptions> {} | ||
} | ||
export type BooleanFilter = | ||
| boolean | ||
| BooleanFilter.$eq | ||
| BooleanFilter.$ne | ||
| BooleanFilter.$in | ||
| BooleanFilter.$isNull; | ||
|
||
/** @internal */ | ||
function _typeCheck() { | ||
const b: BooleanFilter = {} as CatchThemAll<BooleanFilterOptions>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2024 Palantir Technologies, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import type { BaseFilterOptions, CatchThemAll } from "./BaseFilter.js"; | ||
import type { Just } from "./Just.js"; | ||
|
||
export interface DatetimeFilterOptions extends BaseFilterOptions<string> { | ||
"$gt": string; | ||
"$gte": string; | ||
"$lt": string; | ||
"$lte": string; | ||
} | ||
|
||
export namespace DatetimeFilter { | ||
export interface $eq extends Just<"$eq", DatetimeFilterOptions> {} | ||
export interface $ne extends Just<"$ne", DatetimeFilterOptions> {} | ||
export interface $isNull extends Just<"$isNull", DatetimeFilterOptions> {} | ||
export interface $gt extends Just<"$gt", DatetimeFilterOptions> {} | ||
export interface $gte extends Just<"$gte", DatetimeFilterOptions> {} | ||
export interface $lt extends Just<"$lt", DatetimeFilterOptions> {} | ||
export interface $lte extends Just<"$lte", DatetimeFilterOptions> {} | ||
export interface $in extends Just<"$in", DatetimeFilterOptions> {} | ||
} | ||
export type DatetimeFilter = | ||
| string | ||
| DatetimeFilter.$eq | ||
| DatetimeFilter.$ne | ||
| DatetimeFilter.$isNull | ||
| DatetimeFilter.$in | ||
| DatetimeFilter.$gt | ||
| DatetimeFilter.$gte | ||
| DatetimeFilter.$lt | ||
| DatetimeFilter.$lte; | ||
|
||
/** @internal */ | ||
function _typeCheck() { | ||
const b: DatetimeFilter = {} as CatchThemAll<DatetimeFilterOptions>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright 2024 Palantir Technologies, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import type { BBox, Point, Polygon } from "geojson"; | ||
import type { Just } from "./Just.js"; | ||
import type { DistanceUnitMapping } from "./WhereClause.js"; | ||
|
||
interface GeoFilterOptions { | ||
"$within": | ||
| { | ||
$distance: [number, keyof typeof DistanceUnitMapping]; | ||
$of: [number, number] | Readonly<Point>; | ||
$bbox?: never; | ||
$polygon?: never; | ||
} | ||
| { | ||
$bbox: BBox; | ||
$distance?: never; | ||
$of?: never; | ||
$polygon?: never; | ||
} | ||
| BBox | ||
| { | ||
$polygon: Polygon["coordinates"]; | ||
$bbox?: never; | ||
$distance?: never; | ||
$of?: never; | ||
} | ||
| Polygon; | ||
"$intersects": | ||
| { | ||
$bbox: BBox; | ||
$polygon?: never; | ||
} | ||
| BBox | ||
| { | ||
$polygon: Polygon["coordinates"]; | ||
$bbox?: never; | ||
} | ||
| Polygon; | ||
"$isNull": boolean; | ||
} | ||
|
||
export namespace GeoFilter { | ||
export interface $within extends Just<"$within", GeoFilterOptions> {} | ||
export interface $intersects extends Just<"$intersects", GeoFilterOptions> {} | ||
export interface $isNull extends Just<"$isNull", GeoFilterOptions> {} | ||
} | ||
|
||
export type GeoFilter = | ||
| GeoFilter.$within | ||
| GeoFilter.$intersects | ||
| GeoFilter.$isNull; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2024 Palantir Technologies, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
export type Just<Z extends keyof V, V> = | ||
& { | ||
[k in Z]: V[k]; | ||
} | ||
& { | ||
[k in keyof V as k extends Z ? never : k]?: never; | ||
}; | ||
|
||
export type NeverThese<V extends string | symbol | number> = { | ||
[k in V]?: never; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2024 Palantir Technologies, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import type { BaseFilterOptions, CatchThemAll } from "./BaseFilter.js"; | ||
import type { Just } from "./Just.js"; | ||
|
||
interface NumberFilterOptions extends BaseFilterOptions<number> { | ||
"$gt": number; | ||
"$gte": number; | ||
"$lt": number; | ||
"$lte": number; | ||
} | ||
|
||
export namespace NumberFilter { | ||
export interface $eq extends Just<"$eq", NumberFilterOptions> {} | ||
export interface $ne extends Just<"$ne", NumberFilterOptions> {} | ||
export interface $isNull extends Just<"$isNull", NumberFilterOptions> {} | ||
export interface $gt extends Just<"$gt", NumberFilterOptions> {} | ||
export interface $gte extends Just<"$gte", NumberFilterOptions> {} | ||
export interface $lt extends Just<"$lt", NumberFilterOptions> {} | ||
export interface $lte extends Just<"$lte", NumberFilterOptions> {} | ||
export interface $in extends Just<"$in", NumberFilterOptions> {} | ||
} | ||
export type NumberFilter = | ||
| number | ||
| NumberFilter.$eq | ||
| NumberFilter.$ne | ||
| NumberFilter.$isNull | ||
| NumberFilter.$in | ||
| NumberFilter.$gt | ||
| NumberFilter.$gte | ||
| NumberFilter.$lt | ||
| NumberFilter.$lte; | ||
|
||
/** @internal */ | ||
function _typeCheck() { | ||
const b: NumberFilter = {} as CatchThemAll<NumberFilterOptions>; | ||
} |
Oops, something went wrong.