@osdk/functions 1.5.0-beta.3 → 1.5.0-rc.5

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/build/browser/public/experimental.js +2 -0
  3. package/build/browser/public/experimental.js.map +1 -0
  4. package/build/browser/public/unstable-do-not-use.js +1 -0
  5. package/build/browser/public/unstable-do-not-use.js.map +1 -1
  6. package/build/browser/transactions/EditRequestManager.js +20 -1
  7. package/build/browser/transactions/EditRequestManager.js.map +1 -1
  8. package/build/browser/transactions/EditRequestManager.test.js +130 -0
  9. package/build/browser/transactions/EditRequestManager.test.js.map +1 -1
  10. package/build/browser/transactions/WriteableClient.js.map +1 -1
  11. package/build/browser/transactions/createWriteableClient.js +5 -5
  12. package/build/browser/transactions/createWriteableClient.js.map +1 -1
  13. package/build/browser/transactions/flushEdits.js +21 -0
  14. package/build/browser/transactions/flushEdits.js.map +1 -0
  15. package/build/cjs/public/experimental.cjs +4 -0
  16. package/build/cjs/public/experimental.cjs.map +1 -0
  17. package/build/cjs/public/experimental.d.cts +35 -0
  18. package/build/cjs/public/unstable-do-not-use.cjs +33 -6
  19. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
  20. package/build/cjs/public/unstable-do-not-use.d.cts +7 -19
  21. package/build/esm/public/experimental.js +2 -0
  22. package/build/esm/public/experimental.js.map +1 -0
  23. package/build/esm/public/unstable-do-not-use.js +1 -0
  24. package/build/esm/public/unstable-do-not-use.js.map +1 -1
  25. package/build/esm/transactions/EditRequestManager.js +20 -1
  26. package/build/esm/transactions/EditRequestManager.js.map +1 -1
  27. package/build/esm/transactions/EditRequestManager.test.js +130 -0
  28. package/build/esm/transactions/EditRequestManager.test.js.map +1 -1
  29. package/build/esm/transactions/WriteableClient.js.map +1 -1
  30. package/build/esm/transactions/createWriteableClient.js +5 -5
  31. package/build/esm/transactions/createWriteableClient.js.map +1 -1
  32. package/build/esm/transactions/flushEdits.js +21 -0
  33. package/build/esm/transactions/flushEdits.js.map +1 -0
  34. package/build/types/public/experimental.d.ts +1 -0
  35. package/build/types/public/experimental.d.ts.map +1 -0
  36. package/build/types/public/unstable-do-not-use.d.ts +1 -0
  37. package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
  38. package/build/types/transactions/EditRequestManager.d.ts +1 -0
  39. package/build/types/transactions/EditRequestManager.d.ts.map +1 -1
  40. package/build/types/transactions/WriteableClient.d.ts +3 -1
  41. package/build/types/transactions/WriteableClient.d.ts.map +1 -1
  42. package/build/types/transactions/createWriteableClient.d.ts +2 -2
  43. package/build/types/transactions/createWriteableClient.d.ts.map +1 -1
  44. package/build/types/transactions/flushEdits.d.ts +2 -0
  45. package/build/types/transactions/flushEdits.d.ts.map +1 -0
  46. package/experimental.d.ts +17 -0
  47. package/package.json +14 -5
@@ -65,12 +65,31 @@ var EditRequestManager = class {
65
65
  async dispatchRequest() {
66
66
  const copiedEdits = this.pendingEdits;
67
67
  this.pendingEdits = [];
68
- await OntologyTransaction_exports.postEdits(this.client, await this.client[writeableClientContext].ontologyRid, this.client[writeableClientContext].transactionRid, {
68
+ await OntologyTransaction_exports.postEdits(this.client, await this.client[writeableClientContext].ontologyRid, this.client[writeableClientContext].transactionId, {
69
69
  edits: copiedEdits
70
70
  }, {
71
71
  preview: true
72
72
  });
73
73
  }
74
+ async flushPendingEdits() {
75
+ if (this.editTimeout) {
76
+ clearTimeout(this.editTimeout);
77
+ this.editTimeout = null;
78
+ if (this.pendingEdits.length > 0) {
79
+ await this.dispatchRequest();
80
+ this.inFlightRequest = null;
81
+ }
82
+ }
83
+ if (this.inFlightRequest) {
84
+ await this.inFlightRequest;
85
+ }
86
+ if (this.queuedRequest) {
87
+ await this.queuedRequest;
88
+ }
89
+ if (this.pendingEdits.length > 0) {
90
+ await this.dispatchRequest();
91
+ }
92
+ }
74
93
  };
75
94
 
76
95
  // src/transactions/toPropertyDataValue.ts
@@ -98,10 +117,10 @@ function isPoint(o) {
98
117
  }
99
118
 
100
119
  // src/transactions/createWriteableClient.ts
101
- function createWriteableClient(...args) {
102
- const transactionRid = args[0];
103
- const ontologyRid = args[2];
104
- const client = unstableDoNotUse.createClientWithTransaction(...args);
120
+ function createWriteableClient(transactionId, ...args) {
121
+ const ontologyRid = args[1];
122
+ const client = unstableDoNotUse.createClientWithTransaction(transactionId, async () => {
123
+ }, ...args);
105
124
  const editRequestManager = new EditRequestManager(client);
106
125
  const writeableClient = Object.defineProperties(client, {
107
126
  link: {
@@ -191,12 +210,19 @@ function createWriteableClient(...args) {
191
210
  [writeableClientContext]: {
192
211
  value: {
193
212
  ontologyRid,
194
- transactionRid
213
+ transactionId,
214
+ editRequestManager
195
215
  }
196
216
  }
197
217
  });
198
218
  return writeableClient;
199
219
  }
220
+
221
+ // src/transactions/flushEdits.ts
222
+ async function flushEdits(client) {
223
+ await client[writeableClientContext].editRequestManager.flushPendingEdits();
224
+ return;
225
+ }
200
226
  var FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR = "FOUNDRY_SERVICE_DISCOVERY_V2";
201
227
  var API_GATEWAY_SERVICE = "api_gateway";
202
228
  function hasUrisProperty(config) {
@@ -236,6 +262,7 @@ function getApiGatewayBaseUrl() {
236
262
  }
237
263
 
238
264
  exports.createWriteableClient = createWriteableClient;
265
+ exports.flushEdits = flushEdits;
239
266
  exports.getApiGatewayBaseUrl = getApiGatewayBaseUrl;
240
267
  //# sourceMappingURL=unstable-do-not-use.cjs.map
241
268
  //# sourceMappingURL=unstable-do-not-use.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../node_modules/.pnpm/@osdk+foundry.ontologies@2.44.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","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AAQ,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/{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}"]}
1
+ {"version":3,"sources":["../../../../../node_modules/.pnpm/@osdk+foundry.ontologies@2.44.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/transactions/flushEdits.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,IAAA,CAAK,aAAgB,GAAA,IAAA,CAAK,eAAgB,CAAA,IAAA,CAAK,YAAY;AACzD,QAAA,IAAA,CAAK,kBAAkB,IAAK,CAAA,aAAA;AAC5B,QAAA,IAAA,CAAK,aAAgB,GAAA,IAAA;AACrB,QAAK,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mB,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/{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].transactionId, {\n edits: copiedEdits\n }, {\n preview: true\n });\n }\n async flushPendingEdits() {\n if (this.editTimeout) {\n clearTimeout(this.editTimeout);\n this.editTimeout = null;\n if (this.pendingEdits.length > 0) {\n await this.dispatchRequest();\n this.inFlightRequest = null;\n }\n }\n if (this.inFlightRequest) {\n await this.inFlightRequest;\n }\n if (this.queuedRequest) {\n await this.queuedRequest;\n }\n if (this.pendingEdits.length > 0) {\n await this.dispatchRequest();\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(transactionId, ...args) {\n const ontologyRid = args[1];\n const client = createClientWithTransaction(transactionId, async () => {}, ...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 transactionId,\n editRequestManager\n }\n }\n });\n return writeableClient;\n}","/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { writeableClientContext } from \"./WriteableClient.js\";\nexport async function flushEdits(client) {\n await client[writeableClientContext].editRequestManager.flushPendingEdits();\n return;\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,24 +1,12 @@
1
- import { createClientWithTransaction } from '@osdk/client/unstable-do-not-use';
1
+ import { createClient } from '@osdk/client';
2
2
  import { A as AnyEdit } from '../internal-CmSoe_xi.cjs';
3
- import { Client } from '@osdk/client';
4
- import { A as AddLinkSources, a as AddLinkApiNames, b as AddLinkTargets, R as RemoveLinkSources, c as RemoveLinkApiNames, d as RemoveLinkTargets, C as CreatableObjectOrInterfaceTypes, e as CreatableObjectOrInterfaceTypeProperties, D as DeletableObjectOrInterfaceLocators, U as UpdatableObjectOrInterfaceLocators, f as UpdatableObjectOrInterfaceLocatorProperties } from '../EditBatch-CwPxevhT.cjs';
3
+ import { WriteableClient } from './experimental.cjs';
4
+ import '../EditBatch-CwPxevhT.cjs';
5
+ import '@osdk/foundry.ontologies';
5
6
 
6
- interface WriteableClientContext {
7
- ontologyRid: string | Promise<string>;
8
- transactionRid: string;
9
- }
10
- interface WriteableClient<X extends AnyEdit> extends Client, WriteMethods<X> {
11
- [writeableClientContext]: WriteableClientContext;
12
- }
13
- interface WriteMethods<X extends AnyEdit> {
14
- link: <SOL extends AddLinkSources<X>, A extends AddLinkApiNames<X, SOL>>(source: SOL, apiName: A, target: AddLinkTargets<X, SOL, A>) => Promise<void>;
15
- unlink: <SOL extends RemoveLinkSources<X>, A extends RemoveLinkApiNames<X, SOL>>(source: SOL, apiName: A, target: RemoveLinkTargets<X, SOL, A>) => Promise<void>;
16
- create: <OTD extends CreatableObjectOrInterfaceTypes<X>>(obj: OTD, properties: CreatableObjectOrInterfaceTypeProperties<X, OTD>) => Promise<void>;
17
- delete: <OL extends DeletableObjectOrInterfaceLocators<X>>(obj: OL) => Promise<void>;
18
- update: <OL extends UpdatableObjectOrInterfaceLocators<X>>(obj: OL, properties: UpdatableObjectOrInterfaceLocatorProperties<X, OL>) => Promise<void>;
19
- }
7
+ declare function createWriteableClient<X extends AnyEdit = never>(transactionId: string, ...args: Parameters<typeof createClient>): WriteableClient<X>;
20
8
 
21
- declare function createWriteableClient<X extends AnyEdit = never>(...args: Parameters<typeof createClientWithTransaction>): WriteableClient<X>;
9
+ declare function flushEdits(client: WriteableClient<any>): Promise<void>;
22
10
 
23
11
  /**
24
12
  * Retrieves the API Gateway base URL from the Function's environment.
@@ -37,4 +25,4 @@ declare function createWriteableClient<X extends AnyEdit = never>(...args: Param
37
25
  */
38
26
  declare function getApiGatewayBaseUrl(): string;
39
27
 
40
- export { type WriteableClient, createWriteableClient, getApiGatewayBaseUrl };
28
+ export { WriteableClient, createWriteableClient, flushEdits, getApiGatewayBaseUrl };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=experimental.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"experimental.js","names":[],"sources":["experimental.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type { WriteableClient } from \"../transactions/WriteableClient.js\";\n"],"mappings":"","ignoreList":[]}
@@ -15,5 +15,6 @@
15
15
  */
16
16
 
17
17
  export { createWriteableClient } from "../transactions/createWriteableClient.js";
18
+ export { flushEdits } from "../transactions/flushEdits.js";
18
19
  export { getApiGatewayBaseUrl } from "../utils/getApiGatewayBaseUrl.js";
19
20
  //# sourceMappingURL=unstable-do-not-use.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"unstable-do-not-use.js","names":["createWriteableClient","getApiGatewayBaseUrl"],"sources":["unstable-do-not-use.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { createWriteableClient } from \"../transactions/createWriteableClient.js\";\nexport type { WriteableClient } from \"../transactions/WriteableClient.js\";\nexport { getApiGatewayBaseUrl } from \"../utils/getApiGatewayBaseUrl.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,qBAAqB,QAAQ,0CAA0C;AAEhF,SAASC,oBAAoB,QAAQ,kCAAkC","ignoreList":[]}
1
+ {"version":3,"file":"unstable-do-not-use.js","names":["createWriteableClient","flushEdits","getApiGatewayBaseUrl"],"sources":["unstable-do-not-use.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { createWriteableClient } from \"../transactions/createWriteableClient.js\";\nexport { flushEdits } from \"../transactions/flushEdits.js\";\nexport type { WriteableClient } from \"../transactions/WriteableClient.js\";\nexport { getApiGatewayBaseUrl } from \"../utils/getApiGatewayBaseUrl.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,qBAAqB,QAAQ,0CAA0C;AAChF,SAASC,UAAU,QAAQ,+BAA+B;AAE1D,SAASC,oBAAoB,QAAQ,kCAAkC","ignoreList":[]}
@@ -67,11 +67,30 @@ export class EditRequestManager {
67
67
  async dispatchRequest() {
68
68
  const copiedEdits = this.pendingEdits;
69
69
  this.pendingEdits = [];
70
- await OntologyTransactions.postEdits(this.client, await this.client[writeableClientContext].ontologyRid, this.client[writeableClientContext].transactionRid, {
70
+ await OntologyTransactions.postEdits(this.client, await this.client[writeableClientContext].ontologyRid, this.client[writeableClientContext].transactionId, {
71
71
  edits: copiedEdits
72
72
  }, {
73
73
  preview: true
74
74
  });
75
75
  }
76
+ async flushPendingEdits() {
77
+ if (this.editTimeout) {
78
+ clearTimeout(this.editTimeout);
79
+ this.editTimeout = null;
80
+ if (this.pendingEdits.length > 0) {
81
+ await this.dispatchRequest();
82
+ this.inFlightRequest = null;
83
+ }
84
+ }
85
+ if (this.inFlightRequest) {
86
+ await this.inFlightRequest;
87
+ }
88
+ if (this.queuedRequest) {
89
+ await this.queuedRequest;
90
+ }
91
+ if (this.pendingEdits.length > 0) {
92
+ await this.dispatchRequest();
93
+ }
94
+ }
76
95
  }
77
96
  //# sourceMappingURL=EditRequestManager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EditRequestManager.js","names":["OntologyTransactions","writeableClientContext","EditRequestManager","pendingEdits","inFlightRequest","queuedRequest","editTimeout","constructor","client","postEdit","edit","push","then","dispatchRequest","createInitialPromiseWithTimeout","Promise","resolve","setTimeout","copiedEdits","postEdits","ontologyRid","transactionRid","edits","preview"],"sources":["EditRequestManager.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 {\n OntologyTransactions,\n type TransactionEdit,\n} from \"@osdk/foundry.ontologies\";\nimport type { WriteableClient } from \"./WriteableClient.js\";\nimport { writeableClientContext } from \"./WriteableClient.js\";\n\nexport class EditRequestManager {\n private pendingEdits: TransactionEdit[] = [];\n private inFlightRequest: Promise<void> | null = null;\n private queuedRequest: Promise<void> | null = null;\n private editTimeout: NodeJS.Timeout | null = null;\n private client: WriteableClient<any>;\n\n public constructor(client: WriteableClient<any>) {\n this.client = client;\n }\n\n public postEdit(edit: TransactionEdit): Promise<void> {\n if (this.inFlightRequest) {\n if (this.editTimeout) { // 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) { // 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(\n edit,\n );\n return this.inFlightRequest;\n }\n }\n\n private createInitialPromiseWithTimeout(\n edit: TransactionEdit,\n ): Promise<void> {\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) { // 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\n private async dispatchRequest(): Promise<void> {\n const copiedEdits = this.pendingEdits;\n this.pendingEdits = [];\n await OntologyTransactions.postEdits(\n this.client,\n await this.client[writeableClientContext].ontologyRid,\n this.client[writeableClientContext].transactionRid,\n { edits: copiedEdits },\n { preview: true },\n );\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,oBAAoB,QAEf,0BAA0B;AAEjC,SAASC,sBAAsB,QAAQ,sBAAsB;AAE7D,OAAO,MAAMC,kBAAkB,CAAC;EACtBC,YAAY,GAAsB,EAAE;EACpCC,eAAe,GAAyB,IAAI;EAC5CC,aAAa,GAAyB,IAAI;EAC1CC,WAAW,GAA0B,IAAI;EAG1CC,WAAWA,CAACC,MAA4B,EAAE;IAC/C,IAAI,CAACA,MAAM,GAAGA,MAAM;EACtB;EAEOC,QAAQA,CAACC,IAAqB,EAAiB;IACpD,IAAI,IAAI,CAACN,eAAe,EAAE;MACxB,IAAI,IAAI,CAACE,WAAW,EAAE;QAAE;QACtB,IAAI,CAACH,YAAY,CAACQ,IAAI,CAACD,IAAI,CAAC;QAC5B,OAAO,IAAI,CAACN,eAAe;MAC7B;MACA,IAAI,IAAI,CAACC,aAAa,EAAE;QAAE;QACxB,IAAI,CAACF,YAAY,CAACQ,IAAI,CAACD,IAAI,CAAC;QAC5B,OAAO,IAAI,CAACL,aAAa;MAC3B;MACA;MACA,IAAI,CAACA,aAAa,GAAG,IAAI,CAACD,eAAe,CAACQ,IAAI,CAAC,YAAY;QACzD,IAAI,CAACR,eAAe,GAAG,IAAI,CAACC,aAAa;QACzC,IAAI,CAACA,aAAa,GAAG,IAAI;QACzB,IAAI,CAACF,YAAY,CAACQ,IAAI,CAACD,IAAI,CAAC;QAC5B,MAAM,IAAI,CAACG,eAAe,CAAC,CAAC;MAC9B,CAAC,CAAC;MACF,OAAO,IAAI,CAACR,aAAa;IAC3B,CAAC,MAAM;MACL;MACA,IAAI,CAACD,eAAe,GAAG,IAAI,CAACU,+BAA+B,CACzDJ,IACF,CAAC;MACD,OAAO,IAAI,CAACN,eAAe;IAC7B;EACF;EAEQU,+BAA+BA,CACrCJ,IAAqB,EACN;IACf,OAAO,IAAIK,OAAO,CAAEC,OAAO,IAAK;MAC9B,IAAI,CAACb,YAAY,CAACQ,IAAI,CAACD,IAAI,CAAC;MAC5B,IAAI,CAACJ,WAAW,GAAGW,UAAU,CAAC,YAAY;QACxC,IAAI,CAACX,WAAW,GAAG,IAAI;QACvB,MAAM,IAAI,CAACO,eAAe,CAAC,CAAC;QAC5B,IAAI,CAAC,IAAI,CAACR,aAAa,EAAE;UAAE;UACzB,IAAI,CAACD,eAAe,GAAG,IAAI;QAC7B;QACAY,OAAO,CAAC,CAAC;MACX,CAAC,EAAE,CAAC,CAAC;IACP,CAAC,CAAC;EACJ;EAEA,MAAcH,eAAeA,CAAA,EAAkB;IAC7C,MAAMK,WAAW,GAAG,IAAI,CAACf,YAAY;IACrC,IAAI,CAACA,YAAY,GAAG,EAAE;IACtB,MAAMH,oBAAoB,CAACmB,SAAS,CAClC,IAAI,CAACX,MAAM,EACX,MAAM,IAAI,CAACA,MAAM,CAACP,sBAAsB,CAAC,CAACmB,WAAW,EACrD,IAAI,CAACZ,MAAM,CAACP,sBAAsB,CAAC,CAACoB,cAAc,EAClD;MAAEC,KAAK,EAAEJ;IAAY,CAAC,EACtB;MAAEK,OAAO,EAAE;IAAK,CAClB,CAAC;EACH;AACF","ignoreList":[]}
1
+ {"version":3,"file":"EditRequestManager.js","names":["OntologyTransactions","writeableClientContext","EditRequestManager","pendingEdits","inFlightRequest","queuedRequest","editTimeout","constructor","client","postEdit","edit","push","then","dispatchRequest","createInitialPromiseWithTimeout","Promise","resolve","setTimeout","copiedEdits","postEdits","ontologyRid","transactionId","edits","preview","flushPendingEdits","clearTimeout","length"],"sources":["EditRequestManager.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 {\n OntologyTransactions,\n type TransactionEdit,\n} from \"@osdk/foundry.ontologies\";\nimport type { WriteableClient } from \"./WriteableClient.js\";\nimport { writeableClientContext } from \"./WriteableClient.js\";\n\nexport class EditRequestManager {\n private pendingEdits: TransactionEdit[] = [];\n private inFlightRequest: Promise<void> | null = null;\n private queuedRequest: Promise<void> | null = null;\n private editTimeout: NodeJS.Timeout | null = null;\n private client: WriteableClient<any>;\n\n public constructor(client: WriteableClient<any>) {\n this.client = client;\n }\n\n public postEdit(edit: TransactionEdit): Promise<void> {\n if (this.inFlightRequest) {\n if (this.editTimeout) { // 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) { // 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(\n edit,\n );\n return this.inFlightRequest;\n }\n }\n\n private createInitialPromiseWithTimeout(\n edit: TransactionEdit,\n ): Promise<void> {\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) { // 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\n private async dispatchRequest(): Promise<void> {\n const copiedEdits = this.pendingEdits;\n this.pendingEdits = [];\n await OntologyTransactions.postEdits(\n this.client,\n await this.client[writeableClientContext].ontologyRid,\n this.client[writeableClientContext].transactionId,\n { edits: copiedEdits },\n { preview: true },\n );\n }\n\n public async flushPendingEdits(): Promise<void> {\n if (this.editTimeout) {\n clearTimeout(this.editTimeout);\n this.editTimeout = null;\n\n if (this.pendingEdits.length > 0) {\n await this.dispatchRequest();\n this.inFlightRequest = null;\n }\n }\n\n if (this.inFlightRequest) {\n await this.inFlightRequest;\n }\n\n if (this.queuedRequest) {\n await this.queuedRequest;\n }\n\n if (this.pendingEdits.length > 0) {\n await this.dispatchRequest();\n }\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,oBAAoB,QAEf,0BAA0B;AAEjC,SAASC,sBAAsB,QAAQ,sBAAsB;AAE7D,OAAO,MAAMC,kBAAkB,CAAC;EACtBC,YAAY,GAAsB,EAAE;EACpCC,eAAe,GAAyB,IAAI;EAC5CC,aAAa,GAAyB,IAAI;EAC1CC,WAAW,GAA0B,IAAI;EAG1CC,WAAWA,CAACC,MAA4B,EAAE;IAC/C,IAAI,CAACA,MAAM,GAAGA,MAAM;EACtB;EAEOC,QAAQA,CAACC,IAAqB,EAAiB;IACpD,IAAI,IAAI,CAACN,eAAe,EAAE;MACxB,IAAI,IAAI,CAACE,WAAW,EAAE;QAAE;QACtB,IAAI,CAACH,YAAY,CAACQ,IAAI,CAACD,IAAI,CAAC;QAC5B,OAAO,IAAI,CAACN,eAAe;MAC7B;MACA,IAAI,IAAI,CAACC,aAAa,EAAE;QAAE;QACxB,IAAI,CAACF,YAAY,CAACQ,IAAI,CAACD,IAAI,CAAC;QAC5B,OAAO,IAAI,CAACL,aAAa;MAC3B;MACA;MACA,IAAI,CAACA,aAAa,GAAG,IAAI,CAACD,eAAe,CAACQ,IAAI,CAAC,YAAY;QAC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AI,CAAClB,WAAW,EAAE;MACpBmB,YAAY,CAAC,IAAI,CAACnB,WAAW,CAAC;MAC9B,IAAI,CAACA,WAAW,GAAG,IAAI;MAEvB,IAAI,IAAI,CAACH,YAAY,CAACuB,MAAM,GAAG,CAAC,EAAE;QAChC,MAAM,IAAI,CAACb,eAAe,CAAC,CAAC;QAC5B,IAAI,CAACT,eAAe,GAAG,IAAI;MAC7B;IACF;IAEA,IAAI,IAAI,CAACA,eAAe,EAAE;MACxB,MAAM,IAAI,CAACA,eAAe;IAC5B;IAEA,IAAI,IAAI,CAACC,aAAa,EAAE;MACtB,MAAM,IAAI,CAACA,aAAa;IAC1B;IAEA,IAAI,IAAI,CAACF,YAAY,CAACuB,MAAM,GAAG,CAAC,EAAE;MAChC,MAAM,IAAI,CAACb,eAAe,CAAC,CAAC;IAC9B;EACF;AACF","ignoreList":[]}
@@ -177,5 +177,135 @@ describe("EditRequestManager", () => {
177
177
  }
178
178
  `);
179
179
  });
180
+ describe("flushPendingEdits", () => {
181
+ it("immediately dispatches pending edits without timeout", async () => {
182
+ void editRequestManager.postEdit(addLinkEdit);
183
+ void editRequestManager.postEdit(addObjectEdit);
184
+ expect(mockedRequestHandler).toHaveBeenCalledTimes(0);
185
+ await editRequestManager.flushPendingEdits();
186
+ expect(mockedRequestHandler).toHaveBeenCalledTimes(1);
187
+ expect(await mockedRequestHandler.mock.calls[0][0].request.json()).toMatchInlineSnapshot(`
188
+ {
189
+ "edits": [
190
+ {
191
+ "linkType": "test-link-type",
192
+ "linkedObjectPrimaryKey": "test-linked-object-primary-key",
193
+ "objectType": "test-object-type",
194
+ "primaryKey": "test-primary-key",
195
+ "type": "addLink",
196
+ },
197
+ {
198
+ "objectType": "test-object-type",
199
+ "properties": {},
200
+ "type": "addObject",
201
+ },
202
+ ],
203
+ }
204
+ `);
205
+ });
206
+ it("waits for in-flight and queued requests to complete", async () => {
207
+ maybeDeferServer = pDefer();
208
+ const firstEdit = editRequestManager.postEdit(addLinkEdit);
209
+ await new Promise(resolve => setTimeout(resolve, 0));
210
+ const secondEdit = editRequestManager.postEdit(addObjectEdit);
211
+ const flushPromise = editRequestManager.flushPendingEdits();
212
+ expect(mockedRequestHandler).toHaveBeenCalledTimes(1);
213
+ maybeDeferServer.resolve();
214
+ await Promise.all([firstEdit, secondEdit, flushPromise]);
215
+ expect(mockedRequestHandler).toHaveBeenCalledTimes(2);
216
+ expect(await mockedRequestHandler.mock.calls[0][0].request.json()).toMatchInlineSnapshot(`
217
+ {
218
+ "edits": [
219
+ {
220
+ "linkType": "test-link-type",
221
+ "linkedObjectPrimaryKey": "test-linked-object-primary-key",
222
+ "objectType": "test-object-type",
223
+ "primaryKey": "test-primary-key",
224
+ "type": "addLink",
225
+ },
226
+ ],
227
+ }
228
+ `);
229
+ expect(await mockedRequestHandler.mock.calls[1][0].request.json()).toMatchInlineSnapshot(`
230
+ {
231
+ "edits": [
232
+ {
233
+ "objectType": "test-object-type",
234
+ "properties": {},
235
+ "type": "addObject",
236
+ },
237
+ ],
238
+ }
239
+ `);
240
+ });
241
+ it("does nothing when there are no pending edits", async () => {
242
+ await editRequestManager.flushPendingEdits();
243
+ expect(mockedRequestHandler).not.toHaveBeenCalled();
244
+ });
245
+ it("cancels timeout and immediately dispatches edits", async () => {
246
+ const clearTimeoutSpy = vi.spyOn(global, "clearTimeout");
247
+ void editRequestManager.postEdit(addLinkEdit);
248
+ await editRequestManager.flushPendingEdits();
249
+ expect(clearTimeoutSpy).toHaveBeenCalled();
250
+ expect(mockedRequestHandler).toHaveBeenCalledTimes(1);
251
+ expect(await mockedRequestHandler.mock.calls[0][0].request.json()).toMatchInlineSnapshot(`
252
+ {
253
+ "edits": [
254
+ {
255
+ "linkType": "test-link-type",
256
+ "linkedObjectPrimaryKey": "test-linked-object-primary-key",
257
+ "objectType": "test-object-type",
258
+ "primaryKey": "test-primary-key",
259
+ "type": "addLink",
260
+ },
261
+ ],
262
+ }
263
+ `);
264
+ clearTimeoutSpy.mockRestore();
265
+ });
266
+ it("ensures all requests complete when multiple edits are queued", async () => {
267
+ maybeDeferServer = pDefer();
268
+ const firstEdit = editRequestManager.postEdit(addLinkEdit);
269
+ await new Promise(resolve => setTimeout(resolve, 0));
270
+ const secondEdit = editRequestManager.postEdit(addObjectEdit);
271
+ await new Promise(resolve => setTimeout(resolve, 0));
272
+ const thirdEdit = editRequestManager.postEdit(addLinkEdit);
273
+ const flushPromise = editRequestManager.flushPendingEdits();
274
+ maybeDeferServer.resolve();
275
+ await Promise.all([firstEdit, secondEdit, thirdEdit, flushPromise]);
276
+ expect(mockedRequestHandler).toHaveBeenCalledTimes(2);
277
+ expect(await mockedRequestHandler.mock.calls[0][0].request.json()).toMatchInlineSnapshot(`
278
+ {
279
+ "edits": [
280
+ {
281
+ "linkType": "test-link-type",
282
+ "linkedObjectPrimaryKey": "test-linked-object-primary-key",
283
+ "objectType": "test-object-type",
284
+ "primaryKey": "test-primary-key",
285
+ "type": "addLink",
286
+ },
287
+ ],
288
+ }
289
+ `);
290
+ expect(await mockedRequestHandler.mock.calls[1][0].request.json()).toMatchInlineSnapshot(`
291
+ {
292
+ "edits": [
293
+ {
294
+ "linkType": "test-link-type",
295
+ "linkedObjectPrimaryKey": "test-linked-object-primary-key",
296
+ "objectType": "test-object-type",
297
+ "primaryKey": "test-primary-key",
298
+ "type": "addLink",
299
+ },
300
+ {
301
+ "objectType": "test-object-type",
302
+ "properties": {},
303
+ "type": "addObject",
304
+ },
305
+ ],
306
+ }
307
+ `);
308
+ });
309
+ });
180
310
  });
181
311
  //# sourceMappingURL=EditRequestManager.test.js.map
@@ -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 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,OAAO,EACPE,oBACF,CACF,CAAC;IAED,OAAO,MAAM;MACXH,SAAS,CAACe,KAAK,CAAC,CAAC;IACnB,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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":[]}
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","flushPendingEdits","firstEdit","secondEdit","flushPromise","all","not","toHaveBeenCalled","clearTimeoutSpy","spyOn","global","mockRestore","thirdEdit"],"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 describe(\"flushPendingEdits\", () => {\n it(\"immediately dispatches pending edits without timeout\", async () => {\n void editRequestManager.postEdit(addLinkEdit);\n void editRequestManager.postEdit(addObjectEdit);\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(0);\n\n await editRequestManager.flushPendingEdits();\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(1);\n expect(await mockedRequestHandler.mock.calls[0][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 \"objectType\": \"test-object-type\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n ],\n }\n `);\n });\n\n it(\"waits for in-flight and queued requests to complete\", async () => {\n maybeDeferServer = pDefer();\n const firstEdit = editRequestManager.postEdit(addLinkEdit);\n await new Promise(resolve => setTimeout(resolve, 0));\n\n const secondEdit = editRequestManager.postEdit(addObjectEdit);\n\n const flushPromise = editRequestManager.flushPendingEdits();\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(1);\n\n maybeDeferServer.resolve();\n await Promise.all([firstEdit, secondEdit, flushPromise]);\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(2);\n expect(await mockedRequestHandler.mock.calls[0][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 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 }\n `);\n });\n\n it(\"does nothing when there are no pending edits\", async () => {\n await editRequestManager.flushPendingEdits();\n\n expect(mockedRequestHandler).not.toHaveBeenCalled();\n });\n\n it(\"cancels timeout and immediately dispatches edits\", async () => {\n const clearTimeoutSpy = vi.spyOn(global, \"clearTimeout\");\n\n void editRequestManager.postEdit(addLinkEdit);\n\n await editRequestManager.flushPendingEdits();\n\n expect(clearTimeoutSpy).toHaveBeenCalled();\n expect(mockedRequestHandler).toHaveBeenCalledTimes(1);\n expect(await mockedRequestHandler.mock.calls[0][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 clearTimeoutSpy.mockRestore();\n });\n\n it(\"ensures all requests complete when multiple edits are queued\", async () => {\n maybeDeferServer = pDefer();\n const firstEdit = editRequestManager.postEdit(addLinkEdit);\n await new Promise(resolve => setTimeout(resolve, 0));\n\n const secondEdit = editRequestManager.postEdit(addObjectEdit);\n await new Promise(resolve => setTimeout(resolve, 0));\n\n const thirdEdit = editRequestManager.postEdit(addLinkEdit);\n\n const flushPromise = editRequestManager.flushPendingEdits();\n\n maybeDeferServer.resolve();\n await Promise.all([firstEdit, secondEdit, thirdEdit, flushPromise]);\n\n expect(mockedRequestHandler).toHaveBeenCalledTimes(2);\n expect(await mockedRequestHandler.mock.calls[0][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 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 \"objectType\": \"test-object-type\",\n \"properties\": {},\n \"type\": \"addObject\",\n },\n ],\n }\n `);\n });\n });\n});\n"],"m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MsB,YAAY,GAAGnC,kBAAkB,CAACgC,iBAAiB,CAAC,CAAC;MAE3DlC,gBAAgB,CAAC+B,OAAO,CAAC,CAAC;MAC1B,MAAMD,OAAO,CAACQ,GAAG,CAAC,CAACH,SAAS,EAAEC,UAAU,EAAES,SAAS,EAAER,YAAY,CAAC,CAAC;MAEnE7C,MAAM,CAACS,oBAAoB,CAAC,CAACuB,qBAAqB,CAAC,CAAC,CAAC;MACrDhC,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;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,CAAC;MACJrC,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;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,CAAC;IACN,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"WriteableClient.js","names":["writeableClientContext","Symbol"],"sources":["WriteableClient.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 { Client } from \"@osdk/client\";\n\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\";\n\n/** @internal */\nexport const writeableClientContext: unique symbol = Symbol(\n \"writeableClientContext\",\n);\n\nexport interface WriteableClientContext {\n ontologyRid: string | Promise<string>;\n transactionRid: string;\n}\n\nexport interface WriteableClient<X extends AnyEdit>\n extends Client, WriteMethods<X>\n{\n [writeableClientContext]: WriteableClientContext;\n}\n\nexport interface WriteMethods<X extends AnyEdit> {\n link: <\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\n unlink: <\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\n create: <OTD extends CreatableObjectOrInterfaceTypes<X>>(\n obj: OTD,\n properties: CreatableObjectOrInterfaceTypeProperties<X, OTD>,\n ) => Promise<void>;\n\n delete: <OL extends DeletableObjectOrInterfaceLocators<X>>(\n obj: OL,\n ) => Promise<void>;\n\n update: <OL extends UpdatableObjectOrInterfaceLocators<X>>(\n obj: OL,\n properties: UpdatableObjectOrInterfaceLocatorProperties<X, OL>,\n ) => Promise<void>;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA;AACA,OAAO,MAAMA,sBAAqC,GAAGC,MAAM,CACzD,wBACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"WriteableClient.js","names":["writeableClientContext","Symbol"],"sources":["WriteableClient.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 { Client } from \"@osdk/client\";\n\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 type { EditRequestManager } from \"./EditRequestManager.js\";\n\n/** @internal */\nexport const writeableClientContext: unique symbol = Symbol(\n \"writeableClientContext\",\n);\n\nexport interface WriteableClientContext {\n ontologyRid: string | Promise<string>;\n transactionId: string;\n editRequestManager: EditRequestManager;\n}\n\nexport interface WriteableClient<X extends AnyEdit>\n extends Client, WriteMethods<X>\n{\n [writeableClientContext]: WriteableClientContext;\n}\n\nexport interface WriteMethods<X extends AnyEdit> {\n link: <\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\n unlink: <\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\n create: <OTD extends CreatableObjectOrInterfaceTypes<X>>(\n obj: OTD,\n properties: CreatableObjectOrInterfaceTypeProperties<X, OTD>,\n ) => Promise<void>;\n\n delete: <OL extends DeletableObjectOrInterfaceLocators<X>>(\n obj: OL,\n ) => Promise<void>;\n\n update: <OL extends UpdatableObjectOrInterfaceLocators<X>>(\n obj: OL,\n properties: UpdatableObjectOrInterfaceLocatorProperties<X, OL>,\n ) => Promise<void>;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoBA;AACA,OAAO,MAAMA,sBAAqC,GAAGC,MAAM,CACzD,wBACF,CAAC","ignoreList":[]}
@@ -18,10 +18,9 @@ import { createClientWithTransaction } from "@osdk/client/unstable-do-not-use";
18
18
  import { EditRequestManager } from "./EditRequestManager.js";
19
19
  import { toPropertyDataValue } from "./toPropertyDataValue.js";
20
20
  import { writeableClientContext } from "./WriteableClient.js";
21
- export function createWriteableClient(...args) {
22
- const transactionRid = args[0];
23
- const ontologyRid = args[2];
24
- const client = createClientWithTransaction(...args);
21
+ export function createWriteableClient(transactionId, ...args) {
22
+ const ontologyRid = args[1];
23
+ const client = createClientWithTransaction(transactionId, async () => {}, ...args);
25
24
  const editRequestManager = new EditRequestManager(client) // This cast is safe because we create the writeable client properties below.
26
25
  ;
27
26
 
@@ -114,7 +113,8 @@ export function createWriteableClient(...args) {
114
113
  [writeableClientContext]: {
115
114
  value: {
116
115
  ontologyRid,
117
- transactionRid
116
+ transactionId,
117
+ editRequestManager
118
118
  }
119
119
  }
120
120
  });