Commit Graph

38 Commits

Author SHA1 Message Date
hypercross e0317946d5 feat(csv-loader): expand custom type references in schemas
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.
2026-04-22 17:58:36 +08:00
hypercross 46504a53dd 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.
2026-04-22 17:08:06 +08:00
hypercross 55a33b98e5 refactor: modularize validator and type declaration logic 2026-04-21 13:55:47 +08:00
hypercross 53ccac39e6 feat(csv-loader): add support for custom type declarations
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
2026-04-21 13:47:16 +08:00
hypercross f94e9b68e4 refactor(csv-loader): decouple reference resolution and module
generation

Extract reference resolution logic, type generation, and module
generation into dedicated modules to improve maintainability and
clean up the core loader.
2026-04-20 00:48:01 +08:00
hypercross c3572a5b56 fix(csv-loader): handle object foreign keys in reverse lookups
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.
2026-04-19 23:58:09 +08:00
hyper 5f941aba10 feat(csv-loader): support references in addition to strings for foreignKey reverse ref 2026-04-19 18:58:52 +08:00
hypercross 9a2db5edb6 feat(csv-loader): strip comments before parsing CSV
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.
2026-04-19 14:40:41 +08:00
hypercross 5a1627c6f1 test: improve reverse reference resolution handling 2026-04-19 14:19:45 +08:00
hypercross 9dd4f60c2d feat(csv-loader): allow configurable comment character
Allow `parseCsv` to accept a custom comment character for parsing
reverse reference declarations, instead of being hardcoded to `#`.
2026-04-19 14:06:11 +08:00
hypercross e76ae79b2d Add reverse reference schema (~tablename(foreignKey))
Support reverse references via ~tablename(foreignKey) syntax,
complementing forward @tablename references. Includes parser,
validator, and CSV loader integration with the new
ReverseReferenceSchema type.
2026-04-18 22:47:58 +08:00
hypercross 0954dcf594 fix: avoid exporting loader in index 2026-04-17 17:27:19 +08:00
hypercross 740bb503b1 fix: fix type generator for tuples 2026-04-17 15:11:46 +08:00
hypercross c8f0d6b0de refactor: avoid readonly in nested types 2026-04-17 14:53:49 +08:00
hypercross 075045223f feat: add @type? optional notation 2026-04-17 11:41:06 +08:00
hypercross 1f3a812728 fix: all tables generate accessors 2026-04-15 14:52:41 +08:00
hypercross 852a108c53 fix: update type generation 2026-04-15 14:46:03 +08:00
hypercross 6eba70bb3b refactor: accessor based imports 2026-04-15 14:36:52 +08:00
hypercross 8343df2316 fix: bug fixes and new tests 2026-04-15 13:58:14 +08:00
hypercross d5fdb69ad7 fix: fix nested references? 2026-04-15 13:24:51 +08:00
hypercross 51a11a26bf chore: add tests 2026-04-13 10:18:12 +08:00
hypercross d78ef75272 fix: typing and remove singularization 2026-04-11 23:05:22 +08:00
hypercross daac7badbb feat: parse references 2026-04-11 22:56:01 +08:00
hypercross 3051df3e8b fix: skip empty lines 2026-04-07 12:11:01 +08:00
hypercross ad38976e86 refactor: reorg/remove webpack dependency 2026-04-07 11:25:02 +08:00
hypercross 4eb6a17e9f refactor: table name deduction & readonly type 2026-04-05 12:43:23 +08:00
hypercross f656a62606 fix: add int/float to type gen 2026-04-04 17:08:29 +08:00
hypercross b7e65ebc1d feat: export extra functions from the loader 2026-04-02 17:32:13 +08:00
hyper cf55295ce7 feat: include member names in generated tuple type definitions
- Update schemaToTypeString to include names for named tuple elements
- Generates [current: number, max: number] instead of [number, number]
- Uses TypeScript 4.0+ tuple parameter labels syntax

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-31 16:57:52 +08:00
hyper 23ee60bc20 feat: support named members in tuples
- 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>
2026-03-31 16:36:32 +08:00
hyper d056145462 fix: change format of output .d.ts files 2026-03-31 16:12:17 +08:00
hyper 525ae262fd feat: add writeToDisk option for dev server support
- 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>
2026-03-31 15:54:38 +08:00
hyper 377a47e49f fix: improve path handling for .d.ts file emission
- 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>
2026-03-31 15:49:05 +08:00
hyper 452b600487 fix: use declare module syntax for type definitions
- Change from standalone .d.ts to module augmentation style
- Now properly declares types for the CSV module path
- Fixes TypeScript module resolution

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-31 15:25:58 +08:00
hyper 69b419256c feat: add TypeScript type definition generation for csv-loader
- Add emitTypes option (default true) to generate .d.ts files
- Add typesOutputDir option for custom output directory
- Generate interface based on CSV schema definitions
- Export RowType for explicit type imports

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-31 15:19:03 +08:00
hyper 9a8cdcaaea refactor: default csv-parse params 2026-03-31 14:45:02 +08:00
hyper 3a6f57ef6f fix: typing 2026-03-31 14:25:38 +08:00
hypercross fe2e323d19 feat: csv-loader? 2026-03-31 13:02:29 +08:00