refactor: rename package from inline-schema to typed-csv
This commit is contained in:
@@ -13,12 +13,12 @@ No linter or formatter is configured. No CI pipeline exists.
|
||||
|
||||
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/validator.ts` — `parseValue()` and `createValidator()` operate on the AST
|
||||
- `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
|
||||
- `webpack.ts`, `rollup.ts`, `esbuild.ts` — bundler plugin wrappers around `csvToModule`
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
```bash
|
||||
npm install inline-schema
|
||||
npm install typed-csv
|
||||
```
|
||||
|
||||
## Usage
|
||||
@@ -13,7 +13,7 @@ npm install inline-schema
|
||||
### Basic Example
|
||||
|
||||
```typescript
|
||||
import { defineSchema } from 'inline-schema';
|
||||
import { defineSchema } from 'typed-csv';
|
||||
|
||||
// Define a schema
|
||||
const stringSchema = defineSchema('string');
|
||||
@@ -157,7 +157,7 @@ module.exports = {
|
||||
rules: [
|
||||
{
|
||||
test: /\.schema\.csv$/,
|
||||
use: 'inline-schema/csv-loader',
|
||||
use: 'typed-csv/csv-loader',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
+8
-8
@@ -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
|
||||
|
||||
```bash
|
||||
npm install inline-schema
|
||||
npm install typed-csv
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
The loader expects:
|
||||
- **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
|
||||
|
||||
### Example CSV
|
||||
@@ -35,7 +35,7 @@ module.exports = {
|
||||
{
|
||||
test: /\.schema\.csv$/,
|
||||
use: {
|
||||
loader: 'inline-schema/csv-loader',
|
||||
loader: 'typed-csv/csv-loader',
|
||||
options: {
|
||||
delimiter: ',',
|
||||
quote: '"',
|
||||
@@ -60,7 +60,7 @@ module.exports = {
|
||||
|
||||
```typescript
|
||||
import { defineConfig } from 'vite';
|
||||
import { csvLoader } from 'inline-schema/csv-loader/rollup';
|
||||
import { csvLoader } from 'typed-csv/csv-loader/rollup';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
@@ -85,7 +85,7 @@ export default defineConfig({
|
||||
|
||||
```typescript
|
||||
import { defineConfig } from 'tsup';
|
||||
import { csvLoader } from 'inline-schema/csv-loader/rollup';
|
||||
import { csvLoader } from 'typed-csv/csv-loader/rollup';
|
||||
|
||||
export default defineConfig({
|
||||
entry: ['src/index.ts'],
|
||||
@@ -139,7 +139,7 @@ import data from './data.csv';
|
||||
|
||||
## 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 |
|
||||
|------|--------|---------|
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "inline-schema",
|
||||
"name": "typed-csv",
|
||||
"version": "1.0.0",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
@@ -49,7 +49,7 @@
|
||||
],
|
||||
"author": "",
|
||||
"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": {
|
||||
"csv-parse": "^5.5.6"
|
||||
},
|
||||
|
||||
@@ -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 {
|
||||
const {
|
||||
@@ -54,7 +54,7 @@ export function csvLoader(options: CsvEsbuildOptions = {}): Plugin {
|
||||
const includeFilter = createFilter(include);
|
||||
|
||||
return {
|
||||
name: "inline-schema-csv",
|
||||
name: "typed-csv",
|
||||
|
||||
setup(build) {
|
||||
build.onLoad({ filter: includeFilter }, async (args) => {
|
||||
|
||||
@@ -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).
|
||||
*/
|
||||
export function csvLoader(options: CsvRollupOptions = {}): RollupPlugin {
|
||||
@@ -67,7 +67,7 @@ export function csvLoader(options: CsvRollupOptions = {}): RollupPlugin {
|
||||
} = options;
|
||||
|
||||
return {
|
||||
name: "inline-schema-csv",
|
||||
name: "typed-csv",
|
||||
|
||||
transform(code: string, id: string) {
|
||||
// Check if file matches the include/exclude patterns
|
||||
|
||||
Reference in New Issue
Block a user