@osdk/functions 1.5.0 → 1.5.2

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 (59) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/build/browser/aliases/aliases.test.js +191 -0
  3. package/build/browser/aliases/aliases.test.js.map +1 -0
  4. package/build/browser/aliases/custom.js +26 -0
  5. package/build/browser/aliases/custom.js.map +1 -0
  6. package/build/browser/aliases/environment.js +48 -0
  7. package/build/browser/aliases/environment.js.map +1 -0
  8. package/build/browser/aliases/index.js +19 -0
  9. package/build/browser/aliases/index.js.map +1 -0
  10. package/build/browser/aliases/loaders.js +66 -0
  11. package/build/browser/aliases/loaders.js.map +1 -0
  12. package/build/browser/aliases/model.js +26 -0
  13. package/build/browser/aliases/model.js.map +1 -0
  14. package/build/browser/aliases/types.js +30 -0
  15. package/build/browser/aliases/types.js.map +1 -0
  16. package/build/browser/index.js +1 -0
  17. package/build/browser/index.js.map +1 -1
  18. package/build/browser/transactions/createWriteableClient.js +2 -0
  19. package/build/browser/transactions/createWriteableClient.js.map +1 -1
  20. package/build/cjs/index.cjs +133 -0
  21. package/build/cjs/index.cjs.map +1 -1
  22. package/build/cjs/index.d.cts +20 -1
  23. package/build/cjs/public/unstable-do-not-use.cjs +2 -0
  24. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
  25. package/build/esm/aliases/aliases.test.js +191 -0
  26. package/build/esm/aliases/aliases.test.js.map +1 -0
  27. package/build/esm/aliases/custom.js +26 -0
  28. package/build/esm/aliases/custom.js.map +1 -0
  29. package/build/esm/aliases/environment.js +48 -0
  30. package/build/esm/aliases/environment.js.map +1 -0
  31. package/build/esm/aliases/index.js +19 -0
  32. package/build/esm/aliases/index.js.map +1 -0
  33. package/build/esm/aliases/loaders.js +66 -0
  34. package/build/esm/aliases/loaders.js.map +1 -0
  35. package/build/esm/aliases/model.js +26 -0
  36. package/build/esm/aliases/model.js.map +1 -0
  37. package/build/esm/aliases/types.js +30 -0
  38. package/build/esm/aliases/types.js.map +1 -0
  39. package/build/esm/index.js +1 -0
  40. package/build/esm/index.js.map +1 -1
  41. package/build/esm/transactions/createWriteableClient.js +2 -0
  42. package/build/esm/transactions/createWriteableClient.js.map +1 -1
  43. package/build/types/aliases/aliases.test.d.ts +1 -0
  44. package/build/types/aliases/aliases.test.d.ts.map +1 -0
  45. package/build/types/aliases/custom.d.ts +3 -0
  46. package/build/types/aliases/custom.d.ts.map +1 -0
  47. package/build/types/aliases/environment.d.ts +6 -0
  48. package/build/types/aliases/environment.d.ts.map +1 -0
  49. package/build/types/aliases/index.d.ts +2 -0
  50. package/build/types/aliases/index.d.ts.map +1 -0
  51. package/build/types/aliases/loaders.d.ts +3 -0
  52. package/build/types/aliases/loaders.d.ts.map +1 -0
  53. package/build/types/aliases/model.d.ts +3 -0
  54. package/build/types/aliases/model.d.ts.map +1 -0
  55. package/build/types/aliases/types.d.ts +40 -0
  56. package/build/types/aliases/types.d.ts.map +1 -0
  57. package/build/types/index.d.ts +1 -0
  58. package/build/types/index.d.ts.map +1 -1
  59. package/package.json +5 -5
@@ -1,6 +1,138 @@
1
1
  'use strict';
2
2
 
3
3
  var chunk4DCWE2WY_cjs = require('./chunk-4DCWE2WY.cjs');
4
+ var fs = require('fs');
5
+
6
+ function _interopNamespace(e) {
7
+ if (e && e.__esModule) return e;
8
+ var n = Object.create(null);
9
+ if (e) {
10
+ Object.keys(e).forEach(function (k) {
11
+ if (k !== 'default') {
12
+ var d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: function () { return e[k]; }
16
+ });
17
+ }
18
+ });
19
+ }
20
+ n.default = e;
21
+ return Object.freeze(n);
22
+ }
23
+
24
+ var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
25
+
26
+ // src/aliases/index.ts
27
+ var aliases_exports = {};
28
+ chunk4DCWE2WY_cjs.__export(aliases_exports, {
29
+ custom: () => custom,
30
+ model: () => model
31
+ });
32
+
33
+ // src/aliases/types.ts
34
+ var AliasEnvironment = /* @__PURE__ */ (function(AliasEnvironment2) {
35
+ AliasEnvironment2["PUBLISHED"] = "PUBLISHED";
36
+ AliasEnvironment2["LIVE_PREVIEW"] = "LIVE_PREVIEW";
37
+ return AliasEnvironment2;
38
+ })({});
39
+
40
+ // src/aliases/environment.ts
41
+ var ALIASES_JSON_FILE_ENV_VAR = "ALIASES_JSON_FILE";
42
+ var RESOURCES_JSON_FILE_ENV_VAR = "RESOURCES_JSON_FILE";
43
+ function detectEnvironment() {
44
+ const aliasesFileSet = ALIASES_JSON_FILE_ENV_VAR in process.env;
45
+ const resourcesFileSet = RESOURCES_JSON_FILE_ENV_VAR in process.env;
46
+ if (aliasesFileSet && resourcesFileSet) {
47
+ throw new Error(`Ambiguous alias configuration: both ${ALIASES_JSON_FILE_ENV_VAR} and ${RESOURCES_JSON_FILE_ENV_VAR} are set. Only one should be configured.`);
48
+ }
49
+ if (aliasesFileSet) {
50
+ return AliasEnvironment.PUBLISHED;
51
+ }
52
+ if (resourcesFileSet) {
53
+ return AliasEnvironment.LIVE_PREVIEW;
54
+ }
55
+ throw new Error(`Unknown alias environment: neither ${ALIASES_JSON_FILE_ENV_VAR} nor ${RESOURCES_JSON_FILE_ENV_VAR} is set.`);
56
+ }
57
+ function getAliasesFilePath() {
58
+ const path = process.env[ALIASES_JSON_FILE_ENV_VAR];
59
+ if (path == null) {
60
+ throw new Error(`${ALIASES_JSON_FILE_ENV_VAR} environment variable is not set`);
61
+ }
62
+ return path;
63
+ }
64
+ function getResourcesFilePath() {
65
+ const path = process.env[RESOURCES_JSON_FILE_ENV_VAR];
66
+ if (path == null) {
67
+ throw new Error(`${RESOURCES_JSON_FILE_ENV_VAR} environment variable is not set`);
68
+ }
69
+ return path;
70
+ }
71
+
72
+ // src/aliases/loaders.ts
73
+ var cachedPublishedAliases;
74
+ function loadPublishedAliases() {
75
+ if (cachedPublishedAliases !== void 0) {
76
+ return cachedPublishedAliases;
77
+ }
78
+ const aliasesPath = getAliasesFilePath();
79
+ if (!fs__namespace.existsSync(aliasesPath)) {
80
+ throw new Error(`Aliases file not found at ${aliasesPath}`);
81
+ }
82
+ const data = fs__namespace.readFileSync(aliasesPath, "utf-8");
83
+ const aliasesFile = JSON.parse(data);
84
+ cachedPublishedAliases = {
85
+ custom: aliasesFile.defaults.custom,
86
+ models: Object.fromEntries(Object.entries(aliasesFile.defaults.models).map(([alias, {
87
+ id: identifier
88
+ }]) => [alias, identifier]))
89
+ };
90
+ return cachedPublishedAliases;
91
+ }
92
+ function loadPreviewAliases() {
93
+ const resourcesPath = getResourcesFilePath();
94
+ if (!fs__namespace.existsSync(resourcesPath)) {
95
+ throw new Error(`Resources file not found at ${resourcesPath}`);
96
+ }
97
+ const data = fs__namespace.readFileSync(resourcesPath, "utf-8");
98
+ const resourcesFile = JSON.parse(data);
99
+ return {
100
+ custom: resourcesFile.resources.custom,
101
+ models: Object.fromEntries(resourcesFile.resources.models.filter((model2) => model2.alias != null).map(({
102
+ alias,
103
+ identifier
104
+ }) => [alias, identifier]))
105
+ };
106
+ }
107
+ function loadResolvedAliases() {
108
+ const environment = detectEnvironment();
109
+ switch (environment) {
110
+ case AliasEnvironment.PUBLISHED:
111
+ return loadPublishedAliases();
112
+ case AliasEnvironment.LIVE_PREVIEW:
113
+ return loadPreviewAliases();
114
+ }
115
+ }
116
+
117
+ // src/aliases/custom.ts
118
+ function custom(alias) {
119
+ const resolvedAliases = loadResolvedAliases();
120
+ if (!(alias in resolvedAliases.custom)) {
121
+ const available = Object.keys(resolvedAliases.custom);
122
+ throw new Error(`Custom alias '${alias}' not found. Available aliases: [${available.join(", ")}]`);
123
+ }
124
+ return resolvedAliases.custom[alias];
125
+ }
126
+
127
+ // src/aliases/model.ts
128
+ function model(alias) {
129
+ const resolvedAliases = loadResolvedAliases();
130
+ if (!(alias in resolvedAliases.models)) {
131
+ const available = Object.keys(resolvedAliases.models);
132
+ throw new Error(`Model alias '${alias}' not found. Available aliases: [${available.join(", ")}]`);
133
+ }
134
+ return resolvedAliases.models[alias];
135
+ }
4
136
 
5
137
  // src/edits/types.ts
6
138
  function isInterfaceLocator(obj) {
@@ -192,6 +324,7 @@ async function uploadMedia2(client, mediaUpload) {
192
324
  };
193
325
  }
194
326
 
327
+ exports.Aliases = aliases_exports;
195
328
  exports.UserFacingError = UserFacingError;
196
329
  exports.createEditBatch = createEditBatch;
197
330
  exports.uploadMedia = uploadMedia2;
@@ -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.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,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,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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}"]}
1
+ {"version":3,"sources":["../../src/aliases/index.ts","../../src/aliases/types.ts","../../src/aliases/environment.ts","../../src/aliases/loaders.ts","../../src/aliases/custom.ts","../../src/aliases/model.ts","../../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","AliasEnvironment","fs","model","foundryPlatformFetch","uploadMedia"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,eAAA,GAAA;AAAAA,0BAAA,CAAA,eAAA,EAAA;AAAA,EAAA,MAAA,EAAA,MAAA,MAAA;AAAA,EAAA,KAAA,EAAA,MAAA;AAAA,CAAA,CAAA;;;ACoBO,IAAI,gBA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AA;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 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 * from \"./custom.js\";\nexport * from \"./model.js\";","/*\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\n// Types relevant to OSDK APIs\n\n// Environment\n\nexport let AliasEnvironment = /*#__PURE__*/function (AliasEnvironment) {\n AliasEnvironment[\"PUBLISHED\"] = \"PUBLISHED\";\n AliasEnvironment[\"LIVE_PREVIEW\"] = \"LIVE_PREVIEW\";\n return AliasEnvironment;\n}({});\n\n// Live preview mode types (resources.json)\n\n// Published mode types (aliases.json)","/*\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 { AliasEnvironment } from \"./types.js\";\nexport const ALIASES_JSON_FILE_ENV_VAR = \"ALIASES_JSON_FILE\";\nexport const RESOURCES_JSON_FILE_ENV_VAR = \"RESOURCES_JSON_FILE\";\nexport function detectEnvironment() {\n const aliasesFileSet = ALIASES_JSON_FILE_ENV_VAR in process.env;\n const resourcesFileSet = RESOURCES_JSON_FILE_ENV_VAR in process.env;\n if (aliasesFileSet && resourcesFileSet) {\n throw new Error(`Ambiguous alias configuration: both ${ALIASES_JSON_FILE_ENV_VAR} and ` + `${RESOURCES_JSON_FILE_ENV_VAR} are set. Only one should be configured.`);\n }\n if (aliasesFileSet) {\n return AliasEnvironment.PUBLISHED;\n }\n if (resourcesFileSet) {\n return AliasEnvironment.LIVE_PREVIEW;\n }\n throw new Error(`Unknown alias environment: neither ${ALIASES_JSON_FILE_ENV_VAR} nor ${RESOURCES_JSON_FILE_ENV_VAR} is set.`);\n}\nexport function getAliasesFilePath() {\n const path = process.env[ALIASES_JSON_FILE_ENV_VAR];\n if (path == null) {\n throw new Error(`${ALIASES_JSON_FILE_ENV_VAR} environment variable is not set`);\n }\n return path;\n}\nexport function getResourcesFilePath() {\n const path = process.env[RESOURCES_JSON_FILE_ENV_VAR];\n if (path == null) {\n throw new Error(`${RESOURCES_JSON_FILE_ENV_VAR} environment variable is not set`);\n }\n return path;\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 * as fs from \"fs\";\nimport { detectEnvironment, getAliasesFilePath, getResourcesFilePath } from \"./environment.js\";\nimport { AliasEnvironment } from \"./types.js\";\nlet cachedPublishedAliases;\nfunction loadPublishedAliases() {\n if (cachedPublishedAliases !== undefined) {\n return cachedPublishedAliases;\n }\n const aliasesPath = getAliasesFilePath();\n if (!fs.existsSync(aliasesPath)) {\n throw new Error(`Aliases file not found at ${aliasesPath}`);\n }\n const data = fs.readFileSync(aliasesPath, \"utf-8\");\n const aliasesFile = JSON.parse(data);\n cachedPublishedAliases = {\n custom: aliasesFile.defaults.custom,\n models: Object.fromEntries(Object.entries(aliasesFile.defaults.models).map(([alias, {\n id: identifier\n }]) => [alias, identifier]))\n };\n return cachedPublishedAliases;\n}\nfunction loadPreviewAliases() {\n const resourcesPath = getResourcesFilePath();\n if (!fs.existsSync(resourcesPath)) {\n throw new Error(`Resources file not found at ${resourcesPath}`);\n }\n const data = fs.readFileSync(resourcesPath, \"utf-8\");\n const resourcesFile = JSON.parse(data);\n return {\n custom: resourcesFile.resources.custom,\n models: Object.fromEntries(resourcesFile.resources.models.filter(model => model.alias != null).map(({\n alias,\n identifier\n }) => [alias, identifier]))\n };\n}\nexport function resetPublishedCache() {\n cachedPublishedAliases = undefined;\n}\nexport function loadResolvedAliases() {\n const environment = detectEnvironment();\n switch (environment) {\n case AliasEnvironment.PUBLISHED:\n return loadPublishedAliases();\n case AliasEnvironment.LIVE_PREVIEW:\n return loadPreviewAliases();\n }\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 { loadResolvedAliases } from \"./loaders.js\";\nexport function custom(alias) {\n const resolvedAliases = loadResolvedAliases();\n if (!(alias in resolvedAliases.custom)) {\n const available = Object.keys(resolvedAliases.custom);\n throw new Error(`Custom alias '${alias}' not found. Available aliases: [${available.join(\", \")}]`);\n }\n return resolvedAliases.custom[alias];\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 { loadResolvedAliases } from \"./loaders.js\";\nexport function model(alias) {\n const resolvedAliases = loadResolvedAliases();\n if (!(alias in resolvedAliases.models)) {\n const available = Object.keys(resolvedAliases.models);\n throw new Error(`Model alias '${alias}' not found. Available aliases: [${available.join(\", \")}]`);\n }\n return resolvedAliases.models[alias];\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 */\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}"]}
@@ -25,6 +25,25 @@ type TimestampISOString<T extends string = string> = T & {
25
25
  __timestampBrand?: void;
26
26
  };
27
27
 
28
+ type Custom = string & {
29
+ readonly __brand: "Custom";
30
+ };
31
+ interface Model {
32
+ rid: string;
33
+ }
34
+
35
+ declare function custom(alias: string): Custom;
36
+
37
+ declare function model(alias: string): Model;
38
+
39
+ type index_Custom = Custom;
40
+ type index_Model = Model;
41
+ declare const index_custom: typeof custom;
42
+ declare const index_model: typeof model;
43
+ declare namespace index {
44
+ export { type index_Custom as Custom, type index_Model as Model, index_custom as custom, index_model as model };
45
+ }
46
+
28
47
  declare function createEditBatch<T extends AnyEdit = never>(_client: Client): EditBatch<T>;
29
48
 
30
49
  declare class UserFacingError extends Error {
@@ -86,4 +105,4 @@ type Principal = {
86
105
  id: string;
87
106
  };
88
107
 
89
- export { type ClassificationMarking, type DateISOString, type Double, EditBatch, type EmailNotification, type Float, type GroupId, type Integer, type Long, type MandatoryMarking, type Notification, type NotificationLink, type NotificationLinkTarget, type ObjectLinkTarget, type PlatformNotification, type Principal, type RidLinkTarget, type TimestampISOString, type UrlLinkTarget, UserFacingError, type UserId, createEditBatch, uploadMedia };
108
+ export { index as Aliases, type ClassificationMarking, type DateISOString, type Double, EditBatch, type EmailNotification, type Float, type GroupId, type Integer, type Long, type MandatoryMarking, type Notification, type NotificationLink, type NotificationLinkTarget, type ObjectLinkTarget, type PlatformNotification, type Principal, type RidLinkTarget, type TimestampISOString, type UrlLinkTarget, UserFacingError, type UserId, createEditBatch, uploadMedia };
@@ -175,6 +175,7 @@ function createWriteableClient(transactionId, ...args) {
175
175
  value: async function(obj, properties) {
176
176
  const propertyMap = {};
177
177
  for (const [key, value] of Object.entries(properties)) {
178
+ if (key.startsWith("$")) continue;
178
179
  propertyMap[key] = toPropertyDataValue(value);
179
180
  }
180
181
  return editRequestManager.postEdit({
@@ -188,6 +189,7 @@ function createWriteableClient(transactionId, ...args) {
188
189
  value: function(locator, properties) {
189
190
  const propertyMap = {};
190
191
  for (const [key, value] of Object.entries(properties)) {
192
+ if (key.startsWith("$")) continue;
191
193
  propertyMap[key] = toPropertyDataValue(value);
192
194
  }
193
195
  return editRequestManager.postEdit({
@@ -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/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,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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].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
+ {"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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AAA,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].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 if (key.startsWith(\"$\")) continue;\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 if (key.startsWith(\"$\")) continue;\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}"]}
@@ -0,0 +1,191 @@
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 * as fs from "fs";
18
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
19
+ import { custom } from "./custom.js";
20
+ import { ALIASES_JSON_FILE_ENV_VAR, detectEnvironment, RESOURCES_JSON_FILE_ENV_VAR } from "./environment.js";
21
+ import { resetPublishedCache } from "./loaders.js";
22
+ import { model } from "./model.js";
23
+ import { AliasEnvironment } from "./types.js";
24
+
25
+ // Read test data before mocking fs - use node:fs which is not affected by vi.mock("fs")
26
+ const {
27
+ testAliasesData,
28
+ testResourcesData
29
+ } = vi.hoisted(() => {
30
+ const nodeFs = require("node:fs");
31
+ const nodePath = require("node:path");
32
+ const aliasesPath = nodePath.resolve(__dirname, "./test-data/aliases.json");
33
+ const resourcesPath = nodePath.resolve(__dirname, "./test-data/resources.json");
34
+ return {
35
+ testAliasesData: nodeFs.readFileSync(aliasesPath, "utf-8"),
36
+ testResourcesData: nodeFs.readFileSync(resourcesPath, "utf-8")
37
+ };
38
+ });
39
+ vi.mock("fs");
40
+ describe("environment detection", () => {
41
+ beforeEach(() => {
42
+ delete process.env[ALIASES_JSON_FILE_ENV_VAR];
43
+ delete process.env[RESOURCES_JSON_FILE_ENV_VAR];
44
+ });
45
+ afterEach(() => {
46
+ delete process.env[ALIASES_JSON_FILE_ENV_VAR];
47
+ delete process.env[RESOURCES_JSON_FILE_ENV_VAR];
48
+ });
49
+ it("detects published environment", () => {
50
+ process.env[ALIASES_JSON_FILE_ENV_VAR] = "/some/path/aliases.json";
51
+ expect(detectEnvironment()).toBe(AliasEnvironment.PUBLISHED);
52
+ });
53
+ it("detects live preview environment", () => {
54
+ process.env[RESOURCES_JSON_FILE_ENV_VAR] = "/some/path/resources.json";
55
+ expect(detectEnvironment()).toBe(AliasEnvironment.LIVE_PREVIEW);
56
+ });
57
+ it("throws when both env vars are set", () => {
58
+ process.env[ALIASES_JSON_FILE_ENV_VAR] = "/some/path/aliases.json";
59
+ process.env[RESOURCES_JSON_FILE_ENV_VAR] = "/some/path/resources.json";
60
+ expect(() => detectEnvironment()).toThrow("Ambiguous alias configuration");
61
+ });
62
+ it("throws when neither env var is set", () => {
63
+ expect(() => detectEnvironment()).toThrow("Unknown alias environment");
64
+ });
65
+ });
66
+ describe("published mode aliases", () => {
67
+ beforeEach(() => {
68
+ resetPublishedCache();
69
+ vi.clearAllMocks();
70
+ delete process.env[RESOURCES_JSON_FILE_ENV_VAR];
71
+ process.env[ALIASES_JSON_FILE_ENV_VAR] = "/app/var/data/aliases.json";
72
+ vi.mocked(fs.existsSync).mockReturnValue(true);
73
+ vi.mocked(fs.readFileSync).mockReturnValue(testAliasesData);
74
+ });
75
+ afterEach(() => {
76
+ delete process.env[ALIASES_JSON_FILE_ENV_VAR];
77
+ delete process.env[RESOURCES_JSON_FILE_ENV_VAR];
78
+ });
79
+ describe("custom", () => {
80
+ it("loads alias successfully", () => {
81
+ const result = custom("myCustomAlias");
82
+ expect(result).toBe("myCustomValue");
83
+ });
84
+ it("throws on nonexistent alias", () => {
85
+ expect(() => custom("nonexistent")).toThrow("Custom alias 'nonexistent' not found. Available aliases: [myCustomAlias, anotherCustomAlias]");
86
+ });
87
+ it("selects correct alias from multiple", () => {
88
+ expect(custom("myCustomAlias")).toBe("myCustomValue");
89
+ expect(custom("anotherCustomAlias")).toBe("anotherCustomValue");
90
+ });
91
+ });
92
+ describe("model", () => {
93
+ it("loads alias successfully and returns rid", () => {
94
+ const result = model("myModelAlias");
95
+ expect(result).toEqual({
96
+ rid: "ri.foundry-ml.main.model.12345678-1234-1234-1234-123456789012"
97
+ });
98
+ });
99
+ it("throws on nonexistent alias", () => {
100
+ expect(() => model("nonexistent")).toThrow("Model alias 'nonexistent' not found. Available aliases: [myModelAlias, anotherModelAlias]");
101
+ });
102
+ it("selects correct alias from multiple", () => {
103
+ const result1 = model("myModelAlias");
104
+ const result2 = model("anotherModelAlias");
105
+ expect(result1.rid).toBe("ri.foundry-ml.main.model.12345678-1234-1234-1234-123456789012");
106
+ expect(result2.rid).toBe("ri.foundry-ml.main.model.87654321-4321-4321-4321-210987654321");
107
+ });
108
+ });
109
+ describe("caching", () => {
110
+ it("reads file only once across multiple lookups", () => {
111
+ custom("myCustomAlias");
112
+ model("myModelAlias");
113
+ custom("anotherCustomAlias");
114
+ expect(fs.readFileSync).toHaveBeenCalledTimes(1);
115
+ });
116
+ it("re-reads after resetPublishedCache", () => {
117
+ custom("myCustomAlias");
118
+ expect(fs.readFileSync).toHaveBeenCalledTimes(1);
119
+ resetPublishedCache();
120
+ custom("myCustomAlias");
121
+ expect(fs.readFileSync).toHaveBeenCalledTimes(2);
122
+ });
123
+ });
124
+ describe("file not found", () => {
125
+ it("throws when aliases file does not exist", () => {
126
+ vi.mocked(fs.existsSync).mockReturnValue(false);
127
+ expect(() => custom("any-alias")).toThrow("Aliases file not found at");
128
+ });
129
+ });
130
+ });
131
+ describe("live preview mode aliases", () => {
132
+ beforeEach(() => {
133
+ vi.clearAllMocks();
134
+ delete process.env[ALIASES_JSON_FILE_ENV_VAR];
135
+ process.env[RESOURCES_JSON_FILE_ENV_VAR] = "/app/var/data/resources.json";
136
+ vi.mocked(fs.existsSync).mockReturnValue(true);
137
+ vi.mocked(fs.readFileSync).mockReturnValue(testResourcesData);
138
+ });
139
+ afterEach(() => {
140
+ delete process.env[ALIASES_JSON_FILE_ENV_VAR];
141
+ delete process.env[RESOURCES_JSON_FILE_ENV_VAR];
142
+ });
143
+ describe("custom", () => {
144
+ it("loads alias successfully", () => {
145
+ const result = custom("previewCustomAlias");
146
+ expect(result).toBe("previewCustomValue");
147
+ });
148
+ it("throws on nonexistent alias", () => {
149
+ expect(() => custom("nonexistent")).toThrow("Custom alias 'nonexistent' not found. Available aliases: [previewCustomAlias, anotherPreviewCustom]");
150
+ });
151
+ it("selects correct alias from multiple", () => {
152
+ expect(custom("previewCustomAlias")).toBe("previewCustomValue");
153
+ expect(custom("anotherPreviewCustom")).toBe("anotherPreviewValue");
154
+ });
155
+ });
156
+ describe("model", () => {
157
+ it("loads alias successfully and returns rid", () => {
158
+ const result = model("previewModelAlias");
159
+ expect(result).toEqual({
160
+ rid: "ri.foundry-ml.main.model.aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
161
+ });
162
+ });
163
+ it("throws on nonexistent alias", () => {
164
+ expect(() => model("nonexistent")).toThrow("Model alias 'nonexistent' not found. Available aliases: [previewModelAlias, anotherPreviewModel]");
165
+ });
166
+ it("selects correct alias from multiple", () => {
167
+ const result1 = model("previewModelAlias");
168
+ const result2 = model("anotherPreviewModel");
169
+ expect(result1.rid).toBe("ri.foundry-ml.main.model.aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
170
+ expect(result2.rid).toBe("ri.foundry-ml.main.model.bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb");
171
+ });
172
+ it("excludes models with null or missing alias", () => {
173
+ expect(() => model("some-random-lookup")).toThrow("Available aliases: [previewModelAlias, anotherPreviewModel]");
174
+ });
175
+ });
176
+ describe("no caching", () => {
177
+ it("re-reads file on every call", () => {
178
+ custom("previewCustomAlias");
179
+ custom("previewCustomAlias");
180
+ custom("previewCustomAlias");
181
+ expect(fs.readFileSync).toHaveBeenCalledTimes(3);
182
+ });
183
+ });
184
+ describe("file not found", () => {
185
+ it("throws when resources file does not exist", () => {
186
+ vi.mocked(fs.existsSync).mockReturnValue(false);
187
+ expect(() => custom("any-alias")).toThrow("Resources file not found at");
188
+ });
189
+ });
190
+ });
191
+ //# sourceMappingURL=aliases.test.js.map