@osdk/client 2.2.0-beta.6 → 2.2.0-beta.8
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 +43 -0
- package/build/browser/Client.js.map +1 -1
- package/build/browser/actions/actions.test.js +52 -4
- package/build/browser/actions/actions.test.js.map +1 -1
- package/build/browser/actions/applyAction.js +21 -15
- package/build/browser/actions/applyAction.js.map +1 -1
- package/build/browser/createClient.js +11 -4
- package/build/browser/createClient.js.map +1 -1
- package/build/browser/index.js +1 -0
- package/build/browser/index.js.map +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +25 -0
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.js +8 -1
- package/build/browser/object/convertWireToOsdkObjects.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.test.js +7 -3
- package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/browser/object/createObjectSpecifierFromPrimaryKey.js +20 -0
- package/build/browser/object/createObjectSpecifierFromPrimaryKey.js.map +1 -0
- package/build/browser/object/object.test.js +109 -0
- package/build/browser/object/object.test.js.map +1 -1
- package/build/browser/objectSet/ObjectSet.test.js +15 -1
- package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js +2 -0
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/browser/observable/internal/Store.js +1 -1
- package/build/browser/observable/internal/Store.js.map +1 -1
- package/build/browser/observable/internal/testUtils.js +2 -0
- package/build/browser/observable/internal/testUtils.js.map +1 -1
- package/build/browser/queries/applyQuery.js +33 -1
- package/build/browser/queries/applyQuery.js.map +1 -1
- package/build/browser/queries/queries.test.js +26 -5
- package/build/browser/queries/queries.test.js.map +1 -1
- package/build/browser/util/UserAgent.js +1 -1
- package/build/browser/util/toDataValueQueries.js +17 -0
- package/build/browser/util/toDataValueQueries.js.map +1 -1
- package/build/cjs/{Client-C8K3E1vH.d.cts → Client-DBTcM9gB.d.cts} +1 -1
- package/build/cjs/{chunk-2FVV5A63.cjs → chunk-IU47QMYO.cjs} +48 -48
- package/build/cjs/chunk-IU47QMYO.cjs.map +1 -0
- package/build/cjs/{chunk-X7WGNFZ4.cjs → chunk-JPENHIJB.cjs} +19 -19
- package/build/cjs/chunk-JPENHIJB.cjs.map +1 -0
- package/build/cjs/{graphql-JJX5MZPQ.cjs → graphql-RGM5SRWV.cjs} +306 -265
- package/build/cjs/graphql-RGM5SRWV.cjs.map +1 -0
- package/build/cjs/index.cjs +192 -102
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +6 -4
- package/build/cjs/public/internal.cjs +6 -6
- package/build/cjs/public/internal.cjs.map +1 -1
- package/build/cjs/public/internal.d.cts +1 -1
- package/build/cjs/public/unstable-do-not-use.cjs +41 -70
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +1 -1
- package/build/esm/Client.js.map +1 -1
- package/build/esm/actions/actions.test.js +52 -4
- package/build/esm/actions/actions.test.js.map +1 -1
- package/build/esm/actions/applyAction.js +21 -15
- package/build/esm/actions/applyAction.js.map +1 -1
- package/build/esm/createClient.js +11 -4
- package/build/esm/createClient.js.map +1 -1
- package/build/esm/index.js +1 -0
- package/build/esm/index.js.map +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +25 -0
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.js +8 -1
- package/build/esm/object/convertWireToOsdkObjects.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.test.js +7 -3
- package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/esm/object/createObjectSpecifierFromPrimaryKey.js +20 -0
- package/build/esm/object/createObjectSpecifierFromPrimaryKey.js.map +1 -0
- package/build/esm/object/object.test.js +109 -0
- package/build/esm/object/object.test.js.map +1 -1
- package/build/esm/objectSet/ObjectSet.test.js +15 -1
- package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js +2 -0
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/esm/observable/internal/Store.js +1 -1
- package/build/esm/observable/internal/Store.js.map +1 -1
- package/build/esm/observable/internal/testUtils.js +2 -0
- package/build/esm/observable/internal/testUtils.js.map +1 -1
- package/build/esm/queries/applyQuery.js +33 -1
- package/build/esm/queries/applyQuery.js.map +1 -1
- package/build/esm/queries/queries.test.js +26 -5
- package/build/esm/queries/queries.test.js.map +1 -1
- package/build/esm/util/UserAgent.js +1 -1
- package/build/esm/util/toDataValueQueries.js +17 -0
- package/build/esm/util/toDataValueQueries.js.map +1 -1
- package/build/types/Client.d.ts +1 -1
- package/build/types/Client.d.ts.map +1 -1
- package/build/types/actions/applyAction.d.ts.map +1 -1
- package/build/types/createClient.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/object/createObjectSpecifierFromPrimaryKey.d.ts +2 -0
- package/build/types/object/createObjectSpecifierFromPrimaryKey.d.ts.map +1 -0
- package/build/types/object/object.test.d.ts.map +1 -1
- package/build/types/objectSet/ObjectSet.test.d.ts.map +1 -1
- package/build/types/observable/internal/testUtils.d.ts.map +1 -1
- package/build/types/queries/applyQuery.d.ts.map +1 -1
- package/package.json +12 -12
- package/build/cjs/chunk-2FVV5A63.cjs.map +0 -1
- package/build/cjs/chunk-X7WGNFZ4.cjs.map +0 -1
- package/build/cjs/graphql-JJX5MZPQ.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["isOk","PalantirApiError","ActionValidationError","createClient","createPlatformClient","createAttachmentUpload","extractDate","extractDateInLocalTime","extractDateInUTC"],"sources":["index.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type {\n ActionDefinition,\n ActionEditResponse,\n ActionMetadata,\n ActionParam,\n ActionReturnTypeForOptions,\n ActionValidationResponse,\n ApplyActionOptions,\n ApplyBatchActionOptions,\n InterfaceDefinition,\n ObjectMetadata,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n OsdkObject,\n PageResult,\n PropertyDef,\n PropertyKeys,\n PropertyValueWireToClient,\n QueryDefinition,\n QueryParam,\n QueryResult,\n Result,\n SingleLinkAccessor,\n VersionBound,\n WhereClause,\n} from \"@osdk/api\";\nexport { isOk } from \"@osdk/api\";\nexport { PalantirApiError } from \"@osdk/shared.net.errors\";\n\nexport { ActionValidationError } from \"./actions/ActionValidationError.js\";\nexport type { Client } from \"./Client.js\";\nexport { createClient } from \"./createClient.js\";\nexport { createPlatformClient } from \"./createPlatformClient.js\";\nexport type { PlatformClient } from \"./createPlatformClient.js\";\nexport type { Logger } from \"./Logger.js\";\nexport { createAttachmentUpload } from \"./object/AttachmentUpload.js\";\nexport type { ResultOrError } from \"./ResultOrError.js\";\n\nexport {\n extractDate,\n extractDateInLocalTime,\n extractDateInUTC,\n} from \"./util/datetimeConverters.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;
|
|
1
|
+
{"version":3,"file":"index.js","names":["isOk","PalantirApiError","ActionValidationError","createClient","createPlatformClient","createAttachmentUpload","createObjectSpecifierFromPrimaryKey","extractDate","extractDateInLocalTime","extractDateInUTC"],"sources":["index.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type {\n ActionDefinition,\n ActionEditResponse,\n ActionMetadata,\n ActionParam,\n ActionReturnTypeForOptions,\n ActionValidationResponse,\n ApplyActionOptions,\n ApplyBatchActionOptions,\n InterfaceDefinition,\n ObjectMetadata,\n ObjectSet,\n ObjectSpecifier,\n ObjectTypeDefinition,\n Osdk,\n OsdkObject,\n PageResult,\n PropertyDef,\n PropertyKeys,\n PropertyValueWireToClient,\n QueryDefinition,\n QueryParam,\n QueryResult,\n Result,\n SingleLinkAccessor,\n VersionBound,\n WhereClause,\n} from \"@osdk/api\";\nexport { isOk } from \"@osdk/api\";\nexport { PalantirApiError } from \"@osdk/shared.net.errors\";\n\nexport { ActionValidationError } from \"./actions/ActionValidationError.js\";\nexport type { Client } from \"./Client.js\";\nexport { createClient } from \"./createClient.js\";\nexport { createPlatformClient } from \"./createPlatformClient.js\";\nexport type { PlatformClient } from \"./createPlatformClient.js\";\nexport type { Logger } from \"./Logger.js\";\nexport { createAttachmentUpload } from \"./object/AttachmentUpload.js\";\nexport { createObjectSpecifierFromPrimaryKey } from \"./object/createObjectSpecifierFromPrimaryKey.js\";\nexport type { ResultOrError } from \"./ResultOrError.js\";\n\nexport {\n extractDate,\n extractDateInLocalTime,\n extractDateInUTC,\n} from \"./util/datetimeConverters.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA8BA,SAASA,IAAI,QAAQ,WAAW;AAChC,SAASC,gBAAgB,QAAQ,yBAAyB;AAE1D,SAASC,qBAAqB,QAAQ,oCAAoC;AAE1E,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAASC,oBAAoB,QAAQ,2BAA2B;AAGhE,SAASC,sBAAsB,QAAQ,8BAA8B;AACrE,SAASC,mCAAmC,QAAQ,iDAAiD;AAGrG,SACEC,WAAW,EACXC,sBAAsB,EACtBC,gBAAgB,QACX,8BAA8B","ignoreList":[]}
|
|
@@ -109,7 +109,7 @@ function handleWherePair([fieldName, filter], objectOrInterface, structFieldSele
|
|
|
109
109
|
// If any of the keys start with `$` then they must be the only one.
|
|
110
110
|
// e.g. `where({ name: { $eq: "foo", $ne: "bar" } })` is invalid currently
|
|
111
111
|
const hasDollarSign = keysOfFilter.some(key => key.startsWith("$"));
|
|
112
|
-
!(!hasDollarSign || keysOfFilter.length === 1) ? process.env.NODE_ENV !== "production" ? invariant(false, "WhereClause Filter with multiple clauses
|
|
112
|
+
!(!hasDollarSign || keysOfFilter.length === 1) ? process.env.NODE_ENV !== "production" ? invariant(false, "A WhereClause Filter with multiple clauses/fields is not allowed. Instead, use an 'or'/'and' clause to combine multiple filters.") : invariant(false) : void 0;
|
|
113
113
|
if (!hasDollarSign) {
|
|
114
114
|
const structFilter = Object.entries(filter);
|
|
115
115
|
!(structFilter.length === 1) ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot filter on more than one struct field in the same clause, need to use an and clause") : invariant(false) : void 0;
|
|
@@ -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","parts","Object","entries","length","handleWherePair","v","makeGeoFilterBbox","bbox","filterType","propertyIdentifier","field","topLeft","coordinates","bottomRight","makeGeoFilterPolygon","fieldName","filter","structFieldSelector","process","env","NODE_ENV","propertyApiName","fullyQualifyPropName","keysOfFilter","keys","hasDollarSign","some","key","startsWith","structFilter","structFieldApiName","firstKey","withinBody","Array","isArray","$bbox","$distance","$of","center","distance","unit","$polygon","intersectsBody","substring","fuzzy","objApiNamespace","apiName","fieldApiNamespace","fieldShortName"],"sources":["modernToLegacyWhereClause.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n GeoFilterOptions,\n ObjectOrInterfaceDefinition,\n PossibleWhereClauseFilters,\n WhereClause,\n} from \"@osdk/api\";\nimport { DistanceUnitMapping } from \"@osdk/api\";\n\nimport type {\n PropertyIdentifier,\n SearchJsonQueryV2,\n} from \"@osdk/foundry.ontologies\";\nimport type { BBox, Position } from \"geojson\";\nimport invariant from \"tiny-invariant\";\n\nexport function extractNamespace(\n fqApiName: string,\n): [string | undefined, string] {\n const last = fqApiName.lastIndexOf(\".\");\n if (last === -1) return [undefined, fqApiName];\n return [fqApiName.slice(0, last), fqApiName.slice(last + 1)];\n}\n\n/** @internal */\nexport function modernToLegacyWhereClause<\n T extends ObjectOrInterfaceDefinition,\n>(\n whereClause: WhereClause<T>,\n objectOrInterface: T,\n): SearchJsonQueryV2 {\n if (\"$and\" in whereClause) {\n return {\n type: \"and\",\n value: (whereClause.$and as WhereClause<T>[]).map(\n (clause) => modernToLegacyWhereClause(clause, objectOrInterface),\n ),\n };\n } else if (\"$or\" in whereClause) {\n return {\n type: \"or\",\n value: (whereClause.$or as WhereClause<T>[]).map(\n (clause) => modernToLegacyWhereClause(clause, objectOrInterface),\n ),\n };\n } else if (\"$not\" in whereClause) {\n return {\n type: \"not\",\n value: modernToLegacyWhereClause(\n whereClause.$not as WhereClause<T>,\n objectOrInterface,\n ),\n };\n }\n\n const parts = Object.entries(whereClause);\n\n if (parts.length === 1) {\n return handleWherePair(parts[0], objectOrInterface);\n }\n\n return {\n type: \"and\",\n value: parts.map<SearchJsonQueryV2>(\n v => handleWherePair(v, objectOrInterface),\n ),\n };\n}\n\nfunction makeGeoFilterBbox(\n bbox: BBox,\n filterType: \"$within\" | \"$intersects\",\n propertyIdentifier?: PropertyIdentifier,\n field?: string,\n): SearchJsonQueryV2 {\n return {\n type: filterType === \"$within\"\n ? \"withinBoundingBox\"\n : \"intersectsBoundingBox\",\n /**\n * This is a bit ugly, but did this so that propertyIdentifier only shows up in the return object if its defined,\n * this makes it so we don't need to go update our entire test bed either to include a field which may change in near future.\n * Once we solidify that this is the way forward, I can remove field and clean this up\n */\n ...(propertyIdentifier != null && { propertyIdentifier }),\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}\n\nfunction makeGeoFilterPolygon(\n coordinates: Position[][],\n filterType: \"intersectsPolygon\" | \"withinPolygon\",\n propertyIdentifier?: PropertyIdentifier,\n field?: string,\n): SearchJsonQueryV2 {\n return {\n type: filterType,\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n value: {\n type: \"Polygon\",\n coordinates,\n },\n };\n}\n\nfunction handleWherePair(\n [fieldName, filter]: [string, any],\n objectOrInterface: ObjectOrInterfaceDefinition,\n structFieldSelector?: { propertyApiName: string; structFieldApiName: string },\n): SearchJsonQueryV2 {\n invariant(\n filter != null,\n \"Defined key values are only allowed when they are not undefined.\",\n );\n\n const propertyIdentifier: PropertyIdentifier | undefined =\n structFieldSelector != null\n ? {\n type: \"structField\",\n ...structFieldSelector,\n propertyApiName: fullyQualifyPropName(\n structFieldSelector.propertyApiName,\n objectOrInterface,\n ),\n }\n : undefined;\n const field = structFieldSelector == null\n ? fullyQualifyPropName(fieldName, objectOrInterface)\n : undefined;\n\n if (\n typeof filter === \"string\" || typeof filter === \"number\"\n || typeof filter === \"boolean\"\n ) {\n propertyIdentifier;\n return {\n type: \"eq\",\n ...(propertyIdentifier != null\n && { propertyIdentifier }),\n field,\n value: filter,\n };\n }\n\n const keysOfFilter = Object.keys(filter);\n\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(\n !hasDollarSign\n || keysOfFilter.length === 1,\n \"WhereClause Filter with multiple clauses isn't allowed\",\n );\n\n if (!hasDollarSign) {\n const structFilter = Object.entries(filter);\n invariant(\n structFilter.length === 1,\n \"Cannot filter on more than one struct field in the same clause, need to use an and clause\",\n );\n const structFieldApiName = keysOfFilter[0];\n return handleWherePair(Object.entries(filter)[0], objectOrInterface, {\n propertyApiName: fieldName,\n structFieldApiName,\n });\n }\n\n const firstKey = keysOfFilter[0] as PossibleWhereClauseFilters;\n invariant(filter[firstKey] != null);\n\n if (firstKey === \"$ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n value: filter[firstKey],\n },\n };\n }\n\n if (firstKey === \"$within\") {\n const withinBody = filter[firstKey] as GeoFilterOptions[\"$within\"];\n\n if (Array.isArray(withinBody)) {\n return makeGeoFilterBbox(withinBody, firstKey, propertyIdentifier, field);\n } else if (\"$bbox\" in withinBody && withinBody.$bbox != null) {\n return makeGeoFilterBbox(\n withinBody.$bbox,\n firstKey,\n propertyIdentifier,\n field,\n );\n } else if (\n (\"$distance\" in withinBody && \"$of\" in withinBody)\n && withinBody.$distance != null\n && withinBody.$of != null\n ) {\n return {\n type: \"withinDistanceOf\",\n ...(propertyIdentifier != null && { propertyIdentifier }),\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 } else {\n const coordinates = (\"$polygon\" in withinBody)\n ? withinBody.$polygon\n : withinBody.coordinates;\n return makeGeoFilterPolygon(\n coordinates,\n \"withinPolygon\",\n propertyIdentifier,\n fieldName,\n );\n }\n }\n if (firstKey === \"$intersects\") {\n const intersectsBody = filter[firstKey] as GeoFilterOptions[\"$intersects\"];\n if (Array.isArray(intersectsBody)) {\n return makeGeoFilterBbox(\n intersectsBody,\n firstKey,\n propertyIdentifier,\n field,\n );\n } else if (\"$bbox\" in intersectsBody && intersectsBody.$bbox != null) {\n return makeGeoFilterBbox(\n intersectsBody.$bbox,\n firstKey,\n propertyIdentifier,\n field,\n );\n } else {\n const coordinates = (\"$polygon\" in intersectsBody)\n ? intersectsBody.$polygon\n : intersectsBody.coordinates;\n return makeGeoFilterPolygon(\n coordinates,\n \"intersectsPolygon\",\n propertyIdentifier,\n field,\n );\n }\n }\n\n if (firstKey === \"$containsAllTerms\" || firstKey === \"$containsAnyTerm\") {\n return {\n type: firstKey.substring(1) as DropDollarSign<typeof firstKey>,\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n value: typeof filter[firstKey] === \"string\"\n ? filter[firstKey]\n : filter[firstKey][\"term\"],\n fuzzy: typeof filter[firstKey] === \"string\"\n ? false\n : filter[firstKey][\"fuzzySearch\"] ?? false,\n };\n }\n\n return {\n type: firstKey.substring(1) as DropDollarSign<typeof firstKey>,\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n value: filter[firstKey] as any,\n };\n}\n\ntype DropDollarSign<T extends `$${string}`> = T extends `$${infer U}` ? U\n : never;\n\nfunction fullyQualifyPropName(\n fieldName: string,\n objectOrInterface: ObjectOrInterfaceDefinition,\n) {\n if (objectOrInterface.type === \"interface\") {\n const [objApiNamespace] = extractNamespace(objectOrInterface.apiName);\n const [fieldApiNamespace, fieldShortName] = extractNamespace(fieldName);\n return (fieldApiNamespace == null && objApiNamespace != null)\n ? `${objApiNamespace}.${fieldShortName}`\n : fieldName;\n }\n return fieldName;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAASA,mBAAmB,QAAQ,WAAW;AAO/C,OAAOC,SAAS,MAAM,gBAAgB;AAEtC,OAAO,SAASC,gBAAgBA,CAC9BC,SAAiB,EACa;EAC9B,MAAMC,IAAI,GAAGD,SAAS,CAACE,WAAW,CAAC,GAAG,CAAC;EACvC,IAAID,IAAI,KAAK,CAAC,CAAC,EAAE,OAAO,CAACE,SAAS,EAAEH,SAAS,CAAC;EAC9C,OAAO,CAACA,SAAS,CAACI,KAAK,CAAC,CAAC,EAAEH,IAAI,CAAC,EAAED,SAAS,CAACI,KAAK,CAACH,IAAI,GAAG,CAAC,CAAC,CAAC;AAC9D;;AAEA;AACA,OAAO,SAASI,yBAAyBA,CAGvCC,WAA2B,EAC3BC,iBAAoB,EACD;EACnB,IAAI,MAAM,IAAID,WAAW,EAAE;IACzB,OAAO;MACLE,IAAI,EAAE,KAAK;MACXC,KAAK,EAAGH,WAAW,CAACI,IAAI,CAAsBC,GAAG,CAC9CC,MAAM,IAAKP,yBAAyB,CAACO,MAAM,EAAEL,iBAAiB,CACjE;IACF,CAAC;EACH,CAAC,MAAM,IAAI,KAAK,IAAID,WAAW,EAAE;IAC/B,OAAO;MACLE,IAAI,EAAE,IAAI;MACVC,KAAK,EAAGH,WAAW,CAACO,GAAG,CAAsBF,GAAG,CAC7CC,MAAM,IAAKP,yBA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AAM,CAACoD,eAAe,CAAC,GAAG7D,gBAAgB,CAACQ,iBAAiB,CAACsD,OAAO,CAAC;IACrE,MAAM,CAACC,iBAAiB,EAAEC,cAAc,CAAC,GAAGhE,gBAAgB,CAAC+B,SAAS,CAAC;IACvE,OAAQgC,iBAAiB,IAAI,IAAI,IAAIF,eAAe,IAAI,IAAI,GACxD,GAAGA,eAAe,IAAIG,cAAc,EAAE,GACtCjC,SAAS;EACf;EACA,OAAOA,SAAS;AAClB","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","bbox","filterType","propertyIdentifier","field","topLeft","coordinates","bottomRight","makeGeoFilterPolygon","fieldName","filter","structFieldSelector","process","env","NODE_ENV","propertyApiName","fullyQualifyPropName","keysOfFilter","keys","hasDollarSign","some","key","startsWith","structFilter","structFieldApiName","firstKey","withinBody","Array","isArray","$bbox","$distance","$of","center","distance","unit","$polygon","intersectsBody","substring","fuzzy","objApiNamespace","apiName","fieldApiNamespace","fieldShortName"],"sources":["modernToLegacyWhereClause.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n GeoFilterOptions,\n ObjectOrInterfaceDefinition,\n PossibleWhereClauseFilters,\n WhereClause,\n} from \"@osdk/api\";\nimport { DistanceUnitMapping } from \"@osdk/api\";\n\nimport type {\n PropertyIdentifier,\n SearchJsonQueryV2,\n} from \"@osdk/foundry.ontologies\";\nimport type { BBox, Position } from \"geojson\";\nimport invariant from \"tiny-invariant\";\n\nexport function extractNamespace(\n fqApiName: string,\n): [string | undefined, string] {\n const last = fqApiName.lastIndexOf(\".\");\n if (last === -1) return [undefined, fqApiName];\n return [fqApiName.slice(0, last), fqApiName.slice(last + 1)];\n}\n\n/** @internal */\nexport function modernToLegacyWhereClause<\n T extends ObjectOrInterfaceDefinition,\n>(\n whereClause: WhereClause<T>,\n objectOrInterface: T,\n): SearchJsonQueryV2 {\n if (\"$and\" in whereClause) {\n return {\n type: \"and\",\n value: (whereClause.$and as WhereClause<T>[]).map(\n (clause) => modernToLegacyWhereClause(clause, objectOrInterface),\n ),\n };\n } else if (\"$or\" in whereClause) {\n return {\n type: \"or\",\n value: (whereClause.$or as WhereClause<T>[]).map(\n (clause) => modernToLegacyWhereClause(clause, objectOrInterface),\n ),\n };\n } else if (\"$not\" in whereClause) {\n return {\n type: \"not\",\n value: modernToLegacyWhereClause(\n whereClause.$not as WhereClause<T>,\n objectOrInterface,\n ),\n };\n }\n\n const parts = Object.entries(whereClause);\n\n if (parts.length === 1) {\n return handleWherePair(parts[0], objectOrInterface);\n }\n\n return {\n type: \"and\",\n value: parts.map<SearchJsonQueryV2>(\n v => handleWherePair(v, objectOrInterface),\n ),\n };\n}\n\nfunction makeGeoFilterBbox(\n bbox: BBox,\n filterType: \"$within\" | \"$intersects\",\n propertyIdentifier?: PropertyIdentifier,\n field?: string,\n): SearchJsonQueryV2 {\n return {\n type: filterType === \"$within\"\n ? \"withinBoundingBox\"\n : \"intersectsBoundingBox\",\n /**\n * This is a bit ugly, but did this so that propertyIdentifier only shows up in the return object if its defined,\n * this makes it so we don't need to go update our entire test bed either to include a field which may change in near future.\n * Once we solidify that this is the way forward, I can remove field and clean this up\n */\n ...(propertyIdentifier != null && { propertyIdentifier }),\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}\n\nfunction makeGeoFilterPolygon(\n coordinates: Position[][],\n filterType: \"intersectsPolygon\" | \"withinPolygon\",\n propertyIdentifier?: PropertyIdentifier,\n field?: string,\n): SearchJsonQueryV2 {\n return {\n type: filterType,\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n value: {\n type: \"Polygon\",\n coordinates,\n },\n };\n}\n\nfunction handleWherePair(\n [fieldName, filter]: [string, any],\n objectOrInterface: ObjectOrInterfaceDefinition,\n structFieldSelector?: { propertyApiName: string; structFieldApiName: string },\n): SearchJsonQueryV2 {\n invariant(\n filter != null,\n \"Defined key values are only allowed when they are not undefined.\",\n );\n\n const propertyIdentifier: PropertyIdentifier | undefined =\n structFieldSelector != null\n ? {\n type: \"structField\",\n ...structFieldSelector,\n propertyApiName: fullyQualifyPropName(\n structFieldSelector.propertyApiName,\n objectOrInterface,\n ),\n }\n : undefined;\n const field = structFieldSelector == null\n ? fullyQualifyPropName(fieldName, objectOrInterface)\n : undefined;\n\n if (\n typeof filter === \"string\" || typeof filter === \"number\"\n || typeof filter === \"boolean\"\n ) {\n propertyIdentifier;\n return {\n type: \"eq\",\n ...(propertyIdentifier != null\n && { propertyIdentifier }),\n field,\n value: filter,\n };\n }\n\n const keysOfFilter = Object.keys(filter);\n\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(\n !hasDollarSign\n || keysOfFilter.length === 1,\n \"A WhereClause Filter with multiple clauses/fields is not allowed. Instead, use an 'or'/'and' clause to combine multiple filters.\",\n );\n\n if (!hasDollarSign) {\n const structFilter = Object.entries(filter);\n invariant(\n structFilter.length === 1,\n \"Cannot filter on more than one struct field in the same clause, need to use an and clause\",\n );\n const structFieldApiName = keysOfFilter[0];\n return handleWherePair(Object.entries(filter)[0], objectOrInterface, {\n propertyApiName: fieldName,\n structFieldApiName,\n });\n }\n\n const firstKey = keysOfFilter[0] as PossibleWhereClauseFilters;\n invariant(filter[firstKey] != null);\n\n if (firstKey === \"$ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n value: filter[firstKey],\n },\n };\n }\n\n if (firstKey === \"$within\") {\n const withinBody = filter[firstKey] as GeoFilterOptions[\"$within\"];\n\n if (Array.isArray(withinBody)) {\n return makeGeoFilterBbox(withinBody, firstKey, propertyIdentifier, field);\n } else if (\"$bbox\" in withinBody && withinBody.$bbox != null) {\n return makeGeoFilterBbox(\n withinBody.$bbox,\n firstKey,\n propertyIdentifier,\n field,\n );\n } else if (\n (\"$distance\" in withinBody && \"$of\" in withinBody)\n && withinBody.$distance != null\n && withinBody.$of != null\n ) {\n return {\n type: \"withinDistanceOf\",\n ...(propertyIdentifier != null && { propertyIdentifier }),\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 } else {\n const coordinates = (\"$polygon\" in withinBody)\n ? withinBody.$polygon\n : withinBody.coordinates;\n return makeGeoFilterPolygon(\n coordinates,\n \"withinPolygon\",\n propertyIdentifier,\n fieldName,\n );\n }\n }\n if (firstKey === \"$intersects\") {\n const intersectsBody = filter[firstKey] as GeoFilterOptions[\"$intersects\"];\n if (Array.isArray(intersectsBody)) {\n return makeGeoFilterBbox(\n intersectsBody,\n firstKey,\n propertyIdentifier,\n field,\n );\n } else if (\"$bbox\" in intersectsBody && intersectsBody.$bbox != null) {\n return makeGeoFilterBbox(\n intersectsBody.$bbox,\n firstKey,\n propertyIdentifier,\n field,\n );\n } else {\n const coordinates = (\"$polygon\" in intersectsBody)\n ? intersectsBody.$polygon\n : intersectsBody.coordinates;\n return makeGeoFilterPolygon(\n coordinates,\n \"intersectsPolygon\",\n propertyIdentifier,\n field,\n );\n }\n }\n\n if (firstKey === \"$containsAllTerms\" || firstKey === \"$containsAnyTerm\") {\n return {\n type: firstKey.substring(1) as DropDollarSign<typeof firstKey>,\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n value: typeof filter[firstKey] === \"string\"\n ? filter[firstKey]\n : filter[firstKey][\"term\"],\n fuzzy: typeof filter[firstKey] === \"string\"\n ? false\n : filter[firstKey][\"fuzzySearch\"] ?? false,\n };\n }\n\n return {\n type: firstKey.substring(1) as DropDollarSign<typeof firstKey>,\n ...(propertyIdentifier != null && { propertyIdentifier }),\n field,\n value: filter[firstKey] as any,\n };\n}\n\ntype DropDollarSign<T extends `$${string}`> = T extends `$${infer U}` ? U\n : never;\n\nfunction fullyQualifyPropName(\n fieldName: string,\n objectOrInterface: ObjectOrInterfaceDefinition,\n) {\n if (objectOrInterface.type === \"interface\") {\n const [objApiNamespace] = extractNamespace(objectOrInterface.apiName);\n const [fieldApiNamespace, fieldShortName] = extractNamespace(fieldName);\n return (fieldApiNamespace == null && objApiNamespace != null)\n ? `${objApiNamespace}.${fieldShortName}`\n : fieldName;\n }\n return fieldName;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAASA,mBAAmB,QAAQ,WAAW;AAO/C,OAAOC,SAAS,MAAM,gBAAgB;AAEtC,OAAO,SAASC,gBAAgBA,CAC9BC,SAAiB,EACa;EAC9B,MAAMC,IAAI,GAAGD,SAAS,CAACE,WAAW,CAAC,GAAG,CAAC;EACvC,IAAID,IAAI,KAAK,CAAC,CAAC,EAAE,OAAO,CAACE,SAAS,EAAEH,SAAS,CAAC;EAC9C,OAAO,CAACA,SAAS,CAACI,KAAK,CAAC,CAAC,EAAEH,IAAI,CAAC,EAAED,SAAS,CAACI,KAAK,CAACH,IAAI,GAA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5B,MAAM,CAACe,QAAQ,CAAC,KAAK,QAAQ,GACvC,KAAK,GACLf,MAAM,CAACe,QAAQ,CAAC,CAAC,aAAa,CAAC,IAAI;IACzC,CAAC;EACH;EAEA,OAAO;IACLtC,IAAI,EAAEsC,QAAQ,CAACY,SAAS,CAAC,CAAC,CAAoC;IAC9D,IAAIlC,kBAAkB,IAAI,IAAI,IAAI;MAAEA;IAAmB,CAAC,CAAC;IACzDC,KAAK;IACLhB,KAAK,EAAEsB,MAAM,CAACe,QAAQ;EACxB,CAAC;AACH;AAKA,SAAST,oBAAoBA,CAC3BP,SAAiB,EACjBvB,iBAA8C,EAC9C;EACA,IAAIA,iBAAiB,CAACC,IAAI,KAAK,WAAW,EAAE;IAC1C,MAAM,CAACoD,eAAe,CAAC,GAAG7D,gBAAgB,CAACQ,iBAAiB,CAACsD,OAAO,CAAC;IACrE,MAAM,CAACC,iBAAiB,EAAEC,cAAc,CAAC,GAAGhE,gBAAgB,CAAC+B,SAAS,CAAC;IACvE,OAAQgC,iBAAiB,IAAI,IAAI,IAAIF,eAAe,IAAI,IAAI,GACxD,GAAGA,eAAe,IAAIG,cAAc,EAAE,GACtCjC,SAAS;EACf;EACA,OAAOA,SAAS;AAClB","ignoreList":[]}
|
|
@@ -48,6 +48,10 @@ export function createOsdkInterface(underlying, interfaceDef) {
|
|
|
48
48
|
value: underlying.$rid,
|
|
49
49
|
enumerable: "$rid" in underlying
|
|
50
50
|
},
|
|
51
|
+
"$clone": {
|
|
52
|
+
value: clone,
|
|
53
|
+
enumerable: false
|
|
54
|
+
},
|
|
51
55
|
[InterfaceDefRef]: {
|
|
52
56
|
value: interfaceDef
|
|
53
57
|
},
|
|
@@ -61,5 +65,26 @@ export function createOsdkInterface(underlying, interfaceDef) {
|
|
|
61
65
|
}];
|
|
62
66
|
}))
|
|
63
67
|
}));
|
|
68
|
+
function clone(update) {
|
|
69
|
+
if (update == null) {
|
|
70
|
+
return underlying.$clone().$as(interfaceDef);
|
|
71
|
+
}
|
|
72
|
+
for (const key of Object.keys(update)) {
|
|
73
|
+
if (!(key in interfaceDef.properties)) {
|
|
74
|
+
throw new Error(`Invalid property ${key} for interface ${interfaceDef.apiName}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const remappedProps = Object.fromEntries(Object.keys(update).map(p => mapProperty(p, update[p])).filter(x => x != null));
|
|
78
|
+
return underlying.$clone(remappedProps).$as(interfaceDef);
|
|
79
|
+
}
|
|
80
|
+
function mapProperty(propertyName, value) {
|
|
81
|
+
const objDef = underlying[ObjectDefRef];
|
|
82
|
+
const targetPropName = objDef.interfaceMap[interfaceDef.apiName][propertyName];
|
|
83
|
+
// If the underlying object does not implement the SPT, throw errors
|
|
84
|
+
if (targetPropName == null) {
|
|
85
|
+
throw new Error(`Cannot clone interface with ${propertyName} as property is not implemented by the underlying object type ${objDef.apiName}`);
|
|
86
|
+
}
|
|
87
|
+
return [targetPropName, value];
|
|
88
|
+
}
|
|
64
89
|
}
|
|
65
90
|
//# sourceMappingURL=createOsdkInterface.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOsdkInterface.js","names":["extractNamespace","InterfaceDefRef","ObjectDefRef","UnderlyingOsdkObject","createOsdkInterface","underlying","interfaceDef","objApiNamespace","apiName","Object","freeze","defineProperties","value","enumerable","$as","$objectType","$primaryKey","$title","$rid","fromEntries","keys","properties","map","p","objDef","apiNamespace","targetPropName","interfaceMap"],"sources":["createOsdkInterface.ts"],"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 */\n\nimport type { InterfaceMetadata, Osdk } from \"@osdk/api\";\nimport { extractNamespace } from \"../../internal/conversions/modernToLegacyWhereClause.js\";\nimport type { FetchedObjectTypeDefinition } from \"../../ontology/OntologyProvider.js\";\nimport type { InterfaceHolder } from \"./InterfaceHolder.js\";\nimport {\n InterfaceDefRef,\n ObjectDefRef,\n UnderlyingOsdkObject,\n} from \"./InternalSymbols.js\";\nimport type { ObjectHolder } from \"./ObjectHolder.js\";\n\n/** @internal */\nexport function createOsdkInterface<\n Q extends FetchedObjectTypeDefinition,\n>(\n underlying: Osdk<Q> & ObjectHolder<Q>,\n interfaceDef: InterfaceMetadata,\n) {\n const [objApiNamespace] = extractNamespace(interfaceDef.apiName);\n\n return Object.freeze(\n Object.defineProperties({}, {\n // first to minimize hidden classes\n [UnderlyingOsdkObject]: { value: underlying },\n\n \"$apiName\": { value: interfaceDef.apiName, enumerable: true },\n \"$as\": {\n value: underlying.$as,\n enumerable: false,\n },\n \"$objectType\": {\n value: underlying.$objectType,\n enumerable: \"$objectType\" in underlying,\n },\n \"$primaryKey\": {\n value: underlying.$primaryKey,\n enumerable: \"$primaryKey\" in underlying,\n },\n \"$title\": {\n value: underlying.$title,\n enumerable: \"$title\" in underlying,\n },\n \"$rid\": {\n value: (underlying as any).$rid,\n enumerable: \"$rid\" in underlying,\n },\n\n [InterfaceDefRef]: { value: interfaceDef },\n\n ...Object.fromEntries(\n Object.keys(interfaceDef.properties).map(p => {\n const objDef = underlying[ObjectDefRef];\n\n const [apiNamespace, apiName] = extractNamespace(p);\n\n const targetPropName = objDef\n .interfaceMap![interfaceDef.apiName][p];\n\n return [apiNamespace === objApiNamespace ? apiName : p, {\n enumerable: targetPropName in underlying,\n value: underlying[targetPropName as keyof typeof underlying],\n }];\n }),\n ),\n }) as InterfaceHolder<any> & Osdk<any>,\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,gBAAgB,QAAQ,yDAAyD;AAG1F,SACEC,eAAe,EACfC,YAAY,EACZC,oBAAoB,QACf,sBAAsB;AAG7B;AACA,OAAO,SAASC,mBAAmBA,CAGjCC,UAAqC,EACrCC,YAA+B,EAC/B;EACA,MAAM,CAACC,eAAe,CAAC,GAAGP,gBAAgB,CAACM,YAAY,CAACE,OAAO,CAAC;EAEhE,OAAOC,MAAM,CAACC,MAAM,CAClBD,MAAM,CAACE,gBAAgB,CAAC,CAAC,CAAC,EAAE;IAC1B;IACA,CAACR,oBAAoB,GAAG;MAAES,KAAK,EAAEP;IAAW,CAAC;IAE7C,UAAU,EAAE;MAAEO,KAAK,EAAEN,YAAY,CAACE,OAAO;MAAEK,UAAU,EAAE;IAAK,CAAC;IAC7D,KAAK,EAAE;MACLD,KAAK,EAAEP,UAAU,CAACS,GAAG;MACrBD,UAAU,EAAE;IACd,CAAC;IACD,aAAa,EAAE;MACbD,KAAK,EAAEP,UAAU,CAACU,WAAW;MAC7BF,UAAU,EAAE,aAAa,IAAIR;IAC/B,CAAC;IACD,aAAa,EAAE;MACbO,KAAK,EAAEP,UAAU,CAACW,WAAW;MAC7BH,UAAU,EAAE,aAAa,IAAIR;IAC/B,CAAC;IACD,QAAQ,EAAE;MACRO,KAAK,EAAEP,UAAU,CAACY,MAAM;MACxBJ,UAAU,EAAE,QAAQ,IAAIR;IAC1B,CAAC;IACD,MAAM,EAAE;MACNO,KAAK,EAAGP,UAAU,CAASa,IAAI;MAC/BL,UAAU,EAAE,MAAM,IAAIR;IACxB,CAAC;IAED,
|
|
1
|
+
{"version":3,"file":"createOsdkInterface.js","names":["extractNamespace","InterfaceDefRef","ObjectDefRef","UnderlyingOsdkObject","createOsdkInterface","underlying","interfaceDef","objApiNamespace","apiName","Object","freeze","defineProperties","value","enumerable","$as","$objectType","$primaryKey","$title","$rid","clone","fromEntries","keys","properties","map","p","objDef","apiNamespace","targetPropName","interfaceMap","update","$clone","key","Error","remappedProps","mapProperty","filter","x","propertyName"],"sources":["createOsdkInterface.ts"],"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 */\n\nimport type { InterfaceMetadata, Osdk } from \"@osdk/api\";\nimport { extractNamespace } from \"../../internal/conversions/modernToLegacyWhereClause.js\";\nimport type { FetchedObjectTypeDefinition } from \"../../ontology/OntologyProvider.js\";\nimport type { InterfaceHolder } from \"./InterfaceHolder.js\";\nimport {\n InterfaceDefRef,\n ObjectDefRef,\n UnderlyingOsdkObject,\n} from \"./InternalSymbols.js\";\nimport type { ObjectHolder } from \"./ObjectHolder.js\";\n\n/** @internal */\nexport function createOsdkInterface<\n Q extends FetchedObjectTypeDefinition,\n>(\n underlying: Osdk<Q> & ObjectHolder<Q>,\n interfaceDef: InterfaceMetadata,\n) {\n const [objApiNamespace] = extractNamespace(interfaceDef.apiName);\n\n return Object.freeze(\n Object.defineProperties({}, {\n // first to minimize hidden classes\n [UnderlyingOsdkObject]: { value: underlying },\n\n \"$apiName\": { value: interfaceDef.apiName, enumerable: true },\n \"$as\": {\n value: underlying.$as,\n enumerable: false,\n },\n \"$objectType\": {\n value: underlying.$objectType,\n enumerable: \"$objectType\" in underlying,\n },\n \"$primaryKey\": {\n value: underlying.$primaryKey,\n enumerable: \"$primaryKey\" in underlying,\n },\n \"$title\": {\n value: underlying.$title,\n enumerable: \"$title\" in underlying,\n },\n \"$rid\": {\n value: (underlying as any).$rid,\n enumerable: \"$rid\" in underlying,\n },\n \"$clone\": {\n value: clone,\n enumerable: false,\n },\n\n [InterfaceDefRef]: { value: interfaceDef },\n\n ...Object.fromEntries(\n Object.keys(interfaceDef.properties).map(p => {\n const objDef = underlying[ObjectDefRef];\n\n const [apiNamespace, apiName] = extractNamespace(p);\n\n const targetPropName = objDef\n .interfaceMap![interfaceDef.apiName][p];\n\n return [apiNamespace === objApiNamespace ? apiName : p, {\n enumerable: targetPropName in underlying,\n value: underlying[targetPropName as keyof typeof underlying],\n }];\n }),\n ),\n }) as InterfaceHolder<any> & Osdk<any>,\n );\n function clone(update: Record<string, any> | undefined) {\n if (update == null) {\n return underlying.$clone().$as(interfaceDef);\n }\n\n for (const key of Object.keys(update)) {\n if (!(key in interfaceDef.properties)) {\n throw new Error(\n `Invalid property ${key} for interface ${interfaceDef.apiName}`,\n );\n }\n }\n\n const remappedProps = Object.fromEntries(\n Object.keys(update).map(p => mapProperty(p, update[p])).filter(x =>\n x != null\n ),\n );\n\n return underlying.$clone(remappedProps).$as(interfaceDef);\n }\n function mapProperty(propertyName: string, value: any) {\n const objDef = underlying[ObjectDefRef];\n const targetPropName =\n objDef.interfaceMap![interfaceDef.apiName][propertyName];\n // If the underlying object does not implement the SPT, throw errors\n if (targetPropName == null) {\n throw new Error(\n `Cannot clone interface with ${propertyName} as property is not implemented by the underlying object type ${objDef.apiName}`,\n );\n }\n return [targetPropName, value];\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,gBAAgB,QAAQ,yDAAyD;AAG1F,SACEC,eAAe,EACfC,YAAY,EACZC,oBAAoB,QACf,sBAAsB;AAG7B;AACA,OAAO,SAASC,mBAAmBA,CAGjCC,UAAqC,EACrCC,YAA+B,EAC/B;EACA,MAAM,CAACC,eAAe,CAAC,GAAGP,gBAAgB,CAACM,YAAY,CAACE,OAAO,CAAC;EAEhE,OAAOC,MAAM,CAACC,MAAM,CAClBD,MAAM,CAACE,gBAAgB,CAAC,CAAC,CAAC,EAAE;IAC1B;IACA,CAACR,oBAAoB,GAAG;MAAES,KAAK,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
16
|
|
|
17
17
|
import invariant from "tiny-invariant";
|
|
18
18
|
import { createOsdkObject } from "./convertWireToOsdkObjects/createOsdkObject.js";
|
|
19
|
+
import { createObjectSpecifierFromPrimaryKey } from "./createObjectSpecifierFromPrimaryKey.js";
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* If interfaceApiName is not undefined, converts the instances of the
|
|
@@ -108,10 +109,12 @@ export async function convertWireToOsdkObjects2(client, objects, interfaceApiNam
|
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
/**
|
|
112
|
+
* @internal
|
|
113
|
+
*
|
|
111
114
|
* Utility function that lets us take down selected property names from an interface
|
|
112
115
|
* and convert them to an array of property names on an object.
|
|
113
116
|
*/
|
|
114
|
-
function convertInterfacePropNamesToObjectPropNames(objectDef, interfaceApiName, ifacePropsToMap) {
|
|
117
|
+
export function convertInterfacePropNamesToObjectPropNames(objectDef, interfaceApiName, ifacePropsToMap) {
|
|
115
118
|
return ifacePropsToMap.map(ifaceProp => objectDef.interfaceMap[interfaceApiName][ifaceProp]);
|
|
116
119
|
}
|
|
117
120
|
|
|
@@ -187,6 +190,10 @@ function fixObjectPropertiesInPlace(objs, forceRemoveRid) {
|
|
|
187
190
|
// copying over for now as its always returned. In the future, this should just be inferred from underlying
|
|
188
191
|
obj.$primaryKey ??= obj.__primaryKey;
|
|
189
192
|
obj.$title ??= obj.__title;
|
|
193
|
+
obj.$objectSpecifier = createObjectSpecifierFromPrimaryKey({
|
|
194
|
+
apiName: obj.$apiName,
|
|
195
|
+
type: "object"
|
|
196
|
+
}, obj.$primaryKey);
|
|
190
197
|
|
|
191
198
|
// we don't want people to use these
|
|
192
199
|
delete obj.__apiName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertWireToOsdkObjects.js","names":["invariant","createOsdkObject","convertWireToOsdkObjects","client","objects","interfaceApiName","forceRemoveRid","selectedProps","strictNonNull","logger","debug","fixObjectPropertiesInPlace","ifaceDef","ontologyProvider","getInterfaceDefinition","undefined","ifaceSelected","Object","keys","properties","ret","rawObj","objectDef","getObjectDefinition","$apiName","process","env","NODE_ENV","objProps","conforming","invariantInterfacesAsViews","apiName","isConforming","reframeAsObjectInPlace","convertInterfacePropNamesToObjectPropNames","Error","osdkObject","$as","push","convertWireToOsdkObjects2","interfaceToObjectTypeMappings","interfaceToObjMapping","filter","val","includes","values","primaryKeyApiName","ifacePropsToMap","map","ifaceProp","interfaceMap","newProps","sptProp","regularProp","entries","value","assign","$primaryKey","def","obj","propsToCheck","propName","nullable","$objectType","warning","warn","console","error","objs","__rid","$rid","__apiName","__primaryKey","$title","__title"],"sources":["convertWireToOsdkObjects.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n InterfaceMetadata,\n NullabilityAdherence,\n ObjectMetadata,\n ObjectOrInterfaceDefinition,\n Osdk,\n} from \"@osdk/api\";\nimport type {\n InterfaceToObjectTypeMappings,\n InterfaceTypeApiName,\n OntologyObjectV2,\n} from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport {\n type FetchedObjectTypeDefinition,\n} from \"../ontology/OntologyProvider.js\";\nimport { createOsdkObject } from \"./convertWireToOsdkObjects/createOsdkObject.js\";\n\n/**\n * If interfaceApiName is not undefined, converts the instances of the\n * interface into their respective\n * underlying concrete types and then returns the $as() representation\n * for the consumers.\n *\n * Otherwise just does the conversion\n *\n * May mutate in place for performance reasons. If you need a clean copy,\n * keep it first.\n *\n * However, you must use the returned value, which will be whatever is correct.\n *\n * @internal\n * @param interfaceApiName - if undefined\n */\nexport async function convertWireToOsdkObjects(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string | undefined,\n forceRemoveRid: boolean = false,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull: NullabilityAdherence = false,\n): Promise<Osdk.Instance<ObjectOrInterfaceDefinition>[]> {\n client.logger?.debug(`START convertWireToOsdkObjects()`);\n\n fixObjectPropertiesInPlace(objects, forceRemoveRid);\n\n const ifaceDef = interfaceApiName\n ? await client.ontologyProvider.getInterfaceDefinition(interfaceApiName)\n : undefined;\n const ifaceSelected = ifaceDef\n ? (selectedProps ?? Object.keys(ifaceDef.properties))\n : undefined;\n\n const ret = [];\n for (const rawObj of objects) {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n rawObj.$apiName,\n );\n invariant(objectDef, `Missing definition for '${rawObj.$apiName}'`);\n\n // default value for when we are checking an object\n let objProps;\n\n let conforming = true;\n if (ifaceDef && ifaceSelected) {\n // API returns interface spt names but we cache by real values\n invariantInterfacesAsViews(objectDef, ifaceDef.apiName, client);\n\n conforming &&= isConforming(client, ifaceDef, rawObj, ifaceSelected);\n\n reframeAsObjectInPlace(objectDef, ifaceDef.apiName, rawObj);\n\n objProps = convertInterfacePropNamesToObjectPropNames(\n objectDef,\n ifaceDef.apiName,\n ifaceSelected,\n );\n } else {\n objProps = selectedProps ?? Object.keys(objectDef.properties);\n }\n\n conforming &&= isConforming(client, objectDef, rawObj, objProps);\n\n if (strictNonNull === \"throw\" && !conforming) {\n throw new Error(\n \"Unable to safely convert objects as some non nullable properties are null\",\n );\n } else if (strictNonNull === \"drop\" && !conforming) {\n continue;\n }\n\n let osdkObject = createOsdkObject(client, objectDef, rawObj);\n if (interfaceApiName) osdkObject = osdkObject.$as(interfaceApiName);\n\n ret.push(osdkObject);\n }\n\n client.logger?.debug(`END convertWireToOsdkObjects()`);\n return ret;\n}\n\n/**\n * @internal\n */\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string | undefined,\n forceRemoveRid: boolean = false,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull: NullabilityAdherence = false,\n interfaceToObjectTypeMappings: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n > = {},\n): Promise<Osdk.Instance<ObjectOrInterfaceDefinition>[]> {\n client.logger?.debug(`START convertWireToOsdkObjects2()`);\n\n fixObjectPropertiesInPlace(objects, forceRemoveRid);\n\n const ret = [];\n for (const rawObj of objects) {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n rawObj.$apiName,\n );\n invariant(objectDef, `Missing definition for '${rawObj.$apiName}'`);\n\n const interfaceToObjMapping = interfaceApiName\n ? interfaceToObjectTypeMappings[interfaceApiName as InterfaceTypeApiName][\n rawObj.$apiName\n ]\n : undefined;\n\n const ifaceSelected = interfaceApiName && interfaceToObjMapping\n ? (selectedProps\n ? Object.keys(interfaceToObjMapping).filter(\n val => {\n selectedProps?.includes(interfaceToObjMapping[val]);\n },\n )\n : [\n ...Object.values(interfaceToObjMapping),\n objectDef.primaryKeyApiName,\n ])\n : undefined;\n\n // default value for when we are checking an object\n let objProps;\n\n let conforming = true;\n if (interfaceApiName && ifaceSelected) {\n invariantInterfacesAsViews(objectDef, interfaceApiName, client);\n\n objProps = ifaceSelected;\n } else {\n objProps = selectedProps ?? Object.keys(objectDef.properties);\n }\n\n conforming &&= isConforming(client, objectDef, rawObj, objProps);\n\n if (strictNonNull === \"throw\" && !conforming) {\n throw new Error(\n \"Unable to safely convert objects as some non nullable properties are null\",\n );\n } else if (strictNonNull === \"drop\" && !conforming) {\n continue;\n }\n\n let osdkObject = createOsdkObject(client, objectDef, rawObj);\n if (interfaceApiName) osdkObject = osdkObject.$as(interfaceApiName);\n\n ret.push(osdkObject);\n }\n\n client.logger?.debug(`END convertWireToOsdkObjects2()`);\n return ret;\n}\n\n/**\n * Utility function that lets us take down selected property names from an interface\n * and convert them to an array of property names on an object.\n */\nfunction convertInterfacePropNamesToObjectPropNames(\n objectDef: FetchedObjectTypeDefinition & { interfaceMap: {} },\n interfaceApiName: string,\n ifacePropsToMap: readonly string[],\n) {\n return ifacePropsToMap.map((ifaceProp) =>\n objectDef.interfaceMap[interfaceApiName][ifaceProp]\n );\n}\n\n/**\n * Takes a raw object from the wire (contextually as an interface) and\n * updates the fields to reflect the underlying objectDef instead\n * @param objectDef\n * @param interfaceApiName\n * @param client\n * @param rawObj\n */\nfunction reframeAsObjectInPlace(\n objectDef: FetchedObjectTypeDefinition & { interfaceMap: {} },\n interfaceApiName: string,\n rawObj: OntologyObjectV2,\n) {\n const newProps: Record<string, any> = {};\n for (\n const [sptProp, regularProp] of Object.entries(\n objectDef.interfaceMap[interfaceApiName],\n )\n ) {\n if (sptProp in rawObj) {\n const value = rawObj[sptProp];\n delete rawObj[sptProp];\n if (value !== undefined) {\n newProps[regularProp] = value;\n }\n }\n }\n Object.assign(rawObj, newProps);\n\n if (!(objectDef.primaryKeyApiName in rawObj)) {\n rawObj[objectDef.primaryKeyApiName] = rawObj.$primaryKey;\n }\n}\n\nfunction isConforming(\n client: MinimalClient,\n def:\n | InterfaceMetadata\n | ObjectMetadata,\n obj: OntologyObjectV2,\n propsToCheck: readonly string[],\n) {\n for (const propName of propsToCheck) {\n if (\n propName in def.properties && def.properties[propName].nullable === false\n && obj[propName] == null\n ) {\n if (process.env.NODE_ENV !== \"production\") {\n client.logger?.debug(\n {\n obj: {\n $objectType: obj[\"$objectType\"],\n $primaryKey: obj[\"$primaryKey\"],\n },\n },\n `Found object that does not conform to its definition. Expected ${def.apiName}'s ${propName} to not be null.`,\n );\n }\n return false;\n }\n }\n return true;\n}\n\nfunction invariantInterfacesAsViews(\n objectDef: FetchedObjectTypeDefinition,\n interfaceApiName: string,\n client: MinimalClient,\n): asserts objectDef is typeof objectDef & { interfaceMap: {} } {\n if (objectDef.interfaceMap?.[interfaceApiName] == null) {\n const warning =\n \"Interfaces are only supported 'as views' but your metadata object is missing the correct information. This suggests your interfaces have not been migrated to the newer version yet and you cannot use this version of the SDK.\";\n if (client.logger) {\n client.logger.warn(warning);\n } else {\n // eslint-disable-next-line no-console\n console.error(`WARNING! ${warning}`);\n }\n throw new Error(warning);\n }\n}\n\nfunction fixObjectPropertiesInPlace(\n objs: OntologyObjectV2[],\n forceRemoveRid: boolean,\n) {\n for (const obj of objs) {\n if (forceRemoveRid) {\n delete obj.__rid;\n }\n\n if (obj.__rid) {\n obj.$rid = obj.__rid;\n delete obj.__rid;\n }\n\n // Backend returns as __apiName but we want to stick to $ structure\n obj.$apiName ??= obj.__apiName;\n\n // for now these are the same but when we start doing interface projections the $objectType will always be underlying and\n // the $apiName will be for the current view (in current designs)\n obj.$objectType = obj.$apiName;\n\n // copying over for now as its always returned. In the future, this should just be inferred from underlying\n obj.$primaryKey ??= obj.__primaryKey;\n obj.$title ??= obj.__title;\n\n // we don't want people to use these\n delete obj.__apiName;\n delete obj.__primaryKey;\n delete obj.__title;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA,OAAOA,SAAS,MAAM,gBAAgB;AAKtC,SAASC,gBAAgB,QAAQ,gDAAgD;;AAEjF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,wBAAwBA,CAC5CC,MAAqB,EACrBC,OAA2B,EAC3BC,gBAAoC,EACpCC,cAAuB,GAAG,KAAK,EAC/BC,aAAqC,EACrCC,aAAmC,GAAG,KAAK,EACY;EACvDL,MAAM,CAACM,MAAM,EAAEC,KAAK,CAAC,kCAAkC,CAAC;EAExDC,0BAA0B,CAACP,OAAO,EAAEE,cAAc,CAAC;EAEnD,MAAMM,QAAQ,GAAGP,gBAAgB,GAC7B,MAAMF,MAAM,CAACU,gBAAgB,CAACC,sBAAsB,CAACT,gBAAgB,CAAC,G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,YAAY;IACvB,OAAOb,GAAG,CAACe,OAAO;EACpB;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"convertWireToOsdkObjects.js","names":["invariant","createOsdkObject","createObjectSpecifierFromPrimaryKey","convertWireToOsdkObjects","client","objects","interfaceApiName","forceRemoveRid","selectedProps","strictNonNull","logger","debug","fixObjectPropertiesInPlace","ifaceDef","ontologyProvider","getInterfaceDefinition","undefined","ifaceSelected","Object","keys","properties","ret","rawObj","objectDef","getObjectDefinition","$apiName","process","env","NODE_ENV","objProps","conforming","invariantInterfacesAsViews","apiName","isConforming","reframeAsObjectInPlace","convertInterfacePropNamesToObjectPropNames","Error","osdkObject","$as","push","convertWireToOsdkObjects2","interfaceToObjectTypeMappings","interfaceToObjMapping","filter","val","includes","values","primaryKeyApiName","ifacePropsToMap","map","ifaceProp","interfaceMap","newProps","sptProp","regularProp","entries","value","assign","$primaryKey","def","obj","propsToCheck","propName","nullable","$objectType","warning","warn","console","error","objs","__rid","$rid","__apiName","__primaryKey","$title","__title","$objectSpecifier","type"],"sources":["convertWireToOsdkObjects.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n InterfaceMetadata,\n NullabilityAdherence,\n ObjectMetadata,\n ObjectOrInterfaceDefinition,\n Osdk,\n} from \"@osdk/api\";\nimport type {\n InterfaceToObjectTypeMappings,\n InterfaceTypeApiName,\n OntologyObjectV2,\n} from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport {\n type FetchedObjectTypeDefinition,\n} from \"../ontology/OntologyProvider.js\";\nimport { createOsdkObject } from \"./convertWireToOsdkObjects/createOsdkObject.js\";\nimport { createObjectSpecifierFromPrimaryKey } from \"./createObjectSpecifierFromPrimaryKey.js\";\n\n/**\n * If interfaceApiName is not undefined, converts the instances of the\n * interface into their respective\n * underlying concrete types and then returns the $as() representation\n * for the consumers.\n *\n * Otherwise just does the conversion\n *\n * May mutate in place for performance reasons. If you need a clean copy,\n * keep it first.\n *\n * However, you must use the returned value, which will be whatever is correct.\n *\n * @internal\n * @param interfaceApiName - if undefined\n */\nexport async function convertWireToOsdkObjects(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string | undefined,\n forceRemoveRid: boolean = false,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull: NullabilityAdherence = false,\n): Promise<Osdk.Instance<ObjectOrInterfaceDefinition>[]> {\n client.logger?.debug(`START convertWireToOsdkObjects()`);\n\n fixObjectPropertiesInPlace(objects, forceRemoveRid);\n\n const ifaceDef = interfaceApiName\n ? await client.ontologyProvider.getInterfaceDefinition(interfaceApiName)\n : undefined;\n const ifaceSelected = ifaceDef\n ? (selectedProps ?? Object.keys(ifaceDef.properties))\n : undefined;\n\n const ret = [];\n for (const rawObj of objects) {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n rawObj.$apiName,\n );\n invariant(objectDef, `Missing definition for '${rawObj.$apiName}'`);\n\n // default value for when we are checking an object\n let objProps;\n\n let conforming = true;\n if (ifaceDef && ifaceSelected) {\n // API returns interface spt names but we cache by real values\n invariantInterfacesAsViews(objectDef, ifaceDef.apiName, client);\n\n conforming &&= isConforming(client, ifaceDef, rawObj, ifaceSelected);\n\n reframeAsObjectInPlace(objectDef, ifaceDef.apiName, rawObj);\n\n objProps = convertInterfacePropNamesToObjectPropNames(\n objectDef,\n ifaceDef.apiName,\n ifaceSelected,\n );\n } else {\n objProps = selectedProps ?? Object.keys(objectDef.properties);\n }\n\n conforming &&= isConforming(client, objectDef, rawObj, objProps);\n\n if (strictNonNull === \"throw\" && !conforming) {\n throw new Error(\n \"Unable to safely convert objects as some non nullable properties are null\",\n );\n } else if (strictNonNull === \"drop\" && !conforming) {\n continue;\n }\n\n let osdkObject = createOsdkObject(client, objectDef, rawObj);\n if (interfaceApiName) osdkObject = osdkObject.$as(interfaceApiName);\n\n ret.push(osdkObject);\n }\n\n client.logger?.debug(`END convertWireToOsdkObjects()`);\n return ret;\n}\n\n/**\n * @internal\n */\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string | undefined,\n forceRemoveRid: boolean = false,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull: NullabilityAdherence = false,\n interfaceToObjectTypeMappings: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n > = {},\n): Promise<Osdk.Instance<ObjectOrInterfaceDefinition>[]> {\n client.logger?.debug(`START convertWireToOsdkObjects2()`);\n\n fixObjectPropertiesInPlace(objects, forceRemoveRid);\n\n const ret = [];\n for (const rawObj of objects) {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n rawObj.$apiName,\n );\n invariant(objectDef, `Missing definition for '${rawObj.$apiName}'`);\n\n const interfaceToObjMapping = interfaceApiName\n ? interfaceToObjectTypeMappings[interfaceApiName as InterfaceTypeApiName][\n rawObj.$apiName\n ]\n : undefined;\n\n const ifaceSelected = interfaceApiName && interfaceToObjMapping\n ? (selectedProps\n ? Object.keys(interfaceToObjMapping).filter(\n val => {\n selectedProps?.includes(interfaceToObjMapping[val]);\n },\n )\n : [\n ...Object.values(interfaceToObjMapping),\n objectDef.primaryKeyApiName,\n ])\n : undefined;\n\n // default value for when we are checking an object\n let objProps;\n\n let conforming = true;\n if (interfaceApiName && ifaceSelected) {\n invariantInterfacesAsViews(objectDef, interfaceApiName, client);\n\n objProps = ifaceSelected;\n } else {\n objProps = selectedProps ?? Object.keys(objectDef.properties);\n }\n\n conforming &&= isConforming(client, objectDef, rawObj, objProps);\n\n if (strictNonNull === \"throw\" && !conforming) {\n throw new Error(\n \"Unable to safely convert objects as some non nullable properties are null\",\n );\n } else if (strictNonNull === \"drop\" && !conforming) {\n continue;\n }\n\n let osdkObject = createOsdkObject(client, objectDef, rawObj);\n if (interfaceApiName) osdkObject = osdkObject.$as(interfaceApiName);\n\n ret.push(osdkObject);\n }\n\n client.logger?.debug(`END convertWireToOsdkObjects2()`);\n return ret;\n}\n\n/**\n * @internal\n *\n * Utility function that lets us take down selected property names from an interface\n * and convert them to an array of property names on an object.\n */\nexport function convertInterfacePropNamesToObjectPropNames(\n objectDef: FetchedObjectTypeDefinition,\n interfaceApiName: string,\n ifacePropsToMap: readonly string[],\n): string[] {\n return ifacePropsToMap.map((ifaceProp) =>\n objectDef.interfaceMap[interfaceApiName][ifaceProp]\n );\n}\n\n/**\n * Takes a raw object from the wire (contextually as an interface) and\n * updates the fields to reflect the underlying objectDef instead\n * @param objectDef\n * @param interfaceApiName\n * @param client\n * @param rawObj\n */\nfunction reframeAsObjectInPlace(\n objectDef: FetchedObjectTypeDefinition,\n interfaceApiName: string,\n rawObj: OntologyObjectV2,\n) {\n const newProps: Record<string, any> = {};\n for (\n const [sptProp, regularProp] of Object.entries(\n objectDef.interfaceMap[interfaceApiName],\n )\n ) {\n if (sptProp in rawObj) {\n const value = rawObj[sptProp];\n delete rawObj[sptProp];\n if (value !== undefined) {\n newProps[regularProp] = value;\n }\n }\n }\n Object.assign(rawObj, newProps);\n\n if (!(objectDef.primaryKeyApiName in rawObj)) {\n rawObj[objectDef.primaryKeyApiName] = rawObj.$primaryKey;\n }\n}\n\nfunction isConforming(\n client: MinimalClient,\n def:\n | InterfaceMetadata\n | ObjectMetadata,\n obj: OntologyObjectV2,\n propsToCheck: readonly string[],\n) {\n for (const propName of propsToCheck) {\n if (\n propName in def.properties && def.properties[propName].nullable === false\n && obj[propName] == null\n ) {\n if (process.env.NODE_ENV !== \"production\") {\n client.logger?.debug(\n {\n obj: {\n $objectType: obj[\"$objectType\"],\n $primaryKey: obj[\"$primaryKey\"],\n },\n },\n `Found object that does not conform to its definition. Expected ${def.apiName}'s ${propName} to not be null.`,\n );\n }\n return false;\n }\n }\n return true;\n}\n\nfunction invariantInterfacesAsViews(\n objectDef: FetchedObjectTypeDefinition,\n interfaceApiName: string,\n client: MinimalClient,\n): asserts objectDef is typeof objectDef & { interfaceMap: {} } {\n if (objectDef.interfaceMap?.[interfaceApiName] == null) {\n const warning =\n \"Interfaces are only supported 'as views' but your metadata object is missing the correct information. This suggests your interfaces have not been migrated to the newer version yet and you cannot use this version of the SDK.\";\n if (client.logger) {\n client.logger.warn(warning);\n } else {\n // eslint-disable-next-line no-console\n console.error(`WARNING! ${warning}`);\n }\n throw new Error(warning);\n }\n}\n\nfunction fixObjectPropertiesInPlace(\n objs: OntologyObjectV2[],\n forceRemoveRid: boolean,\n) {\n for (const obj of objs) {\n if (forceRemoveRid) {\n delete obj.__rid;\n }\n\n if (obj.__rid) {\n obj.$rid = obj.__rid;\n delete obj.__rid;\n }\n\n // Backend returns as __apiName but we want to stick to $ structure\n obj.$apiName ??= obj.__apiName;\n\n // for now these are the same but when we start doing interface projections the $objectType will always be underlying and\n // the $apiName will be for the current view (in current designs)\n obj.$objectType = obj.$apiName;\n\n // copying over for now as its always returned. In the future, this should just be inferred from underlying\n obj.$primaryKey ??= obj.__primaryKey;\n obj.$title ??= obj.__title;\n\n obj.$objectSpecifier = createObjectSpecifierFromPrimaryKey(\n { apiName: obj.$apiName, type: \"object\" },\n obj.$primaryKey,\n );\n\n // we don't want people to use these\n delete obj.__apiName;\n delete obj.__primaryKey;\n delete obj.__title;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA,OAAOA,SAAS,MAAM,gBAAgB;AAKtC,SAASC,gBAAgB,QAAQ,gDAAgD;AACjF,SAASC,mCAAmC,QAAQ,0CAA0C;;AAE9F;A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GAAG,CAACU,KAAK;IAClB;IAEA,IAAIV,GAAG,CAACU,KAAK,EAAE;MACbV,GAAG,CAACW,IAAI,GAAGX,GAAG,CAACU,KAAK;MACpB,OAAOV,GAAG,CAACU,KAAK;IAClB;;IAEA;IACAV,GAAG,CAACnC,QAAQ,KAAKmC,GAAG,CAACY,SAAS;;IAE9B;IACA;IACAZ,GAAG,CAACI,WAAW,GAAGJ,GAAG,CAACnC,QAAQ;;IAE9B;IACAmC,GAAG,CAACF,WAAW,KAAKE,GAAG,CAACa,YAAY;IACpCb,GAAG,CAACc,MAAM,KAAKd,GAAG,CAACe,OAAO;IAE1Bf,GAAG,CAACgB,gBAAgB,GAAG1E,mCAAmC,CACxD;MAAE8B,OAAO,EAAE4B,GAAG,CAACnC,QAAQ;MAAEoD,IAAI,EAAE;IAAS,CAAC,EACzCjB,GAAG,CAACF,WACN,CAAC;;IAED;IACA,OAAOE,GAAG,CAACY,SAAS;IACpB,OAAOZ,GAAG,CAACa,YAAY;IACvB,OAAOb,GAAG,CAACe,OAAO;EACpB;AACF","ignoreList":[]}
|
|
@@ -42,7 +42,7 @@ describe("convertWireToOsdkObjects", () => {
|
|
|
42
42
|
const {
|
|
43
43
|
data: [employee]
|
|
44
44
|
} = await client(Employee).fetchPage();
|
|
45
|
-
expect(Object.keys(employee).sort()).toEqual(["employeeId", "$title", "fullName", "office", "class", "startDate", "employeeSensor", "employeeStatus", "$apiName", "$objectType", "$primaryKey", "employeeLocation"].sort());
|
|
45
|
+
expect(Object.keys(employee).sort()).toEqual(["employeeId", "$title", "fullName", "office", "class", "startDate", "employeeSensor", "employeeStatus", "$apiName", "$objectType", "$primaryKey", "$objectSpecifier", "employeeLocation"].sort());
|
|
46
46
|
expect(Object.keys(employee.$as)).toEqual([]);
|
|
47
47
|
expect(Object.keys(employee.$link)).toEqual(["peeps", "lead", "officeLink"]);
|
|
48
48
|
});
|
|
@@ -65,11 +65,11 @@ describe("convertWireToOsdkObjects", () => {
|
|
|
65
65
|
}).fetchPage();
|
|
66
66
|
|
|
67
67
|
// Should not have $title
|
|
68
|
-
expect(JSON.stringify(employee)).toMatchInlineSnapshot(`"{"employeeId":50030,"fullName":"John Doe","office":"NYC","class":"Red","startDate":"2019-01-01","employeeStatus":{},"employeeSensor":{},"employeeLocation":{},"$apiName":"Employee","$objectType":"Employee","$primaryKey":50030}"`);
|
|
68
|
+
expect(JSON.stringify(employee)).toMatchInlineSnapshot(`"{"employeeId":50030,"fullName":"John Doe","office":"NYC","class":"Red","startDate":"2019-01-01","employeeStatus":{},"employeeSensor":{},"employeeLocation":{},"$apiName":"Employee","$objectType":"Employee","$primaryKey":50030,"$objectSpecifier":"Employee:50030"}"`);
|
|
69
69
|
expect(JSON.stringify(employee.$as(FooInterface))).toMatchInlineSnapshot(`"{"$apiName":"FooInterface","$objectType":"Employee","$primaryKey":50030,"fooSpt":"John Doe"}"`);
|
|
70
70
|
|
|
71
71
|
// Should have $title
|
|
72
|
-
expect(JSON.stringify(employee2)).toMatchInlineSnapshot(`"{"employeeId":50031,"fullName":"Jane Doe","office":"SEA","class":"Blue","startDate":"2012-02-12","employeeStatus":{},"employeeSensor":{},"employeeLocation":{},"$apiName":"Employee","$objectType":"Employee","$primaryKey":50031,"$title":"Jane Doe"}"`);
|
|
72
|
+
expect(JSON.stringify(employee2)).toMatchInlineSnapshot(`"{"employeeId":50031,"fullName":"Jane Doe","office":"SEA","class":"Blue","startDate":"2012-02-12","employeeStatus":{},"employeeSensor":{},"employeeLocation":{},"$apiName":"Employee","$objectType":"Employee","$primaryKey":50031,"$title":"Jane Doe","$objectSpecifier":"Employee:50031"}"`);
|
|
73
73
|
expect(JSON.stringify(employee2.$as(FooInterface))).toMatchInlineSnapshot(`"{"$apiName":"FooInterface","$objectType":"Employee","$primaryKey":50031,"$title":"Jane Doe","fooSpt":"Jane Doe"}"`);
|
|
74
74
|
});
|
|
75
75
|
it("reuses the object prototype across objects", async () => {
|
|
@@ -185,6 +185,7 @@ describe("convertWireToOsdkObjects", () => {
|
|
|
185
185
|
expect(obj).toMatchInlineSnapshot(`
|
|
186
186
|
{
|
|
187
187
|
"$apiName": "Employee",
|
|
188
|
+
"$objectSpecifier": "Employee:0",
|
|
188
189
|
"$objectType": "Employee",
|
|
189
190
|
"$primaryKey": 0,
|
|
190
191
|
"$title": "Steve",
|
|
@@ -217,6 +218,7 @@ describe("convertWireToOsdkObjects", () => {
|
|
|
217
218
|
expect(obj).toMatchInlineSnapshot(`
|
|
218
219
|
{
|
|
219
220
|
"$apiName": "Employee",
|
|
221
|
+
"$objectSpecifier": "Employee:0",
|
|
220
222
|
"$objectType": "Employee",
|
|
221
223
|
"$primaryKey": 0,
|
|
222
224
|
"$title": "Steve",
|
|
@@ -251,6 +253,7 @@ describe("convertWireToOsdkObjects", () => {
|
|
|
251
253
|
expect(obj).toMatchInlineSnapshot(`
|
|
252
254
|
{
|
|
253
255
|
"$apiName": "Employee",
|
|
256
|
+
"$objectSpecifier": "Employee:0",
|
|
254
257
|
"$objectType": "Employee",
|
|
255
258
|
"$primaryKey": 0,
|
|
256
259
|
"$rid": "hiMom",
|
|
@@ -289,6 +292,7 @@ describe("convertWireToOsdkObjects", () => {
|
|
|
289
292
|
expect(obj).toMatchInlineSnapshot(`
|
|
290
293
|
{
|
|
291
294
|
"$apiName": "Employee",
|
|
295
|
+
"$objectSpecifier": "Employee:0",
|
|
292
296
|
"$objectType": "Employee",
|
|
293
297
|
"$primaryKey": 0,
|
|
294
298
|
"$rid": "hiMom",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertWireToOsdkObjects.test.js","names":["$ontologyRid","Employee","FooInterface","objectTypeWithAllPropertyTypes","createSharedClientContext","apiServer","afterAll","beforeAll","describe","expect","expectTypeOf","it","additionalContext","createClient","createMinimalClient","convertWireToOsdkObjects","convertWireToOsdkObjects2","client","interfaceToObjectTypeMappings","fooSpt","listen","close","data","employee","fetchPage","Object","keys","sort","toEqual","$as","$link","employee2","where","$and","employeeId","$gt","$lt","JSON","stringify","toMatchInlineSnapshot","employees","length","toBeGreaterThanOrEqual","a","b","getPrototypeOf","toBe","withValues","id","attachment","attachmentArray","toMatchTypeOf","rid","Array","isArray","toBeTruthy","withoutValues","emptyAttachment","emptyAttachmentArray","toBeUndefined","mediaReference","toBeDefined","emptyMedia","somePropertyThatShouldNotExist","toThrow","objAsFoo","clientCtx","ontologyRid","object","__apiName","apiName","__primaryKey","prototypeBefore","object2","undefined","prototypeAfter","not","__title","obj","fullName","__rid","$rid","rejects","toThrowErrorMatchingInlineSnapshot","resolves","to","result","instance","osdk"],"sources":["convertWireToOsdkObjects.test.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Attachment, Media, Osdk, PropertyKeys } from \"@osdk/api\";\nimport {\n $ontologyRid,\n Employee,\n FooInterface,\n objectTypeWithAllPropertyTypes,\n} from \"@osdk/client.test.ontology\";\nimport type { OntologyObjectV2 } from \"@osdk/foundry.ontologies\";\nimport { createSharedClientContext } from \"@osdk/shared.client.impl\";\nimport { apiServer } from \"@osdk/shared.test\";\nimport {\n afterAll,\n beforeAll,\n describe,\n expect,\n expectTypeOf,\n it,\n} from \"vitest\";\nimport { additionalContext, type Client } from \"../Client.js\";\nimport { createClient } from \"../createClient.js\";\nimport { createMinimalClient } from \"../createMinimalClient.js\";\nimport {\n convertWireToOsdkObjects,\n convertWireToOsdkObjects2,\n} from \"./convertWireToOsdkObjects.js\";\n\ndescribe(\"convertWireToOsdkObjects\", () => {\n let client: Client;\n const interfaceToObjectTypeMappings = {\n FooInterface: { Employee: { fooSpt: \"fullName\" } },\n };\n\n beforeAll(async () => {\n apiServer.listen();\n client = createClient(\n \"https://stack.palantir.com\",\n $ontologyRid,\n async () => \"myAccessToken\",\n );\n });\n\n afterAll(() => {\n apiServer.close();\n });\n\n it(\"configures properties correctly\", async () => {\n const { data: [employee] } = await client(Employee).fetchPage();\n\n expect(Object.keys(employee).sort()).toEqual([\n \"employeeId\",\n \"$title\",\n \"fullName\",\n \"office\",\n \"class\",\n \"startDate\",\n \"employeeSensor\",\n \"employeeStatus\",\n \"$apiName\",\n \"$objectType\",\n \"$primaryKey\",\n \"employeeLocation\",\n ].sort());\n\n expect(Object.keys(employee.$as)).toEqual([]);\n expect(Object.keys(employee.$link)).toEqual([\n \"peeps\",\n \"lead\",\n \"officeLink\",\n ]);\n });\n\n it(\"stringifies properties on objects and interfaces correctly\", async () => {\n const { data: [employee] } = await client(Employee).fetchPage();\n const { data: [employee2] } = await client(Employee).where({\n $and: [{ employeeId: { $gt: 50030 } }, { employeeId: { $lt: 50032 } }],\n }).fetchPage();\n\n // Should not have $title\n expect(JSON.stringify(employee)).toMatchInlineSnapshot(\n `\"{\"employeeId\":50030,\"fullName\":\"John Doe\",\"office\":\"NYC\",\"class\":\"Red\",\"startDate\":\"2019-01-01\",\"employeeStatus\":{},\"employeeSensor\":{},\"employeeLocation\":{},\"$apiName\":\"Employee\",\"$objectType\":\"Employee\",\"$primaryKey\":50030}\"`,\n );\n\n expect(JSON.stringify(employee.$as(FooInterface))).toMatchInlineSnapshot(\n `\"{\"$apiName\":\"FooInterface\",\"$objectType\":\"Employee\",\"$primaryKey\":50030,\"fooSpt\":\"John Doe\"}\"`,\n );\n\n // Should have $title\n expect(JSON.stringify(employee2)).toMatchInlineSnapshot(\n `\"{\"employeeId\":50031,\"fullName\":\"Jane Doe\",\"office\":\"SEA\",\"class\":\"Blue\",\"startDate\":\"2012-02-12\",\"employeeStatus\":{},\"employeeSensor\":{},\"employeeLocation\":{},\"$apiName\":\"Employee\",\"$objectType\":\"Employee\",\"$primaryKey\":50031,\"$title\":\"Jane Doe\"}\"`,\n );\n\n expect(JSON.stringify(employee2.$as(FooInterface))).toMatchInlineSnapshot(\n `\"{\"$apiName\":\"FooInterface\",\"$objectType\":\"Employee\",\"$primaryKey\":50031,\"$title\":\"Jane Doe\",\"fooSpt\":\"Jane Doe\"}\"`,\n );\n });\n\n it(\"reuses the object prototype across objects\", async () => {\n const employees = await client(Employee).fetchPage();\n expect(employees.data.length).toBeGreaterThanOrEqual(2);\n const [a, b] = employees.data;\n\n expect(Object.getPrototypeOf(Object.getPrototypeOf(a))).toBe(\n Object.getPrototypeOf(Object.getPrototypeOf(b)),\n );\n });\n\n it(\"converts attachments as expected\", async () => {\n const withValues = await client(\n objectTypeWithAllPropertyTypes,\n )\n .where({ id: 1 })\n .fetchPage();\n expect(withValues.data.length).toBeGreaterThanOrEqual(1);\n\n const { attachment, attachmentArray } = withValues.data[0];\n\n expectTypeOf(attachment).toMatchTypeOf<\n Attachment | undefined\n >;\n expect(attachment?.rid).toEqual(\n \"ri.attachments.main.attachment.86016861-707f-4292-b258-6a7108915a75\",\n );\n expect(Array.isArray(attachmentArray)).toBeTruthy();\n expectTypeOf(attachmentArray![0]).toMatchTypeOf<Attachment>;\n\n const withoutValues = await client(\n objectTypeWithAllPropertyTypes,\n ).where({ id: 2 }).fetchPage();\n\n const {\n attachment: emptyAttachment,\n attachmentArray: emptyAttachmentArray,\n } = withoutValues.data[0];\n expect(emptyAttachment).toBeUndefined();\n expect(emptyAttachmentArray).toBeUndefined();\n });\n\n it(\"converts media as expected\", async () => {\n const withValues = await client(\n objectTypeWithAllPropertyTypes,\n )\n .where({ id: 1 })\n .fetchPage();\n expect(withValues.data.length).toBeGreaterThanOrEqual(1);\n\n const { mediaReference } = withValues.data[0];\n\n expectTypeOf(mediaReference).toMatchTypeOf<\n Media | undefined\n >;\n expect(mediaReference).toBeDefined();\n\n const withoutValues = await client(\n objectTypeWithAllPropertyTypes,\n ).where({ id: 2 }).fetchPage();\n\n const {\n mediaReference: emptyMedia,\n } = withoutValues.data[0];\n expect(emptyMedia).toBeUndefined();\n });\n\n it(\"creates immutable objects\", async () => {\n const employees = await client(Employee).fetchPage();\n expect(employees.data.length).toBeGreaterThanOrEqual(2);\n const [a, b] = employees.data;\n\n expect(a).toBeDefined();\n expect(() => {\n (a as any).somePropertyThatShouldNotExist = 5;\n }).toThrow();\n\n const objAsFoo = a.$as(FooInterface);\n expect(objAsFoo).toBeDefined();\n expect(() => {\n (objAsFoo as any).somePropertyThatShouldNotExist = 5;\n }).toThrow();\n });\n\n it(\"works even with unknown apiNames - old\", async () => {\n const clientCtx = createMinimalClient(\n { ontologyRid: $ontologyRid },\n \"https://stack.palantir.com\",\n async () => \"myAccessToken\",\n );\n createSharedClientContext(\n \"https://stack.palantir.com\",\n async () => \"myAccessToken\",\n \"userAgent\",\n );\n\n const object = {\n __apiName: Employee.apiName,\n __primaryKey: 0,\n } as const;\n const prototypeBefore = Object.getPrototypeOf(object);\n const object2 = await convertWireToOsdkObjects(\n clientCtx,\n [object],\n undefined,\n undefined,\n undefined,\n false,\n );\n const prototypeAfter = Object.getPrototypeOf(object2);\n\n expect(prototypeBefore).not.toBe(prototypeAfter);\n });\n\n it(\"works even with unknown apiNames - new\", async () => {\n const clientCtx = createMinimalClient(\n { ontologyRid: $ontologyRid },\n \"https://stack.palantir.com\",\n async () => \"myAccessToken\",\n );\n createSharedClientContext(\n \"https://stack.palantir.com\",\n async () => \"myAccessToken\",\n \"userAgent\",\n );\n\n const object = {\n __apiName: Employee.apiName,\n __primaryKey: 0,\n } as const;\n const prototypeBefore = Object.getPrototypeOf(object);\n const object2 = await convertWireToOsdkObjects2(\n clientCtx,\n [object],\n undefined,\n undefined,\n undefined,\n false,\n );\n const prototypeAfter = Object.getPrototypeOf(object2);\n\n expect(prototypeBefore).not.toBe(prototypeAfter);\n });\n\n it(\"reconstitutes interfaces properly without rid - old\", async () => {\n const clientCtx = createMinimalClient(\n { ontologyRid: $ontologyRid },\n \"https://stack.palantir.com\",\n async () => \"myAccessToken\",\n );\n\n const objectFromWire = {\n __apiName: \"Employee\" as const,\n __primaryKey: 0,\n __title: \"Steve\",\n fooSpt: \"Steve\",\n } satisfies OntologyObjectV2;\n\n const [objAsFoo] = (await convertWireToOsdkObjects(\n clientCtx,\n [objectFromWire],\n FooInterface.apiName,\n )) as unknown as Osdk<FooInterface>[];\n\n expect(objAsFoo).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"FooInterface\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$title\": \"Steve\",\n \"fooSpt\": \"Steve\",\n }\n `);\n\n const obj = objAsFoo.$as(Employee);\n expect(obj.fullName).toEqual(\"Steve\");\n\n expect(obj).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"Employee\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$title\": \"Steve\",\n \"employeeId\": 0,\n \"fullName\": \"Steve\",\n }\n `);\n });\n\n it(\"reconstitutes interfaces properly without rid - new\", async () => {\n const clientCtx = createMinimalClient(\n { ontologyRid: $ontologyRid },\n \"https://stack.palantir.com\",\n async () => \"myAccessToken\",\n );\n\n const objectFromWire = {\n __apiName: \"Employee\" as const,\n __primaryKey: 0,\n __title: \"Steve\",\n fullName: \"Steve\",\n } satisfies OntologyObjectV2;\n\n const [objAsFoo] = (await convertWireToOsdkObjects2(\n clientCtx,\n [objectFromWire],\n FooInterface.apiName,\n false,\n undefined,\n false,\n interfaceToObjectTypeMappings,\n )) as unknown as Osdk<FooInterface>[];\n\n expect(objAsFoo).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"FooInterface\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$title\": \"Steve\",\n \"fooSpt\": \"Steve\",\n }\n `);\n\n const obj = objAsFoo.$as(Employee);\n expect(obj.fullName).toEqual(\"Steve\");\n\n expect(obj).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"Employee\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$title\": \"Steve\",\n \"fullName\": \"Steve\",\n }\n `);\n });\n\n it(\"reconstitutes interfaces properly with rid\", async () => {\n const clientCtx = createMinimalClient(\n { ontologyRid: $ontologyRid },\n \"https://stack.palantir.com\",\n async () => \"myAccessToken\",\n );\n\n const objectFromWire = {\n __apiName: \"Employee\" as const,\n __primaryKey: 0,\n __title: \"Steve\",\n __rid: \"hiMom\",\n fooSpt: \"Steve\",\n } satisfies OntologyObjectV2;\n\n const [objAsFoo] = (await convertWireToOsdkObjects(\n clientCtx,\n [objectFromWire],\n FooInterface.apiName,\n )) as unknown as Osdk<FooInterface, \"$rid\" | \"$all\">[];\n\n expect(objAsFoo).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"FooInterface\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$rid\": \"hiMom\",\n \"$title\": \"Steve\",\n \"fooSpt\": \"Steve\",\n }\n `);\n expect(objAsFoo.$rid).toEqual(\"hiMom\");\n\n const obj = objAsFoo.$as(Employee);\n expect(obj.fullName).toEqual(\"Steve\");\n\n expect(obj).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"Employee\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$rid\": \"hiMom\",\n \"$title\": \"Steve\",\n \"employeeId\": 0,\n \"fullName\": \"Steve\",\n }\n `);\n expect(obj.$rid).toEqual(\"hiMom\");\n });\n\n it(\"reconstitutes interfaces properly with rid - new\", async () => {\n const clientCtx = createMinimalClient(\n { ontologyRid: $ontologyRid },\n \"https://stack.palantir.com\",\n async () => \"myAccessToken\",\n );\n\n const objectFromWire = {\n __apiName: \"Employee\" as const,\n __primaryKey: 0,\n __title: \"Steve\",\n __rid: \"hiMom\",\n fullName: \"Steve\",\n employeeId: 0,\n } satisfies OntologyObjectV2;\n\n const [objAsFoo] = (await convertWireToOsdkObjects2(\n clientCtx,\n [objectFromWire],\n FooInterface.apiName,\n false,\n undefined,\n false,\n interfaceToObjectTypeMappings,\n )) as unknown as Osdk<FooInterface, \"$rid\" | \"$all\">[];\n\n expect(objAsFoo).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"FooInterface\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$rid\": \"hiMom\",\n \"$title\": \"Steve\",\n \"fooSpt\": \"Steve\",\n }\n `);\n expect(objAsFoo.$rid).toEqual(\"hiMom\");\n\n const obj = objAsFoo.$as(Employee);\n expect(obj.fullName).toEqual(\"Steve\");\n\n expect(obj).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"Employee\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$rid\": \"hiMom\",\n \"$title\": \"Steve\",\n \"employeeId\": 0,\n \"fullName\": \"Steve\",\n }\n `);\n expect(obj.$rid).toEqual(\"hiMom\");\n });\n\n describe(\"selection keys\", () => {\n it(\"throws when required is missing\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n await expect(() =>\n convertWireToOsdkObjects(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n [\"employeeId\"],\n \"throw\",\n )\n ).rejects.toThrowErrorMatchingInlineSnapshot(\n `[Error: Unable to safely convert objects as some non nullable properties are null]`,\n );\n });\n\n it(\"does not throw when optional is missing\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n await expect(\n convertWireToOsdkObjects(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n [\"fullName\"],\n \"throw\",\n ),\n ).resolves.to.not.toBeUndefined();\n });\n\n it(\"filters when it should\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n const result = await convertWireToOsdkObjects(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n [\"employeeId\"],\n \"drop\",\n );\n\n expect(result.length).toBe(0);\n });\n\n it(\"does not filter when it shouldn't\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n const result = await convertWireToOsdkObjects(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n [\"fullName\"],\n \"drop\",\n );\n\n expect(result.length).toBe(1);\n });\n });\n\n describe(\"selection keys - new\", () => {\n it(\"throws when required is missing\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n await expect(() =>\n convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n [\"employeeId\"],\n \"throw\",\n )\n ).rejects.toThrowErrorMatchingInlineSnapshot(\n `[Error: Unable to safely convert objects as some non nullable properties are null]`,\n );\n });\n\n it(\"does not throw when optional is missing\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n await expect(\n convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n [\"fullName\"],\n \"throw\",\n ),\n ).resolves.to.not.toBeUndefined();\n });\n\n it(\"filters when it should\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n const result = await convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n [\"employeeId\"],\n \"drop\",\n );\n\n expect(result.length).toBe(0);\n });\n\n it(\"does not filter when it shouldn't\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n const result = await convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n [\"fullName\"],\n \"drop\",\n );\n\n expect(result.length).toBe(1);\n });\n });\n\n describe(\"without selection keys\", () => {\n it(\"throws when required is missing\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n await expect(() =>\n convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n undefined,\n \"throw\",\n )\n ).rejects.toThrowErrorMatchingInlineSnapshot(\n `[Error: Unable to safely convert objects as some non nullable properties are null]`,\n );\n });\n\n it(\"does not throw when required is present\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n \"employeeId\": 0,\n } as const;\n\n await expect(\n convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n undefined,\n \"throw\",\n ),\n ).resolves.to.not.toBeUndefined();\n });\n\n it(\"filters when it should\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n const result = await convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n undefined,\n \"drop\",\n );\n\n expect(result.length).toBe(0);\n });\n\n it(\"does not filter when it shouldn't\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n \"employeeId\": 0,\n } as const;\n\n const result = await convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n undefined,\n \"drop\",\n );\n\n expect(result.length).toBe(1);\n });\n });\n\n describe(\"without selection keys - new\", () => {\n it(\"throws when required is missing\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n await expect(() =>\n convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n undefined,\n \"throw\",\n )\n ).rejects.toThrowErrorMatchingInlineSnapshot(\n `[Error: Unable to safely convert objects as some non nullable properties are null]`,\n );\n });\n\n it(\"does not throw when required is present\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n \"employeeId\": 0,\n } as const;\n\n await expect(\n convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n undefined,\n \"throw\",\n ),\n ).resolves.to.not.toBeUndefined();\n });\n\n it(\"filters when it should\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n const result = await convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n undefined,\n \"drop\",\n );\n\n expect(result.length).toBe(0);\n });\n\n it(\"does not filter when it shouldn't\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n \"employeeId\": 0,\n } as const;\n\n const result = await convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n undefined,\n \"drop\",\n );\n\n expect(result.length).toBe(1);\n });\n });\n\n it(\"behaves correctly when converting\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n fooSpt: \"hi\",\n } as const;\n\n const result = await convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n \"FooInterface\",\n undefined,\n [\"fooSpt\"],\n \"drop\",\n interfaceToObjectTypeMappings,\n );\n\n expect(result.length).toBe(1);\n });\n});\n\ndescribe(\"Osdk.Instance\", () => {\n it(\"is assignable to Osdk<>\", () => {\n const instance: Osdk.Instance<Employee> = {} as any;\n const osdk: Osdk<Employee> = instance;\n });\n\n it(\"is assignable from Osdk<>\", () => {\n const osdk: Osdk<Employee> = {} as any;\n const instance: Osdk.Instance<Employee> = osdk;\n });\n\n it(\"is assignable to Osdk<> with $notStrict\", () => {\n const instance: Osdk.Instance<Employee> = {} as any;\n const osdk: Osdk<Employee, \"$notStrict\"> = instance;\n const osdk2: Osdk<Employee, \"$notStrict\" | \"$all\"> = instance;\n });\n\n it(\"is assignable from Osdk<> with $notStrict\", () => {\n const osdk: Osdk<Employee, \"$notStrict\"> = {} as any;\n const osdk2: Osdk<Employee, \"$notStrict\" | \"$all\"> = osdk;\n const instance: Osdk.Instance<Employee> = osdk;\n const instance2: Osdk.Instance<Employee> = osdk2;\n });\n\n it(\"object with any for props is assignable to its normal self\", () => {\n const foo: readonly Osdk.Instance<Employee, never, any>[] = {} as any;\n\n const bar: readonly Osdk.Instance<\n Employee,\n never,\n PropertyKeys<Employee>\n >[] = foo;\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SACEA,YAAY,EACZC,QAAQ,EACRC,YAAY,EACZC,8BAA8B,QACzB,4BAA4B;AAEnC,SAASC,yBAAyB,QAAQ,0BA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AE,CAAC;QACf,YAAY,EAAE;MAChB,CAAC,CAIS,EACRG,SAAS,EACTA,SAAS,EACTA,SAAS,EACT,MACF,CAAC;MAEDjE,MAAM,CAAC6E,MAAM,CAAC7C,MAAM,CAAC,CAACK,IAAI,CAAC,CAAC,CAAC;IAC/B,CAAC,CAAC;EACJ,CAAC,CAAC;EAEFnC,EAAE,CAAC,mCAAmC,EAAE,YAAY;IAOlD,MAAM2E,MAAM,GAAG,MAAMtE,yBAAyB,CAC5CC,MAAM,CAACL,iBAAiB,CAAC,EACzB,CARa;MACbyD,SAAS,EAAE,UAAU;MACrBE,YAAY,EAAE,CAAC;MACfpD,MAAM,EAAE;IACV,CAAC,CAIS,EACR,cAAc,EACduD,SAAS,EACT,CAAC,QAAQ,CAAC,EACV,MAAM,EACNxD,6BACF,CAAC;IAEDT,MAAM,CAAC6E,MAAM,CAAC7C,MAAM,CAAC,CAACK,IAAI,CAAC,CAAC,CAAC;EAC/B,CAAC,CAAC;AACJ,CAAC,CAAC;AAEFtC,QAAQ,CAAC,eAAe,EAAE,MAAM;EAC9BG,EAAE,CAAC,yBAAyB,EAAE,MAAM,CAGpC,CAAC,CAAC;EAEFA,EAAE,CAAC,2BAA2B,EAAE,MAAM,CAGtC,CAAC,CAAC;EAEFA,EAAE,CAAC,yCAAyC,EAAE,MAAM;IAClD,MAAM4E,QAAiC,GAAG,CAAC,CAAQ;EAGrD,CAAC,CAAC;EAEF5E,EAAE,CAAC,2CAA2C,EAAE,MAAM;IACpD,MAAM6E,IAAkC,GAAG,CAAC,CAAQ;EAItD,CAAC,CAAC;EAEF7E,EAAE,CAAC,4DAA4D,EAAE,MAAM,CAQvE,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"convertWireToOsdkObjects.test.js","names":["$ontologyRid","Employee","FooInterface","objectTypeWithAllPropertyTypes","createSharedClientContext","apiServer","afterAll","beforeAll","describe","expect","expectTypeOf","it","additionalContext","createClient","createMinimalClient","convertWireToOsdkObjects","convertWireToOsdkObjects2","client","interfaceToObjectTypeMappings","fooSpt","listen","close","data","employee","fetchPage","Object","keys","sort","toEqual","$as","$link","employee2","where","$and","employeeId","$gt","$lt","JSON","stringify","toMatchInlineSnapshot","employees","length","toBeGreaterThanOrEqual","a","b","getPrototypeOf","toBe","withValues","id","attachment","attachmentArray","toMatchTypeOf","rid","Array","isArray","toBeTruthy","withoutValues","emptyAttachment","emptyAttachmentArray","toBeUndefined","mediaReference","toBeDefined","emptyMedia","somePropertyThatShouldNotExist","toThrow","objAsFoo","clientCtx","ontologyRid","object","__apiName","apiName","__primaryKey","prototypeBefore","object2","undefined","prototypeAfter","not","__title","obj","fullName","__rid","$rid","rejects","toThrowErrorMatchingInlineSnapshot","resolves","to","result","instance","osdk"],"sources":["convertWireToOsdkObjects.test.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Attachment, Media, Osdk, PropertyKeys } from \"@osdk/api\";\nimport {\n $ontologyRid,\n Employee,\n FooInterface,\n objectTypeWithAllPropertyTypes,\n} from \"@osdk/client.test.ontology\";\nimport type { OntologyObjectV2 } from \"@osdk/foundry.ontologies\";\nimport { createSharedClientContext } from \"@osdk/shared.client.impl\";\nimport { apiServer } from \"@osdk/shared.test\";\nimport {\n afterAll,\n beforeAll,\n describe,\n expect,\n expectTypeOf,\n it,\n} from \"vitest\";\nimport { additionalContext, type Client } from \"../Client.js\";\nimport { createClient } from \"../createClient.js\";\nimport { createMinimalClient } from \"../createMinimalClient.js\";\nimport {\n convertWireToOsdkObjects,\n convertWireToOsdkObjects2,\n} from \"./convertWireToOsdkObjects.js\";\n\ndescribe(\"convertWireToOsdkObjects\", () => {\n let client: Client;\n const interfaceToObjectTypeMappings = {\n FooInterface: { Employee: { fooSpt: \"fullName\" } },\n };\n\n beforeAll(async () => {\n apiServer.listen();\n client = createClient(\n \"https://stack.palantir.com\",\n $ontologyRid,\n async () => \"myAccessToken\",\n );\n });\n\n afterAll(() => {\n apiServer.close();\n });\n\n it(\"configures properties correctly\", async () => {\n const { data: [employee] } = await client(Employee).fetchPage();\n\n expect(Object.keys(employee).sort()).toEqual([\n \"employeeId\",\n \"$title\",\n \"fullName\",\n \"office\",\n \"class\",\n \"startDate\",\n \"employeeSensor\",\n \"employeeStatus\",\n \"$apiName\",\n \"$objectType\",\n \"$primaryKey\",\n \"$objectSpecifier\",\n \"employeeLocation\",\n ].sort());\n\n expect(Object.keys(employee.$as)).toEqual([]);\n expect(Object.keys(employee.$link)).toEqual([\n \"peeps\",\n \"lead\",\n \"officeLink\",\n ]);\n });\n\n it(\"stringifies properties on objects and interfaces correctly\", async () => {\n const { data: [employee] } = await client(Employee).fetchPage();\n const { data: [employee2] } = await client(Employee).where({\n $and: [{ employeeId: { $gt: 50030 } }, { employeeId: { $lt: 50032 } }],\n }).fetchPage();\n\n // Should not have $title\n expect(JSON.stringify(employee)).toMatchInlineSnapshot(\n `\"{\"employeeId\":50030,\"fullName\":\"John Doe\",\"office\":\"NYC\",\"class\":\"Red\",\"startDate\":\"2019-01-01\",\"employeeStatus\":{},\"employeeSensor\":{},\"employeeLocation\":{},\"$apiName\":\"Employee\",\"$objectType\":\"Employee\",\"$primaryKey\":50030,\"$objectSpecifier\":\"Employee:50030\"}\"`,\n );\n\n expect(JSON.stringify(employee.$as(FooInterface))).toMatchInlineSnapshot(\n `\"{\"$apiName\":\"FooInterface\",\"$objectType\":\"Employee\",\"$primaryKey\":50030,\"fooSpt\":\"John Doe\"}\"`,\n );\n\n // Should have $title\n expect(JSON.stringify(employee2)).toMatchInlineSnapshot(\n `\"{\"employeeId\":50031,\"fullName\":\"Jane Doe\",\"office\":\"SEA\",\"class\":\"Blue\",\"startDate\":\"2012-02-12\",\"employeeStatus\":{},\"employeeSensor\":{},\"employeeLocation\":{},\"$apiName\":\"Employee\",\"$objectType\":\"Employee\",\"$primaryKey\":50031,\"$title\":\"Jane Doe\",\"$objectSpecifier\":\"Employee:50031\"}\"`,\n );\n\n expect(JSON.stringify(employee2.$as(FooInterface))).toMatchInlineSnapshot(\n `\"{\"$apiName\":\"FooInterface\",\"$objectType\":\"Employee\",\"$primaryKey\":50031,\"$title\":\"Jane Doe\",\"fooSpt\":\"Jane Doe\"}\"`,\n );\n });\n\n it(\"reuses the object prototype across objects\", async () => {\n const employees = await client(Employee).fetchPage();\n expect(employees.data.length).toBeGreaterThanOrEqual(2);\n const [a, b] = employees.data;\n\n expect(Object.getPrototypeOf(Object.getPrototypeOf(a))).toBe(\n Object.getPrototypeOf(Object.getPrototypeOf(b)),\n );\n });\n\n it(\"converts attachments as expected\", async () => {\n const withValues = await client(\n objectTypeWithAllPropertyTypes,\n )\n .where({ id: 1 })\n .fetchPage();\n expect(withValues.data.length).toBeGreaterThanOrEqual(1);\n\n const { attachment, attachmentArray } = withValues.data[0];\n\n expectTypeOf(attachment).toMatchTypeOf<\n Attachment | undefined\n >;\n expect(attachment?.rid).toEqual(\n \"ri.attachments.main.attachment.86016861-707f-4292-b258-6a7108915a75\",\n );\n expect(Array.isArray(attachmentArray)).toBeTruthy();\n expectTypeOf(attachmentArray![0]).toMatchTypeOf<Attachment>;\n\n const withoutValues = await client(\n objectTypeWithAllPropertyTypes,\n ).where({ id: 2 }).fetchPage();\n\n const {\n attachment: emptyAttachment,\n attachmentArray: emptyAttachmentArray,\n } = withoutValues.data[0];\n expect(emptyAttachment).toBeUndefined();\n expect(emptyAttachmentArray).toBeUndefined();\n });\n\n it(\"converts media as expected\", async () => {\n const withValues = await client(\n objectTypeWithAllPropertyTypes,\n )\n .where({ id: 1 })\n .fetchPage();\n expect(withValues.data.length).toBeGreaterThanOrEqual(1);\n\n const { mediaReference } = withValues.data[0];\n\n expectTypeOf(mediaReference).toMatchTypeOf<\n Media | undefined\n >;\n expect(mediaReference).toBeDefined();\n\n const withoutValues = await client(\n objectTypeWithAllPropertyTypes,\n ).where({ id: 2 }).fetchPage();\n\n const {\n mediaReference: emptyMedia,\n } = withoutValues.data[0];\n expect(emptyMedia).toBeUndefined();\n });\n\n it(\"creates immutable objects\", async () => {\n const employees = await client(Employee).fetchPage();\n expect(employees.data.length).toBeGreaterThanOrEqual(2);\n const [a, b] = employees.data;\n\n expect(a).toBeDefined();\n expect(() => {\n (a as any).somePropertyThatShouldNotExist = 5;\n }).toThrow();\n\n const objAsFoo = a.$as(FooInterface);\n expect(objAsFoo).toBeDefined();\n expect(() => {\n (objAsFoo as any).somePropertyThatShouldNotExist = 5;\n }).toThrow();\n });\n\n it(\"works even with unknown apiNames - old\", async () => {\n const clientCtx = createMinimalClient(\n { ontologyRid: $ontologyRid },\n \"https://stack.palantir.com\",\n async () => \"myAccessToken\",\n );\n createSharedClientContext(\n \"https://stack.palantir.com\",\n async () => \"myAccessToken\",\n \"userAgent\",\n );\n\n const object = {\n __apiName: Employee.apiName,\n __primaryKey: 0,\n } as const;\n const prototypeBefore = Object.getPrototypeOf(object);\n const object2 = await convertWireToOsdkObjects(\n clientCtx,\n [object],\n undefined,\n undefined,\n undefined,\n false,\n );\n const prototypeAfter = Object.getPrototypeOf(object2);\n\n expect(prototypeBefore).not.toBe(prototypeAfter);\n });\n\n it(\"works even with unknown apiNames - new\", async () => {\n const clientCtx = createMinimalClient(\n { ontologyRid: $ontologyRid },\n \"https://stack.palantir.com\",\n async () => \"myAccessToken\",\n );\n createSharedClientContext(\n \"https://stack.palantir.com\",\n async () => \"myAccessToken\",\n \"userAgent\",\n );\n\n const object = {\n __apiName: Employee.apiName,\n __primaryKey: 0,\n } as const;\n const prototypeBefore = Object.getPrototypeOf(object);\n const object2 = await convertWireToOsdkObjects2(\n clientCtx,\n [object],\n undefined,\n undefined,\n undefined,\n false,\n );\n const prototypeAfter = Object.getPrototypeOf(object2);\n\n expect(prototypeBefore).not.toBe(prototypeAfter);\n });\n\n it(\"reconstitutes interfaces properly without rid - old\", async () => {\n const clientCtx = createMinimalClient(\n { ontologyRid: $ontologyRid },\n \"https://stack.palantir.com\",\n async () => \"myAccessToken\",\n );\n\n const objectFromWire = {\n __apiName: \"Employee\" as const,\n __primaryKey: 0,\n __title: \"Steve\",\n fooSpt: \"Steve\",\n } satisfies OntologyObjectV2;\n\n const [objAsFoo] = (await convertWireToOsdkObjects(\n clientCtx,\n [objectFromWire],\n FooInterface.apiName,\n )) as unknown as Osdk<FooInterface>[];\n\n expect(objAsFoo).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"FooInterface\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$title\": \"Steve\",\n \"fooSpt\": \"Steve\",\n }\n `);\n\n const obj = objAsFoo.$as(Employee);\n expect(obj.fullName).toEqual(\"Steve\");\n\n expect(obj).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"Employee\",\n \"$objectSpecifier\": \"Employee:0\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$title\": \"Steve\",\n \"employeeId\": 0,\n \"fullName\": \"Steve\",\n }\n `);\n });\n\n it(\"reconstitutes interfaces properly without rid - new\", async () => {\n const clientCtx = createMinimalClient(\n { ontologyRid: $ontologyRid },\n \"https://stack.palantir.com\",\n async () => \"myAccessToken\",\n );\n\n const objectFromWire = {\n __apiName: \"Employee\" as const,\n __primaryKey: 0,\n __title: \"Steve\",\n fullName: \"Steve\",\n } satisfies OntologyObjectV2;\n\n const [objAsFoo] = (await convertWireToOsdkObjects2(\n clientCtx,\n [objectFromWire],\n FooInterface.apiName,\n false,\n undefined,\n false,\n interfaceToObjectTypeMappings,\n )) as unknown as Osdk<FooInterface>[];\n\n expect(objAsFoo).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"FooInterface\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$title\": \"Steve\",\n \"fooSpt\": \"Steve\",\n }\n `);\n\n const obj = objAsFoo.$as(Employee);\n expect(obj.fullName).toEqual(\"Steve\");\n\n expect(obj).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"Employee\",\n \"$objectSpecifier\": \"Employee:0\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$title\": \"Steve\",\n \"fullName\": \"Steve\",\n }\n `);\n });\n\n it(\"reconstitutes interfaces properly with rid\", async () => {\n const clientCtx = createMinimalClient(\n { ontologyRid: $ontologyRid },\n \"https://stack.palantir.com\",\n async () => \"myAccessToken\",\n );\n\n const objectFromWire = {\n __apiName: \"Employee\" as const,\n __primaryKey: 0,\n __title: \"Steve\",\n __rid: \"hiMom\",\n fooSpt: \"Steve\",\n } satisfies OntologyObjectV2;\n\n const [objAsFoo] = (await convertWireToOsdkObjects(\n clientCtx,\n [objectFromWire],\n FooInterface.apiName,\n )) as unknown as Osdk<FooInterface, \"$rid\" | \"$all\">[];\n\n expect(objAsFoo).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"FooInterface\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$rid\": \"hiMom\",\n \"$title\": \"Steve\",\n \"fooSpt\": \"Steve\",\n }\n `);\n expect(objAsFoo.$rid).toEqual(\"hiMom\");\n\n const obj = objAsFoo.$as(Employee);\n expect(obj.fullName).toEqual(\"Steve\");\n\n expect(obj).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"Employee\",\n \"$objectSpecifier\": \"Employee:0\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$rid\": \"hiMom\",\n \"$title\": \"Steve\",\n \"employeeId\": 0,\n \"fullName\": \"Steve\",\n }\n `);\n expect(obj.$rid).toEqual(\"hiMom\");\n });\n\n it(\"reconstitutes interfaces properly with rid - new\", async () => {\n const clientCtx = createMinimalClient(\n { ontologyRid: $ontologyRid },\n \"https://stack.palantir.com\",\n async () => \"myAccessToken\",\n );\n\n const objectFromWire = {\n __apiName: \"Employee\" as const,\n __primaryKey: 0,\n __title: \"Steve\",\n __rid: \"hiMom\",\n fullName: \"Steve\",\n employeeId: 0,\n } satisfies OntologyObjectV2;\n\n const [objAsFoo] = (await convertWireToOsdkObjects2(\n clientCtx,\n [objectFromWire],\n FooInterface.apiName,\n false,\n undefined,\n false,\n interfaceToObjectTypeMappings,\n )) as unknown as Osdk<FooInterface, \"$rid\" | \"$all\">[];\n\n expect(objAsFoo).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"FooInterface\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$rid\": \"hiMom\",\n \"$title\": \"Steve\",\n \"fooSpt\": \"Steve\",\n }\n `);\n expect(objAsFoo.$rid).toEqual(\"hiMom\");\n\n const obj = objAsFoo.$as(Employee);\n expect(obj.fullName).toEqual(\"Steve\");\n\n expect(obj).toMatchInlineSnapshot(`\n {\n \"$apiName\": \"Employee\",\n \"$objectSpecifier\": \"Employee:0\",\n \"$objectType\": \"Employee\",\n \"$primaryKey\": 0,\n \"$rid\": \"hiMom\",\n \"$title\": \"Steve\",\n \"employeeId\": 0,\n \"fullName\": \"Steve\",\n }\n `);\n expect(obj.$rid).toEqual(\"hiMom\");\n });\n\n describe(\"selection keys\", () => {\n it(\"throws when required is missing\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n await expect(() =>\n convertWireToOsdkObjects(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n [\"employeeId\"],\n \"throw\",\n )\n ).rejects.toThrowErrorMatchingInlineSnapshot(\n `[Error: Unable to safely convert objects as some non nullable properties are null]`,\n );\n });\n\n it(\"does not throw when optional is missing\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n await expect(\n convertWireToOsdkObjects(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n [\"fullName\"],\n \"throw\",\n ),\n ).resolves.to.not.toBeUndefined();\n });\n\n it(\"filters when it should\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n const result = await convertWireToOsdkObjects(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n [\"employeeId\"],\n \"drop\",\n );\n\n expect(result.length).toBe(0);\n });\n\n it(\"does not filter when it shouldn't\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n const result = await convertWireToOsdkObjects(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n [\"fullName\"],\n \"drop\",\n );\n\n expect(result.length).toBe(1);\n });\n });\n\n describe(\"selection keys - new\", () => {\n it(\"throws when required is missing\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n await expect(() =>\n convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n [\"employeeId\"],\n \"throw\",\n )\n ).rejects.toThrowErrorMatchingInlineSnapshot(\n `[Error: Unable to safely convert objects as some non nullable properties are null]`,\n );\n });\n\n it(\"does not throw when optional is missing\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n await expect(\n convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n [\"fullName\"],\n \"throw\",\n ),\n ).resolves.to.not.toBeUndefined();\n });\n\n it(\"filters when it should\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n const result = await convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n [\"employeeId\"],\n \"drop\",\n );\n\n expect(result.length).toBe(0);\n });\n\n it(\"does not filter when it shouldn't\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n const result = await convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n [\"fullName\"],\n \"drop\",\n );\n\n expect(result.length).toBe(1);\n });\n });\n\n describe(\"without selection keys\", () => {\n it(\"throws when required is missing\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n await expect(() =>\n convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n undefined,\n \"throw\",\n )\n ).rejects.toThrowErrorMatchingInlineSnapshot(\n `[Error: Unable to safely convert objects as some non nullable properties are null]`,\n );\n });\n\n it(\"does not throw when required is present\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n \"employeeId\": 0,\n } as const;\n\n await expect(\n convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n undefined,\n \"throw\",\n ),\n ).resolves.to.not.toBeUndefined();\n });\n\n it(\"filters when it should\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n const result = await convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n undefined,\n \"drop\",\n );\n\n expect(result.length).toBe(0);\n });\n\n it(\"does not filter when it shouldn't\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n \"employeeId\": 0,\n } as const;\n\n const result = await convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n undefined,\n \"drop\",\n );\n\n expect(result.length).toBe(1);\n });\n });\n\n describe(\"without selection keys - new\", () => {\n it(\"throws when required is missing\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n await expect(() =>\n convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n undefined,\n \"throw\",\n )\n ).rejects.toThrowErrorMatchingInlineSnapshot(\n `[Error: Unable to safely convert objects as some non nullable properties are null]`,\n );\n });\n\n it(\"does not throw when required is present\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n \"employeeId\": 0,\n } as const;\n\n await expect(\n convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n undefined,\n \"throw\",\n ),\n ).resolves.to.not.toBeUndefined();\n });\n\n it(\"filters when it should\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n } as const;\n\n const result = await convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n undefined,\n \"drop\",\n );\n\n expect(result.length).toBe(0);\n });\n\n it(\"does not filter when it shouldn't\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n \"employeeId\": 0,\n } as const;\n\n const result = await convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n undefined,\n undefined,\n undefined,\n \"drop\",\n );\n\n expect(result.length).toBe(1);\n });\n });\n\n it(\"behaves correctly when converting\", async () => {\n const object = {\n __apiName: \"Employee\",\n __primaryKey: 0,\n fooSpt: \"hi\",\n } as const;\n\n const result = await convertWireToOsdkObjects2(\n client[additionalContext],\n [object],\n \"FooInterface\",\n undefined,\n [\"fooSpt\"],\n \"drop\",\n interfaceToObjectTypeMappings,\n );\n\n expect(result.length).toBe(1);\n });\n});\n\ndescribe(\"Osdk.Instance\", () => {\n it(\"is assignable to Osdk<>\", () => {\n const instance: Osdk.Instance<Employee> = {} as any;\n const osdk: Osdk<Employee> = instance;\n });\n\n it(\"is assignable from Osdk<>\", () => {\n const osdk: Osdk<Employee> = {} as any;\n const instance: Osdk.Instance<Employee> = osdk;\n });\n\n it(\"is assignable to Osdk<> with $notStrict\", () => {\n const instance: Osdk.Instance<Employee> = {} as any;\n const osdk: Osdk<Employee, \"$notStrict\"> = instance;\n const osdk2: Osdk<Employee, \"$notStrict\" | \"$all\"> = instance;\n });\n\n it(\"is assignable from Osdk<> with $notStrict\", () => {\n const osdk: Osdk<Employee, \"$notStrict\"> = {} as any;\n const osdk2: Osdk<Employee, \"$notStrict\" | \"$all\"> = osdk;\n const instance: Osdk.Instance<Employee> = osdk;\n const instance2: Osdk.Instance<Employee> = osdk2;\n });\n\n it(\"object with any for props is assignable to its normal self\", () => {\n const foo: readonly Osdk.Instance<Employee, never, any>[] = {} as any;\n\n const bar: readonly Osdk.Instance<\n Employee,\n never,\n PropertyKeys<Employee>\n >[] = foo;\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SACEA,YAAY,EACZC,QAAQ,EACRC,YAAY,EACZC,8BAA8B,QACzB,4BAA4B;AAEnC,SAASC,yBAAyB,QAAQ,0BAA0B;AACpE,SAASC,SAAS,QAAQ,mBAAmB;AAC7C,SACEC,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,MAAM,EACNC,YAAY,EACZC,EAAE,QACG,QAAQ;AACf,SAASC,iBAAiB,QAAqB,cAAc;AAC7D,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,mBAAmB,QAAQ,2BAA2B;AAC/D,SACEC,wBAAwB,EACxBC,yBAAyB,QACpB,+BAA+B;AAEtCR,QAAQ,CAAC,0BAA0B,EAAE,MAAM;EACzC,IAAIS,MAAc;EAClB,MAAMC,6BAA6B,GAAG;IACpChB,YAAY,EAAE;MAAED,QAAQ,EAAE;QAAEkB,MAAM,EAAE;MAAW;IAAE;EACnD,CAAC;EAEDZ,SAAS,CAAC,YAAY;IACpBF,SAAS,CAACe,MAAM,CAAC,CAAC;IAClBH,MAAM,GAAGJ,YAAY,CACnB,4BAA4B,EAC5Bb,YAAY,EACZ,YAAY,eACd,CAAC;EACH,CAAC,CAAC;EAEFM,QAAQ,CAAC,MAAM;IACbD,SAAS,CAACgB,KAAK,CAAC,CAAC;EACnB,CAAC,CAAC;EAEFV,EAAE,CAAC,iCAAiC,EAAE,YAAY;IAChD,MAAM;MAAEW,IAAI,EAAE,CAACC,QAAQ;IAAE,CAAC,GAAG,MAAMN,MAAM,CAAChB,QAAQ,CAAC,CAACuB,SAAS,CAAC,CAAC;IAE/Df,MAAM,CAACgB,MAAM,CAACC,IAAI,CAACH,QAAQ,CAAC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E,EAAE,CAAC,2CAA2C,EAAE,MAAM;IACpD,MAAM6E,IAAkC,GAAG,CAAC,CAAQ;EAItD,CAAC,CAAC;EAEF7E,EAAE,CAAC,4DAA4D,EAAE,MAAM,CAQvE,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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
|
+
|
|
17
|
+
export function createObjectSpecifierFromPrimaryKey(def, primaryKey) {
|
|
18
|
+
return `${def.apiName}:${primaryKey}`;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=createObjectSpecifierFromPrimaryKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createObjectSpecifierFromPrimaryKey.js","names":["createObjectSpecifierFromPrimaryKey","def","primaryKey","apiName"],"sources":["createObjectSpecifierFromPrimaryKey.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n ObjectSpecifier,\n PrimaryKeyType,\n} from \"@osdk/api\";\n\nexport function createObjectSpecifierFromPrimaryKey<\n Q extends ObjectOrInterfaceDefinition,\n>(def: Q, primaryKey: PrimaryKeyType<Q>): ObjectSpecifier<Q> {\n return `${def.apiName}:${primaryKey}` as ObjectSpecifier<Q>;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAO,SAASA,mCAAmCA,CAEjDC,GAAM,EAAEC,UAA6B,EAAsB;EAC3D,OAAO,GAAGD,GAAG,CAACE,OAAO,IAAID,UAAU,EAAE;AACvC","ignoreList":[]}
|