@osdk/client 2.0.2-rc.0 → 2.1.0-beta.0
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 -15
- 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/__unstable/createBulkLinksAsyncIterFactory.d.ts +3 -3
- package/build/browser/__unstable/createBulkLinksAsyncIterFactory.d.ts.map +1 -1
- package/build/browser/createClient.d.ts.map +1 -1
- package/build/browser/createClient.js +11 -0
- package/build/browser/createClient.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 +19 -7
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js +117 -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/InternalSymbols.d.ts +2 -2
- package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.d.ts.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/object/convertWireToOsdkObjects/createOsdkObject.js +1 -3
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.test.js +25 -1
- package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/browser/object/fetchSingle.js +1 -1
- package/build/browser/object/fetchSingle.js.map +1 -1
- package/build/browser/object/object.test.js +1 -1
- package/build/browser/object/object.test.js.map +1 -1
- package/build/browser/objectSet/ObjectSet.test.js +0 -1
- package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.d.ts +1 -6
- package/build/browser/objectSet/ObjectSetListenerWebsocket.d.ts.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js +37 -156
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js +17 -16
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/browser/objectSet/createObjectSet.js +3 -3
- package/build/browser/objectSet/createObjectSet.js.map +1 -1
- package/build/browser/queries/applyQuery.js +3 -3
- package/build/browser/queries/applyQuery.js.map +1 -1
- package/build/browser/queries/queries.test.js +7 -1
- package/build/browser/queries/queries.test.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/__unstable/createBulkLinksAsyncIterFactory.d.ts +3 -3
- package/build/esm/__unstable/createBulkLinksAsyncIterFactory.d.ts.map +1 -1
- package/build/esm/createClient.d.ts.map +1 -1
- package/build/esm/createClient.js +11 -0
- package/build/esm/createClient.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 +19 -7
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js +117 -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/InternalSymbols.d.ts +2 -2
- package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.d.ts.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/object/convertWireToOsdkObjects/createOsdkObject.js +1 -3
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.test.js +25 -1
- package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/esm/object/fetchSingle.js +1 -1
- package/build/esm/object/fetchSingle.js.map +1 -1
- package/build/esm/object/object.test.js +1 -1
- package/build/esm/object/object.test.js.map +1 -1
- package/build/esm/objectSet/ObjectSet.test.js +0 -1
- package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.d.ts +1 -6
- package/build/esm/objectSet/ObjectSetListenerWebsocket.d.ts.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js +37 -156
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js +17 -16
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/esm/objectSet/createObjectSet.js +3 -3
- package/build/esm/objectSet/createObjectSet.js.map +1 -1
- package/build/esm/queries/applyQuery.js +3 -3
- package/build/esm/queries/applyQuery.js.map +1 -1
- package/build/esm/queries/queries.test.js +7 -1
- package/build/esm/queries/queries.test.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 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modernToLegacyWhereClause.test.js","names":["expectType","describe","expect","it","modernToLegacyWhereClause","geoPoint","$within","toMatchInlineSnapshot","$bbox","$distance","$of","type","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 { expectType } from \"ts-expect\";\nimport { describe, expect, it } from \"vitest\";\nimport { modernToLegacyWhereClause } from \"./modernToLegacyWhereClause.js\";\ndescribe(modernToLegacyWhereClause, () => {\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 })).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 })).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 })).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 })).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 })).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 })).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 })).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 })).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 })).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 })).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 })).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 })).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 })).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 })).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,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,eAAe,EAAE,MAAM;IAC5BA,QAAQ,CAAC,SAAS,EAAE,MAAM;MACtBE,EAAE,CAAC,kCAAkC,EAAE,YAAY;QAC/CD,MAAM,CAACE,yBAAyB,CAAC;UAC7BC,QAAQ,EAAE;YACNC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE;UAC5B;QACJ,CAAC,CAAC,CAAC,CAACC,qBAAqB,CAAC;AAC1C;AACA;AACA;AACA;AACA;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C;MACFJ,EAAE,CAAC,uBAAuB,EAAE,MAAM;QAC9BD,MAAM,CAACE,yBAAyB,CAAC;UAC7Be,IAAI,EAAE,CAAC;YACCD,OAAO,EAAE;UACb,CAAC,EAAE;YACCF,OAAO,EAAE;UACb,CAAC;QACT,CAAC,CAAC,CAAC,CAACT,qBAAqB,CAAC;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,CAAC;MACE,CAAC,CAAC;MACFJ,EAAE,CAAC,sBAAsB,EAAE,MAAM;QAC7BD,MAAM,CAACE,yBAAyB,CAAC;UAC7BgB,GAAG,EAAE,CAAC;YACEF,OAAO,EAAE;UACb,CAAC,EAAE;YACCF,OAAO,EAAE;UACb,CAAC;QACT,CAAC,CAAC,CAAC,CAACT,qBAAqB,CAAC;AAC1C;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,qBAA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A;AACA;AACA;AACA;AACA,OAAO,CAAC;MACI,CAAC,CAAC;IACN,CAAC,CAAC;IACFR,QAAQ,CAAC,iBAAiB,EAAE,MAAM;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":[]}
|
|
@@ -34,7 +34,7 @@ export async function aggregate(clientCtx, objectType, objectSet = {
|
|
|
34
34
|
body.groupBy = modernToLegacyGroupByClause(req.$groupBy);
|
|
35
35
|
}
|
|
36
36
|
if (req.$where) {
|
|
37
|
-
body.where = modernToLegacyWhereClause(req.$where);
|
|
37
|
+
body.where = modernToLegacyWhereClause(req.$where, objectType);
|
|
38
38
|
}
|
|
39
39
|
const result = await OntologiesV2.OntologyObjectSets.aggregate(addUserAgentAndRequestContextHeaders(clientCtx, objectType), await clientCtx.ontologyRid, {
|
|
40
40
|
objectSet,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregate.js","names":["OntologiesV2","invariant","legacyToModernSingleAggregationResult","modernToLegacyAggregationClause","modernToLegacyGroupByClause","modernToLegacyWhereClause","addUserAgentAndRequestContextHeaders","aggregate","clientCtx","objectType","objectSet","type","req","body","aggregation","$select","groupBy","where","undefined","$groupBy","$where","result","OntologyObjectSets","ontologyRid","data","length","aggregationToCountResult","ret","map","entry","$group","group","aggregateResult","metrics","name","$count","value"],"sources":["aggregate.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 * as OntologiesV2 from \"@osdk/internal.foundry.ontologiesv2\";\nimport invariant from \"tiny-invariant\";\nimport { legacyToModernSingleAggregationResult } from \"../internal/conversions/legacyToModernSingleAggregationResult.js\";\nimport { modernToLegacyAggregationClause } from \"../internal/conversions/modernToLegacyAggregationClause.js\";\nimport { modernToLegacyGroupByClause } from \"../internal/conversions/modernToLegacyGroupByClause.js\";\nimport { modernToLegacyWhereClause } from \"../internal/conversions/modernToLegacyWhereClause.js\";\nimport { addUserAgentAndRequestContextHeaders } from \"../util/addUserAgentAndRequestContextHeaders.js\";\n/** @internal */\nexport async function aggregate(clientCtx, objectType, objectSet = {\n type: \"base\",\n objectType: objectType[\"apiName\"],\n}, req) {\n const body = {\n aggregation: modernToLegacyAggregationClause(req.$select),\n groupBy: [],\n where: undefined,\n };\n if (req.$groupBy) {\n body.groupBy = modernToLegacyGroupByClause(req.$groupBy);\n }\n if (req.$where) {\n body.where = modernToLegacyWhereClause(req.$where);\n }\n const result = await OntologiesV2.OntologyObjectSets.aggregate(addUserAgentAndRequestContextHeaders(clientCtx, objectType), await clientCtx.ontologyRid, {\n objectSet,\n groupBy: body.groupBy,\n aggregation: body.aggregation,\n });\n if (!req.$groupBy) {\n invariant(result.data.length === 1, \"no group by clause should mean only one data result\");\n return {\n ...aggregationToCountResult(result.data[0]),\n ...legacyToModernSingleAggregationResult(result.data[0]),\n };\n }\n const ret = result.data\n .map((entry) => {\n return {\n $group: entry.group,\n ...aggregationToCountResult(entry),\n ...legacyToModernSingleAggregationResult(entry),\n };\n }); // fixme\n return ret; // FIXME\n}\nfunction aggregationToCountResult(entry) {\n for (const aggregateResult of entry.metrics) {\n if (aggregateResult.name === \"count\") {\n return { $count: aggregateResult.value };\n }\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,KAAKA,YAAY,MAAM,qCAAqC;AACnE,OAAOC,SAAS,MAAM,gBAAgB;AACtC,SAASC,qCAAqC,QAAQ,kEAAkE;AACxH,SAASC,+BAA+B,QAAQ,4DAA4D;AAC5G,SAASC,2BAA2B,QAAQ,wDAAwD;AACpG,SAASC,yBAAyB,QAAQ,sDAAsD;AAChG,SAASC,oCAAoC,QAAQ,iDAAiD;AACtG;AACA,OAAO,eAAeC,SAASA,CAACC,SAAS,EAAEC,UAAU,EAAEC,SAAS,GAAG;EAC/DC,IAAI,EAAE,MAAM;EACZF,UAAU,EAAEA,UAAU,CAAC,SAAS;AACpC,CAAC,EAAEG,GAAG,EAAE;EACJ,MAAMC,IAAI,GAAG;IACTC,WAAW,EAAEX,+BAA+B,CAACS,GAAG,CAACG,OAAO,CAAC;IACzDC,OAAO,EAAE,EAAE;IACXC,KAAK,EAAEC;EACX,CAAC;EACD,IAAIN,GAAG,CAACO,QAAQ,EAAE;IACdN,IAAI,CAACG,OAAO,GAAGZ,2BAA2B,CAACQ,GAAG,CAACO,QAAQ,CAAC;EAC5D;EACA,IAAIP,GAAG,CAACQ,MAAM,EAAE;IACZP,IAAI,CAACI,KAAK,GAAGZ,yBAAyB,CAACO,GAAG,CAACQ,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"aggregate.js","names":["OntologiesV2","invariant","legacyToModernSingleAggregationResult","modernToLegacyAggregationClause","modernToLegacyGroupByClause","modernToLegacyWhereClause","addUserAgentAndRequestContextHeaders","aggregate","clientCtx","objectType","objectSet","type","req","body","aggregation","$select","groupBy","where","undefined","$groupBy","$where","result","OntologyObjectSets","ontologyRid","data","length","aggregationToCountResult","ret","map","entry","$group","group","aggregateResult","metrics","name","$count","value"],"sources":["aggregate.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 * as OntologiesV2 from \"@osdk/internal.foundry.ontologiesv2\";\nimport invariant from \"tiny-invariant\";\nimport { legacyToModernSingleAggregationResult } from \"../internal/conversions/legacyToModernSingleAggregationResult.js\";\nimport { modernToLegacyAggregationClause } from \"../internal/conversions/modernToLegacyAggregationClause.js\";\nimport { modernToLegacyGroupByClause } from \"../internal/conversions/modernToLegacyGroupByClause.js\";\nimport { modernToLegacyWhereClause } from \"../internal/conversions/modernToLegacyWhereClause.js\";\nimport { addUserAgentAndRequestContextHeaders } from \"../util/addUserAgentAndRequestContextHeaders.js\";\n/** @internal */\nexport async function aggregate(clientCtx, objectType, objectSet = {\n type: \"base\",\n objectType: objectType[\"apiName\"],\n}, req) {\n const body = {\n aggregation: modernToLegacyAggregationClause(req.$select),\n groupBy: [],\n where: undefined,\n };\n if (req.$groupBy) {\n body.groupBy = modernToLegacyGroupByClause(req.$groupBy);\n }\n if (req.$where) {\n body.where = modernToLegacyWhereClause(req.$where, objectType);\n }\n const result = await OntologiesV2.OntologyObjectSets.aggregate(addUserAgentAndRequestContextHeaders(clientCtx, objectType), await clientCtx.ontologyRid, {\n objectSet,\n groupBy: body.groupBy,\n aggregation: body.aggregation,\n });\n if (!req.$groupBy) {\n invariant(result.data.length === 1, \"no group by clause should mean only one data result\");\n return {\n ...aggregationToCountResult(result.data[0]),\n ...legacyToModernSingleAggregationResult(result.data[0]),\n };\n }\n const ret = result.data\n .map((entry) => {\n return {\n $group: entry.group,\n ...aggregationToCountResult(entry),\n ...legacyToModernSingleAggregationResult(entry),\n };\n }); // fixme\n return ret; // FIXME\n}\nfunction aggregationToCountResult(entry) {\n for (const aggregateResult of entry.metrics) {\n if (aggregateResult.name === \"count\") {\n return { $count: aggregateResult.value };\n }\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,KAAKA,YAAY,MAAM,qCAAqC;AACnE,OAAOC,SAAS,MAAM,gBAAgB;AACtC,SAASC,qCAAqC,QAAQ,kEAAkE;AACxH,SAASC,+BAA+B,QAAQ,4DAA4D;AAC5G,SAASC,2BAA2B,QAAQ,wDAAwD;AACpG,SAASC,yBAAyB,QAAQ,sDAAsD;AAChG,SAASC,oCAAoC,QAAQ,iDAAiD;AACtG;AACA,OAAO,eAAeC,SAASA,CAACC,SAAS,EAAEC,UAAU,EAAEC,SAA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;IAClD,CAAC;EACL,CAAC,CAAC,CAAC,CAAC;EACJ,OAAOF,GAAG,CAAC,CAAC;AAChB;AACA,SAASD,wBAAwBA,CAACG,KAAK,EAAE;EACrC,KAAK,MAAMG,eAAe,IAAIH,KAAK,CAACI,OAAO,EAAE;IACzC,IAAID,eAAe,CAACE,IAAI,KAAK,OAAO,EAAE;MAClC,OAAO;QAAEC,MAAM,EAAEH,eAAe,CAACI;MAAM,CAAC;IAC5C;EACJ;AACJ","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ObjectOrInterfaceDefinition,
|
|
1
|
+
import type { ObjectOrInterfaceDefinition, OsdkBase } from "@osdk/api";
|
|
2
2
|
export declare const UnderlyingOsdkObject: unique symbol;
|
|
3
3
|
export declare const ObjectDefRef: unique symbol;
|
|
4
4
|
export declare const InterfaceDefRef: unique symbol;
|
|
@@ -6,7 +6,7 @@ export declare const InterfaceDefRef: unique symbol;
|
|
|
6
6
|
export declare const RawObject: unique symbol;
|
|
7
7
|
export declare const ClientRef: unique symbol;
|
|
8
8
|
export interface HolderBase<T extends ObjectOrInterfaceDefinition> {
|
|
9
|
-
[UnderlyingOsdkObject]:
|
|
9
|
+
[UnderlyingOsdkObject]: OsdkBase<any>;
|
|
10
10
|
[ObjectDefRef]?: T;
|
|
11
11
|
[InterfaceDefRef]?: T;
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalSymbols.d.ts","sourceRoot":"","sources":["../../../../src/object/convertWireToOsdkObjects/InternalSymbols.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,2BAA2B,EAAE,
|
|
1
|
+
{"version":3,"file":"InternalSymbols.d.ts","sourceRoot":"","sources":["../../../../src/object/convertWireToOsdkObjects/InternalSymbols.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,2BAA2B,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEvE,eAAO,MAAM,oBAAoB,eAEhC,CAAC;AAEF,eAAO,MAAM,YAAY,eAExB,CAAC;AAEF,eAAO,MAAM,eAAe,eAE3B,CAAC;AAEF,gGAAgG;AAChG,eAAO,MAAM,SAAS,eAErB,CAAC;AAEF,eAAO,MAAM,SAAS,eAErB,CAAC;AAEF,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,2BAA2B;IAC/D,CAAC,oBAAoB,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC;IACnB,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC;CACvB"}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { extractNamespace } from "../../internal/conversions/modernToLegacyWhereClause.js";
|
|
16
17
|
import { createSimpleCache } from "../SimpleCache.js";
|
|
17
18
|
import { InterfaceDefRef, ObjectDefRef, UnderlyingOsdkObject } from "./InternalSymbols.js";
|
|
18
19
|
const handlerCache = createSimpleCache(new WeakMap(), createInterfaceProxyHandler);
|
|
@@ -45,6 +46,13 @@ function createInterfaceProxyHandler(newDef) {
|
|
|
45
46
|
value: target[InterfaceDefRef].apiName
|
|
46
47
|
};
|
|
47
48
|
}
|
|
49
|
+
const [objApiNamespace] = extractNamespace(newDef.apiName);
|
|
50
|
+
if (objApiNamespace != null) {
|
|
51
|
+
const [apiNamespace, apiName] = extractNamespace(p);
|
|
52
|
+
if (apiNamespace == null) {
|
|
53
|
+
p = `${objApiNamespace}.${apiName}`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
48
56
|
if (newDef.properties[p] != null) {
|
|
49
57
|
return {
|
|
50
58
|
enumerable: true,
|
|
@@ -55,7 +63,18 @@ function createInterfaceProxyHandler(newDef) {
|
|
|
55
63
|
},
|
|
56
64
|
ownKeys(target) {
|
|
57
65
|
const underlying = target[UnderlyingOsdkObject];
|
|
58
|
-
|
|
66
|
+
const [objApiNamespace] = extractNamespace(newDef.apiName);
|
|
67
|
+
let propNames = Object.keys(newDef.properties);
|
|
68
|
+
if (objApiNamespace != null) {
|
|
69
|
+
propNames = propNames.map(p => {
|
|
70
|
+
const [apiNamespace, apiName] = extractNamespace(p);
|
|
71
|
+
if (apiNamespace === objApiNamespace) {
|
|
72
|
+
p = apiName;
|
|
73
|
+
}
|
|
74
|
+
return p;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return ["$apiName", "$objectType", "$primaryKey", ...(underlying["$rid"] ? ["$rid"] : []), "$title", ...propNames];
|
|
59
78
|
},
|
|
60
79
|
get(target, p) {
|
|
61
80
|
const underlying = target[UnderlyingOsdkObject];
|
|
@@ -72,6 +91,13 @@ function createInterfaceProxyHandler(newDef) {
|
|
|
72
91
|
case "$rid":
|
|
73
92
|
return underlying[p];
|
|
74
93
|
}
|
|
94
|
+
const [objApiNamespace] = extractNamespace(newDef.apiName);
|
|
95
|
+
if (objApiNamespace != null) {
|
|
96
|
+
const [apiNamespace, apiName] = extractNamespace(p);
|
|
97
|
+
if (apiNamespace == null) {
|
|
98
|
+
p = `${objApiNamespace}.${apiName}`;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
75
101
|
if (newDef.properties[p] != null) {
|
|
76
102
|
const objDef = target[UnderlyingOsdkObject][ObjectDefRef];
|
|
77
103
|
return underlying[objDef.interfaceMap[newDef.apiName][p]];
|
|
@@ -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,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,OAAOK,UAAU,CAACS,CAAC,CAAC;MAC5B;MACA,MAAM,CAACQ,eAAe,CAAC,GAAG1B,gBAAgB,CAACe,MAAM,CAACU,OAAO,CAAC;MAC1D,IAAIC,eAAe,IAAI,IAAI,EAAE;QACzB,MAAM,CAACC,YAAY,EAAEF,OAAO,CAAC,GAAGzB,gBAAgB,CAACkB,CAAC,CAAC;QACnD,IAAIS,YAAY,IAAI,IAAI,EAAE;UACtBT,CAAC,GAAG,GAAGQ,eAAe,IAAID,OAAO,EAAE;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,mB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;AACA;AACA;AACA,KAAK,CAAC;EACF,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOsdkObject.js","names":["createAttachmentFromRid","TimeSeriesPropertyImpl","createClientCache","get$as","get$link","ClientRef","ObjectDefRef","RawObject","UnderlyingOsdkObject","objectPrototypeCache","client","objectDef","Object","create","value","get","newValues","assign","createOsdkObject","rawObj","objectHolderPrototype","writable","holder","osdkObject","Proxy","ownKeys","target","Reflect","p","receiver","rawValue","propDef","properties","type","Array","isArray","map","a","rid","apiName","primaryKeyApiName","set","newValue","getOwnPropertyDescriptor","configurable","enumerable"],"sources":["createOsdkObject.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 { createAttachmentFromRid } from \"../../createAttachmentFromRid.js\";\nimport { TimeSeriesPropertyImpl } from \"../../createTimeseriesProperty.js\";\nimport { createClientCache } from \"../Cache.js\";\nimport { get$as } from \"./getDollarAs.js\";\nimport { get$link } from \"./getDollarLink.js\";\nimport { ClientRef, ObjectDefRef, RawObject, UnderlyingOsdkObject, } from \"./InternalSymbols.js\";\nconst objectPrototypeCache = createClientCache(function (client, objectDef) {\n return Object.create(null, {\n [ObjectDefRef]: { value: objectDef },\n [ClientRef]: { value: client },\n \"$as\": { value: get$as(objectDef) },\n \"$link\": {\n get: function () {\n return get$link(this);\n },\n },\n \"$updateInternalValues\": {\n value: function (newValues) {\n this[RawObject] = Object.assign({}, this[RawObject], newValues);\n },\n },\n });\n});\n/** @internal */\nexport function createOsdkObject(client, objectDef, rawObj) {\n // We use multiple layers of prototypes to maximize reuse and also to keep\n // [RawObject] out of `ownKeys`. This keeps the code in the proxy below simpler.\n const objectHolderPrototype = Object.create(objectPrototypeCache.get(client, objectDef), {\n [RawObject]: {\n value: rawObj,\n writable: true, // so we can allow updates\n },\n });\n // we separate the holder out so we can update\n // the underlying data without having to return a new object\n // we also need the holder so we can customize the console.log output\n const holder = Object.create(objectHolderPrototype);\n const osdkObject = new Proxy(holder, {\n ownKeys(target) {\n return Reflect.ownKeys(target[RawObject]);\n },\n get(target, p, receiver) {\n switch (p) {\n case UnderlyingOsdkObject:\n // effectively point back to the proxy\n return receiver;\n }\n if (p in target)\n return target[p];\n if (p in rawObj) {\n const rawValue = target[RawObject][p];\n const propDef = objectDef.properties[p];\n if (propDef) {\n if (propDef.type === \"attachment\") {\n if (Array.isArray(rawValue)) {\n return rawValue.map(a => createAttachmentFromRid(client, a.rid));\n }\n return createAttachmentFromRid(client, rawValue.rid);\n }\n if (propDef.type === \"numericTimeseries\"\n || propDef.type === \"stringTimeseries\") {\n return new TimeSeriesPropertyImpl(client, objectDef.apiName, target[RawObject][objectDef.primaryKeyApiName], p);\n }\n }\n return rawValue;\n }\n // we do not do any fall through to avoid unexpected behavior\n },\n set(target, p, newValue) {\n // allow the prototype to update this value\n if (p === RawObject) {\n // symbol only exists internally so no one else can hit this\n target[p] = newValue;\n return true;\n }\n return false;\n },\n getOwnPropertyDescriptor(target, p) {\n if (p === RawObject) {\n return Reflect.getOwnPropertyDescriptor(target, p);\n }\n if (target[RawObject][p] != null) {\n return { configurable: true, enumerable: true };\n }\n return
|
|
1
|
+
{"version":3,"file":"createOsdkObject.js","names":["createAttachmentFromRid","TimeSeriesPropertyImpl","createClientCache","get$as","get$link","ClientRef","ObjectDefRef","RawObject","UnderlyingOsdkObject","objectPrototypeCache","client","objectDef","Object","create","value","get","newValues","assign","createOsdkObject","rawObj","objectHolderPrototype","writable","holder","osdkObject","Proxy","ownKeys","target","Reflect","p","receiver","rawValue","propDef","properties","type","Array","isArray","map","a","rid","apiName","primaryKeyApiName","set","newValue","getOwnPropertyDescriptor","configurable","enumerable","undefined"],"sources":["createOsdkObject.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 { createAttachmentFromRid } from \"../../createAttachmentFromRid.js\";\nimport { TimeSeriesPropertyImpl } from \"../../createTimeseriesProperty.js\";\nimport { createClientCache } from \"../Cache.js\";\nimport { get$as } from \"./getDollarAs.js\";\nimport { get$link } from \"./getDollarLink.js\";\nimport { ClientRef, ObjectDefRef, RawObject, UnderlyingOsdkObject, } from \"./InternalSymbols.js\";\nconst objectPrototypeCache = createClientCache(function (client, objectDef) {\n return Object.create(null, {\n [ObjectDefRef]: { value: objectDef },\n [ClientRef]: { value: client },\n \"$as\": { value: get$as(objectDef) },\n \"$link\": {\n get: function () {\n return get$link(this);\n },\n },\n \"$updateInternalValues\": {\n value: function (newValues) {\n this[RawObject] = Object.assign({}, this[RawObject], newValues);\n },\n },\n });\n});\n/** @internal */\nexport function createOsdkObject(client, objectDef, rawObj) {\n // We use multiple layers of prototypes to maximize reuse and also to keep\n // [RawObject] out of `ownKeys`. This keeps the code in the proxy below simpler.\n const objectHolderPrototype = Object.create(objectPrototypeCache.get(client, objectDef), {\n [RawObject]: {\n value: rawObj,\n writable: true, // so we can allow updates\n },\n });\n // we separate the holder out so we can update\n // the underlying data without having to return a new object\n // we also need the holder so we can customize the console.log output\n const holder = Object.create(objectHolderPrototype);\n const osdkObject = new Proxy(holder, {\n ownKeys(target) {\n return Reflect.ownKeys(target[RawObject]);\n },\n get(target, p, receiver) {\n switch (p) {\n case UnderlyingOsdkObject:\n // effectively point back to the proxy\n return receiver;\n }\n if (p in target)\n return target[p];\n if (p in rawObj) {\n const rawValue = target[RawObject][p];\n const propDef = objectDef.properties[p];\n if (propDef) {\n if (propDef.type === \"attachment\") {\n if (Array.isArray(rawValue)) {\n return rawValue.map(a => createAttachmentFromRid(client, a.rid));\n }\n return createAttachmentFromRid(client, rawValue.rid);\n }\n if (propDef.type === \"numericTimeseries\"\n || propDef.type === \"stringTimeseries\") {\n return new TimeSeriesPropertyImpl(client, objectDef.apiName, target[RawObject][objectDef.primaryKeyApiName], p);\n }\n }\n return rawValue;\n }\n // we do not do any fall through to avoid unexpected behavior\n },\n set(target, p, newValue) {\n // allow the prototype to update this value\n if (p === RawObject) {\n // symbol only exists internally so no one else can hit this\n target[p] = newValue;\n return true;\n }\n return false;\n },\n getOwnPropertyDescriptor(target, p) {\n if (p === RawObject) {\n return Reflect.getOwnPropertyDescriptor(target, p);\n }\n if (target[RawObject][p] != null) {\n return { configurable: true, enumerable: true };\n }\n return undefined;\n },\n });\n return osdkObject;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,uBAAuB,QAAQ,kCAAkC;AAC1E,SAASC,sBAAsB,QAAQ,mCAAmC;AAC1E,SAASC,iBAAiB,QAAQ,aAAa;AAC/C,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,SAAS,EAAEC,YAAY,EAAEC,SAAS,EAAEC,oBAAoB,QAAS,sBAAsB;AAChG,MAAMC,oBAAoB,GAAGP,iBAAiB,CAAC,UAAUQ,MAAM,EAAEC,SAAS,EAAE;EACxE,OAAOC,MAAM,CAACC,MAAM,CAAC,IAAI,EAAE;IACvB,CAACP,YAAY,GAAG;MAAEQ,KAAK,EAAEH;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AAI,IAAI,EAAE;QAC9B,OAAO;UAAEgB,YAAY,EAAE,IAAI;UAAEC,UAAU,EAAE;QAAK,CAAC;MACnD;MACA,OAAOC,SAAS;IACpB;EACJ,CAAC,CAAC;EACF,OAAOvB,UAAU;AACrB","ignoreList":[]}
|
|
@@ -34,10 +34,34 @@ describe("convertWireToOsdkObjects", () => {
|
|
|
34
34
|
const {
|
|
35
35
|
data: [employee]
|
|
36
36
|
} = await client(Employee).fetchPage();
|
|
37
|
-
expect(Object.keys(employee).sort()).toEqual(["employeeId", "fullName", "office", "class", "startDate", "employeeStatus", "$apiName", "$objectType", "$primaryKey"
|
|
37
|
+
expect(Object.keys(employee).sort()).toEqual(["employeeId", "fullName", "office", "class", "startDate", "employeeStatus", "$apiName", "$objectType", "$primaryKey"].sort());
|
|
38
38
|
expect(Object.keys(employee.$as)).toEqual([]);
|
|
39
39
|
expect(Object.keys(employee.$link)).toEqual(["peeps", "lead", "officeLink"]);
|
|
40
40
|
});
|
|
41
|
+
it("stringifies properties on objects and interfaces correctly", async () => {
|
|
42
|
+
const {
|
|
43
|
+
data: [employee]
|
|
44
|
+
} = await client(Employee).fetchPage();
|
|
45
|
+
const {
|
|
46
|
+
data: [employee2]
|
|
47
|
+
} = await client(Employee).where({
|
|
48
|
+
$and: [{
|
|
49
|
+
employeeId: {
|
|
50
|
+
$gt: 50030
|
|
51
|
+
}
|
|
52
|
+
}, {
|
|
53
|
+
employeeId: {
|
|
54
|
+
$lt: 50032
|
|
55
|
+
}
|
|
56
|
+
}]
|
|
57
|
+
}).fetchPage();
|
|
58
|
+
// Should not have $title
|
|
59
|
+
expect(JSON.stringify(employee)).toMatchInlineSnapshot(`"{"employeeId":50030,"fullName":"John Doe","office":"NYC","class":"Red","startDate":"2019-01-01","employeeStatus":{},"$apiName":"Employee","$objectType":"Employee","$primaryKey":50030}"`);
|
|
60
|
+
expect(JSON.stringify(employee.$as(FooInterface))).toMatchInlineSnapshot(`"{"$apiName":"FooInterface","$objectType":"Employee","$primaryKey":50030,"fooSpt":"John Doe"}"`);
|
|
61
|
+
// Should have $title
|
|
62
|
+
expect(JSON.stringify(employee2)).toMatchInlineSnapshot(`"{"employeeId":50031,"fullName":"Jane Doe","office":"SEA","class":"Blue","startDate":"2012-02-12","employeeStatus":{},"$apiName":"Employee","$objectType":"Employee","$primaryKey":50031,"$title":"Jane Doe"}"`);
|
|
63
|
+
expect(JSON.stringify(employee2.$as(FooInterface))).toMatchInlineSnapshot(`"{"$apiName":"FooInterface","$objectType":"Employee","$primaryKey":50031,"$title":"Jane Doe","fooSpt":"Jane Doe"}"`);
|
|
64
|
+
});
|
|
41
65
|
it("reuses the object prototype across objects", async () => {
|
|
42
66
|
const employees = await client(Employee).fetchPage();
|
|
43
67
|
expect(employees.data.length).toBeGreaterThanOrEqual(2);
|