@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,4 +1,4 @@
|
|
|
1
|
-
import { ObjectOrInterfaceDefinition, PropertyKeys, Augment, ObjectTypeDefinition,
|
|
1
|
+
import { ObjectOrInterfaceDefinition, PropertyKeys, Augment, ObjectTypeDefinition, InterfaceDefinition, CompileTimeMetadata, PrimaryKeyType, WhereClause, Osdk, ActionDefinition, ActionValidationResponse } from '@osdk/api';
|
|
2
2
|
import { C as Client, A as ActionSignatureFromDef } from '../Client-CF85LpFu.cjs';
|
|
3
3
|
export { a as createClientWithTransaction } from '../createClient-BJo8T7Js.cjs';
|
|
4
4
|
import '@osdk/shared.client';
|
|
@@ -11,24 +11,109 @@ type Canonical<T> = T & {
|
|
|
11
11
|
__canonical: true;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Represents the current state of an observation.
|
|
16
|
+
*
|
|
17
|
+
* - init: Initial state before any data fetch attempt
|
|
18
|
+
* - loading: Request is in progress
|
|
19
|
+
* - loaded: Data successfully retrieved
|
|
20
|
+
* - error: Request failed
|
|
21
|
+
*/
|
|
20
22
|
type Status = "init" | "loading" | "loaded" | "error";
|
|
23
|
+
/**
|
|
24
|
+
* Standard observer pattern interface for reactive data flow.
|
|
25
|
+
*
|
|
26
|
+
* @template T Type of data being observed
|
|
27
|
+
*
|
|
28
|
+
* Callbacks:
|
|
29
|
+
* - next: Called with updated values when data changes
|
|
30
|
+
* - error: Called when an error occurs
|
|
31
|
+
* - complete: Called when observation completes (rarely used)
|
|
32
|
+
*/
|
|
21
33
|
interface Observer<T> {
|
|
22
34
|
next: (value: T) => void;
|
|
23
35
|
error: (err: any) => void;
|
|
24
36
|
complete: () => void;
|
|
25
37
|
}
|
|
26
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Common options shared by all observation methods.
|
|
40
|
+
*
|
|
41
|
+
* @property dedupeInterval - Time in milliseconds to deduplicate identical emissions
|
|
42
|
+
* Used to prevent rapid UI updates when multiple changes occur
|
|
43
|
+
*/
|
|
44
|
+
interface CommonObserveOptions extends ObserveOptions {
|
|
27
45
|
dedupeInterval?: number;
|
|
28
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Options for object observation.
|
|
49
|
+
*
|
|
50
|
+
* @property mode - Data fetch strategy:
|
|
51
|
+
* - offline: Use only cached data, no network request
|
|
52
|
+
* - force: Always fetch from server, ignore cache
|
|
53
|
+
* - undefined (default): Use cache if available, fetch if missing
|
|
54
|
+
*/
|
|
29
55
|
interface ObserveOptions {
|
|
30
56
|
mode?: "offline" | "force";
|
|
31
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Specifies sort order for collection queries.
|
|
60
|
+
*
|
|
61
|
+
* @template Q Object or interface type whose properties can be sorted
|
|
62
|
+
*
|
|
63
|
+
* Values:
|
|
64
|
+
* - "asc": Sort in ascending order
|
|
65
|
+
* - "desc": Sort in descending order
|
|
66
|
+
* - undefined: Don't sort by this property
|
|
67
|
+
*
|
|
68
|
+
* Example: `{ name: "asc", created: "desc" }`
|
|
69
|
+
*/
|
|
70
|
+
type OrderBy$1<Q extends ObjectTypeDefinition | InterfaceDefinition> = {
|
|
71
|
+
[K in PropertyKeys<Q>]?: "asc" | "desc" | undefined;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Defines how data should be handled during invalidation.
|
|
75
|
+
*
|
|
76
|
+
* Values:
|
|
77
|
+
* - "in-place": Update data without resetting the collection
|
|
78
|
+
* - "wait": Wait for the server response before updating
|
|
79
|
+
* - "reset": Clear existing data and refetch entirely
|
|
80
|
+
*/
|
|
81
|
+
type InvalidationMode = "in-place" | "wait" | "reset";
|
|
82
|
+
|
|
83
|
+
interface Unsubscribable$1 {
|
|
84
|
+
unsubscribe: () => void;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
declare namespace ObserveLinks {
|
|
88
|
+
interface Options<Q extends ObjectTypeDefinition | InterfaceDefinition, L extends keyof CompileTimeMetadata<Q>["links"] & string> extends CommonObserveOptions, ObserveOptions {
|
|
89
|
+
srcType: Pick<Q, "type" | "apiName">;
|
|
90
|
+
pk: PrimaryKeyType<Q>;
|
|
91
|
+
linkName: L;
|
|
92
|
+
where?: WhereClause<CompileTimeMetadata<Q>["links"][L]["targetType"]>;
|
|
93
|
+
pageSize?: number;
|
|
94
|
+
orderBy?: OrderBy$1<CompileTimeMetadata<Q>["links"][L]["targetType"]>;
|
|
95
|
+
invalidationMode?: InvalidationMode;
|
|
96
|
+
expectedLength?: number;
|
|
97
|
+
}
|
|
98
|
+
interface CallbackArgs<T extends ObjectTypeDefinition | InterfaceDefinition> {
|
|
99
|
+
resolvedList: Osdk.Instance<T>[];
|
|
100
|
+
isOptimistic: boolean;
|
|
101
|
+
lastUpdated: number;
|
|
102
|
+
fetchMore: () => Promise<void>;
|
|
103
|
+
hasMore: boolean;
|
|
104
|
+
status: Status;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
interface ObserveLinks {
|
|
108
|
+
observeLinks<T extends ObjectTypeDefinition | InterfaceDefinition, L extends keyof CompileTimeMetadata<T>["links"] & string>(objects: Osdk.Instance<T> | ReadonlyArray<Osdk.Instance<T>>, linkName: L, options: Omit<ObserveLinks.Options<T, L>, "srcType" | "pk">, subFn: Observer<ObserveLinks.CallbackArgs<CompileTimeMetadata<T>["links"][L]["targetType"]>>): Unsubscribable$1;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
interface OptimisticBuilder {
|
|
112
|
+
updateObject: <T extends ObjectTypeDefinition>(value: Osdk.Instance<T>) => this;
|
|
113
|
+
createObject: <T extends ObjectTypeDefinition>(type: T, primaryKey: PrimaryKeyType<T>, properties: Pick<Osdk.Instance<T>, PropertyKeys<T>>) => this;
|
|
114
|
+
deleteObject: <T extends ObjectTypeDefinition>(value: Osdk.Instance<T>) => this;
|
|
115
|
+
}
|
|
116
|
+
|
|
32
117
|
type OrderBy<Q extends ObjectTypeDefinition | InterfaceDefinition> = {
|
|
33
118
|
[K in PropertyKeys<Q>]?: "asc" | "desc" | undefined;
|
|
34
119
|
};
|
|
@@ -37,7 +122,7 @@ interface ObserveListOptions<Q extends ObjectTypeDefinition | InterfaceDefinitio
|
|
|
37
122
|
where?: WhereClause<Q>;
|
|
38
123
|
pageSize?: number;
|
|
39
124
|
orderBy?: OrderBy<Q>;
|
|
40
|
-
invalidationMode?:
|
|
125
|
+
invalidationMode?: InvalidationMode;
|
|
41
126
|
expectedLength?: number;
|
|
42
127
|
streamUpdates?: boolean;
|
|
43
128
|
}
|
|
@@ -51,7 +136,7 @@ interface ObserveObjectsArgs<T extends ObjectTypeDefinition | InterfaceDefinitio
|
|
|
51
136
|
resolvedList: Array<Osdk.Instance<T>>;
|
|
52
137
|
isOptimistic: boolean;
|
|
53
138
|
lastUpdated: number;
|
|
54
|
-
fetchMore: () => Promise<
|
|
139
|
+
fetchMore: () => Promise<void>;
|
|
55
140
|
hasMore: boolean;
|
|
56
141
|
status: Status;
|
|
57
142
|
}
|
|
@@ -60,10 +145,74 @@ declare namespace ObservableClient {
|
|
|
60
145
|
optimisticUpdate?: (ctx: OptimisticBuilder) => void;
|
|
61
146
|
}
|
|
62
147
|
}
|
|
63
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Public interface for reactive data management with automatic updates.
|
|
150
|
+
*
|
|
151
|
+
* The ObservableClient provides a reactive data layer with:
|
|
152
|
+
* - Real-time object and collection observation
|
|
153
|
+
* - Automatic cache updates when data changes
|
|
154
|
+
* - Optimistic updates for immediate UI feedback
|
|
155
|
+
* - Pagination support for large collections
|
|
156
|
+
* - Link traversal for relationship navigation
|
|
157
|
+
*/
|
|
158
|
+
interface ObservableClient extends ObserveLinks {
|
|
159
|
+
/**
|
|
160
|
+
* Observe a single object with automatic updates when it changes.
|
|
161
|
+
*
|
|
162
|
+
* @param apiName - The object type definition or name
|
|
163
|
+
* @param pk - The object's primary key
|
|
164
|
+
* @param options - Observation options including deduplication interval
|
|
165
|
+
* @param subFn - Observer that receives object state updates
|
|
166
|
+
* @returns Subscription that can be unsubscribed to stop updates
|
|
167
|
+
*
|
|
168
|
+
* The observer will receive:
|
|
169
|
+
* - Initial loading state if data not cached
|
|
170
|
+
* - Loaded state with the object data
|
|
171
|
+
* - Updates when the object changes
|
|
172
|
+
* - Error state if fetch fails
|
|
173
|
+
*/
|
|
64
174
|
observeObject<T extends ObjectTypeDefinition>(apiName: T["apiName"] | T, pk: PrimaryKeyType<T>, options: ObserveOptions, subFn: Observer<ObserveObjectArgs<T>>): Unsubscribable;
|
|
175
|
+
/**
|
|
176
|
+
* Observe a filtered and sorted collection of objects.
|
|
177
|
+
*
|
|
178
|
+
* @param options - Filter, sort, and pagination options
|
|
179
|
+
* @param subFn - Observer that receives collection state updates
|
|
180
|
+
* @returns Subscription that can be unsubscribed to stop updates
|
|
181
|
+
*
|
|
182
|
+
* Supports:
|
|
183
|
+
* - Filtering with where clauses
|
|
184
|
+
* - Sorting with orderBy
|
|
185
|
+
* - Pagination via fetchMore() in the payload
|
|
186
|
+
* - Automatic updates when any matching object changes
|
|
187
|
+
*/
|
|
65
188
|
observeList<T extends ObjectTypeDefinition | InterfaceDefinition>(options: ObserveListOptions<T>, subFn: Observer<ObserveObjectsArgs<T>>): Unsubscribable;
|
|
189
|
+
/**
|
|
190
|
+
* Execute an action with optional optimistic updates.
|
|
191
|
+
*
|
|
192
|
+
* @param action - Action definition to execute
|
|
193
|
+
* @param args - Arguments for the action
|
|
194
|
+
* @param opts - Options including optimistic updates
|
|
195
|
+
* @returns Promise that resolves when the action completes
|
|
196
|
+
*
|
|
197
|
+
* When providing optimistic updates:
|
|
198
|
+
* - Changes appear immediately in the UI
|
|
199
|
+
* - Server request still happens in background
|
|
200
|
+
* - On success, server data replaces optimistic data
|
|
201
|
+
* - On failure, optimistic changes automatically roll back
|
|
202
|
+
*/
|
|
66
203
|
applyAction: <Q extends ActionDefinition<any>>(action: Q, args: Parameters<ActionSignatureFromDef<Q>["applyAction"]>[0] | Array<Parameters<ActionSignatureFromDef<Q>["applyAction"]>[0]>, opts?: ObservableClient.ApplyActionOptions) => Promise<unknown>;
|
|
204
|
+
/**
|
|
205
|
+
* Validate action parameters without executing the action.
|
|
206
|
+
*
|
|
207
|
+
* @param action - Action definition to validate
|
|
208
|
+
* @param args - Arguments to validate
|
|
209
|
+
* @returns Promise with validation result
|
|
210
|
+
*
|
|
211
|
+
* Use this to:
|
|
212
|
+
* - Pre-validate forms before submission
|
|
213
|
+
* - Display warnings or errors in the UI
|
|
214
|
+
* - Enable/disable action buttons based on validity
|
|
215
|
+
*/
|
|
67
216
|
validateAction: <Q extends ActionDefinition<any>>(action: Q, args: Parameters<ActionSignatureFromDef<Q>["applyAction"]>[0]) => Promise<ActionValidationResponse>;
|
|
68
217
|
canonicalizeWhereClause: <T extends ObjectTypeDefinition | InterfaceDefinition>(where: WhereClause<T>) => Canonical<WhereClause<T>>;
|
|
69
218
|
}
|
|
@@ -81,4 +230,4 @@ interface OsdkConfig {
|
|
|
81
230
|
}
|
|
82
231
|
declare function getOsdkConfig(ontologyRid: string): OsdkConfig;
|
|
83
232
|
|
|
84
|
-
export { ActionSignatureFromDef, ObservableClient, type ObserveObjectArgs, type ObserveObjectsArgs, type Observer, type OsdkConfig, type Unsubscribable, augment, createObservableClient, getMetaTagContent, getOsdkConfig };
|
|
233
|
+
export { ActionSignatureFromDef, ObservableClient, ObserveLinks, type ObserveObjectArgs, type ObserveObjectsArgs, type Observer, type OsdkConfig, type Unsubscribable, augment, createObservableClient, getMetaTagContent, getOsdkConfig };
|
package/build/esm/Client.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
export const additionalContext = Symbol("additionalContext");
|
|
22
22
|
|
|
23
23
|
// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.
|
|
24
|
-
const MaxOsdkVersion = "2.
|
|
24
|
+
const MaxOsdkVersion = "2.5.0";
|
|
25
25
|
// END: THIS IS GENERATED CODE. DO NOT EDIT.
|
|
26
26
|
|
|
27
27
|
const ErrorMessage = Symbol("ErrorMessage");
|
package/build/esm/Client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.js","names":["additionalContext","Symbol","MaxOsdkVersion","ErrorMessage"],"sources":["Client.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 ActionDefinition,\n ActionMetadata,\n CompileTimeMetadata,\n InterfaceDefinition,\n InterfaceMetadata,\n ObjectMetadata,\n ObjectSet,\n ObjectTypeDefinition,\n QueryDefinition,\n QueryMetadata,\n VersionBound,\n} from \"@osdk/api\";\nimport type {\n Experiment,\n ExperimentFns,\n MinimalObjectSet,\n} from \"@osdk/api/unstable\";\nimport type { SharedClient } from \"@osdk/shared.client2\";\nimport type { ActionSignatureFromDef } from \"./actions/applyAction.js\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport type { QuerySignatureFromDef } from \"./queries/types.js\";\nimport type { SatisfiesSemver } from \"./SatisfiesSemver.js\";\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\ntype OldSharedClient = import(\"@osdk/shared.client\").SharedClient;\n\nexport type CheckVersionBound<Q> = Q extends VersionBound<infer V> ? (\n SatisfiesSemver<V, MaxOsdkVersion> extends true ? Q\n : Q & {\n [ErrorMessage]:\n `Your SDK requires a semver compatible version with ${V}. You have ${MaxOsdkVersion}. Update your package.json`;\n }\n )\n : Q;\n\nexport interface Client extends SharedClient, OldSharedClient {\n <Q extends ObjectTypeDefinition>(\n o: Q,\n ): unknown extends CompileTimeMetadata<Q>[\"objectSet\"] ? ObjectSet<Q>\n : CompileTimeMetadata<Q>[\"objectSet\"];\n\n <Q extends (InterfaceDefinition)>(\n o: Q,\n ): unknown extends CompileTimeMetadata<Q>[\"objectSet\"] ? MinimalObjectSet<Q>\n : CompileTimeMetadata<Q>[\"objectSet\"];\n\n <Q extends ActionDefinition<any>>(\n o: Q,\n ): ActionSignatureFromDef<Q>;\n\n <Q extends QueryDefinition<any>>(\n o: Q,\n ): QuerySignatureFromDef<Q>;\n\n <Q extends Experiment<\"2.0.8\"> | Experiment<\"2.1.0\"> | Experiment<\"2.2.0\">>(\n experiment: Q,\n ): ExperimentFns<Q>;\n\n fetchMetadata<\n Q extends (\n | ObjectTypeDefinition\n | InterfaceDefinition\n | ActionDefinition<any>\n | QueryDefinition<any>\n ),\n >(o: Q): Promise<\n Q extends ObjectTypeDefinition ? ObjectMetadata\n : Q extends InterfaceDefinition ? InterfaceMetadata\n : Q extends ActionDefinition<any> ? ActionMetadata\n : Q extends QueryDefinition<any> ? QueryMetadata\n : never\n >;\n\n /** @internal */\n [additionalContext]: MinimalClient;\n}\n\n// DO NOT EXPORT FROM PACKAGE\n/** @internal */\nexport const additionalContext: unique symbol = Symbol(\"additionalContext\");\n\n// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.\nconst MaxOsdkVersion = \"2.
|
|
1
|
+
{"version":3,"file":"Client.js","names":["additionalContext","Symbol","MaxOsdkVersion","ErrorMessage"],"sources":["Client.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 ActionDefinition,\n ActionMetadata,\n CompileTimeMetadata,\n InterfaceDefinition,\n InterfaceMetadata,\n ObjectMetadata,\n ObjectSet,\n ObjectTypeDefinition,\n QueryDefinition,\n QueryMetadata,\n VersionBound,\n} from \"@osdk/api\";\nimport type {\n Experiment,\n ExperimentFns,\n MinimalObjectSet,\n} from \"@osdk/api/unstable\";\nimport type { SharedClient } from \"@osdk/shared.client2\";\nimport type { ActionSignatureFromDef } from \"./actions/applyAction.js\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport type { QuerySignatureFromDef } from \"./queries/types.js\";\nimport type { SatisfiesSemver } from \"./SatisfiesSemver.js\";\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\ntype OldSharedClient = import(\"@osdk/shared.client\").SharedClient;\n\nexport type CheckVersionBound<Q> = Q extends VersionBound<infer V> ? (\n SatisfiesSemver<V, MaxOsdkVersion> extends true ? Q\n : Q & {\n [ErrorMessage]:\n `Your SDK requires a semver compatible version with ${V}. You have ${MaxOsdkVersion}. Update your package.json`;\n }\n )\n : Q;\n\nexport interface Client extends SharedClient, OldSharedClient {\n <Q extends ObjectTypeDefinition>(\n o: Q,\n ): unknown extends CompileTimeMetadata<Q>[\"objectSet\"] ? ObjectSet<Q>\n : CompileTimeMetadata<Q>[\"objectSet\"];\n\n <Q extends (InterfaceDefinition)>(\n o: Q,\n ): unknown extends CompileTimeMetadata<Q>[\"objectSet\"] ? MinimalObjectSet<Q>\n : CompileTimeMetadata<Q>[\"objectSet\"];\n\n <Q extends ActionDefinition<any>>(\n o: Q,\n ): ActionSignatureFromDef<Q>;\n\n <Q extends QueryDefinition<any>>(\n o: Q,\n ): QuerySignatureFromDef<Q>;\n\n <Q extends Experiment<\"2.0.8\"> | Experiment<\"2.1.0\"> | Experiment<\"2.2.0\">>(\n experiment: Q,\n ): ExperimentFns<Q>;\n\n fetchMetadata<\n Q extends (\n | ObjectTypeDefinition\n | InterfaceDefinition\n | ActionDefinition<any>\n | QueryDefinition<any>\n ),\n >(o: Q): Promise<\n Q extends ObjectTypeDefinition ? ObjectMetadata\n : Q extends InterfaceDefinition ? InterfaceMetadata\n : Q extends ActionDefinition<any> ? ActionMetadata\n : Q extends QueryDefinition<any> ? QueryMetadata\n : never\n >;\n\n /** @internal */\n [additionalContext]: MinimalClient;\n}\n\n// DO NOT EXPORT FROM PACKAGE\n/** @internal */\nexport const additionalContext: unique symbol = Symbol(\"additionalContext\");\n\n// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.\nconst MaxOsdkVersion = \"2.5.0\";\n// END: THIS IS GENERATED CODE. DO NOT EDIT.\nexport type MaxOsdkVersion = typeof MaxOsdkVersion;\nconst ErrorMessage: unique symbol = Symbol(\"ErrorMessage\");\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA0BA;;AAsDA;AACA;AACA,OAAO,MAAMA,iBAAgC,GAAGC,MAAM,CAAC,mBAAmB,CAAC;;AAE3E;AACA,MAAMC,cAAc,GAAG,OAAO;AAC9B;;AAEA,MAAMC,YAA2B,GAAGF,MAAM,CAAC,cAAc,CAAC","ignoreList":[]}
|
|
@@ -21,10 +21,17 @@
|
|
|
21
21
|
|
|
22
22
|
import { Employee } from "@osdk/client.test.ontology";
|
|
23
23
|
void client(Employee).fetchPage({
|
|
24
|
-
|
|
24
|
+
// @ts-expect-error
|
|
25
|
+
$orderBy: {
|
|
26
|
+
"": ""
|
|
27
|
+
}
|
|
25
28
|
});
|
|
26
29
|
void client(Employee).fetchPage({
|
|
27
30
|
// @ts-expect-error
|
|
28
31
|
$orderBy
|
|
29
32
|
});
|
|
33
|
+
void client(Employee).fetchPage({
|
|
34
|
+
// @ts-expect-error
|
|
35
|
+
$orderBy: ""
|
|
36
|
+
});
|
|
30
37
|
//# sourceMappingURL=orderBySuggestionIsRight.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orderBySuggestionIsRight.js","names":["Employee","client","fetchPage","$orderBy"],"sources":["orderBySuggestionIsRight.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\n// WARNING!\n// WARNING!\n// This file is used for tests that check intellisense. Editing this file by hand will likely\n// break tests that have hard coded line numbers and line offsets.\n\nimport { Employee } from \"@osdk/client.test.ontology\";\nimport type { Client } from \"../Client.js\";\n\ndeclare const client: Client;\n\nvoid client(Employee).fetchPage({\n $orderBy: {},\n});\n\nvoid client(Employee).fetchPage({\n // @ts-expect-error\n $orderBy,\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,4BAA4B;AAKrD,KAAKC,MAAM,CAACD,QAAQ,CAAC,CAACE,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"orderBySuggestionIsRight.js","names":["Employee","client","fetchPage","$orderBy"],"sources":["orderBySuggestionIsRight.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\n// WARNING!\n// WARNING!\n// This file is used for tests that check intellisense. Editing this file by hand will likely\n// break tests that have hard coded line numbers and line offsets.\n\nimport { Employee } from \"@osdk/client.test.ontology\";\nimport type { Client } from \"../Client.js\";\n\ndeclare const client: Client;\n\nvoid client(Employee).fetchPage({\n // @ts-expect-error\n $orderBy: { \"\": \"\" },\n});\n\nvoid client(Employee).fetchPage({\n // @ts-expect-error\n $orderBy,\n});\n\nvoid client(Employee).fetchPage({\n // @ts-expect-error\n $orderBy: \"\",\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,4BAA4B;AAKrD,KAAKC,MAAM,CAACD,QAAQ,CAAC,CAACE,SAAS,CAAC;EAC9B;EACAC,QAAQ,EAAE;IAAE,EAAE,EAAE;EAAG;AACrB,CAAC,CAAC;AAEF,KAAKF,MAAM,CAACD,QAAQ,CAAC,CAACE,SAAS,CAAC;EAC9B;EACAC;AACF,CAAC,CAAC;AAEF,KAAKF,MAAM,CAACD,QAAQ,CAAC,CAACE,SAAS,CAAC;EAC9B;EACAC,QAAQ,EAAE;AACZ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -108,20 +108,30 @@ describe("intellisense", () => {
|
|
|
108
108
|
resp
|
|
109
109
|
} = await tsServer.sendCompletionsRequest({
|
|
110
110
|
file: intellisenseFilePath,
|
|
111
|
-
line:
|
|
112
|
-
offset:
|
|
111
|
+
line: 29,
|
|
112
|
+
offset: 15,
|
|
113
113
|
triggerKind: ts.CompletionTriggerKind.Invoked
|
|
114
114
|
});
|
|
115
|
-
expect(resp.body?.entries.length).toBeGreaterThan(2);
|
|
116
115
|
expect(resp.body?.entries.map(e => e.name)).toEqual(["class", "employeeId", "employeeLocation", "employeeSensor", "employeeStatus", "fullName", "office", "skillSet", "skillSetEmbedding", "startDate"]);
|
|
117
116
|
const {
|
|
118
117
|
resp: resp2
|
|
119
118
|
} = await tsServer.sendQuickInfoRequest({
|
|
120
119
|
file: intellisenseFilePath,
|
|
121
|
-
line:
|
|
120
|
+
line: 33,
|
|
122
121
|
offset: 3
|
|
123
122
|
});
|
|
124
123
|
expect(resp2.body?.documentation).not.toEqual("'(property) $orderBy: any'");
|
|
124
|
+
|
|
125
|
+
// order by relevance
|
|
126
|
+
const {
|
|
127
|
+
resp: resp3
|
|
128
|
+
} = await tsServer.sendCompletionsRequest({
|
|
129
|
+
file: intellisenseFilePath,
|
|
130
|
+
line: 39,
|
|
131
|
+
offset: 14,
|
|
132
|
+
triggerKind: ts.CompletionTriggerKind.Invoked
|
|
133
|
+
});
|
|
134
|
+
expect(resp3.body?.entries.map(e => e.name)).toEqual(["relevance"]);
|
|
125
135
|
});
|
|
126
136
|
});
|
|
127
137
|
//# sourceMappingURL=intellisense.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intellisense.test.js","names":["findUpSync","path","invariant","ts","afterEach","beforeAll","beforeEach","describe","expect","it","vi","startTsServer","rootLogger","hoisted","pino","pinoPretty","EventEmitter","Promise","resolve","level","build","sync","timestampKey","undefined","errorLikeObjectKeys","errorProps","ignore","destination","write","a","at","slice","console","log","packagesDir","clientPackagePath","clientsPackageJson","cwd","import","meta","dirname","process","env","NODE_ENV","join","tsServer","intellisenseFilePath","task","name","sys","fileExists","toBeTruthy","sendOpenRequest","file","stop","timeout","resp","sendQuickInfoRequest","line","offset","body","documentation","toMatchInlineSnapshot","sendCompletionsRequest","triggerKind","CompletionTriggerKind","Invoked","entries","
|
|
1
|
+
{"version":3,"file":"intellisense.test.js","names":["findUpSync","path","invariant","ts","afterEach","beforeAll","beforeEach","describe","expect","it","vi","startTsServer","rootLogger","hoisted","pino","pinoPretty","EventEmitter","Promise","resolve","level","build","sync","timestampKey","undefined","errorLikeObjectKeys","errorProps","ignore","destination","write","a","at","slice","console","log","packagesDir","clientPackagePath","clientsPackageJson","cwd","import","meta","dirname","process","env","NODE_ENV","join","tsServer","intellisenseFilePath","task","name","sys","fileExists","toBeTruthy","sendOpenRequest","file","stop","timeout","resp","sendQuickInfoRequest","line","offset","body","documentation","toMatchInlineSnapshot","sendCompletionsRequest","triggerKind","CompletionTriggerKind","Invoked","entries","map","e","toEqual","resp2","not","resp3"],"sources":["intellisense.test.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 { Logger } from \"@osdk/api\";\nimport { findUpSync } from \"find-up\";\nimport * as path from \"node:path\";\nimport invariant from \"tiny-invariant\";\nimport * as ts from \"typescript\";\nimport {\n afterEach,\n beforeAll,\n beforeEach,\n describe,\n expect,\n it,\n vi,\n} from \"vitest\";\nimport type { TsServer } from \"./tsserver.js\";\nimport { startTsServer } from \"./tsserver.js\";\n\n// it needs to be hoisted because its referenced from our mocked WebSocket\n// which must be hoisted to work\nconst rootLogger = await vi.hoisted(async (): Promise<Logger> => {\n const pino = (await import(\"pino\")).pino;\n const pinoPretty = await import(\"pino-pretty\");\n const { EventEmitter } = await import(\"node:events\");\n class PinoConsoleLogDestination extends EventEmitter {\n write(a: string) {\n // remove trailing newline since console.log adds one\n if (a.at(-1) === \"\\n\") a = a.slice(0, -1);\n\n // This lets the test framework aggregate the logs per test, whereas direct to stdout does not\n console.log(a);\n }\n }\n return Promise.resolve(pino(\n { level: \"info\" },\n (pinoPretty.build)({\n sync: true,\n timestampKey: undefined,\n errorLikeObjectKeys: [\"error\", \"err\", \"exception\"],\n errorProps: \"stack,cause,properties\",\n ignore: \"time,hostname,pid\",\n destination: new PinoConsoleLogDestination(),\n }),\n ));\n});\n\ndescribe(\"intellisense\", () => {\n let packagesDir: string;\n let clientPackagePath: string;\n\n beforeAll(() => {\n const clientsPackageJson = findUpSync(\"package.json\", {\n cwd: import.meta.dirname,\n });\n console.log({ clientsPackageJson });\n invariant(clientsPackageJson != null);\n packagesDir = path.join(\n path.dirname(clientsPackageJson),\n \"..\",\n );\n\n clientPackagePath = path.join(packagesDir, \"client\");\n });\n\n let tsServer: TsServer;\n let intellisenseFilePath: string;\n\n beforeEach(async (a) => {\n intellisenseFilePath = path.join(\n clientPackagePath,\n \"src\",\n \"intellisense.test.helpers\",\n `${a.task.name}.ts`,\n );\n\n console.log(intellisenseFilePath);\n\n expect(ts.sys.fileExists(intellisenseFilePath)).toBeTruthy();\n\n tsServer = await startTsServer(rootLogger);\n await tsServer.sendOpenRequest({ file: intellisenseFilePath });\n });\n\n afterEach(async () => {\n tsServer.stop();\n tsServer = undefined as any;\n });\n\n it(\"callsQueryAcceptsObject\", { timeout: 40_000 }, async () => {\n const { resp } = await tsServer.sendQuickInfoRequest({\n file: intellisenseFilePath,\n line: 27,\n offset: 6,\n });\n expect(resp.body?.documentation).toMatchInlineSnapshot(\n `\"(no ontology metadata)\"`,\n );\n });\n\n it(\"showsObjectPropertyJsdoc\", { timeout: 40_000 }, async () => {\n const { resp } = await tsServer.sendQuickInfoRequest({\n file: intellisenseFilePath,\n line: 26,\n offset: 13,\n });\n expect(resp.body?.documentation).toMatchInlineSnapshot(\n `\"description: Geotime series reference of the location of the employee\"`,\n );\n });\n\n it(\"orderBySuggestionIsRight\", { timeout: 40_000 }, async () => {\n const { resp } = await tsServer.sendCompletionsRequest({\n file: intellisenseFilePath,\n line: 29,\n offset: 15,\n triggerKind: ts.CompletionTriggerKind.Invoked,\n });\n expect(resp.body?.entries.map(e => e.name)).toEqual([\n \"class\",\n \"employeeId\",\n \"employeeLocation\",\n \"employeeSensor\",\n \"employeeStatus\",\n \"fullName\",\n \"office\",\n \"skillSet\",\n \"skillSetEmbedding\",\n \"startDate\",\n ]);\n\n const { resp: resp2 } = await tsServer.sendQuickInfoRequest({\n file: intellisenseFilePath,\n line: 33,\n offset: 3,\n });\n expect(resp2.body?.documentation).not.toEqual(\"'(property) $orderBy: any'\");\n\n // order by relevance\n const { resp: resp3 } = await tsServer.sendCompletionsRequest({\n file: intellisenseFilePath,\n line: 39,\n offset: 14,\n triggerKind: ts.CompletionTriggerKind.Invoked,\n });\n\n expect(resp3.body?.entries.map(e => e.name)).toEqual([\n \"relevance\",\n ]);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,UAAU,QAAQ,SAAS;AACpC,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,OAAOC,SAAS,MAAM,gBAAgB;AACtC,OAAO,KAAKC,EAAE,MAAM,YAAY;AAChC,SACEC,SAAS,EACTC,SAAS,EACTC,UAAU,EACVC,QAAQ,EACRC,MAAM,EACNC,EAAE,EACFC,EAAE,QACG,QAAQ;AAEf,SAASC,aAAa,QAAQ,eAAe;;AAE7C;AACA;AACA,MAAMC,UAAU,GAAG,MAAMF,EAAE,CAACG,OAAO,CAAC,YAA6B;EAC/D,MAAMC,IAAI,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,EAAEA,IAAI;EACxC,MAAMC,UAAU,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC;EAC9C,MAAM;IAAEC;EAAa,CAAC,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC;EAUpD,OAAOC,OAAO,CAACC,OAAO,CAACJ,IAAI,CACzB;IAAEK,KAAK,EAAE;EAAO,CAAC,EAChBJ,UAAU,CAACK,KAAK,CAAE;IACjBC,IAAI,EAAE,IAAI;IACVC,YAAY,EAAEC,SAAS;IACvBC,mBAAmB,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC;IAClDC,UAAU,EAAE,wBAAwB;IACpCC,MAAM,EAAE,mBAAmB;IAC3BC,WAAW,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Y,IAAI,EAAE,EAAE;MACRC,MAAM,EAAE,EAAE;MACVK,WAAW,EAAE7D,EAAE,CAAC8D,qBAAqB,CAACC;IACxC,CAAC,CAAC;IACF1D,MAAM,CAACgD,IAAI,CAACI,IAAI,EAAEO,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACrB,IAAI,CAAC,CAAC,CAACsB,OAAO,CAAC,CAClD,OAAO,EACP,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,WAAW,CACZ,CAAC;IAEF,MAAM;MAAEd,IAAI,EAAEe;IAAM,CAAC,GAAG,MAAM1B,QAAQ,CAACY,oBAAoB,CAAC;MAC1DJ,IAAI,EAAEP,oBAAoB;MAC1BY,IAAI,EAAE,EAAE;MACRC,MAAM,EAAE;IACV,CAAC,CAAC;IACFnD,MAAM,CAAC+D,KAAK,CAACX,IAAI,EAAEC,aAAa,CAAC,CAACW,GAAG,CAACF,OAAO,CAAC,4BAA4B,CAAC;;IAE3E;IACA,MAAM;MAAEd,IAAI,EAAEiB;IAAM,CAAC,GAAG,MAAM5B,QAAQ,CAACkB,sBAAsB,CAAC;MAC5DV,IAAI,EAAEP,oBAAoB;MAC1BY,IAAI,EAAE,EAAE;MACRC,MAAM,EAAE,EAAE;MACVK,WAAW,EAAE7D,EAAE,CAAC8D,qBAAqB,CAACC;IACxC,CAAC,CAAC;IAEF1D,MAAM,CAACiE,KAAK,CAACb,IAAI,EAAEO,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACrB,IAAI,CAAC,CAAC,CAACsB,OAAO,CAAC,CACnD,WAAW,CACZ,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -50,7 +50,7 @@ export function createClientCache(fn) {
|
|
|
50
50
|
if (cache.get(client.clientCacheKey) == null) {
|
|
51
51
|
cache.set(client.clientCacheKey, new Map());
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
const r = cache.get(client.clientCacheKey).get(key);
|
|
54
54
|
if (r === undefined && fn !== undefined) {
|
|
55
55
|
return set(client, key, fn(client, key));
|
|
56
56
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cache.js","names":["createClientCache","fn","cache","WeakMap","set","client","key","value","get","clientCacheKey","Map","r","undefined","remove","delete","createAsyncClientCache","createCacheLocal","inProgress","ret","getOrUndefined","k","v","e"],"sources":["Cache.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 { ClientCacheKey, MinimalClient } from \"../MinimalClientContext.js\";\n\n/**\n * A simple cache that can be used to store values for a given client.\n */\ninterface ClientCache<K, V> {\n get: (client: MinimalClient, key: K) => V;\n set: <X extends V>(client: MinimalClient, key: K, value: X) => X;\n remove: (client: MinimalClient, key: K) => boolean;\n}\n\n/**\n * @internal\n * A simple async cache that can be used to store values for a given client.\n */\nexport interface AsyncClientCache<K, V> {\n getOrUndefined: (client: MinimalClient, key: K) => V | undefined;\n\n get: (client: MinimalClient, key: K) => Promise<V>;\n\n /**\n * @param client the client to key from\n * @param key the sub-key to use\n * @param value the value or a promise to the value\n * @returns a new promise to the resolved value\n */\n set: (\n client: MinimalClient,\n key: K,\n value: V | Promise<V>,\n ) => Promise<V>;\n}\n\n/** @internal */\nexport type Factory<K, V> = (client: MinimalClient, key: K) => V;\n\n/**\n * @internal\n * Create a new cache without a factory function.\n */\nexport function createClientCache<K, V extends {}>(): ClientCache<\n K,\n V | undefined\n>;\n/**\n * @internal\n * Create a new cache with a factory function.\n * @param fn A factory function that will be used to create the value if it does not exist in the cache.\n */\nexport function createClientCache<K, V extends {}>(\n fn: Factory<K, V>,\n): ClientCache<K, V>;\nexport function createClientCache<K, V extends {}>(\n fn?: Factory<K, V>,\n): typeof fn extends undefined ? ClientCache<K, V | undefined>\n : ClientCache<K, V>\n{\n const cache = new WeakMap<\n ClientCacheKey,\n typeof fn extends undefined ? Map<K, V | undefined> : Map<K, V>\n >();\n\n function get(client: MinimalClient, key: K) {\n if (cache.get(client.clientCacheKey) == null) {\n cache.set(client.clientCacheKey, new Map());\n }\n
|
|
1
|
+
{"version":3,"file":"Cache.js","names":["createClientCache","fn","cache","WeakMap","set","client","key","value","get","clientCacheKey","Map","r","undefined","remove","delete","createAsyncClientCache","createCacheLocal","inProgress","ret","getOrUndefined","k","v","e"],"sources":["Cache.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 { ClientCacheKey, MinimalClient } from \"../MinimalClientContext.js\";\n\n/**\n * A simple cache that can be used to store values for a given client.\n */\ninterface ClientCache<K, V> {\n get: (client: MinimalClient, key: K) => V;\n set: <X extends V>(client: MinimalClient, key: K, value: X) => X;\n remove: (client: MinimalClient, key: K) => boolean;\n}\n\n/**\n * @internal\n * A simple async cache that can be used to store values for a given client.\n */\nexport interface AsyncClientCache<K, V> {\n getOrUndefined: (client: MinimalClient, key: K) => V | undefined;\n\n get: (client: MinimalClient, key: K) => Promise<V>;\n\n /**\n * @param client the client to key from\n * @param key the sub-key to use\n * @param value the value or a promise to the value\n * @returns a new promise to the resolved value\n */\n set: (\n client: MinimalClient,\n key: K,\n value: V | Promise<V>,\n ) => Promise<V>;\n}\n\n/** @internal */\nexport type Factory<K, V> = (client: MinimalClient, key: K) => V;\n\n/**\n * @internal\n * Create a new cache without a factory function.\n */\nexport function createClientCache<K, V extends {}>(): ClientCache<\n K,\n V | undefined\n>;\n/**\n * @internal\n * Create a new cache with a factory function.\n * @param fn A factory function that will be used to create the value if it does not exist in the cache.\n */\nexport function createClientCache<K, V extends {}>(\n fn: Factory<K, V>,\n): ClientCache<K, V>;\nexport function createClientCache<K, V extends {}>(\n fn?: Factory<K, V>,\n): typeof fn extends undefined ? ClientCache<K, V | undefined>\n : ClientCache<K, V>\n{\n const cache = new WeakMap<\n ClientCacheKey,\n typeof fn extends undefined ? Map<K, V | undefined> : Map<K, V>\n >();\n\n function get(client: MinimalClient, key: K) {\n if (cache.get(client.clientCacheKey) == null) {\n cache.set(client.clientCacheKey, new Map());\n }\n const r = cache.get(client.clientCacheKey)!.get(key);\n if (r === undefined && fn !== undefined) {\n return set(client, key, fn(client, key));\n } else {\n return r;\n }\n }\n\n function set(client: MinimalClient, key: K, value: V) {\n if (cache.get(client.clientCacheKey) == null) {\n cache.set(client.clientCacheKey, new Map());\n }\n\n cache.get(client.clientCacheKey)!.set(key, value);\n return value;\n }\n\n function remove(client: MinimalClient, key: K) {\n if (cache.get(client.clientCacheKey) == null) return false;\n return cache.get(client.clientCacheKey)!.delete(key);\n }\n\n return { get, set, remove } as ClientCache<K, V>;\n}\n\n/** @internal */\nexport type AsyncFactory<K, V extends {}> = (\n client: MinimalClient,\n key: K,\n) => Promise<V>;\n\n/**\n * @internal\n * Create a new cache with an async factory function.\n * @param fn A factory function that will be used to create the value if it does not exist in the cache.\n * @returns\n */\nexport function createAsyncClientCache<K, V extends {}>(\n fn: AsyncFactory<K, V>,\n createCacheLocal: typeof createClientCache = createClientCache,\n): AsyncClientCache<K, V> {\n const cache = createCacheLocal<K, V>();\n const inProgress = createCacheLocal<K, Promise<V> | V>();\n\n const ret = {\n getOrUndefined: function getOrUndefined(client: MinimalClient, key: K) {\n return cache.get(client, key);\n },\n\n get: async function get(client: MinimalClient, key: K) {\n return cache.get(client, key) ?? inProgress.get(client, key)\n ?? ret.set(client, key, fn(client, key));\n },\n\n set: async function set(client: MinimalClient, k: K, v: V | Promise<V>) {\n // the `.set` happens first to prevent races.\n try {\n const r = await inProgress.set(client, k, v); // returns v\n\n cache.set(client, k, r);\n inProgress.remove(client, k);\n return r;\n } catch (e) {\n // we don't want to cache failures\n inProgress.remove(client, k);\n throw e;\n }\n },\n };\n\n return ret;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AACA;;AAmBA;;AAGA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;;AAIA,OAAO,SAASA,iBAAiBA,CAC/BC,EAAkB,EAGpB;EACE,MAAMC,KAAK,GAAG,IAAIC,OAAO,CAGvB,CAAC;EAcH,SAASC,GAAGA,CAACC,MAAqB,EAAEC,GAAM,EAAEC,KAAQ,EAAE;IACpD,IAAIL,KAAK,CAACM,GAAG,CAACH,MAAM,CAACI,cAAc,CAAC,IAAI,IAAI,EAAE;MAC5CP,KAAK,CAACE,GAAG,CAACC,MAAM,CAACI,cAAc,EAAE,IAAIC,GAAG,CAAC,CAAC,CAAC;IAC7C;IAEAR,KAAK,CAACM,GAAG,CAACH,MAAM,CAACI,cAAc,CAAC,CAAEL,GAAG,CAACE,GAAG,EAAEC,KAAK,CAAC;IACjD,OAAOA,KAAK;EACd;EAOA,OAAO;IAAEC,GAAG,EA1BZ,SAAAA,CAAaH,MAAqB,EAAEC,GAAM,EAAE;MAC1C,IAAIJ,KAAK,CAACM,GAAG,CAACH,MAAM,CAACI,cAAc,CAAC,IAAI,IAAI,EAAE;QAC5CP,K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,GAAG,CAAC,IACvDY,GAAG,CAACd,GAAG,CAACC,MAAM,EAAEC,GAAG,EAAEL,EAAE,CAACI,MAAM,EAAEC,GAAG,CAAC,CAAC;IAC5C,CAAC;IAEDF,GAAG,EAAE,eAAAA,CAAmBC,MAAqB,EAAEe,CAAI,EAAEC,CAAiB,EAAE;MACtE;MACA,IAAI;QACF,MAAMV,CAAC,GAAG,MAAMM,UAAU,CAACb,GAAG,CAACC,MAAM,EAAEe,CAAC,EAAEC,CAAC,CAAC,CAAC,CAAC;;QAE9CnB,KAAK,CAACE,GAAG,CAACC,MAAM,EAAEe,CAAC,EAAET,CAAC,CAAC;QACvBM,UAAU,CAACJ,MAAM,CAACR,MAAM,EAAEe,CAAC,CAAC;QAC5B,OAAOT,CAAC;MACV,CAAC,CAAC,OAAOW,CAAC,EAAE;QACV;QACAL,UAAU,CAACJ,MAAM,CAACR,MAAM,EAAEe,CAAC,CAAC;QAC5B,MAAME,CAAC;MACT;IACF;EACF,CAAC;EAED,OAAOJ,GAAG;AACZ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleCache.js","names":["createSimpleCache","map","Map","fn","set","key","value","get","r","undefined","remove","delete","createSimpleAsyncCache","type","createCacheLocal","cache","WeakMap","inProgress","ret","getOrUndefined","k","v","e"],"sources":["SimpleCache.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\n/**\n * A simple cache that can be used to store values for a given client.\n */\n\nexport interface SimpleCache<K, V> {\n get: (key: K) => V;\n set: <X extends V>(key: K, value: X) => X;\n remove: (key: K) => boolean;\n}\n/**\n * Create a new cache with a factory function.\n * @param fn A factory function that will be used to create the value if it does not exist in the cache.\n */\n\nexport function createSimpleCache<K, V>(\n map: Map<K, V> | (K extends object ? WeakMap<K, V> : never),\n fn: (k: K) => V,\n): SimpleCache<K, V>;\n/**\n * Create a new cache without a factory function.\n */\nexport function createSimpleCache<K, V>(\n map?: Map<K, V> | (K extends object ? WeakMap<K, V> : never),\n): SimpleCache<\n K,\n V | undefined\n>;\nexport function createSimpleCache<K, V>(\n map: Map<K, V> | (K extends object ? WeakMap<K, V> : never) =\n new Map() as any,\n fn?: undefined | ((k: K) => V),\n): typeof fn extends undefined ? SimpleCache<K, V | undefined>\n : SimpleCache<K, V>\n{\n function get(key: K) {\n
|
|
1
|
+
{"version":3,"file":"SimpleCache.js","names":["createSimpleCache","map","Map","fn","set","key","value","get","r","undefined","remove","delete","createSimpleAsyncCache","type","createCacheLocal","cache","WeakMap","inProgress","ret","getOrUndefined","k","v","e"],"sources":["SimpleCache.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\n/**\n * A simple cache that can be used to store values for a given client.\n */\n\nexport interface SimpleCache<K, V> {\n get: (key: K) => V;\n set: <X extends V>(key: K, value: X) => X;\n remove: (key: K) => boolean;\n}\n/**\n * Create a new cache with a factory function.\n * @param fn A factory function that will be used to create the value if it does not exist in the cache.\n */\n\nexport function createSimpleCache<K, V>(\n map: Map<K, V> | (K extends object ? WeakMap<K, V> : never),\n fn: (k: K) => V,\n): SimpleCache<K, V>;\n/**\n * Create a new cache without a factory function.\n */\nexport function createSimpleCache<K, V>(\n map?: Map<K, V> | (K extends object ? WeakMap<K, V> : never),\n): SimpleCache<\n K,\n V | undefined\n>;\nexport function createSimpleCache<K, V>(\n map: Map<K, V> | (K extends object ? WeakMap<K, V> : never) =\n new Map() as any,\n fn?: undefined | ((k: K) => V),\n): typeof fn extends undefined ? SimpleCache<K, V | undefined>\n : SimpleCache<K, V>\n{\n function get(key: K) {\n const r = (map as Map<K, V>).get(key as any);\n if (r === undefined && fn !== undefined) {\n return set(key, fn(key));\n } else {\n return r;\n }\n }\n\n function set(key: K, value: V) {\n map.set(key as any, value);\n return value;\n }\n\n function remove(key: K) {\n return map.delete(key as any);\n }\n\n return { get, set, remove } as SimpleCache<K, V>;\n}\n/**\n * A simple async cache that can be used to store values for a given client.\n */\n\nexport interface WeakAsyncCache<K, V> {\n getOrUndefined: (key: K) => V | undefined;\n\n get: (key: K) => Promise<V>;\n\n /**\n * @param client the client to key from\n * @param key the sub-key to use\n * @param value the value or a promise to the value\n * @returns a new promise to the resolved value\n */\n set: (\n key: K,\n value: V | Promise<V>,\n ) => Promise<V>;\n}\n/**\n * Create a new cache with an async factory function.\n * @param fn A factory function that will be used to create the value if it does not exist in the cache.\n * @returns\n */\n\nexport function createSimpleAsyncCache<K, V>(\n type: \"weak\" | \"strong\",\n fn: (key: K) => Promise<V>,\n createCacheLocal: typeof createSimpleCache = createSimpleCache,\n): WeakAsyncCache<K, V> {\n const cache = createCacheLocal<K, V>(\n (type === \"weak\" ? new WeakMap() : new Map()) as Map<K, V>,\n );\n const inProgress = createCacheLocal<K, Promise<V> | V>(\n (type === \"weak\" ? new WeakMap() : new Map()) as Map<K, V>,\n );\n\n const ret = {\n getOrUndefined: function getOrUndefined(key: K) {\n return cache.get(key);\n },\n\n get: async function get(key: K) {\n return cache.get(key) ?? inProgress.get(key)\n ?? ret.set(key, fn(key));\n },\n\n set: async function set(k: K, v: V | Promise<V>) {\n // the `.set` happens first to prevent races.\n try {\n const r = await inProgress.set(k, v); // returns v\n\n cache.set(k, r);\n inProgress.remove(k);\n return r;\n } catch (e) {\n // we don't want to cache failures\n inProgress.remove(k);\n throw e;\n }\n },\n };\n\n return ret;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAOA;AACA;AACA;AACA;;AAMA;AACA;AACA;;AAOA,OAAO,SAASA,iBAAiBA,CAC/BC,GAA2D,GACzD,IAAIC,GAAG,CAAC,CAAQ,EAClBC,EAA8B,EAGhC;EAUE,SAASC,GAAGA,CAACC,GAAM,EAAEC,KAAQ,EAAE;IAC7BL,GAAG,CAACG,GAAG,CAACC,GAAG,EAASC,KAAK,CAAC;IAC1B,OAAOA,KAAK;EACd;EAMA,OAAO;IAAEC,GAAG,EAlBZ,SAAAA,CAAaF,GAAM,EAAE;MACnB,MAAMG,CAAC,GAAIP,GAAG,CAAeM,GAAG,CAACF,GAAU,CAAC;MAC5C,IAAIG,CAAC,KAAKC,SAAS,IAAIN,EAAE,KAAKM,SAAS,EAAE;QACvC,OAAOL,GAAG,CAACC,GAAG,EAAEF,EAAE,CAACE,GAAG,CAAC,CAAC;MAC1B,CAAC,MAAM;QACL,OAAOG,CAAC;MACV;IACF,CAWY;IAAEJ,GAAG;IAAEM,MAAM,EAJzB,SAAAA,CAAgBL,GAAM,EAAE;MACtB,OAAOJ,GAAG,CAACU,MAAM,CAACN,GAAU,CAAC;IAC/B;EAE0B,CAAC;AAC7B;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASO,sBAAsBA,CACpCC,IAAuB,EACvBV,EAA0B,EAC1BW,gBAA0C,GAAGd,iBAAiB,EACxC;EACtB,MAAMe,KAAK,GAAGD,gBAAgB,CAC3BD,IAAI,KAAK,MAAM,GAAG,IAAIG,OAAO,CAAC,CAAC,GAAG,IAAId,GAAG,CAAC,CAC7C,CAAC;EACD,MAAMe,UAAU,GAAGH,gBAAgB,CAChCD,IAAI,KAAK,MAAM,GAAG,IAAIG,OAAO,CAAC,CAAC,GAAG,IAAId,GAAG,CAAC,CAC7C,CAAC;EAED,MAAMgB,GAAG,GAAG;IACVC,cAAc,EAAE,SAAAA,CAAwBd,GAAM,EAAE;MAC9C,OAAOU,KAAK,CAACR,GAAG,CAACF,GAAG,CAAC;IACvB,CAAC;IAEDE,GAAG,EAAE,eAAAA,CAAmBF,GAAM,EAAE;MAC9B,OAAOU,KAAK,CAACR,GAAG,CAACF,GAAG,CAAC,IAAIY,UAAU,CAACV,GAAG,CAACF,GAAG,CAAC,IACvCa,GAAG,CAACd,GAAG,CAACC,GAAG,EAAEF,EAAE,CAACE,GAAG,CAAC,CAAC;IAC5B,CAAC;IAEDD,GAAG,EAAE,eAAAA,CAAmBgB,CAAI,EAAEC,CAAiB,EAAE;MAC/C;MACA,IAAI;QACF,MAAMb,CAAC,GAAG,MAAMS,UAAU,CAACb,GAAG,CAACgB,CAAC,EAAEC,CAAC,CAAC,CAAC,CAAC;;QAEtCN,KAAK,CAACX,GAAG,CAACgB,CAAC,EAAEZ,CAAC,CAAC;QACfS,UAAU,CAACP,MAAM,CAACU,CAAC,CAAC;QACpB,OAAOZ,CAAC;MACV,CAAC,CAAC,OAAOc,CAAC,EAAE;QACV;QACAL,UAAU,CAACP,MAAM,CAACU,CAAC,CAAC;QACpB,MAAME,CAAC;MACT;IACF;EACF,CAAC;EAED,OAAOJ,GAAG;AACZ","ignoreList":[]}
|
|
@@ -176,6 +176,10 @@ function fixObjectPropertiesInPlace(objs, forceRemoveRid) {
|
|
|
176
176
|
obj.$rid = obj.__rid;
|
|
177
177
|
delete obj.__rid;
|
|
178
178
|
}
|
|
179
|
+
if (obj.__score) {
|
|
180
|
+
obj.$score = obj.__score;
|
|
181
|
+
delete obj.__score;
|
|
182
|
+
}
|
|
179
183
|
|
|
180
184
|
// Backend returns as __apiName but we want to stick to $ structure
|
|
181
185
|
obj.$apiName ??= obj.__apiName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertWireToOsdkObjects.js","names":["invariant","createOsdkObject","convertWireToOsdkObjects","client","objects","interfaceApiName","forceRemoveRid","derivedPropertyTypesByName","selectedProps","strictNonNull","fixObjectPropertiesInPlace","ifaceDef","ontologyProvider","getInterfaceDefinition","undefined","ifaceSelected","Object","keys","properties","ret","rawObj","objectDef","getObjectDefinition","$apiName","process","env","NODE_ENV","objProps","conforming","invariantInterfacesAsViews","apiName","isConforming","reframeAsObjectInPlace","convertInterfacePropNamesToObjectPropNames","Error","osdkObject","$as","push","convertWireToOsdkObjects2","derivedPropertyTypeByName","interfaceToObjectTypeMappings","isInterfaceScoped","length","interfaceToObjMapping","filter","val","includes","values","primaryKeyApiName","ifacePropsToMap","map","ifaceProp","interfaceMap","newProps","sptProp","regularProp","entries","value","assign","$primaryKey","def","obj","propsToCheck","propName","nullable","logger","debug","$objectType","warning","warn","console","error","objs","__rid","$rid","__apiName","__primaryKey","$title","__title"],"sources":["convertWireToOsdkObjects.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n InterfaceMetadata,\n NullabilityAdherence,\n ObjectMetadata,\n} from \"@osdk/api\";\nimport type {\n InterfaceToObjectTypeMappings,\n InterfaceTypeApiName,\n OntologyObjectV2,\n} from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport type { DerivedPropertyRuntimeMetadata } from \"../derivedProperties/derivedPropertyRuntimeMetadata.js\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport {\n type FetchedObjectTypeDefinition,\n} from \"../ontology/OntologyProvider.js\";\nimport { createOsdkObject } from \"./convertWireToOsdkObjects/createOsdkObject.js\";\nimport type { InterfaceHolder } from \"./convertWireToOsdkObjects/InterfaceHolder.js\";\nimport type { ObjectHolder } from \"./convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { SimpleOsdkProperties } from \"./SimpleOsdkProperties.js\";\n\n/**\n * If interfaceApiName is not undefined, converts the instances of the\n * interface into their respective\n * underlying concrete types and then returns the $as() representation\n * for the consumers.\n *\n * Otherwise just does the conversion\n *\n * May mutate in place for performance reasons. If you need a clean copy,\n * keep it first.\n *\n * However, you must use the returned value, which will be whatever is correct.\n *\n * @internal\n * @param interfaceApiName - if undefined\n */\nexport async function convertWireToOsdkObjects(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string | undefined,\n forceRemoveRid: boolean = false,\n derivedPropertyTypesByName: DerivedPropertyRuntimeMetadata,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull: NullabilityAdherence = false,\n): Promise<Array<ObjectHolder | InterfaceHolder>> {\n // remove the __ prefixed properties and convert them to $ prefixed.\n // updates in place\n fixObjectPropertiesInPlace(objects, forceRemoveRid);\n\n const ifaceDef = interfaceApiName\n ? await client.ontologyProvider.getInterfaceDefinition(interfaceApiName)\n : undefined;\n const ifaceSelected = ifaceDef\n ? (selectedProps ?? Object.keys(ifaceDef.properties))\n : undefined;\n\n const ret = [];\n for (const rawObj of objects) {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n rawObj.$apiName,\n );\n invariant(objectDef, `Missing definition for '${rawObj.$apiName}'`);\n\n // default value for when we are checking an object\n let objProps;\n\n let conforming = true;\n if (ifaceDef && ifaceSelected) {\n // API returns interface spt names but we cache by real values\n invariantInterfacesAsViews(objectDef, ifaceDef.apiName, client);\n\n conforming &&= isConforming(client, ifaceDef, rawObj, ifaceSelected);\n\n reframeAsObjectInPlace(objectDef, ifaceDef.apiName, rawObj);\n\n objProps = convertInterfacePropNamesToObjectPropNames(\n objectDef,\n ifaceDef.apiName,\n ifaceSelected,\n );\n } else {\n objProps = selectedProps ?? Object.keys(objectDef.properties);\n }\n\n conforming &&= isConforming(client, objectDef, rawObj, objProps);\n\n if (strictNonNull === \"throw\" && !conforming) {\n throw new Error(\n \"Unable to safely convert objects as some non nullable properties are null\",\n );\n } else if (strictNonNull === \"drop\" && !conforming) {\n continue;\n }\n\n let osdkObject: ObjectHolder | InterfaceHolder = createOsdkObject(\n client,\n objectDef,\n rawObj,\n derivedPropertyTypesByName,\n );\n if (interfaceApiName) osdkObject = osdkObject.$as(interfaceApiName);\n\n ret.push(osdkObject);\n }\n\n return ret;\n}\n\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata,\n forceRemoveRid?: boolean,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull?: NullabilityAdherence,\n interfaceToObjectTypeMappings?: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n >,\n): Promise<Array<InterfaceHolder>>;\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: undefined,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata,\n forceRemoveRid?: boolean,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull?: NullabilityAdherence,\n interfaceToObjectTypeMappings?: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n >,\n): Promise<Array<ObjectHolder>>;\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string | undefined,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata,\n forceRemoveRid?: boolean,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull?: NullabilityAdherence,\n interfaceToObjectTypeMappings?: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n >,\n): Promise<Array<ObjectHolder | InterfaceHolder>>;\n/**\n * @internal\n */\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string | undefined,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata,\n forceRemoveRid: boolean = false,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull: NullabilityAdherence = false,\n interfaceToObjectTypeMappings: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n > = {},\n): Promise<Array<ObjectHolder | InterfaceHolder>> {\n fixObjectPropertiesInPlace(objects, forceRemoveRid);\n\n const isInterfaceScoped =\n Object.keys(interfaceToObjectTypeMappings).length > 0;\n const ret = [];\n for (const rawObj of objects) {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n rawObj.$apiName,\n );\n invariant(objectDef, `Missing definition for '${rawObj.$apiName}'`);\n\n const interfaceToObjMapping = (interfaceApiName\n && isInterfaceScoped)\n ? interfaceToObjectTypeMappings[\n interfaceApiName as InterfaceTypeApiName\n ][\n rawObj.$apiName\n ]\n : undefined;\n\n const ifaceSelected = interfaceApiName && interfaceToObjMapping\n ? (selectedProps\n ? Object.keys(interfaceToObjMapping).filter(\n val => {\n selectedProps?.includes(interfaceToObjMapping[val]);\n },\n )\n : [\n ...Object.values(interfaceToObjMapping),\n objectDef.primaryKeyApiName,\n ])\n : undefined;\n\n // default value for when we are checking an object\n let objProps;\n\n let conforming = true;\n if (interfaceApiName && ifaceSelected) {\n invariantInterfacesAsViews(objectDef, interfaceApiName, client);\n\n objProps = ifaceSelected;\n } else {\n objProps = selectedProps ?? Object.keys(objectDef.properties);\n }\n\n conforming &&= isConforming(client, objectDef, rawObj, objProps);\n\n if (strictNonNull === \"throw\" && !conforming) {\n throw new Error(\n \"Unable to safely convert objects as some non nullable properties are null\",\n );\n } else if (strictNonNull === \"drop\" && !conforming) {\n continue;\n }\n\n let osdkObject: ObjectHolder | InterfaceHolder = createOsdkObject(\n client,\n objectDef,\n rawObj,\n derivedPropertyTypeByName,\n );\n if (\n interfaceApiName && isInterfaceScoped\n ) osdkObject = osdkObject.$as(interfaceApiName);\n\n ret.push(osdkObject);\n }\n\n return ret;\n}\n\n/**\n * @internal\n *\n * Utility function that lets us take down selected property names from an interface\n * and convert them to an array of property names on an object.\n */\nexport function convertInterfacePropNamesToObjectPropNames(\n objectDef: FetchedObjectTypeDefinition,\n interfaceApiName: string,\n ifacePropsToMap: readonly string[],\n): string[] {\n return ifacePropsToMap.map((ifaceProp) =>\n objectDef.interfaceMap[interfaceApiName][ifaceProp]\n );\n}\n\n/**\n * Takes a raw object from the wire (contextually as an interface) and\n * updates the fields to reflect the underlying objectDef instead\n * @param objectDef\n * @param interfaceApiName\n * @param client\n * @param rawObj\n */\nfunction reframeAsObjectInPlace(\n objectDef: FetchedObjectTypeDefinition,\n interfaceApiName: string,\n rawObj: OntologyObjectV2,\n) {\n const newProps: Record<string, any> = {};\n for (\n const [sptProp, regularProp] of Object.entries(\n objectDef.interfaceMap[interfaceApiName],\n )\n ) {\n if (sptProp in rawObj) {\n const value = rawObj[sptProp];\n delete rawObj[sptProp];\n if (value !== undefined) {\n newProps[regularProp] = value;\n }\n }\n }\n Object.assign(rawObj, newProps);\n\n if (!(objectDef.primaryKeyApiName in rawObj)) {\n rawObj[objectDef.primaryKeyApiName] = rawObj.$primaryKey;\n }\n}\n\nfunction isConforming(\n client: MinimalClient,\n def:\n | InterfaceMetadata\n | ObjectMetadata,\n obj: OntologyObjectV2,\n propsToCheck: readonly string[],\n) {\n for (const propName of propsToCheck) {\n if (\n propName in def.properties && def.properties[propName].nullable === false\n && obj[propName] == null\n ) {\n if (process.env.NODE_ENV !== \"production\") {\n client.logger?.debug(\n {\n obj: {\n $apiName: obj[\"$apiName\"],\n $objectType: obj[\"$objectType\"],\n $primaryKey: obj[\"$primaryKey\"],\n },\n },\n `Found object that does not conform to its definition. Expected ${def.apiName}'s ${propName} to not be null.`,\n );\n }\n return false;\n }\n }\n return true;\n}\n\nfunction invariantInterfacesAsViews(\n objectDef: FetchedObjectTypeDefinition,\n interfaceApiName: string,\n client: MinimalClient,\n): asserts objectDef is typeof objectDef & { interfaceMap: {} } {\n if (objectDef.interfaceMap?.[interfaceApiName] == null) {\n const warning =\n \"Interfaces are only supported 'as views' but your metadata object is missing the correct information. This suggests your interfaces have not been migrated to the newer version yet and you cannot use this version of the SDK.\";\n if (client.logger) {\n client.logger.warn(warning);\n } else {\n // eslint-disable-next-line no-console\n console.error(`WARNING! ${warning}`);\n }\n throw new Error(warning);\n }\n}\n\nfunction fixObjectPropertiesInPlace(\n objs: OntologyObjectV2[],\n forceRemoveRid: boolean,\n): asserts objs is SimpleOsdkProperties[] {\n for (const obj of objs) {\n if (forceRemoveRid) {\n delete obj.__rid;\n }\n\n if (obj.__rid) {\n obj.$rid = obj.__rid;\n delete obj.__rid;\n }\n\n // Backend returns as __apiName but we want to stick to $ structure\n obj.$apiName ??= obj.__apiName;\n\n // for now these are the same but when we start doing interface projections the $objectType will always be underlying and\n // the $apiName will be for the current view (in current designs)\n obj.$objectType = obj.$apiName;\n\n // copying over for now as its always returned. In the future, this should just be inferred from underlying\n obj.$primaryKey ??= obj.__primaryKey;\n obj.$title ??= obj.__title;\n\n // we don't want people to use these\n delete obj.__apiName;\n delete obj.__primaryKey;\n delete obj.__title;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,OAAOA,SAAS,MAAM,gBAAgB;AAMtC,SAASC,gBAAgB,QAAQ,gDAAgD;AAKjF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,wBAAwBA,CAC5CC,MAAqB,EACrBC,OAA2B,EAC3BC,gBAAoC,EACpCC,cAAuB,GAAG,KAAK,EAC/BC,0BAA0D,EAC1DC,aAAqC,EACrCC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sC,GAAG,CAACc,SAAS;;IAE9B;IACA;IACAd,GAAG,CAACM,WAAW,GAAGN,GAAG,CAACtC,QAAQ;;IAE9B;IACAsC,GAAG,CAACF,WAAW,KAAKE,GAAG,CAACe,YAAY;IACpCf,GAAG,CAACgB,MAAM,KAAKhB,GAAG,CAACiB,OAAO;;IAE1B;IACA,OAAOjB,GAAG,CAACc,SAAS;IACpB,OAAOd,GAAG,CAACe,YAAY;IACvB,OAAOf,GAAG,CAACiB,OAAO;EACpB;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"convertWireToOsdkObjects.js","names":["invariant","createOsdkObject","convertWireToOsdkObjects","client","objects","interfaceApiName","forceRemoveRid","derivedPropertyTypesByName","selectedProps","strictNonNull","fixObjectPropertiesInPlace","ifaceDef","ontologyProvider","getInterfaceDefinition","undefined","ifaceSelected","Object","keys","properties","ret","rawObj","objectDef","getObjectDefinition","$apiName","process","env","NODE_ENV","objProps","conforming","invariantInterfacesAsViews","apiName","isConforming","reframeAsObjectInPlace","convertInterfacePropNamesToObjectPropNames","Error","osdkObject","$as","push","convertWireToOsdkObjects2","derivedPropertyTypeByName","interfaceToObjectTypeMappings","isInterfaceScoped","length","interfaceToObjMapping","filter","val","includes","values","primaryKeyApiName","ifacePropsToMap","map","ifaceProp","interfaceMap","newProps","sptProp","regularProp","entries","value","assign","$primaryKey","def","obj","propsToCheck","propName","nullable","logger","debug","$objectType","warning","warn","console","error","objs","__rid","$rid","__score","$score","__apiName","__primaryKey","$title","__title"],"sources":["convertWireToOsdkObjects.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n InterfaceMetadata,\n NullabilityAdherence,\n ObjectMetadata,\n} from \"@osdk/api\";\nimport type {\n InterfaceToObjectTypeMappings,\n InterfaceTypeApiName,\n OntologyObjectV2,\n} from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport type { DerivedPropertyRuntimeMetadata } from \"../derivedProperties/derivedPropertyRuntimeMetadata.js\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport {\n type FetchedObjectTypeDefinition,\n} from \"../ontology/OntologyProvider.js\";\nimport { createOsdkObject } from \"./convertWireToOsdkObjects/createOsdkObject.js\";\nimport type { InterfaceHolder } from \"./convertWireToOsdkObjects/InterfaceHolder.js\";\nimport type { ObjectHolder } from \"./convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { SimpleOsdkProperties } from \"./SimpleOsdkProperties.js\";\n\n/**\n * If interfaceApiName is not undefined, converts the instances of the\n * interface into their respective\n * underlying concrete types and then returns the $as() representation\n * for the consumers.\n *\n * Otherwise just does the conversion\n *\n * May mutate in place for performance reasons. If you need a clean copy,\n * keep it first.\n *\n * However, you must use the returned value, which will be whatever is correct.\n *\n * @internal\n * @param interfaceApiName - if undefined\n */\nexport async function convertWireToOsdkObjects(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string | undefined,\n forceRemoveRid: boolean = false,\n derivedPropertyTypesByName: DerivedPropertyRuntimeMetadata,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull: NullabilityAdherence = false,\n): Promise<Array<ObjectHolder | InterfaceHolder>> {\n // remove the __ prefixed properties and convert them to $ prefixed.\n // updates in place\n fixObjectPropertiesInPlace(objects, forceRemoveRid);\n\n const ifaceDef = interfaceApiName\n ? await client.ontologyProvider.getInterfaceDefinition(interfaceApiName)\n : undefined;\n const ifaceSelected = ifaceDef\n ? (selectedProps ?? Object.keys(ifaceDef.properties))\n : undefined;\n\n const ret = [];\n for (const rawObj of objects) {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n rawObj.$apiName,\n );\n invariant(objectDef, `Missing definition for '${rawObj.$apiName}'`);\n\n // default value for when we are checking an object\n let objProps;\n\n let conforming = true;\n if (ifaceDef && ifaceSelected) {\n // API returns interface spt names but we cache by real values\n invariantInterfacesAsViews(objectDef, ifaceDef.apiName, client);\n\n conforming &&= isConforming(client, ifaceDef, rawObj, ifaceSelected);\n\n reframeAsObjectInPlace(objectDef, ifaceDef.apiName, rawObj);\n\n objProps = convertInterfacePropNamesToObjectPropNames(\n objectDef,\n ifaceDef.apiName,\n ifaceSelected,\n );\n } else {\n objProps = selectedProps ?? Object.keys(objectDef.properties);\n }\n\n conforming &&= isConforming(client, objectDef, rawObj, objProps);\n\n if (strictNonNull === \"throw\" && !conforming) {\n throw new Error(\n \"Unable to safely convert objects as some non nullable properties are null\",\n );\n } else if (strictNonNull === \"drop\" && !conforming) {\n continue;\n }\n\n let osdkObject: ObjectHolder | InterfaceHolder = createOsdkObject(\n client,\n objectDef,\n rawObj,\n derivedPropertyTypesByName,\n );\n if (interfaceApiName) osdkObject = osdkObject.$as(interfaceApiName);\n\n ret.push(osdkObject);\n }\n\n return ret;\n}\n\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata,\n forceRemoveRid?: boolean,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull?: NullabilityAdherence,\n interfaceToObjectTypeMappings?: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n >,\n): Promise<Array<InterfaceHolder>>;\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: undefined,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata,\n forceRemoveRid?: boolean,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull?: NullabilityAdherence,\n interfaceToObjectTypeMappings?: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n >,\n): Promise<Array<ObjectHolder>>;\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string | undefined,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata,\n forceRemoveRid?: boolean,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull?: NullabilityAdherence,\n interfaceToObjectTypeMappings?: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n >,\n): Promise<Array<ObjectHolder | InterfaceHolder>>;\n/**\n * @internal\n */\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string | undefined,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata,\n forceRemoveRid: boolean = false,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull: NullabilityAdherence = false,\n interfaceToObjectTypeMappings: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n > = {},\n): Promise<Array<ObjectHolder | InterfaceHolder>> {\n fixObjectPropertiesInPlace(objects, forceRemoveRid);\n\n const isInterfaceScoped =\n Object.keys(interfaceToObjectTypeMappings).length > 0;\n const ret = [];\n for (const rawObj of objects) {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n rawObj.$apiName,\n );\n invariant(objectDef, `Missing definition for '${rawObj.$apiName}'`);\n\n const interfaceToObjMapping = (interfaceApiName\n && isInterfaceScoped)\n ? interfaceToObjectTypeMappings[\n interfaceApiName as InterfaceTypeApiName\n ][\n rawObj.$apiName\n ]\n : undefined;\n\n const ifaceSelected = interfaceApiName && interfaceToObjMapping\n ? (selectedProps\n ? Object.keys(interfaceToObjMapping).filter(\n val => {\n selectedProps?.includes(interfaceToObjMapping[val]);\n },\n )\n : [\n ...Object.values(interfaceToObjMapping),\n objectDef.primaryKeyApiName,\n ])\n : undefined;\n\n // default value for when we are checking an object\n let objProps;\n\n let conforming = true;\n if (interfaceApiName && ifaceSelected) {\n invariantInterfacesAsViews(objectDef, interfaceApiName, client);\n\n objProps = ifaceSelected;\n } else {\n objProps = selectedProps ?? Object.keys(objectDef.properties);\n }\n\n conforming &&= isConforming(client, objectDef, rawObj, objProps);\n\n if (strictNonNull === \"throw\" && !conforming) {\n throw new Error(\n \"Unable to safely convert objects as some non nullable properties are null\",\n );\n } else if (strictNonNull === \"drop\" && !conforming) {\n continue;\n }\n\n let osdkObject: ObjectHolder | InterfaceHolder = createOsdkObject(\n client,\n objectDef,\n rawObj,\n derivedPropertyTypeByName,\n );\n if (\n interfaceApiName && isInterfaceScoped\n ) osdkObject = osdkObject.$as(interfaceApiName);\n\n ret.push(osdkObject);\n }\n\n return ret;\n}\n\n/**\n * @internal\n *\n * Utility function that lets us take down selected property names from an interface\n * and convert them to an array of property names on an object.\n */\nexport function convertInterfacePropNamesToObjectPropNames(\n objectDef: FetchedObjectTypeDefinition,\n interfaceApiName: string,\n ifacePropsToMap: readonly string[],\n): string[] {\n return ifacePropsToMap.map((ifaceProp) =>\n objectDef.interfaceMap[interfaceApiName][ifaceProp]\n );\n}\n\n/**\n * Takes a raw object from the wire (contextually as an interface) and\n * updates the fields to reflect the underlying objectDef instead\n * @param objectDef\n * @param interfaceApiName\n * @param client\n * @param rawObj\n */\nfunction reframeAsObjectInPlace(\n objectDef: FetchedObjectTypeDefinition,\n interfaceApiName: string,\n rawObj: OntologyObjectV2,\n) {\n const newProps: Record<string, any> = {};\n for (\n const [sptProp, regularProp] of Object.entries(\n objectDef.interfaceMap[interfaceApiName],\n )\n ) {\n if (sptProp in rawObj) {\n const value = rawObj[sptProp];\n delete rawObj[sptProp];\n if (value !== undefined) {\n newProps[regularProp] = value;\n }\n }\n }\n Object.assign(rawObj, newProps);\n\n if (!(objectDef.primaryKeyApiName in rawObj)) {\n rawObj[objectDef.primaryKeyApiName] = rawObj.$primaryKey;\n }\n}\n\nfunction isConforming(\n client: MinimalClient,\n def:\n | InterfaceMetadata\n | ObjectMetadata,\n obj: OntologyObjectV2,\n propsToCheck: readonly string[],\n) {\n for (const propName of propsToCheck) {\n if (\n propName in def.properties && def.properties[propName].nullable === false\n && obj[propName] == null\n ) {\n if (process.env.NODE_ENV !== \"production\") {\n client.logger?.debug(\n {\n obj: {\n $apiName: obj[\"$apiName\"],\n $objectType: obj[\"$objectType\"],\n $primaryKey: obj[\"$primaryKey\"],\n },\n },\n `Found object that does not conform to its definition. Expected ${def.apiName}'s ${propName} to not be null.`,\n );\n }\n return false;\n }\n }\n return true;\n}\n\nfunction invariantInterfacesAsViews(\n objectDef: FetchedObjectTypeDefinition,\n interfaceApiName: string,\n client: MinimalClient,\n): asserts objectDef is typeof objectDef & { interfaceMap: {} } {\n if (objectDef.interfaceMap?.[interfaceApiName] == null) {\n const warning =\n \"Interfaces are only supported 'as views' but your metadata object is missing the correct information. This suggests your interfaces have not been migrated to the newer version yet and you cannot use this version of the SDK.\";\n if (client.logger) {\n client.logger.warn(warning);\n } else {\n // eslint-disable-next-line no-console\n console.error(`WARNING! ${warning}`);\n }\n throw new Error(warning);\n }\n}\n\nfunction fixObjectPropertiesInPlace(\n objs: OntologyObjectV2[],\n forceRemoveRid: boolean,\n): asserts objs is SimpleOsdkProperties[] {\n for (const obj of objs) {\n if (forceRemoveRid) {\n delete obj.__rid;\n }\n\n if (obj.__rid) {\n obj.$rid = obj.__rid;\n delete obj.__rid;\n }\n\n if (obj.__score) {\n obj.$score = obj.__score;\n delete obj.__score;\n }\n\n // Backend returns as __apiName but we want to stick to $ structure\n obj.$apiName ??= obj.__apiName;\n\n // for now these are the same but when we start doing interface projections the $objectType will always be underlying and\n // the $apiName will be for the current view (in current designs)\n obj.$objectType = obj.$apiName;\n\n // copying over for now as its always returned. In the future, this should just be inferred from underlying\n obj.$primaryKey ??= obj.__primaryKey;\n obj.$title ??= obj.__title;\n\n // we don't want people to use these\n delete obj.__apiName;\n delete obj.__primaryKey;\n delete obj.__title;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;A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SAAS1D,0BAA0BA,CACjC8D,IAAwB,EACxBlE,cAAuB,EACiB;EACxC,KAAK,MAAMuD,GAAG,IAAIW,IAAI,EAAE;IACtB,IAAIlE,cAAc,EAAE;MAClB,OAAOuD,GAAG,CAACY,KAAK;IAClB;IAEA,IAAIZ,GAAG,CAACY,KAAK,EAAE;MACbZ,GAAG,CAACa,IAAI,GAAGb,GAAG,CAACY,KAAK;MACpB,OAAOZ,GAAG,CAACY,KAAK;IAClB;IAEA,IAAIZ,GAAG,CAACc,OAAO,EAAE;MACfd,GAAG,CAACe,MAAM,GAAGf,GAAG,CAACc,OAAO;MACxB,OAAOd,GAAG,CAACc,OAAO;IACpB;;IAEA;IACAd,GAAG,CAACtC,QAAQ,KAAKsC,GAAG,CAACgB,SAAS;;IAE9B;IACA;IACAhB,GAAG,CAACM,WAAW,GAAGN,GAAG,CAACtC,QAAQ;;IAE9B;IACAsC,GAAG,CAACF,WAAW,KAAKE,GAAG,CAACiB,YAAY;IACpCjB,GAAG,CAACkB,MAAM,KAAKlB,GAAG,CAACmB,OAAO;;IAE1B;IACA,OAAOnB,GAAG,CAACgB,SAAS;IACpB,OAAOhB,GAAG,CAACiB,YAAY;IACvB,OAAOjB,GAAG,CAACmB,OAAO;EACpB;AACF","ignoreList":[]}
|
|
@@ -140,9 +140,13 @@ function applyFetchArgs(args, body) {
|
|
|
140
140
|
if (args?.$pageSize != null) {
|
|
141
141
|
body.pageSize = args.$pageSize;
|
|
142
142
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
const orderBy = args?.$orderBy;
|
|
144
|
+
if (orderBy) {
|
|
145
|
+
body.orderBy = orderBy === "relevance" ? {
|
|
146
|
+
orderType: "relevance",
|
|
147
|
+
fields: []
|
|
148
|
+
} : {
|
|
149
|
+
fields: Object.entries(orderBy).map(([field, direction]) => ({
|
|
146
150
|
field,
|
|
147
151
|
direction
|
|
148
152
|
}))
|
|
@@ -167,7 +171,7 @@ export async function fetchObjectPage(client, objectType, args, objectSet, useSn
|
|
|
167
171
|
snapshot: useSnapshot
|
|
168
172
|
}));
|
|
169
173
|
return Promise.resolve({
|
|
170
|
-
data: await client.objectFactory(client, r.data, undefined, undefined, await extractRdpDefinition(client, objectSet), args.$select),
|
|
174
|
+
data: await client.objectFactory(client, r.data, undefined, undefined, await extractRdpDefinition(client, objectSet), args.$select, false),
|
|
171
175
|
nextPageToken: r.nextPageToken,
|
|
172
176
|
totalCount: r.totalCount
|
|
173
177
|
});
|