@osdk/client 2.4.2 → 2.5.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +106 -93
- package/build/browser/Client.js +1 -1
- package/build/browser/Client.js.map +1 -1
- package/build/browser/MinimalClientContext.js.map +1 -1
- package/build/browser/actions/applyAction.js +4 -0
- package/build/browser/actions/applyAction.js.map +1 -1
- package/build/browser/createClient.js +6 -2
- package/build/browser/createClient.js.map +1 -1
- package/build/browser/createMinimalClient.js +2 -1
- package/build/browser/createMinimalClient.js.map +1 -1
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +17 -0
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
- package/build/browser/fetchMetadata.test.js +11 -0
- package/build/browser/fetchMetadata.test.js.map +1 -1
- package/build/browser/index.js +3 -1
- package/build/browser/index.js.map +1 -1
- package/build/browser/intellisense.test.helpers/orderBySuggestionIsRight.js +8 -1
- package/build/browser/intellisense.test.helpers/orderBySuggestionIsRight.js.map +1 -1
- package/build/browser/intellisense.test.js +14 -4
- package/build/browser/intellisense.test.js.map +1 -1
- package/build/browser/object/Cache.js +1 -1
- package/build/browser/object/Cache.js.map +1 -1
- package/build/browser/object/Cache.test.js +1 -1
- package/build/browser/object/Cache.test.js.map +1 -1
- package/build/browser/object/SimpleCache.js +1 -1
- package/build/browser/object/SimpleCache.js.map +1 -1
- package/build/browser/object/aggregate.js +2 -0
- package/build/browser/object/aggregate.js.map +1 -1
- package/build/browser/object/aggregate.test.js +30 -0
- package/build/browser/object/aggregate.test.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/OsdkCustomInspectPrototype.js +1 -0
- package/build/browser/object/convertWireToOsdkObjects/OsdkCustomInspectPrototype.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +6 -0
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/getDollarLink.js +20 -1
- package/build/browser/object/convertWireToOsdkObjects/getDollarLink.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.js +4 -0
- package/build/browser/object/convertWireToOsdkObjects.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.test.js +14 -0
- package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/browser/object/fetchPage.js +96 -21
- package/build/browser/object/fetchPage.js.map +1 -1
- package/build/browser/object/fetchPage.test.js +35 -1
- package/build/browser/object/fetchPage.test.js.map +1 -1
- package/build/browser/object/geotimeseriesreference.test.js +0 -2
- package/build/browser/object/geotimeseriesreference.test.js.map +1 -1
- package/build/browser/object/mediaUpload.js +3 -0
- package/build/browser/object/mediaUpload.js.map +1 -1
- package/build/browser/objectSet/ObjectSet.test.js +6 -0
- package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js +31 -9
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js +69 -4
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/browser/objectSet/createObjectSet.js +3 -1
- package/build/browser/objectSet/createObjectSet.js.map +1 -1
- package/build/browser/observable/LinkPayload.js +2 -0
- package/build/browser/observable/LinkPayload.js.map +1 -0
- package/build/browser/observable/ObjectPayload.js.map +1 -1
- package/build/browser/observable/ObservableClient/ObserveLink.js +17 -0
- package/build/browser/observable/ObservableClient/ObserveLink.js.map +1 -0
- package/build/browser/observable/ObservableClient/common.js +2 -0
- package/build/browser/observable/ObservableClient/common.js.map +1 -0
- package/build/browser/observable/ObservableClient.js +20 -0
- package/build/browser/observable/ObservableClient.js.map +1 -1
- package/build/browser/observable/Unsubscribable.js +2 -0
- package/build/browser/observable/Unsubscribable.js.map +1 -0
- package/build/browser/observable/internal/AbstractHelper.js +54 -0
- package/build/browser/observable/internal/AbstractHelper.js.map +1 -0
- package/build/browser/observable/internal/BatchContext.js +2 -0
- package/build/browser/observable/internal/BatchContext.js.map +1 -0
- package/build/browser/observable/internal/BulkObjectLoader.js +3 -3
- package/build/browser/observable/internal/BulkObjectLoader.js.map +1 -1
- package/build/browser/observable/internal/CacheKeys.js +65 -25
- package/build/browser/observable/internal/CacheKeys.js.map +1 -1
- package/build/browser/observable/internal/Changes.js +6 -0
- package/build/browser/observable/internal/Changes.js.map +1 -1
- package/build/browser/observable/internal/KnownCacheKey.js +2 -0
- package/build/browser/observable/internal/KnownCacheKey.js.map +1 -0
- package/build/browser/observable/internal/Layer.js +0 -8
- package/build/browser/observable/internal/Layer.js.map +1 -1
- package/build/browser/observable/internal/Layers.js +151 -0
- package/build/browser/observable/internal/Layers.js.map +1 -0
- package/build/browser/observable/internal/ObservableClientImpl.js +54 -3
- package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/browser/observable/internal/OrderByCanonicalizer.js +1 -37
- package/build/browser/observable/internal/OrderByCanonicalizer.js.map +1 -1
- package/build/browser/observable/internal/Queries.js +40 -0
- package/build/browser/observable/internal/Queries.js.map +1 -0
- package/build/browser/observable/internal/Query.js +45 -4
- package/build/browser/observable/internal/Query.js.map +1 -1
- package/build/browser/observable/internal/QuerySubscription.js +48 -0
- package/build/browser/observable/internal/QuerySubscription.js.map +1 -0
- package/build/browser/observable/internal/Store.invalidation.test.js +646 -0
- package/build/browser/observable/internal/Store.invalidation.test.js.map +1 -0
- package/build/browser/observable/internal/Store.js +87 -308
- package/build/browser/observable/internal/Store.js.map +1 -1
- package/build/browser/observable/internal/Store.test.js +330 -73
- package/build/browser/observable/internal/Store.test.js.map +1 -1
- package/build/browser/observable/internal/SubjectPayload.js +2 -0
- package/build/browser/observable/internal/SubjectPayload.js.map +1 -0
- package/build/browser/observable/internal/Subjects.js +55 -0
- package/build/browser/observable/internal/Subjects.js.map +1 -0
- package/build/browser/observable/internal/UnsubscribableWrapper.js +30 -0
- package/build/browser/observable/internal/UnsubscribableWrapper.js.map +1 -0
- package/build/browser/observable/internal/WeakRefTrie.js +61 -0
- package/build/browser/observable/internal/WeakRefTrie.js.map +1 -0
- package/build/browser/observable/internal/{ActionApplication.js → actions/ActionApplication.js} +2 -2
- package/build/browser/observable/internal/actions/ActionApplication.js.map +1 -0
- package/build/{esm/observable/internal → browser/observable/internal/actions}/OptimisticJob.js +15 -6
- package/build/browser/observable/internal/actions/OptimisticJob.js.map +1 -0
- package/build/browser/observable/internal/base-list/BaseCollectionQuery.js +2 -0
- package/build/browser/observable/internal/base-list/BaseCollectionQuery.js.map +1 -0
- package/build/browser/observable/internal/base-list/BaseListQuery.js +411 -0
- package/build/browser/observable/internal/base-list/BaseListQuery.js.map +1 -0
- package/build/browser/observable/internal/base-list/createCollectionConnectable.js +50 -0
- package/build/browser/observable/internal/base-list/createCollectionConnectable.js.map +1 -0
- package/build/browser/observable/internal/base-list/createCollectionConnectable.test.js +597 -0
- package/build/browser/observable/internal/base-list/createCollectionConnectable.test.js.map +1 -0
- package/build/browser/observable/internal/base-list/removeDuplicates.js +36 -0
- package/build/browser/observable/internal/base-list/removeDuplicates.js.map +1 -0
- package/build/browser/observable/internal/createInitEntry.js +25 -0
- package/build/browser/observable/internal/createInitEntry.js.map +1 -0
- package/build/browser/observable/internal/getObjectTypesThatInvalidate.js +216 -0
- package/build/browser/observable/internal/getObjectTypesThatInvalidate.js.map +1 -0
- package/build/browser/observable/internal/getObjectTypesThatInvalidate.test.js +382 -0
- package/build/browser/observable/internal/getObjectTypesThatInvalidate.test.js.map +1 -0
- package/build/browser/observable/internal/isObjectInstance.js +23 -0
- package/build/browser/observable/internal/isObjectInstance.js.map +1 -0
- package/build/browser/observable/internal/links/LinksHelper.js +37 -0
- package/build/browser/observable/internal/links/LinksHelper.js.map +1 -0
- package/build/browser/observable/internal/links/SpecificLinkCacheKey.js +2 -0
- package/build/browser/observable/internal/links/SpecificLinkCacheKey.js.map +1 -0
- package/build/browser/observable/internal/links/SpecificLinkQuery.js +185 -0
- package/build/browser/observable/internal/links/SpecificLinkQuery.js.map +1 -0
- package/build/browser/observable/internal/list/InterfaceListQuery.js +83 -0
- package/build/browser/observable/internal/list/InterfaceListQuery.js.map +1 -0
- package/build/browser/observable/internal/list/ListCacheKey.js +2 -0
- package/build/browser/observable/internal/list/ListCacheKey.js.map +1 -0
- package/build/browser/observable/internal/list/ListQuery.js +372 -0
- package/build/browser/observable/internal/list/ListQuery.js.map +1 -0
- package/build/browser/observable/internal/list/ListQueryOptions.js +2 -0
- package/build/browser/observable/internal/list/ListQueryOptions.js.map +1 -0
- package/build/browser/observable/internal/list/ListsHelper.js +51 -0
- package/build/browser/observable/internal/list/ListsHelper.js.map +1 -0
- package/build/browser/observable/internal/list/ObjectListQuery.js +48 -0
- package/build/browser/observable/internal/list/ObjectListQuery.js.map +1 -0
- package/build/browser/observable/internal/object/ObjectCacheKey.js +2 -0
- package/build/browser/observable/internal/object/ObjectCacheKey.js.map +1 -0
- package/build/browser/observable/internal/{ObjectQuery.js → object/ObjectQuery.js} +27 -18
- package/build/browser/observable/internal/object/ObjectQuery.js.map +1 -0
- package/build/browser/observable/internal/object/ObjectsHelper.js +48 -0
- package/build/browser/observable/internal/object/ObjectsHelper.js.map +1 -0
- package/build/browser/observable/internal/sorting/SortingStrategy.js +78 -0
- package/build/browser/observable/internal/sorting/SortingStrategy.js.map +1 -0
- package/build/browser/observable/internal/testUtils/invalidateList.js +23 -0
- package/build/browser/observable/internal/testUtils/invalidateList.js.map +1 -0
- package/build/browser/observable/internal/testUtils/observeLink/expectStandardObserveLink.js +69 -0
- package/build/browser/observable/internal/testUtils/observeLink/expectStandardObserveLink.js.map +1 -0
- package/build/browser/observable/internal/testUtils/observeObject/expectStandardObserveObject.js +56 -0
- package/build/browser/observable/internal/testUtils/observeObject/expectStandardObserveObject.js.map +1 -0
- package/build/browser/observable/internal/testUtils.js +72 -10
- package/build/browser/observable/internal/testUtils.js.map +1 -1
- package/build/browser/ontology/loadActionMetadata.js +3 -1
- package/build/browser/ontology/loadActionMetadata.js.map +1 -1
- package/build/browser/ontology/loadFullObjectMetadata.js +2 -1
- package/build/browser/ontology/loadFullObjectMetadata.js.map +1 -1
- package/build/browser/ontology/loadInterfaceMetadata.js +2 -1
- package/build/browser/ontology/loadInterfaceMetadata.js.map +1 -1
- package/build/browser/public/unstable-do-not-use.js.map +1 -1
- package/build/browser/util/UserAgent.js +2 -2
- package/build/browser/util/UserAgent.js.map +1 -1
- package/build/browser/util/exponentialBackoff.js +51 -0
- package/build/browser/util/exponentialBackoff.js.map +1 -0
- package/build/browser/util/exponentialBackoff.test.js +81 -0
- package/build/browser/util/exponentialBackoff.test.js.map +1 -0
- package/build/browser/util/extractObjectOrInterfaceType.js +9 -1
- package/build/browser/util/extractObjectOrInterfaceType.js.map +1 -1
- package/build/browser/util/extractObjectOrInterfaceType.test.js +2 -2
- package/build/browser/util/extractObjectOrInterfaceType.test.js.map +1 -1
- package/build/browser/util/streamutils.js +1 -1
- package/build/browser/util/streamutils.js.map +1 -1
- package/build/browser/util/toDataValue.js +15 -1
- package/build/browser/util/toDataValue.js.map +1 -1
- package/build/browser/util/toDataValue.test.js +42 -2
- package/build/browser/util/toDataValue.test.js.map +1 -1
- package/build/cjs/{chunk-633AI7EA.cjs → chunk-GVGP7T5P.cjs} +407 -257
- package/build/cjs/chunk-GVGP7T5P.cjs.map +1 -0
- package/build/cjs/{chunk-26WFEZQO.cjs → chunk-YADG7KA6.cjs} +136 -84
- package/build/cjs/chunk-YADG7KA6.cjs.map +1 -0
- package/build/cjs/{createClient-BJo8T7Js.d.cts → createClient-mOlFts15.d.cts} +1 -0
- package/build/cjs/index.cjs +11 -7
- package/build/cjs/index.d.cts +2 -2
- package/build/cjs/public/internal.cjs +8 -8
- package/build/cjs/public/unstable-do-not-use.cjs +1502 -851
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +183 -13
- package/build/esm/Client.js +1 -1
- package/build/esm/Client.js.map +1 -1
- package/build/esm/MinimalClientContext.js.map +1 -1
- package/build/esm/actions/applyAction.js +4 -0
- package/build/esm/actions/applyAction.js.map +1 -1
- package/build/esm/createClient.js +6 -2
- package/build/esm/createClient.js.map +1 -1
- package/build/esm/createMinimalClient.js +2 -1
- package/build/esm/createMinimalClient.js.map +1 -1
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +17 -0
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
- package/build/esm/fetchMetadata.test.js +11 -0
- package/build/esm/fetchMetadata.test.js.map +1 -1
- package/build/esm/index.js +3 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/intellisense.test.helpers/orderBySuggestionIsRight.js +8 -1
- package/build/esm/intellisense.test.helpers/orderBySuggestionIsRight.js.map +1 -1
- package/build/esm/intellisense.test.js +14 -4
- package/build/esm/intellisense.test.js.map +1 -1
- package/build/esm/object/Cache.js +1 -1
- package/build/esm/object/Cache.js.map +1 -1
- package/build/esm/object/Cache.test.js +1 -1
- package/build/esm/object/Cache.test.js.map +1 -1
- package/build/esm/object/SimpleCache.js +1 -1
- package/build/esm/object/SimpleCache.js.map +1 -1
- package/build/esm/object/aggregate.js +2 -0
- package/build/esm/object/aggregate.js.map +1 -1
- package/build/esm/object/aggregate.test.js +30 -0
- package/build/esm/object/aggregate.test.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/OsdkCustomInspectPrototype.js +1 -0
- package/build/esm/object/convertWireToOsdkObjects/OsdkCustomInspectPrototype.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +6 -0
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/getDollarLink.js +20 -1
- package/build/esm/object/convertWireToOsdkObjects/getDollarLink.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.js +4 -0
- package/build/esm/object/convertWireToOsdkObjects.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.test.js +14 -0
- package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/esm/object/fetchPage.js +96 -21
- package/build/esm/object/fetchPage.js.map +1 -1
- package/build/esm/object/fetchPage.test.js +35 -1
- package/build/esm/object/fetchPage.test.js.map +1 -1
- package/build/esm/object/geotimeseriesreference.test.js +0 -2
- package/build/esm/object/geotimeseriesreference.test.js.map +1 -1
- package/build/esm/object/mediaUpload.js +3 -0
- package/build/esm/object/mediaUpload.js.map +1 -1
- package/build/esm/objectSet/ObjectSet.test.js +6 -0
- package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js +31 -9
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js +69 -4
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/esm/objectSet/createObjectSet.js +3 -1
- package/build/esm/objectSet/createObjectSet.js.map +1 -1
- package/build/esm/observable/LinkPayload.js +2 -0
- package/build/esm/observable/LinkPayload.js.map +1 -0
- package/build/esm/observable/ObjectPayload.js.map +1 -1
- package/build/esm/observable/ObservableClient/ObserveLink.js +17 -0
- package/build/esm/observable/ObservableClient/ObserveLink.js.map +1 -0
- package/build/esm/observable/ObservableClient/common.js +2 -0
- package/build/esm/observable/ObservableClient/common.js.map +1 -0
- package/build/esm/observable/ObservableClient.js +20 -0
- package/build/esm/observable/ObservableClient.js.map +1 -1
- package/build/esm/observable/Unsubscribable.js +2 -0
- package/build/esm/observable/Unsubscribable.js.map +1 -0
- package/build/esm/observable/internal/AbstractHelper.js +54 -0
- package/build/esm/observable/internal/AbstractHelper.js.map +1 -0
- package/build/esm/observable/internal/BatchContext.js +2 -0
- package/build/esm/observable/internal/BatchContext.js.map +1 -0
- package/build/esm/observable/internal/BulkObjectLoader.js +3 -3
- package/build/esm/observable/internal/BulkObjectLoader.js.map +1 -1
- package/build/esm/observable/internal/CacheKeys.js +65 -25
- package/build/esm/observable/internal/CacheKeys.js.map +1 -1
- package/build/esm/observable/internal/Changes.js +6 -0
- package/build/esm/observable/internal/Changes.js.map +1 -1
- package/build/esm/observable/internal/KnownCacheKey.js +2 -0
- package/build/esm/observable/internal/KnownCacheKey.js.map +1 -0
- package/build/esm/observable/internal/Layer.js +0 -8
- package/build/esm/observable/internal/Layer.js.map +1 -1
- package/build/esm/observable/internal/Layers.js +151 -0
- package/build/esm/observable/internal/Layers.js.map +1 -0
- package/build/esm/observable/internal/ObservableClientImpl.js +54 -3
- package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/esm/observable/internal/OrderByCanonicalizer.js +1 -37
- package/build/esm/observable/internal/OrderByCanonicalizer.js.map +1 -1
- package/build/esm/observable/internal/Queries.js +40 -0
- package/build/esm/observable/internal/Queries.js.map +1 -0
- package/build/esm/observable/internal/Query.js +45 -4
- package/build/esm/observable/internal/Query.js.map +1 -1
- package/build/esm/observable/internal/QuerySubscription.js +48 -0
- package/build/esm/observable/internal/QuerySubscription.js.map +1 -0
- package/build/esm/observable/internal/Store.invalidation.test.js +646 -0
- package/build/esm/observable/internal/Store.invalidation.test.js.map +1 -0
- package/build/esm/observable/internal/Store.js +87 -308
- package/build/esm/observable/internal/Store.js.map +1 -1
- package/build/esm/observable/internal/Store.test.js +330 -73
- package/build/esm/observable/internal/Store.test.js.map +1 -1
- package/build/esm/observable/internal/SubjectPayload.js +2 -0
- package/build/esm/observable/internal/SubjectPayload.js.map +1 -0
- package/build/esm/observable/internal/Subjects.js +55 -0
- package/build/esm/observable/internal/Subjects.js.map +1 -0
- package/build/esm/observable/internal/UnsubscribableWrapper.js +30 -0
- package/build/esm/observable/internal/UnsubscribableWrapper.js.map +1 -0
- package/build/esm/observable/internal/WeakRefTrie.js +61 -0
- package/build/esm/observable/internal/WeakRefTrie.js.map +1 -0
- package/build/esm/observable/internal/{ActionApplication.js → actions/ActionApplication.js} +2 -2
- package/build/esm/observable/internal/actions/ActionApplication.js.map +1 -0
- package/build/{browser/observable/internal → esm/observable/internal/actions}/OptimisticJob.js +15 -6
- package/build/esm/observable/internal/actions/OptimisticJob.js.map +1 -0
- package/build/esm/observable/internal/base-list/BaseCollectionQuery.js +2 -0
- package/build/esm/observable/internal/base-list/BaseCollectionQuery.js.map +1 -0
- package/build/esm/observable/internal/base-list/BaseListQuery.js +411 -0
- package/build/esm/observable/internal/base-list/BaseListQuery.js.map +1 -0
- package/build/esm/observable/internal/base-list/createCollectionConnectable.js +50 -0
- package/build/esm/observable/internal/base-list/createCollectionConnectable.js.map +1 -0
- package/build/esm/observable/internal/base-list/createCollectionConnectable.test.js +597 -0
- package/build/esm/observable/internal/base-list/createCollectionConnectable.test.js.map +1 -0
- package/build/esm/observable/internal/base-list/removeDuplicates.js +36 -0
- package/build/esm/observable/internal/base-list/removeDuplicates.js.map +1 -0
- package/build/esm/observable/internal/createInitEntry.js +25 -0
- package/build/esm/observable/internal/createInitEntry.js.map +1 -0
- package/build/esm/observable/internal/getObjectTypesThatInvalidate.js +216 -0
- package/build/esm/observable/internal/getObjectTypesThatInvalidate.js.map +1 -0
- package/build/esm/observable/internal/getObjectTypesThatInvalidate.test.js +382 -0
- package/build/esm/observable/internal/getObjectTypesThatInvalidate.test.js.map +1 -0
- package/build/esm/observable/internal/isObjectInstance.js +23 -0
- package/build/esm/observable/internal/isObjectInstance.js.map +1 -0
- package/build/esm/observable/internal/links/LinksHelper.js +37 -0
- package/build/esm/observable/internal/links/LinksHelper.js.map +1 -0
- package/build/esm/observable/internal/links/SpecificLinkCacheKey.js +2 -0
- package/build/esm/observable/internal/links/SpecificLinkCacheKey.js.map +1 -0
- package/build/esm/observable/internal/links/SpecificLinkQuery.js +185 -0
- package/build/esm/observable/internal/links/SpecificLinkQuery.js.map +1 -0
- package/build/esm/observable/internal/list/InterfaceListQuery.js +83 -0
- package/build/esm/observable/internal/list/InterfaceListQuery.js.map +1 -0
- package/build/esm/observable/internal/list/ListCacheKey.js +2 -0
- package/build/esm/observable/internal/list/ListCacheKey.js.map +1 -0
- package/build/esm/observable/internal/list/ListQuery.js +372 -0
- package/build/esm/observable/internal/list/ListQuery.js.map +1 -0
- package/build/esm/observable/internal/list/ListQueryOptions.js +2 -0
- package/build/esm/observable/internal/list/ListQueryOptions.js.map +1 -0
- package/build/esm/observable/internal/list/ListsHelper.js +51 -0
- package/build/esm/observable/internal/list/ListsHelper.js.map +1 -0
- package/build/esm/observable/internal/list/ObjectListQuery.js +48 -0
- package/build/esm/observable/internal/list/ObjectListQuery.js.map +1 -0
- package/build/esm/observable/internal/object/ObjectCacheKey.js +2 -0
- package/build/esm/observable/internal/object/ObjectCacheKey.js.map +1 -0
- package/build/esm/observable/internal/{ObjectQuery.js → object/ObjectQuery.js} +27 -18
- package/build/esm/observable/internal/object/ObjectQuery.js.map +1 -0
- package/build/esm/observable/internal/object/ObjectsHelper.js +48 -0
- package/build/esm/observable/internal/object/ObjectsHelper.js.map +1 -0
- package/build/esm/observable/internal/sorting/SortingStrategy.js +78 -0
- package/build/esm/observable/internal/sorting/SortingStrategy.js.map +1 -0
- package/build/esm/observable/internal/testUtils/invalidateList.js +23 -0
- package/build/esm/observable/internal/testUtils/invalidateList.js.map +1 -0
- package/build/esm/observable/internal/testUtils/observeLink/expectStandardObserveLink.js +69 -0
- package/build/esm/observable/internal/testUtils/observeLink/expectStandardObserveLink.js.map +1 -0
- package/build/esm/observable/internal/testUtils/observeObject/expectStandardObserveObject.js +56 -0
- package/build/esm/observable/internal/testUtils/observeObject/expectStandardObserveObject.js.map +1 -0
- package/build/esm/observable/internal/testUtils.js +72 -10
- package/build/esm/observable/internal/testUtils.js.map +1 -1
- package/build/esm/ontology/loadActionMetadata.js +3 -1
- package/build/esm/ontology/loadActionMetadata.js.map +1 -1
- package/build/esm/ontology/loadFullObjectMetadata.js +2 -1
- package/build/esm/ontology/loadFullObjectMetadata.js.map +1 -1
- package/build/esm/ontology/loadInterfaceMetadata.js +2 -1
- package/build/esm/ontology/loadInterfaceMetadata.js.map +1 -1
- package/build/esm/public/unstable-do-not-use.js.map +1 -1
- package/build/esm/util/UserAgent.js +2 -2
- package/build/esm/util/UserAgent.js.map +1 -1
- package/build/esm/util/exponentialBackoff.js +51 -0
- package/build/esm/util/exponentialBackoff.js.map +1 -0
- package/build/esm/util/exponentialBackoff.test.js +81 -0
- package/build/esm/util/exponentialBackoff.test.js.map +1 -0
- package/build/esm/util/extractObjectOrInterfaceType.js +9 -1
- package/build/esm/util/extractObjectOrInterfaceType.js.map +1 -1
- package/build/esm/util/extractObjectOrInterfaceType.test.js +2 -2
- package/build/esm/util/extractObjectOrInterfaceType.test.js.map +1 -1
- package/build/esm/util/streamutils.js +1 -1
- package/build/esm/util/streamutils.js.map +1 -1
- package/build/esm/util/toDataValue.js +15 -1
- package/build/esm/util/toDataValue.js.map +1 -1
- package/build/esm/util/toDataValue.test.js +42 -2
- package/build/esm/util/toDataValue.test.js.map +1 -1
- package/build/types/Client.d.ts +1 -1
- package/build/types/MinimalClientContext.d.ts +1 -0
- package/build/types/MinimalClientContext.d.ts.map +1 -1
- package/build/types/actions/applyAction.d.ts.map +1 -1
- package/build/types/createClient.d.ts +1 -0
- package/build/types/createClient.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/object/fetchPage.d.ts.map +1 -1
- package/build/types/object/mediaUpload.d.ts +2 -1
- package/build/types/object/mediaUpload.d.ts.map +1 -1
- package/build/types/observable/LinkPayload.d.ts +9 -0
- package/build/types/observable/LinkPayload.d.ts.map +1 -0
- package/build/types/observable/ObjectPayload.d.ts +4 -0
- package/build/types/observable/ObjectPayload.d.ts.map +1 -1
- package/build/types/observable/ObservableClient/ObserveLink.d.ts +32 -0
- package/build/types/observable/ObservableClient/ObserveLink.d.ts.map +1 -0
- package/build/types/observable/ObservableClient/common.d.ts +67 -0
- package/build/types/observable/ObservableClient/common.d.ts.map +1 -0
- package/build/types/observable/ObservableClient.d.ts +103 -15
- package/build/types/observable/ObservableClient.d.ts.map +1 -1
- package/build/types/observable/Unsubscribable.d.ts +3 -0
- package/build/types/observable/Unsubscribable.d.ts.map +1 -0
- package/build/types/observable/internal/AbstractHelper.d.ts +17 -0
- package/build/types/observable/internal/AbstractHelper.d.ts.map +1 -0
- package/build/types/observable/internal/BatchContext.d.ts +11 -0
- package/build/types/observable/internal/BatchContext.d.ts.map +1 -0
- package/build/types/observable/internal/BulkObjectLoader.d.ts.map +1 -1
- package/build/types/observable/internal/CacheKeys.d.ts +12 -6
- package/build/types/observable/internal/CacheKeys.d.ts.map +1 -1
- package/build/types/observable/internal/Changes.d.ts +8 -5
- package/build/types/observable/internal/Changes.d.ts.map +1 -1
- package/build/types/observable/internal/KnownCacheKey.d.ts +4 -0
- package/build/types/observable/internal/KnownCacheKey.d.ts.map +1 -0
- package/build/types/observable/internal/Layer.d.ts +6 -7
- package/build/types/observable/internal/Layer.d.ts.map +1 -1
- package/build/types/observable/internal/Layers.d.ts +26 -0
- package/build/types/observable/internal/Layers.d.ts.map +1 -0
- package/build/types/observable/internal/OrderByCanonicalizer.d.ts +0 -7
- package/build/types/observable/internal/OrderByCanonicalizer.d.ts.map +1 -1
- package/build/types/observable/internal/Queries.d.ts +9 -0
- package/build/types/observable/internal/Queries.d.ts.map +1 -0
- package/build/types/observable/internal/Query.d.ts +23 -6
- package/build/types/observable/internal/Query.d.ts.map +1 -1
- package/build/types/observable/internal/QuerySubscription.d.ts +1 -0
- package/build/types/observable/internal/QuerySubscription.d.ts.map +1 -0
- package/build/types/observable/internal/Store.d.ts +41 -51
- package/build/types/observable/internal/Store.d.ts.map +1 -1
- package/build/types/observable/internal/Store.invalidation.test.d.ts +1 -0
- package/build/types/observable/internal/Store.invalidation.test.d.ts.map +1 -0
- package/build/types/observable/internal/Store.test.d.ts +4 -1
- package/build/types/observable/internal/Store.test.d.ts.map +1 -1
- package/build/types/observable/internal/SubjectPayload.d.ts +5 -0
- package/build/types/observable/internal/SubjectPayload.d.ts.map +1 -0
- package/build/types/observable/internal/Subjects.d.ts +16 -0
- package/build/types/observable/internal/Subjects.d.ts.map +1 -0
- package/build/types/observable/internal/UnsubscribableWrapper.d.ts +1 -0
- package/build/types/observable/internal/UnsubscribableWrapper.d.ts.map +1 -0
- package/build/types/observable/internal/WeakRefTrie.d.ts +13 -0
- package/build/types/observable/internal/WeakRefTrie.d.ts.map +1 -0
- package/build/types/observable/internal/{ActionApplication.d.ts → actions/ActionApplication.d.ts} +2 -2
- package/build/types/observable/internal/{ActionApplication.d.ts.map → actions/ActionApplication.d.ts.map} +1 -1
- package/build/types/observable/internal/{OptimisticJob.d.ts → actions/OptimisticJob.d.ts} +4 -4
- package/build/types/observable/internal/actions/OptimisticJob.d.ts.map +1 -0
- package/build/types/observable/internal/base-list/BaseCollectionQuery.d.ts +64 -0
- package/build/types/observable/internal/base-list/BaseCollectionQuery.d.ts.map +1 -0
- package/build/types/observable/internal/base-list/BaseListQuery.d.ts +145 -0
- package/build/types/observable/internal/base-list/BaseListQuery.d.ts.map +1 -0
- package/build/types/observable/internal/base-list/createCollectionConnectable.d.ts +39 -0
- package/build/types/observable/internal/base-list/createCollectionConnectable.d.ts.map +1 -0
- package/build/types/observable/internal/base-list/createCollectionConnectable.test.d.ts +1 -0
- package/build/types/observable/internal/base-list/createCollectionConnectable.test.d.ts.map +1 -0
- package/build/types/observable/internal/base-list/removeDuplicates.d.ts +11 -0
- package/build/types/observable/internal/base-list/removeDuplicates.d.ts.map +1 -0
- package/build/types/observable/internal/createInitEntry.d.ts +3 -0
- package/build/types/observable/internal/createInitEntry.d.ts.map +1 -0
- package/build/types/observable/internal/getObjectTypesThatInvalidate.d.ts +9 -0
- package/build/types/observable/internal/getObjectTypesThatInvalidate.d.ts.map +1 -0
- package/build/types/observable/internal/getObjectTypesThatInvalidate.test.d.ts +1 -0
- package/build/types/observable/internal/getObjectTypesThatInvalidate.test.d.ts.map +1 -0
- package/build/types/observable/internal/isObjectInstance.d.ts +5 -0
- package/build/types/observable/internal/isObjectInstance.d.ts.map +1 -0
- package/build/types/observable/internal/links/LinksHelper.d.ts +31 -0
- package/build/types/observable/internal/links/LinksHelper.d.ts.map +1 -0
- package/build/types/observable/internal/links/SpecificLinkCacheKey.d.ts +17 -0
- package/build/types/observable/internal/links/SpecificLinkCacheKey.d.ts.map +1 -0
- package/build/types/observable/internal/links/SpecificLinkQuery.d.ts +47 -0
- package/build/types/observable/internal/links/SpecificLinkQuery.d.ts.map +1 -0
- package/build/types/observable/internal/list/InterfaceListQuery.d.ts +18 -0
- package/build/types/observable/internal/list/InterfaceListQuery.d.ts.map +1 -0
- package/build/types/observable/internal/list/ListCacheKey.d.ts +7 -0
- package/build/types/observable/internal/list/ListCacheKey.d.ts.map +1 -0
- package/build/types/observable/internal/list/ListQuery.d.ts +106 -0
- package/build/types/observable/internal/list/ListQuery.d.ts.map +1 -0
- package/build/types/observable/internal/list/ListQueryOptions.d.ts +4 -0
- package/build/types/observable/internal/list/ListQueryOptions.d.ts.map +1 -0
- package/build/types/observable/internal/list/ListsHelper.d.ts +19 -0
- package/build/types/observable/internal/list/ListsHelper.d.ts.map +1 -0
- package/build/types/observable/internal/list/ObjectListQuery.d.ts +18 -0
- package/build/types/observable/internal/list/ObjectListQuery.d.ts.map +1 -0
- package/build/types/observable/internal/object/ObjectCacheKey.d.ts +5 -0
- package/build/types/observable/internal/object/ObjectCacheKey.d.ts.map +1 -0
- package/build/types/observable/internal/{ObjectQuery.d.ts → object/ObjectQuery.d.ts} +11 -9
- package/build/types/observable/internal/object/ObjectQuery.d.ts.map +1 -0
- package/build/types/observable/internal/object/ObjectsHelper.d.ts +11 -0
- package/build/types/observable/internal/object/ObjectsHelper.d.ts.map +1 -0
- package/build/types/observable/internal/sorting/SortingStrategy.d.ts +41 -0
- package/build/types/observable/internal/sorting/SortingStrategy.d.ts.map +1 -0
- package/build/types/observable/internal/testUtils/invalidateList.d.ts +9 -0
- package/build/types/observable/internal/testUtils/invalidateList.d.ts.map +1 -0
- package/build/types/observable/internal/testUtils/observeLink/expectStandardObserveLink.d.ts +46 -0
- package/build/types/observable/internal/testUtils/observeLink/expectStandardObserveLink.d.ts.map +1 -0
- package/build/types/observable/internal/testUtils/observeObject/expectStandardObserveObject.d.ts +26 -0
- package/build/types/observable/internal/testUtils/observeObject/expectStandardObserveObject.d.ts.map +1 -0
- package/build/types/observable/internal/testUtils.d.ts +26 -4
- package/build/types/observable/internal/testUtils.d.ts.map +1 -1
- package/build/types/public/unstable-do-not-use.d.ts +4 -2
- package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
- package/build/types/util/exponentialBackoff.d.ts +14 -0
- package/build/types/util/exponentialBackoff.d.ts.map +1 -0
- package/build/types/util/exponentialBackoff.test.d.ts +1 -0
- package/build/types/util/exponentialBackoff.test.d.ts.map +1 -0
- package/package.json +27 -27
- package/build/browser/observable/internal/ActionApplication.js.map +0 -1
- package/build/browser/observable/internal/ListQuery.js +0 -618
- package/build/browser/observable/internal/ListQuery.js.map +0 -1
- package/build/browser/observable/internal/ObjectQuery.js.map +0 -1
- package/build/browser/observable/internal/OptimisticJob.js.map +0 -1
- package/build/cjs/chunk-26WFEZQO.cjs.map +0 -1
- package/build/cjs/chunk-633AI7EA.cjs.map +0 -1
- package/build/esm/observable/internal/ActionApplication.js.map +0 -1
- package/build/esm/observable/internal/ListQuery.js +0 -618
- package/build/esm/observable/internal/ListQuery.js.map +0 -1
- package/build/esm/observable/internal/ObjectQuery.js.map +0 -1
- package/build/esm/observable/internal/OptimisticJob.js.map +0 -1
- package/build/types/observable/internal/ListQuery.d.ts +0 -88
- package/build/types/observable/internal/ListQuery.d.ts.map +0 -1
- package/build/types/observable/internal/ObjectQuery.d.ts.map +0 -1
- package/build/types/observable/internal/OptimisticJob.d.ts.map +0 -1
|
@@ -0,0 +1,372 @@
|
|
|
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 invariant from "tiny-invariant";
|
|
18
|
+
import { additionalContext } from "../../../Client.js";
|
|
19
|
+
import { BaseListQuery } from "../base-list/BaseListQuery.js";
|
|
20
|
+
import { DEBUG_ONLY__changesToString } from "../Changes.js";
|
|
21
|
+
import { objectSortaMatchesWhereClause as objectMatchesWhereClause } from "../objectMatchesWhereClause.js";
|
|
22
|
+
import { OrderBySortingStrategy } from "../sorting/SortingStrategy.js";
|
|
23
|
+
export const API_NAME_IDX = 1;
|
|
24
|
+
export const TYPE_IDX = 0;
|
|
25
|
+
export const WHERE_IDX = 2;
|
|
26
|
+
export const ORDER_BY_IDX = 3;
|
|
27
|
+
/**
|
|
28
|
+
* Base class for filtered and sorted object collection queries.
|
|
29
|
+
* - Handles where clause filtering and orderBy sorting
|
|
30
|
+
* - Manages pagination through fetchMore
|
|
31
|
+
* - Auto-updates when matching objects change
|
|
32
|
+
* - Uses canonicalized cache keys for consistency
|
|
33
|
+
*/
|
|
34
|
+
export class ListQuery extends BaseListQuery {
|
|
35
|
+
// pageSize?: number; // this is the internal page size. we need to track this properly
|
|
36
|
+
|
|
37
|
+
#whereClause;
|
|
38
|
+
|
|
39
|
+
// Using base class minResultsToLoad instead of a private property
|
|
40
|
+
#orderBy;
|
|
41
|
+
#objectSet;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Register changes to the cache specific to ListQuery
|
|
45
|
+
*/
|
|
46
|
+
registerCacheChanges(batch) {
|
|
47
|
+
batch.changes.registerList(this.cacheKey);
|
|
48
|
+
}
|
|
49
|
+
constructor(store, subject, apiName, whereClause, orderBy, cacheKey, opts) {
|
|
50
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[additionalContext].logger?.child({}, {
|
|
51
|
+
msgPrefix: `ListQuery<${cacheKey.otherKeys.map(x => JSON.stringify(x)).join(", ")}>`
|
|
52
|
+
}) : undefined);
|
|
53
|
+
this.apiName = apiName;
|
|
54
|
+
this.#whereClause = whereClause;
|
|
55
|
+
this.#orderBy = orderBy;
|
|
56
|
+
this.#objectSet = this.createObjectSet(store);
|
|
57
|
+
// Initialize the sorting strategy
|
|
58
|
+
this.sortingStrategy = new OrderBySortingStrategy(this.apiName, this.#orderBy);
|
|
59
|
+
// Initialize the minResultsToLoad inherited from BaseCollectionQuery
|
|
60
|
+
this.minResultsToLoad = 0;
|
|
61
|
+
}
|
|
62
|
+
get canonicalWhere() {
|
|
63
|
+
return this.#whereClause;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Create the ObjectSet for this query.
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Implements fetchPageData from BaseCollectionQuery template method
|
|
72
|
+
* Fetches a page of data
|
|
73
|
+
*/
|
|
74
|
+
async fetchPageData(signal) {
|
|
75
|
+
// Fetch the data with pagination
|
|
76
|
+
const resp = await this.#objectSet.fetchPage({
|
|
77
|
+
$nextPageToken: this.nextPageToken,
|
|
78
|
+
$pageSize: this.options.pageSize,
|
|
79
|
+
// For now this keeps the shared test code from falling apart
|
|
80
|
+
// but shouldn't be needed ideally
|
|
81
|
+
...(Object.keys(this.#orderBy).length > 0 ? {
|
|
82
|
+
$orderBy: this.#orderBy
|
|
83
|
+
} : {})
|
|
84
|
+
});
|
|
85
|
+
if (signal?.aborted) {
|
|
86
|
+
throw new Error("Aborted");
|
|
87
|
+
}
|
|
88
|
+
this.nextPageToken = resp.nextPageToken;
|
|
89
|
+
const fetchedData = await this.postProcessFetchedData(resp.data);
|
|
90
|
+
return {
|
|
91
|
+
...resp,
|
|
92
|
+
data: fetchedData
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Handle fetch errors by setting appropriate error state and notifying subscribers
|
|
98
|
+
*/
|
|
99
|
+
handleFetchError(error, _status, batch) {
|
|
100
|
+
this.logger?.error("error", error);
|
|
101
|
+
this.store.subjects.get(this.cacheKey).error(error);
|
|
102
|
+
|
|
103
|
+
// We don't call super.handleFetchError because ListQuery has special error handling
|
|
104
|
+
// but we still use writeToStore to create a properly structured Entry
|
|
105
|
+
return this.writeToStore({
|
|
106
|
+
data: []
|
|
107
|
+
}, "error", batch);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Will revalidate the list if its query is affected by invalidating the
|
|
112
|
+
* apiName of the object type passed in.
|
|
113
|
+
*
|
|
114
|
+
* @param apiName to invalidate
|
|
115
|
+
* @returns
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Postprocess fetched data.
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
invalidateObjectType = async (objectType, changes) => {
|
|
123
|
+
if (this.cacheKey.otherKeys[1] === objectType) {
|
|
124
|
+
// Only invalidate lists for the matching apiName
|
|
125
|
+
changes?.modified.add(this.cacheKey);
|
|
126
|
+
return this.revalidate(true);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Note: This method is not async because I want it to return right after it
|
|
132
|
+
* finishes the synchronous updates. The promise that is returned
|
|
133
|
+
* will resolve after the revalidation is complete.
|
|
134
|
+
* @param changes
|
|
135
|
+
* @param optimisticId
|
|
136
|
+
* @returns If revalidation is needed, a promise that resolves after the
|
|
137
|
+
* revalidation is complete. Otherwise, undefined.
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
maybeUpdateAndRevalidate = (changes, optimisticId) => {
|
|
141
|
+
if (process.env.NODE_ENV !== "production") {
|
|
142
|
+
this.logger?.child({
|
|
143
|
+
methodName: "maybeUpdateAndRevalidate"
|
|
144
|
+
}).debug(DEBUG_ONLY__changesToString(changes));
|
|
145
|
+
this.logger?.child({
|
|
146
|
+
methodName: "maybeUpdateAndRevalidate"
|
|
147
|
+
}).debug(`Already in changes? ${changes.modified.has(this.cacheKey)}`);
|
|
148
|
+
}
|
|
149
|
+
if (changes.modified.has(this.cacheKey)) return;
|
|
150
|
+
// mark ourselves as updated so we don't infinite recurse.
|
|
151
|
+
changes.modified.add(this.cacheKey);
|
|
152
|
+
try {
|
|
153
|
+
const relevantObjects = this._extractAndCategorizeRelevantObjects(changes);
|
|
154
|
+
|
|
155
|
+
// If we got purely strict matches we can just update the list and move
|
|
156
|
+
// on with our lives. But if we got sorta matches, then we need to revalidate
|
|
157
|
+
// the list so we preemptively set it to loading to avoid thrashing the store.
|
|
158
|
+
const status = optimisticId || relevantObjects.added.sortaMatches.size > 0 || relevantObjects.modified.sortaMatches.size > 0 ? "loading" : "loaded";
|
|
159
|
+
|
|
160
|
+
// while we only push updates for the strict matches, we still need to
|
|
161
|
+
// trigger the list updating if some of our objects changed
|
|
162
|
+
|
|
163
|
+
const newList = [];
|
|
164
|
+
let needsRevalidation = false;
|
|
165
|
+
this.store.batch({
|
|
166
|
+
optimisticId,
|
|
167
|
+
changes
|
|
168
|
+
}, batch => {
|
|
169
|
+
const existingList = new Set(batch.read(this.cacheKey)?.value?.data);
|
|
170
|
+
const toAdd = new Set(
|
|
171
|
+
// easy case. objects are new to the cache and they match this filter
|
|
172
|
+
relevantObjects.added.strictMatches);
|
|
173
|
+
|
|
174
|
+
// anything thats been deleted can be removed, so start there
|
|
175
|
+
const toRemove = new Set(changes.deleted);
|
|
176
|
+
|
|
177
|
+
// deal with the modified objects
|
|
178
|
+
for (const obj of relevantObjects.modified.all) {
|
|
179
|
+
if (relevantObjects.modified.strictMatches.has(obj)) {
|
|
180
|
+
const objectCacheKey = this.cacheKeys.get("object", obj.$objectType, obj.$primaryKey);
|
|
181
|
+
if (!existingList.has(objectCacheKey)) {
|
|
182
|
+
// object is new to the list
|
|
183
|
+
toAdd.add(obj);
|
|
184
|
+
}
|
|
185
|
+
continue;
|
|
186
|
+
} else if (batch.optimisticWrite) {
|
|
187
|
+
// we aren't removing objects in optimistic mode
|
|
188
|
+
// we also don't want to trigger revalidation in optimistic mode
|
|
189
|
+
// as it should be triggered when the optimistic job is done
|
|
190
|
+
continue;
|
|
191
|
+
} else {
|
|
192
|
+
// object is no longer a strict match
|
|
193
|
+
const existingObjectCacheKey = this.cacheKeys.get("object", obj.$objectType, obj.$primaryKey);
|
|
194
|
+
toRemove.add(existingObjectCacheKey);
|
|
195
|
+
if (relevantObjects.modified.sortaMatches.has(obj)) {
|
|
196
|
+
// since it might still be in the list we need to revalidate
|
|
197
|
+
needsRevalidation = true;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
for (const key of existingList) {
|
|
202
|
+
if (toRemove.has(key)) continue;
|
|
203
|
+
newList.push(key);
|
|
204
|
+
}
|
|
205
|
+
for (const obj of toAdd) {
|
|
206
|
+
newList.push(this.cacheKeys.get("object", obj.$objectType, obj.$primaryKey));
|
|
207
|
+
}
|
|
208
|
+
this._updateList(newList, status, batch, /* append */false);
|
|
209
|
+
});
|
|
210
|
+
if (needsRevalidation) {
|
|
211
|
+
return this.revalidate(true);
|
|
212
|
+
}
|
|
213
|
+
return undefined;
|
|
214
|
+
} finally {
|
|
215
|
+
if (process.env.NODE_ENV !== "production") {
|
|
216
|
+
this.logger?.child({
|
|
217
|
+
methodName: "maybeUpdateAndRevalidate"
|
|
218
|
+
}).debug("in finally");
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
#matchType(obj) {
|
|
223
|
+
// if its a strict match we can just insert it into place
|
|
224
|
+
if (objectMatchesWhereClause(obj, this.#whereClause, true)) {
|
|
225
|
+
return "strict";
|
|
226
|
+
}
|
|
227
|
+
// sorta match means it used a filter we cannot use on the frontend
|
|
228
|
+
if (objectMatchesWhereClause(obj, this.#whereClause, false)) {
|
|
229
|
+
return "sorta";
|
|
230
|
+
}
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
_extractAndCategorizeRelevantObjects(changes) {
|
|
234
|
+
const relevantObjects = this.extractRelevantObjects(changes);
|
|
235
|
+
|
|
236
|
+
// categorize
|
|
237
|
+
for (const group of Object.values(relevantObjects)) {
|
|
238
|
+
for (const obj of group.all ?? []) {
|
|
239
|
+
const matchType = this.#matchType(obj);
|
|
240
|
+
if (matchType) {
|
|
241
|
+
group[`${matchType}Matches`].add(obj);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return relevantObjects;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Extract relevant objects for this query type.
|
|
250
|
+
*/
|
|
251
|
+
|
|
252
|
+
registerStreamUpdates(sub) {
|
|
253
|
+
const logger = process.env.NODE_ENV !== "production" ? this.logger?.child({
|
|
254
|
+
methodName: "registerStreamUpdates"
|
|
255
|
+
}) : this.logger;
|
|
256
|
+
if (process.env.NODE_ENV !== "production") {
|
|
257
|
+
logger?.child({
|
|
258
|
+
methodName: "observeList"
|
|
259
|
+
}).info("Subscribing from websocket");
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// FIXME: We should only do this once. If we already have one we should probably
|
|
263
|
+
// just reuse it.
|
|
264
|
+
|
|
265
|
+
const websocketSubscription = this.#objectSet.subscribe({
|
|
266
|
+
onChange: this.onOswChange.bind(this),
|
|
267
|
+
onError: this.onOswError.bind(this),
|
|
268
|
+
onOutOfDate: this.onOswOutOfDate.bind(this),
|
|
269
|
+
onSuccessfulSubscription: this.onOswSuccessfulSubscription.bind(this)
|
|
270
|
+
});
|
|
271
|
+
sub.add(() => {
|
|
272
|
+
if (process.env.NODE_ENV !== "production") {
|
|
273
|
+
logger?.child({
|
|
274
|
+
methodName: "observeList"
|
|
275
|
+
}).info("Unsubscribing from websocket");
|
|
276
|
+
}
|
|
277
|
+
websocketSubscription.unsubscribe();
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
onOswSuccessfulSubscription() {
|
|
281
|
+
if (process.env.NODE_ENV !== "production") {
|
|
282
|
+
this.logger?.child({
|
|
283
|
+
methodName: "onSuccessfulSubscription"
|
|
284
|
+
}).debug("");
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
onOswOutOfDate() {
|
|
288
|
+
if (process.env.NODE_ENV !== "production") {
|
|
289
|
+
this.logger?.child({
|
|
290
|
+
methodName: "onOutOfDate"
|
|
291
|
+
}).debug("");
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
onOswError(errors) {
|
|
295
|
+
if (this.logger) {
|
|
296
|
+
this.logger?.child({
|
|
297
|
+
methodName: "onError"
|
|
298
|
+
}).error("subscription errors", errors);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
onOswChange({
|
|
302
|
+
object: objOrIface,
|
|
303
|
+
state
|
|
304
|
+
}) {
|
|
305
|
+
const logger = process.env.NODE_ENV !== "production" ? this.logger?.child({
|
|
306
|
+
methodName: "registerStreamUpdates"
|
|
307
|
+
}) : this.logger;
|
|
308
|
+
if (process.env.NODE_ENV !== "production") {
|
|
309
|
+
logger?.child({
|
|
310
|
+
methodName: "onChange"
|
|
311
|
+
}).debug(`Got an update of type: ${state}`, objOrIface);
|
|
312
|
+
}
|
|
313
|
+
if (state === "ADDED_OR_UPDATED") {
|
|
314
|
+
const object = objOrIface.$apiName !== objOrIface.$objectType ? objOrIface.$as(objOrIface.$objectType) : objOrIface;
|
|
315
|
+
this.store.batch({}, batch => {
|
|
316
|
+
this.store.objects.storeOsdkInstances([object], batch);
|
|
317
|
+
});
|
|
318
|
+
} else if (state === "REMOVED") {
|
|
319
|
+
this.onOswRemoved(objOrIface, logger);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
onOswRemoved(objOrIface, logger) {
|
|
323
|
+
this.store.batch({}, batch => {
|
|
324
|
+
// Read the truth layer (since not optimistic)
|
|
325
|
+
const existing = batch.read(this.cacheKey);
|
|
326
|
+
!existing ? process.env.NODE_ENV !== "production" ? invariant(false, "the truth value for our list should exist as we already subscribed") : invariant(false) : void 0;
|
|
327
|
+
if (existing.status === "loaded") {
|
|
328
|
+
const objectCacheKey = this.cacheKeys.get("object", objOrIface.$objectType, objOrIface.$primaryKey);
|
|
329
|
+
// remove the object from the list
|
|
330
|
+
const newObjects = existing.value?.data.filter(o => o !== objectCacheKey);
|
|
331
|
+
|
|
332
|
+
// If the filter didn't change anything, then the list was already
|
|
333
|
+
// updated (or didn't exist, which is nonsensical)
|
|
334
|
+
if (newObjects?.length !== existing.value?.data.length) {
|
|
335
|
+
batch.changes.registerList(this.cacheKey);
|
|
336
|
+
batch.write(this.cacheKey, {
|
|
337
|
+
data: newObjects ?? []
|
|
338
|
+
}, "loaded");
|
|
339
|
+
// Should there be an else for this case? Do we need to invalidate
|
|
340
|
+
// the paging tokens we may have? FIXME
|
|
341
|
+
}
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
// There may be a tiny race here where OSW tells us the object has
|
|
345
|
+
// been removed but an outstanding invalidation of this query is
|
|
346
|
+
// about to return. In this case, its possible that we remove this item
|
|
347
|
+
// from the list and then the returned list load re-adds it.
|
|
348
|
+
// To avoid this, we will just force reload the query to be sure
|
|
349
|
+
// we don't leave things in a bad state.
|
|
350
|
+
if (process.env.NODE_ENV !== "production") {
|
|
351
|
+
logger?.info("Removing an object from an object list that is in the middle of being loaded.", existing);
|
|
352
|
+
}
|
|
353
|
+
this.revalidate(/* force */true).catch(e => {
|
|
354
|
+
if (logger) {
|
|
355
|
+
logger?.error("Uncaught error while revalidating list", e);
|
|
356
|
+
} else {
|
|
357
|
+
// Make sure we write to the console if there is no logger!
|
|
358
|
+
// eslint-disable-next-line no-console
|
|
359
|
+
console.error("Uncaught error while revalidating list", e);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
export function isListCacheKey(cacheKey) {
|
|
366
|
+
return cacheKey.type === "list";
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Copied from @osdk/api
|
|
371
|
+
*/
|
|
372
|
+
//# sourceMappingURL=ListQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListQuery.js","names":["invariant","additionalContext","BaseListQuery","DEBUG_ONLY__changesToString","objectSortaMatchesWhereClause","objectMatchesWhereClause","OrderBySortingStrategy","API_NAME_IDX","TYPE_IDX","WHERE_IDX","ORDER_BY_IDX","ListQuery","whereClause","orderBy","objectSet","registerCacheChanges","batch","changes","registerList","cacheKey","constructor","store","subject","apiName","opts","process","env","NODE_ENV","client","logger","child","msgPrefix","otherKeys","map","x","JSON","stringify","join","undefined","createObjectSet","sortingStrategy","minResultsToLoad","canonicalWhere","fetchPageData","signal","resp","fetchPage","$nextPageToken","nextPageToken","$pageSize","options","pageSize","Object","keys","length","$orderBy","aborted","Error","fetchedData","postProcessFetchedData","data","handleFetchError","error","_status","subjects","get","writeToStore","invalidateObjectType","objectType","modified","add","revalidate","maybeUpdateAndRevalidate","optimisticId","methodName","debug","has","relevantObjects","_extractAndCategorizeRelevantObjects","status","added","sortaMatches","size","newList","needsRevalidation","existingList","Set","read","value","toAdd","strictMatches","toRemove","deleted","obj","all","objectCacheKey","cacheKeys","$objectType","$primaryKey","optimisticWrite","existingObjectCacheKey","key","push","_updateList","matchType","#matchType","extractRelevantObjects","group","values","registerStreamUpdates","sub","info","websocketSubscription","subscribe","onChange","onOswChange","bind","onError","onOswError","onOutOfDate","onOswOutOfDate","onSuccessfulSubscription","onOswSuccessfulSubscription","unsubscribe","errors","object","objOrIface","state","$apiName","$as","objects","storeOsdkInstances","onOswRemoved","existing","newObjects","filter","o","write","catch","e","console","isListCacheKey","type"],"sources":["ListQuery.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 Logger,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PageResult,\n PropertyKeys,\n} from \"@osdk/api\";\nimport type { Observable, Subscription } from \"rxjs\";\nimport invariant from \"tiny-invariant\";\nimport { additionalContext } from \"../../../Client.js\";\nimport type { InterfaceHolder } from \"../../../object/convertWireToOsdkObjects/InterfaceHolder.js\";\nimport type {\n ObjectHolder,\n} from \"../../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { ListPayload } from \"../../ListPayload.js\";\nimport type { Status } from \"../../ObservableClient/common.js\";\nimport { BaseListQuery } from \"../base-list/BaseListQuery.js\";\nimport type { BatchContext } from \"../BatchContext.js\";\nimport { type CacheKey } from \"../CacheKey.js\";\nimport type { Canonical } from \"../Canonical.js\";\nimport { type Changes, DEBUG_ONLY__changesToString } from \"../Changes.js\";\nimport type { Entry } from \"../Layer.js\";\nimport { type ObjectCacheKey } from \"../object/ObjectCacheKey.js\";\nimport { objectSortaMatchesWhereClause as objectMatchesWhereClause } from \"../objectMatchesWhereClause.js\";\nimport type { OptimisticId } from \"../OptimisticId.js\";\nimport type { SimpleWhereClause } from \"../SimpleWhereClause.js\";\nimport { OrderBySortingStrategy } from \"../sorting/SortingStrategy.js\";\nimport type { Store } from \"../Store.js\";\nimport type { SubjectPayload } from \"../SubjectPayload.js\";\nimport type { ListCacheKey } from \"./ListCacheKey.js\";\nimport type { ListQueryOptions } from \"./ListQueryOptions.js\";\n\nexport const API_NAME_IDX = 1;\nexport const TYPE_IDX = 0;\nexport const WHERE_IDX = 2;\nexport const ORDER_BY_IDX = 3;\n\ntype ExtractRelevantObjectsResult = Record<\"added\" | \"modified\", {\n all: (ObjectHolder | InterfaceHolder)[];\n strictMatches: Set<(ObjectHolder | InterfaceHolder)>;\n sortaMatches: Set<(ObjectHolder | InterfaceHolder)>;\n}>;\n\n/**\n * Base class for filtered and sorted object collection queries.\n * - Handles where clause filtering and orderBy sorting\n * - Manages pagination through fetchMore\n * - Auto-updates when matching objects change\n * - Uses canonicalized cache keys for consistency\n */\nexport abstract class ListQuery extends BaseListQuery<\n ListCacheKey,\n ListPayload,\n ListQueryOptions\n> {\n // pageSize?: number; // this is the internal page size. we need to track this properly\n\n protected apiName: string;\n #whereClause: Canonical<SimpleWhereClause>;\n\n // Using base class minResultsToLoad instead of a private property\n #orderBy: Canonical<Record<string, \"asc\" | \"desc\" | undefined>>;\n #objectSet: ObjectSet<ObjectTypeDefinition>;\n\n /**\n * Register changes to the cache specific to ListQuery\n */\n protected registerCacheChanges(batch: BatchContext): void {\n batch.changes.registerList(this.cacheKey);\n }\n\n constructor(\n store: Store,\n subject: Observable<SubjectPayload<ListCacheKey>>,\n apiName: string,\n whereClause: Canonical<SimpleWhereClause>,\n orderBy: Canonical<Record<string, \"asc\" | \"desc\" | undefined>>,\n cacheKey: ListCacheKey,\n opts: ListQueryOptions,\n ) {\n super(\n store,\n subject,\n opts,\n cacheKey,\n process.env.NODE_ENV !== \"production\"\n ? (\n store.client[additionalContext].logger?.child({}, {\n msgPrefix: `ListQuery<${\n cacheKey.otherKeys.map(x => JSON.stringify(x)).join(\", \")\n }>`,\n })\n )\n : undefined,\n );\n\n this.apiName = apiName;\n this.#whereClause = whereClause;\n this.#orderBy = orderBy;\n this.#objectSet = this.createObjectSet(store);\n // Initialize the sorting strategy\n this.sortingStrategy = new OrderBySortingStrategy(\n this.apiName,\n this.#orderBy,\n );\n // Initialize the minResultsToLoad inherited from BaseCollectionQuery\n this.minResultsToLoad = 0;\n }\n\n get canonicalWhere(): Canonical<SimpleWhereClause> {\n return this.#whereClause;\n }\n\n /**\n * Create the ObjectSet for this query.\n */\n protected abstract createObjectSet(\n store: Store,\n ): ObjectSet<ObjectTypeDefinition>;\n\n /**\n * Implements fetchPageData from BaseCollectionQuery template method\n * Fetches a page of data\n */\n protected async fetchPageData(\n signal: AbortSignal | undefined,\n ): Promise<PageResult<Osdk.Instance<any>>> {\n // Fetch the data with pagination\n const resp = await this.#objectSet.fetchPage({\n $nextPageToken: this.nextPageToken,\n $pageSize: this.options.pageSize,\n // For now this keeps the shared test code from falling apart\n // but shouldn't be needed ideally\n ...(Object.keys(this.#orderBy).length > 0\n ? { $orderBy: this.#orderBy }\n : {}),\n });\n\n if (signal?.aborted) {\n throw new Error(\"Aborted\");\n }\n\n this.nextPageToken = resp.nextPageToken;\n const fetchedData = await this.postProcessFetchedData(resp.data);\n\n return {\n ...resp,\n data: fetchedData,\n };\n }\n\n /**\n * Handle fetch errors by setting appropriate error state and notifying subscribers\n */\n protected handleFetchError(\n error: unknown,\n _status: Status,\n batch: BatchContext,\n ): Entry<ListCacheKey> {\n this.logger?.error(\"error\", error);\n this.store.subjects.get(this.cacheKey).error(error);\n\n // We don't call super.handleFetchError because ListQuery has special error handling\n // but we still use writeToStore to create a properly structured Entry\n return this.writeToStore({ data: [] }, \"error\", batch);\n }\n\n /**\n * Will revalidate the list if its query is affected by invalidating the\n * apiName of the object type passed in.\n *\n * @param apiName to invalidate\n * @returns\n */\n abstract revalidateObjectType(apiName: string): Promise<void>;\n\n /**\n * Postprocess fetched data.\n */\n protected abstract postProcessFetchedData(\n data: Osdk.Instance<any>[],\n ): Promise<Osdk.Instance<any>[]>;\n\n invalidateObjectType = async (\n objectType: string,\n changes: Changes | undefined,\n ): Promise<void> => {\n if (this.cacheKey.otherKeys[1] === objectType) {\n // Only invalidate lists for the matching apiName\n changes?.modified.add(this.cacheKey);\n return this.revalidate(true);\n }\n };\n\n /**\n * Note: This method is not async because I want it to return right after it\n * finishes the synchronous updates. The promise that is returned\n * will resolve after the revalidation is complete.\n * @param changes\n * @param optimisticId\n * @returns If revalidation is needed, a promise that resolves after the\n * revalidation is complete. Otherwise, undefined.\n */\n\n maybeUpdateAndRevalidate = (\n changes: Changes,\n optimisticId: OptimisticId | undefined,\n ): Promise<void> | undefined => {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child({ methodName: \"maybeUpdateAndRevalidate\" }).debug(\n DEBUG_ONLY__changesToString(changes),\n );\n this.logger?.child({ methodName: \"maybeUpdateAndRevalidate\" }).debug(\n `Already in changes? ${changes.modified.has(this.cacheKey)}`,\n );\n }\n\n if (changes.modified.has(this.cacheKey)) return;\n // mark ourselves as updated so we don't infinite recurse.\n changes.modified.add(this.cacheKey);\n\n try {\n const relevantObjects = this._extractAndCategorizeRelevantObjects(\n changes,\n );\n\n // If we got purely strict matches we can just update the list and move\n // on with our lives. But if we got sorta matches, then we need to revalidate\n // the list so we preemptively set it to loading to avoid thrashing the store.\n const status = optimisticId\n || relevantObjects.added.sortaMatches.size > 0\n || relevantObjects.modified.sortaMatches.size > 0\n ? \"loading\"\n : \"loaded\";\n\n // while we only push updates for the strict matches, we still need to\n // trigger the list updating if some of our objects changed\n\n const newList: Array<ObjectCacheKey> = [];\n\n let needsRevalidation = false;\n this.store.batch({ optimisticId, changes }, (batch) => {\n const existingList = new Set(\n batch.read(this.cacheKey)?.value?.data,\n );\n\n const toAdd = new Set<ObjectHolder | InterfaceHolder>(\n // easy case. objects are new to the cache and they match this filter\n relevantObjects.added.strictMatches,\n );\n\n // anything thats been deleted can be removed, so start there\n const toRemove = new Set<CacheKey>(changes.deleted);\n\n // deal with the modified objects\n for (const obj of relevantObjects.modified.all) {\n if (relevantObjects.modified.strictMatches.has(obj)) {\n const objectCacheKey = this.cacheKeys.get<ObjectCacheKey>(\n \"object\",\n obj.$objectType,\n obj.$primaryKey,\n );\n\n if (!existingList.has(objectCacheKey)) {\n // object is new to the list\n toAdd.add(obj);\n }\n continue;\n } else if (batch.optimisticWrite) {\n // we aren't removing objects in optimistic mode\n // we also don't want to trigger revalidation in optimistic mode\n // as it should be triggered when the optimistic job is done\n continue;\n } else {\n // object is no longer a strict match\n const existingObjectCacheKey = this.cacheKeys.get<ObjectCacheKey>(\n \"object\",\n obj.$objectType,\n obj.$primaryKey,\n );\n\n toRemove.add(existingObjectCacheKey);\n\n if (relevantObjects.modified.sortaMatches.has(obj)) {\n // since it might still be in the list we need to revalidate\n needsRevalidation = true;\n }\n }\n }\n\n for (const key of existingList) {\n if (toRemove.has(key)) continue;\n newList.push(key);\n }\n for (const obj of toAdd) {\n newList.push(\n this.cacheKeys.get<ObjectCacheKey>(\n \"object\",\n obj.$objectType,\n obj.$primaryKey,\n ),\n );\n }\n\n this._updateList(\n newList,\n status,\n batch,\n /* append */ false,\n );\n });\n\n if (needsRevalidation) {\n return this.revalidate(true);\n }\n return undefined;\n } finally {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child({ methodName: \"maybeUpdateAndRevalidate\" })\n .debug(\"in finally\");\n }\n }\n };\n\n #matchType(obj: ObjectHolder | InterfaceHolder): false | \"strict\" | \"sorta\" {\n // if its a strict match we can just insert it into place\n if (objectMatchesWhereClause(obj, this.#whereClause, true)) {\n return \"strict\";\n }\n // sorta match means it used a filter we cannot use on the frontend\n if (objectMatchesWhereClause(obj, this.#whereClause, false)) {\n return \"sorta\";\n }\n return false;\n }\n\n protected _extractAndCategorizeRelevantObjects(\n changes: Changes,\n ): ExtractRelevantObjectsResult {\n const relevantObjects = this.extractRelevantObjects(changes);\n\n // categorize\n for (const group of Object.values(relevantObjects)) {\n for (const obj of group.all ?? []) {\n const matchType = this.#matchType(obj);\n if (matchType) {\n group[`${matchType}Matches`].add(obj);\n }\n }\n }\n\n return relevantObjects;\n }\n\n /**\n * Extract relevant objects for this query type.\n */\n protected abstract extractRelevantObjects(\n changes: Changes,\n ): ExtractRelevantObjectsResult;\n\n registerStreamUpdates(sub: Subscription): void {\n const logger = process.env.NODE_ENV !== \"production\"\n ? this.logger?.child({ methodName: \"registerStreamUpdates\" })\n : this.logger;\n\n if (process.env.NODE_ENV !== \"production\") {\n logger?.child({ methodName: \"observeList\" }).info(\n \"Subscribing from websocket\",\n );\n }\n\n // FIXME: We should only do this once. If we already have one we should probably\n // just reuse it.\n\n const websocketSubscription = this.#objectSet.subscribe({\n onChange: this.onOswChange.bind(this),\n onError: this.onOswError.bind(this),\n onOutOfDate: this.onOswOutOfDate.bind(this),\n onSuccessfulSubscription: this.onOswSuccessfulSubscription.bind(this),\n });\n\n sub.add(() => {\n if (process.env.NODE_ENV !== \"production\") {\n logger?.child({ methodName: \"observeList\" }).info(\n \"Unsubscribing from websocket\",\n );\n }\n\n websocketSubscription.unsubscribe();\n });\n }\n\n protected onOswSuccessfulSubscription(): void {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child(\n { methodName: \"onSuccessfulSubscription\" },\n ).debug(\"\");\n }\n }\n\n protected onOswOutOfDate(): void {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child(\n { methodName: \"onOutOfDate\" },\n ).debug(\"\");\n }\n }\n\n protected onOswError(errors: {\n subscriptionClosed: boolean;\n error: any;\n }): void {\n if (this.logger) {\n this.logger?.child({ methodName: \"onError\" }).error(\n \"subscription errors\",\n errors,\n );\n }\n }\n\n protected onOswChange(\n { object: objOrIface, state }: ObjectUpdate<ObjectTypeDefinition, string>,\n ): void {\n const logger = process.env.NODE_ENV !== \"production\"\n ? this.logger?.child({ methodName: \"registerStreamUpdates\" })\n : this.logger;\n\n if (process.env.NODE_ENV !== \"production\") {\n logger?.child({ methodName: \"onChange\" }).debug(\n `Got an update of type: ${state}`,\n objOrIface,\n );\n }\n\n if (state === \"ADDED_OR_UPDATED\") {\n const object: ObjectHolder =\n (objOrIface.$apiName !== objOrIface.$objectType\n ? objOrIface.$as(objOrIface.$objectType)\n : objOrIface) as unknown as ObjectHolder;\n\n this.store.batch({}, (batch) => {\n this.store.objects.storeOsdkInstances(\n [object as Osdk.Instance<any>],\n batch,\n );\n });\n } else if (state === \"REMOVED\") {\n this.onOswRemoved(objOrIface, logger);\n }\n }\n\n protected onOswRemoved(\n objOrIface: Osdk.Instance<ObjectTypeDefinition, never, string, {}>,\n logger: Logger | undefined,\n ): void {\n this.store.batch({}, (batch) => {\n // Read the truth layer (since not optimistic)\n const existing = batch.read(this.cacheKey);\n invariant(\n existing,\n \"the truth value for our list should exist as we already subscribed\",\n );\n if (existing.status === \"loaded\") {\n const objectCacheKey = this.cacheKeys.get<ObjectCacheKey>(\n \"object\",\n objOrIface.$objectType,\n objOrIface.$primaryKey,\n );\n // remove the object from the list\n const newObjects = existing.value?.data.filter(\n (o) => o !== objectCacheKey,\n );\n\n // If the filter didn't change anything, then the list was already\n // updated (or didn't exist, which is nonsensical)\n if (newObjects?.length !== existing.value?.data.length) {\n batch.changes.registerList(this.cacheKey);\n batch.write(\n this.cacheKey,\n { data: newObjects ?? [] },\n \"loaded\",\n );\n // Should there be an else for this case? Do we need to invalidate\n // the paging tokens we may have? FIXME\n }\n\n return;\n }\n // There may be a tiny race here where OSW tells us the object has\n // been removed but an outstanding invalidation of this query is\n // about to return. In this case, its possible that we remove this item\n // from the list and then the returned list load re-adds it.\n // To avoid this, we will just force reload the query to be sure\n // we don't leave things in a bad state.\n if (process.env.NODE_ENV !== \"production\") {\n logger?.info(\n \"Removing an object from an object list that is in the middle of being loaded.\",\n existing,\n );\n }\n\n this.revalidate(/* force */ true).catch((e: unknown) => {\n if (logger) {\n logger?.error(\"Uncaught error while revalidating list\", e);\n } else {\n // Make sure we write to the console if there is no logger!\n // eslint-disable-next-line no-console\n console.error(\"Uncaught error while revalidating list\", e);\n }\n });\n });\n }\n}\n\nexport function isListCacheKey(\n cacheKey: CacheKey,\n): cacheKey is ListCacheKey {\n return cacheKey.type === \"list\";\n}\n\n/**\n * Copied from @osdk/api\n */\ntype ObjectUpdate<\n O extends ObjectOrInterfaceDefinition,\n P extends PropertyKeys<O>,\n> = {\n object: Osdk.Instance<O, never, P>;\n state: \"ADDED_OR_UPDATED\" | \"REMOVED\";\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,iBAAiB,QAAQ,oBAAoB;AAOtD,SAASC,aAAa,QAAQ,+BAA+B;AAI7D,SAAuBC,2BAA2B,QAAQ,eAAe;AAGzE,SAASC,6BAA6B,IAAIC,wBAAwB,QAAQ,gCAAgC;AAG1G,SAASC,sBAAsB,QAAQ,+BAA+B;AAMtE,OAAO,MAAMC,YAAY,GAAG,CAAC;AAC7B,OAAO,MAAMC,QAAQ,GAAG,CAAC;AACzB,OAAO,MAAMC,SAAS,GAAG,CAAC;AAC1B,OAAO,MAAMC,YAAY,GAAG,CAAC;AAQ7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAeC,SAAS,SAAST,aAAa,CAInD;EACA;;EAGA,CAACU,WAAW;;EAEZ;EACA,CAACC,OAAO;EACR,CAACC,SAAS;;EAEV;AACF;AACA;EACYC,oBAAoBA,CAACC,KAAmB,EAAQ;IACxDA,KAAK,CAACC,OAAO,CAACC,YAAY,CAAC,IAAI,CAACC,QAAQ,CAAC;EAC3C;EAEAC,WAAWA,CACTC,KAAY,EACZC,OAAiD,EACjDC,OAAe,EACfX,WAAyC,EACzCC,OAA8D,EAC9DM,QAAsB,EACtBK,IAAsB,EACtB;IACA,KAAK,CACHH,KAAK,EACLC,OAAO,EACPE,IAAI,EACJL,QAAQ,EACRM,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GAEjCN,KAAK,CAACO,MAAM,CAAC3B,iBAAiB,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KAAK,CAAC,wCAAwC,EAAE6E,CAAC,CAAC;QAC5D,CAAC,MAAM;UACL;UACA;UACAC,OAAO,CAAC9E,KAAK,CAAC,wCAAwC,EAAE6E,CAAC,CAAC;QAC5D;MACF,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;AACF;AAEA,OAAO,SAASE,cAAcA,CAC5B1H,QAAkB,EACQ;EAC1B,OAAOA,QAAQ,CAAC2H,IAAI,KAAK,MAAM;AACjC;;AAEA;AACA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListQueryOptions.js","names":[],"sources":["ListQueryOptions.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 { CommonObserveOptions } from \"../../ObservableClient/common.js\";\n\nexport interface ListQueryOptions extends CommonObserveOptions {\n pageSize?: number;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,51 @@
|
|
|
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 { AbstractHelper } from "../AbstractHelper.js";
|
|
18
|
+
import { InterfaceListQuery } from "./InterfaceListQuery.js";
|
|
19
|
+
import { ObjectListQuery } from "./ObjectListQuery.js";
|
|
20
|
+
export class ListsHelper extends AbstractHelper {
|
|
21
|
+
constructor(store, cacheKeys, whereCanonicalizer, orderByCanonicalizer) {
|
|
22
|
+
super(store, cacheKeys);
|
|
23
|
+
this.whereCanonicalizer = whereCanonicalizer;
|
|
24
|
+
this.orderByCanonicalizer = orderByCanonicalizer;
|
|
25
|
+
}
|
|
26
|
+
observe(options, subFn) {
|
|
27
|
+
const ret = super.observe(options, subFn);
|
|
28
|
+
if (options.streamUpdates) {
|
|
29
|
+
ret.query.registerStreamUpdates(ret.subscription);
|
|
30
|
+
}
|
|
31
|
+
return ret;
|
|
32
|
+
}
|
|
33
|
+
getQuery(options) {
|
|
34
|
+
const {
|
|
35
|
+
type: {
|
|
36
|
+
apiName,
|
|
37
|
+
type
|
|
38
|
+
},
|
|
39
|
+
where,
|
|
40
|
+
orderBy
|
|
41
|
+
} = options;
|
|
42
|
+
const canonWhere = this.whereCanonicalizer.canonicalize(where ?? {});
|
|
43
|
+
const canonOrderBy = this.orderByCanonicalizer.canonicalize(orderBy ?? {});
|
|
44
|
+
const listCacheKey = this.cacheKeys.get("list", type, apiName, canonWhere, canonOrderBy);
|
|
45
|
+
return this.store.queries.get(listCacheKey, () => {
|
|
46
|
+
const QueryClass = type === "object" ? ObjectListQuery : InterfaceListQuery;
|
|
47
|
+
return new QueryClass(this.store, this.store.subjects.get(listCacheKey), apiName, canonWhere, canonOrderBy, listCacheKey, options);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=ListsHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListsHelper.js","names":["AbstractHelper","InterfaceListQuery","ObjectListQuery","ListsHelper","constructor","store","cacheKeys","whereCanonicalizer","orderByCanonicalizer","observe","options","subFn","ret","streamUpdates","query","registerStreamUpdates","subscription","getQuery","type","apiName","where","orderBy","canonWhere","canonicalize","canonOrderBy","listCacheKey","get","queries","QueryClass","subjects"],"sources":["ListsHelper.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 { InterfaceDefinition, ObjectTypeDefinition } from \"@osdk/api\";\nimport type { ListPayload } from \"../../ListPayload.js\";\nimport type { ObserveListOptions } from \"../../ObservableClient.js\";\nimport type { Observer } from \"../../ObservableClient/common.js\";\nimport { AbstractHelper } from \"../AbstractHelper.js\";\nimport type { CacheKeys } from \"../CacheKeys.js\";\nimport type { KnownCacheKey } from \"../KnownCacheKey.js\";\nimport type { OrderByCanonicalizer } from \"../OrderByCanonicalizer.js\";\nimport type { QuerySubscription } from \"../QuerySubscription.js\";\nimport type { Store } from \"../Store.js\";\nimport type { WhereClauseCanonicalizer } from \"../WhereClauseCanonicalizer.js\";\nimport { InterfaceListQuery } from \"./InterfaceListQuery.js\";\nimport type { ListCacheKey } from \"./ListCacheKey.js\";\nimport type { ListQuery } from \"./ListQuery.js\";\nimport { ObjectListQuery } from \"./ObjectListQuery.js\";\n\nexport class ListsHelper extends AbstractHelper<\n ListQuery,\n ObserveListOptions<ObjectTypeDefinition | InterfaceDefinition>\n> {\n whereCanonicalizer: WhereClauseCanonicalizer;\n orderByCanonicalizer: OrderByCanonicalizer;\n\n constructor(\n store: Store,\n cacheKeys: CacheKeys<KnownCacheKey>,\n whereCanonicalizer: WhereClauseCanonicalizer,\n orderByCanonicalizer: OrderByCanonicalizer,\n ) {\n super(store, cacheKeys);\n\n this.whereCanonicalizer = whereCanonicalizer;\n this.orderByCanonicalizer = orderByCanonicalizer;\n }\n\n observe<T extends ObjectTypeDefinition | InterfaceDefinition>(\n options: ObserveListOptions<T>,\n subFn: Observer<ListPayload>,\n ): QuerySubscription<ListQuery> {\n const ret = super.observe(options, subFn);\n\n if (options.streamUpdates) {\n ret.query.registerStreamUpdates(ret.subscription);\n }\n return ret;\n }\n\n getQuery<T extends ObjectTypeDefinition | InterfaceDefinition>(\n options: ObserveListOptions<T>,\n ): ListQuery {\n const { type: { apiName, type }, where, orderBy } = options;\n\n const canonWhere = this.whereCanonicalizer.canonicalize(where ?? {});\n const canonOrderBy = this.orderByCanonicalizer.canonicalize(orderBy ?? {});\n const listCacheKey = this.cacheKeys.get<ListCacheKey>(\n \"list\",\n type,\n apiName,\n canonWhere,\n canonOrderBy,\n );\n\n return this.store.queries.get(listCacheKey, () => {\n const QueryClass = type === \"object\"\n ? ObjectListQuery\n : InterfaceListQuery;\n return new QueryClass(\n this.store,\n this.store.subjects.get(listCacheKey),\n apiName,\n canonWhere,\n canonOrderBy,\n listCacheKey,\n options,\n );\n });\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,SAASA,cAAc,QAAQ,sBAAsB;AAOrD,SAASC,kBAAkB,QAAQ,yBAAyB;AAG5D,SAASC,eAAe,QAAQ,sBAAsB;AAEtD,OAAO,MAAMC,WAAW,SAASH,cAAc,CAG7C;EAIAI,WAAWA,CACTC,KAAY,EACZC,SAAmC,EACnCC,kBAA4C,EAC5CC,oBAA0C,EAC1C;IACA,KAAK,CAACH,KAAK,EAAEC,SAAS,CAAC;IAEvB,IAAI,CAACC,kBAAkB,GAAGA,kBA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. 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 { API_NAME_IDX, ListQuery } from "./ListQuery.js";
|
|
18
|
+
export class ObjectListQuery extends ListQuery {
|
|
19
|
+
createObjectSet(store) {
|
|
20
|
+
return store.client({
|
|
21
|
+
type: "object",
|
|
22
|
+
apiName: this.apiName
|
|
23
|
+
}).where(this.canonicalWhere);
|
|
24
|
+
}
|
|
25
|
+
async revalidateObjectType(apiName) {
|
|
26
|
+
if (this.apiName === apiName) {
|
|
27
|
+
await this.revalidate(/* force */true);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
postProcessFetchedData(data) {
|
|
31
|
+
return Promise.resolve(data);
|
|
32
|
+
}
|
|
33
|
+
extractRelevantObjects(changes) {
|
|
34
|
+
return {
|
|
35
|
+
added: {
|
|
36
|
+
all: changes.addedObjects.get(this.cacheKey.otherKeys[API_NAME_IDX]) ?? [],
|
|
37
|
+
strictMatches: new Set(),
|
|
38
|
+
sortaMatches: new Set()
|
|
39
|
+
},
|
|
40
|
+
modified: {
|
|
41
|
+
all: changes.modifiedObjects.get(this.cacheKey.otherKeys[API_NAME_IDX]) ?? [],
|
|
42
|
+
strictMatches: new Set(),
|
|
43
|
+
sortaMatches: new Set()
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=ObjectListQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectListQuery.js","names":["API_NAME_IDX","ListQuery","ObjectListQuery","createObjectSet","store","client","type","apiName","where","canonicalWhere","revalidateObjectType","revalidate","postProcessFetchedData","data","Promise","resolve","extractRelevantObjects","changes","added","all","addedObjects","get","cacheKey","otherKeys","strictMatches","Set","sortaMatches","modified","modifiedObjects"],"sources":["ObjectListQuery.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 { ObjectSet, ObjectTypeDefinition, Osdk } from \"@osdk/api\";\nimport type { InterfaceHolder } from \"../../../object/convertWireToOsdkObjects/InterfaceHolder.js\";\nimport type { ObjectHolder } from \"../../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { Changes } from \"../Changes.js\";\nimport type { Store } from \"../Store.js\";\nimport { API_NAME_IDX, ListQuery } from \"./ListQuery.js\";\n\ntype ExtractRelevantObjectsResult = Record<\"added\" | \"modified\", {\n all: (ObjectHolder | InterfaceHolder)[];\n strictMatches: Set<(ObjectHolder | InterfaceHolder)>;\n sortaMatches: Set<(ObjectHolder | InterfaceHolder)>;\n}>;\n\nexport class ObjectListQuery extends ListQuery {\n protected createObjectSet(store: Store): ObjectSet<ObjectTypeDefinition> {\n return store.client({\n type: \"object\",\n apiName: this.apiName,\n } as ObjectTypeDefinition)\n .where(this.canonicalWhere);\n }\n\n async revalidateObjectType(apiName: string): Promise<void> {\n if (this.apiName === apiName) {\n await this.revalidate(/* force */ true);\n }\n }\n\n protected postProcessFetchedData(\n data: Osdk.Instance<any>[],\n ): Promise<Osdk.Instance<any>[]> {\n return Promise.resolve(data);\n }\n\n protected extractRelevantObjects(\n changes: Changes,\n ): ExtractRelevantObjectsResult {\n return {\n added: {\n all: changes.addedObjects.get(this.cacheKey.otherKeys[API_NAME_IDX])\n ?? [],\n strictMatches: new Set(),\n sortaMatches: new Set(),\n },\n modified: {\n all: changes.modifiedObjects.get(this.cacheKey.otherKeys[API_NAME_IDX])\n ?? [],\n strictMatches: new Set(),\n sortaMatches: new Set(),\n },\n };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,SAASA,YAAY,EAAEC,SAAS,QAAQ,gBAAgB;AAQxD,OAAO,MAAMC,eAAe,SAASD,SAAS,CAAC;EACnCE,eAAeA,CAACC,KAAY,EAAmC;IACvE,OAAOA,KAAK,CAACC,MAAM,CAAC;MAClBC,IAAI,EAAE,QAAQ;MACdC,OAAO,EAAE,IAAI,CAACA;IAChB,CAAyB,CAAC,CACvBC,KAAK,CAAC,IAAI,CAACC,cAAc,CAAC;EAC/B;EAEA,MAAMC,oBAAoBA,CAACH,OAAe,EAAiB;IACzD,IAAI,IAAI,CAACA,OAAO,KAAKA,OAAO,EAAE;MAC5B,MAAM,IAAI,CAACI,UAAU,CAAC,WAAY,IAAI,CAAC;IACzC;EACF;EAEUC,sBAAsBA,CAC9BC,IAA0B,EACK;IAC/B,OAAOC,OAAO,CAACC,OAAO,CAACF,IAAI,CAAC;EAC9B;EAEUG,sBAAsBA,CAC9BC,OAAgB,EACc;IAC9B,OAAO;MACLC,KAAK,EAAE;QACLC,GAAG,EAAEF,OAAO,CAACG,YAAY,CAACC,GAAG,CAAC,IAAI,CAACC,QAAQ,CAACC,SAAS,CAACvB,YAAY,CAAC,CAAC,IAC/D,EAAE;QACPwB,aAAa,EAAE,IAAIC,GAAG,CAAC,CAAC;QACxBC,YAAY,EAAE,IAAID,GAAG,CAAC;MACxB,CAAC;MACDE,QAAQ,EAAE;QACRR,GAAG,EAAEF,OAAO,CAACW,eAAe,CAACP,GAAG,CAAC,IAAI,CAACC,QAAQ,CAACC,SAAS,CAACvB,YAAY,CAAC,CAAC,IAClE,EAAE;QACPwB,aAAa,EAAE,IAAIC,GAAG,CAAC,CAAC;QACxBC,YAAY,EAAE,IAAID,GAAG,CAAC;MACxB;IACF,CAAC;EACH;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectCacheKey.js","names":[],"sources":["ObjectCacheKey.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 { ObjectTypeDefinition, PrimaryKeyType } from \"@osdk/api\";\nimport type { ObjectHolder } from \"../../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { CacheKey } from \"../CacheKey.js\";\nimport type { ObjectQuery } from \"./ObjectQuery.js\";\n\nexport interface ObjectCacheKey extends\n CacheKey<\n \"object\",\n ObjectHolder,\n ObjectQuery,\n [string, pk: PrimaryKeyType<ObjectTypeDefinition>]\n >\n{\n}\n"],"mappings":"","ignoreList":[]}
|