@palantir/pack.document-schema.type-gen 0.24.0 → 0.25.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 +14 -0
- package/build/esm/commands/ir/__tests__/irDeployFirstParty.test.js +237 -0
- package/build/esm/commands/ir/__tests__/irDeployFirstParty.test.js.map +1 -0
- package/build/esm/commands/ir/irDeployHandler.js +81 -41
- package/build/esm/commands/ir/irDeployHandler.js.map +1 -1
- package/build/esm/commands/ir/irGenAssetHandler.js +13 -0
- package/build/esm/commands/ir/irGenAssetHandler.js.map +1 -1
- package/build/esm/commands/ir/registerIrCommands.js +2 -2
- package/build/esm/commands/ir/registerIrCommands.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__/convertIrToConjureSchema.test.js +185 -0
- package/build/esm/utils/ir/__tests__/convertIrToConjureSchema.test.js.map +1 -0
- package/build/esm/utils/ir/convertIrToConjureSchema.js +148 -0
- package/build/esm/utils/ir/convertIrToConjureSchema.js.map +1 -0
- 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/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/types/commands/ir/__tests__/irDeployFirstParty.test.d.ts +2 -0
- package/build/types/commands/ir/__tests__/irDeployFirstParty.test.d.ts.map +1 -0
- package/build/types/commands/ir/irDeployHandler.d.ts +20 -2
- package/build/types/commands/ir/irDeployHandler.d.ts.map +1 -1
- package/build/types/commands/ir/irGenAssetHandler.d.ts +5 -0
- package/build/types/commands/ir/irGenAssetHandler.d.ts.map +1 -1
- package/build/types/commands/ir/registerIrCommands.d.ts.map +1 -1
- package/build/types/utils/ir/__tests__/convertIrToConjureSchema.test.d.ts +2 -0
- package/build/types/utils/ir/__tests__/convertIrToConjureSchema.test.d.ts.map +1 -0
- package/build/types/utils/ir/convertIrToConjureSchema.d.ts +26 -0
- package/build/types/utils/ir/convertIrToConjureSchema.d.ts.map +1 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -72,6 +72,20 @@ type-gen ir update-schema -i <ir.json> -b <base-url> -a <token> -o <ontology-rid
|
|
|
72
72
|
`ir asset` (generate an asset JSON consumed by backpack's asset-track loader) remains available;
|
|
73
73
|
the deploy/update-schema REST commands are IR-sourced.
|
|
74
74
|
|
|
75
|
+
```bash
|
|
76
|
+
# Generate the asset JSON (plus a sibling schema compatibility range JSON)
|
|
77
|
+
type-gen ir asset -i <ir.json> -o <asset.json> [-f ARTIFACTS|COMPASS] [--force-overwrite]
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`--force-overwrite` writes `forceOverwrite: true` onto the asset so the platform skips
|
|
81
|
+
backwards-compatibility validation when it processes it. Note the flag lands on the underlying `ir asset`
|
|
82
|
+
invocation, so passing it through a `build:asset` package script differs by package manager:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pnpm run build:asset --force-overwrite # pnpm forwards a literal `--`, so omit it
|
|
86
|
+
npm run build:asset -- --force-overwrite # npm requires `--`
|
|
87
|
+
```
|
|
88
|
+
|
|
75
89
|
### Examples
|
|
76
90
|
|
|
77
91
|
#### Generating TypeScript Types from YAML
|
|
@@ -0,0 +1,237 @@
|
|
|
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 { CommanderError } from "commander";
|
|
18
|
+
import { consola } from "consola";
|
|
19
|
+
import { readFileSync } from "fs";
|
|
20
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
21
|
+
import { irDeployHandler } from "../irDeployHandler.js";
|
|
22
|
+
const {
|
|
23
|
+
osdkCreateMock,
|
|
24
|
+
createPlatformClientMock
|
|
25
|
+
} = vi.hoisted(() => ({
|
|
26
|
+
osdkCreateMock: vi.fn(),
|
|
27
|
+
createPlatformClientMock: vi.fn(() => ({}))
|
|
28
|
+
}));
|
|
29
|
+
vi.mock("@osdk/foundry.pack", () => ({
|
|
30
|
+
DocumentTypes: {
|
|
31
|
+
create: osdkCreateMock
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
34
|
+
vi.mock("@osdk/client", () => ({
|
|
35
|
+
createPlatformClient: createPlatformClientMock
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
// Minimal single-version IR: exercises resolveIrInput + convertIrToWireSchema with no models.
|
|
39
|
+
const MIN_IR = {
|
|
40
|
+
name: "com.palantir.pack.test.foo",
|
|
41
|
+
version: 1,
|
|
42
|
+
primaryModelKeys: [],
|
|
43
|
+
models: {}
|
|
44
|
+
};
|
|
45
|
+
const WIRE_SCHEMA = {
|
|
46
|
+
primaryModelKeys: [],
|
|
47
|
+
models: {}
|
|
48
|
+
};
|
|
49
|
+
vi.mock("fs", async importOriginal => ({
|
|
50
|
+
...(await importOriginal()),
|
|
51
|
+
readFileSync: vi.fn(() => JSON.stringify(MIN_IR))
|
|
52
|
+
}));
|
|
53
|
+
const FIRST_PARTY_OPTIONS = {
|
|
54
|
+
ir: "ir.json",
|
|
55
|
+
baseUrl: "https://stack.example.com",
|
|
56
|
+
auth: "test-token",
|
|
57
|
+
firstParty: true,
|
|
58
|
+
firstPartyApiUrl: "https://stack.example.com/first-party/api"
|
|
59
|
+
};
|
|
60
|
+
const PUBLISH_URL = "https://stack.example.com/first-party/api/publish-first-party-document-type";
|
|
61
|
+
const originalFetch = globalThis.fetch;
|
|
62
|
+
let fetchMock;
|
|
63
|
+
function jsonResponse(status, body) {
|
|
64
|
+
return {
|
|
65
|
+
ok: status >= 200 && status < 300,
|
|
66
|
+
status,
|
|
67
|
+
json: () => Promise.resolve(body)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function fetchCall() {
|
|
71
|
+
const call = fetchMock.mock.calls[0];
|
|
72
|
+
return {
|
|
73
|
+
url: call[0],
|
|
74
|
+
init: call[1]
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function publishedBody() {
|
|
78
|
+
return JSON.parse(fetchCall().init.body);
|
|
79
|
+
}
|
|
80
|
+
function silenceConsola() {
|
|
81
|
+
vi.spyOn(consola, "info").mockImplementation(() => {});
|
|
82
|
+
vi.spyOn(consola, "success").mockImplementation(() => {});
|
|
83
|
+
vi.spyOn(consola, "warn").mockImplementation(() => {});
|
|
84
|
+
vi.spyOn(consola, "error").mockImplementation(() => {});
|
|
85
|
+
}
|
|
86
|
+
describe("irDeployHandler — first-party publish", () => {
|
|
87
|
+
beforeEach(() => {
|
|
88
|
+
fetchMock = vi.fn(() => Promise.resolve(jsonResponse(200, {
|
|
89
|
+
name: MIN_IR.name
|
|
90
|
+
})));
|
|
91
|
+
globalThis.fetch = fetchMock;
|
|
92
|
+
vi.mocked(readFileSync).mockReturnValue(JSON.stringify(MIN_IR));
|
|
93
|
+
silenceConsola();
|
|
94
|
+
});
|
|
95
|
+
afterEach(() => {
|
|
96
|
+
globalThis.fetch = originalFetch;
|
|
97
|
+
vi.restoreAllMocks();
|
|
98
|
+
});
|
|
99
|
+
it("PUTs to the publish endpoint with bearer auth and the yjs storage shape", async () => {
|
|
100
|
+
await irDeployHandler({
|
|
101
|
+
...FIRST_PARTY_OPTIONS
|
|
102
|
+
});
|
|
103
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
104
|
+
const {
|
|
105
|
+
url,
|
|
106
|
+
init
|
|
107
|
+
} = fetchCall();
|
|
108
|
+
expect(url).toBe(PUBLISH_URL);
|
|
109
|
+
expect(init.method).toBe("PUT");
|
|
110
|
+
expect(init.headers.Authorization).toBe("Bearer test-token");
|
|
111
|
+
const body = publishedBody();
|
|
112
|
+
expect(body).toMatchObject({
|
|
113
|
+
name: MIN_IR.name,
|
|
114
|
+
storage: {
|
|
115
|
+
type: "yjs",
|
|
116
|
+
yjs: {
|
|
117
|
+
schema: WIRE_SCHEMA
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
fileSystemType: "ARTIFACTS"
|
|
121
|
+
});
|
|
122
|
+
expect(body).not.toHaveProperty("ontologyRid");
|
|
123
|
+
expect(body).not.toHaveProperty("version");
|
|
124
|
+
});
|
|
125
|
+
it("passes an explicit --file-system-type through", async () => {
|
|
126
|
+
await irDeployHandler({
|
|
127
|
+
...FIRST_PARTY_OPTIONS,
|
|
128
|
+
fileSystemType: "COMPASS"
|
|
129
|
+
});
|
|
130
|
+
expect(publishedBody()).toMatchObject({
|
|
131
|
+
fileSystemType: "COMPASS"
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
it("normalizes a trailing slash on --first-party-api-url", async () => {
|
|
135
|
+
await irDeployHandler({
|
|
136
|
+
...FIRST_PARTY_OPTIONS,
|
|
137
|
+
firstPartyApiUrl: "https://stack.example.com/first-party/api/"
|
|
138
|
+
});
|
|
139
|
+
expect(fetchCall().url).toBe(PUBLISH_URL);
|
|
140
|
+
});
|
|
141
|
+
it("fails with a CommanderError when --first-party-api-url is missing", async () => {
|
|
142
|
+
await expect(irDeployHandler({
|
|
143
|
+
ir: "ir.json",
|
|
144
|
+
baseUrl: "https://stack.example.com",
|
|
145
|
+
auth: "test-token",
|
|
146
|
+
firstParty: true
|
|
147
|
+
})).rejects.toBeInstanceOf(CommanderError);
|
|
148
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
149
|
+
});
|
|
150
|
+
it("includes owningApplicationId when the IR chain payload provides one", async () => {
|
|
151
|
+
vi.mocked(readFileSync).mockReturnValue(JSON.stringify({
|
|
152
|
+
latestVersion: 1,
|
|
153
|
+
owningApplicationId: "pack-app-123",
|
|
154
|
+
chain: [{
|
|
155
|
+
version: 1,
|
|
156
|
+
ir: MIN_IR
|
|
157
|
+
}]
|
|
158
|
+
}));
|
|
159
|
+
await irDeployHandler({
|
|
160
|
+
...FIRST_PARTY_OPTIONS
|
|
161
|
+
});
|
|
162
|
+
expect(publishedBody()).toMatchObject({
|
|
163
|
+
owningApplicationId: "pack-app-123"
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
it("omits owningApplicationId when the IR does not provide one", async () => {
|
|
167
|
+
await irDeployHandler({
|
|
168
|
+
...FIRST_PARTY_OPTIONS
|
|
169
|
+
});
|
|
170
|
+
expect(publishedBody()).not.toHaveProperty("owningApplicationId");
|
|
171
|
+
});
|
|
172
|
+
it("warns about and ignores a deprecated --ontology-rid", async () => {
|
|
173
|
+
await irDeployHandler({
|
|
174
|
+
...FIRST_PARTY_OPTIONS,
|
|
175
|
+
ontologyRid: "ri.ontology.main.ontology.test"
|
|
176
|
+
});
|
|
177
|
+
expect(consola.warn).toHaveBeenCalledWith(expect.stringContaining("--ontology-rid is ignored"));
|
|
178
|
+
expect(publishedBody()).not.toHaveProperty("ontologyRid");
|
|
179
|
+
});
|
|
180
|
+
it("warns about and ignores a deprecated --first-party-prefix (no prefix rewrite applied)", async () => {
|
|
181
|
+
await irDeployHandler({
|
|
182
|
+
...FIRST_PARTY_OPTIONS,
|
|
183
|
+
firstPartyPrefix: "/some/prefix"
|
|
184
|
+
});
|
|
185
|
+
expect(consola.warn).toHaveBeenCalledWith(expect.stringContaining("--first-party-prefix is ignored"));
|
|
186
|
+
expect(fetchCall().url).toBe(PUBLISH_URL);
|
|
187
|
+
});
|
|
188
|
+
it("surfaces the Conjure errorName and fails with a CommanderError on non-2xx", async () => {
|
|
189
|
+
fetchMock.mockResolvedValue(jsonResponse(400, {
|
|
190
|
+
errorCode: "INVALID_ARGUMENT",
|
|
191
|
+
errorName: "BackpackCollaboration:MissingDocumentTypeSchema",
|
|
192
|
+
errorInstanceId: "err-1"
|
|
193
|
+
}));
|
|
194
|
+
await expect(irDeployHandler({
|
|
195
|
+
...FIRST_PARTY_OPTIONS
|
|
196
|
+
})).rejects.toBeInstanceOf(CommanderError);
|
|
197
|
+
expect(consola.error).toHaveBeenCalledWith(expect.stringContaining("BackpackCollaboration:MissingDocumentTypeSchema"));
|
|
198
|
+
});
|
|
199
|
+
it("still fails with a CommanderError when the error body is not JSON", async () => {
|
|
200
|
+
fetchMock.mockResolvedValue({
|
|
201
|
+
ok: false,
|
|
202
|
+
status: 503,
|
|
203
|
+
json: () => Promise.reject(new Error("not json"))
|
|
204
|
+
});
|
|
205
|
+
await expect(irDeployHandler({
|
|
206
|
+
...FIRST_PARTY_OPTIONS
|
|
207
|
+
})).rejects.toBeInstanceOf(CommanderError);
|
|
208
|
+
expect(consola.error).toHaveBeenCalledWith(expect.stringContaining("HTTP 503"));
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
describe("irDeployHandler — third-party (regression: unaffected by the swap)", () => {
|
|
212
|
+
beforeEach(() => {
|
|
213
|
+
fetchMock = vi.fn(() => Promise.resolve(jsonResponse(200, {})));
|
|
214
|
+
globalThis.fetch = fetchMock;
|
|
215
|
+
osdkCreateMock.mockReset().mockResolvedValue({
|
|
216
|
+
rid: "ri.pack.main.type.x"
|
|
217
|
+
});
|
|
218
|
+
createPlatformClientMock.mockClear();
|
|
219
|
+
vi.mocked(readFileSync).mockReturnValue(JSON.stringify(MIN_IR));
|
|
220
|
+
silenceConsola();
|
|
221
|
+
});
|
|
222
|
+
afterEach(() => {
|
|
223
|
+
globalThis.fetch = originalFetch;
|
|
224
|
+
vi.restoreAllMocks();
|
|
225
|
+
});
|
|
226
|
+
it("still deploys via the OSDK DocumentTypes.create path and never hits the publish endpoint", async () => {
|
|
227
|
+
await irDeployHandler({
|
|
228
|
+
ir: "ir.json",
|
|
229
|
+
baseUrl: "https://stack.example.com",
|
|
230
|
+
auth: "test-token",
|
|
231
|
+
parentFolder: "ri.compass.main.folder.abc"
|
|
232
|
+
});
|
|
233
|
+
expect(osdkCreateMock).toHaveBeenCalledTimes(1);
|
|
234
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
//# sourceMappingURL=irDeployFirstParty.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"irDeployFirstParty.test.js","names":["CommanderError","consola","readFileSync","afterEach","beforeEach","describe","expect","it","vi","irDeployHandler","osdkCreateMock","createPlatformClientMock","hoisted","fn","mock","DocumentTypes","create","createPlatformClient","MIN_IR","name","version","primaryModelKeys","models","WIRE_SCHEMA","importOriginal","JSON","stringify","FIRST_PARTY_OPTIONS","ir","baseUrl","auth","firstParty","firstPartyApiUrl","PUBLISH_URL","originalFetch","globalThis","fetch","fetchMock","jsonResponse","status","body","ok","json","Promise","resolve","fetchCall","call","calls","url","init","publishedBody","parse","silenceConsola","spyOn","mockImplementation","mocked","mockReturnValue","restoreAllMocks","toHaveBeenCalledTimes","toBe","method","headers","Authorization","toMatchObject","storage","type","yjs","schema","fileSystemType","not","toHaveProperty","rejects","toBeInstanceOf","toHaveBeenCalled","latestVersion","owningApplicationId","chain","ontologyRid","warn","toHaveBeenCalledWith","stringContaining","firstPartyPrefix","mockResolvedValue","errorCode","errorName","errorInstanceId","error","reject","Error","mockReset","rid","mockClear","parentFolder"],"sources":["irDeployFirstParty.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 { CommanderError } from \"commander\";\nimport { consola } from \"consola\";\nimport type * as FsModule from \"fs\";\nimport { readFileSync } from \"fs\";\nimport { afterEach, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport { irDeployHandler } from \"../irDeployHandler.js\";\n\nconst { osdkCreateMock, createPlatformClientMock } = vi.hoisted(() => ({\n osdkCreateMock: vi.fn(),\n createPlatformClientMock: vi.fn(() => ({})),\n}));\n\nvi.mock(\"@osdk/foundry.pack\", () => ({ DocumentTypes: { create: osdkCreateMock } }));\n\nvi.mock(\"@osdk/client\", () => ({ createPlatformClient: createPlatformClientMock }));\n\n// Minimal single-version IR: exercises resolveIrInput + convertIrToWireSchema with no models.\nconst MIN_IR = {\n name: \"com.palantir.pack.test.foo\",\n version: 1,\n primaryModelKeys: [],\n models: {},\n};\nconst WIRE_SCHEMA = { primaryModelKeys: [], models: {} };\n\nvi.mock(\"fs\", async importOriginal => ({\n ...(await importOriginal<typeof FsModule>()),\n readFileSync: vi.fn(() => JSON.stringify(MIN_IR)),\n}));\n\nconst FIRST_PARTY_OPTIONS = {\n ir: \"ir.json\",\n baseUrl: \"https://stack.example.com\",\n auth: \"test-token\",\n firstParty: true,\n firstPartyApiUrl: \"https://stack.example.com/first-party/api\",\n} as const;\n\nconst PUBLISH_URL = \"https://stack.example.com/first-party/api/publish-first-party-document-type\";\n\nconst originalFetch = globalThis.fetch;\nlet fetchMock: ReturnType<typeof vi.fn>;\n\nfunction jsonResponse(status: number, body: unknown): Response {\n return {\n ok: status >= 200 && status < 300,\n status,\n json: () => Promise.resolve(body),\n } as unknown as Response;\n}\n\nfunction fetchCall(): { url: string; init: RequestInit } {\n const call = fetchMock.mock.calls[0]! as [string, RequestInit];\n return { url: call[0], init: call[1] };\n}\n\nfunction publishedBody(): Record<string, unknown> {\n return JSON.parse(fetchCall().init.body as string) as Record<string, unknown>;\n}\n\nfunction silenceConsola(): void {\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\ndescribe(\"irDeployHandler — first-party publish\", () => {\n beforeEach(() => {\n fetchMock = vi.fn(() => Promise.resolve(jsonResponse(200, { name: MIN_IR.name })));\n globalThis.fetch = fetchMock as unknown as typeof globalThis.fetch;\n vi.mocked(readFileSync).mockReturnValue(JSON.stringify(MIN_IR));\n silenceConsola();\n });\n\n afterEach(() => {\n globalThis.fetch = originalFetch;\n vi.restoreAllMocks();\n });\n\n it(\"PUTs to the publish endpoint with bearer auth and the yjs storage shape\", async () => {\n await irDeployHandler({ ...FIRST_PARTY_OPTIONS });\n\n expect(fetchMock).toHaveBeenCalledTimes(1);\n const { url, init } = fetchCall();\n expect(url).toBe(PUBLISH_URL);\n expect(init.method).toBe(\"PUT\");\n expect((init.headers as Record<string, string>).Authorization).toBe(\"Bearer test-token\");\n\n const body = publishedBody();\n expect(body).toMatchObject({\n name: MIN_IR.name,\n storage: { type: \"yjs\", yjs: { schema: WIRE_SCHEMA } },\n fileSystemType: \"ARTIFACTS\",\n });\n expect(body).not.toHaveProperty(\"ontologyRid\");\n expect(body).not.toHaveProperty(\"version\");\n });\n\n it(\"passes an explicit --file-system-type through\", async () => {\n await irDeployHandler({ ...FIRST_PARTY_OPTIONS, fileSystemType: \"COMPASS\" });\n\n expect(publishedBody()).toMatchObject({ fileSystemType: \"COMPASS\" });\n });\n\n it(\"normalizes a trailing slash on --first-party-api-url\", async () => {\n await irDeployHandler({\n ...FIRST_PARTY_OPTIONS,\n firstPartyApiUrl: \"https://stack.example.com/first-party/api/\",\n });\n\n expect(fetchCall().url).toBe(PUBLISH_URL);\n });\n\n it(\"fails with a CommanderError when --first-party-api-url is missing\", async () => {\n await expect(\n irDeployHandler({\n ir: \"ir.json\",\n baseUrl: \"https://stack.example.com\",\n auth: \"test-token\",\n firstParty: true,\n }),\n ).rejects.toBeInstanceOf(CommanderError);\n\n expect(fetchMock).not.toHaveBeenCalled();\n });\n\n it(\"includes owningApplicationId when the IR chain payload provides one\", async () => {\n vi.mocked(readFileSync).mockReturnValue(\n JSON.stringify({\n latestVersion: 1,\n owningApplicationId: \"pack-app-123\",\n chain: [{ version: 1, ir: MIN_IR }],\n }),\n );\n\n await irDeployHandler({ ...FIRST_PARTY_OPTIONS });\n\n expect(publishedBody()).toMatchObject({ owningApplicationId: \"pack-app-123\" });\n });\n\n it(\"omits owningApplicationId when the IR does not provide one\", async () => {\n await irDeployHandler({ ...FIRST_PARTY_OPTIONS });\n\n expect(publishedBody()).not.toHaveProperty(\"owningApplicationId\");\n });\n\n it(\"warns about and ignores a deprecated --ontology-rid\", async () => {\n await irDeployHandler({\n ...FIRST_PARTY_OPTIONS,\n ontologyRid: \"ri.ontology.main.ontology.test\",\n });\n\n expect(consola.warn).toHaveBeenCalledWith(expect.stringContaining(\"--ontology-rid is ignored\"));\n expect(publishedBody()).not.toHaveProperty(\"ontologyRid\");\n });\n\n it(\"warns about and ignores a deprecated --first-party-prefix (no prefix rewrite applied)\", async () => {\n await irDeployHandler({ ...FIRST_PARTY_OPTIONS, firstPartyPrefix: \"/some/prefix\" });\n\n expect(consola.warn).toHaveBeenCalledWith(\n expect.stringContaining(\"--first-party-prefix is ignored\"),\n );\n expect(fetchCall().url).toBe(PUBLISH_URL);\n });\n\n it(\"surfaces the Conjure errorName and fails with a CommanderError on non-2xx\", async () => {\n fetchMock.mockResolvedValue(\n jsonResponse(400, {\n errorCode: \"INVALID_ARGUMENT\",\n errorName: \"BackpackCollaboration:MissingDocumentTypeSchema\",\n errorInstanceId: \"err-1\",\n }),\n );\n\n await expect(irDeployHandler({ ...FIRST_PARTY_OPTIONS })).rejects.toBeInstanceOf(\n CommanderError,\n );\n expect(consola.error).toHaveBeenCalledWith(\n expect.stringContaining(\"BackpackCollaboration:MissingDocumentTypeSchema\"),\n );\n });\n\n it(\"still fails with a CommanderError when the error body is not JSON\", async () => {\n fetchMock.mockResolvedValue({\n ok: false,\n status: 503,\n json: () => Promise.reject(new Error(\"not json\")),\n } as unknown as Response);\n\n await expect(irDeployHandler({ ...FIRST_PARTY_OPTIONS })).rejects.toBeInstanceOf(\n CommanderError,\n );\n expect(consola.error).toHaveBeenCalledWith(expect.stringContaining(\"HTTP 503\"));\n });\n});\n\ndescribe(\"irDeployHandler — third-party (regression: unaffected by the swap)\", () => {\n beforeEach(() => {\n fetchMock = vi.fn(() => Promise.resolve(jsonResponse(200, {})));\n globalThis.fetch = fetchMock as unknown as typeof globalThis.fetch;\n osdkCreateMock.mockReset().mockResolvedValue({ rid: \"ri.pack.main.type.x\" });\n createPlatformClientMock.mockClear();\n vi.mocked(readFileSync).mockReturnValue(JSON.stringify(MIN_IR));\n silenceConsola();\n });\n\n afterEach(() => {\n globalThis.fetch = originalFetch;\n vi.restoreAllMocks();\n });\n\n it(\"still deploys via the OSDK DocumentTypes.create path and never hits the publish endpoint\", async () => {\n await irDeployHandler({\n ir: \"ir.json\",\n baseUrl: \"https://stack.example.com\",\n auth: \"test-token\",\n parentFolder: \"ri.compass.main.folder.abc\",\n });\n\n expect(osdkCreateMock).toHaveBeenCalledTimes(1);\n expect(fetchMock).not.toHaveBeenCalled();\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,cAAc,QAAQ,WAAW;AAC1C,SAASC,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,eAAe,QAAQ,uBAAuB;AAEvD,MAAM;EAAEC,cAAc;EAAEC;AAAyB,CAAC,GAAGH,EAAE,CAACI,OAAO,CAAC,OAAO;EACrEF,cAAc,EAAEF,EAAE,CAACK,EAAE,CAAC,CAAC;EACvBF,wBAAwB,EAAEH,EAAE,CAACK,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAC5C,CAAC,CAAC,CAAC;AAEHL,EAAE,CAACM,IAAI,CAAC,oBAAoB,EAAE,OAAO;EAAEC,aAAa,EAAE;IAAEC,MAAM,EAAEN;EAAe;AAAE,CAAC,CAAC,CAAC;AAEpFF,EAAE,CAACM,IAAI,CAAC,cAAc,EAAE,OAAO;EAAEG,oBAAoB,EAAEN;AAAyB,CAAC,CAAC,CAAC;;AAEnF;AACA,MAAMO,MAAM,GAAG;EACbC,IAAI,EAA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,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -14,30 +14,42 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { createPlatformClient
|
|
17
|
+
import { createPlatformClient } from "@osdk/client";
|
|
18
18
|
import { DocumentTypes } from "@osdk/foundry.pack";
|
|
19
19
|
import { CommanderError } from "commander";
|
|
20
20
|
import { consola } from "consola";
|
|
21
21
|
import { readFileSync } from "fs";
|
|
22
22
|
import { resolve } from "path";
|
|
23
|
+
import { convertIrToConjureSchema } from "../../utils/ir/convertIrToConjureSchema.js";
|
|
23
24
|
import { convertIrToWireSchema } from "../../utils/ir/convertIrToWireSchema.js";
|
|
24
|
-
import { buildPrefixRewriteFetch, DEFAULT_API_PREFIX } from "../utils/firstPartyPrefix.js";
|
|
25
25
|
import { resolveIrInput } from "./resolveIrInput.js";
|
|
26
|
+
/**
|
|
27
|
+
* Handler for `ir deploy`, which creates a document type from a resolved IR.
|
|
28
|
+
*
|
|
29
|
+
* - Third-party (default): creates a versioned document type via the public OSDK
|
|
30
|
+
* (`DocumentTypes.create`) under `--parent-folder`.
|
|
31
|
+
* - First-party (`--first-party`): publishes a global, name-keyed type in DEV MODE via the
|
|
32
|
+
* first-party document type API. The schema is unversioned (dev sentinel, version -1), no RID is
|
|
33
|
+
* minted, and re-running with the same name overwrites the definition so you can iterate freely.
|
|
34
|
+
* This path is dev-only — promoting a type to a real, versioned schema is done separately via an
|
|
35
|
+
* asset deploy, not this command.
|
|
36
|
+
*
|
|
37
|
+
* When you call create for this new doc-type, a RID is minted in the resolved ontology.
|
|
38
|
+
*/
|
|
26
39
|
export async function irDeployHandler(options) {
|
|
27
40
|
try {
|
|
28
41
|
const irPath = resolve(options.ir);
|
|
29
42
|
consola.info(`Reading schema from: ${irPath}`);
|
|
30
43
|
const {
|
|
31
44
|
ir,
|
|
32
|
-
latestVersion,
|
|
33
45
|
owningApplicationId
|
|
34
46
|
} = resolveIrInput(JSON.parse(readFileSync(irPath, "utf8")), irPath);
|
|
35
|
-
const schema = convertIrToWireSchema(ir);
|
|
36
47
|
const fileSystemType = options.fileSystemType ?? "ARTIFACTS";
|
|
37
48
|
if (options.firstParty) {
|
|
38
|
-
|
|
49
|
+
// The first-party publish endpoint expects the nested-union Conjure shape, not the flat OSDK shape.
|
|
50
|
+
await deployFirstParty(options, ir.name, convertIrToConjureSchema(ir), fileSystemType, owningApplicationId);
|
|
39
51
|
} else {
|
|
40
|
-
await deployThirdParty(options, ir.name,
|
|
52
|
+
await deployThirdParty(options, ir.name, convertIrToWireSchema(ir), fileSystemType);
|
|
41
53
|
}
|
|
42
54
|
} catch (error) {
|
|
43
55
|
if (error instanceof CommanderError) {
|
|
@@ -64,44 +76,72 @@ async function deployThirdParty(options, name, schema, fileSystemType) {
|
|
|
64
76
|
});
|
|
65
77
|
consola.success("Successfully created document type", result);
|
|
66
78
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
79
|
+
|
|
80
|
+
/** Subset of the Conjure error body that we surface to the user. */
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Publishes a global, name-keyed first-party document type in DEV MODE, via the internal-only
|
|
84
|
+
* `publishFirstPartyDocumentType` endpoint (a direct authenticated PUT to the first-party Conjure
|
|
85
|
+
* REST API — this is not part of the public Foundry API / OSDK, and its generated client lives in
|
|
86
|
+
* an internal registry this public package cannot depend on).
|
|
87
|
+
*
|
|
88
|
+
* Dev-mode semantics: the schema is recorded unversioned at the dev sentinel (version -1), no RID
|
|
89
|
+
* is minted, and the per-ontology instance is created lazily on first document creation. Re-running
|
|
90
|
+
* with the SAME document type name overwrites the definition, so you can iterate on the schema
|
|
91
|
+
* freely — there is no version bump or backwards-compatibility check until the type graduates to a
|
|
92
|
+
* real version via an asset deploy.
|
|
93
|
+
*
|
|
94
|
+
* Note: a name that already exists as an old-world RID-keyed (non-dev) type is rejected until the
|
|
95
|
+
* one-time backfill migrates it into the asset store; brand-new names publish immediately.
|
|
96
|
+
*/
|
|
97
|
+
async function deployFirstParty(options, name, schema, fileSystemType, owningApplicationId) {
|
|
98
|
+
if (options.firstPartyApiUrl == null || options.firstPartyApiUrl.length === 0) {
|
|
99
|
+
throw new CommanderError(1, "EINVAL", "--first-party-api-url is required for first-party deploys. Pass your stack's first-party " + "document type REST API base URL.");
|
|
70
100
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
consola.info(`Rewriting OSDK '${DEFAULT_API_PREFIX}' -> '${options.firstPartyPrefix}'`);
|
|
101
|
+
if (options.ontologyRid != null) {
|
|
102
|
+
consola.warn("--ontology-rid is ignored for first-party deploys: publishFirstPartyDocumentType has no " + "ontology binding (the per-ontology instance is created lazily on first document creation).");
|
|
74
103
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
104
|
+
if (options.firstPartyPrefix != null) {
|
|
105
|
+
consola.warn("--first-party-prefix is ignored: first-party deploys now call the first-party API directly. " + "Pass its base URL via --first-party-api-url instead.");
|
|
106
|
+
}
|
|
107
|
+
const url = options.firstPartyApiUrl.replace(/\/+$/, "") + "/publish-first-party-document-type";
|
|
108
|
+
|
|
109
|
+
// Conjure wire shape for PublishFirstPartyDocumentTypeRequest; the yjs storage union serializes
|
|
110
|
+
// as { type: "yjs", yjs: { schema } }.
|
|
111
|
+
const body = {
|
|
112
|
+
name,
|
|
113
|
+
storage: {
|
|
114
|
+
type: "yjs",
|
|
115
|
+
yjs: {
|
|
116
|
+
schema
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
fileSystemType,
|
|
120
|
+
...(owningApplicationId != null ? {
|
|
121
|
+
owningApplicationId
|
|
122
|
+
} : {})
|
|
87
123
|
};
|
|
88
|
-
consola.info("
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
124
|
+
consola.info("Publishing first-party document type", {
|
|
125
|
+
name,
|
|
126
|
+
url
|
|
127
|
+
});
|
|
128
|
+
const response = await fetch(url, {
|
|
129
|
+
method: "PUT",
|
|
130
|
+
headers: {
|
|
131
|
+
"Authorization": `Bearer ${options.auth}`,
|
|
132
|
+
"Content-Type": "application/json",
|
|
133
|
+
"Accept": "application/json"
|
|
134
|
+
},
|
|
135
|
+
body: JSON.stringify(body)
|
|
136
|
+
});
|
|
137
|
+
if (!response.ok) {
|
|
138
|
+
const errorBody = await response.json().catch(() => undefined);
|
|
139
|
+
const errorName = errorBody?.errorName ?? `HTTP ${response.status}`;
|
|
140
|
+
const instance = errorBody?.errorInstanceId != null ? ` [${errorBody.errorInstanceId}]` : "";
|
|
141
|
+
consola.error(`❌ Error during first-party publish: ${errorName}${instance}`);
|
|
142
|
+
throw new CommanderError(1, "ERRFPPUBLISH", errorName);
|
|
105
143
|
}
|
|
144
|
+
const result = await response.json();
|
|
145
|
+
consola.success(`Successfully published first-party document type '${result.name}'`);
|
|
106
146
|
}
|
|
107
147
|
//# sourceMappingURL=irDeployHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"irDeployHandler.js","names":["createPlatformClient","PalantirApiError","DocumentTypes","CommanderError","consola","readFileSync","resolve","convertIrToWireSchema","buildPrefixRewriteFetch","DEFAULT_API_PREFIX","resolveIrInput","irDeployHandler","options","irPath","ir","info","latestVersion","owningApplicationId","JSON","parse","schema","fileSystemType","firstParty","deployFirstParty","name","deployThirdParty","error","parentFolder","osdkClient","baseUrl","Promise","auth","request","parentFolderRid","result","create","preview","success","version","ontologyRid","fetchFn","firstPartyPrefix","undefined","requestBody","createFirstParty","message","errorName","errorCode","details","filter","Boolean","join"],"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, PalantirApiError } from \"@osdk/client\";\nimport type {\n CreateDocumentTypeRequest,\n CreateFirstPartyDocumentTypeRequest,\n FileSystemType,\n} 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 { buildPrefixRewriteFetch, DEFAULT_API_PREFIX } from \"../utils/firstPartyPrefix.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 /** Required for first-party deploys. */\n readonly ontologyRid?: string;\n /** Overrides the API prefix for first-party deploys (e.g. /api/gotham). */\n readonly firstPartyPrefix?: string;\n}\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, owningApplicationId } = resolveIrInput(\n JSON.parse(readFileSync(irPath, \"utf8\")) as unknown,\n irPath,\n );\n const schema = convertIrToWireSchema(ir);\n const fileSystemType = options.fileSystemType ?? \"ARTIFACTS\";\n\n if (options.firstParty) {\n await deployFirstParty(\n options,\n ir.name,\n schema,\n latestVersion,\n fileSystemType,\n owningApplicationId,\n );\n } else {\n await deployThirdParty(options, ir.name, schema, 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\nasync function deployFirstParty(\n options: DeployOptions,\n name: string,\n schema: DocumentTypeSchema,\n version: number,\n fileSystemType: FileSystemType,\n owningApplicationId: string | undefined,\n): Promise<void> {\n if (options.ontologyRid == null) {\n throw new CommanderError(\n 1,\n \"EINVAL\",\n \"--ontology-rid is required when deploying a first-party document type\",\n );\n }\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 request: CreateFirstPartyDocumentTypeRequest = {\n requestBody: {\n name,\n ontologyRid: options.ontologyRid,\n schema,\n version,\n fileSystemType,\n ...(owningApplicationId != null ? { owningApplicationId } : {}),\n },\n };\n\n consola.info(\"Creating first-party document type\", request);\n try {\n const result = await DocumentTypes.createFirstParty(osdkClient, request, { preview: true });\n consola.success(\"Successfully created first-party document type\", result);\n } catch (error) {\n if (error instanceof PalantirApiError) {\n const { message, errorName, errorCode } = error;\n const details = [errorName, errorCode].filter(Boolean).join(\" \");\n consola.error(\n `❌ Error during first-party deploy: ${message}${details ? ` [${details}]` : \"\"}`,\n );\n }\n throw error;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,oBAAoB,EAAEC,gBAAgB,QAAQ,cAAc;AAMrE,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,qBAAqB,QAAQ,yCAAyC;AAC/E,SAASC,uBAAuB,EAAEC,kBAAkB,QAAQ,8BAA8B;AAC1F,SAASC,cAAc,QAAQ,qBAAqB;AAgBpD,OAAO,eAAeC,eAAeA,CAACC,OAAsB,EAAiB;EAC3E,IAAI;IACF,MAAMC,MAAM,GAAGP,OAAO,CAACM,OAAO,CAACE,EAAE,CAAC;IAClCV,OAAO,CAACW,IAAI,CAAC,wBAAwBF,MAAM,EAAE,CAAC;IAE9C,MAAM;MAAEC,EAAE;MAAEE,aAAa;MAAEC;IAAoB,CAAC,GAAGP,cAAc,CAC/DQ,IAAI,CAACC,KAAK,CAACd,YAAY,CAACQ,MAAM,EAAE,MAAM,CAAC,CAAC,EACxCA,MACF,CAAC;IACD,MAAMO,MAAM,GAAGb,qBAAqB,CAACO,EAAE,CAAC;IACxC,MAAMO,cAAc,GAAGT,OAAO,CAACS,cAAc,IAAI,WAAW;IAE5D,IAAIT,OAAO,CAACU,UAAU,EAAE;MACtB,MAAMC,gBAAgB,CACpBX,OAAO,E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,OAAO,GAAG,CAACF,SAAS,EAAEC,SAAS,CAAC,CAACE,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC;MAChE/C,OAAO,CAACsB,KAAK,CACX,sCAAsCmB,OAAO,GAAGG,OAAO,GAAG,KAAKA,OAAO,GAAG,GAAG,EAAE,EAChF,CAAC;IACH;IACA,MAAMtB,KAAK;EACb;AACF","ignoreList":[]}
|
|
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;A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Ac,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":[]}
|
|
@@ -44,6 +44,10 @@ function deriveCompatibilityRangePath(assetOutputPath) {
|
|
|
44
44
|
* register the document type automatically at deploy time. Most users should
|
|
45
45
|
* use `ir deploy` to register document types via the Foundry API instead.
|
|
46
46
|
*
|
|
47
|
+
* `--force-overwrite` writes `forceOverwrite: true` onto the asset, telling the
|
|
48
|
+
* platform to skip incremental schema validation when it picks the asset up. It
|
|
49
|
+
* is a transient processing directive, not persisted with the document type.
|
|
50
|
+
*
|
|
47
51
|
* If you are unsure whether you need this command, you almost certainly do not.
|
|
48
52
|
*/
|
|
49
53
|
export function irGenAssetHandler(options) {
|
|
@@ -81,8 +85,14 @@ export function irGenAssetHandler(options) {
|
|
|
81
85
|
schemaVersion: latestVersion,
|
|
82
86
|
...(owningApplicationId != null ? {
|
|
83
87
|
owningApplicationId
|
|
88
|
+
} : {}),
|
|
89
|
+
...(options.forceOverwrite ? {
|
|
90
|
+
forceOverwrite: true
|
|
84
91
|
} : {})
|
|
85
92
|
};
|
|
93
|
+
if (options.forceOverwrite) {
|
|
94
|
+
consola.warn("--force-overwrite is set: the platform will skip backwards-compatibility validation when processing this asset.");
|
|
95
|
+
}
|
|
86
96
|
const outputDir = dirname(outputPath);
|
|
87
97
|
if (!existsSync(outputDir)) {
|
|
88
98
|
mkdirSync(outputDir, {
|
|
@@ -115,6 +125,9 @@ export function irGenAssetHandler(options) {
|
|
|
115
125
|
if (owningApplicationId != null) {
|
|
116
126
|
consola.info(` Owning application id: ${owningApplicationId}`);
|
|
117
127
|
}
|
|
128
|
+
if (options.forceOverwrite) {
|
|
129
|
+
consola.info(" Force overwrite: true");
|
|
130
|
+
}
|
|
118
131
|
} catch (error) {
|
|
119
132
|
if (error instanceof CommanderError) {
|
|
120
133
|
throw error;
|
|
@@ -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","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}\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 * 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 };\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 } 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,OAA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a,CACXwC,sBAAsB,EACtBpB,IAAI,CAACmB,SAAS,CAACE,wBAAwB,EAAE,IAAI,EAAE,CAAC,CAAC,EACjD,MACF,CAAC;IAED7C,OAAO,CAACiD,OAAO,CAAC,4CAA4C,CAAC;IAC7DjD,OAAO,CAACsB,IAAI,CAAC,cAAcF,UAAU,EAAE,CAAC;IACxCpB,OAAO,CAACsB,IAAI,CAAC,kCAAkCsB,sBAAsB,EAAE,CAAC;IACxE5C,OAAO,CAACsB,IAAI,CAAC,qBAAqBU,gBAAgB,EAAE,CAAC;IACrDhC,OAAO,CAACsB,IAAI,CAAC,sBAAsBM,aAAa,EAAE,CAAC;IACnD5B,OAAO,CAACsB,IAAI,CAAC,4BAA4BO,mBAAmB,KAAKD,aAAa,GAAG,CAAC;IAClF5B,OAAO,CAACsB,IAAI,CAAC,wBAAwBY,cAAc,EAAE,CAAC;IACtD,IAAIJ,mBAAmB,IAAI,IAAI,EAAE;MAC/B9B,OAAO,CAACsB,IAAI,CAAC,6BAA6BQ,mBAAmB,EAAE,CAAC;IAClE;EACF,CAAC,CAAC,OAAOoB,KAAK,EAAE;IACd,IAAIA,KAAK,YAAYnD,cAAc,EAAE;MACnC,MAAMmD,KAAK;IACb;IACAlD,OAAO,CAACkD,KAAK,CAAC,uCAAuC,EAAEA,KAAK,CAAC;IAC7D,MAAM,IAAInD,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","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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;MAC/BX,OAAO,EAAE1B,sBAAsB;MAC/B,GAbuD;QACvDuC,GAAG,EAAEpB,mBAAmB;QACxBqB,GAAG,EAAEtB;MACP;IAWA,CAAC;IACDxB,aAAa,CACX0C,sBAAsB,EACtBtB,IAAI,CAACqB,SAAS,CAACE,wBAAwB,EAAE,IAAI,EAAE,CAAC,CAAC,EACjD,MACF,CAAC;IAED/C,OAAO,CAACmD,OAAO,CAAC,4CAA4C,CAAC;IAC7DnD,OAAO,CAACsB,IAAI,CAAC,cAAcF,UAAU,EAAE,CAAC;IACxCpB,OAAO,CAACsB,IAAI,CAAC,kCAAkCwB,sBAAsB,EAAE,CAAC;IACxE9C,OAAO,CAACsB,IAAI,CAAC,qBAAqBU,gBAAgB,EAAE,CAAC;IACrDhC,OAAO,CAACsB,IAAI,CAAC,sBAAsBM,aAAa,EAAE,CAAC;IACnD5B,OAAO,CAACsB,IAAI,CAAC,4BAA4BO,mBAAmB,KAAKD,aAAa,GAAG,CAAC;IAClF5B,OAAO,CAACsB,IAAI,CAAC,wBAAwBY,cAAc,EAAE,CAAC;IACtD,IAAIJ,mBAAmB,IAAI,IAAI,EAAE;MAC/B9B,OAAO,CAACsB,IAAI,CAAC,6BAA6BQ,mBAAmB,EAAE,CAAC;IAClE;IACA,IAAIb,OAAO,CAACwB,cAAc,EAAE;MAC1BzC,OAAO,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":[]}
|
|
@@ -25,8 +25,8 @@ export function registerIrCommands(program) {
|
|
|
25
25
|
irCmd.command("gen-types").description("Generate versioned SDK files (types, schemas, internal/, models.ts, versions.ts, versionedDocRef.ts, index.ts) from a versioned IR chain JSON.").requiredOption("-s, --schema <file>", "Path to versioned IR chain JSON file").requiredOption("-o, --output <dir>", "Output directory for generated SDK files").action(irGenTypesHandler);
|
|
26
26
|
irCmd.command("zod").description("Generate Zod schemas from IR document schema definitions").requiredOption("-s, --schema <file>", "Path to schema JSON file").requiredOption("-o, --output <file>", "Output file path for generated Zod schemas").option("-t, --type-import-path <path>", "Path to import types from (enables satisfies operators)").action(irGenZodHandler);
|
|
27
27
|
irCmd.command("models").description("Generate Model constants from IR document schema definitions").requiredOption("-s, --schema <file>", "Path to schema JSON file").requiredOption("-o, --output <file>", "Output file path for generated Model constants").option("-t, --type-import-path <path>", "Path to import types from", "./types.js").option("--schema-import-path <path>", "Path to import schemas from", "./schema.js").action(irGenModelsHandler);
|
|
28
|
-
irCmd.command("deploy").description("Create a document type on a Foundry stack using an IR document schema. Deploys via the general " + "(third-party) path by default, or the first-party path with --first-party.").requiredOption("-i, --ir <file>", "Path to IR JSON file (chain payload from 'schema ir', or legacy single-version IR)").requiredOption("-b, --base-url <url>", "Base URL for Foundry API").requiredOption("-a, --auth <token>", "Authentication token for Foundry API").option("-p, --parent-folder <rid>", "Parent folder RID for the document type (required for third-party deploys)").option("--first-party", "
|
|
28
|
+
irCmd.command("deploy").description("Create a document type on a Foundry stack using an IR document schema. Deploys via the general " + "(third-party) path by default, or the first-party path with --first-party.").requiredOption("-i, --ir <file>", "Path to IR JSON file (chain payload from 'schema ir', or legacy single-version IR)").requiredOption("-b, --base-url <url>", "Base URL for Foundry API").requiredOption("-a, --auth <token>", "Authentication token for Foundry API").option("-p, --parent-folder <rid>", "Parent folder RID for the document type (required for third-party deploys)").option("--first-party", "Publish a first-party document type in dev mode: schema is unversioned (version -1) and you " + "can re-run with the same name to iterate on it. Requires --first-party-api-url.", false).option("-o, --ontology-rid <rid>", "[deprecated] Ignored for first-party deploys (publish has no ontology binding)").option("-f, --file-system-type <type>", "File system type for the document type (ARTIFACTS or COMPASS)").option("--first-party-api-url <url>", "First-party document type REST API base URL, required for first-party deploys (installation-dependent)").option("--first-party-prefix <path>", "[deprecated] Ignored; use --first-party-api-url for first-party deploys").action(irDeployHandler);
|
|
29
29
|
irCmd.command("update-schema").description("Update the schema of an existing document type using an IR document schema").requiredOption("-i, --ir <file>", "Path to IR JSON file (chain payload from 'schema ir', or legacy single-version IR)").requiredOption("-b, --base-url <url>", "Base URL for Foundry API").requiredOption("-a, --auth <token>", "Authentication token for Foundry API").requiredOption("-o, --ontology-rid <rid>", "Target ontology RID").option("--force-overwrite", "Skip backwards-compatibility validation when updating the schema", false).option("--first-party-prefix <path>", "Override the API prefix used for first-party requests (e.g. /api/gotham). Defaults to /api.").action(irUpdateSchemaHandler);
|
|
30
|
-
irCmd.command("asset").description("Generate document type asset JSON and a sibling schema compatibility range JSON from an IR file (advanced — most users should use 'ir deploy' instead). The minimum supported schema version is sourced from the IR payload's 'minSupportedVersion' field (set by 'schema ir --config <pack-config.json>'); legacy single-IR inputs default to min == max.").requiredOption("-i, --ir <file>", "Path to IR JSON file (chain payload from 'schema ir', or legacy single-version IR)").requiredOption("-o, --output <file>", "Output file path for asset JSON").option("-f, --file-system-type <type>", "File system type (ARTIFACTS or COMPASS)", "ARTIFACTS").option("--compatibility-range-output <file>", "Output path for the schema compatibility range JSON (defaults to a sibling of --output with '-schema-compatibility-range' suffix)").action(irGenAssetHandler);
|
|
30
|
+
irCmd.command("asset").description("Generate document type asset JSON and a sibling schema compatibility range JSON from an IR file (advanced — most users should use 'ir deploy' instead). The minimum supported schema version is sourced from the IR payload's 'minSupportedVersion' field (set by 'schema ir --config <pack-config.json>'); legacy single-IR inputs default to min == max.").requiredOption("-i, --ir <file>", "Path to IR JSON file (chain payload from 'schema ir', or legacy single-version IR)").requiredOption("-o, --output <file>", "Output file path for asset JSON").option("-f, --file-system-type <type>", "File system type (ARTIFACTS or COMPASS)", "ARTIFACTS").option("--compatibility-range-output <file>", "Output path for the schema compatibility range JSON (defaults to a sibling of --output with '-schema-compatibility-range' suffix)").option("--force-overwrite", "Mark the asset so backwards-compatibility validation is skipped when the platform processes it", false).action(irGenAssetHandler);
|
|
31
31
|
}
|
|
32
32
|
//# sourceMappingURL=registerIrCommands.js.map
|