@palantir/pack.document-schema.type-gen 0.6.0 → 0.8.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/build/esm/cli.js +2 -0
- package/build/esm/cli.js.map +1 -1
- package/build/esm/commands/asset/assetDeployHandler.js +60 -0
- package/build/esm/commands/asset/assetDeployHandler.js.map +1 -0
- package/build/esm/commands/asset/registerAssetCommands.js +22 -0
- package/build/esm/commands/asset/registerAssetCommands.js.map +1 -0
- package/build/esm/commands/ir/irDeployHandler.js +5 -4
- package/build/esm/commands/ir/irDeployHandler.js.map +1 -1
- package/build/esm/commands/ir/irGenAssetHandler.js +83 -0
- package/build/esm/commands/ir/irGenAssetHandler.js.map +1 -0
- package/build/esm/commands/ir/registerIrCommands.js +2 -0
- package/build/esm/commands/ir/registerIrCommands.js.map +1 -1
- package/build/esm/commands/steps/stepsGenIrHandler.js +6 -1
- package/build/esm/commands/steps/stepsGenIrHandler.js.map +1 -1
- package/build/esm/commands/types.js +2 -0
- package/build/esm/commands/types.js.map +1 -0
- package/build/esm/lib/pack-docschema-api/pack-docschema-ir/fieldDef.js.map +1 -1
- package/build/esm/lib/pack-docschema-api/pack-docschema-ir/fieldValueDatetime.js.map +1 -1
- package/build/esm/lib/pack-docschema-api/pack-docschema-ir/fieldValueMediaRef.js.map +1 -1
- package/build/esm/lib/pack-docschema-api/pack-docschema-ir/fieldValueText.js.map +1 -1
- package/build/esm/lib/pack-docschema-api/pack-docschema-ir/recordDef.js.map +1 -1
- package/build/esm/lib/pack-docschema-api/pack-docschema-ir/schemaMeta.js.map +1 -1
- package/build/esm/lib/pack-docschema-api/pack-docschema-ir/unionDef.js.map +1 -1
- package/build/esm/utils/generatedFileHeader.js +1 -0
- package/build/esm/utils/generatedFileHeader.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 +335 -0
- package/build/esm/utils/ir/__tests__/convertIrToWireSchema.test.js.map +1 -0
- package/build/esm/utils/ir/__tests__/generateModelsFromIr.test.js +49 -49
- package/build/esm/utils/ir/__tests__/generateModelsFromIr.test.js.map +1 -1
- package/build/esm/utils/ir/__tests__/generateZodSchemasFromIr.test.js +83 -83
- package/build/esm/utils/ir/__tests__/generateZodSchemasFromIr.test.js.map +1 -1
- package/build/esm/utils/ir/convertIrToWireSchema.js +199 -0
- package/build/esm/utils/ir/convertIrToWireSchema.js.map +1 -0
- package/build/esm/utils/ir/generateModelsFromIr.js +2 -2
- 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/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/__tests__/convertStepsToIr.test.js +81 -8
- package/build/esm/utils/steps/__tests__/convertStepsToIr.test.js.map +1 -1
- package/build/esm/utils/steps/convertStepsToIr.js +8 -10
- package/build/esm/utils/steps/convertStepsToIr.js.map +1 -1
- package/build/esm/utils/steps/parseMigrationSteps.js +4 -2
- package/build/esm/utils/steps/parseMigrationSteps.js.map +1 -1
- package/build/types/cli.d.ts.map +1 -1
- package/build/types/commands/asset/assetDeployHandler.d.ts +10 -0
- package/build/types/commands/asset/assetDeployHandler.d.ts.map +1 -0
- package/build/types/commands/asset/registerAssetCommands.d.ts +3 -0
- package/build/types/commands/asset/registerAssetCommands.d.ts.map +1 -0
- package/build/types/commands/ir/irDeployHandler.d.ts +1 -1
- package/build/types/commands/ir/irDeployHandler.d.ts.map +1 -1
- package/build/types/commands/ir/irGenAssetHandler.d.ts +19 -0
- package/build/types/commands/ir/irGenAssetHandler.d.ts.map +1 -0
- package/build/types/commands/ir/registerIrCommands.d.ts.map +1 -1
- package/build/types/commands/steps/stepsGenIrHandler.d.ts.map +1 -1
- package/build/types/commands/types.d.ts +12 -0
- package/build/types/commands/types.d.ts.map +1 -0
- package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldDef.d.ts +2 -2
- package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldDef.d.ts.map +1 -1
- package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldValueDatetime.d.ts +1 -0
- package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldValueDatetime.d.ts.map +1 -1
- package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldValueMediaRef.d.ts +1 -0
- package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldValueMediaRef.d.ts.map +1 -1
- package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldValueText.d.ts +3 -0
- package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldValueText.d.ts.map +1 -1
- package/build/types/lib/pack-docschema-api/pack-docschema-ir/recordDef.d.ts +1 -1
- package/build/types/lib/pack-docschema-api/pack-docschema-ir/recordDef.d.ts.map +1 -1
- package/build/types/lib/pack-docschema-api/pack-docschema-ir/schemaMeta.d.ts +2 -2
- package/build/types/lib/pack-docschema-api/pack-docschema-ir/schemaMeta.d.ts.map +1 -1
- package/build/types/lib/pack-docschema-api/pack-docschema-ir/unionDef.d.ts +1 -1
- package/build/types/lib/pack-docschema-api/pack-docschema-ir/unionDef.d.ts.map +1 -1
- package/build/types/utils/generatedFileHeader.d.ts +1 -0
- package/build/types/utils/generatedFileHeader.d.ts.map +1 -1
- package/build/types/utils/ir/__tests__/convertIrToWireSchema.test.d.ts +2 -0
- package/build/types/utils/ir/__tests__/convertIrToWireSchema.test.d.ts.map +1 -0
- package/build/types/utils/ir/convertIrToWireSchema.d.ts +17 -0
- package/build/types/utils/ir/convertIrToWireSchema.d.ts.map +1 -0
- package/build/types/utils/steps/parseMigrationSteps.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { describe, expect, it } from "vitest";
|
|
18
18
|
import { convertStepsToIr } from "../convertStepsToIr.js";
|
|
19
|
+
import { parseMigrationSteps } from "../parseMigrationSteps.js";
|
|
19
20
|
describe("convertStepsToIr", () => {
|
|
20
21
|
it("should convert simple record types to IR format", () => {
|
|
21
22
|
const schema = convertStepsToIr([{
|
|
@@ -49,7 +50,7 @@ describe("convertStepsToIr", () => {
|
|
|
49
50
|
const nameField = personRecord.fields.find(f => f.key === "name");
|
|
50
51
|
expect(nameField).toBeDefined();
|
|
51
52
|
expect(nameField?.isOptional).toBeUndefined();
|
|
52
|
-
expect(nameField?.
|
|
53
|
+
expect(nameField?.fieldType).toEqual({
|
|
53
54
|
type: "value",
|
|
54
55
|
value: {
|
|
55
56
|
type: "string",
|
|
@@ -60,7 +61,7 @@ describe("convertStepsToIr", () => {
|
|
|
60
61
|
// Check age field
|
|
61
62
|
const ageField = personRecord.fields.find(f => f.key === "age");
|
|
62
63
|
expect(ageField).toBeDefined();
|
|
63
|
-
expect(ageField?.
|
|
64
|
+
expect(ageField?.fieldType).toEqual({
|
|
64
65
|
type: "value",
|
|
65
66
|
value: {
|
|
66
67
|
type: "double",
|
|
@@ -72,7 +73,7 @@ describe("convertStepsToIr", () => {
|
|
|
72
73
|
const emailField = personRecord.fields.find(f => f.key === "email");
|
|
73
74
|
expect(emailField).toBeDefined();
|
|
74
75
|
expect(emailField?.isOptional).toBe(true);
|
|
75
|
-
expect(emailField?.
|
|
76
|
+
expect(emailField?.fieldType).toEqual({
|
|
76
77
|
type: "value",
|
|
77
78
|
value: {
|
|
78
79
|
type: "string",
|
|
@@ -100,7 +101,7 @@ describe("convertStepsToIr", () => {
|
|
|
100
101
|
|
|
101
102
|
// Check tags array field
|
|
102
103
|
const tagsField = containerRecord.fields.find(f => f.key === "tags");
|
|
103
|
-
expect(tagsField?.
|
|
104
|
+
expect(tagsField?.fieldType).toEqual({
|
|
104
105
|
type: "array",
|
|
105
106
|
array: {
|
|
106
107
|
allowNullValue: false,
|
|
@@ -113,7 +114,7 @@ describe("convertStepsToIr", () => {
|
|
|
113
114
|
|
|
114
115
|
// Check numbers list field (treated as array)
|
|
115
116
|
const numbersField = containerRecord.fields.find(f => f.key === "numbers");
|
|
116
|
-
expect(numbersField?.
|
|
117
|
+
expect(numbersField?.fieldType).toEqual({
|
|
117
118
|
type: "array",
|
|
118
119
|
array: {
|
|
119
120
|
allowNullValue: false,
|
|
@@ -147,7 +148,7 @@ describe("convertStepsToIr", () => {
|
|
|
147
148
|
if (personModel?.type !== "record") throw new Error("Expected record type");
|
|
148
149
|
const personRecord = personModel.record;
|
|
149
150
|
const addressField = personRecord.fields.find(f => f.key === "address");
|
|
150
|
-
expect(addressField?.
|
|
151
|
+
expect(addressField?.fieldType).toEqual({
|
|
151
152
|
type: "value",
|
|
152
153
|
value: {
|
|
153
154
|
type: "modelRef",
|
|
@@ -186,7 +187,7 @@ describe("convertStepsToIr", () => {
|
|
|
186
187
|
// Check inherited fields from fragment
|
|
187
188
|
const xField = objectNode.fields.find(f => f.key === "x");
|
|
188
189
|
expect(xField).toBeDefined();
|
|
189
|
-
expect(xField?.
|
|
190
|
+
expect(xField?.fieldType).toEqual({
|
|
190
191
|
type: "value",
|
|
191
192
|
value: {
|
|
192
193
|
type: "double",
|
|
@@ -236,7 +237,7 @@ describe("convertStepsToIr", () => {
|
|
|
236
237
|
if (graphModel?.type !== "record") throw new Error("Expected record type");
|
|
237
238
|
const graphRecord = graphModel.record;
|
|
238
239
|
const nodesField = graphRecord.fields.find(f => f.key === "nodes");
|
|
239
|
-
expect(nodesField?.
|
|
240
|
+
expect(nodesField?.fieldType).toEqual({
|
|
240
241
|
type: "array",
|
|
241
242
|
array: {
|
|
242
243
|
allowNullValue: false,
|
|
@@ -249,6 +250,59 @@ describe("convertStepsToIr", () => {
|
|
|
249
250
|
}
|
|
250
251
|
});
|
|
251
252
|
});
|
|
253
|
+
it("should convert optional array types to IR format", () => {
|
|
254
|
+
const schema = convertStepsToIr([{
|
|
255
|
+
"add-records": {
|
|
256
|
+
Tag: {
|
|
257
|
+
fields: {
|
|
258
|
+
name: "string"
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
Container: {
|
|
262
|
+
docs: "A container with optional collections",
|
|
263
|
+
fields: {
|
|
264
|
+
tags: "optional<array<Tag>>",
|
|
265
|
+
labels: "optional<array<string>>"
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}]);
|
|
270
|
+
const containerModel = schema.models["Container"];
|
|
271
|
+
expect(containerModel).toBeDefined();
|
|
272
|
+
expect(containerModel?.type).toBe("record");
|
|
273
|
+
if (containerModel?.type !== "record") throw new Error("Expected record type");
|
|
274
|
+
const containerRecord = containerModel.record;
|
|
275
|
+
|
|
276
|
+
// Check optional array of references
|
|
277
|
+
const tagsField = containerRecord.fields.find(f => f.key === "tags");
|
|
278
|
+
expect(tagsField?.isOptional).toBe(true);
|
|
279
|
+
expect(tagsField?.fieldType).toEqual({
|
|
280
|
+
type: "array",
|
|
281
|
+
array: {
|
|
282
|
+
allowNullValue: false,
|
|
283
|
+
value: {
|
|
284
|
+
type: "modelRef",
|
|
285
|
+
modelRef: {
|
|
286
|
+
modelTypes: ["Tag"]
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
// Check optional array of primitives
|
|
293
|
+
const labelsField = containerRecord.fields.find(f => f.key === "labels");
|
|
294
|
+
expect(labelsField?.isOptional).toBe(true);
|
|
295
|
+
expect(labelsField?.fieldType).toEqual({
|
|
296
|
+
type: "array",
|
|
297
|
+
array: {
|
|
298
|
+
allowNullValue: false,
|
|
299
|
+
value: {
|
|
300
|
+
type: "string",
|
|
301
|
+
string: {}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
});
|
|
252
306
|
it("should handle modify-records step", () => {
|
|
253
307
|
const schema = convertStepsToIr([{
|
|
254
308
|
"add-records": {
|
|
@@ -285,4 +339,23 @@ describe("convertStepsToIr", () => {
|
|
|
285
339
|
expect(emailField?.isOptional).toBe(true);
|
|
286
340
|
});
|
|
287
341
|
});
|
|
342
|
+
describe("parseMigrationSteps generic type validation", () => {
|
|
343
|
+
function stepsWithField(fieldType) {
|
|
344
|
+
return [{
|
|
345
|
+
"add-records": {
|
|
346
|
+
Foo: {
|
|
347
|
+
fields: {
|
|
348
|
+
bar: fieldType
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}];
|
|
353
|
+
}
|
|
354
|
+
it.each(["optional<optional<string>>", "array<array<string>>", "list<list<double>>", "array<optional<string>>", "optional<array<array<string>>>", "optional<foo<string>>", "foo<string>"])("should reject invalid nested generic type: %s", fieldType => {
|
|
355
|
+
expect(() => parseMigrationSteps(stepsWithField(fieldType))).toThrow();
|
|
356
|
+
});
|
|
357
|
+
it.each(["optional<string>", "optional<double>", "optional<MyType>", "array<string>", "list<double>", "set<MyType>", "map<string>", "optional<array<string>>", "optional<list<Tag>>", "optional<set<double>>", "optional<map<string>>"])("should accept valid generic type: %s", fieldType => {
|
|
358
|
+
expect(() => parseMigrationSteps(stepsWithField(fieldType))).not.toThrow();
|
|
359
|
+
});
|
|
360
|
+
});
|
|
288
361
|
//# sourceMappingURL=convertStepsToIr.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertStepsToIr.test.js","names":["describe","expect","it","convertStepsToIr","schema","Person","docs","fields","name","age","email","toBe","description","version","primaryModelKeys","toEqual","Object","keys","models","toHaveLength","personModel","toBeDefined","type","Error","personRecord","record","key","nameField","find","f","isOptional","toBeUndefined","value","string","ageField","double","emailField","Container","tags","numbers","containerModel","containerRecord","tagsField","array","allowNullValue","numbersField","Address","street","city","address","addressField","modelRef","modelTypes","position","x","y","ObjectNode","extends","label","objectNodeModel","objectNode","xField","yField","labelField","TextBox","text","Node","variants","object","textBox","Graph","nodes","graphModel","graphRecord","nodesField"],"sources":["convertStepsToIr.test.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 { describe, expect, it } from \"vitest\";\nimport type { IFieldTypeUnion } from \"../../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { convertStepsToIr } from \"../convertStepsToIr.js\";\nimport type { MigrationStep } from \"../parseMigrationSteps.js\";\n\ndescribe(\"convertStepsToIr\", () => {\n it(\"should convert simple record types to IR format\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n Person: {\n docs: \"A person record\",\n fields: {\n name: \"string\",\n age: \"double\",\n email: \"optional<string>\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n\n expect(schema.name).toBe(\"Generated Schema\");\n expect(schema.description).toBe(\"Schema generated from migration steps\");\n expect(schema.version).toBe(1);\n expect(schema.primaryModelKeys).toEqual([\"Person\"]);\n expect(Object.keys(schema.models)).toHaveLength(1);\n\n const personModel = schema.models[\"Person\"];\n expect(personModel).toBeDefined();\n expect(personModel?.type).toBe(\"record\");\n if (personModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const personRecord = personModel.record;\n\n expect(personRecord.key).toBe(\"Person\");\n expect(personRecord.name).toBe(\"Person\");\n expect(personRecord.description).toBe(\"A person record\");\n expect(personRecord.fields).toHaveLength(3);\n\n // Check name field\n const nameField = personRecord.fields.find(f => f.key === \"name\");\n expect(nameField).toBeDefined();\n expect(nameField?.isOptional).toBeUndefined();\n expect(nameField?.value).toEqual({\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n });\n\n // Check age field\n const ageField = personRecord.fields.find(f => f.key === \"age\");\n expect(ageField).toBeDefined();\n expect(ageField?.value).toEqual({\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n });\n\n // Check optional email field\n const emailField = personRecord.fields.find(f => f.key === \"email\");\n expect(emailField).toBeDefined();\n expect(emailField?.isOptional).toBe(true);\n expect(emailField?.value).toEqual({\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n });\n });\n\n it(\"should convert array and list types to IR format\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n Container: {\n docs: \"A container with collections\",\n fields: {\n tags: \"array<string>\",\n numbers: \"list<double>\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const containerModel = schema.models[\"Container\"];\n expect(containerModel).toBeDefined();\n expect(containerModel?.type).toBe(\"record\");\n if (containerModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const containerRecord = containerModel.record;\n\n // Check tags array field\n const tagsField = containerRecord.fields.find(f => f.key === \"tags\");\n expect(tagsField?.value).toEqual({\n type: \"array\",\n array: {\n allowNullValue: false,\n value: {\n type: \"string\",\n string: {},\n },\n },\n });\n\n // Check numbers list field (treated as array)\n const numbersField = containerRecord.fields.find(f => f.key === \"numbers\");\n expect(numbersField?.value).toEqual({\n type: \"array\",\n array: {\n allowNullValue: false,\n value: {\n type: \"double\",\n double: {},\n },\n },\n });\n });\n\n it(\"should convert record references to IR format\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n Address: {\n fields: {\n street: \"string\",\n city: \"string\",\n },\n },\n Person: {\n fields: {\n name: \"string\",\n address: \"Address\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const personModel = schema.models[\"Person\"];\n expect(personModel).toBeDefined();\n expect(personModel?.type).toBe(\"record\");\n if (personModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const personRecord = personModel.record;\n\n const addressField = personRecord.fields.find(f => f.key === \"address\");\n expect(addressField?.value).toEqual(\n {\n type: \"value\",\n value: {\n type: \"modelRef\",\n modelRef: {\n modelTypes: [\"Address\"],\n },\n },\n } satisfies IFieldTypeUnion,\n );\n });\n\n it(\"should handle local fragments and extends\", () => {\n const steps: MigrationStep[] = [\n {\n \"local-fragment\": {\n position: {\n x: \"double\",\n y: \"double\",\n },\n },\n },\n {\n \"add-records\": {\n ObjectNode: {\n docs: \"A node with position\",\n extends: [\"position\"],\n fields: {\n label: \"string\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const objectNodeModel = schema.models[\"ObjectNode\"];\n expect(objectNodeModel).toBeDefined();\n expect(objectNodeModel?.type).toBe(\"record\");\n if (objectNodeModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const objectNode = objectNodeModel.record;\n\n expect(objectNode.fields).toHaveLength(3);\n\n // Check inherited fields from fragment\n const xField = objectNode.fields.find(f => f.key === \"x\");\n expect(xField).toBeDefined();\n expect(xField?.value).toEqual({\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n });\n\n const yField = objectNode.fields.find(f => f.key === \"y\");\n expect(yField).toBeDefined();\n\n // Check own field\n const labelField = objectNode.fields.find(f => f.key === \"label\");\n expect(labelField).toBeDefined();\n });\n\n it(\"should convert unions to IR format\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n ObjectNode: {\n fields: {\n label: \"string\",\n },\n },\n TextBox: {\n fields: {\n text: \"string\",\n },\n },\n },\n },\n {\n \"add-union\": {\n Node: {\n variants: {\n object: \"ObjectNode\",\n textBox: \"TextBox\",\n },\n },\n },\n },\n {\n \"add-records\": {\n Graph: {\n fields: {\n nodes: \"array<Node>\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const graphModel = schema.models[\"Graph\"];\n if (graphModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const graphRecord = graphModel.record;\n\n const nodesField = graphRecord.fields.find(f => f.key === \"nodes\");\n expect(nodesField?.value).toEqual({\n type: \"array\",\n array: {\n allowNullValue: false,\n value: {\n type: \"modelRef\",\n modelRef: {\n modelTypes: [\"Node\"],\n },\n },\n },\n });\n });\n\n it(\"should handle modify-records step\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n Person: {\n fields: {\n name: \"string\",\n },\n },\n },\n },\n {\n \"modify-records\": {\n Person: {\n \"add-fields\": {\n age: \"double\",\n email: \"optional<string>\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const personModel = schema.models[\"Person\"];\n expect(personModel).toBeDefined();\n expect(personModel?.type).toBe(\"record\");\n if (personModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const personRecord = personModel.record;\n\n expect(personRecord.fields).toHaveLength(3);\n\n // Original field\n expect(personRecord.fields.find(f => f.key === \"name\")).toBeDefined();\n\n // Added fields\n expect(personRecord.fields.find(f => f.key === \"age\")).toBeDefined();\n\n const emailField = personRecord.fields.find(f => f.key === \"email\");\n expect(emailField).toBeDefined();\n expect(emailField?.isOptional).toBe(true);\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,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YAAY,CAACjB,MAAM,CAACqB,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACH,GAAG,KAAK,KAAK,CAAC,CAAC,CAACL,WAAW,CAAC,CAAC;IAEpE,MAAMe,UAAU,GAAGZ,YAAY,CAACjB,MAAM,CAACqB,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACH,GAAG,KAAK,OAAO,CAAC;IACnEzB,MAAM,CAACmC,UAAU,CAAC,CAACf,WAAW,CAAC,CAAC;IAChCpB,MAAM,CAACmC,UAAU,EAAEN,UAAU,CAAC,CAACnB,IAAI,CAAC,IAAI,CAAC;EAC3C,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"convertStepsToIr.test.js","names":["describe","expect","it","convertStepsToIr","parseMigrationSteps","schema","Person","docs","fields","name","age","email","toBe","description","version","primaryModelKeys","toEqual","Object","keys","models","toHaveLength","personModel","toBeDefined","type","Error","personRecord","record","key","nameField","find","f","isOptional","toBeUndefined","fieldType","value","string","ageField","double","emailField","Container","tags","numbers","containerModel","containerRecord","tagsField","array","allowNullValue","numbersField","Address","street","city","address","addressField","modelRef","modelTypes","position","x","y","ObjectNode","extends","label","objectNodeModel","objectNode","xField","yField","labelField","TextBox","text","Node","variants","object","textBox","Graph","nodes","graphModel","graphRecord","nodesField","Tag","labels","labelsField","stepsWithField","Foo","bar","each","toThrow","not"],"sources":["convertStepsToIr.test.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 { describe, expect, it } from \"vitest\";\nimport type { IFieldTypeUnion } from \"../../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { convertStepsToIr } from \"../convertStepsToIr.js\";\nimport type { MigrationStep } from \"../parseMigrationSteps.js\";\nimport { parseMigrationSteps } from \"../parseMigrationSteps.js\";\n\ndescribe(\"convertStepsToIr\", () => {\n it(\"should convert simple record types to IR format\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n Person: {\n docs: \"A person record\",\n fields: {\n name: \"string\",\n age: \"double\",\n email: \"optional<string>\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n\n expect(schema.name).toBe(\"Generated Schema\");\n expect(schema.description).toBe(\"Schema generated from migration steps\");\n expect(schema.version).toBe(1);\n expect(schema.primaryModelKeys).toEqual([\"Person\"]);\n expect(Object.keys(schema.models)).toHaveLength(1);\n\n const personModel = schema.models[\"Person\"];\n expect(personModel).toBeDefined();\n expect(personModel?.type).toBe(\"record\");\n if (personModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const personRecord = personModel.record;\n\n expect(personRecord.key).toBe(\"Person\");\n expect(personRecord.name).toBe(\"Person\");\n expect(personRecord.description).toBe(\"A person record\");\n expect(personRecord.fields).toHaveLength(3);\n\n // Check name field\n const nameField = personRecord.fields.find(f => f.key === \"name\");\n expect(nameField).toBeDefined();\n expect(nameField?.isOptional).toBeUndefined();\n expect(nameField?.fieldType).toEqual({\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n });\n\n // Check age field\n const ageField = personRecord.fields.find(f => f.key === \"age\");\n expect(ageField).toBeDefined();\n expect(ageField?.fieldType).toEqual({\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n });\n\n // Check optional email field\n const emailField = personRecord.fields.find(f => f.key === \"email\");\n expect(emailField).toBeDefined();\n expect(emailField?.isOptional).toBe(true);\n expect(emailField?.fieldType).toEqual({\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n });\n });\n\n it(\"should convert array and list types to IR format\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n Container: {\n docs: \"A container with collections\",\n fields: {\n tags: \"array<string>\",\n numbers: \"list<double>\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const containerModel = schema.models[\"Container\"];\n expect(containerModel).toBeDefined();\n expect(containerModel?.type).toBe(\"record\");\n if (containerModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const containerRecord = containerModel.record;\n\n // Check tags array field\n const tagsField = containerRecord.fields.find(f => f.key === \"tags\");\n expect(tagsField?.fieldType).toEqual({\n type: \"array\",\n array: {\n allowNullValue: false,\n value: {\n type: \"string\",\n string: {},\n },\n },\n });\n\n // Check numbers list field (treated as array)\n const numbersField = containerRecord.fields.find(f => f.key === \"numbers\");\n expect(numbersField?.fieldType).toEqual({\n type: \"array\",\n array: {\n allowNullValue: false,\n value: {\n type: \"double\",\n double: {},\n },\n },\n });\n });\n\n it(\"should convert record references to IR format\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n Address: {\n fields: {\n street: \"string\",\n city: \"string\",\n },\n },\n Person: {\n fields: {\n name: \"string\",\n address: \"Address\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const personModel = schema.models[\"Person\"];\n expect(personModel).toBeDefined();\n expect(personModel?.type).toBe(\"record\");\n if (personModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const personRecord = personModel.record;\n\n const addressField = personRecord.fields.find(f => f.key === \"address\");\n expect(addressField?.fieldType).toEqual(\n {\n type: \"value\",\n value: {\n type: \"modelRef\",\n modelRef: {\n modelTypes: [\"Address\"],\n },\n },\n } satisfies IFieldTypeUnion,\n );\n });\n\n it(\"should handle local fragments and extends\", () => {\n const steps: MigrationStep[] = [\n {\n \"local-fragment\": {\n position: {\n x: \"double\",\n y: \"double\",\n },\n },\n },\n {\n \"add-records\": {\n ObjectNode: {\n docs: \"A node with position\",\n extends: [\"position\"],\n fields: {\n label: \"string\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const objectNodeModel = schema.models[\"ObjectNode\"];\n expect(objectNodeModel).toBeDefined();\n expect(objectNodeModel?.type).toBe(\"record\");\n if (objectNodeModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const objectNode = objectNodeModel.record;\n\n expect(objectNode.fields).toHaveLength(3);\n\n // Check inherited fields from fragment\n const xField = objectNode.fields.find(f => f.key === \"x\");\n expect(xField).toBeDefined();\n expect(xField?.fieldType).toEqual({\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n });\n\n const yField = objectNode.fields.find(f => f.key === \"y\");\n expect(yField).toBeDefined();\n\n // Check own field\n const labelField = objectNode.fields.find(f => f.key === \"label\");\n expect(labelField).toBeDefined();\n });\n\n it(\"should convert unions to IR format\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n ObjectNode: {\n fields: {\n label: \"string\",\n },\n },\n TextBox: {\n fields: {\n text: \"string\",\n },\n },\n },\n },\n {\n \"add-union\": {\n Node: {\n variants: {\n object: \"ObjectNode\",\n textBox: \"TextBox\",\n },\n },\n },\n },\n {\n \"add-records\": {\n Graph: {\n fields: {\n nodes: \"array<Node>\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const graphModel = schema.models[\"Graph\"];\n if (graphModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const graphRecord = graphModel.record;\n\n const nodesField = graphRecord.fields.find(f => f.key === \"nodes\");\n expect(nodesField?.fieldType).toEqual({\n type: \"array\",\n array: {\n allowNullValue: false,\n value: {\n type: \"modelRef\",\n modelRef: {\n modelTypes: [\"Node\"],\n },\n },\n },\n });\n });\n\n it(\"should convert optional array types to IR format\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n Tag: {\n fields: {\n name: \"string\",\n },\n },\n Container: {\n docs: \"A container with optional collections\",\n fields: {\n tags: \"optional<array<Tag>>\",\n labels: \"optional<array<string>>\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const containerModel = schema.models[\"Container\"];\n expect(containerModel).toBeDefined();\n expect(containerModel?.type).toBe(\"record\");\n if (containerModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const containerRecord = containerModel.record;\n\n // Check optional array of references\n const tagsField = containerRecord.fields.find(f => f.key === \"tags\");\n expect(tagsField?.isOptional).toBe(true);\n expect(tagsField?.fieldType).toEqual({\n type: \"array\",\n array: {\n allowNullValue: false,\n value: {\n type: \"modelRef\",\n modelRef: {\n modelTypes: [\"Tag\"],\n },\n },\n },\n });\n\n // Check optional array of primitives\n const labelsField = containerRecord.fields.find(f => f.key === \"labels\");\n expect(labelsField?.isOptional).toBe(true);\n expect(labelsField?.fieldType).toEqual({\n type: \"array\",\n array: {\n allowNullValue: false,\n value: {\n type: \"string\",\n string: {},\n },\n },\n });\n });\n\n it(\"should handle modify-records step\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n Person: {\n fields: {\n name: \"string\",\n },\n },\n },\n },\n {\n \"modify-records\": {\n Person: {\n \"add-fields\": {\n age: \"double\",\n email: \"optional<string>\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const personModel = schema.models[\"Person\"];\n expect(personModel).toBeDefined();\n expect(personModel?.type).toBe(\"record\");\n if (personModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const personRecord = personModel.record;\n\n expect(personRecord.fields).toHaveLength(3);\n\n // Original field\n expect(personRecord.fields.find(f => f.key === \"name\")).toBeDefined();\n\n // Added fields\n expect(personRecord.fields.find(f => f.key === \"age\")).toBeDefined();\n\n const emailField = personRecord.fields.find(f => f.key === \"email\");\n expect(emailField).toBeDefined();\n expect(emailField?.isOptional).toBe(true);\n });\n});\n\ndescribe(\"parseMigrationSteps generic type validation\", () => {\n function stepsWithField(fieldType: string): unknown {\n return [{ \"add-records\": { Foo: { fields: { bar: fieldType } } } }];\n }\n\n it.each([\n \"optional<optional<string>>\",\n \"array<array<string>>\",\n \"list<list<double>>\",\n \"array<optional<string>>\",\n \"optional<array<array<string>>>\",\n \"optional<foo<string>>\",\n \"foo<string>\",\n ])(\"should reject invalid nested generic type: %s\", fieldType => {\n expect(() => parseMigrationSteps(stepsWithField(fieldType))).toThrow();\n });\n\n it.each([\n \"optional<string>\",\n \"optional<double>\",\n \"optional<MyType>\",\n \"array<string>\",\n \"list<double>\",\n \"set<MyType>\",\n \"map<string>\",\n \"optional<array<string>>\",\n \"optional<list<Tag>>\",\n \"optional<set<double>>\",\n \"optional<map<string>>\",\n ])(\"should accept valid generic type: %s\", fieldType => {\n expect(() => parseMigrationSteps(stepsWithField(fieldType))).not.toThrow();\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,gBAAgB,QAAQ,wBAAwB;AAEzD,SAASC,mBAAmB,QAAQ,2BAA2B;AAE/DJ,QAAQ,CAAC,kBAAkB,EAAE,MAAM;EACjCE,EAAE,CAAC,iDAAiD,EAAE,MAAM;IAgB1D,MAAMG,MAAM,GAAGF,gBAAgB,CAfA,CAC7B;MACE,aAAa,EAAE;QACbG,MAAM,EAAE;UACNC,IAAI,EAAE,iBAAiB;UACvBC,MAAM,EAAE;YACNC,IAAI,EAAE,QAAQ;YACdC,GAAG,EAAE,QAAQ;YACbC,KAAK,EAAE;UACT;QACF;MACF;IACF,CAAC,CAGkC,CAAC;IAEtCV,MAAM,CAACI,MAAM,CAACI,IAAI,CAAC,CAACG,IAAI,CAAC,kBAAkB,CAAC;IAC5CX,MAAM,CAACI,MAAM,CAACQ,WAAW,CAAC,CAACD,IAAI,CAAC,uCAAuC,CAAC;IACxEX,MAAM,CAACI,MAAM,CAACS,OAAO,CAAC,CAACF,IAAI,CAAC,CAAC,CAAC;IAC9BX,MAAM,CAACI,MAAM,CAACU,gBAAgB,CAAC,CAACC,OAAO,CAAC,CAAC,Q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CAAC;IAChCrB,MAAM,CAACqC,UAAU,EAAEP,UAAU,CAAC,CAACnB,IAAI,CAAC,IAAI,CAAC;EAC3C,CAAC,CAAC;AACJ,CAAC,CAAC;AAEFZ,QAAQ,CAAC,6CAA6C,EAAE,MAAM;EAC5D,SAASgF,cAAcA,CAAC/C,SAAiB,EAAW;IAClD,OAAO,CAAC;MAAE,aAAa,EAAE;QAAEgD,GAAG,EAAE;UAAEzE,MAAM,EAAE;YAAE0E,GAAG,EAAEjD;UAAU;QAAE;MAAE;IAAE,CAAC,CAAC;EACrE;EAEA/B,EAAE,CAACiF,IAAI,CAAC,CACN,4BAA4B,EAC5B,sBAAsB,EACtB,oBAAoB,EACpB,yBAAyB,EACzB,gCAAgC,EAChC,uBAAuB,EACvB,aAAa,CACd,CAAC,CAAC,+CAA+C,EAAElD,SAAS,IAAI;IAC/DhC,MAAM,CAAC,MAAMG,mBAAmB,CAAC4E,cAAc,CAAC/C,SAAS,CAAC,CAAC,CAAC,CAACmD,OAAO,CAAC,CAAC;EACxE,CAAC,CAAC;EAEFlF,EAAE,CAACiF,IAAI,CAAC,CACN,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,aAAa,EACb,aAAa,EACb,yBAAyB,EACzB,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,CACxB,CAAC,CAAC,sCAAsC,EAAElD,SAAS,IAAI;IACtDhC,MAAM,CAAC,MAAMG,mBAAmB,CAAC4E,cAAc,CAAC/C,SAAS,CAAC,CAAC,CAAC,CAACoD,GAAG,CAACD,OAAO,CAAC,CAAC;EAC5E,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -75,9 +75,9 @@ export function convertRecordDefToIr(recordDef) {
|
|
|
75
75
|
key: fieldKey,
|
|
76
76
|
name: fieldKey,
|
|
77
77
|
description: undefined,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
fieldType: convertTypeToFieldTypeUnion(fieldType),
|
|
79
|
+
metadata: {
|
|
80
|
+
addedInVersion: 1
|
|
81
81
|
},
|
|
82
82
|
isOptional: fieldType.type === "optional" ? true : undefined
|
|
83
83
|
}));
|
|
@@ -86,8 +86,8 @@ export function convertRecordDefToIr(recordDef) {
|
|
|
86
86
|
name: recordDef.name,
|
|
87
87
|
description: recordDef.docs || undefined,
|
|
88
88
|
fields,
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
metadata: {
|
|
90
|
+
addedInVersion: 1
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
}
|
|
@@ -99,8 +99,8 @@ export function convertUnionDefToIr(unionDef) {
|
|
|
99
99
|
description: unionDef.docs,
|
|
100
100
|
discriminant: unionDef.discriminant,
|
|
101
101
|
variants: Object.fromEntries(variantEntries),
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
metadata: {
|
|
103
|
+
addedInVersion: 1
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
106
|
}
|
|
@@ -151,9 +151,7 @@ function convertTypeToFieldValueUnion(schemaType) {
|
|
|
151
151
|
case "double":
|
|
152
152
|
return IFieldValueUnion.double({});
|
|
153
153
|
case "mediaRef":
|
|
154
|
-
return IFieldValueUnion.mediaRef({
|
|
155
|
-
mediaTypeRids: [] // FIXME: confirm whether we will use rids in the deployed schema.
|
|
156
|
-
});
|
|
154
|
+
return IFieldValueUnion.mediaRef({});
|
|
157
155
|
case "objectRef":
|
|
158
156
|
return IFieldValueUnion.object({
|
|
159
157
|
// FIXME: confirm whether we will use rids in the deployed schema.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertStepsToIr.js","names":["invariant","IFieldTypeUnion","IFieldValueUnion","IModelDef","assertNever","convertStepsToSchema","convertStepsToIr","steps","metadata","recordDefinitions","unionDefinitions","schema","Object","fromEntries","map","def","name","convertSchemaToIr","inputSchema","primaryModelKeys","models","Map","modelDef","values","collectModels","push","description","version","outModels","has","process","env","NODE_ENV","type","set","record","convertRecordDefToIr","union","convertUnionDefToIr","recordDef","fields","entries","fieldKey","fieldType","key","undefined","value","convertTypeToFieldTypeUnion","meta","addedIn","isOptional","docs","unionDef","variantEntries","variants","variantName","modelRef","discriminant","schemaType","array","allowNullValue","convertTypeToFieldValueUnion","items","item","boolean","docRef","documentTypeRids","double","mediaRef","mediaTypeRids","object","interfaceTypeRids","objectTypeRids","modelTypes","string","unmanagedJson","userRef"],"sources":["convertStepsToIr.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 * as P from \"@palantir/pack.schema\";\nimport invariant from \"tiny-invariant\";\nimport type {\n IModelTypeKey,\n IUnionVariantKey,\n} from \"../../lib/pack-docschema-api/pack-docschema-api\";\nimport type {\n IFieldDef,\n IRealTimeDocumentSchema,\n IRecordDef,\n IUnionDef,\n} from \"../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport {\n IFieldTypeUnion,\n IFieldValueUnion,\n IModelDef,\n} from \"../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { assertNever } from \"../assertNever.js\";\nimport { convertStepsToSchema } from \"./convertStepsToSchema.js\";\nimport type { MigrationStep } from \"./parseMigrationSteps.js\";\n\nexport interface SchemaMetadata {\n readonly name?: string;\n readonly description?: string;\n readonly version?: number;\n}\n\n/**\n * Converts migration steps to Palantir IR format\n */\nexport function convertStepsToIr(\n steps: readonly MigrationStep[],\n metadata?: SchemaMetadata,\n): IRealTimeDocumentSchema {\n // First convert steps to document-schema-api format\n const { recordDefinitions, unionDefinitions } = convertStepsToSchema(steps as MigrationStep[]);\n\n const schema = {\n ...Object.fromEntries(recordDefinitions.map(def => [def.name, def])),\n ...Object.fromEntries(unionDefinitions.map(def => [def.name, def])),\n };\n\n return convertSchemaToIr(schema, metadata);\n}\n\n/**\n * Converts record and union definitions to Palantir IR format\n */\nexport function convertSchemaToIr(\n inputSchema: P.Schema<P.ReturnedSchema>,\n metadata?: SchemaMetadata,\n): IRealTimeDocumentSchema {\n const primaryModelKeys: IModelTypeKey[] = [];\n const models = new Map<IModelTypeKey, IModelDef>();\n\n for (const modelDef of Object.values(inputSchema)) {\n if (collectModels(modelDef, models)) {\n primaryModelKeys.push(modelDef.name);\n }\n }\n\n return {\n name: metadata?.name ?? \"Generated Schema\",\n description: metadata?.description ?? \"Schema generated from migration steps\",\n version: metadata?.version ?? 1,\n primaryModelKeys,\n models: Object.fromEntries(models),\n };\n}\n\nfunction collectModels(\n modelDef: P.ModelDef,\n outModels: Map<IModelTypeKey, IModelDef>,\n): boolean {\n invariant(\n !outModels.has(modelDef.name),\n `Duplicate model definition: ${modelDef.name}`,\n );\n\n switch (modelDef.type) {\n case \"record\": {\n outModels.set(modelDef.name, IModelDef.record(convertRecordDefToIr(modelDef)));\n return true;\n }\n case \"union\": {\n outModels.set(modelDef.name, IModelDef.union(convertUnionDefToIr(modelDef)));\n return true;\n }\n default:\n assertNever(modelDef);\n }\n}\n\nexport function convertRecordDefToIr(recordDef: P.RecordDef): IRecordDef {\n const fields = Object.entries(recordDef.fields).map(([fieldKey, fieldType]): IFieldDef => ({\n key: fieldKey,\n name: fieldKey,\n description: undefined,\n value: convertTypeToFieldTypeUnion(fieldType),\n meta: { addedIn: 1 },\n isOptional: fieldType.type === \"optional\" ? true : undefined,\n }));\n\n return {\n key: recordDef.name,\n name: recordDef.name,\n description: recordDef.docs || undefined,\n fields,\n meta: { addedIn: 1 },\n };\n}\n\nexport function convertUnionDefToIr(unionDef: P.UnionDef): IUnionDef {\n const variantEntries = Object.entries(unionDef.variants).map((\n [variantName, modelRef],\n ) =>\n [\n variantName as IUnionVariantKey,\n modelRef.name as IModelTypeKey,\n ] as const\n );\n\n return {\n key: unionDef.name,\n name: unionDef.name,\n description: unionDef.docs,\n discriminant: unionDef.discriminant,\n variants: Object.fromEntries(variantEntries),\n meta: { addedIn: 1 },\n };\n}\n\n// TODO: rename to convertSchemaTypeToFieldTypeUnion\nexport function convertTypeToFieldTypeUnion(schemaType: P.Type): IFieldTypeUnion {\n switch (schemaType.type) {\n case \"array\": {\n const arrayType = schemaType as P.Array;\n return IFieldTypeUnion.array({\n allowNullValue: false,\n value: convertTypeToFieldValueUnion(arrayType.items as P.Type),\n });\n }\n // TODO: have map/set types in document-schema-api\n\n case \"optional\": {\n // Optional flag is handled at field level, but we need to unwrap the inner type\n const optionalType = schemaType as P.Optional;\n return convertTypeToFieldTypeUnion(optionalType.item as P.Type);\n }\n\n case \"boolean\":\n case \"docRef\":\n case \"double\":\n case \"mediaRef\":\n case \"objectRef\":\n case \"ref\":\n case \"string\":\n case \"unknown\":\n case \"userRef\":\n return IFieldTypeUnion.value(convertTypeToFieldValueUnion(schemaType));\n\n default:\n assertNever(schemaType);\n }\n}\n\nfunction convertTypeToFieldValueUnion(schemaType: P.Type): IFieldValueUnion {\n switch (schemaType.type) {\n case \"array\":\n // TODO: fix the argument types so these aren't possible\n invariant(\n false,\n `Collection type passed to convertTypeToFieldValueUnion: ${schemaType.type}`,\n );\n\n case \"boolean\":\n return IFieldValueUnion.boolean({});\n\n case \"docRef\":\n return IFieldValueUnion.docRef({\n documentTypeRids: [], // FIXME: confirm whether we will use rids in the deployed schema.\n });\n\n case \"double\":\n return IFieldValueUnion.double({});\n\n case \"mediaRef\":\n return IFieldValueUnion.mediaRef({\n mediaTypeRids: [], // FIXME: confirm whether we will use rids in the deployed schema.\n });\n\n case \"objectRef\":\n return IFieldValueUnion.object({\n // FIXME: confirm whether we will use rids in the deployed schema.\n interfaceTypeRids: [],\n objectTypeRids: [],\n });\n\n case \"optional\": {\n // If we get here, it means we have nested optionals - unwrap and continue\n // TODO: probably warn? maybe throw\n const optionalType = schemaType as P.Optional;\n return convertTypeToFieldValueUnion(optionalType.item as P.Type);\n }\n\n case \"ref\":\n return IFieldValueUnion.modelRef({\n modelTypes: [schemaType.name as IModelTypeKey],\n });\n\n case \"string\":\n return IFieldValueUnion.string({});\n\n case \"unknown\":\n return IFieldValueUnion.unmanagedJson({});\n\n case \"userRef\":\n return IFieldValueUnion.userRef({});\n\n default:\n assertNever(schemaType);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,SAAS,MAAM,gBAAgB;AAWtC,SACEC,eAAe,EACfC,gBAAgB,EAChBC,SAAS,QACJ,yDAAyD;AAChE,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,oBAAoB,QAAQ,2BAA2B;AAShE;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAC9BC,KAA+B,EAC/BC,QAAyB,EACA;EACzB;EACA,MAAM;IAAEC,iBAAiB;IAAEC;EAAiB,CAAC,GAAGL,oBAAoB,CAACE,KAAwB,CAAC;EAE9F,MAAMI,MAAM,GAAG;IACb,GAAGC,MAAM,CAACC,WAAW,CAACJ,iBAAiB,CAACK,GAAG,CAACC,GAAG,IAAI,CAACA,GAAG,CAACC,IAAI,EAAED,GAAG,CAAC,CAAC,CAAC;IACpE,GAAGH,MAAM,CAACC,WAAW,CAACH,gBAAgB,CAACI,GAAG,CAACC,GAAG,IAAI,CAACA,GAAG,CAACC,IAAI,EAAED,GAAG,CAAC,CAAC;EACpE,CAAC;EAED,OAAOE,iBAAiB,CAACN,MAAM,EAAEH,QAAQ,CAAC;AAC5C;;AAEA;AACA;AACA;AACA,OAAO,SAASS,iBAAiBA,CAC/BC,WAAuC,EACvCV,QAAyB,EACA;EACzB,MAAMW,gBAAiC,GAAG,EAAE;EAC5C,MAAMC,MAAM,GAAG,IAAIC,GAAG,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EAAE;QACrBC,cAAc,EAAE;MAClB,CAAC,CAAC;IAEJ,KAAK,UAAU;MAAE;QACf;QACA;;QAEA,OAAOX,4BAA4B,CADdH,UAAU,CACkBK,IAAc,CAAC;MAClE;IAEA,KAAK,KAAK;MACR,OAAO7D,gBAAgB,CAACsD,QAAQ,CAAC;QAC/BiB,UAAU,EAAE,CAACf,UAAU,CAAC1C,IAAI;MAC9B,CAAC,CAAC;IAEJ,KAAK,QAAQ;MACX,OAAOd,gBAAgB,CAACwE,MAAM,CAAC,CAAC,CAAC,CAAC;IAEpC,KAAK,SAAS;MACZ,OAAOxE,gBAAgB,CAACyE,aAAa,CAAC,CAAC,CAAC,CAAC;IAE3C,KAAK,SAAS;MACZ,OAAOzE,gBAAgB,CAAC0E,OAAO,CAAC,CAAC,CAAC,CAAC;IAErC;MACExE,WAAW,CAACsD,UAAU,CAAC;EAC3B;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"convertStepsToIr.js","names":["invariant","IFieldTypeUnion","IFieldValueUnion","IModelDef","assertNever","convertStepsToSchema","convertStepsToIr","steps","metadata","recordDefinitions","unionDefinitions","schema","Object","fromEntries","map","def","name","convertSchemaToIr","inputSchema","primaryModelKeys","models","Map","modelDef","values","collectModels","push","description","version","outModels","has","process","env","NODE_ENV","type","set","record","convertRecordDefToIr","union","convertUnionDefToIr","recordDef","fields","entries","fieldKey","fieldType","key","undefined","convertTypeToFieldTypeUnion","addedInVersion","isOptional","docs","unionDef","variantEntries","variants","variantName","modelRef","discriminant","schemaType","array","allowNullValue","value","convertTypeToFieldValueUnion","items","item","boolean","docRef","documentTypeRids","double","mediaRef","object","interfaceTypeRids","objectTypeRids","modelTypes","string","unmanagedJson","userRef"],"sources":["convertStepsToIr.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 * as P from \"@palantir/pack.schema\";\nimport invariant from \"tiny-invariant\";\nimport type {\n IModelTypeKey,\n IUnionVariantKey,\n} from \"../../lib/pack-docschema-api/pack-docschema-api\";\nimport type {\n IFieldDef,\n IRealTimeDocumentSchema,\n IRecordDef,\n IUnionDef,\n} from \"../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport {\n IFieldTypeUnion,\n IFieldValueUnion,\n IModelDef,\n} from \"../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { assertNever } from \"../assertNever.js\";\nimport { convertStepsToSchema } from \"./convertStepsToSchema.js\";\nimport type { MigrationStep } from \"./parseMigrationSteps.js\";\n\nexport interface SchemaMetadata {\n readonly name?: string;\n readonly description?: string;\n readonly version?: number;\n}\n\n/**\n * Converts migration steps to Palantir IR format\n */\nexport function convertStepsToIr(\n steps: readonly MigrationStep[],\n metadata?: SchemaMetadata,\n): IRealTimeDocumentSchema {\n // First convert steps to document-schema-api format\n const { recordDefinitions, unionDefinitions } = convertStepsToSchema(steps as MigrationStep[]);\n\n const schema = {\n ...Object.fromEntries(recordDefinitions.map(def => [def.name, def])),\n ...Object.fromEntries(unionDefinitions.map(def => [def.name, def])),\n };\n\n return convertSchemaToIr(schema, metadata);\n}\n\n/**\n * Converts record and union definitions to Palantir IR format\n */\nexport function convertSchemaToIr(\n inputSchema: P.Schema<P.ReturnedSchema>,\n metadata?: SchemaMetadata,\n): IRealTimeDocumentSchema {\n const primaryModelKeys: IModelTypeKey[] = [];\n const models = new Map<IModelTypeKey, IModelDef>();\n\n for (const modelDef of Object.values(inputSchema)) {\n if (collectModels(modelDef, models)) {\n primaryModelKeys.push(modelDef.name);\n }\n }\n\n return {\n name: metadata?.name ?? \"Generated Schema\",\n description: metadata?.description ?? \"Schema generated from migration steps\",\n version: metadata?.version ?? 1,\n primaryModelKeys,\n models: Object.fromEntries(models),\n };\n}\n\nfunction collectModels(\n modelDef: P.ModelDef,\n outModels: Map<IModelTypeKey, IModelDef>,\n): boolean {\n invariant(\n !outModels.has(modelDef.name),\n `Duplicate model definition: ${modelDef.name}`,\n );\n\n switch (modelDef.type) {\n case \"record\": {\n outModels.set(modelDef.name, IModelDef.record(convertRecordDefToIr(modelDef)));\n return true;\n }\n case \"union\": {\n outModels.set(modelDef.name, IModelDef.union(convertUnionDefToIr(modelDef)));\n return true;\n }\n default:\n assertNever(modelDef);\n }\n}\n\nexport function convertRecordDefToIr(recordDef: P.RecordDef): IRecordDef {\n const fields = Object.entries(recordDef.fields).map(([fieldKey, fieldType]): IFieldDef => ({\n key: fieldKey,\n name: fieldKey,\n description: undefined,\n fieldType: convertTypeToFieldTypeUnion(fieldType),\n metadata: { addedInVersion: 1 },\n isOptional: fieldType.type === \"optional\" ? true : undefined,\n }));\n\n return {\n key: recordDef.name,\n name: recordDef.name,\n description: recordDef.docs || undefined,\n fields,\n metadata: { addedInVersion: 1 },\n };\n}\n\nexport function convertUnionDefToIr(unionDef: P.UnionDef): IUnionDef {\n const variantEntries = Object.entries(unionDef.variants).map((\n [variantName, modelRef],\n ) =>\n [\n variantName as IUnionVariantKey,\n modelRef.name as IModelTypeKey,\n ] as const\n );\n\n return {\n key: unionDef.name,\n name: unionDef.name,\n description: unionDef.docs,\n discriminant: unionDef.discriminant,\n variants: Object.fromEntries(variantEntries),\n metadata: { addedInVersion: 1 },\n };\n}\n\n// TODO: rename to convertSchemaTypeToFieldTypeUnion\nexport function convertTypeToFieldTypeUnion(schemaType: P.Type): IFieldTypeUnion {\n switch (schemaType.type) {\n case \"array\": {\n const arrayType = schemaType as P.Array;\n return IFieldTypeUnion.array({\n allowNullValue: false,\n value: convertTypeToFieldValueUnion(arrayType.items as P.Type),\n });\n }\n // TODO: have map/set types in document-schema-api\n\n case \"optional\": {\n // Optional flag is handled at field level, but we need to unwrap the inner type\n const optionalType = schemaType as P.Optional;\n return convertTypeToFieldTypeUnion(optionalType.item as P.Type);\n }\n\n case \"boolean\":\n case \"docRef\":\n case \"double\":\n case \"mediaRef\":\n case \"objectRef\":\n case \"ref\":\n case \"string\":\n case \"unknown\":\n case \"userRef\":\n return IFieldTypeUnion.value(convertTypeToFieldValueUnion(schemaType));\n\n default:\n assertNever(schemaType);\n }\n}\n\nfunction convertTypeToFieldValueUnion(schemaType: P.Type): IFieldValueUnion {\n switch (schemaType.type) {\n case \"array\":\n // TODO: fix the argument types so these aren't possible\n invariant(\n false,\n `Collection type passed to convertTypeToFieldValueUnion: ${schemaType.type}`,\n );\n\n case \"boolean\":\n return IFieldValueUnion.boolean({});\n\n case \"docRef\":\n return IFieldValueUnion.docRef({\n documentTypeRids: [], // FIXME: confirm whether we will use rids in the deployed schema.\n });\n\n case \"double\":\n return IFieldValueUnion.double({});\n\n case \"mediaRef\":\n return IFieldValueUnion.mediaRef({});\n\n case \"objectRef\":\n return IFieldValueUnion.object({\n // FIXME: confirm whether we will use rids in the deployed schema.\n interfaceTypeRids: [],\n objectTypeRids: [],\n });\n\n case \"optional\": {\n // If we get here, it means we have nested optionals - unwrap and continue\n // TODO: probably warn? maybe throw\n const optionalType = schemaType as P.Optional;\n return convertTypeToFieldValueUnion(optionalType.item as P.Type);\n }\n\n case \"ref\":\n return IFieldValueUnion.modelRef({\n modelTypes: [schemaType.name as IModelTypeKey],\n });\n\n case \"string\":\n return IFieldValueUnion.string({});\n\n case \"unknown\":\n return IFieldValueUnion.unmanagedJson({});\n\n case \"userRef\":\n return IFieldValueUnion.userRef({});\n\n default:\n assertNever(schemaType);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,SAAS,MAAM,gBAAgB;AAWtC,SACEC,eAAe,EACfC,gBAAgB,EACh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,CAAC,CAAC;IAErC;MACEtE,WAAW,CAACoD,UAAU,CAAC;EAC3B;AACF","ignoreList":[]}
|
|
@@ -26,8 +26,10 @@ import z from "zod";
|
|
|
26
26
|
// Define allowed primitive types (matching TypeKind from document-schema-api)
|
|
27
27
|
const primitiveType = z.enum(["string", "double"]);
|
|
28
28
|
|
|
29
|
-
// Define generic type patterns like "optional<T>", "list<T>", "array<T>"
|
|
30
|
-
|
|
29
|
+
// Define generic type patterns like "optional<T>", "list<T>", "array<T>", "optional<array<T>>"
|
|
30
|
+
// Flat: (optional|list|array|set|map)<primitive_or_TypeRef>
|
|
31
|
+
// Nested: optional<(list|array|set|map)<primitive_or_TypeRef>>
|
|
32
|
+
const genericTypePattern = z.string().regex(/^(?:(?:list|array|set|map)<[^<>]+>|optional<(?:[^<>]+|(?:list|array|set|map)<[^<>]+>)>)$/, {
|
|
31
33
|
message: "Invalid generic type pattern"
|
|
32
34
|
});
|
|
33
35
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseMigrationSteps.js","names":["z","primitiveType","enum","genericTypePattern","string","regex","message","typeReference","basicType","union","complexFieldDefinition","object","type","docs","optional","recordFieldDefinition","recordFieldKey","fragmentKey","localFragment","record","addRecords","extends","array","fields","unionDefinition","discriminant","variants","addUnion","modifyRecords","migrationStep","migrationStepsSchema","parseMigrationSteps","unparsed","parsed","parse"],"sources":["parseMigrationSteps.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 z from \"zod\";\n\n// Type definitions for the migration steps\n// Note: These match the YAML syntax, not the P.Type objects\n// Only \"string\" and \"double\" are valid primitives in P.TypeKind\ntype PrimitiveType = \"string\" | \"double\";\n\ninterface ComplexFieldDefinition {\n type: string; // Can be primitive, generic pattern, or type reference\n docs?: string;\n}\n\n// RecordFieldDefinition represents the YAML field values\n// Can be: \"string\", \"double\", \"optional<T>\", \"list<T>\", \"ObjectNode\", or a complex definition\ntype RecordFieldDefinition = string | ComplexFieldDefinition;\n\ninterface RecordDefinition {\n docs?: string;\n extends?: string[];\n fields: Record<string, RecordFieldDefinition>;\n}\n\ninterface UnionDefinition {\n discriminant?: string;\n variants: Record<string, string>;\n}\n\ninterface MigrationStep {\n \"local-fragment\"?: Record<string, Record<string, RecordFieldDefinition>>;\n \"add-records\"?: Record<string, RecordDefinition>;\n \"add-union\"?: Record<string, UnionDefinition>;\n \"modify-records\"?: Record<string, { \"add-fields\": Record<string, RecordFieldDefinition> }>;\n}\n\n// Define allowed primitive types (matching TypeKind from document-schema-api)\nconst primitiveType: z.ZodType<PrimitiveType> = z.enum([\"string\", \"double\"]);\n\n// Define generic type patterns like \"optional<T>\", \"list<T>\", \"array<T>\"\nconst genericTypePattern: z.ZodType<string> = z\n .string()\n .regex(/^(optional
|
|
1
|
+
{"version":3,"file":"parseMigrationSteps.js","names":["z","primitiveType","enum","genericTypePattern","string","regex","message","typeReference","basicType","union","complexFieldDefinition","object","type","docs","optional","recordFieldDefinition","recordFieldKey","fragmentKey","localFragment","record","addRecords","extends","array","fields","unionDefinition","discriminant","variants","addUnion","modifyRecords","migrationStep","migrationStepsSchema","parseMigrationSteps","unparsed","parsed","parse"],"sources":["parseMigrationSteps.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 z from \"zod\";\n\n// Type definitions for the migration steps\n// Note: These match the YAML syntax, not the P.Type objects\n// Only \"string\" and \"double\" are valid primitives in P.TypeKind\ntype PrimitiveType = \"string\" | \"double\";\n\ninterface ComplexFieldDefinition {\n type: string; // Can be primitive, generic pattern, or type reference\n docs?: string;\n}\n\n// RecordFieldDefinition represents the YAML field values\n// Can be: \"string\", \"double\", \"optional<T>\", \"list<T>\", \"ObjectNode\", or a complex definition\ntype RecordFieldDefinition = string | ComplexFieldDefinition;\n\ninterface RecordDefinition {\n docs?: string;\n extends?: string[];\n fields: Record<string, RecordFieldDefinition>;\n}\n\ninterface UnionDefinition {\n discriminant?: string;\n variants: Record<string, string>;\n}\n\ninterface MigrationStep {\n \"local-fragment\"?: Record<string, Record<string, RecordFieldDefinition>>;\n \"add-records\"?: Record<string, RecordDefinition>;\n \"add-union\"?: Record<string, UnionDefinition>;\n \"modify-records\"?: Record<string, { \"add-fields\": Record<string, RecordFieldDefinition> }>;\n}\n\n// Define allowed primitive types (matching TypeKind from document-schema-api)\nconst primitiveType: z.ZodType<PrimitiveType> = z.enum([\"string\", \"double\"]);\n\n// Define generic type patterns like \"optional<T>\", \"list<T>\", \"array<T>\", \"optional<array<T>>\"\n// Flat: (optional|list|array|set|map)<primitive_or_TypeRef>\n// Nested: optional<(list|array|set|map)<primitive_or_TypeRef>>\nconst genericTypePattern: z.ZodType<string> = z\n .string()\n .regex(\n /^(?:(?:list|array|set|map)<[^<>]+>|optional<(?:[^<>]+|(?:list|array|set|map)<[^<>]+>)>)$/,\n {\n message: \"Invalid generic type pattern\",\n },\n );\n\n// Reference to other record/union types (capitalized names)\nconst typeReference: z.ZodType<string> = z.string().regex(/^[A-Z][a-zA-Z0-9]*$/, {\n message: \"Type references must be capitalized\",\n});\n\nconst basicType: z.ZodType<string> = z.union([primitiveType, genericTypePattern]);\n\n// Complex field definition object (for future extensibility)\nconst complexFieldDefinition: z.ZodType<ComplexFieldDefinition> = z.object({\n type: basicType,\n docs: z.string().optional(),\n // This can be extended with e.g. constraints like min/max value or length, in the future\n});\n\n// Union of all allowed field definition types - more specific than just z.string()\nconst recordFieldDefinition: z.ZodType<RecordFieldDefinition> = z.union([\n primitiveType,\n genericTypePattern,\n typeReference,\n complexFieldDefinition,\n]);\n\n// Keep as simple strings for now to maintain compatibility with existing code\nconst recordFieldKey = z.string(); // TODO: could be improved w/ regex if we want to control format\nconst fragmentKey = z.string();\n\nconst localFragment: z.ZodType<Record<string, Record<string, RecordFieldDefinition>>> = z\n .record(\n fragmentKey,\n z.record(recordFieldKey, recordFieldDefinition),\n );\nconst addRecords: z.ZodType<Record<string, RecordDefinition>> = z.record(\n z.string().regex(/^[A-Z][a-zA-Z0-9]*$/), // Keys must be capitalized type names\n z.object({\n docs: z.optional(z.string()),\n extends: z.array(z.string()).optional(),\n fields: z.record(recordFieldKey, recordFieldDefinition),\n }),\n);\n\nconst unionDefinition: z.ZodType<UnionDefinition> = z.object({\n discriminant: z.string().optional(),\n variants: z.record(z.string(), z.string().regex(/^[A-Z][a-zA-Z0-9]*$/)),\n});\n\nconst addUnion: z.ZodType<Record<string, UnionDefinition>> = z.record(\n z.string().regex(/^[A-Z][a-zA-Z0-9]*$/), // Union names must be capitalized\n unionDefinition,\n);\n\nconst modifyRecords: z.ZodType<\n Record<string, { \"add-fields\": Record<string, RecordFieldDefinition> }>\n> = z.record(\n z.string().regex(/^[A-Z][a-zA-Z0-9]*$/), // Record names must be capitalized\n z.object({\n \"add-fields\": z.record(recordFieldKey, recordFieldDefinition),\n }),\n);\n\nconst migrationStep: z.ZodType<MigrationStep> = z.object({\n \"local-fragment\": z.optional(localFragment),\n \"add-records\": z.optional(addRecords),\n \"add-union\": z.optional(addUnion),\n \"modify-records\": z.optional(modifyRecords),\n});\n\nconst migrationStepsSchema: z.ZodType<MigrationStep[]> = z.array(migrationStep);\n\nexport type { MigrationStep, RecordFieldDefinition, UnionDefinition };\n\nexport function parseMigrationSteps(unparsed: unknown): MigrationStep[] {\n const parsed = migrationStepsSchema.parse(unparsed);\n return parsed;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,CAAC,MAAM,KAAK;;AAEnB;AACA;AACA;;AAQA;AACA;;AAqBA;AACA,MAAMC,aAAuC,GAAGD,CAAC,CAACE,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;;AAE5E;AACA;AACA;AACA,MAAMC,kBAAqC,GAAGH,CAAC,CAC5CI,MAAM,CAAC,CAAC,CACRC,KAAK,CACJ,0FAA0F,EAC1F;EACEC,OAAO,EAAE;AACX,CACF,CAAC;;AAEH;AACA,MAAMC,aAAgC,GAAGP,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,KAAK,CAAC,qBAAqB,EAAE;EAC/EC,OAAO,EAAE;AACX,CAAC,CAAC;AAEF,MAAME,SAA4B,GAAGR,CAAC,CAACS,KAAK,CAAC,CAACR,aAAa,EAAEE,kBAAkB,CAAC,CAAC;;AAEjF;AACA,MAAMO,sBAAyD,GAAGV,CAAC,CAACW,MAAM,CAAC;EACzEC,IAAI,EAAEJ,SAAS;EACfK,IAAI,EAAEb,CAAC,CAACI,MAAM,CAAC,CAAC,CAACU,QAAQ,CAAC;EAC1B;AACF,CAAC,CAAC;;AAEF;AACA,MAAMC,qBAAuD,GAAGf,CAAC,CAACS,KAAK,CAAC,CACtER,aAAa,EACbE,kBAAkB,EAClBI,aAAa,EACbG,sBAAsB,CACvB,CAAC;;AAEF;AACA,MAAMM,cAAc,GAAGhB,CAAC,CAACI,MAAM,CAAC,CAAC,CAAC,CAAC;AACnC,MAAMa,WAAW,GAAGjB,CAAC,CAACI,MAAM,CAAC,CAAC;AAE9B,MAAMc,aAA+E,GAAGlB,CAAC,CACtFm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7B,CAAC,CAACW,MAAM,CAAC;EACvD,gBAAgB,EAAEX,CAAC,CAACc,QAAQ,CAACI,aAAa,CAAC;EAC3C,aAAa,EAAElB,CAAC,CAACc,QAAQ,CAACM,UAAU,CAAC;EACrC,WAAW,EAAEpB,CAAC,CAACc,QAAQ,CAACa,QAAQ,CAAC;EACjC,gBAAgB,EAAE3B,CAAC,CAACc,QAAQ,CAACc,aAAa;AAC5C,CAAC,CAAC;AAEF,MAAME,oBAAgD,GAAG9B,CAAC,CAACsB,KAAK,CAACO,aAAa,CAAC;AAI/E,OAAO,SAASE,mBAAmBA,CAACC,QAAiB,EAAmB;EACtE,MAAMC,MAAM,GAAGH,oBAAoB,CAACI,KAAK,CAACF,QAAQ,CAAC;EACnD,OAAOC,MAAM;AACf","ignoreList":[]}
|
package/build/types/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAsBA,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAcxC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface AssetDeployOptions {
|
|
2
|
+
readonly input: string;
|
|
3
|
+
readonly baseUrl: string;
|
|
4
|
+
readonly auth: string;
|
|
5
|
+
readonly ontologyRid: string;
|
|
6
|
+
}
|
|
7
|
+
/** Useful for manually deploying a document type during development to test schema changes. */
|
|
8
|
+
export declare function assetDeployHandler(options: AssetDeployOptions): Promise<void>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=assetDeployHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assetDeployHandler.d.ts","sourceRoot":"","sources":["../../../../src/commands/asset/assetDeployHandler.ts"],"names":[],"mappings":"AAyBA,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,+FAA+F;AAC/F,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyCnF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerAssetCommands.d.ts","sourceRoot":"","sources":["../../../../src/commands/asset/registerAssetCommands.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAa5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"irDeployHandler.d.ts","sourceRoot":"","sources":["../../../../src/commands/ir/irDeployHandler.ts"],"names":[],"mappings":"AAyBA,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"irDeployHandler.d.ts","sourceRoot":"","sources":["../../../../src/commands/ir/irDeployHandler.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,UAAU,aAAa;IACrB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;CACzC;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAmC3E"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FileSystemType } from "../types.js";
|
|
2
|
+
interface IrGenAssetOptions {
|
|
3
|
+
readonly ir: string;
|
|
4
|
+
readonly output: string;
|
|
5
|
+
readonly fileSystemType?: FileSystemType;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Generates a document type asset JSON file from an IR schema.
|
|
9
|
+
*
|
|
10
|
+
* This command is intended for internal platform applications where the document
|
|
11
|
+
* type asset must exist on disk so the platform can discover it and register the
|
|
12
|
+
* document type automatically at deploy time. Most users should use `ir deploy`
|
|
13
|
+
* to register document types via the Foundry API instead.
|
|
14
|
+
*
|
|
15
|
+
* If you are unsure whether you need this command, you almost certainly do not.
|
|
16
|
+
*/
|
|
17
|
+
export declare function irGenAssetHandler(options: IrGenAssetOptions): void;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=irGenAssetHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"irGenAssetHandler.d.ts","sourceRoot":"","sources":["../../../../src/commands/ir/irGenAssetHandler.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAqB,cAAc,EAAE,MAAM,aAAa,CAAC;AAErE,UAAU,iBAAiB;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;CAC1C;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAuDlE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerIrCommands.d.ts","sourceRoot":"","sources":["../../../../src/commands/ir/registerIrCommands.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"registerIrCommands.d.ts","sourceRoot":"","sources":["../../../../src/commands/ir/registerIrCommands.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA2DzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stepsGenIrHandler.d.ts","sourceRoot":"","sources":["../../../../src/commands/steps/stepsGenIrHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stepsGenIrHandler.d.ts","sourceRoot":"","sources":["../../../../src/commands/steps/stepsGenIrHandler.ts"],"names":[],"mappings":"AA0BA,UAAU,iBAAiB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAyDlE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DocumentTypeSchema } from "@osdk/foundry.pack";
|
|
2
|
+
export type FileSystemType = "ARTIFACTS" | "COMPASS";
|
|
3
|
+
export interface DocumentTypeAsset {
|
|
4
|
+
readonly documentTypeName: string;
|
|
5
|
+
readonly documentStorageType: {
|
|
6
|
+
readonly type: "yjs";
|
|
7
|
+
readonly yjs: DocumentTypeSchema;
|
|
8
|
+
};
|
|
9
|
+
readonly fileSystemType: FileSystemType;
|
|
10
|
+
readonly schemaVersion: number;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/commands/types.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,SAAS,CAAC;AAErD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,mBAAmB,EAAE;QAC5B,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;QACrB,QAAQ,CAAC,GAAG,EAAE,kBAAkB,CAAC;KAClC,CAAC;IACF,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC"}
|
|
@@ -6,7 +6,7 @@ export interface IFieldDef {
|
|
|
6
6
|
readonly "name": string;
|
|
7
7
|
readonly "description"?: string | null;
|
|
8
8
|
readonly "isOptional"?: boolean | null;
|
|
9
|
-
readonly "
|
|
10
|
-
readonly "
|
|
9
|
+
readonly "fieldType": IFieldTypeUnion.IFieldTypeUnion;
|
|
10
|
+
readonly "metadata": ISchemaMeta;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=fieldDef.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fieldDef.d.ts","sourceRoot":"","sources":["../../../../../src/lib/pack-docschema-api/pack-docschema-ir/fieldDef.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,KAAK,eAAe,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"fieldDef.d.ts","sourceRoot":"","sources":["../../../../../src/lib/pack-docschema-api/pack-docschema-ir/fieldDef.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,KAAK,eAAe,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,WAAW,EAAE,eAAe,CAAC,eAAe,CAAC;IACtD,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;CAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fieldValueDatetime.d.ts","sourceRoot":"","sources":["../../../../../src/lib/pack-docschema-api/pack-docschema-ir/fieldValueDatetime.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,mBAAmB;
|
|
1
|
+
{"version":3,"file":"fieldValueDatetime.d.ts","sourceRoot":"","sources":["../../../../../src/lib/pack-docschema-api/pack-docschema-ir/fieldValueDatetime.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fieldValueMediaRef.d.ts","sourceRoot":"","sources":["../../../../../src/lib/pack-docschema-api/pack-docschema-ir/fieldValueMediaRef.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,mBAAmB;
|
|
1
|
+
{"version":3,"file":"fieldValueMediaRef.d.ts","sourceRoot":"","sources":["../../../../../src/lib/pack-docschema-api/pack-docschema-ir/fieldValueMediaRef.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC;CACxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fieldValueText.d.ts","sourceRoot":"","sources":["../../../../../src/lib/pack-docschema-api/pack-docschema-ir/fieldValueText.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,eAAe;
|
|
1
|
+
{"version":3,"file":"fieldValueText.d.ts","sourceRoot":"","sources":["../../../../../src/lib/pack-docschema-api/pack-docschema-ir/fieldValueText.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordDef.d.ts","sourceRoot":"","sources":["../../../../../src/lib/pack-docschema-api/pack-docschema-ir/recordDef.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IAC5C,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"recordDef.d.ts","sourceRoot":"","sources":["../../../../../src/lib/pack-docschema-api/pack-docschema-ir/recordDef.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IAC5C,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;CAClC"}
|