@palantir/pack.document-schema.type-gen 0.31.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/build/esm/commands/ir/__tests__/irUpdateSchemaHandler.test.js +96 -0
- package/build/esm/commands/ir/__tests__/irUpdateSchemaHandler.test.js.map +1 -0
- package/build/esm/commands/ir/__tests__/resolveIrInput.test.js +80 -0
- package/build/esm/commands/ir/__tests__/resolveIrInput.test.js.map +1 -1
- package/build/esm/commands/ir/irDeployHandler.js +5 -0
- package/build/esm/commands/ir/irDeployHandler.js.map +1 -1
- package/build/esm/commands/ir/irGenAssetHandler.js +6 -1
- package/build/esm/commands/ir/irGenAssetHandler.js.map +1 -1
- package/build/esm/commands/ir/irGenTypesHandler.js +7 -3
- package/build/esm/commands/ir/irGenTypesHandler.js.map +1 -1
- package/build/esm/commands/ir/irUpdateSchemaHandler.js +18 -11
- package/build/esm/commands/ir/irUpdateSchemaHandler.js.map +1 -1
- package/build/esm/commands/ir/resolveIrInput.js +6 -5
- package/build/esm/commands/ir/resolveIrInput.js.map +1 -1
- package/build/esm/commands/schema/registerSchemaCommands.js +1 -1
- package/build/esm/commands/schema/registerSchemaCommands.js.map +1 -1
- package/build/esm/commands/schema/schemaIrHandler.js +15 -8
- package/build/esm/commands/schema/schemaIrHandler.js.map +1 -1
- package/build/esm/lib/pack-docschema-api/pack-docschema-ir/schemaMeta.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/custom-discriminant.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/custom-discriminant.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/external-refs.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/external-refs.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/simple-record.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/simple-record.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/union-types.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/union-types.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/array-and-map-types.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/array-and-map-types.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/boolean-fields.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/boolean-fields.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/custom-discriminant.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/custom-discriminant.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/datetime-fields.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/datetime-fields.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/simple-records.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/simple-records.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-before-records.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-before-records.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-types.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-types.js.map +1 -1
- package/build/esm/utils/ir/__tests__/convertIrToWireSchema.test.js +35 -0
- package/build/esm/utils/ir/__tests__/convertIrToWireSchema.test.js.map +1 -1
- package/build/esm/utils/ir/convertIrToWireSchema.js +1 -0
- package/build/esm/utils/ir/convertIrToWireSchema.js.map +1 -1
- package/build/esm/utils/ir/generateModelsFromIr.js +1 -1
- package/build/esm/utils/ir/generateModelsFromIr.js.map +1 -1
- package/build/esm/utils/ir/generateZodSchemasFromIr.js +1 -1
- package/build/esm/utils/ir/generateZodSchemasFromIr.js.map +1 -1
- package/build/esm/utils/schema/__tests__/__snapshots__/generateDocumentTypeFromSchema/with-name-and-description.js +1 -1
- package/build/esm/utils/schema/__tests__/__snapshots__/generateDocumentTypeFromSchema/with-name-and-description.js.map +1 -1
- package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/single-version.js.map +1 -1
- package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/three-version-chain.js.map +1 -1
- package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/two-version.js.map +1 -1
- package/build/esm/utils/schema/__tests__/assertSdkNamesUnique.test.js +178 -0
- package/build/esm/utils/schema/__tests__/assertSdkNamesUnique.test.js.map +1 -0
- package/build/esm/utils/schema/__tests__/generateIndexFromSchema.test.js +2 -1
- package/build/esm/utils/schema/__tests__/generateIndexFromSchema.test.js.map +1 -1
- package/build/esm/utils/schema/__tests__/generateInternalFromSchema.test.js +40 -1
- package/build/esm/utils/schema/__tests__/generateInternalFromSchema.test.js.map +1 -1
- package/build/esm/utils/schema/__tests__/generateVersionedTypesFromSchema.test.js +8 -0
- package/build/esm/utils/schema/__tests__/generateVersionedTypesFromSchema.test.js.map +1 -1
- package/build/esm/utils/schema/__tests__/generateVersionedZodFromSchema.test.js +8 -0
- package/build/esm/utils/schema/__tests__/generateVersionedZodFromSchema.test.js.map +1 -1
- package/build/esm/utils/schema/__tests__/resolveSchemaChain.test.js +75 -3
- package/build/esm/utils/schema/__tests__/resolveSchemaChain.test.js.map +1 -1
- package/build/esm/utils/schema/assertSdkNamesUnique.js +151 -0
- package/build/esm/utils/schema/assertSdkNamesUnique.js.map +1 -0
- package/build/esm/utils/schema/generateIndexFromSchema.js +9 -8
- package/build/esm/utils/schema/generateIndexFromSchema.js.map +1 -1
- package/build/esm/utils/schema/generateInternalFromSchema.js +35 -19
- package/build/esm/utils/schema/generateInternalFromSchema.js.map +1 -1
- package/build/esm/utils/schema/generateModelMetadataFromSchema.js +16 -12
- package/build/esm/utils/schema/generateModelMetadataFromSchema.js.map +1 -1
- package/build/esm/utils/schema/generateScopeFromSchema.js +6 -9
- package/build/esm/utils/schema/generateScopeFromSchema.js.map +1 -1
- package/build/esm/utils/schema/generateTypesFromSchema.js +1 -2
- package/build/esm/utils/schema/generateTypesFromSchema.js.map +1 -1
- package/build/esm/utils/schema/generateVersionedTypesFromSchema.js +31 -10
- package/build/esm/utils/schema/generateVersionedTypesFromSchema.js.map +1 -1
- package/build/esm/utils/schema/generateVersionedZodFromSchema.js +20 -14
- package/build/esm/utils/schema/generateVersionedZodFromSchema.js.map +1 -1
- package/build/esm/utils/schema/resolveSchemaChain.js +108 -20
- package/build/esm/utils/schema/resolveSchemaChain.js.map +1 -1
- package/build/esm/utils/schema/runtimeSchema.js +57 -0
- package/build/esm/utils/schema/runtimeSchema.js.map +1 -1
- package/build/esm/utils/schema/writeAllSdkFiles.js +2 -0
- package/build/esm/utils/schema/writeAllSdkFiles.js.map +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/arrayFields.js.map +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/customDiscriminant.js +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/customDiscriminant.js.map +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/generateTypeScriptInterfaces.js +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/generateTypeScriptInterfaces.js.map +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/refTypes.js.map +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/simpleRecord.js.map +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/simpleSteps.js +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/simpleSteps.js.map +1 -1
- package/build/esm/utils/steps/convertStepsToIr.js +10 -1
- package/build/esm/utils/steps/convertStepsToIr.js.map +1 -1
- package/build/types/commands/ir/__tests__/irUpdateSchemaHandler.test.d.ts +2 -0
- package/build/types/commands/ir/__tests__/irUpdateSchemaHandler.test.d.ts.map +1 -0
- package/build/types/commands/ir/irDeployHandler.d.ts.map +1 -1
- package/build/types/commands/ir/irGenAssetHandler.d.ts.map +1 -1
- package/build/types/commands/ir/irGenTypesHandler.d.ts.map +1 -1
- package/build/types/commands/ir/irUpdateSchemaHandler.d.ts.map +1 -1
- package/build/types/commands/ir/resolveIrInput.d.ts +1 -0
- package/build/types/commands/ir/resolveIrInput.d.ts.map +1 -1
- package/build/types/commands/schema/schemaIrHandler.d.ts +3 -3
- package/build/types/commands/schema/schemaIrHandler.d.ts.map +1 -1
- package/build/types/lib/pack-docschema-api/pack-docschema-ir/schemaMeta.d.ts +1 -0
- package/build/types/lib/pack-docschema-api/pack-docschema-ir/schemaMeta.d.ts.map +1 -1
- package/build/types/utils/ir/generateModelsFromIr.d.ts.map +1 -1
- package/build/types/utils/ir/generateZodSchemasFromIr.d.ts.map +1 -1
- package/build/types/utils/schema/__tests__/assertSdkNamesUnique.test.d.ts +2 -0
- package/build/types/utils/schema/__tests__/assertSdkNamesUnique.test.d.ts.map +1 -0
- package/build/types/utils/schema/assertSdkNamesUnique.d.ts +9 -0
- package/build/types/utils/schema/assertSdkNamesUnique.d.ts.map +1 -0
- package/build/types/utils/schema/generateIndexFromSchema.d.ts.map +1 -1
- package/build/types/utils/schema/generateInternalFromSchema.d.ts.map +1 -1
- package/build/types/utils/schema/generateModelMetadataFromSchema.d.ts.map +1 -1
- package/build/types/utils/schema/generateScopeFromSchema.d.ts.map +1 -1
- package/build/types/utils/schema/generateTypesFromSchema.d.ts.map +1 -1
- package/build/types/utils/schema/generateVersionedTypesFromSchema.d.ts.map +1 -1
- package/build/types/utils/schema/generateVersionedZodFromSchema.d.ts.map +1 -1
- package/build/types/utils/schema/resolveSchemaChain.d.ts +24 -1
- package/build/types/utils/schema/resolveSchemaChain.d.ts.map +1 -1
- package/build/types/utils/schema/runtimeSchema.d.ts +23 -0
- package/build/types/utils/schema/runtimeSchema.d.ts.map +1 -1
- package/build/types/utils/schema/writeAllSdkFiles.d.ts.map +1 -1
- package/build/types/utils/steps/convertStepsToIr.d.ts +2 -0
- package/build/types/utils/steps/convertStepsToIr.d.ts.map +1 -1
- package/package.json +6 -6
- package/build/esm/utils/formatVariantName.js +0 -21
- package/build/esm/utils/formatVariantName.js.map +0 -1
- package/build/types/utils/formatVariantName.d.ts +0 -2
- package/build/types/utils/formatVariantName.d.ts.map +0 -1
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { CommanderError } from "commander";
|
|
18
|
-
import {
|
|
18
|
+
import { assertSdkNamesUnique } from "../../utils/schema/assertSdkNamesUnique.js";
|
|
19
|
+
import { getEntryMinorVersion, resolveMinVersion } from "../../utils/schema/resolveSchemaChain.js";
|
|
19
20
|
function isChainPayload(parsed) {
|
|
20
21
|
return typeof parsed === "object" && parsed != null && "chain" in parsed && Array.isArray(parsed.chain) && typeof parsed.latestVersion === "number";
|
|
21
22
|
}
|
|
@@ -27,13 +28,12 @@ function resolveFromChain(payload, irPath) {
|
|
|
27
28
|
latestVersion,
|
|
28
29
|
minVersion
|
|
29
30
|
} = resolveMinVersion(payload.chain, payload.minSupportedVersion);
|
|
30
|
-
const latestEntry = payload.chain.
|
|
31
|
-
|
|
32
|
-
throw new CommanderError(1, "EINVAL", `IR chain payload at ${irPath} has no entry matching latestVersion ${latestVersion}`);
|
|
33
|
-
}
|
|
31
|
+
const latestEntry = payload.chain[payload.chain.length - 1];
|
|
32
|
+
assertSdkNamesUnique(payload.chain, payload.minSupportedVersion);
|
|
34
33
|
return {
|
|
35
34
|
ir: latestEntry.ir,
|
|
36
35
|
latestVersion,
|
|
36
|
+
latestMinorVersion: getEntryMinorVersion(latestEntry),
|
|
37
37
|
minSupportedVersion: minVersion,
|
|
38
38
|
owningApplicationId: payload.owningApplicationId
|
|
39
39
|
};
|
|
@@ -42,6 +42,7 @@ function resolveFromSingleIr(ir) {
|
|
|
42
42
|
return {
|
|
43
43
|
ir,
|
|
44
44
|
latestVersion: ir.version,
|
|
45
|
+
latestMinorVersion: 0,
|
|
45
46
|
minSupportedVersion: ir.version
|
|
46
47
|
};
|
|
47
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveIrInput.js","names":["CommanderError","resolveMinVersion","isChainPayload","parsed","Array","isArray","chain","latestVersion","resolveFromChain","payload","irPath","length","minVersion","minSupportedVersion","latestEntry","
|
|
1
|
+
{"version":3,"file":"resolveIrInput.js","names":["CommanderError","assertSdkNamesUnique","getEntryMinorVersion","resolveMinVersion","isChainPayload","parsed","Array","isArray","chain","latestVersion","resolveFromChain","payload","irPath","length","minVersion","minSupportedVersion","latestEntry","ir","latestMinorVersion","owningApplicationId","resolveFromSingleIr","version","resolveIrInput"],"sources":["resolveIrInput.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 type { IRealTimeDocumentSchema } from \"../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { assertSdkNamesUnique } from \"../../utils/schema/assertSdkNamesUnique.js\";\nimport {\n getEntryMinorVersion,\n type IrChainPayload,\n resolveMinVersion,\n} from \"../../utils/schema/resolveSchemaChain.js\";\n\nexport interface ResolvedIrInput {\n readonly ir: IRealTimeDocumentSchema;\n readonly latestVersion: number;\n readonly latestMinorVersion: number;\n readonly minSupportedVersion: number;\n readonly owningApplicationId?: string;\n}\n\nfunction isChainPayload(parsed: unknown): parsed is IrChainPayload {\n return (\n typeof parsed === \"object\"\n && parsed != null\n && \"chain\" in parsed\n && Array.isArray((parsed as IrChainPayload).chain)\n && typeof (parsed as IrChainPayload).latestVersion === \"number\"\n );\n}\n\nfunction resolveFromChain(payload: IrChainPayload, irPath: string): ResolvedIrInput {\n if (payload.chain.length === 0) {\n throw new CommanderError(\n 1,\n \"EINVAL\",\n `Invalid IR chain payload at ${irPath}: 'chain' is empty`,\n );\n }\n const { latestVersion, minVersion } = resolveMinVersion(\n payload.chain,\n payload.minSupportedVersion,\n );\n const latestEntry = payload.chain[payload.chain.length - 1]!;\n assertSdkNamesUnique(payload.chain, payload.minSupportedVersion);\n return {\n ir: latestEntry.ir,\n latestVersion,\n latestMinorVersion: getEntryMinorVersion(latestEntry),\n minSupportedVersion: minVersion,\n owningApplicationId: payload.owningApplicationId,\n };\n}\n\nfunction resolveFromSingleIr(ir: IRealTimeDocumentSchema): ResolvedIrInput {\n return { ir, latestVersion: ir.version, latestMinorVersion: 0, minSupportedVersion: ir.version };\n}\n\nexport function resolveIrInput(parsed: unknown, irPath: string): ResolvedIrInput {\n return isChainPayload(parsed)\n ? resolveFromChain(parsed, irPath)\n : resolveFromSingleIr(parsed as IRealTimeDocumentSchema);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,cAAc,QAAQ,WAAW;AAE1C,SAASC,oBAAoB,QAAQ,4CAA4C;AACjF,SACEC,oBAAoB,EAEpBC,iBAAiB,QACZ,0CAA0C;AAUjD,SAASC,cAAcA,CAACC,MAAe,EAA4B;EACjE,OACE,OAAOA,MAAM,KAAK,QAAQ,IACvBA,MAAM,IAAI,IAAI,IACd,OAAO,IAAIA,MAAM,IACjBC,KAAK,CAACC,OAAO,CAAEF,MAAM,CAAoBG,KAAK,CAAC,IAC/C,OAAQH,MAAM,CAAoBI,aAAa,KAAK,QAAQ;AAEnE;AAEA,SAASC,gBAAgBA,CAACC,OAAuB,EAAEC,MAAc,EAAmB;EAClF,IAAID,OAAO,CAACH,KAAK,CAACK,MAAM,KAAK,CAAC,EAAE;IAC9B,MAAM,IAAIb,cAAc,CACtB,CAAC,EACD,QAAQ,EACR,+BAA+BY,MAAM,oBACvC,CAAC;EACH;EACA,MAAM;IAAEH,aAAa;IAAEK;EAAW,CAAC,GAAGX,iBAAiB,CACrDQ,OAAO,CAACH,KAAK,EACbG,OAAO,CAACI,mBACV,CAAC;EACD,MAAMC,WAAW,GAAGL,OAAO,CAACH,KAAK,CAACG,OAAO,CAACH,KAAK,CAACK,MAAM,GAAG,CAAC,CAAE;EAC5DZ,oBAAoB,CAACU,OAAO,CAACH,KAAK,EAAEG,OAAO,CAACI,mBAAmB,CAAC;EAChE,OAAO;IACLE,EAAE,EAAED,WAAW,CAACC,EAAE;IAClBR,aAAa;IACbS,kBAAkB,EAAEhB,oBAAoB,CAACc,WAAW,CAAC;IACrDD,mBAAmB,EAAED,UAAU;IAC/BK,mBAAmB,EAAER,OAAO,CAACQ;EAC/B,CAAC;AACH;AAEA,SAASC,mBAAmBA,CAACH,EAA2B,EAAmB;EACzE,OAAO;IAAEA,EAAE;IAAER,aAAa,EAAEQ,EAAE,CAACI,OAAO;IAAEH,kBAAkB,EAAE,CAAC;IAAEH,mBAAmB,EAAEE,EAAE,CAACI;EAAQ,CAAC;AAClG;AAEA,OAAO,SAASC,cAAcA,CAACjB,MAAe,EAAEO,MAAc,EAAmB;EAC/E,OAAOR,cAAc,CAACC,MAAM,CAAC,GACzBK,gBAAgB,CAACL,MAAM,EAAEO,MAAM,CAAC,GAChCQ,mBAAmB,CAACf,MAAiC,CAAC;AAC5D","ignoreList":[]}
|
|
@@ -19,6 +19,6 @@ import { schemaToYamlHandler } from "./schemaToYamlHandler.js";
|
|
|
19
19
|
export function registerSchemaCommands(program) {
|
|
20
20
|
const schemaCmd = program.command("schema").description("Commands for working with TypeScript schema definitions");
|
|
21
21
|
schemaCmd.command("yaml").description("Convert TypeScript schema to YAML migration steps").requiredOption("-i, --input <file>", "Input TypeScript schema file").requiredOption("-o, --output <file>", "Output YAML file").action(schemaToYamlHandler);
|
|
22
|
-
schemaCmd.command("ir").description("Resolve a TypeScript schema module to a versioned IR chain JSON file").requiredOption("-i, --input <file>", "Input TypeScript/JavaScript schema module").requiredOption("-o, --output <file>", "Output IR chain JSON file").requiredOption("--config <file>", "Path to the SDK's pack-config JSON file. Its optional 'minSupportedVersion' field declares the oldest schema version this SDK supports; omit the field to track latest only.").option("--max-version <version>", "Generate an IR chain capped at this schema version").action(schemaIrHandler);
|
|
22
|
+
schemaCmd.command("ir").description("Resolve a TypeScript schema module to a versioned IR chain JSON file").requiredOption("-i, --input <file>", "Input TypeScript/JavaScript schema module").requiredOption("-o, --output <file>", "Output IR chain JSON file").requiredOption("--config <file>", "Path to the SDK's pack-config JSON file. Its optional 'minSupportedVersion' field declares the oldest schema version this SDK supports; omit the field to track latest only.").option("--max-version <version>", "Generate an IR chain capped at this schema version, e.g. 2 (meaning 2.0) or 2.1").action(schemaIrHandler);
|
|
23
23
|
}
|
|
24
24
|
//# sourceMappingURL=registerSchemaCommands.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerSchemaCommands.js","names":["schemaIrHandler","schemaToYamlHandler","registerSchemaCommands","program","schemaCmd","command","description","requiredOption","action","option"],"sources":["registerSchemaCommands.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 { Command } from \"commander\";\nimport { schemaIrHandler } from \"./schemaIrHandler.js\";\nimport { schemaToYamlHandler } from \"./schemaToYamlHandler.js\";\n\nexport function registerSchemaCommands(program: Command): void {\n const schemaCmd = program\n .command(\"schema\")\n .description(\"Commands for working with TypeScript schema definitions\");\n\n schemaCmd\n .command(\"yaml\")\n .description(\"Convert TypeScript schema to YAML migration steps\")\n .requiredOption(\"-i, --input <file>\", \"Input TypeScript schema file\")\n .requiredOption(\"-o, --output <file>\", \"Output YAML file\")\n .action(schemaToYamlHandler);\n\n schemaCmd\n .command(\"ir\")\n .description(\"Resolve a TypeScript schema module to a versioned IR chain JSON file\")\n .requiredOption(\"-i, --input <file>\", \"Input TypeScript/JavaScript schema module\")\n .requiredOption(\"-o, --output <file>\", \"Output IR chain JSON file\")\n .requiredOption(\n \"--config <file>\",\n \"Path to the SDK's pack-config JSON file. Its optional 'minSupportedVersion' field declares the oldest schema version this SDK supports; omit the field to track latest only.\",\n )\n .option(\n \"--max-version <version>\",\n \"Generate an IR chain capped at this schema version\",\n )\n .action(schemaIrHandler);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,eAAe,QAAQ,sBAAsB;AACtD,SAASC,mBAAmB,QAAQ,0BAA0B;AAE9D,OAAO,SAASC,sBAAsBA,CAACC,OAAgB,EAAQ;EAC7D,MAAMC,SAAS,GAAGD,OAAO,CACtBE,OAAO,CAAC,QAAQ,CAAC,CACjBC,WAAW,CAAC,yDAAyD,CAAC;EAEzEF,SAAS,CACNC,OAAO,CAAC,MAAM,CAAC,CACfC,WAAW,CAAC,mDAAmD,CAAC,CAChEC,cAAc,CAAC,oBAAoB,EAAE,8BAA8B,CAAC,CACpEA,cAAc,CAAC,qBAAqB,EAAE,kBAAkB,CAAC,CACzDC,MAAM,CAACP,mBAAmB,CAAC;EAE9BG,SAAS,CACNC,OAAO,CAAC,IAAI,CAAC,CACbC,WAAW,CAAC,sEAAsE,CAAC,CACnFC,cAAc,CAAC,oBAAoB,EAAE,2CAA2C,CAAC,CACjFA,cAAc,CAAC,qBAAqB,EAAE,2BAA2B,CAAC,CAClEA,cAAc,CACb,iBAAiB,EACjB,8KACF,CAAC,CACAE,MAAM,CACL,yBAAyB,EACzB,
|
|
1
|
+
{"version":3,"file":"registerSchemaCommands.js","names":["schemaIrHandler","schemaToYamlHandler","registerSchemaCommands","program","schemaCmd","command","description","requiredOption","action","option"],"sources":["registerSchemaCommands.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 { Command } from \"commander\";\nimport { schemaIrHandler } from \"./schemaIrHandler.js\";\nimport { schemaToYamlHandler } from \"./schemaToYamlHandler.js\";\n\nexport function registerSchemaCommands(program: Command): void {\n const schemaCmd = program\n .command(\"schema\")\n .description(\"Commands for working with TypeScript schema definitions\");\n\n schemaCmd\n .command(\"yaml\")\n .description(\"Convert TypeScript schema to YAML migration steps\")\n .requiredOption(\"-i, --input <file>\", \"Input TypeScript schema file\")\n .requiredOption(\"-o, --output <file>\", \"Output YAML file\")\n .action(schemaToYamlHandler);\n\n schemaCmd\n .command(\"ir\")\n .description(\"Resolve a TypeScript schema module to a versioned IR chain JSON file\")\n .requiredOption(\"-i, --input <file>\", \"Input TypeScript/JavaScript schema module\")\n .requiredOption(\"-o, --output <file>\", \"Output IR chain JSON file\")\n .requiredOption(\n \"--config <file>\",\n \"Path to the SDK's pack-config JSON file. Its optional 'minSupportedVersion' field declares the oldest schema version this SDK supports; omit the field to track latest only.\",\n )\n .option(\n \"--max-version <version>\",\n \"Generate an IR chain capped at this schema version, e.g. 2 (meaning 2.0) or 2.1\",\n )\n .action(schemaIrHandler);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,eAAe,QAAQ,sBAAsB;AACtD,SAASC,mBAAmB,QAAQ,0BAA0B;AAE9D,OAAO,SAASC,sBAAsBA,CAACC,OAAgB,EAAQ;EAC7D,MAAMC,SAAS,GAAGD,OAAO,CACtBE,OAAO,CAAC,QAAQ,CAAC,CACjBC,WAAW,CAAC,yDAAyD,CAAC;EAEzEF,SAAS,CACNC,OAAO,CAAC,MAAM,CAAC,CACfC,WAAW,CAAC,mDAAmD,CAAC,CAChEC,cAAc,CAAC,oBAAoB,EAAE,8BAA8B,CAAC,CACpEA,cAAc,CAAC,qBAAqB,EAAE,kBAAkB,CAAC,CACzDC,MAAM,CAACP,mBAAmB,CAAC;EAE9BG,SAAS,CACNC,OAAO,CAAC,IAAI,CAAC,CACbC,WAAW,CAAC,sEAAsE,CAAC,CACnFC,cAAc,CAAC,oBAAoB,EAAE,2CAA2C,CAAC,CACjFA,cAAc,CAAC,qBAAqB,EAAE,2BAA2B,CAAC,CAClEA,cAAc,CACb,iBAAiB,EACjB,8KACF,CAAC,CACAE,MAAM,CACL,yBAAyB,EACzB,iFACF,CAAC,CACAD,MAAM,CAACR,eAAe,CAAC;AAC5B","ignoreList":[]}
|
|
@@ -18,8 +18,9 @@ import { consola } from "consola";
|
|
|
18
18
|
import fs from "fs-extra";
|
|
19
19
|
import path from "path";
|
|
20
20
|
import { GENERATED_JSON_COMMENT } from "../../utils/generatedFileHeader.js";
|
|
21
|
+
import { assertSdkNamesUnique } from "../../utils/schema/assertSdkNamesUnique.js";
|
|
21
22
|
import { loadSchemaModule } from "../../utils/schema/loadSchemaModule.js";
|
|
22
|
-
import { resolveSchemaChain } from "../../utils/schema/resolveSchemaChain.js";
|
|
23
|
+
import { formatSchemaVersion, getEntryMinorVersion, resolveSchemaChain } from "../../utils/schema/resolveSchemaChain.js";
|
|
23
24
|
function assertNonEmptyString(value, field, configPath) {
|
|
24
25
|
if (typeof value !== "string" || value.trim() === "") {
|
|
25
26
|
throw new Error(`'${field}' in ${configPath} must be a non-empty string, got: ${JSON.stringify(value)}`);
|
|
@@ -63,17 +64,21 @@ function parseMaxVersion(maxVersion) {
|
|
|
63
64
|
if (maxVersion == null) {
|
|
64
65
|
return undefined;
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
const match = /^([1-9]\d*)(?:\.(0|[1-9]\d*))?$/.exec(maxVersion);
|
|
68
|
+
if (match == null) {
|
|
69
|
+
throw new Error(`--max-version must be a version like 2 or 2.1, got: ${JSON.stringify(maxVersion)}`);
|
|
68
70
|
}
|
|
69
|
-
return
|
|
71
|
+
return {
|
|
72
|
+
major: Number(match[1]),
|
|
73
|
+
minor: Number(match[2] ?? 0)
|
|
74
|
+
};
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
/**
|
|
73
78
|
* Resolve a TypeScript schema module to a versioned IR chain JSON file.
|
|
74
79
|
*
|
|
75
80
|
* The output is a `{ latestVersion, minSupportedVersion?, chain }` payload
|
|
76
|
-
* where each entry is `{ version, ir, migrations? }` and `ir` is a
|
|
81
|
+
* where each entry is `{ version, minorVersion?, ir, migrations? }` and `ir` is a
|
|
77
82
|
* single-version `IRealTimeDocumentSchema`. This is the input format for
|
|
78
83
|
* `ir gen-types` and `ir asset`.
|
|
79
84
|
*
|
|
@@ -96,8 +101,8 @@ function parseMaxVersion(maxVersion) {
|
|
|
96
101
|
*
|
|
97
102
|
* Note: this is distinct from the legacy single-version IR JSON consumed by
|
|
98
103
|
* `ir zod`, which is a bare `IRealTimeDocumentSchema` (no chain, no migrations).
|
|
99
|
-
* Tools that previously read that format should
|
|
100
|
-
*
|
|
104
|
+
* Tools that previously read that format should use the `ir` field of the last
|
|
105
|
+
* entry in `chain` (several entries can share a major version, e.g. 3.0 and 3.1).
|
|
101
106
|
*/
|
|
102
107
|
export async function schemaIrHandler(options) {
|
|
103
108
|
const {
|
|
@@ -125,6 +130,7 @@ export async function schemaIrHandler(options) {
|
|
|
125
130
|
name: documentTypeName,
|
|
126
131
|
description: documentTypeDescription
|
|
127
132
|
}, maxVersion);
|
|
133
|
+
assertSdkNamesUnique(chain, minSupportedVersion);
|
|
128
134
|
const outputPath = path.resolve(output);
|
|
129
135
|
await fs.ensureDir(path.dirname(outputPath));
|
|
130
136
|
const payload = {
|
|
@@ -139,6 +145,7 @@ export async function schemaIrHandler(options) {
|
|
|
139
145
|
chain
|
|
140
146
|
};
|
|
141
147
|
await fs.writeFile(outputPath, JSON.stringify(payload, null, 2) + "\n", "utf8");
|
|
142
|
-
|
|
148
|
+
const latestEntry = chain[chain.length - 1];
|
|
149
|
+
consola.success(`Wrote IR chain (${chain.length} version(s), min=${minSupportedVersion ?? latestVersion}, max=${formatSchemaVersion(latestEntry.version, getEntryMinorVersion(latestEntry))}) to: ${outputPath}`);
|
|
143
150
|
}
|
|
144
151
|
//# sourceMappingURL=schemaIrHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaIrHandler.js","names":["consola","fs","path","GENERATED_JSON_COMMENT","loadSchemaModule","resolveSchemaChain","assertNonEmptyString","value","field","configPath","trim","Error","JSON","stringify","readRequiredNonEmptyString","readPackConfig","resolvedConfigPath","resolve","pathExists","config","readJson","documentTypeName","documentTypeDescription","minSupportedVersion","rawMin","Number","isInteger","owningApplicationId","parseMaxVersion","maxVersion","undefined","test","schemaIrHandler","options","input","output","warn","info","schema","chain","latestVersion","name","description","outputPath","ensureDir","dirname","payload","comment","writeFile","success","length"],"sources":["schemaIrHandler.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { consola } from \"consola\";\nimport fs from \"fs-extra\";\nimport path from \"path\";\nimport { GENERATED_JSON_COMMENT } from \"../../utils/generatedFileHeader.js\";\nimport { loadSchemaModule } from \"../../utils/schema/loadSchemaModule.js\";\nimport { resolveSchemaChain } from \"../../utils/schema/resolveSchemaChain.js\";\n\ninterface SchemaIrOptions {\n input: string;\n output: string;\n config: string;\n maxVersion?: string;\n}\n\ninterface PackConfigLike {\n documentTypeName?: unknown;\n documentTypeDescription?: unknown;\n minSupportedVersion?: unknown;\n owningApplicationId?: unknown;\n}\n\ninterface PackConfigValues {\n readonly documentTypeName: string;\n readonly documentTypeDescription: string;\n readonly minSupportedVersion?: number;\n readonly owningApplicationId?: string;\n}\n\nfunction assertNonEmptyString(value: unknown, field: string, configPath: string): string {\n if (typeof value !== \"string\" || value.trim() === \"\") {\n throw new Error(\n `'${field}' in ${configPath} must be a non-empty string, got: ${JSON.stringify(value)}`,\n );\n }\n return value;\n}\n\nfunction readRequiredNonEmptyString(\n value: unknown,\n field: string,\n configPath: string,\n): string {\n if (value == null) {\n throw new Error(\n `'${field}' is required in ${configPath} and must be a non-empty string`,\n );\n }\n return assertNonEmptyString(value, field, configPath);\n}\n\nexport async function readPackConfig(configPath: string): Promise<PackConfigValues> {\n const resolvedConfigPath = path.resolve(configPath);\n if (!(await fs.pathExists(resolvedConfigPath))) {\n throw new Error(`--config file not found: ${resolvedConfigPath}`);\n }\n const config = (await fs.readJson(resolvedConfigPath)) as PackConfigLike;\n\n const documentTypeName = readRequiredNonEmptyString(\n config.documentTypeName,\n \"documentTypeName\",\n resolvedConfigPath,\n );\n\n const documentTypeDescription = readRequiredNonEmptyString(\n config.documentTypeDescription,\n \"documentTypeDescription\",\n resolvedConfigPath,\n );\n\n let minSupportedVersion: number | undefined;\n const rawMin = config.minSupportedVersion;\n if (rawMin != null) {\n if (typeof rawMin !== \"number\" || !Number.isInteger(rawMin) || rawMin <= 0) {\n throw new Error(\n `'minSupportedVersion' in ${resolvedConfigPath} must be a positive integer, got: ${\n JSON.stringify(rawMin)\n }`,\n );\n }\n minSupportedVersion = rawMin;\n }\n\n let owningApplicationId: string | undefined;\n if (config.owningApplicationId != null) {\n owningApplicationId = assertNonEmptyString(\n config.owningApplicationId,\n \"owningApplicationId\",\n resolvedConfigPath,\n );\n }\n\n return { documentTypeName, documentTypeDescription, minSupportedVersion, owningApplicationId };\n}\n\nfunction parseMaxVersion(maxVersion: string | undefined): number | undefined {\n if (maxVersion == null) {\n return undefined;\n }\n\n if (!/^[1-9]\\d*$/.test(maxVersion)) {\n throw new Error(\n `--max-version must be a positive integer, got: ${JSON.stringify(maxVersion)}`,\n );\n }\n\n return Number(maxVersion);\n}\n\n/**\n * Resolve a TypeScript schema module to a versioned IR chain JSON file.\n *\n * The output is a `{ latestVersion, minSupportedVersion?, chain }` payload\n * where each entry is `{ version, ir, migrations? }` and `ir` is a\n * single-version `IRealTimeDocumentSchema`. This is the input format for\n * `ir gen-types` and `ir asset`.\n *\n * `--config <pack-config.json>` is required: the pack-config is the single\n * source of truth for document-type identity. Required fields:\n * - `documentTypeName`: the document type name embedded into each chain\n * entry's IR (and surfaced as `documentTypeName` by `ir asset`).\n * - `documentTypeDescription`: document type description embedded into each\n * chain entry's IR.\n * Optional fields:\n * - `minSupportedVersion`: declares the oldest version this SDK supports;\n * when set, it must match one of the chain entries' `version` values and is\n * embedded as `minSupportedVersion` in the payload so downstream consumers\n * (`ir gen-types`, `ir asset`) read the same value. Omitting the field is\n * an explicit opt-out: the IR will not include `minSupportedVersion` and\n * downstream tools default to supporting only the latest schema version.\n * - `owningApplicationId`: the application that owns this document type; when\n * set, it is embedded in the payload and surfaced as `owningApplicationId`\n * by `ir asset`.\n *\n * Note: this is distinct from the legacy single-version IR JSON consumed by\n * `ir zod`, which is a bare `IRealTimeDocumentSchema` (no chain, no migrations).\n * Tools that previously read that format should pick the entry matching\n * `latestVersion` from `chain` and use its `ir` field.\n */\nexport async function schemaIrHandler(options: SchemaIrOptions): Promise<void> {\n const { input, output, config } = options;\n const maxVersion = parseMaxVersion(options.maxVersion);\n const { documentTypeName, documentTypeDescription, minSupportedVersion, owningApplicationId } =\n await readPackConfig(config);\n\n if (minSupportedVersion == null) {\n consola.warn(\n `--config ${\n path.resolve(config)\n } does not set 'minSupportedVersion'. The generated IR will not include it, so downstream tools (ir gen-types, ir asset) will default to supporting only the latest schema version. Add 'minSupportedVersion' to your pack-config to enable back-compat.`,\n );\n }\n\n consola.info(`Loading schema from: ${input}`);\n const schema = await loadSchemaModule(input);\n\n consola.info(\"Resolving versioned IR chain...\");\n const { chain, latestVersion } = resolveSchemaChain(\n schema,\n minSupportedVersion,\n {\n name: documentTypeName,\n description: documentTypeDescription,\n },\n maxVersion,\n );\n\n const outputPath = path.resolve(output);\n await fs.ensureDir(path.dirname(outputPath));\n\n const payload = {\n comment: GENERATED_JSON_COMMENT,\n latestVersion,\n ...(minSupportedVersion != null ? { minSupportedVersion } : {}),\n ...(owningApplicationId != null ? { owningApplicationId } : {}),\n chain,\n };\n await fs.writeFile(outputPath, JSON.stringify(payload, null, 2) + \"\\n\", \"utf8\");\n\n consola.success(\n `Wrote IR chain (${chain.length} version(s), min=${\n minSupportedVersion ?? latestVersion\n }, max=${latestVersion}) to: ${outputPath}`,\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,SAAS;AACjC,OAAOC,EAAE,MAAM,UAAU;AACzB,OAAOC,IAAI,MAAM,MAAM;AACvB,SAAS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IAAIiB,aAAa,SAC7BA,aAAa,SAASG,UAAU,EAC3C,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"schemaIrHandler.js","names":["consola","fs","path","GENERATED_JSON_COMMENT","assertSdkNamesUnique","loadSchemaModule","formatSchemaVersion","getEntryMinorVersion","resolveSchemaChain","assertNonEmptyString","value","field","configPath","trim","Error","JSON","stringify","readRequiredNonEmptyString","readPackConfig","resolvedConfigPath","resolve","pathExists","config","readJson","documentTypeName","documentTypeDescription","minSupportedVersion","rawMin","Number","isInteger","owningApplicationId","parseMaxVersion","maxVersion","undefined","match","exec","major","minor","schemaIrHandler","options","input","output","warn","info","schema","chain","latestVersion","name","description","outputPath","ensureDir","dirname","payload","comment","writeFile","latestEntry","length","success","version"],"sources":["schemaIrHandler.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { consola } from \"consola\";\nimport fs from \"fs-extra\";\nimport path from \"path\";\nimport { GENERATED_JSON_COMMENT } from \"../../utils/generatedFileHeader.js\";\nimport { assertSdkNamesUnique } from \"../../utils/schema/assertSdkNamesUnique.js\";\nimport { loadSchemaModule } from \"../../utils/schema/loadSchemaModule.js\";\nimport {\n formatSchemaVersion,\n type FullSchemaVersion,\n getEntryMinorVersion,\n resolveSchemaChain,\n} from \"../../utils/schema/resolveSchemaChain.js\";\n\ninterface SchemaIrOptions {\n input: string;\n output: string;\n config: string;\n maxVersion?: string;\n}\n\ninterface PackConfigLike {\n documentTypeName?: unknown;\n documentTypeDescription?: unknown;\n minSupportedVersion?: unknown;\n owningApplicationId?: unknown;\n}\n\ninterface PackConfigValues {\n readonly documentTypeName: string;\n readonly documentTypeDescription: string;\n readonly minSupportedVersion?: number;\n readonly owningApplicationId?: string;\n}\n\nfunction assertNonEmptyString(value: unknown, field: string, configPath: string): string {\n if (typeof value !== \"string\" || value.trim() === \"\") {\n throw new Error(\n `'${field}' in ${configPath} must be a non-empty string, got: ${JSON.stringify(value)}`,\n );\n }\n return value;\n}\n\nfunction readRequiredNonEmptyString(\n value: unknown,\n field: string,\n configPath: string,\n): string {\n if (value == null) {\n throw new Error(\n `'${field}' is required in ${configPath} and must be a non-empty string`,\n );\n }\n return assertNonEmptyString(value, field, configPath);\n}\n\nexport async function readPackConfig(configPath: string): Promise<PackConfigValues> {\n const resolvedConfigPath = path.resolve(configPath);\n if (!(await fs.pathExists(resolvedConfigPath))) {\n throw new Error(`--config file not found: ${resolvedConfigPath}`);\n }\n const config = (await fs.readJson(resolvedConfigPath)) as PackConfigLike;\n\n const documentTypeName = readRequiredNonEmptyString(\n config.documentTypeName,\n \"documentTypeName\",\n resolvedConfigPath,\n );\n\n const documentTypeDescription = readRequiredNonEmptyString(\n config.documentTypeDescription,\n \"documentTypeDescription\",\n resolvedConfigPath,\n );\n\n let minSupportedVersion: number | undefined;\n const rawMin = config.minSupportedVersion;\n if (rawMin != null) {\n if (typeof rawMin !== \"number\" || !Number.isInteger(rawMin) || rawMin <= 0) {\n throw new Error(\n `'minSupportedVersion' in ${resolvedConfigPath} must be a positive integer, got: ${\n JSON.stringify(rawMin)\n }`,\n );\n }\n minSupportedVersion = rawMin;\n }\n\n let owningApplicationId: string | undefined;\n if (config.owningApplicationId != null) {\n owningApplicationId = assertNonEmptyString(\n config.owningApplicationId,\n \"owningApplicationId\",\n resolvedConfigPath,\n );\n }\n\n return { documentTypeName, documentTypeDescription, minSupportedVersion, owningApplicationId };\n}\n\nfunction parseMaxVersion(maxVersion: string | undefined): FullSchemaVersion | undefined {\n if (maxVersion == null) {\n return undefined;\n }\n\n const match = /^([1-9]\\d*)(?:\\.(0|[1-9]\\d*))?$/.exec(maxVersion);\n if (match == null) {\n throw new Error(\n `--max-version must be a version like 2 or 2.1, got: ${JSON.stringify(maxVersion)}`,\n );\n }\n\n return { major: Number(match[1]), minor: Number(match[2] ?? 0) };\n}\n\n/**\n * Resolve a TypeScript schema module to a versioned IR chain JSON file.\n *\n * The output is a `{ latestVersion, minSupportedVersion?, chain }` payload\n * where each entry is `{ version, minorVersion?, ir, migrations? }` and `ir` is a\n * single-version `IRealTimeDocumentSchema`. This is the input format for\n * `ir gen-types` and `ir asset`.\n *\n * `--config <pack-config.json>` is required: the pack-config is the single\n * source of truth for document-type identity. Required fields:\n * - `documentTypeName`: the document type name embedded into each chain\n * entry's IR (and surfaced as `documentTypeName` by `ir asset`).\n * - `documentTypeDescription`: document type description embedded into each\n * chain entry's IR.\n * Optional fields:\n * - `minSupportedVersion`: declares the oldest version this SDK supports;\n * when set, it must match one of the chain entries' `version` values and is\n * embedded as `minSupportedVersion` in the payload so downstream consumers\n * (`ir gen-types`, `ir asset`) read the same value. Omitting the field is\n * an explicit opt-out: the IR will not include `minSupportedVersion` and\n * downstream tools default to supporting only the latest schema version.\n * - `owningApplicationId`: the application that owns this document type; when\n * set, it is embedded in the payload and surfaced as `owningApplicationId`\n * by `ir asset`.\n *\n * Note: this is distinct from the legacy single-version IR JSON consumed by\n * `ir zod`, which is a bare `IRealTimeDocumentSchema` (no chain, no migrations).\n * Tools that previously read that format should use the `ir` field of the last\n * entry in `chain` (several entries can share a major version, e.g. 3.0 and 3.1).\n */\nexport async function schemaIrHandler(options: SchemaIrOptions): Promise<void> {\n const { input, output, config } = options;\n const maxVersion = parseMaxVersion(options.maxVersion);\n const { documentTypeName, documentTypeDescription, minSupportedVersion, owningApplicationId } =\n await readPackConfig(config);\n\n if (minSupportedVersion == null) {\n consola.warn(\n `--config ${\n path.resolve(config)\n } does not set 'minSupportedVersion'. The generated IR will not include it, so downstream tools (ir gen-types, ir asset) will default to supporting only the latest schema version. Add 'minSupportedVersion' to your pack-config to enable back-compat.`,\n );\n }\n\n consola.info(`Loading schema from: ${input}`);\n const schema = await loadSchemaModule(input);\n\n consola.info(\"Resolving versioned IR chain...\");\n const { chain, latestVersion } = resolveSchemaChain(\n schema,\n minSupportedVersion,\n {\n name: documentTypeName,\n description: documentTypeDescription,\n },\n maxVersion,\n );\n assertSdkNamesUnique(chain, minSupportedVersion);\n\n const outputPath = path.resolve(output);\n await fs.ensureDir(path.dirname(outputPath));\n\n const payload = {\n comment: GENERATED_JSON_COMMENT,\n latestVersion,\n ...(minSupportedVersion != null ? { minSupportedVersion } : {}),\n ...(owningApplicationId != null ? { owningApplicationId } : {}),\n chain,\n };\n await fs.writeFile(outputPath, JSON.stringify(payload, null, 2) + \"\\n\", \"utf8\");\n\n const latestEntry = chain[chain.length - 1]!;\n consola.success(\n `Wrote IR chain (${chain.length} version(s), min=${minSupportedVersion ?? latestVersion}, max=${\n formatSchemaVersion(latestEntry.version, getEntryMinorVersion(latestEntry))\n }) to: ${outputPath}`,\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,SAAS;AACjC,OAAOC,EAAE,MAAM,UAAU;AACzB,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,sBAAsB,QAAQ,oCAAoC;AAC3E,SAASC,oBAAoB,QAAQ,4CAA4C;AACjF,SAASC,gBAAgB,QAAQ,wCAAwC;AACzE,SACEC,mBAAmB,EAEnBC,oBAAoB,EACpBC,kBAAkB,QACb,0CAA0C;AAuBjD,SAASC,oBAAoBA,CAACC,KAAc,EAAEC,KAAa,EAAEC,UAAkB,EAAU;EACvF,IAAI,OAAOF,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACG,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;IACpD,MAAM,IAAIC,KAAK,CACb,IAAIH,KAAK,QAAQC,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,CAACiD,WAAW,CAACG,OAAO,EAAEnD,oBAAoB,CAACgD,WAAW,CAAC,CAAC,SACpEN,UAAU,EACrB,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaMeta.js","names":[],"sources":["schemaMeta.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 { ISchemaVersion } from \"../pack-docschema-api/schemaVersion.js\";\nexport interface ISchemaMeta {\n readonly \"addedInVersion\": ISchemaVersion;\n readonly \"deprecatedFromVersion\"?: ISchemaVersion | null;\n readonly \"deprecatedMessage\"?: string | null;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"schemaMeta.js","names":[],"sources":["schemaMeta.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 { ISchemaVersion } from \"../pack-docschema-api/schemaVersion.js\";\nexport interface ISchemaMeta {\n readonly \"addedInVersion\": ISchemaVersion;\n readonly \"addedInMinorVersion\"?: number | null;\n readonly \"deprecatedFromVersion\"?: ISchemaVersion | null;\n readonly \"deprecatedMessage\"?: string | null;\n}\n"],"mappings":"","ignoreList":[]}
|
package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/custom-discriminant.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
/* Generated by @palantir/pack.document-schema.type-gen@0.33.0 */
|
|
2
2
|
|
|
3
3
|
import { Metadata } from '@palantir/pack.document-schema.model-types';
|
|
4
4
|
import { AnimalCatSchema, AnimalDogSchema, AnimalSchema, CatSchema, DogSchema } from './schema.js';
|
package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/custom-discriminant.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-discriminant.js","names":["Metadata","AnimalCatSchema","AnimalDogSchema","AnimalSchema","CatSchema","DogSchema","CatModel","__type","zodSchema","name","DogModel","AnimalModel","discriminant","AnimalCatModel","AnimalDogModel","DocumentModel","Cat","Dog","Animal","AnimalCat","AnimalDog","version"],"sources":["custom-discriminant.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"custom-discriminant.js","names":["Metadata","AnimalCatSchema","AnimalDogSchema","AnimalSchema","CatSchema","DogSchema","CatModel","__type","zodSchema","name","DogModel","AnimalModel","discriminant","AnimalCatModel","AnimalDogModel","DocumentModel","Cat","Dog","Animal","AnimalCat","AnimalDog","version"],"sources":["custom-discriminant.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.33.0 */\n\nimport type {\n DocumentSchema,\n RecordModel,\n UnionModel,\n} from '@palantir/pack.document-schema.model-types';\nimport { Metadata } from '@palantir/pack.document-schema.model-types';\nimport type { Animal, AnimalCat, AnimalDog, Cat, Dog } from './types.js';\nimport {\n AnimalCatSchema,\n AnimalDogSchema,\n AnimalSchema,\n CatSchema,\n DogSchema,\n} from './schema.js';\n\nexport interface CatModel extends RecordModel<Cat, typeof CatSchema> {}\nexport const CatModel: CatModel = {\n __type: {} as Cat,\n zodSchema: CatSchema,\n [Metadata]: {\n name: 'Cat',\n },\n};\n\nexport interface DogModel extends RecordModel<Dog, typeof DogSchema> {}\nexport const DogModel: DogModel = {\n __type: {} as Dog,\n zodSchema: DogSchema,\n [Metadata]: {\n name: 'Dog',\n },\n};\n\nexport interface AnimalModel extends UnionModel<Animal, typeof AnimalSchema> {}\nexport const AnimalModel: AnimalModel = {\n __type: {} as Animal,\n zodSchema: AnimalSchema,\n [Metadata]: {\n discriminant: 'kind',\n name: 'Animal',\n },\n};\n\nexport interface AnimalCatModel extends UnionModel<\n AnimalCat,\n typeof AnimalCatSchema\n> {}\nexport const AnimalCatModel: AnimalCatModel = {\n __type: {} as AnimalCat,\n zodSchema: AnimalCatSchema,\n [Metadata]: {\n discriminant: 'kind',\n name: 'AnimalCat',\n },\n};\n\nexport interface AnimalDogModel extends UnionModel<\n AnimalDog,\n typeof AnimalDogSchema\n> {}\nexport const AnimalDogModel: AnimalDogModel = {\n __type: {} as AnimalDog,\n zodSchema: AnimalDogSchema,\n [Metadata]: {\n discriminant: 'kind',\n name: 'AnimalDog',\n },\n};\n\nexport const DocumentModel = {\n Cat: CatModel,\n Dog: DogModel,\n Animal: AnimalModel,\n AnimalCat: AnimalCatModel,\n AnimalDog: AnimalDogModel,\n [Metadata]: {\n version: 1,\n },\n} as const satisfies DocumentSchema;\n\nexport type DocumentModel = typeof DocumentModel;\n"],"mappings":"AAAA;;AAOA,SAASA,QAAQ,QAAQ,4CAA4C;AAErE,SACEC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,SAAS,EACTC,SAAS,QACJ,aAAa;AAGpB,OAAO,MAAMC,QAAkB,GAAG;EAChCC,MAAM,EAAE,CAAC,CAAQ;EACjBC,SAAS,EAAEJ,SAAS;EACpB,CAACJ,QAAQ,GAAG;IACVS,IAAI,EAAE;EACR;AACF,CAAC;AAGD,OAAO,MAAMC,QAAkB,GAAG;EAChCH,MAAM,EAAE,CAAC,CAAQ;EACjBC,SAAS,EAAEH,SAAS;EACpB,CAACL,QAAQ,GAAG;IACVS,IAAI,EAAE;EACR;AACF,CAAC;AAGD,OAAO,MAAME,WAAwB,GAAG;EACtCJ,MAAM,EAAE,CAAC,CAAW;EACpBC,SAAS,EAAEL,YAAY;EACvB,CAACH,QAAQ,GAAG;IACVY,YAAY,EAAE,MAAM;IACpBH,IAAI,EAAE;EACR;AACF,CAAC;AAMD,OAAO,MAAMI,cAA8B,GAAG;EAC5CN,MAAM,EAAE,CAAC,CAAc;EACvBC,SAAS,EAAEP,eAAe;EAC1B,CAACD,QAAQ,GAAG;IACVY,YAAY,EAAE,MAAM;IACpBH,IAAI,EAAE;EACR;AACF,CAAC;AAMD,OAAO,MAAMK,cAA8B,GAAG;EAC5CP,MAAM,EAAE,CAAC,CAAc;EACvBC,SAAS,EAAEN,eAAe;EAC1B,CAACF,QAAQ,GAAG;IACVY,YAAY,EAAE,MAAM;IACpBH,IAAI,EAAE;EACR;AACF,CAAC;AAED,OAAO,MAAMM,aAAa,GAAG;EAC3BC,GAAG,EAAEV,QAAQ;EACbW,GAAG,EAAEP,QAAQ;EACbQ,MAAM,EAAEP,WAAW;EACnBQ,SAAS,EAAEN,cAAc;EACzBO,SAAS,EAAEN,cAAc;EACzB,CAACd,QAAQ,GAAG;IACVqB,OAAO,EAAE;EACX;AACF,CAAmC","ignoreList":[]}
|
package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/external-refs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-refs.js","names":["Metadata","EventSchema","EventModel","__type","zodSchema","externalRefFieldTypes","documentRef","userRef","resourceRef","name","DocumentModel","Event","version"],"sources":["external-refs.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"external-refs.js","names":["Metadata","EventSchema","EventModel","__type","zodSchema","externalRefFieldTypes","documentRef","userRef","resourceRef","name","DocumentModel","Event","version"],"sources":["external-refs.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.33.0 */\n\nimport type {\n DocumentSchema,\n RecordModel,\n UnionModel,\n} from '@palantir/pack.document-schema.model-types';\nimport { Metadata } from '@palantir/pack.document-schema.model-types';\nimport type { Event } from './types.js';\nimport { EventSchema } from './schema.js';\n\nexport interface EventModel extends RecordModel<Event, typeof EventSchema> {}\nexport const EventModel: EventModel = {\n __type: {} as Event,\n zodSchema: EventSchema,\n [Metadata]: {\n externalRefFieldTypes: {\n documentRef: 'docRef',\n userRef: 'userRef',\n resourceRef: 'resourceRef',\n },\n name: 'Event',\n },\n};\n\nexport const DocumentModel = {\n Event: EventModel,\n [Metadata]: {\n version: 1,\n },\n} as const satisfies DocumentSchema;\n\nexport type DocumentModel = typeof DocumentModel;\n"],"mappings":"AAAA;;AAOA,SAASA,QAAQ,QAAQ,4CAA4C;AAErE,SAASC,WAAW,QAAQ,aAAa;AAGzC,OAAO,MAAMC,UAAsB,GAAG;EACpCC,MAAM,EAAE,CAAC,CAAU;EACnBC,SAAS,EAAEH,WAAW;EACtB,CAACD,QAAQ,GAAG;IACVK,qBAAqB,EAAE;MACrBC,WAAW,EAAE,QAAQ;MACrBC,OAAO,EAAE,SAAS;MAClBC,WAAW,EAAE;IACf,CAAC;IACDC,IAAI,EAAE;EACR;AACF,CAAC;AAED,OAAO,MAAMC,aAAa,GAAG;EAC3BC,KAAK,EAAET,UAAU;EACjB,CAACF,QAAQ,GAAG;IACVY,OAAO,EAAE;EACX;AACF,CAAmC","ignoreList":[]}
|
package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/simple-record.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simple-record.js","names":["Metadata","PersonSchema","PersonModel","__type","zodSchema","name","DocumentModel","Person","version"],"sources":["simple-record.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"simple-record.js","names":["Metadata","PersonSchema","PersonModel","__type","zodSchema","name","DocumentModel","Person","version"],"sources":["simple-record.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.33.0 */\n\nimport type {\n DocumentSchema,\n RecordModel,\n UnionModel,\n} from '@palantir/pack.document-schema.model-types';\nimport { Metadata } from '@palantir/pack.document-schema.model-types';\nimport type { Person } from './types.js';\nimport { PersonSchema } from './schema.js';\n\nexport interface PersonModel extends RecordModel<Person, typeof PersonSchema> {}\nexport const PersonModel: PersonModel = {\n __type: {} as Person,\n zodSchema: PersonSchema,\n [Metadata]: {\n name: 'Person',\n },\n};\n\nexport const DocumentModel = {\n Person: PersonModel,\n [Metadata]: {\n version: 1,\n },\n} as const satisfies DocumentSchema;\n\nexport type DocumentModel = typeof DocumentModel;\n"],"mappings":"AAAA;;AAOA,SAASA,QAAQ,QAAQ,4CAA4C;AAErE,SAASC,YAAY,QAAQ,aAAa;AAG1C,OAAO,MAAMC,WAAwB,GAAG;EACtCC,MAAM,EAAE,CAAC,CAAW;EACpBC,SAAS,EAAEH,YAAY;EACvB,CAACD,QAAQ,GAAG;IACVK,IAAI,EAAE;EACR;AACF,CAAC;AAED,OAAO,MAAMC,aAAa,GAAG;EAC3BC,MAAM,EAAEL,WAAW;EACnB,CAACF,QAAQ,GAAG;IACVQ,OAAO,EAAE;EACX;AACF,CAAmC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
/* Generated by @palantir/pack.document-schema.type-gen@0.33.0 */
|
|
2
2
|
|
|
3
3
|
import { Metadata } from '@palantir/pack.document-schema.model-types';
|
|
4
4
|
import { NodeObjectSchema, NodeSchema, NodeTextBoxSchema, ObjectNodeSchema, TextBoxSchema } from './schema.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union-types.js","names":["Metadata","NodeObjectSchema","NodeSchema","NodeTextBoxSchema","ObjectNodeSchema","TextBoxSchema","ObjectNodeModel","__type","zodSchema","name","TextBoxModel","NodeModel","discriminant","NodeObjectModel","NodeTextBoxModel","DocumentModel","ObjectNode","TextBox","Node","NodeObject","NodeTextBox","version"],"sources":["union-types.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"union-types.js","names":["Metadata","NodeObjectSchema","NodeSchema","NodeTextBoxSchema","ObjectNodeSchema","TextBoxSchema","ObjectNodeModel","__type","zodSchema","name","TextBoxModel","NodeModel","discriminant","NodeObjectModel","NodeTextBoxModel","DocumentModel","ObjectNode","TextBox","Node","NodeObject","NodeTextBox","version"],"sources":["union-types.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.33.0 */\n\nimport type {\n DocumentSchema,\n RecordModel,\n UnionModel,\n} from '@palantir/pack.document-schema.model-types';\nimport { Metadata } from '@palantir/pack.document-schema.model-types';\nimport type {\n Node,\n NodeObject,\n NodeTextBox,\n ObjectNode,\n TextBox,\n} from './types.js';\nimport {\n NodeObjectSchema,\n NodeSchema,\n NodeTextBoxSchema,\n ObjectNodeSchema,\n TextBoxSchema,\n} from './schema.js';\n\nexport interface ObjectNodeModel extends RecordModel<\n ObjectNode,\n typeof ObjectNodeSchema\n> {}\nexport const ObjectNodeModel: ObjectNodeModel = {\n __type: {} as ObjectNode,\n zodSchema: ObjectNodeSchema,\n [Metadata]: {\n name: 'ObjectNode',\n },\n};\n\nexport interface TextBoxModel extends RecordModel<\n TextBox,\n typeof TextBoxSchema\n> {}\nexport const TextBoxModel: TextBoxModel = {\n __type: {} as TextBox,\n zodSchema: TextBoxSchema,\n [Metadata]: {\n name: 'TextBox',\n },\n};\n\nexport interface NodeModel extends UnionModel<Node, typeof NodeSchema> {}\nexport const NodeModel: NodeModel = {\n __type: {} as Node,\n zodSchema: NodeSchema,\n [Metadata]: {\n discriminant: 'type',\n name: 'Node',\n },\n};\n\nexport interface NodeObjectModel extends UnionModel<\n NodeObject,\n typeof NodeObjectSchema\n> {}\nexport const NodeObjectModel: NodeObjectModel = {\n __type: {} as NodeObject,\n zodSchema: NodeObjectSchema,\n [Metadata]: {\n discriminant: 'type',\n name: 'NodeObject',\n },\n};\n\nexport interface NodeTextBoxModel extends UnionModel<\n NodeTextBox,\n typeof NodeTextBoxSchema\n> {}\nexport const NodeTextBoxModel: NodeTextBoxModel = {\n __type: {} as NodeTextBox,\n zodSchema: NodeTextBoxSchema,\n [Metadata]: {\n discriminant: 'type',\n name: 'NodeTextBox',\n },\n};\n\nexport const DocumentModel = {\n ObjectNode: ObjectNodeModel,\n TextBox: TextBoxModel,\n Node: NodeModel,\n NodeObject: NodeObjectModel,\n NodeTextBox: NodeTextBoxModel,\n [Metadata]: {\n version: 1,\n },\n} as const satisfies DocumentSchema;\n\nexport type DocumentModel = typeof DocumentModel;\n"],"mappings":"AAAA;;AAOA,SAASA,QAAQ,QAAQ,4CAA4C;AAQrE,SACEC,gBAAgB,EAChBC,UAAU,EACVC,iBAAiB,EACjBC,gBAAgB,EAChBC,aAAa,QACR,aAAa;AAMpB,OAAO,MAAMC,eAAgC,GAAG;EAC9CC,MAAM,EAAE,CAAC,CAAe;EACxBC,SAAS,EAAEJ,gBAAgB;EAC3B,CAACJ,QAAQ,GAAG;IACVS,IAAI,EAAE;EACR;AACF,CAAC;AAMD,OAAO,MAAMC,YAA0B,GAAG;EACxCH,MAAM,EAAE,CAAC,CAAY;EACrBC,SAAS,EAAEH,aAAa;EACxB,CAACL,QAAQ,GAAG;IACVS,IAAI,EAAE;EACR;AACF,CAAC;AAGD,OAAO,MAAME,SAAoB,GAAG;EAClCJ,MAAM,EAAE,CAAC,CAAS;EAClBC,SAAS,EAAEN,UAAU;EACrB,CAACF,QAAQ,GAAG;IACVY,YAAY,EAAE,MAAM;IACpBH,IAAI,EAAE;EACR;AACF,CAAC;AAMD,OAAO,MAAMI,eAAgC,GAAG;EAC9CN,MAAM,EAAE,CAAC,CAAe;EACxBC,SAAS,EAAEP,gBAAgB;EAC3B,CAACD,QAAQ,GAAG;IACVY,YAAY,EAAE,MAAM;IACpBH,IAAI,EAAE;EACR;AACF,CAAC;AAMD,OAAO,MAAMK,gBAAkC,GAAG;EAChDP,MAAM,EAAE,CAAC,CAAgB;EACzBC,SAAS,EAAEL,iBAAiB;EAC5B,CAACH,QAAQ,GAAG;IACVY,YAAY,EAAE,MAAM;IACpBH,IAAI,EAAE;EACR;AACF,CAAC;AAED,OAAO,MAAMM,aAAa,GAAG;EAC3BC,UAAU,EAAEV,eAAe;EAC3BW,OAAO,EAAEP,YAAY;EACrBQ,IAAI,EAAEP,SAAS;EACfQ,UAAU,EAAEN,eAAe;EAC3BO,WAAW,EAAEN,gBAAgB;EAC7B,CAACd,QAAQ,GAAG;IACVqB,OAAO,EAAE;EACX;AACF,CAAmC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-and-map-types.js","names":["z","ContainerSchema","object","tags","array","string","metadata","record","unknown"],"sources":["array-and-map-types.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"array-and-map-types.js","names":["z","ContainerSchema","object","tags","array","string","metadata","record","unknown"],"sources":["array-and-map-types.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.33.0 */\n\nimport { z } from 'zod';\n\nexport const ContainerSchema = z.object({\n tags: z.array(z.string()),\n metadata: z.record(z.string(), z.unknown()),\n});\n"],"mappings":"AAAA;;AAEA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,eAAe,GAAGD,CAAC,CAACE,MAAM,CAAC;EACtCC,IAAI,EAAEH,CAAC,CAACI,KAAK,CAACJ,CAAC,CAACK,MAAM,CAAC,CAAC,CAAC;EACzBC,QAAQ,EAAEN,CAAC,CAACO,MAAM,CAACP,CAAC,CAACK,MAAM,CAAC,CAAC,EAAEL,CAAC,CAACQ,OAAO,CAAC,CAAC;AAC5C,CAAC,CAAC","ignoreList":[]}
|
package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/boolean-fields.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boolean-fields.js","names":["z","FeatureSchema","object","enabled","boolean","isPublic","optional","flags","array"],"sources":["boolean-fields.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"boolean-fields.js","names":["z","FeatureSchema","object","enabled","boolean","isPublic","optional","flags","array"],"sources":["boolean-fields.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.33.0 */\n\nimport { z } from 'zod';\n\nexport const FeatureSchema = z.object({\n enabled: z.boolean(),\n isPublic: z.boolean().optional(),\n flags: z.array(z.boolean()),\n});\n"],"mappings":"AAAA;;AAEA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,aAAa,GAAGD,CAAC,CAACE,MAAM,CAAC;EACpCC,OAAO,EAAEH,CAAC,CAACI,OAAO,CAAC,CAAC;EACpBC,QAAQ,EAAEL,CAAC,CAACI,OAAO,CAAC,CAAC,CAACE,QAAQ,CAAC,CAAC;EAChCC,KAAK,EAAEP,CAAC,CAACQ,KAAK,CAACR,CAAC,CAACI,OAAO,CAAC,CAAC;AAC5B,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-discriminant.js","names":["z","CatSchema","object","meow","string","DogSchema","bark","AnimalCatSchema","extend","kind","literal","AnimalDogSchema","AnimalSchema","discriminatedUnion"],"sources":["custom-discriminant.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"custom-discriminant.js","names":["z","CatSchema","object","meow","string","DogSchema","bark","AnimalCatSchema","extend","kind","literal","AnimalDogSchema","AnimalSchema","discriminatedUnion"],"sources":["custom-discriminant.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.33.0 */\n\nimport { z } from 'zod';\n\nexport const CatSchema = z.object({\n meow: z.string(),\n});\n\nexport const DogSchema = z.object({\n bark: z.string(),\n});\n\nexport const AnimalCatSchema = CatSchema.extend({\n kind: z.literal('cat'),\n});\n\nexport const AnimalDogSchema = DogSchema.extend({\n kind: z.literal('dog'),\n});\n\nexport const AnimalSchema = z.discriminatedUnion('kind', [\n AnimalCatSchema,\n AnimalDogSchema,\n]);\n"],"mappings":"AAAA;;AAEA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,SAAS,GAAGD,CAAC,CAACE,MAAM,CAAC;EAChCC,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC;AACjB,CAAC,CAAC;AAEF,OAAO,MAAMC,SAAS,GAAGL,CAAC,CAACE,MAAM,CAAC;EAChCI,IAAI,EAAEN,CAAC,CAACI,MAAM,CAAC;AACjB,CAAC,CAAC;AAEF,OAAO,MAAMG,eAAe,GAAGN,SAAS,CAACO,MAAM,CAAC;EAC9CC,IAAI,EAAET,CAAC,CAACU,OAAO,CAAC,KAAK;AACvB,CAAC,CAAC;AAEF,OAAO,MAAMC,eAAe,GAAGN,SAAS,CAACG,MAAM,CAAC;EAC9CC,IAAI,EAAET,CAAC,CAACU,OAAO,CAAC,KAAK;AACvB,CAAC,CAAC;AAEF,OAAO,MAAME,YAAY,GAAGZ,CAAC,CAACa,kBAAkB,CAAC,MAAM,EAAE,CACvDN,eAAe,EACfI,eAAe,CAChB,CAAC","ignoreList":[]}
|
package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/datetime-fields.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datetime-fields.js","names":["z","EventSchema","object","timestamp","string","datetime"],"sources":["datetime-fields.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"datetime-fields.js","names":["z","EventSchema","object","timestamp","string","datetime"],"sources":["datetime-fields.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.33.0 */\n\nimport { z } from 'zod';\n\nexport const EventSchema = z.object({\n timestamp: z.string().datetime(),\n});\n"],"mappings":"AAAA;;AAEA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,WAAW,GAAGD,CAAC,CAACE,MAAM,CAAC;EAClCC,SAAS,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC;AACjC,CAAC,CAAC","ignoreList":[]}
|
package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/simple-records.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simple-records.js","names":["z","PersonSchema","object","name","string","min","max","age","number","int","email","optional"],"sources":["simple-records.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"simple-records.js","names":["z","PersonSchema","object","name","string","min","max","age","number","int","email","optional"],"sources":["simple-records.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.33.0 */\n\nimport { z } from 'zod';\n\nexport const PersonSchema = z.object({\n name: z.string().min(2).max(50),\n age: z.number().int().min(0).max(150),\n email: z.string().optional(),\n});\n"],"mappings":"AAAA;;AAEA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,YAAY,GAAGD,CAAC,CAACE,MAAM,CAAC;EACnCC,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAAC,CAACC,GAAG,CAAC,EAAE,CAAC;EAC/BC,GAAG,EAAEP,CAAC,CAACQ,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAACJ,GAAG,CAAC,CAAC,CAAC,CAACC,GAAG,CAAC,GAAG,CAAC;EACrCI,KAAK,EAAEV,CAAC,CAACI,MAAM,CAAC,CAAC,CAACO,QAAQ,CAAC;AAC7B,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union-before-records.js","names":["z","FooSchema","object","value","string","BarSchema","count","number","int","FooBarFooSchema","extend","type","literal","FooBarBarSchema","FooBarSchema","discriminatedUnion"],"sources":["union-before-records.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"union-before-records.js","names":["z","FooSchema","object","value","string","BarSchema","count","number","int","FooBarFooSchema","extend","type","literal","FooBarBarSchema","FooBarSchema","discriminatedUnion"],"sources":["union-before-records.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.33.0 */\n\nimport { z } from 'zod';\n\nexport const FooSchema = z.object({\n value: z.string(),\n});\n\nexport const BarSchema = z.object({\n count: z.number().int(),\n});\n\nexport const FooBarFooSchema = FooSchema.extend({\n type: z.literal('foo'),\n});\n\nexport const FooBarBarSchema = BarSchema.extend({\n type: z.literal('bar'),\n});\n\nexport const FooBarSchema = z.discriminatedUnion('type', [\n FooBarFooSchema,\n FooBarBarSchema,\n]);\n"],"mappings":"AAAA;;AAEA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,SAAS,GAAGD,CAAC,CAACE,MAAM,CAAC;EAChCC,KAAK,EAAEH,CAAC,CAACI,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,OAAO,MAAMC,SAAS,GAAGL,CAAC,CAACE,MAAM,CAAC;EAChCI,KAAK,EAAEN,CAAC,CAACO,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC;AACxB,CAAC,CAAC;AAEF,OAAO,MAAMC,eAAe,GAAGR,SAAS,CAACS,MAAM,CAAC;EAC9CC,IAAI,EAAEX,CAAC,CAACY,OAAO,CAAC,KAAK;AACvB,CAAC,CAAC;AAEF,OAAO,MAAMC,eAAe,GAAGR,SAAS,CAACK,MAAM,CAAC;EAC9CC,IAAI,EAAEX,CAAC,CAACY,OAAO,CAAC,KAAK;AACvB,CAAC,CAAC;AAEF,OAAO,MAAME,YAAY,GAAGd,CAAC,CAACe,kBAAkB,CAAC,MAAM,EAAE,CACvDN,eAAe,EACfI,eAAe,CAChB,CAAC","ignoreList":[]}
|
package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union-types.js","names":["z","ObjectNodeSchema","object","x","number","y","label","string","optional","TextBoxSchema","text","NodeObjectSchema","extend","type","literal","NodeTextBoxSchema","NodeSchema","discriminatedUnion"],"sources":["union-types.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"union-types.js","names":["z","ObjectNodeSchema","object","x","number","y","label","string","optional","TextBoxSchema","text","NodeObjectSchema","extend","type","literal","NodeTextBoxSchema","NodeSchema","discriminatedUnion"],"sources":["union-types.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.33.0 */\n\nimport { z } from 'zod';\n\nexport const ObjectNodeSchema = z.object({\n x: z.number(),\n y: z.number(),\n label: z.string().optional(),\n});\n\nexport const TextBoxSchema = z.object({\n x: z.number(),\n y: z.number(),\n text: z.string(),\n});\n\nexport const NodeObjectSchema = ObjectNodeSchema.extend({\n type: z.literal('object'),\n});\n\nexport const NodeTextBoxSchema = TextBoxSchema.extend({\n type: z.literal('text-box'),\n});\n\nexport const NodeSchema = z.discriminatedUnion('type', [\n NodeObjectSchema,\n NodeTextBoxSchema,\n]);\n"],"mappings":"AAAA;;AAEA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,gBAAgB,GAAGD,CAAC,CAACE,MAAM,CAAC;EACvCC,CAAC,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC;EACbC,CAAC,EAAEL,CAAC,CAACI,MAAM,CAAC,CAAC;EACbE,KAAK,EAAEN,CAAC,CAACO,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC;AAC7B,CAAC,CAAC;AAEF,OAAO,MAAMC,aAAa,GAAGT,CAAC,CAACE,MAAM,CAAC;EACpCC,CAAC,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC;EACbC,CAAC,EAAEL,CAAC,CAACI,MAAM,CAAC,CAAC;EACbM,IAAI,EAAEV,CAAC,CAACO,MAAM,CAAC;AACjB,CAAC,CAAC;AAEF,OAAO,MAAMI,gBAAgB,GAAGV,gBAAgB,CAACW,MAAM,CAAC;EACtDC,IAAI,EAAEb,CAAC,CAACc,OAAO,CAAC,QAAQ;AAC1B,CAAC,CAAC;AAEF,OAAO,MAAMC,iBAAiB,GAAGN,aAAa,CAACG,MAAM,CAAC;EACpDC,IAAI,EAAEb,CAAC,CAACc,OAAO,CAAC,UAAU;AAC5B,CAAC,CAAC;AAEF,OAAO,MAAME,UAAU,GAAGhB,CAAC,CAACiB,kBAAkB,CAAC,MAAM,EAAE,CACrDN,gBAAgB,EAChBI,iBAAiB,CAClB,CAAC","ignoreList":[]}
|
|
@@ -18,6 +18,41 @@ import { describe, expect, it } from "vitest";
|
|
|
18
18
|
import { IFieldValueUnion } from "../../../lib/pack-docschema-api/pack-docschema-ir/index.js";
|
|
19
19
|
import { convertIrToWireSchema } from "../convertIrToWireSchema.js";
|
|
20
20
|
describe("convertIrToWireSchema", () => {
|
|
21
|
+
it("should pass through the minor version a field was added in", () => {
|
|
22
|
+
const record = {
|
|
23
|
+
key: "Shape",
|
|
24
|
+
name: "Shape",
|
|
25
|
+
fields: [{
|
|
26
|
+
key: "label",
|
|
27
|
+
name: "label",
|
|
28
|
+
fieldType: {
|
|
29
|
+
type: "value",
|
|
30
|
+
value: IFieldValueUnion.string({})
|
|
31
|
+
},
|
|
32
|
+
metadata: {
|
|
33
|
+
addedInVersion: 2,
|
|
34
|
+
addedInMinorVersion: 1
|
|
35
|
+
},
|
|
36
|
+
isOptional: true
|
|
37
|
+
}]
|
|
38
|
+
};
|
|
39
|
+
const shape = convertIrToWireSchema({
|
|
40
|
+
name: "Test",
|
|
41
|
+
description: "Test schema",
|
|
42
|
+
version: 2,
|
|
43
|
+
primaryModelKeys: ["Shape"],
|
|
44
|
+
models: {
|
|
45
|
+
Shape: {
|
|
46
|
+
type: "record",
|
|
47
|
+
record
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}).models["Shape"];
|
|
51
|
+
expect(shape.fields[0].metadata).toEqual({
|
|
52
|
+
addedInVersion: 2,
|
|
53
|
+
addedInMinorVersion: 1
|
|
54
|
+
});
|
|
55
|
+
});
|
|
21
56
|
it("should flatten record model and rename fields correctly", () => {
|
|
22
57
|
const record = {
|
|
23
58
|
key: "Person",
|