@osdk/client 2.23.0 → 2.23.1-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 +27 -0
- 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 +3 -1
- package/build/browser/actions/applyAction.js.map +1 -1
- package/build/browser/createClient.js +7 -3
- package/build/browser/createClient.js.map +1 -1
- package/build/browser/createMinimalClient.js +10 -0
- package/build/browser/createMinimalClient.js.map +1 -1
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +3 -0
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js +30 -10
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/browser/object/aggregate.js +2 -1
- package/build/browser/object/aggregate.js.map +1 -1
- package/build/browser/object/fetchPage.js +6 -3
- package/build/browser/object/fetchPage.js.map +1 -1
- package/build/browser/objectSet/createObjectSet.js +3 -0
- package/build/browser/objectSet/createObjectSet.js.map +1 -1
- package/build/browser/public/unstable-do-not-use.js +2 -0
- package/build/browser/public/unstable-do-not-use.js.map +1 -1
- package/build/browser/queries/applyQuery.js +1 -0
- package/build/browser/queries/applyQuery.js.map +1 -1
- package/build/browser/scenarios/ScenarioClient.js +202 -0
- package/build/browser/scenarios/ScenarioClient.js.map +1 -0
- package/build/browser/scenarios/createScenario.js +55 -0
- package/build/browser/scenarios/createScenario.js.map +1 -0
- package/build/browser/scenarios/withScenario.js +42 -0
- package/build/browser/scenarios/withScenario.js.map +1 -0
- 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/cjs/MediaReferenceProperty-CBPMMD73.cjs +22 -0
- package/build/cjs/{MediaReferenceProperty-Y6R5ASNW.cjs.map → MediaReferenceProperty-CBPMMD73.cjs.map} +1 -1
- package/build/cjs/{applyStreamingQuery-F77N7EOP.cjs → applyStreamingQuery-G2PA2SM7.cjs} +11 -11
- package/build/cjs/{applyStreamingQuery-F77N7EOP.cjs.map → applyStreamingQuery-G2PA2SM7.cjs.map} +1 -1
- package/build/cjs/{chunk-KILPUOJP.cjs → chunk-BV6P25ZM.cjs} +51 -21
- package/build/cjs/chunk-BV6P25ZM.cjs.map +1 -0
- package/build/cjs/{chunk-3DMI6Z4B.cjs → chunk-IWAZIBOK.cjs} +75 -75
- package/build/cjs/{chunk-3DMI6Z4B.cjs.map → chunk-IWAZIBOK.cjs.map} +1 -1
- package/build/cjs/{chunk-MURBAIS4.cjs → chunk-NFD4IH4H.cjs} +17 -16
- package/build/cjs/chunk-NFD4IH4H.cjs.map +1 -0
- package/build/cjs/{chunk-5WD6SB7R.cjs → chunk-WBINM4RT.cjs} +297 -100
- package/build/cjs/chunk-WBINM4RT.cjs.map +1 -0
- package/build/cjs/{chunk-DOXHU27E.cjs → chunk-YP43NHIA.cjs} +3 -3
- package/build/cjs/{chunk-DOXHU27E.cjs.map → chunk-YP43NHIA.cjs.map} +1 -1
- package/build/cjs/{chunk-ZPLXXOU6.cjs → chunk-ZFNHWPQA.cjs} +3 -3
- package/build/cjs/{chunk-ZPLXXOU6.cjs.map → chunk-ZFNHWPQA.cjs.map} +1 -1
- package/build/cjs/index.cjs +13 -13
- package/build/cjs/public/experimental.cjs +8 -8
- package/build/cjs/public/internal.cjs +8 -8
- package/build/cjs/public/observable.cjs +7 -7
- package/build/cjs/public/unstable-do-not-use.cjs +37 -12
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +167 -4
- package/build/cjs/{transformAndWaitInternal-F3UV33FN.cjs → transformAndWaitInternal-2GORZXPK.cjs} +6 -6
- package/build/cjs/{transformAndWaitInternal-F3UV33FN.cjs.map → transformAndWaitInternal-2GORZXPK.cjs.map} +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 +3 -1
- package/build/esm/actions/applyAction.js.map +1 -1
- package/build/esm/createClient.js +7 -3
- package/build/esm/createClient.js.map +1 -1
- package/build/esm/createMinimalClient.js +10 -0
- package/build/esm/createMinimalClient.js.map +1 -1
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +3 -0
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js +30 -10
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/esm/object/aggregate.js +2 -1
- package/build/esm/object/aggregate.js.map +1 -1
- package/build/esm/object/fetchPage.js +6 -3
- package/build/esm/object/fetchPage.js.map +1 -1
- package/build/esm/objectSet/createObjectSet.js +3 -0
- package/build/esm/objectSet/createObjectSet.js.map +1 -1
- package/build/esm/public/unstable-do-not-use.js +2 -0
- package/build/esm/public/unstable-do-not-use.js.map +1 -1
- package/build/esm/queries/applyQuery.js +1 -0
- package/build/esm/queries/applyQuery.js.map +1 -1
- package/build/esm/scenarios/ScenarioClient.js +202 -0
- package/build/esm/scenarios/ScenarioClient.js.map +1 -0
- package/build/esm/scenarios/createScenario.js +55 -0
- package/build/esm/scenarios/createScenario.js.map +1 -0
- package/build/esm/scenarios/withScenario.js +42 -0
- package/build/esm/scenarios/withScenario.js.map +1 -0
- 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/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.map +1 -1
- package/build/types/public/unstable-do-not-use.d.ts +3 -0
- package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
- package/build/types/queries/applyQuery.d.ts.map +1 -1
- package/build/types/scenarios/ScenarioClient.d.ts +131 -0
- package/build/types/scenarios/ScenarioClient.d.ts.map +1 -0
- package/build/types/scenarios/createScenario.d.ts +21 -0
- package/build/types/scenarios/createScenario.d.ts.map +1 -0
- package/build/types/scenarios/withScenario.d.ts +23 -0
- package/build/types/scenarios/withScenario.d.ts.map +1 -0
- package/package.json +14 -14
- package/build/cjs/MediaReferenceProperty-Y6R5ASNW.cjs +0 -22
- package/build/cjs/chunk-5WD6SB7R.cjs.map +0 -1
- package/build/cjs/chunk-KILPUOJP.cjs.map +0 -1
- package/build/cjs/chunk-MURBAIS4.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyQuery.js","names":["Queries","invariant","createMediaFromReferenceInternal","createObjectSet","hydrateAttachmentFromRidInternal","addUserAgentAndRequestContextHeaders","augmentRequestContext","createObjectSpecifierFromInterfaceSpecifier","createObjectSpecifierFromPrimaryKey","toDataValueQueries","applyQuery","client","query","params","qd","ontologyProvider","getQueryDefinition","apiName","isFixedVersion","version","undefined","flushEdits","response","execute","finalMethodCall","ontologyRid","parameters","remapQueryParams","transactionId","branch","objectOutputDefs","getRequiredDefinitions","output","remappedResponse","remapQueryResponse","value","paramTypes","parameterMap","key","Object","entries","responseDataType","responseValue","definitions","nullable","Error","type","i","length","array","set","def","get","object","createQueryObjectResponse","interface","createQueryInterfaceResponse","objectSet","objectSets","objectType","reference","subtype","struct","requiresConversion","map","Array","isArray","process","env","NODE_ENV","entry","valueType","keyType","getObjectSpecifier","result","groups","push","subResult","subKey","dataType","Map","objectDef","getObjectDefinition","interfaceDef","getInterfaceDefinition","types","allDefs","Promise","all","defs","structValues","values","some","primaryKey","objectTypeApiName","$apiName","$title","$objectType","$primaryKey","$objectSpecifier","interfaceSpecifier","primaryKeyValue"],"sources":["applyQuery.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 {\n AllowedBucketKeyTypes,\n AllowedBucketTypes,\n CompileTimeMetadata,\n InterfaceDefinition,\n ObjectOrInterfaceDefinition,\n ObjectTypeDefinition,\n OsdkBase,\n PrimaryKeyType,\n QueryDataTypeDefinition,\n QueryDefinition,\n QueryMetadata,\n QueryParameterDefinition,\n} from \"@osdk/api\";\nimport type { DataValue } from \"@osdk/foundry.ontologies\";\nimport * as Queries from \"@osdk/foundry.ontologies/Query\";\nimport invariant from \"tiny-invariant\";\nimport { createMediaFromReferenceInternal } from \"../createMediaFromReference.js\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport { createObjectSet } from \"../objectSet/createObjectSet.js\";\nimport { hydrateAttachmentFromRidInternal } from \"../public-utils/hydrateAttachmentFromRid.js\";\nimport { addUserAgentAndRequestContextHeaders } from \"../util/addUserAgentAndRequestContextHeaders.js\";\nimport { augmentRequestContext } from \"../util/augmentRequestContext.js\";\nimport {\n createObjectSpecifierFromInterfaceSpecifier,\n createObjectSpecifierFromPrimaryKey,\n} from \"../util/objectSpecifierUtils.js\";\nimport { toDataValueQueries } from \"../util/toDataValueQueries.js\";\nimport type { QueryParameterType, QueryReturnType } from \"./types.js\";\n\nexport async function applyQuery<\n QD extends QueryDefinition<any>,\n P extends QueryParameterType<CompileTimeMetadata<QD>[\"parameters\"]>,\n>(\n client: MinimalClient,\n query: QD,\n params?: P,\n): Promise<\n QueryReturnType<CompileTimeMetadata<QD>[\"output\"]>\n> {\n // We fire and forget so if a function has no parameters we don't unnecessarily load all metadata\n const qd: Promise<QueryMetadata> = client.ontologyProvider.getQueryDefinition(\n query.apiName,\n query.isFixedVersion ? query.version : undefined,\n );\n\n if (client.flushEdits != null) {\n await client.flushEdits();\n }\n\n const response = await Queries.execute(\n addUserAgentAndRequestContextHeaders(\n augmentRequestContext(client, _ => ({ finalMethodCall: \"applyQuery\" })),\n query,\n ),\n await client.ontologyRid,\n query.apiName,\n {\n parameters: params\n ? await remapQueryParams(\n params as { [parameterId: string]: any },\n client,\n (await qd).parameters,\n )\n : {},\n },\n {\n version: query.isFixedVersion ? query.version : undefined,\n transactionId: client.transactionId,\n branch: client.branch,\n },\n );\n\n const objectOutputDefs = await getRequiredDefinitions(\n (await qd).output,\n client,\n );\n const remappedResponse = await remapQueryResponse(\n client,\n (await qd).output,\n response.value,\n objectOutputDefs,\n );\n return remappedResponse as QueryReturnType<CompileTimeMetadata<QD>[\"output\"]>;\n}\n\nexport async function remapQueryParams(\n params: { [parameterId: string]: any },\n client: MinimalClient,\n paramTypes: Record<string, QueryParameterDefinition<any>>,\n): Promise<{ [parameterId: string]: any }> {\n const parameterMap: { [parameterName: string]: unknown } = {};\n for (const [key, value] of Object.entries(params)) {\n parameterMap[key] = await toDataValueQueries(\n value,\n client,\n paramTypes[key],\n );\n }\n return parameterMap;\n}\n\nexport async function remapQueryResponse<\n Q extends ObjectTypeDefinition,\n T extends QueryDataTypeDefinition<Q | never>,\n>(\n client: MinimalClient,\n responseDataType: T,\n responseValue: DataValue,\n definitions: Map<string, ObjectOrInterfaceDefinition>,\n): Promise<QueryReturnType<T>> {\n // handle null responses\n if (responseValue == null) {\n if (responseDataType.nullable) {\n return undefined as unknown as QueryReturnType<typeof responseDataType>;\n } else {\n throw new Error(\"Got null response when nullable was not allowed\");\n }\n }\n\n switch (responseDataType.type) {\n case \"union\": {\n throw new Error(\"Union return types are not yet supported\");\n }\n\n case \"array\": {\n for (let i = 0; i < responseValue.length; i++) {\n responseValue[i] = await remapQueryResponse(\n client,\n responseDataType.array,\n responseValue[i],\n definitions,\n );\n }\n\n return responseValue as QueryReturnType<typeof responseDataType>;\n }\n\n case \"set\": {\n for (let i = 0; i < responseValue.length; i++) {\n responseValue[i] = await remapQueryResponse(\n client,\n responseDataType.set,\n responseValue[i],\n definitions,\n );\n }\n\n return responseValue as QueryReturnType<typeof responseDataType>;\n }\n\n case \"attachment\": {\n return hydrateAttachmentFromRidInternal(\n client,\n responseValue,\n ) as QueryReturnType<\n typeof responseDataType\n >;\n }\n\n case \"mediaReference\": {\n return createMediaFromReferenceInternal(\n client,\n responseValue,\n ) as unknown as QueryReturnType<\n typeof responseDataType\n >;\n }\n\n case \"object\": {\n const def = definitions.get(responseDataType.object);\n if (!def || def.type !== \"object\") {\n throw new Error(\n `Missing definition for ${responseDataType.object}`,\n );\n }\n return createQueryObjectResponse(\n responseValue,\n def,\n ) as QueryReturnType<\n typeof responseDataType\n >;\n }\n\n case \"interface\": {\n const def = definitions.get(responseDataType.interface);\n if (!def || def.type !== \"interface\") {\n throw new Error(\n `Missing definition for ${responseDataType.interface}`,\n );\n }\n\n return createQueryInterfaceResponse(\n responseValue,\n def,\n ) as QueryReturnType<\n typeof responseDataType\n >;\n }\n\n case \"objectSet\": {\n const def = definitions.get(responseDataType.objectSet);\n if (!def) {\n throw new Error(\n `Missing definition for ${responseDataType.objectSet}`,\n );\n }\n if (typeof responseValue === \"string\") {\n return createObjectSet(def, client, {\n type: \"intersect\",\n objectSets: [\n { type: \"base\", objectType: responseDataType.objectSet },\n { type: \"reference\", reference: responseValue },\n ],\n }) as QueryReturnType<typeof responseDataType>;\n }\n\n return createObjectSet(\n def,\n client,\n responseValue,\n ) as QueryReturnType<\n typeof responseDataType\n >;\n }\n\n case \"struct\": {\n // figure out what keys need to be fixed up\n for (const [key, subtype] of Object.entries(responseDataType.struct)) {\n if (requiresConversion(subtype) || responseValue[key] == null) {\n responseValue[key] = await remapQueryResponse(\n client,\n subtype,\n responseValue[key],\n definitions,\n );\n }\n }\n\n return responseValue as QueryReturnType<typeof responseDataType>;\n }\n\n case \"map\": {\n const map = {} as any;\n\n invariant(Array.isArray(responseValue), \"Expected array entry\");\n for (const entry of responseValue) {\n invariant(entry.key != null, \"Expected key\");\n invariant(\n responseDataType.valueType.nullable || entry.value != null,\n \"Expected value\",\n );\n const key = responseDataType.keyType.type === \"object\"\n ? getObjectSpecifier(\n entry.key,\n responseDataType.keyType.object,\n definitions,\n )\n : entry.key;\n const value = await remapQueryResponse(\n client,\n responseDataType.valueType,\n entry.value,\n definitions,\n );\n map[key] = value;\n }\n return map;\n }\n\n case \"twoDimensionalAggregation\": {\n const result: {\n key: AllowedBucketKeyTypes;\n value: AllowedBucketTypes;\n }[] = [];\n for (const { key, value } of responseValue.groups) {\n result.push({ key, value });\n }\n return result as QueryReturnType<typeof responseDataType>;\n }\n\n case \"threeDimensionalAggregation\": {\n const result: {\n key: AllowedBucketKeyTypes;\n groups: { key: AllowedBucketKeyTypes; value: AllowedBucketTypes }[];\n }[] = [];\n for (const { key, groups } of responseValue.groups) {\n const subResult: { key: any; value: any }[] = [];\n for (const { key: subKey, value } of groups) {\n subResult.push({ key: subKey, value });\n }\n result.push({ key, groups: subResult });\n }\n return result as QueryReturnType<typeof responseDataType>;\n }\n }\n\n return responseValue as QueryReturnType<typeof responseDataType>;\n}\n\nexport async function getRequiredDefinitions(\n dataType: QueryDataTypeDefinition,\n client: MinimalClient,\n): Promise<Map<string, ObjectOrInterfaceDefinition>> {\n const result = new Map<string, ObjectOrInterfaceDefinition>();\n switch (dataType.type) {\n case \"objectSet\": {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n dataType.objectSet,\n );\n result.set(dataType.objectSet, objectDef);\n break;\n }\n case \"interfaceObjectSet\": {\n const interfaceDef = await client.ontologyProvider.getInterfaceDefinition(\n dataType.objectSet,\n );\n result.set(dataType.objectSet, interfaceDef);\n break;\n }\n case \"object\": {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n dataType.object,\n );\n result.set(dataType.object, objectDef);\n break;\n }\n\n case \"interface\": {\n const interfaceDef = await client.ontologyProvider.getInterfaceDefinition(\n dataType.interface,\n );\n result.set(dataType.interface, interfaceDef);\n break;\n }\n\n case \"set\": {\n return getRequiredDefinitions(dataType.set, client);\n }\n case \"array\": {\n return getRequiredDefinitions(dataType.array, client);\n }\n\n case \"map\": {\n const types = [dataType.keyType, dataType.valueType];\n\n const allDefs = await Promise.all(\n types.map(value => getRequiredDefinitions(value, client)),\n );\n\n for (const defs of allDefs) {\n for (const [type, objectDef] of defs) {\n result.set(type, objectDef);\n }\n }\n break;\n }\n\n case \"struct\": {\n const structValues = Object.values(dataType.struct);\n\n const allDefs = await Promise.all(\n structValues.map(value => getRequiredDefinitions(value, client)),\n );\n\n for (const defs of allDefs) {\n for (const [type, objectDef] of defs) {\n result.set(type, objectDef);\n }\n }\n break;\n }\n case \"attachment\":\n case \"boolean\":\n case \"date\":\n case \"double\":\n case \"float\":\n case \"integer\":\n case \"long\":\n case \"mediaReference\":\n case \"string\":\n case \"threeDimensionalAggregation\":\n case \"timestamp\":\n case \"twoDimensionalAggregation\":\n case \"typeReference\":\n case \"union\":\n break;\n default: {\n const _: never = dataType;\n break;\n }\n }\n\n return result;\n}\nfunction requiresConversion(dataType: QueryDataTypeDefinition) {\n switch (dataType.type) {\n case \"boolean\":\n case \"date\":\n case \"double\":\n case \"float\":\n case \"integer\":\n case \"long\":\n case \"string\":\n case \"timestamp\":\n return false;\n\n case \"union\":\n return true;\n\n case \"struct\":\n return Object.values(dataType.struct).some(requiresConversion);\n\n case \"set\":\n return requiresConversion(dataType.set);\n\n case \"attachment\":\n case \"mediaReference\":\n case \"objectSet\":\n case \"twoDimensionalAggregation\":\n case \"threeDimensionalAggregation\":\n case \"object\":\n return true;\n\n default:\n return false;\n }\n}\n\nfunction getObjectSpecifier(\n primaryKey: any,\n objectTypeApiName: string,\n definitions: Map<string, ObjectOrInterfaceDefinition>,\n): string {\n const def = definitions.get(objectTypeApiName);\n if (!def || def.type !== \"object\") {\n throw new Error(\n `Missing definition for ${objectTypeApiName}`,\n );\n }\n return createObjectSpecifierFromPrimaryKey(\n def,\n primaryKey,\n );\n}\n\nexport function createQueryObjectResponse<\n Q extends ObjectTypeDefinition,\n>(\n primaryKey: PrimaryKeyType<Q>,\n objectDef: Q,\n): OsdkBase<Q> {\n return {\n $apiName: objectDef.apiName,\n $title: undefined,\n $objectType: objectDef.apiName,\n $primaryKey: primaryKey,\n $objectSpecifier: createObjectSpecifierFromPrimaryKey(\n objectDef,\n primaryKey,\n ),\n };\n}\n\nexport function createQueryInterfaceResponse<\n Q extends InterfaceDefinition,\n>(\n interfaceSpecifier: {\n objectTypeApiName: string;\n primaryKeyValue: PrimaryKeyType<Q>;\n },\n interfaceDef: Q,\n): OsdkBase<Q> {\n return {\n $apiName: interfaceDef.apiName,\n $title: undefined,\n $objectType: interfaceSpecifier.objectTypeApiName,\n $primaryKey: interfaceSpecifier.primaryKeyValue,\n $objectSpecifier: createObjectSpecifierFromInterfaceSpecifier(\n interfaceDef,\n interfaceSpecifier,\n ),\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiBA,OAAO,KAAKA,OAAO,MAAM,gCAAgC;AACzD,OAAOC,SAAS,MAAM,gBAAgB;AACtC,SAASC,gCAAgC,QAAQ,gCAAgC;AAEjF,SAASC,eAAe,QAAQ,iCAAiC;AACjE,SAASC,gCAAgC,QAAQ,6CAA6C;AAC9F,SAASC,oCAAoC,QAAQ,iDAAiD;AACtG,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,SACEC,2CAA2C,EAC3CC,mCAAmC,QAC9B,iCAAiC;AACxC,SAASC,kBAAkB,QAAQ,+BAA+B;AAGlE,OAAO,eAAeC,UAAUA,CAI9BC,MAAqB,EACrBC,KAAS,EACTC,MAAU,EAGV;EACA;EACA,MAAMC,EAA0B,GAAGH,MAAM,CAACI,gBAAgB,CAACC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,EACZiB,kBACF;EACF,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"applyQuery.js","names":["Queries","invariant","createMediaFromReferenceInternal","createObjectSet","hydrateAttachmentFromRidInternal","addUserAgentAndRequestContextHeaders","augmentRequestContext","createObjectSpecifierFromInterfaceSpecifier","createObjectSpecifierFromPrimaryKey","toDataValueQueries","applyQuery","client","query","params","qd","ontologyProvider","getQueryDefinition","apiName","isFixedVersion","version","undefined","flushEdits","response","execute","finalMethodCall","ontologyRid","parameters","remapQueryParams","transactionId","scenarioRid","branch","objectOutputDefs","getRequiredDefinitions","output","remappedResponse","remapQueryResponse","value","paramTypes","parameterMap","key","Object","entries","responseDataType","responseValue","definitions","nullable","Error","type","i","length","array","set","def","get","object","createQueryObjectResponse","interface","createQueryInterfaceResponse","objectSet","objectSets","objectType","reference","subtype","struct","requiresConversion","map","Array","isArray","process","env","NODE_ENV","entry","valueType","keyType","getObjectSpecifier","result","groups","push","subResult","subKey","dataType","Map","objectDef","getObjectDefinition","interfaceDef","getInterfaceDefinition","types","allDefs","Promise","all","defs","structValues","values","some","primaryKey","objectTypeApiName","$apiName","$title","$objectType","$primaryKey","$objectSpecifier","interfaceSpecifier","primaryKeyValue"],"sources":["applyQuery.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 {\n AllowedBucketKeyTypes,\n AllowedBucketTypes,\n CompileTimeMetadata,\n InterfaceDefinition,\n ObjectOrInterfaceDefinition,\n ObjectTypeDefinition,\n OsdkBase,\n PrimaryKeyType,\n QueryDataTypeDefinition,\n QueryDefinition,\n QueryMetadata,\n QueryParameterDefinition,\n} from \"@osdk/api\";\nimport type { DataValue } from \"@osdk/foundry.ontologies\";\nimport * as Queries from \"@osdk/foundry.ontologies/Query\";\nimport invariant from \"tiny-invariant\";\nimport { createMediaFromReferenceInternal } from \"../createMediaFromReference.js\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport { createObjectSet } from \"../objectSet/createObjectSet.js\";\nimport { hydrateAttachmentFromRidInternal } from \"../public-utils/hydrateAttachmentFromRid.js\";\nimport { addUserAgentAndRequestContextHeaders } from \"../util/addUserAgentAndRequestContextHeaders.js\";\nimport { augmentRequestContext } from \"../util/augmentRequestContext.js\";\nimport {\n createObjectSpecifierFromInterfaceSpecifier,\n createObjectSpecifierFromPrimaryKey,\n} from \"../util/objectSpecifierUtils.js\";\nimport { toDataValueQueries } from \"../util/toDataValueQueries.js\";\nimport type { QueryParameterType, QueryReturnType } from \"./types.js\";\n\nexport async function applyQuery<\n QD extends QueryDefinition<any>,\n P extends QueryParameterType<CompileTimeMetadata<QD>[\"parameters\"]>,\n>(\n client: MinimalClient,\n query: QD,\n params?: P,\n): Promise<\n QueryReturnType<CompileTimeMetadata<QD>[\"output\"]>\n> {\n // We fire and forget so if a function has no parameters we don't unnecessarily load all metadata\n const qd: Promise<QueryMetadata> = client.ontologyProvider.getQueryDefinition(\n query.apiName,\n query.isFixedVersion ? query.version : undefined,\n );\n\n if (client.flushEdits != null) {\n await client.flushEdits();\n }\n\n const response = await Queries.execute(\n addUserAgentAndRequestContextHeaders(\n augmentRequestContext(client, _ => ({ finalMethodCall: \"applyQuery\" })),\n query,\n ),\n await client.ontologyRid,\n query.apiName,\n {\n parameters: params\n ? await remapQueryParams(\n params as { [parameterId: string]: any },\n client,\n (await qd).parameters,\n )\n : {},\n },\n {\n version: query.isFixedVersion ? query.version : undefined,\n transactionId: client.transactionId,\n scenarioRid: client.scenarioRid,\n branch: client.branch,\n },\n );\n\n const objectOutputDefs = await getRequiredDefinitions(\n (await qd).output,\n client,\n );\n const remappedResponse = await remapQueryResponse(\n client,\n (await qd).output,\n response.value,\n objectOutputDefs,\n );\n return remappedResponse as QueryReturnType<CompileTimeMetadata<QD>[\"output\"]>;\n}\n\nexport async function remapQueryParams(\n params: { [parameterId: string]: any },\n client: MinimalClient,\n paramTypes: Record<string, QueryParameterDefinition<any>>,\n): Promise<{ [parameterId: string]: any }> {\n const parameterMap: { [parameterName: string]: unknown } = {};\n for (const [key, value] of Object.entries(params)) {\n parameterMap[key] = await toDataValueQueries(\n value,\n client,\n paramTypes[key],\n );\n }\n return parameterMap;\n}\n\nexport async function remapQueryResponse<\n Q extends ObjectTypeDefinition,\n T extends QueryDataTypeDefinition<Q | never>,\n>(\n client: MinimalClient,\n responseDataType: T,\n responseValue: DataValue,\n definitions: Map<string, ObjectOrInterfaceDefinition>,\n): Promise<QueryReturnType<T>> {\n // handle null responses\n if (responseValue == null) {\n if (responseDataType.nullable) {\n return undefined as unknown as QueryReturnType<typeof responseDataType>;\n } else {\n throw new Error(\"Got null response when nullable was not allowed\");\n }\n }\n\n switch (responseDataType.type) {\n case \"union\": {\n throw new Error(\"Union return types are not yet supported\");\n }\n\n case \"array\": {\n for (let i = 0; i < responseValue.length; i++) {\n responseValue[i] = await remapQueryResponse(\n client,\n responseDataType.array,\n responseValue[i],\n definitions,\n );\n }\n\n return responseValue as QueryReturnType<typeof responseDataType>;\n }\n\n case \"set\": {\n for (let i = 0; i < responseValue.length; i++) {\n responseValue[i] = await remapQueryResponse(\n client,\n responseDataType.set,\n responseValue[i],\n definitions,\n );\n }\n\n return responseValue as QueryReturnType<typeof responseDataType>;\n }\n\n case \"attachment\": {\n return hydrateAttachmentFromRidInternal(\n client,\n responseValue,\n ) as QueryReturnType<\n typeof responseDataType\n >;\n }\n\n case \"mediaReference\": {\n return createMediaFromReferenceInternal(\n client,\n responseValue,\n ) as unknown as QueryReturnType<\n typeof responseDataType\n >;\n }\n\n case \"object\": {\n const def = definitions.get(responseDataType.object);\n if (!def || def.type !== \"object\") {\n throw new Error(\n `Missing definition for ${responseDataType.object}`,\n );\n }\n return createQueryObjectResponse(\n responseValue,\n def,\n ) as QueryReturnType<\n typeof responseDataType\n >;\n }\n\n case \"interface\": {\n const def = definitions.get(responseDataType.interface);\n if (!def || def.type !== \"interface\") {\n throw new Error(\n `Missing definition for ${responseDataType.interface}`,\n );\n }\n\n return createQueryInterfaceResponse(\n responseValue,\n def,\n ) as QueryReturnType<\n typeof responseDataType\n >;\n }\n\n case \"objectSet\": {\n const def = definitions.get(responseDataType.objectSet);\n if (!def) {\n throw new Error(\n `Missing definition for ${responseDataType.objectSet}`,\n );\n }\n if (typeof responseValue === \"string\") {\n return createObjectSet(def, client, {\n type: \"intersect\",\n objectSets: [\n { type: \"base\", objectType: responseDataType.objectSet },\n { type: \"reference\", reference: responseValue },\n ],\n }) as QueryReturnType<typeof responseDataType>;\n }\n\n return createObjectSet(\n def,\n client,\n responseValue,\n ) as QueryReturnType<\n typeof responseDataType\n >;\n }\n\n case \"struct\": {\n // figure out what keys need to be fixed up\n for (const [key, subtype] of Object.entries(responseDataType.struct)) {\n if (requiresConversion(subtype) || responseValue[key] == null) {\n responseValue[key] = await remapQueryResponse(\n client,\n subtype,\n responseValue[key],\n definitions,\n );\n }\n }\n\n return responseValue as QueryReturnType<typeof responseDataType>;\n }\n\n case \"map\": {\n const map = {} as any;\n\n invariant(Array.isArray(responseValue), \"Expected array entry\");\n for (const entry of responseValue) {\n invariant(entry.key != null, \"Expected key\");\n invariant(\n responseDataType.valueType.nullable || entry.value != null,\n \"Expected value\",\n );\n const key = responseDataType.keyType.type === \"object\"\n ? getObjectSpecifier(\n entry.key,\n responseDataType.keyType.object,\n definitions,\n )\n : entry.key;\n const value = await remapQueryResponse(\n client,\n responseDataType.valueType,\n entry.value,\n definitions,\n );\n map[key] = value;\n }\n return map;\n }\n\n case \"twoDimensionalAggregation\": {\n const result: {\n key: AllowedBucketKeyTypes;\n value: AllowedBucketTypes;\n }[] = [];\n for (const { key, value } of responseValue.groups) {\n result.push({ key, value });\n }\n return result as QueryReturnType<typeof responseDataType>;\n }\n\n case \"threeDimensionalAggregation\": {\n const result: {\n key: AllowedBucketKeyTypes;\n groups: { key: AllowedBucketKeyTypes; value: AllowedBucketTypes }[];\n }[] = [];\n for (const { key, groups } of responseValue.groups) {\n const subResult: { key: any; value: any }[] = [];\n for (const { key: subKey, value } of groups) {\n subResult.push({ key: subKey, value });\n }\n result.push({ key, groups: subResult });\n }\n return result as QueryReturnType<typeof responseDataType>;\n }\n }\n\n return responseValue as QueryReturnType<typeof responseDataType>;\n}\n\nexport async function getRequiredDefinitions(\n dataType: QueryDataTypeDefinition,\n client: MinimalClient,\n): Promise<Map<string, ObjectOrInterfaceDefinition>> {\n const result = new Map<string, ObjectOrInterfaceDefinition>();\n switch (dataType.type) {\n case \"objectSet\": {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n dataType.objectSet,\n );\n result.set(dataType.objectSet, objectDef);\n break;\n }\n case \"interfaceObjectSet\": {\n const interfaceDef = await client.ontologyProvider.getInterfaceDefinition(\n dataType.objectSet,\n );\n result.set(dataType.objectSet, interfaceDef);\n break;\n }\n case \"object\": {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n dataType.object,\n );\n result.set(dataType.object, objectDef);\n break;\n }\n\n case \"interface\": {\n const interfaceDef = await client.ontologyProvider.getInterfaceDefinition(\n dataType.interface,\n );\n result.set(dataType.interface, interfaceDef);\n break;\n }\n\n case \"set\": {\n return getRequiredDefinitions(dataType.set, client);\n }\n case \"array\": {\n return getRequiredDefinitions(dataType.array, client);\n }\n\n case \"map\": {\n const types = [dataType.keyType, dataType.valueType];\n\n const allDefs = await Promise.all(\n types.map(value => getRequiredDefinitions(value, client)),\n );\n\n for (const defs of allDefs) {\n for (const [type, objectDef] of defs) {\n result.set(type, objectDef);\n }\n }\n break;\n }\n\n case \"struct\": {\n const structValues = Object.values(dataType.struct);\n\n const allDefs = await Promise.all(\n structValues.map(value => getRequiredDefinitions(value, client)),\n );\n\n for (const defs of allDefs) {\n for (const [type, objectDef] of defs) {\n result.set(type, objectDef);\n }\n }\n break;\n }\n case \"attachment\":\n case \"boolean\":\n case \"date\":\n case \"double\":\n case \"float\":\n case \"integer\":\n case \"long\":\n case \"mediaReference\":\n case \"string\":\n case \"threeDimensionalAggregation\":\n case \"timestamp\":\n case \"twoDimensionalAggregation\":\n case \"typeReference\":\n case \"union\":\n break;\n default: {\n const _: never = dataType;\n break;\n }\n }\n\n return result;\n}\nfunction requiresConversion(dataType: QueryDataTypeDefinition) {\n switch (dataType.type) {\n case \"boolean\":\n case \"date\":\n case \"double\":\n case \"float\":\n case \"integer\":\n case \"long\":\n case \"string\":\n case \"timestamp\":\n return false;\n\n case \"union\":\n return true;\n\n case \"struct\":\n return Object.values(dataType.struct).some(requiresConversion);\n\n case \"set\":\n return requiresConversion(dataType.set);\n\n case \"attachment\":\n case \"mediaReference\":\n case \"objectSet\":\n case \"twoDimensionalAggregation\":\n case \"threeDimensionalAggregation\":\n case \"object\":\n return true;\n\n default:\n return false;\n }\n}\n\nfunction getObjectSpecifier(\n primaryKey: any,\n objectTypeApiName: string,\n definitions: Map<string, ObjectOrInterfaceDefinition>,\n): string {\n const def = definitions.get(objectTypeApiName);\n if (!def || def.type !== \"object\") {\n throw new Error(\n `Missing definition for ${objectTypeApiName}`,\n );\n }\n return createObjectSpecifierFromPrimaryKey(\n def,\n primaryKey,\n );\n}\n\nexport function createQueryObjectResponse<\n Q extends ObjectTypeDefinition,\n>(\n primaryKey: PrimaryKeyType<Q>,\n objectDef: Q,\n): OsdkBase<Q> {\n return {\n $apiName: objectDef.apiName,\n $title: undefined,\n $objectType: objectDef.apiName,\n $primaryKey: primaryKey,\n $objectSpecifier: createObjectSpecifierFromPrimaryKey(\n objectDef,\n primaryKey,\n ),\n };\n}\n\nexport function createQueryInterfaceResponse<\n Q extends InterfaceDefinition,\n>(\n interfaceSpecifier: {\n objectTypeApiName: string;\n primaryKeyValue: PrimaryKeyType<Q>;\n },\n interfaceDef: Q,\n): OsdkBase<Q> {\n return {\n $apiName: interfaceDef.apiName,\n $title: undefined,\n $objectType: interfaceSpecifier.objectTypeApiName,\n $primaryKey: interfaceSpecifier.primaryKeyValue,\n $objectSpecifier: createObjectSpecifierFromInterfaceSpecifier(\n interfaceDef,\n interfaceSpecifier,\n ),\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiBA,OAAO,KAAKA,OAAO,MAAM,gCAAgC;AACzD,OAAOC,SAAS,MAAM,gBAAgB;AACtC,SAASC,gCAAgC,QAAQ,gCAAgC;AAEjF,SAASC,eAAe,QAAQ,iCAAiC;AACjE,SAASC,gCAAgC,QAAQ,6CAA6C;AAC9F,SAASC,oCAAoC,QAAQ,iDAAiD;AACtG,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,SACEC,2CAA2C,EAC3CC,mCAAmC,QAC9B,iCAAiC;AACxC,SAASC,kBAAkB,QAAQ,+BAA+B;AAGlE,OAAO,eAAeC,UAAUA,CAI9BC,MAAqB,EACrBC,KAAS,EACTC,MAAU,EAGV;EACA;EACA,MAAMC,EAA0B,GAAGH,MAAM,CAACI,gBAAgB,CAACC,kBAAkB,CAC3EJ,KAAK,CAACK,OAAO,EACbL,KAAK,CAACM,cAAc,GAAGN,KAAK,CAACO,OAAO,GAAGC,SACzC,CAAC;EAED,IAAIT,MAAM,CAACU,UAAU,IAAI,IAAI,EAAE;IAC7B,MAAMV,MAAM,CAACU,UAAU,CAAC,CAAC;EAC3B;EAEA,MAAMC,QAAQ,GAAG,MAAMtB,OAAO,CAACuB,OAAO,CACpClB,oCAAoC,CAClCC,qBAAqB,CAACK,MAAM,EAAE,OAAM;IAAEa,eAAe,EAAE;EAAa,CAAC,CAAC,CAAC,EACvEZ,KACF,CAAC,EACD,MAAMD,MAAM,CAACc,WAAW,EACxBb,KAAK,CA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BnD,WAAqD,EAC7C;EACR,MAAMQ,GAAG,GAAGR,WAAW,CAACS,GAAG,CAAC0C,iBAAiB,CAAC;EAC9C,IAAI,CAAC3C,GAAG,IAAIA,GAAG,CAACL,IAAI,KAAK,QAAQ,EAAE;IACjC,MAAM,IAAID,KAAK,CACb,0BAA0BiD,iBAAiB,EAC7C,CAAC;EACH;EACA,OAAOvF,mCAAmC,CACxC4C,GAAG,EACH0C,UACF,CAAC;AACH;AAEA,OAAO,SAASvC,yBAAyBA,CAGvCuC,UAA6B,EAC7BZ,SAAY,EACC;EACb,OAAO;IACLc,QAAQ,EAAEd,SAAS,CAACjE,OAAO;IAC3BgF,MAAM,EAAE7E,SAAS;IACjB8E,WAAW,EAAEhB,SAAS,CAACjE,OAAO;IAC9BkF,WAAW,EAAEL,UAAU;IACvBM,gBAAgB,EAAE5F,mCAAmC,CACnD0E,SAAS,EACTY,UACF;EACF,CAAC;AACH;AAEA,OAAO,SAASrC,4BAA4BA,CAG1C4C,kBAGC,EACDjB,YAAe,EACF;EACb,OAAO;IACLY,QAAQ,EAAEZ,YAAY,CAACnE,OAAO;IAC9BgF,MAAM,EAAE7E,SAAS;IACjB8E,WAAW,EAAEG,kBAAkB,CAACN,iBAAiB;IACjDI,WAAW,EAAEE,kBAAkB,CAACC,eAAe;IAC/CF,gBAAgB,EAAE7F,2CAA2C,CAC3D6E,YAAY,EACZiB,kBACF;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { OntologyScenarios } from "@osdk/foundry.ontologies";
|
|
18
|
+
import { additionalContext } from "../Client.js";
|
|
19
|
+
import { createClientWithScenario } from "../createClient.js";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The set of many-to-many link types modified within a scenario for one source object type. Returned as part of
|
|
23
|
+
* {@link ScenarioEditedEntityTypes.linkTypes}.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The object types and link types that have been modified within a scenario. Only many-to-many link type edits are surfaced via `linkTypes`;
|
|
28
|
+
* one-to-many edits surface as object edits on the object type that owns the foreign key property.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A page of edited object identifiers within a scenario
|
|
33
|
+
* for a given object type. Returned by {@link ScenarioClient.getEditedEntities}. To load full property values,
|
|
34
|
+
* pass the primary keys back through the scenario client, e.g.
|
|
35
|
+
* `scenario(MyObject).where({ $primaryKey: { $in: keys } }).fetchPage()`.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A page of directed link instances edited within a scenario for a given source object type and link api name.
|
|
40
|
+
* Returned by {@link ScenarioClient.getEditedLinks}. Source and target carry only `$primaryKey` + `$apiName`.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A {@link Client} attached to an ontology scenario. All read and write operations performed via this client are
|
|
45
|
+
* scoped to that scenario. `ScenarioClient` is a superset of {@link Client}: it is usable anywhere a `Client` is
|
|
46
|
+
* accepted (e.g. as the `scenarioReference` parameter on a scenario-merge action).
|
|
47
|
+
*
|
|
48
|
+
* @beta This is an experimental, unstable feature subject to change.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Runtime predicate for {@link ScenarioClient}. Returns `true` when `value` exposes a `getScenarioReference()`
|
|
53
|
+
* method — i.e. when it was built by {@link withScenario} or {@link createScenario}. Used by action parameter
|
|
54
|
+
* serialization to accept a `ScenarioClient` directly for `scenarioReference`-typed parameters.
|
|
55
|
+
*
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
export function isScenarioClient(value) {
|
|
59
|
+
return value != null && (typeof value === "object" || typeof value === "function") && typeof value.getScenarioReference === "function";
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Shared internal builder used by both {@link withScenario} and {@link createScenario}. Validates the parent client
|
|
64
|
+
* is not already inside a scenario or transaction, then constructs a fresh {@link Client} via
|
|
65
|
+
* `createClientWithScenario` and decorates it with {@link ScenarioClient}-only methods.
|
|
66
|
+
*
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
export function buildScenarioClient(parent, scenarioRid) {
|
|
70
|
+
const ctx = parent[additionalContext];
|
|
71
|
+
if (ctx.transactionId != null) {
|
|
72
|
+
throw new Error("withScenario / createScenario: the supplied client already has an active transaction. Scenarios cannot be nested on transactions.");
|
|
73
|
+
}
|
|
74
|
+
if (ctx.scenarioRid != null) {
|
|
75
|
+
throw new Error("withScenario / createScenario: the supplied client already has an active scenario. Scenarios cannot be nested.");
|
|
76
|
+
}
|
|
77
|
+
const inner = createClientWithScenario(scenarioRid, ctx.baseUrl, ctx.ontologyRid, ctx.tokenProvider, {
|
|
78
|
+
logger: ctx.logger,
|
|
79
|
+
UNSTABLE_DO_NOT_USE_BRANCH: ctx.branch
|
|
80
|
+
}, ctx.fetch);
|
|
81
|
+
const innerCtx = inner[additionalContext];
|
|
82
|
+
async function getEditedEntities(objectType, options) {
|
|
83
|
+
const ontologyRid = await innerCtx.ontologyRid;
|
|
84
|
+
const response = await OntologyScenarios.listScenarioEditedObjects(innerCtx, ontologyRid, scenarioRid, objectType.apiName, {
|
|
85
|
+
pageSize: options?.pageSize,
|
|
86
|
+
pageToken: options?.pageToken
|
|
87
|
+
});
|
|
88
|
+
const data = response.data.map(entry => {
|
|
89
|
+
const wire = entry;
|
|
90
|
+
return {
|
|
91
|
+
$apiName: wire.__apiName,
|
|
92
|
+
$primaryKey: wire.__primaryKey
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
return {
|
|
96
|
+
data,
|
|
97
|
+
nextPageToken: response.nextPageToken
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
async function getEditedLinks(sourceObjectType, linkType, options) {
|
|
101
|
+
const ontologyRid = await innerCtx.ontologyRid;
|
|
102
|
+
const response = await OntologyScenarios.listScenarioEditedLinks(innerCtx, ontologyRid, scenarioRid, sourceObjectType.apiName, linkType, {
|
|
103
|
+
pageSize: options?.pageSize,
|
|
104
|
+
pageToken: options?.pageToken
|
|
105
|
+
});
|
|
106
|
+
const data = [];
|
|
107
|
+
for (const entry of response.data) {
|
|
108
|
+
const sourceWire = entry.sourceObject;
|
|
109
|
+
if (sourceWire?.__apiName == null || sourceWire.__primaryKey == null) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const source = {
|
|
113
|
+
$apiName: sourceWire.__apiName,
|
|
114
|
+
$primaryKey: sourceWire.__primaryKey
|
|
115
|
+
};
|
|
116
|
+
for (const linked of entry.linkedObjects) {
|
|
117
|
+
const targetWire = linked.targetObject;
|
|
118
|
+
if (targetWire?.__apiName == null || targetWire.__primaryKey == null) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
const target = {
|
|
122
|
+
$apiName: targetWire.__apiName,
|
|
123
|
+
$primaryKey: targetWire.__primaryKey
|
|
124
|
+
};
|
|
125
|
+
data.push({
|
|
126
|
+
source,
|
|
127
|
+
target,
|
|
128
|
+
linkType: linked.linkType ?? linkType
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
data,
|
|
134
|
+
nextPageToken: response.nextPageToken
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return Object.defineProperties(inner, {
|
|
138
|
+
getScenarioReference: {
|
|
139
|
+
value: () => ({
|
|
140
|
+
scenarioRid
|
|
141
|
+
})
|
|
142
|
+
},
|
|
143
|
+
getEditedEntityTypes: {
|
|
144
|
+
value: async function () {
|
|
145
|
+
const ontologyRid = await innerCtx.ontologyRid;
|
|
146
|
+
const response = await OntologyScenarios.listScenarioEditedEntityTypes(innerCtx, ontologyRid, scenarioRid);
|
|
147
|
+
return {
|
|
148
|
+
objectTypes: response.objectTypes,
|
|
149
|
+
linkTypes: response.linkTypes
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
getEditedEntities: {
|
|
154
|
+
value: getEditedEntities
|
|
155
|
+
},
|
|
156
|
+
editedEntitiesAsyncIter: {
|
|
157
|
+
value: async function* (objectType, options) {
|
|
158
|
+
const seen = new Set();
|
|
159
|
+
let pageToken;
|
|
160
|
+
do {
|
|
161
|
+
const page = await getEditedEntities(objectType, {
|
|
162
|
+
pageSize: options?.pageSize,
|
|
163
|
+
pageToken
|
|
164
|
+
});
|
|
165
|
+
for (const obj of page.data) {
|
|
166
|
+
const key = obj.$primaryKey;
|
|
167
|
+
if (seen.has(key)) continue;
|
|
168
|
+
seen.add(key);
|
|
169
|
+
yield obj;
|
|
170
|
+
}
|
|
171
|
+
pageToken = page.nextPageToken;
|
|
172
|
+
} while (pageToken != null);
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
getEditedLinkTypes: {
|
|
176
|
+
value: async function (sourceObjectType) {
|
|
177
|
+
const ontologyRid = await innerCtx.ontologyRid;
|
|
178
|
+
const response = await OntologyScenarios.listScenarioEditedLinkTypes(innerCtx, ontologyRid, scenarioRid, sourceObjectType.apiName);
|
|
179
|
+
return response.data;
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
getEditedLinks: {
|
|
183
|
+
value: getEditedLinks
|
|
184
|
+
},
|
|
185
|
+
editedLinksAsyncIter: {
|
|
186
|
+
value: async function* (sourceObjectType, linkType, options) {
|
|
187
|
+
let pageToken;
|
|
188
|
+
do {
|
|
189
|
+
const page = await getEditedLinks(sourceObjectType, linkType, {
|
|
190
|
+
pageSize: options?.pageSize,
|
|
191
|
+
pageToken
|
|
192
|
+
});
|
|
193
|
+
for (const link of page.data) {
|
|
194
|
+
yield link;
|
|
195
|
+
}
|
|
196
|
+
pageToken = page.nextPageToken;
|
|
197
|
+
} while (pageToken != null);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=ScenarioClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScenarioClient.js","names":["OntologyScenarios","additionalContext","createClientWithScenario","isScenarioClient","value","getScenarioReference","buildScenarioClient","parent","scenarioRid","ctx","transactionId","Error","inner","baseUrl","ontologyRid","tokenProvider","logger","UNSTABLE_DO_NOT_USE_BRANCH","branch","fetch","innerCtx","getEditedEntities","objectType","options","response","listScenarioEditedObjects","apiName","pageSize","pageToken","data","map","entry","wire","$apiName","__apiName","$primaryKey","__primaryKey","nextPageToken","getEditedLinks","sourceObjectType","linkType","listScenarioEditedLinks","sourceWire","sourceObject","source","linked","linkedObjects","targetWire","targetObject","target","push","Object","defineProperties","getEditedEntityTypes","listScenarioEditedEntityTypes","objectTypes","linkTypes","editedEntitiesAsyncIter","seen","Set","page","obj","key","has","add","getEditedLinkTypes","listScenarioEditedLinkTypes","editedLinksAsyncIter","link"],"sources":["ScenarioClient.ts"],"sourcesContent":["/*\n * Copyright 2026 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 LinkTypeApiNamesFor,\n MinimalDirectedObjectLinkInstance,\n ObjectIdentifiers,\n ObjectOrInterfaceDefinition,\n ObjectTypeDefinition,\n PrimaryKeyType,\n} from \"@osdk/api\";\nimport { OntologyScenarios } from \"@osdk/foundry.ontologies\";\nimport { additionalContext, type Client } from \"../Client.js\";\nimport { createClientWithScenario } from \"../createClient.js\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\n\n/**\n * The set of many-to-many link types modified within a scenario for one source object type. Returned as part of\n * {@link ScenarioEditedEntityTypes.linkTypes}.\n */\nexport interface EditedLinksForObjectType {\n objectTypeApiName: string;\n linkTypes: string[];\n}\n\n/**\n * The object types and link types that have been modified within a scenario. Only many-to-many link type edits are surfaced via `linkTypes`;\n * one-to-many edits surface as object edits on the object type that owns the foreign key property.\n */\nexport interface ScenarioEditedEntityTypes {\n objectTypes: string[];\n linkTypes: EditedLinksForObjectType[];\n}\n\n/**\n * A page of edited object identifiers within a scenario\n * for a given object type. Returned by {@link ScenarioClient.getEditedEntities}. To load full property values,\n * pass the primary keys back through the scenario client, e.g.\n * `scenario(MyObject).where({ $primaryKey: { $in: keys } }).fetchPage()`.\n */\nexport interface EditedEntitiesPage<Q extends ObjectTypeDefinition> {\n data: ObjectIdentifiers<Q>[];\n nextPageToken?: string;\n}\n\n/**\n * A page of directed link instances edited within a scenario for a given source object type and link api name.\n * Returned by {@link ScenarioClient.getEditedLinks}. Source and target carry only `$primaryKey` + `$apiName`.\n */\nexport interface EditedLinksPage<\n Q extends ObjectOrInterfaceDefinition,\n LINK_TYPE_API_NAME extends LinkTypeApiNamesFor<Q>,\n> {\n data: MinimalDirectedObjectLinkInstance<Q, LINK_TYPE_API_NAME>[];\n nextPageToken?: string;\n}\n\n/**\n * A {@link Client} attached to an ontology scenario. All read and write operations performed via this client are\n * scoped to that scenario. `ScenarioClient` is a superset of {@link Client}: it is usable anywhere a `Client` is\n * accepted (e.g. as the `scenarioReference` parameter on a scenario-merge action).\n *\n * @beta This is an experimental, unstable feature subject to change.\n */\nexport interface ScenarioClient extends Client {\n /**\n * Returns the scenario reference for this client. Pass directly to an action whose parameter is typed as\n * `scenarioReference`, or use to inspect the underlying scenario RID.\n */\n getScenarioReference(): { scenarioRid: string };\n\n /**\n * List the object types and many-to-many link types that have been modified within this scenario. Useful as a\n * pre-step before paginating individual edited objects per type.\n */\n getEditedEntityTypes(): Promise<ScenarioEditedEntityTypes>;\n\n /**\n * Get a page of object identifiers that have been\n * edited within this scenario for the given object type. Use the scenario client to fetch full property values\n * if needed.\n *\n * @example\n * ```ts\n * let pageToken: string | undefined;\n * const keys: string[] = [];\n * do {\n * const page = await scenario.getEditedEntities(Doctor, { pageSize: 500, pageToken });\n * keys.push(...page.data.map(o => o.$primaryKey));\n * pageToken = page.nextPageToken;\n * } while (pageToken);\n * ```\n */\n getEditedEntities<Q extends ObjectTypeDefinition>(\n objectType: Q,\n options?: { pageSize?: number; pageToken?: string },\n ): Promise<EditedEntitiesPage<Q>>;\n\n /**\n * Stream object identifiers for the objects edited within this scenario for the\n * given object type. Pages are fetched lazily and deduplicated by `$primaryKey` across pages (Funnel may return\n * duplicates).\n *\n * @example\n * ```ts\n * for await (const obj of scenario.editedEntitiesAsyncIter(Doctor, { pageSize: 500 })) {\n * // obj.$primaryKey is the unique key for this edited object\n * }\n * ```\n */\n editedEntitiesAsyncIter<Q extends ObjectTypeDefinition>(\n objectType: Q,\n options?: { pageSize?: number },\n ): AsyncIterableIterator<ObjectIdentifiers<Q>>;\n\n /**\n * List the outgoing many-to-many link API names that have been modified within this scenario for the given\n * source object type. One-to-many link edits surface as object edits on the FK-owning side and are not returned\n * here.\n */\n getEditedLinkTypes<Q extends ObjectOrInterfaceDefinition>(\n sourceObjectType: Q,\n ): Promise<LinkTypeApiNamesFor<Q>[]>;\n\n /**\n * Get a page of directed link instances edited within this scenario for a given source object type and link\n * api name. The page form returns a flattened array of `{ source, target, linkType }` triples.\n */\n getEditedLinks<\n Q extends ObjectOrInterfaceDefinition,\n LINK_TYPE_API_NAME extends LinkTypeApiNamesFor<Q>,\n >(\n sourceObjectType: Q,\n linkType: LINK_TYPE_API_NAME,\n options?: { pageSize?: number; pageToken?: string },\n ): Promise<EditedLinksPage<Q, LINK_TYPE_API_NAME>>;\n\n /**\n * Stream directed link instances edited within this scenario for a given source object type and link api name.\n * Pages are fetched lazily.\n *\n * @example\n * ```ts\n * for await (\n * const { source, target, linkType } of scenario.editedLinksAsyncIter(Doctor, \"treats\")\n * ) {\n * graph.addEdge(source, target, linkType);\n * }\n * ```\n */\n editedLinksAsyncIter<\n Q extends ObjectOrInterfaceDefinition,\n LINK_TYPE_API_NAME extends LinkTypeApiNamesFor<Q>,\n >(\n sourceObjectType: Q,\n linkType: LINK_TYPE_API_NAME,\n options?: { pageSize?: number },\n ): AsyncIterableIterator<\n MinimalDirectedObjectLinkInstance<Q, LINK_TYPE_API_NAME>\n >;\n}\n\n/**\n * Runtime predicate for {@link ScenarioClient}. Returns `true` when `value` exposes a `getScenarioReference()`\n * method — i.e. when it was built by {@link withScenario} or {@link createScenario}. Used by action parameter\n * serialization to accept a `ScenarioClient` directly for `scenarioReference`-typed parameters.\n *\n * @internal\n */\nexport function isScenarioClient(value: unknown): value is ScenarioClient {\n return (\n value != null\n && (typeof value === \"object\" || typeof value === \"function\")\n && typeof (value as { getScenarioReference?: unknown })\n .getScenarioReference === \"function\"\n );\n}\n\n/**\n * Shared internal builder used by both {@link withScenario} and {@link createScenario}. Validates the parent client\n * is not already inside a scenario or transaction, then constructs a fresh {@link Client} via\n * `createClientWithScenario` and decorates it with {@link ScenarioClient}-only methods.\n *\n * @internal\n */\nexport function buildScenarioClient(\n parent: Client,\n scenarioRid: string,\n): ScenarioClient {\n const ctx: MinimalClient = parent[additionalContext];\n\n if (ctx.transactionId != null) {\n throw new Error(\n \"withScenario / createScenario: the supplied client already has an active transaction. Scenarios cannot be nested on transactions.\",\n );\n }\n if (ctx.scenarioRid != null) {\n throw new Error(\n \"withScenario / createScenario: the supplied client already has an active scenario. Scenarios cannot be nested.\",\n );\n }\n\n const inner: Client = createClientWithScenario(\n scenarioRid,\n ctx.baseUrl,\n ctx.ontologyRid,\n ctx.tokenProvider,\n {\n logger: ctx.logger,\n UNSTABLE_DO_NOT_USE_BRANCH: ctx.branch,\n },\n ctx.fetch,\n );\n\n const innerCtx: MinimalClient = inner[additionalContext];\n\n async function getEditedEntityTypes(): Promise<ScenarioEditedEntityTypes> {\n const ontologyRid = await innerCtx.ontologyRid;\n const response = await OntologyScenarios.listScenarioEditedEntityTypes(\n innerCtx,\n ontologyRid,\n scenarioRid,\n );\n return {\n objectTypes: response.objectTypes,\n linkTypes: response.linkTypes,\n };\n }\n\n async function getEditedEntities<Q extends ObjectTypeDefinition>(\n objectType: Q,\n options?: { pageSize?: number; pageToken?: string },\n ): Promise<EditedEntitiesPage<Q>> {\n const ontologyRid = await innerCtx.ontologyRid;\n const response = await OntologyScenarios.listScenarioEditedObjects(\n innerCtx,\n ontologyRid,\n scenarioRid,\n objectType.apiName,\n { pageSize: options?.pageSize, pageToken: options?.pageToken },\n );\n const data: ObjectIdentifiers<Q>[] = response.data.map((entry) => {\n const wire = entry as { __apiName?: unknown; __primaryKey?: unknown };\n return {\n $apiName: wire.__apiName as Q[\"apiName\"],\n $primaryKey: wire.__primaryKey as PrimaryKeyType<Q>,\n };\n });\n return {\n data,\n nextPageToken: response.nextPageToken,\n };\n }\n\n async function* editedEntitiesAsyncIter<Q extends ObjectTypeDefinition>(\n objectType: Q,\n options?: { pageSize?: number },\n ): AsyncIterableIterator<ObjectIdentifiers<Q>> {\n const seen = new Set<unknown>();\n let pageToken: string | undefined;\n do {\n const page = await getEditedEntities(objectType, {\n pageSize: options?.pageSize,\n pageToken,\n });\n for (const obj of page.data) {\n const key = obj.$primaryKey;\n if (seen.has(key)) continue;\n seen.add(key);\n yield obj;\n }\n pageToken = page.nextPageToken;\n } while (pageToken != null);\n }\n\n async function getEditedLinkTypes<Q extends ObjectOrInterfaceDefinition>(\n sourceObjectType: Q,\n ): Promise<LinkTypeApiNamesFor<Q>[]> {\n const ontologyRid = await innerCtx.ontologyRid;\n const response = await OntologyScenarios.listScenarioEditedLinkTypes(\n innerCtx,\n ontologyRid,\n scenarioRid,\n sourceObjectType.apiName,\n );\n return response.data as LinkTypeApiNamesFor<Q>[];\n }\n\n async function getEditedLinks<\n Q extends ObjectOrInterfaceDefinition,\n LINK_TYPE_API_NAME extends LinkTypeApiNamesFor<Q>,\n >(\n sourceObjectType: Q,\n linkType: LINK_TYPE_API_NAME,\n options?: { pageSize?: number; pageToken?: string },\n ): Promise<EditedLinksPage<Q, LINK_TYPE_API_NAME>> {\n const ontologyRid = await innerCtx.ontologyRid;\n const response = await OntologyScenarios.listScenarioEditedLinks(\n innerCtx,\n ontologyRid,\n scenarioRid,\n sourceObjectType.apiName,\n linkType as string,\n { pageSize: options?.pageSize, pageToken: options?.pageToken },\n );\n\n const data: MinimalDirectedObjectLinkInstance<Q, LINK_TYPE_API_NAME>[] = [];\n for (const entry of response.data) {\n const sourceWire = entry.sourceObject as\n | { __apiName?: unknown; __primaryKey?: unknown }\n | undefined;\n if (sourceWire?.__apiName == null || sourceWire.__primaryKey == null) {\n continue;\n }\n const source = {\n $apiName: sourceWire.__apiName,\n $primaryKey: sourceWire.__primaryKey,\n } as MinimalDirectedObjectLinkInstance<Q, LINK_TYPE_API_NAME>[\"source\"];\n\n for (const linked of entry.linkedObjects) {\n const targetWire = linked.targetObject as\n | { __apiName?: unknown; __primaryKey?: unknown }\n | undefined;\n if (targetWire?.__apiName == null || targetWire.__primaryKey == null) {\n continue;\n }\n const target = {\n $apiName: targetWire.__apiName,\n $primaryKey: targetWire.__primaryKey,\n } as MinimalDirectedObjectLinkInstance<Q, LINK_TYPE_API_NAME>[\"target\"];\n\n data.push({\n source,\n target,\n linkType: ((linked.linkType as string | undefined)\n ?? linkType) as LINK_TYPE_API_NAME,\n });\n }\n }\n\n return { data, nextPageToken: response.nextPageToken };\n }\n\n async function* editedLinksAsyncIter<\n Q extends ObjectOrInterfaceDefinition,\n LINK_TYPE_API_NAME extends LinkTypeApiNamesFor<Q>,\n >(\n sourceObjectType: Q,\n linkType: LINK_TYPE_API_NAME,\n options?: { pageSize?: number },\n ): AsyncIterableIterator<\n MinimalDirectedObjectLinkInstance<Q, LINK_TYPE_API_NAME>\n > {\n let pageToken: string | undefined;\n do {\n const page = await getEditedLinks(sourceObjectType, linkType, {\n pageSize: options?.pageSize,\n pageToken,\n });\n for (const link of page.data) {\n yield link;\n }\n pageToken = page.nextPageToken;\n } while (pageToken != null);\n }\n\n return Object.defineProperties(inner, {\n getScenarioReference: {\n value: () => ({ scenarioRid }),\n },\n getEditedEntityTypes: {\n value: getEditedEntityTypes,\n },\n getEditedEntities: {\n value: getEditedEntities,\n },\n editedEntitiesAsyncIter: {\n value: editedEntitiesAsyncIter,\n },\n getEditedLinkTypes: {\n value: getEditedLinkTypes,\n },\n getEditedLinks: {\n value: getEditedLinks,\n },\n editedLinksAsyncIter: {\n value: editedLinksAsyncIter,\n },\n }) as ScenarioClient;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,iBAAiB,QAAQ,0BAA0B;AAC5D,SAASC,iBAAiB,QAAqB,cAAc;AAC7D,SAASC,wBAAwB,QAAQ,oBAAoB;;AAG7D;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAACC,KAAc,EAA2B;EACxE,OACEA,KAAK,IAAI,IAAI,KACT,OAAOA,KAAK,KAAK,QA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ACvB,aAAa;QAChC,CAAC,QAAQT,SAAS,IAAI,IAAI;MAC5B;IAyGE,CAAC;IACDqC,kBAAkB,EAAE;MAClB7D,KAAK,EAzGT,eAAAA,CACEmC,gBAAmB,EACgB;QACnC,MAAMzB,WAAW,GAAG,MAAMM,QAAQ,CAACN,WAAW;QAC9C,MAAMU,QAAQ,GAAG,MAAMxB,iBAAiB,CAACkE,2BAA2B,CAClE9C,QAAQ,EACRN,WAAW,EACXN,WAAW,EACX+B,gBAAgB,CAACb,OACnB,CAAC;QACD,OAAOF,QAAQ,CAACK,IAAI;MACtB;IA+FE,CAAC;IACDS,cAAc,EAAE;MACdlC,KAAK,EAAEkC;IACT,CAAC;IACD6B,oBAAoB,EAAE;MACpB/D,KAAK,EA3CT,gBAAAA,CAIEmC,gBAAmB,EACnBC,QAA4B,EAC5BjB,OAA+B,EAG/B;QACA,IAAIK,SAA6B;QACjC,GAAG;UACD,MAAMgC,IAAI,GAAG,MAAMtB,cAAc,CAACC,gBAAgB,EAAEC,QAAQ,EAAE;YAC5Db,QAAQ,EAAEJ,OAAO,EAAEI,QAAQ;YAC3BC;UACF,CAAC,CAAC;UACF,KAAK,MAAMwC,IAAI,IAAIR,IAAI,CAAC/B,IAAI,EAAE;YAC5B,MAAMuC,IAAI;UACZ;UACAxC,SAAS,GAAGgC,IAAI,CAACvB,aAAa;QAChC,CAAC,QAAQT,SAAS,IAAI,IAAI;MAC5B;IAuBE;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { OntologyScenarios } from "@osdk/foundry.ontologies";
|
|
18
|
+
import { additionalContext } from "../Client.js";
|
|
19
|
+
import { buildScenarioClient } from "./ScenarioClient.js";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Mint a fresh ontology scenario and return a client scoped to it.
|
|
23
|
+
*
|
|
24
|
+
* @param client - The base {@link Client} to derive context (`baseUrl`, `ontologyRid`, `tokenProvider`, `branch`, …)
|
|
25
|
+
* from. Throws at runtime if the client is already scoped to a scenario or transaction. When the base client has a
|
|
26
|
+
* branch set, the newly minted scenario uses that branch as its base.
|
|
27
|
+
* @returns a {@link ScenarioClient} bound to the freshly minted scenario RID.
|
|
28
|
+
*
|
|
29
|
+
* @beta This is an experimental, unstable feature subject to change.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { createScenario } from "@osdk/client/unstable-do-not-use";
|
|
34
|
+
*
|
|
35
|
+
* const scenario = await createScenario(client);
|
|
36
|
+
* const { scenarioRid } = scenario.getScenarioReference();
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export async function createScenario(client) {
|
|
40
|
+
const ctx = client[additionalContext];
|
|
41
|
+
if (ctx.transactionId != null) {
|
|
42
|
+
throw new Error("createScenario: the supplied client already has an active transaction. Scenarios cannot be nested on transactions.");
|
|
43
|
+
}
|
|
44
|
+
if (ctx.scenarioRid != null) {
|
|
45
|
+
throw new Error("createScenario: the supplied client already has an active scenario. Scenarios cannot be nested.");
|
|
46
|
+
}
|
|
47
|
+
const response = await OntologyScenarios.createScenario(ctx, await ctx.ontologyRid, ctx.branch != null ? {
|
|
48
|
+
base: {
|
|
49
|
+
type: "branch",
|
|
50
|
+
branch: ctx.branch
|
|
51
|
+
}
|
|
52
|
+
} : {});
|
|
53
|
+
return buildScenarioClient(client, response.scenarioRid);
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=createScenario.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createScenario.js","names":["OntologyScenarios","additionalContext","buildScenarioClient","createScenario","client","ctx","transactionId","Error","scenarioRid","response","ontologyRid","branch","base","type"],"sources":["createScenario.ts"],"sourcesContent":["/*\n * Copyright 2026 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 { OntologyScenarios } from \"@osdk/foundry.ontologies\";\nimport { additionalContext, type Client } from \"../Client.js\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport { buildScenarioClient, type ScenarioClient } from \"./ScenarioClient.js\";\n\n/**\n * Mint a fresh ontology scenario and return a client scoped to it.\n *\n * @param client - The base {@link Client} to derive context (`baseUrl`, `ontologyRid`, `tokenProvider`, `branch`, …)\n * from. Throws at runtime if the client is already scoped to a scenario or transaction. When the base client has a\n * branch set, the newly minted scenario uses that branch as its base.\n * @returns a {@link ScenarioClient} bound to the freshly minted scenario RID.\n *\n * @beta This is an experimental, unstable feature subject to change.\n *\n * @example\n * ```ts\n * import { createScenario } from \"@osdk/client/unstable-do-not-use\";\n *\n * const scenario = await createScenario(client);\n * const { scenarioRid } = scenario.getScenarioReference();\n * ```\n */\nexport async function createScenario(\n client: Client,\n): Promise<ScenarioClient> {\n const ctx: MinimalClient = client[additionalContext];\n\n if (ctx.transactionId != null) {\n throw new Error(\n \"createScenario: the supplied client already has an active transaction. Scenarios cannot be nested on transactions.\",\n );\n }\n if (ctx.scenarioRid != null) {\n throw new Error(\n \"createScenario: the supplied client already has an active scenario. Scenarios cannot be nested.\",\n );\n }\n\n const response = await OntologyScenarios.createScenario(\n ctx,\n await ctx.ontologyRid,\n ctx.branch != null\n ? { base: { type: \"branch\", branch: ctx.branch } }\n : {},\n );\n\n return buildScenarioClient(client, response.scenarioRid);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,iBAAiB,QAAQ,0BAA0B;AAC5D,SAASC,iBAAiB,QAAqB,cAAc;AAE7D,SAASC,mBAAmB,QAA6B,qBAAqB;;AAE9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,cAAcA,CAClCC,MAAc,EACW;EACzB,MAAMC,GAAkB,GAAGD,MAAM,CAACH,iBAAiB,CAAC;EAEpD,IAAII,GAAG,CAACC,aAAa,IAAI,IAAI,EAAE;IAC7B,MAAM,IAAIC,KAAK,CACb,oHACF,CAAC;EACH;EACA,IAAIF,GAAG,CAACG,WAAW,IAAI,IAAI,EAAE;IAC3B,MAAM,IAAID,KAAK,CACb,iGACF,CAAC;EACH;EAEA,MAAME,QAAQ,GAAG,MAAMT,iBAAiB,CAACG,cAAc,CACrDE,GAAG,EACH,MAAMA,GAAG,CAACK,WAAW,EACrBL,GAAG,CAACM,MAAM,IAAI,IAAI,GACd;IAAEC,IAAI,EAAE;MAAEC,IAAI,EAAE,QAAQ;MAAEF,MAAM,EAAEN,GAAG,CAACM;IAAO;EAAE,CAAC,GAChD,CAAC,CACP,CAAC;EAED,OAAOT,mBAAmB,CAACE,MAAM,EAAEK,QAAQ,CAACD,WAAW,CAAC;AAC1D","ignoreList":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { buildScenarioClient } from "./ScenarioClient.js";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Attach to an existing ontology scenario. Synchronous — no network call is made. The returned client scopes all
|
|
21
|
+
* subsequent operations (`fetchPage`, `applyAction`, `executeFunction`, etc.) to the given `scenarioRid`.
|
|
22
|
+
*
|
|
23
|
+
* @param client - The base {@link Client} to derive context (`baseUrl`, `ontologyRid`, `tokenProvider`, `branch`, …)
|
|
24
|
+
* from. Throws at runtime if the client is already scoped to a scenario or transaction.
|
|
25
|
+
* @param scenarioRid - The RID of the scenario to attach to.
|
|
26
|
+
* @returns a {@link ScenarioClient} bound to `scenarioRid`.
|
|
27
|
+
*
|
|
28
|
+
* @beta This is an experimental, unstable feature subject to change.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { withScenario } from "@osdk/client/unstable-do-not-use";
|
|
33
|
+
*
|
|
34
|
+
* const scenario = withScenario(client, "ri.actions..scenario.abc");
|
|
35
|
+
* const page = await scenario(Doctor).fetchPage();
|
|
36
|
+
* await scenario(Schedule).applyAction({ doctor: page.data[0], shift: "AM" });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export function withScenario(client, scenarioRid) {
|
|
40
|
+
return buildScenarioClient(client, scenarioRid);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=withScenario.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withScenario.js","names":["buildScenarioClient","withScenario","client","scenarioRid"],"sources":["withScenario.ts"],"sourcesContent":["/*\n * Copyright 2026 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 { Client } from \"../Client.js\";\nimport { buildScenarioClient, type ScenarioClient } from \"./ScenarioClient.js\";\n\n/**\n * Attach to an existing ontology scenario. Synchronous — no network call is made. The returned client scopes all\n * subsequent operations (`fetchPage`, `applyAction`, `executeFunction`, etc.) to the given `scenarioRid`.\n *\n * @param client - The base {@link Client} to derive context (`baseUrl`, `ontologyRid`, `tokenProvider`, `branch`, …)\n * from. Throws at runtime if the client is already scoped to a scenario or transaction.\n * @param scenarioRid - The RID of the scenario to attach to.\n * @returns a {@link ScenarioClient} bound to `scenarioRid`.\n *\n * @beta This is an experimental, unstable feature subject to change.\n *\n * @example\n * ```ts\n * import { withScenario } from \"@osdk/client/unstable-do-not-use\";\n *\n * const scenario = withScenario(client, \"ri.actions..scenario.abc\");\n * const page = await scenario(Doctor).fetchPage();\n * await scenario(Schedule).applyAction({ doctor: page.data[0], shift: \"AM\" });\n * ```\n */\nexport function withScenario(\n client: Client,\n scenarioRid: string,\n): ScenarioClient {\n return buildScenarioClient(client, scenarioRid);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,mBAAmB,QAA6B,qBAAqB;;AAE9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAC1BC,MAAc,EACdC,WAAmB,EACH;EAChB,OAAOH,mBAAmB,CAACE,MAAM,EAAEC,WAAW,CAAC;AACjD","ignoreList":[]}
|
|
@@ -14,6 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
export const USER_AGENT = `osdk-client/${"2.23.
|
|
18
|
-
export const OBSERVABLE_USER_AGENT = `osdk-observable-client/${"2.23.
|
|
17
|
+
export const USER_AGENT = `osdk-client/${"2.23.1-beta.2"}`;
|
|
18
|
+
export const OBSERVABLE_USER_AGENT = `osdk-observable-client/${"2.23.1-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,gCAA4C;AAC9E,OAAO,MAAMC,qBAA6B,GACxC,2CAAuD","ignoreList":[]}
|
|
@@ -19,6 +19,7 @@ import * as Attachments from "@osdk/foundry.ontologies/Attachment";
|
|
|
19
19
|
import { isAttachmentFile, isAttachmentUpload } from "../object/AttachmentUpload.js";
|
|
20
20
|
import { isMedia, isMediaReference, isMediaUpload } from "../object/mediaUpload.js";
|
|
21
21
|
import { getWireObjectSet, isObjectSet } from "../objectSet/createObjectSet.js";
|
|
22
|
+
import { isScenarioClient } from "../scenarios/ScenarioClient.js";
|
|
22
23
|
import { isInterfaceActionParam } from "./interfaceUtils.js";
|
|
23
24
|
import { isObjectSpecifiersObject } from "./isObjectSpecifiersObject.js";
|
|
24
25
|
import { isOntologyObjectV2 } from "./isOntologyObjectV2.js";
|
|
@@ -103,6 +104,9 @@ export async function toDataValue(value, client, actionMetadata) {
|
|
|
103
104
|
primaryKeyValue: value.$primaryKey
|
|
104
105
|
};
|
|
105
106
|
}
|
|
107
|
+
if (isScenarioClient(value)) {
|
|
108
|
+
return value.getScenarioReference().scenarioRid;
|
|
109
|
+
}
|
|
106
110
|
|
|
107
111
|
// TODO (during queries implementation)
|
|
108
112
|
// two dimensional aggregation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toDataValue.js","names":["MediaSets","Attachments","isAttachmentFile","isAttachmentUpload","isMedia","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","upload","data","filename","name","rid","mediaRef","uploadMedia","fileName","preview","getMediaReference","__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 Attachments from \"@osdk/foundry.ontologies/Attachment\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport {\n isAttachmentFile,\n isAttachmentUpload,\n} from \"../object/AttachmentUpload.js\";\nimport {\n isMedia,\n isMediaReference,\n isMediaUpload,\n} 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 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 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 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 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 if (isMedia(value)) {\n return value.getMediaReference();\n }\n\n if (isMediaReference(value)) {\n return value;\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 (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;;AAGA,SAASA,SAAS,QAAQ,yBAAyB;AAEnD,OAAO,KAAKC,WAAW,MAAM,qCAAqC;AAElE,SACEC,gBAAgB,EAChBC,kBAAkB,QACb,+BAA+B;AACtC,SACEC,OAAO,EACPC,gBAAgB,EAChBC,aAAa,QACR,0BAA0B;AACjC,SAASC,gBAAgB,EAAEC,WAAW,QAAQ,iCAAiC;AAC/E,SAASC,sBAAsB,QAAQ,qBAAqB;AAC5D,SAASC,wBAAwB,QAAQ,+BAA+B;AACxE,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,OAAO,QAAQ,cAAc;AACtC,SAASC,eAAe,QAAQ,oBAAoB;;AAEpD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,WAAWA,CAC/BC,KAAc,EACdC,MAAqB,EACrBC,cAA8B,EACV;EACpB,IAAIF,KAAK,IAAI,IAAI,EAAE;IACjB;IACA;IACA,OAAOA,KAAK;EACd;;EAEA;EACA,IAAIG,KAAK,CAACC,OAAO,CAACJ,KAAK,CAAC,IAAIA,KAAK,YAAYK,GAAG,EAAE;IAChD,MAAMC,MAAM,GAAGH,KAAK,CAACI,IAAI,CAACP,KAAK,CAAC;IAChC,IACEM,MAAM,CAACE,IAAI,CAAEC,SAAS,
|
|
1
|
+
{"version":3,"file":"toDataValue.js","names":["MediaSets","Attachments","isAttachmentFile","isAttachmentUpload","isMedia","isMediaReference","isMediaUpload","getWireObjectSet","isObjectSet","isScenarioClient","isInterfaceActionParam","isObjectSpecifiersObject","isOntologyObjectV2","isPoint","isWireObjectSet","toDataValue","value","client","actionMetadata","Array","isArray","Set","values","from","some","dataValue","converted","push","promiseArray","innerValue","Promise","all","attachment","upload","data","filename","name","rid","mediaRef","uploadMedia","fileName","preview","getMediaReference","__primaryKey","$primaryKey","coordinates","objectTypeApiName","$objectType","primaryKeyValue","getScenarioReference","scenarioRid","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 Attachments from \"@osdk/foundry.ontologies/Attachment\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport {\n isAttachmentFile,\n isAttachmentUpload,\n} from \"../object/AttachmentUpload.js\";\nimport {\n isMedia,\n isMediaReference,\n isMediaUpload,\n} from \"../object/mediaUpload.js\";\nimport { getWireObjectSet, isObjectSet } from \"../objectSet/createObjectSet.js\";\nimport { isScenarioClient } from \"../scenarios/ScenarioClient.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 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 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 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 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 if (isMedia(value)) {\n return value.getMediaReference();\n }\n\n if (isMediaReference(value)) {\n return value;\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 (isInterfaceActionParam(value)) {\n return {\n objectTypeApiName: value.$objectType,\n primaryKeyValue: value.$primaryKey,\n };\n }\n\n if (isScenarioClient(value)) {\n return value.getScenarioReference().scenarioRid;\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;;AAGA,SAASA,SAAS,QAAQ,yBAAyB;AAEnD,OAAO,KAAKC,WAAW,MAAM,qCAAqC;AAElE,SACEC,gBAAgB,EAChBC,kBAAkB,QACb,+BAA+B;AACtC,SACEC,OAAO,EACPC,gBAAgB,EAChBC,aAAa,QACR,0BAA0B;AACjC,SAASC,gBAAgB,EAAEC,WAAW,QAAQ,iCAAiC;AAC/E,SAASC,gBAAgB,QAAQ,gCAAgC;AACjE,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Object.defineProperty(exports, "getMediaContent", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return chunkYP43NHIA_cjs.getMediaContent; }
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "getMediaMetadata", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return chunkYP43NHIA_cjs.getMediaMetadata; }
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "upload", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return chunkYP43NHIA_cjs.upload; }
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=MediaReferenceProperty-CBPMMD73.cjs.map
|
|
22
|
+
//# sourceMappingURL=MediaReferenceProperty-CBPMMD73.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"MediaReferenceProperty-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"MediaReferenceProperty-CBPMMD73.cjs"}
|