@osdk/integration-testing 0.0.0 → 0.1.0
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 +16 -0
- package/bin/postinstall.mjs +15 -0
- package/build/browser/cli-service/CliServiceLauncher.js +220 -0
- package/build/browser/cli-service/CliServiceLauncher.js.map +1 -0
- package/build/browser/cli-service/FoundryCliService.js +168 -0
- package/build/browser/cli-service/FoundryCliService.js.map +1 -0
- package/build/browser/cli-service/OntologyServer.js +32 -0
- package/build/browser/cli-service/OntologyServer.js.map +1 -0
- package/build/browser/cli-service/ServiceDiscoverer.js +100 -0
- package/build/browser/cli-service/ServiceDiscoverer.js.map +1 -0
- package/build/browser/cli-service/StatusServer.js +91 -0
- package/build/browser/cli-service/StatusServer.js.map +1 -0
- package/build/browser/createIntegrationClient.js +67 -0
- package/build/browser/createIntegrationClient.js.map +1 -0
- package/build/browser/createIntegrationServer.js +115 -0
- package/build/browser/createIntegrationServer.js.map +1 -0
- package/build/browser/createSeedClient.js +77 -0
- package/build/browser/createSeedClient.js.map +1 -0
- package/build/browser/generated/cli/OntologySeedingService/setSeed.js +28 -0
- package/build/browser/generated/cli/OntologySeedingService/setSeed.js.map +1 -0
- package/build/browser/generated/cli/OntologySeedingService.js +19 -0
- package/build/browser/generated/cli/OntologySeedingService.js.map +1 -0
- package/build/browser/generated/cli/StatusService/getStatus.js +25 -0
- package/build/browser/generated/cli/StatusService/getStatus.js.map +1 -0
- package/build/browser/generated/cli/StatusService/publishStatus.js +26 -0
- package/build/browser/generated/cli/StatusService/publishStatus.js.map +1 -0
- package/build/browser/generated/cli/StatusService.js +20 -0
- package/build/browser/generated/cli/StatusService.js.map +1 -0
- package/build/browser/generated/cli/__components.js +2 -0
- package/build/browser/generated/cli/__components.js.map +1 -0
- package/build/browser/generated/cli/index.js +20 -0
- package/build/browser/generated/cli/index.js.map +1 -0
- package/build/browser/index.js +27 -0
- package/build/browser/index.js.map +1 -0
- package/build/browser/scripts/download.js +92 -0
- package/build/browser/scripts/download.js.map +1 -0
- package/build/browser/scripts/foundry-host.js +59 -0
- package/build/browser/scripts/foundry-host.js.map +1 -0
- package/build/browser/scripts/foundry-token.js +50 -0
- package/build/browser/scripts/foundry-token.js.map +1 -0
- package/build/browser/scripts/gitRemote.js +39 -0
- package/build/browser/scripts/gitRemote.js.map +1 -0
- package/build/browser/scripts/postinstall.js +38 -0
- package/build/browser/scripts/postinstall.js.map +1 -0
- package/build/browser/test/NoSpawnStatusServer.js +33 -0
- package/build/browser/test/NoSpawnStatusServer.js.map +1 -0
- package/build/browser/test/StubService.js +61 -0
- package/build/browser/test/StubService.js.map +1 -0
- package/build/browser/test/emptyOntologyMetadata.js +32 -0
- package/build/browser/test/emptyOntologyMetadata.js.map +1 -0
- package/build/browser/test/stubStatusServer.js +74 -0
- package/build/browser/test/stubStatusServer.js.map +1 -0
- package/build/browser/test/writeDiscoveryFile.js +39 -0
- package/build/browser/test/writeDiscoveryFile.js.map +1 -0
- package/build/browser/types.js +2 -0
- package/build/browser/types.js.map +1 -0
- package/build/browser/utils/empty-ontology-block.js +61 -0
- package/build/browser/utils/empty-ontology-block.js.map +1 -0
- package/build/browser/utils/foundry-cli.js +46 -0
- package/build/browser/utils/foundry-cli.js.map +1 -0
- package/build/browser/utils/process.js +26 -0
- package/build/browser/utils/process.js.map +1 -0
- package/build/browser/utils/service.js +33 -0
- package/build/browser/utils/service.js.map +1 -0
- package/build/cjs/index.cjs +841 -0
- package/build/cjs/index.cjs.map +1 -0
- package/build/cjs/index.d.cts +118 -0
- package/build/esm/cli-service/CliServiceLauncher.js +220 -0
- package/build/esm/cli-service/CliServiceLauncher.js.map +1 -0
- package/build/esm/cli-service/FoundryCliService.js +168 -0
- package/build/esm/cli-service/FoundryCliService.js.map +1 -0
- package/build/esm/cli-service/OntologyServer.js +32 -0
- package/build/esm/cli-service/OntologyServer.js.map +1 -0
- package/build/esm/cli-service/ServiceDiscoverer.js +100 -0
- package/build/esm/cli-service/ServiceDiscoverer.js.map +1 -0
- package/build/esm/cli-service/StatusServer.js +91 -0
- package/build/esm/cli-service/StatusServer.js.map +1 -0
- package/build/esm/createIntegrationClient.js +67 -0
- package/build/esm/createIntegrationClient.js.map +1 -0
- package/build/esm/createIntegrationServer.js +115 -0
- package/build/esm/createIntegrationServer.js.map +1 -0
- package/build/esm/createSeedClient.js +77 -0
- package/build/esm/createSeedClient.js.map +1 -0
- package/build/esm/generated/cli/OntologySeedingService/setSeed.js +28 -0
- package/build/esm/generated/cli/OntologySeedingService/setSeed.js.map +1 -0
- package/build/esm/generated/cli/OntologySeedingService.js +19 -0
- package/build/esm/generated/cli/OntologySeedingService.js.map +1 -0
- package/build/esm/generated/cli/StatusService/getStatus.js +25 -0
- package/build/esm/generated/cli/StatusService/getStatus.js.map +1 -0
- package/build/esm/generated/cli/StatusService/publishStatus.js +26 -0
- package/build/esm/generated/cli/StatusService/publishStatus.js.map +1 -0
- package/build/esm/generated/cli/StatusService.js +20 -0
- package/build/esm/generated/cli/StatusService.js.map +1 -0
- package/build/esm/generated/cli/__components.js +2 -0
- package/build/esm/generated/cli/__components.js.map +1 -0
- package/build/esm/generated/cli/index.js +20 -0
- package/build/esm/generated/cli/index.js.map +1 -0
- package/build/esm/index.js +27 -0
- package/build/esm/index.js.map +1 -0
- package/build/esm/scripts/download.js +92 -0
- package/build/esm/scripts/download.js.map +1 -0
- package/build/esm/scripts/foundry-host.js +59 -0
- package/build/esm/scripts/foundry-host.js.map +1 -0
- package/build/esm/scripts/foundry-token.js +50 -0
- package/build/esm/scripts/foundry-token.js.map +1 -0
- package/build/esm/scripts/gitRemote.js +39 -0
- package/build/esm/scripts/gitRemote.js.map +1 -0
- package/build/esm/scripts/postinstall.js +38 -0
- package/build/esm/scripts/postinstall.js.map +1 -0
- package/build/esm/test/NoSpawnStatusServer.js +33 -0
- package/build/esm/test/NoSpawnStatusServer.js.map +1 -0
- package/build/esm/test/StubService.js +61 -0
- package/build/esm/test/StubService.js.map +1 -0
- package/build/esm/test/emptyOntologyMetadata.js +32 -0
- package/build/esm/test/emptyOntologyMetadata.js.map +1 -0
- package/build/esm/test/stubStatusServer.js +74 -0
- package/build/esm/test/stubStatusServer.js.map +1 -0
- package/build/esm/test/writeDiscoveryFile.js +39 -0
- package/build/esm/test/writeDiscoveryFile.js.map +1 -0
- package/build/esm/types.js +2 -0
- package/build/esm/types.js.map +1 -0
- package/build/esm/utils/empty-ontology-block.js +61 -0
- package/build/esm/utils/empty-ontology-block.js.map +1 -0
- package/build/esm/utils/foundry-cli.js +46 -0
- package/build/esm/utils/foundry-cli.js.map +1 -0
- package/build/esm/utils/process.js +26 -0
- package/build/esm/utils/process.js.map +1 -0
- package/build/esm/utils/service.js +33 -0
- package/build/esm/utils/service.js.map +1 -0
- package/build/types/cli-service/CliServiceLauncher.d.ts +36 -0
- package/build/types/cli-service/CliServiceLauncher.d.ts.map +1 -0
- package/build/types/cli-service/FoundryCliService.d.ts +60 -0
- package/build/types/cli-service/FoundryCliService.d.ts.map +1 -0
- package/build/types/cli-service/OntologyServer.d.ts +10 -0
- package/build/types/cli-service/OntologyServer.d.ts.map +1 -0
- package/build/types/cli-service/ServiceDiscoverer.d.ts +22 -0
- package/build/types/cli-service/ServiceDiscoverer.d.ts.map +1 -0
- package/build/types/cli-service/StatusServer.d.ts +17 -0
- package/build/types/cli-service/StatusServer.d.ts.map +1 -0
- package/build/types/createIntegrationClient.d.ts +2 -0
- package/build/types/createIntegrationClient.d.ts.map +1 -0
- package/build/types/createIntegrationServer.d.ts +2 -0
- package/build/types/createIntegrationServer.d.ts.map +1 -0
- package/build/types/createSeedClient.d.ts +9 -0
- package/build/types/createSeedClient.d.ts.map +1 -0
- package/build/types/generated/cli/OntologySeedingService/setSeed.d.ts +9 -0
- package/build/types/generated/cli/OntologySeedingService/setSeed.d.ts.map +1 -0
- package/build/types/generated/cli/OntologySeedingService.d.ts +1 -0
- package/build/types/generated/cli/OntologySeedingService.d.ts.map +1 -0
- package/build/types/generated/cli/StatusService/getStatus.d.ts +6 -0
- package/build/types/generated/cli/StatusService/getStatus.d.ts.map +1 -0
- package/build/types/generated/cli/StatusService/publishStatus.d.ts +7 -0
- package/build/types/generated/cli/StatusService/publishStatus.d.ts.map +1 -0
- package/build/types/generated/cli/StatusService.d.ts +2 -0
- package/build/types/generated/cli/StatusService.d.ts.map +1 -0
- package/build/types/generated/cli/__components.d.ts +189 -0
- package/build/types/generated/cli/__components.d.ts.map +1 -0
- package/build/types/generated/cli/index.d.ts +3 -0
- package/build/types/generated/cli/index.d.ts.map +1 -0
- package/build/types/index.d.ts +10 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/scripts/download.d.ts +6 -0
- package/build/types/scripts/download.d.ts.map +1 -0
- package/build/types/scripts/foundry-host.d.ts +7 -0
- package/build/types/scripts/foundry-host.d.ts.map +1 -0
- package/build/types/scripts/foundry-token.d.ts +5 -0
- package/build/types/scripts/foundry-token.d.ts.map +1 -0
- package/build/types/scripts/gitRemote.d.ts +9 -0
- package/build/types/scripts/gitRemote.d.ts.map +1 -0
- package/build/types/scripts/postinstall.d.ts +1 -0
- package/build/types/scripts/postinstall.d.ts.map +1 -0
- package/build/types/test/NoSpawnStatusServer.d.ts +11 -0
- package/build/types/test/NoSpawnStatusServer.d.ts.map +1 -0
- package/build/types/test/StubService.d.ts +23 -0
- package/build/types/test/StubService.d.ts.map +1 -0
- package/build/types/test/emptyOntologyMetadata.d.ts +3 -0
- package/build/types/test/emptyOntologyMetadata.d.ts.map +1 -0
- package/build/types/test/stubStatusServer.d.ts +14 -0
- package/build/types/test/stubStatusServer.d.ts.map +1 -0
- package/build/types/test/writeDiscoveryFile.d.ts +8 -0
- package/build/types/test/writeDiscoveryFile.d.ts.map +1 -0
- package/build/types/types.d.ts +104 -0
- package/build/types/types.d.ts.map +1 -0
- package/build/types/utils/empty-ontology-block.d.ts +4 -0
- package/build/types/utils/empty-ontology-block.d.ts.map +1 -0
- package/build/types/utils/foundry-cli.d.ts +13 -0
- package/build/types/utils/foundry-cli.d.ts.map +1 -0
- package/build/types/utils/process.d.ts +1 -0
- package/build/types/utils/process.d.ts.map +1 -0
- package/build/types/utils/service.d.ts +4 -0
- package/build/types/utils/service.d.ts.map +1 -0
- package/package.json +93 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createIntegrationServer.js","names":["fs","path","PreviewOntologyIrConverter","invariant","Agent","fetch","undiciFetch","CliServiceLauncher","OntologyServer","createIntegrationClient","createSeedClient","EMPTY_ONTOLOGY_BLOCK_DATA","transformMetadata","metadata","transformed","getPreviewFullMetadataFromBlockData","ontology","writeMetadata","args","metadataPath","previewMetadata","stringified","JSON","stringify","writeFile","createIntegrationServer","config","projectPath","process","cwd","foundryCliPath","testPath","mkdtemp","join","resolve","serviceLauncher","projectDir","register","client","seedClient","getOntologyUrl","getUrl","start","stop","rm","recursive","force","getSeedClient","undefined","baseUrl","env","NODE_ENV","caCertPath","getCaCertPath","agent","connect","ca","readFile","rejectUnauthorized","fetchFn","input","init","dispatcher","getClient"],"sources":["createIntegrationServer.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport type { OntologyFullMetadata } from \"@osdk/foundry.ontologies\";\nimport type { PreviewOntologyFullMetadata } from \"@osdk/generator-converters.preview\";\nimport { PreviewOntologyIrConverter } from \"@osdk/generator-converters.preview\";\nimport invariant from \"tiny-invariant\";\nimport { Agent, fetch as undiciFetch } from \"undici\";\n\nimport { CliServiceLauncher } from \"./cli-service/CliServiceLauncher.js\";\nimport { OntologyServer } from \"./cli-service/OntologyServer.js\";\nimport { createIntegrationClient } from \"./createIntegrationClient.js\";\nimport { createSeedClient } from \"./createSeedClient.js\";\nimport type {\n IntegrationClient,\n IntegrationServer,\n IntegrationServerConfig,\n SeedClient,\n} from \"./types.js\";\nimport { EMPTY_ONTOLOGY_BLOCK_DATA } from \"./utils/empty-ontology-block.js\";\n\nconst transformMetadata = (\n metadata: OntologyFullMetadata,\n): PreviewOntologyFullMetadata => {\n const transformed =\n PreviewOntologyIrConverter.getPreviewFullMetadataFromBlockData(\n EMPTY_ONTOLOGY_BLOCK_DATA,\n metadata,\n );\n return {\n ...transformed,\n ontology: metadata.ontology,\n };\n};\n\nconst writeMetadata = async (args: {\n metadataPath: string;\n previewMetadata: PreviewOntologyFullMetadata;\n}) => {\n const { metadataPath, previewMetadata } = args;\n const stringified = JSON.stringify(previewMetadata);\n await fs.writeFile(metadataPath, stringified);\n};\nexport async function createIntegrationServer(\n config: IntegrationServerConfig,\n): Promise<IntegrationServer> {\n const { metadata, projectPath = process.cwd(), foundryCliPath } = config;\n\n const testPath = await fs.mkdtemp(path.join(projectPath, \".test-run-\"));\n const metadataPath = path.resolve(testPath, \"ontology-metadata.json\");\n const previewMetadata = transformMetadata(metadata);\n\n const serviceLauncher = new CliServiceLauncher({\n projectDir: testPath,\n foundryCliPath,\n });\n // write metadata to metadataPath for foundry cli to read from\n await writeMetadata({\n previewMetadata,\n metadataPath,\n });\n\n const ontology = serviceLauncher.register(\n new OntologyServer({\n projectPath: testPath,\n metadataPath,\n foundryCliPath,\n }),\n );\n\n // stateful cache of client and seed client\n let client: IntegrationClient | undefined;\n let seedClient: SeedClient | undefined;\n\n return {\n getOntologyUrl: () => ontology.getUrl(),\n start: async () => {\n await serviceLauncher.start();\n },\n stop: async () => {\n await serviceLauncher.stop();\n await fs.rm(testPath, { recursive: true, force: true });\n },\n getSeedClient: async () => {\n if (seedClient !== undefined) return seedClient;\n const baseUrl = ontology.getUrl();\n invariant(baseUrl, \"Ontology server is not ready\");\n const caCertPath = ontology.getCaCertPath();\n invariant(caCertPath, \"Ontology server is not ready\");\n const agent = new Agent({\n connect: caCertPath\n ? {\n ca: await fs.readFile(caCertPath),\n }\n : {\n rejectUnauthorized: false,\n },\n });\n const fetchWithCert = ((input, init) =>\n undiciFetch(input, {\n ...init,\n dispatcher: agent,\n })) satisfies typeof undiciFetch as unknown as typeof fetch;\n return (seedClient = createSeedClient({\n baseUrl,\n metadata,\n fetchFn: fetchWithCert,\n }));\n },\n getClient: async () => {\n if (client !== undefined) return client;\n const baseUrl = ontology.getUrl();\n invariant(baseUrl, \"Ontology server is not ready\");\n return (client = await createIntegrationClient({\n baseUrl,\n metadata,\n caCertPath: ontology.getCaCertPath(),\n }));\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,EAAE,MAAM,kBAAkB;AACjC,OAAOC,IAAI,MAAM,WAAW;AAI5B,SAASC,0BAA0B,QAAQ,oCAAoC;AAC/E,OAAOC,SAAS,MAAM,gBAAgB;AACtC,SAASC,KAAK,EAAEC,KAAK,IAAIC,WAAW,QAAQ,QAAQ;AAEpD,SAASC,kBAAkB,QAAQ,qCAAqC;AACxE,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SAASC,uBAAuB,QAAQ,8BAA8B;AACtE,SAASC,gBAAgB,QAAQ,uBAAuB;AAOxD,SAASC,yBAAyB,QAAQ,iCAAiC;AAE3E,MAAMC,iBAAiB,GACrBC,QAA8B,IACE;EAChC,MAAMC,WAAW,GACfZ,0BAA0B,CAACa,mCAAmC,CAC5DJ,yBAAyB,EACzBE,QACF,CAAC;EACH,OAAO;IACL,GAAGC,WAAW;IACdE,QAAQ,EAAEH,QAAQ,CAACG;EACrB,CAAC;AACH,CAAC;AAED,MAAMC,aAAa,GAAG,MAAOC,IAG5B,IAA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,SAAS;MACT,OAAQmC,MAAM,GAAG,MAAM7B,uBAAuB,CAAC;QAC7CwC,OAAO;QACPpC,QAAQ;QACRuC,UAAU,EAAEpC,QAAQ,CAACqC,aAAa,CAAC;MACrC,CAAC,CAAC;IACJ;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,77 @@
|
|
|
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 { SeedBuilder } from "@osdk/seed-helpers";
|
|
18
|
+
import { OntologySeedingService } from "./generated/cli/index.js";
|
|
19
|
+
export function createSeedClient(config) {
|
|
20
|
+
const {
|
|
21
|
+
baseUrl,
|
|
22
|
+
metadata,
|
|
23
|
+
fetchFn
|
|
24
|
+
} = config;
|
|
25
|
+
const builder = new SeedBuilder(metadata);
|
|
26
|
+
const applySeed = async seed => {
|
|
27
|
+
const res = await OntologySeedingService.setSeed({
|
|
28
|
+
baseUrl,
|
|
29
|
+
servicePath: "/api",
|
|
30
|
+
fetchFn
|
|
31
|
+
}, seed);
|
|
32
|
+
return res;
|
|
33
|
+
};
|
|
34
|
+
return Object.defineProperties(async seed => {
|
|
35
|
+
let result;
|
|
36
|
+
if (typeof seed === "function") {
|
|
37
|
+
result = seed(builder);
|
|
38
|
+
} else {
|
|
39
|
+
builder.addAll(seed);
|
|
40
|
+
}
|
|
41
|
+
await applySeed(builder.build());
|
|
42
|
+
return result;
|
|
43
|
+
}, Object.getOwnPropertyDescriptors({
|
|
44
|
+
ref: (o, pk) => builder.ref(o, pk),
|
|
45
|
+
addAll: async output => {
|
|
46
|
+
builder.addAll(output);
|
|
47
|
+
await applySeed(builder.build());
|
|
48
|
+
},
|
|
49
|
+
set: async output => {
|
|
50
|
+
builder.set(output);
|
|
51
|
+
await applySeed(builder.build());
|
|
52
|
+
},
|
|
53
|
+
create: async (o, props) => {
|
|
54
|
+
const ref = builder.create(o, props);
|
|
55
|
+
await applySeed(builder.build());
|
|
56
|
+
return ref;
|
|
57
|
+
},
|
|
58
|
+
update: async (ref, props) => {
|
|
59
|
+
const returnedRef = builder.update(ref, props);
|
|
60
|
+
await applySeed(builder.build());
|
|
61
|
+
return returnedRef;
|
|
62
|
+
},
|
|
63
|
+
delete: async ref => {
|
|
64
|
+
builder.delete(ref);
|
|
65
|
+
await applySeed(builder.build());
|
|
66
|
+
},
|
|
67
|
+
link: async (source, apiName, target) => {
|
|
68
|
+
builder.link(source, apiName, target);
|
|
69
|
+
await applySeed(builder.build());
|
|
70
|
+
},
|
|
71
|
+
unlink: async (source, apiName, target) => {
|
|
72
|
+
builder.unlink(source, apiName, target);
|
|
73
|
+
await applySeed(builder.build());
|
|
74
|
+
}
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=createSeedClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSeedClient.js","names":["SeedBuilder","OntologySeedingService","createSeedClient","config","baseUrl","metadata","fetchFn","builder","applySeed","seed","res","setSeed","servicePath","Object","defineProperties","result","addAll","build","getOwnPropertyDescriptors","ref","o","pk","output","set","create","props","update","returnedRef","delete","link","source","apiName","target","unlink"],"sources":["createSeedClient.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type * as Ontology from \"@osdk/foundry.ontologies\";\nimport {\n SeedBuilder,\n type SeedFunction,\n type SeedOutput,\n} from \"@osdk/seed-helpers\";\n\nimport { OntologySeedingService } from \"./generated/cli/index.js\";\nimport type { SeedClient } from \"./types.js\";\n\ntype SeedClientConfig = {\n baseUrl: string;\n metadata: Ontology.OntologyFullMetadata;\n fetchFn?: typeof fetch;\n};\n\ntype PropsOf<T> = { [K in keyof T]: T[K] };\ntype SeedClientProps = PropsOf<SeedClient>;\n\nexport function createSeedClient(config: SeedClientConfig): SeedClient {\n const { baseUrl, metadata, fetchFn } = config;\n const builder = new SeedBuilder(metadata);\n const seedClientFunction = async <T = void>(\n seed: SeedFunction<T> | SeedOutput,\n ): Promise<T> => {\n let result;\n if (typeof seed === \"function\") {\n result = seed(builder);\n } else {\n builder.addAll(seed);\n }\n await applySeed(builder.build());\n return result as T;\n };\n const applySeed = async (seed: SeedOutput) => {\n const res = await OntologySeedingService.setSeed(\n {\n baseUrl,\n servicePath: \"/api\",\n fetchFn,\n },\n seed,\n );\n return res;\n };\n const seedClientUtils: SeedClientProps = {\n ref: (o, pk) => builder.ref(o, pk),\n addAll: async (output) => {\n builder.addAll(output);\n await applySeed(builder.build());\n },\n set: async (output) => {\n builder.set(output);\n await applySeed(builder.build());\n },\n create: async (o, props) => {\n const ref = builder.create(o, props);\n await applySeed(builder.build());\n return ref;\n },\n update: async (ref, props) => {\n const returnedRef = builder.update(ref, props);\n await applySeed(builder.build());\n return returnedRef;\n },\n delete: async (ref) => {\n builder.delete(ref);\n await applySeed(builder.build());\n },\n link: async (source, apiName, target) => {\n builder.link(source, apiName, target);\n await applySeed(builder.build());\n },\n unlink: async (source, apiName, target) => {\n builder.unlink(source, apiName, target);\n await applySeed(builder.build());\n },\n };\n return Object.defineProperties<SeedClient>(\n seedClientFunction as SeedClient,\n Object.getOwnPropertyDescriptors(seedClientUtils),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SACEA,WAAW,QAGN,oBAAoB;AAE3B,SAASC,sBAAsB,QAAQ,0BAA0B;AAYjE,OAAO,SAASC,gBAAgBA,CAACC,MAAwB,EAAc;EACrE,MAAM;IAAEC,OAAO;IAAEC,QAAQ;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAC7C,MAAMI,OAAO,GAAG,IAAIP,WAAW,CAACK,QAAQ,CAAC;EAazC,MAAMG,SAAS,GAAG,MAAOC,IAAgB,IAAK;IAC5C,MAAMC,GAAG,GAAG,MAAMT,sBAAsB,CAACU,OAAO,CAC9C;MACEP,OAAO;MACPQ,WAAW,EAAE,MAAM;MACnBN;IACF,CAAC,EACDG,IACF,CAAC;IACD,OAAOC,GAAG;EACZ,CAAC;EAkCD,OAAOG,MAAM,CAACC,gBAAgB,CAxDH,MACzBL,IAAkC,IACnB;IACf,IAAIM,MAAM;IACV,IAAI,OAAON,IAAI,KAAK,UAAU,EAAE;MAC9BM,MAAM,GAAGN,IAAI,CAACF,OAAO,CAAC;IACxB,CAAC,MAAM;MACLA,OAAO,CAACS,MAAM,CAACP,IAAI,CAAC;IACtB;IACA,MAAMD,SAAS,CAACD,OAAO,CAACU,KAAK,CAAC,CAAC,CAAC;IAChC,OAAOF,MAAM;EACf,CAAC,EA+CCF,MAAM,CAACK,yBAAyB,CAnCO;IACvCC,GAAG,EAAEA,CAACC,CAAC,EAAEC,EAAE,KAAKd,OAAO,CAACY,GAAG,CAACC,CAAC,EAAEC,EAAE,CAAC;IAClCL,MAAM,EAAE,MAAOM,MAAM,IAAK;MACxBf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AAEC,MAAM,CAAC;MACvC,MAAMxB,SAAS,CAACD,OAAO,CAACU,KAAK,CAAC,CAAC,CAAC;IAClC;EACF,CAGkD,CAClD,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
/**/
|
|
18
|
+
import { conjureFetch } from "conjure-lite";
|
|
19
|
+
/**
|
|
20
|
+
* Sets the seed state of the local ontology server. Succeeds with an
|
|
21
|
+
* empty `200` response; failures surface as errors: 400 for a malformed
|
|
22
|
+
* request body, 503 while the server is still starting, and 500 (with
|
|
23
|
+
* the underlying detail) for seeding failures.
|
|
24
|
+
*/
|
|
25
|
+
export async function setSeed(ctx, seed) {
|
|
26
|
+
return conjureFetch(ctx, `/seed`, "PUT", seed);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=setSeed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setSeed.js","names":["conjureFetch","setSeed","ctx","seed"],"sources":["setSeed.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**/\nimport { conjureFetch, type ConjureContext } from \"conjure-lite\";\n\nimport type {\n OntologySeed as _OntologySeed,\n SetSeedResponse as _SetSeedResponse,\n} from \"../__components.js\";\n\n/**\n * Sets the seed state of the local ontology server. Succeeds with an\n * empty `200` response; failures surface as errors: 400 for a malformed\n * request body, 503 while the server is still starting, and 500 (with\n * the underlying detail) for seeding failures.\n */\nexport async function setSeed(\n ctx: ConjureContext,\n seed: _OntologySeed,\n): Promise<_SetSeedResponse> {\n return conjureFetch(ctx, `/seed`, \"PUT\", seed);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,SAASA,YAAY,QAA6B,cAAc;AAOhE;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,OAAOA,CAC3BC,GAAmB,EACnBC,IAAmB,EACQ;EAC3B,OAAOH,YAAY,CAACE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAEC,IAAI,CAAC;AAChD","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
/**/
|
|
18
|
+
export { setSeed } from "./OntologySeedingService/setSeed.js";
|
|
19
|
+
//# sourceMappingURL=OntologySeedingService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OntologySeedingService.js","names":["setSeed"],"sources":["OntologySeedingService.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**/\nexport { setSeed } from \"./OntologySeedingService/setSeed.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,SAASA,OAAO,QAAQ,qCAAqC","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
/**/
|
|
18
|
+
import { conjureFetch } from "conjure-lite";
|
|
19
|
+
/**
|
|
20
|
+
* Return the current status of all services.
|
|
21
|
+
*/
|
|
22
|
+
export async function getStatus(ctx) {
|
|
23
|
+
return conjureFetch(ctx, `/status`, "GET");
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=getStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getStatus.js","names":["conjureFetch","getStatus","ctx"],"sources":["getStatus.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**/\nimport { conjureFetch, type ConjureContext } from \"conjure-lite\";\n\nimport type { ServiceStatus as _ServiceStatus } from \"../__components.js\";\n\n/**\n * Return the current status of all services.\n */\nexport async function getStatus(\n ctx: ConjureContext,\n): Promise<Array<_ServiceStatus>> {\n return conjureFetch(ctx, `/status`, \"GET\");\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,SAASA,YAAY,QAA6B,cAAc;AAIhE;AACA;AACA;AACA,OAAO,eAAeC,SAASA,CAC7BC,GAAmB,EACa;EAChC,OAAOF,YAAY,CAACE,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC;AAC5C","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
/**/
|
|
18
|
+
import { conjureFetch } from "conjure-lite";
|
|
19
|
+
/**
|
|
20
|
+
* Publish a lifecycle event. Called by services whenever a status
|
|
21
|
+
* transition occurs.
|
|
22
|
+
*/
|
|
23
|
+
export async function publishStatus(ctx, status) {
|
|
24
|
+
return conjureFetch(ctx, `/status`, "POST", status);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=publishStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publishStatus.js","names":["conjureFetch","publishStatus","ctx","status"],"sources":["publishStatus.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**/\nimport { conjureFetch, type ConjureContext } from \"conjure-lite\";\n\nimport type { ServiceStatus as _ServiceStatus } from \"../__components.js\";\n\n/**\n * Publish a lifecycle event. Called by services whenever a status\n * transition occurs.\n */\nexport async function publishStatus(\n ctx: ConjureContext,\n status: _ServiceStatus,\n): Promise<void> {\n return conjureFetch(ctx, `/status`, \"POST\", status);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,SAASA,YAAY,QAA6B,cAAc;AAIhE;AACA;AACA;AACA;AACA,OAAO,eAAeC,aAAaA,CACjCC,GAAmB,EACnBC,MAAsB,EACP;EACf,OAAOH,YAAY,CAACE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAEC,MAAM,CAAC;AACrD","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
/**/
|
|
18
|
+
export { publishStatus } from "./StatusService/publishStatus.js";
|
|
19
|
+
export { getStatus } from "./StatusService/getStatus.js";
|
|
20
|
+
//# sourceMappingURL=StatusService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusService.js","names":["publishStatus","getStatus"],"sources":["StatusService.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**/\nexport { publishStatus } from \"./StatusService/publishStatus.js\";\nexport { getStatus } from \"./StatusService/getStatus.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,SAASA,aAAa,QAAQ,kCAAkC;AAChE,SAASC,SAAS,QAAQ,8BAA8B","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"__components.js","names":[],"sources":["__components.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**/\n\n/**\n * Marketplace bundling settings; CLI flags override these values when provided\n */\nexport interface BundleConfig {\n associatedRid?: string | null | undefined;\n description: string;\n installMode: InstallMode;\n mavenCoordinate?: string | null | undefined;\n name: string;\n salt?: string | null | undefined;\n}\n/**\n * A single component declared in a superrepo's `foundry.yml`.\n */\nexport interface Component {\n path: string;\n type: ServiceName;\n}\n/**\n * Runtime metadata published by a started preview service so\n * other services in the superrepo can locate it. Each running\n * service writes a file at\n * `<foundry.yml dir>/.palantir/.<service-name>-discovery.json`\n * (kebab-cased `ServiceName`). Readers treat the file as stale\n * if the recorded process is no longer alive.\n */\nexport interface ComponentDiscovery {\n caCertPath?: string | null | undefined;\n pid: number;\n processStartTimeSecs: number;\n url: string;\n}\nexport interface FoundryBackendError {\n backtrace?: string | null | undefined;\n errorInstanceId?: string | null | undefined;\n errorName: string;\n message: string;\n}\n/**\n * Project-level configuration loaded from `foundry.yml`.\n * Contains repo-wide settings and a list of products. Single-product\n * foundry.yml files (with top-level `components`) are normalized into\n * this shape at load time with one product.\n */\nexport interface FoundryConfig {\n functionsTypescriptRuntimeVersion?: string | null | undefined;\n minCliVersion: string;\n platformApiProxy?: PlatformApiProxyConfig | null | undefined;\n products: Array<ProductConfig>;\n}\nexport interface GenericFoundryCliError {\n errorName: string;\n message: string;\n}\n/**\n * A single import entry. All fields are optional so the schema can\n * be extended with new import kinds without breaking existing\n * manifests.\n */\nexport interface ImportConfig {\n ontology?: string | null | undefined;\n}\n/**\n * Install strategy for a marketplace block set.\n */\nexport type InstallMode = \"PRODUCTION\" | \"BOOTSTRAP\" | \"SINGLETON\";\n\n/**\n * A single seed object's property bag: keys are property API names,\n * values are the corresponding property values. Serializes to\n * `Record<string, unknown>` in the OSDK `SeedOutput`.\n */\nexport type ObjectSeed = Record<string, SeedPropertyValue>;\n\n/**\n * The seed state of a local ontology. Mirrors the `SeedOutput`\n * shape produced by the OSDK seed helpers (palantir/osdk-ts,\n * `packages/seed-helpers/src/types.ts`): the seed objects keyed by\n * object-type API name, plus the links between them.\n */\nexport interface OntologySeed {\n links: Array<SeedLinkEntry>;\n objects: Record<string, Array<ObjectSeed>>;\n}\n/**\n * Routing rules consumed by `foundry start platform-api-proxy`.\n * Both lists default to empty when omitted.\n */\nexport interface PlatformApiProxyConfig {\n ontologyFoundryFallback: Array<PlatformApiProxyRoute>;\n passthrough: Array<PlatformApiProxyRoute>;\n}\n/**\n * A path glob plus the HTTP methods that may match.\n */\nexport interface PlatformApiProxyRoute {\n methods: Array<string>;\n path: string;\n}\n/**\n * A single product within a superrepo.\n */\nexport interface ProductConfig {\n apiNamespace: string;\n bundle?: BundleConfig | null | undefined;\n components: Array<Component>;\n contentSecurityPolicyAdditions?:\n | Record<string, Array<string>>\n | null\n | undefined;\n imports?: Array<ImportConfig> | null | undefined;\n includeInBundle?: boolean | null | undefined;\n osdkOutput: string;\n}\nexport interface PythonArtifactsChannel {\n channel: string;\n name: string;\n}\nexport interface PythonDependencyChannels {\n conda: Array<PythonArtifactsChannel>;\n pip: Array<PythonArtifactsChannel>;\n}\n/**\n * A single link instance between two seeded objects.\n */\nexport interface SeedLinkEntry {\n linkType: string;\n name: string;\n sourceKey: string;\n sourceObjectType: string;\n targetKey: string;\n targetObjectType: string;\n}\n/**\n * A single property value within a seed object. Opaque JSON whose\n * concrete shape depends on the object type's property definitions.\n */\nexport type SeedPropertyValue = any;\nexport interface SerializableFoundryCliError_foundryBackendError {\n type: \"foundryBackendError\";\n foundryBackendError: FoundryBackendError;\n}\n\nexport interface SerializableFoundryCliError_genericFoundryCliError {\n type: \"genericFoundryCliError\";\n genericFoundryCliError: GenericFoundryCliError;\n}\n\nexport interface SerializableFoundryCliError_unsupportedFeaturesError {\n type: \"unsupportedFeaturesError\";\n unsupportedFeaturesError: UnsupportedFeaturesError;\n}\n\nexport interface SerializableFoundryCliError_unsupportedTemplateTypeError {\n type: \"unsupportedTemplateTypeError\";\n unsupportedTemplateTypeError: UnsupportedTemplateTypeError;\n}\nexport type SerializableFoundryCliError =\n | SerializableFoundryCliError_foundryBackendError\n | SerializableFoundryCliError_genericFoundryCliError\n | SerializableFoundryCliError_unsupportedFeaturesError\n | SerializableFoundryCliError_unsupportedTemplateTypeError;\n\n/**\n * Unified lifecycle stages shared by all services. Each service uses\n * the stages that apply to it.\n */\nexport type ServiceLifecycle =\n | \"PREPARING\"\n | \"READY\"\n | \"FAILED\"\n | \"STARTING\"\n | \"STOPPED\";\n\n/**\n * The kinds of services managed by Foundry. ONTOLOGY,\n * TYPESCRIPT_FUNCTIONS, PYTHON_FUNCTIONS, and APP are user-owned\n * component types declared in `foundry.yml`. STATUS_SERVER and\n * PLATFORM_API_PROXY are internal Foundry-managed services started\n * implicitly by the CLI and must not be declared in `foundry.yml`.\n */\nexport type ServiceName =\n | \"ONTOLOGY\"\n | \"TYPESCRIPT_FUNCTIONS\"\n | \"PYTHON_FUNCTIONS\"\n | \"APP\"\n | \"STATUS_SERVER\"\n | \"PLATFORM_API_PROXY\";\n\n/**\n * The status of a service. Published by services on lifecycle\n * transitions (POST /status), and returned by the server as the\n * current snapshot (GET /status).\n */\nexport interface ServiceStatus {\n level: StatusLevel;\n message?: string | null | undefined;\n service: ServiceName;\n status: ServiceLifecycle;\n timestamp: string;\n}\n/**\n * Result of a successful `setSeed` call.\n */\nexport interface SetSeedResponse {}\n/**\n * Severity of a status.\n */\nexport type StatusLevel = \"INFO\" | \"WARN\" | \"ERROR\";\nexport interface UnsupportedFeaturesError {\n messages: Array<string>;\n}\nexport interface UnsupportedTemplateTypeError {\n message: string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
/**/
|
|
18
|
+
export * as OntologySeedingService from "./OntologySeedingService.js";
|
|
19
|
+
export * as StatusService from "./StatusService.js";
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["OntologySeedingService","StatusService"],"sources":["index.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**/\nexport * as OntologySeedingService from \"./OntologySeedingService.js\";\nexport * as StatusService from \"./StatusService.js\";\n\nexport type {\n BundleConfig,\n Component,\n ComponentDiscovery,\n FoundryBackendError,\n FoundryConfig,\n GenericFoundryCliError,\n ImportConfig,\n InstallMode,\n ObjectSeed,\n OntologySeed,\n PlatformApiProxyConfig,\n PlatformApiProxyRoute,\n ProductConfig,\n PythonArtifactsChannel,\n PythonDependencyChannels,\n SeedLinkEntry,\n SeedPropertyValue,\n SerializableFoundryCliError,\n ServiceLifecycle,\n ServiceName,\n ServiceStatus,\n SetSeedResponse,\n StatusLevel,\n UnsupportedFeaturesError,\n UnsupportedTemplateTypeError,\n} from \"./__components.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAO,KAAKA,sBAAsB,MAAM,6BAA6B;AACrE,OAAO,KAAKC,aAAa,MAAM,oBAAoB","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
/**
|
|
18
|
+
* The published name of this package.
|
|
19
|
+
*
|
|
20
|
+
* Placeholder entry point for `@osdk/integration-testing`. Integration-testing
|
|
21
|
+
* helpers will be exported from here as they are implemented.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
export { createIntegrationClient } from "./createIntegrationClient.js";
|
|
25
|
+
export { createIntegrationServer } from "./createIntegrationServer.js";
|
|
26
|
+
export { checkFoundryCliVersion } from "./utils/foundry-cli.js";
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["createIntegrationClient","createIntegrationServer","checkFoundryCliVersion"],"sources":["index.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * The published name of this package.\n *\n * Placeholder entry point for `@osdk/integration-testing`. Integration-testing\n * helpers will be exported from here as they are implemented.\n */\n\nexport type {\n SeedClient,\n IntegrationClient,\n IntegrationClientConfig,\n IntegrationServer,\n IntegrationServerConfig,\n} from \"./types.js\";\n\nexport { createIntegrationClient } from \"./createIntegrationClient.js\";\nexport { createIntegrationServer } from \"./createIntegrationServer.js\";\n\nexport { checkFoundryCliVersion } from \"./utils/foundry-cli.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,uBAAuB,QAAQ,8BAA8B;AACtE,SAASC,uBAAuB,QAAQ,8BAA8B;AAEtE,SAASC,sBAAsB,QAAQ,wBAAwB","ignoreList":[]}
|
|
@@ -0,0 +1,92 @@
|
|
|
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 { spawn } from "node:child_process";
|
|
18
|
+
import { rm, writeFile } from "node:fs/promises";
|
|
19
|
+
import { tmpdir } from "node:os";
|
|
20
|
+
import { join } from "node:path";
|
|
21
|
+
import consola from "consola";
|
|
22
|
+
import invariant from "tiny-invariant";
|
|
23
|
+
import { resolveFoundryHost } from "./foundry-host.js";
|
|
24
|
+
import { getFoundryToken } from "./foundry-token.js";
|
|
25
|
+
const INSTALL_SCRIPT_PATH = "/code/api/extension/install-script";
|
|
26
|
+
const INSTALL_BAT_PATH = "/code/api/extension/install-bat";
|
|
27
|
+
const fetchInstallScript = async (foundryUrl, token, isWindows) => {
|
|
28
|
+
const url = new URL(isWindows ? INSTALL_BAT_PATH : INSTALL_SCRIPT_PATH, foundryUrl);
|
|
29
|
+
consola.start(`Fetching the Foundry CLI installer from ${url.href}`);
|
|
30
|
+
const response = await fetch(url, {
|
|
31
|
+
headers: {
|
|
32
|
+
authorization: `Bearer ${token}`
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
!response.ok ? process.env.NODE_ENV !== "production" ? invariant(false, () => `Failed to fetch the Foundry CLI installer from ${url.href}: ` + `${response.status} ${response.statusText}`) : invariant(false) : void 0;
|
|
36
|
+
return await response.text();
|
|
37
|
+
};
|
|
38
|
+
const run = async (command, args, env, stdin) => {
|
|
39
|
+
await new Promise((fulfil, reject) => {
|
|
40
|
+
const child = spawn(command, args, {
|
|
41
|
+
env,
|
|
42
|
+
stdio: [stdin === undefined ? "ignore" : "pipe", "inherit", "inherit"]
|
|
43
|
+
});
|
|
44
|
+
child.on("error", reject);
|
|
45
|
+
child.on("close", (code, signal) => {
|
|
46
|
+
if (code === 0) {
|
|
47
|
+
fulfil();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const reason = signal == null ? `code ${String(code)}` : `signal ${signal}`;
|
|
51
|
+
reject(new Error(`The Foundry CLI installer exited with ${reason}`));
|
|
52
|
+
});
|
|
53
|
+
if (stdin !== undefined) {
|
|
54
|
+
child.stdin?.end(stdin);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
const runInstallScript = async (script, env) => await run("bash", ["-s", "--"], env, script);
|
|
59
|
+
const runInstallBat = async (script, env) => {
|
|
60
|
+
const batPath = join(tmpdir(), `install-foundry-${process.pid}.bat`);
|
|
61
|
+
await writeFile(batPath, script);
|
|
62
|
+
try {
|
|
63
|
+
await run("cmd.exe", ["/d", "/s", "/c", batPath], env);
|
|
64
|
+
} finally {
|
|
65
|
+
await rm(batPath, {
|
|
66
|
+
force: true
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Installs the Foundry CLI by running the installer the stack serves, with the
|
|
73
|
+
* resolved stack url and token injected as `FOUNDRY_URL` and `TOKEN`.
|
|
74
|
+
*/
|
|
75
|
+
export const installFoundryCli = async (options = {}) => {
|
|
76
|
+
const env = options.env ?? process.env;
|
|
77
|
+
const isWindows = process.platform === "win32";
|
|
78
|
+
const [host, token] = await Promise.all([resolveFoundryHost(options), getFoundryToken(options)]);
|
|
79
|
+
const foundryUrl = `https://${host}`;
|
|
80
|
+
const script = await fetchInstallScript(foundryUrl, token, isWindows);
|
|
81
|
+
const installerEnv = {
|
|
82
|
+
...env,
|
|
83
|
+
FOUNDRY_URL: foundryUrl,
|
|
84
|
+
TOKEN: token
|
|
85
|
+
};
|
|
86
|
+
if (isWindows) {
|
|
87
|
+
await runInstallBat(script, installerEnv);
|
|
88
|
+
} else {
|
|
89
|
+
await runInstallScript(script, installerEnv);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=download.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download.js","names":["spawn","rm","writeFile","tmpdir","join","consola","invariant","resolveFoundryHost","getFoundryToken","INSTALL_SCRIPT_PATH","INSTALL_BAT_PATH","fetchInstallScript","foundryUrl","token","isWindows","url","URL","start","href","response","fetch","headers","authorization","ok","process","env","NODE_ENV","status","statusText","text","run","command","args","stdin","Promise","fulfil","reject","child","stdio","undefined","on","code","signal","reason","String","Error","end","runInstallScript","script","runInstallBat","batPath","pid","force","installFoundryCli","options","platform","host","all","installerEnv","FOUNDRY_URL","TOKEN"],"sources":["download.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { spawn } from \"node:child_process\";\nimport { rm, writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\n\nimport consola from \"consola\";\nimport invariant from \"tiny-invariant\";\n\nimport { resolveFoundryHost } from \"./foundry-host.js\";\nimport {\n getFoundryToken,\n type ResolveBearerTokenOptions,\n} from \"./foundry-token.js\";\n\nconst INSTALL_SCRIPT_PATH = \"/code/api/extension/install-script\";\nconst INSTALL_BAT_PATH = \"/code/api/extension/install-bat\";\n\nconst fetchInstallScript = async (\n foundryUrl: string,\n token: string,\n isWindows: boolean,\n): Promise<string> => {\n const url = new URL(\n isWindows ? INSTALL_BAT_PATH : INSTALL_SCRIPT_PATH,\n foundryUrl,\n );\n consola.start(`Fetching the Foundry CLI installer from ${url.href}`);\n const response = await fetch(url, {\n headers: { authorization: `Bearer ${token}` },\n });\n invariant(\n response.ok,\n () =>\n `Failed to fetch the Foundry CLI installer from ${url.href}: ` +\n `${response.status} ${response.statusText}`,\n );\n return await response.text();\n};\n\nconst run = async (\n command: string,\n args: string[],\n env: NodeJS.ProcessEnv,\n stdin?: string,\n): Promise<void> => {\n await new Promise<void>((fulfil, reject) => {\n const child = spawn(command, args, {\n env,\n stdio: [stdin === undefined ? \"ignore\" : \"pipe\", \"inherit\", \"inherit\"],\n });\n child.on(\"error\", reject);\n child.on(\"close\", (code, signal) => {\n if (code === 0) {\n fulfil();\n return;\n }\n const reason =\n signal == null ? `code ${String(code)}` : `signal ${signal}`;\n reject(new Error(`The Foundry CLI installer exited with ${reason}`));\n });\n if (stdin !== undefined) {\n child.stdin?.end(stdin);\n }\n });\n};\n\nconst runInstallScript = async (\n script: string,\n env: NodeJS.ProcessEnv,\n): Promise<void> => await run(\"bash\", [\"-s\", \"--\"], env, script);\n\nconst runInstallBat = async (\n script: string,\n env: NodeJS.ProcessEnv,\n): Promise<void> => {\n const batPath = join(tmpdir(), `install-foundry-${process.pid}.bat`);\n await writeFile(batPath, script);\n try {\n await run(\"cmd.exe\", [\"/d\", \"/s\", \"/c\", batPath], env);\n } finally {\n await rm(batPath, { force: true });\n }\n};\n\n/**\n * Installs the Foundry CLI by running the installer the stack serves, with the\n * resolved stack url and token injected as `FOUNDRY_URL` and `TOKEN`.\n */\nexport const installFoundryCli = async (\n options: ResolveBearerTokenOptions = {},\n): Promise<void> => {\n const env = options.env ?? process.env;\n const isWindows = process.platform === \"win32\";\n\n const [host, token] = await Promise.all([\n resolveFoundryHost(options),\n getFoundryToken(options),\n ]);\n const foundryUrl = `https://${host}`;\n\n const script = await fetchInstallScript(foundryUrl, token, isWindows);\n const installerEnv = { ...env, FOUNDRY_URL: foundryUrl, TOKEN: token };\n if (isWindows) {\n await runInstallBat(script, installerEnv);\n } else {\n await runInstallScript(script, installerEnv);\n }\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,QAAQ,oBAAoB;AAC1C,SAASC,EAAE,EAAEC,SAAS,QAAQ,kBAAkB;AAChD,SAASC,MAAM,QAAQ,SAAS;AAChC,SAASC,IAAI,QAAQ,WAAW;AAEhC,OAAOC,OAAO,MAAM,SAAS;AAC7B,OAAOC,SAAS,MAAM,gBAAgB;AAEtC,SAASC,kBAAkB,QAAQ,mBAAmB;AACtD,SACEC,eAAe,QAEV,oBAAoB;AAE3B,MAAMC,mBAAmB,GAAG,oCAAoC;AAChE,MAAMC,gBAAgB,GAAG,iCAAiC;AAE1D,MAAMC,kBAAkB,GAAG,MAAAA,CACzBC,UAAkB,EAClBC,KAAa,EACbC,SAAkB,KACE;EACpB,MAAMC,GAAG,GAAG,IAAIC,GAAG,CACjBF,SAAS,GAAGJ,gBAAgB,GAAGD,mBAAmB,EAClDG,UACF,CAAC;EACDP,OAAO,CAACY,KAAK,CAAC,2CAA2CF,GAAG,CAACG,IAA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AC;EACrE,MAAM4C,YAAY,GAAG;IAAE,GAAGjC,GAAG;IAAEkC,WAAW,EAAE/C,UAAU;IAAEgD,KAAK,EAAE/C;EAAM,CAAC;EACtE,IAAIC,SAAS,EAAE;IACb,MAAMmC,aAAa,CAACD,MAAM,EAAEU,YAAY,CAAC;EAC3C,CAAC,MAAM;IACL,MAAMX,gBAAgB,CAACC,MAAM,EAAEU,YAAY,CAAC;EAC9C;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
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 invariant from "tiny-invariant";
|
|
18
|
+
import { readGitRemoteUrl } from "./gitRemote.js";
|
|
19
|
+
const parseGitRemoteHost = gitRemote => {
|
|
20
|
+
try {
|
|
21
|
+
// Strips any userinfo (`https://user:token@host/...`), and the port with it:
|
|
22
|
+
// a git remote's port belongs to the git transport (`ssh://...:22/repo`),
|
|
23
|
+
// not to the Foundry endpoint this host is used to build.
|
|
24
|
+
return new URL(gitRemote).hostname || undefined;
|
|
25
|
+
} catch {
|
|
26
|
+
// scp-like remotes (`user@host:path`)
|
|
27
|
+
const host = gitRemote.slice(gitRemote.lastIndexOf("@") + 1).split(":")[0].split("/")[0];
|
|
28
|
+
return host === "" ? undefined : host;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Reads the host out of an explicitly configured value.
|
|
34
|
+
*/
|
|
35
|
+
const parseConfiguredHost = value => {
|
|
36
|
+
const trimmed = value.trim();
|
|
37
|
+
let fromUrl;
|
|
38
|
+
try {
|
|
39
|
+
fromUrl = new URL(trimmed).host || undefined;
|
|
40
|
+
} catch {
|
|
41
|
+
fromUrl = undefined;
|
|
42
|
+
}
|
|
43
|
+
return fromUrl ?? (trimmed.split("/")[0] || undefined);
|
|
44
|
+
};
|
|
45
|
+
export const resolveFoundryHost = async (options = {}) => {
|
|
46
|
+
const env = options.env ?? process.env;
|
|
47
|
+
const envValue = env.FOUNDRY_EXTERNAL_HOST ?? env.FOUNDRY_HOSTNAME;
|
|
48
|
+
if (envValue) {
|
|
49
|
+
const configured = parseConfiguredHost(envValue);
|
|
50
|
+
if (configured) {
|
|
51
|
+
return configured;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const gitRemote = await readGitRemoteUrl(options);
|
|
55
|
+
const gitRemoteHost = gitRemote === undefined ? undefined : parseGitRemoteHost(gitRemote);
|
|
56
|
+
!(gitRemoteHost !== undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, "Cannot resolve the Foundry host. Please set FOUNDRY_EXTERNAL_HOST or " + "FOUNDRY_HOSTNAME, or configure a git remote pointing at Foundry.") : invariant(false) : void 0;
|
|
57
|
+
return gitRemoteHost;
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=foundry-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foundry-host.js","names":["invariant","readGitRemoteUrl","parseGitRemoteHost","gitRemote","URL","hostname","undefined","host","slice","lastIndexOf","split","parseConfiguredHost","value","trimmed","trim","fromUrl","resolveFoundryHost","options","env","process","envValue","FOUNDRY_EXTERNAL_HOST","FOUNDRY_HOSTNAME","configured","gitRemoteHost","NODE_ENV"],"sources":["foundry-host.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\n\nimport type { ResolveBearerTokenOptions } from \"./foundry-token.js\";\nimport { readGitRemoteUrl } from \"./gitRemote.js\";\n\nexport type ArtifactPlatform =\n | \"linux-amd64\"\n | \"linux-arm64\"\n | \"macos-amd64\"\n | \"macos-arm64\"\n | \"windows-amd64\";\n\nexport interface FoundryCliInstallPathsOptions {\n env?: NodeJS.ProcessEnv;\n platform?: NodeJS.Platform;\n}\nconst parseGitRemoteHost = (gitRemote: string): string | undefined => {\n try {\n // Strips any userinfo (`https://user:token@host/...`), and the port with it:\n // a git remote's port belongs to the git transport (`ssh://...:22/repo`),\n // not to the Foundry endpoint this host is used to build.\n return new URL(gitRemote).hostname || undefined;\n } catch {\n // scp-like remotes (`user@host:path`)\n const host = gitRemote\n .slice(gitRemote.lastIndexOf(\"@\") + 1)\n .split(\":\")[0]\n .split(\"/\")[0];\n return host === \"\" ? undefined : host;\n }\n};\n\n/**\n * Reads the host out of an explicitly configured value.\n */\nconst parseConfiguredHost = (value: string): string | undefined => {\n const trimmed = value.trim();\n let fromUrl: string | undefined;\n try {\n fromUrl = new URL(trimmed).host || undefined;\n } catch {\n fromUrl = undefined;\n }\n return fromUrl ?? (trimmed.split(\"/\")[0] || undefined);\n};\n\nexport const resolveFoundryHost = async (\n options: ResolveBearerTokenOptions = {},\n): Promise<string> => {\n const env = options.env ?? process.env;\n const envValue = env.FOUNDRY_EXTERNAL_HOST ?? env.FOUNDRY_HOSTNAME;\n if (envValue) {\n const configured = parseConfiguredHost(envValue);\n if (configured) {\n return configured;\n }\n }\n const gitRemote = await readGitRemoteUrl(options);\n const gitRemoteHost =\n gitRemote === undefined ? undefined : parseGitRemoteHost(gitRemote);\n invariant(\n gitRemoteHost !== undefined,\n \"Cannot resolve the Foundry host. Please set FOUNDRY_EXTERNAL_HOST or \" +\n \"FOUNDRY_HOSTNAME, or configure a git remote pointing at Foundry.\",\n );\n return gitRemoteHost;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,SAAS,MAAM,gBAAgB;AAGtC,SAASC,gBAAgB,QAAQ,gBAAgB;AAajD,MAAMC,kBAAkB,GAAIC,SAAiB,IAAyB;EACpE,IAAI;IACF;IACA;IACA;IACA,OAAO,IAAIC,GAAG,CAACD,SAAS,CAAC,CAACE,QAAQ,IAAIC,SAAS;EACjD,CAAC,CAAC,MAAM;IACN;IACA,MAAMC,IAAI,GAAGJ,SAAS,CACnBK,KAAK,CAACL,SAAS,CAACM,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CACrCC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CACbA,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAChB,OAAOH,IAAI,KAAK,EAAE,GAAGD,SAAS,GAAGC,IAAI;EACvC;AACF,CAAC;;AAED;AACA;AACA;AACA,MAAMI,mBAAmB,GAAIC,KAAa,IAAyB;EACjE,MAAMC,OAAO,GAAGD,KAAK,CAACE,IAAI,CAAC,CAAC;EAC5B,IAAIC,OAA2B;EAC/B,IAAI;IACFA,OAAO,GAAG,IAAIX,GAAG,CAACS,OAAO,CAAC,CAACN,IAAI,IAAID,SAAS;EAC9C,CAAC,CAAC,MAAM;IACNS,OAAO,GAAGT,SAAS;EACrB;EACA,OAAOS,OAAO,KAAKF,OAAO,CAACH,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAIJ,SAAS,CAAC;AACxD,CAAC;AAED,OAAO,MAAMU,kBAAkB,GAAG,MAAAA,CAChCC,OAAkC,GAAG,CAAC,CAAC,KACnB;EACpB,MAAMC,GAAG,GAAGD,OAAO,CAACC,GAAG,IAAIC,OAAO,CAACD,GAAG;EACtC,MAAME,QAAQ,GAAGF,GAAG,CAACG,qBAAqB,IAAIH,GAAG,CAACI,gBAAgB;EAClE,IAAIF,QAAQ,EAAE;IACZ,MAAMG,UAAU,GAAGZ,mBAAmB,CAACS,QAAQ,CAAC;IAChD,IAAIG,UAAU,EAAE;MACd,OAAOA,UAAU;IACnB;EACF;EACA,MAAMpB,SAAS,GAAG,MAAMF,gBAAgB,CAACgB,OAAO,CAAC;EACjD,MAAMO,aAAa,GACjBrB,SAAS,KAAKG,SAAS,GAAGA,SAAS,GAAGJ,kBAAkB,CAACC,SAAS,CAAC;EACrE,EACEqB,aAAa,KAAKlB,SAAS,IAAAa,OAAA,CAAAD,GAAA,CAAAO,QAAA,oBAD7BzB,SAAS,QAEP,uEAAuE,GACrE,kEAAkE,IAHtEA,SAAS;EAKT,OAAOwB,aAAa;AACtB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
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 { readFile } from "node:fs/promises";
|
|
18
|
+
import invariant from "tiny-invariant";
|
|
19
|
+
import { readGitRemoteUrl } from "./gitRemote.js";
|
|
20
|
+
const parseGitRemoteToken = gitRemote => {
|
|
21
|
+
let url;
|
|
22
|
+
try {
|
|
23
|
+
url = new URL(gitRemote);
|
|
24
|
+
} catch {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const encodedToken = url.password || url.username;
|
|
28
|
+
return encodedToken.length ? decodeURIComponent(encodedToken) : undefined;
|
|
29
|
+
};
|
|
30
|
+
const resolveFoundryToken = async (options = {}) => {
|
|
31
|
+
const env = options.env ?? process.env;
|
|
32
|
+
if (env.FOUNDRY_CONTAINER_RUNTIME_TYPE === "CODE_WORKSPACE") {
|
|
33
|
+
const tokenPath = env.FOUNDRY_SCOPED_TOKEN;
|
|
34
|
+
!tokenPath ? process.env.NODE_ENV !== "production" ? invariant(false, "FOUNDRY_SCOPED_TOKEN: unbound variable") : invariant(false) : void 0;
|
|
35
|
+
const contents = await readFile(tokenPath, "utf-8");
|
|
36
|
+
return contents.trim();
|
|
37
|
+
}
|
|
38
|
+
if (env.FOUNDRY_HOSTNAME && env.FOUNDRY_TOKEN && env.FOUNDRY_USERNAME) {
|
|
39
|
+
return env.FOUNDRY_TOKEN;
|
|
40
|
+
}
|
|
41
|
+
const gitRemote = await readGitRemoteUrl(options);
|
|
42
|
+
!(gitRemote !== undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, "Warning: Git remote url not set.\n" + "Please ensure the following environment variables are set " + "[FOUNDRY_HOSTNAME, FOUNDRY_USERNAME, FOUNDRY_TOKEN]") : invariant(false) : void 0;
|
|
43
|
+
return parseGitRemoteToken(gitRemote);
|
|
44
|
+
};
|
|
45
|
+
export const getFoundryToken = async (options = {}) => {
|
|
46
|
+
const token = await resolveFoundryToken(options);
|
|
47
|
+
!(token !== undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not resolve token") : invariant(false) : void 0;
|
|
48
|
+
return token;
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=foundry-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foundry-token.js","names":["readFile","invariant","readGitRemoteUrl","parseGitRemoteToken","gitRemote","url","URL","undefined","encodedToken","password","username","length","decodeURIComponent","resolveFoundryToken","options","env","process","FOUNDRY_CONTAINER_RUNTIME_TYPE","tokenPath","FOUNDRY_SCOPED_TOKEN","NODE_ENV","contents","trim","FOUNDRY_HOSTNAME","FOUNDRY_TOKEN","FOUNDRY_USERNAME","getFoundryToken","token"],"sources":["foundry-token.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { readFile } from \"node:fs/promises\";\n\nimport invariant from \"tiny-invariant\";\n\nimport { readGitRemoteUrl } from \"./gitRemote.js\";\n\nexport interface ResolveBearerTokenOptions {\n env?: NodeJS.ProcessEnv;\n cwd?: string;\n}\n\nconst parseGitRemoteToken = (gitRemote: string): string | undefined => {\n let url: URL;\n try {\n url = new URL(gitRemote);\n } catch {\n return undefined;\n }\n const encodedToken = url.password || url.username;\n return encodedToken.length ? decodeURIComponent(encodedToken) : undefined;\n};\n\nconst resolveFoundryToken = async (\n options: ResolveBearerTokenOptions = {},\n): Promise<string | undefined> => {\n const env = options.env ?? process.env;\n if (env.FOUNDRY_CONTAINER_RUNTIME_TYPE === \"CODE_WORKSPACE\") {\n const tokenPath = env.FOUNDRY_SCOPED_TOKEN;\n invariant(tokenPath, \"FOUNDRY_SCOPED_TOKEN: unbound variable\");\n const contents = await readFile(tokenPath, \"utf-8\");\n return contents.trim();\n }\n if (env.FOUNDRY_HOSTNAME && env.FOUNDRY_TOKEN && env.FOUNDRY_USERNAME) {\n return env.FOUNDRY_TOKEN;\n }\n const gitRemote = await readGitRemoteUrl(options);\n invariant(\n gitRemote !== undefined,\n \"Warning: Git remote url not set.\\n\" +\n \"Please ensure the following environment variables are set \" +\n \"[FOUNDRY_HOSTNAME, FOUNDRY_USERNAME, FOUNDRY_TOKEN]\",\n );\n return parseGitRemoteToken(gitRemote);\n};\n\nexport const getFoundryToken = async (\n options: ResolveBearerTokenOptions = {},\n): Promise<string> => {\n const token = await resolveFoundryToken(options);\n invariant(token !== undefined, \"Could not resolve token\");\n return token;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,kBAAkB;AAE3C,OAAOC,SAAS,MAAM,gBAAgB;AAEtC,SAASC,gBAAgB,QAAQ,gBAAgB;AAOjD,MAAMC,mBAAmB,GAAIC,SAAiB,IAAyB;EACrE,IAAIC,GAAQ;EACZ,IAAI;IACFA,GAAG,GAAG,IAAIC,GAAG,CAACF,SAAS,CAAC;EAC1B,CAAC,CAAC,MAAM;IACN,OAAOG,SAAS;EAClB;EACA,MAAMC,YAAY,GAAGH,GAAG,CAACI,QAAQ,IAAIJ,GAAG,CAACK,QAAQ;EACjD,OAAOF,YAAY,CAACG,MAAM,GAAGC,kBAAkB,CAACJ,YAAY,CAAC,GAAGD,SAAS;AAC3E,CAAC;AAED,MAAMM,mBAAmB,GAAG,MAAAA,CAC1BC,OAAkC,GAAG,CAAC,CAAC,KACP;EAChC,MAAMC,GAAG,GAAGD,OAAO,CAACC,GAAG,IAAIC,OAAO,CAACD,GAAG;EACtC,IAAIA,GAAG,CAACE,8BAA8B,KAAK,gBAAgB,EAAE;IAC3D,MAAMC,SAAS,GAAGH,GAAG,CAACI,oBAAo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