@osdk/client 2.0.1 → 2.0.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/build/browser/Client.d.ts +1 -1
- package/build/browser/Client.js +1 -1
- package/build/browser/Client.js.map +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.d.ts +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.d.ts.map +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js +17 -7
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js +101 -14
- package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
- package/build/browser/object/aggregate.js +1 -1
- package/build/browser/object/aggregate.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +27 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.test.d.ts +2 -0
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.test.d.ts.map +1 -0
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.test.js +190 -0
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.test.js.map +1 -0
- package/build/browser/objectSet/createObjectSet.js +1 -1
- package/build/browser/objectSet/createObjectSet.js.map +1 -1
- package/build/browser/util/UserAgent.js +1 -1
- package/build/browser/util/UserAgent.js.map +1 -1
- package/build/esm/Client.d.ts +1 -1
- package/build/esm/Client.js +1 -1
- package/build/esm/Client.js.map +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.d.ts +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.d.ts.map +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js +17 -7
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js +101 -14
- package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
- package/build/esm/object/aggregate.js +1 -1
- package/build/esm/object/aggregate.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +27 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.test.d.ts +2 -0
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.test.d.ts.map +1 -0
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.test.js +190 -0
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.test.js.map +1 -0
- package/build/esm/objectSet/createObjectSet.js +1 -1
- package/build/esm/objectSet/createObjectSet.js.map +1 -1
- package/build/esm/util/UserAgent.js +1 -1
- package/build/esm/util/UserAgent.js.map +1 -1
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOsdkInterface.js","names":["createSimpleCache","InterfaceDefRef","ObjectDefRef","UnderlyingOsdkObject","handlerCache","WeakMap","createInterfaceProxyHandler","createOsdkInterface","underlying","interfaceDef","handler","get","proxy","Proxy","newDef","getOwnPropertyDescriptor","target","p","objDef","Reflect","undefined","enumerable","configurable","value","apiName","properties","interfaceMap","ownKeys","Object","keys"],"sources":["createOsdkInterface.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createSimpleCache } from \"../SimpleCache.js\";\nimport { InterfaceDefRef, ObjectDefRef, UnderlyingOsdkObject, } from \"./InternalSymbols.js\";\nconst handlerCache = createSimpleCache(new WeakMap(), createInterfaceProxyHandler);\n/** @internal */\nexport function createOsdkInterface(underlying, interfaceDef) {\n const interfaceHolder = {\n [UnderlyingOsdkObject]: underlying,\n [InterfaceDefRef]: interfaceDef,\n };\n const handler = handlerCache.get(interfaceDef);\n const proxy = new Proxy(interfaceHolder, // the wrapper doesn't contain everything obviously. we proxy\n handler);\n return proxy;\n}\nfunction createInterfaceProxyHandler(newDef) {\n return {\n getOwnPropertyDescriptor(target, p) {\n const underlying = target[UnderlyingOsdkObject];\n const objDef = underlying[ObjectDefRef];\n switch (p) {\n case \"$primaryKey\":\n case \"$title\":\n case \"$objectType\":\n case \"$rid\":\n return underlying[p] != null\n ? Reflect.getOwnPropertyDescriptor(underlying, p)\n : undefined;\n case \"$apiName\":\n return {\n enumerable: true,\n configurable: true,\n value: target[InterfaceDefRef].apiName,\n };\n }\n if (newDef.properties[p] != null) {\n return {\n enumerable: true,\n configurable: true,\n value: underlying[objDef.interfaceMap[newDef.apiName][p]],\n };\n }\n },\n ownKeys(target) {\n const underlying = target[UnderlyingOsdkObject];\n return [\n \"$apiName\",\n \"$objectType\",\n \"$primaryKey\",\n ...(underlying[\"$rid\"] ? [\"$rid\"] : []),\n \"$title\",\n ...
|
|
1
|
+
{"version":3,"file":"createOsdkInterface.js","names":["extractNamespace","createSimpleCache","InterfaceDefRef","ObjectDefRef","UnderlyingOsdkObject","handlerCache","WeakMap","createInterfaceProxyHandler","createOsdkInterface","underlying","interfaceDef","handler","get","proxy","Proxy","newDef","getOwnPropertyDescriptor","target","p","objDef","Reflect","undefined","enumerable","configurable","value","apiName","objApiNamespace","apiNamespace","properties","interfaceMap","ownKeys","propNames","Object","keys","map"],"sources":["createOsdkInterface.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { extractNamespace } from \"../../internal/conversions/modernToLegacyWhereClause.js\";\nimport { createSimpleCache } from \"../SimpleCache.js\";\nimport { InterfaceDefRef, ObjectDefRef, UnderlyingOsdkObject, } from \"./InternalSymbols.js\";\nconst handlerCache = createSimpleCache(new WeakMap(), createInterfaceProxyHandler);\n/** @internal */\nexport function createOsdkInterface(underlying, interfaceDef) {\n const interfaceHolder = {\n [UnderlyingOsdkObject]: underlying,\n [InterfaceDefRef]: interfaceDef,\n };\n const handler = handlerCache.get(interfaceDef);\n const proxy = new Proxy(interfaceHolder, // the wrapper doesn't contain everything obviously. we proxy\n handler);\n return proxy;\n}\nfunction createInterfaceProxyHandler(newDef) {\n return {\n getOwnPropertyDescriptor(target, p) {\n const underlying = target[UnderlyingOsdkObject];\n const objDef = underlying[ObjectDefRef];\n switch (p) {\n case \"$primaryKey\":\n case \"$title\":\n case \"$objectType\":\n case \"$rid\":\n return underlying[p] != null\n ? Reflect.getOwnPropertyDescriptor(underlying, p)\n : undefined;\n case \"$apiName\":\n return {\n enumerable: true,\n configurable: true,\n value: target[InterfaceDefRef].apiName,\n };\n }\n const [objApiNamespace] = extractNamespace(newDef.apiName);\n if (objApiNamespace != null) {\n const [apiNamespace, apiName] = extractNamespace(p);\n if (apiNamespace == null) {\n p = `${objApiNamespace}.${apiName}`;\n }\n }\n if (newDef.properties[p] != null) {\n return {\n enumerable: true,\n configurable: true,\n value: underlying[objDef.interfaceMap[newDef.apiName][p]],\n };\n }\n },\n ownKeys(target) {\n const underlying = target[UnderlyingOsdkObject];\n const [objApiNamespace] = extractNamespace(newDef.apiName);\n let propNames = Object.keys(newDef.properties);\n if (objApiNamespace != null) {\n propNames = propNames.map(p => {\n const [apiNamespace, apiName] = extractNamespace(p);\n if (apiNamespace === objApiNamespace) {\n p = apiName;\n }\n return p;\n });\n }\n return [\n \"$apiName\",\n \"$objectType\",\n \"$primaryKey\",\n ...(underlying[\"$rid\"] ? [\"$rid\"] : []),\n \"$title\",\n ...propNames,\n ];\n },\n get(target, p) {\n const underlying = target[UnderlyingOsdkObject];\n switch (p) {\n case InterfaceDefRef:\n return newDef;\n case \"$apiName\":\n return newDef.apiName;\n case \"$as\":\n case UnderlyingOsdkObject:\n case \"$primaryKey\":\n case \"$title\":\n case \"$objectType\":\n case \"$rid\":\n return underlying[p];\n }\n const [objApiNamespace] = extractNamespace(newDef.apiName);\n if (objApiNamespace != null) {\n const [apiNamespace, apiName] = extractNamespace(p);\n if (apiNamespace == null) {\n p = `${objApiNamespace}.${apiName}`;\n }\n }\n if (newDef.properties[p] != null) {\n const objDef = target[UnderlyingOsdkObject][ObjectDefRef];\n return underlying[objDef.interfaceMap[newDef.apiName][p]];\n }\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,yDAAyD;AAC1F,SAASC,iBAAiB,QAAQ,mBAAmB;AACrD,SAASC,eAAe,EAAEC,YAAY,EAAEC,oBAAoB,QAAS,sBAAsB;AAC3F,MAAMC,YAAY,GAAGJ,iBAAiB,CAAC,IAAIK,OAAO,CAAC,CAAC,EAAEC,2BAA2B,CAAC;AAClF;AACA,OAAO,SAASC,mBAAmBA,CAACC,UAAU,EAAEC,YAAY,EAAE;EAK1D,MAAMC,OAAO,GAAGN,YAAY,CAACO,GAAG,CAACF,YAAY,CAAC;EAC9C,MAAMG,KAAK,GAAG,IAAIC,KAAK,CALC;IACpB,CAACV,oBAAoB,GAAGK,UAAU;IAClC,CAACP,eAAe,GAAGQ;EACvB,CAAC;EAEwC;EACzCC,OAAO,CAAC;EACR,OAAOE,KAAK;A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QACvC;MACJ;MACA,IAAIV,MAAM,CAACa,UAAU,CAACV,CAAC,CAAC,IAAI,IAAI,EAAE;QAC9B,MAAMC,MAAM,GAAGF,MAAM,CAACb,oBAAoB,CAAC,CAACD,YAAY,CAAC;QACzD,OAAOM,UAAU,CAACU,MAAM,CAACU,YAAY,CAACd,MAAM,CAACU,OAAO,CAAC,CAACP,CAAC,CAAC,CAAC;MAC7D;IACJ;EACJ,CAAC;AACL","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOsdkInterface.test.d.ts","sourceRoot":"","sources":["../../../../src/object/convertWireToOsdkObjects/createOsdkInterface.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { describe, expect, it } from "vitest";
|
|
17
|
+
import { InterfaceDefinitions } from "../../ontology/OntologyProvider.js";
|
|
18
|
+
import { createOsdkInterface } from "./createOsdkInterface.js";
|
|
19
|
+
import { ObjectDefRef } from "./InternalSymbols.js";
|
|
20
|
+
describe(createOsdkInterface, () => {
|
|
21
|
+
it("works in the normal case", () => {
|
|
22
|
+
// underlying: Osdk<Q> & ObjectHolder<Q>,
|
|
23
|
+
// interfaceDef: InterfaceMetadata,
|
|
24
|
+
const iface = createOsdkInterface({
|
|
25
|
+
"foo": "hi mom",
|
|
26
|
+
[ObjectDefRef]: {
|
|
27
|
+
[InterfaceDefinitions]: {},
|
|
28
|
+
apiName: "Obj",
|
|
29
|
+
displayName: "",
|
|
30
|
+
interfaceMap: {
|
|
31
|
+
"IFoo": {
|
|
32
|
+
"asdf": "foo"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
inverseInterfaceMap: {},
|
|
36
|
+
links: {},
|
|
37
|
+
pluralDisplayName: "",
|
|
38
|
+
primaryKeyApiName: "",
|
|
39
|
+
primaryKeyType: "string",
|
|
40
|
+
properties: {
|
|
41
|
+
"foo": {
|
|
42
|
+
type: "string"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
type: "object",
|
|
46
|
+
titleProperty: "foo",
|
|
47
|
+
rid: "",
|
|
48
|
+
status: "ACTIVE"
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
"apiName": "IFoo",
|
|
52
|
+
displayName: "",
|
|
53
|
+
links: {},
|
|
54
|
+
properties: {
|
|
55
|
+
"asdf": {
|
|
56
|
+
type: "string"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
rid: "",
|
|
60
|
+
type: "interface",
|
|
61
|
+
implements: []
|
|
62
|
+
});
|
|
63
|
+
expect(Object.keys(iface)).toMatchInlineSnapshot(`
|
|
64
|
+
[
|
|
65
|
+
"$apiName",
|
|
66
|
+
"asdf",
|
|
67
|
+
]
|
|
68
|
+
`);
|
|
69
|
+
expect(iface.asdf).toBe("hi mom");
|
|
70
|
+
expect(JSON.stringify(iface, undefined, 2)).toMatchInlineSnapshot(`
|
|
71
|
+
"{
|
|
72
|
+
"$apiName": "IFoo",
|
|
73
|
+
"asdf": "hi mom"
|
|
74
|
+
}"
|
|
75
|
+
`);
|
|
76
|
+
});
|
|
77
|
+
it("properly maps apiNamespace", () => {
|
|
78
|
+
// underlying: Osdk<Q> & ObjectHolder<Q>,
|
|
79
|
+
// interfaceDef: InterfaceMetadata,
|
|
80
|
+
const iface = createOsdkInterface({
|
|
81
|
+
"foo": "hi mom",
|
|
82
|
+
[ObjectDefRef]: {
|
|
83
|
+
[InterfaceDefinitions]: {},
|
|
84
|
+
apiName: "Obj",
|
|
85
|
+
displayName: "",
|
|
86
|
+
interfaceMap: {
|
|
87
|
+
"a.IFoo": {
|
|
88
|
+
"a.asdf": "foo"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
inverseInterfaceMap: {},
|
|
92
|
+
links: {},
|
|
93
|
+
pluralDisplayName: "",
|
|
94
|
+
primaryKeyApiName: "",
|
|
95
|
+
primaryKeyType: "string",
|
|
96
|
+
properties: {
|
|
97
|
+
"foo": {
|
|
98
|
+
type: "string"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
type: "object",
|
|
102
|
+
titleProperty: "foo",
|
|
103
|
+
rid: "",
|
|
104
|
+
status: "ACTIVE"
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
"apiName": "a.IFoo",
|
|
108
|
+
displayName: "",
|
|
109
|
+
links: {},
|
|
110
|
+
properties: {
|
|
111
|
+
"a.asdf": {
|
|
112
|
+
type: "string"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
rid: "",
|
|
116
|
+
type: "interface",
|
|
117
|
+
implements: []
|
|
118
|
+
});
|
|
119
|
+
expect(Object.keys(iface)).toMatchInlineSnapshot(`
|
|
120
|
+
[
|
|
121
|
+
"$apiName",
|
|
122
|
+
"asdf",
|
|
123
|
+
]
|
|
124
|
+
`);
|
|
125
|
+
expect(iface.asdf).toBe("hi mom");
|
|
126
|
+
expect(JSON.stringify(iface, undefined, 2)).toMatchInlineSnapshot(`
|
|
127
|
+
"{
|
|
128
|
+
"$apiName": "a.IFoo",
|
|
129
|
+
"asdf": "hi mom"
|
|
130
|
+
}"
|
|
131
|
+
`);
|
|
132
|
+
});
|
|
133
|
+
it("works with mixed namespaces", () => {
|
|
134
|
+
// underlying: Osdk<Q> & ObjectHolder<Q>,
|
|
135
|
+
// interfaceDef: InterfaceMetadata,
|
|
136
|
+
const iface = createOsdkInterface({
|
|
137
|
+
"foo": "hi mom",
|
|
138
|
+
[ObjectDefRef]: {
|
|
139
|
+
[InterfaceDefinitions]: {},
|
|
140
|
+
apiName: "Obj",
|
|
141
|
+
displayName: "",
|
|
142
|
+
interfaceMap: {
|
|
143
|
+
"a.IFoo": {
|
|
144
|
+
"b.asdf": "foo"
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
inverseInterfaceMap: {},
|
|
148
|
+
links: {},
|
|
149
|
+
pluralDisplayName: "",
|
|
150
|
+
primaryKeyApiName: "",
|
|
151
|
+
primaryKeyType: "string",
|
|
152
|
+
properties: {
|
|
153
|
+
"foo": {
|
|
154
|
+
type: "string"
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
type: "object",
|
|
158
|
+
titleProperty: "foo",
|
|
159
|
+
rid: "",
|
|
160
|
+
status: "ACTIVE"
|
|
161
|
+
}
|
|
162
|
+
}, {
|
|
163
|
+
"apiName": "a.IFoo",
|
|
164
|
+
displayName: "",
|
|
165
|
+
links: {},
|
|
166
|
+
properties: {
|
|
167
|
+
"b.asdf": {
|
|
168
|
+
type: "string"
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
rid: "",
|
|
172
|
+
type: "interface",
|
|
173
|
+
implements: []
|
|
174
|
+
});
|
|
175
|
+
expect(Object.keys(iface)).toMatchInlineSnapshot(`
|
|
176
|
+
[
|
|
177
|
+
"$apiName",
|
|
178
|
+
"b.asdf",
|
|
179
|
+
]
|
|
180
|
+
`);
|
|
181
|
+
expect(iface["b.asdf"]).toBe("hi mom");
|
|
182
|
+
expect(JSON.stringify(iface, undefined, 2)).toMatchInlineSnapshot(`
|
|
183
|
+
"{
|
|
184
|
+
"$apiName": "a.IFoo",
|
|
185
|
+
"b.asdf": "hi mom"
|
|
186
|
+
}"
|
|
187
|
+
`);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
//# sourceMappingURL=createOsdkInterface.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOsdkInterface.test.js","names":["describe","expect","it","InterfaceDefinitions","createOsdkInterface","ObjectDefRef","iface","apiName","displayName","interfaceMap","inverseInterfaceMap","links","pluralDisplayName","primaryKeyApiName","primaryKeyType","properties","type","titleProperty","rid","status","implements","Object","keys","toMatchInlineSnapshot","asdf","toBe","JSON","stringify","undefined"],"sources":["createOsdkInterface.test.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { describe, expect, it } from \"vitest\";\nimport { InterfaceDefinitions, } from \"../../ontology/OntologyProvider.js\";\nimport { createOsdkInterface } from \"./createOsdkInterface.js\";\nimport { ObjectDefRef } from \"./InternalSymbols.js\";\ndescribe(createOsdkInterface, () => {\n it(\"works in the normal case\", () => {\n const underlying = {\n \"foo\": \"hi mom\",\n [ObjectDefRef]: {\n [InterfaceDefinitions]: {},\n apiName: \"Obj\",\n displayName: \"\",\n interfaceMap: {\n \"IFoo\": {\n \"asdf\": \"foo\",\n },\n },\n inverseInterfaceMap: {},\n links: {},\n pluralDisplayName: \"\",\n primaryKeyApiName: \"\",\n primaryKeyType: \"string\",\n properties: {\n \"foo\": {\n type: \"string\",\n },\n },\n type: \"object\",\n titleProperty: \"foo\",\n rid: \"\",\n status: \"ACTIVE\",\n },\n };\n // underlying: Osdk<Q> & ObjectHolder<Q>,\n // interfaceDef: InterfaceMetadata,\n const iface = createOsdkInterface(underlying, {\n \"apiName\": \"IFoo\",\n displayName: \"\",\n links: {},\n properties: {\n \"asdf\": {\n type: \"string\",\n },\n },\n rid: \"\",\n type: \"interface\",\n implements: [],\n });\n expect(Object.keys(iface)).toMatchInlineSnapshot(`\n [\n \"$apiName\",\n \"asdf\",\n ]\n `);\n expect(iface.asdf).toBe(\"hi mom\");\n expect(JSON.stringify(iface, undefined, 2)).toMatchInlineSnapshot(`\n \"{\n \"$apiName\": \"IFoo\",\n \"asdf\": \"hi mom\"\n }\"\n `);\n });\n it(\"properly maps apiNamespace\", () => {\n const underlying = {\n \"foo\": \"hi mom\",\n [ObjectDefRef]: {\n [InterfaceDefinitions]: {},\n apiName: \"Obj\",\n displayName: \"\",\n interfaceMap: {\n \"a.IFoo\": {\n \"a.asdf\": \"foo\",\n },\n },\n inverseInterfaceMap: {},\n links: {},\n pluralDisplayName: \"\",\n primaryKeyApiName: \"\",\n primaryKeyType: \"string\",\n properties: {\n \"foo\": {\n type: \"string\",\n },\n },\n type: \"object\",\n titleProperty: \"foo\",\n rid: \"\",\n status: \"ACTIVE\",\n },\n };\n // underlying: Osdk<Q> & ObjectHolder<Q>,\n // interfaceDef: InterfaceMetadata,\n const iface = createOsdkInterface(underlying, {\n \"apiName\": \"a.IFoo\",\n displayName: \"\",\n links: {},\n properties: {\n \"a.asdf\": {\n type: \"string\",\n },\n },\n rid: \"\",\n type: \"interface\",\n implements: [],\n });\n expect(Object.keys(iface)).toMatchInlineSnapshot(`\n [\n \"$apiName\",\n \"asdf\",\n ]\n `);\n expect(iface.asdf).toBe(\"hi mom\");\n expect(JSON.stringify(iface, undefined, 2)).toMatchInlineSnapshot(`\n \"{\n \"$apiName\": \"a.IFoo\",\n \"asdf\": \"hi mom\"\n }\"\n `);\n });\n it(\"works with mixed namespaces\", () => {\n const underlying = {\n \"foo\": \"hi mom\",\n [ObjectDefRef]: {\n [InterfaceDefinitions]: {},\n apiName: \"Obj\",\n displayName: \"\",\n interfaceMap: {\n \"a.IFoo\": {\n \"b.asdf\": \"foo\",\n },\n },\n inverseInterfaceMap: {},\n links: {},\n pluralDisplayName: \"\",\n primaryKeyApiName: \"\",\n primaryKeyType: \"string\",\n properties: {\n \"foo\": {\n type: \"string\",\n },\n },\n type: \"object\",\n titleProperty: \"foo\",\n rid: \"\",\n status: \"ACTIVE\",\n },\n };\n // underlying: Osdk<Q> & ObjectHolder<Q>,\n // interfaceDef: InterfaceMetadata,\n const iface = createOsdkInterface(underlying, {\n \"apiName\": \"a.IFoo\",\n displayName: \"\",\n links: {},\n properties: {\n \"b.asdf\": {\n type: \"string\",\n },\n },\n rid: \"\",\n type: \"interface\",\n implements: [],\n });\n expect(Object.keys(iface)).toMatchInlineSnapshot(`\n [\n \"$apiName\",\n \"b.asdf\",\n ]\n `);\n expect(iface[\"b.asdf\"]).toBe(\"hi mom\");\n expect(JSON.stringify(iface, undefined, 2)).toMatchInlineSnapshot(`\n \"{\n \"$apiName\": \"a.IFoo\",\n \"b.asdf\": \"hi mom\"\n }\"\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,oBAAoB,QAAS,oCAAoC;AAC1E,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,YAAY,QAAQ,sBAAsB;AACnDL,QAAQ,CAACI,mBAAmB,EAAE,MAAM;EAChCF,EAAE,CAAC,0BAA0B,EAAE,MAAM;IA4BjC;IACA;IACA,MAAMI,KAAK,GAAGF,mBAAmB,CA7Bd;MACf,KAAK,EAAE,QAAQ;MACf,CAACC,YAAY,GAAG;QACZ,CAACF,oBAAoB,GAAG,CAAC,CAAC;QAC1BI,OAAO,EAAE,KAAK;QACdC,WAAW,EAAE,EAAE;QACfC,YAAY,EAAE;UACV,MAAM,EAAE;YACJ,MAAM,EAAE;UACZ;QACJ,CAAC;QACD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,CAAC;QACDC,mBAAmB,EAAE,CAAC,CAAC;QACvBC,KAAK,EAAE,CAAC,CAAC;QACTC,iBAAiB,EAAE,EAAE;QACrBC,iBAAiB,EAAE,EAAE;QACrBC,cAAc,EAAE,QAAQ;QACxBC,UAAU,EAAE;UACR,KAAK,EAAE;YACHC,IAAI,EAAE;UACV;QACJ,CAAC;QACDA,IAAI,EAAE,QAAQ;QACdC,aAAa,EAAE,KAAK;QACpBC,GAAG,EAAE,EAAE;QACPC,MAAM,EAAE;MACZ;IACJ,CAAC,EAG6C;MAC1C,SAAS,EAAE,QAAQ;MACnBX,WAAW,EAAE,EAAE;MACfG,KAAK,EAAE,CAAC,CAAC;MACTI,UAAU,EAAE;QACR,QAAQ,EAAE;UACNC,IAAI,EAAE;QACV;MACJ,CAAC;MACDE,GAAG,EAAE,EAAE;MACPF,IAAI,EAAE,WAAW;MACjBI,UAAU,EAAE;IAChB,CAAC,CAAC;IACFnB,MAAM,CAACoB,MAAM,CAACC,IAAI,CAAChB,KAAK,CAAC,CAAC,CAACiB,qBAAqB,CAAC;AACzD;AACA;AACA;AACA;AACA,KAAK,CAAC;IACEtB,MAAM,CAACK,KAAK,CAAC,QAAQ,CAAC,CAAC,CAACmB,IAAI,CAAC,QAAQ,CAAC;IACtCxB,MAAM,CAACyB,IAAI,CAACC,SAAS,CAACrB,KAAK,EAAEsB,SAAS,EAAE,CAAC,CAAC,CAAC,CAACL,qBAAqB,CAAC;AAC1E;AACA;AACA;AACA;AACA,KAAK,CAAC;EACF,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -52,7 +52,7 @@ export function createObjectSet(objectType, clientCtx, objectSet = {
|
|
|
52
52
|
return clientCtx.objectSetFactory(objectType, clientCtx, {
|
|
53
53
|
type: "filter",
|
|
54
54
|
objectSet: objectSet,
|
|
55
|
-
where: modernToLegacyWhereClause(clause)
|
|
55
|
+
where: modernToLegacyWhereClause(clause, objectType)
|
|
56
56
|
});
|
|
57
57
|
},
|
|
58
58
|
pivotTo: function (type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createObjectSet.js","names":["__EXPERIMENTAL__NOT_SUPPORTED_YET_subscribe","modernToLegacyWhereClause","aggregate","fetchPageInternal","fetchPageWithErrorsInternal","fetchSingle","fetchSingleWithErrors","augmentRequestContext","isWireObjectSet","ObjectSetListenerWebsocket","isObjectTypeDefinition","def","type","isObjectSet","o","objectSetDefinitions","get","getWireObjectSet","objectSet","WeakMap","createObjectSet","objectType","clientCtx","base","bind","globalThis","finalMethodCall","fetchPage","fetchPageWithErrors","where","clause","objectSetFactory","pivotTo","createSearchAround","union","objectSets","map","os","intersect","subtract","asyncIter","args","$nextPageToken","undefined","result","nextPageToken","obj","data","fetchOne","primaryKey","options","createWithPk","fetchOneWithErrors","listener","pendingSubscribe","getInstance","subscribe","link","set","objDef","ontologyProvider","getObjectDefinition","apiName","withPk","field","primaryKeyApiName","value"],"sources":["createObjectSet.js"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { __EXPERIMENTAL__NOT_SUPPORTED_YET_subscribe } from \"@osdk/api/unstable\";\nimport { modernToLegacyWhereClause } from \"../internal/conversions/modernToLegacyWhereClause.js\";\nimport { aggregate } from \"../object/aggregate.js\";\nimport { fetchPageInternal, fetchPageWithErrorsInternal, } from \"../object/fetchPage.js\";\nimport { fetchSingle, fetchSingleWithErrors } from \"../object/fetchSingle.js\";\nimport { augmentRequestContext } from \"../util/augmentRequestContext.js\";\nimport { isWireObjectSet } from \"../util/WireObjectSet.js\";\nimport { ObjectSetListenerWebsocket } from \"./ObjectSetListenerWebsocket.js\";\nfunction isObjectTypeDefinition(def) {\n return def.type === \"object\";\n}\n/* @internal */\nexport function isObjectSet(o) {\n return o != null && typeof o === \"object\"\n && isWireObjectSet(objectSetDefinitions.get(o));\n}\n/** @internal */\nexport function getWireObjectSet(objectSet) {\n return objectSetDefinitions.get(objectSet);\n}\nconst objectSetDefinitions = new WeakMap();\n/** @internal */\nexport function createObjectSet(objectType, clientCtx, objectSet = {\n type: \"base\",\n objectType: objectType[\"apiName\"],\n}) {\n const base = {\n aggregate: (aggregate).bind(globalThis, augmentRequestContext(clientCtx, _ => ({ finalMethodCall: \"aggregate\" })), objectType, objectSet),\n fetchPage: fetchPageInternal.bind(globalThis, augmentRequestContext(clientCtx, _ => ({ finalMethodCall: \"fetchPage\" })), objectType, objectSet),\n fetchPageWithErrors: fetchPageWithErrorsInternal.bind(globalThis, augmentRequestContext(clientCtx, _ => ({ finalMethodCall: \"fetchPageWithErrors\" })), objectType, objectSet),\n where: (clause) => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"filter\",\n objectSet: objectSet,\n where: modernToLegacyWhereClause(clause),\n });\n },\n pivotTo: function (type) {\n return createSearchAround(type)();\n },\n union: (...objectSets) => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"union\",\n objectSets: [\n objectSet,\n ...objectSets.map(os => objectSetDefinitions.get(os)),\n ],\n });\n },\n intersect: (...objectSets) => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"intersect\",\n objectSets: [\n objectSet,\n ...objectSets.map(os => objectSetDefinitions.get(os)),\n ],\n });\n },\n subtract: (...objectSets) => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"subtract\",\n objectSets: [\n objectSet,\n ...objectSets.map(os => objectSetDefinitions.get(os)),\n ],\n });\n },\n asyncIter: async function* (args) {\n let $nextPageToken = undefined;\n do {\n const result = await fetchPageInternal(augmentRequestContext(clientCtx, _ => ({ finalMethodCall: \"asyncIter\" })), objectType, objectSet, { ...args, $nextPageToken });\n $nextPageToken = result.nextPageToken;\n for (const obj of result.data) {\n yield obj;\n }\n } while ($nextPageToken != null);\n },\n fetchOne: (isObjectTypeDefinition(objectType)\n ? async (primaryKey, options) => {\n return await fetchSingle(augmentRequestContext(clientCtx, _ => ({ finalMethodCall: \"fetchOne\" })), objectType, options, await createWithPk(clientCtx, objectType, objectSet, primaryKey));\n }\n : undefined),\n fetchOneWithErrors: (isObjectTypeDefinition(objectType)\n ? async (primaryKey, options) => {\n return await fetchSingleWithErrors(augmentRequestContext(clientCtx, _ => ({ finalMethodCall: \"fetchOneWithErrors\" })), objectType, options, await createWithPk(clientCtx, objectType, objectSet, primaryKey));\n }\n : undefined),\n [__EXPERIMENTAL__NOT_SUPPORTED_YET_subscribe]: (listener) => {\n const pendingSubscribe = ObjectSetListenerWebsocket.getInstance(clientCtx).subscribe(objectSet, listener);\n return async () => (await pendingSubscribe)();\n },\n };\n function createSearchAround(link) {\n return () => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"searchAround\",\n objectSet,\n link,\n });\n };\n }\n objectSetDefinitions.set(base, objectSet);\n // we are using a type assertion because the marker symbol defined in BaseObjectSet isn't actually used\n // at runtime.\n return base;\n}\nasync function createWithPk(clientCtx, objectType, objectSet, primaryKey) {\n const objDef = await clientCtx.ontologyProvider.getObjectDefinition(objectType.apiName);\n const withPk = {\n type: \"filter\",\n objectSet: objectSet,\n where: {\n type: \"eq\",\n field: objDef.primaryKeyApiName,\n value: primaryKey,\n },\n };\n return withPk;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,2CAA2C,QAAQ,oBAAoB;AAChF,SAASC,yBAAyB,QAAQ,sDAAsD;AAChG,SAASC,SAAS,QAAQ,wBAAwB;AAClD,SAASC,iBAAiB,EAAEC,2BAA2B,QAAS,wBAAwB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ACzD,MAAMC,gBAAgB,GAAG7C,0BAA0B,CAAC8C,WAAW,CAACjC,SAAS,CAAC,CAACkC,SAAS,CAACtC,SAAS,EAAEmC,QAAQ,CAAC;MACzG,OAAO,YAAY,CAAC,MAAMC,gBAAgB,EAAE,CAAC;IACjD;EACJ,CAAC;EACD,SAASrB,kBAAkBA,CAACwB,IAAI,EAAE;IAC9B,OAAO,MAAM;MACT,OAAOnC,SAAS,CAACS,gBAAgB,CAACV,UAAU,EAAEC,SAAS,EAAE;QACrDV,IAAI,EAAE,cAAc;QACpBM,SAAS;QACTuC;MACJ,CAAC,CAAC;IACN,CAAC;EACL;EACA1C,oBAAoB,CAAC2C,GAAG,CAACnC,IAAI,EAAEL,SAAS,CAAC;EACzC;EACA;EACA,OAAOK,IAAI;AACf;AACA,eAAe4B,YAAYA,CAAC7B,SAAS,EAAED,UAAU,EAAEH,SAAS,EAAE+B,UAAU,EAAE;EACtE,MAAMU,MAAM,GAAG,MAAMrC,SAAS,CAACsC,gBAAgB,CAACC,mBAAmB,CAACxC,UAAU,CAACyC,OAAO,CAAC;EACvF,MAAMC,MAAM,GAAG;IACXnD,IAAI,EAAE,QAAQ;IACdM,SAAS,EAAEA,SAAS;IACpBW,KAAK,EAAE;MACHjB,IAAI,EAAE,IAAI;MACVoD,KAAK,EAAEL,MAAM,CAACM,iBAAiB;MAC/BC,KAAK,EAAEjB;IACX;EACJ,CAAC;EACD,OAAOc,MAAM;AACjB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"createObjectSet.js","names":["__EXPERIMENTAL__NOT_SUPPORTED_YET_subscribe","modernToLegacyWhereClause","aggregate","fetchPageInternal","fetchPageWithErrorsInternal","fetchSingle","fetchSingleWithErrors","augmentRequestContext","isWireObjectSet","ObjectSetListenerWebsocket","isObjectTypeDefinition","def","type","isObjectSet","o","objectSetDefinitions","get","getWireObjectSet","objectSet","WeakMap","createObjectSet","objectType","clientCtx","base","bind","globalThis","finalMethodCall","fetchPage","fetchPageWithErrors","where","clause","objectSetFactory","pivotTo","createSearchAround","union","objectSets","map","os","intersect","subtract","asyncIter","args","$nextPageToken","undefined","result","nextPageToken","obj","data","fetchOne","primaryKey","options","createWithPk","fetchOneWithErrors","listener","pendingSubscribe","getInstance","subscribe","link","set","objDef","ontologyProvider","getObjectDefinition","apiName","withPk","field","primaryKeyApiName","value"],"sources":["createObjectSet.js"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { __EXPERIMENTAL__NOT_SUPPORTED_YET_subscribe } from \"@osdk/api/unstable\";\nimport { modernToLegacyWhereClause } from \"../internal/conversions/modernToLegacyWhereClause.js\";\nimport { aggregate } from \"../object/aggregate.js\";\nimport { fetchPageInternal, fetchPageWithErrorsInternal, } from \"../object/fetchPage.js\";\nimport { fetchSingle, fetchSingleWithErrors } from \"../object/fetchSingle.js\";\nimport { augmentRequestContext } from \"../util/augmentRequestContext.js\";\nimport { isWireObjectSet } from \"../util/WireObjectSet.js\";\nimport { ObjectSetListenerWebsocket } from \"./ObjectSetListenerWebsocket.js\";\nfunction isObjectTypeDefinition(def) {\n return def.type === \"object\";\n}\n/* @internal */\nexport function isObjectSet(o) {\n return o != null && typeof o === \"object\"\n && isWireObjectSet(objectSetDefinitions.get(o));\n}\n/** @internal */\nexport function getWireObjectSet(objectSet) {\n return objectSetDefinitions.get(objectSet);\n}\nconst objectSetDefinitions = new WeakMap();\n/** @internal */\nexport function createObjectSet(objectType, clientCtx, objectSet = {\n type: \"base\",\n objectType: objectType[\"apiName\"],\n}) {\n const base = {\n aggregate: (aggregate).bind(globalThis, augmentRequestContext(clientCtx, _ => ({ finalMethodCall: \"aggregate\" })), objectType, objectSet),\n fetchPage: fetchPageInternal.bind(globalThis, augmentRequestContext(clientCtx, _ => ({ finalMethodCall: \"fetchPage\" })), objectType, objectSet),\n fetchPageWithErrors: fetchPageWithErrorsInternal.bind(globalThis, augmentRequestContext(clientCtx, _ => ({ finalMethodCall: \"fetchPageWithErrors\" })), objectType, objectSet),\n where: (clause) => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"filter\",\n objectSet: objectSet,\n where: modernToLegacyWhereClause(clause, objectType),\n });\n },\n pivotTo: function (type) {\n return createSearchAround(type)();\n },\n union: (...objectSets) => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"union\",\n objectSets: [\n objectSet,\n ...objectSets.map(os => objectSetDefinitions.get(os)),\n ],\n });\n },\n intersect: (...objectSets) => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"intersect\",\n objectSets: [\n objectSet,\n ...objectSets.map(os => objectSetDefinitions.get(os)),\n ],\n });\n },\n subtract: (...objectSets) => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"subtract\",\n objectSets: [\n objectSet,\n ...objectSets.map(os => objectSetDefinitions.get(os)),\n ],\n });\n },\n asyncIter: async function* (args) {\n let $nextPageToken = undefined;\n do {\n const result = await fetchPageInternal(augmentRequestContext(clientCtx, _ => ({ finalMethodCall: \"asyncIter\" })), objectType, objectSet, { ...args, $nextPageToken });\n $nextPageToken = result.nextPageToken;\n for (const obj of result.data) {\n yield obj;\n }\n } while ($nextPageToken != null);\n },\n fetchOne: (isObjectTypeDefinition(objectType)\n ? async (primaryKey, options) => {\n return await fetchSingle(augmentRequestContext(clientCtx, _ => ({ finalMethodCall: \"fetchOne\" })), objectType, options, await createWithPk(clientCtx, objectType, objectSet, primaryKey));\n }\n : undefined),\n fetchOneWithErrors: (isObjectTypeDefinition(objectType)\n ? async (primaryKey, options) => {\n return await fetchSingleWithErrors(augmentRequestContext(clientCtx, _ => ({ finalMethodCall: \"fetchOneWithErrors\" })), objectType, options, await createWithPk(clientCtx, objectType, objectSet, primaryKey));\n }\n : undefined),\n [__EXPERIMENTAL__NOT_SUPPORTED_YET_subscribe]: (listener) => {\n const pendingSubscribe = ObjectSetListenerWebsocket.getInstance(clientCtx).subscribe(objectSet, listener);\n return async () => (await pendingSubscribe)();\n },\n };\n function createSearchAround(link) {\n return () => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"searchAround\",\n objectSet,\n link,\n });\n };\n }\n objectSetDefinitions.set(base, objectSet);\n // we are using a type assertion because the marker symbol defined in BaseObjectSet isn't actually used\n // at runtime.\n return base;\n}\nasync function createWithPk(clientCtx, objectType, objectSet, primaryKey) {\n const objDef = await clientCtx.ontologyProvider.getObjectDefinition(objectType.apiName);\n const withPk = {\n type: \"filter\",\n objectSet: objectSet,\n where: {\n type: \"eq\",\n field: objDef.primaryKeyApiName,\n value: primaryKey,\n },\n };\n return withPk;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,2CAA2C,QAAQ,oBAAoB;AAChF,SAASC,yBAAyB,QAAQ,sDAAsD;AAChG,SAASC,SAAS,QAAQ,wBAAwB;AAClD,SAASC,iBAAiB,EAAEC,2BAA2B,QAAS,wBAAwB;AACxF,SAASC,WAAW,EAAEC,qBAAqB,QAAQ,0BAA0B;AAC7E,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,SAASC,0BAA0B,QAAQ,iCAAiC;AAC5E,SAASC,sBAAsBA,CAACC,GAAG,EAAE;EACjC,OAAOA,GAAG,CAACC,IAAI,KAAK,QAAQ;AAChC;AACA;AACA,OAAO,SAASC,WAAWA,CAACC,CAAC,EAAE;EAC3B,OAAOA,CAAC,IAAI,IAAI,IAAI,OAAOA,CAAC,KAAK,QAAQ,IACl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TuC;MACJ,CAAC,CAAC;IACN,CAAC;EACL;EACA1C,oBAAoB,CAAC2C,GAAG,CAACnC,IAAI,EAAEL,SAAS,CAAC;EACzC;EACA;EACA,OAAOK,IAAI;AACf;AACA,eAAe4B,YAAYA,CAAC7B,SAAS,EAAED,UAAU,EAAEH,SAAS,EAAE+B,UAAU,EAAE;EACtE,MAAMU,MAAM,GAAG,MAAMrC,SAAS,CAACsC,gBAAgB,CAACC,mBAAmB,CAACxC,UAAU,CAACyC,OAAO,CAAC;EACvF,MAAMC,MAAM,GAAG;IACXnD,IAAI,EAAE,QAAQ;IACdM,SAAS,EAAEA,SAAS;IACpBW,KAAK,EAAE;MACHjB,IAAI,EAAE,IAAI;MACVoD,KAAK,EAAEL,MAAM,CAACM,iBAAiB;MAC/BC,KAAK,EAAEjB;IACX;EACJ,CAAC;EACD,OAAOc,MAAM;AACjB","ignoreList":[]}
|
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export const USER_AGENT = `osdk-client/${"2.0.1"}`;
|
|
16
|
+
export const USER_AGENT = `osdk-client/${"2.0.2-beta.1"}`;
|
|
17
17
|
//# sourceMappingURL=UserAgent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserAgent.js","names":["USER_AGENT"],"sources":["UserAgent.js"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport const USER_AGENT = `osdk-client/${process.env.PACKAGE_VERSION}`;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,UAAU,GAAG
|
|
1
|
+
{"version":3,"file":"UserAgent.js","names":["USER_AGENT"],"sources":["UserAgent.js"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport const USER_AGENT = `osdk-client/${process.env.PACKAGE_VERSION}`;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,UAAU,GAAG,+BAA4C","ignoreList":[]}
|
package/build/esm/Client.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export interface Client extends SharedClient<MinimalClient> {
|
|
|
32
32
|
*/
|
|
33
33
|
readonly [__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks]: <T extends ObjectOrInterfaceDefinition>(objs: Osdk<T>[], links: string[]) => AsyncGenerator<BulkLinkResult, void, undefined>;
|
|
34
34
|
}
|
|
35
|
-
declare const MaxOsdkVersion = "2.0.
|
|
35
|
+
declare const MaxOsdkVersion = "2.0.2";
|
|
36
36
|
export type MaxOsdkVersion = typeof MaxOsdkVersion;
|
|
37
37
|
declare const ErrorMessage: unique symbol;
|
|
38
38
|
export {};
|
package/build/esm/Client.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.
|
|
17
|
-
const MaxOsdkVersion = "2.0.
|
|
17
|
+
const MaxOsdkVersion = "2.0.2";
|
|
18
18
|
const ErrorMessage = Symbol("ErrorMessage");
|
|
19
19
|
export {};
|
|
20
20
|
//# sourceMappingURL=Client.js.map
|
package/build/esm/Client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.js","names":["MaxOsdkVersion","ErrorMessage","Symbol"],"sources":["Client.js"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.\nconst MaxOsdkVersion = \"2.0.
|
|
1
|
+
{"version":3,"file":"Client.js","names":["MaxOsdkVersion","ErrorMessage","Symbol"],"sources":["Client.js"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.\nconst MaxOsdkVersion = \"2.0.2\";\nconst ErrorMessage = Symbol(\"ErrorMessage\");\nexport {};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAAc,GAAG,OAAO;AAC9B,MAAMC,YAAY,GAAGC,MAAM,CAAC,cAAc,CAAC;AAC3C","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function extractNamespace(fqApiName: string): [string | undefined, string];
|
|
2
2
|
//# sourceMappingURL=modernToLegacyWhereClause.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modernToLegacyWhereClause.d.ts","sourceRoot":"","sources":["../../../../src/internal/conversions/modernToLegacyWhereClause.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"modernToLegacyWhereClause.d.ts","sourceRoot":"","sources":["../../../../src/internal/conversions/modernToLegacyWhereClause.ts"],"names":[],"mappings":"AA6BA,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,GAChB,CAAC,MAAM,GAAG,SAAS,EAAE,MAAM,CAAC,CAI9B"}
|
|
@@ -15,31 +15,37 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { DistanceUnitMapping } from "@osdk/api";
|
|
17
17
|
import invariant from "tiny-invariant";
|
|
18
|
+
export function extractNamespace(fqApiName) {
|
|
19
|
+
const last = fqApiName.lastIndexOf(".");
|
|
20
|
+
if (last === -1) return [undefined, fqApiName];
|
|
21
|
+
return [fqApiName.slice(0, last), fqApiName.slice(last + 1)];
|
|
22
|
+
}
|
|
18
23
|
/** @internal */
|
|
19
|
-
export function modernToLegacyWhereClause(whereClause) {
|
|
24
|
+
export function modernToLegacyWhereClause(whereClause, objectOrInterface) {
|
|
20
25
|
if ("$and" in whereClause) {
|
|
21
26
|
return {
|
|
22
27
|
type: "and",
|
|
23
|
-
value: whereClause.$and.map(modernToLegacyWhereClause)
|
|
28
|
+
value: whereClause.$and.map(clause => modernToLegacyWhereClause(clause, objectOrInterface))
|
|
24
29
|
};
|
|
25
30
|
} else if ("$or" in whereClause) {
|
|
26
31
|
return {
|
|
27
32
|
type: "or",
|
|
28
|
-
value: whereClause.$or.map(modernToLegacyWhereClause)
|
|
33
|
+
value: whereClause.$or.map(clause => modernToLegacyWhereClause(clause, objectOrInterface))
|
|
29
34
|
};
|
|
30
35
|
} else if ("$not" in whereClause) {
|
|
31
36
|
return {
|
|
32
37
|
type: "not",
|
|
33
|
-
value: modernToLegacyWhereClause(whereClause.$not)
|
|
38
|
+
value: modernToLegacyWhereClause(whereClause.$not, objectOrInterface)
|
|
34
39
|
};
|
|
35
40
|
}
|
|
41
|
+
const [objApiNamespace, objApiShortname] = extractNamespace(objectOrInterface.apiName);
|
|
36
42
|
const parts = Object.entries(whereClause);
|
|
37
43
|
if (parts.length === 1) {
|
|
38
|
-
return handleWherePair(parts[0]);
|
|
44
|
+
return handleWherePair(parts[0], objApiNamespace);
|
|
39
45
|
}
|
|
40
46
|
return {
|
|
41
47
|
type: "and",
|
|
42
|
-
value: parts.map(handleWherePair)
|
|
48
|
+
value: parts.map(v => handleWherePair(v, objApiNamespace))
|
|
43
49
|
};
|
|
44
50
|
}
|
|
45
51
|
function makeGeoFilterBbox(field, bbox, filterType) {
|
|
@@ -68,9 +74,13 @@ function makeGeoFilterPolygon(field, coordinates, filterType) {
|
|
|
68
74
|
}
|
|
69
75
|
};
|
|
70
76
|
}
|
|
71
|
-
function handleWherePair([field, filter]) {
|
|
77
|
+
function handleWherePair([field, filter], objApiNamespace) {
|
|
72
78
|
!(filter != null) ? invariant(false, "Defined key values are only allowed when they are not undefined.") : void 0;
|
|
73
79
|
if (typeof filter === "string" || typeof filter === "number" || typeof filter === "boolean") {
|
|
80
|
+
const [fieldApiNamespace, fieldShortName] = extractNamespace(field);
|
|
81
|
+
if (fieldApiNamespace == null && objApiNamespace != null) {
|
|
82
|
+
field = `${objApiNamespace}.${fieldShortName}`;
|
|
83
|
+
}
|
|
74
84
|
return {
|
|
75
85
|
type: "eq",
|
|
76
86
|
field,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modernToLegacyWhereClause.js","names":["DistanceUnitMapping","invariant","modernToLegacyWhereClause","whereClause","type","value","$and","map","$or","$not","parts","Object","entries","length","handleWherePair","makeGeoFilterBbox","field","bbox","filterType","topLeft","coordinates","bottomRight","makeGeoFilterPolygon","filter","keysOfFilter","keys","hasDollarSign","some","key","startsWith","Error","JSON","stringify","firstKey","withinBody","Array","isArray","$bbox","$distance","$of","center","distance","unit","$polygon","intersectsBody","substring"],"sources":["modernToLegacyWhereClause.js"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { DistanceUnitMapping } from \"@osdk/api\";\nimport invariant from \"tiny-invariant\";\n/** @internal */\nexport function modernToLegacyWhereClause(whereClause) {\n if (\"$and\" in whereClause) {\n return {\n type: \"and\",\n value: whereClause.$and.map(modernToLegacyWhereClause),\n };\n }\n else if (\"$or\" in whereClause) {\n return {\n type: \"or\",\n value: whereClause.$or.map(modernToLegacyWhereClause),\n };\n }\n else if (\"$not\" in whereClause) {\n return {\n type: \"not\",\n value: modernToLegacyWhereClause(whereClause.$not),\n };\n }\n const parts = Object.entries(whereClause);\n if (parts.length === 1) {\n return handleWherePair(parts[0]);\n }\n return {\n type: \"and\",\n value: parts.map(handleWherePair),\n };\n}\nfunction makeGeoFilterBbox(field, bbox, filterType) {\n return {\n type: filterType === \"$within\"\n ? \"withinBoundingBox\"\n : \"intersectsBoundingBox\",\n field,\n value: {\n topLeft: {\n type: \"Point\",\n coordinates: [bbox[0], bbox[3]],\n },\n bottomRight: {\n type: \"Point\",\n coordinates: [bbox[2], bbox[1]],\n },\n },\n };\n}\nfunction makeGeoFilterPolygon(field, coordinates, filterType) {\n return {\n type: filterType,\n field,\n value: {\n type: \"Polygon\",\n coordinates,\n },\n };\n}\nfunction handleWherePair([field, filter]) {\n invariant(filter != null, \"Defined key values are only allowed when they are not undefined.\");\n if (typeof filter === \"string\" || typeof filter === \"number\"\n || typeof filter === \"boolean\") {\n return {\n type: \"eq\",\n field,\n value: filter,\n };\n }\n const keysOfFilter = Object.keys(filter);\n // If any of the keys start with `$` then they must be the only one.\n // e.g. `where({ name: { $eq: \"foo\", $ne: \"bar\" } })` is invalid currently\n const hasDollarSign = keysOfFilter.some((key) => key.startsWith(\"$\"));\n invariant(!hasDollarSign\n || keysOfFilter.length === 1, \"WhereClause Filter with multiple clauses isn't allowed\");\n if (!hasDollarSign) {\n // Future case for structs\n throw new Error(`Unsupported filter. Did you forget to use a $-prefixed filter? (${JSON.stringify(filter)})`);\n }\n const firstKey = keysOfFilter[0];\n invariant(filter[firstKey] != null);\n if (firstKey === \"$ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[firstKey],\n },\n };\n }\n if (firstKey === \"$within\") {\n const withinBody = filter[firstKey];\n if (Array.isArray(withinBody)) {\n return makeGeoFilterBbox(field, withinBody, firstKey);\n }\n else if (\"$bbox\" in withinBody && withinBody.$bbox != null) {\n return makeGeoFilterBbox(field, withinBody.$bbox, firstKey);\n }\n else if ((\"$distance\" in withinBody && \"$of\" in withinBody)\n && withinBody.$distance != null\n && withinBody.$of != null) {\n return {\n type: \"withinDistanceOf\",\n field,\n value: {\n center: Array.isArray(withinBody.$of)\n ? {\n type: \"Point\",\n coordinates: withinBody.$of,\n }\n : withinBody.$of,\n distance: {\n value: withinBody.$distance[0],\n unit: DistanceUnitMapping[withinBody.$distance[1]],\n },\n },\n };\n }\n else {\n const coordinates = (\"$polygon\" in withinBody)\n ? withinBody.$polygon\n : withinBody.coordinates;\n return makeGeoFilterPolygon(field, coordinates, \"withinPolygon\");\n }\n }\n if (firstKey === \"$intersects\") {\n const intersectsBody = filter[firstKey];\n if (Array.isArray(intersectsBody)) {\n return makeGeoFilterBbox(field, intersectsBody, firstKey);\n }\n else if (\"$bbox\" in intersectsBody && intersectsBody.$bbox != null) {\n return makeGeoFilterBbox(field, intersectsBody.$bbox, firstKey);\n }\n else {\n const coordinates = (\"$polygon\" in intersectsBody)\n ? intersectsBody.$polygon\n : intersectsBody.coordinates;\n return makeGeoFilterPolygon(field, coordinates, \"intersectsPolygon\");\n }\n }\n return {\n type: firstKey.substring(1),\n field,\n value: filter[firstKey],\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,mBAAmB,QAAQ,WAAW;AAC/C,OAAOC,SAAS,MAAM,gBAAgB;AACtC;AACA,OAAO,SAASC,yBAAyBA,CAACC,WAAW,EAAE;EACnD,IAAI,MAAM,IAAIA,WAAW,EAAE;IACvB,OAAO;MACHC,IAAI,EAAE,KAAK;MACXC,KAAK,EAAEF,WAAW,CAACG,IAAI,CAACC,GAAG,CAACL,yBAAyB;IACzD,CAAC;EACL,CAAC,MACI,IAAI,KAAK,IAAIC,WAAW,EAAE;IAC3B,OAAO;MACHC,IAAI,EAAE,IAAI;MACVC,KAAK,EAAEF,WAAW,CAACK,GAAG,CAACD,GAAG,CAACL,yBAAyB;IACxD,CAAC;EACL,CAAC,MACI,IAAI,MAAM,IAAIC,WAAW,EAAE;IAC5B,OAAO;MACHC,IAAI,EAAE,KAAK;MACXC,KAAK,EAAEH,yBAAyB,CAACC,WAAW,CAACM,IAAI;IACrD,CAAC;EACL;EACA,MAAMC,KAAK,GAAGC,MAAM,CAACC,OAAO,CAACT,WAAW,CAAC;EACzC,IAAIO,KAAK,CAACG,MAAM,KAAK,CAAC,EAAE;IACpB,OAAOC,eAAe,CAACJ,KAAK,CAAC,CAAC,CAAC,CAAC;EACpC;EACA,OAAO;IACHN,IAAI,EAAE,KAAK;I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amespace","fqApiName","last","lastIndexOf","undefined","slice","modernToLegacyWhereClause","whereClause","objectOrInterface","type","value","$and","map","clause","$or","$not","objApiNamespace","objApiShortname","apiName","parts","Object","entries","length","handleWherePair","v","makeGeoFilterBbox","field","bbox","filterType","topLeft","coordinates","bottomRight","makeGeoFilterPolygon","filter","fieldApiNamespace","fieldShortName","keysOfFilter","keys","hasDollarSign","some","key","startsWith","Error","JSON","stringify","firstKey","withinBody","Array","isArray","$bbox","$distance","$of","center","distance","unit","$polygon","intersectsBody","substring"],"sources":["modernToLegacyWhereClause.js"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { DistanceUnitMapping } from \"@osdk/api\";\nimport invariant from \"tiny-invariant\";\nexport function extractNamespace(fqApiName) {\n const last = fqApiName.lastIndexOf(\".\");\n if (last === -1)\n return [undefined, fqApiName];\n return [fqApiName.slice(0, last), fqApiName.slice(last + 1)];\n}\n/** @internal */\nexport function modernToLegacyWhereClause(whereClause, objectOrInterface) {\n if (\"$and\" in whereClause) {\n return {\n type: \"and\",\n value: whereClause.$and.map((clause) => modernToLegacyWhereClause(clause, objectOrInterface)),\n };\n }\n else if (\"$or\" in whereClause) {\n return {\n type: \"or\",\n value: whereClause.$or.map((clause) => modernToLegacyWhereClause(clause, objectOrInterface)),\n };\n }\n else if (\"$not\" in whereClause) {\n return {\n type: \"not\",\n value: modernToLegacyWhereClause(whereClause.$not, objectOrInterface),\n };\n }\n const [objApiNamespace, objApiShortname] = extractNamespace(objectOrInterface.apiName);\n const parts = Object.entries(whereClause);\n if (parts.length === 1) {\n return handleWherePair(parts[0], objApiNamespace);\n }\n return {\n type: \"and\",\n value: parts.map(v => handleWherePair(v, objApiNamespace)),\n };\n}\nfunction makeGeoFilterBbox(field, bbox, filterType) {\n return {\n type: filterType === \"$within\"\n ? \"withinBoundingBox\"\n : \"intersectsBoundingBox\",\n field,\n value: {\n topLeft: {\n type: \"Point\",\n coordinates: [bbox[0], bbox[3]],\n },\n bottomRight: {\n type: \"Point\",\n coordinates: [bbox[2], bbox[1]],\n },\n },\n };\n}\nfunction makeGeoFilterPolygon(field, coordinates, filterType) {\n return {\n type: filterType,\n field,\n value: {\n type: \"Polygon\",\n coordinates,\n },\n };\n}\nfunction handleWherePair([field, filter], objApiNamespace) {\n invariant(filter != null, \"Defined key values are only allowed when they are not undefined.\");\n if (typeof filter === \"string\" || typeof filter === \"number\"\n || typeof filter === \"boolean\") {\n const [fieldApiNamespace, fieldShortName] = extractNamespace(field);\n if (fieldApiNamespace == null && objApiNamespace != null) {\n field = `${objApiNamespace}.${fieldShortName}`;\n }\n return {\n type: \"eq\",\n field,\n value: filter,\n };\n }\n const keysOfFilter = Object.keys(filter);\n // If any of the keys start with `$` then they must be the only one.\n // e.g. `where({ name: { $eq: \"foo\", $ne: \"bar\" } })` is invalid currently\n const hasDollarSign = keysOfFilter.some((key) => key.startsWith(\"$\"));\n invariant(!hasDollarSign\n || keysOfFilter.length === 1, \"WhereClause Filter with multiple clauses isn't allowed\");\n if (!hasDollarSign) {\n // Future case for structs\n throw new Error(`Unsupported filter. Did you forget to use a $-prefixed filter? (${JSON.stringify(filter)})`);\n }\n const firstKey = keysOfFilter[0];\n invariant(filter[firstKey] != null);\n if (firstKey === \"$ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[firstKey],\n },\n };\n }\n if (firstKey === \"$within\") {\n const withinBody = filter[firstKey];\n if (Array.isArray(withinBody)) {\n return makeGeoFilterBbox(field, withinBody, firstKey);\n }\n else if (\"$bbox\" in withinBody && withinBody.$bbox != null) {\n return makeGeoFilterBbox(field, withinBody.$bbox, firstKey);\n }\n else if ((\"$distance\" in withinBody && \"$of\" in withinBody)\n && withinBody.$distance != null\n && withinBody.$of != null) {\n return {\n type: \"withinDistanceOf\",\n field,\n value: {\n center: Array.isArray(withinBody.$of)\n ? {\n type: \"Point\",\n coordinates: withinBody.$of,\n }\n : withinBody.$of,\n distance: {\n value: withinBody.$distance[0],\n unit: DistanceUnitMapping[withinBody.$distance[1]],\n },\n },\n };\n }\n else {\n const coordinates = (\"$polygon\" in withinBody)\n ? withinBody.$polygon\n : withinBody.coordinates;\n return makeGeoFilterPolygon(field, coordinates, \"withinPolygon\");\n }\n }\n if (firstKey === \"$intersects\") {\n const intersectsBody = filter[firstKey];\n if (Array.isArray(intersectsBody)) {\n return makeGeoFilterBbox(field, intersectsBody, firstKey);\n }\n else if (\"$bbox\" in intersectsBody && intersectsBody.$bbox != null) {\n return makeGeoFilterBbox(field, intersectsBody.$bbox, firstKey);\n }\n else {\n const coordinates = (\"$polygon\" in intersectsBody)\n ? intersectsBody.$polygon\n : intersectsBody.coordinates;\n return makeGeoFilterPolygon(field, coordinates, \"intersectsPolygon\");\n }\n }\n return {\n type: firstKey.substring(1),\n field,\n value: filter[firstKey],\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,mBAAmB,QAAQ,WAAW;AAC/C,OAAOC,SAAS,MAAM,gBAAgB;AACtC,OAAO,SAASC,gBAAgBA,CAACC,SAAS,EAAE;EACxC,MAAMC,IAAI,GAAGD,SAAS,CAACE,WAAW,CAAC,GAAG,CAAC;EACvC,IAAID,IAAI,KAAK,CAAC,CAAC,EACX,OAAO,CAACE,SAAS,EAAEH,SAAS,CAAC;EACjC,OAAO,CAACA,SAAS,CAACI,KAAK,CAAC,CAAC,EAAEH,IAAI,CAAC,EAAED,SAAS,CAACI,KAAK,CAACH,IAAI,GAAG,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