@osdk/client 2.5.0-beta.1 → 2.5.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/build/browser/Client.js +1 -1
- package/build/browser/Client.js.map +1 -1
- package/build/browser/createClient.js +4 -1
- package/build/browser/createClient.js.map +1 -1
- package/build/browser/fetchMetadata.test.js +11 -0
- package/build/browser/fetchMetadata.test.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/SimpleCache.js +1 -1
- package/build/browser/object/SimpleCache.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 +12 -0
- package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/browser/object/fetchPage.js +30 -4
- package/build/browser/object/fetchPage.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/objectSet/ObjectSet.test.js +6 -0
- package/build/browser/objectSet/ObjectSet.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 +50 -0
- package/build/browser/observable/internal/AbstractHelper.js.map +1 -0
- package/build/browser/observable/internal/BaseCollectionQuery.js +2 -0
- package/build/browser/observable/internal/BaseCollectionQuery.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 +17 -2
- 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.map +1 -1
- package/build/browser/observable/internal/ListCacheKey.js +2 -0
- package/build/browser/observable/internal/ListCacheKey.js.map +1 -0
- package/build/browser/observable/internal/ListQuery.js +399 -161
- package/build/browser/observable/internal/ListQuery.js.map +1 -1
- package/build/browser/observable/internal/ObjectQuery.js +27 -2
- package/build/browser/observable/internal/ObjectQuery.js.map +1 -1
- package/build/browser/observable/internal/ObservableClientImpl.js +42 -2
- package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/browser/observable/internal/OptimisticJob.js +12 -3
- package/build/browser/observable/internal/OptimisticJob.js.map +1 -1
- package/build/browser/observable/internal/Query.js +17 -3
- package/build/browser/observable/internal/Query.js.map +1 -1
- package/build/browser/observable/internal/QuerySubscription.js +41 -0
- package/build/browser/observable/internal/QuerySubscription.js.map +1 -0
- package/build/browser/observable/internal/Store.invalidation.test.js +481 -0
- package/build/browser/observable/internal/Store.invalidation.test.js.map +1 -0
- package/build/browser/observable/internal/Store.js +38 -91
- package/build/browser/observable/internal/Store.js.map +1 -1
- package/build/browser/observable/internal/Store.test.js +318 -63
- package/build/browser/observable/internal/Store.test.js.map +1 -1
- package/build/browser/observable/internal/UnsubscribableWrapper.js +30 -0
- package/build/browser/observable/internal/UnsubscribableWrapper.js.map +1 -0
- package/build/browser/observable/internal/createCollectionConnectable.js +50 -0
- package/build/browser/observable/internal/createCollectionConnectable.js.map +1 -0
- package/build/browser/observable/internal/createCollectionConnectable.test.js +599 -0
- package/build/browser/observable/internal/createCollectionConnectable.test.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/ListsHelper.js +49 -0
- package/build/browser/observable/internal/list/ListsHelper.js.map +1 -0
- package/build/browser/observable/internal/object/ObjectsHelper.js +34 -0
- package/build/browser/observable/internal/object/ObjectsHelper.js.map +1 -0
- package/build/browser/observable/internal/removeDuplicates.js +36 -0
- package/build/browser/observable/internal/removeDuplicates.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 +70 -7
- package/build/browser/observable/internal/testUtils.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/streamutils.js +1 -1
- package/build/browser/util/streamutils.js.map +1 -1
- package/build/cjs/{chunk-URDXPIRU.cjs → chunk-AOGMSVFN.cjs} +61 -54
- package/build/cjs/chunk-AOGMSVFN.cjs.map +1 -0
- package/build/cjs/{chunk-BJYCRD5Y.cjs → chunk-BL56QBYG.cjs} +44 -19
- package/build/cjs/chunk-BL56QBYG.cjs.map +1 -0
- package/build/cjs/index.cjs +7 -7
- package/build/cjs/public/internal.cjs +8 -8
- package/build/cjs/public/unstable-do-not-use.cjs +779 -268
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +161 -12
- package/build/esm/Client.js +1 -1
- package/build/esm/Client.js.map +1 -1
- package/build/esm/createClient.js +4 -1
- package/build/esm/createClient.js.map +1 -1
- package/build/esm/fetchMetadata.test.js +11 -0
- package/build/esm/fetchMetadata.test.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/SimpleCache.js +1 -1
- package/build/esm/object/SimpleCache.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 +12 -0
- package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/esm/object/fetchPage.js +30 -4
- package/build/esm/object/fetchPage.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/objectSet/ObjectSet.test.js +6 -0
- package/build/esm/objectSet/ObjectSet.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 +50 -0
- package/build/esm/observable/internal/AbstractHelper.js.map +1 -0
- package/build/esm/observable/internal/BaseCollectionQuery.js +2 -0
- package/build/esm/observable/internal/BaseCollectionQuery.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 +17 -2
- 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.map +1 -1
- package/build/esm/observable/internal/ListCacheKey.js +2 -0
- package/build/esm/observable/internal/ListCacheKey.js.map +1 -0
- package/build/esm/observable/internal/ListQuery.js +399 -161
- package/build/esm/observable/internal/ListQuery.js.map +1 -1
- package/build/esm/observable/internal/ObjectQuery.js +27 -2
- package/build/esm/observable/internal/ObjectQuery.js.map +1 -1
- package/build/esm/observable/internal/ObservableClientImpl.js +42 -2
- package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/esm/observable/internal/OptimisticJob.js +12 -3
- package/build/esm/observable/internal/OptimisticJob.js.map +1 -1
- package/build/esm/observable/internal/Query.js +17 -3
- package/build/esm/observable/internal/Query.js.map +1 -1
- package/build/esm/observable/internal/QuerySubscription.js +41 -0
- package/build/esm/observable/internal/QuerySubscription.js.map +1 -0
- package/build/esm/observable/internal/Store.invalidation.test.js +481 -0
- package/build/esm/observable/internal/Store.invalidation.test.js.map +1 -0
- package/build/esm/observable/internal/Store.js +38 -91
- package/build/esm/observable/internal/Store.js.map +1 -1
- package/build/esm/observable/internal/Store.test.js +318 -63
- package/build/esm/observable/internal/Store.test.js.map +1 -1
- package/build/esm/observable/internal/UnsubscribableWrapper.js +30 -0
- package/build/esm/observable/internal/UnsubscribableWrapper.js.map +1 -0
- package/build/esm/observable/internal/createCollectionConnectable.js +50 -0
- package/build/esm/observable/internal/createCollectionConnectable.js.map +1 -0
- package/build/esm/observable/internal/createCollectionConnectable.test.js +599 -0
- package/build/esm/observable/internal/createCollectionConnectable.test.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/ListsHelper.js +49 -0
- package/build/esm/observable/internal/list/ListsHelper.js.map +1 -0
- package/build/esm/observable/internal/object/ObjectsHelper.js +34 -0
- package/build/esm/observable/internal/object/ObjectsHelper.js.map +1 -0
- package/build/esm/observable/internal/removeDuplicates.js +36 -0
- package/build/esm/observable/internal/removeDuplicates.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 +70 -7
- package/build/esm/observable/internal/testUtils.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/streamutils.js +1 -1
- package/build/esm/util/streamutils.js.map +1 -1
- package/build/types/Client.d.ts +1 -1
- package/build/types/createClient.d.ts.map +1 -1
- package/build/types/object/fetchPage.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 +82 -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 +15 -0
- package/build/types/observable/internal/AbstractHelper.d.ts.map +1 -0
- package/build/types/observable/internal/BaseCollectionQuery.d.ts +64 -0
- package/build/types/observable/internal/BaseCollectionQuery.d.ts.map +1 -0
- package/build/types/observable/internal/BulkObjectLoader.d.ts.map +1 -1
- package/build/types/observable/internal/CacheKeys.d.ts +10 -4
- package/build/types/observable/internal/CacheKeys.d.ts.map +1 -1
- package/build/types/observable/internal/Changes.d.ts +7 -4
- 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 +7 -7
- package/build/types/observable/internal/Layer.d.ts.map +1 -1
- package/build/types/observable/internal/ListCacheKey.d.ts +7 -0
- package/build/types/observable/internal/ListCacheKey.d.ts.map +1 -0
- package/build/types/observable/internal/ListQuery.d.ts +160 -21
- package/build/types/observable/internal/ListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/ObjectQuery.d.ts +3 -1
- package/build/types/observable/internal/ObjectQuery.d.ts.map +1 -1
- package/build/types/observable/internal/OptimisticJob.d.ts.map +1 -1
- package/build/types/observable/internal/Query.d.ts +6 -5
- 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 +34 -31
- 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/UnsubscribableWrapper.d.ts +1 -0
- package/build/types/observable/internal/UnsubscribableWrapper.d.ts.map +1 -0
- package/build/types/observable/internal/createCollectionConnectable.d.ts +38 -0
- package/build/types/observable/internal/createCollectionConnectable.d.ts.map +1 -0
- package/build/types/observable/internal/createCollectionConnectable.test.d.ts +1 -0
- package/build/types/observable/internal/createCollectionConnectable.test.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 +29 -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 +45 -0
- package/build/types/observable/internal/links/SpecificLinkQuery.d.ts.map +1 -0
- package/build/types/observable/internal/list/ListsHelper.d.ts +17 -0
- package/build/types/observable/internal/list/ListsHelper.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/removeDuplicates.d.ts +11 -0
- package/build/types/observable/internal/removeDuplicates.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 +25 -3
- 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/package.json +10 -10
- package/build/cjs/chunk-BJYCRD5Y.cjs.map +0 -1
- package/build/cjs/chunk-URDXPIRU.cjs.map +0 -1
|
@@ -0,0 +1,185 @@
|
|
|
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 deepEqual from "fast-deep-equal";
|
|
18
|
+
import { additionalContext } from "../../../Client.js";
|
|
19
|
+
import { BaseListQuery } from "../ListQuery.js";
|
|
20
|
+
import { OrderBySortingStrategy } from "../sorting/SortingStrategy.js";
|
|
21
|
+
import { tombstone } from "../tombstone.js";
|
|
22
|
+
/**
|
|
23
|
+
* Query implementation for retrieving linked objects from a specific object.
|
|
24
|
+
* - Stores links as ObjectCacheKey[] references
|
|
25
|
+
* - Creates indirect dependencies on linked objects
|
|
26
|
+
* - Supports filtering and sorting of linked collections
|
|
27
|
+
* - Handles proper invalidation of related objects
|
|
28
|
+
*/
|
|
29
|
+
export class SpecificLinkQuery extends BaseListQuery {
|
|
30
|
+
#sourceApiName;
|
|
31
|
+
#sourcePk;
|
|
32
|
+
#linkName;
|
|
33
|
+
#whereClause;
|
|
34
|
+
#orderBy;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Register changes to the cache specific to SpecificLinkQuery
|
|
38
|
+
*/
|
|
39
|
+
registerCacheChanges(batch) {
|
|
40
|
+
batch.changes.modified.add(this.cacheKey);
|
|
41
|
+
}
|
|
42
|
+
constructor(store, subject, cacheKey, opts) {
|
|
43
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[additionalContext].logger?.child({}, {
|
|
44
|
+
msgPrefix: `SpecificLinkQuery<${cacheKey.otherKeys.map(x => JSON.stringify(x)).join(", ")}>`
|
|
45
|
+
}) : undefined);
|
|
46
|
+
|
|
47
|
+
// Extract the necessary parameters from the cache key
|
|
48
|
+
[this.#sourceApiName, this.#sourcePk, this.#linkName, this.#whereClause, this.#orderBy] = cacheKey.otherKeys;
|
|
49
|
+
this.sortingStrategy = new OrderBySortingStrategy(this.#linkName, this.#orderBy);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// _fetchAndStore is now implemented in BaseCollectionQuery
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Implements fetchPageData from the BaseCollectionQuery template method pattern
|
|
56
|
+
* Fetches a page of linked objects
|
|
57
|
+
*/
|
|
58
|
+
async fetchPageData(signal) {
|
|
59
|
+
// Use the client API to create a query that pivots to linked objects
|
|
60
|
+
const client = this.store.client;
|
|
61
|
+
|
|
62
|
+
// First, get metadata for the source object to know the primary key field name
|
|
63
|
+
const sourceObjectDef = {
|
|
64
|
+
type: "object",
|
|
65
|
+
apiName: this.#sourceApiName
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// Use the client's ontologyProvider to get metadata, which has built-in caching
|
|
69
|
+
const sourceMetadata = await client[additionalContext].ontologyProvider.getObjectDefinition(this.#sourceApiName);
|
|
70
|
+
|
|
71
|
+
// Query for the specific source object
|
|
72
|
+
const sourceQuery = client(sourceObjectDef).where({
|
|
73
|
+
[sourceMetadata.primaryKeyApiName]: this.#sourcePk
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Pivot to the linked objects
|
|
77
|
+
const linkQuery = sourceQuery.pivotTo(this.#linkName);
|
|
78
|
+
|
|
79
|
+
// Check for abort signal again before fetching
|
|
80
|
+
if (signal?.aborted) {
|
|
81
|
+
throw new Error("Aborted");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Fetch the linked objects with pagination
|
|
85
|
+
// Add orderBy to the query parameters if specified
|
|
86
|
+
const queryParams = {
|
|
87
|
+
$pageSize: this.options.pageSize || 100,
|
|
88
|
+
$nextPageToken: this.nextPageToken
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// Include orderBy if it has entries
|
|
92
|
+
if (this.#orderBy && Object.keys(this.#orderBy).length > 0) {
|
|
93
|
+
queryParams.$orderBy = this.#orderBy;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Include whereClause if it has entries
|
|
97
|
+
if (this.#whereClause && Object.keys(this.#whereClause).length > 0) {
|
|
98
|
+
queryParams.$where = this.#whereClause;
|
|
99
|
+
}
|
|
100
|
+
const response = await linkQuery.fetchPage(queryParams);
|
|
101
|
+
|
|
102
|
+
// Store the next page token for pagination
|
|
103
|
+
this.nextPageToken = response.nextPageToken;
|
|
104
|
+
return response;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Removes a link query from the store
|
|
109
|
+
*/
|
|
110
|
+
deleteFromStore(status, batch) {
|
|
111
|
+
const entry = batch.read(this.cacheKey);
|
|
112
|
+
if (entry && deepEqual(tombstone, entry.value)) {
|
|
113
|
+
if (process.env.NODE_ENV !== "production") {
|
|
114
|
+
this.logger?.child({
|
|
115
|
+
methodName: "deleteFromStore"
|
|
116
|
+
}).debug(`Links were already deleted, just setting status`);
|
|
117
|
+
}
|
|
118
|
+
return batch.write(this.cacheKey, entry.value, status);
|
|
119
|
+
}
|
|
120
|
+
if (process.env.NODE_ENV !== "production") {
|
|
121
|
+
this.logger?.child({
|
|
122
|
+
methodName: "deleteFromStore"
|
|
123
|
+
}).debug(JSON.stringify({
|
|
124
|
+
status
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// If there is no entry then there is nothing to do
|
|
129
|
+
if (!entry || !entry.value) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const ret = batch.delete(this.cacheKey, status);
|
|
133
|
+
batch.changes.deleted.add(this.cacheKey);
|
|
134
|
+
return ret;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Implements Query.maybeUpdateAndRevalidate to handle cache invalidation
|
|
139
|
+
*/
|
|
140
|
+
maybeUpdateAndRevalidate = async changes => {
|
|
141
|
+
// TODO: Implement proper invalidation logic for linked objects
|
|
142
|
+
// This would check if any of the linked objects have changed,
|
|
143
|
+
// or if the source object's links might have changed
|
|
144
|
+
|
|
145
|
+
// For now, simply check if this specific link cache key was modified
|
|
146
|
+
if (changes.modified.has(this.cacheKey)) {
|
|
147
|
+
return this.revalidate(true);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// No relevant changes were detected
|
|
151
|
+
return Promise.resolve();
|
|
152
|
+
};
|
|
153
|
+
invalidateObjectType = (objectType, changes) => {
|
|
154
|
+
// We need to invalidate links in two cases:
|
|
155
|
+
// 1. When the source object type matches the apiName (direct invalidation)
|
|
156
|
+
// 2. When the target object type might be the invalidated type (affected by target changes)
|
|
157
|
+
|
|
158
|
+
// For case 1 - direct source object type match
|
|
159
|
+
if (this.#sourceApiName === objectType) {
|
|
160
|
+
changes?.modified.add(this.cacheKey);
|
|
161
|
+
return this.revalidate(true);
|
|
162
|
+
} else {
|
|
163
|
+
// For case 2 - check if the link's target type matches the invalidated type
|
|
164
|
+
// We need to use the ontology provider to get the link metadata
|
|
165
|
+
// Since this is async, we'll collect all the metadata check promises
|
|
166
|
+
return (async () => {
|
|
167
|
+
// Get the source object metadata to determine link target type
|
|
168
|
+
const sourceMetadata = await this.store.client[additionalContext].ontologyProvider.getObjectDefinition(this.#sourceApiName);
|
|
169
|
+
const linkDef = sourceMetadata.links?.[this.#linkName];
|
|
170
|
+
if (!linkDef || linkDef.targetType !== objectType) return;
|
|
171
|
+
const promise = this.revalidate(true);
|
|
172
|
+
changes?.modified.add(this.cacheKey);
|
|
173
|
+
return promise;
|
|
174
|
+
})();
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Type guard to check if a cache key is a SpecificLinkCacheKey
|
|
181
|
+
*/
|
|
182
|
+
export function isSpecificLinkCacheKey(key) {
|
|
183
|
+
return key.type === "specificLink";
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=SpecificLinkQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpecificLinkQuery.js","names":["deepEqual","additionalContext","BaseListQuery","OrderBySortingStrategy","tombstone","SpecificLinkQuery","sourceApiName","sourcePk","linkName","whereClause","orderBy","registerCacheChanges","batch","changes","modified","add","cacheKey","constructor","store","subject","opts","process","env","NODE_ENV","client","logger","child","msgPrefix","otherKeys","map","x","JSON","stringify","join","undefined","sortingStrategy","fetchPageData","signal","sourceObjectDef","type","apiName","sourceMetadata","ontologyProvider","getObjectDefinition","sourceQuery","where","primaryKeyApiName","linkQuery","pivotTo","aborted","Error","queryParams","$pageSize","options","pageSize","$nextPageToken","nextPageToken","Object","keys","length","$orderBy","$where","response","fetchPage","deleteFromStore","status","entry","read","value","methodName","debug","write","ret","delete","deleted","maybeUpdateAndRevalidate","has","revalidate","Promise","resolve","invalidateObjectType","objectType","linkDef","links","targetType","promise","isSpecificLinkCacheKey","key"],"sources":["SpecificLinkQuery.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 ObjectTypeDefinition,\n Osdk,\n PageResult,\n PrimaryKeyType,\n WhereClause,\n} from \"@osdk/api\";\nimport deepEqual from \"fast-deep-equal\";\nimport { type Subject } from \"rxjs\";\nimport { additionalContext } from \"../../../Client.js\";\nimport type { SpecificLinkPayload } from \"../../LinkPayload.js\";\nimport type { Status } from \"../../ObservableClient/common.js\";\nimport type { ObserveLinks } from \"../../ObservableClient/ObserveLink.js\";\nimport type { CacheKey } from \"../CacheKey.js\";\nimport type { Canonical } from \"../Canonical.js\";\nimport type { Changes } from \"../Changes.js\";\nimport type { Entry } from \"../Layer.js\";\nimport { BaseListQuery } from \"../ListQuery.js\";\nimport type { OptimisticId } from \"../OptimisticId.js\";\nimport type { SimpleWhereClause } from \"../SimpleWhereClause.js\";\nimport { OrderBySortingStrategy } from \"../sorting/SortingStrategy.js\";\nimport type { BatchContext, Store, SubjectPayload } from \"../Store.js\";\nimport { tombstone } from \"../tombstone.js\";\nimport type { SpecificLinkCacheKey } from \"./SpecificLinkCacheKey.js\";\n\n/**\n * Query implementation for retrieving linked objects from a specific object.\n * - Stores links as ObjectCacheKey[] references\n * - Creates indirect dependencies on linked objects\n * - Supports filtering and sorting of linked collections\n * - Handles proper invalidation of related objects\n */\nexport class SpecificLinkQuery extends BaseListQuery<\n SpecificLinkCacheKey,\n SpecificLinkPayload,\n ObserveLinks.Options<ObjectTypeDefinition, string>\n> {\n #sourceApiName: string;\n #sourcePk: PrimaryKeyType<ObjectTypeDefinition>;\n #linkName: string;\n #whereClause: Canonical<SimpleWhereClause>;\n #orderBy: Canonical<Record<string, \"asc\" | \"desc\" | undefined>>;\n\n /**\n * Register changes to the cache specific to SpecificLinkQuery\n */\n protected registerCacheChanges(batch: BatchContext): void {\n batch.changes.modified.add(this.cacheKey);\n }\n\n constructor(\n store: Store,\n subject: Subject<SubjectPayload<SpecificLinkCacheKey>>,\n cacheKey: SpecificLinkCacheKey,\n opts: ObserveLinks.Options<\n ObjectTypeDefinition,\n string\n >,\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: `SpecificLinkQuery<${\n cacheKey.otherKeys.map(x => JSON.stringify(x)).join(\", \")\n }>`,\n })\n )\n : undefined,\n );\n\n // Extract the necessary parameters from the cache key\n [\n this.#sourceApiName,\n this.#sourcePk,\n this.#linkName,\n this.#whereClause,\n this.#orderBy,\n ] = cacheKey.otherKeys;\n\n this.sortingStrategy = new OrderBySortingStrategy(\n this.#linkName,\n this.#orderBy,\n );\n }\n\n // _fetchAndStore is now implemented in BaseCollectionQuery\n\n /**\n * Implements fetchPageData from the BaseCollectionQuery template method pattern\n * Fetches a page of linked objects\n */\n protected async fetchPageData(\n signal: AbortSignal | undefined,\n ): Promise<PageResult<Osdk.Instance<any>>> {\n // Use the client API to create a query that pivots to linked objects\n const client = this.store.client;\n\n // First, get metadata for the source object to know the primary key field name\n const sourceObjectDef = {\n type: \"object\",\n apiName: this.#sourceApiName,\n } as ObjectTypeDefinition;\n\n // Use the client's ontologyProvider to get metadata, which has built-in caching\n const sourceMetadata = await client[additionalContext].ontologyProvider\n .getObjectDefinition(this.#sourceApiName);\n\n // Query for the specific source object\n const sourceQuery = client(sourceObjectDef).where({\n [sourceMetadata.primaryKeyApiName]: this.#sourcePk,\n } as WhereClause<any>);\n\n // Pivot to the linked objects\n const linkQuery = sourceQuery.pivotTo(this.#linkName);\n\n // Check for abort signal again before fetching\n if (signal?.aborted) {\n throw new Error(\"Aborted\");\n }\n\n // Fetch the linked objects with pagination\n // Add orderBy to the query parameters if specified\n const queryParams: any = {\n $pageSize: this.options.pageSize || 100,\n $nextPageToken: this.nextPageToken,\n };\n\n // Include orderBy if it has entries\n if (this.#orderBy && Object.keys(this.#orderBy).length > 0) {\n queryParams.$orderBy = this.#orderBy;\n }\n\n // Include whereClause if it has entries\n if (this.#whereClause && Object.keys(this.#whereClause).length > 0) {\n queryParams.$where = this.#whereClause;\n }\n\n const response = await linkQuery.fetchPage(queryParams);\n\n // Store the next page token for pagination\n this.nextPageToken = response.nextPageToken;\n\n return response;\n }\n\n /**\n * Removes a link query from the store\n */\n deleteFromStore(\n status: Status,\n batch: BatchContext,\n ): Entry<SpecificLinkCacheKey> | undefined {\n const entry = batch.read(this.cacheKey);\n\n if (entry && deepEqual(tombstone, entry.value)) {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child({ methodName: \"deleteFromStore\" }).debug(\n `Links were already deleted, just setting status`,\n );\n }\n return batch.write(this.cacheKey, entry.value, status);\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child({ methodName: \"deleteFromStore\" }).debug(\n JSON.stringify({ status }),\n );\n }\n\n // If there is no entry then there is nothing to do\n if (!entry || !entry.value) {\n return;\n }\n\n const ret = batch.delete(this.cacheKey, status);\n batch.changes.deleted.add(this.cacheKey);\n\n return ret;\n }\n\n /**\n * Implements Query.maybeUpdateAndRevalidate to handle cache invalidation\n */\n maybeUpdateAndRevalidate = async (\n changes: Changes,\n _optimisticId: OptimisticId | undefined,\n ): Promise<void> => {\n // TODO: Implement proper invalidation logic for linked objects\n // This would check if any of the linked objects have changed,\n // or if the source object's links might have changed\n\n // For now, simply check if this specific link cache key was modified\n if (changes.modified.has(this.cacheKey)) {\n return this.revalidate(true);\n }\n\n // No relevant changes were detected\n return Promise.resolve();\n };\n\n invalidateObjectType = (\n objectType: string,\n changes: Changes | undefined,\n ): Promise<void> => {\n // We need to invalidate links in two cases:\n // 1. When the source object type matches the apiName (direct invalidation)\n // 2. When the target object type might be the invalidated type (affected by target changes)\n\n // For case 1 - direct source object type match\n if (this.#sourceApiName === objectType) {\n changes?.modified.add(this.cacheKey);\n return this.revalidate(true);\n } else {\n // For case 2 - check if the link's target type matches the invalidated type\n // We need to use the ontology provider to get the link metadata\n // Since this is async, we'll collect all the metadata check promises\n return (async () => {\n // Get the source object metadata to determine link target type\n const sourceMetadata = await this.store.client[additionalContext]\n .ontologyProvider\n .getObjectDefinition(this.#sourceApiName);\n\n const linkDef = sourceMetadata.links?.[this.#linkName];\n if (!linkDef || linkDef.targetType !== objectType) return;\n\n const promise = this.revalidate(true);\n changes?.modified.add(this.cacheKey);\n return promise;\n })();\n }\n };\n}\n\n/**\n * Type guard to check if a cache key is a SpecificLinkCacheKey\n */\nexport function isSpecificLinkCacheKey(\n key: CacheKey,\n): key is SpecificLinkCacheKey {\n return key.type === \"specificLink\";\n}\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
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 { ListQuery } from "../ListQuery.js";
|
|
19
|
+
export class ListsHelper extends AbstractHelper {
|
|
20
|
+
constructor(store, whereCanonicalizer, orderByCanonicalizer) {
|
|
21
|
+
super(store);
|
|
22
|
+
this.whereCanonicalizer = whereCanonicalizer;
|
|
23
|
+
this.orderByCanonicalizer = orderByCanonicalizer;
|
|
24
|
+
}
|
|
25
|
+
observe(options, subFn) {
|
|
26
|
+
const ret = super.observe(options, subFn);
|
|
27
|
+
if (options.streamUpdates) {
|
|
28
|
+
ret.query.registerStreamUpdates(ret.subscription);
|
|
29
|
+
}
|
|
30
|
+
return ret;
|
|
31
|
+
}
|
|
32
|
+
getQuery(options) {
|
|
33
|
+
const {
|
|
34
|
+
type: {
|
|
35
|
+
apiName,
|
|
36
|
+
type
|
|
37
|
+
},
|
|
38
|
+
where,
|
|
39
|
+
orderBy
|
|
40
|
+
} = options;
|
|
41
|
+
const canonWhere = this.whereCanonicalizer.canonicalize(where ?? {});
|
|
42
|
+
const canonOrderBy = this.orderByCanonicalizer.canonicalize(orderBy ?? {});
|
|
43
|
+
const listCacheKey = this.store.getCacheKey("list", type, apiName, canonWhere, canonOrderBy);
|
|
44
|
+
return this.store.getQuery(listCacheKey, () => {
|
|
45
|
+
return new ListQuery(this.store, this.store.getSubject(listCacheKey), type, apiName, canonWhere, canonOrderBy, listCacheKey, options);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=ListsHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListsHelper.js","names":["AbstractHelper","ListQuery","ListsHelper","constructor","store","whereCanonicalizer","orderByCanonicalizer","observe","options","subFn","ret","streamUpdates","query","registerStreamUpdates","subscription","getQuery","type","apiName","where","orderBy","canonWhere","canonicalize","canonOrderBy","listCacheKey","getCacheKey","getSubject"],"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 { ListCacheKey } from \"../ListCacheKey.js\";\nimport { ListQuery } from \"../ListQuery.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\";\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 whereCanonicalizer: WhereClauseCanonicalizer,\n orderByCanonicalizer: OrderByCanonicalizer,\n ) {\n super(store);\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.store.getCacheKey<ListCacheKey>(\n \"list\",\n type,\n apiName,\n canonWhere,\n canonOrderBy,\n );\n\n return this.store.getQuery(listCacheKey, () => {\n return new ListQuery(\n this.store,\n this.store.getSubject(listCacheKey),\n type,\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;AAErD,SAASC,SAAS,QAAQ,iBAAiB;AAM3C,OAAO,MAAMC,WAAW,SAASF,cAAc,CAG7C;EAIAG,WAAWA,CACTC,KAAY,EACZC,kBAA4C,EAC5CC,oBAA0C,EAC1C;IACA,KAAK,CAACF,KAAK,CAAC;IAEZ,IAAI,CAACC,kBAAkB,GAAGA,kBAAkB;IAC5C,IAAI,CAACC,oBAAoB,GAAGA,oBAAoB;EAClD;EAEAC,OAAOA,CACLC,OAA8B,EAC9BC,KAA4B,EACE;IAC9B,MAAMC,GAAG,GAAG,KAAK,CAACH,OAAO,CAACC,OAAO,EAAEC,KAAK,CAAC;IAEzC,IAAID,OAAO,CAACG,aAAa,EAAE;MACzBD,GAAG,CAACE,KAAK,CAACC,qBAAqB,CAACH,GAAG,CAACI,YAAY,CAAC;IACnD;IACA,OAAOJ,GAAG;EACZ;EAEAK,QAAQA,CACNP,OAA8B,EACnB;IACX,MAAM;MAAEQ,IAAI,EAAE;QAAEC,OAAO;QAAED;MAAK,CAAC;MAAEE,KAAK;MAAEC;IAAQ,CAAC,GAAGX,OAAO;IAE3D,MAAMY,UAAU,GAAG,IAAI,CAACf,kBAAkB,CAACgB,YAAY,CAACH,KAAK,IAAI,CAAC,CAAC,CAAC;IACpE,MAAMI,YAAY,GAAG,IAAI,CAAChB,oBAAoB,CAACe,YAAY,CAACF,OAAO,IAAI,CAAC,CAAC,CAAC;IAC1E,MAAMI,YAAY,GAAG,IAAI,CAACnB,KAAK,CAACoB,WAAW,CACzC,MAAM,EACNR,IAAI,EACJC,OAAO,EACPG,UAAU,EACVE,YACF,CAAC;IAED,OAAO,IAAI,CAAClB,KAAK,CAACW,QAAQ,CAACQ,YAAY,EAAE,MAAM;MAC7C,OAAO,IAAItB,SAAS,CAClB,IAAI,CAACG,KAAK,EACV,IAAI,CAACA,KAAK,CAACqB,UAAU,CAACF,YAAY,CAAC,EACnCP,IAAI,EACJC,OAAO,EACPG,UAAU,EACVE,YAAY,EACZC,YAAY,EACZf,OACF,CAAC;IACH,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 { ObjectQuery } from "../ObjectQuery.js";
|
|
19
|
+
export class ObjectsHelper extends AbstractHelper {
|
|
20
|
+
observe(options, subFn) {
|
|
21
|
+
return super.observe(options, subFn);
|
|
22
|
+
}
|
|
23
|
+
getQuery(options) {
|
|
24
|
+
const apiName = typeof options.apiName === "string" ? options.apiName : options.apiName.apiName;
|
|
25
|
+
const {
|
|
26
|
+
pk
|
|
27
|
+
} = options;
|
|
28
|
+
const objectCacheKey = this.store.getCacheKey("object", apiName, pk);
|
|
29
|
+
return this.store.getQuery(objectCacheKey, () => new ObjectQuery(this.store, this.store.getSubject(objectCacheKey), apiName, pk, objectCacheKey, {
|
|
30
|
+
dedupeInterval: 0
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=ObjectsHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectsHelper.js","names":["AbstractHelper","ObjectQuery","ObjectsHelper","observe","options","subFn","getQuery","apiName","pk","objectCacheKey","store","getCacheKey","getSubject","dedupeInterval"],"sources":["ObjectsHelper.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 { ObjectPayload } from \"../../ObjectPayload.js\";\nimport type { ObserveObjectOptions } from \"../../ObservableClient.js\";\nimport type { Observer } from \"../../ObservableClient/common.js\";\nimport { AbstractHelper } from \"../AbstractHelper.js\";\nimport { type ObjectCacheKey, ObjectQuery } from \"../ObjectQuery.js\";\nimport type { QuerySubscription } from \"../QuerySubscription.js\";\n\nexport class ObjectsHelper extends AbstractHelper<\n ObjectQuery,\n ObserveObjectOptions<any>\n> {\n observe<T extends ObjectTypeDefinition | InterfaceDefinition>(\n options: ObserveObjectOptions<T>,\n subFn: Observer<ObjectPayload>,\n ): QuerySubscription<ObjectQuery> {\n return super.observe(options, subFn);\n }\n\n getQuery<T extends ObjectTypeDefinition | InterfaceDefinition>(\n options: ObserveObjectOptions<T>,\n ): ObjectQuery {\n const apiName = typeof options.apiName === \"string\"\n ? options.apiName\n : options.apiName.apiName;\n const { pk } = options;\n\n const objectCacheKey = this.store.getCacheKey<ObjectCacheKey>(\n \"object\",\n apiName,\n pk,\n );\n\n return this.store.getQuery(objectCacheKey, () =>\n new ObjectQuery(\n this.store,\n this.store.getSubject(objectCacheKey),\n apiName,\n pk,\n objectCacheKey,\n { dedupeInterval: 0 },\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;AACrD,SAA8BC,WAAW,QAAQ,mBAAmB;AAGpE,OAAO,MAAMC,aAAa,SAASF,cAAc,CAG/C;EACAG,OAAOA,CACLC,OAAgC,EAChCC,KAA8B,EACE;IAChC,OAAO,KAAK,CAACF,OAAO,CAACC,OAAO,EAAEC,KAAK,CAAC;EACtC;EAEAC,QAAQA,CACNF,OAAgC,EACnB;IACb,MAAMG,OAAO,GAAG,OAAOH,OAAO,CAACG,OAAO,KAAK,QAAQ,GAC/CH,OAAO,CAACG,OAAO,GACfH,OAAO,CAACG,OAAO,CAACA,OAAO;IAC3B,MAAM;MAAEC;IAAG,CAAC,GAAGJ,OAAO;IAEtB,MAAMK,cAAc,GAAG,IAAI,CAACC,KAAK,CAACC,WAAW,CAC3C,QAAQ,EACRJ,OAAO,EACPC,EACF,CAAC;IAED,OAAO,IAAI,CAACE,KAAK,CAACJ,QAAQ,CAACG,cAAc,EAAE,MACzC,IAAIR,WAAW,CACb,IAAI,CAACS,KAAK,EACV,IAAI,CAACA,KAAK,CAACE,UAAU,CAACH,cAAc,CAAC,EACrCF,OAAO,EACPC,EAAE,EACFC,cAAc,EACd;MAAEI,cAAc,EAAE;IAAE,CACtB,CAAC,CAAC;EACN;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
/**
|
|
18
|
+
* Removes duplicate object cache keys from an array while maintaining order.
|
|
19
|
+
* Also reads each key from the batch context (for side effects).
|
|
20
|
+
*
|
|
21
|
+
* @param objectCacheKeys Array of object cache keys that may contain duplicates
|
|
22
|
+
* @param batch The batch context used to read cache entries
|
|
23
|
+
* @returns Array with duplicates removed, maintaining the original order
|
|
24
|
+
*/
|
|
25
|
+
export function removeDuplicates(objectCacheKeys, batch) {
|
|
26
|
+
const visited = new Set();
|
|
27
|
+
return objectCacheKeys.filter(key => {
|
|
28
|
+
batch.read(key);
|
|
29
|
+
if (visited.has(key)) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
visited.add(key);
|
|
33
|
+
return true;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=removeDuplicates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeDuplicates.js","names":["removeDuplicates","objectCacheKeys","batch","visited","Set","filter","key","read","has","add"],"sources":["removeDuplicates.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 { ObjectCacheKey } from \"./ObjectQuery.js\";\nimport type { BatchContext } from \"./Store.js\";\n\n/**\n * Removes duplicate object cache keys from an array while maintaining order.\n * Also reads each key from the batch context (for side effects).\n *\n * @param objectCacheKeys Array of object cache keys that may contain duplicates\n * @param batch The batch context used to read cache entries\n * @returns Array with duplicates removed, maintaining the original order\n */\nexport function removeDuplicates(\n objectCacheKeys: ObjectCacheKey[],\n batch: BatchContext,\n): ObjectCacheKey[] {\n const visited = new Set<ObjectCacheKey>();\n return objectCacheKeys.filter((key) => {\n batch.read(key);\n if (visited.has(key)) {\n return false;\n }\n visited.add(key);\n return true;\n });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,gBAAgBA,CAC9BC,eAAiC,EACjCC,KAAmB,EACD;EAClB,MAAMC,OAAO,GAAG,IAAIC,GAAG,CAAiB,CAAC;EACzC,OAAOH,eAAe,CAACI,MAAM,CAAEC,GAAG,IAAK;IACrCJ,KAAK,CAACK,IAAI,CAACD,GAAG,CAAC;IACf,IAAIH,OAAO,CAACK,GAAG,CAACF,GAAG,CAAC,EAAE;MACpB,OAAO,KAAK;IACd;IACAH,OAAO,CAACM,GAAG,CAACH,GAAG,CAAC;IAChB,OAAO,IAAI;EACb,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
/**
|
|
18
|
+
* Strategy interface for collection sorting
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* No-operation sorting strategy that preserves original order
|
|
23
|
+
*/
|
|
24
|
+
export class NoOpSortingStrategy {
|
|
25
|
+
sortCacheKeys(objectCacheKeys) {
|
|
26
|
+
return objectCacheKeys;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Sorting strategy for OrderBy clauses
|
|
31
|
+
*/
|
|
32
|
+
export class OrderBySortingStrategy {
|
|
33
|
+
constructor(apiName, orderBy) {
|
|
34
|
+
this.apiName = apiName;
|
|
35
|
+
this.orderBy = orderBy;
|
|
36
|
+
this.sortFns = createOrderBySortFns(orderBy);
|
|
37
|
+
}
|
|
38
|
+
sortCacheKeys(objectCacheKeys, batch) {
|
|
39
|
+
if (Object.keys(this.orderBy).length === 0) {
|
|
40
|
+
return objectCacheKeys;
|
|
41
|
+
}
|
|
42
|
+
return objectCacheKeys.sort((a, b) => {
|
|
43
|
+
for (const sortFn of this.sortFns) {
|
|
44
|
+
const ret = sortFn(batch.read(a)?.value?.$as(this.apiName), batch.read(b)?.value?.$as(this.apiName));
|
|
45
|
+
if (ret !== 0) {
|
|
46
|
+
return ret;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return 0;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Creates sort functions for an orderBy clause
|
|
56
|
+
* @param orderBy - The order by clause
|
|
57
|
+
* @returns Array of sort functions
|
|
58
|
+
*/
|
|
59
|
+
export function createOrderBySortFns(orderBy) {
|
|
60
|
+
return Object.entries(orderBy).map(([key, order]) => {
|
|
61
|
+
return (a, b) => {
|
|
62
|
+
const aValue = a?.[key];
|
|
63
|
+
const bValue = b?.[key];
|
|
64
|
+
if (aValue == null && bValue == null) {
|
|
65
|
+
return 0;
|
|
66
|
+
}
|
|
67
|
+
if (aValue == null) {
|
|
68
|
+
return 1;
|
|
69
|
+
}
|
|
70
|
+
if (bValue == null) {
|
|
71
|
+
return -1;
|
|
72
|
+
}
|
|
73
|
+
const m = order === "asc" ? -1 : 1;
|
|
74
|
+
return aValue < bValue ? m : aValue > bValue ? -m : 0;
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=SortingStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SortingStrategy.js","names":["NoOpSortingStrategy","sortCacheKeys","objectCacheKeys","OrderBySortingStrategy","constructor","apiName","orderBy","sortFns","createOrderBySortFns","batch","Object","keys","length","sort","a","b","sortFn","ret","read","value","$as","entries","map","key","order","aValue","bValue","m"],"sources":["SortingStrategy.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 { InterfaceHolder } from \"../../../object/convertWireToOsdkObjects/InterfaceHolder.js\";\nimport type { ObjectHolder } from \"../../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { Canonical } from \"../Canonical.js\";\nimport type { ObjectCacheKey } from \"../ObjectQuery.js\";\nimport type { BatchContext } from \"../Store.js\";\n\n/**\n * Strategy interface for collection sorting\n */\nexport interface SortingStrategy {\n /**\n * Sort an array of object cache keys\n * @param objectCacheKeys - Keys to sort\n * @param batch - Batch context for reading objects\n * @returns Sorted array of keys\n */\n sortCacheKeys(\n objectCacheKeys: ObjectCacheKey[],\n batch: BatchContext,\n ): ObjectCacheKey[];\n}\n\n/**\n * No-operation sorting strategy that preserves original order\n */\nexport class NoOpSortingStrategy implements SortingStrategy {\n sortCacheKeys(\n objectCacheKeys: ObjectCacheKey[],\n _batch: BatchContext,\n ): ObjectCacheKey[] {\n return objectCacheKeys;\n }\n}\n\ntype ObjectInterfaceComparer = (\n a: ObjectHolder | InterfaceHolder | undefined,\n b: ObjectHolder | InterfaceHolder | undefined,\n) => number;\n\n/**\n * Sorting strategy for OrderBy clauses\n */\nexport class OrderBySortingStrategy implements SortingStrategy {\n private readonly sortFns: Array<ObjectInterfaceComparer>;\n\n constructor(\n private readonly apiName: string,\n private readonly orderBy: Canonical<\n Record<string, \"asc\" | \"desc\" | undefined>\n >,\n ) {\n this.sortFns = createOrderBySortFns(orderBy);\n }\n\n sortCacheKeys(\n objectCacheKeys: ObjectCacheKey[],\n batch: BatchContext,\n ): ObjectCacheKey[] {\n if (Object.keys(this.orderBy).length === 0) {\n return objectCacheKeys;\n }\n\n return objectCacheKeys.sort((a, b) => {\n for (const sortFn of this.sortFns) {\n const ret = sortFn(\n batch.read(a)?.value?.$as(this.apiName),\n batch.read(b)?.value?.$as(this.apiName),\n );\n if (ret !== 0) {\n return ret;\n }\n }\n return 0;\n });\n }\n}\n\n/**\n * Creates sort functions for an orderBy clause\n * @param orderBy - The order by clause\n * @returns Array of sort functions\n */\nexport function createOrderBySortFns(\n orderBy: Canonical<Record<string, \"asc\" | \"desc\" | undefined>>,\n): ObjectInterfaceComparer[] {\n return Object.entries(orderBy).map(([key, order]) => {\n return (\n a: ObjectHolder | InterfaceHolder | undefined,\n b: ObjectHolder | InterfaceHolder | undefined,\n ): number => {\n const aValue = a?.[key];\n const bValue = b?.[key];\n\n if (aValue == null && bValue == null) {\n return 0;\n }\n if (aValue == null) {\n return 1;\n }\n if (bValue == null) {\n return -1;\n }\n const m = order === \"asc\" ? -1 : 1;\n return aValue < bValue ? m : aValue > bValue ? -m : 0;\n };\n });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;;AAcA;AACA;AACA;AACA,OAAO,MAAMA,mBAAmB,CAA4B;EAC1DC,aAAaA,CACXC,eAAiC,EAEf;IAClB,OAAOA,eAAe;EACxB;AACF;AAOA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,CAA4B;EAG7DC,WAAWA,CACQC,OAAe,EACfC,OAEhB,EACD;IAAA,KAJiBD,OAAe,GAAfA,OAAe;IAAA,KACfC,OAEhB,GAFgBA,OAEhB;IAED,IAAI,CAACC,OAAO,GAAGC,oBAAoB,CAACF,OAAO,CAAC;EAC9C;EAEAL,aAAaA,CACXC,eAAiC,EACjCO,KAAmB,EACD;IAClB,IAAIC,MAAM,CAACC,IAAI,CAAC,IAAI,CAACL,OAAO,CAAC,CAACM,MAAM,KAAK,CAAC,EAAE;MAC1C,OAAOV,eAAe;IACxB;IAEA,OAAOA,eAAe,CAACW,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAK;MACpC,KAAK,MAAMC,MAAM,IAAI,IAAI,CAACT,OAAO,EAAE;QACjC,MAAMU,GAAG,GAAGD,MAAM,CAChBP,KAAK,CAACS,IAAI,CAACJ,CAAC,CAAC,EAAEK,KAAK,EAAEC,GAAG,CAAC,IAAI,CAACf,OAAO,CAAC,EACvCI,KAAK,CAACS,IAAI,CAACH,CAAC,CAAC,EAAEI,KAAK,EAAEC,GAAG,CAAC,IAAI,CAACf,OAAO,CACxC,CAAC;QACD,IAAIY,GAAG,KAAK,CAAC,EAAE;UACb,OAAOA,GAAG;QACZ;MACF;MACA,OAAO,CAAC;IACV,CAAC,CAAC;EACJ;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAST,oBAAoBA,CAClCF,OAA8D,EACnC;EAC3B,OAAOI,MAAM,CAACW,OAAO,CAACf,OAAO,CAAC,CAACgB,GAAG,CAAC,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK;IACnD,OAAO,CACLV,CAA6C,EAC7CC,CAA6C,KAClC;MACX,MAAMU,MAAM,GAAGX,CAAC,GAAGS,GAAG,CAAC;MACvB,MAAMG,MAAM,GAAGX,CAAC,GAAGQ,GAAG,CAAC;MAEvB,IAAIE,MAAM,IAAI,IAAI,IAAIC,MAAM,IAAI,IAAI,EAAE;QACpC,OAAO,CAAC;MACV;MACA,IAAID,MAAM,IAAI,IAAI,EAAE;QAClB,OAAO,CAAC;MACV;MACA,IAAIC,MAAM,IAAI,IAAI,EAAE;QAClB,OAAO,CAAC,CAAC;MACX;MACA,MAAMC,CAAC,GAAGH,KAAK,KAAK,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC;MAClC,OAAOC,MAAM,GAAGC,MAAM,GAAGC,CAAC,GAAGF,MAAM,GAAGC,MAAM,GAAG,CAACC,CAAC,GAAG,CAAC;IACvD,CAAC;EACH,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export async function invalidateList(store, args) {
|
|
18
|
+
const where = store.whereCanonicalizer.canonicalize(args.where ?? {});
|
|
19
|
+
const orderBy = store.orderByCanonicalizer.canonicalize(args.orderBy ?? {});
|
|
20
|
+
const cacheKey = store.getCacheKey("list", args.type.type, args.type.apiName, where, orderBy);
|
|
21
|
+
await store.peekQuery(cacheKey)?.revalidate(true);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=invalidateList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalidateList.js","names":["invalidateList","store","args","where","whereCanonicalizer","canonicalize","orderBy","orderByCanonicalizer","cacheKey","getCacheKey","type","apiName","peekQuery","revalidate"],"sources":["invalidateList.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, WhereClause } from \"@osdk/api\";\nimport type { OrderBy } from \"../../ObservableClient.js\";\nimport type { Canonical } from \"../Canonical.js\";\nimport type { ListCacheKey } from \"../ListCacheKey.js\";\nimport type { SimpleWhereClause } from \"../SimpleWhereClause.js\";\nimport type { Store } from \"../Store.js\";\n\nexport async function invalidateList<T extends ObjectTypeDefinition>(\n store: Store,\n args: {\n type: Pick<T, \"apiName\" | \"type\">;\n where?: WhereClause<T> | SimpleWhereClause;\n orderBy?: OrderBy<T>;\n },\n): Promise<void> {\n const where = store.whereCanonicalizer.canonicalize(args.where ?? {});\n const orderBy = store.orderByCanonicalizer.canonicalize(args.orderBy ?? {});\n\n const cacheKey = store.getCacheKey<ListCacheKey>(\n \"list\",\n args.type.type,\n args.type.apiName,\n where,\n orderBy as Canonical<OrderBy<T>>,\n );\n\n await store.peekQuery(cacheKey)?.revalidate(true);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,OAAO,eAAeA,cAAcA,CAClCC,KAAY,EACZC,IAIC,EACc;EACf,MAAMC,KAAK,GAAGF,KAAK,CAACG,kBAAkB,CAACC,YAAY,CAACH,IAAI,CAACC,KAAK,IAAI,CAAC,CAAC,CAAC;EACrE,MAAMG,OAAO,GAAGL,KAAK,CAACM,oBAAoB,CAACF,YAAY,CAACH,IAAI,CAACI,OAAO,IAAI,CAAC,CAAC,CAAC;EAE3E,MAAME,QAAQ,GAAGP,KAAK,CAACQ,WAAW,CAChC,MAAM,EACNP,IAAI,CAACQ,IAAI,CAACA,IAAI,EACdR,IAAI,CAACQ,IAAI,CAACC,OAAO,EACjBR,KAAK,EACLG,OACF,CAAC;EAED,MAAML,KAAK,CAACW,SAAS,CAACJ,QAAQ,CAAC,EAAEK,UAAU,CAAC,IAAI,CAAC;AACnD","ignoreList":[]}
|
|
@@ -0,0 +1,69 @@
|
|
|
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 { createDefer, expectSingleLinkCallAndClear, mockLinkSubCallback, waitForCall } from "../../testUtils.js";
|
|
18
|
+
const defer = createDefer();
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Utility function for testing link observation behavior between objects
|
|
22
|
+
*
|
|
23
|
+
* This function provides the following guarantees:
|
|
24
|
+
* - Sets up a link subscription using the Store's observeLinks method
|
|
25
|
+
* - Validates that an initial "loading" state is emitted with empty results
|
|
26
|
+
* - Waits for the link data to be fetched and emitted
|
|
27
|
+
* - Validates the "loaded" state contains the expected linked objects
|
|
28
|
+
* - Returns both the link payload and mock subscription function for further assertions
|
|
29
|
+
*
|
|
30
|
+
* This helper creates a standardized test flow for link observations that:
|
|
31
|
+
* 1. Creates a subscription to observe links from source to target objects
|
|
32
|
+
* 2. Verifies the initial loading state is emitted with empty results
|
|
33
|
+
* 3. Waits for the data loading to complete
|
|
34
|
+
* 4. Verifies the loaded state with the expected linked objects
|
|
35
|
+
* 5. Provides the result objects for additional assertions in tests
|
|
36
|
+
*
|
|
37
|
+
* @typeParam S - The source object type definition
|
|
38
|
+
* @typeParam T - The target object type definition
|
|
39
|
+
*/
|
|
40
|
+
export async function expectStandardObserveLink({
|
|
41
|
+
store,
|
|
42
|
+
srcObject,
|
|
43
|
+
srcLinkName,
|
|
44
|
+
targetType,
|
|
45
|
+
expected
|
|
46
|
+
}) {
|
|
47
|
+
const linkSubFn = mockLinkSubCallback();
|
|
48
|
+
defer(store.links.observe({
|
|
49
|
+
linkName: srcLinkName,
|
|
50
|
+
srcType: {
|
|
51
|
+
type: "object",
|
|
52
|
+
apiName: srcObject.$apiName
|
|
53
|
+
},
|
|
54
|
+
pk: srcObject.$primaryKey
|
|
55
|
+
}, linkSubFn));
|
|
56
|
+
await waitForCall(linkSubFn);
|
|
57
|
+
expectSingleLinkCallAndClear(linkSubFn, [], {
|
|
58
|
+
status: "loading"
|
|
59
|
+
});
|
|
60
|
+
await waitForCall(linkSubFn);
|
|
61
|
+
const payload = expectSingleLinkCallAndClear(linkSubFn, expected, {
|
|
62
|
+
status: "loaded"
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
payload,
|
|
66
|
+
linkSubFn
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=expectStandardObserveLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expectStandardObserveLink.js","names":["createDefer","expectSingleLinkCallAndClear","mockLinkSubCallback","waitForCall","defer","expectStandardObserveLink","store","srcObject","srcLinkName","targetType","expected","linkSubFn","links","observe","linkName","srcType","type","apiName","$apiName","pk","$primaryKey","status","payload"],"sources":["expectStandardObserveLink.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, Osdk } from \"@osdk/api\";\nimport type { Observer } from \"type-fest\";\nimport type { MockedObject } from \"vitest\";\nimport type { ObjectHolder } from \"../../../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { SpecificLinkPayload } from \"../../../LinkPayload.js\";\nimport type { Store } from \"../../Store.js\";\nimport {\n createDefer,\n expectSingleLinkCallAndClear,\n mockLinkSubCallback,\n waitForCall,\n} from \"../../testUtils.js\";\n\nconst defer = createDefer();\n\n/**\n * Utility function for testing link observation behavior between objects\n *\n * This function provides the following guarantees:\n * - Sets up a link subscription using the Store's observeLinks method\n * - Validates that an initial \"loading\" state is emitted with empty results\n * - Waits for the link data to be fetched and emitted\n * - Validates the \"loaded\" state contains the expected linked objects\n * - Returns both the link payload and mock subscription function for further assertions\n *\n * This helper creates a standardized test flow for link observations that:\n * 1. Creates a subscription to observe links from source to target objects\n * 2. Verifies the initial loading state is emitted with empty results\n * 3. Waits for the data loading to complete\n * 4. Verifies the loaded state with the expected linked objects\n * 5. Provides the result objects for additional assertions in tests\n *\n * @typeParam S - The source object type definition\n * @typeParam T - The target object type definition\n */\nexport async function expectStandardObserveLink<\n S extends ObjectTypeDefinition,\n T extends ObjectTypeDefinition,\n>(\n {\n store,\n srcObject,\n srcLinkName,\n targetType,\n expected,\n }: {\n /** The Store instance to use for observation */\n store: Store;\n /** The source object that contains the link */\n srcObject: Osdk.Instance<S>;\n /** The name of the link field to observe */\n srcLinkName: string;\n /** The type definition of the linked objects */\n targetType: T;\n /** The expected linked objects that should be returned */\n expected: ObjectHolder<Osdk.Instance<T>>[];\n },\n): Promise<{\n /** The link payload containing the linked objects and metadata */\n payload: SpecificLinkPayload | undefined;\n /** The mocked subscription callback for further testing assertions */\n linkSubFn: MockedObject<\n Observer<\n SpecificLinkPayload | undefined\n >\n >;\n}> {\n const linkSubFn = mockLinkSubCallback();\n defer(\n store.links.observe({\n linkName: srcLinkName,\n srcType: { type: \"object\", apiName: srcObject.$apiName },\n pk: srcObject.$primaryKey,\n }, linkSubFn),\n );\n\n await waitForCall(linkSubFn);\n expectSingleLinkCallAndClear(linkSubFn, [], { status: \"loading\" });\n\n await waitForCall(linkSubFn);\n\n const payload = expectSingleLinkCallAndClear(linkSubFn, expected, {\n status: \"loaded\",\n });\n\n return { payload, linkSubFn };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SACEA,WAAW,EACXC,4BAA4B,EAC5BC,mBAAmB,EACnBC,WAAW,QACN,oBAAoB;AAE3B,MAAMC,KAAK,GAAGJ,WAAW,CAAC,CAAC;;AAE3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeK,yBAAyBA,CAI7C;EACEC,KAAK;EACLC,SAAS;EACTC,WAAW;EACXC,UAAU;EACVC;AAYF,CAAC,EAUA;EACD,MAAMC,SAAS,GAAGT,mBAAmB,CAAC,CAAC;EACvCE,KAAK,CACHE,KAAK,CAACM,KAAK,CAACC,OAAO,CAAC;IAClBC,QAAQ,EAAEN,WAAW;IACrBO,OAAO,EAAE;MAAEC,IAAI,EAAE,QAAQ;MAAEC,OAAO,EAAEV,SAAS,CAACW;IAAS,CAAC;IACxDC,EAAE,EAAEZ,SAAS,CAACa;EAChB,CAAC,EAAET,SAAS,CACd,CAAC;EAED,MAAMR,WAAW,CAACQ,SAAS,CAAC;EAC5BV,4BAA4B,CAACU,SAAS,EAAE,EAAE,EAAE;IAAEU,MAAM,EAAE;EAAU,CAAC,CAAC;EAElE,MAAMlB,WAAW,CAACQ,SAAS,CAAC;EAE5B,MAAMW,OAAO,GAAGrB,4BAA4B,CAACU,SAAS,EAAED,QAAQ,EAAE;IAChEW,MAAM,EAAE;EACV,CAAC,CAAC;EAEF,OAAO;IAAEC,OAAO;IAAEX;EAAU,CAAC;AAC/B","ignoreList":[]}
|
|
@@ -0,0 +1,56 @@
|
|
|
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 { expect } from "vitest";
|
|
18
|
+
import { createDefer, expectSingleObjectCallAndClear, mockSingleSubCallback, waitForCall } from "../../testUtils.js";
|
|
19
|
+
const defer = createDefer();
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Utility function for testing object observation behavior
|
|
23
|
+
*
|
|
24
|
+
* This function provides the following guarantees:
|
|
25
|
+
* - Validates the initial "loading" state is emitted
|
|
26
|
+
* - Waits for the subscription callback to be called again
|
|
27
|
+
* - Validates the "loaded" state with the expected object containing apiName and primaryKey
|
|
28
|
+
* - Returns both the observed object and mock subscription function for further assertions
|
|
29
|
+
*
|
|
30
|
+
* @param cache - The Store instance to use for observation
|
|
31
|
+
* @param apiName - The API name for the object to observe
|
|
32
|
+
* @param primaryKey - The primary key of the object to observe
|
|
33
|
+
* @returns A promise that resolves to the observed object and the mocked subscription callback
|
|
34
|
+
*/
|
|
35
|
+
export async function expectStandardObserveObject({
|
|
36
|
+
cache,
|
|
37
|
+
type,
|
|
38
|
+
primaryKey
|
|
39
|
+
}) {
|
|
40
|
+
const subFn = mockSingleSubCallback();
|
|
41
|
+
defer(cache.objects.observe({
|
|
42
|
+
apiName: type,
|
|
43
|
+
pk: primaryKey
|
|
44
|
+
}, subFn));
|
|
45
|
+
expectSingleObjectCallAndClear(subFn, undefined, "loading");
|
|
46
|
+
await waitForCall(subFn);
|
|
47
|
+
const obj = expectSingleObjectCallAndClear(subFn, expect.objectContaining({
|
|
48
|
+
$apiName: type.apiName,
|
|
49
|
+
$primaryKey: primaryKey
|
|
50
|
+
}), "loaded");
|
|
51
|
+
return {
|
|
52
|
+
payload: obj,
|
|
53
|
+
subFn
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=expectStandardObserveObject.js.map
|