@osdk/client 2.0.2-beta.1 → 2.0.2-beta.2
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 +11 -0
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js +9 -7
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js +17 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
- package/build/browser/util/UserAgent.js +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js +9 -7
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js +17 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
- package/build/esm/util/UserAgent.js +1 -1
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @osdk/client
|
|
2
2
|
|
|
3
|
+
## 2.0.2-beta.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 51354c5: Fixes where clauses when objects have an api namespace
|
|
8
|
+
- 51354c5: Locks dependency version of 3 internal libraries
|
|
9
|
+
- Updated dependencies [51354c5]
|
|
10
|
+
- @osdk/generator-converters@2.0.2-beta.2
|
|
11
|
+
- @osdk/client.unstable@2.0.2-beta.2
|
|
12
|
+
- @osdk/api@2.0.2-beta.2
|
|
13
|
+
|
|
3
14
|
## 2.0.2-beta.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -38,14 +38,13 @@ export function modernToLegacyWhereClause(whereClause, objectOrInterface) {
|
|
|
38
38
|
value: modernToLegacyWhereClause(whereClause.$not, objectOrInterface)
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
const [objApiNamespace, objApiShortname] = extractNamespace(objectOrInterface.apiName);
|
|
42
41
|
const parts = Object.entries(whereClause);
|
|
43
42
|
if (parts.length === 1) {
|
|
44
|
-
return handleWherePair(parts[0],
|
|
43
|
+
return handleWherePair(parts[0], objectOrInterface);
|
|
45
44
|
}
|
|
46
45
|
return {
|
|
47
46
|
type: "and",
|
|
48
|
-
value: parts.map(v => handleWherePair(v,
|
|
47
|
+
value: parts.map(v => handleWherePair(v, objectOrInterface))
|
|
49
48
|
};
|
|
50
49
|
}
|
|
51
50
|
function makeGeoFilterBbox(field, bbox, filterType) {
|
|
@@ -74,12 +73,15 @@ function makeGeoFilterPolygon(field, coordinates, filterType) {
|
|
|
74
73
|
}
|
|
75
74
|
};
|
|
76
75
|
}
|
|
77
|
-
function handleWherePair([field, filter],
|
|
76
|
+
function handleWherePair([field, filter], objectOrInterface) {
|
|
78
77
|
!(filter != null) ? invariant(false, "Defined key values are only allowed when they are not undefined.") : void 0;
|
|
79
78
|
if (typeof filter === "string" || typeof filter === "number" || typeof filter === "boolean") {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
if (objectOrInterface.type === "interface") {
|
|
80
|
+
const [objApiNamespace] = extractNamespace(objectOrInterface.apiName);
|
|
81
|
+
const [fieldApiNamespace, fieldShortName] = extractNamespace(field);
|
|
82
|
+
if (fieldApiNamespace == null && objApiNamespace != null) {
|
|
83
|
+
field = `${objApiNamespace}.${fieldShortName}`;
|
|
84
|
+
}
|
|
83
85
|
}
|
|
84
86
|
return {
|
|
85
87
|
type: "eq",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modernToLegacyWhereClause.js","names":["DistanceUnitMapping","invariant","extractNamespace","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,CAAC,CAAC,CAAC;AAChE;AACA;AACA,OAAO,SAASI,yBAAyBA,CAACC,WAAW,EAAEC,iBAAiB,EAAE;EACtE,IAAI,MAAM,IAAID,WAAW,EAAE;IACvB,OAAO;MACHE,IAAI,EAAE,KAAK;MACXC,KAAK,EAAEH,WAAW,CAACI,IAAI,CAACC,GAAG,CAAEC,MAAM,IA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CAAC,CAAC,CAAC;UACrD;QACJ;MACJ,CAAC;IACL,CAAC,MACI;MACD,MAAMpB,WAAW,GAAI,UAAU,IAAIgB,UAAU,GACvCA,UAAU,CAACS,QAAQ,GACnBT,UAAU,CAAChB,WAAW;MAC5B,OAAOE,oBAAoB,CAACN,KAAK,EAAEI,WAAW,EAAE,eAAe,CAAC;IACpE;EACJ;EACA,IAAIe,QAAQ,KAAK,aAAa,EAAE;IAC5B,MAAMW,cAAc,GAAGvB,MAAM,CAACY,QAAQ,CAAC;IACvC,IAAIE,KAAK,CAACC,OAAO,CAACQ,cAAc,CAAC,EAAE;MAC/B,OAAO/B,iBAAiB,CAACC,KAAK,EAAE8B,cAAc,EAAEX,QAAQ,CAAC;IAC7D,CAAC,MACI,IAAI,OAAO,IAAIW,cAAc,IAAIA,cAAc,CAACP,KAAK,IAAI,IAAI,EAAE;MAChE,OAAOxB,iBAAiB,CAACC,KAAK,EAAE8B,cAAc,CAACP,KAAK,EAAEJ,QAAQ,CAAC;IACnE,CAAC,MACI;MACD,MAAMf,WAAW,GAAI,UAAU,IAAI0B,cAAc,GAC3CA,cAAc,CAACD,QAAQ,GACvBC,cAAc,CAAC1B,WAAW;MAChC,OAAOE,oBAAoB,CAACN,KAAK,EAAEI,WAAW,EAAE,mBAAmB,CAAC;IACxE;EACJ;EACA,OAAO;IACHrB,IAAI,EAAEoC,QAAQ,CAACY,SAAS,CAAC,CAAC,CAAC;IAC3B/B,KAAK;IACLhB,KAAK,EAAEuB,MAAM,CAACY,QAAQ;EAC1B,CAAC;AACL","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"modernToLegacyWhereClause.js","names":["DistanceUnitMapping","invariant","extractNamespace","fqApiName","last","lastIndexOf","undefined","slice","modernToLegacyWhereClause","whereClause","objectOrInterface","type","value","$and","map","clause","$or","$not","parts","Object","entries","length","handleWherePair","v","makeGeoFilterBbox","field","bbox","filterType","topLeft","coordinates","bottomRight","makeGeoFilterPolygon","filter","objApiNamespace","apiName","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 parts = Object.entries(whereClause);\n if (parts.length === 1) {\n return handleWherePair(parts[0], objectOrInterface);\n }\n return {\n type: \"and\",\n value: parts.map(v => handleWherePair(v, objectOrInterface)),\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], objectOrInterface) {\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 if (objectOrInterface.type === \"interface\") {\n const [objApiNamespace] = extractNamespace(objectOrInterface.apiName);\n const [fieldApiNamespace, fieldShortName] = extractNamespace(field);\n if (fieldApiNamespace == null && objApiNamespace != null) {\n field = `${objApiNamespace}.${fieldShortName}`;\n }\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,CAAC,CAAC,CAAC;AAChE;AACA;AACA,OAAO,SAASI,yBAAyBA,CAACC,WAAW,EAAEC,iBAAiB,EAAE;EACtE,IAAI,MAAM,IAAID,WAAW,EAAE;IACvB,OAAO;MACHE,IAAI,EAAE,KAAK;MACXC,KAAK,EAA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EmC,UAAU,CAACI,SAAS,CAAC,CAAC,CAAC;YAC9BI,IAAI,EAAEvD,mBAAmB,CAAC+C,UAAU,CAACI,SAAS,CAAC,CAAC,CAAC;UACrD;QACJ;MACJ,CAAC;IACL,CAAC,MACI;MACD,MAAMtB,WAAW,GAAI,UAAU,IAAIkB,UAAU,GACvCA,UAAU,CAACS,QAAQ,GACnBT,UAAU,CAAClB,WAAW;MAC5B,OAAOE,oBAAoB,CAACN,KAAK,EAAEI,WAAW,EAAE,eAAe,CAAC;IACpE;EACJ;EACA,IAAIiB,QAAQ,KAAK,aAAa,EAAE;IAC5B,MAAMW,cAAc,GAAGzB,MAAM,CAACc,QAAQ,CAAC;IACvC,IAAIE,KAAK,CAACC,OAAO,CAACQ,cAAc,CAAC,EAAE;MAC/B,OAAOjC,iBAAiB,CAACC,KAAK,EAAEgC,cAAc,EAAEX,QAAQ,CAAC;IAC7D,CAAC,MACI,IAAI,OAAO,IAAIW,cAAc,IAAIA,cAAc,CAACP,KAAK,IAAI,IAAI,EAAE;MAChE,OAAO1B,iBAAiB,CAACC,KAAK,EAAEgC,cAAc,CAACP,KAAK,EAAEJ,QAAQ,CAAC;IACnE,CAAC,MACI;MACD,MAAMjB,WAAW,GAAI,UAAU,IAAI4B,cAAc,GAC3CA,cAAc,CAACD,QAAQ,GACvBC,cAAc,CAAC5B,WAAW;MAChC,OAAOE,oBAAoB,CAACN,KAAK,EAAEI,WAAW,EAAE,mBAAmB,CAAC;IACxE;EACJ;EACA,OAAO;IACHlB,IAAI,EAAEmC,QAAQ,CAACY,SAAS,CAAC,CAAC,CAAC;IAC3BjC,KAAK;IACLb,KAAK,EAAEoB,MAAM,CAACc,QAAQ;EAC1B,CAAC;AACL","ignoreList":[]}
|
|
@@ -24,7 +24,6 @@ describe(modernToLegacyWhereClause, () => {
|
|
|
24
24
|
const r = modernToLegacyWhereClause({
|
|
25
25
|
prop: 5
|
|
26
26
|
}, {
|
|
27
|
-
// ...FooInterface
|
|
28
27
|
type: "interface",
|
|
29
28
|
apiName: "a.Foo"
|
|
30
29
|
});
|
|
@@ -103,6 +102,23 @@ describe(modernToLegacyWhereClause, () => {
|
|
|
103
102
|
`);
|
|
104
103
|
});
|
|
105
104
|
});
|
|
105
|
+
describe("objects", () => {
|
|
106
|
+
it("does not convert object short property names to fq", () => {
|
|
107
|
+
const r = modernToLegacyWhereClause({
|
|
108
|
+
prop: 5
|
|
109
|
+
}, {
|
|
110
|
+
type: "object",
|
|
111
|
+
apiName: "a.Foo"
|
|
112
|
+
});
|
|
113
|
+
expect(r).toMatchInlineSnapshot(`
|
|
114
|
+
{
|
|
115
|
+
"field": "prop",
|
|
116
|
+
"type": "eq",
|
|
117
|
+
"value": 5,
|
|
118
|
+
}
|
|
119
|
+
`);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
106
122
|
});
|
|
107
123
|
describe("single checks", () => {
|
|
108
124
|
describe("$within", () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modernToLegacyWhereClause.test.js","names":["objectTypeWithAllPropertyTypes","expectType","describe","expect","it","modernToLegacyWhereClause","r","prop","type","apiName","toMatchInlineSnapshot","foo","geoPoint","$within","$bbox","$distance","$of","coordinates","$polygon","geoShape","$intersects","integer","$ne","decimal","$and","$or"],"sources":["modernToLegacyWhereClause.test.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 { objectTypeWithAllPropertyTypes } from \"@osdk/client.test.ontology\";\nimport { expectType } from \"ts-expect\";\nimport { describe, expect, it } from \"vitest\";\nimport { modernToLegacyWhereClause } from \"./modernToLegacyWhereClause.js\";\ndescribe(modernToLegacyWhereClause, () => {\n describe(\"api namespaces\", () => {\n describe(\"interfaces\", () => {\n it(\"properly converts shortname to fqApiName\", () => {\n const T = {\n // ...FooInterface\n type: \"interface\",\n apiName: \"a.Foo\",\n };\n const r = modernToLegacyWhereClause({\n prop: 5,\n }, T);\n expect(r).toMatchInlineSnapshot(`\n {\n \"field\": \"a.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n }\n `);\n });\n it(\"properly does not convert when interface has no apiNamespace\", () => {\n const T = {\n type: \"interface\",\n apiName: \"Foo\",\n };\n const r = modernToLegacyWhereClause({\n \"b.prop\": 5,\n foo: 6,\n }, T);\n expect(r).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"b.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"foo\",\n \"type\": \"eq\",\n \"value\": 6,\n },\n ],\n }\n `);\n });\n it(\"gracefully handles redundant apiNamespace in property\", () => {\n const T = {\n type: \"interface\",\n apiName: \"a.Foo\",\n };\n const r = modernToLegacyWhereClause({\n \"b.prop\": 5,\n \"a.foo\": 6,\n }, T);\n expect(r).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"b.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"a.foo\",\n \"type\": \"eq\",\n \"value\": 6,\n },\n ],\n }\n `);\n });\n it(\"properly does not convert different apiNamespaces\", () => {\n const T = {\n type: \"interface\",\n apiName: \"a.Foo\",\n };\n expect(modernToLegacyWhereClause({\n \"b.prop\": 5,\n }, T)).toMatchInlineSnapshot(`\n {\n \"field\": \"b.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n }\n `);\n });\n });\n });\n describe(\"single checks\", () => {\n describe(\"$within\", () => {\n it(\"properly generates bbox shortcut\", async () => {\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: [-5, 5, -10, 10],\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n it(\"properly generates bbox long form\", async () => {\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: {\n $bbox: [-5, 5, -10, 10],\n },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n it(\"properly generates within radius\", async () => {\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: { $distance: [5, \"km\"], $of: [-5, 5] },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinDistanceOf\",\n \"value\": {\n \"center\": {\n \"coordinates\": [\n -5,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"distance\": {\n \"unit\": \"KILOMETERS\",\n \"value\": 5,\n },\n },\n }\n `);\n });\n it(\"properly generates within radius of geopoint\", async () => {\n // suppose you loaded an object with a geopoint field\n // and you want to find all objects within 5 km of that point\n const pointAsGeoJsonPoint = {\n type: \"Point\",\n coordinates: [-5, 5],\n };\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: { $distance: [5, \"km\"], $of: pointAsGeoJsonPoint },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinDistanceOf\",\n \"value\": {\n \"center\": {\n \"coordinates\": [\n -5,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"distance\": {\n \"unit\": \"KILOMETERS\",\n \"value\": 5,\n },\n },\n }\n `);\n });\n it(\"properly generates within polygon\", async () => {\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: { $polygon: [[[0, 1], [3, 2], [0, 1]]] },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n it(\"properly generates within polygon geojson\", async () => {\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: {\n type: \"Polygon\",\n coordinates: [[[0, 1], [3, 2], [0, 1]]],\n },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n it(\"check types\", async () => {\n expectType({\n geoPoint: {\n $within: [-5, 5, -10, 10],\n },\n });\n expectType({\n geoPoint: {\n $within: { $distance: [2, \"centimeter\"], $of: [2, 2] },\n },\n });\n expectType({\n geoPoint: {\n $within: { $polygon: [[[0, 1], [3, 2], [0, 1]]] },\n },\n });\n expectType({\n geoPoint: {\n $within: {\n type: \"Polygon\",\n coordinates: [[[0, 1], [3, 2], [0, 1]]],\n },\n },\n });\n expectType({\n geoPoint: {\n $within: { $bbox: [-5, 5, -10, 10] },\n },\n });\n expectType({\n geoPoint: {\n $within: {\n $bbox: [-5, 5, -10, 10],\n // @ts-expect-error\n $distance: [2, \"centimeter\"],\n // @ts-expect-error\n $of: [2, 2],\n },\n },\n });\n expectType({\n geoPoint: {\n $within: {\n $polygon: [[[0, 1], [3, 2], [0, 1]]],\n // @ts-expect-error\n $bbox: [2, 2, 2, 2],\n },\n },\n });\n });\n describe(\"$intersects\", () => {\n it(\"properly generates bbox shortcut\", async () => {\n expect(modernToLegacyWhereClause({\n geoShape: {\n $intersects: [-5, 5, -10, 10],\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n it(\"properly generates bbox long form\", async () => {\n expect(modernToLegacyWhereClause({\n geoShape: {\n $intersects: {\n $bbox: [-5, 5, -10, 10],\n },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n it(\"properly generates intersects polygon\", async () => {\n expect(modernToLegacyWhereClause({\n geoShape: {\n $intersects: { $polygon: [[[0, 1], [3, 2], [0, 1]]] },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n it(\"properly generates within polygon geojson\", async () => {\n expect(modernToLegacyWhereClause({\n geoShape: {\n $intersects: {\n type: \"Polygon\",\n coordinates: [[[0, 1], [3, 2], [0, 1]]],\n },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n });\n it(\"inverts ne short hand properly\", () => {\n expect(modernToLegacyWhereClause({\n integer: { $ne: 5 },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"type\": \"not\",\n \"value\": {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n }\n `);\n });\n });\n describe(\"multiple checks\", () => {\n it(\"properly handles multiple simple where checks\", () => {\n expect(modernToLegacyWhereClause({\n decimal: 5,\n integer: 10,\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"decimal\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 10,\n },\n ],\n }\n `);\n });\n it(\"properly handles $and\", () => {\n expect(modernToLegacyWhereClause({\n $and: [{\n decimal: 5,\n }, {\n integer: 10,\n }],\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"decimal\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 10,\n },\n ],\n }\n `);\n });\n it(\"properly handles $or\", () => {\n expect(modernToLegacyWhereClause({\n $or: [{\n decimal: 5,\n }, {\n integer: 10,\n }],\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"type\": \"or\",\n \"value\": [\n {\n \"field\": \"decimal\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 10,\n },\n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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,CAAC;MACE,CAAC,CAAC;MACFN,EAAE,CAAC,sBAAsB,EAAE,MAAM;QAC7BD,MAAM,CAACE,yBAAyB,CAAC;UAC7BoB,GAAG,EAAE,CAAC;YACEF,OAAO,EAAE;UACb,CAAC,EAAE;YACCF,OAAO,EAAE;UACb,CAAC;QACT,CAAC,EAAErB,8BAA8B,CAAC,CAAC,CAACU,qBAAqB,CAAC;AAC1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,CAAC;MACA,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"modernToLegacyWhereClause.test.js","names":["objectTypeWithAllPropertyTypes","expectType","describe","expect","it","modernToLegacyWhereClause","r","prop","type","apiName","toMatchInlineSnapshot","foo","geoPoint","$within","$bbox","$distance","$of","coordinates","$polygon","geoShape","$intersects","integer","$ne","decimal","$and","$or"],"sources":["modernToLegacyWhereClause.test.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 { objectTypeWithAllPropertyTypes } from \"@osdk/client.test.ontology\";\nimport { expectType } from \"ts-expect\";\nimport { describe, expect, it } from \"vitest\";\nimport { modernToLegacyWhereClause } from \"./modernToLegacyWhereClause.js\";\ndescribe(modernToLegacyWhereClause, () => {\n describe(\"api namespaces\", () => {\n describe(\"interfaces\", () => {\n it(\"properly converts shortname to fqApiName\", () => {\n const T = {\n type: \"interface\",\n apiName: \"a.Foo\",\n };\n const r = modernToLegacyWhereClause({\n prop: 5,\n }, T);\n expect(r).toMatchInlineSnapshot(`\n {\n \"field\": \"a.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n }\n `);\n });\n it(\"properly does not convert when interface has no apiNamespace\", () => {\n const T = {\n type: \"interface\",\n apiName: \"Foo\",\n };\n const r = modernToLegacyWhereClause({\n \"b.prop\": 5,\n foo: 6,\n }, T);\n expect(r).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"b.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"foo\",\n \"type\": \"eq\",\n \"value\": 6,\n },\n ],\n }\n `);\n });\n it(\"gracefully handles redundant apiNamespace in property\", () => {\n const T = {\n type: \"interface\",\n apiName: \"a.Foo\",\n };\n const r = modernToLegacyWhereClause({\n \"b.prop\": 5,\n \"a.foo\": 6,\n }, T);\n expect(r).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"b.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"a.foo\",\n \"type\": \"eq\",\n \"value\": 6,\n },\n ],\n }\n `);\n });\n it(\"properly does not convert different apiNamespaces\", () => {\n const T = {\n type: \"interface\",\n apiName: \"a.Foo\",\n };\n expect(modernToLegacyWhereClause({\n \"b.prop\": 5,\n }, T)).toMatchInlineSnapshot(`\n {\n \"field\": \"b.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n }\n `);\n });\n });\n describe(\"objects\", () => {\n it(\"does not convert object short property names to fq\", () => {\n const T = {\n type: \"object\",\n apiName: \"a.Foo\",\n };\n const r = modernToLegacyWhereClause({\n prop: 5,\n }, T);\n expect(r).toMatchInlineSnapshot(`\n {\n \"field\": \"prop\",\n \"type\": \"eq\",\n \"value\": 5,\n }\n `);\n });\n });\n });\n describe(\"single checks\", () => {\n describe(\"$within\", () => {\n it(\"properly generates bbox shortcut\", async () => {\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: [-5, 5, -10, 10],\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n it(\"properly generates bbox long form\", async () => {\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: {\n $bbox: [-5, 5, -10, 10],\n },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n it(\"properly generates within radius\", async () => {\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: { $distance: [5, \"km\"], $of: [-5, 5] },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinDistanceOf\",\n \"value\": {\n \"center\": {\n \"coordinates\": [\n -5,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"distance\": {\n \"unit\": \"KILOMETERS\",\n \"value\": 5,\n },\n },\n }\n `);\n });\n it(\"properly generates within radius of geopoint\", async () => {\n // suppose you loaded an object with a geopoint field\n // and you want to find all objects within 5 km of that point\n const pointAsGeoJsonPoint = {\n type: \"Point\",\n coordinates: [-5, 5],\n };\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: { $distance: [5, \"km\"], $of: pointAsGeoJsonPoint },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinDistanceOf\",\n \"value\": {\n \"center\": {\n \"coordinates\": [\n -5,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"distance\": {\n \"unit\": \"KILOMETERS\",\n \"value\": 5,\n },\n },\n }\n `);\n });\n it(\"properly generates within polygon\", async () => {\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: { $polygon: [[[0, 1], [3, 2], [0, 1]]] },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n it(\"properly generates within polygon geojson\", async () => {\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: {\n type: \"Polygon\",\n coordinates: [[[0, 1], [3, 2], [0, 1]]],\n },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n it(\"check types\", async () => {\n expectType({\n geoPoint: {\n $within: [-5, 5, -10, 10],\n },\n });\n expectType({\n geoPoint: {\n $within: { $distance: [2, \"centimeter\"], $of: [2, 2] },\n },\n });\n expectType({\n geoPoint: {\n $within: { $polygon: [[[0, 1], [3, 2], [0, 1]]] },\n },\n });\n expectType({\n geoPoint: {\n $within: {\n type: \"Polygon\",\n coordinates: [[[0, 1], [3, 2], [0, 1]]],\n },\n },\n });\n expectType({\n geoPoint: {\n $within: { $bbox: [-5, 5, -10, 10] },\n },\n });\n expectType({\n geoPoint: {\n $within: {\n $bbox: [-5, 5, -10, 10],\n // @ts-expect-error\n $distance: [2, \"centimeter\"],\n // @ts-expect-error\n $of: [2, 2],\n },\n },\n });\n expectType({\n geoPoint: {\n $within: {\n $polygon: [[[0, 1], [3, 2], [0, 1]]],\n // @ts-expect-error\n $bbox: [2, 2, 2, 2],\n },\n },\n });\n });\n describe(\"$intersects\", () => {\n it(\"properly generates bbox shortcut\", async () => {\n expect(modernToLegacyWhereClause({\n geoShape: {\n $intersects: [-5, 5, -10, 10],\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n it(\"properly generates bbox long form\", async () => {\n expect(modernToLegacyWhereClause({\n geoShape: {\n $intersects: {\n $bbox: [-5, 5, -10, 10],\n },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n it(\"properly generates intersects polygon\", async () => {\n expect(modernToLegacyWhereClause({\n geoShape: {\n $intersects: { $polygon: [[[0, 1], [3, 2], [0, 1]]] },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n it(\"properly generates within polygon geojson\", async () => {\n expect(modernToLegacyWhereClause({\n geoShape: {\n $intersects: {\n type: \"Polygon\",\n coordinates: [[[0, 1], [3, 2], [0, 1]]],\n },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n });\n it(\"inverts ne short hand properly\", () => {\n expect(modernToLegacyWhereClause({\n integer: { $ne: 5 },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"type\": \"not\",\n \"value\": {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n }\n `);\n });\n });\n describe(\"multiple checks\", () => {\n it(\"properly handles multiple simple where checks\", () => {\n expect(modernToLegacyWhereClause({\n decimal: 5,\n integer: 10,\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"decimal\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 10,\n },\n ],\n }\n `);\n });\n it(\"properly handles $and\", () => {\n expect(modernToLegacyWhereClause({\n $and: [{\n decimal: 5,\n }, {\n integer: 10,\n }],\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"decimal\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 10,\n },\n ],\n }\n `);\n });\n it(\"properly handles $or\", () => {\n expect(modernToLegacyWhereClause({\n $or: [{\n decimal: 5,\n }, {\n integer: 10,\n }],\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"type\": \"or\",\n \"value\": [\n {\n \"field\": \"decimal\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 10,\n },\n ],\n }\n `);\n });\n });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,8BAA8B,QAAQ,4BAA4B;AAC3E,SAASC,UAAU,QAAQ,WAAW;AACtC,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,yBAAyB,QAAQ,gCAAgC;AAC1EH,QAAQ,CAACG,yBAAyB,EAAE,MAAM;EACtCH,QAAQ,CAAC,gBAAgB,EAAE,MAAM;IAC7BA,QAAQ,CAAC,YAAY,EAAE,MAAM;MACzBE,EAAE,CAAC,0CAA0C,EAAE,MAAM;QAKjD,MAAME,CAAC,GAAGD,yBAAyB,CAAC;UAChCE,IAAI,EAAE;QACV,CAAC,EANS;UACNC,IAAI,EAAE,WAAW;UACjBC,OAAO,EAAE;QACb,CAGI,CAAC;QACLN,MAAM,CAACG,CAAC,CAAC,CAACI,qBAAqB,CAAC;AAChD;AACA;AACA;AACA;AACA;AACA,SAAS,CAAC;MACE,CAAC,CAAC;MACFN,EAAE,CAAC,8DAA8D,EAAE,MAAM;QAKrE,MAAME,CAAC,GAAGD,yBAAyB,CAAC;UAChC,QAAQ,EAAE,CAAC;UACXM,GAAG,EAAE;QACT,CAAC,EAPS;UACNH,IAAI,EAAE,WAAW;UACjBC,OAAO,EAAE;QACb,CAII,CAAC;QACLN,MAAM,CAACG,CAAC,CAAC,CAACI,qBAAqB,CAAC;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,CAAC;MACE,CAAC,CAAC;MACFN,EAAE,CAAC,uDAAuD,EAAE,MAAM;QAK9D,MAAME,CAAC,GAAGD,yBAAyB,CAAC;UAChC,QAAQ,EAAE,CAAC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,EAAE;QACb,CAAC,EAAErB,8BAA8B,CAAC,CAAC,CAACU,qBAAqB,CAAC;AAC1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;MACI,CAAC,CAAC;MACFN,EAAE,CAAC,uBAAuB,EAAE,MAAM;QAC9BD,MAAM,CAACE,yBAAyB,CAAC;UAC7BmB,IAAI,EAAE,CAAC;YACCD,OAAO,EAAE;UACb,CAAC,EAAE;YACCF,OAAO,EAAE;UACb,CAAC;QACT,CAAC,EAAErB,8BAA8B,CAAC,CAAC,CAACU,qBAAqB,CAAC;AAC1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,CAAC;MACE,CAAC,CAAC;MACFN,EAAE,CAAC,sBAAsB,EAAE,MAAM;QAC7BD,MAAM,CAACE,yBAAyB,CAAC;UAC7BoB,GAAG,EAAE,CAAC;YACEF,OAAO,EAAE;UACb,CAAC,EAAE;YACCF,OAAO,EAAE;UACb,CAAC;QACT,CAAC,EAAErB,8BAA8B,CAAC,CAAC,CAACU,qBAAqB,CAAC;AAC1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,CAAC;MACA,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC,CAAC","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.2-beta.
|
|
16
|
+
export const USER_AGENT = `osdk-client/${"2.0.2-beta.2"}`;
|
|
17
17
|
//# sourceMappingURL=UserAgent.js.map
|
|
@@ -38,14 +38,13 @@ export function modernToLegacyWhereClause(whereClause, objectOrInterface) {
|
|
|
38
38
|
value: modernToLegacyWhereClause(whereClause.$not, objectOrInterface)
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
const [objApiNamespace, objApiShortname] = extractNamespace(objectOrInterface.apiName);
|
|
42
41
|
const parts = Object.entries(whereClause);
|
|
43
42
|
if (parts.length === 1) {
|
|
44
|
-
return handleWherePair(parts[0],
|
|
43
|
+
return handleWherePair(parts[0], objectOrInterface);
|
|
45
44
|
}
|
|
46
45
|
return {
|
|
47
46
|
type: "and",
|
|
48
|
-
value: parts.map(v => handleWherePair(v,
|
|
47
|
+
value: parts.map(v => handleWherePair(v, objectOrInterface))
|
|
49
48
|
};
|
|
50
49
|
}
|
|
51
50
|
function makeGeoFilterBbox(field, bbox, filterType) {
|
|
@@ -74,12 +73,15 @@ function makeGeoFilterPolygon(field, coordinates, filterType) {
|
|
|
74
73
|
}
|
|
75
74
|
};
|
|
76
75
|
}
|
|
77
|
-
function handleWherePair([field, filter],
|
|
76
|
+
function handleWherePair([field, filter], objectOrInterface) {
|
|
78
77
|
!(filter != null) ? invariant(false, "Defined key values are only allowed when they are not undefined.") : void 0;
|
|
79
78
|
if (typeof filter === "string" || typeof filter === "number" || typeof filter === "boolean") {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
if (objectOrInterface.type === "interface") {
|
|
80
|
+
const [objApiNamespace] = extractNamespace(objectOrInterface.apiName);
|
|
81
|
+
const [fieldApiNamespace, fieldShortName] = extractNamespace(field);
|
|
82
|
+
if (fieldApiNamespace == null && objApiNamespace != null) {
|
|
83
|
+
field = `${objApiNamespace}.${fieldShortName}`;
|
|
84
|
+
}
|
|
83
85
|
}
|
|
84
86
|
return {
|
|
85
87
|
type: "eq",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modernToLegacyWhereClause.js","names":["DistanceUnitMapping","invariant","extractNamespace","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,CAAC,CAAC,CAAC;AAChE;AACA;AACA,OAAO,SAASI,yBAAyBA,CAACC,WAAW,EAAEC,iBAAiB,EAAE;EACtE,IAAI,MAAM,IAAID,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YACN3C,KAAK,EAAEoC,UAAU,CAACI,SAAS,CAAC,CAAC,CAAC;YAC9BI,IAAI,EAAExD,mBAAmB,CAACgD,UAAU,CAACI,SAAS,CAAC,CAAC,CAAC;UACrD;QACJ;MACJ,CAAC;IACL,CAAC,MACI;MACD,MAAMpB,WAAW,GAAI,UAAU,IAAIgB,UAAU,GACvCA,UAAU,CAACS,QAAQ,GACnBT,UAAU,CAAChB,WAAW;MAC5B,OAAOE,oBAAoB,CAACN,KAAK,EAAEI,WAAW,EAAE,eAAe,CAAC;IACpE;EACJ;EACA,IAAIe,QAAQ,KAAK,aAAa,EAAE;IAC5B,MAAMW,cAAc,GAAGvB,MAAM,CAACY,QAAQ,CAAC;IACvC,IAAIE,KAAK,CAACC,OAAO,CAACQ,cAAc,CAAC,EAAE;MAC/B,OAAO/B,iBAAiB,CAACC,KAAK,EAAE8B,cAAc,EAAEX,QAAQ,CAAC;IAC7D,CAAC,MACI,IAAI,OAAO,IAAIW,cAAc,IAAIA,cAAc,CAACP,KAAK,IAAI,IAAI,EAAE;MAChE,OAAOxB,iBAAiB,CAACC,KAAK,EAAE8B,cAAc,CAACP,KAAK,EAAEJ,QAAQ,CAAC;IACnE,CAAC,MACI;MACD,MAAMf,WAAW,GAAI,UAAU,IAAI0B,cAAc,GAC3CA,cAAc,CAACD,QAAQ,GACvBC,cAAc,CAAC1B,WAAW;MAChC,OAAOE,oBAAoB,CAACN,KAAK,EAAEI,WAAW,EAAE,mBAAmB,CAAC;IACxE;EACJ;EACA,OAAO;IACHrB,IAAI,EAAEoC,QAAQ,CAACY,SAAS,CAAC,CAAC,CAAC;IAC3B/B,KAAK;IACLhB,KAAK,EAAEuB,MAAM,CAACY,QAAQ;EAC1B,CAAC;AACL","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"modernToLegacyWhereClause.js","names":["DistanceUnitMapping","invariant","extractNamespace","fqApiName","last","lastIndexOf","undefined","slice","modernToLegacyWhereClause","whereClause","objectOrInterface","type","value","$and","map","clause","$or","$not","parts","Object","entries","length","handleWherePair","v","makeGeoFilterBbox","field","bbox","filterType","topLeft","coordinates","bottomRight","makeGeoFilterPolygon","filter","objApiNamespace","apiName","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 parts = Object.entries(whereClause);\n if (parts.length === 1) {\n return handleWherePair(parts[0], objectOrInterface);\n }\n return {\n type: \"and\",\n value: parts.map(v => handleWherePair(v, objectOrInterface)),\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], objectOrInterface) {\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 if (objectOrInterface.type === \"interface\") {\n const [objApiNamespace] = extractNamespace(objectOrInterface.apiName);\n const [fieldApiNamespace, fieldShortName] = extractNamespace(field);\n if (fieldApiNamespace == null && objApiNamespace != null) {\n field = `${objApiNamespace}.${fieldShortName}`;\n }\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,CAAC,CAAC,CAAC;AAChE;AACA;AACA,OAAO,SAASI,yBAAyBA,CAACC,WA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() => {
|
|
|
24
24
|
const r = modernToLegacyWhereClause({
|
|
25
25
|
prop: 5
|
|
26
26
|
}, {
|
|
27
|
-
// ...FooInterface
|
|
28
27
|
type: "interface",
|
|
29
28
|
apiName: "a.Foo"
|
|
30
29
|
});
|
|
@@ -103,6 +102,23 @@ describe(modernToLegacyWhereClause, () => {
|
|
|
103
102
|
`);
|
|
104
103
|
});
|
|
105
104
|
});
|
|
105
|
+
describe("objects", () => {
|
|
106
|
+
it("does not convert object short property names to fq", () => {
|
|
107
|
+
const r = modernToLegacyWhereClause({
|
|
108
|
+
prop: 5
|
|
109
|
+
}, {
|
|
110
|
+
type: "object",
|
|
111
|
+
apiName: "a.Foo"
|
|
112
|
+
});
|
|
113
|
+
expect(r).toMatchInlineSnapshot(`
|
|
114
|
+
{
|
|
115
|
+
"field": "prop",
|
|
116
|
+
"type": "eq",
|
|
117
|
+
"value": 5,
|
|
118
|
+
}
|
|
119
|
+
`);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
106
122
|
});
|
|
107
123
|
describe("single checks", () => {
|
|
108
124
|
describe("$within", () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modernToLegacyWhereClause.test.js","names":["objectTypeWithAllPropertyTypes","expectType","describe","expect","it","modernToLegacyWhereClause","r","prop","type","apiName","toMatchInlineSnapshot","foo","geoPoint","$within","$bbox","$distance","$of","coordinates","$polygon","geoShape","$intersects","integer","$ne","decimal","$and","$or"],"sources":["modernToLegacyWhereClause.test.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 { objectTypeWithAllPropertyTypes } from \"@osdk/client.test.ontology\";\nimport { expectType } from \"ts-expect\";\nimport { describe, expect, it } from \"vitest\";\nimport { modernToLegacyWhereClause } from \"./modernToLegacyWhereClause.js\";\ndescribe(modernToLegacyWhereClause, () => {\n describe(\"api namespaces\", () => {\n describe(\"interfaces\", () => {\n it(\"properly converts shortname to fqApiName\", () => {\n const T = {\n // ...FooInterface\n type: \"interface\",\n apiName: \"a.Foo\",\n };\n const r = modernToLegacyWhereClause({\n prop: 5,\n }, T);\n expect(r).toMatchInlineSnapshot(`\n {\n \"field\": \"a.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n }\n `);\n });\n it(\"properly does not convert when interface has no apiNamespace\", () => {\n const T = {\n type: \"interface\",\n apiName: \"Foo\",\n };\n const r = modernToLegacyWhereClause({\n \"b.prop\": 5,\n foo: 6,\n }, T);\n expect(r).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"b.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"foo\",\n \"type\": \"eq\",\n \"value\": 6,\n },\n ],\n }\n `);\n });\n it(\"gracefully handles redundant apiNamespace in property\", () => {\n const T = {\n type: \"interface\",\n apiName: \"a.Foo\",\n };\n const r = modernToLegacyWhereClause({\n \"b.prop\": 5,\n \"a.foo\": 6,\n }, T);\n expect(r).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"b.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"a.foo\",\n \"type\": \"eq\",\n \"value\": 6,\n },\n ],\n }\n `);\n });\n it(\"properly does not convert different apiNamespaces\", () => {\n const T = {\n type: \"interface\",\n apiName: \"a.Foo\",\n };\n expect(modernToLegacyWhereClause({\n \"b.prop\": 5,\n }, T)).toMatchInlineSnapshot(`\n {\n \"field\": \"b.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n }\n `);\n });\n });\n });\n describe(\"single checks\", () => {\n describe(\"$within\", () => {\n it(\"properly generates bbox shortcut\", async () => {\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: [-5, 5, -10, 10],\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n it(\"properly generates bbox long form\", async () => {\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: {\n $bbox: [-5, 5, -10, 10],\n },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n it(\"properly generates within radius\", async () => {\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: { $distance: [5, \"km\"], $of: [-5, 5] },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinDistanceOf\",\n \"value\": {\n \"center\": {\n \"coordinates\": [\n -5,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"distance\": {\n \"unit\": \"KILOMETERS\",\n \"value\": 5,\n },\n },\n }\n `);\n });\n it(\"properly generates within radius of geopoint\", async () => {\n // suppose you loaded an object with a geopoint field\n // and you want to find all objects within 5 km of that point\n const pointAsGeoJsonPoint = {\n type: \"Point\",\n coordinates: [-5, 5],\n };\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: { $distance: [5, \"km\"], $of: pointAsGeoJsonPoint },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinDistanceOf\",\n \"value\": {\n \"center\": {\n \"coordinates\": [\n -5,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"distance\": {\n \"unit\": \"KILOMETERS\",\n \"value\": 5,\n },\n },\n }\n `);\n });\n it(\"properly generates within polygon\", async () => {\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: { $polygon: [[[0, 1], [3, 2], [0, 1]]] },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n it(\"properly generates within polygon geojson\", async () => {\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: {\n type: \"Polygon\",\n coordinates: [[[0, 1], [3, 2], [0, 1]]],\n },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n it(\"check types\", async () => {\n expectType({\n geoPoint: {\n $within: [-5, 5, -10, 10],\n },\n });\n expectType({\n geoPoint: {\n $within: { $distance: [2, \"centimeter\"], $of: [2, 2] },\n },\n });\n expectType({\n geoPoint: {\n $within: { $polygon: [[[0, 1], [3, 2], [0, 1]]] },\n },\n });\n expectType({\n geoPoint: {\n $within: {\n type: \"Polygon\",\n coordinates: [[[0, 1], [3, 2], [0, 1]]],\n },\n },\n });\n expectType({\n geoPoint: {\n $within: { $bbox: [-5, 5, -10, 10] },\n },\n });\n expectType({\n geoPoint: {\n $within: {\n $bbox: [-5, 5, -10, 10],\n // @ts-expect-error\n $distance: [2, \"centimeter\"],\n // @ts-expect-error\n $of: [2, 2],\n },\n },\n });\n expectType({\n geoPoint: {\n $within: {\n $polygon: [[[0, 1], [3, 2], [0, 1]]],\n // @ts-expect-error\n $bbox: [2, 2, 2, 2],\n },\n },\n });\n });\n describe(\"$intersects\", () => {\n it(\"properly generates bbox shortcut\", async () => {\n expect(modernToLegacyWhereClause({\n geoShape: {\n $intersects: [-5, 5, -10, 10],\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n it(\"properly generates bbox long form\", async () => {\n expect(modernToLegacyWhereClause({\n geoShape: {\n $intersects: {\n $bbox: [-5, 5, -10, 10],\n },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n it(\"properly generates intersects polygon\", async () => {\n expect(modernToLegacyWhereClause({\n geoShape: {\n $intersects: { $polygon: [[[0, 1], [3, 2], [0, 1]]] },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n it(\"properly generates within polygon geojson\", async () => {\n expect(modernToLegacyWhereClause({\n geoShape: {\n $intersects: {\n type: \"Polygon\",\n coordinates: [[[0, 1], [3, 2], [0, 1]]],\n },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n });\n it(\"inverts ne short hand properly\", () => {\n expect(modernToLegacyWhereClause({\n integer: { $ne: 5 },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"type\": \"not\",\n \"value\": {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n }\n `);\n });\n });\n describe(\"multiple checks\", () => {\n it(\"properly handles multiple simple where checks\", () => {\n expect(modernToLegacyWhereClause({\n decimal: 5,\n integer: 10,\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"decimal\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 10,\n },\n ],\n }\n `);\n });\n it(\"properly handles $and\", () => {\n expect(modernToLegacyWhereClause({\n $and: [{\n decimal: 5,\n }, {\n integer: 10,\n }],\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"decimal\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 10,\n },\n ],\n }\n `);\n });\n it(\"properly handles $or\", () => {\n expect(modernToLegacyWhereClause({\n $or: [{\n decimal: 5,\n }, {\n integer: 10,\n }],\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"type\": \"or\",\n \"value\": [\n {\n \"field\": \"decimal\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 10,\n },\n ],\n }\n `);\n });\n });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,8BAA8B,QAAQ,4BAA4B;AAC3E,SAASC,UAAU,QAAQ,WAAW;AACtC,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,yBAAyB,QAAQ,gCAAgC;AAC1EH,QAAQ,CAACG,yBAAyB,EAAE,MAAM;EACtCH,QAAQ,CAAC,gBAAgB,EAAE,MAAM;IAC7BA,QAAQ,CAAC,YAAY,EAAE,MAAM;MACzBE,EAAE,CAAC,0CAA0C,EAAE,MAAM;QAMjD,MAAME,CAAC,GAAGD,yBAAyB,CAAC;UAChCE,IAAI,EAAE;QACV,CAAC,EAPS;UACN;UACAC,IAAI,EAAE,WAAW;UACjBC,OAAO,EAAE;QACb,CAGI,CAAC;QACLN,MAAM,CAACG,CAAC,CAAC,CAACI,qBAAqB,CAAC;AAChD;AACA;AACA;AACA;AACA;AACA,SAAS,CAAC;MACE,CAAC,CAAC;MACFN,EAAE,CAAC,8DAA8D,EAAE,MAAM;QAKrE,MAAME,CAAC,GAAGD,yBAAyB,CAAC;UAChC,QAAQ,EAAE,CAAC;UACXM,GAAG,EAAE;QACT,CAAC,EAPS;UACNH,IAAI,EAAE,WAAW;UACjBC,OAAO,EAAE;QACb,CAII,CAAC;QACLN,MAAM,CAACG,CAAC,CAAC,CAACI,qBAAqB,CAAC;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,CAAC;MACE,CAAC,CAAC;MACFN,EAAE,CAAC,uDAAuD,EAAE,MAAM;QAK9D,MAAME,CAAC,GAAGD,yBAAyB,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;YACCF,OAAO,EAAE;UACb,CAAC;QACT,CAAC,EAAErB,8BAA8B,CAAC,CAAC,CAACU,qBAAqB,CAAC;AAC1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,CAAC;MACE,CAAC,CAAC;MACFN,EAAE,CAAC,sBAAsB,EAAE,MAAM;QAC7BD,MAAM,CAACE,yBAAyB,CAAC;UAC7BoB,GAAG,EAAE,CAAC;YACEF,OAAO,EAAE;UACb,CAAC,EAAE;YACCF,OAAO,EAAE;UACb,CAAC;QACT,CAAC,EAAErB,8BAA8B,CAAC,CAAC,CAACU,qBAAqB,CAAC;AAC1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,CAAC;MACA,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"modernToLegacyWhereClause.test.js","names":["objectTypeWithAllPropertyTypes","expectType","describe","expect","it","modernToLegacyWhereClause","r","prop","type","apiName","toMatchInlineSnapshot","foo","geoPoint","$within","$bbox","$distance","$of","coordinates","$polygon","geoShape","$intersects","integer","$ne","decimal","$and","$or"],"sources":["modernToLegacyWhereClause.test.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 { objectTypeWithAllPropertyTypes } from \"@osdk/client.test.ontology\";\nimport { expectType } from \"ts-expect\";\nimport { describe, expect, it } from \"vitest\";\nimport { modernToLegacyWhereClause } from \"./modernToLegacyWhereClause.js\";\ndescribe(modernToLegacyWhereClause, () => {\n describe(\"api namespaces\", () => {\n describe(\"interfaces\", () => {\n it(\"properly converts shortname to fqApiName\", () => {\n const T = {\n type: \"interface\",\n apiName: \"a.Foo\",\n };\n const r = modernToLegacyWhereClause({\n prop: 5,\n }, T);\n expect(r).toMatchInlineSnapshot(`\n {\n \"field\": \"a.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n }\n `);\n });\n it(\"properly does not convert when interface has no apiNamespace\", () => {\n const T = {\n type: \"interface\",\n apiName: \"Foo\",\n };\n const r = modernToLegacyWhereClause({\n \"b.prop\": 5,\n foo: 6,\n }, T);\n expect(r).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"b.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"foo\",\n \"type\": \"eq\",\n \"value\": 6,\n },\n ],\n }\n `);\n });\n it(\"gracefully handles redundant apiNamespace in property\", () => {\n const T = {\n type: \"interface\",\n apiName: \"a.Foo\",\n };\n const r = modernToLegacyWhereClause({\n \"b.prop\": 5,\n \"a.foo\": 6,\n }, T);\n expect(r).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"b.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"a.foo\",\n \"type\": \"eq\",\n \"value\": 6,\n },\n ],\n }\n `);\n });\n it(\"properly does not convert different apiNamespaces\", () => {\n const T = {\n type: \"interface\",\n apiName: \"a.Foo\",\n };\n expect(modernToLegacyWhereClause({\n \"b.prop\": 5,\n }, T)).toMatchInlineSnapshot(`\n {\n \"field\": \"b.prop\",\n \"type\": \"eq\",\n \"value\": 5,\n }\n `);\n });\n });\n describe(\"objects\", () => {\n it(\"does not convert object short property names to fq\", () => {\n const T = {\n type: \"object\",\n apiName: \"a.Foo\",\n };\n const r = modernToLegacyWhereClause({\n prop: 5,\n }, T);\n expect(r).toMatchInlineSnapshot(`\n {\n \"field\": \"prop\",\n \"type\": \"eq\",\n \"value\": 5,\n }\n `);\n });\n });\n });\n describe(\"single checks\", () => {\n describe(\"$within\", () => {\n it(\"properly generates bbox shortcut\", async () => {\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: [-5, 5, -10, 10],\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n it(\"properly generates bbox long form\", async () => {\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: {\n $bbox: [-5, 5, -10, 10],\n },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n it(\"properly generates within radius\", async () => {\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: { $distance: [5, \"km\"], $of: [-5, 5] },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinDistanceOf\",\n \"value\": {\n \"center\": {\n \"coordinates\": [\n -5,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"distance\": {\n \"unit\": \"KILOMETERS\",\n \"value\": 5,\n },\n },\n }\n `);\n });\n it(\"properly generates within radius of geopoint\", async () => {\n // suppose you loaded an object with a geopoint field\n // and you want to find all objects within 5 km of that point\n const pointAsGeoJsonPoint = {\n type: \"Point\",\n coordinates: [-5, 5],\n };\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: { $distance: [5, \"km\"], $of: pointAsGeoJsonPoint },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinDistanceOf\",\n \"value\": {\n \"center\": {\n \"coordinates\": [\n -5,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"distance\": {\n \"unit\": \"KILOMETERS\",\n \"value\": 5,\n },\n },\n }\n `);\n });\n it(\"properly generates within polygon\", async () => {\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: { $polygon: [[[0, 1], [3, 2], [0, 1]]] },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n it(\"properly generates within polygon geojson\", async () => {\n expect(modernToLegacyWhereClause({\n geoPoint: {\n $within: {\n type: \"Polygon\",\n coordinates: [[[0, 1], [3, 2], [0, 1]]],\n },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoPoint\",\n \"type\": \"withinPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n it(\"check types\", async () => {\n expectType({\n geoPoint: {\n $within: [-5, 5, -10, 10],\n },\n });\n expectType({\n geoPoint: {\n $within: { $distance: [2, \"centimeter\"], $of: [2, 2] },\n },\n });\n expectType({\n geoPoint: {\n $within: { $polygon: [[[0, 1], [3, 2], [0, 1]]] },\n },\n });\n expectType({\n geoPoint: {\n $within: {\n type: \"Polygon\",\n coordinates: [[[0, 1], [3, 2], [0, 1]]],\n },\n },\n });\n expectType({\n geoPoint: {\n $within: { $bbox: [-5, 5, -10, 10] },\n },\n });\n expectType({\n geoPoint: {\n $within: {\n $bbox: [-5, 5, -10, 10],\n // @ts-expect-error\n $distance: [2, \"centimeter\"],\n // @ts-expect-error\n $of: [2, 2],\n },\n },\n });\n expectType({\n geoPoint: {\n $within: {\n $polygon: [[[0, 1], [3, 2], [0, 1]]],\n // @ts-expect-error\n $bbox: [2, 2, 2, 2],\n },\n },\n });\n });\n describe(\"$intersects\", () => {\n it(\"properly generates bbox shortcut\", async () => {\n expect(modernToLegacyWhereClause({\n geoShape: {\n $intersects: [-5, 5, -10, 10],\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n it(\"properly generates bbox long form\", async () => {\n expect(modernToLegacyWhereClause({\n geoShape: {\n $intersects: {\n $bbox: [-5, 5, -10, 10],\n },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsBoundingBox\",\n \"value\": {\n \"bottomRight\": {\n \"coordinates\": [\n -10,\n 5,\n ],\n \"type\": \"Point\",\n },\n \"topLeft\": {\n \"coordinates\": [\n -5,\n 10,\n ],\n \"type\": \"Point\",\n },\n },\n }\n `);\n });\n it(\"properly generates intersects polygon\", async () => {\n expect(modernToLegacyWhereClause({\n geoShape: {\n $intersects: { $polygon: [[[0, 1], [3, 2], [0, 1]]] },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n it(\"properly generates within polygon geojson\", async () => {\n expect(modernToLegacyWhereClause({\n geoShape: {\n $intersects: {\n type: \"Polygon\",\n coordinates: [[[0, 1], [3, 2], [0, 1]]],\n },\n },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"field\": \"geoShape\",\n \"type\": \"intersectsPolygon\",\n \"value\": {\n \"coordinates\": [\n [\n [\n 0,\n 1,\n ],\n [\n 3,\n 2,\n ],\n [\n 0,\n 1,\n ],\n ],\n ],\n \"type\": \"Polygon\",\n },\n }\n `);\n });\n });\n it(\"inverts ne short hand properly\", () => {\n expect(modernToLegacyWhereClause({\n integer: { $ne: 5 },\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"type\": \"not\",\n \"value\": {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n }\n `);\n });\n });\n describe(\"multiple checks\", () => {\n it(\"properly handles multiple simple where checks\", () => {\n expect(modernToLegacyWhereClause({\n decimal: 5,\n integer: 10,\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"decimal\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 10,\n },\n ],\n }\n `);\n });\n it(\"properly handles $and\", () => {\n expect(modernToLegacyWhereClause({\n $and: [{\n decimal: 5,\n }, {\n integer: 10,\n }],\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"type\": \"and\",\n \"value\": [\n {\n \"field\": \"decimal\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 10,\n },\n ],\n }\n `);\n });\n it(\"properly handles $or\", () => {\n expect(modernToLegacyWhereClause({\n $or: [{\n decimal: 5,\n }, {\n integer: 10,\n }],\n }, objectTypeWithAllPropertyTypes)).toMatchInlineSnapshot(`\n {\n \"type\": \"or\",\n \"value\": [\n {\n \"field\": \"decimal\",\n \"type\": \"eq\",\n \"value\": 5,\n },\n {\n \"field\": \"integer\",\n \"type\": \"eq\",\n \"value\": 10,\n },\n ],\n }\n `);\n });\n });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,8BAA8B,QAAQ,4BAA4B;AAC3E,SAASC,UAAU,QAAQ,WAAW;AACtC,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,yBAAyB,QAAQ,gCAAgC;AAC1EH,QAAQ,CAACG,yBAAyB,EAAE,MAAM;EACtCH,QAAQ,CAAC,gBAAgB,EAAE,MAAM;IAC7BA,QAAQ,CAAC,YAAY,EAAE,MAAM;MACzBE,EAAE,CAAC,0CAA0C,EAAE,MAAM;QAKjD,MAAME,CAAC,GAAGD,yBAAyB,CAAC;UAChCE,IAAI,EAAE;QACV,CAAC,EANS;UACNC,IAAI,EAAE,WAAW;UACjBC,OAAO,EAAE;QACb,CAGI,CAAC;QACLN,MAAM,CAACG,CAAC,CAAC,CAACI,qBAAqB,CAAC;AAChD;AACA;AACA;AACA;AACA;AACA,SAAS,CAAC;MACE,CAAC,CAAC;MACFN,EAAE,CAAC,8DAA8D,EAAE,MAAM;QAKrE,MAAME,CAAC,GAAGD,yBAAyB,CAAC;UAChC,QAAQ,EAAE,CAAC;UACXM,GAAG,EAAE;QACT,CAAC,EAPS;UACNH,IAAI,EAAE,WAAW;UACjBC,OAAO,EAAE;QACb,CAII,CAAC;QACLN,MAAM,CAACG,CAAC,CAAC,CAACI,qBAAqB,CAAC;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,CAAC;MACE,CA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MAC9BE,EAAE,CAAC,+CAA+C,EAAE,MAAM;QACtDD,MAAM,CAACE,yBAAyB,CAAC;UAC7BkB,OAAO,EAAE,CAAC;UACVF,OAAO,EAAE;QACb,CAAC,EAAErB,8BAA8B,CAAC,CAAC,CAACU,qBAAqB,CAAC;AAC1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;MACI,CAAC,CAAC;MACFN,EAAE,CAAC,uBAAuB,EAAE,MAAM;QAC9BD,MAAM,CAACE,yBAAyB,CAAC;UAC7BmB,IAAI,EAAE,CAAC;YACCD,OAAO,EAAE;UACb,CAAC,EAAE;YACCF,OAAO,EAAE;UACb,CAAC;QACT,CAAC,EAAErB,8BAA8B,CAAC,CAAC,CAACU,qBAAqB,CAAC;AAC1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,CAAC;MACE,CAAC,CAAC;MACFN,EAAE,CAAC,sBAAsB,EAAE,MAAM;QAC7BD,MAAM,CAACE,yBAAyB,CAAC;UAC7BoB,GAAG,EAAE,CAAC;YACEF,OAAO,EAAE;UACb,CAAC,EAAE;YACCF,OAAO,EAAE;UACb,CAAC;QACT,CAAC,EAAErB,8BAA8B,CAAC,CAAC,CAACU,qBAAqB,CAAC;AAC1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,CAAC;MACA,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC,CAAC","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.2-beta.
|
|
16
|
+
export const USER_AGENT = `osdk-client/${"2.0.2-beta.2"}`;
|
|
17
17
|
//# sourceMappingURL=UserAgent.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osdk/client",
|
|
3
|
-
"version": "2.0.2-beta.
|
|
3
|
+
"version": "2.0.2-beta.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"access": "public",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
"tiny-invariant": "^1.3.1",
|
|
30
30
|
"type-fest": "^4.18.2",
|
|
31
31
|
"ws": "^8.18.0",
|
|
32
|
-
"@osdk/
|
|
33
|
-
"@osdk/client.unstable": "2.0.2-beta.1",
|
|
32
|
+
"@osdk/client.unstable": "2.0.2-beta.2",
|
|
34
33
|
"@osdk/client.unstable.osw": "0.2.0",
|
|
35
|
-
"@osdk/
|
|
36
|
-
"@osdk/
|
|
37
|
-
"@osdk/internal.foundry.
|
|
34
|
+
"@osdk/generator-converters": "2.0.2-beta.2",
|
|
35
|
+
"@osdk/api": "~2.0.2-beta.2",
|
|
36
|
+
"@osdk/internal.foundry.core": "0.2.1",
|
|
38
37
|
"@osdk/shared.client.impl": "~1.0.1",
|
|
39
|
-
"@osdk/
|
|
40
|
-
"@osdk/shared.net.fetch": "~1.0.0"
|
|
38
|
+
"@osdk/internal.foundry.ontologiesv2": "0.2.1",
|
|
39
|
+
"@osdk/shared.net.fetch": "~1.0.0",
|
|
40
|
+
"@osdk/shared.net.errors": "~2.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@microsoft/api-documenter": "^7.25.3",
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
"typescript": "^5.5.4",
|
|
58
58
|
"zod": "^3.23.8",
|
|
59
59
|
"@osdk/monorepo.api-extractor": "~0.0.0",
|
|
60
|
-
"@osdk/client.test.ontology": "~2.0.2-beta.
|
|
60
|
+
"@osdk/client.test.ontology": "~2.0.2-beta.2",
|
|
61
61
|
"@osdk/monorepo.tsconfig": "~0.0.0",
|
|
62
|
-
"@osdk/
|
|
63
|
-
"@osdk/
|
|
62
|
+
"@osdk/monorepo.tsup": "~0.0.0",
|
|
63
|
+
"@osdk/shared.test": "~2.0.2-beta.2"
|
|
64
64
|
},
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|