@toiroakr/lines-db 0.4.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/bin/cli.js +472 -406
- package/dist/index.cjs +195 -327
- package/dist/index.d.cts +64 -84
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +64 -84
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +197 -328
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/src/cli.ts +436 -152
- package/src/database.ts +296 -52
- package/src/index.ts +2 -2
- package/src/jsonl-migration.ts +24 -56
- package/src/schema.ts +37 -32
- package/src/types.ts +21 -0
- package/src/validator.test.ts +0 -507
- package/src/validator.ts +0 -441
package/dist/index.d.cts
CHANGED
|
@@ -29,6 +29,24 @@ type StandardSchemaResult<Output> = StandardSchemaV1.Result<Output>;
|
|
|
29
29
|
type StandardSchemaIssue = StandardSchemaV1.Issue;
|
|
30
30
|
type InferInput<T$1> = T$1 extends StandardSchemaV1<infer I, unknown> ? I : never;
|
|
31
31
|
type InferOutput<T$1> = T$1 extends StandardSchemaV1<unknown, infer O> ? O : never;
|
|
32
|
+
interface ValidationResult {
|
|
33
|
+
valid: boolean;
|
|
34
|
+
errors: ValidationErrorDetail[];
|
|
35
|
+
warnings: string[];
|
|
36
|
+
}
|
|
37
|
+
interface ValidationErrorDetail {
|
|
38
|
+
file: string;
|
|
39
|
+
tableName: string;
|
|
40
|
+
rowIndex: number;
|
|
41
|
+
issues: ReadonlyArray<StandardSchemaIssue>;
|
|
42
|
+
type?: 'schema' | 'foreignKey';
|
|
43
|
+
foreignKeyError?: {
|
|
44
|
+
column: string;
|
|
45
|
+
value: unknown;
|
|
46
|
+
referencedTable: string;
|
|
47
|
+
referencedColumn: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
32
50
|
interface ForeignKeyDefinition {
|
|
33
51
|
column: string;
|
|
34
52
|
references: {
|
|
@@ -94,17 +112,26 @@ declare class LinesDB<Tables extends TableDefs> {
|
|
|
94
112
|
private constructor();
|
|
95
113
|
static create<Tables extends TableDefs>(config: DatabaseConfig<Tables>, dbPath?: string): LinesDB<Tables>;
|
|
96
114
|
/**
|
|
97
|
-
* Initialize database by loading all JSONL files
|
|
115
|
+
* Initialize database by loading all JSONL files or a specific table
|
|
98
116
|
* Uses dependency resolution to ensure foreign key references are loaded in correct order
|
|
99
|
-
|
|
100
|
-
|
|
117
|
+
* @param options Optional configuration for initialization
|
|
118
|
+
* @param options.tableName Optional table name to initialize. If not provided, initializes all tables
|
|
119
|
+
* @param options.detailedValidate If true, performs detailed validation by inserting rows one by one to catch constraint violations
|
|
120
|
+
* @param options.transform Optional transform function to apply to rows before validation (only applied to the specified tableName)
|
|
121
|
+
* @returns ValidationResult containing validation status, errors, and warnings
|
|
122
|
+
*/
|
|
123
|
+
initialize(options?: {
|
|
124
|
+
tableName?: string;
|
|
125
|
+
detailedValidate?: boolean;
|
|
126
|
+
transform?: (row: JsonObject) => JsonObject;
|
|
127
|
+
}): Promise<ValidationResult>;
|
|
101
128
|
/**
|
|
102
129
|
* Load a table and its dependencies recursively
|
|
103
130
|
*/
|
|
104
131
|
private loadTableWithDependencies;
|
|
105
132
|
/**
|
|
106
133
|
* Load a single table from JSONL file
|
|
107
|
-
* @returns
|
|
134
|
+
* @returns Object with loaded status and validation errors
|
|
108
135
|
*/
|
|
109
136
|
private loadTable;
|
|
110
137
|
/**
|
|
@@ -120,9 +147,20 @@ declare class LinesDB<Tables extends TableDefs> {
|
|
|
120
147
|
*/
|
|
121
148
|
private quoteIdentifier;
|
|
122
149
|
/**
|
|
123
|
-
* Insert data into table
|
|
150
|
+
* Insert data into table using batch insert (multiple rows per SQL)
|
|
151
|
+
* SQLite has a parameter limit (default 999), so we batch rows accordingly
|
|
152
|
+
* Throws exception if any constraint violation occurs
|
|
124
153
|
*/
|
|
125
154
|
private insertData;
|
|
155
|
+
/**
|
|
156
|
+
* Insert data into table one row at a time with detailed error reporting
|
|
157
|
+
* This is used for validation to catch constraint violations
|
|
158
|
+
*/
|
|
159
|
+
private insertDataWithDetailedValidation;
|
|
160
|
+
/**
|
|
161
|
+
* Analyze constraint error and extract detailed information
|
|
162
|
+
*/
|
|
163
|
+
private analyzeConstraintError;
|
|
126
164
|
/**
|
|
127
165
|
* Execute a raw SQL query
|
|
128
166
|
*/
|
|
@@ -249,8 +287,9 @@ declare class LinesDB<Tables extends TableDefs> {
|
|
|
249
287
|
/**
|
|
250
288
|
* Sync database changes back to JSONL files
|
|
251
289
|
* Uses backward transformation when available
|
|
290
|
+
* @param tableName Optional table name to sync. If not provided, syncs all loaded tables
|
|
252
291
|
*/
|
|
253
|
-
sync(): Promise<void>;
|
|
292
|
+
sync(tableName?: string): Promise<void>;
|
|
254
293
|
/**
|
|
255
294
|
* Execute a function within a transaction
|
|
256
295
|
* Automatically commits on success or rolls back on error
|
|
@@ -325,8 +364,9 @@ declare class DirectoryScanner {
|
|
|
325
364
|
//#region src/schema.d.ts
|
|
326
365
|
/**
|
|
327
366
|
* Schema options for defining constraints and indexes
|
|
367
|
+
* When Input and Output types differ, backward transformation is required
|
|
328
368
|
*/
|
|
329
|
-
|
|
369
|
+
type SchemaOptions<Input extends Table, Output extends Table> = {
|
|
330
370
|
/**
|
|
331
371
|
* Primary key column
|
|
332
372
|
*/
|
|
@@ -339,12 +379,17 @@ interface SchemaOptions {
|
|
|
339
379
|
* Indexes to create
|
|
340
380
|
*/
|
|
341
381
|
indexes?: IndexDefinition[];
|
|
382
|
+
} & (Output extends Input ? {
|
|
342
383
|
/**
|
|
343
|
-
* Backward transformation from Output to Input
|
|
344
|
-
* Required when Input and Output types differ (e.g., with transformations)
|
|
384
|
+
* Backward transformation from Output to Input (optional when output is substitutable for input)
|
|
345
385
|
*/
|
|
346
|
-
backward?: (output:
|
|
347
|
-
}
|
|
386
|
+
backward?: (output: Output) => Input;
|
|
387
|
+
} : {
|
|
388
|
+
/**
|
|
389
|
+
* Backward transformation from Output to Input (REQUIRED when types differ)
|
|
390
|
+
*/
|
|
391
|
+
backward: (output: Output) => Input;
|
|
392
|
+
});
|
|
348
393
|
/**
|
|
349
394
|
* BiDirectional Schema interface
|
|
350
395
|
* Extends StandardSchema with optional backward transformation and schema metadata
|
|
@@ -372,8 +417,7 @@ interface BiDirectionalSchema<Input extends Table = Table, Output extends Table
|
|
|
372
417
|
* Define a bidirectional schema with optional backward transformation
|
|
373
418
|
*
|
|
374
419
|
* @param schema - Standard Schema for validation
|
|
375
|
-
* @param
|
|
376
|
-
* Required when schema performs transformations
|
|
420
|
+
* @param options - SchemaOptions object. When Input and Output types differ, backward transformation is required
|
|
377
421
|
*
|
|
378
422
|
* @example
|
|
379
423
|
* // No transformation - backward not needed
|
|
@@ -382,10 +426,12 @@ interface BiDirectionalSchema<Input extends Table = Table, Output extends Table
|
|
|
382
426
|
* );
|
|
383
427
|
*
|
|
384
428
|
* @example
|
|
385
|
-
* // With transformation - backward
|
|
429
|
+
* // With transformation - backward REQUIRED
|
|
386
430
|
* const schema = defineSchema(
|
|
387
431
|
* v.pipe(v.string(), v.transform(Number)),
|
|
388
|
-
*
|
|
432
|
+
* {
|
|
433
|
+
* backward: (num) => String(num) // backward: number → string (REQUIRED)
|
|
434
|
+
* }
|
|
389
435
|
* );
|
|
390
436
|
*
|
|
391
437
|
* @example
|
|
@@ -400,7 +446,7 @@ interface BiDirectionalSchema<Input extends Table = Table, Output extends Table
|
|
|
400
446
|
* }
|
|
401
447
|
* );
|
|
402
448
|
*/
|
|
403
|
-
declare function defineSchema<Input extends Table, Output extends Table>(schema: StandardSchema<Input, Output>,
|
|
449
|
+
declare function defineSchema<Input extends Table, Output extends Table>(schema: StandardSchema<Input, Output>, ...args: Output extends Input ? [options?: SchemaOptions<Input, Output>] : [options: SchemaOptions<Input, Output>]): BiDirectionalSchema<Input, Output>;
|
|
404
450
|
/**
|
|
405
451
|
* Check if a schema has backward transformation
|
|
406
452
|
*/
|
|
@@ -433,72 +479,6 @@ declare class TypeGenerator {
|
|
|
433
479
|
private formatTableKey;
|
|
434
480
|
}
|
|
435
481
|
//#endregion
|
|
436
|
-
//#region src/validator.d.ts
|
|
437
|
-
interface ValidationResult {
|
|
438
|
-
valid: boolean;
|
|
439
|
-
errors: ValidationErrorDetail[];
|
|
440
|
-
warnings: string[];
|
|
441
|
-
}
|
|
442
|
-
interface ValidationErrorDetail {
|
|
443
|
-
file: string;
|
|
444
|
-
tableName: string;
|
|
445
|
-
rowIndex: number;
|
|
446
|
-
issues: ReadonlyArray<StandardSchemaIssue>;
|
|
447
|
-
type?: 'schema' | 'foreignKey';
|
|
448
|
-
foreignKeyError?: {
|
|
449
|
-
column: string;
|
|
450
|
-
value: unknown;
|
|
451
|
-
referencedTable: string;
|
|
452
|
-
referencedColumn: string;
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
|
-
interface ValidatorOptions {
|
|
456
|
-
path: string;
|
|
457
|
-
projectRoot?: string;
|
|
458
|
-
}
|
|
459
|
-
declare class Validator {
|
|
460
|
-
private path;
|
|
461
|
-
private projectRoot;
|
|
462
|
-
constructor(options: ValidatorOptions);
|
|
463
|
-
/**
|
|
464
|
-
* Validate JSONL file(s)
|
|
465
|
-
*/
|
|
466
|
-
validate(): Promise<ValidationResult>;
|
|
467
|
-
/**
|
|
468
|
-
* Validate all JSONL files in a directory
|
|
469
|
-
*/
|
|
470
|
-
private validateDirectory;
|
|
471
|
-
/**
|
|
472
|
-
* Validate by loading data into database one row at a time
|
|
473
|
-
* This catches constraint violations and extracts detailed error information
|
|
474
|
-
*/
|
|
475
|
-
private validateWithDatabase;
|
|
476
|
-
/**
|
|
477
|
-
* Create table schema from data and validation schema
|
|
478
|
-
*/
|
|
479
|
-
private createTableSchema;
|
|
480
|
-
/**
|
|
481
|
-
* Create table in database
|
|
482
|
-
*/
|
|
483
|
-
private createTableInDb;
|
|
484
|
-
/**
|
|
485
|
-
* Insert a row into database
|
|
486
|
-
*/
|
|
487
|
-
private insertRowIntoDb;
|
|
488
|
-
/**
|
|
489
|
-
* Analyze constraint error and extract detailed information
|
|
490
|
-
*/
|
|
491
|
-
private analyzeConstraintError;
|
|
492
|
-
/**
|
|
493
|
-
* Quote SQL identifier
|
|
494
|
-
*/
|
|
495
|
-
private quoteIdentifier;
|
|
496
|
-
/**
|
|
497
|
-
* Validate a single JSONL file
|
|
498
|
-
*/
|
|
499
|
-
private validateFile;
|
|
500
|
-
}
|
|
501
|
-
//#endregion
|
|
502
482
|
//#region src/jsonl-migration.d.ts
|
|
503
483
|
interface TableValidationOptions {
|
|
504
484
|
dataDir: string;
|
|
@@ -507,7 +487,7 @@ interface TableValidationOptions {
|
|
|
507
487
|
}
|
|
508
488
|
/**
|
|
509
489
|
* Validate a table by temporarily supplying in-memory rows while reusing the existing LinesDB validation pipeline.
|
|
510
|
-
* If validation fails,
|
|
490
|
+
* If validation fails, throws an error with validation details.
|
|
511
491
|
*/
|
|
512
492
|
declare function ensureTableRowsValid(options: TableValidationOptions): Promise<void>;
|
|
513
493
|
//#endregion
|
|
@@ -519,5 +499,5 @@ type RuntimeEnvironment = 'node' | 'unknown';
|
|
|
519
499
|
declare function detectRuntime(): RuntimeEnvironment;
|
|
520
500
|
declare const RUNTIME: RuntimeEnvironment;
|
|
521
501
|
//#endregion
|
|
522
|
-
export { type BiDirectionalSchema, type ColumnDefinition, type DatabaseConfig, DirectoryScanner, type ForeignKeyDefinition, type IndexDefinition, type InferInput, type InferOutput, type JsonArray, type JsonObject, type JsonValue, JsonlReader, JsonlWriter, LinesDB, RUNTIME, type RuntimeEnvironment, type SQLiteDatabase, type SQLiteStatement, SchemaLoader, type SchemaOptions, type StandardSchema, type StandardSchemaIssue, type StandardSchemaResult, type Table, type TableConfig, type TableDefs, type TableSchema, type TableValidationOptions, TypeGenerator, type TypeGeneratorOptions, type ValidationError, type ValidationErrorDetail, type ValidationResult,
|
|
502
|
+
export { type BiDirectionalSchema, type ColumnDefinition, type DatabaseConfig, DirectoryScanner, type ForeignKeyDefinition, type IndexDefinition, type InferInput, type InferOutput, type JsonArray, type JsonObject, type JsonValue, JsonlReader, JsonlWriter, LinesDB, RUNTIME, type RuntimeEnvironment, type SQLiteDatabase, type SQLiteStatement, SchemaLoader, type SchemaOptions, type StandardSchema, type StandardSchemaIssue, type StandardSchemaResult, type Table, type TableConfig, type TableDefs, type TableSchema, type TableValidationOptions, TypeGenerator, type TypeGeneratorOptions, type ValidationError, type ValidationErrorDetail, type ValidationResult, defineSchema, detectRuntime, ensureTableRowsValid, hasBackward };
|
|
523
503
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/sqlite-adapter.ts","../src/types.ts","../src/database.ts","../src/jsonl-reader.ts","../src/jsonl-writer.ts","../src/schema-loader.ts","../src/directory-scanner.ts","../src/schema.ts","../src/type-generator.ts","../src/
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/sqlite-adapter.ts","../src/types.ts","../src/database.ts","../src/jsonl-reader.ts","../src/jsonl-writer.ts","../src/schema-loader.ts","../src/directory-scanner.ts","../src/schema.ts","../src/type-generator.ts","../src/jsonl-migration.ts","../src/runtime.ts"],"sourcesContent":[],"mappings":";;;;;;;AASA;AAMA;;UANiB,cAAA;wBACO;ECPZ,IAAA,CAAA,GAAK,EAAA,MAAA,CAAA,EAAA,IAAG;EACR,KAAA,EAAA,EAAA,IAAA;;AACY,UDUP,eAAA,CCVO;EACP,GAAA,CAAA,GAAA,MAAA,EAAA,GAAA,EAAA,CAAA,EAAA;IAAQ,OAAA,EAAA,MAAA;IACJ,eAAA,EAAA,MAAA,GAAA,MAAA;EAAO,CAAA;EAAxB,GAAA,CAAA,GAAA,MAAA,EAAA,GAAA,EAAA,CAAA,EAAA,GAAA;EAAgB,GAAA,CAAA,GAAA,MAAA,EAAA,GAAA,EAAA,CAAA,EAAA,GAAA,EAAA;AACpB;;;KALY,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,GAAA,IAAA,EK+DpB,ML/DoB,SK+DL,KL/DK,GAAA,CAAA,OAAA,GKgEd,aLhEc,CKgEA,KLhEA,EKgEO,MLhEP,CAAA,CAAA,GAAA,CAAA,OAAA,EKiEf,aLjEe,CKiED,KLjEC,EKiEM,MLjEN,CAAA,CAAA,CAAA,EKkE5B,mBLlE4B,CKkER,KLlEQ,EKkED,MLlEC,CAAA;;;;AAG1B,iBKiGW,WLjGX,CAAA,cKiGqC,KLjGrC,EAAA,eKiG2D,KLjG3D,CAAA,CAAA,MAAA,EKkGK,cLlGL,CKkGoB,KLlGpB,EKkG2B,MLlG3B,CAAA,CAAA,EAAA,MAAA,IKmGQ,mBLnGR,CKmG4B,KLnG5B,EKmGmC,MLnGnC,CAAA;;;UMlCY,oBAAA;;;ARKjB;AAMiB,cQDJ,aAAA,CRCmB;;;;ECZpB,QAAK,WAAA;EACL,WAAA,CAAA,OAAc,EOgBH,oBPhBG;EACV;;;EACS,QAAA,CAAA,CAAA,EO6BL,OP7BK,CAAA,MAAA,CAAA;EACJ;;;EAAD,QAAA,UAAA;EACR;AACZ;AAOA;EAA4B,QAAA,wBAAA;EAAU,QAAA,sBAAA;EAAqC,QAAA,cAAA;;;;UQX1D,sBAAA;;ETIA,SAAA,EAAA,MAAc;EAMd,IAAA,ESPT,UTOS,EAAe;;;;ACZhC;AACA;AACgB,iBQUM,oBAAA,CRVN,OAAA,EQUoC,sBRVpC,CAAA,EQU6D,ORV7D,CAAA,IAAA,CAAA;;;;;;ADIC,KULL,kBAAA,GVMY,MAAA,GAAA,SAAe;AAKtB,iBUTD,aAAA,CAAA,CVSgB,EUTC,kBVSD;cUAnB,SAAO"}
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,24 @@ type StandardSchemaResult<Output> = StandardSchemaV1.Result<Output>;
|
|
|
29
29
|
type StandardSchemaIssue = StandardSchemaV1.Issue;
|
|
30
30
|
type InferInput<T$1> = T$1 extends StandardSchemaV1<infer I, unknown> ? I : never;
|
|
31
31
|
type InferOutput<T$1> = T$1 extends StandardSchemaV1<unknown, infer O> ? O : never;
|
|
32
|
+
interface ValidationResult {
|
|
33
|
+
valid: boolean;
|
|
34
|
+
errors: ValidationErrorDetail[];
|
|
35
|
+
warnings: string[];
|
|
36
|
+
}
|
|
37
|
+
interface ValidationErrorDetail {
|
|
38
|
+
file: string;
|
|
39
|
+
tableName: string;
|
|
40
|
+
rowIndex: number;
|
|
41
|
+
issues: ReadonlyArray<StandardSchemaIssue>;
|
|
42
|
+
type?: 'schema' | 'foreignKey';
|
|
43
|
+
foreignKeyError?: {
|
|
44
|
+
column: string;
|
|
45
|
+
value: unknown;
|
|
46
|
+
referencedTable: string;
|
|
47
|
+
referencedColumn: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
32
50
|
interface ForeignKeyDefinition {
|
|
33
51
|
column: string;
|
|
34
52
|
references: {
|
|
@@ -94,17 +112,26 @@ declare class LinesDB<Tables extends TableDefs> {
|
|
|
94
112
|
private constructor();
|
|
95
113
|
static create<Tables extends TableDefs>(config: DatabaseConfig<Tables>, dbPath?: string): LinesDB<Tables>;
|
|
96
114
|
/**
|
|
97
|
-
* Initialize database by loading all JSONL files
|
|
115
|
+
* Initialize database by loading all JSONL files or a specific table
|
|
98
116
|
* Uses dependency resolution to ensure foreign key references are loaded in correct order
|
|
99
|
-
|
|
100
|
-
|
|
117
|
+
* @param options Optional configuration for initialization
|
|
118
|
+
* @param options.tableName Optional table name to initialize. If not provided, initializes all tables
|
|
119
|
+
* @param options.detailedValidate If true, performs detailed validation by inserting rows one by one to catch constraint violations
|
|
120
|
+
* @param options.transform Optional transform function to apply to rows before validation (only applied to the specified tableName)
|
|
121
|
+
* @returns ValidationResult containing validation status, errors, and warnings
|
|
122
|
+
*/
|
|
123
|
+
initialize(options?: {
|
|
124
|
+
tableName?: string;
|
|
125
|
+
detailedValidate?: boolean;
|
|
126
|
+
transform?: (row: JsonObject) => JsonObject;
|
|
127
|
+
}): Promise<ValidationResult>;
|
|
101
128
|
/**
|
|
102
129
|
* Load a table and its dependencies recursively
|
|
103
130
|
*/
|
|
104
131
|
private loadTableWithDependencies;
|
|
105
132
|
/**
|
|
106
133
|
* Load a single table from JSONL file
|
|
107
|
-
* @returns
|
|
134
|
+
* @returns Object with loaded status and validation errors
|
|
108
135
|
*/
|
|
109
136
|
private loadTable;
|
|
110
137
|
/**
|
|
@@ -120,9 +147,20 @@ declare class LinesDB<Tables extends TableDefs> {
|
|
|
120
147
|
*/
|
|
121
148
|
private quoteIdentifier;
|
|
122
149
|
/**
|
|
123
|
-
* Insert data into table
|
|
150
|
+
* Insert data into table using batch insert (multiple rows per SQL)
|
|
151
|
+
* SQLite has a parameter limit (default 999), so we batch rows accordingly
|
|
152
|
+
* Throws exception if any constraint violation occurs
|
|
124
153
|
*/
|
|
125
154
|
private insertData;
|
|
155
|
+
/**
|
|
156
|
+
* Insert data into table one row at a time with detailed error reporting
|
|
157
|
+
* This is used for validation to catch constraint violations
|
|
158
|
+
*/
|
|
159
|
+
private insertDataWithDetailedValidation;
|
|
160
|
+
/**
|
|
161
|
+
* Analyze constraint error and extract detailed information
|
|
162
|
+
*/
|
|
163
|
+
private analyzeConstraintError;
|
|
126
164
|
/**
|
|
127
165
|
* Execute a raw SQL query
|
|
128
166
|
*/
|
|
@@ -249,8 +287,9 @@ declare class LinesDB<Tables extends TableDefs> {
|
|
|
249
287
|
/**
|
|
250
288
|
* Sync database changes back to JSONL files
|
|
251
289
|
* Uses backward transformation when available
|
|
290
|
+
* @param tableName Optional table name to sync. If not provided, syncs all loaded tables
|
|
252
291
|
*/
|
|
253
|
-
sync(): Promise<void>;
|
|
292
|
+
sync(tableName?: string): Promise<void>;
|
|
254
293
|
/**
|
|
255
294
|
* Execute a function within a transaction
|
|
256
295
|
* Automatically commits on success or rolls back on error
|
|
@@ -325,8 +364,9 @@ declare class DirectoryScanner {
|
|
|
325
364
|
//#region src/schema.d.ts
|
|
326
365
|
/**
|
|
327
366
|
* Schema options for defining constraints and indexes
|
|
367
|
+
* When Input and Output types differ, backward transformation is required
|
|
328
368
|
*/
|
|
329
|
-
|
|
369
|
+
type SchemaOptions<Input extends Table, Output extends Table> = {
|
|
330
370
|
/**
|
|
331
371
|
* Primary key column
|
|
332
372
|
*/
|
|
@@ -339,12 +379,17 @@ interface SchemaOptions {
|
|
|
339
379
|
* Indexes to create
|
|
340
380
|
*/
|
|
341
381
|
indexes?: IndexDefinition[];
|
|
382
|
+
} & (Output extends Input ? {
|
|
342
383
|
/**
|
|
343
|
-
* Backward transformation from Output to Input
|
|
344
|
-
* Required when Input and Output types differ (e.g., with transformations)
|
|
384
|
+
* Backward transformation from Output to Input (optional when output is substitutable for input)
|
|
345
385
|
*/
|
|
346
|
-
backward?: (output:
|
|
347
|
-
}
|
|
386
|
+
backward?: (output: Output) => Input;
|
|
387
|
+
} : {
|
|
388
|
+
/**
|
|
389
|
+
* Backward transformation from Output to Input (REQUIRED when types differ)
|
|
390
|
+
*/
|
|
391
|
+
backward: (output: Output) => Input;
|
|
392
|
+
});
|
|
348
393
|
/**
|
|
349
394
|
* BiDirectional Schema interface
|
|
350
395
|
* Extends StandardSchema with optional backward transformation and schema metadata
|
|
@@ -372,8 +417,7 @@ interface BiDirectionalSchema<Input extends Table = Table, Output extends Table
|
|
|
372
417
|
* Define a bidirectional schema with optional backward transformation
|
|
373
418
|
*
|
|
374
419
|
* @param schema - Standard Schema for validation
|
|
375
|
-
* @param
|
|
376
|
-
* Required when schema performs transformations
|
|
420
|
+
* @param options - SchemaOptions object. When Input and Output types differ, backward transformation is required
|
|
377
421
|
*
|
|
378
422
|
* @example
|
|
379
423
|
* // No transformation - backward not needed
|
|
@@ -382,10 +426,12 @@ interface BiDirectionalSchema<Input extends Table = Table, Output extends Table
|
|
|
382
426
|
* );
|
|
383
427
|
*
|
|
384
428
|
* @example
|
|
385
|
-
* // With transformation - backward
|
|
429
|
+
* // With transformation - backward REQUIRED
|
|
386
430
|
* const schema = defineSchema(
|
|
387
431
|
* v.pipe(v.string(), v.transform(Number)),
|
|
388
|
-
*
|
|
432
|
+
* {
|
|
433
|
+
* backward: (num) => String(num) // backward: number → string (REQUIRED)
|
|
434
|
+
* }
|
|
389
435
|
* );
|
|
390
436
|
*
|
|
391
437
|
* @example
|
|
@@ -400,7 +446,7 @@ interface BiDirectionalSchema<Input extends Table = Table, Output extends Table
|
|
|
400
446
|
* }
|
|
401
447
|
* );
|
|
402
448
|
*/
|
|
403
|
-
declare function defineSchema<Input extends Table, Output extends Table>(schema: StandardSchema<Input, Output>,
|
|
449
|
+
declare function defineSchema<Input extends Table, Output extends Table>(schema: StandardSchema<Input, Output>, ...args: Output extends Input ? [options?: SchemaOptions<Input, Output>] : [options: SchemaOptions<Input, Output>]): BiDirectionalSchema<Input, Output>;
|
|
404
450
|
/**
|
|
405
451
|
* Check if a schema has backward transformation
|
|
406
452
|
*/
|
|
@@ -433,72 +479,6 @@ declare class TypeGenerator {
|
|
|
433
479
|
private formatTableKey;
|
|
434
480
|
}
|
|
435
481
|
//#endregion
|
|
436
|
-
//#region src/validator.d.ts
|
|
437
|
-
interface ValidationResult {
|
|
438
|
-
valid: boolean;
|
|
439
|
-
errors: ValidationErrorDetail[];
|
|
440
|
-
warnings: string[];
|
|
441
|
-
}
|
|
442
|
-
interface ValidationErrorDetail {
|
|
443
|
-
file: string;
|
|
444
|
-
tableName: string;
|
|
445
|
-
rowIndex: number;
|
|
446
|
-
issues: ReadonlyArray<StandardSchemaIssue>;
|
|
447
|
-
type?: 'schema' | 'foreignKey';
|
|
448
|
-
foreignKeyError?: {
|
|
449
|
-
column: string;
|
|
450
|
-
value: unknown;
|
|
451
|
-
referencedTable: string;
|
|
452
|
-
referencedColumn: string;
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
|
-
interface ValidatorOptions {
|
|
456
|
-
path: string;
|
|
457
|
-
projectRoot?: string;
|
|
458
|
-
}
|
|
459
|
-
declare class Validator {
|
|
460
|
-
private path;
|
|
461
|
-
private projectRoot;
|
|
462
|
-
constructor(options: ValidatorOptions);
|
|
463
|
-
/**
|
|
464
|
-
* Validate JSONL file(s)
|
|
465
|
-
*/
|
|
466
|
-
validate(): Promise<ValidationResult>;
|
|
467
|
-
/**
|
|
468
|
-
* Validate all JSONL files in a directory
|
|
469
|
-
*/
|
|
470
|
-
private validateDirectory;
|
|
471
|
-
/**
|
|
472
|
-
* Validate by loading data into database one row at a time
|
|
473
|
-
* This catches constraint violations and extracts detailed error information
|
|
474
|
-
*/
|
|
475
|
-
private validateWithDatabase;
|
|
476
|
-
/**
|
|
477
|
-
* Create table schema from data and validation schema
|
|
478
|
-
*/
|
|
479
|
-
private createTableSchema;
|
|
480
|
-
/**
|
|
481
|
-
* Create table in database
|
|
482
|
-
*/
|
|
483
|
-
private createTableInDb;
|
|
484
|
-
/**
|
|
485
|
-
* Insert a row into database
|
|
486
|
-
*/
|
|
487
|
-
private insertRowIntoDb;
|
|
488
|
-
/**
|
|
489
|
-
* Analyze constraint error and extract detailed information
|
|
490
|
-
*/
|
|
491
|
-
private analyzeConstraintError;
|
|
492
|
-
/**
|
|
493
|
-
* Quote SQL identifier
|
|
494
|
-
*/
|
|
495
|
-
private quoteIdentifier;
|
|
496
|
-
/**
|
|
497
|
-
* Validate a single JSONL file
|
|
498
|
-
*/
|
|
499
|
-
private validateFile;
|
|
500
|
-
}
|
|
501
|
-
//#endregion
|
|
502
482
|
//#region src/jsonl-migration.d.ts
|
|
503
483
|
interface TableValidationOptions {
|
|
504
484
|
dataDir: string;
|
|
@@ -507,7 +487,7 @@ interface TableValidationOptions {
|
|
|
507
487
|
}
|
|
508
488
|
/**
|
|
509
489
|
* Validate a table by temporarily supplying in-memory rows while reusing the existing LinesDB validation pipeline.
|
|
510
|
-
* If validation fails,
|
|
490
|
+
* If validation fails, throws an error with validation details.
|
|
511
491
|
*/
|
|
512
492
|
declare function ensureTableRowsValid(options: TableValidationOptions): Promise<void>;
|
|
513
493
|
//#endregion
|
|
@@ -519,5 +499,5 @@ type RuntimeEnvironment = 'node' | 'unknown';
|
|
|
519
499
|
declare function detectRuntime(): RuntimeEnvironment;
|
|
520
500
|
declare const RUNTIME: RuntimeEnvironment;
|
|
521
501
|
//#endregion
|
|
522
|
-
export { type BiDirectionalSchema, type ColumnDefinition, type DatabaseConfig, DirectoryScanner, type ForeignKeyDefinition, type IndexDefinition, type InferInput, type InferOutput, type JsonArray, type JsonObject, type JsonValue, JsonlReader, JsonlWriter, LinesDB, RUNTIME, type RuntimeEnvironment, type SQLiteDatabase, type SQLiteStatement, SchemaLoader, type SchemaOptions, type StandardSchema, type StandardSchemaIssue, type StandardSchemaResult, type Table, type TableConfig, type TableDefs, type TableSchema, type TableValidationOptions, TypeGenerator, type TypeGeneratorOptions, type ValidationError, type ValidationErrorDetail, type ValidationResult,
|
|
502
|
+
export { type BiDirectionalSchema, type ColumnDefinition, type DatabaseConfig, DirectoryScanner, type ForeignKeyDefinition, type IndexDefinition, type InferInput, type InferOutput, type JsonArray, type JsonObject, type JsonValue, JsonlReader, JsonlWriter, LinesDB, RUNTIME, type RuntimeEnvironment, type SQLiteDatabase, type SQLiteStatement, SchemaLoader, type SchemaOptions, type StandardSchema, type StandardSchemaIssue, type StandardSchemaResult, type Table, type TableConfig, type TableDefs, type TableSchema, type TableValidationOptions, TypeGenerator, type TypeGeneratorOptions, type ValidationError, type ValidationErrorDetail, type ValidationResult, defineSchema, detectRuntime, ensureTableRowsValid, hasBackward };
|
|
523
503
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/sqlite-adapter.ts","../src/types.ts","../src/database.ts","../src/jsonl-reader.ts","../src/jsonl-writer.ts","../src/schema-loader.ts","../src/directory-scanner.ts","../src/schema.ts","../src/type-generator.ts","../src/
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/sqlite-adapter.ts","../src/types.ts","../src/database.ts","../src/jsonl-reader.ts","../src/jsonl-writer.ts","../src/schema-loader.ts","../src/directory-scanner.ts","../src/schema.ts","../src/type-generator.ts","../src/jsonl-migration.ts","../src/runtime.ts"],"sourcesContent":[],"mappings":";;;;;;;AASA;AAMA;;UANiB,cAAA;wBACO;ECPZ,IAAA,CAAA,GAAK,EAAA,MAAA,CAAA,EAAG,IAAA;EACR,KAAA,EAAA,EAAA,IAAA;;AACY,UDUP,eAAA,CCVO;EACP,GAAA,CAAA,GAAA,MAAA,EAAA,GAAA,EAAA,CAAA,EAAA;IAAQ,OAAA,EAAA,MAAA;IACJ,eAAA,EAAA,MAAA,GAAA,MAAA;EAAO,CAAA;EAAxB,GAAA,CAAA,GAAA,MAAA,EAAA,GAAA,EAAA,CAAA,EAAA,GAAA;EAAgB,GAAA,CAAA,GAAA,MAAA,EAAA,GAAA,EAAA,CAAA,EAAA,GAAA,EAAA;AACpB;;;KALY,KAAA,GAAQ;KACR,6BACI,QAAQ,sBACP,QAAQ,SACrB,iBAAiB,OAAO;ADEX,KCDL,oBDCmB,CACP,MAAA,CAAA,GCFmB,gBAAA,CAAiB,MDErB,CCF4B,MDE5B,CAAA;AAKtB,KCNL,mBAAA,GAAsB,gBAAA,CAAiB,KDMnB;KCCpB,kBAAgB,YAAU,qCAAqC;KAC/D,mBAAiB,YAAU,qCAAqC;AAdhE,UAiBK,gBAAA,CAjBS;EACd,KAAA,EAAA,OAAA;EACI,MAAA,EAiBN,qBAjBM,EAAA;EAAQ,QAAA,EAAA,MAAA,EAAA;;AACC,UAoBR,qBAAA,CApBQ;EACJ,IAAA,EAAA,MAAA;EAAO,SAAA,EAAA,MAAA;EAAxB,QAAA,EAAA,MAAA;EAAgB,MAAA,EAuBV,aAvBU,CAuBI,mBAvBJ,CAAA;EACR,IAAA,CAAA,EAAA,QAAA,GAAA,YAAoB;EACpB,eAAA,CAAA,EAAA;IAOA,MAAA,EAAA,MAAU;IAAM,KAAA,EAAA,OAAA;IAAU,eAAA,EAAA,MAAA;IAAqC,gB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