@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableClient.js","names":["ObservableClientImpl","Store","ObservableClient","createObservableClient","client"],"sources":["ObservableClient.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ObjectTypeDefinition,\n PrimaryKeyType,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/api\";\nimport type { ActionSignatureFromDef } from \"../actions/applyAction.js\";\nimport type { Client } from \"../Client.js\";\nimport type { Canonical } from \"./internal/Canonical.js\";\nimport { ObservableClientImpl } from \"./internal/ObservableClientImpl.js\";\nimport { Store } from \"./internal/Store.js\";\nimport type {
|
|
1
|
+
{"version":3,"file":"ObservableClient.js","names":["ObservableClientImpl","Store","ObservableClient","createObservableClient","client"],"sources":["ObservableClient.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n InterfaceDefinition,\n ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/api\";\nimport type { ActionSignatureFromDef } from \"../actions/applyAction.js\";\nimport type { Client } from \"../Client.js\";\nimport type { Canonical } from \"./internal/Canonical.js\";\nimport { ObservableClientImpl } from \"./internal/ObservableClientImpl.js\";\nimport { Store } from \"./internal/Store.js\";\nimport type { OptimisticBuilder } from \"./OptimisticBuilder.js\";\n\nexport type Status = \"init\" | \"loading\" | \"loaded\" | \"error\";\n\nexport interface Observer<T> {\n next: (value: T) => void;\n error: (err: any) => void;\n complete: () => void;\n}\n\nexport namespace ObservableClient {\n export interface ApplyActionOptions {\n optimisticUpdate?: (ctx: OptimisticBuilder) => void;\n }\n}\n\nexport interface CommonObserveOptions {\n dedupeInterval?: number;\n}\n\nexport interface ObserveOptions {\n mode?: \"offline\" | \"force\";\n}\n\nexport interface ObserveObjectOptions<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> extends ObserveOptions {\n select?: PropertyKeys<T>[];\n}\n\nexport type OrderBy<Q extends ObjectTypeDefinition | InterfaceDefinition> = {\n [K in PropertyKeys<Q>]?: \"asc\" | \"desc\" | undefined;\n};\n\nexport interface ObserveListOptions<\n Q extends ObjectTypeDefinition | InterfaceDefinition,\n> extends CommonObserveOptions, ObserveOptions {\n type: Pick<Q, \"apiName\" | \"type\">;\n where?: WhereClause<Q>;\n pageSize?: number;\n orderBy?: OrderBy<Q>;\n invalidationMode?: \"in-place\" | \"wait\" | \"reset\";\n expectedLength?: number;\n streamUpdates?: boolean;\n}\n\nexport interface ObserveObjectArgs<T extends ObjectTypeDefinition> {\n object: Osdk.Instance<T> | undefined;\n isOptimistic: boolean;\n status: Status;\n lastUpdated: number;\n}\n\nexport interface ObserveObjectsArgs<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n resolvedList: Array<Osdk.Instance<T>>;\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<unknown>;\n hasMore: boolean;\n status: Status;\n}\n\nexport interface ObservableClient {\n observeObject<T extends ObjectTypeDefinition>(\n apiName: T[\"apiName\"] | T,\n pk: PrimaryKeyType<T>,\n options: ObserveOptions,\n subFn: Observer<ObserveObjectArgs<T>>,\n ): Unsubscribable;\n\n observeList<T extends ObjectTypeDefinition | InterfaceDefinition>(\n options: ObserveListOptions<T>,\n subFn: Observer<ObserveObjectsArgs<T>>,\n ): Unsubscribable;\n\n applyAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n opts?: ObservableClient.ApplyActionOptions,\n ) => Promise<unknown>;\n\n canonicalizeWhereClause: <\n T extends ObjectTypeDefinition | InterfaceDefinition,\n >(\n where: WhereClause<T>,\n ) => Canonical<WhereClause<T>>;\n}\n\nexport function createObservableClient(client: Client): ObservableClient {\n return new ObservableClientImpl(new Store(client));\n}\n\nexport interface Unsubscribable {\n unsubscribe: () => void;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA,SAASA,oBAAoB,QAAQ,oCAAoC;AACzE,SAASC,KAAK,QAAQ,qBAAqB;AAAC,WAW3BC,gBAAgB;AAgFjC,OAAO,SAASC,sBAAsBA,CAACC,MAAc,EAAoB;EACvE,OAAO,IAAIJ,oBAAoB,CAAC,IAAIC,KAAK,CAACG,MAAM,CAAC,CAAC;AACpD","ignoreList":[]}
|
|
@@ -14,19 +14,22 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import
|
|
18
|
-
import { createChangedObjects } from "./
|
|
17
|
+
import delay from "delay";
|
|
18
|
+
import { createChangedObjects } from "./Changes.js";
|
|
19
19
|
import { runOptimisticJob } from "./OptimisticJob.js";
|
|
20
20
|
const ACTION_DELAY = process.env.NODE_ENV === "production" ? 0 : 1000;
|
|
21
21
|
export class ActionApplication {
|
|
22
22
|
constructor(store) {
|
|
23
23
|
this.store = store;
|
|
24
24
|
}
|
|
25
|
-
applyAction = (action, args, {
|
|
25
|
+
applyAction = async (action, args, {
|
|
26
26
|
optimisticUpdate
|
|
27
27
|
} = {}) => {
|
|
28
|
+
const logger = process.env.NODE_ENV !== "production" ? this.store.logger?.child({
|
|
29
|
+
methodName: "applyAction"
|
|
30
|
+
}) : this.store.logger;
|
|
28
31
|
const removeOptimisticResult = runOptimisticJob(this.store, optimisticUpdate);
|
|
29
|
-
return (async () => {
|
|
32
|
+
return await (async () => {
|
|
30
33
|
try {
|
|
31
34
|
// The types for client get confused when we dynamically applyAction so we
|
|
32
35
|
// have to deal with the `any` here and force cast it to what it should be.
|
|
@@ -35,18 +38,18 @@ export class ActionApplication {
|
|
|
35
38
|
const actionResults = await this.store.client(action).applyAction(args, {
|
|
36
39
|
$returnEdits: true
|
|
37
40
|
});
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
if (process.env.NODE_ENV !== "production") {
|
|
42
|
+
if (ACTION_DELAY > 0) {
|
|
43
|
+
logger?.debug("action done, pausing", actionResults);
|
|
44
|
+
await delay(ACTION_DELAY);
|
|
45
|
+
logger?.debug("action done, pausing done");
|
|
46
|
+
}
|
|
44
47
|
}
|
|
45
48
|
await this.#invalidateActionEditResponse(actionResults);
|
|
46
49
|
return actionResults;
|
|
47
50
|
} finally {
|
|
48
51
|
if (process.env.NODE_ENV !== "production") {
|
|
49
|
-
|
|
52
|
+
logger?.debug("optimistic action complete; remove the results");
|
|
50
53
|
}
|
|
51
54
|
// make sure this happens even if the action fails
|
|
52
55
|
await removeOptimisticResult();
|
|
@@ -69,12 +72,24 @@ export class ActionApplication {
|
|
|
69
72
|
await Promise.all(promisesToWait);
|
|
70
73
|
|
|
71
74
|
// the action invocation just gives back object ids,
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
changes =
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
// but the invalidateObject calls above should have put the
|
|
76
|
+
// actual objects in the cache
|
|
77
|
+
const changes = createChangedObjects();
|
|
78
|
+
for (const changeType of ["addedObjects", "modifiedObjects"]) {
|
|
79
|
+
for (const {
|
|
80
|
+
objectType,
|
|
81
|
+
primaryKey
|
|
82
|
+
} of value[changeType] ?? []) {
|
|
83
|
+
const cacheKey = this.store.getCacheKey("object", objectType, primaryKey);
|
|
84
|
+
// N.B. this probably isn't right. `getValue`() will give you the "top"
|
|
85
|
+
// value but I think we want the "truth" guaranteed.
|
|
86
|
+
const obj = this.store.getValue(cacheKey);
|
|
87
|
+
if (obj && obj.value) {
|
|
88
|
+
changes[changeType].set(objectType, obj.value);
|
|
89
|
+
(changeType === "addedObjects" ? changes.added : changes.modified).add(cacheKey);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
78
93
|
} else {
|
|
79
94
|
for (const apiName of value.editedObjectTypes) {
|
|
80
95
|
typesToInvalidate.add(apiName.toString());
|
|
@@ -83,20 +98,5 @@ export class ActionApplication {
|
|
|
83
98
|
}
|
|
84
99
|
return value;
|
|
85
100
|
};
|
|
86
|
-
#changesFromActionEditResponse = value => {
|
|
87
|
-
const changes = createChangedObjects();
|
|
88
|
-
for (const changeType of ["addedObjects", "modifiedObjects"]) {
|
|
89
|
-
for (const {
|
|
90
|
-
objectType,
|
|
91
|
-
primaryKey
|
|
92
|
-
} of value[changeType] ?? []) {
|
|
93
|
-
const obj = this.store.getObject(objectType, primaryKey);
|
|
94
|
-
if (obj) {
|
|
95
|
-
changes[changeType].set(objectType, obj);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return changes;
|
|
100
|
-
};
|
|
101
101
|
}
|
|
102
102
|
//# sourceMappingURL=ActionApplication.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionApplication.js","names":["delay","createChangedObjects","runOptimisticJob","ACTION_DELAY","process","env","NODE_ENV","ActionApplication","constructor","store","applyAction","action","args","optimisticUpdate","
|
|
1
|
+
{"version":3,"file":"ActionApplication.js","names":["delay","createChangedObjects","runOptimisticJob","ACTION_DELAY","process","env","NODE_ENV","ActionApplication","constructor","store","applyAction","action","args","optimisticUpdate","logger","child","methodName","removeOptimisticResult","actionResults","client","$returnEdits","debug","invalidateActionEditResponse","value","typesToInvalidate","Set","changes","type","promisesToWait","obj","modifiedObjects","push","invalidateObject","objectType","primaryKey","addedObjects","add","Promise","all","changeType","cacheKey","getCacheKey","getValue","set","added","modified","apiName","editedObjectTypes","toString","invalidateObjectType"],"sources":["ActionApplication.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ActionDefinition, ActionEditResponse } from \"@osdk/api\";\nimport delay from \"delay\";\nimport type { ActionSignatureFromDef } from \"../../actions/applyAction.js\";\nimport { type Changes, createChangedObjects } from \"./Changes.js\";\nimport type { ObjectCacheKey } from \"./ObjectQuery.js\";\nimport { runOptimisticJob } from \"./OptimisticJob.js\";\nimport type { Store } from \"./Store.js\";\n\nconst ACTION_DELAY = process.env.NODE_ENV === \"production\" ? 0 : 1000;\n\nexport class ActionApplication {\n constructor(private store: Store) {}\n\n applyAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n opts?: Store.ApplyActionOptions,\n ) => Promise<ActionEditResponse> = async (\n action,\n args,\n { optimisticUpdate } = {},\n ) => {\n const logger = process.env.NODE_ENV !== \"production\"\n ? this.store.logger?.child({ methodName: \"applyAction\" })\n : this.store.logger;\n const removeOptimisticResult = runOptimisticJob(\n this.store,\n optimisticUpdate,\n );\n\n return await (async () => {\n try {\n // The types for client get confused when we dynamically applyAction so we\n // have to deal with the `any` here and force cast it to what it should be.\n // TODO: Update the types so this doesn't happen!\n\n const actionResults: ActionEditResponse = await this.store.client(\n action,\n ).applyAction(args as any, { $returnEdits: true });\n\n if (process.env.NODE_ENV !== \"production\") {\n if (ACTION_DELAY > 0) {\n logger?.debug(\"action done, pausing\", actionResults);\n await delay(ACTION_DELAY);\n logger?.debug(\"action done, pausing done\");\n }\n }\n await this.#invalidateActionEditResponse(actionResults);\n return actionResults;\n } finally {\n if (process.env.NODE_ENV !== \"production\") {\n logger?.debug(\n \"optimistic action complete; remove the results\",\n );\n }\n // make sure this happens even if the action fails\n await removeOptimisticResult();\n }\n })();\n };\n\n #invalidateActionEditResponse = async (\n value: ActionEditResponse,\n ): Promise<ActionEditResponse> => {\n const typesToInvalidate = new Set<string>();\n\n let changes: Changes | undefined;\n if (value.type === \"edits\") {\n const promisesToWait: Promise<any>[] = [];\n // TODO we need an backend update for deletes\n for (const obj of value.modifiedObjects) {\n promisesToWait.push(\n this.store.invalidateObject(obj.objectType, obj.primaryKey),\n );\n }\n\n for (const obj of value.addedObjects) {\n promisesToWait.push(\n this.store.invalidateObject(obj.objectType, obj.primaryKey),\n );\n\n typesToInvalidate.add(obj.objectType);\n }\n\n await Promise.all(promisesToWait);\n\n // the action invocation just gives back object ids,\n // but the invalidateObject calls above should have put the\n // actual objects in the cache\n const changes = createChangedObjects();\n for (const changeType of [\"addedObjects\", \"modifiedObjects\"] as const) {\n for (const { objectType, primaryKey } of (value[changeType] ?? [])) {\n const cacheKey = this.store.getCacheKey<ObjectCacheKey>(\n \"object\",\n objectType,\n primaryKey,\n );\n // N.B. this probably isn't right. `getValue`() will give you the \"top\"\n // value but I think we want the \"truth\" guaranteed.\n const obj = this.store.getValue(cacheKey);\n if (obj && obj.value) {\n changes[changeType].set(objectType, obj.value);\n (changeType === \"addedObjects\" ? changes.added : changes.modified)\n .add(cacheKey);\n }\n }\n }\n } else {\n for (const apiName of value.editedObjectTypes) {\n typesToInvalidate.add(apiName.toString());\n await this.store.invalidateObjectType(apiName as string, changes);\n }\n }\n\n return value;\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAAuBC,oBAAoB,QAAQ,cAAc;AAEjE,SAASC,gBAAgB,QAAQ,oBAAoB;AAGrD,MAAMC,YAAY,GAAGC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GAAG,CAAC,GAAG,IAAI;AAErE,OAAO,MAAMC,iBAAiB,CAAC;EAC7BC,WAAWA,CAASC,KAAY,EAAE;IAAA,KAAdA,KAAY,GAAZA,KAAY;EAAG;EAEnCC,WAAW,GAIwB,MAAAA,CACjCC,MAAM,EACNC,IAAI,EACJ;IAAEC;EAAiB,CAAC,GAAG,CAAC,CAAC,KACtB;IACH,MAAMC,MAAM,GAAGV,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GAChD,IAAI,CAACG,KAAK,CAACK,MAAM,EAAEC,KAAK,CAAC;MAAEC,UAAU,EAAE;IAAc,CAAC,CAAC,GACvD,IAAI,CAACP,KAAK,CAACK,MAAM;IACrB,MAAMG,sBAAsB,GAAGf,gBAAgB,CAC7C,IAAI,CAACO,KAAK,EACVI,gBACF,CAAC;IAED,OAAO,MAAM,CAAC,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* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { PalantirApiError } from "@osdk/shared.net.errors";
|
|
18
|
+
import { DefaultMap, DefaultWeakMap } from "mnemonist";
|
|
19
|
+
import pDefer from "p-defer";
|
|
20
|
+
import { additionalContext } from "../../Client.js";
|
|
21
|
+
const weakCache = new DefaultWeakMap(c => new BulkObjectLoader(c));
|
|
22
|
+
export function getBulkObjectLoader(client) {
|
|
23
|
+
return weakCache.get(client);
|
|
24
|
+
}
|
|
25
|
+
export class BulkObjectLoader {
|
|
26
|
+
#client;
|
|
27
|
+
#m = new DefaultMap(() => ({
|
|
28
|
+
data: [],
|
|
29
|
+
timer: undefined
|
|
30
|
+
}));
|
|
31
|
+
#logger;
|
|
32
|
+
#maxWait;
|
|
33
|
+
#maxEntries;
|
|
34
|
+
constructor(client, maxWait = 25, maxEntries = 100) {
|
|
35
|
+
this.#client = client;
|
|
36
|
+
this.#logger = client[additionalContext].logger;
|
|
37
|
+
this.#maxWait = maxWait;
|
|
38
|
+
this.#maxEntries = maxEntries;
|
|
39
|
+
}
|
|
40
|
+
fetch(apiName, primaryKey) {
|
|
41
|
+
const deferred = pDefer();
|
|
42
|
+
const entry = this.#m.get(apiName);
|
|
43
|
+
entry.data.push({
|
|
44
|
+
primaryKey: primaryKey,
|
|
45
|
+
deferred
|
|
46
|
+
});
|
|
47
|
+
if (!entry.timer) {
|
|
48
|
+
entry.timer = setTimeout(() => {
|
|
49
|
+
this.#loadObjects(apiName, entry.data);
|
|
50
|
+
}, this.#maxWait);
|
|
51
|
+
}
|
|
52
|
+
if (entry.data.length >= this.#maxEntries) {
|
|
53
|
+
clearTimeout(entry.timer);
|
|
54
|
+
this.#loadObjects(apiName, entry.data);
|
|
55
|
+
}
|
|
56
|
+
return deferred.promise;
|
|
57
|
+
}
|
|
58
|
+
#loadObjects(apiName, arr) {
|
|
59
|
+
this.#m.delete(apiName);
|
|
60
|
+
this.#reallyLoadObjects(apiName, arr).catch(e => {
|
|
61
|
+
this.#logger?.error("Unhandled exception", e);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async #reallyLoadObjects(apiName, arr) {
|
|
65
|
+
const miniDef = {
|
|
66
|
+
type: "object",
|
|
67
|
+
apiName
|
|
68
|
+
};
|
|
69
|
+
const objMetadata = await this.#client.fetchMetadata(miniDef);
|
|
70
|
+
const pks = arr.map(x => x.primaryKey);
|
|
71
|
+
const {
|
|
72
|
+
data
|
|
73
|
+
} = await this.#client(miniDef).where({
|
|
74
|
+
[objMetadata.primaryKeyApiName]: {
|
|
75
|
+
$in: pks
|
|
76
|
+
}
|
|
77
|
+
}).fetchPage({
|
|
78
|
+
$pageSize: pks.length
|
|
79
|
+
});
|
|
80
|
+
for (const {
|
|
81
|
+
primaryKey,
|
|
82
|
+
deferred
|
|
83
|
+
} of arr) {
|
|
84
|
+
const object = data.find(x => x.$primaryKey === primaryKey);
|
|
85
|
+
if (object) {
|
|
86
|
+
deferred.resolve(object);
|
|
87
|
+
} else {
|
|
88
|
+
deferred.reject(new PalantirApiError("Object not found"));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=BulkObjectLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BulkObjectLoader.js","names":["PalantirApiError","DefaultMap","DefaultWeakMap","pDefer","additionalContext","weakCache","c","BulkObjectLoader","getBulkObjectLoader","client","get","m","data","timer","undefined","logger","maxWait","maxEntries","constructor","fetch","apiName","primaryKey","deferred","entry","push","setTimeout","loadObjects","length","clearTimeout","promise","#loadObjects","arr","delete","reallyLoadObjects","catch","e","error","#reallyLoadObjects","miniDef","type","objMetadata","fetchMetadata","pks","map","x","where","primaryKeyApiName","$in","fetchPage","$pageSize","object","find","$primaryKey","resolve","reject"],"sources":["BulkObjectLoader.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Logger, ObjectTypeDefinition } from \"@osdk/api\";\nimport { PalantirApiError } from \"@osdk/shared.net.errors\";\nimport { DefaultMap, DefaultWeakMap } from \"mnemonist\";\nimport type { DeferredPromise } from \"p-defer\";\nimport pDefer from \"p-defer\";\nimport { additionalContext, type Client } from \"../../Client.js\";\nimport type {\n ObjectHolder,\n} from \"../../object/convertWireToOsdkObjects/ObjectHolder.js\";\n\ninterface InternalValue {\n primaryKey: string;\n deferred: DeferredPromise<ObjectHolder>;\n}\n\ninterface Accumulator {\n data: InternalValue[];\n timer?: ReturnType<typeof setTimeout>;\n}\n\nconst weakCache = new DefaultWeakMap<Client, BulkObjectLoader>(c =>\n new BulkObjectLoader(c)\n);\n\nexport function getBulkObjectLoader(client: Client): BulkObjectLoader {\n return weakCache.get(client);\n}\n\nexport class BulkObjectLoader {\n #client: Client;\n\n #m = new DefaultMap<string, Accumulator>(() => ({\n data: [],\n timer: undefined,\n }));\n #logger: Logger | undefined;\n #maxWait: number;\n #maxEntries: number;\n\n constructor(client: Client, maxWait = 25, maxEntries = 100) {\n this.#client = client;\n this.#logger = client[additionalContext].logger;\n this.#maxWait = maxWait;\n this.#maxEntries = maxEntries;\n }\n\n public fetch(\n apiName: string,\n primaryKey: string | number | boolean,\n ): Promise<ObjectHolder> {\n const deferred = pDefer<ObjectHolder>();\n\n const entry = this.#m.get(apiName);\n entry.data.push({\n primaryKey: primaryKey as string,\n deferred,\n });\n\n if (!entry.timer) {\n entry.timer = setTimeout(() => {\n this.#loadObjects(apiName, entry.data);\n }, this.#maxWait);\n }\n\n if (entry.data.length >= this.#maxEntries) {\n clearTimeout(entry.timer);\n this.#loadObjects(apiName, entry.data);\n }\n\n return deferred.promise;\n }\n\n #loadObjects(apiName: string, arr: InternalValue[]) {\n this.#m.delete(apiName);\n\n this.#reallyLoadObjects(apiName, arr).catch((e: unknown) => {\n this.#logger?.error(\"Unhandled exception\", e);\n });\n }\n\n async #reallyLoadObjects(apiName: string, arr: InternalValue[]) {\n const miniDef = { type: \"object\", apiName } as ObjectTypeDefinition;\n const objMetadata = await this.#client.fetchMetadata(miniDef);\n\n const pks = arr.map(x => x.primaryKey);\n\n const { data } = await this.#client(miniDef)\n .where({\n [objMetadata.primaryKeyApiName]: { $in: pks },\n }).fetchPage({\n $pageSize: pks.length,\n });\n\n for (const { primaryKey, deferred } of arr) {\n const object = data.find(x => x.$primaryKey === primaryKey) as\n | ObjectHolder\n | undefined;\n if (object) {\n deferred.resolve(object);\n } else {\n deferred.reject(new PalantirApiError(\"Object not found\"));\n }\n }\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,gBAAgB,QAAQ,yBAAyB;AAC1D,SAASC,UAAU,EAAEC,cAAc,QAAQ,WAAW;AAEtD,OAAOC,MAAM,MAAM,SAAS;AAC5B,SAASC,iBAAiB,QAAqB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AACuC,IAAI,CAACP,CAAC,IAAIA,CAAC,CAACQ,WAAW,KAAK/B,UAAU,CAE7C;MACb,IAAI6B,MAAM,EAAE;QACV5B,QAAQ,CAAC+B,OAAO,CAACH,MAAM,CAAC;MAC1B,CAAC,MAAM;QACL5B,QAAQ,CAACgC,MAAM,CAAC,IAAItD,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;MAC3D;IACF;EACF;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
18
|
+
import { BulkObjectLoader } from "./BulkObjectLoader.js";
|
|
19
|
+
import { createClientMockHelper } from "./testUtils.js";
|
|
20
|
+
describe(BulkObjectLoader, () => {
|
|
21
|
+
let client;
|
|
22
|
+
let mockClient;
|
|
23
|
+
beforeEach(async () => {
|
|
24
|
+
mockClient = createClientMockHelper();
|
|
25
|
+
client = mockClient.client;
|
|
26
|
+
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
28
|
+
vi.mocked(client.fetchMetadata).mockReturnValue(Promise.resolve({
|
|
29
|
+
primaryKeyApiName: "id"
|
|
30
|
+
}));
|
|
31
|
+
});
|
|
32
|
+
const employees = [{
|
|
33
|
+
$apiName: "Employee",
|
|
34
|
+
$objectType: "Employee",
|
|
35
|
+
$primaryKey: 0
|
|
36
|
+
}, {
|
|
37
|
+
$apiName: "Employee",
|
|
38
|
+
$objectType: "Employee",
|
|
39
|
+
$primaryKey: 1
|
|
40
|
+
}, {
|
|
41
|
+
$apiName: "Employee",
|
|
42
|
+
$objectType: "Employee",
|
|
43
|
+
$primaryKey: 2
|
|
44
|
+
}];
|
|
45
|
+
it("splits up work by count", async () => {
|
|
46
|
+
const loader = new BulkObjectLoader(client, 25, /*ms*/2 /*entries*/);
|
|
47
|
+
const firstRequest = mockClient.mockFetchPageOnce();
|
|
48
|
+
const secondRequest = mockClient.mockFetchPageOnce();
|
|
49
|
+
const load0 = loader.fetch("Employee", 0);
|
|
50
|
+
const load1 = loader.fetch("Employee", 1);
|
|
51
|
+
const load2 = loader.fetch("Employee", 2);
|
|
52
|
+
firstRequest.resolve({
|
|
53
|
+
data: [employees[0], employees[1]],
|
|
54
|
+
nextPageToken: undefined,
|
|
55
|
+
totalCount: "2"
|
|
56
|
+
});
|
|
57
|
+
await expect(load0).resolves.toMatchObject({
|
|
58
|
+
$primaryKey: 0
|
|
59
|
+
});
|
|
60
|
+
await expect(load1).resolves.toMatchObject({
|
|
61
|
+
$primaryKey: 1
|
|
62
|
+
});
|
|
63
|
+
const mock = vi.fn();
|
|
64
|
+
void load2.then(mock);
|
|
65
|
+
expect(mock).not.toHaveBeenCalled();
|
|
66
|
+
secondRequest.resolve({
|
|
67
|
+
data: [employees[2]],
|
|
68
|
+
nextPageToken: undefined,
|
|
69
|
+
totalCount: "1"
|
|
70
|
+
});
|
|
71
|
+
await expect(load2).resolves.toMatchObject({
|
|
72
|
+
$primaryKey: 2
|
|
73
|
+
});
|
|
74
|
+
expect(mock).toHaveBeenCalled();
|
|
75
|
+
});
|
|
76
|
+
it("splits up work by time", async () => {
|
|
77
|
+
const loader = new BulkObjectLoader(client, /*ms*/25, /*entries*/100);
|
|
78
|
+
const firstRequest = mockClient.mockFetchPageOnce();
|
|
79
|
+
const secondRequest = mockClient.mockFetchPageOnce();
|
|
80
|
+
vi.useFakeTimers();
|
|
81
|
+
const load0 = loader.fetch("Employee", 0);
|
|
82
|
+
vi.advanceTimersByTime(26);
|
|
83
|
+
const load1 = loader.fetch("Employee", 1);
|
|
84
|
+
const load2 = loader.fetch("Employee", 2);
|
|
85
|
+
firstRequest.resolve({
|
|
86
|
+
data: [employees[0]],
|
|
87
|
+
nextPageToken: undefined,
|
|
88
|
+
totalCount: "1"
|
|
89
|
+
});
|
|
90
|
+
vi.runOnlyPendingTimers();
|
|
91
|
+
await expect(load0).resolves.toMatchObject({
|
|
92
|
+
$primaryKey: 0
|
|
93
|
+
});
|
|
94
|
+
const mockThen = vi.fn();
|
|
95
|
+
void load2.then(mockThen);
|
|
96
|
+
expect(mockThen).not.toHaveBeenCalled();
|
|
97
|
+
secondRequest.resolve({
|
|
98
|
+
data: [employees[1], employees[2]],
|
|
99
|
+
nextPageToken: undefined,
|
|
100
|
+
totalCount: "2"
|
|
101
|
+
});
|
|
102
|
+
await expect(load1).resolves.toMatchObject({
|
|
103
|
+
$primaryKey: 1
|
|
104
|
+
});
|
|
105
|
+
await expect(load2).resolves.toMatchObject({
|
|
106
|
+
$primaryKey: 2
|
|
107
|
+
});
|
|
108
|
+
expect(mockThen).toHaveBeenCalled();
|
|
109
|
+
vi.useRealTimers();
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
//# sourceMappingURL=BulkObjectLoader.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BulkObjectLoader.test.js","names":["beforeEach","describe","expect","it","vi","BulkObjectLoader","createClientMockHelper","client","mockClient","mocked","fetchMetadata","mockReturnValue","Promise","resolve","primaryKeyApiName","employees","$apiName","$objectType","$primaryKey","loader","firstRequest","mockFetchPageOnce","secondRequest","load0","fetch","load1","load2","data","nextPageToken","undefined","totalCount","resolves","toMatchObject","mock","fn","then","not","toHaveBeenCalled","useFakeTimers","advanceTimersByTime","runOnlyPendingTimers","mockThen","useRealTimers"],"sources":["BulkObjectLoader.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectMetadata } from \"@osdk/api\";\nimport type { Mock } from \"vitest\";\nimport { beforeEach, describe, expect, it, vi } from \"vitest\";\nimport type { Client } from \"../../Client.js\";\nimport { BulkObjectLoader } from \"./BulkObjectLoader.js\";\nimport { createClientMockHelper, type MockClientHelper } from \"./testUtils.js\";\n\ndescribe(BulkObjectLoader, () => {\n let client: Mock<Client> & Client;\n let mockClient: MockClientHelper;\n\n beforeEach(async () => {\n mockClient = createClientMockHelper();\n client = mockClient.client;\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n vi.mocked(client.fetchMetadata).mockReturnValue(\n Promise.resolve(\n {\n primaryKeyApiName: \"id\",\n } satisfies Pick<ObjectMetadata, \"primaryKeyApiName\"> as ObjectMetadata,\n ),\n );\n });\n\n const employees = [\n {\n $apiName: \"Employee\",\n $objectType: \"Employee\",\n $primaryKey: 0,\n },\n {\n $apiName: \"Employee\",\n $objectType: \"Employee\",\n $primaryKey: 1,\n },\n {\n $apiName: \"Employee\",\n $objectType: \"Employee\",\n $primaryKey: 2,\n },\n ];\n\n it(\"splits up work by count\", async () => {\n const loader = new BulkObjectLoader(client, 25, /*ms*/ 2 /*entries*/);\n\n const firstRequest = mockClient.mockFetchPageOnce();\n const secondRequest = mockClient.mockFetchPageOnce();\n\n const load0 = loader.fetch(\"Employee\", 0);\n const load1 = loader.fetch(\"Employee\", 1);\n const load2 = loader.fetch(\"Employee\", 2);\n\n firstRequest.resolve({\n data: [employees[0], employees[1]],\n nextPageToken: undefined,\n totalCount: \"2\",\n });\n\n await expect(load0).resolves.toMatchObject({\n $primaryKey: 0,\n });\n\n await expect(load1).resolves.toMatchObject({\n $primaryKey: 1,\n });\n\n const mock = vi.fn();\n void load2.then(mock);\n expect(mock).not.toHaveBeenCalled();\n\n secondRequest.resolve({\n data: [employees[2]],\n nextPageToken: undefined,\n totalCount: \"1\",\n });\n\n await expect(load2).resolves.toMatchObject({\n $primaryKey: 2,\n });\n\n expect(mock).toHaveBeenCalled();\n });\n\n it(\"splits up work by time\", async () => {\n const loader = new BulkObjectLoader(client, /*ms*/ 25, /*entries*/ 100);\n\n const firstRequest = mockClient.mockFetchPageOnce();\n const secondRequest = mockClient.mockFetchPageOnce();\n\n vi.useFakeTimers();\n\n const load0 = loader.fetch(\"Employee\", 0);\n\n vi.advanceTimersByTime(26);\n\n const load1 = loader.fetch(\"Employee\", 1);\n const load2 = loader.fetch(\"Employee\", 2);\n\n firstRequest.resolve({\n data: [employees[0]],\n nextPageToken: undefined,\n totalCount: \"1\",\n });\n\n vi.runOnlyPendingTimers();\n\n await expect(load0).resolves.toMatchObject({\n $primaryKey: 0,\n });\n\n const mockThen = vi.fn();\n void load2.then(mockThen);\n\n expect(mockThen).not.toHaveBeenCalled();\n\n secondRequest.resolve({\n data: [\n employees[1],\n employees[2],\n ],\n nextPageToken: undefined,\n totalCount: \"2\",\n });\n\n await expect(load1).resolves.toMatchObject({\n $primaryKey: 1,\n });\n\n await expect(load2).resolves.toMatchObject({\n $primaryKey: 2,\n });\n\n expect(mockThen).toHaveBeenCalled();\n\n vi.useRealTimers();\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC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,CAAC;EACpB,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -31,7 +31,7 @@ export function DEBUG_ONLY__cacheKeyToString(x) {
|
|
|
31
31
|
*/
|
|
32
32
|
export function DEBUG_ONLY__cacheKeysToString(x) {
|
|
33
33
|
if (process.env.NODE_ENV !== "production") {
|
|
34
|
-
return
|
|
34
|
+
return "\n - " + x.map(DEBUG_ONLY__cacheKeyToString).join("\n - ");
|
|
35
35
|
} else {
|
|
36
36
|
throw new Error("not implemented");
|
|
37
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CacheKey.js","names":["DEBUG_ONLY__cacheKeyToString","x","process","env","NODE_ENV","type","otherKeys","map","xx","JSON","stringify","join","replaceAll","Error","DEBUG_ONLY__cacheKeysToString"],"sources":["CacheKey.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Query } from \"./Query.js\";\n\nexport type CacheKey<\n X extends string = string,\n T_StoreValue = unknown,\n T_Query extends Query<any, any, any> = Query<any, any, any>,\n T_KeyFactoryArgs extends any[] = any[],\n> = {\n type: X;\n otherKeys: T_KeyFactoryArgs;\n __cacheKey: {\n value: T_StoreValue;\n query: T_Query;\n args: T_KeyFactoryArgs;\n };\n};\n\n/**\n * This isn't performant and should only be used for debug logging!\n * @internal\n */\nexport function DEBUG_ONLY__cacheKeyToString(x: CacheKey) {\n if (process.env.NODE_ENV !== \"production\") {\n return `${x.type}CacheKey<${\n x.otherKeys.map(xx => JSON.stringify(xx)).join(\", \")\n }>`.replaceAll(\"\\\"\", \"'\");\n } else {\n throw new Error(\"not implemented\");\n }\n}\n/**\n * This isn't performant and should only be used for debug logging!\n * @internal\n */\nexport function DEBUG_ONLY__cacheKeysToString(x: CacheKey[]) {\n if (process.env.NODE_ENV !== \"production\") {\n return
|
|
1
|
+
{"version":3,"file":"CacheKey.js","names":["DEBUG_ONLY__cacheKeyToString","x","process","env","NODE_ENV","type","otherKeys","map","xx","JSON","stringify","join","replaceAll","Error","DEBUG_ONLY__cacheKeysToString"],"sources":["CacheKey.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Query } from \"./Query.js\";\n\nexport type CacheKey<\n X extends string = string,\n T_StoreValue = unknown,\n T_Query extends Query<any, any, any> = Query<any, any, any>,\n T_KeyFactoryArgs extends any[] = any[],\n> = {\n type: X;\n otherKeys: T_KeyFactoryArgs;\n __cacheKey: {\n value: T_StoreValue;\n query: T_Query;\n args: T_KeyFactoryArgs;\n };\n};\n\n/**\n * This isn't performant and should only be used for debug logging!\n * @internal\n */\nexport function DEBUG_ONLY__cacheKeyToString(x: CacheKey) {\n if (process.env.NODE_ENV !== \"production\") {\n return `${x.type}CacheKey<${\n x.otherKeys.map(xx => JSON.stringify(xx)).join(\", \")\n }>`.replaceAll(\"\\\"\", \"'\");\n } else {\n throw new Error(\"not implemented\");\n }\n}\n/**\n * This isn't performant and should only be used for debug logging!\n * @internal\n */\nexport function DEBUG_ONLY__cacheKeysToString(x: CacheKey[]) {\n if (process.env.NODE_ENV !== \"production\") {\n return \"\\n - \" + x.map(DEBUG_ONLY__cacheKeyToString).join(\"\\n - \");\n } else {\n throw new Error(\"not implemented\");\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA;AACA;AACA;AACA;AACA,OAAO,SAASA,4BAA4BA,CAACC,CAAW,EAAE;EACxD,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC,OAAO,GAAGH,CAAC,CAACI,IAAI,YACdJ,CAAC,CAACK,SAAS,CAACC,GAAG,CAACC,EAAE,IAAIC,IAAI,CAACC,SAAS,CAACF,EAAE,CAAC,CAAC,CAACG,IAAI,CAAC,IAAI,CAAC,GACnD,CAACC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC;EAC3B,CAAC,MAAM;IACL,MAAM,IAAIC,KAAK,CAAC,iBAAiB,CAAC;EACpC;AACF;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,6BAA6BA,CAACb,CAAa,EAAE;EAC3D,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC,OAAO,QAAQ,GAAGH,CAAC,CAACM,GAAG,CAACP,4BAA4B,CAAC,CAACW,IAAI,CAAC,QAAQ,CAAC;EACtE,CAAC,MAAM;IACL,MAAM,IAAIE,KAAK,CAAC,iBAAiB,CAAC;EACpC;AACF","ignoreList":[]}
|
|
@@ -37,12 +37,12 @@ export class CacheKeys {
|
|
|
37
37
|
}
|
|
38
38
|
return this.#cacheKeys.lookupArray(["object", apiName, pk]);
|
|
39
39
|
});
|
|
40
|
-
this.#registerCacheKeyFactory("list", (apiName, where, orderBy) => {
|
|
40
|
+
this.#registerCacheKeyFactory("list", (type, apiName, where, orderBy) => {
|
|
41
41
|
if (process.env.NODE_ENV !== "production" && DEBUG_CACHE_KEYS) {
|
|
42
42
|
// eslint-disable-next-line no-console
|
|
43
43
|
console.debug(`CacheKeys.get([list, ${apiName}, ${JSON.stringify(where)}, ${JSON.stringify(orderBy)}]) -- already exists? `, this.#cacheKeys.peekArray(["list", apiName, whereCanonicalizer.canonicalize(where), orderByCanonicalizer.canonicalize(orderBy)]) != null);
|
|
44
44
|
}
|
|
45
|
-
return this.#cacheKeys.lookupArray(["list", apiName, whereCanonicalizer.canonicalize(where), orderByCanonicalizer.canonicalize(orderBy)]);
|
|
45
|
+
return this.#cacheKeys.lookupArray(["list", type, apiName, whereCanonicalizer.canonicalize(where), orderByCanonicalizer.canonicalize(orderBy)]);
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
#registerCacheKeyFactory(type, factory) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CacheKeys.js","names":["Trie","invariant","DEBUG_CACHE_KEYS","CacheKeys","cacheKeys","keys","ret","type","otherKeys","slice","onCreate","cacheKeyFactories","Map","constructor","whereCanonicalizer","orderByCanonicalizer","registerCacheKeyFactory","apiName","pk","process","env","NODE_ENV","console","debug","peekArray","lookupArray","where","orderBy","JSON","stringify","canonicalize","#registerCacheKeyFactory","factory","set","get","args","remove","cacheKey"],"sources":["CacheKeys.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Trie } from \"@wry/trie\";\nimport invariant from \"tiny-invariant\";\nimport { DEBUG_CACHE_KEYS } from \"../DebugFlags.js\";\nimport type { CacheKey } from \"./CacheKey.js\";\nimport type { ListCacheKey } from \"./ListQuery.js\";\nimport type { ObjectCacheKey } from \"./ObjectQuery.js\";\nimport type { OrderByCanonicalizer } from \"./
|
|
1
|
+
{"version":3,"file":"CacheKeys.js","names":["Trie","invariant","DEBUG_CACHE_KEYS","CacheKeys","cacheKeys","keys","ret","type","otherKeys","slice","onCreate","cacheKeyFactories","Map","constructor","whereCanonicalizer","orderByCanonicalizer","registerCacheKeyFactory","apiName","pk","process","env","NODE_ENV","console","debug","peekArray","lookupArray","where","orderBy","JSON","stringify","canonicalize","#registerCacheKeyFactory","factory","set","get","args","remove","cacheKey"],"sources":["CacheKeys.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Trie } from \"@wry/trie\";\nimport invariant from \"tiny-invariant\";\nimport { DEBUG_CACHE_KEYS } from \"../DebugFlags.js\";\nimport type { CacheKey } from \"./CacheKey.js\";\nimport type { ListCacheKey } from \"./ListQuery.js\";\nimport type { ObjectCacheKey } from \"./ObjectQuery.js\";\nimport type { OrderByCanonicalizer } from \"./OrderByCanonicalizer.js\";\nimport type { WhereClauseCanonicalizer } from \"./WhereClauseCanonicalizer.js\";\n\ntype CacheKeyArgs<K extends CacheKey> = [K[\"type\"], ...K[\"otherKeys\"]];\n\nexport class CacheKeys {\n #cacheKeys = new Trie<CacheKey<string, any, any>>(false, (keys) => {\n const ret = {\n type: keys[0],\n otherKeys: keys.slice(1),\n } as unknown as CacheKey<\n string,\n any,\n any\n >;\n this.#onCreate(ret);\n return ret;\n });\n #cacheKeyFactories = new Map<string, (...args: any[]) => CacheKey>();\n #onCreate: (cacheKey: CacheKey) => void;\n\n constructor(\n whereCanonicalizer: WhereClauseCanonicalizer,\n orderByCanonicalizer: OrderByCanonicalizer,\n onCreate: (cacheKey: CacheKey) => void,\n ) {\n this.#onCreate = onCreate;\n this.#registerCacheKeyFactory<ObjectCacheKey>(\n \"object\",\n (apiName, pk) => {\n if (process.env.NODE_ENV !== \"production\" && DEBUG_CACHE_KEYS) {\n // eslint-disable-next-line no-console\n console.debug(\n `CacheKeys.get([object, ${apiName}, ${pk}]) -- already exists? `,\n this.#cacheKeys.peekArray([\n \"object\",\n apiName,\n pk,\n ]) != null,\n );\n }\n return this.#cacheKeys.lookupArray([\n \"object\",\n apiName,\n pk,\n ]) as ObjectCacheKey;\n },\n );\n this.#registerCacheKeyFactory<ListCacheKey>(\n \"list\",\n (type, apiName, where, orderBy) => {\n if (process.env.NODE_ENV !== \"production\" && DEBUG_CACHE_KEYS) {\n // eslint-disable-next-line no-console\n console.debug(\n `CacheKeys.get([list, ${apiName}, ${JSON.stringify(where)}, ${\n JSON.stringify(orderBy)\n }]) -- already exists? `,\n this.#cacheKeys.peekArray([\n \"list\",\n apiName,\n whereCanonicalizer.canonicalize(where),\n orderByCanonicalizer.canonicalize(orderBy),\n ]) != null,\n );\n }\n return this.#cacheKeys.lookupArray<\n CacheKeyArgs<ListCacheKey>\n >([\n \"list\",\n type,\n apiName,\n whereCanonicalizer.canonicalize(where),\n orderByCanonicalizer.canonicalize(orderBy),\n ]) as ListCacheKey;\n },\n );\n }\n\n #registerCacheKeyFactory<K extends CacheKey>(\n type: K[\"type\"],\n factory: (...args: K[\"__cacheKey\"][\"args\"]) => K,\n ): void {\n this.#cacheKeyFactories.set(type, factory);\n }\n\n get<K extends CacheKey<string, any, any>>(\n type: K[\"type\"],\n ...args: K[\"__cacheKey\"][\"args\"]\n ): K {\n const factory = this.#cacheKeyFactories.get(type);\n invariant(factory, `no cache key factory for type \"${type}\"`);\n return factory(...args) as K;\n }\n\n remove<K extends CacheKey<string, any, any>>(\n cacheKey: K,\n ): void {\n this.#cacheKeys.remove(cacheKey.type, ...cac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AACC,QAAQ,CAAC9B,IAAI,EAAE,GAAG8B,QAAQ,CAAC7B,SAAS,CAAC;EAC9D;AACF","ignoreList":[]}
|
|
@@ -16,21 +16,32 @@
|
|
|
16
16
|
|
|
17
17
|
import { MultiMap } from "mnemonist";
|
|
18
18
|
import { DEBUG_ONLY__cacheKeyToString } from "./CacheKey.js";
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
export class Changes {
|
|
20
|
+
modifiedObjects = new MultiMap();
|
|
21
|
+
addedObjects = new MultiMap();
|
|
22
|
+
added = new Set();
|
|
23
|
+
modified = new Set();
|
|
24
|
+
registerObject = (cacheKey, data, isNew) => {
|
|
25
|
+
this[isNew ? "addedObjects" : "modifiedObjects"].set(data.$apiName, data);
|
|
26
|
+
this[isNew ? "added" : "modified"].add(cacheKey);
|
|
27
|
+
};
|
|
28
|
+
registerList = key => {
|
|
29
|
+
this.modified.add(key);
|
|
25
30
|
};
|
|
31
|
+
isEmpty() {
|
|
32
|
+
return this.modifiedObjects.size === 0 && this.addedObjects.size === 0 && this.added.size === 0 && this.modified.size === 0;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function createChangedObjects() {
|
|
36
|
+
return new Changes();
|
|
26
37
|
}
|
|
27
38
|
export function DEBUG_ONLY__changesToString(changes) {
|
|
28
39
|
if (process.env.NODE_ENV !== "production") {
|
|
29
40
|
return JSON.stringify({
|
|
30
41
|
modifiedObjects: multimapHelper(changes.modifiedObjects),
|
|
31
42
|
addedObjects: multimapHelper(changes.addedObjects),
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
added: listHelper(changes.added),
|
|
44
|
+
modified: listHelper(changes.modified)
|
|
34
45
|
}, null, 2);
|
|
35
46
|
} else {
|
|
36
47
|
throw new Error("not implemented");
|
|
@@ -44,4 +55,4 @@ function multimapHelper(multimap) {
|
|
|
44
55
|
return [type, objects.map(o => o.$primaryKey)];
|
|
45
56
|
}));
|
|
46
57
|
}
|
|
47
|
-
//# sourceMappingURL=
|
|
58
|
+
//# sourceMappingURL=Changes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Changes.js","names":["MultiMap","DEBUG_ONLY__cacheKeyToString","Changes","modifiedObjects","addedObjects","added","Set","modified","registerObject","cacheKey","data","isNew","set","$apiName","add","registerList","key","isEmpty","size","createChangedObjects","DEBUG_ONLY__changesToString","changes","process","env","NODE_ENV","JSON","stringify","multimapHelper","listHelper","Error","Array","from","map","multimap","Object","fromEntries","associations","type","objects","o","$primaryKey"],"sources":["Changes.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { MultiMap } from \"mnemonist\";\nimport type { ObjectHolder } from \"../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { CacheKey } from \"./CacheKey.js\";\nimport { DEBUG_ONLY__cacheKeyToString } from \"./CacheKey.js\";\nimport type { ListCacheKey } from \"./ListQuery.js\";\nimport type { ObjectCacheKey } from \"./ObjectQuery.js\";\n\nexport class Changes {\n modifiedObjects: MultiMap<string, ObjectHolder> = new MultiMap();\n addedObjects: MultiMap<string, ObjectHolder> = new MultiMap();\n\n added: Set<ListCacheKey | ObjectCacheKey> = new Set();\n modified: Set<ListCacheKey | ObjectCacheKey> = new Set();\n\n registerObject = (\n cacheKey: ObjectCacheKey,\n data: ObjectHolder,\n isNew: boolean,\n ): void => {\n this[isNew ? \"addedObjects\" : \"modifiedObjects\"].set(data.$apiName, data);\n this[isNew ? \"added\" : \"modified\"].add(cacheKey);\n };\n\n registerList = (key: ListCacheKey): void => {\n this.modified.add(key);\n };\n\n isEmpty(): boolean {\n return (\n this.modifiedObjects.size === 0\n && this.addedObjects.size === 0\n && this.added.size === 0\n && this.modified.size === 0\n );\n }\n}\n\nexport function createChangedObjects(): Changes {\n return new Changes();\n}\n\nexport function DEBUG_ONLY__changesToString(changes: Changes): string {\n if (process.env.NODE_ENV !== \"production\") {\n return JSON.stringify(\n {\n modifiedObjects: multimapHelper(changes.modifiedObjects),\n addedObjects: multimapHelper(changes.addedObjects),\n added: listHelper(changes.added),\n modified: listHelper(changes.modified),\n },\n null,\n 2,\n );\n } else {\n throw new Error(\"not implemented\");\n }\n}\n\nfunction listHelper(set: Set<CacheKey>) {\n return Array.from(set).map(DEBUG_ONLY__cacheKeyToString);\n}\n\nfunction multimapHelper(\n multimap: MultiMap<string, ObjectHolder>,\n) {\n return Object.fromEntries(\n Array.from(multimap.associations()).map(\n ([type, objects]) => {\n return [type, objects.map(o => o.$primaryKey)];\n },\n ),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,WAAW;AAGpC,SAASC,4BAA4B,QAAQ,eAAe;AAI5D,OAAO,MAAMC,OAAO,CAAC;EACnBC,eAAe,GAAmC,IAAIH,QAAQ,CAAC,CAAC;EAChEI,YAAY,GAAmC,IAAIJ,QAAQ,CAAC,CAAC;EAE7DK,KAAK,GAAuC,IAAIC,GAAG,CAAC,CAAC;EACrDC,QAAQ,GAAuC,IAAID,GAAG,CAAC,CAAC;EAExDE,cAAc,GAAGA,CACfC,QAAwB,EACxBC,IAAkB,EAClBC,KAAc,KACL;IACT,IAAI,CAACA,KAAK,GAAG,cAAc,GAAG,iBAAiB,CAAC,CAACC,GAAG,CAACF,IAAI,CAACG,QAAQ,EAAEH,IAAI,CAAC;IACzE,IAAI,CAACC,KAAK,GAAG,OAA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G,YAAY,CAAC,CAAC,CAAC,CAACJ,GAAG,CACrC,CAAC,CAACK,IAAI,EAAEC,OAAO,CAAC,KAAK;IACnB,OAAO,CAACD,IAAI,EAAEC,OAAO,CAACN,GAAG,CAACO,CAAC,IAAIA,CAAC,CAACC,WAAW,CAAC,CAAC;EAChD,CACF,CACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layer.js","names":["WeakMapWithEntries","Layer","parent","cache","layerId","constructor","parentLayer","addLayer","removeLayer","entries","get","cacheKey","set","value","Entry","lastUpdated","status"],"sources":["Layer.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { CacheKey } from \"./CacheKey.js\";\nimport { WeakMapWithEntries } from \"./WeakMapWithEntries.js\";\n\n/*\n Image some layers\n\n [\n { cache: { obj1: { a: 1 } }, layerId: undefined },\n { cache: { obj1: { a: 1, b: 2 } }, layerId: \"layer1\" },\n { cache: { obj1: { a: undefined, b: 2 } }, layerId: \"layer2\" },\n { cache: { obj1: { a: 1, b: 2 } }, layerId: \"layer3\" },\n ]\n*/\n\nexport class Layer {\n #parent: Layer | undefined;\n #cache = new WeakMapWithEntries<CacheKey<string, any, any>, Entry<any>>();\n #layerId: unknown;\n\n constructor(parent: Layer | undefined, layerId: unknown) {\n this.#parent = parent;\n this.#layerId = layerId;\n }\n\n get parentLayer(): Layer | undefined {\n return this.#parent;\n }\n\n get layerId(): unknown {\n return this.#layerId;\n }\n\n addLayer(layerId: unknown): Layer {\n return new Layer(this, layerId);\n }\n\n removeLayer(layerId: unknown): Layer {\n if (layerId == null || this.#parent == null) {\n // we are the root, so we can't remove anything\n return this;\n }\n\n if (this.#layerId !== layerId) {\n this.#parent = this.#parent.removeLayer(layerId);\n return this;\n }\n\n return this.#parent.removeLayer(layerId);\n }\n\n entries(): IterableIterator<[CacheKey<string, any, any>, Entry<any>]> {\n return this.#cache.entries();\n }\n\n public get<K extends CacheKey<string, unknown, any>>(\n cacheKey: K,\n ): Entry<K> | undefined {\n return this.#cache.get(cacheKey) as Entry<K> | undefined\n ?? this.#parent?.get(cacheKey) as Entry<K> | undefined;\n }\n\n public set<K extends CacheKey<string, unknown, any>>(\n cacheKey: K,\n value: Entry<K>,\n ): void {\n this.#cache.set(cacheKey, value);\n }\n}\n\nexport class Entry<K extends CacheKey<any, any, any>> {\n readonly cacheKey: K;\n value: K[\"__cacheKey\"][\"value\"] | undefined;\n lastUpdated: number;\n status: \"init\" | \"loading\" | \"loaded\" | \"error\";\n\n constructor(\n cacheKey: K,\n value: K[\"__cacheKey\"][\"value\"],\n lastUpdated: number,\n status: \"init\" | \"loading\" | \"loaded\" | \"error\" = \"init\",\n ) {\n this.cacheKey = cacheKey;\n this.value = value;\n this.lastUpdated = lastUpdated;\n this.status = status;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,kBAAkB,QAAQ,yBAAyB;;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,KAAK,CAAC;EACjB,CAACC,MAAM;EACP,CAACC,KAAK,GAAG,IAAIH,kBAAkB,CAAyC,CAAC;EACzE,CAACI,OAAO;EAERC,WAAWA,CAACH,MAAyB,EAAEE,OAAgB,EAAE;IACvD,IAAI,CAAC,CAACF,MAAM,GAAGA,MAAM;IACrB,IAAI,CAAC,CAACE,OAAO,GAAGA,OAAO;EACzB;EAEA,IAAIE,WAAWA,CAAA,EAAsB;IACnC,OAAO,IAAI,CAAC,CAACJ,MAAM;EACrB;EAEA,IAAIE,OAAOA,CAAA,EAAY;IACrB,OAAO,IAAI,CAAC,CAACA,OAAO;EACtB;EAEAG,QAAQA,CAACH,OAAgB,EAAS;IAChC,OAAO,IAAIH,KAAK,CAAC,IAAI,EAAEG,OAAO,CAAC;EACjC;EAEAI,WAAWA,CAACJ,OAAgB,EAAS;IACnC,IAAIA,OAAO,IAAI,IAAI,IAAI,IAAI,CAAC,CAACF,MAAM,IAAI,IAAI,EAAE;MAC3C;MACA,OAAO,IAAI;IACb;IAEA,IAAI,IAAI,CAAC,CAACE,OAAO,KAAKA,OAAO,EAAE;MAC7B,IAAI,CAAC,CAACF,MAAM,GAAG,IAAI,CAAC,CAACA,MAAM,CAACM,WAAW,CAACJ,OAAO,CAAC;MAChD,OAAO,IAAI;IACb;IAEA,OAAO,IAAI,CAAC,CAACF,MAAM,CAACM,WAAW,CAACJ,OAAO,CAAC;EAC1C;EAEAK,OAAOA,CAAA,EAA+D;IACpE,OAAO,IAAI,CAAC,CAACN,KAAK,CAACM,OAAO,CAAC,CAAC;EAC9B;EAEOC,GAAGA,CACRC,QAAW,EACW;IACtB,OAAO,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"Layer.js","names":["WeakMapWithEntries","Layer","parent","cache","layerId","constructor","parentLayer","addLayer","removeLayer","entries","keys","get","cacheKey","set","value","Entry","lastUpdated","status"],"sources":["Layer.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { CacheKey } from \"./CacheKey.js\";\nimport { WeakMapWithEntries } from \"./WeakMapWithEntries.js\";\n\n/*\n Image some layers\n\n [\n { cache: { obj1: { a: 1 } }, layerId: undefined },\n { cache: { obj1: { a: 1, b: 2 } }, layerId: \"layer1\" },\n { cache: { obj1: { a: undefined, b: 2 } }, layerId: \"layer2\" },\n { cache: { obj1: { a: 1, b: 2 } }, layerId: \"layer3\" },\n ]\n*/\n\nexport class Layer {\n #parent: Layer | undefined;\n #cache = new WeakMapWithEntries<CacheKey<string, any, any>, Entry<any>>();\n #layerId: unknown;\n\n constructor(parent: Layer | undefined, layerId: unknown) {\n this.#parent = parent;\n this.#layerId = layerId;\n }\n\n get parentLayer(): Layer | undefined {\n return this.#parent;\n }\n\n get layerId(): unknown {\n return this.#layerId;\n }\n\n addLayer(layerId: unknown): Layer {\n return new Layer(this, layerId);\n }\n\n removeLayer(layerId: unknown): Layer {\n if (layerId == null || this.#parent == null) {\n // we are the root, so we can't remove anything\n return this;\n }\n\n if (this.#layerId !== layerId) {\n this.#parent = this.#parent.removeLayer(layerId);\n return this;\n }\n\n return this.#parent.removeLayer(layerId);\n }\n\n entries(): IterableIterator<[CacheKey<string, any, any>, Entry<any>]> {\n return this.#cache.entries();\n }\n\n keys(): IterableIterator<CacheKey<string, any, any>> {\n return this.#cache.keys();\n }\n\n public get<K extends CacheKey<string, unknown, any>>(\n cacheKey: K,\n ): Entry<K> | undefined {\n return this.#cache.get(cacheKey) as Entry<K> | undefined\n ?? this.#parent?.get(cacheKey) as Entry<K> | undefined;\n }\n\n public set<K extends CacheKey<string, unknown, any>>(\n cacheKey: K,\n value: Entry<K>,\n ): void {\n this.#cache.set(cacheKey, value);\n }\n}\n\nexport class Entry<K extends CacheKey<any, any, any>> {\n readonly cacheKey: K;\n value: K[\"__cacheKey\"][\"value\"] | undefined;\n lastUpdated: number;\n status: \"init\" | \"loading\" | \"loaded\" | \"error\";\n\n constructor(\n cacheKey: K,\n value: K[\"__cacheKey\"][\"value\"],\n lastUpdated: number,\n status: \"init\" | \"loading\" | \"loaded\" | \"error\" = \"init\",\n ) {\n this.cacheKey = cacheKey;\n this.value = value;\n this.lastUpdated = lastUpdated;\n this.status = status;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,kBAAkB,QAAQ,yBAAyB;;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,KAAK,CAAC;EACjB,CAACC,MAAM;EACP,CAACC,KAAK,GAAG,IAAIH,kBAAkB,CAAyC,CAAC;EACzE,CAACI,OAAO;EAERC,WAAWA,CAACH,MAAyB,EAAEE,OAAgB,EAAE;IACvD,IAAI,CAAC,CAACF,MAAM,GAAGA,MAAM;IACrB,IAAI,CAAC,CAACE,OAAO,GAAGA,OAAO;EACzB;EAEA,IAAIE,WAAWA,CAAA,EAAsB;IACnC,OAAO,IAAI,CAAC,CAACJ,MAAM;EACrB;EAEA,IAAIE,OAAOA,CAAA,EAAY;IACrB,OAAO,IAAI,CAAC,CAACA,OAAO;EACtB;EAEAG,QAAQA,CAACH,OAAgB,EAAS;IAChC,OAAO,IAAIH,KAAK,CAAC,IAAI,EAAEG,OAAO,CAAC;EACjC;EAEAI,WAAWA,CAACJ,OAAgB,EAAS;IACnC,IAAIA,OAAO,IAAI,IAAI,IAAI,IAAI,CAAC,CAACF,MAAM,IAAI,IAAI,EAAE;MAC3C;MACA,OAAO,IAAI;IACb;IAEA,IAAI,IAAI,CAAC,CAACE,OAAO,KAAKA,OAAO,EAAE;MAC7B,IAAI,CAAC,CAACF,MAAM,GAAG,IAAI,CAAC,CAACA,MAAM,CAACM,WAAW,CAACJ,OAAO,CAAC;MAChD,OAAO,IAAI;IACb;IAEA,OAAO,IAAI,CAAC,CAACF,MAAM,CAACM,WAAW,CAACJ,OAAO,CAAC;EAC1C;EAEAK,OAAOA,CAAA,EA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