feat(csv-loader): preserve original schema strings in type generation
Store the original schema string during CSV parsing to prevent unnecessary expansion of type name references in the generated TypeScript definitions. This ensures that declared types reference each other by name rather than inlining their full definitions.
This commit is contained in:
@@ -160,7 +160,11 @@ export function parseCsv(
|
||||
}
|
||||
|
||||
// Parse type declarations with expansion of type name references
|
||||
const typeDeclarationsParsed: { name: string; schema: Schema }[] = [];
|
||||
const typeDeclarationsParsed: {
|
||||
name: string;
|
||||
schema: Schema;
|
||||
schemaString: string;
|
||||
}[] = [];
|
||||
for (const decl of typeDeclarationsRaw) {
|
||||
// Expand any type name references before parsing
|
||||
const expandedSchema = expandSchemaString(
|
||||
@@ -168,7 +172,11 @@ export function parseCsv(
|
||||
declaredSchemaStrings,
|
||||
);
|
||||
const schema = parseSchema(expandedSchema.trim());
|
||||
typeDeclarationsParsed.push({ name: decl.typeName, schema });
|
||||
typeDeclarationsParsed.push({
|
||||
name: decl.typeName,
|
||||
schema,
|
||||
schemaString: decl.schemaString,
|
||||
});
|
||||
}
|
||||
|
||||
// Build declared types map
|
||||
@@ -181,7 +189,11 @@ export function parseCsv(
|
||||
const typeDeclarations: TypeDeclaration[] = [];
|
||||
for (const decl of typeDeclarationsParsed) {
|
||||
const resolvedSchema = resolveTypeReferences(decl.schema, declaredTypes);
|
||||
typeDeclarations.push({ name: decl.name, schema: resolvedSchema });
|
||||
typeDeclarations.push({
|
||||
name: decl.name,
|
||||
schema: resolvedSchema,
|
||||
schemaString: decl.schemaString,
|
||||
});
|
||||
}
|
||||
|
||||
// Update declaredTypes with resolved schemas for column schema lookup
|
||||
|
||||
Reference in New Issue
Block a user