@osdk/client 2.6.0-rc.16 → 2.7.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 +7 -31
- package/build/browser/Client.js +1 -1
- package/build/browser/Client.js.map +1 -1
- package/build/browser/MinimalClientContext.js.map +1 -1
- package/build/browser/actions/applyAction.js +4 -0
- package/build/browser/actions/applyAction.js.map +1 -1
- package/build/browser/createClient.js +2 -1
- package/build/browser/createClient.js.map +1 -1
- package/build/browser/createMinimalClient.js +1 -0
- package/build/browser/createMinimalClient.js.map +1 -1
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +17 -1
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
- package/build/browser/fetchMetadata.test.js +11 -0
- package/build/browser/fetchMetadata.test.js.map +1 -1
- package/build/browser/index.js +1 -1
- package/build/browser/index.js.map +1 -1
- package/build/browser/object/aggregate.js +1 -0
- package/build/browser/object/aggregate.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/InterfaceHolder.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +4 -0
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js +10 -0
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.test.js +12 -0
- package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/browser/object/fetchPage.js +2 -0
- package/build/browser/object/fetchPage.js.map +1 -1
- package/build/browser/object/formatting/applyPropertyFormatter.js +58 -0
- package/build/browser/object/formatting/applyPropertyFormatter.js.map +1 -0
- package/build/browser/object/formatting/applyPropertyFormatter.test.js +726 -0
- package/build/browser/object/formatting/applyPropertyFormatter.test.js.map +1 -0
- package/build/browser/object/formatting/formatBoolean.js +23 -0
- package/build/browser/object/formatting/formatBoolean.js.map +1 -0
- package/build/browser/object/formatting/formatDateTime.js +158 -0
- package/build/browser/object/formatting/formatDateTime.js.map +1 -0
- package/build/browser/object/formatting/formatNumber.js +242 -0
- package/build/browser/object/formatting/formatNumber.js.map +1 -0
- package/build/browser/object/formatting/propertyFormattingUtils.js +39 -0
- package/build/browser/object/formatting/propertyFormattingUtils.js.map +1 -0
- package/build/browser/observable/internal/links/SpecificLinkQuery.js +9 -1
- package/build/browser/observable/internal/links/SpecificLinkQuery.js.map +1 -1
- package/build/browser/ontology/loadActionMetadata.js +3 -1
- package/build/browser/ontology/loadActionMetadata.js.map +1 -1
- package/build/browser/ontology/loadFullObjectMetadata.js +2 -1
- package/build/browser/ontology/loadFullObjectMetadata.js.map +1 -1
- package/build/browser/ontology/loadInterfaceMetadata.js +2 -1
- package/build/browser/ontology/loadInterfaceMetadata.js.map +1 -1
- package/build/browser/util/UserAgent.js +2 -2
- package/build/browser/util/UserAgent.js.map +1 -1
- package/build/browser/util/toDataValue.js +4 -0
- package/build/browser/util/toDataValue.js.map +1 -1
- package/build/browser/util/toDataValue.test.js +9 -0
- package/build/browser/util/toDataValue.test.js.map +1 -1
- package/build/cjs/{chunk-ITZWQA6K.cjs → chunk-R5RI54KA.cjs} +472 -69
- package/build/cjs/chunk-R5RI54KA.cjs.map +1 -0
- package/build/cjs/{chunk-S3HJUSQ7.cjs → chunk-VYHIAGVJ.cjs} +22 -2
- package/build/cjs/chunk-VYHIAGVJ.cjs.map +1 -0
- package/build/cjs/{createClient-MAHmo-Nv.d.cts → createClient-CPUYdECn.d.cts} +1 -0
- package/build/cjs/index.cjs +12 -8
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +2 -2
- package/build/cjs/public/internal.cjs +8 -8
- package/build/cjs/public/unstable-do-not-use.cjs +40 -34
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +1 -1
- package/build/esm/Client.js +1 -1
- package/build/esm/Client.js.map +1 -1
- package/build/esm/MinimalClientContext.js.map +1 -1
- package/build/esm/actions/applyAction.js +4 -0
- package/build/esm/actions/applyAction.js.map +1 -1
- package/build/esm/createClient.js +2 -1
- package/build/esm/createClient.js.map +1 -1
- package/build/esm/createMinimalClient.js +1 -0
- package/build/esm/createMinimalClient.js.map +1 -1
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +17 -1
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
- package/build/esm/fetchMetadata.test.js +11 -0
- package/build/esm/fetchMetadata.test.js.map +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/object/aggregate.js +1 -0
- package/build/esm/object/aggregate.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/InterfaceHolder.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +4 -0
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js +10 -0
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.test.js +12 -0
- package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/esm/object/fetchPage.js +2 -0
- package/build/esm/object/fetchPage.js.map +1 -1
- package/build/esm/object/formatting/applyPropertyFormatter.js +58 -0
- package/build/esm/object/formatting/applyPropertyFormatter.js.map +1 -0
- package/build/esm/object/formatting/applyPropertyFormatter.test.js +726 -0
- package/build/esm/object/formatting/applyPropertyFormatter.test.js.map +1 -0
- package/build/esm/object/formatting/formatBoolean.js +23 -0
- package/build/esm/object/formatting/formatBoolean.js.map +1 -0
- package/build/esm/object/formatting/formatDateTime.js +158 -0
- package/build/esm/object/formatting/formatDateTime.js.map +1 -0
- package/build/esm/object/formatting/formatNumber.js +242 -0
- package/build/esm/object/formatting/formatNumber.js.map +1 -0
- package/build/esm/object/formatting/propertyFormattingUtils.js +39 -0
- package/build/esm/object/formatting/propertyFormattingUtils.js.map +1 -0
- package/build/esm/observable/internal/links/SpecificLinkQuery.js +9 -1
- package/build/esm/observable/internal/links/SpecificLinkQuery.js.map +1 -1
- package/build/esm/ontology/loadActionMetadata.js +3 -1
- package/build/esm/ontology/loadActionMetadata.js.map +1 -1
- package/build/esm/ontology/loadFullObjectMetadata.js +2 -1
- package/build/esm/ontology/loadFullObjectMetadata.js.map +1 -1
- package/build/esm/ontology/loadInterfaceMetadata.js +2 -1
- package/build/esm/ontology/loadInterfaceMetadata.js.map +1 -1
- package/build/esm/util/UserAgent.js +2 -2
- package/build/esm/util/UserAgent.js.map +1 -1
- package/build/esm/util/toDataValue.js +4 -0
- package/build/esm/util/toDataValue.js.map +1 -1
- package/build/esm/util/toDataValue.test.js +9 -0
- package/build/esm/util/toDataValue.test.js.map +1 -1
- package/build/types/Client.d.ts +1 -1
- package/build/types/MinimalClientContext.d.ts +1 -0
- package/build/types/MinimalClientContext.d.ts.map +1 -1
- package/build/types/actions/applyAction.d.ts.map +1 -1
- package/build/types/createClient.d.ts +1 -0
- package/build/types/createClient.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/object/formatting/applyPropertyFormatter.d.ts +18 -0
- package/build/types/object/formatting/applyPropertyFormatter.d.ts.map +1 -0
- package/build/types/object/formatting/applyPropertyFormatter.test.d.ts +1 -0
- package/build/types/object/formatting/applyPropertyFormatter.test.d.ts.map +1 -0
- package/build/types/object/formatting/formatBoolean.d.ts +5 -0
- package/build/types/object/formatting/formatBoolean.d.ts.map +1 -0
- package/build/types/object/formatting/formatDateTime.d.ts +6 -0
- package/build/types/object/formatting/formatDateTime.d.ts.map +1 -0
- package/build/types/object/formatting/formatNumber.d.ts +15 -0
- package/build/types/object/formatting/formatNumber.d.ts.map +1 -0
- package/build/types/object/formatting/propertyFormattingUtils.d.ts +10 -0
- package/build/types/object/formatting/propertyFormattingUtils.d.ts.map +1 -0
- package/build/types/observable/internal/links/SpecificLinkQuery.d.ts.map +1 -1
- package/package.json +11 -11
- package/build/cjs/chunk-ITZWQA6K.cjs.map +0 -1
- package/build/cjs/chunk-S3HJUSQ7.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propertyFormattingUtils.js","names":["resolvePropertyReference","ref","objectData","type","value","propertyApiName","String","undefined","getBrowserLocale","navigator","language"],"sources":["propertyFormattingUtils.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PropertyTypeReferenceOrStringConstant } from \"@osdk/api\";\nimport type { SimpleOsdkProperties } from \"../SimpleOsdkProperties.js\";\n\n/**\n * Resolves a property reference or string constant to its actual value\n */\n\nexport function resolvePropertyReference(\n ref: PropertyTypeReferenceOrStringConstant,\n objectData: SimpleOsdkProperties,\n): string | undefined {\n if (ref.type === \"constant\") {\n return ref.value;\n } else if (ref.type === \"propertyType\") {\n const value = objectData[ref.propertyApiName];\n return value != null ? String(value) : undefined;\n }\n return undefined;\n}\n/**\n * Gets the browser's current locale\n */\nexport function getBrowserLocale(): string {\n if (typeof navigator !== \"undefined\" && navigator.language != null) {\n return navigator.language;\n }\n return \"en-US\";\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;;AAEA,OAAO,SAASA,wBAAwBA,CACtCC,GAA0C,EAC1CC,UAAgC,EACZ;EACpB,IAAID,GAAG,CAACE,IAAI,KAAK,UAAU,EAAE;IAC3B,OAAOF,GAAG,CAACG,KAAK;EAClB,CAAC,MAAM,IAAIH,GAAG,CAACE,IAAI,KAAK,cAAc,EAAE;IACtC,MAAMC,KAAK,GAAGF,UAAU,CAACD,GAAG,CAACI,eAAe,CAAC;IAC7C,OAAOD,KAAK,IAAI,IAAI,GAAGE,MAAM,CAACF,KAAK,CAAC,GAAGG,SAAS;EAClD;EACA,OAAOA,SAAS;AAClB;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAA,EAAW;EACzC,IAAI,OAAOC,SAAS,KAAK,WAAW,IAAIA,SAAS,CAACC,QAAQ,IAAI,IAAI,EAAE;IAClE,OAAOD,SAAS,CAACC,QAAQ;EAC3B;EACA,OAAO,OAAO;AAChB","ignoreList":[]}
|
|
@@ -46,7 +46,6 @@ export class SpecificLinkQuery extends BaseListQuery {
|
|
|
46
46
|
|
|
47
47
|
// Extract the necessary parameters from the cache key
|
|
48
48
|
[this.#sourceApiName, this.#sourcePk, this.#linkName, this.#whereClause, this.#orderBy] = cacheKey.otherKeys;
|
|
49
|
-
this.sortingStrategy = new OrderBySortingStrategy(this.#linkName, this.#orderBy);
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
// _fetchAndStore is now implemented in BaseCollectionQuery
|
|
@@ -68,6 +67,15 @@ export class SpecificLinkQuery extends BaseListQuery {
|
|
|
68
67
|
// Use the client's ontologyProvider to get metadata, which has built-in caching
|
|
69
68
|
const sourceMetadata = await client[additionalContext].ontologyProvider.getObjectDefinition(this.#sourceApiName);
|
|
70
69
|
|
|
70
|
+
// Initialize sorting strategy with the link's target object type
|
|
71
|
+
if (this.#orderBy && Object.keys(this.#orderBy).length > 0) {
|
|
72
|
+
const linkDef = sourceMetadata.links?.[this.#linkName];
|
|
73
|
+
if (!linkDef?.targetType) {
|
|
74
|
+
throw new Error(`Missing link definition or targetType for link '${this.#linkName}' on object type '${this.#sourceApiName}'`);
|
|
75
|
+
}
|
|
76
|
+
this.sortingStrategy = new OrderBySortingStrategy(linkDef.targetType, this.#orderBy);
|
|
77
|
+
}
|
|
78
|
+
|
|
71
79
|
// Query for the specific source object
|
|
72
80
|
const sourceQuery = client(sourceObjectDef).where({
|
|
73
81
|
[sourceMetadata.primaryKeyApiName]: this.#sourcePk
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpecificLinkQuery.js","names":["deepEqual","additionalContext","BaseListQuery","OrderBySortingStrategy","tombstone","SpecificLinkQuery","sourceApiName","sourcePk","linkName","whereClause","orderBy","registerCacheChanges","batch","changes","modified","add","cacheKey","constructor","store","subject","opts","process","env","NODE_ENV","client","logger","child","msgPrefix","otherKeys","map","x","JSON","stringify","join","undefined","sortingStrategy","fetchPageData","signal","sourceObjectDef","type","apiName","sourceMetadata","ontologyProvider","getObjectDefinition","sourceQuery","where","primaryKeyApiName","linkQuery","pivotTo","aborted","Error","queryParams","$pageSize","options","pageSize","$nextPageToken","nextPageToken","Object","keys","length","$orderBy","$where","response","fetchPage","deleteFromStore","status","entry","read","value","methodName","debug","write","ret","delete","deleted","maybeUpdateAndRevalidate","has","revalidate","Promise","resolve","invalidateObjectType","objectType","linkDef","links","targetType","promise","isSpecificLinkCacheKey","key"],"sources":["SpecificLinkQuery.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectTypeDefinition,\n Osdk,\n PageResult,\n PrimaryKeyType,\n WhereClause,\n} from \"@osdk/api\";\nimport deepEqual from \"fast-deep-equal\";\nimport { type Subject } from \"rxjs\";\nimport { additionalContext } from \"../../../Client.js\";\nimport type { SpecificLinkPayload } from \"../../LinkPayload.js\";\nimport type { Status } from \"../../ObservableClient/common.js\";\nimport type { ObserveLinks } from \"../../ObservableClient/ObserveLink.js\";\nimport { BaseListQuery } from \"../base-list/BaseListQuery.js\";\nimport type { BatchContext } from \"../BatchContext.js\";\nimport type { CacheKey } from \"../CacheKey.js\";\nimport type { Canonical } from \"../Canonical.js\";\nimport type { Changes } from \"../Changes.js\";\nimport type { Entry } from \"../Layer.js\";\nimport type { OptimisticId } from \"../OptimisticId.js\";\nimport type { SimpleWhereClause } from \"../SimpleWhereClause.js\";\nimport { OrderBySortingStrategy } from \"../sorting/SortingStrategy.js\";\nimport type { Store } from \"../Store.js\";\nimport type { SubjectPayload } from \"../SubjectPayload.js\";\nimport { tombstone } from \"../tombstone.js\";\nimport type { SpecificLinkCacheKey } from \"./SpecificLinkCacheKey.js\";\n\n/**\n * Query implementation for retrieving linked objects from a specific object.\n * - Stores links as ObjectCacheKey[] references\n * - Creates indirect dependencies on linked objects\n * - Supports filtering and sorting of linked collections\n * - Handles proper invalidation of related objects\n */\nexport class SpecificLinkQuery extends BaseListQuery<\n SpecificLinkCacheKey,\n SpecificLinkPayload,\n ObserveLinks.Options<ObjectTypeDefinition, string>\n> {\n #sourceApiName: string;\n #sourcePk: PrimaryKeyType<ObjectTypeDefinition>;\n #linkName: string;\n #whereClause: Canonical<SimpleWhereClause>;\n #orderBy: Canonical<Record<string, \"asc\" | \"desc\" | undefined>>;\n\n /**\n * Register changes to the cache specific to SpecificLinkQuery\n */\n protected registerCacheChanges(batch: BatchContext): void {\n batch.changes.modified.add(this.cacheKey);\n }\n\n constructor(\n store: Store,\n subject: Subject<SubjectPayload<SpecificLinkCacheKey>>,\n cacheKey: SpecificLinkCacheKey,\n opts: ObserveLinks.Options<\n ObjectTypeDefinition,\n string\n >,\n ) {\n super(\n store,\n subject,\n opts,\n cacheKey,\n process.env.NODE_ENV !== \"production\"\n ? (\n store.client[additionalContext].logger?.child({}, {\n msgPrefix: `SpecificLinkQuery<${\n cacheKey.otherKeys.map(x => JSON.stringify(x)).join(\", \")\n }>`,\n })\n )\n : undefined,\n );\n\n // Extract the necessary parameters from the cache key\n [\n this.#sourceApiName,\n this.#sourcePk,\n this.#linkName,\n this.#whereClause,\n this.#orderBy,\n ] = cacheKey.otherKeys;\n\n this.sortingStrategy = new OrderBySortingStrategy(\n this.#linkName,\n this.#orderBy,\n );\n }\n\n // _fetchAndStore is now implemented in BaseCollectionQuery\n\n /**\n * Implements fetchPageData from the BaseCollectionQuery template method pattern\n * Fetches a page of linked objects\n */\n protected async fetchPageData(\n signal: AbortSignal | undefined,\n ): Promise<PageResult<Osdk.Instance<any>>> {\n // Use the client API to create a query that pivots to linked objects\n const client = this.store.client;\n\n // First, get metadata for the source object to know the primary key field name\n const sourceObjectDef = {\n type: \"object\",\n apiName: this.#sourceApiName,\n } as ObjectTypeDefinition;\n\n // Use the client's ontologyProvider to get metadata, which has built-in caching\n const sourceMetadata = await client[additionalContext].ontologyProvider\n .getObjectDefinition(this.#sourceApiName);\n\n // Query for the specific source object\n const sourceQuery = client(sourceObjectDef).where({\n [sourceMetadata.primaryKeyApiName]: this.#sourcePk,\n } as WhereClause<any>);\n\n // Pivot to the linked objects\n const linkQuery = sourceQuery.pivotTo(this.#linkName);\n\n // Check for abort signal again before fetching\n if (signal?.aborted) {\n throw new Error(\"Aborted\");\n }\n\n // Fetch the linked objects with pagination\n // Add orderBy to the query parameters if specified\n const queryParams: any = {\n $pageSize: this.options.pageSize || 100,\n $nextPageToken: this.nextPageToken,\n };\n\n // Include orderBy if it has entries\n if (this.#orderBy && Object.keys(this.#orderBy).length > 0) {\n queryParams.$orderBy = this.#orderBy;\n }\n\n // Include whereClause if it has entries\n if (this.#whereClause && Object.keys(this.#whereClause).length > 0) {\n queryParams.$where = this.#whereClause;\n }\n\n const response = await linkQuery.fetchPage(queryParams);\n\n // Store the next page token for pagination\n this.nextPageToken = response.nextPageToken;\n\n return response;\n }\n\n /**\n * Removes a link query from the store\n */\n deleteFromStore(\n status: Status,\n batch: BatchContext,\n ): Entry<SpecificLinkCacheKey> | undefined {\n const entry = batch.read(this.cacheKey);\n\n if (entry && deepEqual(tombstone, entry.value)) {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child({ methodName: \"deleteFromStore\" }).debug(\n `Links were already deleted, just setting status`,\n );\n }\n return batch.write(this.cacheKey, entry.value, status);\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child({ methodName: \"deleteFromStore\" }).debug(\n JSON.stringify({ status }),\n );\n }\n\n // If there is no entry then there is nothing to do\n if (!entry || !entry.value) {\n return;\n }\n\n const ret = batch.delete(this.cacheKey, status);\n batch.changes.deleted.add(this.cacheKey);\n\n return ret;\n }\n\n /**\n * Implements Query.maybeUpdateAndRevalidate to handle cache invalidation\n */\n maybeUpdateAndRevalidate = async (\n changes: Changes,\n _optimisticId: OptimisticId | undefined,\n ): Promise<void> => {\n // TODO: Implement proper invalidation logic for linked objects\n // This would check if any of the linked objects have changed,\n // or if the source object's links might have changed\n\n // For now, simply check if this specific link cache key was modified\n if (changes.modified.has(this.cacheKey)) {\n return this.revalidate(true);\n }\n\n // No relevant changes were detected\n return Promise.resolve();\n };\n\n invalidateObjectType = (\n objectType: string,\n changes: Changes | undefined,\n ): Promise<void> => {\n // We need to invalidate links in two cases:\n // 1. When the source object type matches the apiName (direct invalidation)\n // 2. When the target object type might be the invalidated type (affected by target changes)\n\n // For case 1 - direct source object type match\n if (this.#sourceApiName === objectType) {\n changes?.modified.add(this.cacheKey);\n return this.revalidate(true);\n } else {\n // For case 2 - check if the link's target type matches the invalidated type\n // We need to use the ontology provider to get the link metadata\n // Since this is async, we'll collect all the metadata check promises\n return (async () => {\n // Get the source object metadata to determine link target type\n const sourceMetadata = await this.store.client[additionalContext]\n .ontologyProvider\n .getObjectDefinition(this.#sourceApiName);\n\n const linkDef = sourceMetadata.links?.[this.#linkName];\n if (!linkDef || linkDef.targetType !== objectType) return;\n\n const promise = this.revalidate(true);\n changes?.modified.add(this.cacheKey);\n return promise;\n })();\n }\n };\n}\n\n/**\n * Type guard to check if a cache key is a SpecificLinkCacheKey\n */\nexport function isSpecificLinkCacheKey(\n key: CacheKey,\n): key is SpecificLinkCacheKey {\n return key.type === \"specificLink\";\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,OAAOA,SAAS,MAAM,iBAAiB;AAEvC,SAASC,iBAAiB,QAAQ,oBAAoB;AAItD,SAASC,aAAa,QAAQ,+BAA+B;AAQ7D,SAASC,sBAAsB,QAAQ,+BAA+B;AAGtE,SAASC,SAAS,QAAQ,iBAAiB;AAG3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,SAASH,aAAa,CAIlD;EACA,CAACI,aAAa;EACd,CAACC,QAAQ;EACT,CAACC,QAAQ;EACT,CAACC,WAAW;EACZ,CAACC,OAAO;;EAER;AACF;AACA;EACYC,oBAAoBA,CAACC,KAAmB,EAAQ;IACxDA,KAAK,CAACC,OAAO,CAACC,QAAQ,CAACC,GAAG,CAAC,IAAI,CAACC,QAAQ,CAAC;EAC3C;EAEAC,WAAWA,CACTC,KAAY,EACZC,OAAsD,EACtDH,QAA8B,EAC9BI,IAGC,EACD;IACA,KAAK,CACHF,KAAK,EACLC,OAAO,EACPC,IAAI,EACJJ,QAAQ,EACRK,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GAEjCL,KAAK,CAACM,MAAM,CAACvB,iBAAiB,CAAC,CAACwB,MAAM,EAAEC,KAAK,CAAC,CAAC,CAAC,EAAE;MAChDC,SAAS,EAAE,qBACTX,QAAQ,CAACY,SAAS,CAACC,GAAG,CAACC,CAAC,IAAIC,IAA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,KAAK,GAAG,IAAI,CAAC,CAAC3E,QAAQ,CAAC;QACtD,IAAI,CAAC0E,OAAO,IAAIA,OAAO,CAACE,UAAU,KAAKH,UAAU,EAAE;QAEnD,MAAMI,OAAO,GAAG,IAAI,CAACR,UAAU,CAAC,IAAI,CAAC;QACrChE,OAAO,EAAEC,QAAQ,CAACC,GAAG,CAAC,IAAI,CAACC,QAAQ,CAAC;QACpC,OAAOqE,OAAO;MAChB,CAAC,EAAE,CAAC;IACN;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CACpCC,GAAa,EACgB;EAC7B,OAAOA,GAAG,CAAChD,IAAI,KAAK,cAAc;AACpC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"SpecificLinkQuery.js","names":["deepEqual","additionalContext","BaseListQuery","OrderBySortingStrategy","tombstone","SpecificLinkQuery","sourceApiName","sourcePk","linkName","whereClause","orderBy","registerCacheChanges","batch","changes","modified","add","cacheKey","constructor","store","subject","opts","process","env","NODE_ENV","client","logger","child","msgPrefix","otherKeys","map","x","JSON","stringify","join","undefined","fetchPageData","signal","sourceObjectDef","type","apiName","sourceMetadata","ontologyProvider","getObjectDefinition","Object","keys","length","linkDef","links","targetType","Error","sortingStrategy","sourceQuery","where","primaryKeyApiName","linkQuery","pivotTo","aborted","queryParams","$pageSize","options","pageSize","$nextPageToken","nextPageToken","$orderBy","$where","response","fetchPage","deleteFromStore","status","entry","read","value","methodName","debug","write","ret","delete","deleted","maybeUpdateAndRevalidate","has","revalidate","Promise","resolve","invalidateObjectType","objectType","promise","isSpecificLinkCacheKey","key"],"sources":["SpecificLinkQuery.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectTypeDefinition,\n Osdk,\n PageResult,\n PrimaryKeyType,\n WhereClause,\n} from \"@osdk/api\";\nimport deepEqual from \"fast-deep-equal\";\nimport { type Subject } from \"rxjs\";\nimport { additionalContext } from \"../../../Client.js\";\nimport type { SpecificLinkPayload } from \"../../LinkPayload.js\";\nimport type { Status } from \"../../ObservableClient/common.js\";\nimport type { ObserveLinks } from \"../../ObservableClient/ObserveLink.js\";\nimport { BaseListQuery } from \"../base-list/BaseListQuery.js\";\nimport type { BatchContext } from \"../BatchContext.js\";\nimport type { CacheKey } from \"../CacheKey.js\";\nimport type { Canonical } from \"../Canonical.js\";\nimport type { Changes } from \"../Changes.js\";\nimport type { Entry } from \"../Layer.js\";\nimport type { OptimisticId } from \"../OptimisticId.js\";\nimport type { SimpleWhereClause } from \"../SimpleWhereClause.js\";\nimport { OrderBySortingStrategy } from \"../sorting/SortingStrategy.js\";\nimport type { Store } from \"../Store.js\";\nimport type { SubjectPayload } from \"../SubjectPayload.js\";\nimport { tombstone } from \"../tombstone.js\";\nimport type { SpecificLinkCacheKey } from \"./SpecificLinkCacheKey.js\";\n\n/**\n * Query implementation for retrieving linked objects from a specific object.\n * - Stores links as ObjectCacheKey[] references\n * - Creates indirect dependencies on linked objects\n * - Supports filtering and sorting of linked collections\n * - Handles proper invalidation of related objects\n */\nexport class SpecificLinkQuery extends BaseListQuery<\n SpecificLinkCacheKey,\n SpecificLinkPayload,\n ObserveLinks.Options<ObjectTypeDefinition, string>\n> {\n #sourceApiName: string;\n #sourcePk: PrimaryKeyType<ObjectTypeDefinition>;\n #linkName: string;\n #whereClause: Canonical<SimpleWhereClause>;\n #orderBy: Canonical<Record<string, \"asc\" | \"desc\" | undefined>>;\n\n /**\n * Register changes to the cache specific to SpecificLinkQuery\n */\n protected registerCacheChanges(batch: BatchContext): void {\n batch.changes.modified.add(this.cacheKey);\n }\n\n constructor(\n store: Store,\n subject: Subject<SubjectPayload<SpecificLinkCacheKey>>,\n cacheKey: SpecificLinkCacheKey,\n opts: ObserveLinks.Options<\n ObjectTypeDefinition,\n string\n >,\n ) {\n super(\n store,\n subject,\n opts,\n cacheKey,\n process.env.NODE_ENV !== \"production\"\n ? (\n store.client[additionalContext].logger?.child({}, {\n msgPrefix: `SpecificLinkQuery<${\n cacheKey.otherKeys.map(x => JSON.stringify(x)).join(\", \")\n }>`,\n })\n )\n : undefined,\n );\n\n // Extract the necessary parameters from the cache key\n [\n this.#sourceApiName,\n this.#sourcePk,\n this.#linkName,\n this.#whereClause,\n this.#orderBy,\n ] = cacheKey.otherKeys;\n }\n\n // _fetchAndStore is now implemented in BaseCollectionQuery\n\n /**\n * Implements fetchPageData from the BaseCollectionQuery template method pattern\n * Fetches a page of linked objects\n */\n protected async fetchPageData(\n signal: AbortSignal | undefined,\n ): Promise<PageResult<Osdk.Instance<any>>> {\n // Use the client API to create a query that pivots to linked objects\n const client = this.store.client;\n\n // First, get metadata for the source object to know the primary key field name\n const sourceObjectDef = {\n type: \"object\",\n apiName: this.#sourceApiName,\n } as ObjectTypeDefinition;\n\n // Use the client's ontologyProvider to get metadata, which has built-in caching\n const sourceMetadata = await client[additionalContext].ontologyProvider\n .getObjectDefinition(this.#sourceApiName);\n\n // Initialize sorting strategy with the link's target object type\n if (this.#orderBy && Object.keys(this.#orderBy).length > 0) {\n const linkDef = sourceMetadata.links?.[this.#linkName];\n if (!linkDef?.targetType) {\n throw new Error(\n `Missing link definition or targetType for link '${this.#linkName}' on object type '${this.#sourceApiName}'`,\n );\n }\n this.sortingStrategy = new OrderBySortingStrategy(\n linkDef.targetType,\n this.#orderBy,\n );\n }\n\n // Query for the specific source object\n const sourceQuery = client(sourceObjectDef).where({\n [sourceMetadata.primaryKeyApiName]: this.#sourcePk,\n } as WhereClause<any>);\n\n // Pivot to the linked objects\n const linkQuery = sourceQuery.pivotTo(this.#linkName);\n\n // Check for abort signal again before fetching\n if (signal?.aborted) {\n throw new Error(\"Aborted\");\n }\n\n // Fetch the linked objects with pagination\n // Add orderBy to the query parameters if specified\n const queryParams: any = {\n $pageSize: this.options.pageSize || 100,\n $nextPageToken: this.nextPageToken,\n };\n\n // Include orderBy if it has entries\n if (this.#orderBy && Object.keys(this.#orderBy).length > 0) {\n queryParams.$orderBy = this.#orderBy;\n }\n\n // Include whereClause if it has entries\n if (this.#whereClause && Object.keys(this.#whereClause).length > 0) {\n queryParams.$where = this.#whereClause;\n }\n\n const response = await linkQuery.fetchPage(queryParams);\n\n // Store the next page token for pagination\n this.nextPageToken = response.nextPageToken;\n\n return response;\n }\n\n /**\n * Removes a link query from the store\n */\n deleteFromStore(\n status: Status,\n batch: BatchContext,\n ): Entry<SpecificLinkCacheKey> | undefined {\n const entry = batch.read(this.cacheKey);\n\n if (entry && deepEqual(tombstone, entry.value)) {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child({ methodName: \"deleteFromStore\" }).debug(\n `Links were already deleted, just setting status`,\n );\n }\n return batch.write(this.cacheKey, entry.value, status);\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child({ methodName: \"deleteFromStore\" }).debug(\n JSON.stringify({ status }),\n );\n }\n\n // If there is no entry then there is nothing to do\n if (!entry || !entry.value) {\n return;\n }\n\n const ret = batch.delete(this.cacheKey, status);\n batch.changes.deleted.add(this.cacheKey);\n\n return ret;\n }\n\n /**\n * Implements Query.maybeUpdateAndRevalidate to handle cache invalidation\n */\n maybeUpdateAndRevalidate = async (\n changes: Changes,\n _optimisticId: OptimisticId | undefined,\n ): Promise<void> => {\n // TODO: Implement proper invalidation logic for linked objects\n // This would check if any of the linked objects have changed,\n // or if the source object's links might have changed\n\n // For now, simply check if this specific link cache key was modified\n if (changes.modified.has(this.cacheKey)) {\n return this.revalidate(true);\n }\n\n // No relevant changes were detected\n return Promise.resolve();\n };\n\n invalidateObjectType = (\n objectType: string,\n changes: Changes | undefined,\n ): Promise<void> => {\n // We need to invalidate links in two cases:\n // 1. When the source object type matches the apiName (direct invalidation)\n // 2. When the target object type might be the invalidated type (affected by target changes)\n\n // For case 1 - direct source object type match\n if (this.#sourceApiName === objectType) {\n changes?.modified.add(this.cacheKey);\n return this.revalidate(true);\n } else {\n // For case 2 - check if the link's target type matches the invalidated type\n // We need to use the ontology provider to get the link metadata\n // Since this is async, we'll collect all the metadata check promises\n return (async () => {\n // Get the source object metadata to determine link target type\n const sourceMetadata = await this.store.client[additionalContext]\n .ontologyProvider\n .getObjectDefinition(this.#sourceApiName);\n\n const linkDef = sourceMetadata.links?.[this.#linkName];\n if (!linkDef || linkDef.targetType !== objectType) return;\n\n const promise = this.revalidate(true);\n changes?.modified.add(this.cacheKey);\n return promise;\n })();\n }\n };\n}\n\n/**\n * Type guard to check if a cache key is a SpecificLinkCacheKey\n */\nexport function isSpecificLinkCacheKey(\n key: CacheKey,\n): key is SpecificLinkCacheKey {\n return key.type === \"specificLink\";\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,OAAOA,SAAS,MAAM,iBAAiB;AAEvC,SAASC,iBAAiB,QAAQ,oBAAoB;AAItD,SAASC,aAAa,QAAQ,+BAA+B;AAQ7D,SAASC,sBAAsB,QAAQ,+BAA+B;AAGtE,SAASC,SAAS,QAAQ,iBAAiB;AAG3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,SAASH,aAAa,CAIlD;EACA,CAACI,aAAa;EACd,CAACC,QAAQ;EACT,CAACC,QAAQ;EACT,CAACC,WAAW;EACZ,CAACC,OAAO;;EAER;AACF;AACA;EACYC,oBAAoBA,CAACC,KAAmB,EAAQ;IACxDA,KAAK,CAACC,OAAO,CAACC,QAAQ,CAACC,GAAG,CAAC,IAAI,CAACC,QAAQ,CAAC;EAC3C;EAEAC,WAAWA,CACTC,KAAY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";
|
|
18
18
|
import { wireActionTypeV2ToSdkActionMetadata } from "@osdk/generator-converters";
|
|
19
19
|
export async function loadActionMetadata(client, actionType) {
|
|
20
|
-
const r = await OntologiesV2.ActionTypesV2.get(client, await client.ontologyRid, actionType
|
|
20
|
+
const r = await OntologiesV2.ActionTypesV2.get(client, await client.ontologyRid, actionType, {
|
|
21
|
+
branch: client.branch
|
|
22
|
+
});
|
|
21
23
|
return wireActionTypeV2ToSdkActionMetadata(r);
|
|
22
24
|
}
|
|
23
25
|
//# sourceMappingURL=loadActionMetadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadActionMetadata.js","names":["OntologiesV2","wireActionTypeV2ToSdkActionMetadata","loadActionMetadata","client","actionType","r","ActionTypesV2","get","ontologyRid"],"sources":["loadActionMetadata.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 { ActionMetadata } from \"@osdk/api\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport {\n wireActionTypeV2ToSdkActionMetadata,\n} from \"@osdk/generator-converters\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\n\nexport async function loadActionMetadata(\n client: MinimalClient,\n actionType: string,\n): Promise<ActionMetadata> {\n const r = await OntologiesV2.ActionTypesV2.get(\n client,\n await client.ontologyRid,\n actionType,\n );\n\n return wireActionTypeV2ToSdkActionMetadata(r);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAO,KAAKA,YAAY,MAAM,0BAA0B;AACxD,SACEC,mCAAmC,QAC9B,4BAA4B;AAGnC,OAAO,eAAeC,kBAAkBA,CACtCC,MAAqB,EACrBC,UAAkB,EACO;EACzB,MAAMC,CAAC,GAAG,MAAML,YAAY,CAACM,aAAa,CAACC,GAAG,CAC5CJ,MAAM,EACN,MAAMA,MAAM,CAACK,WAAW,EACxBJ,
|
|
1
|
+
{"version":3,"file":"loadActionMetadata.js","names":["OntologiesV2","wireActionTypeV2ToSdkActionMetadata","loadActionMetadata","client","actionType","r","ActionTypesV2","get","ontologyRid","branch"],"sources":["loadActionMetadata.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 { ActionMetadata } from \"@osdk/api\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport {\n wireActionTypeV2ToSdkActionMetadata,\n} from \"@osdk/generator-converters\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\n\nexport async function loadActionMetadata(\n client: MinimalClient,\n actionType: string,\n): Promise<ActionMetadata> {\n const r = await OntologiesV2.ActionTypesV2.get(\n client,\n await client.ontologyRid,\n actionType,\n { branch: client.branch },\n );\n\n return wireActionTypeV2ToSdkActionMetadata(r);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAO,KAAKA,YAAY,MAAM,0BAA0B;AACxD,SACEC,mCAAmC,QAC9B,4BAA4B;AAGnC,OAAO,eAAeC,kBAAkBA,CACtCC,MAAqB,EACrBC,UAAkB,EACO;EACzB,MAAMC,CAAC,GAAG,MAAML,YAAY,CAACM,aAAa,CAACC,GAAG,CAC5CJ,MAAM,EACN,MAAMA,MAAM,CAACK,WAAW,EACxBJ,UAAU,EACV;IAAEK,MAAM,EAAEN,MAAM,CAACM;EAAO,CAC1B,CAAC;EAED,OAAOR,mCAAmC,CAACI,CAAC,CAAC;AAC/C","ignoreList":[]}
|
|
@@ -18,7 +18,8 @@ import * as OntologiesV2 from "@osdk/foundry.ontologies";
|
|
|
18
18
|
import { wireObjectTypeFullMetadataToSdkObjectMetadata } from "@osdk/generator-converters";
|
|
19
19
|
export async function loadFullObjectMetadata(client, objectType) {
|
|
20
20
|
const full = await OntologiesV2.ObjectTypesV2.getFullMetadata(client, await client.ontologyRid, objectType, {
|
|
21
|
-
preview: true
|
|
21
|
+
preview: true,
|
|
22
|
+
branch: client.branch
|
|
22
23
|
});
|
|
23
24
|
const ret = wireObjectTypeFullMetadataToSdkObjectMetadata(full, true);
|
|
24
25
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadFullObjectMetadata.js","names":["OntologiesV2","wireObjectTypeFullMetadataToSdkObjectMetadata","loadFullObjectMetadata","client","objectType","full","ObjectTypesV2","getFullMetadata","ontologyRid","preview","ret"],"sources":["loadFullObjectMetadata.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 { ObjectMetadata } from \"@osdk/api\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport { wireObjectTypeFullMetadataToSdkObjectMetadata } from \"@osdk/generator-converters\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\n\nexport async function loadFullObjectMetadata(\n client: MinimalClient,\n objectType: string,\n): Promise<ObjectMetadata & { rid: string }> {\n const full = await OntologiesV2.ObjectTypesV2.getFullMetadata(\n client,\n await client.ontologyRid,\n objectType,\n { preview: true },\n );\n const ret = wireObjectTypeFullMetadataToSdkObjectMetadata(full, true);\n return { ...ret };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAO,KAAKA,YAAY,MAAM,0BAA0B;AACxD,SAASC,6CAA6C,QAAQ,4BAA4B;AAG1F,OAAO,eAAeC,sBAAsBA,CAC1CC,MAAqB,EACrBC,UAAkB,EACyB;EAC3C,MAAMC,IAAI,GAAG,MAAML,YAAY,CAACM,aAAa,CAACC,eAAe,CAC3DJ,MAAM,EACN,MAAMA,MAAM,CAACK,WAAW,EACxBJ,UAAU,EACV;IAAEK,OAAO,EAAE;
|
|
1
|
+
{"version":3,"file":"loadFullObjectMetadata.js","names":["OntologiesV2","wireObjectTypeFullMetadataToSdkObjectMetadata","loadFullObjectMetadata","client","objectType","full","ObjectTypesV2","getFullMetadata","ontologyRid","preview","branch","ret"],"sources":["loadFullObjectMetadata.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 { ObjectMetadata } from \"@osdk/api\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport { wireObjectTypeFullMetadataToSdkObjectMetadata } from \"@osdk/generator-converters\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\n\nexport async function loadFullObjectMetadata(\n client: MinimalClient,\n objectType: string,\n): Promise<ObjectMetadata & { rid: string }> {\n const full = await OntologiesV2.ObjectTypesV2.getFullMetadata(\n client,\n await client.ontologyRid,\n objectType,\n { preview: true, branch: client.branch },\n );\n const ret = wireObjectTypeFullMetadataToSdkObjectMetadata(full, true);\n return { ...ret };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAO,KAAKA,YAAY,MAAM,0BAA0B;AACxD,SAASC,6CAA6C,QAAQ,4BAA4B;AAG1F,OAAO,eAAeC,sBAAsBA,CAC1CC,MAAqB,EACrBC,UAAkB,EACyB;EAC3C,MAAMC,IAAI,GAAG,MAAML,YAAY,CAACM,aAAa,CAACC,eAAe,CAC3DJ,MAAM,EACN,MAAMA,MAAM,CAACK,WAAW,EACxBJ,UAAU,EACV;IAAEK,OAAO,EAAE,IAAI;IAAEC,MAAM,EAAEP,MAAM,CAACO;EAAO,CACzC,CAAC;EACD,MAAMC,GAAG,GAAGV,6CAA6C,CAACI,IAAI,EAAE,IAAI,CAAC;EACrE,OAAO;IAAE,GAAGM;EAAI,CAAC;AACnB","ignoreList":[]}
|
|
@@ -18,7 +18,8 @@ import * as OntologiesV2 from "@osdk/foundry.ontologies";
|
|
|
18
18
|
import { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition } from "@osdk/generator-converters";
|
|
19
19
|
export async function loadInterfaceMetadata(client, objectType) {
|
|
20
20
|
const r = await OntologiesV2.OntologyInterfaces.get(client, await client.ontologyRid, objectType, {
|
|
21
|
-
preview: true
|
|
21
|
+
preview: true,
|
|
22
|
+
branch: client.branch
|
|
22
23
|
});
|
|
23
24
|
return __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(r, true);
|
|
24
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadInterfaceMetadata.js","names":["OntologiesV2","__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition","loadInterfaceMetadata","client","objectType","r","OntologyInterfaces","get","ontologyRid","preview"],"sources":["loadInterfaceMetadata.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 { InterfaceMetadata } from \"@osdk/api\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition } from \"@osdk/generator-converters\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\n\nexport async function loadInterfaceMetadata(\n client: MinimalClient,\n objectType: string,\n): Promise<InterfaceMetadata> {\n const r = await OntologiesV2.OntologyInterfaces.get(\n client,\n await client.ontologyRid,\n objectType,\n { preview: true },\n );\n\n return __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(r, true);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAO,KAAKA,YAAY,MAAM,0BAA0B;AACxD,SAASC,mDAAmD,QAAQ,4BAA4B;AAGhG,OAAO,eAAeC,qBAAqBA,CACzCC,MAAqB,EACrBC,UAAkB,EACU;EAC5B,MAAMC,CAAC,GAAG,MAAML,YAAY,CAACM,kBAAkB,CAACC,GAAG,CACjDJ,MAAM,EACN,MAAMA,MAAM,CAACK,WAAW,EACxBJ,UAAU,EACV;IAAEK,OAAO,EAAE;
|
|
1
|
+
{"version":3,"file":"loadInterfaceMetadata.js","names":["OntologiesV2","__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition","loadInterfaceMetadata","client","objectType","r","OntologyInterfaces","get","ontologyRid","preview","branch"],"sources":["loadInterfaceMetadata.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 { InterfaceMetadata } from \"@osdk/api\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition } from \"@osdk/generator-converters\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\n\nexport async function loadInterfaceMetadata(\n client: MinimalClient,\n objectType: string,\n): Promise<InterfaceMetadata> {\n const r = await OntologiesV2.OntologyInterfaces.get(\n client,\n await client.ontologyRid,\n objectType,\n { preview: true, branch: client.branch },\n );\n\n return __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(r, true);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAO,KAAKA,YAAY,MAAM,0BAA0B;AACxD,SAASC,mDAAmD,QAAQ,4BAA4B;AAGhG,OAAO,eAAeC,qBAAqBA,CACzCC,MAAqB,EACrBC,UAAkB,EACU;EAC5B,MAAMC,CAAC,GAAG,MAAML,YAAY,CAACM,kBAAkB,CAACC,GAAG,CACjDJ,MAAM,EACN,MAAMA,MAAM,CAACK,WAAW,EACxBJ,UAAU,EACV;IAAEK,OAAO,EAAE,IAAI;IAAEC,MAAM,EAAEP,MAAM,CAACO;EAAO,CACzC,CAAC;EAED,OAAOT,mDAAmD,CAACI,CAAC,EAAE,IAAI,CAAC;AACrE","ignoreList":[]}
|
|
@@ -14,6 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
export const USER_AGENT = `osdk-client/${"2.
|
|
18
|
-
export const OBSERVABLE_USER_AGENT = `osdk-observable-client/${"2.
|
|
17
|
+
export const USER_AGENT = `osdk-client/${"2.7.0-beta.2"}`;
|
|
18
|
+
export const OBSERVABLE_USER_AGENT = `osdk-observable-client/${"2.7.0-beta.2"}`;
|
|
19
19
|
//# sourceMappingURL=UserAgent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserAgent.js","names":["USER_AGENT","OBSERVABLE_USER_AGENT"],"sources":["UserAgent.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\nexport const USER_AGENT: string = `osdk-client/${process.env.PACKAGE_VERSION}`;\nexport const OBSERVABLE_USER_AGENT: string =\n `osdk-observable-client/${process.env.PACKAGE_VERSION}`;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMA,UAAkB,GAAG
|
|
1
|
+
{"version":3,"file":"UserAgent.js","names":["USER_AGENT","OBSERVABLE_USER_AGENT"],"sources":["UserAgent.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\nexport const USER_AGENT: string = `osdk-client/${process.env.PACKAGE_VERSION}`;\nexport const OBSERVABLE_USER_AGENT: string =\n `osdk-observable-client/${process.env.PACKAGE_VERSION}`;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMA,UAAkB,GAAG,+BAA4C;AAC9E,OAAO,MAAMC,qBAA6B,GACxC,0CAAuD","ignoreList":[]}
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { NULL_VALUE } from "@osdk/api";
|
|
17
18
|
import { MediaSets } from "@osdk/foundry.mediasets";
|
|
18
19
|
import * as OntologiesV2 from "@osdk/foundry.ontologies";
|
|
19
20
|
import { isAttachmentFile, isAttachmentUpload } from "../object/AttachmentUpload.js";
|
|
@@ -38,6 +39,9 @@ export async function toDataValue(value, client, actionMetadata) {
|
|
|
38
39
|
// Null values are not allowed with OSDK types, but leaving here as an override.
|
|
39
40
|
return value;
|
|
40
41
|
}
|
|
42
|
+
if (value === NULL_VALUE) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
41
45
|
|
|
42
46
|
// arrays and sets are both sent over the wire as arrays
|
|
43
47
|
if (Array.isArray(value) || value instanceof Set) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toDataValue.js","names":["MediaSets","OntologiesV2","isAttachmentFile","isAttachmentUpload","isMediaReference","isMediaUpload","getWireObjectSet","isObjectSet","isInterfaceActionParam","isObjectSpecifiersObject","isOntologyObjectV2","isPoint","isWireObjectSet","toDataValue","value","client","actionMetadata","Array","isArray","Set","values","from","some","dataValue","converted","push","promiseArray","innerValue","Promise","all","attachment","Attachments","upload","data","filename","name","rid","mediaRef","uploadMedia","fileName","preview","__primaryKey","$primaryKey","coordinates","objectTypeApiName","$objectType","primaryKeyValue","Object","entries","reduce","promisedAcc","key","structValue","acc","resolve"],"sources":["toDataValue.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 { ActionMetadata } from \"@osdk/api\";\nimport { MediaSets } from \"@osdk/foundry.mediasets\";\nimport { type DataValue } from \"@osdk/foundry.ontologies\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport {\n isAttachmentFile,\n isAttachmentUpload,\n} from \"../object/AttachmentUpload.js\";\nimport { isMediaReference, isMediaUpload } from \"../object/mediaUpload.js\";\nimport { getWireObjectSet, isObjectSet } from \"../objectSet/createObjectSet.js\";\nimport { isInterfaceActionParam } from \"./interfaceUtils.js\";\nimport { isObjectSpecifiersObject } from \"./isObjectSpecifiersObject.js\";\nimport { isOntologyObjectV2 } from \"./isOntologyObjectV2.js\";\nimport { isPoint } from \"./isPoint.js\";\nimport { isWireObjectSet } from \"./WireObjectSet.js\";\n\n/**\n * Marshall user-facing data into the wire DataValue type\n *\n * @see DataValue for the expected payloads\n * @internal\n */\nexport async function toDataValue(\n value: unknown,\n client: MinimalClient,\n actionMetadata: ActionMetadata,\n): Promise<DataValue> {\n if (value == null) {\n // typeof null is 'object' so do this first\n // Sending null over the wire clears the data, whereas undefined is dropped at request time.\n // Null values are not allowed with OSDK types, but leaving here as an override.\n return value;\n }\n\n // arrays and sets are both sent over the wire as arrays\n if (Array.isArray(value) || value instanceof Set) {\n const values = Array.from(value);\n if (\n values.some((dataValue) =>\n isAttachmentUpload(dataValue) || isAttachmentFile(dataValue)\n )\n ) {\n const converted = [];\n for (const value of values) {\n converted.push(await toDataValue(value, client, actionMetadata));\n }\n return converted;\n }\n const promiseArray = Array.from(\n value,\n async (innerValue) =>\n await toDataValue(innerValue, client, actionMetadata),\n );\n return Promise.all(promiseArray);\n }\n\n // For uploads, we need to upload ourselves first to get the RID of the attachment\n if (isAttachmentUpload(value)) {\n const attachment = await OntologiesV2.Attachments.upload(\n client,\n value.data,\n {\n filename: value.name,\n },\n );\n return await toDataValue(attachment.rid, client, actionMetadata);\n }\n\n if (isAttachmentFile(value)) {\n const attachment = await OntologiesV2.Attachments.upload(\n client,\n value,\n {\n filename: value.name as string,\n },\n );\n return await toDataValue(attachment.rid, client, actionMetadata);\n }\n\n // new media item upload interface, very similar to how attachments work above\n\n if (isMediaUpload(value)) {\n const mediaRef = await MediaSets.uploadMedia(\n client,\n value.data,\n {\n filename: value.fileName,\n preview: true,\n },\n );\n return await toDataValue(mediaRef, client, actionMetadata);\n }\n\n // objects just send the JSON'd primaryKey\n if (isOntologyObjectV2(value)) {\n return await toDataValue(value.__primaryKey, client, actionMetadata);\n }\n\n if (isObjectSpecifiersObject(value)) {\n return await toDataValue(value.$primaryKey, client, actionMetadata);\n }\n\n if (isPoint(value)) {\n return await toDataValue(\n `${value.coordinates[1]},${value.coordinates[0]}`,\n client,\n actionMetadata,\n );\n }\n\n // object set (the rid as a string (passes through the last return), or the ObjectSet definition directly)\n if (isWireObjectSet(value)) {\n return value;\n }\n if (isObjectSet(value)) {\n return getWireObjectSet(value);\n }\n\n if (isMediaReference(value)) {\n return value;\n }\n\n if (isInterfaceActionParam(value)) {\n return {\n objectTypeApiName: value.$objectType,\n primaryKeyValue: value.$primaryKey,\n };\n }\n\n // TODO (during queries implementation)\n // two dimensional aggregation\n // three dimensional aggregation\n\n // struct\n if (typeof value === \"object\") {\n return Object.entries(value).reduce(\n async (promisedAcc, [key, structValue]) => {\n const acc = await promisedAcc;\n acc[key] = await toDataValue(structValue, client, actionMetadata);\n return acc;\n },\n Promise.resolve({} as { [key: string]: DataValue }),\n );\n }\n\n // expected to pass through - boolean, byte, date, decimal, float, double, integer, long, short, string, timestamp, object type reference\n return value;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;
|
|
1
|
+
{"version":3,"file":"toDataValue.js","names":["NULL_VALUE","MediaSets","OntologiesV2","isAttachmentFile","isAttachmentUpload","isMediaReference","isMediaUpload","getWireObjectSet","isObjectSet","isInterfaceActionParam","isObjectSpecifiersObject","isOntologyObjectV2","isPoint","isWireObjectSet","toDataValue","value","client","actionMetadata","Array","isArray","Set","values","from","some","dataValue","converted","push","promiseArray","innerValue","Promise","all","attachment","Attachments","upload","data","filename","name","rid","mediaRef","uploadMedia","fileName","preview","__primaryKey","$primaryKey","coordinates","objectTypeApiName","$objectType","primaryKeyValue","Object","entries","reduce","promisedAcc","key","structValue","acc","resolve"],"sources":["toDataValue.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 { NULL_VALUE } from \"@osdk/api\";\nimport type { ActionMetadata } from \"@osdk/api\";\nimport { MediaSets } from \"@osdk/foundry.mediasets\";\nimport { type DataValue } from \"@osdk/foundry.ontologies\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport {\n isAttachmentFile,\n isAttachmentUpload,\n} from \"../object/AttachmentUpload.js\";\nimport { isMediaReference, isMediaUpload } from \"../object/mediaUpload.js\";\nimport { getWireObjectSet, isObjectSet } from \"../objectSet/createObjectSet.js\";\nimport { isInterfaceActionParam } from \"./interfaceUtils.js\";\nimport { isObjectSpecifiersObject } from \"./isObjectSpecifiersObject.js\";\nimport { isOntologyObjectV2 } from \"./isOntologyObjectV2.js\";\nimport { isPoint } from \"./isPoint.js\";\nimport { isWireObjectSet } from \"./WireObjectSet.js\";\n\n/**\n * Marshall user-facing data into the wire DataValue type\n *\n * @see DataValue for the expected payloads\n * @internal\n */\nexport async function toDataValue(\n value: unknown,\n client: MinimalClient,\n actionMetadata: ActionMetadata,\n): Promise<DataValue> {\n if (value == null) {\n // typeof null is 'object' so do this first\n // Sending null over the wire clears the data, whereas undefined is dropped at request time.\n // Null values are not allowed with OSDK types, but leaving here as an override.\n return value;\n }\n\n if (value === NULL_VALUE) {\n return null;\n }\n\n // arrays and sets are both sent over the wire as arrays\n if (Array.isArray(value) || value instanceof Set) {\n const values = Array.from(value);\n if (\n values.some((dataValue) =>\n isAttachmentUpload(dataValue) || isAttachmentFile(dataValue)\n )\n ) {\n const converted = [];\n for (const value of values) {\n converted.push(await toDataValue(value, client, actionMetadata));\n }\n return converted;\n }\n const promiseArray = Array.from(\n value,\n async (innerValue) =>\n await toDataValue(innerValue, client, actionMetadata),\n );\n return Promise.all(promiseArray);\n }\n\n // For uploads, we need to upload ourselves first to get the RID of the attachment\n if (isAttachmentUpload(value)) {\n const attachment = await OntologiesV2.Attachments.upload(\n client,\n value.data,\n {\n filename: value.name,\n },\n );\n return await toDataValue(attachment.rid, client, actionMetadata);\n }\n\n if (isAttachmentFile(value)) {\n const attachment = await OntologiesV2.Attachments.upload(\n client,\n value,\n {\n filename: value.name as string,\n },\n );\n return await toDataValue(attachment.rid, client, actionMetadata);\n }\n\n // new media item upload interface, very similar to how attachments work above\n\n if (isMediaUpload(value)) {\n const mediaRef = await MediaSets.uploadMedia(\n client,\n value.data,\n {\n filename: value.fileName,\n preview: true,\n },\n );\n return await toDataValue(mediaRef, client, actionMetadata);\n }\n\n // objects just send the JSON'd primaryKey\n if (isOntologyObjectV2(value)) {\n return await toDataValue(value.__primaryKey, client, actionMetadata);\n }\n\n if (isObjectSpecifiersObject(value)) {\n return await toDataValue(value.$primaryKey, client, actionMetadata);\n }\n\n if (isPoint(value)) {\n return await toDataValue(\n `${value.coordinates[1]},${value.coordinates[0]}`,\n client,\n actionMetadata,\n );\n }\n\n // object set (the rid as a string (passes through the last return), or the ObjectSet definition directly)\n if (isWireObjectSet(value)) {\n return value;\n }\n if (isObjectSet(value)) {\n return getWireObjectSet(value);\n }\n\n if (isMediaReference(value)) {\n return value;\n }\n\n if (isInterfaceActionParam(value)) {\n return {\n objectTypeApiName: value.$objectType,\n primaryKeyValue: value.$primaryKey,\n };\n }\n\n // TODO (during queries implementation)\n // two dimensional aggregation\n // three dimensional aggregation\n\n // struct\n if (typeof value === \"object\") {\n return Object.entries(value).reduce(\n async (promisedAcc, [key, structValue]) => {\n const acc = await promisedAcc;\n acc[key] = await toDataValue(structValue, client, actionMetadata);\n return acc;\n },\n Promise.resolve({} as { [key: string]: DataValue }),\n );\n }\n\n // expected to pass through - boolean, byte, date, decimal, float, double, integer, long, short, string, timestamp, object type reference\n return value;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,UAAU,QAAQ,WAAW;AAEtC,SAASC,SAAS,QAAQ,yBAAyB;AAEnD,OAAO,KAAKC,YAAY,MAAM,0BAA0B;AAExD,SACEC,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AClB,OAAO,MAAMD,WAAW,CACtB,GAAGC,KAAK,CAAC6B,WAAW,CAAC,CAAC,CAAC,IAAI7B,KAAK,CAAC6B,WAAW,CAAC,CAAC,CAAC,EAAE,EACjD5B,MAAM,EACNC,cACF,CAAC;EACH;;EAEA;EACA,IAAIJ,eAAe,CAACE,KAAK,CAAC,EAAE;IAC1B,OAAOA,KAAK;EACd;EACA,IAAIP,WAAW,CAACO,KAAK,CAAC,EAAE;IACtB,OAAOR,gBAAgB,CAACQ,KAAK,CAAC;EAChC;EAEA,IAAIV,gBAAgB,CAACU,KAAK,CAAC,EAAE;IAC3B,OAAOA,KAAK;EACd;EAEA,IAAIN,sBAAsB,CAACM,KAAK,CAAC,EAAE;IACjC,OAAO;MACL8B,iBAAiB,EAAE9B,KAAK,CAAC+B,WAAW;MACpCC,eAAe,EAAEhC,KAAK,CAAC4B;IACzB,CAAC;EACH;;EAEA;EACA;EACA;;EAEA;EACA,IAAI,OAAO5B,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAOiC,MAAM,CAACC,OAAO,CAAClC,KAAK,CAAC,CAACmC,MAAM,CACjC,OAAOC,WAAW,EAAE,CAACC,GAAG,EAAEC,WAAW,CAAC,KAAK;MACzC,MAAMC,GAAG,GAAG,MAAMH,WAAW;MAC7BG,GAAG,CAACF,GAAG,CAAC,GAAG,MAAMtC,WAAW,CAACuC,WAAW,EAAErC,MAAM,EAAEC,cAAc,CAAC;MACjE,OAAOqC,GAAG;IACZ,CAAC,EACDzB,OAAO,CAAC0B,OAAO,CAAC,CAAC,CAAiC,CACpD,CAAC;EACH;;EAEA;EACA,OAAOxC,KAAK;AACd","ignoreList":[]}
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { NULL_VALUE } from "@osdk/api";
|
|
17
18
|
import { Employee, Task } from "@osdk/client.test.ontology";
|
|
18
19
|
import { LegacyFauxFoundry, MockOntologiesV2, startNodeApiServer, stubData } from "@osdk/shared.test";
|
|
19
20
|
import { beforeAll, describe, expect, it, vi } from "vitest";
|
|
@@ -186,5 +187,13 @@ describe(toDataValue, () => {
|
|
|
186
187
|
const converted = await toDataValue(mediaReference, clientCtx, mockActionMetadata);
|
|
187
188
|
expect(converted).toEqual(mediaReference);
|
|
188
189
|
});
|
|
190
|
+
it("Converts NULL_VALUE to null", async () => {
|
|
191
|
+
const converted = await toDataValue(NULL_VALUE, clientCtx, mockActionMetadata);
|
|
192
|
+
expect(converted).toBeNull();
|
|
193
|
+
});
|
|
194
|
+
it("Converts NULL_VALUE equivalents to null", async () => {
|
|
195
|
+
const converted = await toDataValue(Symbol.for("NULL_VALUE"), clientCtx, mockActionMetadata);
|
|
196
|
+
expect(converted).toEqual(null);
|
|
197
|
+
});
|
|
189
198
|
});
|
|
190
199
|
//# sourceMappingURL=toDataValue.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toDataValue.test.js","names":["Employee","Task","LegacyFauxFoundry","MockOntologiesV2","startNodeApiServer","stubData","beforeAll","describe","expect","it","vi","createClient","createMinimalClient","createAttachmentUpload","isMediaReference","getWireObjectSet","toDataValue","client","clientCtx","mockActionMetadata","apiServer","fn","testSetup","ontologyRid","fauxFoundry","defaultOntologyRid","baseUrl","auth","apiName","close","basic","null","undefined","boolean","date","integer","string","timestamp","convertedBasic","toEqual","attachment","attachmentArray","attachmentSet","Set","recursiveConversion","inner","employee","employee1","ontologyConversion","__primaryKey","task","fetchOne","$primaryKey","clientObjectSet","where","id","definition","expected","objectSetConversion","toMatchInlineSnapshot","definitionConversion","blob","Blob","JSON","stringify","attachmentUpload","converted","toMatch","file","Object","assign","name","type","data","fileName","boundary","use","MediaReferenceProperties","uploadMedia","mimeType","reference","mediaSetViewItem","mediaItemRid","mediaSetRid","mediaSetViewRid","toBe","mediaReference"],"sources":["toDataValue.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 { ActionMetadata, MediaUpload } from \"@osdk/api\";\nimport { Employee, Task } from \"@osdk/client.test.ontology\";\nimport type { MediaReference } from \"@osdk/foundry.core\";\nimport type { SetupServer } from \"@osdk/shared.test\";\nimport {\n LegacyFauxFoundry,\n MockOntologiesV2,\n startNodeApiServer,\n stubData,\n} from \"@osdk/shared.test\";\nimport type { MockedFunction } from \"vitest\";\nimport { beforeAll, describe, expect, it, vi } from \"vitest\";\nimport type { Client } from \"../Client.js\";\nimport { createClient } from \"../createClient.js\";\nimport { createMinimalClient } from \"../createMinimalClient.js\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport { createAttachmentUpload } from \"../object/AttachmentUpload.js\";\nimport { isMediaReference } from \"../object/mediaUpload.js\";\nimport { getWireObjectSet } from \"../objectSet/createObjectSet.js\";\nimport { toDataValue } from \"./toDataValue.js\";\n\ndescribe(toDataValue, () => {\n let client: Client;\n let clientCtx: MinimalClient;\n let mockActionMetadata: ActionMetadata;\n let apiServer: SetupServer;\n\n const mockFetch: MockedFunction<typeof globalThis.fetch> = vi.fn();\n\n beforeAll(() => {\n const testSetup = startNodeApiServer(new LegacyFauxFoundry(), createClient);\n ({ client } = testSetup);\n\n apiServer = testSetup.apiServer;\n\n clientCtx = createMinimalClient(\n { ontologyRid: testSetup.fauxFoundry.defaultOntologyRid },\n testSetup.fauxFoundry.baseUrl,\n testSetup.auth,\n {},\n );\n\n // toDataValue only needs the apiName right now, update this if that changes\n const fakeActionMetadata = {\n apiName: \"createUnstructuredImageExampleObject\",\n };\n mockActionMetadata = fakeActionMetadata as ActionMetadata;\n\n return () => {\n testSetup.apiServer.close();\n };\n });\n\n it(\"converts passthrough values correctly\", async () => {\n // basic pass through types\n const basic = {\n null: undefined,\n boolean: false,\n date: \"2024-01-01\",\n integer: 0,\n string: \"string\",\n timestamp: \"2024-01-01T00:00:00Z\",\n };\n const convertedBasic = await toDataValue(\n basic,\n clientCtx,\n mockActionMetadata,\n );\n expect(convertedBasic).toEqual(basic);\n });\n\n it(\"recursively converts arrays and sets into array types\", async () => {\n const attachment = \"rid\";\n const attachmentArray = [attachment];\n const attachmentSet = new Set(attachmentArray);\n\n const recursiveConversion = await toDataValue(\n {\n attachment,\n attachmentArray,\n attachmentSet,\n },\n clientCtx,\n mockActionMetadata,\n );\n\n expect(recursiveConversion).toEqual({\n attachment: \"rid\",\n attachmentArray: [\"rid\"],\n attachmentSet: [\"rid\"],\n });\n });\n\n it(\"recursively handles structs\", async () => {\n const struct = {\n inner: {\n attachment: \"rid\",\n },\n };\n\n const recursiveConversion = await toDataValue(\n struct,\n clientCtx,\n mockActionMetadata,\n );\n\n expect(recursiveConversion).toEqual({\n inner: { attachment: \"rid\" },\n });\n });\n\n it(\"maps an ontology object into just its primary key\", async () => {\n const employee = stubData.employee1;\n const ontologyConversion = await toDataValue(\n employee,\n clientCtx,\n mockActionMetadata,\n );\n expect(ontologyConversion).toEqual(\n stubData.employee1.__primaryKey,\n );\n });\n\n it(\"maps an ontology object into just its primary key with osdk wrapper\", async () => {\n const task = await client(Employee).fetchOne(50030);\n const ontologyConversion = await toDataValue(\n task,\n clientCtx,\n mockActionMetadata,\n );\n expect(ontologyConversion).toEqual(\n task.$primaryKey,\n );\n });\n\n it(\"passes through object set definitions\", async () => {\n const clientObjectSet = client(Task).where({ id: 0 });\n const definition = getWireObjectSet(clientObjectSet);\n\n const expected = `\n {\n \"objectSet\": {\n \"objectType\": \"Task\",\n \"type\": \"base\",\n },\n \"type\": \"filter\",\n \"where\": {\n \"field\": \"id\",\n \"type\": \"eq\",\n \"value\": 0,\n },\n }\n `;\n const objectSetConversion = await toDataValue(\n clientObjectSet,\n clientCtx,\n mockActionMetadata,\n );\n expect(objectSetConversion).toMatchInlineSnapshot(\n expected,\n );\n\n const definitionConversion = await toDataValue(\n definition,\n clientCtx,\n mockActionMetadata,\n );\n expect(definitionConversion).toMatchInlineSnapshot(expected);\n });\n\n it(\"converts blob attachment uploads correctly\", async () => {\n const blob = new Blob([JSON.stringify({ \"hi\": \"mom\" })]);\n const attachmentUpload = createAttachmentUpload(blob, \"file1.txt\");\n const converted = await toDataValue(\n attachmentUpload,\n clientCtx,\n mockActionMetadata,\n );\n\n expect(converted).toMatch(/ri\\.attachments.main.attachment\\.[a-z0-9\\-]+/i);\n });\n\n it(\"converts file attachment uploads correctly\", async () => {\n // Mimics the Web file API (https://developer.mozilla.org/en-US/docs/Web/API/File). The File constructor is only available in Node 19.2.0 and above\n const file = Object.assign(\n new Blob([\n JSON.stringify({ name: \"Hello World\" }, null, 2),\n ], {\n type: \"application/json\",\n }),\n { name: \"file1.txt\" },\n );\n\n const converted = await toDataValue(file, clientCtx, mockActionMetadata);\n expect(converted).toMatch(/ri\\.attachments.main.attachment\\.[a-z0-9\\-]+/i);\n });\n\n it(\"converts media uploads correctly\", async () => {\n const file: MediaUpload = {\n data: new Blob([\n JSON.stringify({ name: \"Hello World\" }, null, 2),\n ], {\n type: \"application/json\",\n }),\n fileName: \"file.txt\",\n };\n\n // TODO: Mock MediaUpload properly in FauxFoundry\n apiServer.boundary(async () => {\n apiServer.use(\n MockOntologiesV2.MediaReferenceProperties.uploadMedia(\n \"https://stack.palantir.com\",\n () => {\n return {\n mimeType: \"application/json\",\n reference: {\n type: \"mediaSetViewItem\",\n mediaSetViewItem: {\n mediaItemRid: \"media-item-rid\",\n mediaSetRid: \"media-set-rid\",\n mediaSetViewRid: \"media-set-view-rid\",\n },\n },\n };\n },\n ),\n );\n const converted = await toDataValue(file, clientCtx, mockActionMetadata);\n expect(isMediaReference(converted)).toBe(true);\n });\n });\n\n it(\"converts media reference correctly\", async () => {\n const mediaReference: MediaReference = {\n mimeType: \"application/json\",\n reference: {\n type: \"mediaSetViewItem\",\n mediaSetViewItem: {\n mediaItemRid: \"media-item-rid\",\n mediaSetRid: \"media-set-rid\",\n mediaSetViewRid: \"media-set-view-rid\",\n },\n },\n };\n\n const converted = await toDataValue(\n mediaReference,\n clientCtx,\n mockActionMetadata,\n );\n expect(converted).toEqual(mediaReference);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,EAAEC,IAAI,QAAQ,4BAA4B;AAG3D,SACEC,iBAAiB,EACjBC,gBAAgB,EAChBC,kBAAkB,EAClBC,QAAQ,QACH,mBAAmB;AAE1B,SAASC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,QAAQ;AAE5D,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,mBAAmB,QAAQ,2BAA2B;AAE/D,SAASC,sBAAsB,QAAQ,+BAA+B;AACtE,SAASC,gBAAgB,QAAQ,0BAA0B;AAC3D,SAASC,gBAAgB,QAAQ,iCAAiC;AAClE,SAASC,WAAW,QAAQ,kBAAkB;AAE9CT,QAAQ,CAACS,WAAW,EAAE,MAAM;EAC1B,IAAIC,MAAc;EAClB,IAAIC,SAAwB;EAC5B,IAAIC,kBAAkC;EACtC,IAAIC,SAAsB;EAEiCV,EAAE,CAACW,EAAE,CAAC,CAAC;EAElEf,SAAS,CAAC,MAAM;IACd,MAAMgB,SAAS,GAAGlB,kBAAkB,CAAC,IAAIF,iBAAiB,CAAC,CAAC,EAAES,YAAY,CAAC;IAC3E,CAAC;MAAEM;IAAO,CAAC,GAAGK,SAAS;IAEvBF,SAAS,GAAGE,SAAS,CAACF,SAAS;IAE/BF,SAAS,GAAGN,mBAAmB,CAC7B;MAAEW,WAAW,EAAED,SAAS,CAACE,WAAW,CA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ALUE","Employee","Task","LegacyFauxFoundry","MockOntologiesV2","startNodeApiServer","stubData","beforeAll","describe","expect","it","vi","createClient","createMinimalClient","createAttachmentUpload","isMediaReference","getWireObjectSet","toDataValue","client","clientCtx","mockActionMetadata","apiServer","fn","testSetup","ontologyRid","fauxFoundry","defaultOntologyRid","baseUrl","auth","apiName","close","basic","null","undefined","boolean","date","integer","string","timestamp","convertedBasic","toEqual","attachment","attachmentArray","attachmentSet","Set","recursiveConversion","inner","employee","employee1","ontologyConversion","__primaryKey","task","fetchOne","$primaryKey","clientObjectSet","where","id","definition","expected","objectSetConversion","toMatchInlineSnapshot","definitionConversion","blob","Blob","JSON","stringify","attachmentUpload","converted","toMatch","file","Object","assign","name","type","data","fileName","boundary","use","MediaReferenceProperties","uploadMedia","mimeType","reference","mediaSetViewItem","mediaItemRid","mediaSetRid","mediaSetViewRid","toBe","mediaReference","toBeNull","Symbol","for"],"sources":["toDataValue.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 { NULL_VALUE } from \"@osdk/api\";\nimport type { ActionMetadata, MediaUpload } from \"@osdk/api\";\nimport { Employee, Task } from \"@osdk/client.test.ontology\";\nimport type { MediaReference } from \"@osdk/foundry.core\";\nimport type { SetupServer } from \"@osdk/shared.test\";\nimport {\n LegacyFauxFoundry,\n MockOntologiesV2,\n startNodeApiServer,\n stubData,\n} from \"@osdk/shared.test\";\nimport type { MockedFunction } from \"vitest\";\nimport { beforeAll, describe, expect, it, vi } from \"vitest\";\nimport type { Client } from \"../Client.js\";\nimport { createClient } from \"../createClient.js\";\nimport { createMinimalClient } from \"../createMinimalClient.js\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport { createAttachmentUpload } from \"../object/AttachmentUpload.js\";\nimport { isMediaReference } from \"../object/mediaUpload.js\";\nimport { getWireObjectSet } from \"../objectSet/createObjectSet.js\";\nimport { toDataValue } from \"./toDataValue.js\";\n\ndescribe(toDataValue, () => {\n let client: Client;\n let clientCtx: MinimalClient;\n let mockActionMetadata: ActionMetadata;\n let apiServer: SetupServer;\n\n const mockFetch: MockedFunction<typeof globalThis.fetch> = vi.fn();\n\n beforeAll(() => {\n const testSetup = startNodeApiServer(new LegacyFauxFoundry(), createClient);\n ({ client } = testSetup);\n\n apiServer = testSetup.apiServer;\n\n clientCtx = createMinimalClient(\n { ontologyRid: testSetup.fauxFoundry.defaultOntologyRid },\n testSetup.fauxFoundry.baseUrl,\n testSetup.auth,\n {},\n );\n\n // toDataValue only needs the apiName right now, update this if that changes\n const fakeActionMetadata = {\n apiName: \"createUnstructuredImageExampleObject\",\n };\n mockActionMetadata = fakeActionMetadata as ActionMetadata;\n\n return () => {\n testSetup.apiServer.close();\n };\n });\n\n it(\"converts passthrough values correctly\", async () => {\n // basic pass through types\n const basic = {\n null: undefined,\n boolean: false,\n date: \"2024-01-01\",\n integer: 0,\n string: \"string\",\n timestamp: \"2024-01-01T00:00:00Z\",\n };\n const convertedBasic = await toDataValue(\n basic,\n clientCtx,\n mockActionMetadata,\n );\n expect(convertedBasic).toEqual(basic);\n });\n\n it(\"recursively converts arrays and sets into array types\", async () => {\n const attachment = \"rid\";\n const attachmentArray = [attachment];\n const attachmentSet = new Set(attachmentArray);\n\n const recursiveConversion = await toDataValue(\n {\n attachment,\n attachmentArray,\n attachmentSet,\n },\n clientCtx,\n mockActionMetadata,\n );\n\n expect(recursiveConversion).toEqual({\n attachment: \"rid\",\n attachmentArray: [\"rid\"],\n attachmentSet: [\"rid\"],\n });\n });\n\n it(\"recursively handles structs\", async () => {\n const struct = {\n inner: {\n attachment: \"rid\",\n },\n };\n\n const recursiveConversion = await toDataValue(\n struct,\n clientCtx,\n mockActionMetadata,\n );\n\n expect(recursiveConversion).toEqual({\n inner: { attachment: \"rid\" },\n });\n });\n\n it(\"maps an ontology object into just its primary key\", async () => {\n const employee = stubData.employee1;\n const ontologyConversion = await toDataValue(\n employee,\n clientCtx,\n mockActionMetadata,\n );\n expect(ontologyConversion).toEqual(\n stubData.employee1.__primaryKey,\n );\n });\n\n it(\"maps an ontology object into just its primary key with osdk wrapper\", async () => {\n const task = await client(Employee).fetchOne(50030);\n const ontologyConversion = await toDataValue(\n task,\n clientCtx,\n mockActionMetadata,\n );\n expect(ontologyConversion).toEqual(\n task.$primaryKey,\n );\n });\n\n it(\"passes through object set definitions\", async () => {\n const clientObjectSet = client(Task).where({ id: 0 });\n const definition = getWireObjectSet(clientObjectSet);\n\n const expected = `\n {\n \"objectSet\": {\n \"objectType\": \"Task\",\n \"type\": \"base\",\n },\n \"type\": \"filter\",\n \"where\": {\n \"field\": \"id\",\n \"type\": \"eq\",\n \"value\": 0,\n },\n }\n `;\n const objectSetConversion = await toDataValue(\n clientObjectSet,\n clientCtx,\n mockActionMetadata,\n );\n expect(objectSetConversion).toMatchInlineSnapshot(\n expected,\n );\n\n const definitionConversion = await toDataValue(\n definition,\n clientCtx,\n mockActionMetadata,\n );\n expect(definitionConversion).toMatchInlineSnapshot(expected);\n });\n\n it(\"converts blob attachment uploads correctly\", async () => {\n const blob = new Blob([JSON.stringify({ \"hi\": \"mom\" })]);\n const attachmentUpload = createAttachmentUpload(blob, \"file1.txt\");\n const converted = await toDataValue(\n attachmentUpload,\n clientCtx,\n mockActionMetadata,\n );\n\n expect(converted).toMatch(/ri\\.attachments.main.attachment\\.[a-z0-9\\-]+/i);\n });\n\n it(\"converts file attachment uploads correctly\", async () => {\n // Mimics the Web file API (https://developer.mozilla.org/en-US/docs/Web/API/File). The File constructor is only available in Node 19.2.0 and above\n const file = Object.assign(\n new Blob([\n JSON.stringify({ name: \"Hello World\" }, null, 2),\n ], {\n type: \"application/json\",\n }),\n { name: \"file1.txt\" },\n );\n\n const converted = await toDataValue(file, clientCtx, mockActionMetadata);\n expect(converted).toMatch(/ri\\.attachments.main.attachment\\.[a-z0-9\\-]+/i);\n });\n\n it(\"converts media uploads correctly\", async () => {\n const file: MediaUpload = {\n data: new Blob([\n JSON.stringify({ name: \"Hello World\" }, null, 2),\n ], {\n type: \"application/json\",\n }),\n fileName: \"file.txt\",\n };\n\n // TODO: Mock MediaUpload properly in FauxFoundry\n apiServer.boundary(async () => {\n apiServer.use(\n MockOntologiesV2.MediaReferenceProperties.uploadMedia(\n \"https://stack.palantir.com\",\n () => {\n return {\n mimeType: \"application/json\",\n reference: {\n type: \"mediaSetViewItem\",\n mediaSetViewItem: {\n mediaItemRid: \"media-item-rid\",\n mediaSetRid: \"media-set-rid\",\n mediaSetViewRid: \"media-set-view-rid\",\n },\n },\n };\n },\n ),\n );\n const converted = await toDataValue(file, clientCtx, mockActionMetadata);\n expect(isMediaReference(converted)).toBe(true);\n });\n });\n\n it(\"converts media reference correctly\", async () => {\n const mediaReference: MediaReference = {\n mimeType: \"application/json\",\n reference: {\n type: \"mediaSetViewItem\",\n mediaSetViewItem: {\n mediaItemRid: \"media-item-rid\",\n mediaSetRid: \"media-set-rid\",\n mediaSetViewRid: \"media-set-view-rid\",\n },\n },\n };\n\n const converted = await toDataValue(\n mediaReference,\n clientCtx,\n mockActionMetadata,\n );\n expect(converted).toEqual(mediaReference);\n });\n\n it(\"Converts NULL_VALUE to null\", async () => {\n const converted = await toDataValue(\n NULL_VALUE,\n clientCtx,\n mockActionMetadata,\n );\n expect(converted).toBeNull();\n });\n\n it(\"Converts NULL_VALUE equivalents to null\", async () => {\n const clearData = Symbol.for(\"NULL_VALUE\") as symbol & {\n __type: \"NULL_VALUE\";\n };\n const converted = await toDataValue(\n clearData,\n clientCtx,\n mockActionMetadata,\n );\n expect(converted).toEqual(null);\n });\n});\n"],"m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