refactor: rename package from inline-schema to typed-csv

This commit is contained in:
2026-06-13 10:22:18 +08:00
parent 89be2783d1
commit ea98399c24
6 changed files with 21 additions and 21 deletions
+2 -2
View File
@@ -13,12 +13,12 @@ No linter or formatter is configured. No CI pipeline exists.
Single-package TypeScript library with two runtime entry points: Single-package TypeScript library with two runtime entry points:
- **`inline-schema`** (`src/index.ts`) — core schema parser, value parser, and validator - **`typed-csv`** (`src/index.ts`) — core schema parser, value parser, and validator
- `src/parser.ts``parseSchema()` turns schema strings into AST (`Schema` type) - `src/parser.ts``parseSchema()` turns schema strings into AST (`Schema` type)
- `src/validator.ts``parseValue()` and `createValidator()` operate on the AST - `src/validator.ts``parseValue()` and `createValidator()` operate on the AST
- `src/types.ts` — union type `Schema = Primitive | Tuple | Array | Reference | StringLiteral | Union` - `src/types.ts` — union type `Schema = Primitive | Tuple | Array | Reference | StringLiteral | Union`
- **`inline-schema/csv-loader`** (`src/csv-loader/loader.ts`) — CSV loader with `@table` reference resolution - **`typed-csv/csv-loader`** (`src/csv-loader/loader.ts`) — CSV loader with `@table` reference resolution
- `loader.ts``parseCsv()` (eager resolution) and `csvToModule()` (accessor-based output with lazy resolution); `resolveReferences: false` mode stores IDs instead of resolved objects - `loader.ts``parseCsv()` (eager resolution) and `csvToModule()` (accessor-based output with lazy resolution); `resolveReferences: false` mode stores IDs instead of resolved objects
- `webpack.ts`, `rollup.ts`, `esbuild.ts` — bundler plugin wrappers around `csvToModule` - `webpack.ts`, `rollup.ts`, `esbuild.ts` — bundler plugin wrappers around `csvToModule`
+5 -5
View File
@@ -1,11 +1,11 @@
# inline-schema # typed-csv
A TypeScript library for parsing and validating inline schemas with a TypeScript-like syntax using `;` instead of `,`. A TypeScript library for typed CSV data with inline schema validation using a TypeScript-like syntax with `;` instead of `,`.
## Installation ## Installation
```bash ```bash
npm install inline-schema npm install typed-csv
``` ```
## Usage ## Usage
@@ -13,7 +13,7 @@ npm install inline-schema
### Basic Example ### Basic Example
```typescript ```typescript
import { defineSchema } from 'inline-schema'; import { defineSchema } from 'typed-csv';
// Define a schema // Define a schema
const stringSchema = defineSchema('string'); const stringSchema = defineSchema('string');
@@ -157,7 +157,7 @@ module.exports = {
rules: [ rules: [
{ {
test: /\.schema\.csv$/, test: /\.schema\.csv$/,
use: 'inline-schema/csv-loader', use: 'typed-csv/csv-loader',
}, },
], ],
}, },
+8 -8
View File
@@ -1,18 +1,18 @@
# inline-schema/csv-loader # typed-csv/csv-loader
A rspack/rollup loader for CSV files that uses inline-schema for type validation. A rspack/rollup loader for CSV files that uses typed-csv for type validation.
## Installation ## Installation
```bash ```bash
npm install inline-schema npm install typed-csv
``` ```
## Usage ## Usage
The loader expects: The loader expects:
- **First row**: Property names (headers) - **First row**: Property names (headers)
- **Second row**: Inline-schema definitions for each property - **Second row**: typed-csv schema definitions for each property
- **Remaining rows**: Data values - **Remaining rows**: Data values
### Example CSV ### Example CSV
@@ -35,7 +35,7 @@ module.exports = {
{ {
test: /\.schema\.csv$/, test: /\.schema\.csv$/,
use: { use: {
loader: 'inline-schema/csv-loader', loader: 'typed-csv/csv-loader',
options: { options: {
delimiter: ',', delimiter: ',',
quote: '"', quote: '"',
@@ -60,7 +60,7 @@ module.exports = {
```typescript ```typescript
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
import { csvLoader } from 'inline-schema/csv-loader/rollup'; import { csvLoader } from 'typed-csv/csv-loader/rollup';
export default defineConfig({ export default defineConfig({
plugins: [ plugins: [
@@ -85,7 +85,7 @@ export default defineConfig({
```typescript ```typescript
import { defineConfig } from 'tsup'; import { defineConfig } from 'tsup';
import { csvLoader } from 'inline-schema/csv-loader/rollup'; import { csvLoader } from 'typed-csv/csv-loader/rollup';
export default defineConfig({ export default defineConfig({
entry: ['src/index.ts'], entry: ['src/index.ts'],
@@ -139,7 +139,7 @@ import data from './data.csv';
## Schema Syntax ## Schema Syntax
Uses [inline-schema](https://github.com/your-repo/inline-schema) syntax: Uses [typed-csv](https://github.com/your-repo/typed-csv) syntax:
| Type | Schema | Example | | Type | Schema | Example |
|------|--------|---------| |------|--------|---------|
+2 -2
View File
@@ -1,5 +1,5 @@
{ {
"name": "inline-schema", "name": "typed-csv",
"version": "1.0.0", "version": "1.0.0",
"main": "./dist/index.js", "main": "./dist/index.js",
"module": "./dist/index.mjs", "module": "./dist/index.mjs",
@@ -49,7 +49,7 @@
], ],
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"description": "A TypeScript library for parsing and validating inline schemas", "description": "A TypeScript library for typed CSV data with inline schema validation",
"dependencies": { "dependencies": {
"csv-parse": "^5.5.6" "csv-parse": "^5.5.6"
}, },
+2 -2
View File
@@ -39,7 +39,7 @@ function matchesPattern(
} }
/** /**
* Esbuild plugin for loading CSV files with inline-schema validation. * Esbuild plugin for loading CSV files with typed-csv validation.
*/ */
export function csvLoader(options: CsvEsbuildOptions = {}): Plugin { export function csvLoader(options: CsvEsbuildOptions = {}): Plugin {
const { const {
@@ -54,7 +54,7 @@ export function csvLoader(options: CsvEsbuildOptions = {}): Plugin {
const includeFilter = createFilter(include); const includeFilter = createFilter(include);
return { return {
name: "inline-schema-csv", name: "typed-csv",
setup(build) { setup(build) {
build.onLoad({ filter: includeFilter }, async (args) => { build.onLoad({ filter: includeFilter }, async (args) => {
+2 -2
View File
@@ -53,7 +53,7 @@ interface RollupPlugin {
} }
/** /**
* Rollup plugin for loading CSV files with inline-schema validation. * Rollup plugin for loading CSV files with typed-csv validation.
* Works with both Vite and Tsup (esbuild). * Works with both Vite and Tsup (esbuild).
*/ */
export function csvLoader(options: CsvRollupOptions = {}): RollupPlugin { export function csvLoader(options: CsvRollupOptions = {}): RollupPlugin {
@@ -67,7 +67,7 @@ export function csvLoader(options: CsvRollupOptions = {}): RollupPlugin {
} = options; } = options;
return { return {
name: "inline-schema-csv", name: "typed-csv",
transform(code: string, id: string) { transform(code: string, id: string) {
// Check if file matches the include/exclude patterns // Check if file matches the include/exclude patterns