@osdk/client 2.2.1 → 2.3.0-beta.10
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 +94 -134
- package/build/browser/Client.js +1 -1
- package/build/browser/Client.js.map +1 -1
- package/build/browser/__unstable/createBulkLinksAsyncIterFactory.js +6 -1
- package/build/browser/__unstable/createBulkLinksAsyncIterFactory.js.map +1 -1
- 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/createClient.js +8 -1
- package/build/browser/createClient.js.map +1 -1
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +41 -1
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.test.js +145 -12
- package/build/browser/derivedProperties/createWithPropertiesObjectSet.test.js.map +1 -1
- package/build/browser/derivedProperties/derivedPropertyDefinitionFactory.js +93 -0
- package/build/browser/derivedProperties/derivedPropertyDefinitionFactory.js.map +1 -0
- package/build/browser/logger/BaseLogger.js +1 -1
- package/build/browser/logger/BaseLogger.js.map +1 -1
- package/build/browser/object/fetchPage.js +9 -7
- package/build/browser/object/fetchPage.js.map +1 -1
- package/build/browser/object/mediaUpload.js +3 -0
- package/build/browser/object/mediaUpload.js.map +1 -1
- package/build/browser/objectSet/ObjectSet.test.js +85 -106
- package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
- package/build/browser/objectSet/createObjectSet.js +1 -1
- package/build/browser/objectSet/createObjectSet.js.map +1 -1
- package/build/browser/observable/ObservableClient.js +17 -1
- package/build/browser/observable/ObservableClient.js.map +1 -1
- package/build/browser/observable/OptimisticBuilder.js.map +1 -1
- package/build/browser/observable/internal/ActionApplication.js +31 -30
- package/build/browser/observable/internal/ActionApplication.js.map +1 -1
- package/build/browser/observable/internal/Changes.js +5 -1
- package/build/browser/observable/internal/Changes.js.map +1 -1
- package/build/browser/observable/internal/ListQuery.js +24 -22
- package/build/browser/observable/internal/ListQuery.js.map +1 -1
- package/build/browser/observable/internal/ObjectQuery.js +30 -1
- package/build/browser/observable/internal/ObjectQuery.js.map +1 -1
- package/build/browser/observable/internal/ObservableClientImpl.js +1 -2
- package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/browser/observable/internal/OptimisticJob.js +8 -0
- package/build/browser/observable/internal/OptimisticJob.js.map +1 -1
- package/build/browser/observable/internal/Query.js +2 -2
- package/build/browser/observable/internal/Query.js.map +1 -1
- package/build/browser/observable/internal/Store.js +4 -0
- package/build/browser/observable/internal/Store.js.map +1 -1
- package/build/browser/observable/internal/Store.test.js +45 -5
- package/build/browser/observable/internal/Store.test.js.map +1 -1
- package/build/browser/observable/internal/testUtils.js.map +1 -1
- package/build/browser/observable/internal/tombstone.js +18 -0
- package/build/browser/observable/internal/tombstone.js.map +1 -0
- package/build/browser/public/internal.js +1 -0
- package/build/browser/public/internal.js.map +1 -1
- package/build/browser/public-utils/hydrateObjectSetFromObjectRids.js +39 -0
- package/build/browser/public-utils/hydrateObjectSetFromObjectRids.js.map +1 -0
- package/build/browser/queries/applyQuery.js +8 -4
- package/build/browser/queries/applyQuery.js.map +1 -1
- package/build/browser/util/UserAgent.js +2 -1
- package/build/browser/util/UserAgent.js.map +1 -1
- 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-VZ57PNLC.cjs +1808 -0
- package/build/cjs/chunk-VZ57PNLC.cjs.map +1 -0
- package/build/cjs/{chunk-LPYAXRWJ.cjs → chunk-YGJRXE4F.cjs} +757 -36
- package/build/cjs/chunk-YGJRXE4F.cjs.map +1 -0
- package/build/cjs/index.cjs +16 -1764
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +4 -3
- package/build/cjs/public/internal.cjs +22 -8
- package/build/cjs/public/internal.cjs.map +1 -1
- package/build/cjs/public/internal.d.cts +10 -1
- package/build/cjs/public/unstable-do-not-use.cjs +182 -123
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +2 -1
- package/build/esm/Client.js +1 -1
- package/build/esm/Client.js.map +1 -1
- package/build/esm/__unstable/createBulkLinksAsyncIterFactory.js +6 -1
- package/build/esm/__unstable/createBulkLinksAsyncIterFactory.js.map +1 -1
- 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/createClient.js +8 -1
- package/build/esm/createClient.js.map +1 -1
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +41 -1
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.test.js +145 -12
- package/build/esm/derivedProperties/createWithPropertiesObjectSet.test.js.map +1 -1
- package/build/esm/derivedProperties/derivedPropertyDefinitionFactory.js +93 -0
- package/build/esm/derivedProperties/derivedPropertyDefinitionFactory.js.map +1 -0
- package/build/esm/logger/BaseLogger.js +1 -1
- package/build/esm/logger/BaseLogger.js.map +1 -1
- package/build/esm/object/fetchPage.js +9 -7
- package/build/esm/object/fetchPage.js.map +1 -1
- package/build/esm/object/mediaUpload.js +3 -0
- package/build/esm/object/mediaUpload.js.map +1 -1
- package/build/esm/objectSet/ObjectSet.test.js +85 -106
- package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
- package/build/esm/objectSet/createObjectSet.js +1 -1
- package/build/esm/objectSet/createObjectSet.js.map +1 -1
- package/build/esm/observable/ObservableClient.js +17 -1
- package/build/esm/observable/ObservableClient.js.map +1 -1
- package/build/esm/observable/OptimisticBuilder.js.map +1 -1
- package/build/esm/observable/internal/ActionApplication.js +31 -30
- package/build/esm/observable/internal/ActionApplication.js.map +1 -1
- package/build/esm/observable/internal/Changes.js +5 -1
- package/build/esm/observable/internal/Changes.js.map +1 -1
- package/build/esm/observable/internal/ListQuery.js +24 -22
- package/build/esm/observable/internal/ListQuery.js.map +1 -1
- package/build/esm/observable/internal/ObjectQuery.js +30 -1
- package/build/esm/observable/internal/ObjectQuery.js.map +1 -1
- package/build/esm/observable/internal/ObservableClientImpl.js +1 -2
- package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/esm/observable/internal/OptimisticJob.js +8 -0
- package/build/esm/observable/internal/OptimisticJob.js.map +1 -1
- package/build/esm/observable/internal/Query.js +2 -2
- package/build/esm/observable/internal/Query.js.map +1 -1
- package/build/esm/observable/internal/Store.js +4 -0
- package/build/esm/observable/internal/Store.js.map +1 -1
- package/build/esm/observable/internal/Store.test.js +45 -5
- package/build/esm/observable/internal/Store.test.js.map +1 -1
- package/build/esm/observable/internal/testUtils.js.map +1 -1
- package/build/esm/observable/internal/tombstone.js +18 -0
- package/build/esm/observable/internal/tombstone.js.map +1 -0
- package/build/esm/public/internal.js +1 -0
- package/build/esm/public/internal.js.map +1 -1
- package/build/esm/public-utils/hydrateObjectSetFromObjectRids.js +39 -0
- package/build/esm/public-utils/hydrateObjectSetFromObjectRids.js.map +1 -0
- package/build/esm/queries/applyQuery.js +8 -4
- package/build/esm/queries/applyQuery.js.map +1 -1
- package/build/esm/util/UserAgent.js +2 -1
- package/build/esm/util/UserAgent.js.map +1 -1
- 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/Client.d.ts +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/createClient.d.ts.map +1 -1
- package/build/types/derivedProperties/derivedPropertyDefinitionFactory.d.ts +1 -0
- package/build/types/derivedProperties/derivedPropertyDefinitionFactory.d.ts.map +1 -0
- package/build/types/object/mediaUpload.d.ts +2 -1
- package/build/types/object/mediaUpload.d.ts.map +1 -1
- package/build/types/observable/ObservableClient.d.ts +2 -2
- package/build/types/observable/ObservableClient.d.ts.map +1 -1
- package/build/types/observable/OptimisticBuilder.d.ts +1 -0
- package/build/types/observable/OptimisticBuilder.d.ts.map +1 -1
- package/build/types/observable/internal/ActionApplication.d.ts +1 -1
- package/build/types/observable/internal/ActionApplication.d.ts.map +1 -1
- package/build/types/observable/internal/Changes.d.ts +2 -0
- package/build/types/observable/internal/Changes.d.ts.map +1 -1
- package/build/types/observable/internal/ListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/ObjectQuery.d.ts +1 -0
- package/build/types/observable/internal/ObjectQuery.d.ts.map +1 -1
- package/build/types/observable/internal/OptimisticJob.d.ts.map +1 -1
- package/build/types/observable/internal/Store.d.ts +2 -1
- package/build/types/observable/internal/Store.d.ts.map +1 -1
- package/build/types/observable/internal/testUtils.d.ts +1 -1
- package/build/types/observable/internal/testUtils.d.ts.map +1 -1
- package/build/types/observable/internal/tombstone.d.ts +1 -0
- package/build/types/observable/internal/tombstone.d.ts.map +1 -0
- package/build/types/public/internal.d.ts +1 -0
- package/build/types/public/internal.d.ts.map +1 -1
- package/build/types/public-utils/hydrateObjectSetFromObjectRids.d.ts +10 -0
- package/build/types/public-utils/hydrateObjectSetFromObjectRids.d.ts.map +1 -0
- package/build/types/queries/applyQuery.d.ts.map +1 -1
- package/build/types/util/UserAgent.d.ts +1 -0
- package/build/types/util/UserAgent.d.ts.map +1 -1
- package/package.json +14 -14
- package/build/cjs/chunk-LPYAXRWJ.cjs.map +0 -1
- package/build/cjs/chunk-T4NIFYZS.cjs +0 -14
- package/build/cjs/chunk-T4NIFYZS.cjs.map +0 -1
- package/build/cjs/chunk-UCW7RLKM.cjs +0 -615
- package/build/cjs/chunk-UCW7RLKM.cjs.map +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export const tombstone = undefined;
|
|
18
|
+
//# sourceMappingURL=tombstone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tombstone.js","names":["tombstone","undefined"],"sources":["tombstone.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const tombstone: undefined = undefined;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMA,SAAoB,GAAGC,SAAS","ignoreList":[]}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
export { createAndFetchTempObjectSetRid } from "../public-utils/createAndFetchTempObjectSetRid.js";
|
|
18
18
|
export { hydrateAttachmentFromRid } from "../public-utils/hydrateAttachmentFromRid.js";
|
|
19
|
+
export { hydrateObjectSetFromObjectRids } from "../public-utils/hydrateObjectSetFromObjectRids.js";
|
|
19
20
|
export { hydrateObjectSetFromRid } from "../public-utils/hydrateObjectSetFromRid.js";
|
|
20
21
|
export { BrowserLogger } from "../logger/BrowserLogger.js";
|
|
21
22
|
export { MinimalLogger } from "../logger/MinimalLogger.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","names":["createAndFetchTempObjectSetRid","hydrateAttachmentFromRid","hydrateObjectSetFromRid","BrowserLogger","MinimalLogger"],"sources":["internal.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { createAndFetchTempObjectSetRid } from \"../public-utils/createAndFetchTempObjectSetRid.js\";\nexport { hydrateAttachmentFromRid } from \"../public-utils/hydrateAttachmentFromRid.js\";\nexport { hydrateObjectSetFromRid } from \"../public-utils/hydrateObjectSetFromRid.js\";\n\nexport { BrowserLogger } from \"../logger/BrowserLogger.js\";\nexport { MinimalLogger } from \"../logger/MinimalLogger.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,8BAA8B,QAAQ,mDAAmD;AAClG,SAASC,wBAAwB,QAAQ,6CAA6C;AACtF,SAASC,uBAAuB,QAAQ,4CAA4C;AAEpF,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,aAAa,QAAQ,4BAA4B","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"internal.js","names":["createAndFetchTempObjectSetRid","hydrateAttachmentFromRid","hydrateObjectSetFromObjectRids","hydrateObjectSetFromRid","BrowserLogger","MinimalLogger"],"sources":["internal.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { createAndFetchTempObjectSetRid } from \"../public-utils/createAndFetchTempObjectSetRid.js\";\nexport { hydrateAttachmentFromRid } from \"../public-utils/hydrateAttachmentFromRid.js\";\nexport { hydrateObjectSetFromObjectRids } from \"../public-utils/hydrateObjectSetFromObjectRids.js\";\nexport { hydrateObjectSetFromRid } from \"../public-utils/hydrateObjectSetFromRid.js\";\n\nexport { BrowserLogger } from \"../logger/BrowserLogger.js\";\nexport { MinimalLogger } from \"../logger/MinimalLogger.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,8BAA8B,QAAQ,mDAAmD;AAClG,SAASC,wBAAwB,QAAQ,6CAA6C;AACtF,SAASC,8BAA8B,QAAQ,mDAAmD;AAClG,SAASC,uBAAuB,QAAQ,4CAA4C;AAEpF,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,aAAa,QAAQ,4BAA4B","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { additionalContext } from "../Client.js";
|
|
18
|
+
import { createObjectSet } from "../objectSet/createObjectSet.js";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Creates an OSDK object set from object RIDs.
|
|
22
|
+
* @param client - An OSDK client.
|
|
23
|
+
* @param definition - An OSDK object or interface definition.
|
|
24
|
+
* @param rids - An array of object RIDs.
|
|
25
|
+
* @returns An OSDK object set.
|
|
26
|
+
*/
|
|
27
|
+
export function hydrateObjectSetFromObjectRids(client, definition, rids) {
|
|
28
|
+
return createObjectSet(definition, client[additionalContext], {
|
|
29
|
+
type: "intersect",
|
|
30
|
+
objectSets: [{
|
|
31
|
+
type: "base",
|
|
32
|
+
objectType: definition.apiName
|
|
33
|
+
}, {
|
|
34
|
+
type: "static",
|
|
35
|
+
objects: rids
|
|
36
|
+
}]
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=hydrateObjectSetFromObjectRids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydrateObjectSetFromObjectRids.js","names":["additionalContext","createObjectSet","hydrateObjectSetFromObjectRids","client","definition","rids","type","objectSets","objectType","apiName","objects"],"sources":["hydrateObjectSetFromObjectRids.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 { ObjectOrInterfaceDefinition, ObjectSet } from \"@osdk/api\";\nimport type { Client } from \"../Client.js\";\nimport { additionalContext } from \"../Client.js\";\nimport { createObjectSet } from \"../objectSet/createObjectSet.js\";\n\n/**\n * Creates an OSDK object set from object RIDs.\n * @param client - An OSDK client.\n * @param definition - An OSDK object or interface definition.\n * @param rids - An array of object RIDs.\n * @returns An OSDK object set.\n */\nexport function hydrateObjectSetFromObjectRids<\n T extends ObjectOrInterfaceDefinition,\n>(client: Client, definition: T, rids: string[]): ObjectSet<T> {\n return createObjectSet(definition, client[additionalContext], {\n type: \"intersect\",\n objectSets: [\n {\n type: \"base\",\n objectType: definition.apiName,\n },\n {\n type: \"static\",\n objects: rids,\n },\n ],\n });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,iBAAiB,QAAQ,cAAc;AAChD,SAASC,eAAe,QAAQ,iCAAiC;;AAEjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,8BAA8BA,CAE5CC,MAAc,EAAEC,UAAa,EAAEC,IAAc,EAAgB;EAC7D,OAAOJ,eAAe,CAACG,UAAU,EAAED,MAAM,CAACH,iBAAiB,CAAC,EAAE;IAC5DM,IAAI,EAAE,WAAW;IACjBC,UAAU,EAAE,CACV;MACED,IAAI,EAAE,MAAM;MACZE,UAAU,EAAEJ,UAAU,CAACK;IACzB,CAAC,EACD;MACEH,IAAI,EAAE,QAAQ;MACdI,OAAO,EAAEL;IACX,CAAC;EAEL,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -190,8 +190,10 @@ async function getRequiredDefinitions(dataType, client) {
|
|
|
190
190
|
}
|
|
191
191
|
case "map":
|
|
192
192
|
{
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
const types = [dataType.keyType, dataType.valueType];
|
|
194
|
+
const allDefs = await Promise.all(types.map(value => getRequiredDefinitions(value, client)));
|
|
195
|
+
for (const defs of allDefs) {
|
|
196
|
+
for (const [type, objectDef] of defs) {
|
|
195
197
|
result.set(type, objectDef);
|
|
196
198
|
}
|
|
197
199
|
}
|
|
@@ -199,8 +201,10 @@ async function getRequiredDefinitions(dataType, client) {
|
|
|
199
201
|
}
|
|
200
202
|
case "struct":
|
|
201
203
|
{
|
|
202
|
-
|
|
203
|
-
|
|
204
|
+
const structValues = Object.values(dataType.struct);
|
|
205
|
+
const allDefs = await Promise.all(structValues.map(value => getRequiredDefinitions(value, client)));
|
|
206
|
+
for (const defs of allDefs) {
|
|
207
|
+
for (const [type, objectDef] of defs) {
|
|
204
208
|
result.set(type, objectDef);
|
|
205
209
|
}
|
|
206
210
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyQuery.js","names":["OntologiesV2","invariant","createObjectSet","hydrateAttachmentFromRidInternal","addUserAgentAndRequestContextHeaders","augmentRequestContext","createObjectSpecifierFromPrimaryKey","toDataValueQueries","applyQuery","client","query","params","qd","ontologyProvider","getQueryDefinition","apiName","isFixedVersion","version","undefined","response","Queries","execute","finalMethodCall","ontologyRid","parameters","remapQueryParams","objectOutputDefs","getRequiredDefinitions","output","remappedResponse","remapQueryResponse","value","paramTypes","parameterMap","key","Object","entries","responseDataType","responseValue","definitions","nullable","Error","multiplicity","withoutMultiplicity","i","length","type","set","def","get","object","createQueryObjectResponse","objectSet","objectSets","objectType","reference","subtype","struct","requiresConversion","map","Array","isArray","process","env","NODE_ENV","entry","keyType","getObjectSpecifier","valueType","result","groups","push","subResult","subKey","dataType","Map","objectDef","getObjectDefinition","values","some","primaryKey","objectTypeApiName","$apiName","$title","$objectType","$primaryKey","$objectSpecifier"],"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 ObjectOrInterfaceDefinition,\n ObjectTypeDefinition,\n OsdkBase,\n PrimaryKeyType,\n QueryDataTypeDefinition,\n QueryDefinition,\n QueryParameterDefinition,\n} from \"@osdk/api\";\nimport type { DataValue } from \"@osdk/foundry.ontologies\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\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 { createObjectSpecifierFromPrimaryKey } 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 const qd = await client.ontologyProvider.getQueryDefinition(\n query.apiName,\n query.isFixedVersion ? query.version : undefined,\n );\n\n const response = await OntologiesV2.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 qd.parameters,\n )\n : {},\n },\n { version: qd.version },\n );\n const objectOutputDefs = await getRequiredDefinitions(qd.output, client);\n const remappedResponse = await remapQueryResponse(\n client,\n qd.output,\n response.value,\n objectOutputDefs,\n );\n return remappedResponse as QueryReturnType<CompileTimeMetadata<QD>[\"output\"]>;\n}\n\nasync 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\nasync 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 if (\n responseDataType.multiplicity != null\n && responseDataType.multiplicity\n ) {\n const withoutMultiplicity = { ...responseDataType, multiplicity: false };\n for (let i = 0; i < responseValue.length; i++) {\n responseValue[i] = await remapQueryResponse(\n client,\n withoutMultiplicity,\n responseValue[i],\n definitions,\n );\n }\n return responseValue as QueryReturnType<typeof responseDataType>;\n }\n\n switch (responseDataType.type) {\n case \"union\": {\n throw new Error(\"Union return types are not yet supported\");\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 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 \"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 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)) {\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, \"Expected key\");\n invariant(entry.value, \"Expected value\");\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\nasync 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 \"object\": {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n dataType.object,\n );\n result.set(dataType.object, objectDef);\n break;\n }\n\n case \"set\": {\n return getRequiredDefinitions(dataType.set, client);\n }\n\n case \"map\": {\n for (const value of [dataType.keyType, dataType.valueType]) {\n for (\n const [type, objectDef] of await getRequiredDefinitions(value, client)\n ) {\n result.set(type, objectDef);\n }\n }\n break;\n }\n\n case \"struct\": {\n for (const value of Object.values(dataType.struct)) {\n for (\n const [type, objectDef] of await getRequiredDefinitions(value, client)\n ) {\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 \"string\":\n case \"threeDimensionalAggregation\":\n case \"timestamp\":\n case \"twoDimensionalAggregation\":\n case \"union\":\n break;\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 \"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"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA,OAAO,KAAKA,YAAY,MAAM,0BAA0B;AACxD,OAAOC,SAAS,MAAM,gBAAgB;AAEtC,SAASC,eAAe,QAAQ,iCAAiC;AACjE,SAASC,gCAAgC,QAAQ,6CAA6C;AAC9F,SAASC,oCAAoC,QAAQ,iDAAiD;AACtG,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,SAASC,mCAAmC,QAAQ,iCAAiC;AACrF,SAASC,kBAAkB,QAAQ,+BAA+B;AAGlE,OAAO,eAAeC,UAAUA,CAI9BC,MAAqB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ChC,KAAK,6BAA6B;IAClC,KAAK,QAAQ;MACX,OAAO,IAAI;IAEb;MACE,OAAO,KAAK;EAChB;AACF;AAEA,SAASoB,kBAAkBA,CACzBa,UAAe,EACfC,iBAAyB,EACzB1C,WAAqD,EAC7C;EACR,MAAMS,GAAG,GAAGT,WAAW,CAACU,GAAG,CAACgC,iBAAiB,CAAC;EAC9C,IAAI,CAACjC,GAAG,IAAIA,GAAG,CAACF,IAAI,KAAK,QAAQ,EAAE;IACjC,MAAM,IAAIL,KAAK,CACb,0BAA0BwC,iBAAiB,EAC7C,CAAC;EACH;EACA,OAAO3E,mCAAmC,CACxC0C,GAAG,EACHgC,UACF,CAAC;AACH;AAEA,OAAO,SAAS7B,yBAAyBA,CAGvC6B,UAA6B,EAC7BJ,SAAY,EACC;EACb,OAAO;IACLM,QAAQ,EAAEN,SAAS,CAAC7D,OAAO;IAC3BoE,MAAM,EAAEjE,SAAS;IACjBkE,WAAW,EAAER,SAAS,CAAC7D,OAAO;IAC9BsE,WAAW,EAAEL,UAAU;IACvBM,gBAAgB,EAAEhF,mCAAmC,CACnDsE,SAAS,EACTI,UACF;EACF,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"applyQuery.js","names":["OntologiesV2","invariant","createObjectSet","hydrateAttachmentFromRidInternal","addUserAgentAndRequestContextHeaders","augmentRequestContext","createObjectSpecifierFromPrimaryKey","toDataValueQueries","applyQuery","client","query","params","qd","ontologyProvider","getQueryDefinition","apiName","isFixedVersion","version","undefined","response","Queries","execute","finalMethodCall","ontologyRid","parameters","remapQueryParams","objectOutputDefs","getRequiredDefinitions","output","remappedResponse","remapQueryResponse","value","paramTypes","parameterMap","key","Object","entries","responseDataType","responseValue","definitions","nullable","Error","multiplicity","withoutMultiplicity","i","length","type","set","def","get","object","createQueryObjectResponse","objectSet","objectSets","objectType","reference","subtype","struct","requiresConversion","map","Array","isArray","process","env","NODE_ENV","entry","keyType","getObjectSpecifier","valueType","result","groups","push","subResult","subKey","dataType","Map","objectDef","getObjectDefinition","types","allDefs","Promise","all","defs","structValues","values","some","primaryKey","objectTypeApiName","$apiName","$title","$objectType","$primaryKey","$objectSpecifier"],"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 ObjectOrInterfaceDefinition,\n ObjectTypeDefinition,\n OsdkBase,\n PrimaryKeyType,\n QueryDataTypeDefinition,\n QueryDefinition,\n QueryParameterDefinition,\n} from \"@osdk/api\";\nimport type { DataValue } from \"@osdk/foundry.ontologies\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\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 { createObjectSpecifierFromPrimaryKey } 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 const qd = await client.ontologyProvider.getQueryDefinition(\n query.apiName,\n query.isFixedVersion ? query.version : undefined,\n );\n\n const response = await OntologiesV2.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 qd.parameters,\n )\n : {},\n },\n { version: qd.version },\n );\n const objectOutputDefs = await getRequiredDefinitions(qd.output, client);\n const remappedResponse = await remapQueryResponse(\n client,\n qd.output,\n response.value,\n objectOutputDefs,\n );\n return remappedResponse as QueryReturnType<CompileTimeMetadata<QD>[\"output\"]>;\n}\n\nasync 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\nasync 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 if (\n responseDataType.multiplicity != null\n && responseDataType.multiplicity\n ) {\n const withoutMultiplicity = { ...responseDataType, multiplicity: false };\n for (let i = 0; i < responseValue.length; i++) {\n responseValue[i] = await remapQueryResponse(\n client,\n withoutMultiplicity,\n responseValue[i],\n definitions,\n );\n }\n return responseValue as QueryReturnType<typeof responseDataType>;\n }\n\n switch (responseDataType.type) {\n case \"union\": {\n throw new Error(\"Union return types are not yet supported\");\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 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 \"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 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)) {\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, \"Expected key\");\n invariant(entry.value, \"Expected value\");\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\nasync 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 \"object\": {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n dataType.object,\n );\n result.set(dataType.object, objectDef);\n break;\n }\n\n case \"set\": {\n return getRequiredDefinitions(dataType.set, 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 \"string\":\n case \"threeDimensionalAggregation\":\n case \"timestamp\":\n case \"twoDimensionalAggregation\":\n case \"union\":\n break;\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 \"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"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA,OAAO,KAAKA,YAAY,MAAM,0BAA0B;AACxD,OAAOC,SAAS,MAAM,gBAAgB;AAEtC,SAASC,eAAe,QAAQ,iCAAiC;AACjE,SAASC,gCAAgC,QAAQ,6CAA6C;AAC9F,SAASC,oCAAoC,QAAQ,iDAAiD;AACtG,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,SAASC,mCAAmC,QAAQ,iCAAiC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ACZ,KAAK,SAAS;IACd,KAAK,MAAM;IACX,KAAK,QAAQ;IACb,KAAK,WAAW;MACd,OAAO,KAAK;IAEd,KAAK,OAAO;MACV,OAAO,IAAI;IAEb,KAAK,QAAQ;MACX,OAAOX,MAAM,CAACiD,MAAM,CAACV,QAAQ,CAACjB,MAAM,CAAC,CAAC4B,IAAI,CAAC3B,kBAAkB,CAAC;IAEhE,KAAK,KAAK;MACR,OAAOA,kBAAkB,CAACgB,QAAQ,CAAC3B,GAAG,CAAC;IAEzC,KAAK,YAAY;IACjB,KAAK,WAAW;IAChB,KAAK,2BAA2B;IAChC,KAAK,6BAA6B;IAClC,KAAK,QAAQ;MACX,OAAO,IAAI;IAEb;MACE,OAAO,KAAK;EAChB;AACF;AAEA,SAASoB,kBAAkBA,CACzBmB,UAAe,EACfC,iBAAyB,EACzBhD,WAAqD,EAC7C;EACR,MAAMS,GAAG,GAAGT,WAAW,CAACU,GAAG,CAACsC,iBAAiB,CAAC;EAC9C,IAAI,CAACvC,GAAG,IAAIA,GAAG,CAACF,IAAI,KAAK,QAAQ,EAAE;IACjC,MAAM,IAAIL,KAAK,CACb,0BAA0B8C,iBAAiB,EAC7C,CAAC;EACH;EACA,OAAOjF,mCAAmC,CACxC0C,GAAG,EACHsC,UACF,CAAC;AACH;AAEA,OAAO,SAASnC,yBAAyBA,CAGvCmC,UAA6B,EAC7BV,SAAY,EACC;EACb,OAAO;IACLY,QAAQ,EAAEZ,SAAS,CAAC7D,OAAO;IAC3B0E,MAAM,EAAEvE,SAAS;IACjBwE,WAAW,EAAEd,SAAS,CAAC7D,OAAO;IAC9B4E,WAAW,EAAEL,UAAU;IACvBM,gBAAgB,EAAEtF,mCAAmC,CACnDsE,SAAS,EACTU,UACF;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -14,5 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
export const USER_AGENT = `osdk-client/${"2.
|
|
17
|
+
export const USER_AGENT = `osdk-client/${"2.3.0-beta.10"}`;
|
|
18
|
+
export const OBSERVABLE_USER_AGENT = `osdk-observable-client/${"2.3.0-beta.10"}`;
|
|
18
19
|
//# sourceMappingURL=UserAgent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserAgent.js","names":["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}`;\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":[]}
|
|
@@ -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;IACpB,KAAK,cAAc;MAAE;QACnB,MAAM;UAAEF,WAAW;UAAEG;QAAgB,CAAC,GACpC,MAAML,4BAA4B,CAChCF,SAAS,EACTC,SAAS,CAACA,SAAS,EACnBI,qBACF,CAAC;QAEH,IAAIE,eAAe,KAAKJ,SAAS,IAAII,eAAe,KAAK,EAAE,EAAE;UAC3D,OAAO;YAAEH,WAAW,EAAE,CAAC;UAAE,CAAC;QAC5B;QACA,MAAMI,MAAM,GAAG,MAAMR,SAAS,CAACS,gBAAgB,CAACC,mBAAmB,CACjEH,eACF,CAAC;QACD,MAAMI,OAAO,GAAGH,MAAM,CAACI,KAAK,CAACX,SAAS,CAACY,IAAI,CAAC;QAC5C,CAAUF,OAAO,GAAAG,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAjBlB,SAAS,QAAU,gCAAgCG,SAAS,CAACY,IAAI,GAAG,IAApEf,SAAS;QACT,OAAO;UACLM,WAAW;UACXG,eAAe,EAAEC,MAAM,CAACI,KAAK,CAACX,SAAS,CAACY,IAAI,CAAC,CAACI;QAChD,CAA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AAC,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;IACpB,KAAK,cAAc;MAAE;QACnB,MAAM;UAAEF,WAAW;UAAEG;QAAgB,CAAC,GACpC,MAAML,4BAA4B,CAChCF,SAAS,EACTC,SAAS,CAACA,SAAS,EACnBI,qBACF,CAAC;QAEH,IAAIE,eAAe,KAAKJ,SAAS,IAAII,eAAe,KAAK,EAAE,EAAE;UAC3D,OAAO;YAAEH,WAAW,EAAE,CAAC;UAAE,CAAC;QAC5B;QACA,MAAMI,MAAM,GAAG,MAAMR,SAAS,CAACS,gBAAgB,CAACC,mBAAmB,CACjEH,eACF,CAAC;QACD,MAAMI,OAAO,GAAGH,MAAM,CAACI,KAAK,CAACX,SAAS,CAACY,IAAI,CAAC;QAC5C,CAAUF,OAAO,GAAAG,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAjBlB,SAAS,QAAU,gCAAgCG,SAAS,CAACY,IAAI,GAAG,IAApEf,SAAS;QACT,OAAO;UACLM,WAAW;UACXG,eAAe,EAAEC,MAAM,CAACI,KAAK,CAACX,SAAS,CAACY,IAAI,CAAC,CAACI;QAChD,CAAC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AC,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,KAAK,2BAA2B;MAC9BU,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAAlB,SAAS,QAEP,4DAA4D,IAF9DA,SAAS;IAIX;MAEEgB,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAAlB,SAAS,QAEP,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.
|
|
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","
|
|
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,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,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,IACpBpB,kBAAkB,CAACoB,SAAS,CAAC,IAAIrB,gBAAgB,CAACqB,SAAS,CAC7D,CAAC,EACD;MACA,MAAMC,SAAS,GAAG,EAAE;MACpB,KAAK,MAAMV,KAAK,IAAIM,MAAM,EAA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W,CAAC2C,WAAW,EAAEzC,MAAM,EAAEC,cAAc,CAAC;MACjE,OAAOyC,GAAG;IACZ,CAAC,EACD7B,OAAO,CAAC8B,OAAO,CAAC,CAAC,CAAiC,CACpD,CAAC;EACH;;EAEA;EACA,OAAO5C,KAAK;AACd","ignoreList":[]}
|
|
@@ -15,25 +15,35 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { Employee, Task } from "@osdk/client.test.ontology";
|
|
18
|
-
import { LegacyFauxFoundry, startNodeApiServer, stubData } from "@osdk/shared.test";
|
|
18
|
+
import { LegacyFauxFoundry, MockOntologiesV2, startNodeApiServer, stubData } from "@osdk/shared.test";
|
|
19
19
|
import { beforeAll, describe, expect, it, vi } from "vitest";
|
|
20
20
|
import { createClient } from "../createClient.js";
|
|
21
21
|
import { createMinimalClient } from "../createMinimalClient.js";
|
|
22
22
|
import { createAttachmentUpload } from "../object/AttachmentUpload.js";
|
|
23
|
+
import { isMediaReference } from "../object/mediaUpload.js";
|
|
23
24
|
import { getWireObjectSet } from "../objectSet/createObjectSet.js";
|
|
24
25
|
import { toDataValue } from "./toDataValue.js";
|
|
25
26
|
describe(toDataValue, () => {
|
|
26
27
|
let client;
|
|
27
28
|
let clientCtx;
|
|
29
|
+
let mockActionMetadata;
|
|
30
|
+
let apiServer;
|
|
28
31
|
vi.fn();
|
|
29
32
|
beforeAll(() => {
|
|
30
33
|
const testSetup = startNodeApiServer(new LegacyFauxFoundry(), createClient);
|
|
31
34
|
({
|
|
32
35
|
client
|
|
33
36
|
} = testSetup);
|
|
37
|
+
apiServer = testSetup.apiServer;
|
|
34
38
|
clientCtx = createMinimalClient({
|
|
35
39
|
ontologyRid: testSetup.fauxFoundry.defaultOntologyRid
|
|
36
40
|
}, testSetup.fauxFoundry.baseUrl, testSetup.auth, {});
|
|
41
|
+
|
|
42
|
+
// toDataValue only needs the apiName right now, update this if that changes
|
|
43
|
+
|
|
44
|
+
mockActionMetadata = {
|
|
45
|
+
apiName: "createUnstructuredImageExampleObject"
|
|
46
|
+
};
|
|
37
47
|
return () => {
|
|
38
48
|
testSetup.apiServer.close();
|
|
39
49
|
};
|
|
@@ -48,7 +58,7 @@ describe(toDataValue, () => {
|
|
|
48
58
|
string: "string",
|
|
49
59
|
timestamp: "2024-01-01T00:00:00Z"
|
|
50
60
|
};
|
|
51
|
-
const convertedBasic = await toDataValue(basic, clientCtx);
|
|
61
|
+
const convertedBasic = await toDataValue(basic, clientCtx, mockActionMetadata);
|
|
52
62
|
expect(convertedBasic).toEqual(basic);
|
|
53
63
|
});
|
|
54
64
|
it("recursively converts arrays and sets into array types", async () => {
|
|
@@ -59,7 +69,7 @@ describe(toDataValue, () => {
|
|
|
59
69
|
attachment,
|
|
60
70
|
attachmentArray,
|
|
61
71
|
attachmentSet
|
|
62
|
-
}, clientCtx);
|
|
72
|
+
}, clientCtx, mockActionMetadata);
|
|
63
73
|
expect(recursiveConversion).toEqual({
|
|
64
74
|
attachment: "rid",
|
|
65
75
|
attachmentArray: ["rid"],
|
|
@@ -71,7 +81,7 @@ describe(toDataValue, () => {
|
|
|
71
81
|
inner: {
|
|
72
82
|
attachment: "rid"
|
|
73
83
|
}
|
|
74
|
-
}, clientCtx);
|
|
84
|
+
}, clientCtx, mockActionMetadata);
|
|
75
85
|
expect(recursiveConversion).toEqual({
|
|
76
86
|
inner: {
|
|
77
87
|
attachment: "rid"
|
|
@@ -80,12 +90,12 @@ describe(toDataValue, () => {
|
|
|
80
90
|
});
|
|
81
91
|
it("maps an ontology object into just its primary key", async () => {
|
|
82
92
|
const employee = stubData.employee1;
|
|
83
|
-
const ontologyConversion = await toDataValue(employee, clientCtx);
|
|
93
|
+
const ontologyConversion = await toDataValue(employee, clientCtx, mockActionMetadata);
|
|
84
94
|
expect(ontologyConversion).toEqual(stubData.employee1.__primaryKey);
|
|
85
95
|
});
|
|
86
96
|
it("maps an ontology object into just its primary key with osdk wrapper", async () => {
|
|
87
97
|
const task = await client(Employee).fetchOne(50030);
|
|
88
|
-
const ontologyConversion = await toDataValue(task, clientCtx);
|
|
98
|
+
const ontologyConversion = await toDataValue(task, clientCtx, mockActionMetadata);
|
|
89
99
|
expect(ontologyConversion).toEqual(task.$primaryKey);
|
|
90
100
|
});
|
|
91
101
|
it("passes through object set definitions", async () => {
|
|
@@ -107,9 +117,9 @@ describe(toDataValue, () => {
|
|
|
107
117
|
},
|
|
108
118
|
}
|
|
109
119
|
`;
|
|
110
|
-
const objectSetConversion = await toDataValue(clientObjectSet, clientCtx);
|
|
120
|
+
const objectSetConversion = await toDataValue(clientObjectSet, clientCtx, mockActionMetadata);
|
|
111
121
|
expect(objectSetConversion).toMatchInlineSnapshot(expected);
|
|
112
|
-
const definitionConversion = await toDataValue(definition, clientCtx);
|
|
122
|
+
const definitionConversion = await toDataValue(definition, clientCtx, mockActionMetadata);
|
|
113
123
|
expect(definitionConversion).toMatchInlineSnapshot(expected);
|
|
114
124
|
});
|
|
115
125
|
it("converts blob attachment uploads correctly", async () => {
|
|
@@ -117,7 +127,7 @@ describe(toDataValue, () => {
|
|
|
117
127
|
"hi": "mom"
|
|
118
128
|
})]);
|
|
119
129
|
const attachmentUpload = createAttachmentUpload(blob, "file1.txt");
|
|
120
|
-
const converted = await toDataValue(attachmentUpload, clientCtx);
|
|
130
|
+
const converted = await toDataValue(attachmentUpload, clientCtx, mockActionMetadata);
|
|
121
131
|
expect(converted).toMatch(/ri\.attachments.main.attachment\.[a-z0-9\-]+/i);
|
|
122
132
|
});
|
|
123
133
|
it("converts file attachment uploads correctly", async () => {
|
|
@@ -129,9 +139,38 @@ describe(toDataValue, () => {
|
|
|
129
139
|
}), {
|
|
130
140
|
name: "file1.txt"
|
|
131
141
|
});
|
|
132
|
-
const converted = await toDataValue(file, clientCtx);
|
|
142
|
+
const converted = await toDataValue(file, clientCtx, mockActionMetadata);
|
|
133
143
|
expect(converted).toMatch(/ri\.attachments.main.attachment\.[a-z0-9\-]+/i);
|
|
134
144
|
});
|
|
145
|
+
it("converts media uploads correctly", async () => {
|
|
146
|
+
const file = {
|
|
147
|
+
data: new Blob([JSON.stringify({
|
|
148
|
+
name: "Hello World"
|
|
149
|
+
}, null, 2)], {
|
|
150
|
+
type: "application/json"
|
|
151
|
+
}),
|
|
152
|
+
path: "file.txt"
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// TODO: Mock MediaUpload properly in FauxFoundry
|
|
156
|
+
apiServer.boundary(async () => {
|
|
157
|
+
apiServer.use(MockOntologiesV2.MediaReferenceProperties.uploadMedia("https://stack.palantir.com", () => {
|
|
158
|
+
return {
|
|
159
|
+
mimeType: "application/json",
|
|
160
|
+
reference: {
|
|
161
|
+
type: "mediaSetViewItem",
|
|
162
|
+
mediaSetViewItem: {
|
|
163
|
+
mediaItemRid: "media-item-rid",
|
|
164
|
+
mediaSetRid: "media-set-rid",
|
|
165
|
+
mediaSetViewRid: "media-set-view-rid"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}));
|
|
170
|
+
const converted = await toDataValue(file, clientCtx, mockActionMetadata);
|
|
171
|
+
expect(isMediaReference(converted)).toBe(true);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
135
174
|
it("converts media reference correctly", async () => {
|
|
136
175
|
const mediaReference = {
|
|
137
176
|
mimeType: "application/json",
|
|
@@ -144,7 +183,7 @@ describe(toDataValue, () => {
|
|
|
144
183
|
}
|
|
145
184
|
}
|
|
146
185
|
};
|
|
147
|
-
const converted = await toDataValue(mediaReference, clientCtx);
|
|
186
|
+
const converted = await toDataValue(mediaReference, clientCtx, mockActionMetadata);
|
|
148
187
|
expect(converted).toEqual(mediaReference);
|
|
149
188
|
});
|
|
150
189
|
});
|