@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,54 @@
|
|
|
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
|
+
function collectVersionedSchemaChain(input) {
|
|
18
|
+
const chain = [];
|
|
19
|
+
let current = input;
|
|
20
|
+
while (current.type === "versioned") {
|
|
21
|
+
chain.unshift({
|
|
22
|
+
version: current.version,
|
|
23
|
+
schema: current.models,
|
|
24
|
+
migrations: current.migrations
|
|
25
|
+
});
|
|
26
|
+
current = current.previous;
|
|
27
|
+
}
|
|
28
|
+
chain.unshift({
|
|
29
|
+
version: current.version,
|
|
30
|
+
schema: current.models
|
|
31
|
+
});
|
|
32
|
+
return chain;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Collect the version chain and resolve min/latest versions.
|
|
37
|
+
* Throws on empty chain or invalid minSupportedVersion.
|
|
38
|
+
*/
|
|
39
|
+
export function resolveSchemaChain(schema, minSupportedVersion) {
|
|
40
|
+
const chain = collectVersionedSchemaChain(schema);
|
|
41
|
+
if (chain.length === 0) {
|
|
42
|
+
throw new Error("Schema version chain is empty");
|
|
43
|
+
}
|
|
44
|
+
const latestVersion = chain[chain.length - 1].version;
|
|
45
|
+
if (minSupportedVersion != null && !chain.some(c => c.version === minSupportedVersion)) {
|
|
46
|
+
throw new Error(`minSupportedVersion ${minSupportedVersion} is not in the schema chain ` + `(available versions: ${chain.map(c => c.version).join(", ")})`);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
chain,
|
|
50
|
+
latestVersion,
|
|
51
|
+
minVersion: minSupportedVersion ?? latestVersion
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=resolveSchemaChain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveSchemaChain.js","names":["collectVersionedSchemaChain","input","chain","current","type","unshift","version","schema","models","migrations","previous","resolveSchemaChain","minSupportedVersion","length","Error","latestVersion","some","c","map","join","minVersion"],"sources":["resolveSchemaChain.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 { SchemaDefinition, VersionMigrations } from \"@palantir/pack.schema\";\nimport type { RuntimeSchema } from \"./runtimeSchema.js\";\n\nexport interface VersionedSchemaEntry {\n version: number;\n schema: RuntimeSchema;\n migrations?: VersionMigrations;\n}\n\nexport interface ResolvedSchemaChain {\n chain: VersionedSchemaEntry[];\n latestVersion: number;\n minVersion: number;\n}\n\nfunction collectVersionedSchemaChain(input: SchemaDefinition): VersionedSchemaEntry[] {\n const chain: VersionedSchemaEntry[] = [];\n let current: SchemaDefinition = input;\n\n while (current.type === \"versioned\") {\n chain.unshift({\n version: current.version,\n schema: current.models as RuntimeSchema,\n migrations: current.migrations,\n });\n current = current.previous;\n }\n chain.unshift({ version: current.version, schema: current.models as RuntimeSchema });\n\n return chain;\n}\n\n/**\n * Collect the version chain and resolve min/latest versions.\n * Throws on empty chain or invalid minSupportedVersion.\n */\nexport function resolveSchemaChain(\n schema: SchemaDefinition,\n minSupportedVersion?: number,\n): ResolvedSchemaChain {\n const chain = collectVersionedSchemaChain(schema);\n\n if (chain.length === 0) {\n throw new Error(\"Schema version chain is empty\");\n }\n\n const latestVersion = chain[chain.length - 1]!.version;\n\n if (minSupportedVersion != null && !chain.some(c => c.version === minSupportedVersion)) {\n throw new Error(\n `minSupportedVersion ${minSupportedVersion} is not in the schema chain `\n + `(available versions: ${chain.map(c => c.version).join(\", \")})`,\n );\n }\n\n const minVersion = minSupportedVersion ?? latestVersion;\n\n return { chain, latestVersion, minVersion };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiBA,SAASA,2BAA2BA,CAACC,KAAuB,EAA0B;EACpF,MAAMC,KAA6B,GAAG,EAAE;EACxC,IAAIC,OAAyB,GAAGF,KAAK;EAErC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
|
|
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 { TypeKind as SchemaTypeKind } from "@palantir/pack.schema";
|
|
18
|
+
export const TypeKind = {
|
|
19
|
+
...SchemaTypeKind,
|
|
20
|
+
ANY: "any"
|
|
21
|
+
};
|
|
22
|
+
export const SchemaDefKind = {
|
|
23
|
+
RECORD: "record",
|
|
24
|
+
UNION: "union"
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// Runtime types mirroring the schema structure
|
|
28
|
+
|
|
29
|
+
export function isRecordSchema(item) {
|
|
30
|
+
return item.type === SchemaDefKind.RECORD && "fields" in item;
|
|
31
|
+
}
|
|
32
|
+
export function isUnionSchema(item) {
|
|
33
|
+
return item.type === SchemaDefKind.UNION && "variants" in item;
|
|
34
|
+
}
|
|
35
|
+
export function findRecordExportName(recordName, schema) {
|
|
36
|
+
for (const [exportName, item] of Object.entries(schema)) {
|
|
37
|
+
if (isRecordSchema(item) && item.name === recordName) {
|
|
38
|
+
return exportName;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Versioned read type name: `RecordName_vN` */
|
|
45
|
+
export function versionedTypeName(exportName, version) {
|
|
46
|
+
return `${exportName}_v${version}`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Versioned write type name: `RecordNameUpdate_vN` */
|
|
50
|
+
export function versionedWriteTypeName(exportName, version) {
|
|
51
|
+
return `${exportName}Update_v${version}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Versioned Zod schema name: `RecordNameSchema_vN` */
|
|
55
|
+
export function versionedSchemaName(exportName, version) {
|
|
56
|
+
return `${exportName}Schema_v${version}`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Model constant name: `RecordNameModel` */
|
|
60
|
+
export function modelName(exportName) {
|
|
61
|
+
return `${exportName}Model`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Unversioned Zod schema name: `RecordNameSchema` */
|
|
65
|
+
export function schemaName(exportName) {
|
|
66
|
+
return `${exportName}Schema`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Per-version types file path: `./types_vN.js` */
|
|
70
|
+
export function typesFilePath(version) {
|
|
71
|
+
return `./types_v${version}.js`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Per-version write types file path: `./writeTypes_vN.js` */
|
|
75
|
+
export function writeTypesFilePath(version) {
|
|
76
|
+
return `./writeTypes_v${version}.js`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Types re-export file path: `./types.js` */
|
|
80
|
+
export const TYPES_REEXPORT_PATH = "./types.js";
|
|
81
|
+
|
|
82
|
+
/** Schema re-export file path: `./schema.js` */
|
|
83
|
+
export const SCHEMA_REEXPORT_PATH = "./schema.js";
|
|
84
|
+
|
|
85
|
+
/** Models file path: `./models.js` */
|
|
86
|
+
export const MODELS_PATH = "./models.js";
|
|
87
|
+
|
|
88
|
+
/** Internal upgrades file path: `./_internal/upgrades.js` */
|
|
89
|
+
export const INTERNAL_UPGRADES_PATH = "./_internal/upgrades.js";
|
|
90
|
+
|
|
91
|
+
/** Versions file path: `./versions.js` */
|
|
92
|
+
export const VERSIONS_PATH = "./versions.js";
|
|
93
|
+
|
|
94
|
+
/** Versioned doc ref file path: `./versionedDocRef.js` */
|
|
95
|
+
export const VERSIONED_DOC_REF_PATH = "./versionedDocRef.js";
|
|
96
|
+
//# sourceMappingURL=runtimeSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeSchema.js","names":["TypeKind","SchemaTypeKind","ANY","SchemaDefKind","RECORD","UNION","isRecordSchema","item","type","isUnionSchema","findRecordExportName","recordName","schema","exportName","Object","entries","name","versionedTypeName","version","versionedWriteTypeName","versionedSchemaName","modelName","schemaName","typesFilePath","writeTypesFilePath","TYPES_REEXPORT_PATH","SCHEMA_REEXPORT_PATH","MODELS_PATH","INTERNAL_UPGRADES_PATH","VERSIONS_PATH","VERSIONED_DOC_REF_PATH"],"sources":["runtimeSchema.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 { TypeKind as SchemaTypeKind } from \"@palantir/pack.schema\";\n\nexport const TypeKind: typeof SchemaTypeKind & { readonly ANY: \"any\" } = {\n ...SchemaTypeKind,\n ANY: \"any\",\n};\n\nexport const SchemaDefKind = {\n RECORD: \"record\",\n UNION: \"union\",\n} as const;\n\n// Runtime types mirroring the schema structure\nexport interface SchemaField {\n readonly type: string;\n readonly items?: SchemaField;\n readonly item?: SchemaField;\n readonly refType?: \"record\" | \"union\";\n readonly name?: string;\n}\n\nexport interface RuntimeSchemaRecord {\n readonly type: typeof SchemaDefKind.RECORD;\n readonly name: string;\n readonly docs?: string;\n readonly fields: Readonly<Record<string, SchemaField>>;\n}\n\nexport interface RuntimeSchemaUnion {\n readonly type: typeof SchemaDefKind.UNION;\n readonly name?: string;\n readonly variants: Readonly<Record<string, SchemaField>>;\n readonly discriminant: string;\n}\n\nexport type RuntimeSchemaItem = RuntimeSchemaRecord | RuntimeSchemaUnion;\nexport type RuntimeSchema = Record<string, RuntimeSchemaItem>;\n\nexport function isRecordSchema(item: RuntimeSchemaItem): item is RuntimeSchemaRecord {\n return item.type === SchemaDefKind.RECORD && \"fields\" in item;\n}\n\nexport function isUnionSchema(item: RuntimeSchemaItem): item is RuntimeSchemaUnion {\n return item.type === SchemaDefKind.UNION && \"variants\" in item;\n}\n\nexport function findRecordExportName(recordName: string, schema: RuntimeSchema): string | null {\n for (const [exportName, item] of Object.entries(schema)) {\n if (isRecordSchema(item) && item.name === recordName) {\n return exportName;\n }\n }\n return null;\n}\n\n/** Versioned read type name: `RecordName_vN` */\nexport function versionedTypeName(exportName: string, version: number): string {\n return `${exportName}_v${version}`;\n}\n\n/** Versioned write type name: `RecordNameUpdate_vN` */\nexport function versionedWriteTypeName(exportName: string, version: number): string {\n return `${exportName}Update_v${version}`;\n}\n\n/** Versioned Zod schema name: `RecordNameSchema_vN` */\nexport function versionedSchemaName(exportName: string, version: number): string {\n return `${exportName}Schema_v${version}`;\n}\n\n/** Model constant name: `RecordNameModel` */\nexport function modelName(exportName: string): string {\n return `${exportName}Model`;\n}\n\n/** Unversioned Zod schema name: `RecordNameSchema` */\nexport function schemaName(exportName: string): string {\n return `${exportName}Schema`;\n}\n\n/** Per-version types file path: `./types_vN.js` */\nexport function typesFilePath(version: number): string {\n return `./types_v${version}.js`;\n}\n\n/** Per-version write types file path: `./writeTypes_vN.js` */\nexport function writeTypesFilePath(version: number): string {\n return `./writeTypes_v${version}.js`;\n}\n\n/** Types re-export file path: `./types.js` */\nexport const TYPES_REEXPORT_PATH = \"./types.js\";\n\n/** Schema re-export file path: `./schema.js` */\nexport const SCHEMA_REEXPORT_PATH = \"./schema.js\";\n\n/** Models file path: `./models.js` */\nexport const MODELS_PATH = \"./models.js\";\n\n/** Internal upgrades file path: `./_internal/upgrades.js` */\nexport const INTERNAL_UPGRADES_PATH = \"./_internal/upgrades.js\";\n\n/** Versions file path: `./versions.js` */\nexport const VERSIONS_PATH = \"./versions.js\";\n\n/** Versioned doc ref file path: `./versionedDocRef.js` */\nexport const VERSIONED_DOC_REF_PATH = \"./versionedDocRef.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,IAAIC,cAAc,QAAQ,uBAAuB;AAElE,OAAO,MAAMD,QAAyD,GAAG;EACvE,GAAGC,cAAc;EACjBC,GAAG,EAAE;AACP,CAAC;AAED,OAAO,MAAMC,aAAa,GAAG;EAC3BC,MAAM,EAAE,QAAQ;EAChBC,KAAK,EAAE;AACT,CAAU;;AAEV;;AA0BA,OAAO,SAASC,cAAcA,CAACC,IAAuB,EAA+B;EACnF,OAAOA,IAAI,CAACC,IAAI,KAAKL,aAAa,CAACC,MAAM,IAAI,QAAQ,IAAIG,IAAI;AAC/D;AAEA,OAAO,SAASE,aAAaA,CAACF,IAAuB,EAA8B;EACjF,OAAOA,IAAI,CAACC,IAAI,KAAKL,aAAa,CAACE,KAAK,IAAI,UAAU,IAAIE,IAAI;AAChE;AAEA,OAAO,SAASG,oBAAoBA,CAACC,UAAkB,EAAEC,MAAqB,EAAiB;EAC7F,KAAK,MAAM,CAACC,UAAU,EAAEN,IAAI,CAAC,IAAIO,MAAM,CAACC,OAAO,CAACH,MAAM,CAAC,EAAE;IACvD,IAAIN,cAAc,CAACC,IAAI,CAAC,IAAIA,IAAI,CAACS,IAAI,KAAKL,UAAU,EAAE;MACpD,OAAOE,UAAU;IACnB;EACF;EACA,OAAO,IAAI;AACb;;AAEA;AACA,OAAO,SAASI,iBAAiBA,CAACJ,UAAkB,EAAEK,OAAe,EAAU;EAC7E,OAAO,GAAGL,UAAU,KAAKK,OAAO,EAAE;AACpC;;AAEA;AACA,OAAO,SAASC,sBAAsBA,CAACN,UAAkB,EAAEK,OAAe,EAAU;EAClF,OAAO,GAAGL,UAAU,WAAWK,OAAO,EAAE;AAC1C;;AAEA;AACA,OAAO,SAASE,mBAAmBA,CAACP,UAAkB,EAAEK,OAAe,EAAU;EAC/E,OAAO,GAAGL,UAAU,WAAWK,OAAO,EAAE;AAC1C;;AAEA;AACA,OAAO,SAASG,SAASA,CAACR,UAAkB,EAAU;EACpD,OAAO,GAAGA,UAAU,OAAO;AAC7B;;AAEA;AACA,OAAO,SAASS,UAAUA,CAACT,UAAkB,EAAU;EACrD,OAAO,GAAGA,UAAU,QAAQ;AAC9B;;AAEA;AACA,OAAO,SAASU,aAAaA,CAACL,OAAe,EAAU;EACrD,OAAO,YAAYA,OAAO,KAAK;AACjC;;AAEA;AACA,OAAO,SAASM,kBAAkBA,CAACN,OAAe,EAAU;EAC1D,OAAO,iBAAiBA,OAAO,KAAK;AACtC;;AAEA;AACA,OAAO,MAAMO,mBAAmB,GAAG,YAAY;;AAE/C;AACA,OAAO,MAAMC,oBAAoB,GAAG,aAAa;;AAEjD;AACA,OAAO,MAAMC,WAAW,GAAG,aAAa;;AAExC;AACA,OAAO,MAAMC,sBAAsB,GAAG,yBAAyB;;AAE/D;AACA,OAAO,MAAMC,aAAa,GAAG,eAAe;;AAE5C;AACA,OAAO,MAAMC,sBAAsB,GAAG,sBAAsB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrayFields.js","names":[],"sources":["arrayFields.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"arrayFields.js","names":[],"sources":["arrayFields.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.9.0 */\n\n\nexport interface Container {\n readonly items: readonly string[];\n readonly numbers: readonly number[];\n}\n\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customDiscriminant.js","names":["isAnimalCat","value","kind","isAnimalDog"],"sources":["customDiscriminant.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"customDiscriminant.js","names":["isAnimalCat","value","kind","isAnimalDog"],"sources":["customDiscriminant.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.9.0 */\n\n\n/**\n * A cat\n */\nexport interface Cat {\n readonly meow: string;\n readonly whiskers: number;\n}\n\n/**\n * A dog\n */\nexport interface Dog {\n readonly bark: string;\n readonly tailWags: number;\n}\n\nexport interface AnimalCat extends Cat {\n readonly kind: \"cat\";\n}\n\nexport interface AnimalDog extends Dog {\n readonly kind: \"dog\";\n}\n\nexport type Animal = AnimalCat | AnimalDog;\n\nexport function isAnimalCat(value: Animal): value is AnimalCat {\n return value.kind === \"cat\";\n}\n\nexport function isAnimalDog(value: Animal): value is AnimalDog {\n return value.kind === \"dog\";\n}\n\n"],"mappings":"AAAA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;;AAgBA,OAAO,SAASA,WAAWA,CAACC,KAAa,EAAsB;EAC7D,OAAOA,KAAK,CAACC,IAAI,KAAK,KAAK;AAC7B;AAEA,OAAO,SAASC,WAAWA,CAACF,KAAa,EAAsB;EAC7D,OAAOA,KAAK,CAACC,IAAI,KAAK,KAAK;AAC7B","ignoreList":[]}
|
package/build/esm/utils/steps/__tests__/__snapshots__/types/generateTypeScriptInterfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateTypeScriptInterfaces.js","names":["isNodeObject","value","type","isNodeTextBox"],"sources":["generateTypeScriptInterfaces.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"generateTypeScriptInterfaces.js","names":["isNodeObject","value","type","isNodeTextBox"],"sources":["generateTypeScriptInterfaces.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.9.0 */\n\n\n/**\n * Represents an edge in a graph\n */\nexport interface Edge {\n readonly source: ObjectNode;\n readonly target: ObjectNode;\n}\n\nexport interface ObjectNode {\n readonly x: number;\n readonly y: number;\n readonly label?: string;\n readonly color?: string;\n}\n\n/**\n * Represents a text box in a graph\n */\nexport interface TextBox {\n readonly x: number;\n readonly y: number;\n readonly text: string;\n}\n\nexport interface NodeObject extends ObjectNode {\n readonly type: \"object\";\n}\n\nexport interface NodeTextBox extends TextBox {\n readonly type: \"text-box\";\n}\n\nexport type Node = NodeObject | NodeTextBox;\n\nexport function isNodeObject(value: Node): value is NodeObject {\n return value.type === \"object\";\n}\n\nexport function isNodeTextBox(value: Node): value is NodeTextBox {\n return value.type === \"text-box\";\n}\n\n"],"mappings":"AAAA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;;AAiBA,OAAO,SAASA,YAAYA,CAACC,KAAW,EAAuB;EAC7D,OAAOA,KAAK,CAACC,IAAI,KAAK,QAAQ;AAChC;AAEA,OAAO,SAASC,aAAaA,CAACF,KAAW,EAAwB;EAC/D,OAAOA,KAAK,CAACC,IAAI,KAAK,UAAU;AAClC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refTypes.js","names":[],"sources":["refTypes.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"refTypes.js","names":[],"sources":["refTypes.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.9.0 */\n\nimport type { DocumentRef, MediaRef, ObjectRef, UserRef } from \"@palantir/pack.document-schema.model-types\";\n\n/**\n * A record containing all reference types\n */\nexport interface Document {\n readonly id: string;\n readonly docRef: DocumentRef;\n readonly userRef: UserRef;\n readonly objectRef: ObjectRef;\n readonly mediaRef: MediaRef;\n readonly optionalDocRef?: DocumentRef;\n readonly docRefArray: readonly DocumentRef[];\n readonly userRefArray: readonly UserRef[];\n}\n\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simpleRecord.js","names":[],"sources":["simpleRecord.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"simpleRecord.js","names":[],"sources":["simpleRecord.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.9.0 */\n\n\n/**\n * A person record\n */\nexport interface Person {\n readonly name: string;\n readonly age: number;\n readonly email?: string;\n}\n\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simpleSteps.js","names":["isNodeObject","value","type","isNodeTextBox"],"sources":["simpleSteps.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"simpleSteps.js","names":["isNodeObject","value","type","isNodeTextBox"],"sources":["simpleSteps.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.9.0 */\n\n\n/**\n * A node in the graph\n */\nexport interface ObjectNode {\n readonly x: number;\n readonly y: number;\n readonly object: string;\n readonly label?: string;\n readonly edges: readonly Edge[];\n}\n\n/**\n * A text box in the graph\n */\nexport interface TextBox {\n readonly x: number;\n readonly y: number;\n readonly text: string;\n}\n\n/**\n * An edge in the graph\n */\nexport interface Edge {\n readonly source: ObjectNode;\n readonly target: ObjectNode;\n}\n\nexport interface NodeObject extends ObjectNode {\n readonly type: \"object\";\n}\n\nexport interface NodeTextBox extends TextBox {\n readonly type: \"textBox\";\n}\n\nexport type Node = NodeObject | NodeTextBox;\n\nexport function isNodeObject(value: Node): value is NodeObject {\n return value.type === \"object\";\n}\n\nexport function isNodeTextBox(value: Node): value is NodeTextBox {\n return value.type === \"textBox\";\n}\n\n"],"mappings":"AAAA;;AAGA;AACA;AACA;;AASA;AACA;AACA;;AAOA;AACA;AACA;;AAgBA,OAAO,SAASA,YAAYA,CAACC,KAAW,EAAuB;EAC7D,OAAOA,KAAK,CAACC,IAAI,KAAK,QAAQ;AAChC;AAEA,OAAO,SAASC,aAAaA,CAACF,KAAW,EAAwB;EAC/D,OAAOA,KAAK,CAACC,IAAI,KAAK,SAAS;AACjC","ignoreList":[]}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { describe, expect, it } from "vitest";
|
|
18
18
|
import { convertStepsToIr } from "../convertStepsToIr.js";
|
|
19
|
+
import { parseMigrationSteps } from "../parseMigrationSteps.js";
|
|
19
20
|
describe("convertStepsToIr", () => {
|
|
20
21
|
it("should convert simple record types to IR format", () => {
|
|
21
22
|
const schema = convertStepsToIr([{
|
|
@@ -49,7 +50,7 @@ describe("convertStepsToIr", () => {
|
|
|
49
50
|
const nameField = personRecord.fields.find(f => f.key === "name");
|
|
50
51
|
expect(nameField).toBeDefined();
|
|
51
52
|
expect(nameField?.isOptional).toBeUndefined();
|
|
52
|
-
expect(nameField?.
|
|
53
|
+
expect(nameField?.fieldType).toEqual({
|
|
53
54
|
type: "value",
|
|
54
55
|
value: {
|
|
55
56
|
type: "string",
|
|
@@ -60,7 +61,7 @@ describe("convertStepsToIr", () => {
|
|
|
60
61
|
// Check age field
|
|
61
62
|
const ageField = personRecord.fields.find(f => f.key === "age");
|
|
62
63
|
expect(ageField).toBeDefined();
|
|
63
|
-
expect(ageField?.
|
|
64
|
+
expect(ageField?.fieldType).toEqual({
|
|
64
65
|
type: "value",
|
|
65
66
|
value: {
|
|
66
67
|
type: "double",
|
|
@@ -72,7 +73,7 @@ describe("convertStepsToIr", () => {
|
|
|
72
73
|
const emailField = personRecord.fields.find(f => f.key === "email");
|
|
73
74
|
expect(emailField).toBeDefined();
|
|
74
75
|
expect(emailField?.isOptional).toBe(true);
|
|
75
|
-
expect(emailField?.
|
|
76
|
+
expect(emailField?.fieldType).toEqual({
|
|
76
77
|
type: "value",
|
|
77
78
|
value: {
|
|
78
79
|
type: "string",
|
|
@@ -100,7 +101,7 @@ describe("convertStepsToIr", () => {
|
|
|
100
101
|
|
|
101
102
|
// Check tags array field
|
|
102
103
|
const tagsField = containerRecord.fields.find(f => f.key === "tags");
|
|
103
|
-
expect(tagsField?.
|
|
104
|
+
expect(tagsField?.fieldType).toEqual({
|
|
104
105
|
type: "array",
|
|
105
106
|
array: {
|
|
106
107
|
allowNullValue: false,
|
|
@@ -113,7 +114,7 @@ describe("convertStepsToIr", () => {
|
|
|
113
114
|
|
|
114
115
|
// Check numbers list field (treated as array)
|
|
115
116
|
const numbersField = containerRecord.fields.find(f => f.key === "numbers");
|
|
116
|
-
expect(numbersField?.
|
|
117
|
+
expect(numbersField?.fieldType).toEqual({
|
|
117
118
|
type: "array",
|
|
118
119
|
array: {
|
|
119
120
|
allowNullValue: false,
|
|
@@ -147,7 +148,7 @@ describe("convertStepsToIr", () => {
|
|
|
147
148
|
if (personModel?.type !== "record") throw new Error("Expected record type");
|
|
148
149
|
const personRecord = personModel.record;
|
|
149
150
|
const addressField = personRecord.fields.find(f => f.key === "address");
|
|
150
|
-
expect(addressField?.
|
|
151
|
+
expect(addressField?.fieldType).toEqual({
|
|
151
152
|
type: "value",
|
|
152
153
|
value: {
|
|
153
154
|
type: "modelRef",
|
|
@@ -186,7 +187,7 @@ describe("convertStepsToIr", () => {
|
|
|
186
187
|
// Check inherited fields from fragment
|
|
187
188
|
const xField = objectNode.fields.find(f => f.key === "x");
|
|
188
189
|
expect(xField).toBeDefined();
|
|
189
|
-
expect(xField?.
|
|
190
|
+
expect(xField?.fieldType).toEqual({
|
|
190
191
|
type: "value",
|
|
191
192
|
value: {
|
|
192
193
|
type: "double",
|
|
@@ -236,7 +237,7 @@ describe("convertStepsToIr", () => {
|
|
|
236
237
|
if (graphModel?.type !== "record") throw new Error("Expected record type");
|
|
237
238
|
const graphRecord = graphModel.record;
|
|
238
239
|
const nodesField = graphRecord.fields.find(f => f.key === "nodes");
|
|
239
|
-
expect(nodesField?.
|
|
240
|
+
expect(nodesField?.fieldType).toEqual({
|
|
240
241
|
type: "array",
|
|
241
242
|
array: {
|
|
242
243
|
allowNullValue: false,
|
|
@@ -249,6 +250,59 @@ describe("convertStepsToIr", () => {
|
|
|
249
250
|
}
|
|
250
251
|
});
|
|
251
252
|
});
|
|
253
|
+
it("should convert optional array types to IR format", () => {
|
|
254
|
+
const schema = convertStepsToIr([{
|
|
255
|
+
"add-records": {
|
|
256
|
+
Tag: {
|
|
257
|
+
fields: {
|
|
258
|
+
name: "string"
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
Container: {
|
|
262
|
+
docs: "A container with optional collections",
|
|
263
|
+
fields: {
|
|
264
|
+
tags: "optional<array<Tag>>",
|
|
265
|
+
labels: "optional<array<string>>"
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}]);
|
|
270
|
+
const containerModel = schema.models["Container"];
|
|
271
|
+
expect(containerModel).toBeDefined();
|
|
272
|
+
expect(containerModel?.type).toBe("record");
|
|
273
|
+
if (containerModel?.type !== "record") throw new Error("Expected record type");
|
|
274
|
+
const containerRecord = containerModel.record;
|
|
275
|
+
|
|
276
|
+
// Check optional array of references
|
|
277
|
+
const tagsField = containerRecord.fields.find(f => f.key === "tags");
|
|
278
|
+
expect(tagsField?.isOptional).toBe(true);
|
|
279
|
+
expect(tagsField?.fieldType).toEqual({
|
|
280
|
+
type: "array",
|
|
281
|
+
array: {
|
|
282
|
+
allowNullValue: false,
|
|
283
|
+
value: {
|
|
284
|
+
type: "modelRef",
|
|
285
|
+
modelRef: {
|
|
286
|
+
modelTypes: ["Tag"]
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
// Check optional array of primitives
|
|
293
|
+
const labelsField = containerRecord.fields.find(f => f.key === "labels");
|
|
294
|
+
expect(labelsField?.isOptional).toBe(true);
|
|
295
|
+
expect(labelsField?.fieldType).toEqual({
|
|
296
|
+
type: "array",
|
|
297
|
+
array: {
|
|
298
|
+
allowNullValue: false,
|
|
299
|
+
value: {
|
|
300
|
+
type: "string",
|
|
301
|
+
string: {}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
});
|
|
252
306
|
it("should handle modify-records step", () => {
|
|
253
307
|
const schema = convertStepsToIr([{
|
|
254
308
|
"add-records": {
|
|
@@ -285,4 +339,23 @@ describe("convertStepsToIr", () => {
|
|
|
285
339
|
expect(emailField?.isOptional).toBe(true);
|
|
286
340
|
});
|
|
287
341
|
});
|
|
342
|
+
describe("parseMigrationSteps generic type validation", () => {
|
|
343
|
+
function stepsWithField(fieldType) {
|
|
344
|
+
return [{
|
|
345
|
+
"add-records": {
|
|
346
|
+
Foo: {
|
|
347
|
+
fields: {
|
|
348
|
+
bar: fieldType
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}];
|
|
353
|
+
}
|
|
354
|
+
it.each(["optional<optional<string>>", "array<array<string>>", "list<list<double>>", "array<optional<string>>", "optional<array<array<string>>>", "optional<foo<string>>", "foo<string>"])("should reject invalid nested generic type: %s", fieldType => {
|
|
355
|
+
expect(() => parseMigrationSteps(stepsWithField(fieldType))).toThrow();
|
|
356
|
+
});
|
|
357
|
+
it.each(["optional<string>", "optional<double>", "optional<MyType>", "array<string>", "list<double>", "set<MyType>", "map<string>", "optional<array<string>>", "optional<list<Tag>>", "optional<set<double>>", "optional<map<string>>"])("should accept valid generic type: %s", fieldType => {
|
|
358
|
+
expect(() => parseMigrationSteps(stepsWithField(fieldType))).not.toThrow();
|
|
359
|
+
});
|
|
360
|
+
});
|
|
288
361
|
//# sourceMappingURL=convertStepsToIr.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertStepsToIr.test.js","names":["describe","expect","it","convertStepsToIr","schema","Person","docs","fields","name","age","email","toBe","description","version","primaryModelKeys","toEqual","Object","keys","models","toHaveLength","personModel","toBeDefined","type","Error","personRecord","record","key","nameField","find","f","isOptional","toBeUndefined","value","string","ageField","double","emailField","Container","tags","numbers","containerModel","containerRecord","tagsField","array","allowNullValue","numbersField","Address","street","city","address","addressField","modelRef","modelTypes","position","x","y","ObjectNode","extends","label","objectNodeModel","objectNode","xField","yField","labelField","TextBox","text","Node","variants","object","textBox","Graph","nodes","graphModel","graphRecord","nodesField"],"sources":["convertStepsToIr.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { describe, expect, it } from \"vitest\";\nimport type { IFieldTypeUnion } from \"../../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { convertStepsToIr } from \"../convertStepsToIr.js\";\nimport type { MigrationStep } from \"../parseMigrationSteps.js\";\n\ndescribe(\"convertStepsToIr\", () => {\n it(\"should convert simple record types to IR format\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n Person: {\n docs: \"A person record\",\n fields: {\n name: \"string\",\n age: \"double\",\n email: \"optional<string>\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n\n expect(schema.name).toBe(\"Generated Schema\");\n expect(schema.description).toBe(\"Schema generated from migration steps\");\n expect(schema.version).toBe(1);\n expect(schema.primaryModelKeys).toEqual([\"Person\"]);\n expect(Object.keys(schema.models)).toHaveLength(1);\n\n const personModel = schema.models[\"Person\"];\n expect(personModel).toBeDefined();\n expect(personModel?.type).toBe(\"record\");\n if (personModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const personRecord = personModel.record;\n\n expect(personRecord.key).toBe(\"Person\");\n expect(personRecord.name).toBe(\"Person\");\n expect(personRecord.description).toBe(\"A person record\");\n expect(personRecord.fields).toHaveLength(3);\n\n // Check name field\n const nameField = personRecord.fields.find(f => f.key === \"name\");\n expect(nameField).toBeDefined();\n expect(nameField?.isOptional).toBeUndefined();\n expect(nameField?.value).toEqual({\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n });\n\n // Check age field\n const ageField = personRecord.fields.find(f => f.key === \"age\");\n expect(ageField).toBeDefined();\n expect(ageField?.value).toEqual({\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n });\n\n // Check optional email field\n const emailField = personRecord.fields.find(f => f.key === \"email\");\n expect(emailField).toBeDefined();\n expect(emailField?.isOptional).toBe(true);\n expect(emailField?.value).toEqual({\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n });\n });\n\n it(\"should convert array and list types to IR format\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n Container: {\n docs: \"A container with collections\",\n fields: {\n tags: \"array<string>\",\n numbers: \"list<double>\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const containerModel = schema.models[\"Container\"];\n expect(containerModel).toBeDefined();\n expect(containerModel?.type).toBe(\"record\");\n if (containerModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const containerRecord = containerModel.record;\n\n // Check tags array field\n const tagsField = containerRecord.fields.find(f => f.key === \"tags\");\n expect(tagsField?.value).toEqual({\n type: \"array\",\n array: {\n allowNullValue: false,\n value: {\n type: \"string\",\n string: {},\n },\n },\n });\n\n // Check numbers list field (treated as array)\n const numbersField = containerRecord.fields.find(f => f.key === \"numbers\");\n expect(numbersField?.value).toEqual({\n type: \"array\",\n array: {\n allowNullValue: false,\n value: {\n type: \"double\",\n double: {},\n },\n },\n });\n });\n\n it(\"should convert record references to IR format\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n Address: {\n fields: {\n street: \"string\",\n city: \"string\",\n },\n },\n Person: {\n fields: {\n name: \"string\",\n address: \"Address\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const personModel = schema.models[\"Person\"];\n expect(personModel).toBeDefined();\n expect(personModel?.type).toBe(\"record\");\n if (personModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const personRecord = personModel.record;\n\n const addressField = personRecord.fields.find(f => f.key === \"address\");\n expect(addressField?.value).toEqual(\n {\n type: \"value\",\n value: {\n type: \"modelRef\",\n modelRef: {\n modelTypes: [\"Address\"],\n },\n },\n } satisfies IFieldTypeUnion,\n );\n });\n\n it(\"should handle local fragments and extends\", () => {\n const steps: MigrationStep[] = [\n {\n \"local-fragment\": {\n position: {\n x: \"double\",\n y: \"double\",\n },\n },\n },\n {\n \"add-records\": {\n ObjectNode: {\n docs: \"A node with position\",\n extends: [\"position\"],\n fields: {\n label: \"string\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const objectNodeModel = schema.models[\"ObjectNode\"];\n expect(objectNodeModel).toBeDefined();\n expect(objectNodeModel?.type).toBe(\"record\");\n if (objectNodeModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const objectNode = objectNodeModel.record;\n\n expect(objectNode.fields).toHaveLength(3);\n\n // Check inherited fields from fragment\n const xField = objectNode.fields.find(f => f.key === \"x\");\n expect(xField).toBeDefined();\n expect(xField?.value).toEqual({\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n });\n\n const yField = objectNode.fields.find(f => f.key === \"y\");\n expect(yField).toBeDefined();\n\n // Check own field\n const labelField = objectNode.fields.find(f => f.key === \"label\");\n expect(labelField).toBeDefined();\n });\n\n it(\"should convert unions to IR format\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n ObjectNode: {\n fields: {\n label: \"string\",\n },\n },\n TextBox: {\n fields: {\n text: \"string\",\n },\n },\n },\n },\n {\n \"add-union\": {\n Node: {\n variants: {\n object: \"ObjectNode\",\n textBox: \"TextBox\",\n },\n },\n },\n },\n {\n \"add-records\": {\n Graph: {\n fields: {\n nodes: \"array<Node>\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const graphModel = schema.models[\"Graph\"];\n if (graphModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const graphRecord = graphModel.record;\n\n const nodesField = graphRecord.fields.find(f => f.key === \"nodes\");\n expect(nodesField?.value).toEqual({\n type: \"array\",\n array: {\n allowNullValue: false,\n value: {\n type: \"modelRef\",\n modelRef: {\n modelTypes: [\"Node\"],\n },\n },\n },\n });\n });\n\n it(\"should handle modify-records step\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n Person: {\n fields: {\n name: \"string\",\n },\n },\n },\n },\n {\n \"modify-records\": {\n Person: {\n \"add-fields\": {\n age: \"double\",\n email: \"optional<string>\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const personModel = schema.models[\"Person\"];\n expect(personModel).toBeDefined();\n expect(personModel?.type).toBe(\"record\");\n if (personModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const personRecord = personModel.record;\n\n expect(personRecord.fields).toHaveLength(3);\n\n // Original field\n expect(personRecord.fields.find(f => f.key === \"name\")).toBeDefined();\n\n // Added fields\n expect(personRecord.fields.find(f => f.key === \"age\")).toBeDefined();\n\n const emailField = personRecord.fields.find(f => f.key === \"email\");\n expect(emailField).toBeDefined();\n expect(emailField?.isOptional).toBe(true);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAE7C,SAASC,gBAAgB,QAAQ,wBAAwB;AAGzDH,QAAQ,CAAC,kBAAkB,EAAE,MAAM;EACjCE,EAAE,CAAC,iDAAiD,EAAE,MAAM;IAgB1D,MAAME,MAAM,GAAGD,gBAAgB,CAfA,CAC7B;MACE,aAAa,EAAE;QACbE,MAAM,EAAE;UACNC,IAAI,EAAE,iBAAiB;UACvBC,MAAM,EAAE;YACNC,IAAI,EAAE,QAAQ;YACdC,GAAG,EAAE,QAAQ;YACbC,KAAK,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,UAAU,CAAC,CAACnB,IAAI,CAAC,IAAI,CAAC;EAC3C,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"convertStepsToIr.test.js","names":["describe","expect","it","convertStepsToIr","parseMigrationSteps","schema","Person","docs","fields","name","age","email","toBe","description","version","primaryModelKeys","toEqual","Object","keys","models","toHaveLength","personModel","toBeDefined","type","Error","personRecord","record","key","nameField","find","f","isOptional","toBeUndefined","fieldType","value","string","ageField","double","emailField","Container","tags","numbers","containerModel","containerRecord","tagsField","array","allowNullValue","numbersField","Address","street","city","address","addressField","modelRef","modelTypes","position","x","y","ObjectNode","extends","label","objectNodeModel","objectNode","xField","yField","labelField","TextBox","text","Node","variants","object","textBox","Graph","nodes","graphModel","graphRecord","nodesField","Tag","labels","labelsField","stepsWithField","Foo","bar","each","toThrow","not"],"sources":["convertStepsToIr.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { describe, expect, it } from \"vitest\";\nimport type { IFieldTypeUnion } from \"../../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { convertStepsToIr } from \"../convertStepsToIr.js\";\nimport type { MigrationStep } from \"../parseMigrationSteps.js\";\nimport { parseMigrationSteps } from \"../parseMigrationSteps.js\";\n\ndescribe(\"convertStepsToIr\", () => {\n it(\"should convert simple record types to IR format\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n Person: {\n docs: \"A person record\",\n fields: {\n name: \"string\",\n age: \"double\",\n email: \"optional<string>\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n\n expect(schema.name).toBe(\"Generated Schema\");\n expect(schema.description).toBe(\"Schema generated from migration steps\");\n expect(schema.version).toBe(1);\n expect(schema.primaryModelKeys).toEqual([\"Person\"]);\n expect(Object.keys(schema.models)).toHaveLength(1);\n\n const personModel = schema.models[\"Person\"];\n expect(personModel).toBeDefined();\n expect(personModel?.type).toBe(\"record\");\n if (personModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const personRecord = personModel.record;\n\n expect(personRecord.key).toBe(\"Person\");\n expect(personRecord.name).toBe(\"Person\");\n expect(personRecord.description).toBe(\"A person record\");\n expect(personRecord.fields).toHaveLength(3);\n\n // Check name field\n const nameField = personRecord.fields.find(f => f.key === \"name\");\n expect(nameField).toBeDefined();\n expect(nameField?.isOptional).toBeUndefined();\n expect(nameField?.fieldType).toEqual({\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n });\n\n // Check age field\n const ageField = personRecord.fields.find(f => f.key === \"age\");\n expect(ageField).toBeDefined();\n expect(ageField?.fieldType).toEqual({\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n });\n\n // Check optional email field\n const emailField = personRecord.fields.find(f => f.key === \"email\");\n expect(emailField).toBeDefined();\n expect(emailField?.isOptional).toBe(true);\n expect(emailField?.fieldType).toEqual({\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n });\n });\n\n it(\"should convert array and list types to IR format\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n Container: {\n docs: \"A container with collections\",\n fields: {\n tags: \"array<string>\",\n numbers: \"list<double>\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const containerModel = schema.models[\"Container\"];\n expect(containerModel).toBeDefined();\n expect(containerModel?.type).toBe(\"record\");\n if (containerModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const containerRecord = containerModel.record;\n\n // Check tags array field\n const tagsField = containerRecord.fields.find(f => f.key === \"tags\");\n expect(tagsField?.fieldType).toEqual({\n type: \"array\",\n array: {\n allowNullValue: false,\n value: {\n type: \"string\",\n string: {},\n },\n },\n });\n\n // Check numbers list field (treated as array)\n const numbersField = containerRecord.fields.find(f => f.key === \"numbers\");\n expect(numbersField?.fieldType).toEqual({\n type: \"array\",\n array: {\n allowNullValue: false,\n value: {\n type: \"double\",\n double: {},\n },\n },\n });\n });\n\n it(\"should convert record references to IR format\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n Address: {\n fields: {\n street: \"string\",\n city: \"string\",\n },\n },\n Person: {\n fields: {\n name: \"string\",\n address: \"Address\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const personModel = schema.models[\"Person\"];\n expect(personModel).toBeDefined();\n expect(personModel?.type).toBe(\"record\");\n if (personModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const personRecord = personModel.record;\n\n const addressField = personRecord.fields.find(f => f.key === \"address\");\n expect(addressField?.fieldType).toEqual(\n {\n type: \"value\",\n value: {\n type: \"modelRef\",\n modelRef: {\n modelTypes: [\"Address\"],\n },\n },\n } satisfies IFieldTypeUnion,\n );\n });\n\n it(\"should handle local fragments and extends\", () => {\n const steps: MigrationStep[] = [\n {\n \"local-fragment\": {\n position: {\n x: \"double\",\n y: \"double\",\n },\n },\n },\n {\n \"add-records\": {\n ObjectNode: {\n docs: \"A node with position\",\n extends: [\"position\"],\n fields: {\n label: \"string\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const objectNodeModel = schema.models[\"ObjectNode\"];\n expect(objectNodeModel).toBeDefined();\n expect(objectNodeModel?.type).toBe(\"record\");\n if (objectNodeModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const objectNode = objectNodeModel.record;\n\n expect(objectNode.fields).toHaveLength(3);\n\n // Check inherited fields from fragment\n const xField = objectNode.fields.find(f => f.key === \"x\");\n expect(xField).toBeDefined();\n expect(xField?.fieldType).toEqual({\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n });\n\n const yField = objectNode.fields.find(f => f.key === \"y\");\n expect(yField).toBeDefined();\n\n // Check own field\n const labelField = objectNode.fields.find(f => f.key === \"label\");\n expect(labelField).toBeDefined();\n });\n\n it(\"should convert unions to IR format\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n ObjectNode: {\n fields: {\n label: \"string\",\n },\n },\n TextBox: {\n fields: {\n text: \"string\",\n },\n },\n },\n },\n {\n \"add-union\": {\n Node: {\n variants: {\n object: \"ObjectNode\",\n textBox: \"TextBox\",\n },\n },\n },\n },\n {\n \"add-records\": {\n Graph: {\n fields: {\n nodes: \"array<Node>\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const graphModel = schema.models[\"Graph\"];\n if (graphModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const graphRecord = graphModel.record;\n\n const nodesField = graphRecord.fields.find(f => f.key === \"nodes\");\n expect(nodesField?.fieldType).toEqual({\n type: \"array\",\n array: {\n allowNullValue: false,\n value: {\n type: \"modelRef\",\n modelRef: {\n modelTypes: [\"Node\"],\n },\n },\n },\n });\n });\n\n it(\"should convert optional array types to IR format\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n Tag: {\n fields: {\n name: \"string\",\n },\n },\n Container: {\n docs: \"A container with optional collections\",\n fields: {\n tags: \"optional<array<Tag>>\",\n labels: \"optional<array<string>>\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const containerModel = schema.models[\"Container\"];\n expect(containerModel).toBeDefined();\n expect(containerModel?.type).toBe(\"record\");\n if (containerModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const containerRecord = containerModel.record;\n\n // Check optional array of references\n const tagsField = containerRecord.fields.find(f => f.key === \"tags\");\n expect(tagsField?.isOptional).toBe(true);\n expect(tagsField?.fieldType).toEqual({\n type: \"array\",\n array: {\n allowNullValue: false,\n value: {\n type: \"modelRef\",\n modelRef: {\n modelTypes: [\"Tag\"],\n },\n },\n },\n });\n\n // Check optional array of primitives\n const labelsField = containerRecord.fields.find(f => f.key === \"labels\");\n expect(labelsField?.isOptional).toBe(true);\n expect(labelsField?.fieldType).toEqual({\n type: \"array\",\n array: {\n allowNullValue: false,\n value: {\n type: \"string\",\n string: {},\n },\n },\n });\n });\n\n it(\"should handle modify-records step\", () => {\n const steps: MigrationStep[] = [\n {\n \"add-records\": {\n Person: {\n fields: {\n name: \"string\",\n },\n },\n },\n },\n {\n \"modify-records\": {\n Person: {\n \"add-fields\": {\n age: \"double\",\n email: \"optional<string>\",\n },\n },\n },\n },\n ];\n\n const schema = convertStepsToIr(steps);\n const personModel = schema.models[\"Person\"];\n expect(personModel).toBeDefined();\n expect(personModel?.type).toBe(\"record\");\n if (personModel?.type !== \"record\") throw new Error(\"Expected record type\");\n const personRecord = personModel.record;\n\n expect(personRecord.fields).toHaveLength(3);\n\n // Original field\n expect(personRecord.fields.find(f => f.key === \"name\")).toBeDefined();\n\n // Added fields\n expect(personRecord.fields.find(f => f.key === \"age\")).toBeDefined();\n\n const emailField = personRecord.fields.find(f => f.key === \"email\");\n expect(emailField).toBeDefined();\n expect(emailField?.isOptional).toBe(true);\n });\n});\n\ndescribe(\"parseMigrationSteps generic type validation\", () => {\n function stepsWithField(fieldType: string): unknown {\n return [{ \"add-records\": { Foo: { fields: { bar: fieldType } } } }];\n }\n\n it.each([\n \"optional<optional<string>>\",\n \"array<array<string>>\",\n \"list<list<double>>\",\n \"array<optional<string>>\",\n \"optional<array<array<string>>>\",\n \"optional<foo<string>>\",\n \"foo<string>\",\n ])(\"should reject invalid nested generic type: %s\", fieldType => {\n expect(() => parseMigrationSteps(stepsWithField(fieldType))).toThrow();\n });\n\n it.each([\n \"optional<string>\",\n \"optional<double>\",\n \"optional<MyType>\",\n \"array<string>\",\n \"list<double>\",\n \"set<MyType>\",\n \"map<string>\",\n \"optional<array<string>>\",\n \"optional<list<Tag>>\",\n \"optional<set<double>>\",\n \"optional<map<string>>\",\n ])(\"should accept valid generic type: %s\", fieldType => {\n expect(() => parseMigrationSteps(stepsWithField(fieldType))).not.toThrow();\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAE7C,SAASC,gBAAgB,QAAQ,wBAAwB;AAEzD,SAASC,mBAAmB,QAAQ,2BAA2B;AAE/DJ,QAAQ,CAAC,kBAAkB,EAAE,MAAM;EACjCE,EAAE,CAAC,iDAAiD,EAAE,MAAM;IAgB1D,MAAMG,MAAM,GAAGF,gBAAgB,CAfA,CAC7B;MACE,aAAa,EAAE;QACbG,MAAM,EAAE;UACNC,IAAI,EAAE,iBAAiB;UACvBC,MAAM,EAAE;YACNC,IAAI,EAAE,QAAQ;YACdC,GAAG,EAAE,QAAQ;YACbC,KAAK,EAAE;UACT;QACF;MACF;IACF,CAAC,CAGkC,CAAC;IAEtCV,MAAM,CAACI,MAAM,CAACI,IAAI,CAAC,CAACG,IAAI,CAAC,kBAAkB,CAAC;IAC5CX,MAAM,CAACI,MAAM,CAACQ,WAAW,CAAC,CAACD,IAAI,CAAC,uCAAuC,CAAC;IACxEX,MAAM,CAACI,MAAM,CAACS,OAAO,CAAC,CAACF,IAAI,CAAC,CAAC,CAAC;IAC9BX,MAAM,CAACI,MAAM,CAACU,gBAAgB,CAAC,CAACC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC;IACnDf,MAAM,CAACgB,MAAM,CAACC,IAAI,CAACb,MAAM,CAACc,MAAM,CAAC,CAAC,CAACC,YAAY,CAAC,CAAC,CAAC;IAElD,MAAMC,WAAW,GAAGhB,MAAM,CAACc,MAAM,CAAC,QAAQ,CAAC;IAC3ClB,MAAM,CAACoB,WAAW,CAAC,CAACC,WAAW,CAAC,CAAC;IACjCrB,MAAM,CAACoB,WAAW,EAAEE,IAAI,CAAC,CAACX,IAAI,CAAC,QAAQ,CAAC;I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AAE,CAAC,CAAC;EACrE;EAEA/B,EAAE,CAACiF,IAAI,CAAC,CACN,4BAA4B,EAC5B,sBAAsB,EACtB,oBAAoB,EACpB,yBAAyB,EACzB,gCAAgC,EAChC,uBAAuB,EACvB,aAAa,CACd,CAAC,CAAC,+CAA+C,EAAElD,SAAS,IAAI;IAC/DhC,MAAM,CAAC,MAAMG,mBAAmB,CAAC4E,cAAc,CAAC/C,SAAS,CAAC,CAAC,CAAC,CAACmD,OAAO,CAAC,CAAC;EACxE,CAAC,CAAC;EAEFlF,EAAE,CAACiF,IAAI,CAAC,CACN,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,aAAa,EACb,aAAa,EACb,yBAAyB,EACzB,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,CACxB,CAAC,CAAC,sCAAsC,EAAElD,SAAS,IAAI;IACtDhC,MAAM,CAAC,MAAMG,mBAAmB,CAAC4E,cAAc,CAAC/C,SAAS,CAAC,CAAC,CAAC,CAACoD,GAAG,CAACD,OAAO,CAAC,CAAC;EAC5E,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -75,20 +75,17 @@ export function convertRecordDefToIr(recordDef) {
|
|
|
75
75
|
key: fieldKey,
|
|
76
76
|
name: fieldKey,
|
|
77
77
|
description: undefined,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
fieldType: convertTypeToFieldTypeUnion(fieldType),
|
|
79
|
+
metadata: {
|
|
80
|
+
addedInVersion: 1
|
|
81
81
|
},
|
|
82
82
|
isOptional: fieldType.type === "optional" ? true : undefined
|
|
83
83
|
}));
|
|
84
84
|
return {
|
|
85
85
|
key: recordDef.name,
|
|
86
86
|
name: recordDef.name,
|
|
87
|
-
description: recordDef.docs
|
|
88
|
-
fields
|
|
89
|
-
meta: {
|
|
90
|
-
addedIn: 1
|
|
91
|
-
}
|
|
87
|
+
description: recordDef.docs ?? undefined,
|
|
88
|
+
fields
|
|
92
89
|
};
|
|
93
90
|
}
|
|
94
91
|
export function convertUnionDefToIr(unionDef) {
|
|
@@ -99,8 +96,8 @@ export function convertUnionDefToIr(unionDef) {
|
|
|
99
96
|
description: unionDef.docs,
|
|
100
97
|
discriminant: unionDef.discriminant,
|
|
101
98
|
variants: Object.fromEntries(variantEntries),
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
metadata: {
|
|
100
|
+
addedInVersion: 1
|
|
104
101
|
}
|
|
105
102
|
};
|
|
106
103
|
}
|
|
@@ -151,9 +148,7 @@ function convertTypeToFieldValueUnion(schemaType) {
|
|
|
151
148
|
case "double":
|
|
152
149
|
return IFieldValueUnion.double({});
|
|
153
150
|
case "mediaRef":
|
|
154
|
-
return IFieldValueUnion.mediaRef({
|
|
155
|
-
mediaTypeRids: [] // FIXME: confirm whether we will use rids in the deployed schema.
|
|
156
|
-
});
|
|
151
|
+
return IFieldValueUnion.mediaRef({});
|
|
157
152
|
case "objectRef":
|
|
158
153
|
return IFieldValueUnion.object({
|
|
159
154
|
// FIXME: confirm whether we will use rids in the deployed schema.
|