@osdk/functions 1.4.0-rc.11 → 1.4.1
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 +47 -0
- package/build/browser/public/experimental.js +2 -0
- package/build/browser/public/experimental.js.map +1 -0
- package/build/browser/public/unstable-do-not-use.js +1 -0
- package/build/browser/public/unstable-do-not-use.js.map +1 -1
- package/build/browser/transactions/EditRequestManager.js +20 -1
- package/build/browser/transactions/EditRequestManager.js.map +1 -1
- package/build/browser/transactions/EditRequestManager.test.js +130 -0
- package/build/browser/transactions/EditRequestManager.test.js.map +1 -1
- package/build/browser/transactions/WriteableClient.js.map +1 -1
- package/build/browser/transactions/createWriteableClient.js +5 -5
- package/build/browser/transactions/createWriteableClient.js.map +1 -1
- package/build/browser/transactions/flushEdits.js +21 -0
- package/build/browser/transactions/flushEdits.js.map +1 -0
- package/build/cjs/index.cjs +1 -1
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/public/experimental.cjs +4 -0
- package/build/cjs/public/experimental.cjs.map +1 -0
- package/build/cjs/public/experimental.d.cts +35 -0
- package/build/cjs/public/unstable-do-not-use.cjs +34 -7
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +7 -19
- package/build/esm/public/experimental.js +2 -0
- package/build/esm/public/experimental.js.map +1 -0
- package/build/esm/public/unstable-do-not-use.js +1 -0
- package/build/esm/public/unstable-do-not-use.js.map +1 -1
- package/build/esm/transactions/EditRequestManager.js +20 -1
- package/build/esm/transactions/EditRequestManager.js.map +1 -1
- package/build/esm/transactions/EditRequestManager.test.js +130 -0
- package/build/esm/transactions/EditRequestManager.test.js.map +1 -1
- package/build/esm/transactions/WriteableClient.js.map +1 -1
- package/build/esm/transactions/createWriteableClient.js +5 -5
- package/build/esm/transactions/createWriteableClient.js.map +1 -1
- package/build/esm/transactions/flushEdits.js +21 -0
- package/build/esm/transactions/flushEdits.js.map +1 -0
- package/build/types/public/experimental.d.ts +1 -0
- package/build/types/public/experimental.d.ts.map +1 -0
- package/build/types/public/unstable-do-not-use.d.ts +1 -0
- package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
- package/build/types/transactions/EditRequestManager.d.ts +1 -0
- package/build/types/transactions/EditRequestManager.d.ts.map +1 -1
- package/build/types/transactions/WriteableClient.d.ts +3 -1
- package/build/types/transactions/WriteableClient.d.ts.map +1 -1
- package/build/types/transactions/createWriteableClient.d.ts +2 -2
- package/build/types/transactions/createWriteableClient.d.ts.map +1 -1
- package/build/types/transactions/flushEdits.d.ts +2 -0
- package/build/types/transactions/flushEdits.d.ts.map +1 -0
- package/experimental.d.ts +17 -0
- package/package.json +18 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# @osdk/functions
|
|
2
2
|
|
|
3
|
+
## 1.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 931dff7: Add ability to flush edits to transactions
|
|
8
|
+
- 931dff7: Add Transaction ID to Queries
|
|
9
|
+
- Updated dependencies [931dff7]
|
|
10
|
+
- Updated dependencies [931dff7]
|
|
11
|
+
- @osdk/client@2.6.1
|
|
12
|
+
|
|
13
|
+
## 1.4.0
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 776ae8a: Simulated release
|
|
18
|
+
- b313525: bump osdk
|
|
19
|
+
- 3fbb596: Pipe through transactionId to endpoints that load data via object sets
|
|
20
|
+
- 7f9f123: Add foundry hostname util
|
|
21
|
+
- 3d7dc0a: introduce new token field, note readToken as deprecated
|
|
22
|
+
- f318daf: Use correct API gateway service name
|
|
23
|
+
- b307201: Add edits support for media reference.
|
|
24
|
+
- a2e9c62: Fix upload function.
|
|
25
|
+
- a1ffb20: Use new ephemeral media upload endpoint.
|
|
26
|
+
- af4f3bf: Remove the following features for RC:
|
|
27
|
+
- Property formatting
|
|
28
|
+
- Branching
|
|
29
|
+
- Constant RDPs
|
|
30
|
+
|
|
31
|
+
- Updated dependencies [322c5bc]
|
|
32
|
+
- Updated dependencies [b48526f]
|
|
33
|
+
- Updated dependencies [b313525]
|
|
34
|
+
- Updated dependencies [3fbb596]
|
|
35
|
+
- Updated dependencies [f7ae38a]
|
|
36
|
+
- Updated dependencies [486ef7e]
|
|
37
|
+
- Updated dependencies [ea077c6]
|
|
38
|
+
- Updated dependencies [507ec7f]
|
|
39
|
+
- Updated dependencies [c5a3815]
|
|
40
|
+
- Updated dependencies [5a9cd8f]
|
|
41
|
+
- Updated dependencies [61eb5b0]
|
|
42
|
+
- Updated dependencies [9961f06]
|
|
43
|
+
- Updated dependencies [e7bf02a]
|
|
44
|
+
- Updated dependencies [a1ffb20]
|
|
45
|
+
- Updated dependencies [b959085]
|
|
46
|
+
- Updated dependencies [af4f3bf]
|
|
47
|
+
- Updated dependencies [e62c692]
|
|
48
|
+
- @osdk/client@2.6.0
|
|
49
|
+
|
|
3
50
|
## 1.4.0-rc.11
|
|
4
51
|
|
|
5
52
|
### Patch Changes
|
|
@@ -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;
|
|
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].
|
|
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","
|
|
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;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|
});
|
|
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,oBAA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ACA,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,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"],"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,EA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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
|
|
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
|
|
23
|
-
const
|
|
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
|
-
|
|
116
|
+
transactionId,
|
|
117
|
+
editRequestManager
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
});
|
|
@@ -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 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,MAAM,CAACQ;UACjC,CAAC,CAAC;QACJ;QACA,MAAMG,QAAyB,GA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BW,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","transactionId","args","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, createClient } 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 transactionId: string,\n ...args: Parameters<typeof createClient>\n): WriteableClient<X> {\n const ontologyRid = args[1];\n\n const client = createClientWithTransaction(\n transactionId,\n async () => {},\n ...args,\n ) as Client;\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 transactionId,\n editRequestManager,\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,CAGnCC,aAAqB,EACrB,GAAGC,IAAqC,EACpB;EACpB,MAAMC,WAAW,GAAGD,I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,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;QACXF,aAAa;QACbI;MACF;IACF;EACF,CAIF,CAAuB;EAEvB,OAAOC,eAAe;AACxB","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { writeableClientContext } from "./WriteableClient.js";
|
|
18
|
+
export async function flushEdits(client) {
|
|
19
|
+
await client[writeableClientContext].editRequestManager.flushPendingEdits();
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=flushEdits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flushEdits.js","names":["writeableClientContext","flushEdits","client","editRequestManager","flushPendingEdits"],"sources":["flushEdits.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\nimport {\n type WriteableClient,\n writeableClientContext,\n} from \"./WriteableClient.js\";\n\nexport async function flushEdits(client: WriteableClient<any>): Promise<void> {\n await client[writeableClientContext].editRequestManager.flushPendingEdits();\n return;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAEEA,sBAAsB,QACjB,sBAAsB;AAE7B,OAAO,eAAeC,UAAUA,CAACC,MAA4B,EAAiB;EAC5E,MAAMA,MAAM,CAACF,sBAAsB,CAAC,CAACG,kBAAkB,CAACC,iBAAiB,CAAC,CAAC;AAE7E","ignoreList":[]}
|
package/build/cjs/index.cjs
CHANGED
|
@@ -106,7 +106,7 @@ var UserFacingError = class extends Error {
|
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
// ../../node_modules/.pnpm/@osdk+foundry.mediasets@2.
|
|
109
|
+
// ../../node_modules/.pnpm/@osdk+foundry.mediasets@2.44.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,
|
package/build/cjs/index.cjs.map
CHANGED
|
@@ -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.42.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,M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AW,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,KAAA,EAAO,eAAgB,CAAA,SAAA,CAAU,gBAAiB,CAAA,KAAA;AAAA,QAClD,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 * @beta\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 token: gatewayMediaRef.reference.mediaSetViewItem.token,\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.44.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,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AAA,CAAY,SAAS,IAAM,EAAA;AACzC,EAAA,OAAOA,sCAAsB,CAAA,IAAA,EAAM,YAAc,EAAA,GAAG,IAAI,CAAA;AAC1D;;;ACxJA,eAAsBC,YAAAA,CAAY,QAAQ,WAAa,EAAA;AACrD,EAAA,MAAM,kBAAkB,MAAM,gBAAA,CAAU,WAAY,CAAA,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,KAAA,EAAO,eAAgB,CAAA,SAAA,CAAU,gBAAiB,CAAA,KAAA;AAAA,QAClD,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 * @beta\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 token: gatewayMediaRef.reference.mediaSetViewItem.token,\n readToken: gatewayMediaRef.reference.mediaSetViewItem.token\n }\n }\n };\n}"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"experimental.cjs"}
|