@palantir/pack.document-schema.type-gen 0.31.0 → 0.33.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/README.md +7 -0
- package/build/esm/commands/ir/__tests__/irUpdateSchemaHandler.test.js +96 -0
- package/build/esm/commands/ir/__tests__/irUpdateSchemaHandler.test.js.map +1 -0
- package/build/esm/commands/ir/__tests__/resolveIrInput.test.js +80 -0
- package/build/esm/commands/ir/__tests__/resolveIrInput.test.js.map +1 -1
- package/build/esm/commands/ir/irDeployHandler.js +5 -0
- package/build/esm/commands/ir/irDeployHandler.js.map +1 -1
- package/build/esm/commands/ir/irGenAssetHandler.js +6 -1
- package/build/esm/commands/ir/irGenAssetHandler.js.map +1 -1
- package/build/esm/commands/ir/irGenTypesHandler.js +7 -3
- package/build/esm/commands/ir/irGenTypesHandler.js.map +1 -1
- package/build/esm/commands/ir/irUpdateSchemaHandler.js +18 -11
- package/build/esm/commands/ir/irUpdateSchemaHandler.js.map +1 -1
- package/build/esm/commands/ir/resolveIrInput.js +6 -5
- package/build/esm/commands/ir/resolveIrInput.js.map +1 -1
- package/build/esm/commands/schema/registerSchemaCommands.js +1 -1
- package/build/esm/commands/schema/registerSchemaCommands.js.map +1 -1
- package/build/esm/commands/schema/schemaIrHandler.js +15 -8
- package/build/esm/commands/schema/schemaIrHandler.js.map +1 -1
- package/build/esm/lib/pack-docschema-api/pack-docschema-ir/schemaMeta.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/custom-discriminant.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/custom-discriminant.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/external-refs.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/external-refs.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/simple-record.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/simple-record.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/union-types.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/union-types.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/array-and-map-types.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/array-and-map-types.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/boolean-fields.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/boolean-fields.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/custom-discriminant.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/custom-discriminant.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/datetime-fields.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/datetime-fields.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/simple-records.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/simple-records.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-before-records.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-before-records.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-types.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-types.js.map +1 -1
- package/build/esm/utils/ir/__tests__/convertIrToWireSchema.test.js +35 -0
- package/build/esm/utils/ir/__tests__/convertIrToWireSchema.test.js.map +1 -1
- package/build/esm/utils/ir/convertIrToWireSchema.js +1 -0
- package/build/esm/utils/ir/convertIrToWireSchema.js.map +1 -1
- package/build/esm/utils/ir/generateModelsFromIr.js +1 -1
- package/build/esm/utils/ir/generateModelsFromIr.js.map +1 -1
- package/build/esm/utils/ir/generateZodSchemasFromIr.js +1 -1
- package/build/esm/utils/ir/generateZodSchemasFromIr.js.map +1 -1
- package/build/esm/utils/schema/__tests__/__snapshots__/generateDocumentTypeFromSchema/with-name-and-description.js +1 -1
- package/build/esm/utils/schema/__tests__/__snapshots__/generateDocumentTypeFromSchema/with-name-and-description.js.map +1 -1
- package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/single-version.js.map +1 -1
- package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/three-version-chain.js.map +1 -1
- package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/two-version.js.map +1 -1
- package/build/esm/utils/schema/__tests__/assertSdkNamesUnique.test.js +178 -0
- package/build/esm/utils/schema/__tests__/assertSdkNamesUnique.test.js.map +1 -0
- package/build/esm/utils/schema/__tests__/generateIndexFromSchema.test.js +2 -1
- package/build/esm/utils/schema/__tests__/generateIndexFromSchema.test.js.map +1 -1
- package/build/esm/utils/schema/__tests__/generateInternalFromSchema.test.js +40 -1
- package/build/esm/utils/schema/__tests__/generateInternalFromSchema.test.js.map +1 -1
- package/build/esm/utils/schema/__tests__/generateVersionedTypesFromSchema.test.js +8 -0
- package/build/esm/utils/schema/__tests__/generateVersionedTypesFromSchema.test.js.map +1 -1
- package/build/esm/utils/schema/__tests__/generateVersionedZodFromSchema.test.js +8 -0
- package/build/esm/utils/schema/__tests__/generateVersionedZodFromSchema.test.js.map +1 -1
- package/build/esm/utils/schema/__tests__/resolveSchemaChain.test.js +75 -3
- package/build/esm/utils/schema/__tests__/resolveSchemaChain.test.js.map +1 -1
- package/build/esm/utils/schema/assertSdkNamesUnique.js +151 -0
- package/build/esm/utils/schema/assertSdkNamesUnique.js.map +1 -0
- package/build/esm/utils/schema/generateIndexFromSchema.js +9 -8
- package/build/esm/utils/schema/generateIndexFromSchema.js.map +1 -1
- package/build/esm/utils/schema/generateInternalFromSchema.js +35 -19
- package/build/esm/utils/schema/generateInternalFromSchema.js.map +1 -1
- package/build/esm/utils/schema/generateModelMetadataFromSchema.js +16 -12
- package/build/esm/utils/schema/generateModelMetadataFromSchema.js.map +1 -1
- package/build/esm/utils/schema/generateScopeFromSchema.js +6 -9
- package/build/esm/utils/schema/generateScopeFromSchema.js.map +1 -1
- package/build/esm/utils/schema/generateTypesFromSchema.js +1 -2
- package/build/esm/utils/schema/generateTypesFromSchema.js.map +1 -1
- package/build/esm/utils/schema/generateVersionedTypesFromSchema.js +31 -10
- package/build/esm/utils/schema/generateVersionedTypesFromSchema.js.map +1 -1
- package/build/esm/utils/schema/generateVersionedZodFromSchema.js +20 -14
- package/build/esm/utils/schema/generateVersionedZodFromSchema.js.map +1 -1
- package/build/esm/utils/schema/resolveSchemaChain.js +108 -20
- package/build/esm/utils/schema/resolveSchemaChain.js.map +1 -1
- package/build/esm/utils/schema/runtimeSchema.js +57 -0
- package/build/esm/utils/schema/runtimeSchema.js.map +1 -1
- package/build/esm/utils/schema/writeAllSdkFiles.js +2 -0
- package/build/esm/utils/schema/writeAllSdkFiles.js.map +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/arrayFields.js.map +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/customDiscriminant.js +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/customDiscriminant.js.map +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/generateTypeScriptInterfaces.js +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/generateTypeScriptInterfaces.js.map +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/refTypes.js.map +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/simpleRecord.js.map +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/simpleSteps.js +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/simpleSteps.js.map +1 -1
- package/build/esm/utils/steps/convertStepsToIr.js +10 -1
- package/build/esm/utils/steps/convertStepsToIr.js.map +1 -1
- package/build/types/commands/ir/__tests__/irUpdateSchemaHandler.test.d.ts +2 -0
- package/build/types/commands/ir/__tests__/irUpdateSchemaHandler.test.d.ts.map +1 -0
- package/build/types/commands/ir/irDeployHandler.d.ts.map +1 -1
- package/build/types/commands/ir/irGenAssetHandler.d.ts.map +1 -1
- package/build/types/commands/ir/irGenTypesHandler.d.ts.map +1 -1
- package/build/types/commands/ir/irUpdateSchemaHandler.d.ts.map +1 -1
- package/build/types/commands/ir/resolveIrInput.d.ts +1 -0
- package/build/types/commands/ir/resolveIrInput.d.ts.map +1 -1
- package/build/types/commands/schema/schemaIrHandler.d.ts +3 -3
- package/build/types/commands/schema/schemaIrHandler.d.ts.map +1 -1
- package/build/types/lib/pack-docschema-api/pack-docschema-ir/schemaMeta.d.ts +1 -0
- package/build/types/lib/pack-docschema-api/pack-docschema-ir/schemaMeta.d.ts.map +1 -1
- package/build/types/utils/ir/generateModelsFromIr.d.ts.map +1 -1
- package/build/types/utils/ir/generateZodSchemasFromIr.d.ts.map +1 -1
- package/build/types/utils/schema/__tests__/assertSdkNamesUnique.test.d.ts +2 -0
- package/build/types/utils/schema/__tests__/assertSdkNamesUnique.test.d.ts.map +1 -0
- package/build/types/utils/schema/assertSdkNamesUnique.d.ts +9 -0
- package/build/types/utils/schema/assertSdkNamesUnique.d.ts.map +1 -0
- package/build/types/utils/schema/generateIndexFromSchema.d.ts.map +1 -1
- package/build/types/utils/schema/generateInternalFromSchema.d.ts.map +1 -1
- package/build/types/utils/schema/generateModelMetadataFromSchema.d.ts.map +1 -1
- package/build/types/utils/schema/generateScopeFromSchema.d.ts.map +1 -1
- package/build/types/utils/schema/generateTypesFromSchema.d.ts.map +1 -1
- package/build/types/utils/schema/generateVersionedTypesFromSchema.d.ts.map +1 -1
- package/build/types/utils/schema/generateVersionedZodFromSchema.d.ts.map +1 -1
- package/build/types/utils/schema/resolveSchemaChain.d.ts +24 -1
- package/build/types/utils/schema/resolveSchemaChain.d.ts.map +1 -1
- package/build/types/utils/schema/runtimeSchema.d.ts +23 -0
- package/build/types/utils/schema/runtimeSchema.d.ts.map +1 -1
- package/build/types/utils/schema/writeAllSdkFiles.d.ts.map +1 -1
- package/build/types/utils/steps/convertStepsToIr.d.ts +2 -0
- package/build/types/utils/steps/convertStepsToIr.d.ts.map +1 -1
- package/package.json +6 -6
- package/build/esm/utils/formatVariantName.js +0 -21
- package/build/esm/utils/formatVariantName.js.map +0 -1
- package/build/types/utils/formatVariantName.d.ts +0 -2
- package/build/types/utils/formatVariantName.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -69,6 +69,13 @@ type-gen ir update-schema -i <ir.json> -b <base-url> -a <token> -o <ontology-rid
|
|
|
69
69
|
[--force-overwrite] [--first-party-prefix /api/gotham]
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
+
`ir update-schema` is for third-party document types. The backend applies those schema versions one
|
|
73
|
+
step at a time (e.g. 1.0 → 1.1 → 2.0). To publish a specific step, build the IR capped at that
|
|
74
|
+
version first with `type-gen schema ir ... --max-version <version>`, where `<version>` is `2`
|
|
75
|
+
(meaning 2.0) or `2.1`. A third-party `ir deploy` must be at a `.0` version; publish minor versions
|
|
76
|
+
with `ir update-schema`. First-party document types publish new versions as assets (`ir asset`),
|
|
77
|
+
which have no one-step rule.
|
|
78
|
+
|
|
72
79
|
`ir asset` (generate an asset JSON consumed by backpack's asset-track loader) remains available;
|
|
73
80
|
the deploy/update-schema REST commands are IR-sourced.
|
|
74
81
|
|
|
@@ -0,0 +1,96 @@
|
|
|
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 { consola } from "consola";
|
|
18
|
+
import { readFileSync } from "fs";
|
|
19
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
20
|
+
import { irUpdateSchemaHandler } from "../irUpdateSchemaHandler.js";
|
|
21
|
+
const {
|
|
22
|
+
updateSchemaMock
|
|
23
|
+
} = vi.hoisted(() => ({
|
|
24
|
+
updateSchemaMock: vi.fn()
|
|
25
|
+
}));
|
|
26
|
+
vi.mock("@osdk/foundry.pack", () => ({
|
|
27
|
+
DocumentTypes: {
|
|
28
|
+
updateSchema: updateSchemaMock
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
vi.mock("@osdk/client", () => ({
|
|
32
|
+
createPlatformClient: vi.fn(() => ({}))
|
|
33
|
+
}));
|
|
34
|
+
vi.mock("fs", async importOriginal => ({
|
|
35
|
+
...(await importOriginal()),
|
|
36
|
+
readFileSync: vi.fn()
|
|
37
|
+
}));
|
|
38
|
+
function ir(version) {
|
|
39
|
+
return {
|
|
40
|
+
name: "Test Document Type",
|
|
41
|
+
version,
|
|
42
|
+
primaryModelKeys: [],
|
|
43
|
+
models: {}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function chainPayload(chain) {
|
|
47
|
+
return JSON.stringify({
|
|
48
|
+
latestVersion: chain[chain.length - 1].version,
|
|
49
|
+
chain: chain.map(entry => ({
|
|
50
|
+
...entry,
|
|
51
|
+
ir: ir(entry.version)
|
|
52
|
+
}))
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const OPTIONS = {
|
|
56
|
+
ir: "ir.json",
|
|
57
|
+
baseUrl: "https://stack.example.com",
|
|
58
|
+
auth: "test-token",
|
|
59
|
+
ontologyRid: "ri.ontology.main.ontology.test"
|
|
60
|
+
};
|
|
61
|
+
function sentRequestBody() {
|
|
62
|
+
const request = updateSchemaMock.mock.calls[0][1];
|
|
63
|
+
return request.requestBody;
|
|
64
|
+
}
|
|
65
|
+
describe("irUpdateSchemaHandler", () => {
|
|
66
|
+
beforeEach(() => {
|
|
67
|
+
updateSchemaMock.mockResolvedValue({
|
|
68
|
+
type: "success",
|
|
69
|
+
version: 1
|
|
70
|
+
});
|
|
71
|
+
vi.spyOn(consola, "info").mockImplementation(() => {});
|
|
72
|
+
vi.spyOn(consola, "success").mockImplementation(() => {});
|
|
73
|
+
vi.spyOn(consola, "warn").mockImplementation(() => {});
|
|
74
|
+
vi.spyOn(consola, "error").mockImplementation(() => {});
|
|
75
|
+
});
|
|
76
|
+
afterEach(() => {
|
|
77
|
+
vi.restoreAllMocks();
|
|
78
|
+
updateSchemaMock.mockReset();
|
|
79
|
+
});
|
|
80
|
+
it("sends schemaMinorVersion for a minor version", async () => {
|
|
81
|
+
vi.mocked(readFileSync).mockReturnValue(chainPayload([{
|
|
82
|
+
version: 1
|
|
83
|
+
}, {
|
|
84
|
+
version: 1,
|
|
85
|
+
minorVersion: 1
|
|
86
|
+
}]));
|
|
87
|
+
await irUpdateSchemaHandler({
|
|
88
|
+
...OPTIONS
|
|
89
|
+
});
|
|
90
|
+
expect(sentRequestBody()).toMatchObject({
|
|
91
|
+
version: 1,
|
|
92
|
+
schemaMinorVersion: 1
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
//# sourceMappingURL=irUpdateSchemaHandler.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"irUpdateSchemaHandler.test.js","names":["consola","readFileSync","afterEach","beforeEach","describe","expect","it","vi","irUpdateSchemaHandler","updateSchemaMock","hoisted","fn","mock","DocumentTypes","updateSchema","createPlatformClient","importOriginal","ir","version","name","primaryModelKeys","models","chainPayload","chain","JSON","stringify","latestVersion","length","map","entry","OPTIONS","baseUrl","auth","ontologyRid","sentRequestBody","request","calls","requestBody","mockResolvedValue","type","spyOn","mockImplementation","restoreAllMocks","mockReset","mocked","mockReturnValue","minorVersion","toMatchObject","schemaMinorVersion"],"sources":["irUpdateSchemaHandler.test.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 { consola } from \"consola\";\nimport type * as FsModule from \"fs\";\nimport { readFileSync } from \"fs\";\nimport { afterEach, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport { irUpdateSchemaHandler } from \"../irUpdateSchemaHandler.js\";\n\nconst { updateSchemaMock } = vi.hoisted(() => ({ updateSchemaMock: vi.fn() }));\n\nvi.mock(\"@osdk/foundry.pack\", () => ({ DocumentTypes: { updateSchema: updateSchemaMock } }));\n\nvi.mock(\"@osdk/client\", () => ({ createPlatformClient: vi.fn(() => ({})) }));\n\nvi.mock(\"fs\", async importOriginal => ({\n ...(await importOriginal<typeof FsModule>()),\n readFileSync: vi.fn(),\n}));\n\nfunction ir(version: number) {\n return { name: \"Test Document Type\", version, primaryModelKeys: [], models: {} };\n}\n\nfunction chainPayload(chain: ReadonlyArray<{ version: number; minorVersion?: number }>): string {\n return JSON.stringify({\n latestVersion: chain[chain.length - 1]!.version,\n chain: chain.map(entry => ({ ...entry, ir: ir(entry.version) })),\n });\n}\n\nconst OPTIONS = {\n ir: \"ir.json\",\n baseUrl: \"https://stack.example.com\",\n auth: \"test-token\",\n ontologyRid: \"ri.ontology.main.ontology.test\",\n} as const;\n\nfunction sentRequestBody(): Record<string, unknown> {\n const request = updateSchemaMock.mock.calls[0]![1] as { requestBody: Record<string, unknown> };\n return request.requestBody;\n}\n\ndescribe(\"irUpdateSchemaHandler\", () => {\n beforeEach(() => {\n updateSchemaMock.mockResolvedValue({ type: \"success\", version: 1 });\n vi.spyOn(consola, \"info\").mockImplementation(() => {});\n vi.spyOn(consola, \"success\").mockImplementation(() => {});\n vi.spyOn(consola, \"warn\").mockImplementation(() => {});\n vi.spyOn(consola, \"error\").mockImplementation(() => {});\n });\n\n afterEach(() => {\n vi.restoreAllMocks();\n updateSchemaMock.mockReset();\n });\n\n it(\"sends schemaMinorVersion for a minor version\", async () => {\n vi.mocked(readFileSync).mockReturnValue(\n chainPayload([{ version: 1 }, { version: 1, minorVersion: 1 }]),\n );\n\n await irUpdateSchemaHandler({ ...OPTIONS });\n\n expect(sentRequestBody()).toMatchObject({ version: 1, schemaMinorVersion: 1 });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,SAAS;AAEjC,SAASC,YAAY,QAAQ,IAAI;AACjC,SAASC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,QAAQ;AACxE,SAASC,qBAAqB,QAAQ,6BAA6B;AAEnE,MAAM;EAAEC;AAAiB,CAAC,GAAGF,EAAE,CAACG,OAAO,CAAC,OAAO;EAAED,gBAAgB,EAAEF,EAAE,CAACI,EAAE,CAAC;AAAE,CAAC,CAAC,CAAC;AAE9EJ,EAAE,CAACK,IAAI,CAAC,oBAAoB,EAAE,OAAO;EAAEC,aAAa,EAAE;IAAEC,YAAY,EAAEL;EAAiB;AAAE,CAAC,CAAC,CAAC;AAE5FF,EAAE,CAACK,IAAI,CAAC,cAAc,EAAE,OAA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AC;IACnEX,EAAE,CAACiC,KAAK,CAACxC,OAAO,EAAE,MAAM,CAAC,CAACyC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;IACtDlC,EAAE,CAACiC,KAAK,CAACxC,OAAO,EAAE,SAAS,CAAC,CAACyC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;IACzDlC,EAAE,CAACiC,KAAK,CAACxC,OAAO,EAAE,MAAM,CAAC,CAACyC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;IACtDlC,EAAE,CAACiC,KAAK,CAACxC,OAAO,EAAE,OAAO,CAAC,CAACyC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;EACzD,CAAC,CAAC;EAEFvC,SAAS,CAAC,MAAM;IACdK,EAAE,CAACmC,eAAe,CAAC,CAAC;IACpBjC,gBAAgB,CAACkC,SAAS,CAAC,CAAC;EAC9B,CAAC,CAAC;EAEFrC,EAAE,CAAC,8CAA8C,EAAE,YAAY;IAC7DC,EAAE,CAACqC,MAAM,CAAC3C,YAAY,CAAC,CAAC4C,eAAe,CACrCvB,YAAY,CAAC,CAAC;MAAEJ,OAAO,EAAE;IAAE,CAAC,EAAE;MAAEA,OAAO,EAAE,CAAC;MAAE4B,YAAY,EAAE;IAAE,CAAC,CAAC,CAChE,CAAC;IAED,MAAMtC,qBAAqB,CAAC;MAAE,GAAGsB;IAAQ,CAAC,CAAC;IAE3CzB,MAAM,CAAC6B,eAAe,CAAC,CAAC,CAAC,CAACa,aAAa,CAAC;MAAE7B,OAAO,EAAE,CAAC;MAAE8B,kBAAkB,EAAE;IAAE,CAAC,CAAC;EAChF,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -25,12 +25,23 @@ function ir(version) {
|
|
|
25
25
|
models: {}
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
+
function record(key) {
|
|
29
|
+
return {
|
|
30
|
+
type: "record",
|
|
31
|
+
record: {
|
|
32
|
+
key,
|
|
33
|
+
name: key,
|
|
34
|
+
fields: []
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
28
38
|
describe("resolveIrInput", () => {
|
|
29
39
|
it("passes through legacy single-version IR", () => {
|
|
30
40
|
const resolved = resolveIrInput(ir(2), "legacy.json");
|
|
31
41
|
expect(resolved).toEqual({
|
|
32
42
|
ir: ir(2),
|
|
33
43
|
latestVersion: 2,
|
|
44
|
+
latestMinorVersion: 0,
|
|
34
45
|
minSupportedVersion: 2
|
|
35
46
|
});
|
|
36
47
|
});
|
|
@@ -49,9 +60,33 @@ describe("resolveIrInput", () => {
|
|
|
49
60
|
expect(resolved).toEqual({
|
|
50
61
|
ir: ir(3),
|
|
51
62
|
latestVersion: 3,
|
|
63
|
+
latestMinorVersion: 0,
|
|
52
64
|
minSupportedVersion: 1
|
|
53
65
|
});
|
|
54
66
|
});
|
|
67
|
+
it("selects the latest minor version when entries share a major version", () => {
|
|
68
|
+
const latestIr = {
|
|
69
|
+
...ir(3),
|
|
70
|
+
name: "Test v3.1"
|
|
71
|
+
};
|
|
72
|
+
const resolved = resolveIrInput({
|
|
73
|
+
latestVersion: 3,
|
|
74
|
+
chain: [{
|
|
75
|
+
version: 1,
|
|
76
|
+
ir: ir(1)
|
|
77
|
+
}, {
|
|
78
|
+
version: 3,
|
|
79
|
+
ir: ir(3)
|
|
80
|
+
}, {
|
|
81
|
+
version: 3,
|
|
82
|
+
minorVersion: 1,
|
|
83
|
+
ir: latestIr
|
|
84
|
+
}]
|
|
85
|
+
}, "chain.json");
|
|
86
|
+
expect(resolved.ir).toBe(latestIr);
|
|
87
|
+
expect(resolved.latestVersion).toBe(3);
|
|
88
|
+
expect(resolved.latestMinorVersion).toBe(1);
|
|
89
|
+
});
|
|
55
90
|
it("carries owningApplicationId through from a chain payload", () => {
|
|
56
91
|
const resolved = resolveIrInput({
|
|
57
92
|
latestVersion: 1,
|
|
@@ -95,5 +130,50 @@ describe("resolveIrInput", () => {
|
|
|
95
130
|
}]
|
|
96
131
|
}, "missing.json")).toThrow("minSupportedVersion 2");
|
|
97
132
|
});
|
|
133
|
+
it("rejects an IR chain whose SDK would use one name twice", () => {
|
|
134
|
+
const models = {
|
|
135
|
+
Status: record("Status"),
|
|
136
|
+
StatusUpdate: record("StatusUpdate")
|
|
137
|
+
};
|
|
138
|
+
expect(() => resolveIrInput({
|
|
139
|
+
latestVersion: 1,
|
|
140
|
+
chain: [{
|
|
141
|
+
version: 1,
|
|
142
|
+
ir: {
|
|
143
|
+
...ir(1),
|
|
144
|
+
models
|
|
145
|
+
}
|
|
146
|
+
}]
|
|
147
|
+
}, "chain.json")).toThrow(`"StatusUpdate_v1" for both record "Status" (v1 write type) and record "StatusUpdate" (v1 type)`);
|
|
148
|
+
});
|
|
149
|
+
it.each([["unknown", "kind", `Variant "unknown" in union "Shape" uses a reserved name.`], ["Unknown", "kind", `Variant "Unknown" in union "Shape" uses a reserved name.`], ["_unknown", "kind", `Variant "_unknown" in union "Shape" uses a reserved name.`], ["box", "rawValue", `Union "Shape" can't use "rawValue" as its discriminant.`]])("rejects JSON union variant %s and discriminant %s when reserved", (variantKey, discriminant, message) => {
|
|
150
|
+
const models = {
|
|
151
|
+
Box: record("Box"),
|
|
152
|
+
Shape: {
|
|
153
|
+
type: "union",
|
|
154
|
+
union: {
|
|
155
|
+
key: "Shape",
|
|
156
|
+
name: "Shape",
|
|
157
|
+
discriminant,
|
|
158
|
+
variants: {
|
|
159
|
+
[variantKey]: "Box"
|
|
160
|
+
},
|
|
161
|
+
metadata: {
|
|
162
|
+
addedInVersion: 1
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
expect(() => resolveIrInput({
|
|
168
|
+
latestVersion: 1,
|
|
169
|
+
chain: [{
|
|
170
|
+
version: 1,
|
|
171
|
+
ir: {
|
|
172
|
+
...ir(1),
|
|
173
|
+
models
|
|
174
|
+
}
|
|
175
|
+
}]
|
|
176
|
+
}, "chain.json")).toThrow(message);
|
|
177
|
+
});
|
|
98
178
|
});
|
|
99
179
|
//# sourceMappingURL=resolveIrInput.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveIrInput.test.js","names":["describe","expect","it","resolveIrInput","ir","version","name","description","primaryModelKeys","models","resolved","toEqual","latestVersion","minSupportedVersion","chain","owningApplicationId","toBe","toThrow"],"sources":["resolveIrInput.test.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 { describe, expect, it } from \"vitest\";\nimport type { IRealTimeDocumentSchema } from \"../../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { resolveIrInput } from \"../resolveIrInput.js\";\n\nfunction ir(version: number): IRealTimeDocumentSchema {\n return {\n name: `Test v${version}`,\n description: \"Test schema\",\n version,\n primaryModelKeys: [],\n models: {},\n };\n}\n\ndescribe(\"resolveIrInput\", () => {\n it(\"passes through legacy single-version IR\", () => {\n const resolved = resolveIrInput(ir(2), \"legacy.json\");\n\n expect(resolved).toEqual({\n ir: ir(2),\n latestVersion: 2,\n minSupportedVersion: 2,\n });\n });\n\n it(\"selects the latest entry from a versioned IR chain\", () => {\n const resolved = resolveIrInput({\n latestVersion: 3,\n minSupportedVersion: 1,\n chain: [\n { version: 1, ir: ir(1) },\n { version: 3, ir: ir(3) },\n ],\n }, \"chain.json\");\n\n expect(resolved).toEqual({\n ir: ir(3),\n latestVersion: 3,\n minSupportedVersion: 1,\n });\n });\n\n it(\"carries owningApplicationId through from a chain payload\", () => {\n const resolved = resolveIrInput({\n latestVersion: 1,\n owningApplicationId: \"app-123\",\n chain: [{ version: 1, ir: ir(1) }],\n }, \"chain.json\");\n\n expect(resolved.owningApplicationId).toBe(\"app-123\");\n });\n\n it(\"defaults chain minSupportedVersion to latestVersion\", () => {\n const resolved = resolveIrInput({\n latestVersion: 3,\n chain: [\n { version: 1, ir: ir(1) },\n { version: 3, ir: ir(3) },\n ],\n }, \"chain.json\");\n\n expect(resolved.minSupportedVersion).toBe(3);\n });\n\n it(\"rejects an empty chain\", () => {\n expect(() =>\n resolveIrInput({\n latestVersion: 1,\n chain: [],\n }, \"empty.json\")\n ).toThrow(\"chain\");\n });\n\n it(\"rejects a chain with an invalid minSupportedVersion\", () => {\n expect(() =>\n resolveIrInput({\n latestVersion: 3,\n minSupportedVersion: 2,\n chain: [\n { version: 1, ir: ir(1) },\n { version: 3, ir: ir(3) },\n ],\n }, \"missing.json\")\n ).toThrow(\"minSupportedVersion 2\");\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAE7C,SAASC,cAAc,QAAQ,sBAAsB;AAErD,SAASC,EAAEA,CAACC,OAAe,EAA2B;EACpD,OAAO;IACLC,IAAI,EAAE,SAASD,OAAO,EAAE;IACxBE,WAAW,EAAE,aAAa;IAC1BF,OAAO;IACPG,gBAAgB,EAAE,EAAE;IACpBC,MAAM,EAAE,CAAC;EACX,CAAC;AACH;AAEAT,QAAQ,CAAC,gBAAgB,EAAE,MAAM;EAC/BE,EAAE,CAAC,yCAAyC,EAAE,MAAM;IAClD,MAAMQ,QAAQ,GAAGP,cAAc,CAACC,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC;IAErDH,MAAM,CAACS,QAAQ,CAAC,CAACC,OAAO,CAAC;MACvBP,EAAE,EAAEA,EAAE,CAAC,CAAC,CAAC;MACTQ,aAAa,EAAE,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AC;IAE7B,CAAC,EAAE,YAAY,CAAC;IAEhBH,MAAM,CAACS,QAAQ,CAACG,mBAAmB,CAAC,CAACG,IAAI,CAAC,CAAC,CAAC;EAC9C,CAAC,CAAC;EAEFd,EAAE,CAAC,wBAAwB,EAAE,MAAM;IACjCD,MAAM,CAAC,MACLE,cAAc,CAAC;MACbS,aAAa,EAAE,CAAC;MAChBE,KAAK,EAAE;IACT,CAAC,EAAE,YAAY,CACjB,CAAC,CAACG,OAAO,CAAC,OAAO,CAAC;EACpB,CAAC,CAAC;EAEFf,EAAE,CAAC,qDAAqD,EAAE,MAAM;IAC9DD,MAAM,CAAC,MACLE,cAAc,CAAC;MACbS,aAAa,EAAE,CAAC;MAChBC,mBAAmB,EAAE,CAAC;MACtBC,KAAK,EAAE,CACL;QAAET,OAAO,EAAE,CAAC;QAAED,EAAE,EAAEA,EAAE,CAAC,CAAC;MAAE,CAAC,EACzB;QAAEC,OAAO,EAAE,CAAC;QAAED,EAAE,EAAEA,EAAE,CAAC,CAAC;MAAE,CAAC;IAE7B,CAAC,EAAE,cAAc,CACnB,CAAC,CAACa,OAAO,CAAC,uBAAuB,CAAC;EACpC,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"resolveIrInput.test.js","names":["describe","expect","it","resolveIrInput","ir","version","name","description","primaryModelKeys","models","record","key","type","fields","resolved","toEqual","latestVersion","latestMinorVersion","minSupportedVersion","chain","latestIr","minorVersion","toBe","owningApplicationId","toThrow","Status","StatusUpdate","each","variantKey","discriminant","message","Box","Shape","union","variants","metadata","addedInVersion"],"sources":["resolveIrInput.test.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 { describe, expect, it } from \"vitest\";\nimport type {\n IModelDef,\n IRealTimeDocumentSchema,\n} from \"../../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { resolveIrInput } from \"../resolveIrInput.js\";\n\nfunction ir(version: number): IRealTimeDocumentSchema {\n return {\n name: `Test v${version}`,\n description: \"Test schema\",\n version,\n primaryModelKeys: [],\n models: {},\n };\n}\n\nfunction record(key: string): IModelDef {\n return { type: \"record\", record: { key, name: key, fields: [] } };\n}\n\ndescribe(\"resolveIrInput\", () => {\n it(\"passes through legacy single-version IR\", () => {\n const resolved = resolveIrInput(ir(2), \"legacy.json\");\n\n expect(resolved).toEqual({\n ir: ir(2),\n latestVersion: 2,\n latestMinorVersion: 0,\n minSupportedVersion: 2,\n });\n });\n\n it(\"selects the latest entry from a versioned IR chain\", () => {\n const resolved = resolveIrInput({\n latestVersion: 3,\n minSupportedVersion: 1,\n chain: [\n { version: 1, ir: ir(1) },\n { version: 3, ir: ir(3) },\n ],\n }, \"chain.json\");\n\n expect(resolved).toEqual({\n ir: ir(3),\n latestVersion: 3,\n latestMinorVersion: 0,\n minSupportedVersion: 1,\n });\n });\n\n it(\"selects the latest minor version when entries share a major version\", () => {\n const latestIr = { ...ir(3), name: \"Test v3.1\" };\n const resolved = resolveIrInput({\n latestVersion: 3,\n chain: [\n { version: 1, ir: ir(1) },\n { version: 3, ir: ir(3) },\n { version: 3, minorVersion: 1, ir: latestIr },\n ],\n }, \"chain.json\");\n\n expect(resolved.ir).toBe(latestIr);\n expect(resolved.latestVersion).toBe(3);\n expect(resolved.latestMinorVersion).toBe(1);\n });\n\n it(\"carries owningApplicationId through from a chain payload\", () => {\n const resolved = resolveIrInput({\n latestVersion: 1,\n owningApplicationId: \"app-123\",\n chain: [{ version: 1, ir: ir(1) }],\n }, \"chain.json\");\n\n expect(resolved.owningApplicationId).toBe(\"app-123\");\n });\n\n it(\"defaults chain minSupportedVersion to latestVersion\", () => {\n const resolved = resolveIrInput({\n latestVersion: 3,\n chain: [\n { version: 1, ir: ir(1) },\n { version: 3, ir: ir(3) },\n ],\n }, \"chain.json\");\n\n expect(resolved.minSupportedVersion).toBe(3);\n });\n\n it(\"rejects an empty chain\", () => {\n expect(() =>\n resolveIrInput({\n latestVersion: 1,\n chain: [],\n }, \"empty.json\")\n ).toThrow(\"chain\");\n });\n\n it(\"rejects a chain with an invalid minSupportedVersion\", () => {\n expect(() =>\n resolveIrInput({\n latestVersion: 3,\n minSupportedVersion: 2,\n chain: [\n { version: 1, ir: ir(1) },\n { version: 3, ir: ir(3) },\n ],\n }, \"missing.json\")\n ).toThrow(\"minSupportedVersion 2\");\n });\n\n it(\"rejects an IR chain whose SDK would use one name twice\", () => {\n const models = { Status: record(\"Status\"), StatusUpdate: record(\"StatusUpdate\") };\n\n expect(() =>\n resolveIrInput(\n { latestVersion: 1, chain: [{ version: 1, ir: { ...ir(1), models } }] },\n \"chain.json\",\n )\n )\n .toThrow(\n `\"StatusUpdate_v1\" for both record \"Status\" (v1 write type) and record \"StatusUpdate\" (v1 type)`,\n );\n });\n\n it.each([\n [\"unknown\", \"kind\", `Variant \"unknown\" in union \"Shape\" uses a reserved name.`],\n [\"Unknown\", \"kind\", `Variant \"Unknown\" in union \"Shape\" uses a reserved name.`],\n [\"_unknown\", \"kind\", `Variant \"_unknown\" in union \"Shape\" uses a reserved name.`],\n [\"box\", \"rawValue\", `Union \"Shape\" can't use \"rawValue\" as its discriminant.`],\n ])(\n \"rejects JSON union variant %s and discriminant %s when reserved\",\n (variantKey, discriminant, message) => {\n const models: Record<string, IModelDef> = {\n Box: record(\"Box\"),\n Shape: {\n type: \"union\",\n union: {\n key: \"Shape\",\n name: \"Shape\",\n discriminant,\n variants: { [variantKey]: \"Box\" },\n metadata: { addedInVersion: 1 },\n },\n },\n };\n\n expect(() =>\n resolveIrInput(\n { latest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AAE,CAAC,CAAC,CAAC;UAAEK;QAAO;MAAE,CAAC;IAAE,CAAC,EACvE,YACF,CACF,CAAC,CAACe,OAAO,CAACM,OAAO,CAAC;EACpB,CACF,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
|
@@ -42,6 +42,8 @@ export async function irDeployHandler(options) {
|
|
|
42
42
|
consola.info(`Reading schema from: ${irPath}`);
|
|
43
43
|
const {
|
|
44
44
|
ir,
|
|
45
|
+
latestVersion,
|
|
46
|
+
latestMinorVersion,
|
|
45
47
|
owningApplicationId
|
|
46
48
|
} = resolveIrInput(JSON.parse(readFileSync(irPath, "utf8")), irPath);
|
|
47
49
|
const fileSystemType = options.fileSystemType ?? "ARTIFACTS";
|
|
@@ -49,6 +51,9 @@ export async function irDeployHandler(options) {
|
|
|
49
51
|
// The first-party publish endpoint expects the nested-union Conjure shape, not the flat OSDK shape.
|
|
50
52
|
await deployFirstParty(options, ir.name, convertIrToConjureSchema(ir), fileSystemType, owningApplicationId);
|
|
51
53
|
} else {
|
|
54
|
+
if (latestMinorVersion > 0) {
|
|
55
|
+
throw new CommanderError(1, "EINVAL", `The first deploy must be a .0 version, but the IR is at ${latestVersion}.${latestMinorVersion}.` + ` Build the IR with \`type-gen schema ir --max-version ${latestVersion}\`, deploy it,` + ` then apply the minor version with \`type-gen ir update-schema\`.`);
|
|
56
|
+
}
|
|
52
57
|
await deployThirdParty(options, ir.name, convertIrToWireSchema(ir), fileSystemType);
|
|
53
58
|
}
|
|
54
59
|
} catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"irDeployHandler.js","names":["createPlatformClient","DocumentTypes","CommanderError","consola","readFileSync","resolve","convertIrToConjureSchema","convertIrToWireSchema","resolveIrInput","irDeployHandler","options","irPath","ir","info","owningApplicationId","JSON","parse","fileSystemType","firstParty","deployFirstParty","name","deployThirdParty","error","schema","parentFolder","osdkClient","baseUrl","Promise","auth","request","parentFolderRid","result","create","preview","success","firstPartyApiUrl","length","ontologyRid","warn","firstPartyPrefix","url","replace","body","storage","type","yjs","response","fetch","method","headers","stringify","ok","errorBody","json","catch","undefined","errorName","status","instance","errorInstanceId"],"sources":["irDeployHandler.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createPlatformClient } from \"@osdk/client\";\nimport type { CreateDocumentTypeRequest, FileSystemType } from \"@osdk/foundry.pack\";\nimport { DocumentTypes } from \"@osdk/foundry.pack\";\nimport { CommanderError } from \"commander\";\nimport { consola } from \"consola\";\nimport { readFileSync } from \"fs\";\nimport { resolve } from \"path\";\nimport type { ConjureDocumentTypeSchema } from \"../../utils/ir/convertIrToConjureSchema.js\";\nimport { convertIrToConjureSchema } from \"../../utils/ir/convertIrToConjureSchema.js\";\nimport { convertIrToWireSchema } from \"../../utils/ir/convertIrToWireSchema.js\";\nimport { resolveIrInput } from \"./resolveIrInput.js\";\n\ninterface DeployOptions {\n readonly ir: string;\n readonly baseUrl: string;\n readonly auth: string;\n readonly fileSystemType?: FileSystemType;\n readonly firstParty?: boolean;\n /** Required for third-party deploys. */\n readonly parentFolder?: string;\n /** Deprecated/ignored for first-party deploys (publish has no ontology binding); kept so existing invocations don't fail. */\n readonly ontologyRid?: string;\n /** Deprecated/ignored; first-party deploys call the first-party API directly (use firstPartyApiUrl). Kept so existing invocations don't fail. */\n readonly firstPartyPrefix?: string;\n /**\n * First-party document type REST API base URL, REQUIRED for first-party deploys. The context path\n * is installation-dependent, so pass the value for your stack.\n */\n readonly firstPartyApiUrl?: string;\n}\n\n/**\n * Handler for `ir deploy`, which creates a document type from a resolved IR.\n *\n * - Third-party (default): creates a versioned document type via the public OSDK\n * (`DocumentTypes.create`) under `--parent-folder`.\n * - First-party (`--first-party`): publishes a global, name-keyed type in DEV MODE via the\n * first-party document type API. The schema is unversioned (dev sentinel, version -1), no RID is\n * minted, and re-running with the same name overwrites the definition so you can iterate freely.\n * This path is dev-only — promoting a type to a real, versioned schema is done separately via an\n * asset deploy, not this command.\n *\n * When you call create for this new doc-type, a RID is minted in the resolved ontology.\n */\nexport async function irDeployHandler(options: DeployOptions): Promise<void> {\n try {\n const irPath = resolve(options.ir);\n consola.info(`Reading schema from: ${irPath}`);\n\n const { ir, owningApplicationId } = resolveIrInput(\n JSON.parse(readFileSync(irPath, \"utf8\")) as unknown,\n irPath,\n );\n const fileSystemType = options.fileSystemType ?? \"ARTIFACTS\";\n\n if (options.firstParty) {\n // The first-party publish endpoint expects the nested-union Conjure shape, not the flat OSDK shape.\n await deployFirstParty(\n options,\n ir.name,\n convertIrToConjureSchema(ir),\n fileSystemType,\n owningApplicationId,\n );\n } else {\n await deployThirdParty(options, ir.name, convertIrToWireSchema(ir), fileSystemType);\n }\n } catch (error) {\n if (error instanceof CommanderError) {\n throw error;\n }\n consola.error(\"❌ Error during Deploy:\", error);\n throw new CommanderError(1, \"ERRIRMDEPLOY\", \"Error deploying IR document schema\");\n }\n}\n\ntype DocumentTypeSchema = CreateDocumentTypeRequest[\"schema\"];\n\nasync function deployThirdParty(\n options: DeployOptions,\n name: string,\n schema: DocumentTypeSchema,\n fileSystemType: FileSystemType,\n): Promise<void> {\n if (options.parentFolder == null) {\n throw new CommanderError(\n 1,\n \"EINVAL\",\n \"--parent-folder is required when deploying a third-party document type\",\n );\n }\n\n const osdkClient = createPlatformClient(options.baseUrl, () => Promise.resolve(options.auth));\n\n const request: CreateDocumentTypeRequest = {\n name,\n parentFolderRid: options.parentFolder,\n schema,\n fileSystemType,\n };\n\n consola.info(\"Creating document type with schema\", request);\n const result = await DocumentTypes.create(osdkClient, request, { preview: true });\n consola.success(\"Successfully created document type\", result);\n}\n\n/** Subset of the Conjure error body that we surface to the user. */\ninterface ConjureErrorBody {\n readonly errorName?: string;\n readonly errorInstanceId?: string;\n}\n\n/**\n * Publishes a global, name-keyed first-party document type in DEV MODE, via the internal-only\n * `publishFirstPartyDocumentType` endpoint (a direct authenticated PUT to the first-party Conjure\n * REST API — this is not part of the public Foundry API / OSDK, and its generated client lives in\n * an internal registry this public package cannot depend on).\n *\n * Dev-mode semantics: the schema is recorded unversioned at the dev sentinel (version -1), no RID\n * is minted, and the per-ontology instance is created lazily on first document creation. Re-running\n * with the SAME document type name overwrites the definition, so you can iterate on the schema\n * freely — there is no version bump or backwards-compatibility check until the type graduates to a\n * real version via an asset deploy.\n *\n * Note: a name that already exists as an old-world RID-keyed (non-dev) type is rejected until the\n * one-time backfill migrates it into the asset store; brand-new names publish immediately.\n */\nasync function deployFirstParty(\n options: DeployOptions,\n name: string,\n schema: ConjureDocumentTypeSchema,\n fileSystemType: FileSystemType,\n owningApplicationId: string | undefined,\n): Promise<void> {\n if (options.firstPartyApiUrl == null || options.firstPartyApiUrl.length === 0) {\n throw new CommanderError(\n 1,\n \"EINVAL\",\n \"--first-party-api-url is required for first-party deploys. Pass your stack's first-party \"\n + \"document type REST API base URL.\",\n );\n }\n if (options.ontologyRid != null) {\n consola.warn(\n \"--ontology-rid is ignored for first-party deploys: publishFirstPartyDocumentType has no \"\n + \"ontology binding (the per-ontology instance is created lazily on first document creation).\",\n );\n }\n if (options.firstPartyPrefix != null) {\n consola.warn(\n \"--first-party-prefix is ignored: first-party deploys now call the first-party API directly. \"\n + \"Pass its base URL via --first-party-api-url instead.\",\n );\n }\n\n const url = options.firstPartyApiUrl.replace(/\\/+$/, \"\") + \"/publish-first-party-document-type\";\n\n // Conjure wire shape for PublishFirstPartyDocumentTypeRequest; the yjs storage union serializes\n // as { type: \"yjs\", yjs: { schema } }.\n const body = {\n name,\n storage: { type: \"yjs\", yjs: { schema } },\n fileSystemType,\n ...(owningApplicationId != null ? { owningApplicationId } : {}),\n };\n\n consola.info(\"Publishing first-party document type\", { name, url });\n const response = await fetch(url, {\n method: \"PUT\",\n headers: {\n \"Authorization\": `Bearer ${options.auth}`,\n \"Content-Type\": \"application/json\",\n \"Accept\": \"application/json\",\n },\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n const errorBody = (await response.json().catch(() => undefined)) as\n | ConjureErrorBody\n | undefined;\n const errorName = errorBody?.errorName ?? `HTTP ${response.status}`;\n const instance = errorBody?.errorInstanceId != null ? ` [${errorBody.errorInstanceId}]` : \"\";\n consola.error(`❌ Error during first-party publish: ${errorName}${instance}`);\n throw new CommanderError(1, \"ERRFPPUBLISH\", errorName);\n }\n\n const result = (await response.json()) as { name: string };\n consola.success(`Successfully published first-party document type '${result.name}'`);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,oBAAoB,QAAQ,cAAc;AAEnD,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,cAAc,QAAQ,WAAW;AAC1C,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,YAAY,QAAQ,IAAI;AACjC,SAASC,OAAO,QAAQ,MAAM;AAE9B,SAASC,wBAAwB,QAAQ,4CAA4C;AACrF,SAASC,qBAAqB,QAAQ,yCAAyC;AAC/E,SAASC,cAAc,QAAQ,qBAAqB;AAqBpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,eAAeA,CAACC,OAAsB,EAAiB;EAC3E,IAAI;IACF,MAAMC,MAAM,GAAGN,OAAO,CAACK,OAAO,CAACE,EAAE,CAAC;IAClCT,OAAO,CAACU,IAAI,CAAC,wBAAwBF,MAAM,EAAE,CAAC;IAE9C,MAAM;MAAEC,EAAE;MAAEE;IAAoB,CAAC,GAAGN,cAAc,CAChDO,IAAI,CAACC,KAAK,CA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G,EAAE;IAChCQ,MAAM,EAAE,KAAK;IACbC,OAAO,EAAE;MACP,eAAe,EAAE,UAAUvC,OAAO,CAACkB,IAAI,EAAE;MACzC,cAAc,EAAE,kBAAkB;MAClC,QAAQ,EAAE;IACZ,CAAC;IACDc,IAAI,EAAE3B,IAAI,CAACmC,SAAS,CAACR,IAAI;EAC3B,CAAC,CAAC;EAEF,IAAI,CAACI,QAAQ,CAACK,EAAE,EAAE;IAChB,MAAMC,SAAS,GAAI,MAAMN,QAAQ,CAACO,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,MAAMC,SAAS,CAEjD;IACb,MAAMC,SAAS,GAAGJ,SAAS,EAAEI,SAAS,IAAI,QAAQV,QAAQ,CAACW,MAAM,EAAE;IACnE,MAAMC,QAAQ,GAAGN,SAAS,EAAEO,eAAe,IAAI,IAAI,GAAG,KAAKP,SAAS,CAACO,eAAe,GAAG,GAAG,EAAE;IAC5FxD,OAAO,CAACmB,KAAK,CAAC,uCAAuCkC,SAAS,GAAGE,QAAQ,EAAE,CAAC;IAC5E,MAAM,IAAIxD,cAAc,CAAC,CAAC,EAAE,cAAc,EAAEsD,SAAS,CAAC;EACxD;EAEA,MAAMzB,MAAM,GAAI,MAAMe,QAAQ,CAACO,IAAI,CAAC,CAAsB;EAC1DlD,OAAO,CAAC+B,OAAO,CAAC,qDAAqDH,MAAM,CAACX,IAAI,GAAG,CAAC;AACtF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"irDeployHandler.js","names":["createPlatformClient","DocumentTypes","CommanderError","consola","readFileSync","resolve","convertIrToConjureSchema","convertIrToWireSchema","resolveIrInput","irDeployHandler","options","irPath","ir","info","latestVersion","latestMinorVersion","owningApplicationId","JSON","parse","fileSystemType","firstParty","deployFirstParty","name","deployThirdParty","error","schema","parentFolder","osdkClient","baseUrl","Promise","auth","request","parentFolderRid","result","create","preview","success","firstPartyApiUrl","length","ontologyRid","warn","firstPartyPrefix","url","replace","body","storage","type","yjs","response","fetch","method","headers","stringify","ok","errorBody","json","catch","undefined","errorName","status","instance","errorInstanceId"],"sources":["irDeployHandler.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createPlatformClient } from \"@osdk/client\";\nimport type { CreateDocumentTypeRequest, FileSystemType } from \"@osdk/foundry.pack\";\nimport { DocumentTypes } from \"@osdk/foundry.pack\";\nimport { CommanderError } from \"commander\";\nimport { consola } from \"consola\";\nimport { readFileSync } from \"fs\";\nimport { resolve } from \"path\";\nimport type { ConjureDocumentTypeSchema } from \"../../utils/ir/convertIrToConjureSchema.js\";\nimport { convertIrToConjureSchema } from \"../../utils/ir/convertIrToConjureSchema.js\";\nimport { convertIrToWireSchema } from \"../../utils/ir/convertIrToWireSchema.js\";\nimport { resolveIrInput } from \"./resolveIrInput.js\";\n\ninterface DeployOptions {\n readonly ir: string;\n readonly baseUrl: string;\n readonly auth: string;\n readonly fileSystemType?: FileSystemType;\n readonly firstParty?: boolean;\n /** Required for third-party deploys. */\n readonly parentFolder?: string;\n /** Deprecated/ignored for first-party deploys (publish has no ontology binding); kept so existing invocations don't fail. */\n readonly ontologyRid?: string;\n /** Deprecated/ignored; first-party deploys call the first-party API directly (use firstPartyApiUrl). Kept so existing invocations don't fail. */\n readonly firstPartyPrefix?: string;\n /**\n * First-party document type REST API base URL, REQUIRED for first-party deploys. The context path\n * is installation-dependent, so pass the value for your stack.\n */\n readonly firstPartyApiUrl?: string;\n}\n\n/**\n * Handler for `ir deploy`, which creates a document type from a resolved IR.\n *\n * - Third-party (default): creates a versioned document type via the public OSDK\n * (`DocumentTypes.create`) under `--parent-folder`.\n * - First-party (`--first-party`): publishes a global, name-keyed type in DEV MODE via the\n * first-party document type API. The schema is unversioned (dev sentinel, version -1), no RID is\n * minted, and re-running with the same name overwrites the definition so you can iterate freely.\n * This path is dev-only — promoting a type to a real, versioned schema is done separately via an\n * asset deploy, not this command.\n *\n * When you call create for this new doc-type, a RID is minted in the resolved ontology.\n */\nexport async function irDeployHandler(options: DeployOptions): Promise<void> {\n try {\n const irPath = resolve(options.ir);\n consola.info(`Reading schema from: ${irPath}`);\n\n const { ir, latestVersion, latestMinorVersion, owningApplicationId } = resolveIrInput(\n JSON.parse(readFileSync(irPath, \"utf8\")) as unknown,\n irPath,\n );\n const fileSystemType = options.fileSystemType ?? \"ARTIFACTS\";\n\n if (options.firstParty) {\n // The first-party publish endpoint expects the nested-union Conjure shape, not the flat OSDK shape.\n await deployFirstParty(\n options,\n ir.name,\n convertIrToConjureSchema(ir),\n fileSystemType,\n owningApplicationId,\n );\n } else {\n if (latestMinorVersion > 0) {\n throw new CommanderError(\n 1,\n \"EINVAL\",\n `The first deploy must be a .0 version, but the IR is at ${latestVersion}.${latestMinorVersion}.`\n + ` Build the IR with \\`type-gen schema ir --max-version ${latestVersion}\\`, deploy it,`\n + ` then apply the minor version with \\`type-gen ir update-schema\\`.`,\n );\n }\n await deployThirdParty(options, ir.name, convertIrToWireSchema(ir), fileSystemType);\n }\n } catch (error) {\n if (error instanceof CommanderError) {\n throw error;\n }\n consola.error(\"❌ Error during Deploy:\", error);\n throw new CommanderError(1, \"ERRIRMDEPLOY\", \"Error deploying IR document schema\");\n }\n}\n\ntype DocumentTypeSchema = CreateDocumentTypeRequest[\"schema\"];\n\nasync function deployThirdParty(\n options: DeployOptions,\n name: string,\n schema: DocumentTypeSchema,\n fileSystemType: FileSystemType,\n): Promise<void> {\n if (options.parentFolder == null) {\n throw new CommanderError(\n 1,\n \"EINVAL\",\n \"--parent-folder is required when deploying a third-party document type\",\n );\n }\n\n const osdkClient = createPlatformClient(options.baseUrl, () => Promise.resolve(options.auth));\n\n const request: CreateDocumentTypeRequest = {\n name,\n parentFolderRid: options.parentFolder,\n schema,\n fileSystemType,\n };\n\n consola.info(\"Creating document type with schema\", request);\n const result = await DocumentTypes.create(osdkClient, request, { preview: true });\n consola.success(\"Successfully created document type\", result);\n}\n\n/** Subset of the Conjure error body that we surface to the user. */\ninterface ConjureErrorBody {\n readonly errorName?: string;\n readonly errorInstanceId?: string;\n}\n\n/**\n * Publishes a global, name-keyed first-party document type in DEV MODE, via the internal-only\n * `publishFirstPartyDocumentType` endpoint (a direct authenticated PUT to the first-party Conjure\n * REST API — this is not part of the public Foundry API / OSDK, and its generated client lives in\n * an internal registry this public package cannot depend on).\n *\n * Dev-mode semantics: the schema is recorded unversioned at the dev sentinel (version -1), no RID\n * is minted, and the per-ontology instance is created lazily on first document creation. Re-running\n * with the SAME document type name overwrites the definition, so you can iterate on the schema\n * freely — there is no version bump or backwards-compatibility check until the type graduates to a\n * real version via an asset deploy.\n *\n * Note: a name that already exists as an old-world RID-keyed (non-dev) type is rejected until the\n * one-time backfill migrates it into the asset store; brand-new names publish immediately.\n */\nasync function deployFirstParty(\n options: DeployOptions,\n name: string,\n schema: ConjureDocumentTypeSchema,\n fileSystemType: FileSystemType,\n owningApplicationId: string | undefined,\n): Promise<void> {\n if (options.firstPartyApiUrl == null || options.firstPartyApiUrl.length === 0) {\n throw new CommanderError(\n 1,\n \"EINVAL\",\n \"--first-party-api-url is required for first-party deploys. Pass your stack's first-party \"\n + \"document type REST API base URL.\",\n );\n }\n if (options.ontologyRid != null) {\n consola.warn(\n \"--ontology-rid is ignored for first-party deploys: publishFirstPartyDocumentType has no \"\n + \"ontology binding (the per-ontology instance is created lazily on first document creation).\",\n );\n }\n if (options.firstPartyPrefix != null) {\n consola.warn(\n \"--first-party-prefix is ignored: first-party deploys now call the first-party API directly. \"\n + \"Pass its base URL via --first-party-api-url instead.\",\n );\n }\n\n const url = options.firstPartyApiUrl.replace(/\\/+$/, \"\") + \"/publish-first-party-document-type\";\n\n // Conjure wire shape for PublishFirstPartyDocumentTypeRequest; the yjs storage union serializes\n // as { type: \"yjs\", yjs: { schema } }.\n const body = {\n name,\n storage: { type: \"yjs\", yjs: { schema } },\n fileSystemType,\n ...(owningApplicationId != null ? { owningApplicationId } : {}),\n };\n\n consola.info(\"Publishing first-party document type\", { name, url });\n const response = await fetch(url, {\n method: \"PUT\",\n headers: {\n \"Authorization\": `Bearer ${options.auth}`,\n \"Content-Type\": \"application/json\",\n \"Accept\": \"application/json\",\n },\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n const errorBody = (await response.json().catch(() => undefined)) as\n | ConjureErrorBody\n | undefined;\n const errorName = errorBody?.errorName ?? `HTTP ${response.status}`;\n const instance = errorBody?.errorInstanceId != null ? ` [${errorBody.errorInstanceId}]` : \"\";\n consola.error(`❌ Error during first-party publish: ${errorName}${instance}`);\n throw new CommanderError(1, \"ERRFPPUBLISH\", errorName);\n }\n\n const result = (await response.json()) as { name: string };\n consola.success(`Successfully published first-party document type '${result.name}'`);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,oBAAoB,QAAQ,cAAc;AAEnD,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,cAAc,QAAQ,WAAW;AAC1C,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,YAAY,QAAQ,IAAI;AACjC,SAASC,OAAO,QAAQ,MAAM;AAE9B,SAASC,wBAAwB,QAAQ,4CAA4C;AACrF,SAASC,qBAAqB,QAAQ,yCAAyC;AAC/E,SAASC,cAAc,QAAQ,qBAAqB;AAqBpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,eAAeA,CAACC,OAAsB,EAAiB;EAC3E,IAAI;IACF,MAAMC,MAAM,GAAGN,OAAO,CAACK,OAA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AAI,GAAG,CAAC;AACtF","ignoreList":[]}
|
|
@@ -20,6 +20,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
|
20
20
|
import { basename, dirname, extname, join, resolve } from "path";
|
|
21
21
|
import { GENERATED_JSON_COMMENT } from "../../utils/generatedFileHeader.js";
|
|
22
22
|
import { convertIrToWireSchema } from "../../utils/ir/convertIrToWireSchema.js";
|
|
23
|
+
import { formatSchemaVersion } from "../../utils/schema/resolveSchemaChain.js";
|
|
23
24
|
import { resolveIrInput } from "./resolveIrInput.js";
|
|
24
25
|
function deriveCompatibilityRangePath(assetOutputPath) {
|
|
25
26
|
const stem = basename(assetOutputPath, extname(assetOutputPath));
|
|
@@ -63,6 +64,7 @@ export function irGenAssetHandler(options) {
|
|
|
63
64
|
const {
|
|
64
65
|
ir: irSchema,
|
|
65
66
|
latestVersion,
|
|
67
|
+
latestMinorVersion,
|
|
66
68
|
minSupportedVersion,
|
|
67
69
|
owningApplicationId
|
|
68
70
|
} = resolved;
|
|
@@ -83,6 +85,9 @@ export function irGenAssetHandler(options) {
|
|
|
83
85
|
},
|
|
84
86
|
fileSystemType,
|
|
85
87
|
schemaVersion: latestVersion,
|
|
88
|
+
...(latestMinorVersion > 0 ? {
|
|
89
|
+
schemaMinorVersion: latestMinorVersion
|
|
90
|
+
} : {}),
|
|
86
91
|
...(owningApplicationId != null ? {
|
|
87
92
|
owningApplicationId
|
|
88
93
|
} : {}),
|
|
@@ -119,7 +124,7 @@ export function irGenAssetHandler(options) {
|
|
|
119
124
|
consola.info(` Output: ${outputPath}`);
|
|
120
125
|
consola.info(` Compatibility range output: ${compatibilityRangePath}`);
|
|
121
126
|
consola.info(` Document type: ${documentTypeName}`);
|
|
122
|
-
consola.info(` Schema version: ${latestVersion}`);
|
|
127
|
+
consola.info(` Schema version: ${formatSchemaVersion(latestVersion, latestMinorVersion)}`);
|
|
123
128
|
consola.info(` Compatibility range: [${minSupportedVersion}, ${latestVersion}]`);
|
|
124
129
|
consola.info(` File system type: ${fileSystemType}`);
|
|
125
130
|
if (owningApplicationId != null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"irGenAssetHandler.js","names":["CommanderError","consola","existsSync","mkdirSync","readFileSync","writeFileSync","basename","dirname","extname","join","resolve","GENERATED_JSON_COMMENT","convertIrToWireSchema","resolveIrInput","deriveCompatibilityRangePath","assetOutputPath","stem","irGenAssetHandler","options","irPath","ir","outputPath","output","info","parsed","JSON","parse","resolved","irSchema","latestVersion","minSupportedVersion","owningApplicationId","name","documentTypeName","wireSchema","fileSystemType","asset","comment","documentStorageType","type","schema","schemaVersion","forceOverwrite","warn","outputDir","recursive","stringify","compatibilityRangePath","compatibilityRangeOutput","compatibilityRangeDir","min","max","success","error"],"sources":["irGenAssetHandler.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { DocumentTypeAsset, FileSystemType } from \"@osdk/foundry.pack\";\nimport { CommanderError } from \"commander\";\nimport { consola } from \"consola\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"fs\";\nimport { basename, dirname, extname, join, resolve } from \"path\";\nimport { GENERATED_JSON_COMMENT } from \"../../utils/generatedFileHeader.js\";\nimport { convertIrToWireSchema } from \"../../utils/ir/convertIrToWireSchema.js\";\nimport { resolveIrInput } from \"./resolveIrInput.js\";\n\ninterface IrGenAssetOptions {\n readonly ir: string;\n readonly output: string;\n readonly fileSystemType?: FileSystemType;\n readonly compatibilityRangeOutput?: string;\n readonly forceOverwrite?: boolean;\n}\n\ninterface SchemaCompatibilityRangeFile {\n readonly min: number;\n readonly max: number;\n}\n\nfunction deriveCompatibilityRangePath(assetOutputPath: string): string {\n const stem = basename(assetOutputPath, extname(assetOutputPath));\n return join(dirname(assetOutputPath), `${stem}-schema-compatibility-range.json`);\n}\n\n/**\n * Generates a document type asset JSON file (and a sibling schema\n * compatibility range JSON file) from an IR schema.\n *\n * The input IR may be either:\n * - a chain payload `{ latestVersion, minSupportedVersion?, chain }` produced\n * by `schema ir`. The latest entry's `ir` is used as the wire schema; the\n * asset's `schemaVersion` is `latestVersion`; the compatibility range is\n * `{ min: minSupportedVersion ?? latestVersion, max: latestVersion }`.\n * - a bare single-version `IRealTimeDocumentSchema` (legacy). The compat\n * range defaults to `{ min: version, max: version }` since no chain\n * information is available.\n *\n * This command is intended for internal platform applications where the\n * document type asset must exist on disk so the platform can discover it and\n * register the document type automatically at deploy time. Most users should\n * use `ir deploy` to register document types via the Foundry API instead.\n *\n * `--force-overwrite` writes `forceOverwrite: true` onto the asset, telling the\n * platform to skip incremental schema validation when it picks the asset up. It\n * is a transient processing directive, not persisted with the document type.\n *\n * If you are unsure whether you need this command, you almost certainly do not.\n */\nexport function irGenAssetHandler(options: IrGenAssetOptions): void {\n try {\n const irPath = resolve(options.ir);\n const outputPath = resolve(options.output);\n\n if (!existsSync(irPath)) {\n throw new CommanderError(1, \"ENOENT\", `IR file does not exist: ${irPath}`);\n }\n\n consola.info(`Reading IR schema from: ${irPath}`);\n const parsed = JSON.parse(readFileSync(irPath, \"utf8\")) as unknown;\n\n const resolved = resolveIrInput(parsed, irPath);\n\n const { ir: irSchema, latestVersion, minSupportedVersion, owningApplicationId } = resolved;\n const { name: documentTypeName } = irSchema;\n const wireSchema = convertIrToWireSchema(irSchema);\n\n const fileSystemType = options.fileSystemType ?? \"ARTIFACTS\";\n if (fileSystemType !== \"ARTIFACTS\" && fileSystemType !== \"COMPASS\") {\n throw new CommanderError(\n 1,\n \"EINVAL\",\n `Invalid fileSystemType \"${fileSystemType}\". Must be \"ARTIFACTS\" or \"COMPASS\".`,\n );\n }\n\n const asset: DocumentTypeAsset = {\n comment: GENERATED_JSON_COMMENT,\n documentTypeName,\n documentStorageType: {\n type: \"yjs\",\n schema: wireSchema,\n },\n fileSystemType,\n schemaVersion: latestVersion,\n ...(owningApplicationId != null ? { owningApplicationId } : {}),\n ...(options.forceOverwrite ? { forceOverwrite: true } : {}),\n };\n\n if (options.forceOverwrite) {\n consola.warn(\n \"--force-overwrite is set: the platform will skip backwards-compatibility validation when processing this asset.\",\n );\n }\n\n const outputDir = dirname(outputPath);\n if (!existsSync(outputDir)) {\n mkdirSync(outputDir, { recursive: true });\n }\n writeFileSync(outputPath, JSON.stringify(asset, null, 2), \"utf8\");\n\n const compatibilityRange: SchemaCompatibilityRangeFile = {\n min: minSupportedVersion,\n max: latestVersion,\n };\n const compatibilityRangePath = resolve(\n options.compatibilityRangeOutput ?? deriveCompatibilityRangePath(outputPath),\n );\n const compatibilityRangeDir = dirname(compatibilityRangePath);\n if (!existsSync(compatibilityRangeDir)) {\n mkdirSync(compatibilityRangeDir, { recursive: true });\n }\n const compatibilityRangeOutput = {\n comment: GENERATED_JSON_COMMENT,\n ...compatibilityRange,\n };\n writeFileSync(\n compatibilityRangePath,\n JSON.stringify(compatibilityRangeOutput, null, 2),\n \"utf8\",\n );\n\n consola.success(\"Successfully generated document type asset\");\n consola.info(` Output: ${outputPath}`);\n consola.info(` Compatibility range output: ${compatibilityRangePath}`);\n consola.info(` Document type: ${documentTypeName}`);\n consola.info(` Schema version: ${latestVersion}`);\n consola.info(` Compatibility range: [${minSupportedVersion}, ${latestVersion}]`);\n consola.info(` File system type: ${fileSystemType}`);\n if (owningApplicationId != null) {\n consola.info(` Owning application id: ${owningApplicationId}`);\n }\n if (options.forceOverwrite) {\n consola.info(\" Force overwrite: true\");\n }\n } catch (error) {\n if (error instanceof CommanderError) {\n throw error;\n }\n consola.error(\"Error generating document type asset:\", error);\n throw new CommanderError(1, \"IR_ASSET_ERROR\", \"Failed to generate document type asset\");\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,cAAc,QAAQ,WAAW;AAC1C,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,UAAU,EAAEC,SAAS,EAAEC,YAAY,EAAEC,aAAa,QAAQ,IAAI;AACvE,SAASC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,EAAEC,IAAI,EAAEC,OAAO,QAAQ,MAAM;AAChE,SAASC,sBAAsB,QAAQ,oCAAoC;AAC3E,SAASC,qBAAqB,QAAQ,yCAAyC;AAC/E,SAASC,cAAc,QAAQ,qBAAqB;AAepD,SAASC,4BAA4BA,CAACC,eAAuB,EAAU;EACrE,MAAMC,IAAI,GAAGV,QAAQ,CAACS,eAAe,EAAEP,OAAO,CAACO,eAAe,CAAC,CAAC;EAChE,OAAON,IAAI,CAACF,OAAO,CAACQ,eAAe,CAAC,EAAE,GAAGC,IAAI,kCAAkC,CAAC;AAClF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAACC,OAA0B,EAAQ;EAClE,IAAI;IACF,MAAMC,MAAM,GAAGT,OAAO,CAACQ,OAAO,CAACE,EAAE,CAAC;IAClC,MAAMC,UAAU,GAAGX,OAAO,CAACQ,OAAO,CAACI,MAAM,CAAC;IAE1C,IAAI,CAACpB,UAAU,CAACiB,MAAM,CAAC,EAAE;MACvB,MAAM,IAAInB,cAAc,CAAC,CAAC,EAAE,QAAQ,EAAE,2BAA2BmB,MAAM,EAAE,CAAC;IAC5E;IAEAlB,OAAO,CAACsB,IAAI,CAAC,2BAA2BJ,MAAM,EAAE,CAAC;IACjD,MAAMK,MAAM,GAAGC,IAAI,CAACC,KAAK,CAACtB,YAAY,CAACe,M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AAO,CAACsB,IAAI,CAAC,0BAA0B,CAAC;IAC1C;EACF,CAAC,CAAC,OAAO8B,KAAK,EAAE;IACd,IAAIA,KAAK,YAAYrD,cAAc,EAAE;MACnC,MAAMqD,KAAK;IACb;IACApD,OAAO,CAACoD,KAAK,CAAC,uCAAuC,EAAEA,KAAK,CAAC;IAC7D,MAAM,IAAIrD,cAAc,CAAC,CAAC,EAAE,gBAAgB,EAAE,wCAAwC,CAAC;EACzF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"irGenAssetHandler.js","names":["CommanderError","consola","existsSync","mkdirSync","readFileSync","writeFileSync","basename","dirname","extname","join","resolve","GENERATED_JSON_COMMENT","convertIrToWireSchema","formatSchemaVersion","resolveIrInput","deriveCompatibilityRangePath","assetOutputPath","stem","irGenAssetHandler","options","irPath","ir","outputPath","output","info","parsed","JSON","parse","resolved","irSchema","latestVersion","latestMinorVersion","minSupportedVersion","owningApplicationId","name","documentTypeName","wireSchema","fileSystemType","asset","comment","documentStorageType","type","schema","schemaVersion","schemaMinorVersion","forceOverwrite","warn","outputDir","recursive","stringify","compatibilityRangePath","compatibilityRangeOutput","compatibilityRangeDir","min","max","success","error"],"sources":["irGenAssetHandler.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { DocumentTypeAsset, FileSystemType } from \"@osdk/foundry.pack\";\nimport { CommanderError } from \"commander\";\nimport { consola } from \"consola\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"fs\";\nimport { basename, dirname, extname, join, resolve } from \"path\";\nimport { GENERATED_JSON_COMMENT } from \"../../utils/generatedFileHeader.js\";\nimport { convertIrToWireSchema } from \"../../utils/ir/convertIrToWireSchema.js\";\nimport { formatSchemaVersion } from \"../../utils/schema/resolveSchemaChain.js\";\nimport { resolveIrInput } from \"./resolveIrInput.js\";\n\ninterface IrGenAssetOptions {\n readonly ir: string;\n readonly output: string;\n readonly fileSystemType?: FileSystemType;\n readonly compatibilityRangeOutput?: string;\n readonly forceOverwrite?: boolean;\n}\n\ninterface SchemaCompatibilityRangeFile {\n readonly min: number;\n readonly max: number;\n}\n\nfunction deriveCompatibilityRangePath(assetOutputPath: string): string {\n const stem = basename(assetOutputPath, extname(assetOutputPath));\n return join(dirname(assetOutputPath), `${stem}-schema-compatibility-range.json`);\n}\n\n/**\n * Generates a document type asset JSON file (and a sibling schema\n * compatibility range JSON file) from an IR schema.\n *\n * The input IR may be either:\n * - a chain payload `{ latestVersion, minSupportedVersion?, chain }` produced\n * by `schema ir`. The latest entry's `ir` is used as the wire schema; the\n * asset's `schemaVersion` is `latestVersion`; the compatibility range is\n * `{ min: minSupportedVersion ?? latestVersion, max: latestVersion }`.\n * - a bare single-version `IRealTimeDocumentSchema` (legacy). The compat\n * range defaults to `{ min: version, max: version }` since no chain\n * information is available.\n *\n * This command is intended for internal platform applications where the\n * document type asset must exist on disk so the platform can discover it and\n * register the document type automatically at deploy time. Most users should\n * use `ir deploy` to register document types via the Foundry API instead.\n *\n * `--force-overwrite` writes `forceOverwrite: true` onto the asset, telling the\n * platform to skip incremental schema validation when it picks the asset up. It\n * is a transient processing directive, not persisted with the document type.\n *\n * If you are unsure whether you need this command, you almost certainly do not.\n */\nexport function irGenAssetHandler(options: IrGenAssetOptions): void {\n try {\n const irPath = resolve(options.ir);\n const outputPath = resolve(options.output);\n\n if (!existsSync(irPath)) {\n throw new CommanderError(1, \"ENOENT\", `IR file does not exist: ${irPath}`);\n }\n\n consola.info(`Reading IR schema from: ${irPath}`);\n const parsed = JSON.parse(readFileSync(irPath, \"utf8\")) as unknown;\n\n const resolved = resolveIrInput(parsed, irPath);\n\n const {\n ir: irSchema,\n latestVersion,\n latestMinorVersion,\n minSupportedVersion,\n owningApplicationId,\n } = resolved;\n const { name: documentTypeName } = irSchema;\n const wireSchema = convertIrToWireSchema(irSchema);\n\n const fileSystemType = options.fileSystemType ?? \"ARTIFACTS\";\n if (fileSystemType !== \"ARTIFACTS\" && fileSystemType !== \"COMPASS\") {\n throw new CommanderError(\n 1,\n \"EINVAL\",\n `Invalid fileSystemType \"${fileSystemType}\". Must be \"ARTIFACTS\" or \"COMPASS\".`,\n );\n }\n\n const asset: DocumentTypeAsset = {\n comment: GENERATED_JSON_COMMENT,\n documentTypeName,\n documentStorageType: {\n type: \"yjs\",\n schema: wireSchema,\n },\n fileSystemType,\n schemaVersion: latestVersion,\n ...(latestMinorVersion > 0 ? { schemaMinorVersion: latestMinorVersion } : {}),\n ...(owningApplicationId != null ? { owningApplicationId } : {}),\n ...(options.forceOverwrite ? { forceOverwrite: true } : {}),\n };\n\n if (options.forceOverwrite) {\n consola.warn(\n \"--force-overwrite is set: the platform will skip backwards-compatibility validation when processing this asset.\",\n );\n }\n\n const outputDir = dirname(outputPath);\n if (!existsSync(outputDir)) {\n mkdirSync(outputDir, { recursive: true });\n }\n writeFileSync(outputPath, JSON.stringify(asset, null, 2), \"utf8\");\n\n const compatibilityRange: SchemaCompatibilityRangeFile = {\n min: minSupportedVersion,\n max: latestVersion,\n };\n const compatibilityRangePath = resolve(\n options.compatibilityRangeOutput ?? deriveCompatibilityRangePath(outputPath),\n );\n const compatibilityRangeDir = dirname(compatibilityRangePath);\n if (!existsSync(compatibilityRangeDir)) {\n mkdirSync(compatibilityRangeDir, { recursive: true });\n }\n const compatibilityRangeOutput = {\n comment: GENERATED_JSON_COMMENT,\n ...compatibilityRange,\n };\n writeFileSync(\n compatibilityRangePath,\n JSON.stringify(compatibilityRangeOutput, null, 2),\n \"utf8\",\n );\n\n consola.success(\"Successfully generated document type asset\");\n consola.info(` Output: ${outputPath}`);\n consola.info(` Compatibility range output: ${compatibilityRangePath}`);\n consola.info(` Document type: ${documentTypeName}`);\n consola.info(` Schema version: ${formatSchemaVersion(latestVersion, latestMinorVersion)}`);\n consola.info(` Compatibility range: [${minSupportedVersion}, ${latestVersion}]`);\n consola.info(` File system type: ${fileSystemType}`);\n if (owningApplicationId != null) {\n consola.info(` Owning application id: ${owningApplicationId}`);\n }\n if (options.forceOverwrite) {\n consola.info(\" Force overwrite: true\");\n }\n } catch (error) {\n if (error instanceof CommanderError) {\n throw error;\n }\n consola.error(\"Error generating document type asset:\", error);\n throw new CommanderError(1, \"IR_ASSET_ERROR\", \"Failed to generate document type asset\");\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,cAAc,QAAQ,WAAW;AAC1C,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,UAAU,EAAEC,SAAS,EAAEC,YAAY,EAAEC,aAAa,QAAQ,IAAI;AACvE,SAASC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,EAAEC,IAAI,EAAEC,OAAO,QAAQ,MAAM;AAChE,SAASC,sBAAsB,QAAQ,oCAAoC;AAC3E,SAASC,qBAAqB,QAAQ,yCAAyC;AAC/E,SAASC,mBAAmB,QAAQ,0CAA0C;AAC9E,SAASC,cAAc,QAAQ,qBAAqB;AAepD,SAASC,4BAA4BA,CAACC,eAAuB,EAAU;EACrE,MAAMC,IAAI,GAAGX,QAAQ,CAACU,eAAe,EAAER,OAAO,CAACQ,eAAe,CAAC,CAAC;EAChE,OAAOP,IAAI,CAACF,OAAO,CAACS,eAAe,CAAC,EAAE,GAAGC,IAAI,kCAAkC,CAAC;AAClF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SA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C;IAC7DtD,OAAO,CAACuB,IAAI,CAAC,cAAcF,UAAU,EAAE,CAAC;IACxCrB,OAAO,CAACuB,IAAI,CAAC,kCAAkC0B,sBAAsB,EAAE,CAAC;IACxEjD,OAAO,CAACuB,IAAI,CAAC,qBAAqBW,gBAAgB,EAAE,CAAC;IACrDlC,OAAO,CAACuB,IAAI,CAAC,sBAAsBX,mBAAmB,CAACiB,aAAa,EAAEC,kBAAkB,CAAC,EAAE,CAAC;IAC5F9B,OAAO,CAACuB,IAAI,CAAC,4BAA4BQ,mBAAmB,KAAKF,aAAa,GAAG,CAAC;IAClF7B,OAAO,CAACuB,IAAI,CAAC,wBAAwBa,cAAc,EAAE,CAAC;IACtD,IAAIJ,mBAAmB,IAAI,IAAI,EAAE;MAC/BhC,OAAO,CAACuB,IAAI,CAAC,6BAA6BS,mBAAmB,EAAE,CAAC;IAClE;IACA,IAAId,OAAO,CAAC0B,cAAc,EAAE;MAC1B5C,OAAO,CAACuB,IAAI,CAAC,0BAA0B,CAAC;IAC1C;EACF,CAAC,CAAC,OAAOgC,KAAK,EAAE;IACd,IAAIA,KAAK,YAAYxD,cAAc,EAAE;MACnC,MAAMwD,KAAK;IACb;IACAvD,OAAO,CAACuD,KAAK,CAAC,uCAAuC,EAAEA,KAAK,CAAC;IAC7D,MAAM,IAAIxD,cAAc,CAAC,CAAC,EAAE,gBAAgB,EAAE,wCAAwC,CAAC;EACzF;AACF","ignoreList":[]}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { consola } from "consola";
|
|
18
18
|
import fs from "fs-extra";
|
|
19
19
|
import path from "path";
|
|
20
|
-
import { resolveMinVersion, stripDeprecatedFieldsForSdk } from "../../utils/schema/resolveSchemaChain.js";
|
|
20
|
+
import { collapseChainToMajors, resolveMinVersion, stripDeprecatedFieldsForSdk } from "../../utils/schema/resolveSchemaChain.js";
|
|
21
21
|
import { writeAllSdkFiles } from "../../utils/schema/writeAllSdkFiles.js";
|
|
22
22
|
export async function irGenTypesHandler(options) {
|
|
23
23
|
const {
|
|
@@ -40,12 +40,16 @@ export async function irGenTypesHandler(options) {
|
|
|
40
40
|
latestVersion,
|
|
41
41
|
minVersion
|
|
42
42
|
} = resolveMinVersion(payload.chain, minSupportedVersion);
|
|
43
|
-
|
|
43
|
+
// Types are generated per major, so `chain` merges 3.0, 3.1 and 3.2 into one `3` entry.
|
|
44
|
+
// Upgrade steps compare every version in `stepChain`, so `title` added in 3.2 gets a `v3_2` step.
|
|
45
|
+
const stepChain = stripDeprecatedFieldsForSdk(payload.chain);
|
|
46
|
+
const chain = collapseChainToMajors(stepChain);
|
|
44
47
|
const resolvedOutputDir = path.resolve(outputDir);
|
|
45
48
|
await writeAllSdkFiles({
|
|
46
49
|
chain,
|
|
47
50
|
latestVersion,
|
|
48
|
-
minVersion
|
|
51
|
+
minVersion,
|
|
52
|
+
stepChain
|
|
49
53
|
}, resolvedOutputDir, minSupportedVersion);
|
|
50
54
|
}
|
|
51
55
|
//# sourceMappingURL=irGenTypesHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"irGenTypesHandler.js","names":["consola","fs","path","resolveMinVersion","stripDeprecatedFieldsForSdk","writeAllSdkFiles","irGenTypesHandler","options","schema","schemaPath","output","outputDir","inputPath","resolve","pathExists","Error","info","payload","readJson","Array","isArray","chain","length","minSupportedVersion","latestVersion","minVersion","resolvedOutputDir"],"sources":["irGenTypesHandler.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 { consola } from \"consola\";\nimport fs from \"fs-extra\";\nimport path from \"path\";\nimport {\n type IrChainPayload,\n resolveMinVersion,\n stripDeprecatedFieldsForSdk,\n} from \"../../utils/schema/resolveSchemaChain.js\";\nimport { writeAllSdkFiles } from \"../../utils/schema/writeAllSdkFiles.js\";\n\ninterface IrGenTypesOptions {\n schema: string;\n output: string;\n}\n\nexport async function irGenTypesHandler(options: IrGenTypesOptions): Promise<void> {\n const { schema: schemaPath, output: outputDir } = options;\n\n const inputPath = path.resolve(schemaPath);\n if (!(await fs.pathExists(inputPath))) {\n throw new Error(`Input file not found: ${inputPath}`);\n }\n\n consola.info(`Loading IR chain from: ${inputPath}`);\n const payload = (await fs.readJson(inputPath)) as IrChainPayload;\n\n if (!Array.isArray(payload.chain) || payload.chain.length === 0) {\n throw new Error(`Invalid IR chain payload at ${inputPath}: missing non-empty 'chain' array`);\n }\n\n const { minSupportedVersion } = payload;\n const { latestVersion, minVersion } = resolveMinVersion(payload.chain, minSupportedVersion);\n
|
|
1
|
+
{"version":3,"file":"irGenTypesHandler.js","names":["consola","fs","path","collapseChainToMajors","resolveMinVersion","stripDeprecatedFieldsForSdk","writeAllSdkFiles","irGenTypesHandler","options","schema","schemaPath","output","outputDir","inputPath","resolve","pathExists","Error","info","payload","readJson","Array","isArray","chain","length","minSupportedVersion","latestVersion","minVersion","stepChain","resolvedOutputDir"],"sources":["irGenTypesHandler.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 { consola } from \"consola\";\nimport fs from \"fs-extra\";\nimport path from \"path\";\nimport {\n collapseChainToMajors,\n type IrChainPayload,\n resolveMinVersion,\n stripDeprecatedFieldsForSdk,\n} from \"../../utils/schema/resolveSchemaChain.js\";\nimport { writeAllSdkFiles } from \"../../utils/schema/writeAllSdkFiles.js\";\n\ninterface IrGenTypesOptions {\n schema: string;\n output: string;\n}\n\nexport async function irGenTypesHandler(options: IrGenTypesOptions): Promise<void> {\n const { schema: schemaPath, output: outputDir } = options;\n\n const inputPath = path.resolve(schemaPath);\n if (!(await fs.pathExists(inputPath))) {\n throw new Error(`Input file not found: ${inputPath}`);\n }\n\n consola.info(`Loading IR chain from: ${inputPath}`);\n const payload = (await fs.readJson(inputPath)) as IrChainPayload;\n\n if (!Array.isArray(payload.chain) || payload.chain.length === 0) {\n throw new Error(`Invalid IR chain payload at ${inputPath}: missing non-empty 'chain' array`);\n }\n\n const { minSupportedVersion } = payload;\n const { latestVersion, minVersion } = resolveMinVersion(payload.chain, minSupportedVersion);\n // Types are generated per major, so `chain` merges 3.0, 3.1 and 3.2 into one `3` entry.\n // Upgrade steps compare every version in `stepChain`, so `title` added in 3.2 gets a `v3_2` step.\n const stepChain = stripDeprecatedFieldsForSdk(payload.chain);\n const chain = collapseChainToMajors(stepChain);\n const resolved = { chain, latestVersion, minVersion, stepChain };\n\n const resolvedOutputDir = path.resolve(outputDir);\n await writeAllSdkFiles(resolved, resolvedOutputDir, minSupportedVersion);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,SAAS;AACjC,OAAOC,EAAE,MAAM,UAAU;AACzB,OAAOC,IAAI,MAAM,MAAM;AACvB,SACEC,qBAAqB,EAErBC,iBAAiB,EACjBC,2BAA2B,QACtB,0CAA0C;AACjD,SAASC,gBAAgB,QAAQ,wCAAwC;AAOzE,OAAO,eAAeC,iBAAiBA,CAACC,OAA0B,EAAiB;EACjF,MAAM;IAAEC,MAAM,EAAEC,UAAU;IAAEC,MAAM,EAAEC;EAAU,CAAC,GAAGJ,OAAO;EAEzD,MAAMK,SAAS,GAAGX,IAAI,CAACY,OAAO,CAACJ,UAAU,CAAC;EAC1C,IAAI,EAAE,MAAMT,EAAE,CAACc,UAAU,CAACF,SAAS,CAAC,CAAC,EAAE;IACrC,MAAM,IAAIG,KAAK,CAAC,yBAAyBH,SAAS,EAAE,CAAC;EACvD;EAEAb,OAAO,CAACiB,IAAI,CAAC,0BAA0BJ,SAAS,EAAE,CAAC;EACnD,MAAMK,OAAO,GAAI,MAAMjB,EAAE,CAACkB,QAAQ,CAACN,SAAS,CAAoB;EAEhE,IAAI,CAACO,KAAK,CAACC,OAAO,CAACH,OAAO,CAACI,KAAK,CAAC,IAAIJ,OAAO,CAACI,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE;IAC/D,MAAM,IAAIP,KAAK,CAAC,+BAA+BH,SAAS,mCAAmC,CAAC;EAC9F;EAEA,MAAM;IAAEW;EAAoB,CAAC,GAAGN,OAAO;EACvC,MAAM;IAAEO,aAAa;IAAEC;EAAW,CAAC,GAAGtB,iBAAiB,CAACc,OAAO,CAACI,KAAK,EAAEE,mBAAmB,CAAC;EAC3F;EACA;EACA,MAAMG,SAAS,GAAGtB,2BAA2B,CAACa,OAAO,CAACI,KAAK,CAAC;EAC5D,MAAMA,KAAK,GAAGnB,qBAAqB,CAACwB,SAAS,CAAC;EAG9C,MAAMC,iBAAiB,GAAG1B,IAAI,CAACY,OAAO,CAACF,SAAS,CAAC;EACjD,MAAMN,gBAAgB,CAHL;IAAEgB,KAAK;IAAEG,aAAa;IAAEC,UAAU;IAAEC;EAAU,CAAC,EAG/BC,iBAAiB,EAAEJ,mBAAmB,CAAC;AAC1E","ignoreList":[]}
|
|
@@ -21,6 +21,7 @@ import { consola } from "consola";
|
|
|
21
21
|
import { readFileSync } from "fs";
|
|
22
22
|
import { resolve } from "path";
|
|
23
23
|
import { convertIrToWireSchema } from "../../utils/ir/convertIrToWireSchema.js";
|
|
24
|
+
import { formatSchemaVersion } from "../../utils/schema/resolveSchemaChain.js";
|
|
24
25
|
import { buildPrefixRewriteFetch, DEFAULT_API_PREFIX } from "../utils/firstPartyPrefix.js";
|
|
25
26
|
import { resolveIrInput } from "./resolveIrInput.js";
|
|
26
27
|
/**
|
|
@@ -33,34 +34,40 @@ export async function irUpdateSchemaHandler(options) {
|
|
|
33
34
|
consola.info(`Reading schema from: ${irPath}`);
|
|
34
35
|
const {
|
|
35
36
|
ir,
|
|
36
|
-
latestVersion
|
|
37
|
+
latestVersion,
|
|
38
|
+
latestMinorVersion
|
|
37
39
|
} = resolveIrInput(JSON.parse(readFileSync(irPath, "utf8")), irPath);
|
|
38
40
|
const schema = convertIrToWireSchema(ir);
|
|
41
|
+
const versionLabel = formatSchemaVersion(latestVersion, latestMinorVersion);
|
|
39
42
|
const fetchFn = options.firstPartyPrefix != null ? buildPrefixRewriteFetch(options.firstPartyPrefix) : undefined;
|
|
40
43
|
if (fetchFn != null) {
|
|
41
44
|
consola.info(`Rewriting OSDK '${DEFAULT_API_PREFIX}' -> '${options.firstPartyPrefix}'`);
|
|
42
45
|
}
|
|
43
46
|
const osdkClient = createPlatformClient(options.baseUrl, () => Promise.resolve(options.auth), undefined, fetchFn);
|
|
47
|
+
const requestBody = {
|
|
48
|
+
ontologyRid: options.ontologyRid,
|
|
49
|
+
schema,
|
|
50
|
+
version: latestVersion,
|
|
51
|
+
...(latestMinorVersion > 0 ? {
|
|
52
|
+
schemaMinorVersion: latestMinorVersion
|
|
53
|
+
} : {}),
|
|
54
|
+
...(options.forceOverwrite ? {
|
|
55
|
+
forceOverwrite: true
|
|
56
|
+
} : {})
|
|
57
|
+
};
|
|
44
58
|
const request = {
|
|
45
59
|
documentTypeName: ir.name,
|
|
46
|
-
requestBody
|
|
47
|
-
ontologyRid: options.ontologyRid,
|
|
48
|
-
schema,
|
|
49
|
-
version: latestVersion,
|
|
50
|
-
...(options.forceOverwrite ? {
|
|
51
|
-
forceOverwrite: true
|
|
52
|
-
} : {})
|
|
53
|
-
}
|
|
60
|
+
requestBody
|
|
54
61
|
};
|
|
55
62
|
if (options.forceOverwrite) {
|
|
56
63
|
consola.warn("--force-overwrite is set: backwards-compatibility validation will be skipped.");
|
|
57
64
|
}
|
|
58
|
-
consola.info(`Updating schema for document type "${ir.name}" -> version ${
|
|
65
|
+
consola.info(`Updating schema for document type "${ir.name}" -> version ${versionLabel}`);
|
|
59
66
|
const result = await DocumentTypes.updateSchema(osdkClient, request, {
|
|
60
67
|
preview: true
|
|
61
68
|
});
|
|
62
69
|
if (result.type === "success") {
|
|
63
|
-
consola.success(`Schema updated successfully (version ${result.version})`);
|
|
70
|
+
consola.success(`Schema updated successfully (version ${formatSchemaVersion(result.version, result.schemaMinorVersion)})`);
|
|
64
71
|
return;
|
|
65
72
|
}
|
|
66
73
|
consola.error(`Schema validation failed with ${result.violations.length} violation(s):`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"irUpdateSchemaHandler.js","names":["createPlatformClient","DocumentTypes","CommanderError","consola","readFileSync","resolve","convertIrToWireSchema","buildPrefixRewriteFetch","DEFAULT_API_PREFIX","resolveIrInput","irUpdateSchemaHandler","options","irPath","ir","info","latestVersion","JSON","parse","schema","fetchFn","firstPartyPrefix","undefined","osdkClient","baseUrl","Promise","auth","
|
|
1
|
+
{"version":3,"file":"irUpdateSchemaHandler.js","names":["createPlatformClient","DocumentTypes","CommanderError","consola","readFileSync","resolve","convertIrToWireSchema","formatSchemaVersion","buildPrefixRewriteFetch","DEFAULT_API_PREFIX","resolveIrInput","irUpdateSchemaHandler","options","irPath","ir","info","latestVersion","latestMinorVersion","JSON","parse","schema","versionLabel","fetchFn","firstPartyPrefix","undefined","osdkClient","baseUrl","Promise","auth","requestBody","ontologyRid","version","schemaMinorVersion","forceOverwrite","request","documentTypeName","name","warn","result","updateSchema","preview","type","success","error","violations","length","violation","fieldPath","message","violationType"],"sources":["irUpdateSchemaHandler.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 { createPlatformClient } from \"@osdk/client\";\nimport type { UpdateSchemaDocumentTypeRequest, UpdateSchemaRequestBody } from \"@osdk/foundry.pack\";\nimport { DocumentTypes } from \"@osdk/foundry.pack\";\nimport { CommanderError } from \"commander\";\nimport { consola } from \"consola\";\nimport { readFileSync } from \"fs\";\nimport { resolve } from \"path\";\nimport { convertIrToWireSchema } from \"../../utils/ir/convertIrToWireSchema.js\";\nimport { formatSchemaVersion } from \"../../utils/schema/resolveSchemaChain.js\";\nimport { buildPrefixRewriteFetch, DEFAULT_API_PREFIX } from \"../utils/firstPartyPrefix.js\";\nimport { resolveIrInput } from \"./resolveIrInput.js\";\n\ninterface IrUpdateSchemaOptions {\n readonly ir: string;\n readonly baseUrl: string;\n readonly auth: string;\n readonly ontologyRid: string;\n readonly forceOverwrite?: boolean;\n readonly firstPartyPrefix?: string;\n}\n\n/**\n * Updates the schema of an existing document type from an IR file. Sources the wire schema and version directly from\n * the IR (the same single source of truth used by `ir deploy`), avoiding a separately-generated asset file.\n */\nexport async function irUpdateSchemaHandler(options: IrUpdateSchemaOptions): Promise<void> {\n try {\n const irPath = resolve(options.ir);\n consola.info(`Reading schema from: ${irPath}`);\n\n const { ir, latestVersion, latestMinorVersion } = resolveIrInput(\n JSON.parse(readFileSync(irPath, \"utf8\")) as unknown,\n irPath,\n );\n const schema = convertIrToWireSchema(ir);\n const versionLabel = formatSchemaVersion(latestVersion, latestMinorVersion);\n\n const fetchFn = options.firstPartyPrefix != null\n ? buildPrefixRewriteFetch(options.firstPartyPrefix)\n : undefined;\n if (fetchFn != null) {\n consola.info(`Rewriting OSDK '${DEFAULT_API_PREFIX}' -> '${options.firstPartyPrefix}'`);\n }\n\n const osdkClient = createPlatformClient(\n options.baseUrl,\n () => Promise.resolve(options.auth),\n undefined,\n fetchFn,\n );\n\n const requestBody: UpdateSchemaRequestBody = {\n ontologyRid: options.ontologyRid,\n schema,\n version: latestVersion,\n ...(latestMinorVersion > 0 ? { schemaMinorVersion: latestMinorVersion } : {}),\n ...(options.forceOverwrite ? { forceOverwrite: true } : {}),\n };\n const request: UpdateSchemaDocumentTypeRequest = { documentTypeName: ir.name, requestBody };\n\n if (options.forceOverwrite) {\n consola.warn(\"--force-overwrite is set: backwards-compatibility validation will be skipped.\");\n }\n consola.info(`Updating schema for document type \"${ir.name}\" -> version ${versionLabel}`);\n\n const result = await DocumentTypes.updateSchema(osdkClient, request, { preview: true });\n\n if (result.type === \"success\") {\n consola.success(\n `Schema updated successfully (version ${\n formatSchemaVersion(result.version, result.schemaMinorVersion)\n })`,\n );\n return;\n }\n\n consola.error(`Schema validation failed with ${result.violations.length} violation(s):`);\n for (const violation of result.violations) {\n consola.error(\n ` - ${violation.fieldPath}: ${violation.message} (${violation.violationType})`,\n );\n }\n throw new CommanderError(1, \"ERRIRUPDATESCHEMA\", \"Schema validation failed\");\n } catch (error) {\n if (error instanceof CommanderError) {\n throw error;\n }\n consola.error(\"❌ Error during update-schema:\", error);\n throw new CommanderError(1, \"ERRIRUPDATESCHEMA\", \"Error updating schema from IR\");\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,oBAAoB,QAAQ,cAAc;AAEnD,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,cAAc,QAAQ,WAAW;AAC1C,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,YAAY,QAAQ,IAAI;AACjC,SAASC,OAAO,QAAQ,MAAM;AAC9B,SAASC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