Allow custom type names to be expanded before parsing the schema
string. This enables using declared types within complex structures
like tuples or arrays. The original schema string is preserved for
type generation to ensure the output uses the named type rather than
the expanded inline definition.
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.
Introduce the ability to define reusable types within CSV files using
comment lines with the format `# TypeName := schema`.
- Support parsing type declarations from comments or schema cells
- Enable recursive expansion of type names within schemas
- Integrate declared types into generated TypeScript definitions
- Allow columns to reference declared types by name
generation
Extract reference resolution logic, type generation, and module
generation into dedicated modules to improve maintainability and
clean up the core loader.
Update `csvToModule` to check if a foreign key value is an object
containing the default primary key before converting it to a string.
This ensures correct key mapping when references are resolved as
objects rather than primitive IDs.
Pre-filter comment lines from the content before passing it to
`csv-parse`. This prevents quote parsing errors when comment lines
contain double quotes and simplifies the record filtering logic.
Support reverse references via ~tablename(foreignKey) syntax,
complementing forward @tablename references. Includes parser,
validator, and CSV loader integration with the new
ReverseReferenceSchema type.
- Add NamedSchema interface with optional name property
- Update TupleSchema.elements to use NamedSchema[]
- Add parseNamedSchema() to support [x: number; y: number] syntax
- Update validator to parse named members in tuple values
- Fix schemaToTypeString in csv-loader for NamedSchema
- Fix createValidator to handle NamedSchema.schema
- Ensure single named element stays as tuple (not array)
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Add writeToDisk option to write .d.ts files directly to disk
- Useful for rsbuild/rspack dev server which uses in-memory FS
- Set writeToDisk: true in dev mode to see generated types
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Fix leading slash in relative path
- Use .d.ts extension instead of .csv.d.ts
- Support typesOutputDir option properly
- Use ./ prefix for module declaration path
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>