@osdk/client 2.2.0-beta.6 → 2.2.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 +43 -0
- package/build/browser/Client.js.map +1 -1
- package/build/browser/actions/actions.test.js +52 -4
- package/build/browser/actions/actions.test.js.map +1 -1
- package/build/browser/actions/applyAction.js +21 -15
- package/build/browser/actions/applyAction.js.map +1 -1
- package/build/browser/createClient.js +11 -4
- package/build/browser/createClient.js.map +1 -1
- package/build/browser/index.js +1 -0
- package/build/browser/index.js.map +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +25 -0
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.js +8 -1
- package/build/browser/object/convertWireToOsdkObjects.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.test.js +7 -3
- package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/browser/object/createObjectSpecifierFromPrimaryKey.js +20 -0
- package/build/browser/object/createObjectSpecifierFromPrimaryKey.js.map +1 -0
- package/build/browser/object/object.test.js +109 -0
- package/build/browser/object/object.test.js.map +1 -1
- package/build/browser/objectSet/ObjectSet.test.js +15 -1
- package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js +2 -0
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/browser/observable/internal/Store.js +1 -1
- package/build/browser/observable/internal/Store.js.map +1 -1
- package/build/browser/observable/internal/testUtils.js +2 -0
- package/build/browser/observable/internal/testUtils.js.map +1 -1
- package/build/browser/queries/applyQuery.js +33 -1
- package/build/browser/queries/applyQuery.js.map +1 -1
- package/build/browser/queries/queries.test.js +26 -5
- package/build/browser/queries/queries.test.js.map +1 -1
- package/build/browser/util/UserAgent.js +1 -1
- package/build/browser/util/toDataValueQueries.js +17 -0
- package/build/browser/util/toDataValueQueries.js.map +1 -1
- package/build/cjs/{Client-C8K3E1vH.d.cts → Client-DBTcM9gB.d.cts} +1 -1
- package/build/cjs/{chunk-2FVV5A63.cjs → chunk-IU47QMYO.cjs} +48 -48
- package/build/cjs/chunk-IU47QMYO.cjs.map +1 -0
- package/build/cjs/{chunk-X7WGNFZ4.cjs → chunk-JPENHIJB.cjs} +19 -19
- package/build/cjs/chunk-JPENHIJB.cjs.map +1 -0
- package/build/cjs/{graphql-JJX5MZPQ.cjs → graphql-RGM5SRWV.cjs} +306 -265
- package/build/cjs/graphql-RGM5SRWV.cjs.map +1 -0
- package/build/cjs/index.cjs +192 -102
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +6 -4
- package/build/cjs/public/internal.cjs +6 -6
- package/build/cjs/public/internal.cjs.map +1 -1
- package/build/cjs/public/internal.d.cts +1 -1
- package/build/cjs/public/unstable-do-not-use.cjs +41 -70
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +1 -1
- package/build/esm/Client.js.map +1 -1
- package/build/esm/actions/actions.test.js +52 -4
- package/build/esm/actions/actions.test.js.map +1 -1
- package/build/esm/actions/applyAction.js +21 -15
- package/build/esm/actions/applyAction.js.map +1 -1
- package/build/esm/createClient.js +11 -4
- package/build/esm/createClient.js.map +1 -1
- package/build/esm/index.js +1 -0
- package/build/esm/index.js.map +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +25 -0
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.js +8 -1
- package/build/esm/object/convertWireToOsdkObjects.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.test.js +7 -3
- package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/esm/object/createObjectSpecifierFromPrimaryKey.js +20 -0
- package/build/esm/object/createObjectSpecifierFromPrimaryKey.js.map +1 -0
- package/build/esm/object/object.test.js +109 -0
- package/build/esm/object/object.test.js.map +1 -1
- package/build/esm/objectSet/ObjectSet.test.js +15 -1
- package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js +2 -0
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/esm/observable/internal/Store.js +1 -1
- package/build/esm/observable/internal/Store.js.map +1 -1
- package/build/esm/observable/internal/testUtils.js +2 -0
- package/build/esm/observable/internal/testUtils.js.map +1 -1
- package/build/esm/queries/applyQuery.js +33 -1
- package/build/esm/queries/applyQuery.js.map +1 -1
- package/build/esm/queries/queries.test.js +26 -5
- package/build/esm/queries/queries.test.js.map +1 -1
- package/build/esm/util/UserAgent.js +1 -1
- package/build/esm/util/toDataValueQueries.js +17 -0
- package/build/esm/util/toDataValueQueries.js.map +1 -1
- package/build/types/Client.d.ts +1 -1
- package/build/types/Client.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/index.d.ts +2 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/object/createObjectSpecifierFromPrimaryKey.d.ts +2 -0
- package/build/types/object/createObjectSpecifierFromPrimaryKey.d.ts.map +1 -0
- package/build/types/object/object.test.d.ts.map +1 -1
- package/build/types/objectSet/ObjectSet.test.d.ts.map +1 -1
- package/build/types/observable/internal/testUtils.d.ts.map +1 -1
- package/build/types/queries/applyQuery.d.ts.map +1 -1
- package/package.json +12 -12
- package/build/cjs/chunk-2FVV5A63.cjs.map +0 -1
- package/build/cjs/chunk-X7WGNFZ4.cjs.map +0 -1
- package/build/cjs/graphql-JJX5MZPQ.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
# @osdk/client
|
|
2
2
|
|
|
3
|
+
## 2.2.0-beta.8
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1ba3871: Support $clone for interface objects
|
|
8
|
+
- 63b2e63: Update Platform SDK Dependencies
|
|
9
|
+
- 26c2d95: Add experimental function to load page of objects by rid.
|
|
10
|
+
- 63b2e63: Supports generating queries for entrySet function types
|
|
11
|
+
- 63b2e63: Adds ObjectSpecifiers to generated OSDK objects
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [ad93d55]
|
|
16
|
+
- Updated dependencies [0e874b1]
|
|
17
|
+
- Updated dependencies [63b2e63]
|
|
18
|
+
- Updated dependencies [26c2d95]
|
|
19
|
+
- Updated dependencies [63b2e63]
|
|
20
|
+
- Updated dependencies [63b2e63]
|
|
21
|
+
- @osdk/shared.net.errors@2.2.0-beta.2
|
|
22
|
+
- @osdk/shared.net.fetch@1.2.0-beta.2
|
|
23
|
+
- @osdk/api@2.2.0-beta.8
|
|
24
|
+
- @osdk/generator-converters@2.2.0-beta.8
|
|
25
|
+
- @osdk/shared.client.impl@1.2.0-beta.2
|
|
26
|
+
- @osdk/client.unstable@2.2.0-beta.8
|
|
27
|
+
|
|
28
|
+
## 2.2.0-beta.7
|
|
29
|
+
|
|
30
|
+
### Minor Changes
|
|
31
|
+
|
|
32
|
+
- 7416ce4: Adds deleted objects and links returned from applyAction
|
|
33
|
+
- 7416ce4: Update Platform SDK Dependencies
|
|
34
|
+
- 879b6c3: Include a more descriptive error message for multiple filters on a single property filter clause
|
|
35
|
+
- 805df40: Fix interface action types.
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- Updated dependencies [7416ce4]
|
|
40
|
+
- Updated dependencies [7416ce4]
|
|
41
|
+
- Updated dependencies [805df40]
|
|
42
|
+
- @osdk/api@2.2.0-beta.7
|
|
43
|
+
- @osdk/generator-converters@2.2.0-beta.7
|
|
44
|
+
- @osdk/client.unstable@2.2.0-beta.7
|
|
45
|
+
|
|
3
46
|
## 2.2.0-beta.6
|
|
4
47
|
|
|
5
48
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.js","names":["additionalContext","Symbol","MaxOsdkVersion","ErrorMessage"],"sources":["Client.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionMetadata,\n CompileTimeMetadata,\n InterfaceDefinition,\n InterfaceMetadata,\n ObjectMetadata,\n ObjectSet,\n ObjectTypeDefinition,\n QueryDefinition,\n QueryMetadata,\n VersionBound,\n} from \"@osdk/api\";\nimport type {\n Experiment,\n ExperimentFns,\n MinimalObjectSet,\n} from \"@osdk/api/unstable\";\nimport type { SharedClient } from \"@osdk/shared.client2\";\nimport type { ActionSignatureFromDef } from \"./actions/applyAction.js\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport type { QuerySignatureFromDef } from \"./queries/types.js\";\nimport type { SatisfiesSemver } from \"./SatisfiesSemver.js\";\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\ntype OldSharedClient = import(\"@osdk/shared.client\").SharedClient;\n\nexport type CheckVersionBound<Q> = Q extends VersionBound<infer V> ? (\n SatisfiesSemver<V, MaxOsdkVersion> extends true ? Q\n : Q & {\n [ErrorMessage]:\n `Your SDK requires a semver compatible version with ${V}. You have ${MaxOsdkVersion}. Update your package.json`;\n }\n )\n : Q;\n\nexport interface Client extends SharedClient, OldSharedClient {\n <Q extends ObjectTypeDefinition>(\n o: Q,\n ): unknown extends CompileTimeMetadata<Q>[\"objectSet\"] ? ObjectSet<Q>\n : CompileTimeMetadata<Q>[\"objectSet\"];\n\n <Q extends (InterfaceDefinition)>(\n o: Q,\n ): unknown extends CompileTimeMetadata<Q>[\"objectSet\"] ? MinimalObjectSet<Q>\n : CompileTimeMetadata<Q>[\"objectSet\"];\n\n <Q extends ActionDefinition<any>>(\n o: Q,\n ): ActionSignatureFromDef<Q>;\n\n <Q extends QueryDefinition<any>>(\n o: Q,\n ): QuerySignatureFromDef<Q>;\n\n <Q extends Experiment<\"2.0.8\"> | Experiment<\"2.1.0\">>(\n experiment: Q,\n ): ExperimentFns<Q>;\n\n fetchMetadata<\n Q extends (\n | ObjectTypeDefinition\n | InterfaceDefinition\n | ActionDefinition<any>\n | QueryDefinition<any>\n ),\n >(o: Q): Promise<\n Q extends ObjectTypeDefinition ? ObjectMetadata\n : Q extends InterfaceDefinition ? InterfaceMetadata\n : Q extends ActionDefinition<any> ? ActionMetadata\n : Q extends QueryDefinition<any> ? QueryMetadata\n : never\n >;\n\n /** @internal */\n [additionalContext]: MinimalClient;\n}\n\n// DO NOT EXPORT FROM PACKAGE\n/** @internal */\nexport const additionalContext: unique symbol = Symbol(\"additionalContext\");\n\n// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.\nconst MaxOsdkVersion = \"2.2.0\";\n// END: THIS IS GENERATED CODE. DO NOT EDIT.\nexport type MaxOsdkVersion = typeof MaxOsdkVersion;\nconst ErrorMessage: unique symbol = Symbol(\"ErrorMessage\");\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA0BA;;AAsDA;AACA;AACA,OAAO,MAAMA,iBAAgC,GAAGC,MAAM,CAAC,mBAAmB,CAAC;;AAE3E;AACA,MAAMC,cAAc,GAAG,OAAO;AAC9B;;AAEA,MAAMC,YAA2B,GAAGF,MAAM,CAAC,cAAc,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Client.js","names":["additionalContext","Symbol","MaxOsdkVersion","ErrorMessage"],"sources":["Client.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionMetadata,\n CompileTimeMetadata,\n InterfaceDefinition,\n InterfaceMetadata,\n ObjectMetadata,\n ObjectSet,\n ObjectTypeDefinition,\n QueryDefinition,\n QueryMetadata,\n VersionBound,\n} from \"@osdk/api\";\nimport type {\n Experiment,\n ExperimentFns,\n MinimalObjectSet,\n} from \"@osdk/api/unstable\";\nimport type { SharedClient } from \"@osdk/shared.client2\";\nimport type { ActionSignatureFromDef } from \"./actions/applyAction.js\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport type { QuerySignatureFromDef } from \"./queries/types.js\";\nimport type { SatisfiesSemver } from \"./SatisfiesSemver.js\";\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\ntype OldSharedClient = import(\"@osdk/shared.client\").SharedClient;\n\nexport type CheckVersionBound<Q> = Q extends VersionBound<infer V> ? (\n SatisfiesSemver<V, MaxOsdkVersion> extends true ? Q\n : Q & {\n [ErrorMessage]:\n `Your SDK requires a semver compatible version with ${V}. You have ${MaxOsdkVersion}. Update your package.json`;\n }\n )\n : Q;\n\nexport interface Client extends SharedClient, OldSharedClient {\n <Q extends ObjectTypeDefinition>(\n o: Q,\n ): unknown extends CompileTimeMetadata<Q>[\"objectSet\"] ? ObjectSet<Q>\n : CompileTimeMetadata<Q>[\"objectSet\"];\n\n <Q extends (InterfaceDefinition)>(\n o: Q,\n ): unknown extends CompileTimeMetadata<Q>[\"objectSet\"] ? MinimalObjectSet<Q>\n : CompileTimeMetadata<Q>[\"objectSet\"];\n\n <Q extends ActionDefinition<any>>(\n o: Q,\n ): ActionSignatureFromDef<Q>;\n\n <Q extends QueryDefinition<any>>(\n o: Q,\n ): QuerySignatureFromDef<Q>;\n\n <Q extends Experiment<\"2.0.8\"> | Experiment<\"2.1.0\"> | Experiment<\"2.2.0\">>(\n experiment: Q,\n ): ExperimentFns<Q>;\n\n fetchMetadata<\n Q extends (\n | ObjectTypeDefinition\n | InterfaceDefinition\n | ActionDefinition<any>\n | QueryDefinition<any>\n ),\n >(o: Q): Promise<\n Q extends ObjectTypeDefinition ? ObjectMetadata\n : Q extends InterfaceDefinition ? InterfaceMetadata\n : Q extends ActionDefinition<any> ? ActionMetadata\n : Q extends QueryDefinition<any> ? QueryMetadata\n : never\n >;\n\n /** @internal */\n [additionalContext]: MinimalClient;\n}\n\n// DO NOT EXPORT FROM PACKAGE\n/** @internal */\nexport const additionalContext: unique symbol = Symbol(\"additionalContext\");\n\n// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.\nconst MaxOsdkVersion = \"2.2.0\";\n// END: THIS IS GENERATED CODE. DO NOT EDIT.\nexport type MaxOsdkVersion = typeof MaxOsdkVersion;\nconst ErrorMessage: unique symbol = Symbol(\"ErrorMessage\");\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA0BA;;AAsDA;AACA;AACA,OAAO,MAAMA,iBAAgC,GAAGC,MAAM,CAAC,mBAAmB,CAAC;;AAE3E;AACA,MAAMC,cAAc,GAAG,OAAO;AAC9B;;AAEA,MAAMC,YAA2B,GAAGF,MAAM,CAAC,cAAc,CAAC","ignoreList":[]}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { $Actions, $ontologyRid, actionTakesAttachment, actionTakesMedia, createFooInterface, createOffice, createStructPerson, deleteFooInterface, moveOffice } from "@osdk/client.test.ontology";
|
|
17
|
+
import { $Actions, $ontologyRid, actionTakesAttachment, actionTakesMedia, createFooInterface, createOffice, createStructPerson, deleteBarInterface, deleteFooInterface, moveOffice } from "@osdk/client.test.ontology";
|
|
18
18
|
import { apiServer, stubData } from "@osdk/shared.test";
|
|
19
19
|
import { afterAll, beforeAll, describe, expect, expectTypeOf, it, vi } from "vitest";
|
|
20
20
|
import { createClient } from "../createClient.js";
|
|
@@ -50,7 +50,9 @@ describe("actions", () => {
|
|
|
50
50
|
"primaryKey": "NYC",
|
|
51
51
|
},
|
|
52
52
|
],
|
|
53
|
+
"deletedLinks": [],
|
|
53
54
|
"deletedLinksCount": 0,
|
|
55
|
+
"deletedObjects": [],
|
|
54
56
|
"deletedObjectsCount": 0,
|
|
55
57
|
"editedObjectTypes": [
|
|
56
58
|
"Office",
|
|
@@ -204,6 +206,12 @@ describe("actions", () => {
|
|
|
204
206
|
expectTypeOf().toEqualTypeOf();
|
|
205
207
|
expect(result).toBeUndefined();
|
|
206
208
|
});
|
|
209
|
+
it("Accepts interfaces if implementing object types unknown", async () => {
|
|
210
|
+
client(deleteBarInterface).applyAction;
|
|
211
|
+
expectTypeOf().toMatchTypeOf();
|
|
212
|
+
client(deleteBarInterface).batchApplyAction;
|
|
213
|
+
expectTypeOf().toMatchTypeOf();
|
|
214
|
+
});
|
|
207
215
|
it("Accepts object type refs", async () => {
|
|
208
216
|
client(createFooInterface).applyAction;
|
|
209
217
|
expectTypeOf().toMatchTypeOf();
|
|
@@ -231,7 +239,9 @@ describe("actions", () => {
|
|
|
231
239
|
{
|
|
232
240
|
"addedLinks": [],
|
|
233
241
|
"addedObjects": [],
|
|
242
|
+
"deletedLinks": [],
|
|
234
243
|
"deletedLinksCount": 0,
|
|
244
|
+
"deletedObjects": [],
|
|
235
245
|
"deletedObjectsCount": 0,
|
|
236
246
|
"editedObjectTypes": [
|
|
237
247
|
"Office",
|
|
@@ -275,9 +285,25 @@ describe("ActionResponse remapping", () => {
|
|
|
275
285
|
"objectType": "Employee"
|
|
276
286
|
},
|
|
277
287
|
"type": "addLink"
|
|
288
|
+
}, {
|
|
289
|
+
"objectType": "Developer",
|
|
290
|
+
"primaryKey": "PalantirDev",
|
|
291
|
+
"type": "deleteObject"
|
|
292
|
+
}, {
|
|
293
|
+
"aSideObject": {
|
|
294
|
+
"primaryKey": "key1",
|
|
295
|
+
"objectType": "Office"
|
|
296
|
+
},
|
|
297
|
+
"linkTypeApiNameAtoB": "test",
|
|
298
|
+
"linkTypeApiNameBtoA": "test",
|
|
299
|
+
"bSideObject": {
|
|
300
|
+
"primaryKey": "key2",
|
|
301
|
+
"objectType": "Employee"
|
|
302
|
+
},
|
|
303
|
+
"type": "deleteLink"
|
|
278
304
|
}],
|
|
279
305
|
deletedLinksCount: 0,
|
|
280
|
-
deletedObjectsCount:
|
|
306
|
+
deletedObjectsCount: 1,
|
|
281
307
|
addedObjectCount: 1,
|
|
282
308
|
modifiedObjectsCount: 1,
|
|
283
309
|
addedLinksCount: 1
|
|
@@ -339,8 +365,28 @@ describe("ActionResponse remapping", () => {
|
|
|
339
365
|
"primaryKey": "PalantirDev",
|
|
340
366
|
},
|
|
341
367
|
],
|
|
368
|
+
"deletedLinks": [
|
|
369
|
+
{
|
|
370
|
+
"aSideObject": {
|
|
371
|
+
"objectType": "Office",
|
|
372
|
+
"primaryKey": "key1",
|
|
373
|
+
},
|
|
374
|
+
"bSideObject": {
|
|
375
|
+
"objectType": "Employee",
|
|
376
|
+
"primaryKey": "key2",
|
|
377
|
+
},
|
|
378
|
+
"linkTypeApiNameAtoB": "test",
|
|
379
|
+
"linkTypeApiNameBtoA": "test",
|
|
380
|
+
},
|
|
381
|
+
],
|
|
342
382
|
"deletedLinksCount": 0,
|
|
343
|
-
"
|
|
383
|
+
"deletedObjects": [
|
|
384
|
+
{
|
|
385
|
+
"objectType": "Developer",
|
|
386
|
+
"primaryKey": "PalantirDev",
|
|
387
|
+
},
|
|
388
|
+
],
|
|
389
|
+
"deletedObjectsCount": 1,
|
|
344
390
|
"editedObjectTypes": [
|
|
345
391
|
"Developer",
|
|
346
392
|
"Contractor",
|
|
@@ -378,7 +424,9 @@ describe("ActionResponse remapping", () => {
|
|
|
378
424
|
"primaryKey": "PalantirDev",
|
|
379
425
|
},
|
|
380
426
|
],
|
|
427
|
+
"deletedLinks": [],
|
|
381
428
|
"deletedLinksCount": 0,
|
|
429
|
+
"deletedObjects": [],
|
|
382
430
|
"deletedObjectsCount": 0,
|
|
383
431
|
"editedObjectTypes": [
|
|
384
432
|
"Developer",
|
|
@@ -398,7 +446,7 @@ describe("ActionResponse remapping", () => {
|
|
|
398
446
|
});
|
|
399
447
|
it("actions are enumerable", async () => {
|
|
400
448
|
const actions = Object.keys($Actions);
|
|
401
|
-
expect(actions).toStrictEqual(["actionTakesAttachment", "actionTakesMedia", "actionTakesObjectSet", "createFooInterface", "createOffice", "createOfficeAndEmployee", "createStructPerson", "deleteFooInterface", "moveOffice", "promoteEmployee", "promoteEmployeeObject"]);
|
|
449
|
+
expect(actions).toStrictEqual(["actionTakesAttachment", "actionTakesMedia", "actionTakesObjectSet", "createFooInterface", "createOffice", "createOfficeAndEmployee", "createStructPerson", "deleteBarInterface", "deleteFooInterface", "moveOffice", "promoteEmployee", "promoteEmployeeObject"]);
|
|
402
450
|
});
|
|
403
451
|
});
|
|
404
452
|
//# sourceMappingURL=actions.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.test.js","names":["$Actions","$ontologyRid","actionTakesAttachment","actionTakesMedia","createFooInterface","createOffice","createStructPerson","deleteFooInterface","moveOffice","apiServer","stubData","afterAll","beforeAll","describe","expect","expectTypeOf","it","vi","createClient","createAttachmentUpload","ActionValidationError","remapActionResponse","client","customEntryPointClient","listen","close","result","applyAction","officeId","address","capacity","$returnEdits","toEqualTypeOf","toMatchInlineSnapshot","undefinedResult","toBeUndefined","batchApplyAction","clientCreateOfficeMock","fn","newAddress","newCapacity","$validateOnly","fail","e","toBeInstanceOf","validation","toMatchTypeOf","name","city","state","zipcode","attachment","blob","attachmentUploadRequestBody","localAttachment1","filename","fileAttachment","Object","assign","result2","media_reference","mediaReference","deletedInterface","$objectType","$primaryKey","createdInterface","actionResponse","edits","type","deletedLinksCount","deletedObjectsCount","addedObjectCount","modifiedObjectsCount","addedLinksCount","batchActionResponse","remappedActionResponse","remappedBatchActionResponse","actions","keys","toStrictEqual"],"sources":["actions.test.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionEditResponse,\n ActionValidationResponse,\n AttachmentUpload,\n MediaReference,\n} from \"@osdk/api\";\nimport {\n $Actions,\n $ontologyRid,\n actionTakesAttachment,\n actionTakesMedia,\n createFooInterface,\n createOffice,\n createStructPerson,\n deleteFooInterface,\n moveOffice,\n} from \"@osdk/client.test.ontology\";\nimport type {\n BatchApplyActionResponseV2,\n SyncApplyActionResponseV2,\n} from \"@osdk/foundry.ontologies\";\nimport { apiServer, stubData } from \"@osdk/shared.test\";\nimport {\n afterAll,\n beforeAll,\n describe,\n expect,\n expectTypeOf,\n it,\n vi,\n} from \"vitest\";\nimport type { Client } from \"../Client.js\";\nimport { createClient } from \"../createClient.js\";\nimport { createAttachmentUpload } from \"../object/AttachmentUpload.js\";\nimport { ActionValidationError } from \"./ActionValidationError.js\";\nimport { remapActionResponse } from \"./applyAction.js\";\n\ndescribe(\"actions\", () => {\n let client: Client;\n let customEntryPointClient: Client;\n\n beforeAll(async () => {\n apiServer.listen();\n client = createClient(\n \"https://stack.palantir.com\",\n $ontologyRid,\n async () => \"myAccessToken\",\n );\n customEntryPointClient = createClient(\n \"https://stack.palantirCustom.com/foo/first/someStuff\",\n $ontologyRid,\n async () => \"myAccessToken\",\n );\n });\n\n afterAll(() => {\n apiServer.close();\n });\n\n it(\"conditionally returns the edits\", async () => {\n const result = await client(createOffice).applyAction({\n officeId: \"NYC\",\n address: \"123 Main Street\",\n capacity: 100,\n }, { $returnEdits: true });\n\n expectTypeOf<typeof result>().toEqualTypeOf<ActionEditResponse>();\n expect(result).toMatchInlineSnapshot(`\n {\n \"addedLinks\": [],\n \"addedObjects\": [\n {\n \"objectType\": \"Office\",\n \"primaryKey\": \"NYC\",\n },\n ],\n \"deletedLinksCount\": 0,\n \"deletedObjectsCount\": 0,\n \"editedObjectTypes\": [\n \"Office\",\n ],\n \"modifiedObjects\": [],\n \"type\": \"edits\",\n }\n `);\n\n // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression\n const undefinedResult = await client(createOffice).applyAction({\n officeId: \"NYC\",\n address: \"123 Main Street\",\n capacity: 100,\n });\n\n expectTypeOf<typeof undefinedResult>().toEqualTypeOf<undefined>();\n expect(undefinedResult).toBeUndefined();\n\n const clientCreateOffice = client(createOffice).batchApplyAction;\n const clientCreateOfficeMock: typeof clientCreateOffice = vi.fn();\n void clientCreateOfficeMock([{\n officeId: \"NYC\",\n address: \"123 Main Street\",\n capacity: 100,\n }], { $returnEdits: true });\n });\n\n it(\"returns validation directly on validateOnly mode\", async () => {\n const result = await client(moveOffice).applyAction({\n officeId: \"SEA\",\n newAddress: \"456 Pike Place\",\n newCapacity: 40,\n }, {\n $validateOnly: true,\n });\n expectTypeOf<typeof result>().toEqualTypeOf<ActionValidationResponse>();\n\n expect(result).toMatchInlineSnapshot(`\n {\n \"parameters\": {},\n \"result\": \"INVALID\",\n \"submissionCriteria\": [],\n }\n `);\n });\n\n it(\"returns validation directly on validateOnly mode, with custom entry point in URL\", async () => {\n const result = await customEntryPointClient(moveOffice).applyAction({\n officeId: \"SEA\",\n newAddress: \"456 Pike Place\",\n newCapacity: 40,\n }, {\n $validateOnly: true,\n });\n expectTypeOf<typeof result>().toEqualTypeOf<ActionValidationResponse>();\n\n expect(result).toMatchInlineSnapshot(`\n {\n \"parameters\": {},\n \"result\": \"INVALID\",\n \"submissionCriteria\": [],\n }\n `);\n });\n\n it(\"throws on validation errors\", async () => {\n try {\n const result = await client(moveOffice).applyAction({\n officeId: \"SEA\",\n newAddress: \"456 Pike Place\",\n newCapacity: 40,\n }, {\n $returnEdits: true,\n });\n expect.fail(\"Should not reach here\");\n } catch (e) {\n expect(e).toBeInstanceOf(ActionValidationError);\n expect((e as ActionValidationError).validation).toMatchInlineSnapshot(`\n {\n \"parameters\": {},\n \"result\": \"INVALID\",\n \"submissionCriteria\": [],\n }\n `);\n }\n });\n\n it(\"Accepts structs\", async () => {\n const clientBoundActionTakesStruct = client(createStructPerson).applyAction;\n type InferredParamType = Parameters<\n typeof clientBoundActionTakesStruct\n >[0];\n expectTypeOf<\n {\n name: string;\n address: { city: string; state: string; zipcode: number };\n }\n >()\n .toMatchTypeOf<\n InferredParamType\n >();\n\n const result = await client(createStructPerson).applyAction({\n name: \"testMan\",\n address: { city: \"NYC\", state: \"NY\", zipcode: 12345 },\n });\n expectTypeOf<typeof result>().toEqualTypeOf<undefined>();\n expect(result).toBeUndefined();\n });\n\n it(\"Accepts attachments\", async () => {\n const clientBoundActionTakesAttachment = client(\n actionTakesAttachment,\n ).applyAction;\n\n type InferredParamType = Parameters<\n typeof clientBoundActionTakesAttachment\n >[0];\n\n expectTypeOf<{ attachment: string | AttachmentUpload }>().toMatchTypeOf<\n InferredParamType\n >();\n\n const clientBoundBatchActionTakesAttachment = client(\n actionTakesAttachment,\n ).batchApplyAction;\n type InferredBatchParamType = Parameters<\n typeof clientBoundBatchActionTakesAttachment\n >[0];\n\n expectTypeOf<{\n attachment: string | AttachmentUpload;\n }[]>().toMatchTypeOf<InferredBatchParamType>();\n\n const result = await client(actionTakesAttachment).applyAction({\n attachment: \"attachment.rid\",\n });\n\n expectTypeOf<typeof result>().toEqualTypeOf<undefined>();\n expect(result).toBeUndefined();\n });\n\n it(\"Accepts attachment uploads\", async () => {\n const clientBoundActionTakesAttachment = client(\n actionTakesAttachment,\n ).applyAction;\n type InferredParamType = Parameters<\n typeof clientBoundActionTakesAttachment\n >[0];\n const clientBoundBatchActionTakesAttachment = client(\n actionTakesAttachment,\n ).batchApplyAction;\n type InferredBatchParamType = Parameters<\n typeof clientBoundBatchActionTakesAttachment\n >[0];\n\n expectTypeOf<\n {\n attachment:\n | string\n | AttachmentUpload\n | Blob & { readonly name: string };\n }\n >().toMatchTypeOf<\n InferredParamType\n >();\n expectTypeOf<\n {\n attachment:\n | string\n | AttachmentUpload\n | Blob & { readonly name: string };\n }[]\n >().toMatchTypeOf<\n InferredBatchParamType\n >();\n\n const blob =\n stubData.attachmentUploadRequestBody[stubData.localAttachment1.filename];\n\n const attachment = createAttachmentUpload(blob, \"file1.txt\");\n\n // Mimics the Web file API (https://developer.mozilla.org/en-US/docs/Web/API/File). The File constructor is only available in Node 19.2.0 and above\n const fileAttachment = Object.assign(blob, { name: \"file1.txt\" });\n\n const result = await client(actionTakesAttachment).applyAction({\n attachment,\n });\n\n const result2 = await client(actionTakesAttachment).applyAction({\n attachment: fileAttachment,\n });\n\n expectTypeOf<typeof result>().toEqualTypeOf<undefined>();\n expect(result).toBeUndefined();\n\n expectTypeOf<typeof result2>().toEqualTypeOf<undefined>();\n expect(result2).toBeUndefined();\n });\n\n it(\"Accepts media reference\", async () => {\n const clientBoundActionTakesMedia = client(\n actionTakesMedia,\n ).applyAction;\n type InferredParamType = Parameters<\n typeof clientBoundActionTakesMedia\n >[0];\n\n expectTypeOf<\n {\n media_reference: MediaReference;\n }\n >().toMatchTypeOf<\n InferredParamType\n >();\n\n const result = await client(actionTakesMedia).applyAction({\n media_reference: stubData.mediaReference,\n });\n\n expectTypeOf<typeof result>().toEqualTypeOf<undefined>();\n expect(result).toBeUndefined();\n });\n\n it(\"Accepts interfaces\", async () => {\n const clientBoundTakesInterface = client(\n deleteFooInterface,\n ).applyAction;\n\n type InferredParamType = Parameters<\n typeof clientBoundTakesInterface\n >[0];\n\n expectTypeOf<\n {\n deletedInterface: {\n $objectType: \"Employee\" | \"Person\";\n $primaryKey: string | number;\n };\n }\n >().toMatchTypeOf<\n InferredParamType\n >();\n\n const clientBoundBatchActionTakesInterface = client(\n deleteFooInterface,\n ).batchApplyAction;\n type InferredBatchParamType = Parameters<\n typeof clientBoundBatchActionTakesInterface\n >[0];\n\n expectTypeOf<{\n deletedInterface: {\n $objectType: \"Employee\" | \"Person\";\n $primaryKey: string | number;\n };\n }[]>().toMatchTypeOf<InferredBatchParamType>();\n\n const result = await client(deleteFooInterface).applyAction({\n deletedInterface: {\n $objectType: \"Employee\",\n $primaryKey: 1,\n },\n });\n\n expectTypeOf<typeof result>().toEqualTypeOf<undefined>();\n expect(result).toBeUndefined();\n });\n it(\"Accepts object type refs\", async () => {\n const clientBoundTakesObjectType = client(\n createFooInterface,\n ).applyAction;\n\n type InferredParamType = Parameters<\n typeof clientBoundTakesObjectType\n >[0];\n\n expectTypeOf<\n {\n createdInterface: string;\n }\n >().toMatchTypeOf<\n InferredParamType\n >();\n\n const clientBoundBatchActionTakesObjectType = client(\n createFooInterface,\n ).batchApplyAction;\n type InferredBatchParamType = Parameters<\n typeof clientBoundBatchActionTakesObjectType\n >[0];\n\n expectTypeOf<{\n createdInterface: string;\n }[]>().toMatchTypeOf<InferredBatchParamType>();\n\n const result = await client(createFooInterface).applyAction({\n createdInterface: \"UnderlyingObject\",\n });\n\n expectTypeOf<typeof result>().toEqualTypeOf<undefined>();\n expect(result).toBeUndefined();\n });\n it(\"conditionally returns edits in batch mode\", async () => {\n const result = await client(moveOffice).batchApplyAction([\n {\n officeId: \"SEA\",\n newAddress: \"456 Good Place\",\n newCapacity: 40,\n },\n {\n officeId: \"NYC\",\n newAddress: \"123 Main Street\",\n newCapacity: 80,\n },\n ], { $returnEdits: true });\n\n expect(result).toMatchInlineSnapshot(`\n {\n \"addedLinks\": [],\n \"addedObjects\": [],\n \"deletedLinksCount\": 0,\n \"deletedObjectsCount\": 0,\n \"editedObjectTypes\": [\n \"Office\",\n ],\n \"modifiedObjects\": [\n {\n \"objectType\": \"Office\",\n \"primaryKey\": \"SEA\",\n },\n {\n \"objectType\": \"Office\",\n \"primaryKey\": \"NYC\",\n },\n ],\n \"type\": \"edits\",\n }\n `);\n });\n});\n\ndescribe(\"ActionResponse remapping\", () => {\n const actionResponse: SyncApplyActionResponseV2 = {\n edits: {\n type: \"edits\",\n edits: [{\n \"objectType\": \"Developer\",\n \"primaryKey\": \"PalantirDev\",\n \"type\": \"addObject\",\n }, {\n \"objectType\": \"Contractor\",\n \"primaryKey\": \"Contractor1\",\n \"type\": \"modifyObject\",\n }, {\n \"aSideObject\": { \"primaryKey\": \"key1\", \"objectType\": \"Office\" },\n \"linkTypeApiNameAtoB\": \"test\",\n \"linkTypeApiNameBtoA\": \"test\",\n \"bSideObject\": { \"primaryKey\": \"key2\", \"objectType\": \"Employee\" },\n \"type\": \"addLink\",\n }],\n deletedLinksCount: 0,\n deletedObjectsCount: 0,\n addedObjectCount: 1,\n modifiedObjectsCount: 1,\n addedLinksCount: 1,\n },\n };\n\n const batchActionResponse: BatchApplyActionResponseV2 = {\n edits: {\n type: \"edits\",\n edits: [{\n \"objectType\": \"Developer\",\n \"primaryKey\": \"PalantirDev\",\n \"type\": \"addObject\",\n }, {\n \"objectType\": \"Contractor\",\n \"primaryKey\": \"Contractor1\",\n \"type\": \"modifyObject\",\n }, {\n \"aSideObject\": { \"primaryKey\": \"key1\", \"objectType\": \"Office\" },\n \"linkTypeApiNameAtoB\": \"test\",\n \"linkTypeApiNameBtoA\": \"test\",\n \"bSideObject\": { \"primaryKey\": \"key2\", \"objectType\": \"Employee\" },\n \"type\": \"addLink\",\n }],\n deletedLinksCount: 0,\n deletedObjectsCount: 0,\n addedObjectCount: 1,\n modifiedObjectsCount: 1,\n addedLinksCount: 1,\n },\n };\n\n it(\"Correctly unpacks edits and editedObjectTypes\", () => {\n const remappedActionResponse = remapActionResponse(actionResponse);\n const remappedBatchActionResponse = remapActionResponse(\n batchActionResponse,\n );\n expect(remappedActionResponse).toMatchInlineSnapshot(`\n {\n \"addedLinks\": [\n {\n \"aSideObject\": {\n \"objectType\": \"Office\",\n \"primaryKey\": \"key1\",\n },\n \"bSideObject\": {\n \"objectType\": \"Employee\",\n \"primaryKey\": \"key2\",\n },\n \"linkTypeApiNameAtoB\": \"test\",\n \"linkTypeApiNameBtoA\": \"test\",\n },\n ],\n \"addedObjects\": [\n {\n \"objectType\": \"Developer\",\n \"primaryKey\": \"PalantirDev\",\n },\n ],\n \"deletedLinksCount\": 0,\n \"deletedObjectsCount\": 0,\n \"editedObjectTypes\": [\n \"Developer\",\n \"Contractor\",\n \"Office\",\n \"Employee\",\n ],\n \"modifiedObjects\": [\n {\n \"objectType\": \"Contractor\",\n \"primaryKey\": \"Contractor1\",\n },\n ],\n \"type\": \"edits\",\n }\n `);\n expect(remappedBatchActionResponse).toMatchInlineSnapshot(`\n {\n \"addedLinks\": [\n {\n \"aSideObject\": {\n \"objectType\": \"Office\",\n \"primaryKey\": \"key1\",\n },\n \"bSideObject\": {\n \"objectType\": \"Employee\",\n \"primaryKey\": \"key2\",\n },\n \"linkTypeApiNameAtoB\": \"test\",\n \"linkTypeApiNameBtoA\": \"test\",\n },\n ],\n \"addedObjects\": [\n {\n \"objectType\": \"Developer\",\n \"primaryKey\": \"PalantirDev\",\n },\n ],\n \"deletedLinksCount\": 0,\n \"deletedObjectsCount\": 0,\n \"editedObjectTypes\": [\n \"Developer\",\n \"Contractor\",\n \"Office\",\n \"Employee\",\n ],\n \"modifiedObjects\": [\n {\n \"objectType\": \"Contractor\",\n \"primaryKey\": \"Contractor1\",\n },\n ],\n \"type\": \"edits\",\n }\n `);\n });\n it(\"actions are enumerable\", async () => {\n const actions = Object.keys($Actions);\n expect(actions).toStrictEqual([\n \"actionTakesAttachment\",\n \"actionTakesMedia\",\n \"actionTakesObjectSet\",\n \"createFooInterface\",\n \"createOffice\",\n \"createOfficeAndEmployee\",\n \"createStructPerson\",\n \"deleteFooInterface\",\n \"moveOffice\",\n \"promoteEmployee\",\n \"promoteEmployeeObject\",\n ]);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SACEA,QAAQ,EACRC,YAAY,EACZC,qBAAqB,EACrBC,gBAAgB,EAChBC,kBAAkB,EAClBC,YAAY,EACZC,kBAAkB,EAClBC,kBAAkB,EAClBC,UAAU,QACL,4BAA4B;AAKnC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,mBAAmB;AACvD,SACEC,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,MAAM,EACNC,YAAY,EACZC,EAAE,EACFC,EAAE,QACG,QAAQ;AAEf,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,sBAAsB,QAAQ,+BAA+B;AACtE,SAASC,qBAAqB,QAAQ,4BAA4B;AAClE,SAASC,mBAAmB,QAAQ,kBAAkB;AAEtDR,QAAQ,CAAC,SAAS,EAAE,MAAM;EACxB,IAAIS,MAAc;EAClB,IAAIC,sBAA8B;EAElCX,SAAS,CAAC,YAAY;IACpBH,SAAS,CAACe,MAAM,CAAC,CAAC;IAClBF,MAAM,GAAGJ,YAAY,CACnB,4BAA4B,EAC5BjB,YAAY,EACZ,YAAY,eACd,CAAC;IACDsB,sBAAsB,GAAGL,YAAY,CACnC,sDAAsD,EACtDjB,YAAY,EACZ,YAAY,eACd,CAAC;EACH,CAAC,CAAC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C5B,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,EACd,yBAAyB,EACzB,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,CACxB,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"actions.test.js","names":["$Actions","$ontologyRid","actionTakesAttachment","actionTakesMedia","createFooInterface","createOffice","createStructPerson","deleteBarInterface","deleteFooInterface","moveOffice","apiServer","stubData","afterAll","beforeAll","describe","expect","expectTypeOf","it","vi","createClient","createAttachmentUpload","ActionValidationError","remapActionResponse","client","customEntryPointClient","listen","close","result","applyAction","officeId","address","capacity","$returnEdits","toEqualTypeOf","toMatchInlineSnapshot","undefinedResult","toBeUndefined","batchApplyAction","clientCreateOfficeMock","fn","newAddress","newCapacity","$validateOnly","fail","e","toBeInstanceOf","validation","toMatchTypeOf","name","city","state","zipcode","attachment","blob","attachmentUploadRequestBody","localAttachment1","filename","fileAttachment","Object","assign","result2","media_reference","mediaReference","deletedInterface","$objectType","$primaryKey","createdInterface","actionResponse","edits","type","deletedLinksCount","deletedObjectsCount","addedObjectCount","modifiedObjectsCount","addedLinksCount","batchActionResponse","remappedActionResponse","remappedBatchActionResponse","actions","keys","toStrictEqual"],"sources":["actions.test.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionEditResponse,\n ActionValidationResponse,\n AttachmentUpload,\n MediaReference,\n} from \"@osdk/api\";\nimport {\n $Actions,\n $ontologyRid,\n actionTakesAttachment,\n actionTakesMedia,\n createFooInterface,\n createOffice,\n createStructPerson,\n deleteBarInterface,\n deleteFooInterface,\n moveOffice,\n} from \"@osdk/client.test.ontology\";\nimport type {\n BatchApplyActionResponseV2,\n SyncApplyActionResponseV2,\n} from \"@osdk/foundry.ontologies\";\nimport { apiServer, stubData } from \"@osdk/shared.test\";\nimport {\n afterAll,\n beforeAll,\n describe,\n expect,\n expectTypeOf,\n it,\n vi,\n} from \"vitest\";\nimport type { Client } from \"../Client.js\";\nimport { createClient } from \"../createClient.js\";\nimport { createAttachmentUpload } from \"../object/AttachmentUpload.js\";\nimport { ActionValidationError } from \"./ActionValidationError.js\";\nimport { remapActionResponse } from \"./applyAction.js\";\n\ndescribe(\"actions\", () => {\n let client: Client;\n let customEntryPointClient: Client;\n\n beforeAll(async () => {\n apiServer.listen();\n client = createClient(\n \"https://stack.palantir.com\",\n $ontologyRid,\n async () => \"myAccessToken\",\n );\n customEntryPointClient = createClient(\n \"https://stack.palantirCustom.com/foo/first/someStuff\",\n $ontologyRid,\n async () => \"myAccessToken\",\n );\n });\n\n afterAll(() => {\n apiServer.close();\n });\n\n it(\"conditionally returns the edits\", async () => {\n const result = await client(createOffice).applyAction({\n officeId: \"NYC\",\n address: \"123 Main Street\",\n capacity: 100,\n }, { $returnEdits: true });\n\n expectTypeOf<typeof result>().toEqualTypeOf<ActionEditResponse>();\n expect(result).toMatchInlineSnapshot(`\n {\n \"addedLinks\": [],\n \"addedObjects\": [\n {\n \"objectType\": \"Office\",\n \"primaryKey\": \"NYC\",\n },\n ],\n \"deletedLinks\": [],\n \"deletedLinksCount\": 0,\n \"deletedObjects\": [],\n \"deletedObjectsCount\": 0,\n \"editedObjectTypes\": [\n \"Office\",\n ],\n \"modifiedObjects\": [],\n \"type\": \"edits\",\n }\n `);\n\n // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression\n const undefinedResult = await client(createOffice).applyAction({\n officeId: \"NYC\",\n address: \"123 Main Street\",\n capacity: 100,\n });\n\n expectTypeOf<typeof undefinedResult>().toEqualTypeOf<undefined>();\n expect(undefinedResult).toBeUndefined();\n\n const clientCreateOffice = client(createOffice).batchApplyAction;\n const clientCreateOfficeMock: typeof clientCreateOffice = vi.fn();\n void clientCreateOfficeMock([{\n officeId: \"NYC\",\n address: \"123 Main Street\",\n capacity: 100,\n }], { $returnEdits: true });\n });\n\n it(\"returns validation directly on validateOnly mode\", async () => {\n const result = await client(moveOffice).applyAction({\n officeId: \"SEA\",\n newAddress: \"456 Pike Place\",\n newCapacity: 40,\n }, {\n $validateOnly: true,\n });\n expectTypeOf<typeof result>().toEqualTypeOf<ActionValidationResponse>();\n\n expect(result).toMatchInlineSnapshot(`\n {\n \"parameters\": {},\n \"result\": \"INVALID\",\n \"submissionCriteria\": [],\n }\n `);\n });\n\n it(\"returns validation directly on validateOnly mode, with custom entry point in URL\", async () => {\n const result = await customEntryPointClient(moveOffice).applyAction({\n officeId: \"SEA\",\n newAddress: \"456 Pike Place\",\n newCapacity: 40,\n }, {\n $validateOnly: true,\n });\n expectTypeOf<typeof result>().toEqualTypeOf<ActionValidationResponse>();\n\n expect(result).toMatchInlineSnapshot(`\n {\n \"parameters\": {},\n \"result\": \"INVALID\",\n \"submissionCriteria\": [],\n }\n `);\n });\n\n it(\"throws on validation errors\", async () => {\n try {\n const result = await client(moveOffice).applyAction({\n officeId: \"SEA\",\n newAddress: \"456 Pike Place\",\n newCapacity: 40,\n }, {\n $returnEdits: true,\n });\n expect.fail(\"Should not reach here\");\n } catch (e) {\n expect(e).toBeInstanceOf(ActionValidationError);\n expect((e as ActionValidationError).validation).toMatchInlineSnapshot(`\n {\n \"parameters\": {},\n \"result\": \"INVALID\",\n \"submissionCriteria\": [],\n }\n `);\n }\n });\n\n it(\"Accepts structs\", async () => {\n const clientBoundActionTakesStruct = client(createStructPerson).applyAction;\n type InferredParamType = Parameters<\n typeof clientBoundActionTakesStruct\n >[0];\n expectTypeOf<\n {\n name: string;\n address: { city: string; state: string; zipcode: number };\n }\n >()\n .toMatchTypeOf<\n InferredParamType\n >();\n\n const result = await client(createStructPerson).applyAction({\n name: \"testMan\",\n address: { city: \"NYC\", state: \"NY\", zipcode: 12345 },\n });\n expectTypeOf<typeof result>().toEqualTypeOf<undefined>();\n expect(result).toBeUndefined();\n });\n\n it(\"Accepts attachments\", async () => {\n const clientBoundActionTakesAttachment = client(\n actionTakesAttachment,\n ).applyAction;\n\n type InferredParamType = Parameters<\n typeof clientBoundActionTakesAttachment\n >[0];\n\n expectTypeOf<{ attachment: string | AttachmentUpload }>().toMatchTypeOf<\n InferredParamType\n >();\n\n const clientBoundBatchActionTakesAttachment = client(\n actionTakesAttachment,\n ).batchApplyAction;\n type InferredBatchParamType = Parameters<\n typeof clientBoundBatchActionTakesAttachment\n >[0];\n\n expectTypeOf<{\n attachment: string | AttachmentUpload;\n }[]>().toMatchTypeOf<InferredBatchParamType>();\n\n const result = await client(actionTakesAttachment).applyAction({\n attachment: \"attachment.rid\",\n });\n\n expectTypeOf<typeof result>().toEqualTypeOf<undefined>();\n expect(result).toBeUndefined();\n });\n\n it(\"Accepts attachment uploads\", async () => {\n const clientBoundActionTakesAttachment = client(\n actionTakesAttachment,\n ).applyAction;\n type InferredParamType = Parameters<\n typeof clientBoundActionTakesAttachment\n >[0];\n const clientBoundBatchActionTakesAttachment = client(\n actionTakesAttachment,\n ).batchApplyAction;\n type InferredBatchParamType = Parameters<\n typeof clientBoundBatchActionTakesAttachment\n >[0];\n\n expectTypeOf<\n {\n attachment:\n | string\n | AttachmentUpload\n | Blob & { readonly name: string };\n }\n >().toMatchTypeOf<\n InferredParamType\n >();\n expectTypeOf<\n {\n attachment:\n | string\n | AttachmentUpload\n | Blob & { readonly name: string };\n }[]\n >().toMatchTypeOf<\n InferredBatchParamType\n >();\n\n const blob =\n stubData.attachmentUploadRequestBody[stubData.localAttachment1.filename];\n\n const attachment = createAttachmentUpload(blob, \"file1.txt\");\n\n // Mimics the Web file API (https://developer.mozilla.org/en-US/docs/Web/API/File). The File constructor is only available in Node 19.2.0 and above\n const fileAttachment = Object.assign(blob, { name: \"file1.txt\" });\n\n const result = await client(actionTakesAttachment).applyAction({\n attachment,\n });\n\n const result2 = await client(actionTakesAttachment).applyAction({\n attachment: fileAttachment,\n });\n\n expectTypeOf<typeof result>().toEqualTypeOf<undefined>();\n expect(result).toBeUndefined();\n\n expectTypeOf<typeof result2>().toEqualTypeOf<undefined>();\n expect(result2).toBeUndefined();\n });\n\n it(\"Accepts media reference\", async () => {\n const clientBoundActionTakesMedia = client(\n actionTakesMedia,\n ).applyAction;\n type InferredParamType = Parameters<\n typeof clientBoundActionTakesMedia\n >[0];\n\n expectTypeOf<\n {\n media_reference: MediaReference;\n }\n >().toMatchTypeOf<\n InferredParamType\n >();\n\n const result = await client(actionTakesMedia).applyAction({\n media_reference: stubData.mediaReference,\n });\n\n expectTypeOf<typeof result>().toEqualTypeOf<undefined>();\n expect(result).toBeUndefined();\n });\n\n it(\"Accepts interfaces\", async () => {\n const clientBoundTakesInterface = client(\n deleteFooInterface,\n ).applyAction;\n\n type InferredParamType = Parameters<\n typeof clientBoundTakesInterface\n >[0];\n\n expectTypeOf<\n {\n deletedInterface: {\n $objectType: \"Employee\" | \"Person\";\n $primaryKey: string | number;\n };\n }\n >().toMatchTypeOf<\n InferredParamType\n >();\n\n const clientBoundBatchActionTakesInterface = client(\n deleteFooInterface,\n ).batchApplyAction;\n type InferredBatchParamType = Parameters<\n typeof clientBoundBatchActionTakesInterface\n >[0];\n\n expectTypeOf<{\n deletedInterface: {\n $objectType: \"Employee\" | \"Person\";\n $primaryKey: string | number;\n };\n }[]>().toMatchTypeOf<InferredBatchParamType>();\n\n const result = await client(deleteFooInterface).applyAction({\n deletedInterface: {\n $objectType: \"Employee\",\n $primaryKey: 1,\n },\n });\n\n expectTypeOf<typeof result>().toEqualTypeOf<undefined>();\n expect(result).toBeUndefined();\n });\n it(\"Accepts interfaces if implementing object types unknown\", async () => {\n const clientBoundTakesInterface = client(\n deleteBarInterface,\n ).applyAction;\n\n type InferredParamType = Parameters<\n typeof clientBoundTakesInterface\n >[0];\n\n expectTypeOf<\n {\n deletedInterface: {\n $objectType: string;\n $primaryKey: string | number;\n };\n }\n >().toMatchTypeOf<\n InferredParamType\n >();\n\n const clientBoundBatchActionTakesInterface = client(\n deleteBarInterface,\n ).batchApplyAction;\n type InferredBatchParamType = Parameters<\n typeof clientBoundBatchActionTakesInterface\n >[0];\n\n expectTypeOf<{\n deletedInterface: {\n $objectType: string;\n $primaryKey: string | number;\n };\n }[]>().toMatchTypeOf<InferredBatchParamType>();\n });\n it(\"Accepts object type refs\", async () => {\n const clientBoundTakesObjectType = client(\n createFooInterface,\n ).applyAction;\n\n type InferredParamType = Parameters<\n typeof clientBoundTakesObjectType\n >[0];\n\n expectTypeOf<\n {\n createdInterface: string;\n }\n >().toMatchTypeOf<\n InferredParamType\n >();\n\n const clientBoundBatchActionTakesObjectType = client(\n createFooInterface,\n ).batchApplyAction;\n type InferredBatchParamType = Parameters<\n typeof clientBoundBatchActionTakesObjectType\n >[0];\n\n expectTypeOf<{\n createdInterface: string;\n }[]>().toMatchTypeOf<InferredBatchParamType>();\n\n const result = await client(createFooInterface).applyAction({\n createdInterface: \"UnderlyingObject\",\n });\n\n expectTypeOf<typeof result>().toEqualTypeOf<undefined>();\n expect(result).toBeUndefined();\n });\n it(\"conditionally returns edits in batch mode\", async () => {\n const result = await client(moveOffice).batchApplyAction([\n {\n officeId: \"SEA\",\n newAddress: \"456 Good Place\",\n newCapacity: 40,\n },\n {\n officeId: \"NYC\",\n newAddress: \"123 Main Street\",\n newCapacity: 80,\n },\n ], { $returnEdits: true });\n\n expect(result).toMatchInlineSnapshot(`\n {\n \"addedLinks\": [],\n \"addedObjects\": [],\n \"deletedLinks\": [],\n \"deletedLinksCount\": 0,\n \"deletedObjects\": [],\n \"deletedObjectsCount\": 0,\n \"editedObjectTypes\": [\n \"Office\",\n ],\n \"modifiedObjects\": [\n {\n \"objectType\": \"Office\",\n \"primaryKey\": \"SEA\",\n },\n {\n \"objectType\": \"Office\",\n \"primaryKey\": \"NYC\",\n },\n ],\n \"type\": \"edits\",\n }\n `);\n });\n});\n\ndescribe(\"ActionResponse remapping\", () => {\n const actionResponse: SyncApplyActionResponseV2 = {\n edits: {\n type: \"edits\",\n edits: [{\n \"objectType\": \"Developer\",\n \"primaryKey\": \"PalantirDev\",\n \"type\": \"addObject\",\n }, {\n \"objectType\": \"Contractor\",\n \"primaryKey\": \"Contractor1\",\n \"type\": \"modifyObject\",\n }, {\n \"aSideObject\": { \"primaryKey\": \"key1\", \"objectType\": \"Office\" },\n \"linkTypeApiNameAtoB\": \"test\",\n \"linkTypeApiNameBtoA\": \"test\",\n \"bSideObject\": { \"primaryKey\": \"key2\", \"objectType\": \"Employee\" },\n \"type\": \"addLink\",\n }, {\n \"objectType\": \"Developer\",\n \"primaryKey\": \"PalantirDev\",\n \"type\": \"deleteObject\",\n }, {\n \"aSideObject\": { \"primaryKey\": \"key1\", \"objectType\": \"Office\" },\n \"linkTypeApiNameAtoB\": \"test\",\n \"linkTypeApiNameBtoA\": \"test\",\n \"bSideObject\": { \"primaryKey\": \"key2\", \"objectType\": \"Employee\" },\n \"type\": \"deleteLink\",\n }],\n deletedLinksCount: 0,\n deletedObjectsCount: 1,\n addedObjectCount: 1,\n modifiedObjectsCount: 1,\n addedLinksCount: 1,\n },\n };\n\n const batchActionResponse: BatchApplyActionResponseV2 = {\n edits: {\n type: \"edits\",\n edits: [{\n \"objectType\": \"Developer\",\n \"primaryKey\": \"PalantirDev\",\n \"type\": \"addObject\",\n }, {\n \"objectType\": \"Contractor\",\n \"primaryKey\": \"Contractor1\",\n \"type\": \"modifyObject\",\n }, {\n \"aSideObject\": { \"primaryKey\": \"key1\", \"objectType\": \"Office\" },\n \"linkTypeApiNameAtoB\": \"test\",\n \"linkTypeApiNameBtoA\": \"test\",\n \"bSideObject\": { \"primaryKey\": \"key2\", \"objectType\": \"Employee\" },\n \"type\": \"addLink\",\n }],\n deletedLinksCount: 0,\n deletedObjectsCount: 0,\n addedObjectCount: 1,\n modifiedObjectsCount: 1,\n addedLinksCount: 1,\n },\n };\n\n it(\"Correctly unpacks edits and editedObjectTypes\", () => {\n const remappedActionResponse = remapActionResponse(actionResponse);\n const remappedBatchActionResponse = remapActionResponse(\n batchActionResponse,\n );\n expect(remappedActionResponse).toMatchInlineSnapshot(`\n {\n \"addedLinks\": [\n {\n \"aSideObject\": {\n \"objectType\": \"Office\",\n \"primaryKey\": \"key1\",\n },\n \"bSideObject\": {\n \"objectType\": \"Employee\",\n \"primaryKey\": \"key2\",\n },\n \"linkTypeApiNameAtoB\": \"test\",\n \"linkTypeApiNameBtoA\": \"test\",\n },\n ],\n \"addedObjects\": [\n {\n \"objectType\": \"Developer\",\n \"primaryKey\": \"PalantirDev\",\n },\n ],\n \"deletedLinks\": [\n {\n \"aSideObject\": {\n \"objectType\": \"Office\",\n \"primaryKey\": \"key1\",\n },\n \"bSideObject\": {\n \"objectType\": \"Employee\",\n \"primaryKey\": \"key2\",\n },\n \"linkTypeApiNameAtoB\": \"test\",\n \"linkTypeApiNameBtoA\": \"test\",\n },\n ],\n \"deletedLinksCount\": 0,\n \"deletedObjects\": [\n {\n \"objectType\": \"Developer\",\n \"primaryKey\": \"PalantirDev\",\n },\n ],\n \"deletedObjectsCount\": 1,\n \"editedObjectTypes\": [\n \"Developer\",\n \"Contractor\",\n \"Office\",\n \"Employee\",\n ],\n \"modifiedObjects\": [\n {\n \"objectType\": \"Contractor\",\n \"primaryKey\": \"Contractor1\",\n },\n ],\n \"type\": \"edits\",\n }\n `);\n expect(remappedBatchActionResponse).toMatchInlineSnapshot(`\n {\n \"addedLinks\": [\n {\n \"aSideObject\": {\n \"objectType\": \"Office\",\n \"primaryKey\": \"key1\",\n },\n \"bSideObject\": {\n \"objectType\": \"Employee\",\n \"primaryKey\": \"key2\",\n },\n \"linkTypeApiNameAtoB\": \"test\",\n \"linkTypeApiNameBtoA\": \"test\",\n },\n ],\n \"addedObjects\": [\n {\n \"objectType\": \"Developer\",\n \"primaryKey\": \"PalantirDev\",\n },\n ],\n \"deletedLinks\": [],\n \"deletedLinksCount\": 0,\n \"deletedObjects\": [],\n \"deletedObjectsCount\": 0,\n \"editedObjectTypes\": [\n \"Developer\",\n \"Contractor\",\n \"Office\",\n \"Employee\",\n ],\n \"modifiedObjects\": [\n {\n \"objectType\": \"Contractor\",\n \"primaryKey\": \"Contractor1\",\n },\n ],\n \"type\": \"edits\",\n }\n `);\n });\n it(\"actions are enumerable\", async () => {\n const actions = Object.keys($Actions);\n expect(actions).toStrictEqual([\n \"actionTakesAttachment\",\n \"actionTakesMedia\",\n \"actionTakesObjectSet\",\n \"createFooInterface\",\n \"createOffice\",\n \"createOfficeAndEmployee\",\n \"createStructPerson\",\n \"deleteBarInterface\",\n \"deleteFooInterface\",\n \"moveOffice\",\n \"promoteEmployee\",\n \"promoteEmployeeObject\",\n ]);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SACEA,QAAQ,EACRC,YAAY,EACZC,qBAAqB,EACrBC,gBAAgB,EAChBC,kBAAkB,EAClBC,YAAY,EACZC,kBAAkB,EAClBC,kBAAkB,EAClBC,kBAAkB,EAClBC,UAAU,QACL,4BAA4B;AAKnC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,mBAAmB;AACvD,SACEC,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,MAAM,EACNC,YAAY,EACZC,EAAE,EACFC,EAAE,QACG,QAAQ;AAEf,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,sBAAsB,QAAQ,+BAA+B;AACtE,SAASC,qBAAqB,QAAQ,4BAA4B;AAClE,SAASC,mBAAmB,QAAQ,kBAAkB;AAEtDR,QAAQ,CAAC,SAAS,EAAE,MAAM;EACxB,IAAIS,MAAc;EAClB,IAA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CAAC;EAEDzD,EAAE,CAAC,+CAA+C,EAAE,MAAM;IACxD,MAAM2D,sBAAsB,GAAGtD,mBAAmB,CAAC6C,cAAc,CAAC;IAClE,MAAMU,2BAA2B,GAAGvD,mBAAmB,CACrDqD,mBACF,CAAC;IACD5D,MAAM,CAAC6D,sBAAsB,CAAC,CAAC1C,qBAAqB,CAAC;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;IACFnB,MAAM,CAAC8D,2BAA2B,CAAC,CAAC3C,qBAAqB,CAAC;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;EACJ,CAAC,CAAC;EACFjB,EAAE,CAAC,wBAAwB,EAAE,YAAY;IACvC,MAAM6D,OAAO,GAAGpB,MAAM,CAACqB,IAAI,CAAC/E,QAAQ,CAAC;IACrCe,MAAM,CAAC+D,OAAO,CAAC,CAACE,aAAa,CAAC,CAC5B,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,EACd,yBAAyB,EACzB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,CACxB,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import * as OntologiesV2 from "@osdk/foundry.ontologies";
|
|
18
|
-
import invariant from "tiny-invariant";
|
|
19
18
|
import { addUserAgentAndRequestContextHeaders } from "../util/addUserAgentAndRequestContextHeaders.js";
|
|
20
19
|
import { augmentRequestContext } from "../util/augmentRequestContext.js";
|
|
21
20
|
import { toDataValue } from "../util/toDataValue.js";
|
|
@@ -38,7 +37,7 @@ export async function applyAction(client, action, parameters, options = {}) {
|
|
|
38
37
|
parameters: await remapActionParams(parameters, client),
|
|
39
38
|
options: {
|
|
40
39
|
mode: options?.$validateOnly ? "VALIDATE_ONLY" : "VALIDATE_AND_EXECUTE",
|
|
41
|
-
returnEdits: options?.$returnEdits ? "
|
|
40
|
+
returnEdits: options?.$returnEdits ? "ALL_V2_WITH_DELETIONS" : "NONE"
|
|
42
41
|
}
|
|
43
42
|
});
|
|
44
43
|
if (options?.$validateOnly) {
|
|
@@ -77,35 +76,42 @@ export function remapActionResponse(response) {
|
|
|
77
76
|
deletedLinksCount: editResponses.deletedLinksCount,
|
|
78
77
|
deletedObjectsCount: editResponses.deletedObjectsCount,
|
|
79
78
|
addedLinks: [],
|
|
79
|
+
deletedLinks: [],
|
|
80
80
|
addedObjects: [],
|
|
81
|
+
deletedObjects: [],
|
|
81
82
|
modifiedObjects: [],
|
|
82
83
|
editedObjectTypes: []
|
|
83
84
|
};
|
|
84
85
|
const editedObjectTypesSet = new Set();
|
|
85
86
|
for (const edit of editResponses.edits) {
|
|
86
|
-
if (edit.type === "addLink") {
|
|
87
|
-
|
|
87
|
+
if (edit.type === "addLink" || edit.type === "deleteLink") {
|
|
88
|
+
const osdkEdit = {
|
|
88
89
|
linkTypeApiNameAtoB: edit.linkTypeApiNameAtoB,
|
|
89
90
|
linkTypeApiNameBtoA: edit.linkTypeApiNameBtoA,
|
|
90
91
|
aSideObject: edit.aSideObject,
|
|
91
92
|
bSideObject: edit.bSideObject
|
|
92
|
-
}
|
|
93
|
+
};
|
|
94
|
+
edit.type === "addLink" ? remappedActionResponse.addedLinks.push(osdkEdit) : remappedActionResponse.deletedLinks?.push(osdkEdit);
|
|
93
95
|
editedObjectTypesSet.add(edit.aSideObject.objectType);
|
|
94
96
|
editedObjectTypesSet.add(edit.bSideObject.objectType);
|
|
95
|
-
} else if (edit.type === "addObject") {
|
|
96
|
-
|
|
97
|
-
objectType: edit.objectType,
|
|
98
|
-
primaryKey: edit.primaryKey
|
|
99
|
-
});
|
|
100
|
-
editedObjectTypesSet.add(edit.objectType);
|
|
101
|
-
} else if (edit.type === "modifyObject") {
|
|
102
|
-
remappedActionResponse.modifiedObjects.push({
|
|
97
|
+
} else if (edit.type === "addObject" || edit.type === "deleteObject" || edit.type === "modifyObject") {
|
|
98
|
+
const osdkEdit = {
|
|
103
99
|
objectType: edit.objectType,
|
|
104
100
|
primaryKey: edit.primaryKey
|
|
105
|
-
}
|
|
101
|
+
};
|
|
102
|
+
if (edit.type === "addObject") {
|
|
103
|
+
remappedActionResponse.addedObjects.push(osdkEdit);
|
|
104
|
+
} else if (edit.type === "deleteObject") {
|
|
105
|
+
remappedActionResponse.deletedObjects?.push(osdkEdit);
|
|
106
|
+
} else if (edit.type === "modifyObject") {
|
|
107
|
+
remappedActionResponse.modifiedObjects.push(osdkEdit);
|
|
108
|
+
}
|
|
106
109
|
editedObjectTypesSet.add(edit.objectType);
|
|
107
110
|
} else {
|
|
108
|
-
process.env.NODE_ENV !== "production"
|
|
111
|
+
if (process.env.NODE_ENV !== "production") {
|
|
112
|
+
// eslint-disable-next-line no-console
|
|
113
|
+
console.warn(`Unexpected edit type: ${JSON.stringify(edit)}`);
|
|
114
|
+
}
|
|
109
115
|
}
|
|
110
116
|
}
|
|
111
117
|
remappedActionResponse.editedObjectTypes = [...editedObjectTypesSet];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyAction.js","names":["OntologiesV2","invariant","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","addedObjects","modifiedObjects","editedObjectTypes","editedObjectTypesSet","Set","edit","push","linkTypeApiNameAtoB","linkTypeApiNameBtoA","aSideObject","bSideObject","add","objectType","primaryKey","process","env","NODE_ENV"],"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 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 invariant from \"tiny-invariant\";\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 CompileTimeActionMetadata<\n T extends ActionDefinition<any>,\n> = NonNullable<T[\"__DefinitionMetadata\"]>;\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\"\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 addedObjects: [],\n modifiedObjects: [],\n editedObjectTypes: [],\n };\n\n const editedObjectTypesSet = new Set<string>();\n for (const edit of editResponses.edits) {\n if (edit.type === \"addLink\") {\n remappedActionResponse.addedLinks.push(\n {\n linkTypeApiNameAtoB: edit.linkTypeApiNameAtoB,\n linkTypeApiNameBtoA: edit.linkTypeApiNameBtoA,\n aSideObject: edit.aSideObject,\n bSideObject: edit.bSideObject,\n },\n );\n editedObjectTypesSet.add(edit.aSideObject.objectType);\n editedObjectTypesSet.add(edit.bSideObject.objectType);\n } else if (edit.type === \"addObject\") {\n remappedActionResponse.addedObjects.push(\n {\n objectType: edit.objectType,\n primaryKey: edit.primaryKey,\n },\n );\n editedObjectTypesSet.add(edit.objectType);\n } else if (edit.type === \"modifyObject\") {\n remappedActionResponse.modifiedObjects.push({\n objectType: edit.objectType,\n primaryKey: edit.primaryKey,\n });\n editedObjectTypesSet.add(edit.objectType);\n } else {\n invariant(false, \"Unknown edit type\");\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;;AAiBA,OAAO,KAAKA,YAAY,MAAM,0BAA0B;AACxD,OAAOC,SAAS,MAAM,gBAAgB;AAEtC,SAASC,oCAAoC,QAAQ,iDAAiD;AACtG,SAASC,qBAAqB,QAAQ,kCAAkC;AAIxE,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,qBAAqB,QAAQ,4BAA4B;AAyElE,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,MAAMf,YAAY,CAACgB,OAAO,CAACC,UAAU,CACpDN,iBAAiB,EACjB,MAAMJ,MAAM,CAACW,WAAW,EACxBV,MAAM,CAACW,OAAO,EACd;MACEC,QAAQ,EAAEX,UAAU,GAChB,MAAMY,sBAAsB,CAACZ,UAAU,EAAEF,MAAM,CAAC,GAChD,EAAE;MACNG,OAAO,EAAE;QACPY,W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,IAAI,CAACI,WAAW;UAC7BC,WAAW,EAAEL,IAAI,CAACK;QACpB,CACF,CAAC;QACDP,oBAAoB,CAACQ,GAAG,CAACN,IAAI,CAACI,WAAW,CAACG,UAAU,CAAC;QACrDT,oBAAoB,CAACQ,GAAG,CAACN,IAAI,CAACK,WAAW,CAACE,UAAU,CAAC;MACvD,CAAC,MAAM,IAAIP,IAAI,CAAC9B,IAAI,KAAK,WAAW,EAAE;QACpCqB,sBAAsB,CAACI,YAAY,CAACM,IAAI,CACtC;UACEM,UAAU,EAAEP,IAAI,CAACO,UAAU;UAC3BC,UAAU,EAAER,IAAI,CAACQ;QACnB,CACF,CAAC;QACDV,oBAAoB,CAACQ,GAAG,CAACN,IAAI,CAACO,UAAU,CAAC;MAC3C,CAAC,MAAM,IAAIP,IAAI,CAAC9B,IAAI,KAAK,cAAc,EAAE;QACvCqB,sBAAsB,CAACK,eAAe,CAACK,IAAI,CAAC;UAC1CM,UAAU,EAAEP,IAAI,CAACO,UAAU;UAC3BC,UAAU,EAAER,IAAI,CAACQ;QACnB,CAAC,CAAC;QACFV,oBAAoB,CAACQ,GAAG,CAACN,IAAI,CAACO,UAAU,CAAC;MAC3C,CAAC,MAAM;QACLE,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAAjE,SAAS,QAAQ,mBAAmB,IAApCA,SAAS;MACX;IACF;IACA6C,sBAAsB,CAACM,iBAAiB,GAAG,CAAC,GAAGC,oBAAoB,CAAC;IACpE,OAAOP,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","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 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 CompileTimeActionMetadata<\n T extends ActionDefinition<any>,\n> = NonNullable<T[\"__DefinitionMetadata\"]>;\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;;AAiBA,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;AAyElE,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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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":[]}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference, __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid, __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks } from "@osdk/api/unstable";
|
|
17
|
+
import { __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference, __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid, __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchPageByRid, __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks } from "@osdk/api/unstable";
|
|
18
18
|
import * as OntologiesV2 from "@osdk/foundry.ontologies";
|
|
19
19
|
import { symbolClientContext as oldSymbolClientContext } from "@osdk/shared.client";
|
|
20
20
|
import { createBulkLinksAsyncIterFactory } from "./__unstable/createBulkLinksAsyncIterFactory.js";
|
|
@@ -22,6 +22,7 @@ import { applyAction } from "./actions/applyAction.js";
|
|
|
22
22
|
import { additionalContext } from "./Client.js";
|
|
23
23
|
import { createMinimalClient } from "./createMinimalClient.js";
|
|
24
24
|
import { fetchMetadataInternal } from "./fetchMetadata.js";
|
|
25
|
+
import { fetchPage } from "./object/fetchPage.js";
|
|
25
26
|
import { fetchSingle } from "./object/fetchSingle.js";
|
|
26
27
|
import { createObjectSet } from "./objectSet/createObjectSet.js";
|
|
27
28
|
import { applyQuery } from "./queries/applyQuery.js";
|
|
@@ -85,7 +86,7 @@ baseUrl, ontologyRid, tokenProvider, options = undefined, fetchFn = fetch) {
|
|
|
85
86
|
case __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid.name:
|
|
86
87
|
return {
|
|
87
88
|
fetchOneByRid: async (objectType, rid, options) => {
|
|
88
|
-
return await fetchSingle(clientCtx, objectType, options, createWithRid(rid));
|
|
89
|
+
return await fetchSingle(clientCtx, objectType, options, createWithRid([rid]));
|
|
89
90
|
}
|
|
90
91
|
};
|
|
91
92
|
case __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference.name:
|
|
@@ -103,6 +104,12 @@ baseUrl, ontologyRid, tokenProvider, options = undefined, fetchFn = fetch) {
|
|
|
103
104
|
});
|
|
104
105
|
}
|
|
105
106
|
};
|
|
107
|
+
case __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchPageByRid.name:
|
|
108
|
+
return {
|
|
109
|
+
fetchPageByRid: async (objectOrInterfaceType, rids, options = {}) => {
|
|
110
|
+
return await fetchPage(clientCtx, objectOrInterfaceType, options, createWithRid(rids));
|
|
111
|
+
}
|
|
112
|
+
};
|
|
106
113
|
}
|
|
107
114
|
throw new Error("not implemented");
|
|
108
115
|
} else {
|
|
@@ -125,10 +132,10 @@ baseUrl, ontologyRid, tokenProvider, options = undefined, fetchFn = fetch) {
|
|
|
125
132
|
return client;
|
|
126
133
|
}
|
|
127
134
|
export const createClient = createClientInternal.bind(undefined, createObjectSet);
|
|
128
|
-
function createWithRid(
|
|
135
|
+
function createWithRid(rids) {
|
|
129
136
|
return {
|
|
130
137
|
type: "static",
|
|
131
|
-
"objects":
|
|
138
|
+
"objects": rids
|
|
132
139
|
};
|
|
133
140
|
}
|
|
134
141
|
//# sourceMappingURL=createClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.js","names":["__EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference","__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid","__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks","OntologiesV2","symbolClientContext","oldSymbolClientContext","createBulkLinksAsyncIterFactory","applyAction","additionalContext","createMinimalClient","fetchMetadataInternal","fetchSingle","createObjectSet","applyQuery","ActionInvoker","constructor","clientCtx","actionDef","bind","undefined","batchApplyAction","QueryInvoker","queryDef","executeFunction","createClientInternal","objectSetFactory","baseUrl","ontologyRid","tokenProvider","options","fetchFn","fetch","startsWith","Error","then","fetchMetadata","client","Object","defineProperties","o","type","name","getBulkLinks","fetchOneByRid","objectType","rid","createWithRid","createMediaReference","args","data","fileName","propertyType","MediaReferenceProperties","upload","apiName","mediaItemPath","preview","value","createClient"],"sources":["createClient.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 ActionDefinition,\n FilteredPropertyKeys,\n InterfaceDefinition,\n NullabilityAdherence,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SelectArg,\n} from \"@osdk/api\";\nimport type {\n Experiment,\n ExperimentFns,\n MinimalObjectSet,\n} from \"@osdk/api/unstable\";\nimport {\n __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks,\n} from \"@osdk/api/unstable\";\nimport type { ObjectSet as WireObjectSet } from \"@osdk/foundry.ontologies\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport { symbolClientContext as oldSymbolClientContext } from \"@osdk/shared.client\";\nimport { createBulkLinksAsyncIterFactory } from \"./__unstable/createBulkLinksAsyncIterFactory.js\";\nimport type { ActionSignatureFromDef } from \"./actions/applyAction.js\";\nimport { applyAction } from \"./actions/applyAction.js\";\nimport { additionalContext, type Client } from \"./Client.js\";\nimport { createMinimalClient } from \"./createMinimalClient.js\";\nimport { fetchMetadataInternal } from \"./fetchMetadata.js\";\nimport type { Logger } from \"./Logger.js\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport { fetchSingle } from \"./object/fetchSingle.js\";\nimport { createObjectSet } from \"./objectSet/createObjectSet.js\";\nimport type { ObjectSetFactory } from \"./objectSet/ObjectSetFactory.js\";\nimport { applyQuery } from \"./queries/applyQuery.js\";\nimport type { QuerySignatureFromDef } from \"./queries/types.js\";\n\n// We import it this way to keep compatible with CJS. If we referenced the\n// value of `symbolClientContext` directly, then we would have to a dynamic import\n// in `createClientInternal` which would make it async and a break.\n// Since this is just a string in `@osdk/shared.client2` instead of a symbol,\n// we can safely perform this trick.\ntype newSymbolClientContext =\n // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n typeof import(\"@osdk/shared.client2\").symbolClientContext;\n\nclass ActionInvoker<Q extends ActionDefinition<any>>\n implements ActionSignatureFromDef<Q>\n{\n constructor(\n clientCtx: MinimalClient,\n actionDef: ActionDefinition<any>,\n ) {\n // We type the property as a generic function as binding `applyAction`\n // doesn't return a type thats all that useful anyway\n // The implements covers us for the most part here as this exact type doesn't\n // escape this file\n this.applyAction = applyAction.bind(undefined, clientCtx, actionDef);\n this.batchApplyAction = applyAction.bind(undefined, clientCtx, actionDef);\n }\n\n applyAction: (...args: any[]) => any;\n batchApplyAction: (...args: any[]) => any;\n}\n\nclass QueryInvoker<Q extends QueryDefinition<any>>\n implements QuerySignatureFromDef<Q>\n{\n constructor(\n clientCtx: MinimalClient,\n queryDef: QueryDefinition<any>,\n ) {\n this.executeFunction = applyQuery.bind(undefined, clientCtx, queryDef);\n }\n\n executeFunction: (...args: any[]) => any;\n}\n\n/** @internal */\nexport function createClientInternal(\n objectSetFactory: ObjectSetFactory<any, any>, // first so i can bind\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n options: { logger?: Logger } | undefined = undefined,\n fetchFn: typeof globalThis.fetch = fetch,\n): Client {\n if (typeof ontologyRid === \"string\") {\n if (!ontologyRid.startsWith(\"ri.\")) {\n throw new Error(\"Invalid ontology RID\");\n }\n } else {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n ontologyRid.then((ontologyRid) => {\n if (!ontologyRid.startsWith(\"ri.\")) {\n // FIXME this promise is not await so this just shows up as an unhandled promise rejection\n throw new Error(\"Invalid ontology RID\");\n }\n });\n }\n\n const clientCtx: MinimalClient = createMinimalClient(\n { ontologyRid },\n baseUrl,\n tokenProvider,\n options,\n fetchFn,\n objectSetFactory,\n );\n\n function clientFn<\n T extends\n | ObjectOrInterfaceDefinition\n | ActionDefinition<any>\n | QueryDefinition<any>\n | Experiment<\"2.0.8\">\n | Experiment<\"2.1.0\">,\n >(o: T): T extends ObjectTypeDefinition ? ObjectSet<T>\n : T extends InterfaceDefinition ? MinimalObjectSet<T>\n : T extends ActionDefinition<any> ? ActionSignatureFromDef<T>\n : T extends QueryDefinition<any> ? QuerySignatureFromDef<T>\n : T extends Experiment<\"2.0.8\"> | Experiment<\"2.1.0\">\n ? { invoke: ExperimentFns<T> }\n : never\n {\n if (o.type === \"object\" || o.type === \"interface\") {\n return objectSetFactory(o, clientCtx) as any;\n } else if (o.type === \"action\") {\n return new ActionInvoker(\n clientCtx,\n o,\n ) as (T extends ActionDefinition<any>\n // first `as` to the action definition for our \"real\" typecheck\n ? ActionSignatureFromDef<T>\n : never) as any; // then as any for dealing with the conditional return value\n } else if (o.type === \"query\") {\n return new QueryInvoker(\n clientCtx,\n o,\n ) as (T extends QueryDefinition<any> ? QuerySignatureFromDef<T>\n : never) as any;\n } else if (o.type === \"experiment\") {\n switch (o.name) {\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks.name:\n return {\n getBulkLinks: createBulkLinksAsyncIterFactory(\n clientCtx,\n ),\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid.name:\n return {\n fetchOneByRid: async <\n Q extends ObjectTypeDefinition,\n const L extends PropertyKeys<Q>,\n const R extends boolean,\n const S extends false | \"throw\" = NullabilityAdherence.Default,\n >(\n objectType: Q,\n rid: string,\n options: SelectArg<Q, L, R, S>,\n ) => {\n return await fetchSingle(\n clientCtx,\n objectType,\n options,\n createWithRid(\n rid,\n ),\n ) as Osdk<Q>;\n },\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference.name:\n return {\n createMediaReference: async <\n Q extends ObjectTypeDefinition,\n const L extends FilteredPropertyKeys<Q, \"mediaReference\">,\n >(args: {\n data: Blob;\n fileName: string;\n objectType: Q;\n propertyType: L;\n }) => {\n const { data, fileName, objectType, propertyType } = args;\n return await OntologiesV2.MediaReferenceProperties.upload(\n clientCtx,\n await clientCtx.ontologyRid,\n objectType.apiName,\n propertyType as string,\n data,\n {\n mediaItemPath: fileName,\n preview: true,\n },\n );\n },\n } as any;\n }\n\n throw new Error(\"not implemented\");\n } else {\n throw new Error(\"not implemented\");\n }\n }\n\n const fetchMetadata = fetchMetadataInternal.bind(\n undefined,\n clientCtx,\n );\n\n const symbolClientContext: newSymbolClientContext = \"__osdkClientContext\";\n\n const client: Client = Object.defineProperties<Client>(\n clientFn as Client,\n {\n [oldSymbolClientContext]: {\n value: clientCtx,\n },\n [symbolClientContext]: {\n value: clientCtx,\n },\n [additionalContext]: {\n value: clientCtx,\n },\n fetchMetadata: {\n value: fetchMetadata,\n },\n } satisfies Record<keyof Client, PropertyDescriptor>,\n );\n\n return client;\n}\n\nexport const createClient: (\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n options?: {\n logger?: Logger;\n } | undefined,\n fetchFn?: typeof fetch | undefined,\n) => Client = createClientInternal.bind(\n undefined,\n createObjectSet,\n);\n\nfunction createWithRid(\n rid: string,\n) {\n const withRid: WireObjectSet = {\n type: \"static\",\n \"objects\": [rid],\n };\n\n return withRid;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoBA,SACEA,uDAAuD,EACvDC,gDAAgD,EAChDC,+CAA+C,QAC1C,oBAAoB;AAE3B,OAAO,KAAKC,YAAY,MAAM,0BAA0B;AACxD,SAASC,mBAAmB,IAAIC,sBAAsB,QAAQ,qBAAqB;AACnF,SAASC,+BAA+B,QAAQ,iDAAiD;AAEjG,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,iBAAiB,QAAqB,aAAa;AAC5D,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,qBAAqB,QAAQ,oBAAoB;AAG1D,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,eAAe,QAAQ,gCAAgC;AAEhE,SAASC,UAAU,QAAQ,yBAAyB;;AAGpD;AACA;AACA;AACA;AACA;;AAKA,MAAMC,aAAa,CAEnB;EACEC,WAAWA,CACTC,SAAwB,EACxBC,SAAgC,EAChC;IACA;IACA;IACA;IACA;IACA,IAAI,CAACV,WAAW,GAAGA,WAAW,CAACW,IAAI,CAACC,SAAS,EAAEH,SAAS,EAAEC,SAAS,CAAC;IACpE,IAAI,CAACG,gBAAgB,GAAGb,WAAW,CAACW,IAAI,CAACC,SAAS,EAAEH,SAAS,EAAEC,SAAS,CAAC;EAC3E;AAIF;AAEA,MAAMI,YAAY,CAElB;EACEN,WAAWA,CACTC,SAAwB,EACxBM,QAA8B,EAC9B;IACA,IAAI,CAACC,eAAe,GAAGV,UAAU,CAACK,IAAI,CAACC,SAAS,EAAEH,SAAS,EAAEM,QAAQ,CAAC;EACxE;AAGF;;AAEA;AACA,OAAO,SAASE,oBAAoBA,CAClCC,gBAA4C;AAAE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ACF,CAAC;AAED,SAASkC,aAAaA,CACpBD,GAAW,EACX;EAMA,OAL+B;IAC7BL,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,CAACK,GAAG;EACjB,CAAC;AAGH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"createClient.js","names":["__EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference","__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid","__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchPageByRid","__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks","OntologiesV2","symbolClientContext","oldSymbolClientContext","createBulkLinksAsyncIterFactory","applyAction","additionalContext","createMinimalClient","fetchMetadataInternal","fetchPage","fetchSingle","createObjectSet","applyQuery","ActionInvoker","constructor","clientCtx","actionDef","bind","undefined","batchApplyAction","QueryInvoker","queryDef","executeFunction","createClientInternal","objectSetFactory","baseUrl","ontologyRid","tokenProvider","options","fetchFn","fetch","startsWith","Error","then","fetchMetadata","client","Object","defineProperties","o","type","name","getBulkLinks","fetchOneByRid","objectType","rid","createWithRid","createMediaReference","args","data","fileName","propertyType","MediaReferenceProperties","upload","apiName","mediaItemPath","preview","fetchPageByRid","objectOrInterfaceType","rids","value","createClient"],"sources":["createClient.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 ActionDefinition,\n FetchPageArgs,\n FilteredPropertyKeys,\n InterfaceDefinition,\n NullabilityAdherence,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SelectArg,\n} from \"@osdk/api\";\nimport type {\n Experiment,\n ExperimentFns,\n MinimalObjectSet,\n} from \"@osdk/api/unstable\";\nimport {\n __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchPageByRid,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks,\n} from \"@osdk/api/unstable\";\nimport type { ObjectSet as WireObjectSet } from \"@osdk/foundry.ontologies\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport { symbolClientContext as oldSymbolClientContext } from \"@osdk/shared.client\";\nimport { createBulkLinksAsyncIterFactory } from \"./__unstable/createBulkLinksAsyncIterFactory.js\";\nimport type { ActionSignatureFromDef } from \"./actions/applyAction.js\";\nimport { applyAction } from \"./actions/applyAction.js\";\nimport { additionalContext, type Client } from \"./Client.js\";\nimport { createMinimalClient } from \"./createMinimalClient.js\";\nimport { fetchMetadataInternal } from \"./fetchMetadata.js\";\nimport type { Logger } from \"./Logger.js\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport { fetchPage } from \"./object/fetchPage.js\";\nimport { fetchSingle } from \"./object/fetchSingle.js\";\nimport { createObjectSet } from \"./objectSet/createObjectSet.js\";\nimport type { ObjectSetFactory } from \"./objectSet/ObjectSetFactory.js\";\nimport { applyQuery } from \"./queries/applyQuery.js\";\nimport type { QuerySignatureFromDef } from \"./queries/types.js\";\n\n// We import it this way to keep compatible with CJS. If we referenced the\n// value of `symbolClientContext` directly, then we would have to a dynamic import\n// in `createClientInternal` which would make it async and a break.\n// Since this is just a string in `@osdk/shared.client2` instead of a symbol,\n// we can safely perform this trick.\ntype newSymbolClientContext =\n // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n typeof import(\"@osdk/shared.client2\").symbolClientContext;\n\nclass ActionInvoker<Q extends ActionDefinition<any>>\n implements ActionSignatureFromDef<Q>\n{\n constructor(\n clientCtx: MinimalClient,\n actionDef: ActionDefinition<any>,\n ) {\n // We type the property as a generic function as binding `applyAction`\n // doesn't return a type thats all that useful anyway\n // The implements covers us for the most part here as this exact type doesn't\n // escape this file\n this.applyAction = applyAction.bind(undefined, clientCtx, actionDef);\n this.batchApplyAction = applyAction.bind(undefined, clientCtx, actionDef);\n }\n\n applyAction: (...args: any[]) => any;\n batchApplyAction: (...args: any[]) => any;\n}\n\nclass QueryInvoker<Q extends QueryDefinition<any>>\n implements QuerySignatureFromDef<Q>\n{\n constructor(\n clientCtx: MinimalClient,\n queryDef: QueryDefinition<any>,\n ) {\n this.executeFunction = applyQuery.bind(undefined, clientCtx, queryDef);\n }\n\n executeFunction: (...args: any[]) => any;\n}\n\n/** @internal */\nexport function createClientInternal(\n objectSetFactory: ObjectSetFactory<any, any>, // first so i can bind\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n options: { logger?: Logger } | undefined = undefined,\n fetchFn: typeof globalThis.fetch = fetch,\n): Client {\n if (typeof ontologyRid === \"string\") {\n if (!ontologyRid.startsWith(\"ri.\")) {\n throw new Error(\"Invalid ontology RID\");\n }\n } else {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n ontologyRid.then((ontologyRid) => {\n if (!ontologyRid.startsWith(\"ri.\")) {\n // FIXME this promise is not await so this just shows up as an unhandled promise rejection\n throw new Error(\"Invalid ontology RID\");\n }\n });\n }\n\n const clientCtx: MinimalClient = createMinimalClient(\n { ontologyRid },\n baseUrl,\n tokenProvider,\n options,\n fetchFn,\n objectSetFactory,\n );\n\n function clientFn<\n T extends\n | ObjectOrInterfaceDefinition\n | ActionDefinition<any>\n | QueryDefinition<any>\n | Experiment<\"2.0.8\">\n | Experiment<\"2.1.0\">,\n >(o: T): T extends ObjectTypeDefinition ? ObjectSet<T>\n : T extends InterfaceDefinition ? MinimalObjectSet<T>\n : T extends ActionDefinition<any> ? ActionSignatureFromDef<T>\n : T extends QueryDefinition<any> ? QuerySignatureFromDef<T>\n : T extends Experiment<\"2.0.8\"> | Experiment<\"2.1.0\">\n ? { invoke: ExperimentFns<T> }\n : never\n {\n if (o.type === \"object\" || o.type === \"interface\") {\n return objectSetFactory(o, clientCtx) as any;\n } else if (o.type === \"action\") {\n return new ActionInvoker(\n clientCtx,\n o,\n ) as (T extends ActionDefinition<any>\n // first `as` to the action definition for our \"real\" typecheck\n ? ActionSignatureFromDef<T>\n : never) as any; // then as any for dealing with the conditional return value\n } else if (o.type === \"query\") {\n return new QueryInvoker(\n clientCtx,\n o,\n ) as (T extends QueryDefinition<any> ? QuerySignatureFromDef<T>\n : never) as any;\n } else if (o.type === \"experiment\") {\n switch (o.name) {\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks.name:\n return {\n getBulkLinks: createBulkLinksAsyncIterFactory(\n clientCtx,\n ),\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid.name:\n return {\n fetchOneByRid: async <\n Q extends ObjectTypeDefinition,\n const L extends PropertyKeys<Q>,\n const R extends boolean,\n const S extends false | \"throw\" = NullabilityAdherence.Default,\n >(\n objectType: Q,\n rid: string,\n options: SelectArg<Q, L, R, S>,\n ) => {\n return await fetchSingle(\n clientCtx,\n objectType,\n options,\n createWithRid(\n [rid],\n ),\n ) as Osdk<Q>;\n },\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference.name:\n return {\n createMediaReference: async <\n Q extends ObjectTypeDefinition,\n const L extends FilteredPropertyKeys<Q, \"mediaReference\">,\n >(args: {\n data: Blob;\n fileName: string;\n objectType: Q;\n propertyType: L;\n }) => {\n const { data, fileName, objectType, propertyType } = args;\n return await OntologiesV2.MediaReferenceProperties.upload(\n clientCtx,\n await clientCtx.ontologyRid,\n objectType.apiName,\n propertyType as string,\n data,\n {\n mediaItemPath: fileName,\n preview: true,\n },\n );\n },\n } as any;\n\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchPageByRid.name:\n return {\n fetchPageByRid: async <\n Q extends ObjectOrInterfaceDefinition,\n const L extends PropertyKeys<Q>,\n const R extends boolean,\n const S extends false | \"throw\" = NullabilityAdherence.Default,\n >(\n objectOrInterfaceType: Q,\n rids: string[],\n options: FetchPageArgs<Q, L, R, any, S> = {},\n ) => {\n return await fetchPage(\n clientCtx,\n objectOrInterfaceType,\n options,\n createWithRid(rids),\n );\n },\n } as any;\n }\n\n throw new Error(\"not implemented\");\n } else {\n throw new Error(\"not implemented\");\n }\n }\n\n const fetchMetadata = fetchMetadataInternal.bind(\n undefined,\n clientCtx,\n );\n\n const symbolClientContext: newSymbolClientContext = \"__osdkClientContext\";\n\n const client: Client = Object.defineProperties<Client>(\n clientFn as Client,\n {\n [oldSymbolClientContext]: {\n value: clientCtx,\n },\n [symbolClientContext]: {\n value: clientCtx,\n },\n [additionalContext]: {\n value: clientCtx,\n },\n fetchMetadata: {\n value: fetchMetadata,\n },\n } satisfies Record<keyof Client, PropertyDescriptor>,\n );\n\n return client;\n}\n\nexport const createClient: (\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n options?: {\n logger?: Logger;\n } | undefined,\n fetchFn?: typeof fetch | undefined,\n) => Client = createClientInternal.bind(\n undefined,\n createObjectSet,\n);\n\nfunction createWithRid(\n rids: string[],\n) {\n const withRid: WireObjectSet = {\n type: \"static\",\n \"objects\": rids,\n };\n\n return withRid;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqBA,SACEA,uDAAuD,EACvDC,gDAAgD,EAChDC,iDAAiD,EACjDC,+CAA+C,QAC1C,oBAAoB;AAE3B,OAAO,KAAKC,YAAY,MAAM,0BAA0B;AACxD,SAASC,mBAAmB,IAAIC,sBAAsB,QAAQ,qBAAqB;AACnF,SAASC,+BAA+B,QAAQ,iDAAiD;AAEjG,SAASC,WAAW,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
|
package/build/browser/index.js
CHANGED
|
@@ -20,5 +20,6 @@ export { ActionValidationError } from "./actions/ActionValidationError.js";
|
|
|
20
20
|
export { createClient } from "./createClient.js";
|
|
21
21
|
export { createPlatformClient } from "./createPlatformClient.js";
|
|
22
22
|
export { createAttachmentUpload } from "./object/AttachmentUpload.js";
|
|
23
|
+
export { createObjectSpecifierFromPrimaryKey } from "./object/createObjectSpecifierFromPrimaryKey.js";
|
|
23
24
|
export { extractDate, extractDateInLocalTime, extractDateInUTC } from "./util/datetimeConverters.js";
|
|
24
25
|
//# sourceMappingURL=index.js.map
|