@osdk/functions 1.4.0-beta.7 → 1.4.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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @osdk/functions
2
2
 
3
+ ## 1.4.0-beta.8
4
+
5
+ ### Minor Changes
6
+
7
+ - 3fbb596: Pipe through transactionId to endpoints that load data via object sets
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [3fbb596]
12
+ - @osdk/client@2.6.0-beta.10
13
+
3
14
  ## 1.4.0-beta.7
4
15
 
5
16
  ### Minor Changes
@@ -60,7 +60,6 @@ describe("EditRequestManager", () => {
60
60
  };
61
61
  const addObjectEdit = {
62
62
  type: "addObject",
63
- primaryKey: "test-primary-key",
64
63
  objectType: "test-object-type",
65
64
  properties: {}
66
65
  };
@@ -87,7 +86,6 @@ describe("EditRequestManager", () => {
87
86
  "edits": [
88
87
  {
89
88
  "objectType": "test-object-type",
90
- "primaryKey": "test-primary-key",
91
89
  "properties": {},
92
90
  "type": "addObject",
93
91
  },
@@ -112,13 +110,11 @@ describe("EditRequestManager", () => {
112
110
  },
113
111
  {
114
112
  "objectType": "test-object-type",
115
- "primaryKey": "test-primary-key",
116
113
  "properties": {},
117
114
  "type": "addObject",
118
115
  },
119
116
  {
120
117
  "objectType": "test-object-type",
121
- "primaryKey": "test-primary-key",
122
118
  "properties": {},
123
119
  "type": "addObject",
124
120
  },
@@ -169,13 +165,11 @@ describe("EditRequestManager", () => {
169
165
  "edits": [
170
166
  {
171
167
  "objectType": "test-object-type",
172
- "primaryKey": "test-primary-key",
173
168
  "properties": {},
174
169
  "type": "addObject",
175
170
  },
176
171
  {
177
172
  "objectType": "test-object-type",
178
- "primaryKey": "test-primary-key",
179
173
  "properties": {},
180
174
  "type": "addObject",
181
175
  },
@@ -1 +1 @@
1
- {"version":3,"file":"EditRequestManager.test.js","names":["LegacyFauxFoundry","MockOntologiesV2","startNodeApiServer","pDefer","beforeAll","beforeEach","describe","expect","it","vi","createWriteableClient","EditRequestManager","client","apiServer","baseUrl","maybeDeferServer","mockedRequestHandler","editRequestManager","testSetup","bind","fauxFoundry","fn","promise","status","body","use","OntologyTransactions","postEdits","close","restoreAllMocks","addLinkEdit","type","primaryKey","linkedObjectPrimaryKey","linkType","objectType","addObjectEdit","properties","postEdit","toHaveBeenCalledTimes","mock","calls","request","json","toMatchInlineSnapshot","Promise","resolve","setTimeout","secondPromise"],"sources":["EditRequestManager.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { TransactionEdit } from \"@osdk/foundry.ontologies\";\nimport type { SetupServer } from \"@osdk/shared.test\";\nimport {\n LegacyFauxFoundry,\n MockOntologiesV2,\n startNodeApiServer,\n} from \"@osdk/shared.test\";\nimport type { DeferredPromise } from \"p-defer\";\nimport pDefer from \"p-defer\";\nimport type { Mock } from \"vitest\";\nimport { beforeAll, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport { createWriteableClient } from \"./createWriteableClient.js\";\nimport { EditRequestManager } from \"./EditRequestManager.js\";\nimport type { WriteableClient } from \"./WriteableClient.js\";\n\ndescribe(\"EditRequestManager\", () => {\n let client: WriteableClient<any>;\n let apiServer: SetupServer;\n let baseUrl: string;\n let maybeDeferServer: DeferredPromise<void> | undefined;\n let mockedRequestHandler: Mock<\n Parameters<typeof MockOntologiesV2.OntologyTransactions.postEdits>[1]\n >;\n let editRequestManager: EditRequestManager;\n\n beforeAll(() => {\n const testSetup = startNodeApiServer(\n new LegacyFauxFoundry(),\n createWriteableClient.bind(null, \"transaction\"),\n );\n ({ client, apiServer } = testSetup);\n baseUrl = testSetup.fauxFoundry.baseUrl;\n\n mockedRequestHandler = vi.fn<\n Parameters<typeof MockOntologiesV2.OntologyTransactions.postEdits>[1]\n >(async () => {\n if (maybeDeferServer) {\n await maybeDeferServer.promise;\n }\n return {\n status: 200,\n body: {},\n };\n });\n apiServer.use(\n MockOntologiesV2.OntologyTransactions.postEdits(\n baseUrl,\n mockedRequestHandler,\n ),\n );\n\n return () => {\n apiServer.close();\n };\n });\n\n beforeEach(() => {\n editRequestManager = new EditRequestManager(client);\n vi.restoreAllMocks();\n });\n\n const addLinkEdit: TransactionEdit = {\n type: \"addLink\",\n primaryKey: \"test-primary-key\",\n linkedObjectPrimaryKey: \"test-linked-object-primary-key\",\n linkType: \"test-link-type\",\n objectType: \"test-object-type\",\n };\n\n const addObjectEdit: TransactionEdit = {\n type: \"addObject\",\n primaryKey: \"test-primary-key\",\n objectType: \"test-object-type\",\n properties: {},\n };\n\n it(\"will stage single edits in a row\", async () => {\n await editRequestManager.postEdit(addLinkEdit);\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(1);\n expect(await mockedRequestHandler.mock.calls[0][0].request.json())\n .toMatchInlineSnapshot(\n `\n {\n \"edits\": [\n {\n \"linkType\": \"test-link-type\",\n \"linkedObjectPrimaryKey\": \"test-linked-object-primary-key\",\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"type\": \"addLink\",\n },\n ],\n }\n `,\n );\n\n await editRequestManager.postEdit(addObjectEdit);\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(2);\n expect(await mockedRequestHandler.mock.calls[1][0].request.json())\n .toMatchInlineSnapshot(\n `\n {\n \"edits\": [\n {\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n ],\n }\n `,\n );\n });\n\n it(\"stages multiple edits from the same tick in one request in order\", async () => {\n void editRequestManager.postEdit(addLinkEdit);\n void editRequestManager.postEdit(addObjectEdit);\n await editRequestManager.postEdit(addObjectEdit);\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(1);\n expect(await mockedRequestHandler.mock.calls[0][0].request.json())\n .toMatchInlineSnapshot(\n `\n {\n \"edits\": [\n {\n \"linkType\": \"test-link-type\",\n \"linkedObjectPrimaryKey\": \"test-linked-object-primary-key\",\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"type\": \"addLink\",\n },\n {\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n {\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n ],\n }\n `,\n );\n\n await editRequestManager.postEdit(addLinkEdit);\n expect(mockedRequestHandler).toHaveBeenCalledTimes(2);\n expect(await mockedRequestHandler.mock.calls[1][0].request.json())\n .toMatchInlineSnapshot(`\n {\n \"edits\": [\n {\n \"linkType\": \"test-link-type\",\n \"linkedObjectPrimaryKey\": \"test-linked-object-primary-key\",\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"type\": \"addLink\",\n },\n ],\n }\n `);\n });\n\n it(\"handles edits posted while a request is in flight\", async () => {\n maybeDeferServer = pDefer();\n void editRequestManager.postEdit(\n addLinkEdit,\n );\n await new Promise(resolve => setTimeout(resolve, 0)); // Ensure the initial request is in flight\n const secondPromise: Promise<void> = editRequestManager.postEdit(\n addObjectEdit,\n );\n void editRequestManager.postEdit(addObjectEdit);\n maybeDeferServer.resolve();\n\n await secondPromise; // Awaiting the second edit should ensure the first resolves first and should also resolve the third since it was dispatched in the same tick\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(2);\n expect(await mockedRequestHandler.mock.calls[0][0].request.json())\n .toMatchInlineSnapshot(\n `\n {\n \"edits\": [\n {\n \"linkType\": \"test-link-type\",\n \"linkedObjectPrimaryKey\": \"test-linked-object-primary-key\",\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"type\": \"addLink\",\n },\n ],\n }\n `,\n );\n expect(await mockedRequestHandler.mock.calls[1][0].request.json())\n .toMatchInlineSnapshot(`\n {\n \"edits\": [\n {\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n {\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n ],\n }\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SACEA,iBAAiB,EACjBC,gBAAgB,EAChBC,kBAAkB,QACb,mBAAmB;AAE1B,OAAOC,MAAM,MAAM,SAAS;AAE5B,SAASC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,QAAQ;AACxE,SAASC,qBAAqB,QAAQ,4BAA4B;AAClE,SAASC,kBAAkB,QAAQ,yBAAyB;AAG5DL,QAAQ,CAAC,oBAAoB,EAAE,MAAM;EACnC,IAAIM,MAA4B;EAChC,IAAIC,SAAsB;EAC1B,IAAIC,OAAe;EACnB,IAAIC,gBAAmD;EACvD,IAAIC,oBAEH;EACD,IAAIC,kBAAsC;EAE1Cb,SAAS,CAAC,MAAM;IACd,MAAMc,SAAS,GAAGhB,kBAAkB,CAClC,IAAIF,iBAAiB,CAAC,CAAC,EACvBU,qBAAqB,CAACS,IAAI,CAAC,IAAI,EAAE,aAAa,CAChD,CAAC;IACD,CAAC;MAAEP,MAAM;MAAEC;IAAU,CAAC,GAAGK,SAAS;IAClCJ,OAAO,GAAGI,SAAS,CAACE,WAAW,CAACN,OAAO;IAEvCE,oBAAoB,GAAGP,EAAE,CAACY,EAAE,CAE1B,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;AACA;AACA,OAAO,CAAC;EACN,CAAC,CAAC;EAEFpC,EAAE,CAAC,mDAAmD,EAAE,YAAY;IAClEO,gBAAgB,GAAGZ,MAAM,CAAC,CAAC;IAC3B,KAAKc,kBAAkB,CAACqB,QAAQ,CAC9BR,WACF,CAAC;IACD,MAAM,IAAIe,OAAO,CAACC,OAAO,IAAIC,UAAU,CAACD,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,MAAME,aAA4B,GAAG/B,kBAAkB,CAACqB,QAAQ,CAC9DF,aACF,CAAC;IACD,KAAKnB,kBAAkB,CAACqB,QAAQ,CAACF,aAAa,CAAC;IAC/CrB,gBAAgB,CAAC+B,OAAO,CAAC,CAAC;IAE1B,MAAME,aAAa,CAAC,CAAC;;IAErBzC,MAAM,CAACS,oBAAoB,CAAC,CAACuB,qBAAqB,CAAC,CAAC,CAAC;IACrDhC,MAAM,CAAC,MAAMS,oBAAoB,CAACwB,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC,CAC/DC,qBAAqB,CACpB;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OACM,CAAC;IACHrC,MAAM,CAAC,MAAMS,oBAAoB,CAACwB,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC,CAC/DC,qBAAqB,CAAC;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;EACN,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"EditRequestManager.test.js","names":["LegacyFauxFoundry","MockOntologiesV2","startNodeApiServer","pDefer","beforeAll","beforeEach","describe","expect","it","vi","createWriteableClient","EditRequestManager","client","apiServer","baseUrl","maybeDeferServer","mockedRequestHandler","editRequestManager","testSetup","bind","fauxFoundry","fn","promise","status","body","use","OntologyTransactions","postEdits","close","restoreAllMocks","addLinkEdit","type","primaryKey","linkedObjectPrimaryKey","linkType","objectType","addObjectEdit","properties","postEdit","toHaveBeenCalledTimes","mock","calls","request","json","toMatchInlineSnapshot","Promise","resolve","setTimeout","secondPromise"],"sources":["EditRequestManager.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { TransactionEdit } from \"@osdk/foundry.ontologies\";\nimport type { SetupServer } from \"@osdk/shared.test\";\nimport {\n LegacyFauxFoundry,\n MockOntologiesV2,\n startNodeApiServer,\n} from \"@osdk/shared.test\";\nimport type { DeferredPromise } from \"p-defer\";\nimport pDefer from \"p-defer\";\nimport type { Mock } from \"vitest\";\nimport { beforeAll, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport { createWriteableClient } from \"./createWriteableClient.js\";\nimport { EditRequestManager } from \"./EditRequestManager.js\";\nimport type { WriteableClient } from \"./WriteableClient.js\";\n\ndescribe(\"EditRequestManager\", () => {\n let client: WriteableClient<any>;\n let apiServer: SetupServer;\n let baseUrl: string;\n let maybeDeferServer: DeferredPromise<void> | undefined;\n let mockedRequestHandler: Mock<\n Parameters<typeof MockOntologiesV2.OntologyTransactions.postEdits>[1]\n >;\n let editRequestManager: EditRequestManager;\n\n beforeAll(() => {\n const testSetup = startNodeApiServer(\n new LegacyFauxFoundry(),\n createWriteableClient.bind(null, \"transaction\"),\n );\n ({ client, apiServer } = testSetup);\n baseUrl = testSetup.fauxFoundry.baseUrl;\n\n mockedRequestHandler = vi.fn<\n Parameters<typeof MockOntologiesV2.OntologyTransactions.postEdits>[1]\n >(async () => {\n if (maybeDeferServer) {\n await maybeDeferServer.promise;\n }\n return {\n status: 200,\n body: {},\n };\n });\n apiServer.use(\n MockOntologiesV2.OntologyTransactions.postEdits(\n baseUrl,\n mockedRequestHandler,\n ),\n );\n\n return () => {\n apiServer.close();\n };\n });\n\n beforeEach(() => {\n editRequestManager = new EditRequestManager(client);\n vi.restoreAllMocks();\n });\n\n const addLinkEdit: TransactionEdit = {\n type: \"addLink\",\n primaryKey: \"test-primary-key\",\n linkedObjectPrimaryKey: \"test-linked-object-primary-key\",\n linkType: \"test-link-type\",\n objectType: \"test-object-type\",\n };\n\n const addObjectEdit: TransactionEdit = {\n type: \"addObject\",\n objectType: \"test-object-type\",\n properties: {},\n };\n\n it(\"will stage single edits in a row\", async () => {\n await editRequestManager.postEdit(addLinkEdit);\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(1);\n expect(await mockedRequestHandler.mock.calls[0][0].request.json())\n .toMatchInlineSnapshot(\n `\n {\n \"edits\": [\n {\n \"linkType\": \"test-link-type\",\n \"linkedObjectPrimaryKey\": \"test-linked-object-primary-key\",\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"type\": \"addLink\",\n },\n ],\n }\n `,\n );\n\n await editRequestManager.postEdit(addObjectEdit);\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(2);\n expect(await mockedRequestHandler.mock.calls[1][0].request.json())\n .toMatchInlineSnapshot(\n `\n {\n \"edits\": [\n {\n \"objectType\": \"test-object-type\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n ],\n }\n `,\n );\n });\n\n it(\"stages multiple edits from the same tick in one request in order\", async () => {\n void editRequestManager.postEdit(addLinkEdit);\n void editRequestManager.postEdit(addObjectEdit);\n await editRequestManager.postEdit(addObjectEdit);\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(1);\n expect(await mockedRequestHandler.mock.calls[0][0].request.json())\n .toMatchInlineSnapshot(\n `\n {\n \"edits\": [\n {\n \"linkType\": \"test-link-type\",\n \"linkedObjectPrimaryKey\": \"test-linked-object-primary-key\",\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"type\": \"addLink\",\n },\n {\n \"objectType\": \"test-object-type\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n {\n \"objectType\": \"test-object-type\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n ],\n }\n `,\n );\n\n await editRequestManager.postEdit(addLinkEdit);\n expect(mockedRequestHandler).toHaveBeenCalledTimes(2);\n expect(await mockedRequestHandler.mock.calls[1][0].request.json())\n .toMatchInlineSnapshot(`\n {\n \"edits\": [\n {\n \"linkType\": \"test-link-type\",\n \"linkedObjectPrimaryKey\": \"test-linked-object-primary-key\",\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"type\": \"addLink\",\n },\n ],\n }\n `);\n });\n\n it(\"handles edits posted while a request is in flight\", async () => {\n maybeDeferServer = pDefer();\n void editRequestManager.postEdit(\n addLinkEdit,\n );\n await new Promise(resolve => setTimeout(resolve, 0)); // Ensure the initial request is in flight\n const secondPromise: Promise<void> = editRequestManager.postEdit(\n addObjectEdit,\n );\n void editRequestManager.postEdit(addObjectEdit);\n maybeDeferServer.resolve();\n\n await secondPromise; // Awaiting the second edit should ensure the first resolves first and should also resolve the third since it was dispatched in the same tick\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(2);\n expect(await mockedRequestHandler.mock.calls[0][0].request.json())\n .toMatchInlineSnapshot(\n `\n {\n \"edits\": [\n {\n \"linkType\": \"test-link-type\",\n \"linkedObjectPrimaryKey\": \"test-linked-object-primary-key\",\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"type\": \"addLink\",\n },\n ],\n }\n `,\n );\n expect(await mockedRequestHandler.mock.calls[1][0].request.json())\n .toMatchInlineSnapshot(`\n {\n \"edits\": [\n {\n \"objectType\": \"test-object-type\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n {\n \"objectType\": \"test-object-type\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n ],\n }\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SACEA,iBAAiB,EACjBC,gBAAgB,EAChBC,kBAAkB,QACb,mBAAmB;AAE1B,OAAOC,MAAM,MAAM,SAAS;AAE5B,SAASC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,QAAQ;AACxE,SAASC,qBAAqB,QAAQ,4BAA4B;AAClE,SAASC,kBAAkB,QAAQ,yBAAyB;AAG5DL,QAAQ,CAAC,oBAAoB,EAAE,MAAM;EACnC,IAAIM,MAA4B;EAChC,IAAIC,SAAsB;EAC1B,IAAIC,OAAe;EACnB,IAAIC,gBAAmD;EACvD,IAAIC,oBAEH;EACD,IAAIC,kBAAsC;EAE1Cb,SAAS,CAAC,MAAM;IACd,MAAMc,SAAS,GAAGhB,kBAAkB,CAClC,IAAIF,iBAAiB,CAAC,CAAC,EACvBU,qBAAqB,CAACS,IAAI,CAAC,IAAI,EAAE,aAAa,CAChD,CAAC;IACD,CAAC;MAAEP,MAAM;MAAEC;IAAU,CAAC,GAAGK,SAAS;IAClCJ,OAAO,GAAGI,SAAS,CAACE,WAAW,CAACN,OAAO;IAEvCE,oBAAoB,GAAGP,EAAE,CAACY,EAAE,CAE1B,YAAY;MACZ,IAAIN,gBAAgB,EAAE;QACpB,MAAMA,gBAAgB,CAACO,OAAO;MAChC;MACA,OAAO;QACLC,MAAM,EAAE,GAAG;QACXC,IAAI,EAAE,CAAC;MACT,CAAC;IACH,CAAC,CAAC;IACFX,SAAS,CAACY,GAAG,CACXxB,gBAAgB,CAACyB,oBAAoB,CAACC,SAAS,CAC7Cb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tD,MAAME,aAA4B,GAAG/B,kBAAkB,CAACqB,QAAQ,CAC9DF,aACF,CAAC;IACD,KAAKnB,kBAAkB,CAACqB,QAAQ,CAACF,aAAa,CAAC;IAC/CrB,gBAAgB,CAAC+B,OAAO,CAAC,CAAC;IAE1B,MAAME,aAAa,CAAC,CAAC;;IAErBzC,MAAM,CAACS,oBAAoB,CAAC,CAACuB,qBAAqB,CAAC,CAAC,CAAC;IACrDhC,MAAM,CAAC,MAAMS,oBAAoB,CAACwB,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC,CAC/DC,qBAAqB,CACpB;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OACM,CAAC;IACHrC,MAAM,CAAC,MAAMS,oBAAoB,CAACwB,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC,CAC/DC,qBAAqB,CAAC;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;EACN,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -84,7 +84,6 @@ export function createWriteableClient(...args) {
84
84
  return editRequestManager.postEdit({
85
85
  type: "addObject",
86
86
  objectType: obj.apiName,
87
- primaryKey: obj.$primaryKey,
88
87
  properties: propertyMap
89
88
  });
90
89
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createWriteableClient.js","names":["createClientWithTransaction","EditRequestManager","toPropertyDataValue","writeableClientContext","createWriteableClient","args","transactionRid","ontologyRid","client","editRequestManager","writeableClient","Object","defineProperties","link","value","source","apiName","target","Array","isArray","postEdit","type","objectType","$apiName","primaryKey","$primaryKey","linkType","linkedObjectPrimaryKey","promises","elem","push","Promise","all","then","undefined","unlink","create","obj","properties","propertyMap","key","entries","update","locator","delete"],"sources":["createWriteableClient.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createClientWithTransaction } from \"@osdk/client/unstable-do-not-use\";\n\nimport type { Client } from \"@osdk/client\";\nimport type {\n AddLinkApiNames,\n AddLinkSources,\n AddLinkTargets,\n CreatableObjectOrInterfaceTypeProperties,\n CreatableObjectOrInterfaceTypes,\n DeletableObjectOrInterfaceLocators,\n RemoveLinkApiNames,\n RemoveLinkSources,\n RemoveLinkTargets,\n UpdatableObjectOrInterfaceLocatorProperties,\n UpdatableObjectOrInterfaceLocators,\n} from \"../edits/EditBatch.js\";\nimport type { AnyEdit } from \"../edits/types.js\";\nimport { EditRequestManager } from \"./EditRequestManager.js\";\nimport { toPropertyDataValue } from \"./toPropertyDataValue.js\";\nimport type {\n WriteableClient,\n WriteableClientContext,\n WriteMethods,\n} from \"./WriteableClient.js\";\nimport { writeableClientContext } from \"./WriteableClient.js\";\n\nexport function createWriteableClient<\n X extends AnyEdit = never,\n>(\n ...args: Parameters<typeof createClientWithTransaction>\n): WriteableClient<X> {\n const transactionRid = args[0];\n const ontologyRid = args[2];\n\n const client = createClientWithTransaction(...args);\n\n const editRequestManager = new EditRequestManager(\n client as WriteableClient<any>, // This cast is safe because we create the writeable client properties below.\n );\n\n // We use define properties because the client has non-enumerable properties that we want to preserve.\n const writeableClient = Object.defineProperties<Client>(\n client,\n {\n link: {\n value: function<\n SOL extends AddLinkSources<X>,\n A extends AddLinkApiNames<X, SOL>,\n >(\n source: SOL,\n apiName: A,\n target: AddLinkTargets<X, SOL, A>,\n ): Promise<void> {\n if (!Array.isArray(target)) {\n return editRequestManager.postEdit({\n type: \"addLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: target.$primaryKey,\n });\n }\n const promises: Promise<void>[] = [];\n\n for (const elem of target) {\n promises.push(\n editRequestManager.postEdit({\n type: \"addLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: elem.$primaryKey,\n }),\n );\n }\n return Promise.all(promises).then(() => undefined);\n },\n },\n unlink: {\n value: function<\n SOL extends RemoveLinkSources<X>,\n A extends RemoveLinkApiNames<X, SOL>,\n >(\n source: SOL,\n apiName: A,\n target: RemoveLinkTargets<X, SOL, A>,\n ): Promise<void> {\n if (!Array.isArray(target)) {\n return editRequestManager.postEdit({\n type: \"removeLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: target.$primaryKey,\n });\n }\n const promises: Promise<void>[] = [];\n for (const elem of target) {\n promises.push(editRequestManager.postEdit({\n type: \"removeLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: elem.$primaryKey,\n }));\n }\n return Promise.all(promises).then(() => undefined);\n },\n },\n create: {\n value: async function<OTD extends CreatableObjectOrInterfaceTypes<X>>(\n obj: OTD,\n properties: CreatableObjectOrInterfaceTypeProperties<X, OTD>,\n ): Promise<void> {\n const propertyMap: { [propertyName: string]: unknown } = {};\n for (const [key, value] of Object.entries(properties)) {\n propertyMap[key] = toPropertyDataValue(value);\n }\n return editRequestManager.postEdit({\n type: \"addObject\",\n objectType: obj.apiName,\n primaryKey: obj.$primaryKey,\n properties: propertyMap,\n });\n },\n },\n update: {\n value: function<\n SOL extends UpdatableObjectOrInterfaceLocators<X>,\n OTD extends UpdatableObjectOrInterfaceLocatorProperties<X, SOL>,\n >(\n locator: SOL,\n properties: OTD,\n ): Promise<void> {\n const propertyMap: { [propertyName: string]: unknown } = {};\n for (const [key, value] of Object.entries(properties)) {\n propertyMap[key] = toPropertyDataValue(value);\n }\n return editRequestManager.postEdit({\n type: \"modifyObject\",\n objectType: locator.$apiName,\n primaryKey: locator.$primaryKey,\n properties: propertyMap,\n });\n },\n },\n delete: {\n value: function<OL extends DeletableObjectOrInterfaceLocators<X>>(\n obj: OL,\n ): Promise<void> {\n return editRequestManager.postEdit({\n type: \"deleteObject\",\n objectType: obj.$apiName,\n primaryKey: obj.$primaryKey,\n });\n },\n },\n [writeableClientContext]: {\n value: {\n ontologyRid,\n transactionRid,\n } satisfies WriteableClientContext,\n },\n } satisfies Record<\n keyof WriteMethods<any> | typeof writeableClientContext,\n PropertyDescriptor\n >,\n ) as WriteableClient<X>;\n\n return writeableClient;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,2BAA2B,QAAQ,kCAAkC;AAiB9E,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,mBAAmB,QAAQ,0BAA0B;AAM9D,SAASC,sBAAsB,QAAQ,sBAAsB;AAE7D,OAAO,SAASC,qBAAqBA,CAGnC,GAAGC,IAAoD,EACnC;EACpB,MAAMC,cAAc,GAAGD,IAAI,CAAC,CAAC,CAAC;EAC9B,MAAME,WAAW,GAAGF,IAAI,CAAC,CAAC,CAAC;EAE3B,MAAMG,MAAM,GAAGR,2BAA2B,CAAC,GAAGK,IAAI,CAAC;EAEnD,MAAMI,kBAAkB,GAAG,IAAIR,kBAAkB,CAC/CO,MACF,CAAC,CADiC;EACjC;;EAED;EACA,MAAME,eAAe,GAAGC,MAAM,CAACC,gBAAgB,CAC7CJ,MAAM,EACN;IACEK,IAAI,EAAE;MACJC,KAAK,EAAE,SAAAA,CAILC,MAAW,EACXC,OAAU,EACVC,MAAiC,EAClB;QACf,IAAI,CAACC,KAAK,CAACC,OAAO,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C/Ba,UAAU,EAAEC;QACd,CAAC,CAAC;MACJ;IACF,CAAC;IACDK,MAAM,EAAE;MACN9B,KAAK,EAAE,SAAAA,CACLuB,GAAO,EACQ;QACf,OAAO5B,kBAAkB,CAACW,QAAQ,CAAC;UACjCC,IAAI,EAAE,cAAc;UACpBC,UAAU,EAAEe,GAAG,CAACd,QAAQ;UACxBC,UAAU,EAAEa,GAAG,CAACZ;QAClB,CAAC,CAAC;MACJ;IACF,CAAC;IACD,CAACtB,sBAAsB,GAAG;MACxBW,KAAK,EAAE;QACLP,WAAW;QACXD;MACF;IACF;EACF,CAIF,CAAuB;EAEvB,OAAOI,eAAe;AACxB","ignoreList":[]}
1
+ {"version":3,"file":"createWriteableClient.js","names":["createClientWithTransaction","EditRequestManager","toPropertyDataValue","writeableClientContext","createWriteableClient","args","transactionRid","ontologyRid","client","editRequestManager","writeableClient","Object","defineProperties","link","value","source","apiName","target","Array","isArray","postEdit","type","objectType","$apiName","primaryKey","$primaryKey","linkType","linkedObjectPrimaryKey","promises","elem","push","Promise","all","then","undefined","unlink","create","obj","properties","propertyMap","key","entries","update","locator","delete"],"sources":["createWriteableClient.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createClientWithTransaction } from \"@osdk/client/unstable-do-not-use\";\n\nimport type { Client } from \"@osdk/client\";\nimport type {\n AddLinkApiNames,\n AddLinkSources,\n AddLinkTargets,\n CreatableObjectOrInterfaceTypeProperties,\n CreatableObjectOrInterfaceTypes,\n DeletableObjectOrInterfaceLocators,\n RemoveLinkApiNames,\n RemoveLinkSources,\n RemoveLinkTargets,\n UpdatableObjectOrInterfaceLocatorProperties,\n UpdatableObjectOrInterfaceLocators,\n} from \"../edits/EditBatch.js\";\nimport type { AnyEdit } from \"../edits/types.js\";\nimport { EditRequestManager } from \"./EditRequestManager.js\";\nimport { toPropertyDataValue } from \"./toPropertyDataValue.js\";\nimport type {\n WriteableClient,\n WriteableClientContext,\n WriteMethods,\n} from \"./WriteableClient.js\";\nimport { writeableClientContext } from \"./WriteableClient.js\";\n\nexport function createWriteableClient<\n X extends AnyEdit = never,\n>(\n ...args: Parameters<typeof createClientWithTransaction>\n): WriteableClient<X> {\n const transactionRid = args[0];\n const ontologyRid = args[2];\n\n const client = createClientWithTransaction(...args);\n\n const editRequestManager = new EditRequestManager(\n client as WriteableClient<any>, // This cast is safe because we create the writeable client properties below.\n );\n\n // We use define properties because the client has non-enumerable properties that we want to preserve.\n const writeableClient = Object.defineProperties<Client>(\n client,\n {\n link: {\n value: function<\n SOL extends AddLinkSources<X>,\n A extends AddLinkApiNames<X, SOL>,\n >(\n source: SOL,\n apiName: A,\n target: AddLinkTargets<X, SOL, A>,\n ): Promise<void> {\n if (!Array.isArray(target)) {\n return editRequestManager.postEdit({\n type: \"addLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: target.$primaryKey,\n });\n }\n const promises: Promise<void>[] = [];\n\n for (const elem of target) {\n promises.push(\n editRequestManager.postEdit({\n type: \"addLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: elem.$primaryKey,\n }),\n );\n }\n return Promise.all(promises).then(() => undefined);\n },\n },\n unlink: {\n value: function<\n SOL extends RemoveLinkSources<X>,\n A extends RemoveLinkApiNames<X, SOL>,\n >(\n source: SOL,\n apiName: A,\n target: RemoveLinkTargets<X, SOL, A>,\n ): Promise<void> {\n if (!Array.isArray(target)) {\n return editRequestManager.postEdit({\n type: \"removeLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: target.$primaryKey,\n });\n }\n const promises: Promise<void>[] = [];\n for (const elem of target) {\n promises.push(editRequestManager.postEdit({\n type: \"removeLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: elem.$primaryKey,\n }));\n }\n return Promise.all(promises).then(() => undefined);\n },\n },\n create: {\n value: async function<OTD extends CreatableObjectOrInterfaceTypes<X>>(\n obj: OTD,\n properties: CreatableObjectOrInterfaceTypeProperties<X, OTD>,\n ): Promise<void> {\n const propertyMap: { [propertyName: string]: unknown } = {};\n for (const [key, value] of Object.entries(properties)) {\n propertyMap[key] = toPropertyDataValue(value);\n }\n return editRequestManager.postEdit({\n type: \"addObject\",\n objectType: obj.apiName,\n properties: propertyMap,\n });\n },\n },\n update: {\n value: function<\n SOL extends UpdatableObjectOrInterfaceLocators<X>,\n OTD extends UpdatableObjectOrInterfaceLocatorProperties<X, SOL>,\n >(\n locator: SOL,\n properties: OTD,\n ): Promise<void> {\n const propertyMap: { [propertyName: string]: unknown } = {};\n for (const [key, value] of Object.entries(properties)) {\n propertyMap[key] = toPropertyDataValue(value);\n }\n return editRequestManager.postEdit({\n type: \"modifyObject\",\n objectType: locator.$apiName,\n primaryKey: locator.$primaryKey,\n properties: propertyMap,\n });\n },\n },\n delete: {\n value: function<OL extends DeletableObjectOrInterfaceLocators<X>>(\n obj: OL,\n ): Promise<void> {\n return editRequestManager.postEdit({\n type: \"deleteObject\",\n objectType: obj.$apiName,\n primaryKey: obj.$primaryKey,\n });\n },\n },\n [writeableClientContext]: {\n value: {\n ontologyRid,\n transactionRid,\n } satisfies WriteableClientContext,\n },\n } satisfies Record<\n keyof WriteMethods<any> | typeof writeableClientContext,\n PropertyDescriptor\n >,\n ) as WriteableClient<X>;\n\n return writeableClient;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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mB,CAACY,KAAK,CAAC;QAC/C;QACA,OAAOL,kBAAkB,CAACW,QAAQ,CAAC;UACjCC,IAAI,EAAE,WAAW;UACjBC,UAAU,EAAEe,GAAG,CAACrB,OAAO;UACvBsB,UAAU,EAAEC;QACd,CAAC,CAAC;MACJ;IACF,CAAC;IACDG,MAAM,EAAE;MACN5B,KAAK,EAAE,SAAAA,CAIL6B,OAAY,EACZL,UAAe,EACA;QACf,MAAMC,WAAgD,GAAG,CAAC,CAAC;QAC3D,KAAK,MAAM,CAACC,GAAG,EAAE1B,KAAK,CAAC,IAAIH,MAAM,CAAC8B,OAAO,CAACH,UAAU,CAAC,EAAE;UACrDC,WAAW,CAACC,GAAG,CAAC,GAAGtC,mBAAmB,CAACY,KAAK,CAAC;QAC/C;QACA,OAAOL,kBAAkB,CAACW,QAAQ,CAAC;UACjCC,IAAI,EAAE,cAAc;UACpBC,UAAU,EAAEqB,OAAO,CAACpB,QAAQ;UAC5BC,UAAU,EAAEmB,OAAO,CAAClB,WAAW;UAC/Ba,UAAU,EAAEC;QACd,CAAC,CAAC;MACJ;IACF,CAAC;IACDK,MAAM,EAAE;MACN9B,KAAK,EAAE,SAAAA,CACLuB,GAAO,EACQ;QACf,OAAO5B,kBAAkB,CAACW,QAAQ,CAAC;UACjCC,IAAI,EAAE,cAAc;UACpBC,UAAU,EAAEe,GAAG,CAACd,QAAQ;UACxBC,UAAU,EAAEa,GAAG,CAACZ;QAClB,CAAC,CAAC;MACJ;IACF,CAAC;IACD,CAACtB,sBAAsB,GAAG;MACxBW,KAAK,EAAE;QACLP,WAAW;QACXD;MACF;IACF;EACF,CAIF,CAAuB;EAEvB,OAAOI,eAAe;AACxB","ignoreList":[]}
@@ -106,7 +106,7 @@ var UserFacingError = class extends Error {
106
106
  }
107
107
  };
108
108
 
109
- // ../../node_modules/.pnpm/@osdk+foundry.mediasets@2.38.0/node_modules/@osdk/foundry.mediasets/build/esm/public/MediaSet.js
109
+ // ../../node_modules/.pnpm/@osdk+foundry.mediasets@2.40.0/node_modules/@osdk/foundry.mediasets/build/esm/public/MediaSet.js
110
110
  var MediaSet_exports = {};
111
111
  chunk4DCWE2WY_cjs.__export(MediaSet_exports, {
112
112
  abort: () => abort,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/edits/types.ts","../../src/edits/createEditBatch.ts","../../src/errors/UserFacingError.ts","../../../../node_modules/.pnpm/@osdk+foundry.mediasets@2.38.0/node_modules/@osdk/foundry.mediasets/build/esm/public/MediaSet.js","../../src/helpers/uploadMedia.ts"],"names":["__export","foundryPlatformFetch","uploadMedia"],"mappings":";;;;;AAmBO,SAAS,mBAAmB,GAAK,EAAA;AACtC,EAAA,OAAO,GAAO,IAAA,IAAA,IAAQ,OAAO,GAAA,KAAQ,YAAY,OAAO,GAAA,CAAI,WAAgB,KAAA,QAAA,IAAY,OAAO,GAAI,CAAA,QAAA,KAAa,QAAY,IAAA,GAAA,CAAI,aAAa,GAAI,CAAA,WAAA;AACnJ;;;ACJA,IAAM,oBAAN,MAAwB;AAAA,EACtB,QAAQ,EAAC;AAAA,EACT,IAAA,CAAK,MAAQ,EAAA,OAAA,EAAS,MAAQ,EAAA;AAC5B,IAAA,IAAI,CAAC,KAAA,CAAM,OAAQ,CAAA,MAAM,CAAG,EAAA;AAC1B,MAAA,IAAA,CAAK,MAAM,IAAK,CAAA;AAAA,QACd,IAAM,EAAA,SAAA;AAAA,QACN,MAAA;AAAA,QACA,OAAA;AAAA,QACA;AAAA,OACD,CAAA;AACD,MAAA;AAAA;AAEF,IAAA,KAAA,MAAW,QAAQ,MAAQ,EAAA;AACzB,MAAA,IAAA,CAAK,MAAM,IAAK,CAAA;AAAA,QACd,IAAM,EAAA,SAAA;AAAA,QACN,MAAA;AAAA,QACA,OAAA;AAAA,QACA,MAAQ,EAAA;AAAA,OACT,CAAA;AAAA;AACH;AACF,EACA,MAAA,CAAO,MAAQ,EAAA,OAAA,EAAS,MAAQ,EAAA;AAC9B,IAAA,IAAI,CAAC,KAAA,C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,QAChB,YAAA,EAAc,eAAgB,CAAA,SAAA,CAAU,gBAAiB,CAAA,YAAA;AAAA,QACzD,WAAA,EAAa,eAAgB,CAAA,SAAA,CAAU,gBAAiB,CAAA,WAAA;AAAA,QACxD,eAAA,EAAiB,eAAgB,CAAA,SAAA,CAAU,gBAAiB,CAAA,eAAA;AAAA,QAC5D,SAAA,EAAW,eAAgB,CAAA,SAAA,CAAU,gBAAiB,CAAA;AAAA;AACxD;AACF,GACF;AACF","file":"index.cjs","sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport let Edits;\n// Check if locator is for an interface by comparing $apiName and $objectType.\n// Both object types and interfaces store the object type API name in $objectType,\n// but interfaces store the interface API name in $apiName.\nexport function isInterfaceLocator(obj) {\n return obj != null && typeof obj === \"object\" && typeof obj.$objectType === \"string\" && typeof obj.$apiName === \"string\" && obj.$apiName !== obj.$objectType;\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isInterfaceLocator } from \"./types.js\";\nclass InMemoryEditBatch {\n edits = [];\n link(source, apiName, target) {\n if (!Array.isArray(target)) {\n this.edits.push({\n type: \"addLink\",\n source,\n apiName,\n target\n });\n return;\n }\n for (const elem of target) {\n this.edits.push({\n type: \"addLink\",\n source,\n apiName,\n target: elem\n });\n }\n }\n unlink(source, apiName, target) {\n if (!Array.isArray(target)) {\n this.edits.push({\n type: \"removeLink\",\n source,\n apiName,\n target\n });\n return;\n }\n for (const elem of target) {\n this.edits.push({\n type: \"removeLink\",\n source,\n apiName,\n target: elem\n });\n }\n }\n create(objectOrInterfaceType, properties) {\n if (objectOrInterfaceType.type === \"interface\") {\n this.edits.push({\n type: \"createObjectForInterface\",\n int: objectOrInterfaceType,\n properties\n });\n return;\n }\n this.edits.push({\n type: \"createObject\",\n obj: objectOrInterfaceType,\n properties\n });\n }\n delete(obj) {\n if (isInterfaceLocator(obj)) {\n this.edits.push({\n type: \"deleteObjectForInterface\",\n obj\n });\n return;\n }\n this.edits.push({\n type: \"deleteObject\",\n obj\n });\n }\n update(obj, properties) {\n if (isInterfaceLocator(obj)) {\n this.edits.push({\n type: \"updateObjectForInterface\",\n obj,\n properties\n });\n return;\n }\n this.edits.push({\n type: \"updateObject\",\n obj,\n properties\n });\n }\n getEdits() {\n return [...this.edits];\n }\n}\nexport function createEditBatch(_client) {\n return new InMemoryEditBatch();\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport class UserFacingError extends Error {\n constructor(message) {\n super(message);\n }\n}","/*\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 */\nimport { foundryPlatformFetch as $foundryPlatformFetch } from \"@osdk/shared.net.platformapi\";\n//\nconst _abort = [1, \"/v2/mediasets/{0}/transactions/{1}/abort\", 2];\n/**\n * Aborts an open transaction. Items uploaded to the media set during this transaction will be deleted.\n *\n * @beta\n *\n * Required Scopes: [api:mediasets-write]\n * URL: /v2/mediasets/{mediaSetRid}/transactions/{transactionId}/abort\n */\nexport function abort($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _abort, ...args);\n}\nconst _calculate = [0, \"/v2/mediasets/{0}/items/{1}/transform/imagery/thumbnail/calculate\", 6];\n/**\n * Starts calculation of a thumbnail for a given image.\n *\n * @alpha\n *\n * Required Scopes: [api:mediasets-read]\n * URL: /v2/mediasets/{mediaSetRid}/items/{mediaItemRid}/transform/imagery/thumbnail/calculate\n */\nexport function calculate($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _calculate, ...args);\n}\nconst _commit = [1, \"/v2/mediasets/{0}/transactions/{1}/commit\", 2];\n/**\n * Commits an open transaction. On success, items uploaded to the media set during this transaction will become available.\n *\n * @beta\n *\n * Required Scopes: [api:mediasets-write]\n * URL: /v2/mediasets/{mediaSetRid}/transactions/{transactionId}/commit\n */\nexport function commit($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _commit, ...args);\n}\nconst _create = [1, \"/v2/mediasets/{0}/transactions\", 2];\n/**\n * Creates a new transaction. Items uploaded to the media set while this transaction is open will not be reflected until the transaction is committed.\n *\n * @beta\n *\n * Required Scopes: [api:mediasets-write]\n * URL: /v2/mediasets/{mediaSetRid}/transactions\n */\nexport function create($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _create, ...args);\n}\nconst _info = [0, \"/v2/mediasets/{0}/items/{1}\", 6];\n/**\n * Gets information about the media item.\n *\n * @beta\n *\n * Required Scopes: [api:mediasets-read]\n * URL: /v2/mediasets/{mediaSetRid}/items/{mediaItemRid}\n */\nexport function info($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _info, ...args);\n}\nconst _reference = [0, \"/v2/mediasets/{0}/items/{1}/reference\", 6];\n/**\n * Gets the [media reference](https://www.palantir.com/docs/foundry/data-integration/media-sets/#media-references) for this media item.\n *\n * @beta\n *\n * Required Scopes: [api:mediasets-read]\n * URL: /v2/mediasets/{mediaSetRid}/items/{mediaItemRid}/reference\n */\nexport function reference($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _reference, ...args);\n}\nconst _getRidByPath = [0, \"/v2/mediasets/{0}/items/getRidByPath\", 2];\n/**\n * Returns the media item RID for the media item with the specified path.\n *\n * @beta\n *\n * Required Scopes: [api:mediasets-read]\n * URL: /v2/mediasets/{mediaSetRid}/items/getRidByPath\n */\nexport function getRidByPath($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _getRidByPath, ...args);\n}\nconst _upload = [1, \"/v2/mediasets/{0}/items\", 3, \"*/*\"];\n/**\n * Uploads a media item to an existing media set.\n * The body of the request must contain the binary content of the file and the `Content-Type` header must be `application/octet-stream`.\n * A branch name, or branch rid, or view rid may optionally be specified. If none is specified, the item will be uploaded to the default branch. If more than one is specified, an error is thrown.\n *\n * @beta\n *\n * Required Scopes: [api:mediasets-write]\n * URL: /v2/mediasets/{mediaSetRid}/items\n */\nexport function upload($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _upload, ...args);\n}\nconst _read = [0, \"/v2/mediasets/{0}/items/{1}/content\", 6,, \"*/*\"];\n/**\n * Gets the content of a media item.\n *\n * @beta\n *\n * Required Scopes: [api:mediasets-read]\n * URL: /v2/mediasets/{mediaSetRid}/items/{mediaItemRid}/content\n */\nexport function read($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _read, ...args);\n}\nconst _readOriginal = [0, \"/v2/mediasets/{0}/items/{1}/original\", 6,, \"*/*\"];\n/**\n * Gets the content of an original file uploaded to the media item, even if it was transformed on upload due to being an additional input format.\n *\n * @beta\n *\n * Required Scopes: [api:mediasets-read]\n * URL: /v2/mediasets/{mediaSetRid}/items/{mediaItemRid}/original\n */\nexport function readOriginal($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _readOriginal, ...args);\n}\nconst _retrieve = [0, \"/v2/mediasets/{0}/items/{1}/transform/imagery/thumbnail/retrieve\", 6,, \"*/*\"];\n/**\n * Retrieves a successfully calculated thumbnail for a given image.\n *\n * Thumbnails are 200px wide in the format of `image/webp`\n *\n * @alpha\n *\n * Required Scopes: [api:mediasets-read]\n * URL: /v2/mediasets/{mediaSetRid}/items/{mediaItemRid}/transform/imagery/thumbnail/retrieve\n */\nexport function retrieve($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _retrieve, ...args);\n}\nconst _uploadMedia = [2, \"/v2/mediasets/media/upload\", 7, \"*/*\"];\n/**\n * \"Uploads a temporary media item. If the media item isn't persisted within 1 hour, the item will be deleted.\n *\n * The body of the request must contain the binary content of the file and the `Content-Type` header must be `application/octet-stream`.\n * Third-party applications using this endpoint via OAuth2 must request the following operation scopes: `api:ontologies-read api:ontologies-write`.\"\n *\n * @alpha\n *\n * Required Scopes: [api:ontologies-read, api:ontologies-write]\n * URL: /v2/mediasets/media/upload\n */\nexport function uploadMedia($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _uploadMedia, ...args);\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { MediaSets } from \"@osdk/foundry.mediasets\";\nexport async function uploadMedia(client, mediaUpload) {\n const gatewayMediaRef = await MediaSets.uploadMedia(client, mediaUpload.data, {\n filename: mediaUpload.fileName,\n preview: true\n });\n return {\n mimeType: gatewayMediaRef.mimeType,\n reference: {\n type: \"mediaSetViewItem\",\n mediaSetViewItem: {\n mediaItemRid: gatewayMediaRef.reference.mediaSetViewItem.mediaItemRid,\n mediaSetRid: gatewayMediaRef.reference.mediaSetViewItem.mediaSetRid,\n mediaSetViewRid: gatewayMediaRef.reference.mediaSetViewItem.mediaSetViewRid,\n readToken: gatewayMediaRef.reference.mediaSetViewItem.token\n }\n }\n };\n}"]}
1
+ {"version":3,"sources":["../../src/edits/types.ts","../../src/edits/createEditBatch.ts","../../src/errors/UserFacingError.ts","../../../../node_modules/.pnpm/@osdk+foundry.mediasets@2.40.0/node_modules/@osdk/foundry.mediasets/build/esm/public/MediaSet.js","../../src/helpers/uploadMedia.ts"],"names":["__export","foundryPlatformFetch","uploadMedia"],"mappings":";;;;;AAmBO,SAAS,mBAAmB,GAAK,EAAA;AACtC,EAAA,OAAO,GAAO,IAAA,IAAA,IAAQ,OAAO,GAAA,KAAQ,YAAY,OAAO,GAAA,CAAI,WAAgB,KAAA,QAAA,IAAY,OAAO,GAAI,CAAA,QAAA,KAAa,QAAY,IAAA,GAAA,CAAI,aAAa,GAAI,CAAA,WAAA;AACnJ;;;ACJA,IAAM,oBAAN,MAAwB;AAAA,EACtB,QAAQ,EAAC;AAAA,EACT,IAAA,CAAK,MAAQ,EAAA,OAAA,EAAS,MAAQ,EAAA;AAC5B,IAAA,IAAI,CAAC,KAAA,CAAM,OAAQ,CAAA,MAAM,CAAG,EAAA;AAC1B,MAAA,IAAA,CAAK,MAAM,IAAK,CAAA;AAAA,QACd,IAAM,EAAA,SAAA;AAAA,QACN,MAAA;AAAA,QACA,OAAA;AAAA,QACA;AAAA,OACD,CAAA;AACD,MAAA;AAAA;AAEF,IAAA,KAAA,MAAW,QAAQ,MAAQ,EA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AAA,MAAA,EAAQ,YAAY,IAAM,EAAA;AAAA,IAC5E,UAAU,WAAY,CAAA,QAAA;AAAA,IACtB,OAAS,EAAA;AAAA,GACV,CAAA;AACD,EAAO,OAAA;AAAA,IACL,UAAU,eAAgB,CAAA,QAAA;AAAA,IAC1B,SAAW,EAAA;AAAA,MACT,IAAM,EAAA,kBAAA;AAAA,MACN,gBAAkB,EAAA;AAAA,QAChB,YAAA,EAAc,eAAgB,CAAA,SAAA,CAAU,gBAAiB,CAAA,YAAA;AAAA,QACzD,WAAA,EAAa,eAAgB,CAAA,SAAA,CAAU,gBAAiB,CAAA,WAAA;AAAA,QACxD,eAAA,EAAiB,eAAgB,CAAA,SAAA,CAAU,gBAAiB,CAAA,eAAA;AAAA,QAC5D,SAAA,EAAW,eAAgB,CAAA,SAAA,CAAU,gBAAiB,CAAA;AAAA;AACxD;AACF,GACF;AACF","file":"index.cjs","sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport let Edits;\n// Check if locator is for an interface by comparing $apiName and $objectType.\n// Both object types and interfaces store the object type API name in $objectType,\n// but interfaces store the interface API name in $apiName.\nexport function isInterfaceLocator(obj) {\n return obj != null && typeof obj === \"object\" && typeof obj.$objectType === \"string\" && typeof obj.$apiName === \"string\" && obj.$apiName !== obj.$objectType;\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isInterfaceLocator } from \"./types.js\";\nclass InMemoryEditBatch {\n edits = [];\n link(source, apiName, target) {\n if (!Array.isArray(target)) {\n this.edits.push({\n type: \"addLink\",\n source,\n apiName,\n target\n });\n return;\n }\n for (const elem of target) {\n this.edits.push({\n type: \"addLink\",\n source,\n apiName,\n target: elem\n });\n }\n }\n unlink(source, apiName, target) {\n if (!Array.isArray(target)) {\n this.edits.push({\n type: \"removeLink\",\n source,\n apiName,\n target\n });\n return;\n }\n for (const elem of target) {\n this.edits.push({\n type: \"removeLink\",\n source,\n apiName,\n target: elem\n });\n }\n }\n create(objectOrInterfaceType, properties) {\n if (objectOrInterfaceType.type === \"interface\") {\n this.edits.push({\n type: \"createObjectForInterface\",\n int: objectOrInterfaceType,\n properties\n });\n return;\n }\n this.edits.push({\n type: \"createObject\",\n obj: objectOrInterfaceType,\n properties\n });\n }\n delete(obj) {\n if (isInterfaceLocator(obj)) {\n this.edits.push({\n type: \"deleteObjectForInterface\",\n obj\n });\n return;\n }\n this.edits.push({\n type: \"deleteObject\",\n obj\n });\n }\n update(obj, properties) {\n if (isInterfaceLocator(obj)) {\n this.edits.push({\n type: \"updateObjectForInterface\",\n obj,\n properties\n });\n return;\n }\n this.edits.push({\n type: \"updateObject\",\n obj,\n properties\n });\n }\n getEdits() {\n return [...this.edits];\n }\n}\nexport function createEditBatch(_client) {\n return new InMemoryEditBatch();\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport class UserFacingError extends Error {\n constructor(message) {\n super(message);\n }\n}","/*\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 */\nimport { foundryPlatformFetch as $foundryPlatformFetch } from \"@osdk/shared.net.platformapi\";\n//\nconst _abort = [1, \"/v2/mediasets/{0}/transactions/{1}/abort\", 2];\n/**\n * Aborts an open transaction. Items uploaded to the media set during this transaction will be deleted.\n *\n * @beta\n *\n * Required Scopes: [api:mediasets-write]\n * URL: /v2/mediasets/{mediaSetRid}/transactions/{transactionId}/abort\n */\nexport function abort($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _abort, ...args);\n}\nconst _calculate = [0, \"/v2/mediasets/{0}/items/{1}/transform/imagery/thumbnail/calculate\", 6];\n/**\n * Starts calculation of a thumbnail for a given image.\n *\n * @alpha\n *\n * Required Scopes: [api:mediasets-read]\n * URL: /v2/mediasets/{mediaSetRid}/items/{mediaItemRid}/transform/imagery/thumbnail/calculate\n */\nexport function calculate($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _calculate, ...args);\n}\nconst _commit = [1, \"/v2/mediasets/{0}/transactions/{1}/commit\", 2];\n/**\n * Commits an open transaction. On success, items uploaded to the media set during this transaction will become available.\n *\n * @beta\n *\n * Required Scopes: [api:mediasets-write]\n * URL: /v2/mediasets/{mediaSetRid}/transactions/{transactionId}/commit\n */\nexport function commit($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _commit, ...args);\n}\nconst _create = [1, \"/v2/mediasets/{0}/transactions\", 2];\n/**\n * Creates a new transaction. Items uploaded to the media set while this transaction is open will not be reflected until the transaction is committed.\n *\n * @beta\n *\n * Required Scopes: [api:mediasets-write]\n * URL: /v2/mediasets/{mediaSetRid}/transactions\n */\nexport function create($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _create, ...args);\n}\nconst _info = [0, \"/v2/mediasets/{0}/items/{1}\", 6];\n/**\n * Gets information about the media item.\n *\n * @beta\n *\n * Required Scopes: [api:mediasets-read]\n * URL: /v2/mediasets/{mediaSetRid}/items/{mediaItemRid}\n */\nexport function info($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _info, ...args);\n}\nconst _reference = [0, \"/v2/mediasets/{0}/items/{1}/reference\", 6];\n/**\n * Gets the [media reference](https://www.palantir.com/docs/foundry/data-integration/media-sets/#media-references) for this media item.\n *\n * @beta\n *\n * Required Scopes: [api:mediasets-read]\n * URL: /v2/mediasets/{mediaSetRid}/items/{mediaItemRid}/reference\n */\nexport function reference($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _reference, ...args);\n}\nconst _getRidByPath = [0, \"/v2/mediasets/{0}/items/getRidByPath\", 2];\n/**\n * Returns the media item RID for the media item with the specified path.\n *\n * @beta\n *\n * Required Scopes: [api:mediasets-read]\n * URL: /v2/mediasets/{mediaSetRid}/items/getRidByPath\n */\nexport function getRidByPath($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _getRidByPath, ...args);\n}\nconst _upload = [1, \"/v2/mediasets/{0}/items\", 3, \"*/*\"];\n/**\n * Uploads a media item to an existing media set.\n * The body of the request must contain the binary content of the file and the `Content-Type` header must be `application/octet-stream`.\n * A branch name, or branch rid, or view rid may optionally be specified. If none is specified, the item will be uploaded to the default branch. If more than one is specified, an error is thrown.\n *\n * @beta\n *\n * Required Scopes: [api:mediasets-write]\n * URL: /v2/mediasets/{mediaSetRid}/items\n */\nexport function upload($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _upload, ...args);\n}\nconst _read = [0, \"/v2/mediasets/{0}/items/{1}/content\", 6,, \"*/*\"];\n/**\n * Gets the content of a media item.\n *\n * @beta\n *\n * Required Scopes: [api:mediasets-read]\n * URL: /v2/mediasets/{mediaSetRid}/items/{mediaItemRid}/content\n */\nexport function read($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _read, ...args);\n}\nconst _readOriginal = [0, \"/v2/mediasets/{0}/items/{1}/original\", 6,, \"*/*\"];\n/**\n * Gets the content of an original file uploaded to the media item, even if it was transformed on upload due to being an additional input format.\n *\n * @beta\n *\n * Required Scopes: [api:mediasets-read]\n * URL: /v2/mediasets/{mediaSetRid}/items/{mediaItemRid}/original\n */\nexport function readOriginal($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _readOriginal, ...args);\n}\nconst _retrieve = [0, \"/v2/mediasets/{0}/items/{1}/transform/imagery/thumbnail/retrieve\", 6,, \"*/*\"];\n/**\n * Retrieves a successfully calculated thumbnail for a given image.\n *\n * Thumbnails are 200px wide in the format of `image/webp`\n *\n * @alpha\n *\n * Required Scopes: [api:mediasets-read]\n * URL: /v2/mediasets/{mediaSetRid}/items/{mediaItemRid}/transform/imagery/thumbnail/retrieve\n */\nexport function retrieve($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _retrieve, ...args);\n}\nconst _uploadMedia = [2, \"/v2/mediasets/media/upload\", 7, \"*/*\"];\n/**\n * Uploads a temporary media item. If the media item isn't persisted within 1 hour, the item will be deleted.\n *\n * If multiple resources are attributed to, usage will be attributed to the first one in the list.\n *\n * The body of the request must contain the binary content of the file and the `Content-Type` header must be `application/octet-stream`.\n * Third-party applications using this endpoint via OAuth2 must request the following operation scopes: `api:ontologies-read api:ontologies-write`.\n *\n * @alpha\n *\n * Required Scopes: [api:ontologies-read, api:ontologies-write]\n * URL: /v2/mediasets/media/upload\n */\nexport function uploadMedia($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _uploadMedia, ...args);\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { MediaSets } from \"@osdk/foundry.mediasets\";\nexport async function uploadMedia(client, mediaUpload) {\n const gatewayMediaRef = await MediaSets.uploadMedia(client, mediaUpload.data, {\n filename: mediaUpload.fileName,\n preview: true\n });\n return {\n mimeType: gatewayMediaRef.mimeType,\n reference: {\n type: \"mediaSetViewItem\",\n mediaSetViewItem: {\n mediaItemRid: gatewayMediaRef.reference.mediaSetViewItem.mediaItemRid,\n mediaSetRid: gatewayMediaRef.reference.mediaSetViewItem.mediaSetRid,\n mediaSetViewRid: gatewayMediaRef.reference.mediaSetViewItem.mediaSetViewRid,\n readToken: gatewayMediaRef.reference.mediaSetViewItem.token\n }\n }\n };\n}"]}
@@ -5,7 +5,7 @@ var unstableDoNotUse = require('@osdk/client/unstable-do-not-use');
5
5
  var fs = require('fs');
6
6
  var yaml = require('yaml');
7
7
 
8
- // ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.38.0/node_modules/@osdk/foundry.ontologies/build/esm/public/OntologyTransaction.js
8
+ // ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.40.0/node_modules/@osdk/foundry.ontologies/build/esm/public/OntologyTransaction.js
9
9
  var OntologyTransaction_exports = {};
10
10
  chunk4DCWE2WY_cjs.__export(OntologyTransaction_exports, {
11
11
  postEdits: () => postEdits
@@ -161,7 +161,6 @@ function createWriteableClient(...args) {
161
161
  return editRequestManager.postEdit({
162
162
  type: "addObject",
163
163
  objectType: obj.apiName,
164
- primaryKey: obj.$primaryKey,
165
164
  properties: propertyMap
166
165
  });
167
166
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../node_modules/.pnpm/@osdk+foundry.ontologies@2.38.0/node_modules/@osdk/foundry.ontologies/build/esm/public/OntologyTransaction.js","../../../src/transactions/WriteableClient.ts","../../../src/transactions/EditRequestManager.ts","../../../src/transactions/toPropertyDataValue.ts","../../../src/transactions/createWriteableClient.ts","../../../src/utils/getApiGatewayBaseUrl.ts"],"names":["__export","foundryPlatformFetch","createClientWithTransaction","readFileSync","parseYaml"],"mappings":";;;;;;;;AAAA,IAAA,2BAAA,GAAA,EAAA;AAAAA,0BAAA,CAAA,2BAAA,EAAA;AAAA,EAAA,SAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAiBA,IAAM,UAAa,GAAA,CAAC,CAAG,EAAA,2CAAA,EAA6C,CAAC,CAAA;AAS9D,SAAS,SAAA,CAAU,SAAS,IAAM,EAAA;AACvC,EAAA,OAAOC,sCAAsB,CAAA,IAAA,EAAM,UAAY,EAAA,GAAG,IAAI,CAAA;AACxD;;;ACXO,IAAM,sBAAA,GAAyB,OAAO,wBAAwB,CAAA;;;ACC9D,IAAM,qBAAN,MAAyB;AAAA,EAC9B,eAAe,EAAC;AAAA,EAChB,eAAkB,GAAA,IAAA;AAAA,EAClB,aAAgB,GAAA,IAAA;AAAA,EAChB,WAAc,GAAA,IAAA;AAAA,EACd,YAAY,MAAQ,EAAA;AAClB,IAAA,IAAA,CAAK,MAAS,GAAA,MAAA;AAAA;AAChB,EACA,SAAS,IAAM,EAAA;AACb,IAAA,IAAI,KAAK,eAAiB,EAAA;AACxB,MAAA,IAAI,KAAK,WAAa,EAAA;AAEpB,QAAK,IAAA,CAAA,YAAA,CAAa,KAAK,IAAI,CAAA;AAC3B,QAAA,OAAO,IAAK,CAAA,eAAA;AAAA;AAEd,MAAA,IAAI,KAAK,aAAe,EAAA;AAEtB,QAAK,IAAA,CAAA,YAAA,CAAa,KAAK,IAAI,CAAA;AAC3B,QAAA,OAAO,IAAK,CAAA,aAAA;AAAA;AAGd,MAAA,IA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A,CAAA,CAAA;AAAA;AAE3F,EAAI,IAAA,WAAA;AACJ,EAAI,IAAA;AACF,IAAc,WAAA,GAAAC,eAAA,CAAa,UAAU,OAAO,CAAA;AAAA,WACrC,KAAO,EAAA;AACd,IAAA,MAAM,eAAe,KAAiB,YAAA,KAAA,GAAQ,KAAM,CAAA,OAAA,GAAU,OAAO,KAAK,CAAA;AAC1E,IAAA,MAAM,IAAI,KAAM,CAAA,CAAA,yCAAA,EAA4C,QAAQ,CAAA,EAAA,EAAK,YAAY,CAAE,CAAA,CAAA;AAAA;AAEzF,EAAI,IAAA,SAAA;AACJ,EAAI,IAAA;AACF,IAAA,SAAA,GAAYC,WAAU,WAAW,CAAA;AAAA,WAC1B,KAAO,EAAA;AACd,IAAA,MAAM,eAAe,KAAiB,YAAA,KAAA,GAAQ,KAAM,CAAA,OAAA,GAAU,OAAO,KAAK,CAAA;AAC1E,IAAA,MAAM,IAAI,KAAM,CAAA,CAAA,+CAAA,EAAkD,QAAQ,CAAA,EAAA,EAAK,YAAY,CAAE,CAAA,CAAA;AAAA;AAE/F,EAAM,MAAA,gBAAA,GAAmB,UAAU,mBAAmB,CAAA;AACtD,EAAA,IAAI,CAAC,gBAAkB,EAAA;AACrB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAG,EAAA,mBAAmB,CAA8C,4CAAA,CAAA,CAAA;AAAA;AAEtF,EAAM,MAAA,IAAA,GAAO,YAAY,gBAAgB,CAAA;AACzC,EAAI,IAAA,IAAA,CAAK,WAAW,CAAG,EAAA;AACrB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAqB,kBAAA,EAAA,mBAAmB,CAAoC,kCAAA,CAAA,CAAA;AAAA;AAE9F,EAAA,OAAO,KAAK,CAAC,CAAA;AACf","file":"unstable-do-not-use.cjs","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 */\nimport { foundryPlatformFetch as $foundryPlatformFetch } from \"@osdk/shared.net.platformapi\";\n//\nconst _postEdits = [1, \"/v2/ontologies/{0}/transactions/{1}/edits\", 3];\n/**\n * Applies a set of edits to a transaction in order.\n *\n * @alpha\n *\n * Required Scopes: [api:ontologies-read]\n * URL: /v2/ontologies/{ontology}/transactions/{transactionRid}/edits\n */\nexport function postEdits($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _postEdits, ...args);\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @internal */\nexport const writeableClientContext = Symbol(\"writeableClientContext\");","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { OntologyTransactions } from \"@osdk/foundry.ontologies\";\nimport { writeableClientContext } from \"./WriteableClient.js\";\nexport class EditRequestManager {\n pendingEdits = [];\n inFlightRequest = null;\n queuedRequest = null;\n editTimeout = null;\n constructor(client) {\n this.client = client;\n }\n postEdit(edit) {\n if (this.inFlightRequest) {\n if (this.editTimeout) {\n // This means we are in the same tick that the request was created, meaning we can just add to the same request\n this.pendingEdits.push(edit);\n return this.inFlightRequest;\n }\n if (this.queuedRequest) {\n // This means we already have a queued request that will run after the inFlightRequest finishes, so we can just add to that one\n this.pendingEdits.push(edit);\n return this.queuedRequest;\n }\n // This means a request has already been sent to the wire but not been returned, so we need to queue up a new request for when that one finishes\n this.queuedRequest = this.inFlightRequest.then(async () => {\n this.inFlightRequest = this.queuedRequest;\n this.queuedRequest = null;\n this.pendingEdits.push(edit);\n await this.dispatchRequest();\n });\n return this.queuedRequest;\n } else {\n // There is no request in flight, which means we should create a new one\n this.inFlightRequest = this.createInitialPromiseWithTimeout(edit);\n return this.inFlightRequest;\n }\n }\n createInitialPromiseWithTimeout(edit) {\n return new Promise(resolve => {\n this.pendingEdits.push(edit);\n this.editTimeout = setTimeout(async () => {\n this.editTimeout = null;\n await this.dispatchRequest();\n if (!this.queuedRequest) {\n // The queued request will see this inFlightRequest resolve and should set the inFlightRequest to itself\n this.inFlightRequest = null;\n }\n resolve();\n }, 0);\n });\n }\n async dispatchRequest() {\n const copiedEdits = this.pendingEdits;\n this.pendingEdits = [];\n await OntologyTransactions.postEdits(this.client, await this.client[writeableClientContext].ontologyRid, this.client[writeableClientContext].transactionRid, {\n edits: copiedEdits\n }, {\n preview: true\n });\n }\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function toPropertyDataValue(value) {\n if (value == null) {\n return null; // This differs from how actions handles null, which expects a specific enum value.\n }\n if (Array.isArray(value)) {\n return value.map(item => toPropertyDataValue(item));\n }\n if (isPoint(value)) {\n return toPropertyDataValue(`${value.coordinates[1]},${value.coordinates[0]}`);\n }\n if (typeof value === \"object\") {\n const result = {};\n for (const key in value) {\n result[key] = toPropertyDataValue(value[key]);\n }\n return result;\n }\n\n // expected to pass through - boolean, byte, date, decimal, float, double, integer, long, short, string, timestamp, object type reference\n return value;\n}\nfunction isPoint(o) {\n return o && typeof o === \"object\" && \"type\" in o && o.type === \"Point\" && \"coordinates\" in o && o.coordinates.length === 2;\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createClientWithTransaction } from \"@osdk/client/unstable-do-not-use\";\nimport { EditRequestManager } from \"./EditRequestManager.js\";\nimport { toPropertyDataValue } from \"./toPropertyDataValue.js\";\nimport { writeableClientContext } from \"./WriteableClient.js\";\nexport function createWriteableClient(...args) {\n const transactionRid = args[0];\n const ontologyRid = args[2];\n const client = createClientWithTransaction(...args);\n const editRequestManager = new EditRequestManager(client) // This cast is safe because we create the writeable client properties below.\n ;\n\n // We use define properties because the client has non-enumerable properties that we want to preserve.\n const writeableClient = Object.defineProperties(client, {\n link: {\n value: function (source, apiName, target) {\n if (!Array.isArray(target)) {\n return editRequestManager.postEdit({\n type: \"addLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: target.$primaryKey\n });\n }\n const promises = [];\n for (const elem of target) {\n promises.push(editRequestManager.postEdit({\n type: \"addLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: elem.$primaryKey\n }));\n }\n return Promise.all(promises).then(() => undefined);\n }\n },\n unlink: {\n value: function (source, apiName, target) {\n if (!Array.isArray(target)) {\n return editRequestManager.postEdit({\n type: \"removeLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: target.$primaryKey\n });\n }\n const promises = [];\n for (const elem of target) {\n promises.push(editRequestManager.postEdit({\n type: \"removeLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: elem.$primaryKey\n }));\n }\n return Promise.all(promises).then(() => undefined);\n }\n },\n create: {\n value: async function (obj, properties) {\n const propertyMap = {};\n for (const [key, value] of Object.entries(properties)) {\n propertyMap[key] = toPropertyDataValue(value);\n }\n return editRequestManager.postEdit({\n type: \"addObject\",\n objectType: obj.apiName,\n primaryKey: obj.$primaryKey,\n properties: propertyMap\n });\n }\n },\n update: {\n value: function (locator, properties) {\n const propertyMap = {};\n for (const [key, value] of Object.entries(properties)) {\n propertyMap[key] = toPropertyDataValue(value);\n }\n return editRequestManager.postEdit({\n type: \"modifyObject\",\n objectType: locator.$apiName,\n primaryKey: locator.$primaryKey,\n properties: propertyMap\n });\n }\n },\n delete: {\n value: function (obj) {\n return editRequestManager.postEdit({\n type: \"deleteObject\",\n objectType: obj.$apiName,\n primaryKey: obj.$primaryKey\n });\n }\n },\n [writeableClientContext]: {\n value: {\n ontologyRid,\n transactionRid\n }\n }\n });\n return writeableClient;\n}","/*\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 { readFileSync } from \"fs\";\nimport { parse as parseYaml } from \"yaml\";\nconst FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR = \"FOUNDRY_SERVICE_DISCOVERY_V2\";\nconst API_GATEWAY_SERVICE = \"api_gateway\";\n/**\n * Type guard to check if config is an object with uris property\n */\nfunction hasUrisProperty(config) {\n return !Array.isArray(config) && \"uris\" in config && Array.isArray(config.uris) && config.uris.every(uri => typeof uri === \"string\");\n}\n\n/**\n * Extracts URIs from either array or object format\n */\nfunction extractUris(config) {\n return hasUrisProperty(config) ? config.uris : config;\n}\n\n/**\n * Retrieves the API Gateway base URL from the Function's environment.\n *\n * This function is intended to be used only from within a function. Usage of this utility elsewhere may result\n * in errors since the environment may not be properly configured.\n *\n * @returns The API Gateway base URL (e.g., \"https://example.palantirfoundry.com\")\n * @throws Error if the API Gateway base URL has not been properly configured in the function's environment.\n *\n * @example\n * ```typescript\n * const baseUrl = getApiGatewayBaseUrl();\n * // Returns: \"https://example.palantirfoundry.com\"\n * ```\n */\nexport function getApiGatewayBaseUrl() {\n const filePath = process.env[FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR];\n if (!filePath) {\n throw new Error(`${FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR} environment variable is not set`);\n }\n let fileContent;\n try {\n fileContent = readFileSync(filePath, \"utf-8\");\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(`Failed to read service discovery file at ${filePath}: ${errorMessage}`);\n }\n let discovery;\n try {\n discovery = parseYaml(fileContent);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(`Failed to parse service discovery YAML file at ${filePath}: ${errorMessage}`);\n }\n const apiGatewayConfig = discovery[API_GATEWAY_SERVICE];\n if (!apiGatewayConfig) {\n throw new Error(`${API_GATEWAY_SERVICE} service not found in service discovery file`);\n }\n const uris = extractUris(apiGatewayConfig);\n if (uris.length === 0) {\n throw new Error(`No URIs found for ${API_GATEWAY_SERVICE} service in service discovery file`);\n }\n return uris[0];\n}"]}
1
+ {"version":3,"sources":["../../../../../node_modules/.pnpm/@osdk+foundry.ontologies@2.40.0/node_modules/@osdk/foundry.ontologies/build/esm/public/OntologyTransaction.js","../../../src/transactions/WriteableClient.ts","../../../src/transactions/EditRequestManager.ts","../../../src/transactions/toPropertyDataValue.ts","../../../src/transactions/createWriteableClient.ts","../../../src/utils/getApiGatewayBaseUrl.ts"],"names":["__export","foundryPlatformFetch","createClientWithTransaction","readFileSync","parseYaml"],"mappings":";;;;;;;;AAAA,IAAA,2BAAA,GAAA,EAAA;AAAAA,0BAAA,CAAA,2BAAA,EAAA;AAAA,EAAA,SAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAiBA,IAAM,UAAa,GAAA,CAAC,CAAG,EAAA,2CAAA,EAA6C,CAAC,CAAA;AAS9D,SAAS,SAAA,CAAU,SAAS,IAAM,EAAA;AACvC,EAAA,OAAOC,sCAAsB,CAAA,IAAA,EAAM,UAAY,EAAA,GAAG,IAAI,CAAA;AACxD;;;ACXO,IAAM,sBAAA,GAAyB,OAAO,wBAAwB,CAAA;;;ACC9D,IAAM,qBAAN,MAAyB;AAAA,EAC9B,eAAe,EAAC;AAAA,EAChB,eAAkB,GAAA,IAAA;AAAA,EAClB,aAAgB,GAAA,IAAA;AAAA,EAChB,WAAc,GAAA,IAAA;AAAA,EACd,YAAY,MAAQ,EAAA;AAClB,IAAA,IAAA,CAAK,MAAS,GAAA,MAAA;AAAA;AAChB,EACA,SAAS,IAAM,EAAA;AACb,IAAA,IAAI,KAAK,eAAiB,EAAA;AACxB,MAAA,IAAI,KAAK,WAAa,EAAA;AAEpB,QAAK,IAAA,CAAA,YAAA,CAAa,KAAK,IAAI,CAAA;AAC3B,QAAA,OAAO,IAAK,CAAA,eAAA;AAAA;AAEd,MAAA,IAAI,KAAK,aAAe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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 */\nimport { foundryPlatformFetch as $foundryPlatformFetch } from \"@osdk/shared.net.platformapi\";\n//\nconst _postEdits = [1, \"/v2/ontologies/{0}/transactions/{1}/edits\", 3];\n/**\n * Applies a set of edits to a transaction in order.\n *\n * @alpha\n *\n * Required Scopes: [api:ontologies-read]\n * URL: /v2/ontologies/{ontology}/transactions/{transactionId}/edits\n */\nexport function postEdits($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _postEdits, ...args);\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @internal */\nexport const writeableClientContext = Symbol(\"writeableClientContext\");","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { OntologyTransactions } from \"@osdk/foundry.ontologies\";\nimport { writeableClientContext } from \"./WriteableClient.js\";\nexport class EditRequestManager {\n pendingEdits = [];\n inFlightRequest = null;\n queuedRequest = null;\n editTimeout = null;\n constructor(client) {\n this.client = client;\n }\n postEdit(edit) {\n if (this.inFlightRequest) {\n if (this.editTimeout) {\n // This means we are in the same tick that the request was created, meaning we can just add to the same request\n this.pendingEdits.push(edit);\n return this.inFlightRequest;\n }\n if (this.queuedRequest) {\n // This means we already have a queued request that will run after the inFlightRequest finishes, so we can just add to that one\n this.pendingEdits.push(edit);\n return this.queuedRequest;\n }\n // This means a request has already been sent to the wire but not been returned, so we need to queue up a new request for when that one finishes\n this.queuedRequest = this.inFlightRequest.then(async () => {\n this.inFlightRequest = this.queuedRequest;\n this.queuedRequest = null;\n this.pendingEdits.push(edit);\n await this.dispatchRequest();\n });\n return this.queuedRequest;\n } else {\n // There is no request in flight, which means we should create a new one\n this.inFlightRequest = this.createInitialPromiseWithTimeout(edit);\n return this.inFlightRequest;\n }\n }\n createInitialPromiseWithTimeout(edit) {\n return new Promise(resolve => {\n this.pendingEdits.push(edit);\n this.editTimeout = setTimeout(async () => {\n this.editTimeout = null;\n await this.dispatchRequest();\n if (!this.queuedRequest) {\n // The queued request will see this inFlightRequest resolve and should set the inFlightRequest to itself\n this.inFlightRequest = null;\n }\n resolve();\n }, 0);\n });\n }\n async dispatchRequest() {\n const copiedEdits = this.pendingEdits;\n this.pendingEdits = [];\n await OntologyTransactions.postEdits(this.client, await this.client[writeableClientContext].ontologyRid, this.client[writeableClientContext].transactionRid, {\n edits: copiedEdits\n }, {\n preview: true\n });\n }\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function toPropertyDataValue(value) {\n if (value == null) {\n return null; // This differs from how actions handles null, which expects a specific enum value.\n }\n if (Array.isArray(value)) {\n return value.map(item => toPropertyDataValue(item));\n }\n if (isPoint(value)) {\n return toPropertyDataValue(`${value.coordinates[1]},${value.coordinates[0]}`);\n }\n if (typeof value === \"object\") {\n const result = {};\n for (const key in value) {\n result[key] = toPropertyDataValue(value[key]);\n }\n return result;\n }\n\n // expected to pass through - boolean, byte, date, decimal, float, double, integer, long, short, string, timestamp, object type reference\n return value;\n}\nfunction isPoint(o) {\n return o && typeof o === \"object\" && \"type\" in o && o.type === \"Point\" && \"coordinates\" in o && o.coordinates.length === 2;\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createClientWithTransaction } from \"@osdk/client/unstable-do-not-use\";\nimport { EditRequestManager } from \"./EditRequestManager.js\";\nimport { toPropertyDataValue } from \"./toPropertyDataValue.js\";\nimport { writeableClientContext } from \"./WriteableClient.js\";\nexport function createWriteableClient(...args) {\n const transactionRid = args[0];\n const ontologyRid = args[2];\n const client = createClientWithTransaction(...args);\n const editRequestManager = new EditRequestManager(client) // This cast is safe because we create the writeable client properties below.\n ;\n\n // We use define properties because the client has non-enumerable properties that we want to preserve.\n const writeableClient = Object.defineProperties(client, {\n link: {\n value: function (source, apiName, target) {\n if (!Array.isArray(target)) {\n return editRequestManager.postEdit({\n type: \"addLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: target.$primaryKey\n });\n }\n const promises = [];\n for (const elem of target) {\n promises.push(editRequestManager.postEdit({\n type: \"addLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: elem.$primaryKey\n }));\n }\n return Promise.all(promises).then(() => undefined);\n }\n },\n unlink: {\n value: function (source, apiName, target) {\n if (!Array.isArray(target)) {\n return editRequestManager.postEdit({\n type: \"removeLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: target.$primaryKey\n });\n }\n const promises = [];\n for (const elem of target) {\n promises.push(editRequestManager.postEdit({\n type: \"removeLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: elem.$primaryKey\n }));\n }\n return Promise.all(promises).then(() => undefined);\n }\n },\n create: {\n value: async function (obj, properties) {\n const propertyMap = {};\n for (const [key, value] of Object.entries(properties)) {\n propertyMap[key] = toPropertyDataValue(value);\n }\n return editRequestManager.postEdit({\n type: \"addObject\",\n objectType: obj.apiName,\n properties: propertyMap\n });\n }\n },\n update: {\n value: function (locator, properties) {\n const propertyMap = {};\n for (const [key, value] of Object.entries(properties)) {\n propertyMap[key] = toPropertyDataValue(value);\n }\n return editRequestManager.postEdit({\n type: \"modifyObject\",\n objectType: locator.$apiName,\n primaryKey: locator.$primaryKey,\n properties: propertyMap\n });\n }\n },\n delete: {\n value: function (obj) {\n return editRequestManager.postEdit({\n type: \"deleteObject\",\n objectType: obj.$apiName,\n primaryKey: obj.$primaryKey\n });\n }\n },\n [writeableClientContext]: {\n value: {\n ontologyRid,\n transactionRid\n }\n }\n });\n return writeableClient;\n}","/*\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 { readFileSync } from \"fs\";\nimport { parse as parseYaml } from \"yaml\";\nconst FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR = \"FOUNDRY_SERVICE_DISCOVERY_V2\";\nconst API_GATEWAY_SERVICE = \"api_gateway\";\n/**\n * Type guard to check if config is an object with uris property\n */\nfunction hasUrisProperty(config) {\n return !Array.isArray(config) && \"uris\" in config && Array.isArray(config.uris) && config.uris.every(uri => typeof uri === \"string\");\n}\n\n/**\n * Extracts URIs from either array or object format\n */\nfunction extractUris(config) {\n return hasUrisProperty(config) ? config.uris : config;\n}\n\n/**\n * Retrieves the API Gateway base URL from the Function's environment.\n *\n * This function is intended to be used only from within a function. Usage of this utility elsewhere may result\n * in errors since the environment may not be properly configured.\n *\n * @returns The API Gateway base URL (e.g., \"https://example.palantirfoundry.com\")\n * @throws Error if the API Gateway base URL has not been properly configured in the function's environment.\n *\n * @example\n * ```typescript\n * const baseUrl = getApiGatewayBaseUrl();\n * // Returns: \"https://example.palantirfoundry.com\"\n * ```\n */\nexport function getApiGatewayBaseUrl() {\n const filePath = process.env[FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR];\n if (!filePath) {\n throw new Error(`${FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR} environment variable is not set`);\n }\n let fileContent;\n try {\n fileContent = readFileSync(filePath, \"utf-8\");\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(`Failed to read service discovery file at ${filePath}: ${errorMessage}`);\n }\n let discovery;\n try {\n discovery = parseYaml(fileContent);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(`Failed to parse service discovery YAML file at ${filePath}: ${errorMessage}`);\n }\n const apiGatewayConfig = discovery[API_GATEWAY_SERVICE];\n if (!apiGatewayConfig) {\n throw new Error(`${API_GATEWAY_SERVICE} service not found in service discovery file`);\n }\n const uris = extractUris(apiGatewayConfig);\n if (uris.length === 0) {\n throw new Error(`No URIs found for ${API_GATEWAY_SERVICE} service in service discovery file`);\n }\n return uris[0];\n}"]}
@@ -60,7 +60,6 @@ describe("EditRequestManager", () => {
60
60
  };
61
61
  const addObjectEdit = {
62
62
  type: "addObject",
63
- primaryKey: "test-primary-key",
64
63
  objectType: "test-object-type",
65
64
  properties: {}
66
65
  };
@@ -87,7 +86,6 @@ describe("EditRequestManager", () => {
87
86
  "edits": [
88
87
  {
89
88
  "objectType": "test-object-type",
90
- "primaryKey": "test-primary-key",
91
89
  "properties": {},
92
90
  "type": "addObject",
93
91
  },
@@ -112,13 +110,11 @@ describe("EditRequestManager", () => {
112
110
  },
113
111
  {
114
112
  "objectType": "test-object-type",
115
- "primaryKey": "test-primary-key",
116
113
  "properties": {},
117
114
  "type": "addObject",
118
115
  },
119
116
  {
120
117
  "objectType": "test-object-type",
121
- "primaryKey": "test-primary-key",
122
118
  "properties": {},
123
119
  "type": "addObject",
124
120
  },
@@ -169,13 +165,11 @@ describe("EditRequestManager", () => {
169
165
  "edits": [
170
166
  {
171
167
  "objectType": "test-object-type",
172
- "primaryKey": "test-primary-key",
173
168
  "properties": {},
174
169
  "type": "addObject",
175
170
  },
176
171
  {
177
172
  "objectType": "test-object-type",
178
- "primaryKey": "test-primary-key",
179
173
  "properties": {},
180
174
  "type": "addObject",
181
175
  },
@@ -1 +1 @@
1
- {"version":3,"file":"EditRequestManager.test.js","names":["LegacyFauxFoundry","MockOntologiesV2","startNodeApiServer","pDefer","beforeAll","beforeEach","describe","expect","it","vi","createWriteableClient","EditRequestManager","client","apiServer","baseUrl","maybeDeferServer","mockedRequestHandler","editRequestManager","testSetup","bind","fauxFoundry","fn","promise","status","body","use","OntologyTransactions","postEdits","close","restoreAllMocks","addLinkEdit","type","primaryKey","linkedObjectPrimaryKey","linkType","objectType","addObjectEdit","properties","postEdit","toHaveBeenCalledTimes","mock","calls","request","json","toMatchInlineSnapshot","Promise","resolve","setTimeout","secondPromise"],"sources":["EditRequestManager.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { TransactionEdit } from \"@osdk/foundry.ontologies\";\nimport type { SetupServer } from \"@osdk/shared.test\";\nimport {\n LegacyFauxFoundry,\n MockOntologiesV2,\n startNodeApiServer,\n} from \"@osdk/shared.test\";\nimport type { DeferredPromise } from \"p-defer\";\nimport pDefer from \"p-defer\";\nimport type { Mock } from \"vitest\";\nimport { beforeAll, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport { createWriteableClient } from \"./createWriteableClient.js\";\nimport { EditRequestManager } from \"./EditRequestManager.js\";\nimport type { WriteableClient } from \"./WriteableClient.js\";\n\ndescribe(\"EditRequestManager\", () => {\n let client: WriteableClient<any>;\n let apiServer: SetupServer;\n let baseUrl: string;\n let maybeDeferServer: DeferredPromise<void> | undefined;\n let mockedRequestHandler: Mock<\n Parameters<typeof MockOntologiesV2.OntologyTransactions.postEdits>[1]\n >;\n let editRequestManager: EditRequestManager;\n\n beforeAll(() => {\n const testSetup = startNodeApiServer(\n new LegacyFauxFoundry(),\n createWriteableClient.bind(null, \"transaction\"),\n );\n ({ client, apiServer } = testSetup);\n baseUrl = testSetup.fauxFoundry.baseUrl;\n\n mockedRequestHandler = vi.fn<\n Parameters<typeof MockOntologiesV2.OntologyTransactions.postEdits>[1]\n >(async () => {\n if (maybeDeferServer) {\n await maybeDeferServer.promise;\n }\n return {\n status: 200,\n body: {},\n };\n });\n apiServer.use(\n MockOntologiesV2.OntologyTransactions.postEdits(\n baseUrl,\n mockedRequestHandler,\n ),\n );\n\n return () => {\n apiServer.close();\n };\n });\n\n beforeEach(() => {\n editRequestManager = new EditRequestManager(client);\n vi.restoreAllMocks();\n });\n\n const addLinkEdit: TransactionEdit = {\n type: \"addLink\",\n primaryKey: \"test-primary-key\",\n linkedObjectPrimaryKey: \"test-linked-object-primary-key\",\n linkType: \"test-link-type\",\n objectType: \"test-object-type\",\n };\n\n const addObjectEdit: TransactionEdit = {\n type: \"addObject\",\n primaryKey: \"test-primary-key\",\n objectType: \"test-object-type\",\n properties: {},\n };\n\n it(\"will stage single edits in a row\", async () => {\n await editRequestManager.postEdit(addLinkEdit);\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(1);\n expect(await mockedRequestHandler.mock.calls[0][0].request.json())\n .toMatchInlineSnapshot(\n `\n {\n \"edits\": [\n {\n \"linkType\": \"test-link-type\",\n \"linkedObjectPrimaryKey\": \"test-linked-object-primary-key\",\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"type\": \"addLink\",\n },\n ],\n }\n `,\n );\n\n await editRequestManager.postEdit(addObjectEdit);\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(2);\n expect(await mockedRequestHandler.mock.calls[1][0].request.json())\n .toMatchInlineSnapshot(\n `\n {\n \"edits\": [\n {\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n ],\n }\n `,\n );\n });\n\n it(\"stages multiple edits from the same tick in one request in order\", async () => {\n void editRequestManager.postEdit(addLinkEdit);\n void editRequestManager.postEdit(addObjectEdit);\n await editRequestManager.postEdit(addObjectEdit);\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(1);\n expect(await mockedRequestHandler.mock.calls[0][0].request.json())\n .toMatchInlineSnapshot(\n `\n {\n \"edits\": [\n {\n \"linkType\": \"test-link-type\",\n \"linkedObjectPrimaryKey\": \"test-linked-object-primary-key\",\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"type\": \"addLink\",\n },\n {\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n {\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n ],\n }\n `,\n );\n\n await editRequestManager.postEdit(addLinkEdit);\n expect(mockedRequestHandler).toHaveBeenCalledTimes(2);\n expect(await mockedRequestHandler.mock.calls[1][0].request.json())\n .toMatchInlineSnapshot(`\n {\n \"edits\": [\n {\n \"linkType\": \"test-link-type\",\n \"linkedObjectPrimaryKey\": \"test-linked-object-primary-key\",\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"type\": \"addLink\",\n },\n ],\n }\n `);\n });\n\n it(\"handles edits posted while a request is in flight\", async () => {\n maybeDeferServer = pDefer();\n void editRequestManager.postEdit(\n addLinkEdit,\n );\n await new Promise(resolve => setTimeout(resolve, 0)); // Ensure the initial request is in flight\n const secondPromise: Promise<void> = editRequestManager.postEdit(\n addObjectEdit,\n );\n void editRequestManager.postEdit(addObjectEdit);\n maybeDeferServer.resolve();\n\n await secondPromise; // Awaiting the second edit should ensure the first resolves first and should also resolve the third since it was dispatched in the same tick\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(2);\n expect(await mockedRequestHandler.mock.calls[0][0].request.json())\n .toMatchInlineSnapshot(\n `\n {\n \"edits\": [\n {\n \"linkType\": \"test-link-type\",\n \"linkedObjectPrimaryKey\": \"test-linked-object-primary-key\",\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"type\": \"addLink\",\n },\n ],\n }\n `,\n );\n expect(await mockedRequestHandler.mock.calls[1][0].request.json())\n .toMatchInlineSnapshot(`\n {\n \"edits\": [\n {\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n {\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n ],\n }\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SACEA,iBAAiB,EACjBC,gBAAgB,EAChBC,kBAAkB,QACb,mBAAmB;AAE1B,OAAOC,MAAM,MAAM,SAAS;AAE5B,SAASC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,QAAQ;AACxE,SAASC,qBAAqB,QAAQ,4BAA4B;AAClE,SAASC,kBAAkB,QAAQ,yBAAyB;AAG5DL,QAAQ,CAAC,oBAAoB,EAAE,MAAM;EACnC,IAAIM,MAA4B;EAChC,IAAIC,SAAsB;EAC1B,IAAIC,OAAe;EACnB,IAAIC,gBAAmD;EACvD,IAAIC,oBAEH;EACD,IAAIC,kBAAsC;EAE1Cb,SAAS,CAAC,MAAM;IACd,MAAMc,SAAS,GAAGhB,kBAAkB,CAClC,IAAIF,iBAAiB,CAAC,CAAC,EACvBU,qBAAqB,CAACS,IAAI,CAAC,IAAI,EAAE,aAAa,CAChD,CAAC;IACD,CAAC;MAAEP,MAAM;MAAEC;IAAU,CAAC,GAAGK,SAAS;IAClCJ,OAAO,GAAGI,SAAS,CAACE,WAAW,CAACN,OAAO;IAEvCE,oBAAoB,GAAGP,EAAE,CAACY,EAAE,CAE1B,YAAY;MACZ,IAAIN,gBAAgB,EAAE;QACpB,MAAMA,gBAAgB,CAACO,OAAO;MAChC;MACA,OAAO;QACLC,MAAM,EAAE,GAAG;QACXC,IAAI,EAAE,CAAC;MACT,CAAC;IACH,CAAC,CAAC;IACFX,SAAS,CAACY,GAAG,CACXxB,gBAAgB,CAACyB,oBAAoB,CAACC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C,UAAU,CAACD,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,MAAME,aAA4B,GAAG/B,kBAAkB,CAACqB,QAAQ,CAC9DF,aACF,CAAC;IACD,KAAKnB,kBAAkB,CAACqB,QAAQ,CAACF,aAAa,CAAC;IAC/CrB,gBAAgB,CAAC+B,OAAO,CAAC,CAAC;IAE1B,MAAME,aAAa,CAAC,CAAC;;IAErBzC,MAAM,CAACS,oBAAoB,CAAC,CAACuB,qBAAqB,CAAC,CAAC,CAAC;IACrDhC,MAAM,CAAC,MAAMS,oBAAoB,CAACwB,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC,CAC/DC,qBAAqB,CACpB;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OACM,CAAC;IACHrC,MAAM,CAAC,MAAMS,oBAAoB,CAACwB,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC,CAC/DC,qBAAqB,CAAC;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;EACN,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"EditRequestManager.test.js","names":["LegacyFauxFoundry","MockOntologiesV2","startNodeApiServer","pDefer","beforeAll","beforeEach","describe","expect","it","vi","createWriteableClient","EditRequestManager","client","apiServer","baseUrl","maybeDeferServer","mockedRequestHandler","editRequestManager","testSetup","bind","fauxFoundry","fn","promise","status","body","use","OntologyTransactions","postEdits","close","restoreAllMocks","addLinkEdit","type","primaryKey","linkedObjectPrimaryKey","linkType","objectType","addObjectEdit","properties","postEdit","toHaveBeenCalledTimes","mock","calls","request","json","toMatchInlineSnapshot","Promise","resolve","setTimeout","secondPromise"],"sources":["EditRequestManager.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { TransactionEdit } from \"@osdk/foundry.ontologies\";\nimport type { SetupServer } from \"@osdk/shared.test\";\nimport {\n LegacyFauxFoundry,\n MockOntologiesV2,\n startNodeApiServer,\n} from \"@osdk/shared.test\";\nimport type { DeferredPromise } from \"p-defer\";\nimport pDefer from \"p-defer\";\nimport type { Mock } from \"vitest\";\nimport { beforeAll, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport { createWriteableClient } from \"./createWriteableClient.js\";\nimport { EditRequestManager } from \"./EditRequestManager.js\";\nimport type { WriteableClient } from \"./WriteableClient.js\";\n\ndescribe(\"EditRequestManager\", () => {\n let client: WriteableClient<any>;\n let apiServer: SetupServer;\n let baseUrl: string;\n let maybeDeferServer: DeferredPromise<void> | undefined;\n let mockedRequestHandler: Mock<\n Parameters<typeof MockOntologiesV2.OntologyTransactions.postEdits>[1]\n >;\n let editRequestManager: EditRequestManager;\n\n beforeAll(() => {\n const testSetup = startNodeApiServer(\n new LegacyFauxFoundry(),\n createWriteableClient.bind(null, \"transaction\"),\n );\n ({ client, apiServer } = testSetup);\n baseUrl = testSetup.fauxFoundry.baseUrl;\n\n mockedRequestHandler = vi.fn<\n Parameters<typeof MockOntologiesV2.OntologyTransactions.postEdits>[1]\n >(async () => {\n if (maybeDeferServer) {\n await maybeDeferServer.promise;\n }\n return {\n status: 200,\n body: {},\n };\n });\n apiServer.use(\n MockOntologiesV2.OntologyTransactions.postEdits(\n baseUrl,\n mockedRequestHandler,\n ),\n );\n\n return () => {\n apiServer.close();\n };\n });\n\n beforeEach(() => {\n editRequestManager = new EditRequestManager(client);\n vi.restoreAllMocks();\n });\n\n const addLinkEdit: TransactionEdit = {\n type: \"addLink\",\n primaryKey: \"test-primary-key\",\n linkedObjectPrimaryKey: \"test-linked-object-primary-key\",\n linkType: \"test-link-type\",\n objectType: \"test-object-type\",\n };\n\n const addObjectEdit: TransactionEdit = {\n type: \"addObject\",\n objectType: \"test-object-type\",\n properties: {},\n };\n\n it(\"will stage single edits in a row\", async () => {\n await editRequestManager.postEdit(addLinkEdit);\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(1);\n expect(await mockedRequestHandler.mock.calls[0][0].request.json())\n .toMatchInlineSnapshot(\n `\n {\n \"edits\": [\n {\n \"linkType\": \"test-link-type\",\n \"linkedObjectPrimaryKey\": \"test-linked-object-primary-key\",\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"type\": \"addLink\",\n },\n ],\n }\n `,\n );\n\n await editRequestManager.postEdit(addObjectEdit);\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(2);\n expect(await mockedRequestHandler.mock.calls[1][0].request.json())\n .toMatchInlineSnapshot(\n `\n {\n \"edits\": [\n {\n \"objectType\": \"test-object-type\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n ],\n }\n `,\n );\n });\n\n it(\"stages multiple edits from the same tick in one request in order\", async () => {\n void editRequestManager.postEdit(addLinkEdit);\n void editRequestManager.postEdit(addObjectEdit);\n await editRequestManager.postEdit(addObjectEdit);\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(1);\n expect(await mockedRequestHandler.mock.calls[0][0].request.json())\n .toMatchInlineSnapshot(\n `\n {\n \"edits\": [\n {\n \"linkType\": \"test-link-type\",\n \"linkedObjectPrimaryKey\": \"test-linked-object-primary-key\",\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"type\": \"addLink\",\n },\n {\n \"objectType\": \"test-object-type\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n {\n \"objectType\": \"test-object-type\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n ],\n }\n `,\n );\n\n await editRequestManager.postEdit(addLinkEdit);\n expect(mockedRequestHandler).toHaveBeenCalledTimes(2);\n expect(await mockedRequestHandler.mock.calls[1][0].request.json())\n .toMatchInlineSnapshot(`\n {\n \"edits\": [\n {\n \"linkType\": \"test-link-type\",\n \"linkedObjectPrimaryKey\": \"test-linked-object-primary-key\",\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"type\": \"addLink\",\n },\n ],\n }\n `);\n });\n\n it(\"handles edits posted while a request is in flight\", async () => {\n maybeDeferServer = pDefer();\n void editRequestManager.postEdit(\n addLinkEdit,\n );\n await new Promise(resolve => setTimeout(resolve, 0)); // Ensure the initial request is in flight\n const secondPromise: Promise<void> = editRequestManager.postEdit(\n addObjectEdit,\n );\n void editRequestManager.postEdit(addObjectEdit);\n maybeDeferServer.resolve();\n\n await secondPromise; // Awaiting the second edit should ensure the first resolves first and should also resolve the third since it was dispatched in the same tick\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(2);\n expect(await mockedRequestHandler.mock.calls[0][0].request.json())\n .toMatchInlineSnapshot(\n `\n {\n \"edits\": [\n {\n \"linkType\": \"test-link-type\",\n \"linkedObjectPrimaryKey\": \"test-linked-object-primary-key\",\n \"objectType\": \"test-object-type\",\n \"primaryKey\": \"test-primary-key\",\n \"type\": \"addLink\",\n },\n ],\n }\n `,\n );\n expect(await mockedRequestHandler.mock.calls[1][0].request.json())\n .toMatchInlineSnapshot(`\n {\n \"edits\": [\n {\n \"objectType\": \"test-object-type\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n {\n \"objectType\": \"test-object-type\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n ],\n }\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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BAAoB,CAAC,CAACuB,qBAAqB,CAAC,CAAC,CAAC;IACrDhC,MAAM,CAAC,MAAMS,oBAAoB,CAACwB,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC,CAC/DC,qBAAqB,CACpB;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OACM,CAAC;IACHrC,MAAM,CAAC,MAAMS,oBAAoB,CAACwB,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC,CAC/DC,qBAAqB,CAAC;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;EACN,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -84,7 +84,6 @@ export function createWriteableClient(...args) {
84
84
  return editRequestManager.postEdit({
85
85
  type: "addObject",
86
86
  objectType: obj.apiName,
87
- primaryKey: obj.$primaryKey,
88
87
  properties: propertyMap
89
88
  });
90
89
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createWriteableClient.js","names":["createClientWithTransaction","EditRequestManager","toPropertyDataValue","writeableClientContext","createWriteableClient","args","transactionRid","ontologyRid","client","editRequestManager","writeableClient","Object","defineProperties","link","value","source","apiName","target","Array","isArray","postEdit","type","objectType","$apiName","primaryKey","$primaryKey","linkType","linkedObjectPrimaryKey","promises","elem","push","Promise","all","then","undefined","unlink","create","obj","properties","propertyMap","key","entries","update","locator","delete"],"sources":["createWriteableClient.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createClientWithTransaction } from \"@osdk/client/unstable-do-not-use\";\n\nimport type { Client } from \"@osdk/client\";\nimport type {\n AddLinkApiNames,\n AddLinkSources,\n AddLinkTargets,\n CreatableObjectOrInterfaceTypeProperties,\n CreatableObjectOrInterfaceTypes,\n DeletableObjectOrInterfaceLocators,\n RemoveLinkApiNames,\n RemoveLinkSources,\n RemoveLinkTargets,\n UpdatableObjectOrInterfaceLocatorProperties,\n UpdatableObjectOrInterfaceLocators,\n} from \"../edits/EditBatch.js\";\nimport type { AnyEdit } from \"../edits/types.js\";\nimport { EditRequestManager } from \"./EditRequestManager.js\";\nimport { toPropertyDataValue } from \"./toPropertyDataValue.js\";\nimport type {\n WriteableClient,\n WriteableClientContext,\n WriteMethods,\n} from \"./WriteableClient.js\";\nimport { writeableClientContext } from \"./WriteableClient.js\";\n\nexport function createWriteableClient<\n X extends AnyEdit = never,\n>(\n ...args: Parameters<typeof createClientWithTransaction>\n): WriteableClient<X> {\n const transactionRid = args[0];\n const ontologyRid = args[2];\n\n const client = createClientWithTransaction(...args);\n\n const editRequestManager = new EditRequestManager(\n client as WriteableClient<any>, // This cast is safe because we create the writeable client properties below.\n );\n\n // We use define properties because the client has non-enumerable properties that we want to preserve.\n const writeableClient = Object.defineProperties<Client>(\n client,\n {\n link: {\n value: function<\n SOL extends AddLinkSources<X>,\n A extends AddLinkApiNames<X, SOL>,\n >(\n source: SOL,\n apiName: A,\n target: AddLinkTargets<X, SOL, A>,\n ): Promise<void> {\n if (!Array.isArray(target)) {\n return editRequestManager.postEdit({\n type: \"addLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: target.$primaryKey,\n });\n }\n const promises: Promise<void>[] = [];\n\n for (const elem of target) {\n promises.push(\n editRequestManager.postEdit({\n type: \"addLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: elem.$primaryKey,\n }),\n );\n }\n return Promise.all(promises).then(() => undefined);\n },\n },\n unlink: {\n value: function<\n SOL extends RemoveLinkSources<X>,\n A extends RemoveLinkApiNames<X, SOL>,\n >(\n source: SOL,\n apiName: A,\n target: RemoveLinkTargets<X, SOL, A>,\n ): Promise<void> {\n if (!Array.isArray(target)) {\n return editRequestManager.postEdit({\n type: \"removeLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: target.$primaryKey,\n });\n }\n const promises: Promise<void>[] = [];\n for (const elem of target) {\n promises.push(editRequestManager.postEdit({\n type: \"removeLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: elem.$primaryKey,\n }));\n }\n return Promise.all(promises).then(() => undefined);\n },\n },\n create: {\n value: async function<OTD extends CreatableObjectOrInterfaceTypes<X>>(\n obj: OTD,\n properties: CreatableObjectOrInterfaceTypeProperties<X, OTD>,\n ): Promise<void> {\n const propertyMap: { [propertyName: string]: unknown } = {};\n for (const [key, value] of Object.entries(properties)) {\n propertyMap[key] = toPropertyDataValue(value);\n }\n return editRequestManager.postEdit({\n type: \"addObject\",\n objectType: obj.apiName,\n primaryKey: obj.$primaryKey,\n properties: propertyMap,\n });\n },\n },\n update: {\n value: function<\n SOL extends UpdatableObjectOrInterfaceLocators<X>,\n OTD extends UpdatableObjectOrInterfaceLocatorProperties<X, SOL>,\n >(\n locator: SOL,\n properties: OTD,\n ): Promise<void> {\n const propertyMap: { [propertyName: string]: unknown } = {};\n for (const [key, value] of Object.entries(properties)) {\n propertyMap[key] = toPropertyDataValue(value);\n }\n return editRequestManager.postEdit({\n type: \"modifyObject\",\n objectType: locator.$apiName,\n primaryKey: locator.$primaryKey,\n properties: propertyMap,\n });\n },\n },\n delete: {\n value: function<OL extends DeletableObjectOrInterfaceLocators<X>>(\n obj: OL,\n ): Promise<void> {\n return editRequestManager.postEdit({\n type: \"deleteObject\",\n objectType: obj.$apiName,\n primaryKey: obj.$primaryKey,\n });\n },\n },\n [writeableClientContext]: {\n value: {\n ontologyRid,\n transactionRid,\n } satisfies WriteableClientContext,\n },\n } satisfies Record<\n keyof WriteMethods<any> | typeof writeableClientContext,\n PropertyDescriptor\n >,\n ) as WriteableClient<X>;\n\n return writeableClient;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,2BAA2B,QAAQ,kCAAkC;AAiB9E,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,mBAAmB,QAAQ,0BAA0B;AAM9D,SAASC,sBAAsB,QAAQ,sBAAsB;AAE7D,OAAO,SAASC,qBAAqBA,CAGnC,GAAGC,IAAoD,EACnC;EACpB,MAAMC,cAAc,GAAGD,IAAI,CAAC,CAAC,CAAC;EAC9B,MAAME,WAAW,GAAGF,IAAI,CAAC,CAAC,CAAC;EAE3B,MAAMG,MAAM,GAAGR,2BAA2B,CAAC,GAAGK,IAAI,CAAC;EAEnD,MAAMI,kBAAkB,GAAG,IAAIR,kBAAkB,CAC/CO,MACF,CAAC,CADiC;EACjC;;EAED;EACA,MAAME,eAAe,GAAGC,MAAM,CAACC,gBAAgB,CAC7CJ,MAAM,EACN;IACEK,IAAI,EAAE;MACJC,KAAK,EAAE,SAAAA,CAILC,MAAW,EACXC,OAAU,EACVC,MAAiC,EAClB;QACf,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,EAAE;UAC1B,OAAOR,kBAAkB,CAACW,QAAQ,CAAC;YACjCC,IAAI,EAAE,SAAS;YACfC,UAAU,EAAEP,MAAM,CAACQ,QAAQ;YAC3BC,UAAU,EAAET,MAAM,CAACU,WAAW;YAC9BC,QAAQ,EAAEV,OAAO;YACjBW,sBAAsB,EAAEV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Q;UACxBC,UAAU,EAAEa,GAAG,CAACZ;QAClB,CAAC,CAAC;MACJ;IACF,CAAC;IACD,CAACtB,sBAAsB,GAAG;MACxBW,KAAK,EAAE;QACLP,WAAW;QACXD;MACF;IACF;EACF,CAIF,CAAuB;EAEvB,OAAOI,eAAe;AACxB","ignoreList":[]}
1
+ {"version":3,"file":"createWriteableClient.js","names":["createClientWithTransaction","EditRequestManager","toPropertyDataValue","writeableClientContext","createWriteableClient","args","transactionRid","ontologyRid","client","editRequestManager","writeableClient","Object","defineProperties","link","value","source","apiName","target","Array","isArray","postEdit","type","objectType","$apiName","primaryKey","$primaryKey","linkType","linkedObjectPrimaryKey","promises","elem","push","Promise","all","then","undefined","unlink","create","obj","properties","propertyMap","key","entries","update","locator","delete"],"sources":["createWriteableClient.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createClientWithTransaction } from \"@osdk/client/unstable-do-not-use\";\n\nimport type { Client } from \"@osdk/client\";\nimport type {\n AddLinkApiNames,\n AddLinkSources,\n AddLinkTargets,\n CreatableObjectOrInterfaceTypeProperties,\n CreatableObjectOrInterfaceTypes,\n DeletableObjectOrInterfaceLocators,\n RemoveLinkApiNames,\n RemoveLinkSources,\n RemoveLinkTargets,\n UpdatableObjectOrInterfaceLocatorProperties,\n UpdatableObjectOrInterfaceLocators,\n} from \"../edits/EditBatch.js\";\nimport type { AnyEdit } from \"../edits/types.js\";\nimport { EditRequestManager } from \"./EditRequestManager.js\";\nimport { toPropertyDataValue } from \"./toPropertyDataValue.js\";\nimport type {\n WriteableClient,\n WriteableClientContext,\n WriteMethods,\n} from \"./WriteableClient.js\";\nimport { writeableClientContext } from \"./WriteableClient.js\";\n\nexport function createWriteableClient<\n X extends AnyEdit = never,\n>(\n ...args: Parameters<typeof createClientWithTransaction>\n): WriteableClient<X> {\n const transactionRid = args[0];\n const ontologyRid = args[2];\n\n const client = createClientWithTransaction(...args);\n\n const editRequestManager = new EditRequestManager(\n client as WriteableClient<any>, // This cast is safe because we create the writeable client properties below.\n );\n\n // We use define properties because the client has non-enumerable properties that we want to preserve.\n const writeableClient = Object.defineProperties<Client>(\n client,\n {\n link: {\n value: function<\n SOL extends AddLinkSources<X>,\n A extends AddLinkApiNames<X, SOL>,\n >(\n source: SOL,\n apiName: A,\n target: AddLinkTargets<X, SOL, A>,\n ): Promise<void> {\n if (!Array.isArray(target)) {\n return editRequestManager.postEdit({\n type: \"addLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: target.$primaryKey,\n });\n }\n const promises: Promise<void>[] = [];\n\n for (const elem of target) {\n promises.push(\n editRequestManager.postEdit({\n type: \"addLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: elem.$primaryKey,\n }),\n );\n }\n return Promise.all(promises).then(() => undefined);\n },\n },\n unlink: {\n value: function<\n SOL extends RemoveLinkSources<X>,\n A extends RemoveLinkApiNames<X, SOL>,\n >(\n source: SOL,\n apiName: A,\n target: RemoveLinkTargets<X, SOL, A>,\n ): Promise<void> {\n if (!Array.isArray(target)) {\n return editRequestManager.postEdit({\n type: \"removeLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: target.$primaryKey,\n });\n }\n const promises: Promise<void>[] = [];\n for (const elem of target) {\n promises.push(editRequestManager.postEdit({\n type: \"removeLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: elem.$primaryKey,\n }));\n }\n return Promise.all(promises).then(() => undefined);\n },\n },\n create: {\n value: async function<OTD extends CreatableObjectOrInterfaceTypes<X>>(\n obj: OTD,\n properties: CreatableObjectOrInterfaceTypeProperties<X, OTD>,\n ): Promise<void> {\n const propertyMap: { [propertyName: string]: unknown } = {};\n for (const [key, value] of Object.entries(properties)) {\n propertyMap[key] = toPropertyDataValue(value);\n }\n return editRequestManager.postEdit({\n type: \"addObject\",\n objectType: obj.apiName,\n properties: propertyMap,\n });\n },\n },\n update: {\n value: function<\n SOL extends UpdatableObjectOrInterfaceLocators<X>,\n OTD extends UpdatableObjectOrInterfaceLocatorProperties<X, SOL>,\n >(\n locator: SOL,\n properties: OTD,\n ): Promise<void> {\n const propertyMap: { [propertyName: string]: unknown } = {};\n for (const [key, value] of Object.entries(properties)) {\n propertyMap[key] = toPropertyDataValue(value);\n }\n return editRequestManager.postEdit({\n type: \"modifyObject\",\n objectType: locator.$apiName,\n primaryKey: locator.$primaryKey,\n properties: propertyMap,\n });\n },\n },\n delete: {\n value: function<OL extends DeletableObjectOrInterfaceLocators<X>>(\n obj: OL,\n ): Promise<void> {\n return editRequestManager.postEdit({\n type: \"deleteObject\",\n objectType: obj.$apiName,\n primaryKey: obj.$primaryKey,\n });\n },\n },\n [writeableClientContext]: {\n value: {\n ontologyRid,\n transactionRid,\n } satisfies WriteableClientContext,\n },\n } satisfies Record<\n keyof WriteMethods<any> | typeof writeableClientContext,\n PropertyDescriptor\n >,\n ) as WriteableClient<X>;\n\n return writeableClient;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,2BAA2B,QAAQ,kCAAkC;AAiB9E,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,mBAAmB,QAAQ,0BAA0B;AAM9D,SAASC,sBAAsB,QAAQ,sBAAsB;AAE7D,OAAO,SAASC,qBAAqBA,CAGnC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EAAE,SAAAA,CAIL6B,OAAY,EACZL,UAAe,EACA;QACf,MAAMC,WAAgD,GAAG,CAAC,CAAC;QAC3D,KAAK,MAAM,CAACC,GAAG,EAAE1B,KAAK,CAAC,IAAIH,MAAM,CAAC8B,OAAO,CAACH,UAAU,CAAC,EAAE;UACrDC,WAAW,CAACC,GAAG,CAAC,GAAGtC,mBAAmB,CAACY,KAAK,CAAC;QAC/C;QACA,OAAOL,kBAAkB,CAACW,QAAQ,CAAC;UACjCC,IAAI,EAAE,cAAc;UACpBC,UAAU,EAAEqB,OAAO,CAACpB,QAAQ;UAC5BC,UAAU,EAAEmB,OAAO,CAAClB,WAAW;UAC/Ba,UAAU,EAAEC;QACd,CAAC,CAAC;MACJ;IACF,CAAC;IACDK,MAAM,EAAE;MACN9B,KAAK,EAAE,SAAAA,CACLuB,GAAO,EACQ;QACf,OAAO5B,kBAAkB,CAACW,QAAQ,CAAC;UACjCC,IAAI,EAAE,cAAc;UACpBC,UAAU,EAAEe,GAAG,CAACd,QAAQ;UACxBC,UAAU,EAAEa,GAAG,CAACZ;QAClB,CAAC,CAAC;MACJ;IACF,CAAC;IACD,CAACtB,sBAAsB,GAAG;MACxBW,KAAK,EAAE;QACLP,WAAW;QACXD;MACF;IACF;EACF,CAIF,CAAuB;EAEvB,OAAOI,eAAe;AACxB","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdk/functions",
3
- "version": "1.4.0-beta.7",
3
+ "version": "1.4.0-beta.8",
4
4
  "description": "",
5
5
  "access": "public",
6
6
  "license": "Apache-2.0",
@@ -47,14 +47,14 @@
47
47
  }
48
48
  },
49
49
  "dependencies": {
50
- "@osdk/foundry.core": "^2.38.0",
51
- "@osdk/foundry.mediasets": "^2.38.0",
52
- "@osdk/foundry.ontologies": "^2.38.0",
50
+ "@osdk/foundry.core": "^2.40.0",
51
+ "@osdk/foundry.mediasets": "^2.40.0",
52
+ "@osdk/foundry.ontologies": "^2.40.0",
53
53
  "@types/geojson": "^7946.0.16",
54
54
  "yaml": "^2.8.1"
55
55
  },
56
56
  "peerDependencies": {
57
- "@osdk/client": "^2.6.0-beta.9"
57
+ "@osdk/client": "^2.6.0-beta.10"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@microsoft/api-documenter": "^7.26.32",
@@ -64,10 +64,10 @@
64
64
  "p-defer": "^4.0.1",
65
65
  "ts-expect": "^1.3.0",
66
66
  "typescript": "~5.5.4",
67
- "@osdk/client.test.ontology": "~2.6.0-beta.9",
67
+ "@osdk/client.test.ontology": "~2.6.0-beta.10",
68
+ "@osdk/monorepo.api-extractor": "~0.5.0-beta.1",
68
69
  "@osdk/monorepo.tsconfig": "~0.5.0-beta.1",
69
- "@osdk/shared.test": "~2.6.0-beta.3",
70
- "@osdk/monorepo.api-extractor": "~0.5.0-beta.1"
70
+ "@osdk/shared.test": "~2.6.0-beta.4"
71
71
  },
72
72
  "publishConfig": {
73
73
  "access": "public"