@osdk/client 2.2.0-beta.8 → 2.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +388 -0
- package/build/browser/MinimalClientContext.js.map +1 -1
- package/build/browser/__unstable/ConjureSupport.js.map +1 -1
- package/build/browser/actions/ActionValidationError.js +1 -1
- package/build/browser/actions/ActionValidationError.js.map +1 -1
- package/build/browser/actions/actions.test.js +134 -89
- package/build/browser/actions/actions.test.js.map +1 -1
- package/build/browser/actions/applyAction.js.map +1 -1
- package/build/browser/createClient.js +5 -1
- package/build/browser/createClient.js.map +1 -1
- package/build/browser/createClient.test.js +14 -6
- package/build/browser/createClient.test.js.map +1 -1
- package/build/browser/createMinimalClient.js +2 -2
- package/build/browser/createMinimalClient.js.map +1 -1
- package/build/browser/createMinimalClientHelper.js +25 -0
- package/build/browser/createMinimalClientHelper.js.map +1 -0
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +36 -13
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.test.js +133 -0
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.test.js.map +1 -1
- package/build/browser/derivedProperties/derivedPropertyDefinitionFactory.js +93 -0
- package/build/browser/derivedProperties/derivedPropertyDefinitionFactory.js.map +1 -0
- package/build/browser/fetchMetadata.js +1 -1
- package/build/browser/fetchMetadata.js.map +1 -1
- package/build/browser/fetchMetadata.test.js +11 -9
- package/build/browser/fetchMetadata.test.js.map +1 -1
- package/build/browser/index.js +0 -1
- package/build/browser/index.js.map +1 -1
- package/build/{esm/util/isOsdkBaseObject.js → browser/intellisense.test.helpers/showsObjectPropertyJsdoc.js} +9 -4
- package/build/browser/intellisense.test.helpers/showsObjectPropertyJsdoc.js.map +1 -0
- package/build/browser/intellisense.test.js +17 -1
- package/build/browser/intellisense.test.js.map +1 -1
- package/build/browser/logger/BaseLogger.js +59 -0
- package/build/browser/logger/BaseLogger.js.map +1 -0
- package/build/browser/logger/BrowserLogger.js +67 -0
- package/build/browser/logger/BrowserLogger.js.map +1 -0
- package/build/browser/logger/MinimalLogger.js +39 -0
- package/build/browser/logger/MinimalLogger.js.map +1 -0
- package/build/browser/logger/MinimalLogger.test.js +60 -0
- package/build/browser/logger/MinimalLogger.test.js.map +1 -0
- package/build/browser/logger/TestLogger.js +56 -0
- package/build/browser/logger/TestLogger.js.map +1 -0
- package/build/browser/object/SimpleOsdkProperties.js +2 -0
- package/build/browser/object/SimpleOsdkProperties.js.map +1 -0
- package/build/browser/object/attachment.test.js +20 -7
- package/build/browser/object/attachment.test.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/BaseHolder.js +2 -0
- package/build/browser/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -0
- package/build/browser/object/convertWireToOsdkObjects/InterfaceHolder.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/ObjectHolder.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +4 -0
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js +53 -35
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/getDollarAs.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/getDollarLink.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.js +7 -15
- package/build/browser/object/convertWireToOsdkObjects.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.test.js +39 -33
- package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/browser/object/fetchPage.js +17 -4
- package/build/browser/object/fetchPage.js.map +1 -1
- package/build/browser/object/fetchPage.test.js +56 -2
- package/build/browser/object/fetchPage.test.js.map +1 -1
- package/build/browser/object/geotimeseriesreference.test.js +56 -134
- package/build/browser/object/geotimeseriesreference.test.js.map +1 -1
- package/build/browser/object/media.test.js +19 -14
- package/build/browser/object/media.test.js.map +1 -1
- package/build/browser/object/object.test.js +96 -89
- package/build/browser/object/object.test.js.map +1 -1
- package/build/browser/object/timeseries.test.js +119 -85
- package/build/browser/object/timeseries.test.js.map +1 -1
- package/build/browser/objectSet/InterfaceObjectSet.test.js +37 -17
- package/build/browser/objectSet/InterfaceObjectSet.test.js.map +1 -1
- package/build/browser/objectSet/ObjectSet.test.js +200 -116
- package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js +20 -16
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js +19 -12
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/browser/objectSet/createObjectSet.js +2 -1
- package/build/browser/objectSet/createObjectSet.js.map +1 -1
- package/build/browser/observable/ListPayload.js.map +1 -1
- package/build/browser/observable/ObjectPayload.js.map +1 -1
- package/build/browser/observable/ObservableClient.js.map +1 -1
- package/build/browser/observable/internal/ActionApplication.js +32 -32
- package/build/browser/observable/internal/ActionApplication.js.map +1 -1
- package/build/browser/observable/internal/BulkObjectLoader.js +93 -0
- package/build/browser/observable/internal/BulkObjectLoader.js.map +1 -0
- package/build/browser/observable/internal/BulkObjectLoader.test.js +112 -0
- package/build/browser/observable/internal/BulkObjectLoader.test.js.map +1 -0
- package/build/browser/observable/internal/CacheKey.js +1 -1
- package/build/browser/observable/internal/CacheKey.js.map +1 -1
- package/build/browser/observable/internal/CacheKeys.js +2 -2
- package/build/browser/observable/internal/CacheKeys.js.map +1 -1
- package/build/browser/observable/internal/{ChangedObjects.js → Changes.js} +20 -9
- package/build/browser/observable/internal/Changes.js.map +1 -0
- package/build/browser/observable/internal/Layer.js +3 -0
- package/build/browser/observable/internal/Layer.js.map +1 -1
- package/build/browser/observable/internal/ListQuery.js +414 -170
- package/build/browser/observable/internal/ListQuery.js.map +1 -1
- package/build/browser/observable/internal/ObjectQuery.js +34 -21
- package/build/browser/observable/internal/ObjectQuery.js.map +1 -1
- package/build/browser/observable/internal/ObservableClientImpl.js +4 -12
- package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/browser/observable/internal/OptimisticJob.js +1 -1
- package/build/browser/observable/internal/OptimisticJob.js.map +1 -1
- package/build/browser/observable/internal/OrderByCanonicalizer.js +73 -0
- package/build/browser/observable/internal/OrderByCanonicalizer.js.map +1 -0
- package/build/browser/observable/internal/OrderByCanonicalizer.test.js +78 -0
- package/build/browser/observable/internal/OrderByCanonicalizer.test.js.map +1 -0
- package/build/browser/observable/internal/Query.js +64 -31
- package/build/browser/observable/internal/Query.js.map +1 -1
- package/build/browser/observable/internal/RefCounts.js +7 -2
- package/build/browser/observable/internal/RefCounts.js.map +1 -1
- package/build/browser/observable/internal/SimpleWhereClause.js +2 -0
- package/build/browser/observable/internal/SimpleWhereClause.js.map +1 -0
- package/build/browser/observable/internal/Store.js +86 -269
- package/build/browser/observable/internal/Store.js.map +1 -1
- package/build/browser/observable/internal/Store.test.js +401 -375
- package/build/browser/observable/internal/Store.test.js.map +1 -1
- package/build/browser/observable/internal/WhereClauseCanonicalizer.js +11 -3
- package/build/browser/observable/internal/WhereClauseCanonicalizer.js.map +1 -1
- package/build/browser/observable/internal/objectMatchesWhereClause.js +0 -2
- package/build/browser/observable/internal/objectMatchesWhereClause.js.map +1 -1
- package/build/browser/observable/internal/objectMatchesWhereClause.test.js.map +1 -1
- package/build/browser/observable/internal/testUtils.js +85 -20
- package/build/browser/observable/internal/testUtils.js.map +1 -1
- package/build/browser/ontology/OntologyProvider.js.map +1 -1
- package/build/browser/ontology/StandardOntologyProvider.js +12 -5
- package/build/browser/ontology/StandardOntologyProvider.js.map +1 -1
- package/build/browser/ontology/StandardOntologyProvider.test.js +17 -16
- package/build/browser/ontology/StandardOntologyProvider.test.js.map +1 -1
- package/build/browser/ontology/loadFullObjectMetadata.js +0 -1
- package/build/browser/ontology/loadFullObjectMetadata.js.map +1 -1
- package/build/browser/ontology/loadQueryMetadata.js +5 -2
- package/build/browser/ontology/loadQueryMetadata.js.map +1 -1
- package/build/browser/public/internal.js +2 -0
- package/build/browser/public/internal.js.map +1 -1
- package/build/browser/public/unstable-do-not-use.js +1 -0
- package/build/browser/public/unstable-do-not-use.js.map +1 -1
- package/build/browser/public-utils/osdkConfig.js +49 -0
- package/build/browser/public-utils/osdkConfig.js.map +1 -0
- package/build/browser/{object/createObjectSpecifierFromPrimaryKey.js → public-utils/vite-env.d.ts} +2 -3
- package/build/browser/queries/applyQuery.js +6 -4
- package/build/browser/queries/applyQuery.js.map +1 -1
- package/build/browser/queries/queries.test.js +93 -27
- package/build/browser/queries/queries.test.js.map +1 -1
- package/build/browser/queries/types.js.map +1 -1
- package/build/browser/tsserver.js.map +1 -1
- package/build/browser/util/UserAgent.js +1 -1
- package/build/browser/util/extractRdpDefinition.js +140 -0
- package/build/browser/util/extractRdpDefinition.js.map +1 -0
- package/build/browser/util/extractRdpDefinition.test.js +233 -0
- package/build/browser/util/extractRdpDefinition.test.js.map +1 -0
- package/build/browser/util/{isOsdkBaseObject.js → isObjectSpecifiersObject.js} +2 -2
- package/build/browser/util/isObjectSpecifiersObject.js.map +1 -0
- package/build/browser/util/isPoint.js +20 -0
- package/build/browser/util/isPoint.js.map +1 -0
- package/build/browser/util/objectSpecifierUtils.js +48 -0
- package/build/browser/util/objectSpecifierUtils.js.map +1 -0
- package/build/browser/util/objectSpecifierUtils.test.js +42 -0
- package/build/browser/util/objectSpecifierUtils.test.js.map +1 -0
- package/build/browser/util/toDataValue.js +6 -2
- package/build/browser/util/toDataValue.js.map +1 -1
- package/build/browser/util/toDataValue.test.js +37 -16
- package/build/browser/util/toDataValue.test.js.map +1 -1
- package/build/browser/util/toDataValueQueries.js +4 -6
- package/build/browser/util/toDataValueQueries.js.map +1 -1
- package/build/cjs/{Client-DBTcM9gB.d.cts → Client-CgL2LKN9.d.cts} +6 -7
- package/build/cjs/{chunk-IU47QMYO.cjs → chunk-FKI2LO2O.cjs} +250 -82
- package/build/cjs/chunk-FKI2LO2O.cjs.map +1 -0
- package/build/cjs/chunk-T4NIFYZS.cjs +14 -0
- package/build/cjs/chunk-T4NIFYZS.cjs.map +1 -0
- package/build/cjs/{chunk-JPENHIJB.cjs → chunk-W5PFESFR.cjs} +174 -35
- package/build/cjs/chunk-W5PFESFR.cjs.map +1 -0
- package/build/cjs/index.cjs +212 -193
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +4 -24
- package/build/cjs/public/internal.cjs +61 -7
- package/build/cjs/public/internal.cjs.map +1 -1
- package/build/cjs/public/internal.d.cts +50 -3
- package/build/cjs/public/unstable-do-not-use.cjs +885 -620
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +35 -25
- package/build/esm/MinimalClientContext.js.map +1 -1
- package/build/esm/__unstable/ConjureSupport.js.map +1 -1
- package/build/esm/actions/ActionValidationError.js +1 -1
- package/build/esm/actions/ActionValidationError.js.map +1 -1
- package/build/esm/actions/actions.test.js +134 -89
- package/build/esm/actions/actions.test.js.map +1 -1
- package/build/esm/actions/applyAction.js.map +1 -1
- package/build/esm/createClient.js +5 -1
- package/build/esm/createClient.js.map +1 -1
- package/build/esm/createClient.test.js +14 -6
- package/build/esm/createClient.test.js.map +1 -1
- package/build/esm/createMinimalClient.js +2 -2
- package/build/esm/createMinimalClient.js.map +1 -1
- package/build/esm/createMinimalClientHelper.js +25 -0
- package/build/esm/createMinimalClientHelper.js.map +1 -0
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +36 -13
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.test.js +133 -0
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.test.js.map +1 -1
- package/build/esm/derivedProperties/derivedPropertyDefinitionFactory.js +93 -0
- package/build/esm/derivedProperties/derivedPropertyDefinitionFactory.js.map +1 -0
- package/build/esm/fetchMetadata.js +1 -1
- package/build/esm/fetchMetadata.js.map +1 -1
- package/build/esm/fetchMetadata.test.js +11 -9
- package/build/esm/fetchMetadata.test.js.map +1 -1
- package/build/esm/index.js +0 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/{util/isOsdkObject.js → intellisense.test.helpers/showsObjectPropertyJsdoc.js} +9 -4
- package/build/esm/intellisense.test.helpers/showsObjectPropertyJsdoc.js.map +1 -0
- package/build/esm/intellisense.test.js +17 -1
- package/build/esm/intellisense.test.js.map +1 -1
- package/build/esm/logger/BaseLogger.js +59 -0
- package/build/esm/logger/BaseLogger.js.map +1 -0
- package/build/esm/logger/BrowserLogger.js +67 -0
- package/build/esm/logger/BrowserLogger.js.map +1 -0
- package/build/esm/logger/MinimalLogger.js +39 -0
- package/build/esm/logger/MinimalLogger.js.map +1 -0
- package/build/esm/logger/MinimalLogger.test.js +60 -0
- package/build/esm/logger/MinimalLogger.test.js.map +1 -0
- package/build/esm/logger/TestLogger.js +56 -0
- package/build/esm/logger/TestLogger.js.map +1 -0
- package/build/esm/object/SimpleOsdkProperties.js +2 -0
- package/build/esm/object/SimpleOsdkProperties.js.map +1 -0
- package/build/esm/object/attachment.test.js +20 -7
- package/build/esm/object/attachment.test.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/BaseHolder.js +2 -0
- package/build/esm/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -0
- package/build/esm/object/convertWireToOsdkObjects/InterfaceHolder.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/ObjectHolder.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +4 -0
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js +53 -35
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/getDollarAs.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/getDollarLink.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.js +7 -15
- package/build/esm/object/convertWireToOsdkObjects.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.test.js +39 -33
- package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/esm/object/fetchPage.js +17 -4
- package/build/esm/object/fetchPage.js.map +1 -1
- package/build/esm/object/fetchPage.test.js +56 -2
- package/build/esm/object/fetchPage.test.js.map +1 -1
- package/build/esm/object/geotimeseriesreference.test.js +56 -134
- package/build/esm/object/geotimeseriesreference.test.js.map +1 -1
- package/build/esm/object/media.test.js +19 -14
- package/build/esm/object/media.test.js.map +1 -1
- package/build/esm/object/object.test.js +96 -89
- package/build/esm/object/object.test.js.map +1 -1
- package/build/esm/object/timeseries.test.js +119 -85
- package/build/esm/object/timeseries.test.js.map +1 -1
- package/build/esm/objectSet/InterfaceObjectSet.test.js +37 -17
- package/build/esm/objectSet/InterfaceObjectSet.test.js.map +1 -1
- package/build/esm/objectSet/ObjectSet.test.js +200 -116
- package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js +20 -16
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js +19 -12
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/esm/objectSet/createObjectSet.js +2 -1
- package/build/esm/objectSet/createObjectSet.js.map +1 -1
- package/build/esm/observable/ListPayload.js.map +1 -1
- package/build/esm/observable/ObjectPayload.js.map +1 -1
- package/build/esm/observable/ObservableClient.js.map +1 -1
- package/build/esm/observable/internal/ActionApplication.js +32 -32
- package/build/esm/observable/internal/ActionApplication.js.map +1 -1
- package/build/esm/observable/internal/BulkObjectLoader.js +93 -0
- package/build/esm/observable/internal/BulkObjectLoader.js.map +1 -0
- package/build/esm/observable/internal/BulkObjectLoader.test.js +112 -0
- package/build/esm/observable/internal/BulkObjectLoader.test.js.map +1 -0
- package/build/esm/observable/internal/CacheKey.js +1 -1
- package/build/esm/observable/internal/CacheKey.js.map +1 -1
- package/build/esm/observable/internal/CacheKeys.js +2 -2
- package/build/esm/observable/internal/CacheKeys.js.map +1 -1
- package/build/esm/observable/internal/{ChangedObjects.js → Changes.js} +20 -9
- package/build/esm/observable/internal/Changes.js.map +1 -0
- package/build/esm/observable/internal/Layer.js +3 -0
- package/build/esm/observable/internal/Layer.js.map +1 -1
- package/build/esm/observable/internal/ListQuery.js +414 -170
- package/build/esm/observable/internal/ListQuery.js.map +1 -1
- package/build/esm/observable/internal/ObjectQuery.js +34 -21
- package/build/esm/observable/internal/ObjectQuery.js.map +1 -1
- package/build/esm/observable/internal/ObservableClientImpl.js +4 -12
- package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/esm/observable/internal/OptimisticJob.js +1 -1
- package/build/esm/observable/internal/OptimisticJob.js.map +1 -1
- package/build/esm/observable/internal/OrderByCanonicalizer.js +73 -0
- package/build/esm/observable/internal/OrderByCanonicalizer.js.map +1 -0
- package/build/esm/observable/internal/OrderByCanonicalizer.test.js +78 -0
- package/build/esm/observable/internal/OrderByCanonicalizer.test.js.map +1 -0
- package/build/esm/observable/internal/Query.js +64 -31
- package/build/esm/observable/internal/Query.js.map +1 -1
- package/build/esm/observable/internal/RefCounts.js +7 -2
- package/build/esm/observable/internal/RefCounts.js.map +1 -1
- package/build/esm/observable/internal/SimpleWhereClause.js +2 -0
- package/build/esm/observable/internal/SimpleWhereClause.js.map +1 -0
- package/build/esm/observable/internal/Store.js +86 -269
- package/build/esm/observable/internal/Store.js.map +1 -1
- package/build/esm/observable/internal/Store.test.js +401 -375
- package/build/esm/observable/internal/Store.test.js.map +1 -1
- package/build/esm/observable/internal/WhereClauseCanonicalizer.js +11 -3
- package/build/esm/observable/internal/WhereClauseCanonicalizer.js.map +1 -1
- package/build/esm/observable/internal/objectMatchesWhereClause.js +0 -2
- package/build/esm/observable/internal/objectMatchesWhereClause.js.map +1 -1
- package/build/esm/observable/internal/objectMatchesWhereClause.test.js.map +1 -1
- package/build/esm/observable/internal/testUtils.js +85 -20
- package/build/esm/observable/internal/testUtils.js.map +1 -1
- package/build/esm/ontology/OntologyProvider.js.map +1 -1
- package/build/esm/ontology/StandardOntologyProvider.js +12 -5
- package/build/esm/ontology/StandardOntologyProvider.js.map +1 -1
- package/build/esm/ontology/StandardOntologyProvider.test.js +17 -16
- package/build/esm/ontology/StandardOntologyProvider.test.js.map +1 -1
- package/build/esm/ontology/loadFullObjectMetadata.js +0 -1
- package/build/esm/ontology/loadFullObjectMetadata.js.map +1 -1
- package/build/esm/ontology/loadQueryMetadata.js +5 -2
- package/build/esm/ontology/loadQueryMetadata.js.map +1 -1
- package/build/esm/public/internal.js +2 -0
- package/build/esm/public/internal.js.map +1 -1
- package/build/esm/public/unstable-do-not-use.js +1 -0
- package/build/esm/public/unstable-do-not-use.js.map +1 -1
- package/build/esm/public-utils/osdkConfig.js +49 -0
- package/build/esm/public-utils/osdkConfig.js.map +1 -0
- package/build/esm/{object/createObjectSpecifierFromPrimaryKey.js → public-utils/vite-env.d.ts} +2 -3
- package/build/esm/queries/applyQuery.js +6 -4
- package/build/esm/queries/applyQuery.js.map +1 -1
- package/build/esm/queries/queries.test.js +93 -27
- package/build/esm/queries/queries.test.js.map +1 -1
- package/build/esm/queries/types.js.map +1 -1
- package/build/esm/tsserver.js.map +1 -1
- package/build/esm/util/UserAgent.js +1 -1
- package/build/esm/util/extractRdpDefinition.js +140 -0
- package/build/esm/util/extractRdpDefinition.js.map +1 -0
- package/build/esm/util/extractRdpDefinition.test.js +233 -0
- package/build/esm/util/extractRdpDefinition.test.js.map +1 -0
- package/build/{browser/util/isOsdkObject.js → esm/util/isObjectSpecifiersObject.js} +2 -2
- package/build/esm/util/isObjectSpecifiersObject.js.map +1 -0
- package/build/esm/util/isPoint.js +20 -0
- package/build/esm/util/isPoint.js.map +1 -0
- package/build/esm/util/objectSpecifierUtils.js +48 -0
- package/build/esm/util/objectSpecifierUtils.js.map +1 -0
- package/build/esm/util/objectSpecifierUtils.test.js +42 -0
- package/build/esm/util/objectSpecifierUtils.test.js.map +1 -0
- package/build/esm/util/toDataValue.js +6 -2
- package/build/esm/util/toDataValue.js.map +1 -1
- package/build/esm/util/toDataValue.test.js +37 -16
- package/build/esm/util/toDataValue.test.js.map +1 -1
- package/build/esm/util/toDataValueQueries.js +4 -6
- package/build/esm/util/toDataValueQueries.js.map +1 -1
- package/build/types/MinimalClientContext.d.ts +1 -1
- package/build/types/MinimalClientContext.d.ts.map +1 -1
- package/build/types/__unstable/ConjureSupport.d.ts +2 -2
- package/build/types/actions/applyAction.d.ts +1 -2
- package/build/types/actions/applyAction.d.ts.map +1 -1
- package/build/types/createClient.d.ts +1 -1
- package/build/types/createClient.d.ts.map +1 -1
- package/build/types/createClient.test.d.ts +2 -1
- package/build/types/createClient.test.d.ts.map +1 -1
- package/build/types/createMinimalClientHelper.d.ts +1 -0
- package/build/types/createMinimalClientHelper.d.ts.map +1 -0
- package/build/types/derivedProperties/derivedPropertyDefinitionFactory.d.ts +1 -0
- package/build/types/derivedProperties/derivedPropertyDefinitionFactory.d.ts.map +1 -0
- package/build/types/index.d.ts +4 -6
- package/build/types/index.d.ts.map +1 -1
- package/build/types/intellisense.test.helpers/showsObjectPropertyJsdoc.d.ts +1 -0
- package/build/types/intellisense.test.helpers/showsObjectPropertyJsdoc.d.ts.map +1 -0
- package/build/types/logger/BaseLogger.d.ts +33 -0
- package/build/types/logger/BaseLogger.d.ts.map +1 -0
- package/build/types/logger/BrowserLogger.d.ts +9 -0
- package/build/types/logger/BrowserLogger.d.ts.map +1 -0
- package/build/types/logger/MinimalLogger.d.ts +9 -0
- package/build/types/logger/MinimalLogger.d.ts.map +1 -0
- package/build/types/logger/MinimalLogger.test.d.ts +1 -0
- package/build/types/logger/MinimalLogger.test.d.ts.map +1 -0
- package/build/types/logger/TestLogger.d.ts +14 -0
- package/build/types/logger/TestLogger.d.ts.map +1 -0
- package/build/types/object/SimpleOsdkProperties.d.ts +1 -0
- package/build/types/object/SimpleOsdkProperties.d.ts.map +1 -0
- package/build/types/object/convertWireToOsdkObjects/BaseHolder.d.ts +1 -0
- package/build/types/object/convertWireToOsdkObjects/BaseHolder.d.ts.map +1 -0
- package/build/types/object/convertWireToOsdkObjects.d.ts +8 -1
- package/build/types/object/convertWireToOsdkObjects.d.ts.map +1 -1
- package/build/types/object/fetchPage.d.ts.map +1 -1
- package/build/types/object/object.test.d.ts.map +1 -1
- package/build/types/objectSet/ObjectSet.test.d.ts.map +1 -1
- package/build/types/observable/ListPayload.d.ts +5 -9
- package/build/types/observable/ListPayload.d.ts.map +1 -1
- package/build/types/observable/ObjectPayload.d.ts +4 -7
- package/build/types/observable/ObjectPayload.d.ts.map +1 -1
- package/build/types/observable/ObservableClient.d.ts +27 -11
- package/build/types/observable/ObservableClient.d.ts.map +1 -1
- package/build/types/observable/internal/ActionApplication.d.ts +2 -2
- package/build/types/observable/internal/ActionApplication.d.ts.map +1 -1
- package/build/types/observable/internal/BulkObjectLoader.d.ts +8 -0
- package/build/types/observable/internal/BulkObjectLoader.d.ts.map +1 -0
- package/build/types/observable/internal/BulkObjectLoader.test.d.ts +1 -0
- package/build/types/observable/internal/BulkObjectLoader.test.d.ts.map +1 -0
- package/build/types/observable/internal/CacheKeys.d.ts +1 -1
- package/build/types/observable/internal/CacheKeys.d.ts.map +1 -1
- package/build/types/observable/internal/Changes.d.ts +15 -0
- package/build/types/observable/internal/Changes.d.ts.map +1 -0
- package/build/types/observable/internal/Layer.d.ts +1 -0
- package/build/types/observable/internal/Layer.d.ts.map +1 -1
- package/build/types/observable/internal/ListQuery.d.ts +59 -14
- package/build/types/observable/internal/ListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/ObjectQuery.d.ts +5 -6
- package/build/types/observable/internal/ObjectQuery.d.ts.map +1 -1
- package/build/types/observable/internal/OptimisticJob.d.ts +1 -1
- package/build/types/observable/internal/OptimisticJob.d.ts.map +1 -1
- package/build/types/observable/internal/OrderByCanonicalizer.d.ts +12 -0
- package/build/types/observable/internal/OrderByCanonicalizer.d.ts.map +1 -0
- package/build/types/observable/internal/OrderByCanonicalizer.test.d.ts +1 -0
- package/build/types/observable/internal/OrderByCanonicalizer.test.d.ts.map +1 -0
- package/build/types/observable/internal/Query.d.ts +41 -6
- package/build/types/observable/internal/Query.d.ts.map +1 -1
- package/build/types/observable/internal/RefCounts.d.ts.map +1 -1
- package/build/types/observable/internal/SimpleWhereClause.d.ts +2 -0
- package/build/types/observable/internal/SimpleWhereClause.d.ts.map +1 -0
- package/build/types/observable/internal/Store.d.ts +20 -44
- package/build/types/observable/internal/Store.d.ts.map +1 -1
- package/build/types/observable/internal/WhereClauseCanonicalizer.d.ts +2 -1
- package/build/types/observable/internal/WhereClauseCanonicalizer.d.ts.map +1 -1
- package/build/types/observable/internal/objectMatchesWhereClause.d.ts +4 -2
- package/build/types/observable/internal/objectMatchesWhereClause.d.ts.map +1 -1
- package/build/types/observable/internal/testUtils.d.ts +39 -10
- package/build/types/observable/internal/testUtils.d.ts.map +1 -1
- package/build/types/ontology/OntologyProvider.d.ts +1 -1
- package/build/types/ontology/OntologyProvider.d.ts.map +1 -1
- package/build/types/ontology/loadQueryMetadata.d.ts +1 -1
- package/build/types/ontology/loadQueryMetadata.d.ts.map +1 -1
- package/build/types/public/internal.d.ts +2 -0
- package/build/types/public/internal.d.ts.map +1 -1
- package/build/types/public/unstable-do-not-use.d.ts +4 -5
- package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
- package/build/types/public-utils/osdkConfig.d.ts +8 -0
- package/build/types/public-utils/osdkConfig.d.ts.map +1 -0
- package/build/types/public-utils/vite-env.d.d.ts +3 -0
- package/build/types/public-utils/vite-env.d.d.ts.map +1 -0
- package/build/types/queries/applyQuery.d.ts +2 -2
- package/build/types/queries/applyQuery.d.ts.map +1 -1
- package/build/types/queries/types.d.ts +1 -1
- package/build/types/queries/types.d.ts.map +1 -1
- package/build/types/tsserver.d.ts +1 -1
- package/build/types/tsserver.d.ts.map +1 -1
- package/build/types/util/extractRdpDefinition.d.ts +4 -0
- package/build/types/util/extractRdpDefinition.d.ts.map +1 -0
- package/build/types/util/extractRdpDefinition.test.d.ts +1 -0
- package/build/types/util/extractRdpDefinition.test.d.ts.map +1 -0
- package/build/types/util/isObjectSpecifiersObject.d.ts +5 -0
- package/build/types/util/isObjectSpecifiersObject.d.ts.map +1 -0
- package/build/types/util/isPoint.d.ts +1 -0
- package/build/types/util/isPoint.d.ts.map +1 -0
- package/build/types/util/objectSpecifierUtils.d.ts +24 -0
- package/build/types/util/objectSpecifierUtils.d.ts.map +1 -0
- package/build/types/util/objectSpecifierUtils.test.d.ts +1 -0
- package/build/types/util/objectSpecifierUtils.test.d.ts.map +1 -0
- package/package.json +21 -18
- package/build/browser/Logger.js +0 -2
- package/build/browser/Logger.js.map +0 -1
- package/build/browser/object/createObjectSpecifierFromPrimaryKey.js.map +0 -1
- package/build/browser/observable/internal/ChangedObjects.js.map +0 -1
- package/build/browser/util/isOsdkBaseObject.js.map +0 -1
- package/build/browser/util/isOsdkObject.js.map +0 -1
- package/build/cjs/chunk-IU47QMYO.cjs.map +0 -1
- package/build/cjs/chunk-JPENHIJB.cjs.map +0 -1
- package/build/cjs/chunk-Q7SFCCGT.cjs +0 -11
- package/build/cjs/chunk-Q7SFCCGT.cjs.map +0 -1
- package/build/cjs/graphql-RGM5SRWV.cjs +0 -10532
- package/build/cjs/graphql-RGM5SRWV.cjs.map +0 -1
- package/build/esm/Logger.js +0 -2
- package/build/esm/Logger.js.map +0 -1
- package/build/esm/object/createObjectSpecifierFromPrimaryKey.js.map +0 -1
- package/build/esm/observable/internal/ChangedObjects.js.map +0 -1
- package/build/esm/util/isOsdkBaseObject.js.map +0 -1
- package/build/esm/util/isOsdkObject.js.map +0 -1
- package/build/types/Logger.d.ts +0 -17
- package/build/types/Logger.d.ts.map +0 -1
- package/build/types/object/createObjectSpecifierFromPrimaryKey.d.ts +0 -2
- package/build/types/object/createObjectSpecifierFromPrimaryKey.d.ts.map +0 -1
- package/build/types/observable/internal/ChangedObjects.d.ts +0 -11
- package/build/types/observable/internal/ChangedObjects.d.ts.map +0 -1
- package/build/types/util/isOsdkBaseObject.d.ts +0 -2
- package/build/types/util/isOsdkBaseObject.d.ts.map +0 -1
- package/build/types/util/isOsdkObject.d.ts +0 -2
- package/build/types/util/isOsdkObject.d.ts.map +0 -1
|
@@ -19,6 +19,7 @@ import { GeotimeSeriesPropertyImpl } from "../../createGeotimeSeriesProperty.js"
|
|
|
19
19
|
import { MediaReferencePropertyImpl } from "../../createMediaReferenceProperty.js";
|
|
20
20
|
import { TimeSeriesPropertyImpl } from "../../createTimeseriesProperty.js";
|
|
21
21
|
import { hydrateAttachmentFromRidInternal } from "../../public-utils/hydrateAttachmentFromRid.js";
|
|
22
|
+
import { createObjectSpecifierFromPrimaryKey } from "../../util/objectSpecifierUtils.js";
|
|
22
23
|
import { get$as } from "./getDollarAs.js";
|
|
23
24
|
import { get$link } from "./getDollarLink.js";
|
|
24
25
|
import { ClientRef, ObjectDefRef, UnderlyingOsdkObject } from "./InternalSymbols.js";
|
|
@@ -39,6 +40,7 @@ const basePropDefs = {
|
|
|
39
40
|
},
|
|
40
41
|
"$clone": {
|
|
41
42
|
value: function (update) {
|
|
43
|
+
// I think `rawObj` is the same thing as `this` and can be removed?
|
|
42
44
|
const rawObj = this[UnderlyingOsdkObject];
|
|
43
45
|
const def = this[ObjectDefRef];
|
|
44
46
|
if (update == null) {
|
|
@@ -58,16 +60,29 @@ const basePropDefs = {
|
|
|
58
60
|
};
|
|
59
61
|
return createOsdkObject(this[ClientRef], this[ObjectDefRef], newObject);
|
|
60
62
|
}
|
|
63
|
+
},
|
|
64
|
+
"$objectSpecifier": {
|
|
65
|
+
get: function () {
|
|
66
|
+
const rawObj = this[UnderlyingOsdkObject];
|
|
67
|
+
return createObjectSpecifierFromPrimaryKey(this[ObjectDefRef], rawObj.$primaryKey);
|
|
68
|
+
},
|
|
69
|
+
enumerable: true
|
|
61
70
|
}
|
|
62
71
|
};
|
|
63
72
|
|
|
64
|
-
/**
|
|
65
|
-
|
|
73
|
+
/**
|
|
74
|
+
* @internal
|
|
75
|
+
* @param client
|
|
76
|
+
* @param objectDef
|
|
77
|
+
* @param simpleOsdkProperties
|
|
78
|
+
*/
|
|
79
|
+
export function createOsdkObject(client, objectDef, simpleOsdkProperties, derivedPropertyTypeByName = {}) {
|
|
66
80
|
// updates the object's "hidden class/map".
|
|
81
|
+
const rawObj = simpleOsdkProperties;
|
|
67
82
|
Object.defineProperties(rawObj, {
|
|
68
83
|
[UnderlyingOsdkObject]: {
|
|
69
84
|
enumerable: false,
|
|
70
|
-
value:
|
|
85
|
+
value: simpleOsdkProperties
|
|
71
86
|
},
|
|
72
87
|
[ObjectDefRef]: {
|
|
73
88
|
value: objectDef,
|
|
@@ -84,6 +99,17 @@ export function createOsdkObject(client, objectDef, rawObj) {
|
|
|
84
99
|
for (const propKey of Object.keys(rawObj)) {
|
|
85
100
|
if (propKey in objectDef.properties && typeof objectDef.properties[propKey].type === "string" && specialPropertyTypes.has(objectDef.properties[propKey].type)) {
|
|
86
101
|
rawObj[propKey] = createSpecialProperty(client, objectDef, rawObj, propKey);
|
|
102
|
+
} else if (propKey in derivedPropertyTypeByName && typeof derivedPropertyTypeByName[propKey].type === "string" && specialPropertyTypes.has(derivedPropertyTypeByName[propKey].type)) {
|
|
103
|
+
const rawValue = rawObj[propKey];
|
|
104
|
+
if (derivedPropertyTypeByName[propKey].type === "attachment") {
|
|
105
|
+
if (Array.isArray(rawValue)) {
|
|
106
|
+
rawObj[propKey] = rawValue.map(a => hydrateAttachmentFromRidInternal(client, a.rid));
|
|
107
|
+
} else {
|
|
108
|
+
rawObj[propKey] = hydrateAttachmentFromRidInternal(client, rawValue.rid);
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
process.env.NODE_ENV !== "production" ? invariant(false, "Derived property aggregations for Timeseries and Media are not supported") : invariant(false);
|
|
112
|
+
}
|
|
87
113
|
}
|
|
88
114
|
}
|
|
89
115
|
return Object.freeze(rawObj);
|
|
@@ -94,39 +120,31 @@ function createSpecialProperty(client, objectDef, rawObject, p) {
|
|
|
94
120
|
if (process.env.NODE_ENV !== "production") {
|
|
95
121
|
!(propDef != null && typeof propDef.type === "string" && specialPropertyTypes.has(propDef.type)) ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
|
|
96
122
|
}
|
|
97
|
-
{
|
|
98
|
-
{
|
|
99
|
-
|
|
100
|
-
{
|
|
101
|
-
if (propDef.type === "attachment") {
|
|
102
|
-
if (Array.isArray(rawValue)) {
|
|
103
|
-
return rawValue.map(a => hydrateAttachmentFromRidInternal(client, a.rid));
|
|
104
|
-
}
|
|
105
|
-
return hydrateAttachmentFromRidInternal(client, rawValue.rid);
|
|
106
|
-
}
|
|
107
|
-
if (propDef.type === "numericTimeseries" || propDef.type === "stringTimeseries" || propDef.type === "sensorTimeseries") {
|
|
108
|
-
return new TimeSeriesPropertyImpl(client, objectDef.apiName, rawObject[objectDef.primaryKeyApiName], p);
|
|
109
|
-
}
|
|
110
|
-
if (propDef.type === "geotimeSeriesReference") {
|
|
111
|
-
return new GeotimeSeriesPropertyImpl(client, objectDef.apiName, rawObject[objectDef.primaryKeyApiName], p, rawValue.type === "geotimeSeriesValue" ? {
|
|
112
|
-
time: rawValue.timestamp,
|
|
113
|
-
value: {
|
|
114
|
-
type: "Point",
|
|
115
|
-
coordinates: rawValue.position
|
|
116
|
-
}
|
|
117
|
-
} : undefined);
|
|
118
|
-
}
|
|
119
|
-
if (propDef.type === "mediaReference") {
|
|
120
|
-
return new MediaReferencePropertyImpl({
|
|
121
|
-
client,
|
|
122
|
-
objectApiName: objectDef.apiName,
|
|
123
|
-
primaryKey: rawObject[objectDef.primaryKeyApiName],
|
|
124
|
-
propertyName: p
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
123
|
+
if (propDef.type === "attachment") {
|
|
124
|
+
if (Array.isArray(rawValue)) {
|
|
125
|
+
return rawValue.map(a => hydrateAttachmentFromRidInternal(client, a.rid));
|
|
129
126
|
}
|
|
127
|
+
return hydrateAttachmentFromRidInternal(client, rawValue.rid);
|
|
128
|
+
}
|
|
129
|
+
if (propDef.type === "numericTimeseries" || propDef.type === "stringTimeseries" || propDef.type === "sensorTimeseries") {
|
|
130
|
+
return new TimeSeriesPropertyImpl(client, objectDef.apiName, rawObject[objectDef.primaryKeyApiName], p);
|
|
131
|
+
}
|
|
132
|
+
if (propDef.type === "geotimeSeriesReference") {
|
|
133
|
+
return new GeotimeSeriesPropertyImpl(client, objectDef.apiName, rawObject[objectDef.primaryKeyApiName], p, rawValue.type === "geotimeSeriesValue" ? {
|
|
134
|
+
time: rawValue.timestamp,
|
|
135
|
+
value: {
|
|
136
|
+
type: "Point",
|
|
137
|
+
coordinates: rawValue.position
|
|
138
|
+
}
|
|
139
|
+
} : undefined);
|
|
140
|
+
}
|
|
141
|
+
if (propDef.type === "mediaReference") {
|
|
142
|
+
return new MediaReferencePropertyImpl({
|
|
143
|
+
client,
|
|
144
|
+
objectApiName: objectDef.apiName,
|
|
145
|
+
primaryKey: rawObject[objectDef.primaryKeyApiName],
|
|
146
|
+
propertyName: p
|
|
147
|
+
});
|
|
130
148
|
}
|
|
131
149
|
}
|
|
132
150
|
//# sourceMappingURL=createOsdkObject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOsdkObject.js","names":["invariant","GeotimeSeriesPropertyImpl","MediaReferencePropertyImpl","TimeSeriesPropertyImpl","hydrateAttachmentFromRidInternal","get$as","get$link","ClientRef","ObjectDefRef","UnderlyingOsdkObject","specialPropertyTypes","Set","basePropDefs","get","value","update","rawObj","def","createOsdkObject","primaryKeyApiName","Error","apiName","titleProperty","$title","newObject","client","objectDef","Object","defineProperties","enumerable","propKey","keys","properties","type","has","createSpecialProperty","freeze","rawObject","p","rawValue","propDef","process","env","NODE_ENV","Array","isArray","map","a","rid","time","timestamp","coordinates","position","undefined","objectApiName","primaryKey","propertyName"],"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 { ObjectTypeDefinition, Osdk } from \"@osdk/api\";\nimport type { OntologyObjectV2 } 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 { MinimalClient } from \"../../MinimalClientContext.js\";\nimport type { FetchedObjectTypeDefinition } from \"../../ontology/OntologyProvider.js\";\nimport { hydrateAttachmentFromRidInternal } from \"../../public-utils/hydrateAttachmentFromRid.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\ninterface InternalOsdkInstance {\n [ObjectDefRef]: FetchedObjectTypeDefinition;\n [ClientRef]: MinimalClient;\n}\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: InternalOsdkInstance) {\n return get$as(this[ObjectDefRef]);\n },\n },\n \"$link\": {\n get: function(this: InternalOsdkInstance & ObjectHolder<any>) {\n return get$link(this);\n },\n },\n \"$clone\": {\n value: function(\n this: InternalOsdkInstance & ObjectHolder<any>,\n update: Record<string, any> | undefined,\n ) {\n const rawObj = this[UnderlyingOsdkObject];\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};\n\n/** @internal */\nexport function createOsdkObject<\n Q extends FetchedObjectTypeDefinition,\n>(\n client: MinimalClient,\n objectDef: Q,\n rawObj: OntologyObjectV2,\n): Osdk<ObjectTypeDefinition, any> {\n // updates the object's \"hidden class/map\".\n Object.defineProperties(rawObj, {\n [UnderlyingOsdkObject]: {\n enumerable: false,\n value: rawObj,\n },\n [ObjectDefRef]: { value: objectDef, enumerable: false },\n [ClientRef]: { value: client, enumerable: false },\n ...basePropDefs,\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 as any,\n propKey,\n );\n }\n }\n\n return Object.freeze(rawObj) as Osdk<ObjectTypeDefinition, any>;\n}\n\nfunction createSpecialProperty(\n client: MinimalClient,\n objectDef: FetchedObjectTypeDefinition,\n rawObject: Osdk.Instance<any>,\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 {\n {\n {\n {\n if (propDef.type === \"attachment\") {\n if (Array.isArray(rawValue)) {\n return rawValue.map(a =>\n hydrateAttachmentFromRidInternal(client, a.rid)\n );\n }\n return hydrateAttachmentFromRidInternal(client, rawValue.rid);\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.type === \"geotimeSeriesValue\"\n ? {\n time: rawValue.timestamp,\n value: {\n type: \"Point\",\n coordinates: rawValue.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 });\n }\n }\n }\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;AA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Q,CAACW,SAAS;cACxBpC,KAAK,EAAE;gBACLmB,IAAI,EAAE,OAAO;gBACbkB,WAAW,EAAEZ,QAAQ,CAACa;cACxB;YACF,CAAC,GACCC,SACN,CAAC;UACH;UACA,IAAIb,OAAO,CAACP,IAAI,KAAK,gBAAgB,EAAE;YACrC,OAAO,IAAI/B,0BAA0B,CAAC;cACpCuB,MAAM;cACN6B,aAAa,EAAE5B,SAAS,CAACL,OAAO;cAChCkC,UAAU,EAAElB,SAAS,CAACX,SAAS,CAACP,iBAAiB,CAAW;cAC5DqC,YAAY,EAAElB;YAChB,CAAC,CAAC;UACJ;QACF;MACF;IACF;EACF;AACF","ignoreList":[]}
|
|
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","client","objectDef","simpleOsdkProperties","derivedPropertyTypeByName","Object","defineProperties","propKey","keys","properties","type","has","createSpecialProperty","rawValue","Array","isArray","map","a","rid","process","env","NODE_ENV","freeze","rawObject","p","propDef","time","timestamp","coordinates","position","undefined","objectApiName","primaryKey","propertyName"],"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 { ObjectMetadata } from \"@osdk/api\";\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 { 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};\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: Record<string, ObjectMetadata.Property> = {},\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 },\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 (\n propKey in derivedPropertyTypeByName\n && typeof (derivedPropertyTypeByName[propKey].type) === \"string\"\n && specialPropertyTypes.has(derivedPropertyTypeByName[propKey].type)\n ) {\n const rawValue = rawObj[propKey as any];\n if (derivedPropertyTypeByName[propKey].type === \"attachment\") {\n if (Array.isArray(rawValue)) {\n rawObj[propKey] = rawValue.map(a =>\n hydrateAttachmentFromRidInternal(client, a.rid)\n );\n } else {\n rawObj[propKey] = hydrateAttachmentFromRidInternal(\n client,\n (rawValue as Attachment).rid,\n );\n }\n } else {\n invariant(\n false,\n \"Derived property aggregations for Timeseries and Media are not supported\",\n );\n }\n }\n }\n\n return Object.freeze(rawObj);\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 });\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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AoBH,IAAI,KAAK,oBAAoB,GACtD;MACAgB,IAAI,EAAGb,QAAQ,CAAoBc,SAAS;MAC5CvC,KAAK,EAAE;QACLsB,IAAI,EAAE,OAAO;QACbkB,WAAW,EAAGf,QAAQ,CAAoBgB;MAC5C;IACF,CAAC,GACCC,SACN,CAAC;EACH;EACA,IAAIL,OAAO,CAACf,IAAI,KAAK,gBAAgB,EAAE;IACrC,OAAO,IAAInC,0BAA0B,CAAC;MACpC0B,MAAM;MACN8B,aAAa,EAAE7B,SAAS,CAACP,OAAO;MAChCqC,UAAU,EAAET,SAAS,CAACrB,SAAS,CAACT,iBAAiB,CAAW;MAC5DwC,YAAY,EAAET;IAChB,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDollarAs.js","names":["InterfaceDefinitions","createSimpleCache","createOsdkInterface","UnderlyingOsdkObject","get$as","WeakMap","$asFactory","get","osdkObjectToInterfaceView","Map","objDef","targetMinDef","targetInterfaceApiName","apiName","interfaceMap","Error","type","def","underlying","existing","deref","osdkInterface","set","WeakRef"],"sources":["getDollarAs.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 { ObjectOrInterfaceDefinition,
|
|
1
|
+
{"version":3,"file":"getDollarAs.js","names":["InterfaceDefinitions","createSimpleCache","createOsdkInterface","UnderlyingOsdkObject","get$as","WeakMap","$asFactory","get","osdkObjectToInterfaceView","Map","objDef","targetMinDef","targetInterfaceApiName","apiName","interfaceMap","Error","type","def","underlying","existing","deref","osdkInterface","set","WeakRef"],"sources":["getDollarAs.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 { ObjectOrInterfaceDefinition, OsdkBase } from \"@osdk/api\";\nimport {\n type FetchedObjectTypeDefinition,\n InterfaceDefinitions,\n} from \"../../ontology/OntologyProvider.js\";\nimport { createSimpleCache } from \"../SimpleCache.js\";\nimport { createOsdkInterface } from \"./createOsdkInterface.js\";\nimport type { InterfaceHolder } from \"./InterfaceHolder.js\";\nimport { UnderlyingOsdkObject } from \"./InternalSymbols.js\";\nimport type { ObjectHolder } from \"./ObjectHolder.js\";\n\n/** @internal */\nexport type DollarAsFn = <\n Q extends FetchedObjectTypeDefinition,\n NEW_Q extends ObjectOrInterfaceDefinition,\n>(\n this: InterfaceHolder | ObjectHolder,\n newDef: string | NEW_Q,\n) => OsdkBase<any>;\n\nexport const get$as: (key: FetchedObjectTypeDefinition) => DollarAsFn =\n createSimpleCache<\n FetchedObjectTypeDefinition,\n DollarAsFn\n >(new WeakMap(), $asFactory).get;\n\nconst osdkObjectToInterfaceView = createSimpleCache(\n new WeakMap<\n OsdkBase<any>,\n Map<string, WeakRef<OsdkBase<any>>>\n >(),\n () =>\n new Map<\n /* interface api name */ string,\n /* $as'd object */ WeakRef<OsdkBase<any>>\n >(),\n);\n\nfunction $asFactory(\n objDef: FetchedObjectTypeDefinition,\n): DollarAsFn {\n // We use the exact same logic for both the interface rep and the underlying rep\n\n return function $as<\n NEW_Q extends ObjectOrInterfaceDefinition,\n >(\n this: OsdkBase<any> & { [UnderlyingOsdkObject]: any },\n targetMinDef: NEW_Q | string,\n ): OsdkBase<any> {\n let targetInterfaceApiName: string;\n\n if (typeof targetMinDef === \"string\") {\n if (targetMinDef === objDef.apiName) {\n return this[UnderlyingOsdkObject];\n }\n\n // this is sufficient to determine if we implement the interface\n if (objDef.interfaceMap?.[targetMinDef] == null) {\n throw new Error(\n `Object does not implement interface '${targetMinDef}'.`,\n );\n }\n\n targetInterfaceApiName = targetMinDef;\n } else if (targetMinDef.apiName === objDef.apiName) {\n return this[UnderlyingOsdkObject];\n } else {\n if (targetMinDef.type === \"object\") {\n throw new Error(\n `'${targetMinDef.apiName}' is not an interface nor is it '${objDef.apiName}', which is the object type.`,\n );\n }\n targetInterfaceApiName = targetMinDef.apiName;\n }\n\n const def = objDef[InterfaceDefinitions][targetInterfaceApiName];\n if (!def) {\n throw new Error(\n `Object does not implement interface '${targetInterfaceApiName}'.`,\n );\n }\n\n const underlying = this[UnderlyingOsdkObject];\n\n const existing = osdkObjectToInterfaceView\n .get(underlying)\n .get(targetInterfaceApiName)?.deref();\n if (existing) return existing;\n\n const osdkInterface = createOsdkInterface(underlying, def.def);\n osdkObjectToInterfaceView.get(underlying).set(\n targetInterfaceApiName,\n new WeakRef(osdkInterface),\n );\n return osdkInterface;\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAEEA,oBAAoB,QACf,oCAAoC;AAC3C,SAASC,iBAAiB,QAAQ,mBAAmB;AACrD,SAASC,mBAAmB,QAAQ,0BAA0B;AAE9D,SAASC,oBAAoB,QAAQ,sBAAsB;;AAG3D;;AASA,OAAO,MAAMC,MAAwD,GACnEH,iBAAiB,CAGf,IAAII,OAAO,CAAC,CAAC,EAAEC,UAAU,CAAC,CAACC,GAAG;AAElC,MAAMC,yBAAyB,GAAGP,iBAAiB,CACjD,IAAII,OAAO,CAGT,CAAC,EACH,MACE,IAAII,GAAG,CA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CAACD,GAAG,CAACW,UAAU,CAAC,CAACI,GAAG,CAC3CV,sBAAsB,EACtB,IAAIW,OAAO,CAACF,aAAa,CAC3B,CAAC;IACD,OAAOA,aAAa;EACtB,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDollarLink.js","names":["getWireObjectSet","fetchSingle","fetchSingleWithErrors","ClientRef","ObjectDefRef","UnderlyingOsdkObject","get$link","holder","client","objDef","rawObj","Object","freeze","fromEntries","keys","links","map","linkName","linkDef","objectSet","objectSetFactory","where","primaryKeyApiName","$primaryKey","pivotTo","value","multiplicity","fetchOne","options","fetchOneWithErrors"],"sources":["getDollarLink.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 {\n ObjectSet,\n
|
|
1
|
+
{"version":3,"file":"getDollarLink.js","names":["getWireObjectSet","fetchSingle","fetchSingleWithErrors","ClientRef","ObjectDefRef","UnderlyingOsdkObject","get$link","holder","client","objDef","rawObj","Object","freeze","fromEntries","keys","links","map","linkName","linkDef","objectSet","objectSetFactory","where","primaryKeyApiName","$primaryKey","pivotTo","value","multiplicity","fetchOne","options","fetchOneWithErrors"],"sources":["getDollarLink.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 {\n ObjectSet,\n OsdkObjectLinksObject,\n SelectArg,\n SingleLinkAccessor,\n WhereClause,\n} from \"@osdk/api\";\nimport { getWireObjectSet } from \"../../objectSet/createObjectSet.js\";\nimport { fetchSingle, fetchSingleWithErrors } from \"../fetchSingle.js\";\nimport {\n ClientRef,\n ObjectDefRef,\n UnderlyingOsdkObject,\n} from \"./InternalSymbols.js\";\nimport type { ObjectHolder } from \"./ObjectHolder.js\";\n\n/** @internal */\nexport function get$link(\n holder: ObjectHolder,\n): OsdkObjectLinksObject<any> {\n const client = holder[ClientRef];\n const objDef = holder[ObjectDefRef];\n const rawObj = holder[UnderlyingOsdkObject];\n return Object.freeze(Object.fromEntries(\n Object.keys(objDef.links).map(\n (linkName) => {\n const linkDef = objDef.links[linkName as keyof typeof objDef.links];\n const objectSet =\n (client.objectSetFactory(objDef, client) as ObjectSet<any>)\n .where({\n [objDef.primaryKeyApiName]: rawObj.$primaryKey,\n } as WhereClause<any>)\n .pivotTo(linkName);\n\n const value = !linkDef.multiplicity\n ? {\n fetchOne: <A extends SelectArg<any, any, any, any>>(\n options?: A,\n ) =>\n fetchSingle(\n client,\n objDef,\n options ?? {},\n getWireObjectSet(objectSet),\n ),\n fetchOneWithErrors: <A extends SelectArg<any, any, any, any>>(\n options?: A,\n ) =>\n fetchSingleWithErrors(\n client,\n objDef,\n options ?? {},\n getWireObjectSet(objectSet),\n ),\n } as SingleLinkAccessor<any>\n : objectSet;\n\n return [linkName, value];\n },\n ),\n ));\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAASA,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,WAAW,EAAEC,qBAAqB,QAAQ,mBAAmB;AACtE,SACEC,SAAS,EACTC,YAAY,EACZC,oBAAoB,QACf,sBAAsB;AAG7B;AACA,OAAO,SAASC,QAAQA,CACtBC,MAAoB,EACQ;EAC5B,MAAMC,MAAM,GAAGD,MAAM,CAACJ,SAAS,CAAC;EAChC,MAAMM,MAAM,GAAGF,MAAM,CAACH,YAAY,CAAC;EACnC,MAAMM,MAAM,GAAGH,MAAM,CAACF,oBAAoB,CAAC;EAC3C,OAAOM,MAAM,CAACC,MAAM,CAACD,MAAM,CAACE,WAAW,CACrCF,MAAM,CAACG,IAAI,CAACL,MAAM,CAACM,KAAK,CAAC,CAACC,GAAG,CAC1BC,QAAQ,IAAK;IACZ,MAAMC,OAAO,GAAGT,MAAM,CAACM,KAAK,CAACE,QAAQ,CAA8B;IACnE,MAAME,SAAS,GACZX,MAAM,CAACY,gBAAgB,CAACX,MAAM,EAAED,MAAM,CAAC,CACrCa,KAAK,CAAC;MACL,CAACZ,MAAM,CAACa,iBAAiB,GAAGZ,MAAM,CAACa;IACrC,CAAqB,CAAC,CACrBC,OAAO,CAACP,QAAQ,CAAC;IAEtB,MAAMQ,KAAK,GAAG,CAACP,OAAO,CAACQ,YAAY,GAC/B;MACAC,QAAQ,EACNC,OAAW,IAEX3B,WAAW,CACTO,MAAM,EACNC,MAAM,EACNmB,OAAO,IAAI,CAAC,CAAC,EACb5B,gBAAgB,CAACmB,SAAS,CAC5B,CAAC;MACHU,kBAAkB,EAChBD,OAAW,IAEX1B,qBAAqB,CACnBM,MAAM,EACNC,MAAM,EACNmB,OAAO,IAAI,CAAC,CAAC,EACb5B,gBAAgB,CAACmB,SAAS,CAC5B;IACJ,CAAC,GACCA,SAAS;IAEb,OAAO,CAACF,QAAQ,EAAEQ,KAAK,CAAC;EAC1B,CACF,CACF,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -16,8 +16,6 @@
|
|
|
16
16
|
|
|
17
17
|
import invariant from "tiny-invariant";
|
|
18
18
|
import { createOsdkObject } from "./convertWireToOsdkObjects/createOsdkObject.js";
|
|
19
|
-
import { createObjectSpecifierFromPrimaryKey } from "./createObjectSpecifierFromPrimaryKey.js";
|
|
20
|
-
|
|
21
19
|
/**
|
|
22
20
|
* If interfaceApiName is not undefined, converts the instances of the
|
|
23
21
|
* interface into their respective
|
|
@@ -34,8 +32,9 @@ import { createObjectSpecifierFromPrimaryKey } from "./createObjectSpecifierFrom
|
|
|
34
32
|
* @internal
|
|
35
33
|
* @param interfaceApiName - if undefined
|
|
36
34
|
*/
|
|
37
|
-
export async function convertWireToOsdkObjects(client, objects, interfaceApiName, forceRemoveRid = false, selectedProps, strictNonNull = false) {
|
|
38
|
-
|
|
35
|
+
export async function convertWireToOsdkObjects(client, objects, interfaceApiName, forceRemoveRid = false, derivedPropertyTypesByName, selectedProps, strictNonNull = false) {
|
|
36
|
+
// remove the __ prefixed properties and convert them to $ prefixed.
|
|
37
|
+
// updates in place
|
|
39
38
|
fixObjectPropertiesInPlace(objects, forceRemoveRid);
|
|
40
39
|
const ifaceDef = interfaceApiName ? await client.ontologyProvider.getInterfaceDefinition(interfaceApiName) : undefined;
|
|
41
40
|
const ifaceSelected = ifaceDef ? selectedProps ?? Object.keys(ifaceDef.properties) : undefined;
|
|
@@ -62,19 +61,16 @@ export async function convertWireToOsdkObjects(client, objects, interfaceApiName
|
|
|
62
61
|
} else if (strictNonNull === "drop" && !conforming) {
|
|
63
62
|
continue;
|
|
64
63
|
}
|
|
65
|
-
let osdkObject = createOsdkObject(client, objectDef, rawObj);
|
|
64
|
+
let osdkObject = createOsdkObject(client, objectDef, rawObj, derivedPropertyTypesByName);
|
|
66
65
|
if (interfaceApiName) osdkObject = osdkObject.$as(interfaceApiName);
|
|
67
66
|
ret.push(osdkObject);
|
|
68
67
|
}
|
|
69
|
-
client.logger?.debug(`END convertWireToOsdkObjects()`);
|
|
70
68
|
return ret;
|
|
71
69
|
}
|
|
72
|
-
|
|
73
70
|
/**
|
|
74
71
|
* @internal
|
|
75
72
|
*/
|
|
76
|
-
export async function convertWireToOsdkObjects2(client, objects, interfaceApiName, forceRemoveRid = false, selectedProps, strictNonNull = false, interfaceToObjectTypeMappings = {}) {
|
|
77
|
-
client.logger?.debug(`START convertWireToOsdkObjects2()`);
|
|
73
|
+
export async function convertWireToOsdkObjects2(client, objects, interfaceApiName, derivedPropertyTypeByName, forceRemoveRid = false, selectedProps, strictNonNull = false, interfaceToObjectTypeMappings = {}) {
|
|
78
74
|
fixObjectPropertiesInPlace(objects, forceRemoveRid);
|
|
79
75
|
const ret = [];
|
|
80
76
|
for (const rawObj of objects) {
|
|
@@ -100,11 +96,10 @@ export async function convertWireToOsdkObjects2(client, objects, interfaceApiNam
|
|
|
100
96
|
} else if (strictNonNull === "drop" && !conforming) {
|
|
101
97
|
continue;
|
|
102
98
|
}
|
|
103
|
-
let osdkObject = createOsdkObject(client, objectDef, rawObj);
|
|
99
|
+
let osdkObject = createOsdkObject(client, objectDef, rawObj, derivedPropertyTypeByName);
|
|
104
100
|
if (interfaceApiName) osdkObject = osdkObject.$as(interfaceApiName);
|
|
105
101
|
ret.push(osdkObject);
|
|
106
102
|
}
|
|
107
|
-
client.logger?.debug(`END convertWireToOsdkObjects2()`);
|
|
108
103
|
return ret;
|
|
109
104
|
}
|
|
110
105
|
|
|
@@ -148,6 +143,7 @@ function isConforming(client, def, obj, propsToCheck) {
|
|
|
148
143
|
if (process.env.NODE_ENV !== "production") {
|
|
149
144
|
client.logger?.debug({
|
|
150
145
|
obj: {
|
|
146
|
+
$apiName: obj["$apiName"],
|
|
151
147
|
$objectType: obj["$objectType"],
|
|
152
148
|
$primaryKey: obj["$primaryKey"]
|
|
153
149
|
}
|
|
@@ -190,10 +186,6 @@ function fixObjectPropertiesInPlace(objs, forceRemoveRid) {
|
|
|
190
186
|
// copying over for now as its always returned. In the future, this should just be inferred from underlying
|
|
191
187
|
obj.$primaryKey ??= obj.__primaryKey;
|
|
192
188
|
obj.$title ??= obj.__title;
|
|
193
|
-
obj.$objectSpecifier = createObjectSpecifierFromPrimaryKey({
|
|
194
|
-
apiName: obj.$apiName,
|
|
195
|
-
type: "object"
|
|
196
|
-
}, obj.$primaryKey);
|
|
197
189
|
|
|
198
190
|
// we don't want people to use these
|
|
199
191
|
delete obj.__apiName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertWireToOsdkObjects.js","names":["invariant","createOsdkObject","createObjectSpecifierFromPrimaryKey","convertWireToOsdkObjects","client","objects","interfaceApiName","forceRemoveRid","selectedProps","strictNonNull","logger","debug","fixObjectPropertiesInPlace","ifaceDef","ontologyProvider","getInterfaceDefinition","undefined","ifaceSelected","Object","keys","properties","ret","rawObj","objectDef","getObjectDefinition","$apiName","process","env","NODE_ENV","objProps","conforming","invariantInterfacesAsViews","apiName","isConforming","reframeAsObjectInPlace","convertInterfacePropNamesToObjectPropNames","Error","osdkObject","$as","push","convertWireToOsdkObjects2","interfaceToObjectTypeMappings","interfaceToObjMapping","filter","val","includes","values","primaryKeyApiName","ifacePropsToMap","map","ifaceProp","interfaceMap","newProps","sptProp","regularProp","entries","value","assign","$primaryKey","def","obj","propsToCheck","propName","nullable","$objectType","warning","warn","console","error","objs","__rid","$rid","__apiName","__primaryKey","$title","__title","$objectSpecifier","type"],"sources":["convertWireToOsdkObjects.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n InterfaceMetadata,\n NullabilityAdherence,\n ObjectMetadata,\n ObjectOrInterfaceDefinition,\n Osdk,\n} from \"@osdk/api\";\nimport type {\n InterfaceToObjectTypeMappings,\n InterfaceTypeApiName,\n OntologyObjectV2,\n} from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport {\n type FetchedObjectTypeDefinition,\n} from \"../ontology/OntologyProvider.js\";\nimport { createOsdkObject } from \"./convertWireToOsdkObjects/createOsdkObject.js\";\nimport { createObjectSpecifierFromPrimaryKey } from \"./createObjectSpecifierFromPrimaryKey.js\";\n\n/**\n * If interfaceApiName is not undefined, converts the instances of the\n * interface into their respective\n * underlying concrete types and then returns the $as() representation\n * for the consumers.\n *\n * Otherwise just does the conversion\n *\n * May mutate in place for performance reasons. If you need a clean copy,\n * keep it first.\n *\n * However, you must use the returned value, which will be whatever is correct.\n *\n * @internal\n * @param interfaceApiName - if undefined\n */\nexport async function convertWireToOsdkObjects(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string | undefined,\n forceRemoveRid: boolean = false,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull: NullabilityAdherence = false,\n): Promise<Osdk.Instance<ObjectOrInterfaceDefinition>[]> {\n client.logger?.debug(`START convertWireToOsdkObjects()`);\n\n fixObjectPropertiesInPlace(objects, forceRemoveRid);\n\n const ifaceDef = interfaceApiName\n ? await client.ontologyProvider.getInterfaceDefinition(interfaceApiName)\n : undefined;\n const ifaceSelected = ifaceDef\n ? (selectedProps ?? Object.keys(ifaceDef.properties))\n : undefined;\n\n const ret = [];\n for (const rawObj of objects) {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n rawObj.$apiName,\n );\n invariant(objectDef, `Missing definition for '${rawObj.$apiName}'`);\n\n // default value for when we are checking an object\n let objProps;\n\n let conforming = true;\n if (ifaceDef && ifaceSelected) {\n // API returns interface spt names but we cache by real values\n invariantInterfacesAsViews(objectDef, ifaceDef.apiName, client);\n\n conforming &&= isConforming(client, ifaceDef, rawObj, ifaceSelected);\n\n reframeAsObjectInPlace(objectDef, ifaceDef.apiName, rawObj);\n\n objProps = convertInterfacePropNamesToObjectPropNames(\n objectDef,\n ifaceDef.apiName,\n ifaceSelected,\n );\n } else {\n objProps = selectedProps ?? Object.keys(objectDef.properties);\n }\n\n conforming &&= isConforming(client, objectDef, rawObj, objProps);\n\n if (strictNonNull === \"throw\" && !conforming) {\n throw new Error(\n \"Unable to safely convert objects as some non nullable properties are null\",\n );\n } else if (strictNonNull === \"drop\" && !conforming) {\n continue;\n }\n\n let osdkObject = createOsdkObject(client, objectDef, rawObj);\n if (interfaceApiName) osdkObject = osdkObject.$as(interfaceApiName);\n\n ret.push(osdkObject);\n }\n\n client.logger?.debug(`END convertWireToOsdkObjects()`);\n return ret;\n}\n\n/**\n * @internal\n */\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string | undefined,\n forceRemoveRid: boolean = false,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull: NullabilityAdherence = false,\n interfaceToObjectTypeMappings: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n > = {},\n): Promise<Osdk.Instance<ObjectOrInterfaceDefinition>[]> {\n client.logger?.debug(`START convertWireToOsdkObjects2()`);\n\n fixObjectPropertiesInPlace(objects, forceRemoveRid);\n\n const ret = [];\n for (const rawObj of objects) {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n rawObj.$apiName,\n );\n invariant(objectDef, `Missing definition for '${rawObj.$apiName}'`);\n\n const interfaceToObjMapping = interfaceApiName\n ? interfaceToObjectTypeMappings[interfaceApiName as InterfaceTypeApiName][\n rawObj.$apiName\n ]\n : undefined;\n\n const ifaceSelected = interfaceApiName && interfaceToObjMapping\n ? (selectedProps\n ? Object.keys(interfaceToObjMapping).filter(\n val => {\n selectedProps?.includes(interfaceToObjMapping[val]);\n },\n )\n : [\n ...Object.values(interfaceToObjMapping),\n objectDef.primaryKeyApiName,\n ])\n : undefined;\n\n // default value for when we are checking an object\n let objProps;\n\n let conforming = true;\n if (interfaceApiName && ifaceSelected) {\n invariantInterfacesAsViews(objectDef, interfaceApiName, client);\n\n objProps = ifaceSelected;\n } else {\n objProps = selectedProps ?? Object.keys(objectDef.properties);\n }\n\n conforming &&= isConforming(client, objectDef, rawObj, objProps);\n\n if (strictNonNull === \"throw\" && !conforming) {\n throw new Error(\n \"Unable to safely convert objects as some non nullable properties are null\",\n );\n } else if (strictNonNull === \"drop\" && !conforming) {\n continue;\n }\n\n let osdkObject = createOsdkObject(client, objectDef, rawObj);\n if (interfaceApiName) osdkObject = osdkObject.$as(interfaceApiName);\n\n ret.push(osdkObject);\n }\n\n client.logger?.debug(`END convertWireToOsdkObjects2()`);\n return ret;\n}\n\n/**\n * @internal\n *\n * Utility function that lets us take down selected property names from an interface\n * and convert them to an array of property names on an object.\n */\nexport function convertInterfacePropNamesToObjectPropNames(\n objectDef: FetchedObjectTypeDefinition,\n interfaceApiName: string,\n ifacePropsToMap: readonly string[],\n): string[] {\n return ifacePropsToMap.map((ifaceProp) =>\n objectDef.interfaceMap[interfaceApiName][ifaceProp]\n );\n}\n\n/**\n * Takes a raw object from the wire (contextually as an interface) and\n * updates the fields to reflect the underlying objectDef instead\n * @param objectDef\n * @param interfaceApiName\n * @param client\n * @param rawObj\n */\nfunction reframeAsObjectInPlace(\n objectDef: FetchedObjectTypeDefinition,\n interfaceApiName: string,\n rawObj: OntologyObjectV2,\n) {\n const newProps: Record<string, any> = {};\n for (\n const [sptProp, regularProp] of Object.entries(\n objectDef.interfaceMap[interfaceApiName],\n )\n ) {\n if (sptProp in rawObj) {\n const value = rawObj[sptProp];\n delete rawObj[sptProp];\n if (value !== undefined) {\n newProps[regularProp] = value;\n }\n }\n }\n Object.assign(rawObj, newProps);\n\n if (!(objectDef.primaryKeyApiName in rawObj)) {\n rawObj[objectDef.primaryKeyApiName] = rawObj.$primaryKey;\n }\n}\n\nfunction isConforming(\n client: MinimalClient,\n def:\n | InterfaceMetadata\n | ObjectMetadata,\n obj: OntologyObjectV2,\n propsToCheck: readonly string[],\n) {\n for (const propName of propsToCheck) {\n if (\n propName in def.properties && def.properties[propName].nullable === false\n && obj[propName] == null\n ) {\n if (process.env.NODE_ENV !== \"production\") {\n client.logger?.debug(\n {\n obj: {\n $objectType: obj[\"$objectType\"],\n $primaryKey: obj[\"$primaryKey\"],\n },\n },\n `Found object that does not conform to its definition. Expected ${def.apiName}'s ${propName} to not be null.`,\n );\n }\n return false;\n }\n }\n return true;\n}\n\nfunction invariantInterfacesAsViews(\n objectDef: FetchedObjectTypeDefinition,\n interfaceApiName: string,\n client: MinimalClient,\n): asserts objectDef is typeof objectDef & { interfaceMap: {} } {\n if (objectDef.interfaceMap?.[interfaceApiName] == null) {\n const warning =\n \"Interfaces are only supported 'as views' but your metadata object is missing the correct information. This suggests your interfaces have not been migrated to the newer version yet and you cannot use this version of the SDK.\";\n if (client.logger) {\n client.logger.warn(warning);\n } else {\n // eslint-disable-next-line no-console\n console.error(`WARNING! ${warning}`);\n }\n throw new Error(warning);\n }\n}\n\nfunction fixObjectPropertiesInPlace(\n objs: OntologyObjectV2[],\n forceRemoveRid: boolean,\n) {\n for (const obj of objs) {\n if (forceRemoveRid) {\n delete obj.__rid;\n }\n\n if (obj.__rid) {\n obj.$rid = obj.__rid;\n delete obj.__rid;\n }\n\n // Backend returns as __apiName but we want to stick to $ structure\n obj.$apiName ??= obj.__apiName;\n\n // for now these are the same but when we start doing interface projections the $objectType will always be underlying and\n // the $apiName will be for the current view (in current designs)\n obj.$objectType = obj.$apiName;\n\n // copying over for now as its always returned. In the future, this should just be inferred from underlying\n obj.$primaryKey ??= obj.__primaryKey;\n obj.$title ??= obj.__title;\n\n obj.$objectSpecifier = createObjectSpecifierFromPrimaryKey(\n { apiName: obj.$apiName, type: \"object\" },\n obj.$primaryKey,\n );\n\n // we don't want people to use these\n delete obj.__apiName;\n delete obj.__primaryKey;\n delete obj.__title;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA,OAAOA,SAAS,MAAM,gBA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B;EACA,KAAK,MAAMqD,GAAG,IAAIS,IAAI,EAAE;IACtB,IAAI9D,cAAc,EAAE;MAClB,OAAOqD,GAAG,CAACU,KAAK;IAClB;IAEA,IAAIV,GAAG,CAACU,KAAK,EAAE;MACbV,GAAG,CAACW,IAAI,GAAGX,GAAG,CAACU,KAAK;MACpB,OAAOV,GAAG,CAACU,KAAK;IAClB;;IAEA;IACAV,GAAG,CAACnC,QAAQ,KAAKmC,GAAG,CAACY,SAAS;;IAE9B;IACA;IACAZ,GAAG,CAACI,WAAW,GAAGJ,GAAG,CAACnC,QAAQ;;IAE9B;IACAmC,GAAG,CAACF,WAAW,KAAKE,GAAG,CAACa,YAAY;IACpCb,GAAG,CAACc,MAAM,KAAKd,GAAG,CAACe,OAAO;IAE1Bf,GAAG,CAACgB,gBAAgB,GAAG1E,mCAAmC,CACxD;MAAE8B,OAAO,EAAE4B,GAAG,CAACnC,QAAQ;MAAEoD,IAAI,EAAE;IAAS,CAAC,EACzCjB,GAAG,CAACF,WACN,CAAC;;IAED;IACA,OAAOE,GAAG,CAACY,SAAS;IACpB,OAAOZ,GAAG,CAACa,YAAY;IACvB,OAAOb,GAAG,CAACe,OAAO;EACpB;AACF","ignoreList":[]}
|
|
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","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","__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 { 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: Record<\n string,\n ObjectMetadata.Property\n >,\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: Record<\n string,\n ObjectMetadata.Property\n >,\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: Record<\n string,\n ObjectMetadata.Property\n >,\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: Record<\n string,\n ObjectMetadata.Property\n >,\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: Record<\n string,\n ObjectMetadata.Property\n >,\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 ret = [];\n for (const rawObj of objects) {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n rawObj.$apiName,\n );\n invariant(objectDef, `Missing definition for '${rawObj.$apiName}'`);\n\n const interfaceToObjMapping = interfaceApiName\n ? interfaceToObjectTypeMappings[interfaceApiName as InterfaceTypeApiName][\n rawObj.$apiName\n ]\n : undefined;\n\n const ifaceSelected = interfaceApiName && interfaceToObjMapping\n ? (selectedProps\n ? Object.keys(interfaceToObjMapping).filter(\n val => {\n selectedProps?.includes(interfaceToObjMapping[val]);\n },\n )\n : [\n ...Object.values(interfaceToObjMapping),\n objectDef.primaryKeyApiName,\n ])\n : undefined;\n\n // default value for when we are checking an object\n let objProps;\n\n let conforming = true;\n if (interfaceApiName && ifaceSelected) {\n invariantInterfacesAsViews(objectDef, interfaceApiName, client);\n\n objProps = ifaceSelected;\n } else {\n objProps = selectedProps ?? Object.keys(objectDef.properties);\n }\n\n conforming &&= isConforming(client, objectDef, rawObj, objProps);\n\n if (strictNonNull === \"throw\" && !conforming) {\n throw new Error(\n \"Unable to safely convert objects as some non nullable properties are null\",\n );\n } else if (strictNonNull === \"drop\" && !conforming) {\n continue;\n }\n\n let osdkObject: ObjectHolder | InterfaceHolder = createOsdkObject(\n client,\n objectDef,\n rawObj,\n derivedPropertyTypeByName,\n );\n if (interfaceApiName) 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 // 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;AAKtC,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,0BAGC,EACDC,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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