@osdk/client 2.5.0-beta.1 → 2.5.0-beta.2
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 +26 -0
- package/build/browser/Client.js +1 -1
- package/build/browser/Client.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/fetchPage.js +8 -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/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-N5DMNYGH.cjs} +58 -54
- package/build/cjs/chunk-N5DMNYGH.cjs.map +1 -0
- package/build/cjs/{chunk-BJYCRD5Y.cjs → chunk-NWD33DSJ.cjs} +23 -19
- package/build/cjs/chunk-NWD33DSJ.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/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/fetchPage.js +8 -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/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/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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geotimeseriesreference.test.js","names":["$ontologyRid","Employee","LegacyFauxFoundry","startNodeApiServer","formatISO","sub","beforeAll","describe","expect","it","vi","createClient","client","locationGeotimeData","time","value","type","coordinates","Date","now","testSetup","pk","data","Object","entries","fauxFoundry","getDataStore","registerTimeSeriesData","useFakeTimers","setSystemTime","apiServer","close","useRealTimers","employee","fetchOne","employee2","$primaryKey","toEqual","location","employeeLocation","toBeDefined","initialLastPoint","lastFetchedValue","toBeUndefined","fetchedPoint","getLatestValue","nextLastPoint","initialPointEmployee2","fetchedPoint2","nextLastPoint2","points","getAllValues","$before","$unit","$after","$startTime","$endTime","pointsIter","asyncIterValues","point","push"],"sources":["geotimeseriesreference.test.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { TimeSeriesPoint } from \"@osdk/api\";\nimport { $ontologyRid, Employee } from \"@osdk/client.test.ontology\";\nimport { LegacyFauxFoundry, startNodeApiServer } from \"@osdk/shared.test\";\nimport { formatISO, sub } from \"date-fns\";\nimport { beforeAll, describe, expect, it, vi } from \"vitest\";\nimport type { Client } from \"../Client.js\";\nimport { createClient } from \"../createClient.js\";\n\ndescribe(\"Timeseries\", () => {\n let client: Client;\n const locationGeotimeData = {\n 50030: [\n {\n time: \"2012-02-12\",\n value: { type: \"Point\", coordinates: [1.1, 1.1] },\n },\n {\n time: \"2013-03-13\",\n value: { type: \"Point\", coordinates: [2.2, 2.2] },\n },\n {\n time: \"2014-04-14\",\n value: { type: \"Point\", coordinates: [3.3, 3.3] },\n },\n ],\n 50031: [\n {\n time: formatISO(sub(Date.now(), { \"days\": 2 })),\n value: {\n type: \"Point\",\n coordinates: [2.2, 2.2],\n },\n },\n ],\n };\n\n beforeAll(async () => {\n const testSetup = startNodeApiServer(\n new LegacyFauxFoundry(),\n createClient,\n );\n ({ client } = testSetup);\n\n for (const [pk, data] of Object.entries(locationGeotimeData)) {\n testSetup.fauxFoundry.getDataStore($ontologyRid)\n .registerTimeSeriesData(\n \"Employee\",\n pk,\n \"employeeLocation\",\n data,\n );\n }\n\n vi.useFakeTimers();\n vi.setSystemTime(new Date(\"2013-03-13\"));\n\n return () => {\n testSetup.apiServer.close();\n vi.useRealTimers();\n };\n });\n\n it(\"get latest value works\", async () => {\n const employee = await client(Employee).fetchOne(50030);\n const employee2 = await client(Employee).fetchOne(50031);\n expect(employee.$primaryKey).toEqual(50030);\n expect(employee2.$primaryKey).toEqual(50031);\n const location = employee.employeeLocation;\n\n expect(location).toBeDefined();\n\n const initialLastPoint = employee.employeeLocation?.lastFetchedValue;\n expect(initialLastPoint).toBeUndefined();\n\n const fetchedPoint = await employee.employeeLocation?.getLatestValue();\n const nextLastPoint = employee.employeeLocation?.lastFetchedValue;\n expect(employee.employeeLocation?.lastFetchedValue).toBeDefined();\n\n expect(nextLastPoint).toEqual(fetchedPoint);\n expect(nextLastPoint).toEqual(locationGeotimeData[50030][2]);\n\n expect(fetchedPoint).toEqual(locationGeotimeData[50030][2]);\n\n // Making sure caching working as expected\n const initialPointEmployee2 = employee2.employeeLocation?.lastFetchedValue;\n expect(initialPointEmployee2).toBeUndefined();\n\n const fetchedPoint2 = await employee2.employeeLocation?.getLatestValue();\n const nextLastPoint2 = employee2.employeeLocation?.lastFetchedValue;\n expect(employee2.employeeLocation?.lastFetchedValue).toBeDefined();\n\n expect(nextLastPoint2).toEqual(fetchedPoint2);\n expect(nextLastPoint2).toEqual(locationGeotimeData[50031][0]);\n\n expect(fetchedPoint2).toEqual(locationGeotimeData[50031][0]);\n });\n\n it(\"getAll values with before works\", async () => {\n const employee = await client(Employee).fetchOne(50030);\n expect(employee.$primaryKey).toEqual(50030);\n const points = await employee.employeeLocation?.getAllValues({\n $before: 1,\n $unit: \"month\",\n });\n expect(points).toBeDefined();\n expect(points!).toEqual([\n locationGeotimeData[50030][1],\n locationGeotimeData[50030][2],\n ]);\n });\n\n it(\"getAll values with after works\", async () => {\n const employee = await client(Employee).fetchOne(50030);\n expect(employee.$primaryKey).toEqual(50030);\n const points = await employee.employeeLocation?.getAllValues({\n $after: 1,\n $unit: \"month\",\n });\n expect(points).toBeDefined();\n expect(points!).toEqual([\n locationGeotimeData[50030][0],\n locationGeotimeData[50030][1],\n ]);\n\n vi.useRealTimers();\n });\n\n it(\"getAll points with absolute range works\", async () => {\n const employee = await client(Employee).fetchOne(50030);\n expect(employee.$primaryKey).toEqual(50030);\n const points = await employee.employeeLocation?.getAllValues({\n $startTime: \"2013-03-12T12:00:00.000Z\",\n $endTime: \"2014-04-14T12:00:00.000Z\",\n });\n expect(points).toBeDefined();\n expect(points!).toEqual([{\n time: \"2013-03-13\",\n value: { type: \"Point\", coordinates: [2.2, 2.2] },\n }, {\n time: \"2014-04-14\",\n value: { type: \"Point\", coordinates: [3.3, 3.3] },\n }]);\n });\n\n it(\"getAll points with no query works\", async () => {\n const employee = await client(Employee).fetchOne(50030);\n expect(employee.$primaryKey).toEqual(50030);\n const points = await employee.employeeLocation?.getAllValues();\n expect(points).toBeDefined();\n expect(points!).toEqual(\n locationGeotimeData[50030],\n );\n });\n\n it(\"getAll points with no data works\", async () => {\n const employee = await client(Employee).fetchOne(50030);\n expect(employee.$primaryKey).toEqual(50030);\n const points = await employee.employeeLocation?.getAllValues({\n $startTime: \"2021-03-12T12:00:00.000Z\",\n $endTime: \"2022-04-14T12:00:00.000Z\",\n });\n expect(points).toBeDefined();\n expect(points!).toEqual([]);\n });\n\n it(\"async iter points with absolute range works\", async () => {\n const employee = await client(Employee).fetchOne(50030);\n expect(employee.$primaryKey).toEqual(50030);\n const pointsIter = employee.employeeLocation?.asyncIterValues({\n $startTime: \"2013-03-12T12:00:00.000Z\",\n $endTime: \"2014-04-14T12:00:00.000Z\",\n });\n\n const points: TimeSeriesPoint<GeoJSON.Point>[] = [];\n for await (const point of pointsIter!) {\n points.push(point);\n }\n expect(points).toBeDefined();\n expect(points!).toEqual([\n locationGeotimeData[50030][1],\n locationGeotimeData[50030][2],\n ]);\n });\n\n it(\"async iter points with no query\", async () => {\n const employee = await client(Employee).fetchOne(50030);\n expect(employee.$primaryKey).toEqual(50030);\n const pointsIter = employee.employeeLocation?.asyncIterValues();\n\n const points: TimeSeriesPoint<GeoJSON.Point>[] = [];\n for await (const point of pointsIter!) {\n points.push(point);\n }\n expect(points).toBeDefined();\n expect(points!).toEqual(\n locationGeotimeData[50030],\n );\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,YAAY,EAAEC,QAAQ,QAAQ,4BAA4B;AACnE,SAASC,iBAAiB,EAAEC,kBAAkB,QAAQ,mBAAmB;AACzE,SAASC,SAAS,EAAEC,GAAG,QAAQ,UAAU;AACzC,SAASC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,QAAQ;AAE5D,SAASC,YAAY,QAAQ,oBAAoB;AAEjDJ,QAAQ,CAAC,YAAY,EAAE,MAAM;EAC3B,IAAIK,MAAc;EAClB,MAAMC,mBAAmB,GAAG;IAC1B,KAAK,EAAE,CACL;MACEC,IAAI,EAAE,YAAY;MAClBC,KAAK,EAAE;QAAEC,IAAI,EAAE,OAAO;QAAEC,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG;MAAE;IAClD,CAAC,EACD;MACEH,IAAI,EAAE,YAAY;MAClBC,KAAK,EAAE;QAAEC,IAAI,EAAE,OAAO;QAAEC,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG;MAAE;IAClD,CAAC,EACD;MACEH,IAAI,EAAE,YAAY;MAClB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KAAK,IAAIF,UAAU,EAAG;MACrCP,MAAM,CAACU,IAAI,CAACD,KAAK,CAAC;IACpB;IACAnD,MAAM,CAAC0C,MAAM,CAAC,CAACV,WAAW,CAAC,CAAC;IAC5BhC,MAAM,CAAC0C,MAAO,CAAC,CAACb,OAAO,CAAC,CACtBxB,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAC7BA,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAC9B,CAAC;EACJ,CAAC,CAAC;EAEFJ,EAAE,CAAC,iCAAiC,EAAE,YAAY;IAChD,MAAMwB,QAAQ,GAAG,MAAMrB,MAAM,CAACX,QAAQ,CAAC,CAACiC,QAAQ,CAAC,KAAK,CAAC;IACvD1B,MAAM,CAACyB,QAAQ,CAACG,WAAW,CAAC,CAACC,OAAO,CAAC,KAAK,CAAC;IAC3C,MAAMoB,UAAU,GAAGxB,QAAQ,CAACM,gBAAgB,EAAEmB,eAAe,CAAC,CAAC;IAE/D,MAAMR,MAAwC,GAAG,EAAE;IACnD,WAAW,MAAMS,KAAK,IAAIF,UAAU,EAAG;MACrCP,MAAM,CAACU,IAAI,CAACD,KAAK,CAAC;IACpB;IACAnD,MAAM,CAAC0C,MAAM,CAAC,CAACV,WAAW,CAAC,CAAC;IAC5BhC,MAAM,CAAC0C,MAAO,CAAC,CAACb,OAAO,CACrBxB,mBAAmB,CAAC,KAAK,CAC3B,CAAC;EACH,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"geotimeseriesreference.test.js","names":["$ontologyRid","Employee","LegacyFauxFoundry","startNodeApiServer","formatISO","sub","beforeAll","describe","expect","it","vi","createClient","client","locationGeotimeData","time","value","type","coordinates","Date","now","testSetup","pk","data","Object","entries","fauxFoundry","getDataStore","registerTimeSeriesData","setSystemTime","apiServer","close","employee","fetchOne","employee2","$primaryKey","toEqual","location","employeeLocation","toBeDefined","initialLastPoint","lastFetchedValue","toBeUndefined","fetchedPoint","getLatestValue","nextLastPoint","initialPointEmployee2","fetchedPoint2","nextLastPoint2","points","getAllValues","$before","$unit","$after","useRealTimers","$startTime","$endTime","pointsIter","asyncIterValues","point","push"],"sources":["geotimeseriesreference.test.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { TimeSeriesPoint } from \"@osdk/api\";\nimport { $ontologyRid, Employee } from \"@osdk/client.test.ontology\";\nimport { LegacyFauxFoundry, startNodeApiServer } from \"@osdk/shared.test\";\nimport { formatISO, sub } from \"date-fns\";\nimport { beforeAll, describe, expect, it, vi } from \"vitest\";\nimport type { Client } from \"../Client.js\";\nimport { createClient } from \"../createClient.js\";\n\ndescribe(\"Timeseries\", () => {\n let client: Client;\n const locationGeotimeData = {\n 50030: [\n {\n time: \"2012-02-12\",\n value: { type: \"Point\", coordinates: [1.1, 1.1] },\n },\n {\n time: \"2013-03-13\",\n value: { type: \"Point\", coordinates: [2.2, 2.2] },\n },\n {\n time: \"2014-04-14\",\n value: { type: \"Point\", coordinates: [3.3, 3.3] },\n },\n ],\n 50031: [\n {\n time: formatISO(sub(Date.now(), { \"days\": 2 })),\n value: {\n type: \"Point\",\n coordinates: [2.2, 2.2],\n },\n },\n ],\n };\n\n beforeAll(async () => {\n const testSetup = startNodeApiServer(\n new LegacyFauxFoundry(),\n createClient,\n );\n ({ client } = testSetup);\n\n for (const [pk, data] of Object.entries(locationGeotimeData)) {\n testSetup.fauxFoundry.getDataStore($ontologyRid)\n .registerTimeSeriesData(\n \"Employee\",\n pk,\n \"employeeLocation\",\n data,\n );\n }\n\n vi.setSystemTime(new Date(\"2013-03-13\"));\n\n return () => {\n testSetup.apiServer.close();\n };\n });\n\n it(\"get latest value works\", async () => {\n const employee = await client(Employee).fetchOne(50030);\n const employee2 = await client(Employee).fetchOne(50031);\n expect(employee.$primaryKey).toEqual(50030);\n expect(employee2.$primaryKey).toEqual(50031);\n const location = employee.employeeLocation;\n\n expect(location).toBeDefined();\n\n const initialLastPoint = employee.employeeLocation?.lastFetchedValue;\n expect(initialLastPoint).toBeUndefined();\n\n const fetchedPoint = await employee.employeeLocation?.getLatestValue();\n const nextLastPoint = employee.employeeLocation?.lastFetchedValue;\n expect(employee.employeeLocation?.lastFetchedValue).toBeDefined();\n\n expect(nextLastPoint).toEqual(fetchedPoint);\n expect(nextLastPoint).toEqual(locationGeotimeData[50030][2]);\n\n expect(fetchedPoint).toEqual(locationGeotimeData[50030][2]);\n\n // Making sure caching working as expected\n const initialPointEmployee2 = employee2.employeeLocation?.lastFetchedValue;\n expect(initialPointEmployee2).toBeUndefined();\n\n const fetchedPoint2 = await employee2.employeeLocation?.getLatestValue();\n const nextLastPoint2 = employee2.employeeLocation?.lastFetchedValue;\n expect(employee2.employeeLocation?.lastFetchedValue).toBeDefined();\n\n expect(nextLastPoint2).toEqual(fetchedPoint2);\n expect(nextLastPoint2).toEqual(locationGeotimeData[50031][0]);\n\n expect(fetchedPoint2).toEqual(locationGeotimeData[50031][0]);\n });\n\n it(\"getAll values with before works\", async () => {\n const employee = await client(Employee).fetchOne(50030);\n expect(employee.$primaryKey).toEqual(50030);\n const points = await employee.employeeLocation?.getAllValues({\n $before: 1,\n $unit: \"month\",\n });\n expect(points).toBeDefined();\n expect(points!).toEqual([\n locationGeotimeData[50030][1],\n locationGeotimeData[50030][2],\n ]);\n });\n\n it(\"getAll values with after works\", async () => {\n const employee = await client(Employee).fetchOne(50030);\n expect(employee.$primaryKey).toEqual(50030);\n const points = await employee.employeeLocation?.getAllValues({\n $after: 1,\n $unit: \"month\",\n });\n expect(points).toBeDefined();\n expect(points!).toEqual([\n locationGeotimeData[50030][0],\n locationGeotimeData[50030][1],\n ]);\n\n vi.useRealTimers();\n });\n\n it(\"getAll points with absolute range works\", async () => {\n const employee = await client(Employee).fetchOne(50030);\n expect(employee.$primaryKey).toEqual(50030);\n const points = await employee.employeeLocation?.getAllValues({\n $startTime: \"2013-03-12T12:00:00.000Z\",\n $endTime: \"2014-04-14T12:00:00.000Z\",\n });\n expect(points).toBeDefined();\n expect(points!).toEqual([{\n time: \"2013-03-13\",\n value: { type: \"Point\", coordinates: [2.2, 2.2] },\n }, {\n time: \"2014-04-14\",\n value: { type: \"Point\", coordinates: [3.3, 3.3] },\n }]);\n });\n\n it(\"getAll points with no query works\", async () => {\n const employee = await client(Employee).fetchOne(50030);\n expect(employee.$primaryKey).toEqual(50030);\n const points = await employee.employeeLocation?.getAllValues();\n expect(points).toBeDefined();\n expect(points!).toEqual(\n locationGeotimeData[50030],\n );\n });\n\n it(\"getAll points with no data works\", async () => {\n const employee = await client(Employee).fetchOne(50030);\n expect(employee.$primaryKey).toEqual(50030);\n const points = await employee.employeeLocation?.getAllValues({\n $startTime: \"2021-03-12T12:00:00.000Z\",\n $endTime: \"2022-04-14T12:00:00.000Z\",\n });\n expect(points).toBeDefined();\n expect(points!).toEqual([]);\n });\n\n it(\"async iter points with absolute range works\", async () => {\n const employee = await client(Employee).fetchOne(50030);\n expect(employee.$primaryKey).toEqual(50030);\n const pointsIter = employee.employeeLocation?.asyncIterValues({\n $startTime: \"2013-03-12T12:00:00.000Z\",\n $endTime: \"2014-04-14T12:00:00.000Z\",\n });\n\n const points: TimeSeriesPoint<GeoJSON.Point>[] = [];\n for await (const point of pointsIter!) {\n points.push(point);\n }\n expect(points).toBeDefined();\n expect(points!).toEqual([\n locationGeotimeData[50030][1],\n locationGeotimeData[50030][2],\n ]);\n });\n\n it(\"async iter points with no query\", async () => {\n const employee = await client(Employee).fetchOne(50030);\n expect(employee.$primaryKey).toEqual(50030);\n const pointsIter = employee.employeeLocation?.asyncIterValues();\n\n const points: TimeSeriesPoint<GeoJSON.Point>[] = [];\n for await (const point of pointsIter!) {\n points.push(point);\n }\n expect(points).toBeDefined();\n expect(points!).toEqual(\n locationGeotimeData[50030],\n );\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,YAAY,EAAEC,QAAQ,QAAQ,4BAA4B;AACnE,SAASC,iBAAiB,EAAEC,kBAAkB,QAAQ,mBAAmB;AACzE,SAASC,SAAS,EAAEC,GAAG,QAAQ,UAAU;AACzC,SAASC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,QAAQ;AAE5D,SAASC,YAAY,QAAQ,oBAAoB;AAEjDJ,QAAQ,CAAC,YAAY,EAAE,MAAM;EAC3B,IAAIK,MAAc;EAClB,MAAMC,mBAAmB,GAAG;IAC1B,KAAK,EAAE,CACL;MACEC,IAAI,EAAE,YAAY;MAClBC,KAAK,EAAE;QAAEC,IAAI,EAAE,OAAO;QAAEC,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG;MAAE;IAClD,CAAC,EACD;MACEH,IAAI,EAAE,YAAY;MAClBC,KAAK,EAAE;QAAEC,IAAI,EAAE,OAAO;QAAEC,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG;MAAE;IAClD,CAAC,EACD;MACEH,IAAI,EAAE,YAAY;MAClBC,KAAK,EAAE;QAAEC,IAAI,EAAE,OAAO;QAAEC,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG;MAAE;IAClD,CAAC,CACF;IACD,KAAK,EAAE,CACL;MACEH,IAAI,EAAEV,SAAS,CAACC,GAAG,CAACa,IAAI,CAACC,GAAG,CAAC,CAAC,EAAE;QAAE,MAAM,EAAE;MAAE,CAAC,CAAC,CAAC;MAC/CJ,KAAK,EAAE;QACLC,IAAI,EAAE,OAAO;QACbC,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AQ,GAAG,MAAMnB,MAAM,CAACX,QAAQ,CAAC,CAAC+B,QAAQ,CAAC,KAAK,CAAC;IACvDxB,MAAM,CAACuB,QAAQ,CAACG,WAAW,CAAC,CAACC,OAAO,CAAC,KAAK,CAAC;IAC3C,MAAMqB,UAAU,GAAGzB,QAAQ,CAACM,gBAAgB,EAAEoB,eAAe,CAAC,CAAC;IAE/D,MAAMT,MAAwC,GAAG,EAAE;IACnD,WAAW,MAAMU,KAAK,IAAIF,UAAU,EAAG;MACrCR,MAAM,CAACW,IAAI,CAACD,KAAK,CAAC;IACpB;IACAlD,MAAM,CAACwC,MAAM,CAAC,CAACV,WAAW,CAAC,CAAC;IAC5B9B,MAAM,CAACwC,MAAO,CAAC,CAACb,OAAO,CACrBtB,mBAAmB,CAAC,KAAK,CAC3B,CAAC;EACH,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -36,7 +36,9 @@ export function isObjectSet(o) {
|
|
|
36
36
|
export function getWireObjectSet(objectSet) {
|
|
37
37
|
return objectSetDefinitions.get(objectSet);
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
|
|
40
|
+
/** @internal exported for internal use only */
|
|
41
|
+
export const objectSetDefinitions = new WeakMap();
|
|
40
42
|
|
|
41
43
|
/** @internal */
|
|
42
44
|
export function createObjectSet(objectType, clientCtx, objectSet = resolveBaseObjectSetType(objectType)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createObjectSet.js","names":["createWithPropertiesObjectSet","modernToLegacyWhereClause","aggregate","fetchPageInternal","fetchPageWithErrorsInternal","fetchSingle","fetchSingleWithErrors","augmentRequestContext","resolveBaseObjectSetType","isWireObjectSet","ObjectSetListenerWebsocket","isObjectTypeDefinition","def","type","isObjectSet","o","objectSetDefinitions","get","getWireObjectSet","objectSet","WeakMap","createObjectSet","objectType","clientCtx","base","bind","globalThis","finalMethodCall","fetchPage","fetchPageWithErrors","where","clause","objectSetFactory","pivotTo","createSearchAround","union","objectSets","map","os","intersect","subtract","nearestNeighbors","query","numNeighbors","property","nearestNeighborsQuery","isTextQuery","propertyIdentifier","apiName","asyncIter","args","$nextPageToken","undefined","result","$pageSize","nextPageToken","obj","data","fetchOne","primaryKey","options","createWithPk","fetchOneWithErrors","subscribe","listener","opts","pendingSubscribe","getInstance","properties","unsubscribe","withProperties","definitionMap","Map","derivedProperties","key","Object","keys","derivedPropertyDefinition","$objectSetInternals","link","interfaceLink","set","objDef","ontologyProvider","getObjectDefinition","withPk","field","primaryKeyApiName","value"],"sources":["createObjectSet.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n AsyncIterArgs,\n Augments,\n FetchPageResult,\n LinkedType,\n LinkNames,\n NullabilityAdherence,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n Result,\n SelectArg,\n SingleOsdkResult,\n} from \"@osdk/api\";\nimport type { MinimalObjectSet } from \"@osdk/api/unstable\";\nimport type {\n DerivedPropertyDefinition,\n ObjectSet as WireObjectSet,\n PropertyApiName,\n} from \"@osdk/foundry.ontologies\";\nimport { createWithPropertiesObjectSet } from \"../derivedProperties/createWithPropertiesObjectSet.js\";\nimport { modernToLegacyWhereClause } from \"../internal/conversions/modernToLegacyWhereClause.js\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport { aggregate } from \"../object/aggregate.js\";\nimport {\n fetchPageInternal,\n fetchPageWithErrorsInternal,\n} from \"../object/fetchPage.js\";\nimport { fetchSingle, fetchSingleWithErrors } from \"../object/fetchSingle.js\";\nimport { augmentRequestContext } from \"../util/augmentRequestContext.js\";\nimport { resolveBaseObjectSetType } from \"../util/objectSetUtils.js\";\nimport { isWireObjectSet } from \"../util/WireObjectSet.js\";\nimport { ObjectSetListenerWebsocket } from \"./ObjectSetListenerWebsocket.js\";\n\nfunction isObjectTypeDefinition(\n def: ObjectOrInterfaceDefinition,\n): def is ObjectTypeDefinition {\n return def.type === \"object\";\n}\n\n/* @internal */\nexport function isObjectSet(o: any): o is ObjectSet<any> {\n return o != null && typeof o === \"object\"\n && isWireObjectSet(objectSetDefinitions.get(o));\n}\n\n/** @internal */\nexport function getWireObjectSet(\n objectSet: ObjectSet<any> | MinimalObjectSet<any>,\n): WireObjectSet {\n return objectSetDefinitions.get(objectSet)!;\n}\n\nconst objectSetDefinitions = new WeakMap<\n any,\n WireObjectSet\n>();\n\n/** @internal */\nexport function createObjectSet<Q extends ObjectOrInterfaceDefinition>(\n objectType: Q,\n clientCtx: MinimalClient,\n objectSet: WireObjectSet = resolveBaseObjectSetType(objectType),\n): ObjectSet<Q> {\n const base: ObjectSet<Q> = {\n aggregate: (aggregate<Q, any>).bind(\n globalThis,\n augmentRequestContext(clientCtx, _ => ({ finalMethodCall: \"aggregate\" })),\n objectType,\n objectSet,\n ) as ObjectSet<Q>[\"aggregate\"],\n\n fetchPage: fetchPageInternal.bind(\n globalThis,\n augmentRequestContext(clientCtx, _ => ({ finalMethodCall: \"fetchPage\" })),\n objectType,\n objectSet,\n ) as ObjectSet<Q>[\"fetchPage\"],\n\n fetchPageWithErrors: fetchPageWithErrorsInternal.bind(\n globalThis,\n augmentRequestContext(\n clientCtx,\n _ => ({ finalMethodCall: \"fetchPageWithErrors\" }),\n ),\n objectType,\n objectSet,\n ) as ObjectSet<Q>[\"fetchPageWithErrors\"],\n\n where: (clause) => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"filter\",\n objectSet: objectSet,\n where: modernToLegacyWhereClause(clause, objectType),\n });\n },\n\n pivotTo: function<L extends LinkNames<Q>>(\n type: L,\n ): ObjectSet<LinkedType<Q, L>> {\n return createSearchAround(type)();\n },\n\n union: (...objectSets) => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"union\",\n objectSets: [\n objectSet,\n ...objectSets.map(os => objectSetDefinitions.get(os)!),\n ],\n });\n },\n\n intersect: (...objectSets) => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"intersect\",\n objectSets: [\n objectSet,\n ...objectSets.map(os => objectSetDefinitions.get(os)!),\n ],\n });\n },\n\n subtract: (...objectSets) => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"subtract\",\n objectSets: [\n objectSet,\n ...objectSets.map(os => objectSetDefinitions.get(os)!),\n ],\n });\n },\n\n nearestNeighbors: (query, numNeighbors, property) => {\n const nearestNeighborsQuery = isTextQuery(query)\n ? { \"type\": \"text\" as const, \"value\": query }\n : { \"type\": \"vector\" as const, \"value\": query };\n return clientCtx.objectSetFactory(\n objectType,\n clientCtx,\n {\n type: \"nearestNeighbors\",\n objectSet,\n propertyIdentifier: {\n type: \"property\",\n apiName: property as PropertyApiName,\n },\n numNeighbors,\n query: nearestNeighborsQuery,\n },\n ) as ObjectSet<Q>;\n },\n\n asyncIter: async function*<\n L extends PropertyKeys<Q>,\n R extends boolean,\n const A extends Augments,\n S extends NullabilityAdherence = NullabilityAdherence.Default,\n T extends boolean = false,\n >(\n args?: AsyncIterArgs<Q, L, R, A, S, T>,\n ): AsyncIterableIterator<SingleOsdkResult<Q, L, R, S, {}, T>> {\n let $nextPageToken: string | undefined = undefined;\n do {\n const result: FetchPageResult<\n Q,\n L,\n R,\n S,\n T\n > = await fetchPageInternal(\n augmentRequestContext(\n clientCtx,\n _ => ({ finalMethodCall: \"asyncIter\" }),\n ),\n objectType,\n objectSet,\n { ...args, $pageSize: 10000, $nextPageToken },\n true,\n );\n $nextPageToken = result.nextPageToken;\n\n for (const obj of result.data) {\n yield obj as SingleOsdkResult<Q, L, R, S, {}, T>;\n }\n } while ($nextPageToken != null);\n },\n\n fetchOne: (isObjectTypeDefinition(objectType)\n ? async <A extends SelectArg<Q>>(\n primaryKey: PrimaryKeyType<Q>,\n options: A,\n ) => {\n return await fetchSingle(\n augmentRequestContext(\n clientCtx,\n _ => ({ finalMethodCall: \"fetchOne\" }),\n ),\n objectType,\n options,\n await createWithPk(\n clientCtx,\n objectType,\n objectSet,\n primaryKey,\n ),\n ) as Osdk<Q>;\n }\n : undefined) as ObjectSet<Q>[\"fetchOne\"],\n\n fetchOneWithErrors: (isObjectTypeDefinition(objectType)\n ? async <A extends SelectArg<Q>>(\n primaryKey: Q extends ObjectTypeDefinition ? PrimaryKeyType<Q>\n : never,\n options: A,\n ) => {\n return await fetchSingleWithErrors(\n augmentRequestContext(\n clientCtx,\n _ => ({ finalMethodCall: \"fetchOneWithErrors\" }),\n ),\n objectType,\n options,\n await createWithPk(\n clientCtx,\n objectType,\n objectSet,\n primaryKey,\n ),\n ) as Result<Osdk<Q>>;\n }\n : undefined) as ObjectSet<Q>[\"fetchOneWithErrors\"],\n\n subscribe: (\n listener,\n opts,\n ) => {\n const pendingSubscribe = ObjectSetListenerWebsocket.getInstance(\n clientCtx,\n ).subscribe(\n objectType,\n objectSet,\n listener,\n opts?.properties,\n );\n\n return { unsubscribe: async () => (await pendingSubscribe)() };\n },\n\n withProperties: (clause) => {\n const definitionMap = new Map<any, DerivedPropertyDefinition>();\n\n const derivedProperties: Record<string, DerivedPropertyDefinition> = {};\n for (const key of Object.keys(clause)) {\n const derivedPropertyDefinition = clause\n [key](createWithPropertiesObjectSet(\n objectType,\n { type: \"methodInput\" },\n definitionMap,\n true,\n ));\n derivedProperties[key] = definitionMap.get(\n derivedPropertyDefinition,\n )!;\n }\n\n return clientCtx.objectSetFactory(\n objectType,\n clientCtx,\n {\n type: \"withProperties\",\n derivedProperties: derivedProperties,\n objectSet: objectSet,\n },\n );\n },\n\n $objectSetInternals: {\n def: objectType,\n },\n };\n\n function createSearchAround<L extends LinkNames<Q>>(link: L) {\n return () => {\n return clientCtx.objectSetFactory(\n objectType,\n clientCtx,\n objectType.type === \"object\"\n ? {\n type: \"searchAround\",\n objectSet,\n link,\n }\n : {\n type: \"interfaceLinkSearchAround\",\n objectSet,\n interfaceLink: link,\n },\n );\n };\n }\n\n objectSetDefinitions.set(base, objectSet);\n\n // we are using a type assertion because the marker symbol defined in BaseObjectSet isn't actually used\n // at runtime.\n return base as ObjectSet<Q>;\n}\n\nasync function createWithPk(\n clientCtx: MinimalClient,\n objectType: ObjectTypeDefinition,\n objectSet: WireObjectSet,\n primaryKey: PrimaryKeyType<ObjectTypeDefinition>,\n) {\n const objDef = await clientCtx.ontologyProvider.getObjectDefinition(\n objectType.apiName,\n );\n\n const withPk: WireObjectSet = {\n type: \"filter\",\n objectSet: objectSet,\n where: {\n type: \"eq\",\n field: objDef.primaryKeyApiName,\n value: primaryKey,\n },\n };\n return withPk;\n}\n\nfunction isTextQuery(query: string | number[]): query is string {\n return typeof query === \"string\";\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBA,SAASA,6BAA6B,QAAQ,uDAAuD;AACrG,SAASC,yBAAyB,QAAQ,sDAAsD;AAEhG,SAASC,SAAS,QAAQ,wBAAwB;AAClD,SACEC,iBAAiB,EACjBC,2BAA2B,QACtB,wBAAwB;AAC/B,SAASC,WAAW,EAAEC,qBAAqB,QAAQ,0BAA0B;AAC7E,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,SAASC,wBAAwB,QAAQ,2BAA2B;AACpE,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,SAASC,0BAA0B,QAAQ,iCAAiC;AAE5E,SAASC,sBAAsBA,CAC7BC,GAAgC,EACH;EAC7B,OAAOA,GAAG,CAACC,IAAI,KAAK,QAAQ;AAC9B;;AAEA;AACA,OAAO,SAASC,WAAWA,CAACC,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OxD,SAAS,CAACS,gBAAgB,CAC/BV,UAAU,EACVC,SAAS,EACTD,UAAU,CAACT,IAAI,KAAK,QAAQ,GACxB;QACAA,IAAI,EAAE,cAAc;QACpBM,SAAS;QACT4D;MACF,CAAC,GACC;QACAlE,IAAI,EAAE,2BAA2B;QACjCM,SAAS;QACT6D,aAAa,EAAED;MACjB,CACJ,CAAC;IACH,CAAC;EACH;EAEA/D,oBAAoB,CAACiE,GAAG,CAACzD,IAAI,EAAEL,SAAS,CAAC;;EAEzC;EACA;EACA,OAAOK,IAAI;AACb;AAEA,eAAeqC,YAAYA,CACzBtC,SAAwB,EACxBD,UAAgC,EAChCH,SAAwB,EACxBwC,UAAgD,EAChD;EACA,MAAMuB,MAAM,GAAG,MAAM3D,SAAS,CAAC4D,gBAAgB,CAACC,mBAAmB,CACjE9D,UAAU,CAAC0B,OACb,CAAC;EAED,MAAMqC,MAAqB,GAAG;IAC5BxE,IAAI,EAAE,QAAQ;IACdM,SAAS,EAAEA,SAAS;IACpBW,KAAK,EAAE;MACLjB,IAAI,EAAE,IAAI;MACVyE,KAAK,EAAEJ,MAAM,CAACK,iBAAiB;MAC/BC,KAAK,EAAE7B;IACT;EACF,CAAC;EACD,OAAO0B,MAAM;AACf;AAEA,SAASvC,WAAWA,CAACJ,KAAwB,EAAmB;EAC9D,OAAO,OAAOA,KAAK,KAAK,QAAQ;AAClC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"createObjectSet.js","names":["createWithPropertiesObjectSet","modernToLegacyWhereClause","aggregate","fetchPageInternal","fetchPageWithErrorsInternal","fetchSingle","fetchSingleWithErrors","augmentRequestContext","resolveBaseObjectSetType","isWireObjectSet","ObjectSetListenerWebsocket","isObjectTypeDefinition","def","type","isObjectSet","o","objectSetDefinitions","get","getWireObjectSet","objectSet","WeakMap","createObjectSet","objectType","clientCtx","base","bind","globalThis","finalMethodCall","fetchPage","fetchPageWithErrors","where","clause","objectSetFactory","pivotTo","createSearchAround","union","objectSets","map","os","intersect","subtract","nearestNeighbors","query","numNeighbors","property","nearestNeighborsQuery","isTextQuery","propertyIdentifier","apiName","asyncIter","args","$nextPageToken","undefined","result","$pageSize","nextPageToken","obj","data","fetchOne","primaryKey","options","createWithPk","fetchOneWithErrors","subscribe","listener","opts","pendingSubscribe","getInstance","properties","unsubscribe","withProperties","definitionMap","Map","derivedProperties","key","Object","keys","derivedPropertyDefinition","$objectSetInternals","link","interfaceLink","set","objDef","ontologyProvider","getObjectDefinition","withPk","field","primaryKeyApiName","value"],"sources":["createObjectSet.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n AsyncIterArgs,\n Augments,\n FetchPageResult,\n LinkedType,\n LinkNames,\n NullabilityAdherence,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectSetArgs,\n ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n Result,\n SelectArg,\n SingleOsdkResult,\n} from \"@osdk/api\";\nimport type { MinimalObjectSet } from \"@osdk/api/unstable\";\nimport type {\n DerivedPropertyDefinition,\n ObjectSet as WireObjectSet,\n PropertyApiName,\n} from \"@osdk/foundry.ontologies\";\nimport { createWithPropertiesObjectSet } from \"../derivedProperties/createWithPropertiesObjectSet.js\";\nimport { modernToLegacyWhereClause } from \"../internal/conversions/modernToLegacyWhereClause.js\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport { aggregate } from \"../object/aggregate.js\";\nimport {\n fetchPageInternal,\n fetchPageWithErrorsInternal,\n} from \"../object/fetchPage.js\";\nimport { fetchSingle, fetchSingleWithErrors } from \"../object/fetchSingle.js\";\nimport { augmentRequestContext } from \"../util/augmentRequestContext.js\";\nimport { resolveBaseObjectSetType } from \"../util/objectSetUtils.js\";\nimport { isWireObjectSet } from \"../util/WireObjectSet.js\";\nimport { ObjectSetListenerWebsocket } from \"./ObjectSetListenerWebsocket.js\";\n\nfunction isObjectTypeDefinition(\n def: ObjectOrInterfaceDefinition,\n): def is ObjectTypeDefinition {\n return def.type === \"object\";\n}\n\n/* @internal */\nexport function isObjectSet(o: any): o is ObjectSet<any> {\n return o != null && typeof o === \"object\"\n && isWireObjectSet(objectSetDefinitions.get(o));\n}\n\n/** @internal */\nexport function getWireObjectSet(\n objectSet: ObjectSet<any> | MinimalObjectSet<any>,\n): WireObjectSet {\n return objectSetDefinitions.get(objectSet)!;\n}\n\n/** @internal exported for internal use only */\nexport const objectSetDefinitions = new WeakMap<\n any,\n WireObjectSet\n>();\n\n/** @internal */\nexport function createObjectSet<Q extends ObjectOrInterfaceDefinition>(\n objectType: Q,\n clientCtx: MinimalClient,\n objectSet: WireObjectSet = resolveBaseObjectSetType(objectType),\n): ObjectSet<Q> {\n const base: ObjectSet<Q> = {\n aggregate: (aggregate<Q, any>).bind(\n globalThis,\n augmentRequestContext(clientCtx, _ => ({ finalMethodCall: \"aggregate\" })),\n objectType,\n objectSet,\n ) as ObjectSet<Q>[\"aggregate\"],\n\n fetchPage: fetchPageInternal.bind(\n globalThis,\n augmentRequestContext(clientCtx, _ => ({ finalMethodCall: \"fetchPage\" })),\n objectType,\n objectSet,\n ) as ObjectSet<Q>[\"fetchPage\"],\n\n fetchPageWithErrors: fetchPageWithErrorsInternal.bind(\n globalThis,\n augmentRequestContext(\n clientCtx,\n _ => ({ finalMethodCall: \"fetchPageWithErrors\" }),\n ),\n objectType,\n objectSet,\n ) as ObjectSet<Q>[\"fetchPageWithErrors\"],\n\n where: (clause) => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"filter\",\n objectSet: objectSet,\n where: modernToLegacyWhereClause(clause, objectType),\n });\n },\n\n pivotTo: function<L extends LinkNames<Q>>(\n type: L,\n ): ObjectSet<LinkedType<Q, L>> {\n return createSearchAround(type)();\n },\n\n union: (...objectSets) => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"union\",\n objectSets: [\n objectSet,\n ...objectSets.map(os => objectSetDefinitions.get(os)!),\n ],\n });\n },\n\n intersect: (...objectSets) => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"intersect\",\n objectSets: [\n objectSet,\n ...objectSets.map(os => objectSetDefinitions.get(os)!),\n ],\n });\n },\n\n subtract: (...objectSets) => {\n return clientCtx.objectSetFactory(objectType, clientCtx, {\n type: \"subtract\",\n objectSets: [\n objectSet,\n ...objectSets.map(os => objectSetDefinitions.get(os)!),\n ],\n });\n },\n\n nearestNeighbors: (query, numNeighbors, property) => {\n const nearestNeighborsQuery = isTextQuery(query)\n ? { \"type\": \"text\" as const, \"value\": query }\n : { \"type\": \"vector\" as const, \"value\": query };\n return clientCtx.objectSetFactory(\n objectType,\n clientCtx,\n {\n type: \"nearestNeighbors\",\n objectSet,\n propertyIdentifier: {\n type: \"property\",\n apiName: property as PropertyApiName,\n },\n numNeighbors,\n query: nearestNeighborsQuery,\n },\n ) as ObjectSet<Q>;\n },\n\n asyncIter: async function*<\n L extends PropertyKeys<Q>,\n R extends boolean,\n const A extends Augments,\n S extends NullabilityAdherence = NullabilityAdherence.Default,\n T extends boolean = false,\n ORDER_BY_OPTIONS extends ObjectSetArgs.OrderByOptions<L> = never,\n >(\n args?: AsyncIterArgs<Q, L, R, A, S, T, never, ORDER_BY_OPTIONS>,\n ): AsyncIterableIterator<\n SingleOsdkResult<Q, L, R, S, {}, T, ORDER_BY_OPTIONS>\n > {\n let $nextPageToken: string | undefined = undefined;\n do {\n const result: FetchPageResult<\n Q,\n L,\n R,\n S,\n T,\n ORDER_BY_OPTIONS\n > = await fetchPageInternal(\n augmentRequestContext(\n clientCtx,\n _ => ({ finalMethodCall: \"asyncIter\" }),\n ),\n objectType,\n objectSet,\n { ...args, $pageSize: 10000, $nextPageToken },\n true,\n );\n $nextPageToken = result.nextPageToken;\n\n for (const obj of result.data) {\n yield obj as SingleOsdkResult<Q, L, R, S, {}, T, ORDER_BY_OPTIONS>;\n }\n } while ($nextPageToken != null);\n },\n\n fetchOne: (isObjectTypeDefinition(objectType)\n ? async <A extends SelectArg<Q>>(\n primaryKey: PrimaryKeyType<Q>,\n options: A,\n ) => {\n return await fetchSingle(\n augmentRequestContext(\n clientCtx,\n _ => ({ finalMethodCall: \"fetchOne\" }),\n ),\n objectType,\n options,\n await createWithPk(\n clientCtx,\n objectType,\n objectSet,\n primaryKey,\n ),\n ) as Osdk<Q>;\n }\n : undefined) as ObjectSet<Q>[\"fetchOne\"],\n\n fetchOneWithErrors: (isObjectTypeDefinition(objectType)\n ? async <A extends SelectArg<Q>>(\n primaryKey: Q extends ObjectTypeDefinition ? PrimaryKeyType<Q>\n : never,\n options: A,\n ) => {\n return await fetchSingleWithErrors(\n augmentRequestContext(\n clientCtx,\n _ => ({ finalMethodCall: \"fetchOneWithErrors\" }),\n ),\n objectType,\n options,\n await createWithPk(\n clientCtx,\n objectType,\n objectSet,\n primaryKey,\n ),\n ) as Result<Osdk<Q>>;\n }\n : undefined) as ObjectSet<Q>[\"fetchOneWithErrors\"],\n\n subscribe: (\n listener,\n opts,\n ) => {\n const pendingSubscribe = ObjectSetListenerWebsocket.getInstance(\n clientCtx,\n ).subscribe(\n objectType,\n objectSet,\n listener,\n opts?.properties,\n );\n\n return { unsubscribe: async () => (await pendingSubscribe)() };\n },\n\n withProperties: (clause) => {\n const definitionMap = new Map<any, DerivedPropertyDefinition>();\n\n const derivedProperties: Record<string, DerivedPropertyDefinition> = {};\n for (const key of Object.keys(clause)) {\n const derivedPropertyDefinition = clause\n [key](createWithPropertiesObjectSet(\n objectType,\n { type: \"methodInput\" },\n definitionMap,\n true,\n ));\n derivedProperties[key] = definitionMap.get(\n derivedPropertyDefinition,\n )!;\n }\n\n return clientCtx.objectSetFactory(\n objectType,\n clientCtx,\n {\n type: \"withProperties\",\n derivedProperties: derivedProperties,\n objectSet: objectSet,\n },\n );\n },\n\n $objectSetInternals: {\n def: objectType,\n },\n };\n\n function createSearchAround<L extends LinkNames<Q>>(link: L) {\n return () => {\n return clientCtx.objectSetFactory(\n objectType,\n clientCtx,\n objectType.type === \"object\"\n ? {\n type: \"searchAround\",\n objectSet,\n link,\n }\n : {\n type: \"interfaceLinkSearchAround\",\n objectSet,\n interfaceLink: link,\n },\n );\n };\n }\n\n objectSetDefinitions.set(base, objectSet);\n\n // we are using a type assertion because the marker symbol defined in BaseObjectSet isn't actually used\n // at runtime.\n return base as ObjectSet<Q>;\n}\n\nasync function createWithPk(\n clientCtx: MinimalClient,\n objectType: ObjectTypeDefinition,\n objectSet: WireObjectSet,\n primaryKey: PrimaryKeyType<ObjectTypeDefinition>,\n) {\n const objDef = await clientCtx.ontologyProvider.getObjectDefinition(\n objectType.apiName,\n );\n\n const withPk: WireObjectSet = {\n type: \"filter\",\n objectSet: objectSet,\n where: {\n type: \"eq\",\n field: objDef.primaryKeyApiName,\n value: primaryKey,\n },\n };\n return withPk;\n}\n\nfunction isTextQuery(query: string | number[]): query is string {\n return typeof query === \"string\";\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA0BA,SAASA,6BAA6B,QAAQ,uDAAuD;AACrG,SAASC,yBAAyB,QAAQ,sDAAsD;AAEhG,SAASC,SAAS,QAAQ,wBAAwB;AAClD,SACEC,iBAAiB,EACjBC,2BAA2B,QACtB,wBAAwB;AAC/B,SAASC,WAAW,EAAEC,qBAAqB,QAAQ,0BAA0B;AAC7E,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,SAASC,wBAAwB,QAAQ,2BAA2B;AACpE,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,SAASC,0BAA0B,Q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AEA;MACb,CACF,CAAC;IACH,CAAC;IAED2D,mBAAmB,EAAE;MACnBlE,GAAG,EAAEU;IACP;EACF,CAAC;EAED,SAASY,kBAAkBA,CAAyB6C,IAAO,EAAE;IAC3D,OAAO,MAAM;MACX,OAAOxD,SAAS,CAACS,gBAAgB,CAC/BV,UAAU,EACVC,SAAS,EACTD,UAAU,CAACT,IAAI,KAAK,QAAQ,GACxB;QACAA,IAAI,EAAE,cAAc;QACpBM,SAAS;QACT4D;MACF,CAAC,GACC;QACAlE,IAAI,EAAE,2BAA2B;QACjCM,SAAS;QACT6D,aAAa,EAAED;MACjB,CACJ,CAAC;IACH,CAAC;EACH;EAEA/D,oBAAoB,CAACiE,GAAG,CAACzD,IAAI,EAAEL,SAAS,CAAC;;EAEzC;EACA;EACA,OAAOK,IAAI;AACb;AAEA,eAAeqC,YAAYA,CACzBtC,SAAwB,EACxBD,UAAgC,EAChCH,SAAwB,EACxBwC,UAAgD,EAChD;EACA,MAAMuB,MAAM,GAAG,MAAM3D,SAAS,CAAC4D,gBAAgB,CAACC,mBAAmB,CACjE9D,UAAU,CAAC0B,OACb,CAAC;EAED,MAAMqC,MAAqB,GAAG;IAC5BxE,IAAI,EAAE,QAAQ;IACdM,SAAS,EAAEA,SAAS;IACpBW,KAAK,EAAE;MACLjB,IAAI,EAAE,IAAI;MACVyE,KAAK,EAAEJ,MAAM,CAACK,iBAAiB;MAC/BC,KAAK,EAAE7B;IACT;EACF,CAAC;EACD,OAAO0B,MAAM;AACf;AAEA,SAASvC,WAAWA,CAACJ,KAAwB,EAAmB;EAC9D,OAAO,OAAOA,KAAK,KAAK,QAAQ;AAClC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkPayload.js","names":[],"sources":["LinkPayload.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 { ObserveLinkCallbackArgs } from \"./ObservableClient.js\";\n\n/**\n * Internal type to keep the generic insanity down internal to the observable code\n */\nexport interface SpecificLinkPayload\n extends Omit<ObserveLinkCallbackArgs<any>, \"resolvedList\">\n{\n resolvedList: Array<ObjectHolder | InterfaceHolder>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectPayload.js","names":[],"sources":["ObjectPayload.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 { ObjectHolder } from \"../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { ObserveObjectArgs } from \"./ObservableClient.js\";\n\nexport interface ObjectPayload extends Omit<ObserveObjectArgs<any>, \"object\"> {\n object: ObjectHolder | undefined;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ObjectPayload.js","names":[],"sources":["ObjectPayload.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 { ObjectHolder } from \"../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { ObserveObjectArgs } from \"./ObservableClient.js\";\n\nexport interface ObjectPayload extends Omit<ObserveObjectArgs<any>, \"object\"> {\n object: ObjectHolder | undefined;\n}\n\nexport interface TypedObjectPayload<T extends ObjectTypeDefinition>\n extends ObjectPayload\n{\n object: ObjectHolder<Osdk.Instance<T>> & Osdk.Instance<T> | undefined;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
export let ObserveLinks;
|
|
17
|
+
//# sourceMappingURL=ObserveLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObserveLink.js","names":["ObserveLinks"],"sources":["ObserveLink.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 CompileTimeMetadata,\n InterfaceDefinition,\n ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n WhereClause,\n} from \"@osdk/api\";\nimport type { Unsubscribable } from \"../Unsubscribable.js\";\nimport type {\n CommonObserveOptions,\n InvalidationMode,\n ObserveOptions,\n Observer,\n OrderBy,\n Status,\n} from \"./common.js\";\n\nexport namespace ObserveLinks {\n export interface Options<\n Q extends ObjectTypeDefinition | InterfaceDefinition,\n L extends keyof CompileTimeMetadata<Q>[\"links\"] & string,\n > extends CommonObserveOptions, ObserveOptions {\n srcType: Pick<Q, \"type\" | \"apiName\">;\n pk: PrimaryKeyType<Q>;\n linkName: L;\n where?: WhereClause<CompileTimeMetadata<Q>[\"links\"][L][\"targetType\"]>;\n pageSize?: number;\n orderBy?: OrderBy<CompileTimeMetadata<Q>[\"links\"][L][\"targetType\"]>;\n invalidationMode?: InvalidationMode;\n expectedLength?: number;\n }\n\n export interface CallbackArgs<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n > {\n resolvedList: Osdk.Instance<T>[];\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<void>;\n hasMore: boolean;\n status: Status;\n }\n}\n\nexport interface ObserveLinks {\n observeLinks<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n L extends keyof CompileTimeMetadata<T>[\"links\"] & string,\n >(\n objects: Osdk.Instance<T> | ReadonlyArray<Osdk.Instance<T>>,\n linkName: L,\n options: Omit<ObserveLinks.Options<T, L>, \"srcType\" | \"pk\">,\n subFn: Observer<\n ObserveLinks.CallbackArgs<\n CompileTimeMetadata<T>[\"links\"][L][\"targetType\"]\n >\n >,\n ): Unsubscribable;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAdA,WAkCiBA,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","names":[],"sources":["common.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 InterfaceDefinition,\n ObjectTypeDefinition,\n PropertyKeys,\n} from \"@osdk/api\";\n\n/**\n * Represents the current state of an observation.\n *\n * - init: Initial state before any data fetch attempt\n * - loading: Request is in progress\n * - loaded: Data successfully retrieved\n * - error: Request failed\n */\nexport type Status = \"init\" | \"loading\" | \"loaded\" | \"error\";\n\n/**\n * Standard observer pattern interface for reactive data flow.\n *\n * @template T Type of data being observed\n *\n * Callbacks:\n * - next: Called with updated values when data changes\n * - error: Called when an error occurs\n * - complete: Called when observation completes (rarely used)\n */\nexport interface Observer<T> {\n next: (value: T) => void;\n error: (err: any) => void;\n complete: () => void;\n}\n\n/**\n * Common options shared by all observation methods.\n *\n * @property dedupeInterval - Time in milliseconds to deduplicate identical emissions\n * Used to prevent rapid UI updates when multiple changes occur\n */\nexport interface CommonObserveOptions extends ObserveOptions {\n dedupeInterval?: number;\n}\n\n/**\n * Options for object observation.\n *\n * @property mode - Data fetch strategy:\n * - offline: Use only cached data, no network request\n * - force: Always fetch from server, ignore cache\n * - undefined (default): Use cache if available, fetch if missing\n */\nexport interface ObserveOptions {\n mode?: \"offline\" | \"force\";\n}\n\n/**\n * Specifies sort order for collection queries.\n *\n * @template Q Object or interface type whose properties can be sorted\n *\n * Values:\n * - \"asc\": Sort in ascending order\n * - \"desc\": Sort in descending order\n * - undefined: Don't sort by this property\n *\n * Example: `{ name: \"asc\", created: \"desc\" }`\n */\nexport type OrderBy<Q extends ObjectTypeDefinition | InterfaceDefinition> = {\n [K in PropertyKeys<Q>]?: \"asc\" | \"desc\" | undefined;\n};\n\n/**\n * Defines how data should be handled during invalidation.\n *\n * Values:\n * - \"in-place\": Update data without resetting the collection\n * - \"wait\": Wait for the server response before updating\n * - \"reset\": Clear existing data and refetch entirely\n */\nexport type InvalidationMode = \"in-place\" | \"wait\" | \"reset\";\n"],"mappings":"","ignoreList":[]}
|
|
@@ -21,6 +21,26 @@ import { OBSERVABLE_USER_AGENT } from "../util/UserAgent.js";
|
|
|
21
21
|
import { ObservableClientImpl } from "./internal/ObservableClientImpl.js";
|
|
22
22
|
import { Store } from "./internal/Store.js";
|
|
23
23
|
export let ObservableClient;
|
|
24
|
+
// TODO: Rename this from `ObserveObjectArgs` => `ObserveObjectCallbackArgs`. Not doing it now to reduce churn
|
|
25
|
+
// in repo.
|
|
26
|
+
|
|
27
|
+
// TODO: Rename this from `ObserveObjectsArgs` => `ObserveObjectsCallbackArgs`. Not doing it now to reduce churn
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* User facing callback args for `observeLink`
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Public interface for reactive data management with automatic updates.
|
|
35
|
+
*
|
|
36
|
+
* The ObservableClient provides a reactive data layer with:
|
|
37
|
+
* - Real-time object and collection observation
|
|
38
|
+
* - Automatic cache updates when data changes
|
|
39
|
+
* - Optimistic updates for immediate UI feedback
|
|
40
|
+
* - Pagination support for large collections
|
|
41
|
+
* - Link traversal for relationship navigation
|
|
42
|
+
*/
|
|
43
|
+
|
|
24
44
|
export function createObservableClient(client) {
|
|
25
45
|
// First we need a modified client that adds an extra header so we know its
|
|
26
46
|
// an observable client
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableClient.js","names":["createFetchHeaderMutator","additionalContext","createClientFromContext","OBSERVABLE_USER_AGENT","ObservableClientImpl","Store","ObservableClient","createObservableClient","client","tweakedClient","fetch","headers","set","get","filter","x","length","join"],"sources":["ObservableClient.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionValidationResponse,\n InterfaceDefinition,\n ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/api\";\nimport { createFetchHeaderMutator } from \"@osdk/shared.net.fetch\";\nimport type { ActionSignatureFromDef } from \"../actions/applyAction.js\";\nimport { additionalContext, type Client } from \"../Client.js\";\nimport { createClientFromContext } from \"../createClient.js\";\nimport { OBSERVABLE_USER_AGENT } from \"../util/UserAgent.js\";\nimport type { Canonical } from \"./internal/Canonical.js\";\nimport { ObservableClientImpl } from \"./internal/ObservableClientImpl.js\";\nimport { Store } from \"./internal/Store.js\";\nimport type {
|
|
1
|
+
{"version":3,"file":"ObservableClient.js","names":["createFetchHeaderMutator","additionalContext","createClientFromContext","OBSERVABLE_USER_AGENT","ObservableClientImpl","Store","ObservableClient","createObservableClient","client","tweakedClient","fetch","headers","set","get","filter","x","length","join"],"sources":["ObservableClient.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionValidationResponse,\n InterfaceDefinition,\n ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/api\";\nimport { createFetchHeaderMutator } from \"@osdk/shared.net.fetch\";\nimport type { ActionSignatureFromDef } from \"../actions/applyAction.js\";\nimport { additionalContext, type Client } from \"../Client.js\";\nimport { createClientFromContext } from \"../createClient.js\";\nimport { OBSERVABLE_USER_AGENT } from \"../util/UserAgent.js\";\nimport type { Canonical } from \"./internal/Canonical.js\";\nimport { ObservableClientImpl } from \"./internal/ObservableClientImpl.js\";\nimport { Store } from \"./internal/Store.js\";\nimport type {\n CommonObserveOptions,\n InvalidationMode,\n ObserveOptions,\n Observer,\n Status,\n} from \"./ObservableClient/common.js\";\nimport type { ObserveLinks } from \"./ObservableClient/ObserveLink.js\";\nimport type { OptimisticBuilder } from \"./OptimisticBuilder.js\";\n\nexport namespace ObservableClient {\n export interface ApplyActionOptions {\n optimisticUpdate?: (ctx: OptimisticBuilder) => void;\n }\n}\n\nexport interface ObserveObjectOptions<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> extends ObserveOptions {\n apiName: T[\"apiName\"] | T;\n pk: PrimaryKeyType<T>;\n select?: PropertyKeys<T>[];\n}\n\nexport type OrderBy<Q extends ObjectTypeDefinition | InterfaceDefinition> = {\n [K in PropertyKeys<Q>]?: \"asc\" | \"desc\" | undefined;\n};\n\nexport interface ObserveListOptions<\n Q extends ObjectTypeDefinition | InterfaceDefinition,\n> extends CommonObserveOptions, ObserveOptions {\n type: Pick<Q, \"apiName\" | \"type\">;\n where?: WhereClause<Q>;\n pageSize?: number;\n orderBy?: OrderBy<Q>;\n invalidationMode?: InvalidationMode;\n expectedLength?: number;\n streamUpdates?: boolean;\n}\n\n// TODO: Rename this from `ObserveObjectArgs` => `ObserveObjectCallbackArgs`. Not doing it now to reduce churn\n// in repo.\nexport interface ObserveObjectArgs<T extends ObjectTypeDefinition> {\n object: Osdk.Instance<T> | undefined;\n isOptimistic: boolean;\n status: Status;\n lastUpdated: number;\n}\n\n// TODO: Rename this from `ObserveObjectsArgs` => `ObserveObjectsCallbackArgs`. Not doing it now to reduce churn\nexport interface ObserveObjectsArgs<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n resolvedList: Array<Osdk.Instance<T>>;\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<void>;\n hasMore: boolean;\n status: Status;\n}\n\n/**\n * User facing callback args for `observeLink`\n */\nexport interface ObserveLinkCallbackArgs<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n resolvedList: Osdk.Instance<T>[];\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<void>;\n hasMore: boolean;\n status: Status;\n}\n\n/**\n * Public interface for reactive data management with automatic updates.\n *\n * The ObservableClient provides a reactive data layer with:\n * - Real-time object and collection observation\n * - Automatic cache updates when data changes\n * - Optimistic updates for immediate UI feedback\n * - Pagination support for large collections\n * - Link traversal for relationship navigation\n */\nexport interface ObservableClient extends ObserveLinks {\n /**\n * Observe a single object with automatic updates when it changes.\n *\n * @param apiName - The object type definition or name\n * @param pk - The object's primary key\n * @param options - Observation options including deduplication interval\n * @param subFn - Observer that receives object state updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * The observer will receive:\n * - Initial loading state if data not cached\n * - Loaded state with the object data\n * - Updates when the object changes\n * - Error state if fetch fails\n */\n observeObject<T extends ObjectTypeDefinition>(\n apiName: T[\"apiName\"] | T,\n pk: PrimaryKeyType<T>,\n options: ObserveOptions,\n subFn: Observer<ObserveObjectArgs<T>>,\n ): Unsubscribable;\n\n /**\n * Observe a filtered and sorted collection of objects.\n *\n * @param options - Filter, sort, and pagination options\n * @param subFn - Observer that receives collection state updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * Supports:\n * - Filtering with where clauses\n * - Sorting with orderBy\n * - Pagination via fetchMore() in the payload\n * - Automatic updates when any matching object changes\n */\n observeList<T extends ObjectTypeDefinition | InterfaceDefinition>(\n options: ObserveListOptions<T>,\n subFn: Observer<ObserveObjectsArgs<T>>,\n ): Unsubscribable;\n\n /**\n * Execute an action with optional optimistic updates.\n *\n * @param action - Action definition to execute\n * @param args - Arguments for the action\n * @param opts - Options including optimistic updates\n * @returns Promise that resolves when the action completes\n *\n * When providing optimistic updates:\n * - Changes appear immediately in the UI\n * - Server request still happens in background\n * - On success, server data replaces optimistic data\n * - On failure, optimistic changes automatically roll back\n */\n applyAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args:\n | Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]\n | Array<Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]>,\n opts?: ObservableClient.ApplyActionOptions,\n ) => Promise<unknown>;\n\n /**\n * Validate action parameters without executing the action.\n *\n * @param action - Action definition to validate\n * @param args - Arguments to validate\n * @returns Promise with validation result\n *\n * Use this to:\n * - Pre-validate forms before submission\n * - Display warnings or errors in the UI\n * - Enable/disable action buttons based on validity\n */\n validateAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ) => Promise<ActionValidationResponse>;\n\n canonicalizeWhereClause: <\n T extends ObjectTypeDefinition | InterfaceDefinition,\n >(\n where: WhereClause<T>,\n ) => Canonical<WhereClause<T>>;\n}\n\nexport function createObservableClient(client: Client): ObservableClient {\n // First we need a modified client that adds an extra header so we know its\n // an observable client\n const tweakedClient = createClientFromContext({\n ...client[additionalContext],\n\n fetch: createFetchHeaderMutator(\n client[additionalContext].fetch,\n (headers) => {\n headers.set(\n \"Fetch-User-Agent\",\n [\n headers.get(\"Fetch-User-Agent\"),\n OBSERVABLE_USER_AGENT,\n ].filter(x => x && x?.length > 0).join(\" \"),\n );\n return headers;\n },\n ),\n });\n\n // Then we use that client instead. Because the `client` does not hold\n // any real state, this whole thing works.\n return new ObservableClientImpl(new Store(tweakedClient));\n}\n\nexport interface Unsubscribable {\n unsubscribe: () => void;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,SAASA,wBAAwB,QAAQ,wBAAwB;AAEjE,SAASC,iBAAiB,QAAqB,cAAc;AAC7D,SAASC,uBAAuB,QAAQ,oBAAoB;AAC5D,SAASC,qBAAqB,QAAQ,sBAAsB;AAE5D,SAASC,oBAAoB,QAAQ,oCAAoC;AACzE,SAASC,KAAK,QAAQ,qBAAqB;AAAC,WAW3BC,gBAAgB;AA8BjC;AACA;;AAQA;;AAYA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwFA,OAAO,SAASC,sBAAsBA,CAACC,MAAc,EAAoB;EACvE;EACA;EACA,MAAMC,aAAa,GAAGP,uBAAuB,CAAC;IAC5C,GAAGM,MAAM,CAACP,iBAAiB,CAAC;IAE5BS,KAAK,EAAEV,wBAAwB,CAC7BQ,MAAM,CAACP,iBAAiB,CAAC,CAACS,KAAK,EAC9BC,OAAO,IAAK;MACXA,OAAO,CAACC,GAAG,CACT,kBAAkB,EAClB,CACED,OAAO,CAACE,GAAG,CAAC,kBAAkB,CAAC,EAC/BV,qBAAqB,CACtB,CAACW,MAAM,CAACC,CAAC,IAAIA,CAAC,IAAIA,CAAC,EAAEC,MAAM,GAAG,CAAC,CAAC,CAACC,IAAI,CAAC,GAAG,CAC5C,CAAC;MACD,OAAON,OAAO;IAChB,CACF;EACF,CAAC,CAAC;;EAEF;EACA;EACA,OAAO,IAAIP,oBAAoB,CAAC,IAAIC,KAAK,CAACI,aAAa,CAAC,CAAC;AAC3D","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Unsubscribable.js","names":[],"sources":["Unsubscribable.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\nexport interface Unsubscribable {\n unsubscribe: () => void;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
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 { QuerySubscription } from "./QuerySubscription.js";
|
|
18
|
+
export class AbstractHelper {
|
|
19
|
+
constructor(store) {
|
|
20
|
+
this.store = store;
|
|
21
|
+
}
|
|
22
|
+
observe(options, subFn) {
|
|
23
|
+
const query = this.getQuery(options);
|
|
24
|
+
return this._subscribe(query, options, subFn);
|
|
25
|
+
}
|
|
26
|
+
_subscribe(query, options, subFn) {
|
|
27
|
+
// the ListQuery represents the shared state of the list
|
|
28
|
+
this.store.retain(query.cacheKey);
|
|
29
|
+
if (options.mode !== "offline") {
|
|
30
|
+
query.revalidate(options.mode === "force").catch(e => {
|
|
31
|
+
subFn.error(e);
|
|
32
|
+
|
|
33
|
+
// we don't want observeObject() to return a promise,
|
|
34
|
+
// so we settle for logging an error here instead of
|
|
35
|
+
// dropping it on the floor.
|
|
36
|
+
if (this.store.logger) {
|
|
37
|
+
this.store.logger.error("Unhandled error in observeObject", e);
|
|
38
|
+
} else {
|
|
39
|
+
throw e;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const sub = query.subscribe(subFn);
|
|
44
|
+
sub.add(() => {
|
|
45
|
+
this.store.release(query.cacheKey);
|
|
46
|
+
});
|
|
47
|
+
return new QuerySubscription(query, sub);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=AbstractHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractHelper.js","names":["QuerySubscription","AbstractHelper","constructor","store","observe","options","subFn","query","getQuery","_subscribe","retain","cacheKey","mode","revalidate","catch","e","error","logger","sub","subscribe","add","release"],"sources":["AbstractHelper.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 CommonObserveOptions,\n Observer,\n} from \"../ObservableClient/common.js\";\nimport type { KnownCacheKey } from \"./KnownCacheKey.js\";\nimport type { Query } from \"./Query.js\";\nimport { QuerySubscription } from \"./QuerySubscription.js\";\nimport type { Store } from \"./Store.js\";\n\nexport abstract class AbstractHelper<\n TQuery extends Query<KnownCacheKey, any, CommonObserveOptions>,\n TObserveOptions extends CommonObserveOptions,\n> {\n protected readonly store: Store;\n\n constructor(store: Store) {\n this.store = store;\n }\n\n observe(\n options: TObserveOptions,\n subFn: Observer<\n TQuery extends Query<any, infer PAYLOAD, any> ? PAYLOAD : never\n >,\n ): QuerySubscription<TQuery> {\n const query = this.getQuery(options);\n return this._subscribe(query, options, subFn);\n }\n\n abstract getQuery(options: TObserveOptions): TQuery;\n\n protected _subscribe(\n query: TQuery,\n options: TObserveOptions,\n subFn: Observer<\n TQuery extends Query<any, infer PAYLOAD, any> ? PAYLOAD : never\n >,\n ): QuerySubscription<TQuery> {\n // the ListQuery represents the shared state of the list\n this.store.retain(query.cacheKey);\n\n if (options.mode !== \"offline\") {\n query.revalidate(options.mode === \"force\").catch((e: unknown) => {\n subFn.error(e);\n\n // we don't want observeObject() to return a promise,\n // so we settle for logging an error here instead of\n // dropping it on the floor.\n if (this.store.logger) {\n this.store.logger.error(\"Unhandled error in observeObject\", e);\n } else {\n throw e;\n }\n });\n }\n const sub = query.subscribe(subFn);\n sub.add(() => {\n this.store.release(query.cacheKey);\n });\n\n return new QuerySubscription(query, sub);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAASA,iBAAiB,QAAQ,wBAAwB;AAG1D,OAAO,MAAeC,cAAc,CAGlC;EAGAC,WAAWA,CAACC,KAAY,EAAE;IACxB,IAAI,CAACA,KAAK,GAAGA,KAAK;EACpB;EAEAC,OAAOA,CACLC,OAAwB,EACxBC,KAEC,EAC0B;IAC3B,MAAMC,KAAK,GAAG,IAAI,CAACC,QAAQ,CAACH,OAAO,CAAC;IACpC,OAAO,IAAI,CAACI,UAAU,CAACF,KAAK,EAAEF,OAAO,EAAEC,KAAK,CAAC;EAC/C;EAIUG,UAAUA,CAClBF,KAAa,EACbF,OAAwB,EACxBC,KAEC,EAC0B;IAC3B;IACA,IAAI,CAACH,KAAK,CAACO,MAAM,CAACH,KAAK,CAACI,QAAQ,CAAC;IAEjC,IAAIN,OAAO,CAACO,IAAI,KAAK,SAAS,EAAE;MAC9BL,KAAK,CAACM,UAAU,CAACR,OAAO,CAACO,IAAI,KAAK,OAAO,CAAC,CAACE,KAAK,CAAEC,CAAU,IAAK;QAC/DT,KAAK,CAACU,KAAK,CAACD,CAAC,CAAC;;QAEd;QACA;QACA;QACA,IAAI,IAAI,CAACZ,KAAK,CAACc,MAAM,EAAE;UACrB,IAAI,CAACd,KAAK,CAACc,MAAM,CAACD,KAAK,CAAC,kCAAkC,EAAED,CAAC,CAAC;QAChE,CAAC,MAAM;UACL,MAAMA,CAAC;QACT;MACF,CAAC,CAAC;IACJ;IACA,MAAMG,GAAG,GAAGX,KAAK,CAACY,SAAS,CAACb,KAAK,CAAC;IAClCY,GAAG,CAACE,GAAG,CAAC,MAAM;MACZ,IAAI,CAACjB,KAAK,CAACkB,OAAO,CAACd,KAAK,CAACI,QAAQ,CAAC;IACpC,CAAC,CAAC;IAEF,OAAO,IAAIX,iBAAiB,CAACO,KAAK,EAAEW,GAAG,CAAC;EAC1C;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseCollectionQuery.js","names":[],"sources":["BaseCollectionQuery.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 { Status } from \"../ObservableClient/common.js\";\nimport { type ObjectCacheKey } from \"./ObjectQuery.js\";\n\n/**\n * Abstract base for ListQuery and SpecificLinkQuery.\n * - Stores object references, not duplicates\n * - Implements shared pagination and reference counting\n * - Template method pattern for collection operations\n */\nexport interface CollectionStorageData {\n data: ObjectCacheKey[];\n}\n\n/**\n * Base interface for collection-based payloads (lists and links)\n * Contains the common properties shared by all collection payload types\n */\nexport interface BaseCollectionPayload {\n /**\n * The resolved collection of objects\n */\n resolvedList: Array<ObjectHolder | InterfaceHolder>;\n\n /**\n * Whether the data is from an optimistic update\n */\n isOptimistic: boolean;\n\n /**\n * Function to fetch more items when available\n */\n fetchMore: () => Promise<void>;\n\n /**\n * Whether there are more items available to fetch\n */\n hasMore: boolean;\n\n /**\n * Current loading status\n */\n status: Status;\n\n /**\n * Timestamp of when the data was last updated\n */\n lastUpdated: number;\n}\n\n/**\n * Common parameters available for constructing a collection payload\n */\nexport interface CollectionConnectableParams {\n /**\n * Array of resolved objects\n */\n resolvedData: any[];\n\n /**\n * Whether the data is from an optimistic update\n */\n isOptimistic: boolean;\n\n /**\n * Current loading status\n */\n status: Status;\n\n /**\n * Timestamp of the last update\n */\n lastUpdated: number;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -37,7 +37,7 @@ export class BulkObjectLoader {
|
|
|
37
37
|
this.#maxWait = maxWait;
|
|
38
38
|
this.#maxEntries = maxEntries;
|
|
39
39
|
}
|
|
40
|
-
fetch(apiName, primaryKey) {
|
|
40
|
+
async fetch(apiName, primaryKey) {
|
|
41
41
|
const deferred = pDefer();
|
|
42
42
|
const entry = this.#m.get(apiName);
|
|
43
43
|
entry.data.push({
|
|
@@ -53,7 +53,7 @@ export class BulkObjectLoader {
|
|
|
53
53
|
clearTimeout(entry.timer);
|
|
54
54
|
this.#loadObjects(apiName, entry.data);
|
|
55
55
|
}
|
|
56
|
-
return deferred.promise;
|
|
56
|
+
return await deferred.promise;
|
|
57
57
|
}
|
|
58
58
|
#loadObjects(apiName, arr) {
|
|
59
59
|
this.#m.delete(apiName);
|
|
@@ -85,7 +85,7 @@ export class BulkObjectLoader {
|
|
|
85
85
|
if (object) {
|
|
86
86
|
deferred.resolve(object);
|
|
87
87
|
} else {
|
|
88
|
-
deferred.reject(new PalantirApiError(
|
|
88
|
+
deferred.reject(new PalantirApiError(`Object not found: ${primaryKey}`));
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BulkObjectLoader.js","names":["PalantirApiError","DefaultMap","DefaultWeakMap","pDefer","additionalContext","weakCache","c","BulkObjectLoader","getBulkObjectLoader","client","get","m","data","timer","undefined","logger","maxWait","maxEntries","constructor","fetch","apiName","primaryKey","deferred","entry","push","setTimeout","loadObjects","length","clearTimeout","promise","#loadObjects","arr","delete","reallyLoadObjects","catch","e","error","#reallyLoadObjects","miniDef","type","objMetadata","fetchMetadata","pks","map","x","where","primaryKeyApiName","$in","fetchPage","$pageSize","object","find","$primaryKey","resolve","reject"],"sources":["BulkObjectLoader.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Logger, ObjectTypeDefinition } from \"@osdk/api\";\nimport { PalantirApiError } from \"@osdk/shared.net.errors\";\nimport { DefaultMap, DefaultWeakMap } from \"mnemonist\";\nimport type { DeferredPromise } from \"p-defer\";\nimport pDefer from \"p-defer\";\nimport { additionalContext, type Client } from \"../../Client.js\";\nimport type {\n ObjectHolder,\n} from \"../../object/convertWireToOsdkObjects/ObjectHolder.js\";\n\ninterface InternalValue {\n primaryKey: string;\n deferred: DeferredPromise<ObjectHolder>;\n}\n\ninterface Accumulator {\n data: InternalValue[];\n timer?: ReturnType<typeof setTimeout>;\n}\n\nconst weakCache = new DefaultWeakMap<Client, BulkObjectLoader>(c =>\n new BulkObjectLoader(c)\n);\n\nexport function getBulkObjectLoader(client: Client): BulkObjectLoader {\n return weakCache.get(client);\n}\n\nexport class BulkObjectLoader {\n #client: Client;\n\n #m = new DefaultMap<string, Accumulator>(() => ({\n data: [],\n timer: undefined,\n }));\n #logger: Logger | undefined;\n #maxWait: number;\n #maxEntries: number;\n\n constructor(client: Client, maxWait = 25, maxEntries = 100) {\n this.#client = client;\n this.#logger = client[additionalContext].logger;\n this.#maxWait = maxWait;\n this.#maxEntries = maxEntries;\n }\n\n public fetch(\n apiName: string,\n primaryKey: string | number | boolean,\n ): Promise<ObjectHolder> {\n const deferred = pDefer<ObjectHolder>();\n\n const entry = this.#m.get(apiName);\n entry.data.push({\n primaryKey: primaryKey as string,\n deferred,\n });\n\n if (!entry.timer) {\n entry.timer = setTimeout(() => {\n this.#loadObjects(apiName, entry.data);\n }, this.#maxWait);\n }\n\n if (entry.data.length >= this.#maxEntries) {\n clearTimeout(entry.timer);\n this.#loadObjects(apiName, entry.data);\n }\n\n return deferred.promise;\n }\n\n #loadObjects(apiName: string, arr: InternalValue[]) {\n this.#m.delete(apiName);\n\n this.#reallyLoadObjects(apiName, arr).catch((e: unknown) => {\n this.#logger?.error(\"Unhandled exception\", e);\n });\n }\n\n async #reallyLoadObjects(apiName: string, arr: InternalValue[]) {\n const miniDef = { type: \"object\", apiName } as ObjectTypeDefinition;\n const objMetadata = await this.#client.fetchMetadata(miniDef);\n\n const pks = arr.map(x => x.primaryKey);\n\n const { data } = await this.#client(miniDef)\n .where({\n [objMetadata.primaryKeyApiName]: { $in: pks },\n }).fetchPage({\n $pageSize: pks.length,\n });\n\n for (const { primaryKey, deferred } of arr) {\n const object = data.find(x => x.$primaryKey === primaryKey) as\n | ObjectHolder\n | undefined;\n if (object) {\n deferred.resolve(object);\n } else {\n deferred.reject(new PalantirApiError(
|
|
1
|
+
{"version":3,"file":"BulkObjectLoader.js","names":["PalantirApiError","DefaultMap","DefaultWeakMap","pDefer","additionalContext","weakCache","c","BulkObjectLoader","getBulkObjectLoader","client","get","m","data","timer","undefined","logger","maxWait","maxEntries","constructor","fetch","apiName","primaryKey","deferred","entry","push","setTimeout","loadObjects","length","clearTimeout","promise","#loadObjects","arr","delete","reallyLoadObjects","catch","e","error","#reallyLoadObjects","miniDef","type","objMetadata","fetchMetadata","pks","map","x","where","primaryKeyApiName","$in","fetchPage","$pageSize","object","find","$primaryKey","resolve","reject"],"sources":["BulkObjectLoader.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Logger, ObjectTypeDefinition } from \"@osdk/api\";\nimport { PalantirApiError } from \"@osdk/shared.net.errors\";\nimport { DefaultMap, DefaultWeakMap } from \"mnemonist\";\nimport type { DeferredPromise } from \"p-defer\";\nimport pDefer from \"p-defer\";\nimport { additionalContext, type Client } from \"../../Client.js\";\nimport type {\n ObjectHolder,\n} from \"../../object/convertWireToOsdkObjects/ObjectHolder.js\";\n\ninterface InternalValue {\n primaryKey: string;\n deferred: DeferredPromise<ObjectHolder>;\n}\n\ninterface Accumulator {\n data: InternalValue[];\n timer?: ReturnType<typeof setTimeout>;\n}\n\nconst weakCache = new DefaultWeakMap<Client, BulkObjectLoader>(c =>\n new BulkObjectLoader(c)\n);\n\nexport function getBulkObjectLoader(client: Client): BulkObjectLoader {\n return weakCache.get(client);\n}\n\nexport class BulkObjectLoader {\n #client: Client;\n\n #m = new DefaultMap<string, Accumulator>(() => ({\n data: [],\n timer: undefined,\n }));\n #logger: Logger | undefined;\n #maxWait: number;\n #maxEntries: number;\n\n constructor(client: Client, maxWait = 25, maxEntries = 100) {\n this.#client = client;\n this.#logger = client[additionalContext].logger;\n this.#maxWait = maxWait;\n this.#maxEntries = maxEntries;\n }\n\n public async fetch(\n apiName: string,\n primaryKey: string | number | boolean,\n ): Promise<ObjectHolder> {\n const deferred = pDefer<ObjectHolder>();\n\n const entry = this.#m.get(apiName);\n entry.data.push({\n primaryKey: primaryKey as string,\n deferred,\n });\n\n if (!entry.timer) {\n entry.timer = setTimeout(() => {\n this.#loadObjects(apiName, entry.data);\n }, this.#maxWait);\n }\n\n if (entry.data.length >= this.#maxEntries) {\n clearTimeout(entry.timer);\n this.#loadObjects(apiName, entry.data);\n }\n\n return await deferred.promise;\n }\n\n #loadObjects(apiName: string, arr: InternalValue[]) {\n this.#m.delete(apiName);\n\n this.#reallyLoadObjects(apiName, arr).catch((e: unknown) => {\n this.#logger?.error(\"Unhandled exception\", e);\n });\n }\n\n async #reallyLoadObjects(apiName: string, arr: InternalValue[]) {\n const miniDef = { type: \"object\", apiName } as ObjectTypeDefinition;\n const objMetadata = await this.#client.fetchMetadata(miniDef);\n\n const pks = arr.map(x => x.primaryKey);\n\n const { data } = await this.#client(miniDef)\n .where({\n [objMetadata.primaryKeyApiName]: { $in: pks },\n }).fetchPage({\n $pageSize: pks.length,\n });\n\n for (const { primaryKey, deferred } of arr) {\n const object = data.find(x => x.$primaryKey === primaryKey) as\n | ObjectHolder\n | undefined;\n if (object) {\n deferred.resolve(object);\n } else {\n deferred.reject(\n new PalantirApiError(`Object not found: ${primaryKey}`),\n );\n }\n }\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,gBAAgB,QAAQ,yBAAyB;AAC1D,SAASC,UAAU,EAAEC,cAAc,QAAQ,WAAW;AAEtD,OAAOC,MAAM,MAAM,SAAS;AAC5B,SAASC,iBAAiB,QAAqB,iBAAiB;AAehE,MAAMC,SAAS,GAAG,IAAIH,cAAc,CAA2BI,CAAC,IAC9D,IAAIC,gBAAgB,CAACD,CAAC,CACxB,CAAC;AAED,OAAO,SAASE,mBAAmBA,CAACC,MAAc,EAAoB;EACpE,OAAOJ,SAAS,CAACK,GAAG,CAACD,MAAM,CAAC;AAC9B;AAEA,OAAO,MAAMF,gBAAgB,CAAC;EAC5B,CAACE,MAAM;EAEP,CAACE,CAAC,GAAG,IAAIV,UAAU,CAAsB,OAAO;IAC9CW,IAAI,EAAE,EAAE;IACRC,KAAK,EAAEC;EACT,CAAC,CAAC,CAAC;EACH,CAACC,MAAM;EACP,CAACC,OAAO;EACR,CAACC,UAAU;EAEXC,WAAWA,CAACT,MAAc,EAAEO,OAAO,GAAG,EAAE,EAAEC,UAAU,GAAG,GAAG,EAAE;IAC1D,IAAI,CAAC,CAACR,MAAM,GAAGA,MAAM;IACrB,IAAI,CAAC,CAACM,MAAM,GAAGN,MAAM,CAACL,iBAAiB,CAAC,CAACW,MAAM;IAC/C,IAAI,CAAC,CAACC,OAAO,GAAGA,OAAO;IACvB,IAAI,CAAC,CAACC,UAAU,GAAGA,UAAU;EAC/B;EAEA,MAAaE,KAAKA,CAChBC,OAAe,EACfC,UAAqC,EACd;IACvB,MAAMC,QAAQ,GAAGnB,MAAM,CAAe,CAAC;IAEvC,MAAMoB,KAAK,GAAG,IAAI,CAAC,CAACZ,CAAC,CAACD,GAAG,CAACU,OAAO,CAAC;IAClC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AM,IAAI,CAAC,CAACH,MAAM,CAAC6B,OAAO,CAAC,CACzCO,KAAK,CAAC;MACL,CAACL,WAAW,CAACM,iBAAiB,GAAG;QAAEC,GAAG,EAAEL;MAAI;IAC9C,CAAC,CAAC,CAACM,SAAS,CAAC;MACXC,SAAS,EAAEP,GAAG,CAACf;IACjB,CAAC,CAAC;IAEJ,KAAK,MAAM;MAAEN,UAAU;MAAEC;IAAS,CAAC,IAAIS,GAAG,EAAE;MAC1C,MAAMmB,MAAM,GAAGtC,IAAI,CAACuC,IAAI,CAACP,CAAC,IAAIA,CAAC,CAACQ,WAAW,KAAK/B,UAAU,CAE7C;MACb,IAAI6B,MAAM,EAAE;QACV5B,QAAQ,CAAC+B,OAAO,CAACH,MAAM,CAAC;MAC1B,CAAC,MAAM;QACL5B,QAAQ,CAACgC,MAAM,CACb,IAAItD,gBAAgB,CAAC,qBAAqBqB,UAAU,EAAE,CACxD,CAAC;MACH;IACF;EACF;AACF","ignoreList":[]}
|
|
@@ -17,6 +17,12 @@
|
|
|
17
17
|
import { Trie } from "@wry/trie";
|
|
18
18
|
import invariant from "tiny-invariant";
|
|
19
19
|
import { DEBUG_CACHE_KEYS } from "../DebugFlags.js";
|
|
20
|
+
/**
|
|
21
|
+
* Cache key management with canonicalization.
|
|
22
|
+
* - Formats: {type}:{pk} | {type}:list:{where} | {source}:{pk}:{link}:{where}
|
|
23
|
+
* - Uses Trie structure for efficient storage and lookup
|
|
24
|
+
* - Ensures consistent keys through canonicalization
|
|
25
|
+
*/
|
|
20
26
|
export class CacheKeys {
|
|
21
27
|
#cacheKeys = new Trie(false, keys => {
|
|
22
28
|
const ret = {
|
|
@@ -38,11 +44,20 @@ export class CacheKeys {
|
|
|
38
44
|
return this.#cacheKeys.lookupArray(["object", apiName, pk]);
|
|
39
45
|
});
|
|
40
46
|
this.#registerCacheKeyFactory("list", (type, apiName, where, orderBy) => {
|
|
47
|
+
const cacheKeyArgs = ["list", type, apiName, whereCanonicalizer.canonicalize(where), orderByCanonicalizer.canonicalize(orderBy)];
|
|
48
|
+
if (process.env.NODE_ENV !== "production" && DEBUG_CACHE_KEYS) {
|
|
49
|
+
// eslint-disable-next-line no-console
|
|
50
|
+
console.debug(`CacheKeys.get([list, ${apiName}, ${JSON.stringify(where)}, ${JSON.stringify(orderBy)}]) -- already exists? `, this.#cacheKeys.peekArray(cacheKeyArgs) != null);
|
|
51
|
+
}
|
|
52
|
+
return this.#cacheKeys.lookupArray(cacheKeyArgs);
|
|
53
|
+
});
|
|
54
|
+
this.#registerCacheKeyFactory("specificLink", (sourceObjectType, sourcePk, linkName, where, orderBy) => {
|
|
55
|
+
const cacheKeyArgs = ["specificLink", sourceObjectType, sourcePk, linkName, whereCanonicalizer.canonicalize(where), orderByCanonicalizer.canonicalize(orderBy)];
|
|
41
56
|
if (process.env.NODE_ENV !== "production" && DEBUG_CACHE_KEYS) {
|
|
42
57
|
// eslint-disable-next-line no-console
|
|
43
|
-
console.debug(`CacheKeys.get([
|
|
58
|
+
console.debug(`CacheKeys.get([specificLink, ${sourceObjectType}, ${sourcePk}, ${linkName}, ${JSON.stringify(where)}, ${JSON.stringify(orderBy)}]) -- already exists? `, this.#cacheKeys.peekArray(cacheKeyArgs) != null);
|
|
44
59
|
}
|
|
45
|
-
return this.#cacheKeys.lookupArray(
|
|
60
|
+
return this.#cacheKeys.lookupArray(cacheKeyArgs);
|
|
46
61
|
});
|
|
47
62
|
}
|
|
48
63
|
#registerCacheKeyFactory(type, factory) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CacheKeys.js","names":["Trie","invariant","DEBUG_CACHE_KEYS","CacheKeys","cacheKeys","keys","ret","type","otherKeys","slice","onCreate","cacheKeyFactories","Map","constructor","whereCanonicalizer","orderByCanonicalizer","registerCacheKeyFactory","apiName","pk","process","env","NODE_ENV","console","debug","peekArray","lookupArray","where","orderBy","JSON","stringify","
|
|
1
|
+
{"version":3,"file":"CacheKeys.js","names":["Trie","invariant","DEBUG_CACHE_KEYS","CacheKeys","cacheKeys","keys","ret","type","otherKeys","slice","onCreate","cacheKeyFactories","Map","constructor","whereCanonicalizer","orderByCanonicalizer","registerCacheKeyFactory","apiName","pk","process","env","NODE_ENV","console","debug","peekArray","lookupArray","where","orderBy","cacheKeyArgs","canonicalize","JSON","stringify","sourceObjectType","sourcePk","linkName","#registerCacheKeyFactory","factory","set","get","args","remove","cacheKey"],"sources":["CacheKeys.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Trie } from \"@wry/trie\";\nimport invariant from \"tiny-invariant\";\nimport { DEBUG_CACHE_KEYS } from \"../DebugFlags.js\";\nimport type { CacheKey } from \"./CacheKey.js\";\nimport type { KnownCacheKey } from \"./KnownCacheKey.js\";\nimport type { SpecificLinkCacheKey } from \"./links/SpecificLinkCacheKey.js\";\nimport type { ListCacheKey } from \"./ListCacheKey.js\";\nimport type { ObjectCacheKey } from \"./ObjectQuery.js\";\nimport type { OrderByCanonicalizer } from \"./OrderByCanonicalizer.js\";\nimport type { WhereClauseCanonicalizer } from \"./WhereClauseCanonicalizer.js\";\n\ntype CacheKeyArgs<K extends CacheKey> = [K[\"type\"], ...K[\"otherKeys\"]];\n\n/**\n * Cache key management with canonicalization.\n * - Formats: {type}:{pk} | {type}:list:{where} | {source}:{pk}:{link}:{where}\n * - Uses Trie structure for efficient storage and lookup\n * - Ensures consistent keys through canonicalization\n */\nexport class CacheKeys {\n #cacheKeys = new Trie<KnownCacheKey>(false, (keys) => {\n const ret = {\n type: keys[0],\n otherKeys: keys.slice(1),\n } as unknown as KnownCacheKey;\n this.#onCreate(ret);\n return ret;\n });\n #cacheKeyFactories = new Map<string, (...args: any[]) => KnownCacheKey>();\n #onCreate: (cacheKey: KnownCacheKey) => void;\n\n constructor(\n whereCanonicalizer: WhereClauseCanonicalizer,\n orderByCanonicalizer: OrderByCanonicalizer,\n onCreate: (cacheKey: KnownCacheKey) => void,\n ) {\n this.#onCreate = onCreate;\n this.#registerCacheKeyFactory<ObjectCacheKey>(\n \"object\",\n (apiName, pk) => {\n if (process.env.NODE_ENV !== \"production\" && DEBUG_CACHE_KEYS) {\n // eslint-disable-next-line no-console\n console.debug(\n `CacheKeys.get([object, ${apiName}, ${pk}]) -- already exists? `,\n this.#cacheKeys.peekArray([\n \"object\",\n apiName,\n pk,\n ]) != null,\n );\n }\n return this.#cacheKeys.lookupArray([\n \"object\",\n apiName,\n pk,\n ]) as ObjectCacheKey;\n },\n );\n this.#registerCacheKeyFactory<ListCacheKey>(\n \"list\",\n (type, apiName, where, orderBy) => {\n const cacheKeyArgs: CacheKeyArgs<ListCacheKey> = [\n \"list\",\n type,\n apiName,\n whereCanonicalizer.canonicalize(where),\n orderByCanonicalizer.canonicalize(orderBy),\n ];\n\n if (process.env.NODE_ENV !== \"production\" && DEBUG_CACHE_KEYS) {\n // eslint-disable-next-line no-console\n console.debug(\n `CacheKeys.get([list, ${apiName}, ${JSON.stringify(where)}, ${\n JSON.stringify(orderBy)\n }]) -- already exists? `,\n this.#cacheKeys.peekArray(cacheKeyArgs) != null,\n );\n }\n\n return this.#cacheKeys.lookupArray<\n CacheKeyArgs<ListCacheKey>\n >(cacheKeyArgs) as ListCacheKey;\n },\n );\n this.#registerCacheKeyFactory<SpecificLinkCacheKey>(\n \"specificLink\",\n (sourceObjectType, sourcePk, linkName, where, orderBy) => {\n const cacheKeyArgs: CacheKeyArgs<SpecificLinkCacheKey> = [\n \"specificLink\",\n sourceObjectType,\n sourcePk,\n linkName,\n whereCanonicalizer.canonicalize(where),\n orderByCanonicalizer.canonicalize(orderBy),\n ];\n\n if (process.env.NODE_ENV !== \"production\" && DEBUG_CACHE_KEYS) {\n // eslint-disable-next-line no-console\n console.debug(\n `CacheKeys.get([specificLink, ${sourceObjectType}, ${sourcePk}, ${linkName}, ${\n JSON.stringify(where)\n }, ${JSON.stringify(orderBy)}]) -- already exists? `,\n this.#cacheKeys.peekArray(cacheKeyArgs) != null,\n );\n }\n\n return this.#cacheKeys.lookupArray(\n cacheKeyArgs,\n ) as SpecificLinkCacheKey;\n },\n );\n }\n\n #registerCacheKeyFactory<K extends KnownCacheKey>(\n type: K[\"type\"],\n factory: (...args: K[\"__cacheKey\"][\"args\"]) => K,\n ): void {\n this.#cacheKeyFactories.set(type, factory);\n }\n\n get<K extends KnownCacheKey>(\n type: K[\"type\"],\n ...args: K[\"__cacheKey\"][\"args\"]\n ): K {\n const factory = this.#cacheKeyFactories.get(type);\n invariant(factory, `no cache key factory for type \"${type}\"`);\n return factory(...args) as K;\n }\n\n remove<K extends KnownCacheKey>(\n cacheKey: K,\n ): void {\n this.#cacheKeys.remove(cacheKey.type, ...cacheKey.otherKeys);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,IAAI,QAAQ,WAAW;AAChC,OAAOC,SAAS,MAAM,gBAAgB;AACtC,SAASC,gBAAgB,QAAQ,kBAAkB;AAWnD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,SAAS,CAAC;EACrB,CAACC,SAAS,GAAG,IAAIJ,IAAI,CAAgB,KAAK,EAAGK,IAAI,IAAK;IACpD,MAAMC,GAAG,GAAG;MACVC,IAAI,EAAEF,IAAI,CAAC,CAAC,CAAC;MACbG,SAAS,EAAEH,IAAI,CAACI,KAAK,CAAC,CAAC;IACzB,CAA6B;IAC7B,IAAI,CAAC,CAACC,QAAQ,CAACJ,GAAG,CAAC;IACnB,OAAOA,GAAG;EACZ,CAAC,C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IAA5DN,SAAS;IACT,OAAOmC,OAAO,CAAC,GAAGG,IAAI,CAAC;EACzB;EAEAC,MAAMA,CACJC,QAAW,EACL;IACN,IAAI,CAAC,CAACrC,SAAS,CAACoC,MAAM,CAACC,QAAQ,CAAClC,IAAI,EAAE,GAAGkC,QAAQ,CAACjC,SAAS,CAAC;EAC9D;AACF","ignoreList":[]}
|
|
@@ -32,6 +32,12 @@ export class Changes {
|
|
|
32
32
|
registerList = key => {
|
|
33
33
|
this.modified.add(key);
|
|
34
34
|
};
|
|
35
|
+
registerLink = cacheKey => {
|
|
36
|
+
this.modified.add(cacheKey);
|
|
37
|
+
};
|
|
38
|
+
deleteLink = cacheKey => {
|
|
39
|
+
this.deleted.add(cacheKey);
|
|
40
|
+
};
|
|
35
41
|
isEmpty() {
|
|
36
42
|
return this.modifiedObjects.size === 0 && this.addedObjects.size === 0 && this.added.size === 0 && this.modified.size === 0 && this.deleted.size === 0;
|
|
37
43
|
}
|