@osdk/client 2.6.1 → 2.7.0-beta.10
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 +92 -88
- package/build/browser/Client.js +1 -1
- package/build/browser/Client.js.map +1 -1
- package/build/browser/MinimalClientContext.js.map +1 -1
- package/build/browser/actions/actions.test.js +9 -0
- package/build/browser/actions/actions.test.js.map +1 -1
- package/build/browser/actions/applyAction.js +4 -0
- package/build/browser/actions/applyAction.js.map +1 -1
- package/build/browser/createClient.js +2 -1
- package/build/browser/createClient.js.map +1 -1
- package/build/browser/createMinimalClient.js +1 -0
- package/build/browser/createMinimalClient.js.map +1 -1
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +17 -1
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
- package/build/browser/fetchMetadata.test.js +31 -0
- package/build/browser/fetchMetadata.test.js.map +1 -1
- package/build/browser/intellisense.test.js +1 -1
- package/build/browser/intellisense.test.js.map +1 -1
- package/build/browser/object/aggregate.js +1 -0
- package/build/browser/object/aggregate.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/InterfaceHolder.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.js +3 -0
- package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +8 -0
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js +95 -3
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.js +18 -6
- package/build/browser/object/convertWireToOsdkObjects.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.test.js +189 -28
- package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/browser/object/fetchPage.js +18 -5
- package/build/browser/object/fetchPage.js.map +1 -1
- package/build/browser/object/fetchPage.test.js.map +1 -1
- package/build/browser/object/formatting/applyPropertyFormatter.js +58 -0
- package/build/browser/object/formatting/applyPropertyFormatter.js.map +1 -0
- package/build/browser/object/formatting/applyPropertyFormatter.test.js +726 -0
- package/build/browser/object/formatting/applyPropertyFormatter.test.js.map +1 -0
- package/build/browser/object/formatting/formatBoolean.js +23 -0
- package/build/browser/object/formatting/formatBoolean.js.map +1 -0
- package/build/browser/object/formatting/formatDateTime.js +158 -0
- package/build/browser/object/formatting/formatDateTime.js.map +1 -0
- package/build/browser/object/formatting/formatNumber.js +242 -0
- package/build/browser/object/formatting/formatNumber.js.map +1 -0
- package/build/browser/object/formatting/propertyFormattingUtils.js +39 -0
- package/build/browser/object/formatting/propertyFormattingUtils.js.map +1 -0
- package/build/browser/object/object.test.js +123 -0
- package/build/browser/object/object.test.js.map +1 -1
- package/build/browser/objectSet/InterfaceObjectSet.test.js +1 -1
- package/build/browser/objectSet/InterfaceObjectSet.test.js.map +1 -1
- package/build/browser/objectSet/ObjectSet.test.js +7 -6
- package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js +2 -2
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js +3 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/browser/objectSet/createObjectSet.js +13 -0
- package/build/browser/objectSet/createObjectSet.js.map +1 -1
- package/build/browser/objectSet/fetchLinksPage.js +57 -0
- package/build/browser/objectSet/fetchLinksPage.js.map +1 -0
- package/build/browser/objectSet/fetchLinksPage.test.js +102 -0
- package/build/browser/objectSet/fetchLinksPage.test.js.map +1 -0
- package/build/browser/observable/ListPayload.js.map +1 -1
- package/build/browser/observable/ObjectPayload.js.map +1 -1
- package/build/browser/observable/ObservableClient.js +0 -5
- package/build/browser/observable/ObservableClient.js.map +1 -1
- package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/browser/observable/internal/Store.test.js +104 -1
- package/build/browser/observable/internal/Store.test.js.map +1 -1
- package/build/browser/observable/internal/actions/OptimisticJob.js +1 -1
- package/build/browser/observable/internal/actions/OptimisticJob.js.map +1 -1
- package/build/browser/observable/internal/base-list/BaseListQuery.js +1 -1
- package/build/browser/observable/internal/base-list/BaseListQuery.js.map +1 -1
- package/build/browser/observable/internal/links/SpecificLinkQuery.js +9 -1
- package/build/browser/observable/internal/links/SpecificLinkQuery.js.map +1 -1
- package/build/browser/observable/internal/list/ListQuery.js +17 -2
- package/build/browser/observable/internal/list/ListQuery.js.map +1 -1
- package/build/browser/observable/internal/objectset/ObjectSetQuery.js +9 -7
- package/build/browser/observable/internal/objectset/ObjectSetQuery.js.map +1 -1
- package/build/browser/observable/internal/utils/rdpFieldOperations.js +46 -25
- package/build/browser/observable/internal/utils/rdpFieldOperations.js.map +1 -1
- package/build/browser/observable/internal/utils/rdpFieldOperations.test.js +172 -0
- package/build/browser/observable/internal/utils/rdpFieldOperations.test.js.map +1 -0
- package/build/browser/ontology/loadActionMetadata.js +3 -1
- package/build/browser/ontology/loadActionMetadata.js.map +1 -1
- package/build/browser/ontology/loadFullObjectMetadata.js +2 -1
- package/build/browser/ontology/loadFullObjectMetadata.js.map +1 -1
- package/build/browser/ontology/loadInterfaceMetadata.js +2 -1
- package/build/browser/ontology/loadInterfaceMetadata.js.map +1 -1
- package/build/browser/public/unstable-do-not-use.js.map +1 -1
- package/build/browser/queries/applyQuery.js +14 -0
- package/build/browser/queries/applyQuery.js.map +1 -1
- package/build/browser/queries/queries.test.js +14 -2
- package/build/browser/queries/queries.test.js.map +1 -1
- package/build/browser/util/UserAgent.js +2 -2
- package/build/browser/util/UserAgent.js.map +1 -1
- package/build/browser/util/toDataValue.js +0 -1
- package/build/browser/util/toDataValue.js.map +1 -1
- package/build/browser/util/toDataValue.test.js +4 -0
- package/build/browser/util/toDataValue.test.js.map +1 -1
- package/build/cjs/{chunk-6SCDLAU2.cjs → chunk-LDTMSHUZ.cjs} +4 -4
- package/build/cjs/{chunk-6SCDLAU2.cjs.map → chunk-LDTMSHUZ.cjs.map} +1 -1
- package/build/cjs/{chunk-BRUBBJUT.cjs → chunk-MZZAHBN6.cjs} +636 -138
- package/build/cjs/chunk-MZZAHBN6.cjs.map +1 -0
- package/build/cjs/{chunk-EHMN4DL4.cjs → chunk-RDZ5NKAI.cjs} +210 -129
- package/build/cjs/chunk-RDZ5NKAI.cjs.map +1 -0
- package/build/cjs/{createClient-DvwysJMX.d.cts → createClient-D5G3qzAO.d.cts} +1 -0
- package/build/cjs/{delay-KIUUJ5NJ.cjs → delay-W2TSML2P.cjs} +4 -4
- package/build/cjs/{delay-KIUUJ5NJ.cjs.map → delay-W2TSML2P.cjs.map} +1 -1
- package/build/cjs/index.cjs +12 -12
- package/build/cjs/index.d.cts +1 -1
- package/build/cjs/public/internal-node.cjs +219 -219
- package/build/cjs/public/internal.cjs +14 -14
- package/build/cjs/public/unstable-do-not-use.cjs +335 -145
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +9 -9
- package/build/esm/Client.js +1 -1
- package/build/esm/Client.js.map +1 -1
- package/build/esm/MinimalClientContext.js.map +1 -1
- package/build/esm/actions/actions.test.js +9 -0
- package/build/esm/actions/actions.test.js.map +1 -1
- package/build/esm/actions/applyAction.js +4 -0
- package/build/esm/actions/applyAction.js.map +1 -1
- package/build/esm/createClient.js +2 -1
- package/build/esm/createClient.js.map +1 -1
- package/build/esm/createMinimalClient.js +1 -0
- package/build/esm/createMinimalClient.js.map +1 -1
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +17 -1
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
- package/build/esm/fetchMetadata.test.js +31 -0
- package/build/esm/fetchMetadata.test.js.map +1 -1
- package/build/esm/intellisense.test.js +1 -1
- package/build/esm/intellisense.test.js.map +1 -1
- package/build/esm/object/aggregate.js +1 -0
- package/build/esm/object/aggregate.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/InterfaceHolder.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.js +3 -0
- package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +8 -0
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js +95 -3
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.js +18 -6
- package/build/esm/object/convertWireToOsdkObjects.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.test.js +189 -28
- package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/esm/object/fetchPage.js +18 -5
- package/build/esm/object/fetchPage.js.map +1 -1
- package/build/esm/object/fetchPage.test.js.map +1 -1
- package/build/esm/object/formatting/applyPropertyFormatter.js +58 -0
- package/build/esm/object/formatting/applyPropertyFormatter.js.map +1 -0
- package/build/esm/object/formatting/applyPropertyFormatter.test.js +726 -0
- package/build/esm/object/formatting/applyPropertyFormatter.test.js.map +1 -0
- package/build/esm/object/formatting/formatBoolean.js +23 -0
- package/build/esm/object/formatting/formatBoolean.js.map +1 -0
- package/build/esm/object/formatting/formatDateTime.js +158 -0
- package/build/esm/object/formatting/formatDateTime.js.map +1 -0
- package/build/esm/object/formatting/formatNumber.js +242 -0
- package/build/esm/object/formatting/formatNumber.js.map +1 -0
- package/build/esm/object/formatting/propertyFormattingUtils.js +39 -0
- package/build/esm/object/formatting/propertyFormattingUtils.js.map +1 -0
- package/build/esm/object/object.test.js +123 -0
- package/build/esm/object/object.test.js.map +1 -1
- package/build/esm/objectSet/InterfaceObjectSet.test.js +1 -1
- package/build/esm/objectSet/InterfaceObjectSet.test.js.map +1 -1
- package/build/esm/objectSet/ObjectSet.test.js +7 -6
- package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js +2 -2
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js +3 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/esm/objectSet/createObjectSet.js +13 -0
- package/build/esm/objectSet/createObjectSet.js.map +1 -1
- package/build/esm/objectSet/fetchLinksPage.js +57 -0
- package/build/esm/objectSet/fetchLinksPage.js.map +1 -0
- package/build/esm/objectSet/fetchLinksPage.test.js +102 -0
- package/build/esm/objectSet/fetchLinksPage.test.js.map +1 -0
- package/build/esm/observable/ListPayload.js.map +1 -1
- package/build/esm/observable/ObjectPayload.js.map +1 -1
- package/build/esm/observable/ObservableClient.js +0 -5
- package/build/esm/observable/ObservableClient.js.map +1 -1
- package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/esm/observable/internal/Store.test.js +104 -1
- package/build/esm/observable/internal/Store.test.js.map +1 -1
- package/build/esm/observable/internal/actions/OptimisticJob.js +1 -1
- package/build/esm/observable/internal/actions/OptimisticJob.js.map +1 -1
- package/build/esm/observable/internal/base-list/BaseListQuery.js +1 -1
- package/build/esm/observable/internal/base-list/BaseListQuery.js.map +1 -1
- package/build/esm/observable/internal/links/SpecificLinkQuery.js +9 -1
- package/build/esm/observable/internal/links/SpecificLinkQuery.js.map +1 -1
- package/build/esm/observable/internal/list/ListQuery.js +17 -2
- package/build/esm/observable/internal/list/ListQuery.js.map +1 -1
- package/build/esm/observable/internal/objectset/ObjectSetQuery.js +9 -7
- package/build/esm/observable/internal/objectset/ObjectSetQuery.js.map +1 -1
- package/build/esm/observable/internal/utils/rdpFieldOperations.js +46 -25
- package/build/esm/observable/internal/utils/rdpFieldOperations.js.map +1 -1
- package/build/esm/observable/internal/utils/rdpFieldOperations.test.js +172 -0
- package/build/esm/observable/internal/utils/rdpFieldOperations.test.js.map +1 -0
- package/build/esm/ontology/loadActionMetadata.js +3 -1
- package/build/esm/ontology/loadActionMetadata.js.map +1 -1
- package/build/esm/ontology/loadFullObjectMetadata.js +2 -1
- package/build/esm/ontology/loadFullObjectMetadata.js.map +1 -1
- package/build/esm/ontology/loadInterfaceMetadata.js +2 -1
- package/build/esm/ontology/loadInterfaceMetadata.js.map +1 -1
- package/build/esm/public/unstable-do-not-use.js.map +1 -1
- package/build/esm/queries/applyQuery.js +14 -0
- package/build/esm/queries/applyQuery.js.map +1 -1
- package/build/esm/queries/queries.test.js +14 -2
- package/build/esm/queries/queries.test.js.map +1 -1
- package/build/esm/util/UserAgent.js +2 -2
- package/build/esm/util/UserAgent.js.map +1 -1
- package/build/esm/util/toDataValue.js +0 -1
- package/build/esm/util/toDataValue.js.map +1 -1
- package/build/esm/util/toDataValue.test.js +4 -0
- package/build/esm/util/toDataValue.test.js.map +1 -1
- package/build/types/Client.d.ts +1 -1
- package/build/types/MinimalClientContext.d.ts +1 -0
- package/build/types/MinimalClientContext.d.ts.map +1 -1
- package/build/types/actions/applyAction.d.ts.map +1 -1
- package/build/types/createClient.d.ts +1 -0
- package/build/types/createClient.d.ts.map +1 -1
- package/build/types/object/convertWireToOsdkObjects/InternalSymbols.d.ts +2 -0
- package/build/types/object/convertWireToOsdkObjects/InternalSymbols.d.ts.map +1 -1
- package/build/types/object/convertWireToOsdkObjects.d.ts +4 -4
- package/build/types/object/convertWireToOsdkObjects.d.ts.map +1 -1
- package/build/types/object/fetchPage.d.ts.map +1 -1
- package/build/types/object/formatting/applyPropertyFormatter.d.ts +18 -0
- package/build/types/object/formatting/applyPropertyFormatter.d.ts.map +1 -0
- package/build/types/object/formatting/applyPropertyFormatter.test.d.ts +1 -0
- package/build/types/object/formatting/applyPropertyFormatter.test.d.ts.map +1 -0
- package/build/types/object/formatting/formatBoolean.d.ts +5 -0
- package/build/types/object/formatting/formatBoolean.d.ts.map +1 -0
- package/build/types/object/formatting/formatDateTime.d.ts +6 -0
- package/build/types/object/formatting/formatDateTime.d.ts.map +1 -0
- package/build/types/object/formatting/formatNumber.d.ts +15 -0
- package/build/types/object/formatting/formatNumber.d.ts.map +1 -0
- package/build/types/object/formatting/propertyFormattingUtils.d.ts +10 -0
- package/build/types/object/formatting/propertyFormattingUtils.d.ts.map +1 -0
- package/build/types/object/object.test.d.ts.map +1 -1
- package/build/types/objectSet/fetchLinksPage.d.ts +1 -0
- package/build/types/objectSet/fetchLinksPage.d.ts.map +1 -0
- package/build/types/objectSet/fetchLinksPage.test.d.ts +1 -0
- package/build/types/objectSet/fetchLinksPage.test.d.ts.map +1 -0
- package/build/types/observable/ListPayload.d.ts +3 -2
- package/build/types/observable/ListPayload.d.ts.map +1 -1
- package/build/types/observable/ObjectPayload.d.ts +2 -2
- package/build/types/observable/ObjectPayload.d.ts.map +1 -1
- package/build/types/observable/ObservableClient.d.ts +10 -7
- package/build/types/observable/ObservableClient.d.ts.map +1 -1
- package/build/types/observable/internal/Store.test.d.ts.map +1 -1
- package/build/types/observable/internal/actions/OptimisticJob.d.ts.map +1 -1
- package/build/types/observable/internal/links/SpecificLinkQuery.d.ts.map +1 -1
- package/build/types/observable/internal/list/ListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts.map +1 -1
- package/build/types/observable/internal/utils/rdpFieldOperations.d.ts.map +1 -1
- package/build/types/observable/internal/utils/rdpFieldOperations.test.d.ts +1 -0
- package/build/types/observable/internal/utils/rdpFieldOperations.test.d.ts.map +1 -0
- package/build/types/public/unstable-do-not-use.d.ts +1 -1
- package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
- package/build/types/queries/applyQuery.d.ts.map +1 -1
- package/package.json +14 -14
- package/build/cjs/chunk-BRUBBJUT.cjs.map +0 -1
- package/build/cjs/chunk-EHMN4DL4.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOsdkInterface.js","names":["extractNamespace","get$linkForInterface","InterfaceDefRef","ObjectDefRef","UnderlyingOsdkObject","createOsdkInterface","underlying","interfaceDef","objApiNamespace","apiName","Object","freeze","defineProperties","value","enumerable","$as","$objectType","$primaryKey","$objectSpecifier","$title","$rid","clone","get","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 } from \"@osdk/api\";\nimport { extractNamespace } from \"../../internal/conversions/extractNamespace.js\";\nimport type { FetchedObjectTypeDefinition } from \"../../ontology/OntologyProvider.js\";\nimport { get$linkForInterface } from \"./getDollarLink.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: ObjectHolder,\n interfaceDef: InterfaceMetadata,\n): InterfaceHolder {\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 \"$objectSpecifier\": {\n value: underlying.$objectSpecifier,\n enumerable: \"$objectSpecifier\" 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 \"$__EXPERIMENTAL__NOT_SUPPORTED_YET__metadata\": {\n value: {\n \"ObjectMetadata\": underlying[ObjectDefRef],\n \"InterfaceMetadata\": interfaceDef,\n },\n enumerable: false,\n },\n\n \"$link\": {\n get: function(this: InterfaceHolder) {\n return get$linkForInterface(this);\n },\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,\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,gDAAgD;AAEjF,SAASC,oBAAoB,QAAQ,oBAAoB;AAEzD,SACEC,eAAe,EACfC,YAAY,EACZC,oBAAoB,QACf,sBAAsB;AAG7B;AACA,OAAO,SAASC,mBAAmBA,CAGjCC,UAAwB,EACxBC,YAA+B,EACd;EACjB,MAAM,CAACC,eAAe,CAAC,GAAGR,gBAAgB,CAACO,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,kBAAkB,EAAE;MAClBO,KAAK,EAAEP,UAAU,CAACY,gBAAgB;MAClCJ,UAAU,EAAE,kBAAkB,IAAIR;IACpC,CAAC;IACD,QAAQ,EAAE;MACRO,KAAK,EAAEP,UAAU,CAACa,MAAM;MACxBL,UAAU,EAAE,QAAQ,IAAIR;IAC1B,CAAC;IACD,MAAM,EAAE;MACNO,KAAK,EAAGP,UAAU,CAASc,IAAI;MAC/BN,UAAU,EAAE,MAAM,IAAIR;IACxB,CAAC;IACD,QAAQ,EAAE;MACRO,KAAK,EAAEQ,KAAK;MACZP,UAAU,EAAE;IACd,CAAC;IACD,8CAA8C,EAAE;
|
|
1
|
+
{"version":3,"file":"createOsdkInterface.js","names":["extractNamespace","get$linkForInterface","InterfaceDefRef","ObjectDefRef","UnderlyingOsdkObject","createOsdkInterface","underlying","interfaceDef","objApiNamespace","apiName","Object","freeze","defineProperties","value","enumerable","$as","$objectType","$primaryKey","$objectSpecifier","$title","$rid","clone","$propertySecurities","$__EXPERIMENTAL__NOT_SUPPORTED_YET__getFormattedValue","get","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 } from \"@osdk/api\";\nimport { extractNamespace } from \"../../internal/conversions/extractNamespace.js\";\nimport type { FetchedObjectTypeDefinition } from \"../../ontology/OntologyProvider.js\";\nimport { get$linkForInterface } from \"./getDollarLink.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: ObjectHolder,\n interfaceDef: InterfaceMetadata,\n): InterfaceHolder {\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 \"$objectSpecifier\": {\n value: underlying.$objectSpecifier,\n enumerable: \"$objectSpecifier\" 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 \"$propertySecurities\": {\n value: underlying.$propertySecurities,\n enumerable: \"$propertySecurities\" in underlying,\n },\n \"$__EXPERIMENTAL__NOT_SUPPORTED_YET__metadata\": {\n value: {\n \"ObjectMetadata\": underlying[ObjectDefRef],\n \"InterfaceMetadata\": interfaceDef,\n },\n enumerable: false,\n },\n \"$__EXPERIMENTAL__NOT_SUPPORTED_YET__getFormattedValue\": {\n value: underlying.$__EXPERIMENTAL__NOT_SUPPORTED_YET__getFormattedValue,\n enumerable: false,\n },\n\n \"$link\": {\n get: function(this: InterfaceHolder) {\n return get$linkForInterface(this);\n },\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,\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,gDAAgD;AAEjF,SAASC,oBAAoB,QAAQ,oBAAoB;AAEzD,SACEC,eAAe,EACfC,YAAY,EACZC,oBAAoB,QACf,sBAAsB;AAG7B;AACA,OAAO,SAASC,mBAAmBA,CAGjCC,UAAwB,EACxBC,YAA+B,EACd;EACjB,MAAM,CAACC,eAAe,CAAC,GAAGR,gBAAgB,CAACO,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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,MAAMiB,MAAM,GAAGxB,UAAU,CAACH,YAAY,CAAC;IACvC,MAAM6B,cAAc,GAClBF,MAAM,CAACG,YAAY,CAAE1B,YAAY,CAACE,OAAO,CAAC,CAACiC,YAAY,CAAC;IAC1D;IACA,IAAIV,cAAc,IAAI,IAAI,EAAE;MAC1B,MAAM,IAAIK,KAAK,CACb,+BAA+BK,YAAY,iEAAiEZ,MAAM,CAACrB,OAAO,EAC5H,CAAC;IACH;IACA,OAAO,CAACuB,cAAc,EAAEnB,KAAK,CAAC;EAChC;AACF","ignoreList":[]}
|
|
@@ -20,9 +20,10 @@ import { MediaReferencePropertyImpl } from "../../createMediaReferenceProperty.j
|
|
|
20
20
|
import { TimeSeriesPropertyImpl } from "../../createTimeseriesProperty.js";
|
|
21
21
|
import { hydrateAttachmentFromRidInternal } from "../../public-utils/hydrateAttachmentFromRid.js";
|
|
22
22
|
import { createObjectSpecifierFromPrimaryKey } from "../../util/objectSpecifierUtils.js";
|
|
23
|
+
import { applyPropertyFormatter } from "../formatting/applyPropertyFormatter.js";
|
|
23
24
|
import { get$as } from "./getDollarAs.js";
|
|
24
25
|
import { get$link } from "./getDollarLink.js";
|
|
25
|
-
import { ClientRef, ObjectDefRef, UnderlyingOsdkObject } from "./InternalSymbols.js";
|
|
26
|
+
import { ClientRef, ObjectDefRef, PropertySecuritiesRef, UnderlyingOsdkObject } from "./InternalSymbols.js";
|
|
26
27
|
const specialPropertyTypes = new Set(["attachment", "geotimeSeriesReference", "mediaReference", "numericTimeseries", "stringTimeseries", "sensorTimeseries"]);
|
|
27
28
|
|
|
28
29
|
// kept separate so we are not redefining these functions
|
|
@@ -68,6 +69,12 @@ const basePropDefs = {
|
|
|
68
69
|
},
|
|
69
70
|
enumerable: true
|
|
70
71
|
},
|
|
72
|
+
"$propertySecurities": {
|
|
73
|
+
get: function () {
|
|
74
|
+
return this[PropertySecuritiesRef];
|
|
75
|
+
},
|
|
76
|
+
enumerable: true
|
|
77
|
+
},
|
|
71
78
|
"$__EXPERIMENTAL__NOT_SUPPORTED_YET__metadata": {
|
|
72
79
|
get: function () {
|
|
73
80
|
return {
|
|
@@ -75,6 +82,15 @@ const basePropDefs = {
|
|
|
75
82
|
};
|
|
76
83
|
},
|
|
77
84
|
enumerable: false
|
|
85
|
+
},
|
|
86
|
+
"$__EXPERIMENTAL__NOT_SUPPORTED_YET__getFormattedValue": {
|
|
87
|
+
value: function (propertyApiName, options) {
|
|
88
|
+
const rawObj = this[UnderlyingOsdkObject];
|
|
89
|
+
const def = this[ObjectDefRef];
|
|
90
|
+
const propertyValue = rawObj[propertyApiName];
|
|
91
|
+
return applyPropertyFormatter(propertyValue, def.properties[propertyApiName], rawObj, options);
|
|
92
|
+
},
|
|
93
|
+
enumerable: false
|
|
78
94
|
}
|
|
79
95
|
};
|
|
80
96
|
|
|
@@ -84,14 +100,23 @@ const basePropDefs = {
|
|
|
84
100
|
* @param objectDef
|
|
85
101
|
* @param simpleOsdkProperties
|
|
86
102
|
*/
|
|
87
|
-
export function createOsdkObject(client, objectDef, simpleOsdkProperties, derivedPropertyTypeByName = {}) {
|
|
103
|
+
export function createOsdkObject(client, objectDef, simpleOsdkProperties, derivedPropertyTypeByName = {}, wirePropertySecurities = []) {
|
|
104
|
+
const {
|
|
105
|
+
parsedObject,
|
|
106
|
+
clientPropertySecurities
|
|
107
|
+
} = parseWhenSecuritiesLoaded(wirePropertySecurities, simpleOsdkProperties, objectDef, derivedPropertyTypeByName);
|
|
108
|
+
|
|
88
109
|
// updates the object's "hidden class/map".
|
|
89
|
-
const rawObj =
|
|
110
|
+
const rawObj = parsedObject;
|
|
90
111
|
Object.defineProperties(rawObj, {
|
|
91
112
|
[UnderlyingOsdkObject]: {
|
|
92
113
|
enumerable: false,
|
|
93
114
|
value: simpleOsdkProperties
|
|
94
115
|
},
|
|
116
|
+
[PropertySecuritiesRef]: {
|
|
117
|
+
enumerable: false,
|
|
118
|
+
value: clientPropertySecurities
|
|
119
|
+
},
|
|
95
120
|
[ObjectDefRef]: {
|
|
96
121
|
value: objectDef,
|
|
97
122
|
enumerable: false
|
|
@@ -169,4 +194,71 @@ function createSpecialProperty(client, objectDef, rawObject, p) {
|
|
|
169
194
|
});
|
|
170
195
|
}
|
|
171
196
|
}
|
|
197
|
+
function parseWhenSecuritiesLoaded(wirePropertySecurities, rawObject, objectDef, derivedPropertyTypeByName = {}) {
|
|
198
|
+
if (wirePropertySecurities == null || wirePropertySecurities.length === 0) {
|
|
199
|
+
return {
|
|
200
|
+
parsedObject: rawObject,
|
|
201
|
+
clientPropertySecurities: undefined
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
const parsedObject = {
|
|
205
|
+
...rawObject
|
|
206
|
+
};
|
|
207
|
+
const clientPropertySecurities = {};
|
|
208
|
+
for (const propKey of Object.keys(rawObject)) {
|
|
209
|
+
if (propKey in objectDef.properties || propKey in derivedPropertyTypeByName) {
|
|
210
|
+
const value = rawObject[propKey];
|
|
211
|
+
if (Array.isArray(value)) {
|
|
212
|
+
const newVal = [];
|
|
213
|
+
const newSecurities = [];
|
|
214
|
+
value.forEach(spv => {
|
|
215
|
+
!(typeof spv === "object" && spv != null && "value" in spv && "propertySecurityIndex" in spv) ? process.env.NODE_ENV !== "production" ? invariant(false, "Expected destructured secured property value object in array") : invariant(false) : void 0;
|
|
216
|
+
const securedValue = spv;
|
|
217
|
+
newVal.push(securedValue.value);
|
|
218
|
+
const securityIndex = securedValue.propertySecurityIndex;
|
|
219
|
+
!(securityIndex != null) ? process.env.NODE_ENV !== "production" ? invariant(false, "Expected property security index to be defined") : invariant(false) : void 0;
|
|
220
|
+
!(securityIndex < wirePropertySecurities.length) ? process.env.NODE_ENV !== "production" ? invariant(false, "Expected property security index to be within bounds") : invariant(false) : void 0;
|
|
221
|
+
newSecurities.push(wirePropertySecurities[securityIndex].disjunction.map(wireToClientPropertySecurities));
|
|
222
|
+
});
|
|
223
|
+
parsedObject[propKey] = newVal;
|
|
224
|
+
clientPropertySecurities[propKey] = newSecurities;
|
|
225
|
+
} // Check if this is a secured property value object
|
|
226
|
+
else if (typeof value === "object" && value != null && "value" in value && "propertySecurityIndex" in value) {
|
|
227
|
+
const securedValue = value;
|
|
228
|
+
parsedObject[propKey] = securedValue.value;
|
|
229
|
+
const securityIndex = securedValue.propertySecurityIndex;
|
|
230
|
+
!(securityIndex != null) ? process.env.NODE_ENV !== "production" ? invariant(false, "Expected property security index to be defined") : invariant(false) : void 0;
|
|
231
|
+
!(securityIndex < wirePropertySecurities.length) ? process.env.NODE_ENV !== "production" ? invariant(false, "Expected property security index to be within bounds") : invariant(false) : void 0;
|
|
232
|
+
clientPropertySecurities[propKey] = wirePropertySecurities[securityIndex].disjunction.map(wireToClientPropertySecurities);
|
|
233
|
+
} else {
|
|
234
|
+
// Regular property without security
|
|
235
|
+
parsedObject[propKey] = value;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
parsedObject,
|
|
241
|
+
clientPropertySecurities
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function wireToClientPropertySecurities(propertySecurity) {
|
|
245
|
+
switch (propertySecurity.type) {
|
|
246
|
+
case "propertyMarkingSummary":
|
|
247
|
+
return {
|
|
248
|
+
type: "propertyMarkings",
|
|
249
|
+
conjunctive: propertySecurity.conjunctive,
|
|
250
|
+
containerConjunctive: propertySecurity.containerConjunctive,
|
|
251
|
+
disjunctive: propertySecurity.disjunctive,
|
|
252
|
+
containerDisjunctive: propertySecurity.containerDisjunctive
|
|
253
|
+
};
|
|
254
|
+
case "errorComputingSecurity":
|
|
255
|
+
return {
|
|
256
|
+
type: "errorComputingSecurity"
|
|
257
|
+
};
|
|
258
|
+
case "unsupportedPolicy":
|
|
259
|
+
return {
|
|
260
|
+
type: "unsupportedPolicy"
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
}
|
|
172
264
|
//# sourceMappingURL=createOsdkObject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOsdkObject.js","names":["invariant","GeotimeSeriesPropertyImpl","MediaReferencePropertyImpl","TimeSeriesPropertyImpl","hydrateAttachmentFromRidInternal","createObjectSpecifierFromPrimaryKey","get$as","get$link","ClientRef","ObjectDefRef","UnderlyingOsdkObject","specialPropertyTypes","Set","basePropDefs","get","value","update","rawObj","def","createOsdkObject","primaryKeyApiName","Error","apiName","titleProperty","$title","newObject","$primaryKey","enumerable","ObjectMetadata","client","objectDef","simpleOsdkProperties","derivedPropertyTypeByName","Object","defineProperties","propKey","keys","properties","type","has","createSpecialProperty","modifyRdpProperties","freeze","rawValue","definition","operation","num","Number","isSafeInteger","process","env","NODE_ENV","selectedOrCollectedPropertyType","Array","isArray","map","a","rid","rawObject","p","propDef","time","timestamp","coordinates","position","undefined","objectApiName","primaryKey","propertyName","mediaReference"],"sources":["createOsdkObject.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 { MediaReference } from \"@osdk/foundry.core\";\nimport type { Attachment, ReferenceValue } from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport { GeotimeSeriesPropertyImpl } from \"../../createGeotimeSeriesProperty.js\";\nimport { MediaReferencePropertyImpl } from \"../../createMediaReferenceProperty.js\";\nimport { TimeSeriesPropertyImpl } from \"../../createTimeseriesProperty.js\";\nimport type { DerivedPropertyRuntimeMetadata } from \"../../derivedProperties/derivedPropertyRuntimeMetadata.js\";\nimport type { MinimalClient } from \"../../MinimalClientContext.js\";\nimport type { FetchedObjectTypeDefinition } from \"../../ontology/OntologyProvider.js\";\nimport { hydrateAttachmentFromRidInternal } from \"../../public-utils/hydrateAttachmentFromRid.js\";\nimport { createObjectSpecifierFromPrimaryKey } from \"../../util/objectSpecifierUtils.js\";\nimport type { SimpleOsdkProperties } from \"../SimpleOsdkProperties.js\";\nimport { get$as } from \"./getDollarAs.js\";\nimport { get$link } from \"./getDollarLink.js\";\nimport {\n ClientRef,\n ObjectDefRef,\n UnderlyingOsdkObject,\n} from \"./InternalSymbols.js\";\nimport type { ObjectHolder } from \"./ObjectHolder.js\";\n\nconst specialPropertyTypes = new Set(\n [\n \"attachment\",\n \"geotimeSeriesReference\",\n \"mediaReference\",\n \"numericTimeseries\",\n \"stringTimeseries\",\n \"sensorTimeseries\",\n ],\n);\n\n// kept separate so we are not redefining these functions\n// every time an object is created.\nconst basePropDefs = {\n \"$as\": {\n get: function(this: ObjectHolder) {\n return get$as(this[ObjectDefRef]);\n },\n },\n \"$link\": {\n get: function(this: ObjectHolder) {\n return get$link(this);\n },\n },\n \"$clone\": {\n value: function(\n this: ObjectHolder,\n update: Record<string, any> | undefined,\n ) {\n // I think `rawObj` is the same thing as `this` and can be removed?\n const rawObj = this[UnderlyingOsdkObject] as SimpleOsdkProperties;\n const def = this[ObjectDefRef];\n\n if (update == null) {\n return createOsdkObject(this[ClientRef], def, { ...rawObj });\n }\n\n if (\n def.primaryKeyApiName in update\n && rawObj[def.primaryKeyApiName] !== update[def.primaryKeyApiName]\n ) {\n throw new Error(\n `Cannot update ${def.apiName} object with differing primary key values `,\n );\n }\n\n if (def.titleProperty in update && !(\"$title\" in update)) {\n update.$title = update[def.titleProperty];\n }\n\n const newObject = { ...this[UnderlyingOsdkObject], ...update };\n return createOsdkObject(this[ClientRef], this[ObjectDefRef], newObject);\n },\n },\n \"$objectSpecifier\": {\n get: function(this: ObjectHolder) {\n const rawObj = this[UnderlyingOsdkObject];\n return createObjectSpecifierFromPrimaryKey(\n this[ObjectDefRef],\n rawObj.$primaryKey,\n );\n },\n enumerable: true,\n },\n \"$__EXPERIMENTAL__NOT_SUPPORTED_YET__metadata\": {\n get: function(this: ObjectHolder) {\n return {\n ObjectMetadata: this[ObjectDefRef],\n };\n },\n enumerable: false,\n },\n};\n\n/**\n * @internal\n * @param client\n * @param objectDef\n * @param simpleOsdkProperties\n */\nexport function createOsdkObject(\n client: MinimalClient,\n objectDef: FetchedObjectTypeDefinition,\n simpleOsdkProperties: SimpleOsdkProperties,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata = {},\n): ObjectHolder {\n // updates the object's \"hidden class/map\".\n const rawObj = simpleOsdkProperties as ObjectHolder;\n Object.defineProperties(\n rawObj,\n {\n [UnderlyingOsdkObject]: {\n enumerable: false,\n value: simpleOsdkProperties,\n },\n [ObjectDefRef]: { value: objectDef, enumerable: false }, // TODO: Potentially update when GA metadata field\n [ClientRef]: { value: client, enumerable: false },\n ...basePropDefs,\n } satisfies Record<keyof ObjectHolder, PropertyDescriptor>,\n );\n\n // Assign the special values\n for (const propKey of Object.keys(rawObj)) {\n if (\n propKey in objectDef.properties\n && typeof (objectDef.properties[propKey].type) === \"string\"\n && specialPropertyTypes.has(objectDef.properties[propKey].type)\n ) {\n rawObj[propKey] = createSpecialProperty(\n client,\n objectDef,\n rawObj,\n propKey,\n );\n } else if (propKey in derivedPropertyTypeByName) {\n rawObj[propKey] = modifyRdpProperties(\n client,\n derivedPropertyTypeByName,\n rawObj[propKey],\n propKey,\n );\n }\n }\n\n return Object.freeze(rawObj);\n}\n\nfunction modifyRdpProperties(\n client: MinimalClient,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata,\n rawValue: any,\n propKey: string,\n): any {\n if (\n derivedPropertyTypeByName[propKey].definition.type === \"selection\"\n && derivedPropertyTypeByName[propKey].definition.operation.type\n === \"count\"\n ) {\n const num = Number(rawValue);\n invariant(\n Number.isSafeInteger(num),\n \"Count aggregation for derived property \" + propKey\n + \" returned a value larger than safe integer.\",\n );\n return num;\n } // Selected or collected properties need to be deserialized specially when constructed with RDP\n else if (\n derivedPropertyTypeByName[propKey].selectedOrCollectedPropertyType\n != null\n && typeof (derivedPropertyTypeByName[propKey]\n .selectedOrCollectedPropertyType.type)\n === \"string\"\n && specialPropertyTypes.has(\n derivedPropertyTypeByName[propKey].selectedOrCollectedPropertyType\n .type,\n )\n ) {\n switch (\n derivedPropertyTypeByName[propKey].selectedOrCollectedPropertyType\n ?.type\n ) {\n case \"attachment\":\n if (Array.isArray(rawValue)) {\n return rawValue.map(a =>\n hydrateAttachmentFromRidInternal(client, a.rid)\n );\n } else {\n return hydrateAttachmentFromRidInternal(\n client,\n (rawValue as Attachment).rid,\n );\n }\n break;\n default:\n invariant(\n false,\n \"Derived property aggregations for Timeseries and Media are not supported\",\n );\n }\n }\n return rawValue;\n}\n\nfunction createSpecialProperty(\n client: MinimalClient,\n objectDef: FetchedObjectTypeDefinition,\n rawObject: ObjectHolder,\n p: keyof typeof rawObject & string | symbol,\n) {\n const rawValue = rawObject[p as any];\n const propDef = objectDef.properties[p as any];\n if (process.env.NODE_ENV !== \"production\") {\n invariant(\n propDef != null && typeof propDef.type === \"string\"\n && specialPropertyTypes.has(propDef.type),\n );\n }\n if (propDef.type === \"attachment\") {\n if (Array.isArray(rawValue)) {\n return rawValue.map(a => hydrateAttachmentFromRidInternal(client, a.rid));\n }\n return hydrateAttachmentFromRidInternal(\n client,\n (rawValue as Attachment).rid,\n );\n }\n\n if (\n propDef.type === \"numericTimeseries\"\n || propDef.type === \"stringTimeseries\"\n || propDef.type === \"sensorTimeseries\"\n ) {\n return new TimeSeriesPropertyImpl<\n (typeof propDef)[\"type\"] extends \"numericTimeseries\" ? number\n : (typeof propDef)[\"type\"] extends \"stringTimeseries\" ? string\n : number | string\n >(\n client,\n objectDef.apiName,\n rawObject[objectDef.primaryKeyApiName as string],\n p as string,\n );\n }\n\n if (propDef.type === \"geotimeSeriesReference\") {\n return new GeotimeSeriesPropertyImpl<GeoJSON.Point>(\n client,\n objectDef.apiName,\n rawObject[objectDef.primaryKeyApiName as string],\n p as string,\n (rawValue as ReferenceValue).type === \"geotimeSeriesValue\"\n ? {\n time: (rawValue as ReferenceValue).timestamp,\n value: {\n type: \"Point\",\n coordinates: (rawValue as ReferenceValue).position,\n },\n }\n : undefined,\n );\n }\n if (propDef.type === \"mediaReference\") {\n return new MediaReferencePropertyImpl({\n client,\n objectApiName: objectDef.apiName,\n primaryKey: rawObject[objectDef.primaryKeyApiName as string],\n propertyName: p as string,\n mediaReference: rawValue as MediaReference,\n });\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,yBAAyB,QAAQ,sCAAsC;AAChF,SAASC,0BAA0B,QAAQ,uCAAuC;AAClF,SAASC,sBAAsB,QAAQ,mCAAmC;AAI1E,SAASC,gCAAgC,QAAQ,gDAAgD;AACjG,SAASC,mCAAmC,QAAQ,oCAAoC;AAExF,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SACEC,SAAS,EACTC,YAAY,EACZC,oBAAoB,QACf,sBAAsB;AAG7B,MAAMC,oBAAoB,GAAG,IAAIC,GAAG,CAClC,CACE,YAAY,EACZ,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,CAEtB,CAAC;;AAED;AACA;AACA,MAAMC,YAAY,GAAG;EACnB,KAAK,EAAE;IACLC,GAAG,EAAE,SAAAA,CAAA,EAA6B;MAChC,OAAOR,MAAM,CAAC,IAAI,CAACG,YAAY,CAAC,CAAC;IACnC;EACF,CAAC;EACD,OAAO,EAAE;IACPK,GAAG,EAAE,SAAAA,CAAA,EAA6B;MAChC,OAAOP,QAAQ,CAAC,IAAI,CAAC;IACvB;EACF,CAAC;EACD,QAAQ,EAAE;IACRQ,KAAK,EAAE,SAAAA,CAELC,MAAuC,EACvC;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oBL,IAAI,KAAK,oBAAoB,GACtD;MACAuB,IAAI,EAAGlB,QAAQ,CAAoBmB,SAAS;MAC5C/C,KAAK,EAAE;QACLuB,IAAI,EAAE,OAAO;QACbyB,WAAW,EAAGpB,QAAQ,CAAoBqB;MAC5C;IACF,CAAC,GACCC,SACN,CAAC;EACH;EACA,IAAIL,OAAO,CAACtB,IAAI,KAAK,gBAAgB,EAAE;IACrC,OAAO,IAAIpC,0BAA0B,CAAC;MACpC2B,MAAM;MACNqC,aAAa,EAAEpC,SAAS,CAACR,OAAO;MAChC6C,UAAU,EAAET,SAAS,CAAC5B,SAAS,CAACV,iBAAiB,CAAW;MAC5DgD,YAAY,EAAET,CAAW;MACzBU,cAAc,EAAE1B;IAClB,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"createOsdkObject.js","names":["invariant","GeotimeSeriesPropertyImpl","MediaReferencePropertyImpl","TimeSeriesPropertyImpl","hydrateAttachmentFromRidInternal","createObjectSpecifierFromPrimaryKey","applyPropertyFormatter","get$as","get$link","ClientRef","ObjectDefRef","PropertySecuritiesRef","UnderlyingOsdkObject","specialPropertyTypes","Set","basePropDefs","get","value","update","rawObj","def","createOsdkObject","primaryKeyApiName","Error","apiName","titleProperty","$title","newObject","$primaryKey","enumerable","ObjectMetadata","propertyApiName","options","propertyValue","properties","client","objectDef","simpleOsdkProperties","derivedPropertyTypeByName","wirePropertySecurities","parsedObject","clientPropertySecurities","parseWhenSecuritiesLoaded","Object","defineProperties","propKey","keys","type","has","createSpecialProperty","modifyRdpProperties","freeze","rawValue","definition","operation","num","Number","isSafeInteger","process","env","NODE_ENV","selectedOrCollectedPropertyType","Array","isArray","map","a","rid","rawObject","p","propDef","time","timestamp","coordinates","position","undefined","objectApiName","primaryKey","propertyName","mediaReference","length","newVal","newSecurities","forEach","spv","securedValue","push","securityIndex","propertySecurityIndex","disjunction","wireToClientPropertySecurities","propertySecurity","conjunctive","containerConjunctive","disjunctive","containerDisjunctive"],"sources":["createOsdkObject.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 { PropertySecurity } from \"@osdk/api\";\nimport type { MediaReference } from \"@osdk/foundry.core\";\nimport type {\n Attachment,\n PropertySecurities,\n PropertySecurity as WirePropertySecurity,\n ReferenceValue,\n SecuredPropertyValue,\n} from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport { GeotimeSeriesPropertyImpl } from \"../../createGeotimeSeriesProperty.js\";\nimport { MediaReferencePropertyImpl } from \"../../createMediaReferenceProperty.js\";\nimport { TimeSeriesPropertyImpl } from \"../../createTimeseriesProperty.js\";\nimport type { DerivedPropertyRuntimeMetadata } from \"../../derivedProperties/derivedPropertyRuntimeMetadata.js\";\nimport type { MinimalClient } from \"../../MinimalClientContext.js\";\nimport type { FetchedObjectTypeDefinition } from \"../../ontology/OntologyProvider.js\";\nimport { hydrateAttachmentFromRidInternal } from \"../../public-utils/hydrateAttachmentFromRid.js\";\nimport { createObjectSpecifierFromPrimaryKey } from \"../../util/objectSpecifierUtils.js\";\nimport {\n applyPropertyFormatter,\n type FormatPropertyOptions,\n} from \"../formatting/applyPropertyFormatter.js\";\nimport type { SimpleOsdkProperties } from \"../SimpleOsdkProperties.js\";\nimport { get$as } from \"./getDollarAs.js\";\nimport { get$link } from \"./getDollarLink.js\";\nimport {\n ClientRef,\n ObjectDefRef,\n PropertySecuritiesRef,\n UnderlyingOsdkObject,\n} from \"./InternalSymbols.js\";\nimport type { ObjectHolder } from \"./ObjectHolder.js\";\n\nconst specialPropertyTypes = new Set(\n [\n \"attachment\",\n \"geotimeSeriesReference\",\n \"mediaReference\",\n \"numericTimeseries\",\n \"stringTimeseries\",\n \"sensorTimeseries\",\n ],\n);\n\n// kept separate so we are not redefining these functions\n// every time an object is created.\nconst basePropDefs = {\n \"$as\": {\n get: function(this: ObjectHolder) {\n return get$as(this[ObjectDefRef]);\n },\n },\n \"$link\": {\n get: function(this: ObjectHolder) {\n return get$link(this);\n },\n },\n \"$clone\": {\n value: function(\n this: ObjectHolder,\n update: Record<string, any> | undefined,\n ) {\n // I think `rawObj` is the same thing as `this` and can be removed?\n const rawObj = this[UnderlyingOsdkObject] as SimpleOsdkProperties;\n const def = this[ObjectDefRef];\n\n if (update == null) {\n return createOsdkObject(this[ClientRef], def, { ...rawObj });\n }\n\n if (\n def.primaryKeyApiName in update\n && rawObj[def.primaryKeyApiName] !== update[def.primaryKeyApiName]\n ) {\n throw new Error(\n `Cannot update ${def.apiName} object with differing primary key values `,\n );\n }\n\n if (def.titleProperty in update && !(\"$title\" in update)) {\n update.$title = update[def.titleProperty];\n }\n\n const newObject = { ...this[UnderlyingOsdkObject], ...update };\n return createOsdkObject(this[ClientRef], this[ObjectDefRef], newObject);\n },\n },\n \"$objectSpecifier\": {\n get: function(this: ObjectHolder) {\n const rawObj = this[UnderlyingOsdkObject];\n return createObjectSpecifierFromPrimaryKey(\n this[ObjectDefRef],\n rawObj.$primaryKey,\n );\n },\n enumerable: true,\n },\n \"$propertySecurities\": {\n get: function(this: ObjectHolder) {\n return this[PropertySecuritiesRef];\n },\n enumerable: true,\n },\n \"$__EXPERIMENTAL__NOT_SUPPORTED_YET__metadata\": {\n get: function(this: ObjectHolder) {\n return {\n ObjectMetadata: this[ObjectDefRef],\n };\n },\n enumerable: false,\n },\n \"$__EXPERIMENTAL__NOT_SUPPORTED_YET__getFormattedValue\": {\n value: function(\n this: ObjectHolder,\n propertyApiName: string,\n options?: FormatPropertyOptions,\n ): string | undefined {\n const rawObj = this[UnderlyingOsdkObject] as SimpleOsdkProperties;\n const def = this[ObjectDefRef];\n const propertyValue = rawObj[propertyApiName];\n\n return applyPropertyFormatter(\n propertyValue,\n def.properties[propertyApiName],\n rawObj,\n options,\n );\n },\n enumerable: false,\n },\n};\n\n/**\n * @internal\n * @param client\n * @param objectDef\n * @param simpleOsdkProperties\n */\nexport function createOsdkObject(\n client: MinimalClient,\n objectDef: FetchedObjectTypeDefinition,\n simpleOsdkProperties: SimpleOsdkProperties,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata = {},\n wirePropertySecurities: PropertySecurities[] | undefined = [],\n): ObjectHolder {\n const { parsedObject, clientPropertySecurities } = parseWhenSecuritiesLoaded(\n wirePropertySecurities,\n simpleOsdkProperties,\n objectDef,\n derivedPropertyTypeByName,\n );\n\n // updates the object's \"hidden class/map\".\n const rawObj = parsedObject as ObjectHolder;\n Object.defineProperties(\n rawObj,\n {\n [UnderlyingOsdkObject]: {\n enumerable: false,\n value: simpleOsdkProperties,\n },\n [PropertySecuritiesRef]: {\n enumerable: false,\n value: clientPropertySecurities,\n },\n [ObjectDefRef]: { value: objectDef, enumerable: false }, // TODO: Potentially update when GA metadata field\n [ClientRef]: { value: client, enumerable: false },\n ...basePropDefs,\n } satisfies Record<keyof ObjectHolder, PropertyDescriptor>,\n );\n\n // Assign the special values\n for (const propKey of Object.keys(rawObj)) {\n if (\n propKey in objectDef.properties\n && typeof (objectDef.properties[propKey].type) === \"string\"\n && specialPropertyTypes.has(objectDef.properties[propKey].type)\n ) {\n rawObj[propKey] = createSpecialProperty(\n client,\n objectDef,\n rawObj,\n propKey,\n );\n } else if (propKey in derivedPropertyTypeByName) {\n rawObj[propKey] = modifyRdpProperties(\n client,\n derivedPropertyTypeByName,\n rawObj[propKey],\n propKey,\n );\n }\n }\n\n return Object.freeze(rawObj);\n}\n\nfunction modifyRdpProperties(\n client: MinimalClient,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata,\n rawValue: any,\n propKey: string,\n): any {\n if (\n derivedPropertyTypeByName[propKey].definition.type === \"selection\"\n && derivedPropertyTypeByName[propKey].definition.operation.type\n === \"count\"\n ) {\n const num = Number(rawValue);\n invariant(\n Number.isSafeInteger(num),\n \"Count aggregation for derived property \" + propKey\n + \" returned a value larger than safe integer.\",\n );\n return num;\n } // Selected or collected properties need to be deserialized specially when constructed with RDP\n else if (\n derivedPropertyTypeByName[propKey].selectedOrCollectedPropertyType\n != null\n && typeof (derivedPropertyTypeByName[propKey]\n .selectedOrCollectedPropertyType.type)\n === \"string\"\n && specialPropertyTypes.has(\n derivedPropertyTypeByName[propKey].selectedOrCollectedPropertyType\n .type,\n )\n ) {\n switch (\n derivedPropertyTypeByName[propKey].selectedOrCollectedPropertyType\n ?.type\n ) {\n case \"attachment\":\n if (Array.isArray(rawValue)) {\n return rawValue.map(a =>\n hydrateAttachmentFromRidInternal(client, a.rid)\n );\n } else {\n return hydrateAttachmentFromRidInternal(\n client,\n (rawValue as Attachment).rid,\n );\n }\n break;\n default:\n invariant(\n false,\n \"Derived property aggregations for Timeseries and Media are not supported\",\n );\n }\n }\n return rawValue;\n}\n\nfunction createSpecialProperty(\n client: MinimalClient,\n objectDef: FetchedObjectTypeDefinition,\n rawObject: ObjectHolder,\n p: keyof typeof rawObject & string | symbol,\n) {\n const rawValue = rawObject[p as any];\n const propDef = objectDef.properties[p as any];\n if (process.env.NODE_ENV !== \"production\") {\n invariant(\n propDef != null && typeof propDef.type === \"string\"\n && specialPropertyTypes.has(propDef.type),\n );\n }\n if (propDef.type === \"attachment\") {\n if (Array.isArray(rawValue)) {\n return rawValue.map(a => hydrateAttachmentFromRidInternal(client, a.rid));\n }\n return hydrateAttachmentFromRidInternal(\n client,\n (rawValue as Attachment).rid,\n );\n }\n\n if (\n propDef.type === \"numericTimeseries\"\n || propDef.type === \"stringTimeseries\"\n || propDef.type === \"sensorTimeseries\"\n ) {\n return new TimeSeriesPropertyImpl<\n (typeof propDef)[\"type\"] extends \"numericTimeseries\" ? number\n : (typeof propDef)[\"type\"] extends \"stringTimeseries\" ? string\n : number | string\n >(\n client,\n objectDef.apiName,\n rawObject[objectDef.primaryKeyApiName as string],\n p as string,\n );\n }\n\n if (propDef.type === \"geotimeSeriesReference\") {\n return new GeotimeSeriesPropertyImpl<GeoJSON.Point>(\n client,\n objectDef.apiName,\n rawObject[objectDef.primaryKeyApiName as string],\n p as string,\n (rawValue as ReferenceValue).type === \"geotimeSeriesValue\"\n ? {\n time: (rawValue as ReferenceValue).timestamp,\n value: {\n type: \"Point\",\n coordinates: (rawValue as ReferenceValue).position,\n },\n }\n : undefined,\n );\n }\n if (propDef.type === \"mediaReference\") {\n return new MediaReferencePropertyImpl({\n client,\n objectApiName: objectDef.apiName,\n primaryKey: rawObject[objectDef.primaryKeyApiName as string],\n propertyName: p as string,\n mediaReference: rawValue as MediaReference,\n });\n }\n}\n\nfunction parseWhenSecuritiesLoaded(\n wirePropertySecurities: PropertySecurities[] | undefined,\n rawObject: SimpleOsdkProperties,\n objectDef: FetchedObjectTypeDefinition,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata = {},\n): {\n parsedObject: SimpleOsdkProperties;\n clientPropertySecurities:\n | { [propName: string]: PropertySecurity[] | PropertySecurity[][] }\n | undefined;\n} {\n if (wirePropertySecurities == null || wirePropertySecurities.length === 0) {\n return { parsedObject: rawObject, clientPropertySecurities: undefined };\n }\n\n const parsedObject: SimpleOsdkProperties = { ...rawObject };\n const clientPropertySecurities: {\n [propName: string]: PropertySecurity[] | PropertySecurity[][];\n } = {};\n\n for (const propKey of Object.keys(rawObject)) {\n if (\n propKey in objectDef.properties || propKey in derivedPropertyTypeByName\n ) {\n const value = rawObject[propKey];\n\n if (Array.isArray(value)) {\n const newVal: any[] = [];\n const newSecurities: PropertySecurity[][] = [];\n value.forEach(spv => {\n invariant(\n typeof spv === \"object\"\n && spv != null\n && \"value\" in spv\n && \"propertySecurityIndex\" in spv,\n \"Expected destructured secured property value object in array\",\n );\n const securedValue = spv as SecuredPropertyValue;\n newVal.push(securedValue.value);\n const securityIndex = securedValue.propertySecurityIndex;\n invariant(\n securityIndex != null,\n \"Expected property security index to be defined\",\n );\n invariant(\n securityIndex < wirePropertySecurities.length,\n \"Expected property security index to be within bounds\",\n );\n newSecurities.push(\n wirePropertySecurities[securityIndex].disjunction\n .map(wireToClientPropertySecurities),\n );\n });\n parsedObject[propKey] = newVal;\n clientPropertySecurities[propKey] = newSecurities;\n } // Check if this is a secured property value object\n else if (\n typeof value === \"object\"\n && value != null\n && \"value\" in value\n && \"propertySecurityIndex\" in value\n ) {\n const securedValue = value as SecuredPropertyValue;\n parsedObject[propKey] = securedValue.value;\n\n const securityIndex = securedValue.propertySecurityIndex;\n invariant(\n securityIndex != null,\n \"Expected property security index to be defined\",\n );\n invariant(\n securityIndex < wirePropertySecurities.length,\n \"Expected property security index to be within bounds\",\n );\n clientPropertySecurities[propKey] =\n wirePropertySecurities[securityIndex].disjunction\n .map(wireToClientPropertySecurities);\n } else {\n // Regular property without security\n parsedObject[propKey] = value;\n }\n }\n }\n\n return { parsedObject, clientPropertySecurities };\n}\n\nfunction wireToClientPropertySecurities(\n propertySecurity: WirePropertySecurity,\n): PropertySecurity {\n switch (propertySecurity.type) {\n case \"propertyMarkingSummary\":\n return {\n type: \"propertyMarkings\",\n conjunctive: propertySecurity.conjunctive,\n containerConjunctive: propertySecurity.containerConjunctive,\n disjunctive: propertySecurity.disjunctive,\n containerDisjunctive: propertySecurity.containerDisjunctive,\n };\n case \"errorComputingSecurity\":\n return { type: \"errorComputingSecurity\" };\n case \"unsupportedPolicy\":\n return { type: \"unsupportedPolicy\" };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,yBAAyB,QAAQ,sCAAsC;AAChF,SAASC,0BAA0B,QAAQ,uCAAuC;AAClF,SAASC,sBAAsB,QAAQ,mC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sdkObject.js
|
|
|
32
32
|
* @internal
|
|
33
33
|
* @param interfaceApiName - if undefined
|
|
34
34
|
*/
|
|
35
|
-
export async function convertWireToOsdkObjects(client, objects, interfaceApiName, forceRemoveRid = false, derivedPropertyTypesByName, selectedProps, strictNonNull = false) {
|
|
35
|
+
export async function convertWireToOsdkObjects(client, objects, interfaceApiName, forceRemoveRid = false, derivedPropertyTypesByName, propertySecurities, selectedProps, strictNonNull = false) {
|
|
36
36
|
// remove the __ prefixed properties and convert them to $ prefixed.
|
|
37
37
|
// updates in place
|
|
38
38
|
fixObjectPropertiesInPlace(objects, forceRemoveRid);
|
|
@@ -61,7 +61,7 @@ export async function convertWireToOsdkObjects(client, objects, interfaceApiName
|
|
|
61
61
|
} else if (strictNonNull === "drop" && !conforming) {
|
|
62
62
|
continue;
|
|
63
63
|
}
|
|
64
|
-
let osdkObject = createOsdkObject(client, objectDef, rawObj, derivedPropertyTypesByName);
|
|
64
|
+
let osdkObject = createOsdkObject(client, objectDef, rawObj, derivedPropertyTypesByName, propertySecurities);
|
|
65
65
|
if (interfaceApiName) osdkObject = osdkObject.$as(interfaceApiName);
|
|
66
66
|
ret.push(osdkObject);
|
|
67
67
|
}
|
|
@@ -70,14 +70,17 @@ export async function convertWireToOsdkObjects(client, objects, interfaceApiName
|
|
|
70
70
|
/**
|
|
71
71
|
* @internal
|
|
72
72
|
*/
|
|
73
|
-
export async function convertWireToOsdkObjects2(client, objects, interfaceApiName, derivedPropertyTypeByName, forceRemoveRid = false, selectedProps, strictNonNull = false, interfaceToObjectTypeMappings = {}) {
|
|
73
|
+
export async function convertWireToOsdkObjects2(client, objects, interfaceApiName, derivedPropertyTypeByName, propertySecurities, forceRemoveRid = false, selectedProps, strictNonNull = false, interfaceToObjectTypeMappings = {}, interfaceToObjectTypeMappingsV2 = {}) {
|
|
74
74
|
fixObjectPropertiesInPlace(objects, forceRemoveRid);
|
|
75
|
-
|
|
75
|
+
|
|
76
|
+
// prefer V2 mappings if non-empty, otherwise fall back to V1
|
|
77
|
+
const effectiveMappings = Object.keys(interfaceToObjectTypeMappingsV2).length > 0 ? convertInterfaceToObjectTypeMappingsV2ToV1(interfaceToObjectTypeMappingsV2) : interfaceToObjectTypeMappings;
|
|
78
|
+
const isInterfaceScoped = Object.keys(effectiveMappings).length > 0;
|
|
76
79
|
const ret = [];
|
|
77
80
|
for (const rawObj of objects) {
|
|
78
81
|
const objectDef = await client.ontologyProvider.getObjectDefinition(rawObj.$apiName);
|
|
79
82
|
!objectDef ? process.env.NODE_ENV !== "production" ? invariant(false, `Missing definition for '${rawObj.$apiName}'`) : invariant(false) : void 0;
|
|
80
|
-
const interfaceToObjMapping = interfaceApiName && isInterfaceScoped ?
|
|
83
|
+
const interfaceToObjMapping = interfaceApiName && isInterfaceScoped ? effectiveMappings[interfaceApiName][rawObj.$apiName] : undefined;
|
|
81
84
|
const ifaceSelected = interfaceApiName && interfaceToObjMapping ? selectedProps ? Object.keys(interfaceToObjMapping).filter(val => {
|
|
82
85
|
selectedProps?.includes(interfaceToObjMapping[val]);
|
|
83
86
|
}) : [...Object.values(interfaceToObjMapping), objectDef.primaryKeyApiName] : undefined;
|
|
@@ -97,7 +100,7 @@ export async function convertWireToOsdkObjects2(client, objects, interfaceApiNam
|
|
|
97
100
|
} else if (strictNonNull === "drop" && !conforming) {
|
|
98
101
|
continue;
|
|
99
102
|
}
|
|
100
|
-
let osdkObject = createOsdkObject(client, objectDef, rawObj, derivedPropertyTypeByName);
|
|
103
|
+
let osdkObject = createOsdkObject(client, objectDef, rawObj, derivedPropertyTypeByName, propertySecurities);
|
|
101
104
|
if (interfaceApiName && isInterfaceScoped) osdkObject = osdkObject.$as(interfaceApiName);
|
|
102
105
|
ret.push(osdkObject);
|
|
103
106
|
}
|
|
@@ -198,4 +201,13 @@ function fixObjectPropertiesInPlace(objs, forceRemoveRid) {
|
|
|
198
201
|
delete obj.__title;
|
|
199
202
|
}
|
|
200
203
|
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Converts interfaceToObjectTypeMappingsV2 format to the V1 format.
|
|
207
|
+
* V2 format: { interfaceProp: { type: "localPropertyImplementation", propertyApiName: "objectProp" } }
|
|
208
|
+
* V1 format: { interfaceProp: "objectProp" }
|
|
209
|
+
*/
|
|
210
|
+
function convertInterfaceToObjectTypeMappingsV2ToV1(mappingsV2) {
|
|
211
|
+
return Object.fromEntries(Object.entries(mappingsV2).map(([interfaceApiName, objectTypeMappingsV2]) => [interfaceApiName, Object.fromEntries(Object.entries(objectTypeMappingsV2).map(([objectTypeName, propertyMappings]) => [objectTypeName, Object.fromEntries(Object.entries(propertyMappings).filter(([, impl]) => impl.type === "localPropertyImplementation").map(([interfaceProp, impl]) => [interfaceProp, impl.propertyApiName]))]))]));
|
|
212
|
+
}
|
|
201
213
|
//# sourceMappingURL=convertWireToOsdkObjects.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertWireToOsdkObjects.js","names":["invariant","createOsdkObject","convertWireToOsdkObjects","client","objects","interfaceApiName","forceRemoveRid","derivedPropertyTypesByName","selectedProps","strictNonNull","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","derivedPropertyTypeByName","interfaceToObjectTypeMappings","isInterfaceScoped","length","interfaceToObjMapping","filter","val","includes","values","primaryKeyApiName","ifacePropsToMap","map","ifaceProp","interfaceMap","newProps","sptProp","regularProp","entries","value","assign","$primaryKey","def","obj","propsToCheck","propName","nullable","logger","debug","$objectType","warning","warn","console","error","objs","__rid","$rid","__score","$score","__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} from \"@osdk/api\";\nimport type {\n InterfaceToObjectTypeMappings,\n InterfaceTypeApiName,\n OntologyObjectV2,\n} from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport type { DerivedPropertyRuntimeMetadata } from \"../derivedProperties/derivedPropertyRuntimeMetadata.js\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport {\n type FetchedObjectTypeDefinition,\n} from \"../ontology/OntologyProvider.js\";\nimport { createOsdkObject } from \"./convertWireToOsdkObjects/createOsdkObject.js\";\nimport type { InterfaceHolder } from \"./convertWireToOsdkObjects/InterfaceHolder.js\";\nimport type { ObjectHolder } from \"./convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { SimpleOsdkProperties } from \"./SimpleOsdkProperties.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 derivedPropertyTypesByName: DerivedPropertyRuntimeMetadata,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull: NullabilityAdherence = false,\n): Promise<Array<ObjectHolder | InterfaceHolder>> {\n // remove the __ prefixed properties and convert them to $ prefixed.\n // updates in place\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: ObjectHolder | InterfaceHolder = createOsdkObject(\n client,\n objectDef,\n rawObj,\n derivedPropertyTypesByName,\n );\n if (interfaceApiName) osdkObject = osdkObject.$as(interfaceApiName);\n\n ret.push(osdkObject);\n }\n\n return ret;\n}\n\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata,\n forceRemoveRid?: boolean,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull?: NullabilityAdherence,\n interfaceToObjectTypeMappings?: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n >,\n): Promise<Array<InterfaceHolder>>;\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: undefined,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata,\n forceRemoveRid?: boolean,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull?: NullabilityAdherence,\n interfaceToObjectTypeMappings?: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n >,\n): Promise<Array<ObjectHolder>>;\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string | undefined,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata,\n forceRemoveRid?: boolean,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull?: NullabilityAdherence,\n interfaceToObjectTypeMappings?: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n >,\n): Promise<Array<ObjectHolder | InterfaceHolder>>;\n/**\n * @internal\n */\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string | undefined,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata,\n forceRemoveRid: boolean = false,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull: NullabilityAdherence = false,\n interfaceToObjectTypeMappings: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n > = {},\n): Promise<Array<ObjectHolder | InterfaceHolder>> {\n fixObjectPropertiesInPlace(objects, forceRemoveRid);\n\n const isInterfaceScoped =\n Object.keys(interfaceToObjectTypeMappings).length > 0;\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 && isInterfaceScoped)\n ? interfaceToObjectTypeMappings[\n interfaceApiName as InterfaceTypeApiName\n ][\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: ObjectHolder | InterfaceHolder = createOsdkObject(\n client,\n objectDef,\n rawObj,\n derivedPropertyTypeByName,\n );\n if (\n interfaceApiName && isInterfaceScoped\n ) osdkObject = osdkObject.$as(interfaceApiName);\n\n ret.push(osdkObject);\n }\n\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 $apiName: obj[\"$apiName\"],\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): asserts objs is SimpleOsdkProperties[] {\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 if (obj.__score) {\n obj.$score = obj.__score;\n delete obj.__score;\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;;AAYA,OAAOA,SAAS,MAAM,gBAAgB;AAMtC,SAASC,gBAAgB,QAAQ,gDAAgD;AAKjF;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,0BAA0D,EAC1DC,aAAqC,EACrCC,aAAmC,GAAG,KAAK,EACK;EAChD;EACA;EACAC,0BAA0B,CAACN,OAAO,EAAEE,cAAc,CAAC;EAEnD,MAAMK,QAAQ,GAAGN,gBAAgB,GAC7B,MAAMF,MAAM,CAACS,gBAAgB,CAACC,sBAAsB,CAACR,gBAAgB,CAAC,GACtES,SAAS;EACb,MAAMC,aAAa,GAAGJ,QAAQ,GACzBH,aAAa,IAAIQ,MAAM,CAACC,IAAI,CAACN,QAAQ,CAACO,UAAU,CAAC,GAClDJ,SAAS;EAEb,MAAMK,GAAG,GAAG,EAAE;EACd,KAAK,MAAMC,MAAM,IAAIhB,OAAO,EAAE;IAC5B,MAAMiB,SAAS,GAAG,MAAMlB,MAAM,CAACS,gBAAgB,CAACU,mBAAmB,CACjEF,MAAM,CAACG,QACT,CAAC;IACD,CAAUF,SAAS,GAAAG,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAnB1B,SAAS,QAAY,2BAA2BoB,MAAM,CAACG,QAAQ,GAAG,IAAlEvB,SAAS;;IAET;IACA,IAAI2B,QAAQ;IAEZ,IAAIC,UAAU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C8D,MAAM,EAAE;MACjB9D,MAAM,CAAC8D,MAAM,CAACI,IAAI,CAACD,OAAO,CAAC;IAC7B,CAAC,MAAM;MACL;MACAE,OAAO,CAACC,KAAK,CAAC,YAAYH,OAAO,EAAE,CAAC;IACtC;IACA,MAAM,IAAIlC,KAAK,CAACkC,OAAO,CAAC;EAC1B;AACF;AAEA,SAAS1D,0BAA0BA,CACjC8D,IAAwB,EACxBlE,cAAuB,EACiB;EACxC,KAAK,MAAMuD,GAAG,IAAIW,IAAI,EAAE;IACtB,IAAIlE,cAAc,EAAE;MAClB,OAAOuD,GAAG,CAACY,KAAK;IAClB;IAEA,IAAIZ,GAAG,CAACY,KAAK,EAAE;MACbZ,GAAG,CAACa,IAAI,GAAGb,GAAG,CAACY,KAAK;MACpB,OAAOZ,GAAG,CAACY,KAAK;IAClB;IAEA,IAAIZ,GAAG,CAACc,OAAO,EAAE;MACfd,GAAG,CAACe,MAAM,GAAGf,GAAG,CAACc,OAAO;MACxB,OAAOd,GAAG,CAACc,OAAO;IACpB;;IAEA;IACAd,GAAG,CAACtC,QAAQ,KAAKsC,GAAG,CAACgB,SAAS;;IAE9B;IACA;IACAhB,GAAG,CAACM,WAAW,GAAGN,GAAG,CAACtC,QAAQ;;IAE9B;IACAsC,GAAG,CAACF,WAAW,KAAKE,GAAG,CAACiB,YAAY;IACpCjB,GAAG,CAACkB,MAAM,KAAKlB,GAAG,CAACmB,OAAO;;IAE1B;IACA,OAAOnB,GAAG,CAACgB,SAAS;IACpB,OAAOhB,GAAG,CAACiB,YAAY;IACvB,OAAOjB,GAAG,CAACmB,OAAO;EACpB;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"convertWireToOsdkObjects.js","names":["invariant","createOsdkObject","convertWireToOsdkObjects","client","objects","interfaceApiName","forceRemoveRid","derivedPropertyTypesByName","propertySecurities","selectedProps","strictNonNull","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","derivedPropertyTypeByName","interfaceToObjectTypeMappings","interfaceToObjectTypeMappingsV2","effectiveMappings","length","convertInterfaceToObjectTypeMappingsV2ToV1","isInterfaceScoped","interfaceToObjMapping","filter","val","includes","values","primaryKeyApiName","ifacePropsToMap","map","ifaceProp","interfaceMap","newProps","sptProp","regularProp","entries","value","assign","$primaryKey","def","obj","propsToCheck","propName","nullable","logger","debug","$objectType","warning","warn","console","error","objs","__rid","$rid","__score","$score","__apiName","__primaryKey","$title","__title","mappingsV2","fromEntries","objectTypeMappingsV2","objectTypeName","propertyMappings","impl","type","interfaceProp","propertyApiName"],"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} from \"@osdk/api\";\nimport type {\n InterfacePropertyLocalPropertyImplementation,\n InterfaceToObjectTypeMappings,\n InterfaceToObjectTypeMappingsV2,\n InterfaceTypeApiName,\n OntologyObjectV2,\n PropertySecurities,\n} from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport type { DerivedPropertyRuntimeMetadata } from \"../derivedProperties/derivedPropertyRuntimeMetadata.js\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport {\n type FetchedObjectTypeDefinition,\n} from \"../ontology/OntologyProvider.js\";\nimport { createOsdkObject } from \"./convertWireToOsdkObjects/createOsdkObject.js\";\nimport type { InterfaceHolder } from \"./convertWireToOsdkObjects/InterfaceHolder.js\";\nimport type { ObjectHolder } from \"./convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { SimpleOsdkProperties } from \"./SimpleOsdkProperties.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 derivedPropertyTypesByName: DerivedPropertyRuntimeMetadata,\n propertySecurities: PropertySecurities[] | undefined,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull: NullabilityAdherence = false,\n): Promise<Array<ObjectHolder | InterfaceHolder>> {\n // remove the __ prefixed properties and convert them to $ prefixed.\n // updates in place\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: ObjectHolder | InterfaceHolder = createOsdkObject(\n client,\n objectDef,\n rawObj,\n derivedPropertyTypesByName,\n propertySecurities,\n );\n if (interfaceApiName) osdkObject = osdkObject.$as(interfaceApiName);\n\n ret.push(osdkObject);\n }\n\n return ret;\n}\n\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata,\n propertySecurities: PropertySecurities[] | undefined,\n forceRemoveRid?: boolean,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull?: NullabilityAdherence,\n interfaceToObjectTypeMappings?: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n >,\n interfaceToObjectTypeMappingsV2?: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappingsV2\n >,\n): Promise<Array<InterfaceHolder>>;\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: undefined,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata,\n propertySecurities: PropertySecurities[] | undefined,\n forceRemoveRid?: boolean,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull?: NullabilityAdherence,\n interfaceToObjectTypeMappings?: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n >,\n interfaceToObjectTypeMappingsV2?: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappingsV2\n >,\n): Promise<Array<ObjectHolder>>;\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string | undefined,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata,\n propertySecurities: PropertySecurities[] | undefined,\n forceRemoveRid?: boolean,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull?: NullabilityAdherence,\n interfaceToObjectTypeMappings?: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n >,\n interfaceToObjectTypeMappingsV2?: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappingsV2\n >,\n): Promise<Array<ObjectHolder | InterfaceHolder>>;\n/**\n * @internal\n */\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string | undefined,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata,\n propertySecurities: PropertySecurities[] | undefined,\n forceRemoveRid: boolean = false,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull: NullabilityAdherence = false,\n interfaceToObjectTypeMappings: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n > = {},\n interfaceToObjectTypeMappingsV2: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappingsV2\n > = {},\n): Promise<Array<ObjectHolder | InterfaceHolder>> {\n fixObjectPropertiesInPlace(objects, forceRemoveRid);\n\n // prefer V2 mappings if non-empty, otherwise fall back to V1\n const effectiveMappings =\n Object.keys(interfaceToObjectTypeMappingsV2).length > 0\n ? convertInterfaceToObjectTypeMappingsV2ToV1(\n interfaceToObjectTypeMappingsV2,\n )\n : interfaceToObjectTypeMappings;\n\n const isInterfaceScoped = Object.keys(effectiveMappings).length > 0;\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 && isInterfaceScoped)\n ? effectiveMappings[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: ObjectHolder | InterfaceHolder = createOsdkObject(\n client,\n objectDef,\n rawObj,\n derivedPropertyTypeByName,\n propertySecurities,\n );\n if (\n interfaceApiName && isInterfaceScoped\n ) osdkObject = osdkObject.$as(interfaceApiName);\n\n ret.push(osdkObject);\n }\n\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 $apiName: obj[\"$apiName\"],\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): asserts objs is SimpleOsdkProperties[] {\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 if (obj.__score) {\n obj.$score = obj.__score;\n delete obj.__score;\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\n/**\n * Converts interfaceToObjectTypeMappingsV2 format to the V1 format.\n * V2 format: { interfaceProp: { type: \"localPropertyImplementation\", propertyApiName: \"objectProp\" } }\n * V1 format: { interfaceProp: \"objectProp\" }\n */\nfunction convertInterfaceToObjectTypeMappingsV2ToV1(\n mappingsV2: Record<InterfaceTypeApiName, InterfaceToObjectTypeMappingsV2>,\n): Record<InterfaceTypeApiName, InterfaceToObjectTypeMappings> {\n return Object.fromEntries(\n Object.entries(mappingsV2).map((\n [interfaceApiName, objectTypeMappingsV2],\n ) => [\n interfaceApiName,\n Object.fromEntries(\n Object.entries(objectTypeMappingsV2).map((\n [objectTypeName, propertyMappings],\n ) => [\n objectTypeName,\n Object.fromEntries(\n Object.entries(propertyMappings)\n .filter(([, impl]) => impl.type === \"localPropertyImplementation\")\n .map((\n [interfaceProp, impl],\n ) => [\n interfaceProp,\n (impl as InterfacePropertyLocalPropertyImplementation)\n .propertyApiName,\n ]),\n ),\n ]),\n ),\n ]),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA,OAAOA,SAAS,MAAM,gBAAgB;AAMtC,SAASC,gBAAgB,QAAQ,gDAAgD;AAKjF;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,0BAA0D,EAC1DC,kBAAoD,EACpDC,aAAqC,EACrCC,aA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