@osdk/client 2.3.0-beta.6 → 2.3.0-beta.8
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 +23 -0
- package/build/browser/actions/ActionValidationError.js.map +1 -1
- package/build/browser/actions/applyAction.js +9 -8
- package/build/browser/actions/applyAction.js.map +1 -1
- package/build/browser/object/mediaUpload.js +3 -0
- package/build/browser/object/mediaUpload.js.map +1 -1
- package/build/browser/util/UserAgent.js +2 -2
- package/build/browser/util/extractRdpDefinition.js +2 -0
- package/build/browser/util/extractRdpDefinition.js.map +1 -1
- package/build/browser/util/toDataValue.js +20 -10
- package/build/browser/util/toDataValue.js.map +1 -1
- package/build/browser/util/toDataValue.test.js +50 -11
- package/build/browser/util/toDataValue.test.js.map +1 -1
- package/build/cjs/{chunk-DHPFI5ZJ.cjs → chunk-4ZC7PBHG.cjs} +77 -66
- package/build/cjs/chunk-4ZC7PBHG.cjs.map +1 -0
- package/build/cjs/{chunk-N4KFUVWG.cjs → chunk-HTPVXLYY.cjs} +26 -19
- package/build/cjs/chunk-HTPVXLYY.cjs.map +1 -0
- package/build/cjs/index.cjs +6 -6
- package/build/cjs/index.d.cts +4 -3
- package/build/cjs/public/internal.cjs +7 -7
- package/build/cjs/public/unstable-do-not-use.cjs +15 -15
- package/build/esm/actions/ActionValidationError.js.map +1 -1
- package/build/esm/actions/applyAction.js +9 -8
- package/build/esm/actions/applyAction.js.map +1 -1
- package/build/esm/object/mediaUpload.js +3 -0
- package/build/esm/object/mediaUpload.js.map +1 -1
- package/build/esm/util/UserAgent.js +2 -2
- package/build/esm/util/extractRdpDefinition.js +2 -0
- package/build/esm/util/extractRdpDefinition.js.map +1 -1
- package/build/esm/util/toDataValue.js +20 -10
- package/build/esm/util/toDataValue.js.map +1 -1
- package/build/esm/util/toDataValue.test.js +50 -11
- package/build/esm/util/toDataValue.test.js.map +1 -1
- package/build/types/actions/ActionValidationError.d.ts +1 -1
- package/build/types/actions/ActionValidationError.d.ts.map +1 -1
- package/build/types/actions/applyAction.d.ts.map +1 -1
- package/build/types/object/mediaUpload.d.ts +2 -1
- package/build/types/object/mediaUpload.d.ts.map +1 -1
- package/package.json +9 -9
- package/build/cjs/chunk-DHPFI5ZJ.cjs.map +0 -1
- package/build/cjs/chunk-N4KFUVWG.cjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk4ZC7PBHG_cjs = require('../chunk-4ZC7PBHG.cjs');
|
|
4
|
+
var chunkHTPVXLYY_cjs = require('../chunk-HTPVXLYY.cjs');
|
|
5
5
|
var shared_net_fetch = require('@osdk/shared.net.fetch');
|
|
6
6
|
var rxjs = require('rxjs');
|
|
7
7
|
var invariant2 = require('tiny-invariant');
|
|
@@ -138,7 +138,7 @@ var OptimisticJob = class {
|
|
|
138
138
|
return this;
|
|
139
139
|
},
|
|
140
140
|
createObject(type, pk, properties) {
|
|
141
|
-
const create = store.client[
|
|
141
|
+
const create = store.client[chunkHTPVXLYY_cjs.additionalContext].objectFactory2(store.client[chunkHTPVXLYY_cjs.additionalContext], [{
|
|
142
142
|
$primaryKey: pk,
|
|
143
143
|
$apiName: type.apiName,
|
|
144
144
|
$objectType: type.apiName,
|
|
@@ -618,7 +618,7 @@ var BulkObjectLoader = class {
|
|
|
618
618
|
#maxEntries;
|
|
619
619
|
constructor(client, maxWait = 25, maxEntries = 100) {
|
|
620
620
|
this.#client = client;
|
|
621
|
-
this.#logger = client[
|
|
621
|
+
this.#logger = client[chunkHTPVXLYY_cjs.additionalContext].logger;
|
|
622
622
|
this.#maxWait = maxWait;
|
|
623
623
|
this.#maxEntries = maxEntries;
|
|
624
624
|
}
|
|
@@ -688,7 +688,7 @@ var Query = class {
|
|
|
688
688
|
this.cacheKey = cacheKey;
|
|
689
689
|
this.store = store;
|
|
690
690
|
this.#subject = observable;
|
|
691
|
-
this.logger = logger ?? (process.env.NODE_ENV === "production" ? store.client[
|
|
691
|
+
this.logger = logger ?? (process.env.NODE_ENV === "production" ? store.client[chunkHTPVXLYY_cjs.additionalContext].logger : store.client[chunkHTPVXLYY_cjs.additionalContext].logger?.child({}, {
|
|
692
692
|
msgPrefix: process.env.NODE_ENV !== "production" ? `Query<${cacheKey.type}, ${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>` : "Query"
|
|
693
693
|
}));
|
|
694
694
|
}
|
|
@@ -798,7 +798,7 @@ var ObjectQuery = class extends Query {
|
|
|
798
798
|
#apiName;
|
|
799
799
|
#pk;
|
|
800
800
|
constructor(store, subject, type, pk, cacheKey, opts) {
|
|
801
|
-
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[
|
|
801
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkHTPVXLYY_cjs.additionalContext].logger?.child({}, {
|
|
802
802
|
msgPrefix: `ObjectQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
803
803
|
}) : void 0);
|
|
804
804
|
this.#apiName = type;
|
|
@@ -983,7 +983,7 @@ var ListQuery = class extends BaseListQuery {
|
|
|
983
983
|
#objectSet;
|
|
984
984
|
#sortFns;
|
|
985
985
|
constructor(store, subject, apiType, apiName, whereClause, orderBy, cacheKey, opts) {
|
|
986
|
-
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[
|
|
986
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkHTPVXLYY_cjs.additionalContext].logger?.child({}, {
|
|
987
987
|
msgPrefix: `ListQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
988
988
|
}) : void 0);
|
|
989
989
|
this.#type = apiType;
|
|
@@ -1228,7 +1228,7 @@ var ListQuery = class extends BaseListQuery {
|
|
|
1228
1228
|
}
|
|
1229
1229
|
#extractRelevantObjectsForTypeInterface(changes) {
|
|
1230
1230
|
const matchesApiName = ([, object]) => {
|
|
1231
|
-
return this.#apiName in object[
|
|
1231
|
+
return this.#apiName in object[chunk4ZC7PBHG_cjs.ObjectDefRef].interfaceMap;
|
|
1232
1232
|
};
|
|
1233
1233
|
const added = Array.from(changes.addedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.#apiName));
|
|
1234
1234
|
const modified = Array.from(changes.modifiedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.#apiName));
|
|
@@ -1404,7 +1404,7 @@ function createOrderBySortFns(orderBy) {
|
|
|
1404
1404
|
async function reloadDataAsFullObjects(client, data) {
|
|
1405
1405
|
const groups = groupBy__default.default(data, (x) => x.$objectType);
|
|
1406
1406
|
const objectTypeToPrimaryKeyToObject = Object.fromEntries(await Promise.all(Object.entries(groups).map(async ([apiName, objects]) => {
|
|
1407
|
-
const objectDef = objects[0][
|
|
1407
|
+
const objectDef = objects[0][chunk4ZC7PBHG_cjs.UnderlyingOsdkObject][chunk4ZC7PBHG_cjs.ObjectDefRef];
|
|
1408
1408
|
const where = {
|
|
1409
1409
|
[objectDef.primaryKeyApiName]: {
|
|
1410
1410
|
$in: objects.map((x) => x.$primaryKey)
|
|
@@ -1612,7 +1612,7 @@ var Store = class {
|
|
|
1612
1612
|
#finalizationRegistry;
|
|
1613
1613
|
constructor(client) {
|
|
1614
1614
|
this.client = client;
|
|
1615
|
-
this.logger = client[
|
|
1615
|
+
this.logger = client[chunkHTPVXLYY_cjs.additionalContext].logger?.child({}, {
|
|
1616
1616
|
msgPrefix: "Store"
|
|
1617
1617
|
});
|
|
1618
1618
|
this.#topLayer = this.#truthLayer;
|
|
@@ -1906,10 +1906,10 @@ var Store = class {
|
|
|
1906
1906
|
|
|
1907
1907
|
// src/observable/ObservableClient.ts
|
|
1908
1908
|
function createObservableClient(client) {
|
|
1909
|
-
const tweakedClient =
|
|
1910
|
-
...client[
|
|
1911
|
-
fetch: shared_net_fetch.createFetchHeaderMutator(client[
|
|
1912
|
-
headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"),
|
|
1909
|
+
const tweakedClient = chunk4ZC7PBHG_cjs.createClientFromContext({
|
|
1910
|
+
...client[chunkHTPVXLYY_cjs.additionalContext],
|
|
1911
|
+
fetch: shared_net_fetch.createFetchHeaderMutator(client[chunkHTPVXLYY_cjs.additionalContext].fetch, (headers) => {
|
|
1912
|
+
headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"), chunk4ZC7PBHG_cjs.OBSERVABLE_USER_AGENT].filter((x) => x && x?.length > 0).join(" "));
|
|
1913
1913
|
return headers;
|
|
1914
1914
|
})
|
|
1915
1915
|
});
|
|
@@ -1952,7 +1952,7 @@ function getOsdkConfig(ontologyRid) {
|
|
|
1952
1952
|
|
|
1953
1953
|
Object.defineProperty(exports, "augment", {
|
|
1954
1954
|
enumerable: true,
|
|
1955
|
-
get: function () { return
|
|
1955
|
+
get: function () { return chunkHTPVXLYY_cjs.augment; }
|
|
1956
1956
|
});
|
|
1957
1957
|
exports.createObservableClient = createObservableClient;
|
|
1958
1958
|
exports.getMetaTagContent = getMetaTagContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionValidationError.js","names":["ActionValidationError","Error","constructor","validation","JSON","stringify"],"sources":["ActionValidationError.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 { ActionValidationResponse } from \"@osdk/
|
|
1
|
+
{"version":3,"file":"ActionValidationError.js","names":["ActionValidationError","Error","constructor","validation","JSON","stringify"],"sources":["ActionValidationError.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 { ValidateActionResponseV2 as ActionValidationResponse } from \"@osdk/foundry.ontologies\";\n\nexport class ActionValidationError extends Error {\n constructor(public validation: ActionValidationResponse) {\n super(\"Validation Error: \" + JSON.stringify(validation, null, 2));\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAO,MAAMA,qBAAqB,SAASC,KAAK,CAAC;EAC/CC,WAAWA,CAAQC,UAAoC,EAAE;IACvD,KAAK,CAAC,oBAAoB,GAAGC,IAAI,CAACC,SAAS,CAACF,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAAC,KADjDA,UAAoC,GAApCA,UAAoC;EAEvD;AACF","ignoreList":[]}
|
|
@@ -25,7 +25,7 @@ export async function applyAction(client, action, parameters, options = {}) {
|
|
|
25
25
|
})), action);
|
|
26
26
|
if (Array.isArray(parameters)) {
|
|
27
27
|
const response = await OntologiesV2.Actions.applyBatch(clientWithHeaders, await client.ontologyRid, action.apiName, {
|
|
28
|
-
requests: parameters ? await remapBatchActionParams(parameters, client) : [],
|
|
28
|
+
requests: parameters ? await remapBatchActionParams(parameters, client, await client.ontologyProvider.getActionDefinition(action.apiName)) : [],
|
|
29
29
|
options: {
|
|
30
30
|
returnEdits: options?.$returnEdits ? "ALL" : "NONE"
|
|
31
31
|
}
|
|
@@ -34,7 +34,7 @@ export async function applyAction(client, action, parameters, options = {}) {
|
|
|
34
34
|
return options?.$returnEdits ? edits?.type === "edits" ? remapActionResponse(response) : edits : undefined;
|
|
35
35
|
} else {
|
|
36
36
|
const response = await OntologiesV2.Actions.apply(clientWithHeaders, await client.ontologyRid, action.apiName, {
|
|
37
|
-
parameters: await remapActionParams(parameters, client),
|
|
37
|
+
parameters: await remapActionParams(parameters, client, await client.ontologyProvider.getActionDefinition(action.apiName)),
|
|
38
38
|
options: {
|
|
39
39
|
mode: options?.$validateOnly ? "VALIDATE_ONLY" : "VALIDATE_AND_EXECUTE",
|
|
40
40
|
returnEdits: options?.$returnEdits ? "ALL_V2_WITH_DELETIONS" : "NONE"
|
|
@@ -43,27 +43,28 @@ export async function applyAction(client, action, parameters, options = {}) {
|
|
|
43
43
|
if (options?.$validateOnly) {
|
|
44
44
|
return response.validation;
|
|
45
45
|
}
|
|
46
|
-
if (response.validation?.result === "INVALID") {
|
|
47
|
-
|
|
46
|
+
if (response.validation && response.validation?.result === "INVALID") {
|
|
47
|
+
const validation = response.validation;
|
|
48
|
+
throw new ActionValidationError(validation);
|
|
48
49
|
}
|
|
49
50
|
const edits = response.edits;
|
|
50
51
|
return options?.$returnEdits ? edits?.type === "edits" ? remapActionResponse(response) : edits : undefined;
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
|
-
async function remapActionParams(params, client) {
|
|
54
|
+
async function remapActionParams(params, client, actionMetadata) {
|
|
54
55
|
if (params == null) {
|
|
55
56
|
return {};
|
|
56
57
|
}
|
|
57
58
|
const parameterMap = {};
|
|
58
59
|
for (const [key, value] of Object.entries(params)) {
|
|
59
|
-
parameterMap[key] = await toDataValue(value, client);
|
|
60
|
+
parameterMap[key] = await toDataValue(value, client, actionMetadata);
|
|
60
61
|
}
|
|
61
62
|
return parameterMap;
|
|
62
63
|
}
|
|
63
|
-
async function remapBatchActionParams(params, client) {
|
|
64
|
+
async function remapBatchActionParams(params, client, actionMetadata) {
|
|
64
65
|
const remappedParams = await Promise.all(params.map(async param => {
|
|
65
66
|
return {
|
|
66
|
-
parameters: await remapActionParams(param, client)
|
|
67
|
+
parameters: await remapActionParams(param, client, actionMetadata)
|
|
67
68
|
};
|
|
68
69
|
}));
|
|
69
70
|
return remappedParams;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyAction.js","names":["OntologiesV2","addUserAgentAndRequestContextHeaders","augmentRequestContext","toDataValue","ActionValidationError","applyAction","client","action","parameters","options","clientWithHeaders","finalMethodCall","Array","isArray","response","Actions","applyBatch","ontologyRid","apiName","requests","remapBatchActionParams","returnEdits","$returnEdits","edits","type","remapActionResponse","undefined","apply","remapActionParams","mode","$validateOnly","validation","result","params","parameterMap","key","value","Object","entries","remappedParams","Promise","all","map","param","editResponses","remappedActionResponse","deletedLinksCount","deletedObjectsCount","addedLinks","deletedLinks","addedObjects","deletedObjects","modifiedObjects","editedObjectTypes","editedObjectTypesSet","Set","edit","osdkEdit","linkTypeApiNameAtoB","linkTypeApiNameBtoA","aSideObject","bSideObject","push","add","objectType","primaryKey","process","env","NODE_ENV","console","warn","JSON","stringify"],"sources":["applyAction.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionEditResponse,\n ActionMetadata,\n ActionParam,\n ActionReturnTypeForOptions,\n ApplyActionOptions,\n ApplyBatchActionOptions,\n CompileTimeMetadata as CompileTimeActionMetadata,\n DataValueClientToWire,\n} from \"@osdk/api\";\nimport type {\n BatchApplyActionResponseV2,\n DataValue,\n SyncApplyActionResponseV2,\n} from \"@osdk/foundry.ontologies\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport { addUserAgentAndRequestContextHeaders } from \"../util/addUserAgentAndRequestContextHeaders.js\";\nimport { augmentRequestContext } from \"../util/augmentRequestContext.js\";\nimport type { NOOP } from \"../util/NOOP.js\";\nimport type { NullableProps } from \"../util/NullableProps.js\";\nimport type { PartialBy } from \"../util/partialBy.js\";\nimport { toDataValue } from \"../util/toDataValue.js\";\nimport { ActionValidationError } from \"./ActionValidationError.js\";\n\ntype BaseType<APD extends Pick<ActionMetadata.Parameter<any>, \"type\">> =\n APD[\"type\"] extends ActionMetadata.DataType.Object<infer TTargetType>\n ? ActionParam.ObjectType<TTargetType>\n : APD[\"type\"] extends ActionMetadata.DataType.ObjectSet<infer TTargetType>\n ? ActionParam.ObjectSetType<TTargetType>\n : APD[\"type\"] extends ActionMetadata.DataType.Struct<infer TStructType>\n ? ActionParam.StructType<TStructType>\n : APD[\"type\"] extends keyof DataValueClientToWire\n ? ActionParam.PrimitiveType<APD[\"type\"]>\n : never;\n\ntype MaybeArrayType<APD extends ActionMetadata.Parameter<any>> =\n APD[\"multiplicity\"] extends true ? Array<BaseType<APD>>\n : BaseType<APD>;\n\ntype NotOptionalParams<X extends ActionParametersDefinition> = {\n [P in keyof X]: MaybeArrayType<X[P]>;\n};\n\nexport type OsdkActionParameters<\n X extends ActionParametersDefinition,\n> = NullableProps<X> extends never ? NotOptionalParams<X>\n : PartialBy<NotOptionalParams<X>, NullableProps<X>>;\n\nexport type ActionSignatureFromDef<\n T extends ActionDefinition<any>,\n> = {\n applyAction:\n [CompileTimeActionMetadata<T>[\"signatures\"][\"applyAction\"]] extends [never]\n ? ActionSignature<CompileTimeActionMetadata<T>[\"parameters\"]>\n : CompileTimeActionMetadata<T>[\"signatures\"][\"applyAction\"];\n\n batchApplyAction:\n [CompileTimeActionMetadata<T>[\"signatures\"][\"batchApplyAction\"]] extends\n [never] ? BatchActionSignature<CompileTimeActionMetadata<T>[\"parameters\"]>\n : CompileTimeActionMetadata<T>[\"signatures\"][\"batchApplyAction\"];\n};\n\ntype ActionParametersDefinition = Record<\n any,\n ActionMetadata.Parameter<any>\n>;\n\nexport type ActionSignature<\n X extends Record<any, ActionMetadata.Parameter<any>>,\n> = <\n A extends NOOP<OsdkActionParameters<X>>,\n OP extends ApplyActionOptions,\n>(\n args: A,\n options?: OP,\n) => Promise<\n ActionReturnTypeForOptions<OP>\n>;\n\nexport type BatchActionSignature<\n X extends Record<any, ActionMetadata.Parameter<any>>,\n> = <\n A extends NOOP<OsdkActionParameters<X>>[],\n OP extends ApplyBatchActionOptions,\n>(\n args: A,\n options?: OP,\n) => Promise<\n ActionReturnTypeForOptions<OP>\n>;\n\nexport async function applyAction<\n AD extends ActionDefinition<any>,\n P extends\n | OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>\n | OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>[],\n Op extends P extends OsdkActionParameters<\n CompileTimeActionMetadata<AD>[\"parameters\"]\n >[] ? ApplyBatchActionOptions\n : ApplyActionOptions,\n>(\n client: MinimalClient,\n action: AD,\n parameters?: P,\n options: Op = {} as Op,\n): Promise<\n ActionReturnTypeForOptions<Op>\n> {\n const clientWithHeaders = addUserAgentAndRequestContextHeaders(\n augmentRequestContext(client, _ => ({ finalMethodCall: \"applyAction\" })),\n action,\n );\n if (Array.isArray(parameters)) {\n const response = await OntologiesV2.Actions.applyBatch(\n clientWithHeaders,\n await client.ontologyRid,\n action.apiName,\n {\n requests: parameters\n ? await remapBatchActionParams(parameters, client)\n : [],\n options: {\n returnEdits: options?.$returnEdits ? \"ALL\" : \"NONE\",\n },\n },\n );\n\n const edits = response.edits;\n return (options?.$returnEdits\n ? edits?.type === \"edits\" ? remapActionResponse(response) : edits\n : undefined) as ActionReturnTypeForOptions<Op>;\n } else {\n const response = await OntologiesV2.Actions.apply(\n clientWithHeaders,\n await client.ontologyRid,\n action.apiName,\n {\n parameters: await remapActionParams(\n parameters as OsdkActionParameters<\n CompileTimeActionMetadata<AD>[\"parameters\"]\n >,\n client,\n ),\n options: {\n mode: (options as ApplyActionOptions)?.$validateOnly\n ? \"VALIDATE_ONLY\"\n : \"VALIDATE_AND_EXECUTE\",\n returnEdits: options\n ?.$returnEdits\n ? \"ALL_V2_WITH_DELETIONS\"\n : \"NONE\",\n },\n },\n );\n\n if ((options as ApplyActionOptions)?.$validateOnly) {\n return response.validation as ActionReturnTypeForOptions<Op>;\n }\n\n if (response.validation?.result === \"INVALID\") {\n throw new ActionValidationError(response.validation);\n }\n\n const edits = response.edits;\n return (options?.$returnEdits\n ? edits?.type === \"edits\" ? remapActionResponse(response) : edits\n : undefined) as ActionReturnTypeForOptions<Op>;\n }\n}\n\nasync function remapActionParams<AD extends ActionDefinition<any>>(\n params:\n | OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>\n | undefined,\n client: MinimalClient,\n): Promise<Record<string, DataValue>> {\n if (params == null) {\n return {};\n }\n\n const parameterMap: { [parameterName: string]: unknown } = {};\n for (const [key, value] of Object.entries(params)) {\n parameterMap[key] = await toDataValue(value, client);\n }\n\n return parameterMap;\n}\n\nasync function remapBatchActionParams<\n AD extends ActionDefinition<any>,\n>(\n params: OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>[],\n client: MinimalClient,\n) {\n const remappedParams = await Promise.all(params.map(\n async param => {\n return { parameters: await remapActionParams<AD>(param, client) };\n },\n ));\n\n return remappedParams;\n}\n\nexport function remapActionResponse(\n response: SyncApplyActionResponseV2 | BatchApplyActionResponseV2,\n): ActionEditResponse | undefined {\n const editResponses = response?.edits;\n if (editResponses?.type === \"edits\") {\n const remappedActionResponse: ActionEditResponse = {\n type: editResponses.type,\n deletedLinksCount: editResponses.deletedLinksCount,\n deletedObjectsCount: editResponses.deletedObjectsCount,\n addedLinks: [],\n deletedLinks: [],\n addedObjects: [],\n deletedObjects: [],\n modifiedObjects: [],\n editedObjectTypes: [],\n };\n\n const editedObjectTypesSet = new Set<string>();\n for (const edit of editResponses.edits) {\n if (edit.type === \"addLink\" || edit.type === \"deleteLink\") {\n const osdkEdit = {\n linkTypeApiNameAtoB: edit.linkTypeApiNameAtoB,\n linkTypeApiNameBtoA: edit.linkTypeApiNameBtoA,\n aSideObject: edit.aSideObject,\n bSideObject: edit.bSideObject,\n };\n edit.type === \"addLink\"\n ? remappedActionResponse.addedLinks.push(\n osdkEdit,\n )\n : remappedActionResponse.deletedLinks?.push(osdkEdit);\n editedObjectTypesSet.add(edit.aSideObject.objectType);\n editedObjectTypesSet.add(edit.bSideObject.objectType);\n } else if (\n edit.type === \"addObject\" || edit.type === \"deleteObject\"\n || edit.type === \"modifyObject\"\n ) {\n const osdkEdit = {\n objectType: edit.objectType,\n primaryKey: edit.primaryKey,\n };\n if (edit.type === \"addObject\") {\n remappedActionResponse.addedObjects.push(osdkEdit);\n } else if (edit.type === \"deleteObject\") {\n remappedActionResponse.deletedObjects?.push(osdkEdit);\n } else if (edit.type === \"modifyObject\") {\n remappedActionResponse.modifiedObjects.push(osdkEdit);\n }\n editedObjectTypesSet.add(edit.objectType);\n } else {\n if (process.env.NODE_ENV !== \"production\") {\n // eslint-disable-next-line no-console\n console.warn(\n `Unexpected edit type: ${JSON.stringify(edit)}`,\n );\n }\n }\n }\n remappedActionResponse.editedObjectTypes = [...editedObjectTypesSet];\n return remappedActionResponse;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA,OAAO,KAAKA,YAAY,MAAM,0BAA0B;AAExD,SAASC,oCAAoC,QAAQ,iDAAiD;AACtG,SAASC,qBAAqB,QAAQ,kCAAkC;AAIxE,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,qBAAqB,QAAQ,4BAA4B;AAqElE,OAAO,eAAeC,WAAWA,CAU/BC,MAAqB,EACrBC,MAAU,EACVC,UAAc,EACdC,OAAW,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AACK,YAAY,CAACY,IAAI,CAACL,QAAQ,CAAC;QACpD,CAAC,MAAM,IAAID,IAAI,CAAChC,IAAI,KAAK,cAAc,EAAE;UACvCqB,sBAAsB,CAACM,cAAc,EAAEW,IAAI,CAACL,QAAQ,CAAC;QACvD,CAAC,MAAM,IAAID,IAAI,CAAChC,IAAI,KAAK,cAAc,EAAE;UACvCqB,sBAAsB,CAACO,eAAe,CAACU,IAAI,CAACL,QAAQ,CAAC;QACvD;QACAH,oBAAoB,CAACS,GAAG,CAACP,IAAI,CAACQ,UAAU,CAAC;MAC3C,CAAC,MAAM;QACL,IAAIE,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;UACzC;UACAC,OAAO,CAACC,IAAI,CACV,yBAAyBC,IAAI,CAACC,SAAS,CAAChB,IAAI,CAAC,EAC/C,CAAC;QACH;MACF;IACF;IACAX,sBAAsB,CAACQ,iBAAiB,GAAG,CAAC,GAAGC,oBAAoB,CAAC;IACpE,OAAOT,sBAAsB;EAC/B;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"applyAction.js","names":["OntologiesV2","addUserAgentAndRequestContextHeaders","augmentRequestContext","toDataValue","ActionValidationError","applyAction","client","action","parameters","options","clientWithHeaders","finalMethodCall","Array","isArray","response","Actions","applyBatch","ontologyRid","apiName","requests","remapBatchActionParams","ontologyProvider","getActionDefinition","returnEdits","$returnEdits","edits","type","remapActionResponse","undefined","apply","remapActionParams","mode","$validateOnly","validation","result","params","actionMetadata","parameterMap","key","value","Object","entries","remappedParams","Promise","all","map","param","editResponses","remappedActionResponse","deletedLinksCount","deletedObjectsCount","addedLinks","deletedLinks","addedObjects","deletedObjects","modifiedObjects","editedObjectTypes","editedObjectTypesSet","Set","edit","osdkEdit","linkTypeApiNameAtoB","linkTypeApiNameBtoA","aSideObject","bSideObject","push","add","objectType","primaryKey","process","env","NODE_ENV","console","warn","JSON","stringify"],"sources":["applyAction.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionEditResponse,\n ActionMetadata,\n ActionParam,\n ActionReturnTypeForOptions,\n ApplyActionOptions,\n ApplyBatchActionOptions,\n CompileTimeMetadata as CompileTimeActionMetadata,\n DataValueClientToWire,\n} from \"@osdk/api\";\nimport type {\n BatchApplyActionResponseV2,\n DataValue,\n SyncApplyActionResponseV2,\n} from \"@osdk/foundry.ontologies\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport { addUserAgentAndRequestContextHeaders } from \"../util/addUserAgentAndRequestContextHeaders.js\";\nimport { augmentRequestContext } from \"../util/augmentRequestContext.js\";\nimport type { NOOP } from \"../util/NOOP.js\";\nimport type { NullableProps } from \"../util/NullableProps.js\";\nimport type { PartialBy } from \"../util/partialBy.js\";\nimport { toDataValue } from \"../util/toDataValue.js\";\nimport { ActionValidationError } from \"./ActionValidationError.js\";\n\ntype BaseType<APD extends Pick<ActionMetadata.Parameter<any>, \"type\">> =\n APD[\"type\"] extends ActionMetadata.DataType.Object<infer TTargetType>\n ? ActionParam.ObjectType<TTargetType>\n : APD[\"type\"] extends ActionMetadata.DataType.ObjectSet<infer TTargetType>\n ? ActionParam.ObjectSetType<TTargetType>\n : APD[\"type\"] extends ActionMetadata.DataType.Struct<infer TStructType>\n ? ActionParam.StructType<TStructType>\n : APD[\"type\"] extends keyof DataValueClientToWire\n ? ActionParam.PrimitiveType<APD[\"type\"]>\n : never;\n\ntype MaybeArrayType<APD extends ActionMetadata.Parameter<any>> =\n APD[\"multiplicity\"] extends true ? Array<BaseType<APD>>\n : BaseType<APD>;\n\ntype NotOptionalParams<X extends ActionParametersDefinition> = {\n [P in keyof X]: MaybeArrayType<X[P]>;\n};\n\nexport type OsdkActionParameters<\n X extends ActionParametersDefinition,\n> = NullableProps<X> extends never ? NotOptionalParams<X>\n : PartialBy<NotOptionalParams<X>, NullableProps<X>>;\n\nexport type ActionSignatureFromDef<\n T extends ActionDefinition<any>,\n> = {\n applyAction:\n [CompileTimeActionMetadata<T>[\"signatures\"][\"applyAction\"]] extends [never]\n ? ActionSignature<CompileTimeActionMetadata<T>[\"parameters\"]>\n : CompileTimeActionMetadata<T>[\"signatures\"][\"applyAction\"];\n\n batchApplyAction:\n [CompileTimeActionMetadata<T>[\"signatures\"][\"batchApplyAction\"]] extends\n [never] ? BatchActionSignature<CompileTimeActionMetadata<T>[\"parameters\"]>\n : CompileTimeActionMetadata<T>[\"signatures\"][\"batchApplyAction\"];\n};\n\ntype ActionParametersDefinition = Record<\n any,\n ActionMetadata.Parameter<any>\n>;\n\nexport type ActionSignature<\n X extends Record<any, ActionMetadata.Parameter<any>>,\n> = <\n A extends NOOP<OsdkActionParameters<X>>,\n OP extends ApplyActionOptions,\n>(\n args: A,\n options?: OP,\n) => Promise<\n ActionReturnTypeForOptions<OP>\n>;\n\nexport type BatchActionSignature<\n X extends Record<any, ActionMetadata.Parameter<any>>,\n> = <\n A extends NOOP<OsdkActionParameters<X>>[],\n OP extends ApplyBatchActionOptions,\n>(\n args: A,\n options?: OP,\n) => Promise<\n ActionReturnTypeForOptions<OP>\n>;\n\nexport async function applyAction<\n AD extends ActionDefinition<any>,\n P extends\n | OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>\n | OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>[],\n Op extends P extends OsdkActionParameters<\n CompileTimeActionMetadata<AD>[\"parameters\"]\n >[] ? ApplyBatchActionOptions\n : ApplyActionOptions,\n>(\n client: MinimalClient,\n action: AD,\n parameters?: P,\n options: Op = {} as Op,\n): Promise<\n ActionReturnTypeForOptions<Op>\n> {\n const clientWithHeaders = addUserAgentAndRequestContextHeaders(\n augmentRequestContext(client, _ => ({ finalMethodCall: \"applyAction\" })),\n action,\n );\n if (Array.isArray(parameters)) {\n const response = await OntologiesV2.Actions.applyBatch(\n clientWithHeaders,\n await client.ontologyRid,\n action.apiName,\n {\n requests: parameters\n ? await remapBatchActionParams(\n parameters,\n client,\n await client.ontologyProvider.getActionDefinition(action.apiName),\n )\n : [],\n options: {\n returnEdits: options?.$returnEdits ? \"ALL\" : \"NONE\",\n },\n },\n );\n\n const edits = response.edits;\n return (options?.$returnEdits\n ? edits?.type === \"edits\" ? remapActionResponse(response) : edits\n : undefined) as ActionReturnTypeForOptions<Op>;\n } else {\n const response = await OntologiesV2.Actions.apply(\n clientWithHeaders,\n await client.ontologyRid,\n action.apiName,\n {\n parameters: await remapActionParams(\n parameters as OsdkActionParameters<\n CompileTimeActionMetadata<AD>[\"parameters\"]\n >,\n client,\n await client.ontologyProvider.getActionDefinition(action.apiName),\n ),\n options: {\n mode: (options as ApplyActionOptions)?.$validateOnly\n ? \"VALIDATE_ONLY\"\n : \"VALIDATE_AND_EXECUTE\",\n returnEdits: options\n ?.$returnEdits\n ? \"ALL_V2_WITH_DELETIONS\"\n : \"NONE\",\n },\n },\n );\n\n if ((options as ApplyActionOptions)?.$validateOnly) {\n return response.validation as ActionReturnTypeForOptions<Op>;\n }\n\n if (response.validation && response.validation?.result === \"INVALID\") {\n const validation = response.validation;\n throw new ActionValidationError(validation);\n }\n\n const edits = response.edits;\n return (options?.$returnEdits\n ? edits?.type === \"edits\" ? remapActionResponse(response) : edits\n : undefined) as ActionReturnTypeForOptions<Op>;\n }\n}\n\nasync function remapActionParams<AD extends ActionDefinition<any>>(\n params:\n | OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>\n | undefined,\n client: MinimalClient,\n actionMetadata: ActionMetadata,\n): Promise<Record<string, DataValue>> {\n if (params == null) {\n return {};\n }\n\n const parameterMap: { [parameterName: string]: unknown } = {};\n for (const [key, value] of Object.entries(params)) {\n parameterMap[key] = await toDataValue(value, client, actionMetadata);\n }\n\n return parameterMap;\n}\n\nasync function remapBatchActionParams<\n AD extends ActionDefinition<any>,\n>(\n params: OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>[],\n client: MinimalClient,\n actionMetadata: ActionMetadata,\n) {\n const remappedParams = await Promise.all(params.map(\n async param => {\n return {\n parameters: await remapActionParams<AD>(param, client, actionMetadata),\n };\n },\n ));\n\n return remappedParams;\n}\n\nexport function remapActionResponse(\n response: SyncApplyActionResponseV2 | BatchApplyActionResponseV2,\n): ActionEditResponse | undefined {\n const editResponses = response?.edits;\n if (editResponses?.type === \"edits\") {\n const remappedActionResponse: ActionEditResponse = {\n type: editResponses.type,\n deletedLinksCount: editResponses.deletedLinksCount,\n deletedObjectsCount: editResponses.deletedObjectsCount,\n addedLinks: [],\n deletedLinks: [],\n addedObjects: [],\n deletedObjects: [],\n modifiedObjects: [],\n editedObjectTypes: [],\n };\n\n const editedObjectTypesSet = new Set<string>();\n for (const edit of editResponses.edits) {\n if (edit.type === \"addLink\" || edit.type === \"deleteLink\") {\n const osdkEdit = {\n linkTypeApiNameAtoB: edit.linkTypeApiNameAtoB,\n linkTypeApiNameBtoA: edit.linkTypeApiNameBtoA,\n aSideObject: edit.aSideObject,\n bSideObject: edit.bSideObject,\n };\n edit.type === \"addLink\"\n ? remappedActionResponse.addedLinks.push(\n osdkEdit,\n )\n : remappedActionResponse.deletedLinks?.push(osdkEdit);\n editedObjectTypesSet.add(edit.aSideObject.objectType);\n editedObjectTypesSet.add(edit.bSideObject.objectType);\n } else if (\n edit.type === \"addObject\" || edit.type === \"deleteObject\"\n || edit.type === \"modifyObject\"\n ) {\n const osdkEdit = {\n objectType: edit.objectType,\n primaryKey: edit.primaryKey,\n };\n if (edit.type === \"addObject\") {\n remappedActionResponse.addedObjects.push(osdkEdit);\n } else if (edit.type === \"deleteObject\") {\n remappedActionResponse.deletedObjects?.push(osdkEdit);\n } else if (edit.type === \"modifyObject\") {\n remappedActionResponse.modifiedObjects.push(osdkEdit);\n }\n editedObjectTypesSet.add(edit.objectType);\n } else {\n if (process.env.NODE_ENV !== \"production\") {\n // eslint-disable-next-line no-console\n console.warn(\n `Unexpected edit type: ${JSON.stringify(edit)}`,\n );\n }\n }\n }\n remappedActionResponse.editedObjectTypes = [...editedObjectTypesSet];\n return remappedActionResponse;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA,OAAO,KAAKA,YAAY,MAAM,0BAA0B;AAExD,SAASC,oCAAoC,QAAQ,iDAAiD;AACtG,SAASC,qBAAqB,QAAQ,kCAAkC;AAIxE,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,qBAAqB,QAAQ,4BAA4B;AAqElE,OAAO,eAAeC,WAAWA,CAU/BC,MAAqB,EACrBC,MAAU,EACVC,UAAc,EACdC,OAAW,GAAG,CAAC,CAAO,EAGtB;EACA,MAAMC,iBAAiB,GAAGT,oCAAoC,CAC5DC,qBAAqB,CAACI,MAAM,EAAE,OAAM;IAAEK,eAAe,EAAE;EAAc,CAAC,CAAC,CAAC,EACxEJ,MACF,CAAC;EACD,IAAIK,KAAK,CAACC,OAAO,CAACL,UAAU,CAAC,EAAE;IAC7B,MAAMM,QAAQ,GAAG,MAAMd,YAAY,CAACe,OAAO,CAACC,UAAU,CACpDN,iBAAiB,EACjB,MAAMJ,MAAM,CAACW,WAAW,EACxBV,MAAM,CAACW,OAAO,EACd;MACEC,QAAQ,EAAEX,UAAU,GAChB,MAAMY,sBAAsB,CAC5BZ,UAAU,EACVF,MAAM,EACN,MAAMA,MAAM,CAACe,gBAAgB,CAACC,mBAAmB,CAACf,MAAM,CAACW,OAAO,CAClE,CAAC,GACC,EAAE;MACNT,OAAO,EAA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Q,CAAC;QACvD;QACAH,oBAAoB,CAACS,GAAG,CAACP,IAAI,CAACQ,UAAU,CAAC;MAC3C,CAAC,MAAM;QACL,IAAIE,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;UACzC;UACAC,OAAO,CAACC,IAAI,CACV,yBAAyBC,IAAI,CAACC,SAAS,CAAChB,IAAI,CAAC,EAC/C,CAAC;QACH;MACF;IACF;IACAX,sBAAsB,CAACQ,iBAAiB,GAAG,CAAC,GAAGC,oBAAoB,CAAC;IACpE,OAAOT,sBAAsB;EAC/B;AACF","ignoreList":[]}
|
|
@@ -17,4 +17,7 @@
|
|
|
17
17
|
export function isMediaReference(o) {
|
|
18
18
|
return typeof o === `object` && typeof o.mimeType === "string" && "reference" in o && typeof o.reference === "object" && o.reference.type === "mediaSetViewItem" && "mediaSetViewItem" in o.reference && typeof o.reference.mediaSetViewItem === "object" && typeof o.reference.mediaSetViewItem.mediaSetRid === "string" && typeof o.reference.mediaSetViewItem.mediaSetViewRid === "string" && typeof o.reference.mediaSetViewItem.mediaItemRid === "string";
|
|
19
19
|
}
|
|
20
|
+
export function isMediaUpload(o) {
|
|
21
|
+
return typeof o === "object" && "path" in o && typeof o.path === "string" && "data" in o && typeof o.data === "object" && o.data instanceof Blob;
|
|
22
|
+
}
|
|
20
23
|
//# sourceMappingURL=mediaUpload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mediaUpload.js","names":["isMediaReference","o","mimeType","reference","type","mediaSetViewItem","mediaSetRid","mediaSetViewRid","mediaItemRid"],"sources":["mediaUpload.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 { MediaReference } from \"@osdk/api\";\n\nexport function isMediaReference(o: any): o is MediaReference {\n return typeof o === `object`\n && typeof o.mimeType === \"string\"\n && \"reference\" in o\n && typeof o.reference === \"object\"\n && o.reference.type === \"mediaSetViewItem\"\n && \"mediaSetViewItem\" in o.reference\n && typeof o.reference.mediaSetViewItem === \"object\"\n && typeof o.reference.mediaSetViewItem.mediaSetRid === \"string\"\n && typeof o.reference.mediaSetViewItem.mediaSetViewRid === \"string\"\n && typeof o.reference.mediaSetViewItem.mediaItemRid === \"string\";\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAO,SAASA,gBAAgBA,CAACC,CAAM,EAAuB;EAC5D,OAAO,OAAOA,CAAC,KAAK,QAAQ,IACvB,OAAOA,CAAC,CAACC,QAAQ,KAAK,QAAQ,IAC9B,WAAW,IAAID,CAAC,IAChB,OAAOA,CAAC,CAACE,SAAS,KAAK,QAAQ,IAC/BF,CAAC,CAACE,SAAS,CAACC,IAAI,KAAK,kBAAkB,IACvC,kBAAkB,IAAIH,CAAC,CAACE,SAAS,IACjC,OAAOF,CAAC,CAACE,SAAS,CAACE,gBAAgB,KAAK,QAAQ,IAChD,OAAOJ,CAAC,CAACE,SAAS,CAACE,gBAAgB,CAACC,WAAW,KAAK,QAAQ,IAC5D,OAAOL,CAAC,CAACE,SAAS,CAACE,gBAAgB,CAACE,eAAe,KAAK,QAAQ,IAChE,OAAON,CAAC,CAACE,SAAS,CAACE,gBAAgB,CAACG,YAAY,KAAK,QAAQ;AACpE","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"mediaUpload.js","names":["isMediaReference","o","mimeType","reference","type","mediaSetViewItem","mediaSetRid","mediaSetViewRid","mediaItemRid","isMediaUpload","path","data","Blob"],"sources":["mediaUpload.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 { MediaReference, MediaUpload } from \"@osdk/api\";\n\nexport function isMediaReference(o: any): o is MediaReference {\n return typeof o === `object`\n && typeof o.mimeType === \"string\"\n && \"reference\" in o\n && typeof o.reference === \"object\"\n && o.reference.type === \"mediaSetViewItem\"\n && \"mediaSetViewItem\" in o.reference\n && typeof o.reference.mediaSetViewItem === \"object\"\n && typeof o.reference.mediaSetViewItem.mediaSetRid === \"string\"\n && typeof o.reference.mediaSetViewItem.mediaSetViewRid === \"string\"\n && typeof o.reference.mediaSetViewItem.mediaItemRid === \"string\";\n}\n\nexport function isMediaUpload(o: any): o is MediaUpload {\n return typeof o === \"object\"\n && \"path\" in o\n && typeof o.path === \"string\"\n && \"data\" in o\n && typeof o.data === \"object\"\n && o.data instanceof Blob;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAO,SAASA,gBAAgBA,CAACC,CAAM,EAAuB;EAC5D,OAAO,OAAOA,CAAC,KAAK,QAAQ,IACvB,OAAOA,CAAC,CAACC,QAAQ,KAAK,QAAQ,IAC9B,WAAW,IAAID,CAAC,IAChB,OAAOA,CAAC,CAACE,SAAS,KAAK,QAAQ,IAC/BF,CAAC,CAACE,SAAS,CAACC,IAAI,KAAK,kBAAkB,IACvC,kBAAkB,IAAIH,CAAC,CAACE,SAAS,IACjC,OAAOF,CAAC,CAACE,SAAS,CAACE,gBAAgB,KAAK,QAAQ,IAChD,OAAOJ,CAAC,CAACE,SAAS,CAACE,gBAAgB,CAACC,WAAW,KAAK,QAAQ,IAC5D,OAAOL,CAAC,CAACE,SAAS,CAACE,gBAAgB,CAACE,eAAe,KAAK,QAAQ,IAChE,OAAON,CAAC,CAACE,SAAS,CAACE,gBAAgB,CAACG,YAAY,KAAK,QAAQ;AACpE;AAEA,OAAO,SAASC,aAAaA,CAACR,CAAM,EAAoB;EACtD,OAAO,OAAOA,CAAC,KAAK,QAAQ,IACvB,MAAM,IAAIA,CAAC,IACX,OAAOA,CAAC,CAACS,IAAI,KAAK,QAAQ,IAC1B,MAAM,IAAIT,CAAC,IACX,OAAOA,CAAC,CAACU,IAAI,KAAK,QAAQ,IAC1BV,CAAC,CAACU,IAAI,YAAYC,IAAI;AAC7B","ignoreList":[]}
|
|
@@ -14,6 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
export const USER_AGENT = `osdk-client/${"2.3.0-beta.
|
|
18
|
-
export const OBSERVABLE_USER_AGENT = `osdk-observable-client/${"2.3.0-beta.
|
|
17
|
+
export const USER_AGENT = `osdk-client/${"2.3.0-beta.8"}`;
|
|
18
|
+
export const OBSERVABLE_USER_AGENT = `osdk-observable-client/${"2.3.0-beta.8"}`;
|
|
19
19
|
//# sourceMappingURL=UserAgent.js.map
|
|
@@ -144,6 +144,8 @@ async function extractRdpDefinitionInternal(clientCtx, objectSet, methodInputObj
|
|
|
144
144
|
definitions: {}
|
|
145
145
|
};
|
|
146
146
|
// We don't have to worry about new object sets being added and doing a runtime break and breaking people since the OSDK is always constructing these.
|
|
147
|
+
case "interfaceLinkSearchAround":
|
|
148
|
+
process.env.NODE_ENV !== "production" ? invariant(false, `Unsupported object set type for Runtime Derived Properties`) : invariant(false);
|
|
147
149
|
default:
|
|
148
150
|
process.env.NODE_ENV !== "production" ? invariant(false, `Unsupported object set type for Runtime Derived Properties`) : invariant(false);
|
|
149
151
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractRdpDefinition.js","names":["invariant","extractRdpDefinition","clientCtx","objectSet","extractRdpDefinitionInternal","undefined","definitions","methodInputObjectType","type","childObjectType","objDef","ontologyProvider","getObjectDefinition","linkDef","links","link","process","env","NODE_ENV","targetType","name","definition","Object","entries","derivedProperties","selectedOrCollectedPropertyType","operation","operationLevelObjectType","properties","selectedPropertyApiName","objectType","interfaceType","objectSets","objectSetTypes","Promise","all","map","os","reduce","acc","keys","length","firstValidChildObjectType","find","every"],"sources":["extractRdpDefinition.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 { ObjectSet } from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport type { DerivedPropertyRuntimeMetadata } from \"../derivedProperties/derivedPropertyRuntimeMetadata.js\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\n\nexport async function extractRdpDefinition(\n clientCtx: MinimalClient,\n objectSet: ObjectSet,\n): Promise<\n DerivedPropertyRuntimeMetadata\n> {\n return (await extractRdpDefinitionInternal(\n clientCtx,\n objectSet,\n undefined,\n )).definitions;\n}\n\n/* @internal\n* Returns a tuple of the derived property definitions and the object type that the derived property is defined on.\n*/\nasync function extractRdpDefinitionInternal(\n clientCtx: MinimalClient,\n objectSet: ObjectSet,\n methodInputObjectType: string | undefined,\n): Promise<\n {\n definitions: DerivedPropertyRuntimeMetadata;\n childObjectType?: string;\n }\n> {\n switch (objectSet.type) {\n case \"searchAround\": {\n const { definitions, childObjectType } =\n await extractRdpDefinitionInternal(\n clientCtx,\n objectSet.objectSet,\n methodInputObjectType,\n );\n\n if (childObjectType === undefined || childObjectType === \"\") {\n return { definitions: {} };\n }\n const objDef = await clientCtx.ontologyProvider.getObjectDefinition(\n childObjectType,\n );\n const linkDef = objDef.links[objectSet.link];\n invariant(linkDef, `Missing link definition for '${objectSet.link}'`);\n return {\n definitions,\n childObjectType: objDef.links[objectSet.link].targetType,\n };\n }\n case \"withProperties\": {\n // These are the definitions and current object type for all object set operations prior to the definition (e.g. filter, pivotTo, etc.)\n const { definitions, childObjectType } =\n await extractRdpDefinitionInternal(\n clientCtx,\n objectSet.objectSet,\n methodInputObjectType,\n );\n if (childObjectType === undefined || childObjectType === \"\") {\n return { definitions: {} };\n }\n\n for (\n const [name, definition] of Object.entries(objectSet.derivedProperties)\n ) {\n if (definition.type !== \"selection\") {\n definitions[name] = {\n selectedOrCollectedPropertyType: undefined,\n definition,\n };\n continue;\n }\n\n switch (definition.operation.type) {\n case \"collectList\":\n case \"collectSet\":\n case \"get\":\n // This is the object set construction for the derived property definition construction. We pass in childObjectType so that when we reach MethodInputObjectSet, we know where to start looking.\n const { childObjectType: operationLevelObjectType } =\n await extractRdpDefinitionInternal(\n clientCtx,\n definition.objectSet,\n childObjectType,\n );\n if (\n operationLevelObjectType === undefined\n || operationLevelObjectType === \"\"\n ) {\n return { definitions: {} };\n }\n const objDef = await clientCtx.ontologyProvider.getObjectDefinition(\n operationLevelObjectType,\n );\n\n definitions[name] = {\n selectedOrCollectedPropertyType:\n objDef.properties[definition.operation.selectedPropertyApiName],\n definition,\n };\n break;\n\n default:\n definitions[name] = {\n selectedOrCollectedPropertyType: undefined,\n definition,\n };\n }\n }\n return { definitions, childObjectType };\n }\n case \"methodInput\":\n return { definitions: {}, childObjectType: methodInputObjectType };\n case \"base\":\n return { definitions: {}, childObjectType: objectSet.objectType };\n case \"interfaceBase\":\n return { definitions: {}, childObjectType: objectSet.interfaceType };\n case \"filter\":\n case \"asBaseObjectTypes\":\n case \"asType\":\n case \"nearestNeighbors\":\n return extractRdpDefinitionInternal(\n clientCtx,\n objectSet.objectSet,\n methodInputObjectType,\n );\n // These will throw in OSS so we should throw here so no request is made\n case \"intersect\":\n case \"subtract\":\n case \"union\":\n const objectSets = objectSet.objectSets;\n const objectSetTypes = await Promise.all(\n objectSets.map((os) =>\n extractRdpDefinitionInternal(\n clientCtx,\n os,\n methodInputObjectType,\n )\n ),\n );\n\n const definitions = objectSetTypes.reduce(\n (acc, { definitions }) => ({ ...acc, ...definitions }),\n {},\n );\n invariant(\n Object.keys(definitions).length === 0,\n \"Object sets combined using intersect, subtract, or union must not contain any derived property definitions\",\n );\n\n const firstValidChildObjectType = objectSetTypes.find(\n ({ childObjectType }) => childObjectType != null,\n )?.childObjectType;\n invariant(\n objectSetTypes.every(\n ({ childObjectType }) =>\n childObjectType === firstValidChildObjectType\n || childObjectType == null,\n ),\n \"All object sets in an intersect, subtract, or union must have the same child object type\",\n );\n\n return {\n definitions: {},\n childObjectType: firstValidChildObjectType,\n };\n case \"static\":\n case \"reference\":\n // Static and reference object sets are always intersected with a base object set, so we can just return no child object type.\n return { definitions: {} };\n // We don't have to worry about new object sets being added and doing a runtime break and breaking people since the OSDK is always constructing these.\n default:\n const _: never = objectSet;\n invariant(\n false,\n `Unsupported object set type for Runtime Derived Properties`,\n );\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,SAAS,MAAM,gBAAgB;AAItC,OAAO,eAAeC,oBAAoBA,CACxCC,SAAwB,EACxBC,SAAoB,EAGpB;EACA,OAAO,CAAC,MAAMC,4BAA4B,CACxCF,SAAS,EACTC,SAAS,EACTE,SACF,CAAC,EAAEC,WAAW;AAChB;;AAEA;AACA;AACA;AACA,eAAeF,4BAA4BA,CACzCF,SAAwB,EACxBC,SAAoB,EACpBI,qBAAyC,EAMzC;EACA,QAAQJ,SAAS,CAACK,IAAI;IAC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AK,OAAO;MACV,MAAMyB,UAAU,GAAG7B,SAAS,CAAC6B,UAAU;MACvC,MAAMC,cAAc,GAAG,MAAMC,OAAO,CAACC,GAAG,CACtCH,UAAU,CAACI,GAAG,CAAEC,EAAE,IAChBjC,4BAA4B,CAC1BF,SAAS,EACTmC,EAAE,EACF9B,qBACF,CACF,CACF,CAAC;MAED,MAAMD,WAAW,GAAG2B,cAAc,CAACK,MAAM,CACvC,CAACC,GAAG,EAAE;QAAEjC;MAAY,CAAC,MAAM;QAAE,GAAGiC,GAAG;QAAE,GAAGjC;MAAY,CAAC,CAAC,EACtD,CAAC,CACH,CAAC;MACD,EACEgB,MAAM,CAACkB,IAAI,CAAClC,WAAW,CAAC,CAACmC,MAAM,KAAK,CAAC,IAAAzB,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBADvClB,SAAS,QAEP,4GAA4G,IAF9GA,SAAS;MAKT,MAAM0C,yBAAyB,GAAGT,cAAc,CAACU,IAAI,CACnD,CAAC;QAAElC;MAAgB,CAAC,KAAKA,eAAe,IAAI,IAC9C,CAAC,EAAEA,eAAe;MAClB,CACEwB,cAAc,CAACW,KAAK,CAClB,CAAC;QAAEnC;MAAgB,CAAC,KAClBA,eAAe,KAAKiC,yBAAyB,IAC1CjC,eAAe,IAAI,IAC1B,CAAC,GAAAO,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBALHlB,SAAS,QAMP,0FAA0F,IAN5FA,SAAS;MAST,OAAO;QACLM,WAAW,EAAE,CAAC,CAAC;QACfG,eAAe,EAAEiC;MACnB,CAAC;IACH,KAAK,QAAQ;IACb,KAAK,WAAW;MACd;MACA,OAAO;QAAEpC,WAAW,EAAE,CAAC;MAAE,CAAC;IAC5B;IACA;MAEEU,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAAlB,SAAS,QAEP,4DAA4D,IAF9DA,SAAS;EAIb;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"extractRdpDefinition.js","names":["invariant","extractRdpDefinition","clientCtx","objectSet","extractRdpDefinitionInternal","undefined","definitions","methodInputObjectType","type","childObjectType","objDef","ontologyProvider","getObjectDefinition","linkDef","links","link","process","env","NODE_ENV","targetType","name","definition","Object","entries","derivedProperties","selectedOrCollectedPropertyType","operation","operationLevelObjectType","properties","selectedPropertyApiName","objectType","interfaceType","objectSets","objectSetTypes","Promise","all","map","os","reduce","acc","keys","length","firstValidChildObjectType","find","every"],"sources":["extractRdpDefinition.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 { ObjectSet } from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport type { DerivedPropertyRuntimeMetadata } from \"../derivedProperties/derivedPropertyRuntimeMetadata.js\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\n\nexport async function extractRdpDefinition(\n clientCtx: MinimalClient,\n objectSet: ObjectSet,\n): Promise<\n DerivedPropertyRuntimeMetadata\n> {\n return (await extractRdpDefinitionInternal(\n clientCtx,\n objectSet,\n undefined,\n )).definitions;\n}\n\n/* @internal\n* Returns a tuple of the derived property definitions and the object type that the derived property is defined on.\n*/\nasync function extractRdpDefinitionInternal(\n clientCtx: MinimalClient,\n objectSet: ObjectSet,\n methodInputObjectType: string | undefined,\n): Promise<\n {\n definitions: DerivedPropertyRuntimeMetadata;\n childObjectType?: string;\n }\n> {\n switch (objectSet.type) {\n case \"searchAround\": {\n const { definitions, childObjectType } =\n await extractRdpDefinitionInternal(\n clientCtx,\n objectSet.objectSet,\n methodInputObjectType,\n );\n\n if (childObjectType === undefined || childObjectType === \"\") {\n return { definitions: {} };\n }\n const objDef = await clientCtx.ontologyProvider.getObjectDefinition(\n childObjectType,\n );\n const linkDef = objDef.links[objectSet.link];\n invariant(linkDef, `Missing link definition for '${objectSet.link}'`);\n return {\n definitions,\n childObjectType: objDef.links[objectSet.link].targetType,\n };\n }\n case \"withProperties\": {\n // These are the definitions and current object type for all object set operations prior to the definition (e.g. filter, pivotTo, etc.)\n const { definitions, childObjectType } =\n await extractRdpDefinitionInternal(\n clientCtx,\n objectSet.objectSet,\n methodInputObjectType,\n );\n if (childObjectType === undefined || childObjectType === \"\") {\n return { definitions: {} };\n }\n\n for (\n const [name, definition] of Object.entries(objectSet.derivedProperties)\n ) {\n if (definition.type !== \"selection\") {\n definitions[name] = {\n selectedOrCollectedPropertyType: undefined,\n definition,\n };\n continue;\n }\n\n switch (definition.operation.type) {\n case \"collectList\":\n case \"collectSet\":\n case \"get\":\n // This is the object set construction for the derived property definition construction. We pass in childObjectType so that when we reach MethodInputObjectSet, we know where to start looking.\n const { childObjectType: operationLevelObjectType } =\n await extractRdpDefinitionInternal(\n clientCtx,\n definition.objectSet,\n childObjectType,\n );\n if (\n operationLevelObjectType === undefined\n || operationLevelObjectType === \"\"\n ) {\n return { definitions: {} };\n }\n const objDef = await clientCtx.ontologyProvider.getObjectDefinition(\n operationLevelObjectType,\n );\n\n definitions[name] = {\n selectedOrCollectedPropertyType:\n objDef.properties[definition.operation.selectedPropertyApiName],\n definition,\n };\n break;\n\n default:\n definitions[name] = {\n selectedOrCollectedPropertyType: undefined,\n definition,\n };\n }\n }\n return { definitions, childObjectType };\n }\n case \"methodInput\":\n return { definitions: {}, childObjectType: methodInputObjectType };\n case \"base\":\n return { definitions: {}, childObjectType: objectSet.objectType };\n case \"interfaceBase\":\n return { definitions: {}, childObjectType: objectSet.interfaceType };\n case \"filter\":\n case \"asBaseObjectTypes\":\n case \"asType\":\n case \"nearestNeighbors\":\n return extractRdpDefinitionInternal(\n clientCtx,\n objectSet.objectSet,\n methodInputObjectType,\n );\n // These will throw in OSS so we should throw here so no request is made\n case \"intersect\":\n case \"subtract\":\n case \"union\":\n const objectSets = objectSet.objectSets;\n const objectSetTypes = await Promise.all(\n objectSets.map((os) =>\n extractRdpDefinitionInternal(\n clientCtx,\n os,\n methodInputObjectType,\n )\n ),\n );\n\n const definitions = objectSetTypes.reduce(\n (acc, { definitions }) => ({ ...acc, ...definitions }),\n {},\n );\n invariant(\n Object.keys(definitions).length === 0,\n \"Object sets combined using intersect, subtract, or union must not contain any derived property definitions\",\n );\n\n const firstValidChildObjectType = objectSetTypes.find(\n ({ childObjectType }) => childObjectType != null,\n )?.childObjectType;\n invariant(\n objectSetTypes.every(\n ({ childObjectType }) =>\n childObjectType === firstValidChildObjectType\n || childObjectType == null,\n ),\n \"All object sets in an intersect, subtract, or union must have the same child object type\",\n );\n\n return {\n definitions: {},\n childObjectType: firstValidChildObjectType,\n };\n case \"static\":\n case \"reference\":\n // Static and reference object sets are always intersected with a base object set, so we can just return no child object type.\n return { definitions: {} };\n // We don't have to worry about new object sets being added and doing a runtime break and breaking people since the OSDK is always constructing these.\n case \"interfaceLinkSearchAround\":\n invariant(\n false,\n `Unsupported object set type for Runtime Derived Properties`,\n );\n default:\n const _: never = objectSet;\n invariant(\n false,\n `Unsupported object set type for Runtime Derived Properties`,\n );\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,SAAS,MAAM,gBAAgB;AAItC,OAAO,eAAeC,oBAAoBA,CACxCC,SAAwB,EACxBC,SAAoB,EAGpB;EACA,OAAO,CAAC,MAAMC,4BAA4B,CACxCF,SAAS,EACTC,SAAS,EACTE,SACF,CAAC,EAAEC,WAAW;AAChB;;AAEA;AACA;AACA;AACA,eAAeF,4BAA4BA,CACzCF,SAAwB,EACxBC,SAAoB,EACpBI,qBAAyC,EAMzC;EACA,QAAQJ,SAAS,CAACK,IAAI;IACp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4DAA4D,IAF9DA,SAAS;EAIb;AACF","ignoreList":[]}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import * as OntologiesV2 from "@osdk/foundry.ontologies";
|
|
18
18
|
import { isAttachmentFile, isAttachmentUpload } from "../object/AttachmentUpload.js";
|
|
19
|
-
import { isMediaReference } from "../object/mediaUpload.js";
|
|
19
|
+
import { isMediaReference, isMediaUpload } from "../object/mediaUpload.js";
|
|
20
20
|
import { getWireObjectSet, isObjectSet } from "../objectSet/createObjectSet.js";
|
|
21
21
|
import { isInterfaceActionParam } from "./interfaceUtils.js";
|
|
22
22
|
import { isObjectSpecifiersObject } from "./isObjectSpecifiersObject.js";
|
|
@@ -30,7 +30,7 @@ import { isWireObjectSet } from "./WireObjectSet.js";
|
|
|
30
30
|
* @see DataValue for the expected payloads
|
|
31
31
|
* @internal
|
|
32
32
|
*/
|
|
33
|
-
export async function toDataValue(value, client) {
|
|
33
|
+
export async function toDataValue(value, client, actionMetadata) {
|
|
34
34
|
if (value == null) {
|
|
35
35
|
// typeof null is 'object' so do this first
|
|
36
36
|
return value;
|
|
@@ -42,11 +42,11 @@ export async function toDataValue(value, client) {
|
|
|
42
42
|
if (values.some(dataValue => isAttachmentUpload(dataValue) || isAttachmentFile(dataValue))) {
|
|
43
43
|
const converted = [];
|
|
44
44
|
for (const value of values) {
|
|
45
|
-
converted.push(await toDataValue(value, client));
|
|
45
|
+
converted.push(await toDataValue(value, client, actionMetadata));
|
|
46
46
|
}
|
|
47
47
|
return converted;
|
|
48
48
|
}
|
|
49
|
-
const promiseArray = Array.from(value, async innerValue => await toDataValue(innerValue, client));
|
|
49
|
+
const promiseArray = Array.from(value, async innerValue => await toDataValue(innerValue, client, actionMetadata));
|
|
50
50
|
return Promise.all(promiseArray);
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -55,24 +55,34 @@ export async function toDataValue(value, client) {
|
|
|
55
55
|
const attachment = await OntologiesV2.Attachments.upload(client, value.data, {
|
|
56
56
|
filename: value.name
|
|
57
57
|
});
|
|
58
|
-
return await toDataValue(attachment.rid, client);
|
|
58
|
+
return await toDataValue(attachment.rid, client, actionMetadata);
|
|
59
59
|
}
|
|
60
60
|
if (isAttachmentFile(value)) {
|
|
61
61
|
const attachment = await OntologiesV2.Attachments.upload(client, value, {
|
|
62
62
|
filename: value.name
|
|
63
63
|
});
|
|
64
|
-
return await toDataValue(attachment.rid, client);
|
|
64
|
+
return await toDataValue(attachment.rid, client, actionMetadata);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// new media item upload interface, very similar to how attachments work above
|
|
68
|
+
|
|
69
|
+
if (isMediaUpload(value)) {
|
|
70
|
+
const mediaRef = await OntologiesV2.MediaReferenceProperties.uploadMedia(client, await client.ontologyRid, actionMetadata.apiName, value.data, {
|
|
71
|
+
mediaItemPath: value.path,
|
|
72
|
+
preview: true
|
|
73
|
+
});
|
|
74
|
+
return await toDataValue(mediaRef, client, actionMetadata);
|
|
65
75
|
}
|
|
66
76
|
|
|
67
77
|
// objects just send the JSON'd primaryKey
|
|
68
78
|
if (isOntologyObjectV2(value)) {
|
|
69
|
-
return await toDataValue(value.__primaryKey, client);
|
|
79
|
+
return await toDataValue(value.__primaryKey, client, actionMetadata);
|
|
70
80
|
}
|
|
71
81
|
if (isObjectSpecifiersObject(value)) {
|
|
72
|
-
return await toDataValue(value.$primaryKey, client);
|
|
82
|
+
return await toDataValue(value.$primaryKey, client, actionMetadata);
|
|
73
83
|
}
|
|
74
84
|
if (isPoint(value)) {
|
|
75
|
-
return await toDataValue(`${value.coordinates[1]},${value.coordinates[0]}`, client);
|
|
85
|
+
return await toDataValue(`${value.coordinates[1]},${value.coordinates[0]}`, client, actionMetadata);
|
|
76
86
|
}
|
|
77
87
|
|
|
78
88
|
// object set (the rid as a string (passes through the last return), or the ObjectSet definition directly)
|
|
@@ -100,7 +110,7 @@ export async function toDataValue(value, client) {
|
|
|
100
110
|
if (typeof value === "object") {
|
|
101
111
|
return Object.entries(value).reduce(async (promisedAcc, [key, structValue]) => {
|
|
102
112
|
const acc = await promisedAcc;
|
|
103
|
-
acc[key] = await toDataValue(structValue, client);
|
|
113
|
+
acc[key] = await toDataValue(structValue, client, actionMetadata);
|
|
104
114
|
return acc;
|
|
105
115
|
}, Promise.resolve({}));
|
|
106
116
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toDataValue.js","names":["OntologiesV2","isAttachmentFile","isAttachmentUpload","isMediaReference","getWireObjectSet","isObjectSet","isInterfaceActionParam","isObjectSpecifiersObject","isOntologyObjectV2","isPoint","isWireObjectSet","toDataValue","value","client","Array","isArray","Set","values","from","some","dataValue","converted","push","promiseArray","innerValue","Promise","all","attachment","Attachments","upload","data","filename","name","rid","__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 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 } 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): Promise<DataValue> {\n if (value == null) {\n // typeof null is 'object' so do this first\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));\n }\n return converted;\n }\n const promiseArray = Array.from(\n value,\n async (innerValue)
|
|
1
|
+
{"version":3,"file":"toDataValue.js","names":["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","MediaReferenceProperties","uploadMedia","ontologyRid","apiName","mediaItemPath","path","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 { 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 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 OntologiesV2.MediaReferenceProperties\n .uploadMedia(\n client,\n await client.ontologyRid,\n actionMetadata.apiName,\n value.data,\n {\n mediaItemPath: value.path,\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;;AAIA,OAAO,KAAKA,YAAY,MAAM,0BAA0B;AAExD,SACEC,gBAAgB,EAChBC,kBAAkB,QACb,+BAA+B;AACtC,SAASC,gBAAgB,EAAEC,aAAa,QAAQ,0BAA0B;AAC1E,SAASC,gBAAgB,EAAEC,WAAW,QAAQ,iCAAiC;AAC/E,SAASC,sBAAsB,QAAQ,q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