tempest-db-js 0.5.0 → 0.7.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/README.md +8 -4
- package/dist/bin.cjs +580 -329
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +3 -3
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-5QQMVTS5.js → chunk-4AWUP7BM.js} +540 -57
- package/dist/chunk-4AWUP7BM.js.map +1 -0
- package/dist/{chunk-EPMLFNFK.js → chunk-SI4CLSF7.js} +109 -59
- package/dist/chunk-SI4CLSF7.js.map +1 -0
- package/dist/index.cjs +544 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +430 -22
- package/dist/index.d.ts +430 -22
- package/dist/index.js +1 -1
- package/dist/migrations/index.cjs +122 -55
- package/dist/migrations/index.cjs.map +1 -1
- package/dist/migrations/index.d.cts +46 -3
- package/dist/migrations/index.d.ts +46 -3
- package/dist/migrations/index.js +2 -2
- package/package.json +6 -1
- package/dist/chunk-5QQMVTS5.js.map +0 -1
- package/dist/chunk-EPMLFNFK.js.map +0 -1
|
@@ -399,6 +399,40 @@ declare function sqliteAffinity(declared: string): SqliteAffinity;
|
|
|
399
399
|
*/
|
|
400
400
|
declare function introspectSqlite(driver: SyncDriver): SchemaIR;
|
|
401
401
|
declare function checkDrift(driver: SyncDriver, models: readonly ModelClass[]): string[];
|
|
402
|
+
/**
|
|
403
|
+
* Compare an introspected SQLite schema against the reflected models.
|
|
404
|
+
*
|
|
405
|
+
* Split out from {@link checkDrift} so the sync and async drivers share one
|
|
406
|
+
* comparison — a second copy would drift from this one the first time a rule
|
|
407
|
+
* changes.
|
|
408
|
+
*
|
|
409
|
+
* @param actual The schema read from the database.
|
|
410
|
+
* @param expected The schema reflected from the models.
|
|
411
|
+
* @returns A list of human-readable drift messages — empty means no drift.
|
|
412
|
+
*/
|
|
413
|
+
declare function compareSqliteSchemas(actual: SchemaIR, expected: SchemaIR): string[];
|
|
414
|
+
/**
|
|
415
|
+
* Read the current SQLite schema into a `SchemaIR` over an **async** driver.
|
|
416
|
+
*
|
|
417
|
+
* The sequencing differs from {@link introspectSqlite} — each `PRAGMA` depends on
|
|
418
|
+
* the previous result, so it cannot be one awaited batch — but every row → IR
|
|
419
|
+
* mapping is the shared code above.
|
|
420
|
+
*
|
|
421
|
+
* @param driver An async SQLite driver.
|
|
422
|
+
* @returns The introspected schema.
|
|
423
|
+
*/
|
|
424
|
+
declare function introspectSqliteAsync(driver: AsyncDriver): Promise<SchemaIR>;
|
|
425
|
+
/**
|
|
426
|
+
* Drift check over an **async** driver, routed by dialect. This is what
|
|
427
|
+
* `tempest-db check` runs, so the CLI reaches the same comparison for every
|
|
428
|
+
* supported database instead of only SQLite.
|
|
429
|
+
*
|
|
430
|
+
* @param driver An async driver for the live database.
|
|
431
|
+
* @param dialect The dialect the driver speaks.
|
|
432
|
+
* @param models The model classes that define the intended schema.
|
|
433
|
+
* @returns A list of drift messages — empty means no drift.
|
|
434
|
+
*/
|
|
435
|
+
declare function checkDriftAsync(driver: AsyncDriver, dialect: Dialect, models: readonly ModelClass[]): Promise<string[]>;
|
|
402
436
|
/**
|
|
403
437
|
* Read the current PostgreSQL schema into a `SchemaIR` from `information_schema`.
|
|
404
438
|
*
|
|
@@ -500,7 +534,12 @@ declare function applyRenames(ops: readonly Operation[], confirmed: readonly Ren
|
|
|
500
534
|
|
|
501
535
|
/** Configuration the CLI operates against. */
|
|
502
536
|
interface CliConfig {
|
|
503
|
-
|
|
537
|
+
/**
|
|
538
|
+
* The driver for the live database — sync (SQLite) or async (PostgreSQL,
|
|
539
|
+
* MySQL). Both are accepted: the CLI adapts either to the async runner, so a
|
|
540
|
+
* Postgres migration runs through the same commands as a SQLite one.
|
|
541
|
+
*/
|
|
542
|
+
readonly driver: SyncDriver | AsyncDriver;
|
|
504
543
|
readonly dialect: Dialect;
|
|
505
544
|
readonly migrations: readonly Migration[];
|
|
506
545
|
readonly models?: readonly ModelClass[];
|
|
@@ -542,10 +581,14 @@ declare function defineMigrationConfig(config: CliConfig): CliConfig;
|
|
|
542
581
|
* Commands: `current`, `history`, `heads`, `upgrade [--sql]`, `downgrade [N]`,
|
|
543
582
|
* `check`, `revision -m <msg> [--autogenerate]`.
|
|
544
583
|
*
|
|
584
|
+
* Async for every dialect: the config's driver is adapted with
|
|
585
|
+
* {@link toAsyncDriver}, so SQLite and PostgreSQL take the same path and the CLI
|
|
586
|
+
* is not silently SQLite-only.
|
|
587
|
+
*
|
|
545
588
|
* @param argv The command and its arguments (without the program name).
|
|
546
589
|
* @param config The driver, migrations, and models to operate on.
|
|
547
590
|
* @returns Output lines and an exit code.
|
|
548
591
|
*/
|
|
549
|
-
declare function runMigrationCli(argv: readonly string[], config: CliConfig): CliResult
|
|
592
|
+
declare function runMigrationCli(argv: readonly string[], config: CliConfig): Promise<CliResult>;
|
|
550
593
|
|
|
551
|
-
export { AsyncMigrationRunner, type CliConfig, type CliResult, type ColumnIR, CyclicMigrationGraph, type DefaultIR, type ForeignKeyIR, IrreversibleMigration, type Migration, type MigrationDraft, MigrationRunner, type NamedConstraint, Op, type Operation, type RenameCandidate, type RevisionNode, type SchemaIR, type SqliteAffinity, type TableIR, type UniqueConstraintIR, UnknownRevision, applyOperation, applyRenames, checkDrift, checkDriftPostgres, defineMigrationConfig, detectRenames, diffSchema, emptySchema, generateMigration, heads, introspectPostgres, introspectSqlite, invert, invertAll, makeRevisionId, reflectSchema, reflectTable, renderColumnDef, renderColumnType, renderDefault, renderOperation, replaySchema, runMigrationCli, sqliteAffinity, topoOrder };
|
|
594
|
+
export { AsyncMigrationRunner, type CliConfig, type CliResult, type ColumnIR, CyclicMigrationGraph, type DefaultIR, type ForeignKeyIR, IrreversibleMigration, type Migration, type MigrationDraft, MigrationRunner, type NamedConstraint, Op, type Operation, type RenameCandidate, type RevisionNode, type SchemaIR, type SqliteAffinity, type TableIR, type UniqueConstraintIR, UnknownRevision, applyOperation, applyRenames, checkDrift, checkDriftAsync, checkDriftPostgres, compareSqliteSchemas, defineMigrationConfig, detectRenames, diffSchema, emptySchema, generateMigration, heads, introspectPostgres, introspectSqlite, introspectSqliteAsync, invert, invertAll, makeRevisionId, reflectSchema, reflectTable, renderColumnDef, renderColumnType, renderDefault, renderOperation, replaySchema, runMigrationCli, sqliteAffinity, topoOrder };
|
|
@@ -399,6 +399,40 @@ declare function sqliteAffinity(declared: string): SqliteAffinity;
|
|
|
399
399
|
*/
|
|
400
400
|
declare function introspectSqlite(driver: SyncDriver): SchemaIR;
|
|
401
401
|
declare function checkDrift(driver: SyncDriver, models: readonly ModelClass[]): string[];
|
|
402
|
+
/**
|
|
403
|
+
* Compare an introspected SQLite schema against the reflected models.
|
|
404
|
+
*
|
|
405
|
+
* Split out from {@link checkDrift} so the sync and async drivers share one
|
|
406
|
+
* comparison — a second copy would drift from this one the first time a rule
|
|
407
|
+
* changes.
|
|
408
|
+
*
|
|
409
|
+
* @param actual The schema read from the database.
|
|
410
|
+
* @param expected The schema reflected from the models.
|
|
411
|
+
* @returns A list of human-readable drift messages — empty means no drift.
|
|
412
|
+
*/
|
|
413
|
+
declare function compareSqliteSchemas(actual: SchemaIR, expected: SchemaIR): string[];
|
|
414
|
+
/**
|
|
415
|
+
* Read the current SQLite schema into a `SchemaIR` over an **async** driver.
|
|
416
|
+
*
|
|
417
|
+
* The sequencing differs from {@link introspectSqlite} — each `PRAGMA` depends on
|
|
418
|
+
* the previous result, so it cannot be one awaited batch — but every row → IR
|
|
419
|
+
* mapping is the shared code above.
|
|
420
|
+
*
|
|
421
|
+
* @param driver An async SQLite driver.
|
|
422
|
+
* @returns The introspected schema.
|
|
423
|
+
*/
|
|
424
|
+
declare function introspectSqliteAsync(driver: AsyncDriver): Promise<SchemaIR>;
|
|
425
|
+
/**
|
|
426
|
+
* Drift check over an **async** driver, routed by dialect. This is what
|
|
427
|
+
* `tempest-db check` runs, so the CLI reaches the same comparison for every
|
|
428
|
+
* supported database instead of only SQLite.
|
|
429
|
+
*
|
|
430
|
+
* @param driver An async driver for the live database.
|
|
431
|
+
* @param dialect The dialect the driver speaks.
|
|
432
|
+
* @param models The model classes that define the intended schema.
|
|
433
|
+
* @returns A list of drift messages — empty means no drift.
|
|
434
|
+
*/
|
|
435
|
+
declare function checkDriftAsync(driver: AsyncDriver, dialect: Dialect, models: readonly ModelClass[]): Promise<string[]>;
|
|
402
436
|
/**
|
|
403
437
|
* Read the current PostgreSQL schema into a `SchemaIR` from `information_schema`.
|
|
404
438
|
*
|
|
@@ -500,7 +534,12 @@ declare function applyRenames(ops: readonly Operation[], confirmed: readonly Ren
|
|
|
500
534
|
|
|
501
535
|
/** Configuration the CLI operates against. */
|
|
502
536
|
interface CliConfig {
|
|
503
|
-
|
|
537
|
+
/**
|
|
538
|
+
* The driver for the live database — sync (SQLite) or async (PostgreSQL,
|
|
539
|
+
* MySQL). Both are accepted: the CLI adapts either to the async runner, so a
|
|
540
|
+
* Postgres migration runs through the same commands as a SQLite one.
|
|
541
|
+
*/
|
|
542
|
+
readonly driver: SyncDriver | AsyncDriver;
|
|
504
543
|
readonly dialect: Dialect;
|
|
505
544
|
readonly migrations: readonly Migration[];
|
|
506
545
|
readonly models?: readonly ModelClass[];
|
|
@@ -542,10 +581,14 @@ declare function defineMigrationConfig(config: CliConfig): CliConfig;
|
|
|
542
581
|
* Commands: `current`, `history`, `heads`, `upgrade [--sql]`, `downgrade [N]`,
|
|
543
582
|
* `check`, `revision -m <msg> [--autogenerate]`.
|
|
544
583
|
*
|
|
584
|
+
* Async for every dialect: the config's driver is adapted with
|
|
585
|
+
* {@link toAsyncDriver}, so SQLite and PostgreSQL take the same path and the CLI
|
|
586
|
+
* is not silently SQLite-only.
|
|
587
|
+
*
|
|
545
588
|
* @param argv The command and its arguments (without the program name).
|
|
546
589
|
* @param config The driver, migrations, and models to operate on.
|
|
547
590
|
* @returns Output lines and an exit code.
|
|
548
591
|
*/
|
|
549
|
-
declare function runMigrationCli(argv: readonly string[], config: CliConfig): CliResult
|
|
592
|
+
declare function runMigrationCli(argv: readonly string[], config: CliConfig): Promise<CliResult>;
|
|
550
593
|
|
|
551
|
-
export { AsyncMigrationRunner, type CliConfig, type CliResult, type ColumnIR, CyclicMigrationGraph, type DefaultIR, type ForeignKeyIR, IrreversibleMigration, type Migration, type MigrationDraft, MigrationRunner, type NamedConstraint, Op, type Operation, type RenameCandidate, type RevisionNode, type SchemaIR, type SqliteAffinity, type TableIR, type UniqueConstraintIR, UnknownRevision, applyOperation, applyRenames, checkDrift, checkDriftPostgres, defineMigrationConfig, detectRenames, diffSchema, emptySchema, generateMigration, heads, introspectPostgres, introspectSqlite, invert, invertAll, makeRevisionId, reflectSchema, reflectTable, renderColumnDef, renderColumnType, renderDefault, renderOperation, replaySchema, runMigrationCli, sqliteAffinity, topoOrder };
|
|
594
|
+
export { AsyncMigrationRunner, type CliConfig, type CliResult, type ColumnIR, CyclicMigrationGraph, type DefaultIR, type ForeignKeyIR, IrreversibleMigration, type Migration, type MigrationDraft, MigrationRunner, type NamedConstraint, Op, type Operation, type RenameCandidate, type RevisionNode, type SchemaIR, type SqliteAffinity, type TableIR, type UniqueConstraintIR, UnknownRevision, applyOperation, applyRenames, checkDrift, checkDriftAsync, checkDriftPostgres, compareSqliteSchemas, defineMigrationConfig, detectRenames, diffSchema, emptySchema, generateMigration, heads, introspectPostgres, introspectSqlite, introspectSqliteAsync, invert, invertAll, makeRevisionId, reflectSchema, reflectTable, renderColumnDef, renderColumnType, renderDefault, renderOperation, replaySchema, runMigrationCli, sqliteAffinity, topoOrder };
|
package/dist/migrations/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AsyncMigrationRunner, CyclicMigrationGraph, IrreversibleMigration, MigrationRunner, Op, UnknownRevision, applyOperation, applyRenames, checkDrift, checkDriftPostgres, defineMigrationConfig, detectRenames, diffSchema, emptySchema, generateMigration, heads, introspectPostgres, introspectSqlite, invert, invertAll, makeRevisionId, reflectSchema, reflectTable, renderColumnDef, renderColumnType, renderDefault, renderOperation, replaySchema, runMigrationCli, sqliteAffinity, topoOrder } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { AsyncMigrationRunner, CyclicMigrationGraph, IrreversibleMigration, MigrationRunner, Op, UnknownRevision, applyOperation, applyRenames, checkDrift, checkDriftAsync, checkDriftPostgres, compareSqliteSchemas, defineMigrationConfig, detectRenames, diffSchema, emptySchema, generateMigration, heads, introspectPostgres, introspectSqlite, introspectSqliteAsync, invert, invertAll, makeRevisionId, reflectSchema, reflectTable, renderColumnDef, renderColumnType, renderDefault, renderOperation, replaySchema, runMigrationCli, sqliteAffinity, topoOrder } from '../chunk-SI4CLSF7.js';
|
|
2
|
+
import '../chunk-4AWUP7BM.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tempest-db-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Type-safe, class-based ORM for TypeScript — SQLAlchemy 2.0 ergonomics for the JS/TS world.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"better-sqlite3": "^12.11.1",
|
|
63
63
|
"drizzle-orm": "^0.45.2",
|
|
64
64
|
"kysely": "^0.29.2",
|
|
65
|
+
"mysql2": "^3.11.5",
|
|
65
66
|
"postgres": "^3.4.5",
|
|
66
67
|
"tsup": "^8.3.0",
|
|
67
68
|
"typescript": "^5.9.3",
|
|
@@ -69,12 +70,16 @@
|
|
|
69
70
|
},
|
|
70
71
|
"peerDependencies": {
|
|
71
72
|
"better-sqlite3": "*",
|
|
73
|
+
"mysql2": "*",
|
|
72
74
|
"postgres": "*"
|
|
73
75
|
},
|
|
74
76
|
"peerDependenciesMeta": {
|
|
75
77
|
"better-sqlite3": {
|
|
76
78
|
"optional": true
|
|
77
79
|
},
|
|
80
|
+
"mysql2": {
|
|
81
|
+
"optional": true
|
|
82
|
+
},
|
|
78
83
|
"postgres": {
|
|
79
84
|
"optional": true
|
|
80
85
|
}
|