@osdk/functions 1.4.0-beta.3 → 1.4.0-beta.4
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 +6 -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/utils/getApiGatewayBaseUrl.js +79 -0
- package/build/browser/utils/getApiGatewayBaseUrl.js.map +1 -0
- package/build/cjs/public/unstable-do-not-use.cjs +40 -0
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +18 -1
- 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/utils/getApiGatewayBaseUrl.js +79 -0
- package/build/esm/utils/getApiGatewayBaseUrl.js.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/utils/getApiGatewayBaseUrl.d.ts +16 -0
- package/build/types/utils/getApiGatewayBaseUrl.d.ts.map +1 -0
- package/package.json +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unstable-do-not-use.js","names":["createWriteableClient"],"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\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,qBAAqB,QAAQ,0CAA0C","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"unstable-do-not-use.js","names":["createWriteableClient","getApiGatewayBaseUrl"],"sources":["unstable-do-not-use.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { createWriteableClient } from \"../transactions/createWriteableClient.js\";\nexport type { WriteableClient } from \"../transactions/WriteableClient.js\";\nexport { getApiGatewayBaseUrl } from \"../utils/getApiGatewayBaseUrl.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,qBAAqB,QAAQ,0CAA0C;AAEhF,SAASC,oBAAoB,QAAQ,kCAAkC","ignoreList":[]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 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 { readFileSync } from "fs";
|
|
18
|
+
import { parse as parseYaml } from "yaml";
|
|
19
|
+
const FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR = "FOUNDRY_SERVICE_DISCOVERY_V2";
|
|
20
|
+
const API_GATEWAY_SERVICE = "api-gateway";
|
|
21
|
+
/**
|
|
22
|
+
* Type guard to check if config is an object with uris property
|
|
23
|
+
*/
|
|
24
|
+
function hasUrisProperty(config) {
|
|
25
|
+
return !Array.isArray(config) && "uris" in config && Array.isArray(config.uris) && config.uris.every(uri => typeof uri === "string");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Extracts URIs from either array or object format
|
|
30
|
+
*/
|
|
31
|
+
function extractUris(config) {
|
|
32
|
+
return hasUrisProperty(config) ? config.uris : config;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Retrieves the API Gateway base URL from the Function's environment.
|
|
37
|
+
*
|
|
38
|
+
* This function is intended to be used only from within a function. Usage of this utility elsewhere may result
|
|
39
|
+
* in errors since the environment may not be properly configured.
|
|
40
|
+
*
|
|
41
|
+
* @returns The API Gateway base URL (e.g., "https://example.palantirfoundry.com")
|
|
42
|
+
* @throws Error if the API Gateway base URL has not been properly configured in the function's environment.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const baseUrl = getApiGatewayBaseUrl();
|
|
47
|
+
* // Returns: "https://example.palantirfoundry.com"
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export function getApiGatewayBaseUrl() {
|
|
51
|
+
const filePath = process.env[FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR];
|
|
52
|
+
if (!filePath) {
|
|
53
|
+
throw new Error(`${FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR} environment variable is not set`);
|
|
54
|
+
}
|
|
55
|
+
let fileContent;
|
|
56
|
+
try {
|
|
57
|
+
fileContent = readFileSync(filePath, "utf-8");
|
|
58
|
+
} catch (error) {
|
|
59
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
60
|
+
throw new Error(`Failed to read service discovery file at ${filePath}: ${errorMessage}`);
|
|
61
|
+
}
|
|
62
|
+
let discovery;
|
|
63
|
+
try {
|
|
64
|
+
discovery = parseYaml(fileContent);
|
|
65
|
+
} catch (error) {
|
|
66
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
67
|
+
throw new Error(`Failed to parse service discovery YAML file at ${filePath}: ${errorMessage}`);
|
|
68
|
+
}
|
|
69
|
+
const apiGatewayConfig = discovery[API_GATEWAY_SERVICE];
|
|
70
|
+
if (!apiGatewayConfig) {
|
|
71
|
+
throw new Error(`${API_GATEWAY_SERVICE} service not found in service discovery file`);
|
|
72
|
+
}
|
|
73
|
+
const uris = extractUris(apiGatewayConfig);
|
|
74
|
+
if (uris.length === 0) {
|
|
75
|
+
throw new Error(`No URIs found for ${API_GATEWAY_SERVICE} service in service discovery file`);
|
|
76
|
+
}
|
|
77
|
+
return uris[0];
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=getApiGatewayBaseUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getApiGatewayBaseUrl.js","names":["readFileSync","parse","parseYaml","FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR","API_GATEWAY_SERVICE","hasUrisProperty","config","Array","isArray","uris","every","uri","extractUris","getApiGatewayBaseUrl","filePath","process","env","Error","fileContent","error","errorMessage","message","String","discovery","apiGatewayConfig","length"],"sources":["getApiGatewayBaseUrl.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { readFileSync } from \"fs\";\nimport { parse as parseYaml } from \"yaml\";\n\nconst FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR =\n \"FOUNDRY_SERVICE_DISCOVERY_V2\" as const;\nconst API_GATEWAY_SERVICE = \"api-gateway\" as const;\n\ntype ServiceConfig = string[] | { uris: string[] };\n\ninterface ServiceDiscoveryConfig {\n [serviceName: string]: ServiceConfig;\n}\n\n/**\n * Type guard to check if config is an object with uris property\n */\nfunction hasUrisProperty(config: ServiceConfig): config is { uris: string[] } {\n return !Array.isArray(config)\n && \"uris\" in config\n && Array.isArray(config.uris)\n && config.uris.every((uri) => typeof uri === \"string\");\n}\n\n/**\n * Extracts URIs from either array or object format\n */\nfunction extractUris(config: ServiceConfig): string[] {\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(): string {\n const filePath = process.env[FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR];\n\n if (!filePath) {\n throw new Error(\n `${FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR} environment variable is not set`,\n );\n }\n\n let fileContent: string;\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(\n `Failed to read service discovery file at ${filePath}: ${errorMessage}`,\n );\n }\n\n let discovery: ServiceDiscoveryConfig;\n try {\n discovery = parseYaml(fileContent) as ServiceDiscoveryConfig;\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(\n `Failed to parse service discovery YAML file at ${filePath}: ${errorMessage}`,\n );\n }\n\n const apiGatewayConfig = discovery[API_GATEWAY_SERVICE];\n\n if (!apiGatewayConfig) {\n throw new Error(\n `${API_GATEWAY_SERVICE} service not found in service discovery file`,\n );\n }\n\n const uris = extractUris(apiGatewayConfig);\n\n if (uris.length === 0) {\n throw new Error(\n `No URIs found for ${API_GATEWAY_SERVICE} service in service discovery file`,\n );\n }\n\n return uris[0];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,YAAY,QAAQ,IAAI;AACjC,SAASC,KAAK,IAAIC,SAAS,QAAQ,MAAM;AAEzC,MAAMC,oCAAoC,GACxC,8BAAuC;AACzC,MAAMC,mBAAmB,GAAG,aAAsB;AAQlD;AACA;AACA;AACA,SAASC,eAAeA,CAACC,MAAqB,EAAgC;EAC5E,OAAO,CAACC,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,IACxB,MAAM,IAAIA,MAAM,IAChBC,KAAK,CAACC,OAAO,CAACF,MAAM,CAACG,IAAI,CAAC,IAC1BH,MAAM,CAACG,IAAI,CAACC,KAAK,CAAEC,GAAG,IAAK,OAAOA,GAAG,KAAK,QAAQ,CAAC;AAC1D;;AAEA;AACA;AACA;AACA,SAASC,WAAWA,CAACN,MAAqB,EAAY;EACpD,OAAOD,eAAe,CAACC,MAAM,CAAC,GAAGA,MAAM,CAACG,IAAI,GAAGH,MAAM;AACvD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASO,oBAAoBA,CAAA,EAAW;EAC7C,MAAMC,QAAQ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4
4
|
var unstableDoNotUse = require('@osdk/client/unstable-do-not-use');
|
|
5
|
+
var fs = require('fs');
|
|
6
|
+
var yaml = require('yaml');
|
|
5
7
|
|
|
6
8
|
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.38.0/node_modules/@osdk/foundry.ontologies/build/esm/public/OntologyTransaction.js
|
|
7
9
|
var OntologyTransaction_exports = {};
|
|
@@ -196,7 +198,45 @@ function createWriteableClient(...args) {
|
|
|
196
198
|
});
|
|
197
199
|
return writeableClient;
|
|
198
200
|
}
|
|
201
|
+
var FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR = "FOUNDRY_SERVICE_DISCOVERY_V2";
|
|
202
|
+
var API_GATEWAY_SERVICE = "api-gateway";
|
|
203
|
+
function hasUrisProperty(config) {
|
|
204
|
+
return !Array.isArray(config) && "uris" in config && Array.isArray(config.uris) && config.uris.every((uri) => typeof uri === "string");
|
|
205
|
+
}
|
|
206
|
+
function extractUris(config) {
|
|
207
|
+
return hasUrisProperty(config) ? config.uris : config;
|
|
208
|
+
}
|
|
209
|
+
function getApiGatewayBaseUrl() {
|
|
210
|
+
const filePath = process.env[FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR];
|
|
211
|
+
if (!filePath) {
|
|
212
|
+
throw new Error(`${FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR} environment variable is not set`);
|
|
213
|
+
}
|
|
214
|
+
let fileContent;
|
|
215
|
+
try {
|
|
216
|
+
fileContent = fs.readFileSync(filePath, "utf-8");
|
|
217
|
+
} catch (error) {
|
|
218
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
219
|
+
throw new Error(`Failed to read service discovery file at ${filePath}: ${errorMessage}`);
|
|
220
|
+
}
|
|
221
|
+
let discovery;
|
|
222
|
+
try {
|
|
223
|
+
discovery = yaml.parse(fileContent);
|
|
224
|
+
} catch (error) {
|
|
225
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
226
|
+
throw new Error(`Failed to parse service discovery YAML file at ${filePath}: ${errorMessage}`);
|
|
227
|
+
}
|
|
228
|
+
const apiGatewayConfig = discovery[API_GATEWAY_SERVICE];
|
|
229
|
+
if (!apiGatewayConfig) {
|
|
230
|
+
throw new Error(`${API_GATEWAY_SERVICE} service not found in service discovery file`);
|
|
231
|
+
}
|
|
232
|
+
const uris = extractUris(apiGatewayConfig);
|
|
233
|
+
if (uris.length === 0) {
|
|
234
|
+
throw new Error(`No URIs found for ${API_GATEWAY_SERVICE} service in service discovery file`);
|
|
235
|
+
}
|
|
236
|
+
return uris[0];
|
|
237
|
+
}
|
|
199
238
|
|
|
200
239
|
exports.createWriteableClient = createWriteableClient;
|
|
240
|
+
exports.getApiGatewayBaseUrl = getApiGatewayBaseUrl;
|
|
201
241
|
//# sourceMappingURL=unstable-do-not-use.cjs.map
|
|
202
242
|
//# sourceMappingURL=unstable-do-not-use.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../node_modules/.pnpm/@osdk+foundry.ontologies@2.38.0/node_modules/@osdk/foundry.ontologies/build/esm/public/OntologyTransaction.js","../../../src/transactions/WriteableClient.ts","../../../src/transactions/EditRequestManager.ts","../../../src/transactions/toPropertyDataValue.ts","../../../src/transactions/createWriteableClient.ts"],"names":["__export","foundryPlatformFetch","createClientWithTransaction"],"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,EAC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G,EAAA;AACrD,UAAY,WAAA,CAAA,GAAG,CAAI,GAAA,mBAAA,CAAoB,KAAK,CAAA;AAAA;AAE9C,QAAA,OAAO,mBAAmB,QAAS,CAAA;AAAA,UACjC,IAAM,EAAA,WAAA;AAAA,UACN,YAAY,GAAI,CAAA,OAAA;AAAA,UAChB,YAAY,GAAI,CAAA,WAAA;AAAA,UAChB,UAAY,EAAA;AAAA,SACb,CAAA;AAAA;AACH,KACF;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAA,EAAO,SAAU,OAAA,EAAS,UAAY,EAAA;AACpC,QAAA,MAAM,cAAc,EAAC;AACrB,QAAA,KAAA,MAAW,CAAC,GAAK,EAAA,KAAK,KAAK,MAAO,CAAA,OAAA,CAAQ,UAAU,CAAG,EAAA;AACrD,UAAY,WAAA,CAAA,GAAG,CAAI,GAAA,mBAAA,CAAoB,KAAK,CAAA;AAAA;AAE9C,QAAA,OAAO,mBAAmB,QAAS,CAAA;AAAA,UACjC,IAAM,EAAA,cAAA;AAAA,UACN,YAAY,OAAQ,CAAA,QAAA;AAAA,UACpB,YAAY,OAAQ,CAAA,WAAA;AAAA,UACpB,UAAY,EAAA;AAAA,SACb,CAAA;AAAA;AACH,KACF;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAA,EAAO,SAAU,GAAK,EAAA;AACpB,QAAA,OAAO,mBAAmB,QAAS,CAAA;AAAA,UACjC,IAAM,EAAA,cAAA;AAAA,UACN,YAAY,GAAI,CAAA,QAAA;AAAA,UAChB,YAAY,GAAI,CAAA;AAAA,SACjB,CAAA;AAAA;AACH,KACF;AAAA,IACA,CAAC,sBAAsB,GAAG;AAAA,MACxB,KAAO,EAAA;AAAA,QACL,WAAA;AAAA,QACA;AAAA;AACF;AACF,GACD,CAAA;AACD,EAAO,OAAA,eAAA;AACT","file":"unstable-do-not-use.cjs","sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { foundryPlatformFetch as $foundryPlatformFetch } from \"@osdk/shared.net.platformapi\";\n//\nconst _postEdits = [1, \"/v2/ontologies/{0}/transactions/{1}/edits\", 3];\n/**\n * Applies a set of edits to a transaction in order.\n *\n * @alpha\n *\n * Required Scopes: [api:ontologies-read]\n * URL: /v2/ontologies/{ontology}/transactions/{transactionRid}/edits\n */\nexport function postEdits($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _postEdits, ...args);\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @internal */\nexport const writeableClientContext = Symbol(\"writeableClientContext\");","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { OntologyTransactions } from \"@osdk/foundry.ontologies\";\nimport { writeableClientContext } from \"./WriteableClient.js\";\nexport class EditRequestManager {\n pendingEdits = [];\n inFlightRequest = null;\n queuedRequest = null;\n editTimeout = null;\n constructor(client) {\n this.client = client;\n }\n postEdit(edit) {\n if (this.inFlightRequest) {\n if (this.editTimeout) {\n // This means we are in the same tick that the request was created, meaning we can just add to the same request\n this.pendingEdits.push(edit);\n return this.inFlightRequest;\n }\n if (this.queuedRequest) {\n // This means we already have a queued request that will run after the inFlightRequest finishes, so we can just add to that one\n this.pendingEdits.push(edit);\n return this.queuedRequest;\n }\n // This means a request has already been sent to the wire but not been returned, so we need to queue up a new request for when that one finishes\n this.queuedRequest = this.inFlightRequest.then(async () => {\n this.inFlightRequest = this.queuedRequest;\n this.queuedRequest = null;\n this.pendingEdits.push(edit);\n await this.dispatchRequest();\n });\n return this.queuedRequest;\n } else {\n // There is no request in flight, which means we should create a new one\n this.inFlightRequest = this.createInitialPromiseWithTimeout(edit);\n return this.inFlightRequest;\n }\n }\n createInitialPromiseWithTimeout(edit) {\n return new Promise(resolve => {\n this.pendingEdits.push(edit);\n this.editTimeout = setTimeout(async () => {\n this.editTimeout = null;\n await this.dispatchRequest();\n if (!this.queuedRequest) {\n // The queued request will see this inFlightRequest resolve and should set the inFlightRequest to itself\n this.inFlightRequest = null;\n }\n resolve();\n }, 0);\n });\n }\n async dispatchRequest() {\n const copiedEdits = this.pendingEdits;\n this.pendingEdits = [];\n await OntologyTransactions.postEdits(this.client, await this.client[writeableClientContext].ontologyRid, this.client[writeableClientContext].transactionRid, {\n edits: copiedEdits\n }, {\n preview: true\n });\n }\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function toPropertyDataValue(value) {\n if (value == null) {\n return null; // This differs from how actions handles null, which expects a specific enum value.\n }\n if (Array.isArray(value)) {\n return value.map(item => toPropertyDataValue(item));\n }\n if (isPoint(value)) {\n return toPropertyDataValue(`${value.coordinates[1]},${value.coordinates[0]}`);\n }\n if (typeof value === \"object\") {\n const result = {};\n for (const key in value) {\n result[key] = toPropertyDataValue(value[key]);\n }\n return result;\n }\n\n // expected to pass through - boolean, byte, date, decimal, float, double, integer, long, short, string, timestamp, object type reference\n return value;\n}\nfunction isPoint(o) {\n return o && typeof o === \"object\" && \"type\" in o && o.type === \"Point\" && \"coordinates\" in o && o.coordinates.length === 2;\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createClientWithTransaction } from \"@osdk/client/unstable-do-not-use\";\nimport { EditRequestManager } from \"./EditRequestManager.js\";\nimport { toPropertyDataValue } from \"./toPropertyDataValue.js\";\nimport { writeableClientContext } from \"./WriteableClient.js\";\nexport function createWriteableClient(...args) {\n const transactionRid = args[0];\n const ontologyRid = args[2];\n const client = createClientWithTransaction(...args);\n const editRequestManager = new EditRequestManager(client) // This cast is safe because we create the writeable client properties below.\n ;\n\n // We use define properties because the client has non-enumerable properties that we want to preserve.\n const writeableClient = Object.defineProperties(client, {\n link: {\n value: function (source, apiName, target) {\n if (!Array.isArray(target)) {\n return editRequestManager.postEdit({\n type: \"addLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: target.$primaryKey\n });\n }\n const promises = [];\n for (const elem of target) {\n promises.push(editRequestManager.postEdit({\n type: \"addLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: elem.$primaryKey\n }));\n }\n return Promise.all(promises).then(() => undefined);\n }\n },\n unlink: {\n value: function (source, apiName, target) {\n if (!Array.isArray(target)) {\n return editRequestManager.postEdit({\n type: \"removeLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: target.$primaryKey\n });\n }\n const promises = [];\n for (const elem of target) {\n promises.push(editRequestManager.postEdit({\n type: \"removeLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: elem.$primaryKey\n }));\n }\n return Promise.all(promises).then(() => undefined);\n }\n },\n create: {\n value: async function (obj, properties) {\n const propertyMap = {};\n for (const [key, value] of Object.entries(properties)) {\n propertyMap[key] = toPropertyDataValue(value);\n }\n return editRequestManager.postEdit({\n type: \"addObject\",\n objectType: obj.apiName,\n primaryKey: obj.$primaryKey,\n properties: propertyMap\n });\n }\n },\n update: {\n value: function (locator, properties) {\n const propertyMap = {};\n for (const [key, value] of Object.entries(properties)) {\n propertyMap[key] = toPropertyDataValue(value);\n }\n return editRequestManager.postEdit({\n type: \"modifyObject\",\n objectType: locator.$apiName,\n primaryKey: locator.$primaryKey,\n properties: propertyMap\n });\n }\n },\n delete: {\n value: function (obj) {\n return editRequestManager.postEdit({\n type: \"deleteObject\",\n objectType: obj.$apiName,\n primaryKey: obj.$primaryKey\n });\n }\n },\n [writeableClientContext]: {\n value: {\n ontologyRid,\n transactionRid\n }\n }\n });\n return writeableClient;\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../node_modules/.pnpm/@osdk+foundry.ontologies@2.38.0/node_modules/@osdk/foundry.ontologies/build/esm/public/OntologyTransaction.js","../../../src/transactions/WriteableClient.ts","../../../src/transactions/EditRequestManager.ts","../../../src/transactions/toPropertyDataValue.ts","../../../src/transactions/createWriteableClient.ts","../../../src/utils/getApiGatewayBaseUrl.ts"],"names":["__export","foundryPlatformFetch","createClientWithTransaction","readFileSync","parseYaml"],"mappings":";;;;;;;;AAAA,IAAA,2BAAA,GAAA,EAAA;AAAAA,0BAAA,CAAA,2BAAA,EAAA;AAAA,EAAA,SAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAiBA,IAAM,UAAa,GAAA,CAAC,CAAG,EAAA,2CAAA,EAA6C,CAAC,CAAA;AAS9D,SAAS,SAAA,CAAU,SAAS,IAAM,EAAA;AACvC,EAAA,OAAOC,sCAAsB,CAAA,IAAA,EAAM,UAAY,EAAA,GAAG,IAAI,CAAA;AACxD;;;ACXO,IAAM,sBAAA,GAAyB,OAAO,wBAAwB,CAAA;;;ACC9D,IAAM,qBAAN,MAAyB;AAAA,EAC9B,eAAe,EAAC;AAAA,EAChB,eAAkB,GAAA,IAAA;AAAA,EAClB,aAAgB,GAAA,IAAA;AAAA,EAChB,WAAc,GAAA,IAAA;AAAA,EACd,YAAY,MAAQ,EAAA;AAClB,IAAA,IAAA,CAAK,MAAS,GAAA,MAAA;AAAA;AAChB,EACA,SAAS,IAAM,EAAA;AACb,IAAA,IAAI,KAAK,eAAiB,EAAA;AACxB,MAAA,IAAI,KAAK,WAAa,EAAA;AAEpB,QAAK,IAAA,CAAA,YAAA,CAAa,KAAK,IAAI,CAAA;AAC3B,QAAA,OAAO,IAAK,CAAA,eAAA;AAAA;AAEd,MAAA,IAAI,KAAK,aAAe,EAAA;AAEtB,QAAK,IAAA,CAAA,YAAA,CAAa,KAAK,IAAI,CAAA;AAC3B,QAAA,OAAO,IAAK,CAAA,aAAA;AAAA;AAGd,MAAA,IAAA,CAAK,aAAgB,GAAA,IAAA,CAAK,eAAgB,CAAA,IAAA,CAAK,YAAY;AACzD,QAAA,IAAA,CAAK,kBAAkB,IAAK,CAAA,aAAA;AAC5B,QAAA,IAAA,CAAK,aAAgB,GAAA,IAAA;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Ae,KAAiB,YAAA,KAAA,GAAQ,KAAM,CAAA,OAAA,GAAU,OAAO,KAAK,CAAA;AAC1E,IAAA,MAAM,IAAI,KAAM,CAAA,CAAA,yCAAA,EAA4C,QAAQ,CAAA,EAAA,EAAK,YAAY,CAAE,CAAA,CAAA;AAAA;AAEzF,EAAI,IAAA,SAAA;AACJ,EAAI,IAAA;AACF,IAAA,SAAA,GAAYC,WAAU,WAAW,CAAA;AAAA,WAC1B,KAAO,EAAA;AACd,IAAA,MAAM,eAAe,KAAiB,YAAA,KAAA,GAAQ,KAAM,CAAA,OAAA,GAAU,OAAO,KAAK,CAAA;AAC1E,IAAA,MAAM,IAAI,KAAM,CAAA,CAAA,+CAAA,EAAkD,QAAQ,CAAA,EAAA,EAAK,YAAY,CAAE,CAAA,CAAA;AAAA;AAE/F,EAAM,MAAA,gBAAA,GAAmB,UAAU,mBAAmB,CAAA;AACtD,EAAA,IAAI,CAAC,gBAAkB,EAAA;AACrB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAG,EAAA,mBAAmB,CAA8C,4CAAA,CAAA,CAAA;AAAA;AAEtF,EAAM,MAAA,IAAA,GAAO,YAAY,gBAAgB,CAAA;AACzC,EAAI,IAAA,IAAA,CAAK,WAAW,CAAG,EAAA;AACrB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAqB,kBAAA,EAAA,mBAAmB,CAAoC,kCAAA,CAAA,CAAA;AAAA;AAE9F,EAAA,OAAO,KAAK,CAAC,CAAA;AACf","file":"unstable-do-not-use.cjs","sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { foundryPlatformFetch as $foundryPlatformFetch } from \"@osdk/shared.net.platformapi\";\n//\nconst _postEdits = [1, \"/v2/ontologies/{0}/transactions/{1}/edits\", 3];\n/**\n * Applies a set of edits to a transaction in order.\n *\n * @alpha\n *\n * Required Scopes: [api:ontologies-read]\n * URL: /v2/ontologies/{ontology}/transactions/{transactionRid}/edits\n */\nexport function postEdits($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _postEdits, ...args);\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @internal */\nexport const writeableClientContext = Symbol(\"writeableClientContext\");","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { OntologyTransactions } from \"@osdk/foundry.ontologies\";\nimport { writeableClientContext } from \"./WriteableClient.js\";\nexport class EditRequestManager {\n pendingEdits = [];\n inFlightRequest = null;\n queuedRequest = null;\n editTimeout = null;\n constructor(client) {\n this.client = client;\n }\n postEdit(edit) {\n if (this.inFlightRequest) {\n if (this.editTimeout) {\n // This means we are in the same tick that the request was created, meaning we can just add to the same request\n this.pendingEdits.push(edit);\n return this.inFlightRequest;\n }\n if (this.queuedRequest) {\n // This means we already have a queued request that will run after the inFlightRequest finishes, so we can just add to that one\n this.pendingEdits.push(edit);\n return this.queuedRequest;\n }\n // This means a request has already been sent to the wire but not been returned, so we need to queue up a new request for when that one finishes\n this.queuedRequest = this.inFlightRequest.then(async () => {\n this.inFlightRequest = this.queuedRequest;\n this.queuedRequest = null;\n this.pendingEdits.push(edit);\n await this.dispatchRequest();\n });\n return this.queuedRequest;\n } else {\n // There is no request in flight, which means we should create a new one\n this.inFlightRequest = this.createInitialPromiseWithTimeout(edit);\n return this.inFlightRequest;\n }\n }\n createInitialPromiseWithTimeout(edit) {\n return new Promise(resolve => {\n this.pendingEdits.push(edit);\n this.editTimeout = setTimeout(async () => {\n this.editTimeout = null;\n await this.dispatchRequest();\n if (!this.queuedRequest) {\n // The queued request will see this inFlightRequest resolve and should set the inFlightRequest to itself\n this.inFlightRequest = null;\n }\n resolve();\n }, 0);\n });\n }\n async dispatchRequest() {\n const copiedEdits = this.pendingEdits;\n this.pendingEdits = [];\n await OntologyTransactions.postEdits(this.client, await this.client[writeableClientContext].ontologyRid, this.client[writeableClientContext].transactionRid, {\n edits: copiedEdits\n }, {\n preview: true\n });\n }\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function toPropertyDataValue(value) {\n if (value == null) {\n return null; // This differs from how actions handles null, which expects a specific enum value.\n }\n if (Array.isArray(value)) {\n return value.map(item => toPropertyDataValue(item));\n }\n if (isPoint(value)) {\n return toPropertyDataValue(`${value.coordinates[1]},${value.coordinates[0]}`);\n }\n if (typeof value === \"object\") {\n const result = {};\n for (const key in value) {\n result[key] = toPropertyDataValue(value[key]);\n }\n return result;\n }\n\n // expected to pass through - boolean, byte, date, decimal, float, double, integer, long, short, string, timestamp, object type reference\n return value;\n}\nfunction isPoint(o) {\n return o && typeof o === \"object\" && \"type\" in o && o.type === \"Point\" && \"coordinates\" in o && o.coordinates.length === 2;\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createClientWithTransaction } from \"@osdk/client/unstable-do-not-use\";\nimport { EditRequestManager } from \"./EditRequestManager.js\";\nimport { toPropertyDataValue } from \"./toPropertyDataValue.js\";\nimport { writeableClientContext } from \"./WriteableClient.js\";\nexport function createWriteableClient(...args) {\n const transactionRid = args[0];\n const ontologyRid = args[2];\n const client = createClientWithTransaction(...args);\n const editRequestManager = new EditRequestManager(client) // This cast is safe because we create the writeable client properties below.\n ;\n\n // We use define properties because the client has non-enumerable properties that we want to preserve.\n const writeableClient = Object.defineProperties(client, {\n link: {\n value: function (source, apiName, target) {\n if (!Array.isArray(target)) {\n return editRequestManager.postEdit({\n type: \"addLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: target.$primaryKey\n });\n }\n const promises = [];\n for (const elem of target) {\n promises.push(editRequestManager.postEdit({\n type: \"addLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: elem.$primaryKey\n }));\n }\n return Promise.all(promises).then(() => undefined);\n }\n },\n unlink: {\n value: function (source, apiName, target) {\n if (!Array.isArray(target)) {\n return editRequestManager.postEdit({\n type: \"removeLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: target.$primaryKey\n });\n }\n const promises = [];\n for (const elem of target) {\n promises.push(editRequestManager.postEdit({\n type: \"removeLink\",\n objectType: source.$apiName,\n primaryKey: source.$primaryKey,\n linkType: apiName,\n linkedObjectPrimaryKey: elem.$primaryKey\n }));\n }\n return Promise.all(promises).then(() => undefined);\n }\n },\n create: {\n value: async function (obj, properties) {\n const propertyMap = {};\n for (const [key, value] of Object.entries(properties)) {\n propertyMap[key] = toPropertyDataValue(value);\n }\n return editRequestManager.postEdit({\n type: \"addObject\",\n objectType: obj.apiName,\n primaryKey: obj.$primaryKey,\n properties: propertyMap\n });\n }\n },\n update: {\n value: function (locator, properties) {\n const propertyMap = {};\n for (const [key, value] of Object.entries(properties)) {\n propertyMap[key] = toPropertyDataValue(value);\n }\n return editRequestManager.postEdit({\n type: \"modifyObject\",\n objectType: locator.$apiName,\n primaryKey: locator.$primaryKey,\n properties: propertyMap\n });\n }\n },\n delete: {\n value: function (obj) {\n return editRequestManager.postEdit({\n type: \"deleteObject\",\n objectType: obj.$apiName,\n primaryKey: obj.$primaryKey\n });\n }\n },\n [writeableClientContext]: {\n value: {\n ontologyRid,\n transactionRid\n }\n }\n });\n return writeableClient;\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { readFileSync } from \"fs\";\nimport { parse as parseYaml } from \"yaml\";\nconst FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR = \"FOUNDRY_SERVICE_DISCOVERY_V2\";\nconst API_GATEWAY_SERVICE = \"api-gateway\";\n/**\n * Type guard to check if config is an object with uris property\n */\nfunction hasUrisProperty(config) {\n return !Array.isArray(config) && \"uris\" in config && Array.isArray(config.uris) && config.uris.every(uri => typeof uri === \"string\");\n}\n\n/**\n * Extracts URIs from either array or object format\n */\nfunction extractUris(config) {\n return hasUrisProperty(config) ? config.uris : config;\n}\n\n/**\n * Retrieves the API Gateway base URL from the Function's environment.\n *\n * This function is intended to be used only from within a function. Usage of this utility elsewhere may result\n * in errors since the environment may not be properly configured.\n *\n * @returns The API Gateway base URL (e.g., \"https://example.palantirfoundry.com\")\n * @throws Error if the API Gateway base URL has not been properly configured in the function's environment.\n *\n * @example\n * ```typescript\n * const baseUrl = getApiGatewayBaseUrl();\n * // Returns: \"https://example.palantirfoundry.com\"\n * ```\n */\nexport function getApiGatewayBaseUrl() {\n const filePath = process.env[FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR];\n if (!filePath) {\n throw new Error(`${FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR} environment variable is not set`);\n }\n let fileContent;\n try {\n fileContent = readFileSync(filePath, \"utf-8\");\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(`Failed to read service discovery file at ${filePath}: ${errorMessage}`);\n }\n let discovery;\n try {\n discovery = parseYaml(fileContent);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(`Failed to parse service discovery YAML file at ${filePath}: ${errorMessage}`);\n }\n const apiGatewayConfig = discovery[API_GATEWAY_SERVICE];\n if (!apiGatewayConfig) {\n throw new Error(`${API_GATEWAY_SERVICE} service not found in service discovery file`);\n }\n const uris = extractUris(apiGatewayConfig);\n if (uris.length === 0) {\n throw new Error(`No URIs found for ${API_GATEWAY_SERVICE} service in service discovery file`);\n }\n return uris[0];\n}"]}
|
|
@@ -20,4 +20,21 @@ interface WriteMethods<X extends AnyEdit> {
|
|
|
20
20
|
|
|
21
21
|
declare function createWriteableClient<X extends AnyEdit = never>(...args: Parameters<typeof createClientWithTransaction>): WriteableClient<X>;
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Retrieves the API Gateway base URL from the Function's environment.
|
|
25
|
+
*
|
|
26
|
+
* This function is intended to be used only from within a function. Usage of this utility elsewhere may result
|
|
27
|
+
* in errors since the environment may not be properly configured.
|
|
28
|
+
*
|
|
29
|
+
* @returns The API Gateway base URL (e.g., "https://example.palantirfoundry.com")
|
|
30
|
+
* @throws Error if the API Gateway base URL has not been properly configured in the function's environment.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const baseUrl = getApiGatewayBaseUrl();
|
|
35
|
+
* // Returns: "https://example.palantirfoundry.com"
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare function getApiGatewayBaseUrl(): string;
|
|
39
|
+
|
|
40
|
+
export { type WriteableClient, createWriteableClient, getApiGatewayBaseUrl };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unstable-do-not-use.js","names":["createWriteableClient"],"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\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,qBAAqB,QAAQ,0CAA0C","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"unstable-do-not-use.js","names":["createWriteableClient","getApiGatewayBaseUrl"],"sources":["unstable-do-not-use.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { createWriteableClient } from \"../transactions/createWriteableClient.js\";\nexport type { WriteableClient } from \"../transactions/WriteableClient.js\";\nexport { getApiGatewayBaseUrl } from \"../utils/getApiGatewayBaseUrl.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,qBAAqB,QAAQ,0CAA0C;AAEhF,SAASC,oBAAoB,QAAQ,kCAAkC","ignoreList":[]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 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 { readFileSync } from "fs";
|
|
18
|
+
import { parse as parseYaml } from "yaml";
|
|
19
|
+
const FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR = "FOUNDRY_SERVICE_DISCOVERY_V2";
|
|
20
|
+
const API_GATEWAY_SERVICE = "api-gateway";
|
|
21
|
+
/**
|
|
22
|
+
* Type guard to check if config is an object with uris property
|
|
23
|
+
*/
|
|
24
|
+
function hasUrisProperty(config) {
|
|
25
|
+
return !Array.isArray(config) && "uris" in config && Array.isArray(config.uris) && config.uris.every(uri => typeof uri === "string");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Extracts URIs from either array or object format
|
|
30
|
+
*/
|
|
31
|
+
function extractUris(config) {
|
|
32
|
+
return hasUrisProperty(config) ? config.uris : config;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Retrieves the API Gateway base URL from the Function's environment.
|
|
37
|
+
*
|
|
38
|
+
* This function is intended to be used only from within a function. Usage of this utility elsewhere may result
|
|
39
|
+
* in errors since the environment may not be properly configured.
|
|
40
|
+
*
|
|
41
|
+
* @returns The API Gateway base URL (e.g., "https://example.palantirfoundry.com")
|
|
42
|
+
* @throws Error if the API Gateway base URL has not been properly configured in the function's environment.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const baseUrl = getApiGatewayBaseUrl();
|
|
47
|
+
* // Returns: "https://example.palantirfoundry.com"
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export function getApiGatewayBaseUrl() {
|
|
51
|
+
const filePath = process.env[FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR];
|
|
52
|
+
if (!filePath) {
|
|
53
|
+
throw new Error(`${FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR} environment variable is not set`);
|
|
54
|
+
}
|
|
55
|
+
let fileContent;
|
|
56
|
+
try {
|
|
57
|
+
fileContent = readFileSync(filePath, "utf-8");
|
|
58
|
+
} catch (error) {
|
|
59
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
60
|
+
throw new Error(`Failed to read service discovery file at ${filePath}: ${errorMessage}`);
|
|
61
|
+
}
|
|
62
|
+
let discovery;
|
|
63
|
+
try {
|
|
64
|
+
discovery = parseYaml(fileContent);
|
|
65
|
+
} catch (error) {
|
|
66
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
67
|
+
throw new Error(`Failed to parse service discovery YAML file at ${filePath}: ${errorMessage}`);
|
|
68
|
+
}
|
|
69
|
+
const apiGatewayConfig = discovery[API_GATEWAY_SERVICE];
|
|
70
|
+
if (!apiGatewayConfig) {
|
|
71
|
+
throw new Error(`${API_GATEWAY_SERVICE} service not found in service discovery file`);
|
|
72
|
+
}
|
|
73
|
+
const uris = extractUris(apiGatewayConfig);
|
|
74
|
+
if (uris.length === 0) {
|
|
75
|
+
throw new Error(`No URIs found for ${API_GATEWAY_SERVICE} service in service discovery file`);
|
|
76
|
+
}
|
|
77
|
+
return uris[0];
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=getApiGatewayBaseUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getApiGatewayBaseUrl.js","names":["readFileSync","parse","parseYaml","FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR","API_GATEWAY_SERVICE","hasUrisProperty","config","Array","isArray","uris","every","uri","extractUris","getApiGatewayBaseUrl","filePath","process","env","Error","fileContent","error","errorMessage","message","String","discovery","apiGatewayConfig","length"],"sources":["getApiGatewayBaseUrl.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { readFileSync } from \"fs\";\nimport { parse as parseYaml } from \"yaml\";\n\nconst FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR =\n \"FOUNDRY_SERVICE_DISCOVERY_V2\" as const;\nconst API_GATEWAY_SERVICE = \"api-gateway\" as const;\n\ntype ServiceConfig = string[] | { uris: string[] };\n\ninterface ServiceDiscoveryConfig {\n [serviceName: string]: ServiceConfig;\n}\n\n/**\n * Type guard to check if config is an object with uris property\n */\nfunction hasUrisProperty(config: ServiceConfig): config is { uris: string[] } {\n return !Array.isArray(config)\n && \"uris\" in config\n && Array.isArray(config.uris)\n && config.uris.every((uri) => typeof uri === \"string\");\n}\n\n/**\n * Extracts URIs from either array or object format\n */\nfunction extractUris(config: ServiceConfig): string[] {\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(): string {\n const filePath = process.env[FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR];\n\n if (!filePath) {\n throw new Error(\n `${FOUNDRY_SERVICE_DISCOVERY_V2_ENV_VAR} environment variable is not set`,\n );\n }\n\n let fileContent: string;\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(\n `Failed to read service discovery file at ${filePath}: ${errorMessage}`,\n );\n }\n\n let discovery: ServiceDiscoveryConfig;\n try {\n discovery = parseYaml(fileContent) as ServiceDiscoveryConfig;\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(\n `Failed to parse service discovery YAML file at ${filePath}: ${errorMessage}`,\n );\n }\n\n const apiGatewayConfig = discovery[API_GATEWAY_SERVICE];\n\n if (!apiGatewayConfig) {\n throw new Error(\n `${API_GATEWAY_SERVICE} service not found in service discovery file`,\n );\n }\n\n const uris = extractUris(apiGatewayConfig);\n\n if (uris.length === 0) {\n throw new Error(\n `No URIs found for ${API_GATEWAY_SERVICE} service in service discovery file`,\n );\n }\n\n return uris[0];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,YAAY,QAAQ,IAAI;AACjC,SAASC,KAAK,IAAIC,SAAS,QAAQ,MAAM;AAEzC,MAAMC,oCAAoC,GACxC,8BAAuC;AACzC,MAAMC,mBAAmB,GAAG,aAAsB;AAQlD;AACA;AACA;AACA,SAASC,eAAeA,CAACC,MAAqB,EAAgC;EAC5E,OAAO,CAACC,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,IACxB,MAAM,IAAIA,MAAM,IAChBC,KAAK,CAACC,OAAO,CAACF,MAAM,CAACG,IAAI,CAAC,IAC1BH,MAAM,CAACG,IAAI,CAACC,KAAK,CAAEC,GAAG,IAAK,OAAOA,GAAG,KAAK,QAAQ,CAAC;AAC1D;;AAEA;AACA;AACA;AACA,SAASC,WAAWA,CAACN,MAAqB,EAAY;EACpD,OAAOD,eAAe,CAACC,MAAM,CAAC,GAAGA,MAAM,CAACG,IAAI,GAAGH,MAAM;AACvD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASO,oBAAoBA,CAAA,EAAW;EAC7C,MAAMC,QAAQ,GAAGC,OAAO,CAACC,GAAG,CAACb,oCAAoC,CAAC;EAElE,IAAI,CAACW,QAAQ,EAAE;IACb,MAAM,IAAIG,KAAK,CACb,GAAGd,oCAAoC,kCACzC,CAAC;EACH;EAEA,IAAIe,WAAmB;EACvB,IAAI;IACFA,WAAW,GAAGlB,YAAY,CAACc,QAAQ,EAAE,OAAO,CAAC;EAC/C,CAAC,CAAC,OAAOK,KAAK,EAAE;IACd,MAAMC,YAAY,GAAGD,KAAK,YAAYF,KAAK,GAAGE,KAAK,CAACE,OAAO,GAAGC,MAAM,CAACH,KAAK,CAAC;IAC3E,MAAM,IAAIF,KAAK,CACb,4CAA4CH,QAAQ,KAAKM,YAAY,EACvE,CAAC;EACH;EAEA,IAAIG,SAAiC;EACrC,IAAI;IACFA,SAAS,GAAGrB,SAAS,CAACgB,WAAW,CAA2B;EAC9D,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,MAAMC,YAAY,GAAGD,KAAK,YAAYF,KAAK,GAAGE,KAAK,CAACE,OAAO,GAAGC,MAAM,CAACH,KAAK,CAAC;IAC3E,MAAM,IAAIF,KAAK,CACb,kDAAkDH,QAAQ,KAAKM,YAAY,EAC7E,CAAC;EACH;EAEA,MAAMI,gBAAgB,GAAGD,SAAS,CAACnB,mBAAmB,CAAC;EAEvD,IAAI,CAACoB,gBAAgB,EAAE;IACrB,MAAM,IAAIP,KAAK,CACb,GAAGb,mBAAmB,8CACxB,CAAC;EACH;EAEA,MAAMK,IAAI,GAAGG,WAAW,CAACY,gBAAgB,CAAC;EAE1C,IAAIf,IAAI,CAACgB,MAAM,KAAK,CAAC,EAAE;IACrB,MAAM,IAAIR,KAAK,CACb,qBAAqBb,mBAAmB,oCAC1C,CAAC;EACH;EAEA,OAAOK,IAAI,CAAC,CAAC,CAAC;AAChB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,SAAS,6BAA6B;AACtC,cAAc,uBAAuB","names":[],"sources":["../../../src/public/unstable-do-not-use.ts"],"version":3,"file":"unstable-do-not-use.d.ts"}
|
|
1
|
+
{"mappings":"AAgBA,SAAS,6BAA6B;AACtC,cAAc,uBAAuB;AACrC,SAAS,4BAA4B","names":[],"sources":["../../../src/public/unstable-do-not-use.ts"],"version":3,"file":"unstable-do-not-use.d.ts"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves the API Gateway base URL from the Function's environment.
|
|
3
|
+
*
|
|
4
|
+
* This function is intended to be used only from within a function. Usage of this utility elsewhere may result
|
|
5
|
+
* in errors since the environment may not be properly configured.
|
|
6
|
+
*
|
|
7
|
+
* @returns The API Gateway base URL (e.g., "https://example.palantirfoundry.com")
|
|
8
|
+
* @throws Error if the API Gateway base URL has not been properly configured in the function's environment.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const baseUrl = getApiGatewayBaseUrl();
|
|
13
|
+
* // Returns: "https://example.palantirfoundry.com"
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function getApiGatewayBaseUrl(): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AA6DA,OAAO,iBAAS","names":[],"sources":["../../../src/utils/getApiGatewayBaseUrl.ts"],"version":3,"file":"getApiGatewayBaseUrl.d.ts"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osdk/functions",
|
|
3
|
-
"version": "1.4.0-beta.
|
|
3
|
+
"version": "1.4.0-beta.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"access": "public",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -50,7 +50,8 @@
|
|
|
50
50
|
"@osdk/foundry.core": "^2.38.0",
|
|
51
51
|
"@osdk/foundry.mediasets": "^2.38.0",
|
|
52
52
|
"@osdk/foundry.ontologies": "^2.38.0",
|
|
53
|
-
"@types/geojson": "^7946.0.16"
|
|
53
|
+
"@types/geojson": "^7946.0.16",
|
|
54
|
+
"yaml": "^2.8.1"
|
|
54
55
|
},
|
|
55
56
|
"peerDependencies": {
|
|
56
57
|
"@osdk/client": "^2.6.0-beta.8"
|
|
@@ -59,13 +60,14 @@
|
|
|
59
60
|
"@microsoft/api-documenter": "^7.26.32",
|
|
60
61
|
"@microsoft/api-extractor": "^7.52.11",
|
|
61
62
|
"@types/geojson": "^7946.0.16",
|
|
63
|
+
"@types/node": "^18.19.0",
|
|
62
64
|
"p-defer": "^4.0.1",
|
|
63
65
|
"ts-expect": "^1.3.0",
|
|
64
66
|
"typescript": "~5.5.4",
|
|
65
67
|
"@osdk/client.test.ontology": "~2.6.0-beta.8",
|
|
66
|
-
"@osdk/monorepo.tsconfig": "~0.5.0-beta.1",
|
|
67
68
|
"@osdk/shared.test": "~2.6.0-beta.3",
|
|
68
|
-
"@osdk/monorepo.api-extractor": "~0.5.0-beta.1"
|
|
69
|
+
"@osdk/monorepo.api-extractor": "~0.5.0-beta.1",
|
|
70
|
+
"@osdk/monorepo.tsconfig": "~0.5.0-beta.1"
|
|
69
71
|
},
|
|
70
72
|
"publishConfig": {
|
|
71
73
|
"access": "public"
|