@palantir/pack.document-schema.type-gen 0.7.0 → 0.9.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 +19 -13
- package/build/esm/commands/ir/irGenAssetHandler.js.map +1 -1
- package/build/esm/commands/schema/registerSchemaCommands.js +2 -0
- package/build/esm/commands/schema/registerSchemaCommands.js.map +1 -1
- package/build/esm/commands/schema/schemaGenTypesHandler.js +147 -0
- package/build/esm/commands/schema/schemaGenTypesHandler.js.map +1 -0
- 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/index.js +6 -0
- package/build/esm/index.js.map +1 -1
- 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 +323 -0
- package/build/esm/utils/ir/__tests__/convertIrToWireSchema.test.js.map +1 -0
- package/build/esm/utils/ir/__tests__/generateModelsFromIr.test.js +43 -61
- package/build/esm/utils/ir/__tests__/generateModelsFromIr.test.js.map +1 -1
- package/build/esm/utils/ir/__tests__/generateZodSchemasFromIr.test.js +73 -103
- package/build/esm/utils/ir/__tests__/generateZodSchemasFromIr.test.js.map +1 -1
- package/build/esm/utils/ir/convertIrToWireSchema.js +201 -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 +2 -2
- package/build/esm/utils/ir/generateZodSchemasFromIr.js.map +1 -1
- package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/single-version.js +2 -0
- package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/single-version.js.map +1 -0
- package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/three-version-chain.js +2 -0
- package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/three-version-chain.js.map +1 -0
- package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/two-version.js +2 -0
- package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/two-version.js.map +1 -0
- package/build/esm/utils/schema/__tests__/fixtures.js +207 -0
- package/build/esm/utils/schema/__tests__/fixtures.js.map +1 -0
- package/build/esm/utils/schema/__tests__/generateInternalFromSchema.test.js +41 -0
- package/build/esm/utils/schema/__tests__/generateInternalFromSchema.test.js.map +1 -0
- package/build/esm/utils/schema/__tests__/generateModelMetadataFromSchema.test.js +41 -0
- package/build/esm/utils/schema/__tests__/generateModelMetadataFromSchema.test.js.map +1 -0
- package/build/esm/utils/schema/__tests__/generateScopeFromSchema.test.js +37 -0
- package/build/esm/utils/schema/__tests__/generateScopeFromSchema.test.js.map +1 -0
- package/build/esm/utils/schema/__tests__/generateVersionedTypesFromSchema.test.js +55 -0
- package/build/esm/utils/schema/__tests__/generateVersionedTypesFromSchema.test.js.map +1 -0
- package/build/esm/utils/schema/__tests__/generateVersionedZodFromSchema.test.js +55 -0
- package/build/esm/utils/schema/__tests__/generateVersionedZodFromSchema.test.js.map +1 -0
- package/build/esm/utils/schema/__tests__/generateVersionsFromSchema.test.js +37 -0
- package/build/esm/utils/schema/__tests__/generateVersionsFromSchema.test.js.map +1 -0
- package/build/esm/utils/schema/__tests__/snapshotUtils.js +106 -0
- package/build/esm/utils/schema/__tests__/snapshotUtils.js.map +1 -0
- package/build/esm/utils/schema/generateIndexFromSchema.js +72 -0
- package/build/esm/utils/schema/generateIndexFromSchema.js.map +1 -0
- package/build/esm/utils/schema/generateInternalFromSchema.js +380 -0
- package/build/esm/utils/schema/generateInternalFromSchema.js.map +1 -0
- package/build/esm/utils/schema/generateModelMetadataFromSchema.js +195 -0
- package/build/esm/utils/schema/generateModelMetadataFromSchema.js.map +1 -0
- package/build/esm/utils/schema/generateScopeFromSchema.js +155 -0
- package/build/esm/utils/schema/generateScopeFromSchema.js.map +1 -0
- package/build/esm/utils/schema/generateTypesFromSchema.js +16 -30
- package/build/esm/utils/schema/generateTypesFromSchema.js.map +1 -1
- package/build/esm/utils/schema/generateVersionedTypesFromSchema.js +281 -0
- package/build/esm/utils/schema/generateVersionedTypesFromSchema.js.map +1 -0
- package/build/esm/utils/schema/generateVersionedZodFromSchema.js +189 -0
- package/build/esm/utils/schema/generateVersionedZodFromSchema.js.map +1 -0
- package/build/esm/utils/schema/generateVersionsFromSchema.js +50 -0
- package/build/esm/utils/schema/generateVersionsFromSchema.js.map +1 -0
- package/build/esm/utils/schema/resolveSchemaChain.js +54 -0
- package/build/esm/utils/schema/resolveSchemaChain.js.map +1 -0
- package/build/esm/utils/schema/runtimeSchema.js +96 -0
- package/build/esm/utils/schema/runtimeSchema.js.map +1 -0
- 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 -13
- 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 +1 -1
- package/build/types/commands/ir/irGenAssetHandler.d.ts.map +1 -1
- package/build/types/commands/schema/registerSchemaCommands.d.ts.map +1 -1
- package/build/types/commands/schema/schemaGenTypesHandler.d.ts +8 -0
- package/build/types/commands/schema/schemaGenTypesHandler.d.ts.map +1 -0
- 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/index.d.ts +6 -0
- package/build/types/index.d.ts.map +1 -1
- 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 +0 -2
- 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/schema/__tests__/fixtures.d.ts +14 -0
- package/build/types/utils/schema/__tests__/fixtures.d.ts.map +1 -0
- package/build/types/utils/schema/__tests__/generateInternalFromSchema.test.d.ts +2 -0
- package/build/types/utils/schema/__tests__/generateInternalFromSchema.test.d.ts.map +1 -0
- package/build/types/utils/schema/__tests__/generateModelMetadataFromSchema.test.d.ts +2 -0
- package/build/types/utils/schema/__tests__/generateModelMetadataFromSchema.test.d.ts.map +1 -0
- package/build/types/utils/schema/__tests__/generateScopeFromSchema.test.d.ts +2 -0
- package/build/types/utils/schema/__tests__/generateScopeFromSchema.test.d.ts.map +1 -0
- package/build/types/utils/schema/__tests__/generateVersionedTypesFromSchema.test.d.ts +2 -0
- package/build/types/utils/schema/__tests__/generateVersionedTypesFromSchema.test.d.ts.map +1 -0
- package/build/types/utils/schema/__tests__/generateVersionedZodFromSchema.test.d.ts +2 -0
- package/build/types/utils/schema/__tests__/generateVersionedZodFromSchema.test.d.ts.map +1 -0
- package/build/types/utils/schema/__tests__/generateVersionsFromSchema.test.d.ts +2 -0
- package/build/types/utils/schema/__tests__/generateVersionsFromSchema.test.d.ts.map +1 -0
- package/build/types/utils/schema/__tests__/snapshotUtils.d.ts +47 -0
- package/build/types/utils/schema/__tests__/snapshotUtils.d.ts.map +1 -0
- package/build/types/utils/schema/generateIndexFromSchema.d.ts +14 -0
- package/build/types/utils/schema/generateIndexFromSchema.d.ts.map +1 -0
- package/build/types/utils/schema/generateInternalFromSchema.d.ts +18 -0
- package/build/types/utils/schema/generateInternalFromSchema.d.ts.map +1 -0
- package/build/types/utils/schema/generateModelMetadataFromSchema.d.ts +15 -0
- package/build/types/utils/schema/generateModelMetadataFromSchema.d.ts.map +1 -0
- package/build/types/utils/schema/generateScopeFromSchema.d.ts +13 -0
- package/build/types/utils/schema/generateScopeFromSchema.d.ts.map +1 -0
- package/build/types/utils/schema/generateTypesFromSchema.d.ts.map +1 -1
- package/build/types/utils/schema/generateVersionedTypesFromSchema.d.ts +18 -0
- package/build/types/utils/schema/generateVersionedTypesFromSchema.d.ts.map +1 -0
- package/build/types/utils/schema/generateVersionedZodFromSchema.d.ts +16 -0
- package/build/types/utils/schema/generateVersionedZodFromSchema.d.ts.map +1 -0
- package/build/types/utils/schema/generateVersionsFromSchema.d.ts +13 -0
- package/build/types/utils/schema/generateVersionsFromSchema.d.ts.map +1 -0
- package/build/types/utils/schema/resolveSchemaChain.d.ts +18 -0
- package/build/types/utils/schema/resolveSchemaChain.d.ts.map +1 -0
- package/build/types/utils/schema/runtimeSchema.d.ts +59 -0
- package/build/types/utils/schema/runtimeSchema.d.ts.map +1 -0
- package/build/types/utils/steps/convertStepsToIr.d.ts.map +1 -1
- package/build/types/utils/steps/parseMigrationSteps.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { defineRecord, defineSchema, defineSchemaUpdate, defineUnion, modelToRef, nextSchema } from "@palantir/pack.schema";
|
|
18
|
+
import * as P from "@palantir/pack.schema";
|
|
19
|
+
|
|
20
|
+
/** Single-version schema: ShapeBox with 5 fields */
|
|
21
|
+
const singleVersionModels = {
|
|
22
|
+
ShapeBox: defineRecord("ShapeBox", {
|
|
23
|
+
docs: "A box shape",
|
|
24
|
+
fields: {
|
|
25
|
+
left: P.Double,
|
|
26
|
+
right: P.Double,
|
|
27
|
+
top: P.Double,
|
|
28
|
+
bottom: P.Double,
|
|
29
|
+
color: P.Optional(P.String)
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
};
|
|
33
|
+
const singleVersionSchemaNarrow = defineSchema(singleVersionModels);
|
|
34
|
+
export const singleVersionSchema = singleVersionSchemaNarrow;
|
|
35
|
+
|
|
36
|
+
/** Two-version schema with field removal (color removed, fillColor + strokeColor + opacity added) */
|
|
37
|
+
export const twoVersionFieldRemovalSchema = {
|
|
38
|
+
type: "versioned",
|
|
39
|
+
models: {
|
|
40
|
+
ShapeBox: defineRecord("ShapeBox", {
|
|
41
|
+
docs: "A box shape",
|
|
42
|
+
fields: {
|
|
43
|
+
left: P.Double,
|
|
44
|
+
right: P.Double,
|
|
45
|
+
top: P.Double,
|
|
46
|
+
bottom: P.Double,
|
|
47
|
+
fillColor: P.Optional(P.String),
|
|
48
|
+
strokeColor: P.Optional(P.String),
|
|
49
|
+
opacity: P.Optional(P.Double)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
},
|
|
53
|
+
version: 2,
|
|
54
|
+
previous: singleVersionSchema
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** Two-version schema with additive change only (adds fillColor) */
|
|
58
|
+
const addFillColorUpdate = defineSchemaUpdate("addFillColor", schema => ({
|
|
59
|
+
ShapeBox: schema.ShapeBox.addField("fillColor", P.Optional(P.String)).build()
|
|
60
|
+
}));
|
|
61
|
+
export const twoVersionAdditiveSchema = nextSchema(singleVersionSchemaNarrow).addSchemaUpdate(addFillColorUpdate).build();
|
|
62
|
+
|
|
63
|
+
/** Schema with ref fields: tests import paths for record refs, DocumentRef, UserRef */
|
|
64
|
+
const CircleRecord = defineRecord("Circle", {
|
|
65
|
+
docs: "A circle",
|
|
66
|
+
fields: {
|
|
67
|
+
radius: P.Double
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const DocRef = {
|
|
71
|
+
type: "docRef"
|
|
72
|
+
};
|
|
73
|
+
const UserRefField = {
|
|
74
|
+
type: "userRef"
|
|
75
|
+
};
|
|
76
|
+
export const refFieldsSchema = defineSchema({
|
|
77
|
+
Circle: CircleRecord,
|
|
78
|
+
Drawing: defineRecord("Drawing", {
|
|
79
|
+
docs: "A drawing with references",
|
|
80
|
+
fields: {
|
|
81
|
+
mainShape: CircleRecord,
|
|
82
|
+
extraShapes: P.Array(modelToRef(CircleRecord)),
|
|
83
|
+
background: P.Optional(modelToRef(CircleRecord)),
|
|
84
|
+
attachment: DocRef,
|
|
85
|
+
owner: P.Optional(UserRefField)
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
/** Schema with union types: tests union variant interfaces, discriminated union, and type guards */
|
|
91
|
+
const RectangleRecord = defineRecord("Rectangle", {
|
|
92
|
+
docs: "A rectangle",
|
|
93
|
+
fields: {
|
|
94
|
+
width: P.Double,
|
|
95
|
+
height: P.Double
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
export const unionTypesSchema = defineSchema({
|
|
99
|
+
Circle: CircleRecord,
|
|
100
|
+
Rectangle: RectangleRecord,
|
|
101
|
+
Shape: defineUnion("Shape", {
|
|
102
|
+
docs: "A shape",
|
|
103
|
+
variants: {
|
|
104
|
+
circle: CircleRecord,
|
|
105
|
+
rectangle: RectangleRecord
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
/** Schema with nested optionals: tests that optional inside array/nested structures is preserved */
|
|
111
|
+
export const nestedOptionalsSchema = defineSchema({
|
|
112
|
+
Config: defineRecord("Config", {
|
|
113
|
+
docs: "A config with nested optional fields",
|
|
114
|
+
fields: {
|
|
115
|
+
tags: P.Array(P.Optional(P.String)),
|
|
116
|
+
matrix: P.Array(P.Array(P.Optional(P.Double))),
|
|
117
|
+
label: P.Optional(P.String),
|
|
118
|
+
// Sparse 3D point cloud: pages of rows where each row may omit coordinate triples
|
|
119
|
+
pointCloud: P.Array(P.Array(P.Optional(P.Array(P.Double))))
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
/** Two-version schema with derived fields (color split into fillColor + strokeColor) */
|
|
125
|
+
export const twoVersionDerivedFieldsSchema = {
|
|
126
|
+
type: "versioned",
|
|
127
|
+
models: {
|
|
128
|
+
ShapeBox: defineRecord("ShapeBox", {
|
|
129
|
+
docs: "A box shape",
|
|
130
|
+
fields: {
|
|
131
|
+
left: P.Double,
|
|
132
|
+
right: P.Double,
|
|
133
|
+
top: P.Double,
|
|
134
|
+
bottom: P.Double,
|
|
135
|
+
fillColor: P.Optional(P.String),
|
|
136
|
+
strokeColor: P.Optional(P.String),
|
|
137
|
+
opacity: P.Optional(P.Double)
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
},
|
|
141
|
+
version: 2,
|
|
142
|
+
previous: singleVersionSchema,
|
|
143
|
+
migrations: {
|
|
144
|
+
ShapeBox: {
|
|
145
|
+
fillColor: {
|
|
146
|
+
derivedFrom: ["color"],
|
|
147
|
+
forward: ({
|
|
148
|
+
color
|
|
149
|
+
}) => color
|
|
150
|
+
},
|
|
151
|
+
strokeColor: {
|
|
152
|
+
derivedFrom: ["color"],
|
|
153
|
+
forward: ({
|
|
154
|
+
color
|
|
155
|
+
}) => color
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/** Three-version chain: Item (name, color -> name, hexColor -> name, hexColor, tags) */
|
|
162
|
+
export const threeVersionChainSchema = (() => {
|
|
163
|
+
const v1Models = {
|
|
164
|
+
Item: defineRecord("Item", {
|
|
165
|
+
docs: "",
|
|
166
|
+
fields: {
|
|
167
|
+
name: P.String,
|
|
168
|
+
color: P.Optional(P.String)
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
};
|
|
172
|
+
const v2Models = {
|
|
173
|
+
Item: defineRecord("Item", {
|
|
174
|
+
docs: "",
|
|
175
|
+
fields: {
|
|
176
|
+
name: P.String,
|
|
177
|
+
hexColor: P.Optional(P.String)
|
|
178
|
+
}
|
|
179
|
+
})
|
|
180
|
+
};
|
|
181
|
+
const v3Models = {
|
|
182
|
+
Item: defineRecord("Item", {
|
|
183
|
+
docs: "",
|
|
184
|
+
fields: {
|
|
185
|
+
name: P.String,
|
|
186
|
+
hexColor: P.Optional(P.String),
|
|
187
|
+
tags: P.Optional(P.String)
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
};
|
|
191
|
+
return {
|
|
192
|
+
type: "versioned",
|
|
193
|
+
models: v3Models,
|
|
194
|
+
version: 3,
|
|
195
|
+
previous: {
|
|
196
|
+
type: "versioned",
|
|
197
|
+
models: v2Models,
|
|
198
|
+
version: 2,
|
|
199
|
+
previous: {
|
|
200
|
+
type: "initial",
|
|
201
|
+
version: 1,
|
|
202
|
+
models: v1Models
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
})();
|
|
207
|
+
//# sourceMappingURL=fixtures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures.js","names":["defineRecord","defineSchema","defineSchemaUpdate","defineUnion","modelToRef","nextSchema","P","singleVersionModels","ShapeBox","docs","fields","left","Double","right","top","bottom","color","Optional","String","singleVersionSchemaNarrow","singleVersionSchema","twoVersionFieldRemovalSchema","type","models","fillColor","strokeColor","opacity","version","previous","addFillColorUpdate","schema","addField","build","twoVersionAdditiveSchema","addSchemaUpdate","CircleRecord","radius","DocRef","UserRefField","refFieldsSchema","Circle","Drawing","mainShape","extraShapes","Array","background","attachment","owner","RectangleRecord","width","height","unionTypesSchema","Rectangle","Shape","variants","circle","rectangle","nestedOptionalsSchema","Config","tags","matrix","label","pointCloud","twoVersionDerivedFieldsSchema","migrations","derivedFrom","forward","threeVersionChainSchema","v1Models","Item","name","v2Models","hexColor","v3Models"],"sources":["fixtures.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { SchemaBuilder, SchemaDefinition } from \"@palantir/pack.schema\";\nimport {\n defineRecord,\n defineSchema,\n defineSchemaUpdate,\n defineUnion,\n modelToRef,\n nextSchema,\n} from \"@palantir/pack.schema\";\nimport * as P from \"@palantir/pack.schema\";\n\n/** Single-version schema: ShapeBox with 5 fields */\nconst singleVersionModels = {\n ShapeBox: defineRecord(\"ShapeBox\", {\n docs: \"A box shape\",\n fields: {\n left: P.Double,\n right: P.Double,\n top: P.Double,\n bottom: P.Double,\n color: P.Optional(P.String),\n },\n }),\n};\nconst singleVersionSchemaNarrow = defineSchema(singleVersionModels);\nexport const singleVersionSchema: SchemaDefinition = singleVersionSchemaNarrow;\n\n/** Two-version schema with field removal (color removed, fillColor + strokeColor + opacity added) */\nexport const twoVersionFieldRemovalSchema: SchemaDefinition = {\n type: \"versioned\",\n models: {\n ShapeBox: defineRecord(\"ShapeBox\", {\n docs: \"A box shape\",\n fields: {\n left: P.Double,\n right: P.Double,\n top: P.Double,\n bottom: P.Double,\n fillColor: P.Optional(P.String),\n strokeColor: P.Optional(P.String),\n opacity: P.Optional(P.Double),\n },\n }),\n },\n version: 2,\n previous: singleVersionSchema,\n};\n\n/** Two-version schema with additive change only (adds fillColor) */\nconst addFillColorUpdate = defineSchemaUpdate(\n \"addFillColor\",\n (schema: SchemaBuilder<typeof singleVersionModels>) => ({\n ShapeBox: schema.ShapeBox\n .addField(\"fillColor\", P.Optional(P.String))\n .build(),\n }),\n);\n\nexport const twoVersionAdditiveSchema: SchemaDefinition = nextSchema(singleVersionSchemaNarrow)\n .addSchemaUpdate(addFillColorUpdate)\n .build();\n\n/** Schema with ref fields: tests import paths for record refs, DocumentRef, UserRef */\nconst CircleRecord = defineRecord(\"Circle\", {\n docs: \"A circle\",\n fields: {\n radius: P.Double,\n },\n});\n\nconst DocRef: P.DocRef = { type: \"docRef\" };\nconst UserRefField: P.UserRef = { type: \"userRef\" };\n\nexport const refFieldsSchema: SchemaDefinition = defineSchema({\n Circle: CircleRecord,\n Drawing: defineRecord(\"Drawing\", {\n docs: \"A drawing with references\",\n fields: {\n mainShape: CircleRecord,\n extraShapes: P.Array(modelToRef(CircleRecord)),\n background: P.Optional(modelToRef(CircleRecord)),\n attachment: DocRef,\n owner: P.Optional(UserRefField),\n },\n }),\n});\n\n/** Schema with union types: tests union variant interfaces, discriminated union, and type guards */\nconst RectangleRecord = defineRecord(\"Rectangle\", {\n docs: \"A rectangle\",\n fields: {\n width: P.Double,\n height: P.Double,\n },\n});\n\nexport const unionTypesSchema: SchemaDefinition = defineSchema({\n Circle: CircleRecord,\n Rectangle: RectangleRecord,\n Shape: defineUnion(\"Shape\", {\n docs: \"A shape\",\n variants: {\n circle: CircleRecord,\n rectangle: RectangleRecord,\n },\n }),\n});\n\n/** Schema with nested optionals: tests that optional inside array/nested structures is preserved */\nexport const nestedOptionalsSchema: SchemaDefinition = defineSchema({\n Config: defineRecord(\"Config\", {\n docs: \"A config with nested optional fields\",\n fields: {\n tags: P.Array(P.Optional(P.String)),\n matrix: P.Array(P.Array(P.Optional(P.Double))),\n label: P.Optional(P.String),\n // Sparse 3D point cloud: pages of rows where each row may omit coordinate triples\n pointCloud: P.Array(P.Array(P.Optional(P.Array(P.Double)))),\n },\n }),\n});\n\n/** Two-version schema with derived fields (color split into fillColor + strokeColor) */\nexport const twoVersionDerivedFieldsSchema: SchemaDefinition = {\n type: \"versioned\",\n models: {\n ShapeBox: defineRecord(\"ShapeBox\", {\n docs: \"A box shape\",\n fields: {\n left: P.Double,\n right: P.Double,\n top: P.Double,\n bottom: P.Double,\n fillColor: P.Optional(P.String),\n strokeColor: P.Optional(P.String),\n opacity: P.Optional(P.Double),\n },\n }),\n },\n version: 2,\n previous: singleVersionSchema,\n migrations: {\n ShapeBox: {\n fillColor: {\n derivedFrom: [\"color\"],\n forward: ({ color }: Record<string, unknown>) => color,\n },\n strokeColor: {\n derivedFrom: [\"color\"],\n forward: ({ color }: Record<string, unknown>) => color,\n },\n },\n },\n};\n\n/** Three-version chain: Item (name, color -> name, hexColor -> name, hexColor, tags) */\nexport const threeVersionChainSchema: SchemaDefinition = (() => {\n const v1Models = {\n Item: defineRecord(\"Item\", {\n docs: \"\",\n fields: {\n name: P.String,\n color: P.Optional(P.String),\n },\n }),\n };\n const v2Models = {\n Item: defineRecord(\"Item\", {\n docs: \"\",\n fields: {\n name: P.String,\n hexColor: P.Optional(P.String),\n },\n }),\n };\n const v3Models = {\n Item: defineRecord(\"Item\", {\n docs: \"\",\n fields: {\n name: P.String,\n hexColor: P.Optional(P.String),\n tags: P.Optional(P.String),\n },\n }),\n };\n return {\n type: \"versioned\",\n models: v3Models,\n version: 3,\n previous: {\n type: \"versioned\",\n models: v2Models,\n version: 2,\n previous: { type: \"initial\", version: 1, models: v1Models },\n },\n };\n})();\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SACEA,YAAY,EACZC,YAAY,EACZC,kBAAkB,EAClBC,WAAW,EACXC,UAAU,EACVC,UAAU,QACL,uBAAuB;AAC9B,OAAO,KAAKC,CAAC,MAAM,uBAAuB;;AAE1C;AACA,MAAMC,mBAAmB,GAAG;EAC1BC,QAAQ,EAA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ElE,CAAC,CAACW,QAAQ,CAACX,CAAC,CAACY,MAAM,CAAC;QAC9ByC,IAAI,EAAErD,CAAC,CAACW,QAAQ,CAACX,CAAC,CAACY,MAAM;MAC3B;IACF,CAAC;EACH,CAAC;EACD,OAAO;IACLI,IAAI,EAAE,WAAW;IACjBC,MAAM,EAAEkD,QAAQ;IAChB9C,OAAO,EAAE,CAAC;IACVC,QAAQ,EAAE;MACRN,IAAI,EAAE,WAAW;MACjBC,MAAM,EAAEgD,QAAQ;MAChB5C,OAAO,EAAE,CAAC;MACVC,QAAQ,EAAE;QAAEN,IAAI,EAAE,SAAS;QAAEK,OAAO,EAAE,CAAC;QAAEJ,MAAM,EAAE6C;MAAS;IAC5D;EACF,CAAC;AACH,CAAC,EAAE,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import path from "path";
|
|
18
|
+
import { describe, expect, it } from "vitest";
|
|
19
|
+
import { generateInternalFromSchema } from "../generateInternalFromSchema.js";
|
|
20
|
+
import { nestedOptionalsSchema, singleVersionSchema, twoVersionDerivedFieldsSchema, twoVersionFieldRemovalSchema } from "./fixtures.js";
|
|
21
|
+
import { formatInternalTypesSnapshot } from "./snapshotUtils.js";
|
|
22
|
+
describe("generateInternalFromSchema", () => {
|
|
23
|
+
const snapshotDir = path.join(__dirname, "__snapshots__", "generateInternalFromSchema");
|
|
24
|
+
it("single-version schema", async () => {
|
|
25
|
+
const result = generateInternalFromSchema(singleVersionSchema);
|
|
26
|
+
await expect(await formatInternalTypesSnapshot(result)).toMatchFileSnapshot(path.join(snapshotDir, "single-version.snap"));
|
|
27
|
+
});
|
|
28
|
+
it("nested optionals inside arrays", async () => {
|
|
29
|
+
const result = generateInternalFromSchema(nestedOptionalsSchema);
|
|
30
|
+
await expect(await formatInternalTypesSnapshot(result)).toMatchFileSnapshot(path.join(snapshotDir, "nested-optionals.snap"));
|
|
31
|
+
});
|
|
32
|
+
it("two-version field removal", async () => {
|
|
33
|
+
const result = generateInternalFromSchema(twoVersionFieldRemovalSchema);
|
|
34
|
+
await expect(await formatInternalTypesSnapshot(result)).toMatchFileSnapshot(path.join(snapshotDir, "two-version-field-removal.snap"));
|
|
35
|
+
});
|
|
36
|
+
it("two-version derived fields", async () => {
|
|
37
|
+
const result = generateInternalFromSchema(twoVersionDerivedFieldsSchema);
|
|
38
|
+
await expect(await formatInternalTypesSnapshot(result)).toMatchFileSnapshot(path.join(snapshotDir, "two-version-derived-fields.snap"));
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=generateInternalFromSchema.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateInternalFromSchema.test.js","names":["path","describe","expect","it","generateInternalFromSchema","nestedOptionalsSchema","singleVersionSchema","twoVersionDerivedFieldsSchema","twoVersionFieldRemovalSchema","formatInternalTypesSnapshot","snapshotDir","join","__dirname","result","toMatchFileSnapshot"],"sources":["generateInternalFromSchema.test.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport path from \"path\";\nimport { describe, expect, it } from \"vitest\";\nimport { generateInternalFromSchema } from \"../generateInternalFromSchema.js\";\nimport {\n nestedOptionalsSchema,\n singleVersionSchema,\n twoVersionDerivedFieldsSchema,\n twoVersionFieldRemovalSchema,\n} from \"./fixtures.js\";\nimport { formatInternalTypesSnapshot } from \"./snapshotUtils.js\";\n\ndescribe(\"generateInternalFromSchema\", () => {\n const snapshotDir = path.join(__dirname, \"__snapshots__\", \"generateInternalFromSchema\");\n\n it(\"single-version schema\", async () => {\n const result = generateInternalFromSchema(singleVersionSchema);\n await expect(await formatInternalTypesSnapshot(result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"single-version.snap\"),\n );\n });\n\n it(\"nested optionals inside arrays\", async () => {\n const result = generateInternalFromSchema(nestedOptionalsSchema);\n await expect(await formatInternalTypesSnapshot(result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"nested-optionals.snap\"),\n );\n });\n\n it(\"two-version field removal\", async () => {\n const result = generateInternalFromSchema(twoVersionFieldRemovalSchema);\n await expect(await formatInternalTypesSnapshot(result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"two-version-field-removal.snap\"),\n );\n });\n\n it(\"two-version derived fields\", async () => {\n const result = generateInternalFromSchema(twoVersionDerivedFieldsSchema);\n await expect(await formatInternalTypesSnapshot(result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"two-version-derived-fields.snap\"),\n );\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,IAAI,MAAM,MAAM;AACvB,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC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I,CAACW,IAAI,CAACD,WAAW,EAAE,iCAAiC,CAC1D,CAAC;EACH,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import path from "path";
|
|
18
|
+
import { describe, expect, it } from "vitest";
|
|
19
|
+
import { generateModelMetadataFromSchema } from "../generateModelMetadataFromSchema.js";
|
|
20
|
+
import { singleVersionSchema, threeVersionChainSchema, twoVersionFieldRemovalSchema, unionTypesSchema } from "./fixtures.js";
|
|
21
|
+
import { formatModelMetadataSnapshot } from "./snapshotUtils.js";
|
|
22
|
+
describe("generateModelMetadataFromSchema", () => {
|
|
23
|
+
const snapshotDir = path.join(__dirname, "__snapshots__", "generateModelMetadataFromSchema");
|
|
24
|
+
it("single-version schema", async () => {
|
|
25
|
+
const result = generateModelMetadataFromSchema(singleVersionSchema);
|
|
26
|
+
await expect(await formatModelMetadataSnapshot(result)).toMatchFileSnapshot(path.join(snapshotDir, "single-version.snap"));
|
|
27
|
+
});
|
|
28
|
+
it("two-version field removal", async () => {
|
|
29
|
+
const result = generateModelMetadataFromSchema(twoVersionFieldRemovalSchema, 1);
|
|
30
|
+
await expect(await formatModelMetadataSnapshot(result)).toMatchFileSnapshot(path.join(snapshotDir, "two-version-field-removal.snap"));
|
|
31
|
+
});
|
|
32
|
+
it("three-version chain", async () => {
|
|
33
|
+
const result = generateModelMetadataFromSchema(threeVersionChainSchema, 1);
|
|
34
|
+
await expect(await formatModelMetadataSnapshot(result)).toMatchFileSnapshot(path.join(snapshotDir, "three-version-chain.snap"));
|
|
35
|
+
});
|
|
36
|
+
it("union types schema", async () => {
|
|
37
|
+
const result = generateModelMetadataFromSchema(unionTypesSchema);
|
|
38
|
+
await expect(await formatModelMetadataSnapshot(result)).toMatchFileSnapshot(path.join(snapshotDir, "union-types.snap"));
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=generateModelMetadataFromSchema.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateModelMetadataFromSchema.test.js","names":["path","describe","expect","it","generateModelMetadataFromSchema","singleVersionSchema","threeVersionChainSchema","twoVersionFieldRemovalSchema","unionTypesSchema","formatModelMetadataSnapshot","snapshotDir","join","__dirname","result","toMatchFileSnapshot"],"sources":["generateModelMetadataFromSchema.test.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport path from \"path\";\nimport { describe, expect, it } from \"vitest\";\nimport { generateModelMetadataFromSchema } from \"../generateModelMetadataFromSchema.js\";\nimport {\n singleVersionSchema,\n threeVersionChainSchema,\n twoVersionFieldRemovalSchema,\n unionTypesSchema,\n} from \"./fixtures.js\";\nimport { formatModelMetadataSnapshot } from \"./snapshotUtils.js\";\n\ndescribe(\"generateModelMetadataFromSchema\", () => {\n const snapshotDir = path.join(__dirname, \"__snapshots__\", \"generateModelMetadataFromSchema\");\n\n it(\"single-version schema\", async () => {\n const result = generateModelMetadataFromSchema(singleVersionSchema);\n await expect(await formatModelMetadataSnapshot(result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"single-version.snap\"),\n );\n });\n\n it(\"two-version field removal\", async () => {\n const result = generateModelMetadataFromSchema(twoVersionFieldRemovalSchema, 1);\n await expect(await formatModelMetadataSnapshot(result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"two-version-field-removal.snap\"),\n );\n });\n\n it(\"three-version chain\", async () => {\n const result = generateModelMetadataFromSchema(threeVersionChainSchema, 1);\n await expect(await formatModelMetadataSnapshot(result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"three-version-chain.snap\"),\n );\n });\n\n it(\"union types schema\", async () => {\n const result = generateModelMetadataFromSchema(unionTypesSchema);\n await expect(await formatModelMetadataSnapshot(result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"union-types.snap\"),\n );\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,IAAI,MAAM,MAAM;AACvB,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,+BAA+B,QAAQ,uCAAuC;AACvF,SACEC,mBAAmB,EACnBC,uBAAuB,EACvBC,4BAA4B,EAC5BC,gBAAgB,QACX,eAAe;AACtB,SAASC,2BAA2B,QAAQ,oBAAoB;AAEhER,QAAQ,CAAC,iCAAiC,EAAE,MAAM;EAChD,MAAMS,WAAW,GAAGV,IAAI,CAACW,IAAI,CAACC,SAAS,EAAE,eAAe,EAAE,iCAAiC,CAAC;EAE5FT,EAAE,CAAC,uBAAuB,EAAE,YAAY;IACtC,MAAMU,MAAM,GAAGT,+BAA+B,CAACC,mBAAmB,CAAC;IACnE,MAAMH,MAAM,CAAC,MAAMO,2BAA2B,CAACI,MAAM,CAAC,CAAC,CAACC,mBAAmB,CACzEd,IAAI,CAACW,IAAI,CAACD,WAAW,EAAE,qBAAqB,CAC9C,CAAC;EACH,CAAC,CAAC;EAEFP,EAAE,CAAC,2BAA2B,EAAE,YAAY;IAC1C,MAAMU,MAAM,GAAGT,+BAA+B,CAACG,4BAA4B,EAAE,CAAC,CAAC;IAC/E,MAAML,MAAM,CAAC,MAAMO,2BAA2B,CAACI,MAAM,CAAC,CAAC,CAACC,mBAAmB,CACzEd,IAAI,CAACW,IAAI,CAACD,WAAW,EAAE,gCAAgC,CACzD,CAAC;EACH,CAAC,CAAC;EAEFP,EAAE,CAAC,qBAAqB,EAAE,YAAY;IACpC,MAAMU,MAAM,GAAGT,+BAA+B,CAACE,uBAAuB,EAAE,CAAC,CAAC;IAC1E,MAAMJ,MAAM,CAAC,MAAMO,2BAA2B,CAACI,MAAM,CAAC,CAAC,CAACC,mBAAmB,CACzEd,IAAI,CAACW,IAAI,CAACD,WAAW,EAAE,0BAA0B,CACnD,CAAC;EACH,CAAC,CAAC;EAEFP,EAAE,CAAC,oBAAoB,EAAE,YAAY;IACnC,MAAMU,MAAM,GAAGT,+BAA+B,CAACI,gBAAgB,CAAC;IAChE,MAAMN,MAAM,CAAC,MAAMO,2BAA2B,CAACI,MAAM,CAAC,CAAC,CAACC,mBAAmB,CACzEd,IAAI,CAACW,IAAI,CAACD,WAAW,EAAE,kBAAkB,CAC3C,CAAC;EACH,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import path from "path";
|
|
18
|
+
import { describe, expect, it } from "vitest";
|
|
19
|
+
import { generateScopeFromSchema } from "../generateScopeFromSchema.js";
|
|
20
|
+
import { singleVersionSchema, twoVersionFieldRemovalSchema, unionTypesSchema } from "./fixtures.js";
|
|
21
|
+
import { formatSingleSnapshot } from "./snapshotUtils.js";
|
|
22
|
+
describe("generateScopeFromSchema", () => {
|
|
23
|
+
const snapshotDir = path.join(__dirname, "__snapshots__", "generateScopeFromSchema");
|
|
24
|
+
it("single-version schema", async () => {
|
|
25
|
+
const result = generateScopeFromSchema(singleVersionSchema);
|
|
26
|
+
await expect(await formatSingleSnapshot("versionedDocRef.ts", result)).toMatchFileSnapshot(path.join(snapshotDir, "single-version.snap"));
|
|
27
|
+
});
|
|
28
|
+
it("two-version field removal", async () => {
|
|
29
|
+
const result = generateScopeFromSchema(twoVersionFieldRemovalSchema, 1);
|
|
30
|
+
await expect(await formatSingleSnapshot("versionedDocRef.ts", result)).toMatchFileSnapshot(path.join(snapshotDir, "two-version-field-removal.snap"));
|
|
31
|
+
});
|
|
32
|
+
it("union types schema", async () => {
|
|
33
|
+
const result = generateScopeFromSchema(unionTypesSchema);
|
|
34
|
+
await expect(await formatSingleSnapshot("versionedDocRef.ts", result)).toMatchFileSnapshot(path.join(snapshotDir, "union-types.snap"));
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=generateScopeFromSchema.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateScopeFromSchema.test.js","names":["path","describe","expect","it","generateScopeFromSchema","singleVersionSchema","twoVersionFieldRemovalSchema","unionTypesSchema","formatSingleSnapshot","snapshotDir","join","__dirname","result","toMatchFileSnapshot"],"sources":["generateScopeFromSchema.test.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport path from \"path\";\nimport { describe, expect, it } from \"vitest\";\nimport { generateScopeFromSchema } from \"../generateScopeFromSchema.js\";\nimport { singleVersionSchema, twoVersionFieldRemovalSchema, unionTypesSchema } from \"./fixtures.js\";\nimport { formatSingleSnapshot } from \"./snapshotUtils.js\";\n\ndescribe(\"generateScopeFromSchema\", () => {\n const snapshotDir = path.join(__dirname, \"__snapshots__\", \"generateScopeFromSchema\");\n\n it(\"single-version schema\", async () => {\n const result = generateScopeFromSchema(singleVersionSchema);\n await expect(await formatSingleSnapshot(\"versionedDocRef.ts\", result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"single-version.snap\"),\n );\n });\n\n it(\"two-version field removal\", async () => {\n const result = generateScopeFromSchema(twoVersionFieldRemovalSchema, 1);\n await expect(await formatSingleSnapshot(\"versionedDocRef.ts\", result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"two-version-field-removal.snap\"),\n );\n });\n\n it(\"union types schema\", async () => {\n const result = generateScopeFromSchema(unionTypesSchema);\n await expect(await formatSingleSnapshot(\"versionedDocRef.ts\", result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"union-types.snap\"),\n );\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAA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 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import path from "path";
|
|
18
|
+
import { describe, expect, it } from "vitest";
|
|
19
|
+
import { generateVersionedTypesFromSchema } from "../generateVersionedTypesFromSchema.js";
|
|
20
|
+
import { refFieldsSchema, singleVersionSchema, threeVersionChainSchema, twoVersionAdditiveSchema, twoVersionFieldRemovalSchema, unionTypesSchema } from "./fixtures.js";
|
|
21
|
+
import { formatVersionedTypesSnapshot } from "./snapshotUtils.js";
|
|
22
|
+
describe("generateVersionedTypesFromSchema", () => {
|
|
23
|
+
const snapshotDir = path.join(__dirname, "__snapshots__", "generateVersionedTypesFromSchema");
|
|
24
|
+
it("single-version schema", async () => {
|
|
25
|
+
const result = generateVersionedTypesFromSchema(singleVersionSchema);
|
|
26
|
+
await expect(await formatVersionedTypesSnapshot(result)).toMatchFileSnapshot(path.join(snapshotDir, "single-version.snap"));
|
|
27
|
+
});
|
|
28
|
+
it("two-version additive change", async () => {
|
|
29
|
+
const result = generateVersionedTypesFromSchema(twoVersionAdditiveSchema, 1);
|
|
30
|
+
await expect(await formatVersionedTypesSnapshot(result)).toMatchFileSnapshot(path.join(snapshotDir, "two-version-additive.snap"));
|
|
31
|
+
});
|
|
32
|
+
it("two-version field removal", async () => {
|
|
33
|
+
const result = generateVersionedTypesFromSchema(twoVersionFieldRemovalSchema, 1);
|
|
34
|
+
await expect(await formatVersionedTypesSnapshot(result)).toMatchFileSnapshot(path.join(snapshotDir, "two-version-field-removal.snap"));
|
|
35
|
+
});
|
|
36
|
+
it("three-version chain", async () => {
|
|
37
|
+
const result = generateVersionedTypesFromSchema(threeVersionChainSchema, 1);
|
|
38
|
+
await expect(await formatVersionedTypesSnapshot(result)).toMatchFileSnapshot(path.join(snapshotDir, "three-version-chain.snap"));
|
|
39
|
+
});
|
|
40
|
+
it("schema with ref fields", async () => {
|
|
41
|
+
const result = generateVersionedTypesFromSchema(refFieldsSchema);
|
|
42
|
+
await expect(await formatVersionedTypesSnapshot(result)).toMatchFileSnapshot(path.join(snapshotDir, "ref-fields.snap"));
|
|
43
|
+
});
|
|
44
|
+
it("schema with union types", async () => {
|
|
45
|
+
const result = generateVersionedTypesFromSchema(unionTypesSchema);
|
|
46
|
+
await expect(await formatVersionedTypesSnapshot(result)).toMatchFileSnapshot(path.join(snapshotDir, "union-types.snap"));
|
|
47
|
+
});
|
|
48
|
+
it("respects minSupportedVersion default (latest only)", () => {
|
|
49
|
+
const result = generateVersionedTypesFromSchema(twoVersionAdditiveSchema);
|
|
50
|
+
expect(result.readTypes.size).toBe(1);
|
|
51
|
+
expect(result.readTypes.has(2)).toBe(true);
|
|
52
|
+
expect(result.readTypes.has(1)).toBe(false);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=generateVersionedTypesFromSchema.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateVersionedTypesFromSchema.test.js","names":["path","describe","expect","it","generateVersionedTypesFromSchema","refFieldsSchema","singleVersionSchema","threeVersionChainSchema","twoVersionAdditiveSchema","twoVersionFieldRemovalSchema","unionTypesSchema","formatVersionedTypesSnapshot","snapshotDir","join","__dirname","result","toMatchFileSnapshot","readTypes","size","toBe","has"],"sources":["generateVersionedTypesFromSchema.test.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport path from \"path\";\nimport { describe, expect, it } from \"vitest\";\nimport { generateVersionedTypesFromSchema } from \"../generateVersionedTypesFromSchema.js\";\nimport {\n refFieldsSchema,\n singleVersionSchema,\n threeVersionChainSchema,\n twoVersionAdditiveSchema,\n twoVersionFieldRemovalSchema,\n unionTypesSchema,\n} from \"./fixtures.js\";\nimport { formatVersionedTypesSnapshot } from \"./snapshotUtils.js\";\n\ndescribe(\"generateVersionedTypesFromSchema\", () => {\n const snapshotDir = path.join(__dirname, \"__snapshots__\", \"generateVersionedTypesFromSchema\");\n\n it(\"single-version schema\", async () => {\n const result = generateVersionedTypesFromSchema(singleVersionSchema);\n await expect(await formatVersionedTypesSnapshot(result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"single-version.snap\"),\n );\n });\n\n it(\"two-version additive change\", async () => {\n const result = generateVersionedTypesFromSchema(twoVersionAdditiveSchema, 1);\n await expect(await formatVersionedTypesSnapshot(result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"two-version-additive.snap\"),\n );\n });\n\n it(\"two-version field removal\", async () => {\n const result = generateVersionedTypesFromSchema(twoVersionFieldRemovalSchema, 1);\n await expect(await formatVersionedTypesSnapshot(result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"two-version-field-removal.snap\"),\n );\n });\n\n it(\"three-version chain\", async () => {\n const result = generateVersionedTypesFromSchema(threeVersionChainSchema, 1);\n await expect(await formatVersionedTypesSnapshot(result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"three-version-chain.snap\"),\n );\n });\n\n it(\"schema with ref fields\", async () => {\n const result = generateVersionedTypesFromSchema(refFieldsSchema);\n await expect(await formatVersionedTypesSnapshot(result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"ref-fields.snap\"),\n );\n });\n\n it(\"schema with union types\", async () => {\n const result = generateVersionedTypesFromSchema(unionTypesSchema);\n await expect(await formatVersionedTypesSnapshot(result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"union-types.snap\"),\n );\n });\n\n it(\"respects minSupportedVersion default (latest only)\", () => {\n const result = generateVersionedTypesFromSchema(twoVersionAdditiveSchema);\n expect(result.readTypes.size).toBe(1);\n expect(result.readTypes.has(2)).toBe(true);\n expect(result.readTypes.has(1)).toBe(false);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,IAAI,MAAM,MAAM;AACvB,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,gCAAgC,QAAQ,wCAAwC;AACzF,SACEC,eAAe,EACfC,mBAAmB,EACnBC,uBAAuB,EACvBC,wBAAwB,EACxBC,4BAA4B,EAC5BC,gBAAgB,QACX,eAAe;AACtB,SAASC,4BAA4B,QAAQ,oBAAoB;AAEjEV,QAAQ,CAAC,kCAAkC,EAAE,MAAM;EACjD,MAAMW,WAAW,GAAGZ,IAAI,CAACa,IAAI,CAACC,SAAS,EAAE,eAAe,EAAE,kCAAkC,CAAC;EAE7FX,EAAE,CAAC,uBAAuB,EAAE,YAAY;IACtC,MAAMY,MAAM,GAAGX,gCAAgC,CAACE,mBAAmB,CAAC;IACpE,MAAMJ,MAAM,CAAC,MAAMS,4BAA4B,CAACI,MAAM,CAAC,CAAC,CAACC,mBAAmB,CAC1EhB,IAAI,CAACa,IAAI,CAACD,WAAW,EAAE,qBAAqB,CAC9C,CAAC;EACH,CAAC,CAAC;EAEFT,EA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,CAC1EhB,IAAI,CAACa,IAAI,CAACD,WAAW,EAAE,kBAAkB,CAC3C,CAAC;EACH,CAAC,CAAC;EAEFT,EAAE,CAAC,oDAAoD,EAAE,MAAM;IAC7D,MAAMY,MAAM,GAAGX,gCAAgC,CAACI,wBAAwB,CAAC;IACzEN,MAAM,CAACa,MAAM,CAACE,SAAS,CAACC,IAAI,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC;IACrCjB,MAAM,CAACa,MAAM,CAACE,SAAS,CAACG,GAAG,CAAC,CAAC,CAAC,CAAC,CAACD,IAAI,CAAC,IAAI,CAAC;IAC1CjB,MAAM,CAACa,MAAM,CAACE,SAAS,CAACG,GAAG,CAAC,CAAC,CAAC,CAAC,CAACD,IAAI,CAAC,KAAK,CAAC;EAC7C,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import path from "path";
|
|
18
|
+
import { describe, expect, it } from "vitest";
|
|
19
|
+
import { generateVersionedZodFromSchema } from "../generateVersionedZodFromSchema.js";
|
|
20
|
+
import { nestedOptionalsSchema, refFieldsSchema, singleVersionSchema, twoVersionAdditiveSchema, twoVersionFieldRemovalSchema, unionTypesSchema } from "./fixtures.js";
|
|
21
|
+
import { formatVersionedZodSnapshot } from "./snapshotUtils.js";
|
|
22
|
+
describe("generateVersionedZodFromSchema", () => {
|
|
23
|
+
const snapshotDir = path.join(__dirname, "__snapshots__", "generateVersionedZodFromSchema");
|
|
24
|
+
it("single-version schema", async () => {
|
|
25
|
+
const result = generateVersionedZodFromSchema(singleVersionSchema);
|
|
26
|
+
await expect(await formatVersionedZodSnapshot(result)).toMatchFileSnapshot(path.join(snapshotDir, "single-version.snap"));
|
|
27
|
+
});
|
|
28
|
+
it("two-version additive change", async () => {
|
|
29
|
+
const result = generateVersionedZodFromSchema(twoVersionAdditiveSchema, 1);
|
|
30
|
+
await expect(await formatVersionedZodSnapshot(result)).toMatchFileSnapshot(path.join(snapshotDir, "two-version-additive.snap"));
|
|
31
|
+
});
|
|
32
|
+
it("two-version field removal", async () => {
|
|
33
|
+
const result = generateVersionedZodFromSchema(twoVersionFieldRemovalSchema, 1);
|
|
34
|
+
await expect(await formatVersionedZodSnapshot(result)).toMatchFileSnapshot(path.join(snapshotDir, "two-version-field-removal.snap"));
|
|
35
|
+
});
|
|
36
|
+
it("schema with union types", async () => {
|
|
37
|
+
const result = generateVersionedZodFromSchema(unionTypesSchema);
|
|
38
|
+
await expect(await formatVersionedZodSnapshot(result)).toMatchFileSnapshot(path.join(snapshotDir, "union-types.snap"));
|
|
39
|
+
});
|
|
40
|
+
it("schema with ref fields", async () => {
|
|
41
|
+
const result = generateVersionedZodFromSchema(refFieldsSchema);
|
|
42
|
+
await expect(await formatVersionedZodSnapshot(result)).toMatchFileSnapshot(path.join(snapshotDir, "ref-fields.snap"));
|
|
43
|
+
});
|
|
44
|
+
it("nested optionals inside arrays", async () => {
|
|
45
|
+
const result = generateVersionedZodFromSchema(nestedOptionalsSchema);
|
|
46
|
+
await expect(await formatVersionedZodSnapshot(result)).toMatchFileSnapshot(path.join(snapshotDir, "nested-optionals.snap"));
|
|
47
|
+
});
|
|
48
|
+
it("respects minSupportedVersion default (latest only)", () => {
|
|
49
|
+
const result = generateVersionedZodFromSchema(twoVersionAdditiveSchema);
|
|
50
|
+
expect(result.zodSchemas.size).toBe(1);
|
|
51
|
+
expect(result.zodSchemas.has(2)).toBe(true);
|
|
52
|
+
expect(result.zodSchemas.has(1)).toBe(false);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=generateVersionedZodFromSchema.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateVersionedZodFromSchema.test.js","names":["path","describe","expect","it","generateVersionedZodFromSchema","nestedOptionalsSchema","refFieldsSchema","singleVersionSchema","twoVersionAdditiveSchema","twoVersionFieldRemovalSchema","unionTypesSchema","formatVersionedZodSnapshot","snapshotDir","join","__dirname","result","toMatchFileSnapshot","zodSchemas","size","toBe","has"],"sources":["generateVersionedZodFromSchema.test.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport path from \"path\";\nimport { describe, expect, it } from \"vitest\";\nimport { generateVersionedZodFromSchema } from \"../generateVersionedZodFromSchema.js\";\nimport {\n nestedOptionalsSchema,\n refFieldsSchema,\n singleVersionSchema,\n twoVersionAdditiveSchema,\n twoVersionFieldRemovalSchema,\n unionTypesSchema,\n} from \"./fixtures.js\";\nimport { formatVersionedZodSnapshot } from \"./snapshotUtils.js\";\n\ndescribe(\"generateVersionedZodFromSchema\", () => {\n const snapshotDir = path.join(__dirname, \"__snapshots__\", \"generateVersionedZodFromSchema\");\n\n it(\"single-version schema\", async () => {\n const result = generateVersionedZodFromSchema(singleVersionSchema);\n await expect(await formatVersionedZodSnapshot(result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"single-version.snap\"),\n );\n });\n\n it(\"two-version additive change\", async () => {\n const result = generateVersionedZodFromSchema(twoVersionAdditiveSchema, 1);\n await expect(await formatVersionedZodSnapshot(result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"two-version-additive.snap\"),\n );\n });\n\n it(\"two-version field removal\", async () => {\n const result = generateVersionedZodFromSchema(twoVersionFieldRemovalSchema, 1);\n await expect(await formatVersionedZodSnapshot(result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"two-version-field-removal.snap\"),\n );\n });\n\n it(\"schema with union types\", async () => {\n const result = generateVersionedZodFromSchema(unionTypesSchema);\n await expect(await formatVersionedZodSnapshot(result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"union-types.snap\"),\n );\n });\n\n it(\"schema with ref fields\", async () => {\n const result = generateVersionedZodFromSchema(refFieldsSchema);\n await expect(await formatVersionedZodSnapshot(result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"ref-fields.snap\"),\n );\n });\n\n it(\"nested optionals inside arrays\", async () => {\n const result = generateVersionedZodFromSchema(nestedOptionalsSchema);\n await expect(await formatVersionedZodSnapshot(result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"nested-optionals.snap\"),\n );\n });\n\n it(\"respects minSupportedVersion default (latest only)\", () => {\n const result = generateVersionedZodFromSchema(twoVersionAdditiveSchema);\n expect(result.zodSchemas.size).toBe(1);\n expect(result.zodSchemas.has(2)).toBe(true);\n expect(result.zodSchemas.has(1)).toBe(false);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,IAAI,MAAM,MAAM;AACvB,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,8BAA8B,QAAQ,sCAAsC;AACrF,SACEC,qBAAqB,E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xEhB,IAAI,CAACa,IAAI,CAACD,WAAW,EAAE,kBAAkB,CAC3C,CAAC;EACH,CAAC,CAAC;EAEFT,EAAE,CAAC,wBAAwB,EAAE,YAAY;IACvC,MAAMY,MAAM,GAAGX,8BAA8B,CAACE,eAAe,CAAC;IAC9D,MAAMJ,MAAM,CAAC,MAAMS,0BAA0B,CAACI,MAAM,CAAC,CAAC,CAACC,mBAAmB,CACxEhB,IAAI,CAACa,IAAI,CAACD,WAAW,EAAE,iBAAiB,CAC1C,CAAC;EACH,CAAC,CAAC;EAEFT,EAAE,CAAC,gCAAgC,EAAE,YAAY;IAC/C,MAAMY,MAAM,GAAGX,8BAA8B,CAACC,qBAAqB,CAAC;IACpE,MAAMH,MAAM,CAAC,MAAMS,0BAA0B,CAACI,MAAM,CAAC,CAAC,CAACC,mBAAmB,CACxEhB,IAAI,CAACa,IAAI,CAACD,WAAW,EAAE,uBAAuB,CAChD,CAAC;EACH,CAAC,CAAC;EAEFT,EAAE,CAAC,oDAAoD,EAAE,MAAM;IAC7D,MAAMY,MAAM,GAAGX,8BAA8B,CAACI,wBAAwB,CAAC;IACvEN,MAAM,CAACa,MAAM,CAACE,UAAU,CAACC,IAAI,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC;IACtCjB,MAAM,CAACa,MAAM,CAACE,UAAU,CAACG,GAAG,CAAC,CAAC,CAAC,CAAC,CAACD,IAAI,CAAC,IAAI,CAAC;IAC3CjB,MAAM,CAACa,MAAM,CAACE,UAAU,CAACG,GAAG,CAAC,CAAC,CAAC,CAAC,CAACD,IAAI,CAAC,KAAK,CAAC;EAC9C,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import path from "path";
|
|
18
|
+
import { describe, expect, it } from "vitest";
|
|
19
|
+
import { generateVersionsFromSchema } from "../generateVersionsFromSchema.js";
|
|
20
|
+
import { singleVersionSchema, threeVersionChainSchema, twoVersionAdditiveSchema } from "./fixtures.js";
|
|
21
|
+
import { formatSingleSnapshot } from "./snapshotUtils.js";
|
|
22
|
+
describe("generateVersionsFromSchema", () => {
|
|
23
|
+
const snapshotDir = path.join(__dirname, "__snapshots__", "generateVersionsFromSchema");
|
|
24
|
+
it("single-version schema", async () => {
|
|
25
|
+
const result = generateVersionsFromSchema(singleVersionSchema);
|
|
26
|
+
await expect(await formatSingleSnapshot("versions.ts", result)).toMatchFileSnapshot(path.join(snapshotDir, "single-version.ts"));
|
|
27
|
+
});
|
|
28
|
+
it("two-version with minSupportedVersion", async () => {
|
|
29
|
+
const result = generateVersionsFromSchema(twoVersionAdditiveSchema, 1);
|
|
30
|
+
await expect(await formatSingleSnapshot("versions.ts", result)).toMatchFileSnapshot(path.join(snapshotDir, "two-version.ts"));
|
|
31
|
+
});
|
|
32
|
+
it("three-version chain", async () => {
|
|
33
|
+
const result = generateVersionsFromSchema(threeVersionChainSchema, 1);
|
|
34
|
+
await expect(await formatSingleSnapshot("versions.ts", result)).toMatchFileSnapshot(path.join(snapshotDir, "three-version-chain.ts"));
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=generateVersionsFromSchema.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateVersionsFromSchema.test.js","names":["path","describe","expect","it","generateVersionsFromSchema","singleVersionSchema","threeVersionChainSchema","twoVersionAdditiveSchema","formatSingleSnapshot","snapshotDir","join","__dirname","result","toMatchFileSnapshot"],"sources":["generateVersionsFromSchema.test.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport path from \"path\";\nimport { describe, expect, it } from \"vitest\";\nimport { generateVersionsFromSchema } from \"../generateVersionsFromSchema.js\";\nimport {\n singleVersionSchema,\n threeVersionChainSchema,\n twoVersionAdditiveSchema,\n} from \"./fixtures.js\";\nimport { formatSingleSnapshot } from \"./snapshotUtils.js\";\n\ndescribe(\"generateVersionsFromSchema\", () => {\n const snapshotDir = path.join(__dirname, \"__snapshots__\", \"generateVersionsFromSchema\");\n\n it(\"single-version schema\", async () => {\n const result = generateVersionsFromSchema(singleVersionSchema);\n await expect(await formatSingleSnapshot(\"versions.ts\", result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"single-version.ts\"),\n );\n });\n\n it(\"two-version with minSupportedVersion\", async () => {\n const result = generateVersionsFromSchema(twoVersionAdditiveSchema, 1);\n await expect(await formatSingleSnapshot(\"versions.ts\", result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"two-version.ts\"),\n );\n });\n\n it(\"three-version chain\", async () => {\n const result = generateVersionsFromSchema(threeVersionChainSchema, 1);\n await expect(await formatSingleSnapshot(\"versions.ts\", result)).toMatchFileSnapshot(\n path.join(snapshotDir, \"three-version-chain.ts\"),\n );\n });\n});\n"],"m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