tempest-db-js 0.2.0 → 0.3.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.
@@ -1,4 +1,4 @@
1
- import { ColumnType, DefaultValue, ModelClass, Dialect, SyncDriver, AsyncDriver } from '../index.cjs';
1
+ import { ColumnType, DefaultValue, ModelClass, Dialect, AsyncDriver, SyncDriver } from '../index.cjs';
2
2
 
3
3
  /**
4
4
  * tempest-db-js — Phase 6: the Schema IR (intermediate representation).
@@ -106,11 +106,11 @@ declare function invert(op: Operation): Operation;
106
106
  declare function invertAll(ops: readonly Operation[]): Operation[];
107
107
 
108
108
  /**
109
- * tempest-db-js — Phase 6: DDL rendering.
109
+ * tempest-db-js — Phase 6/9: DDL rendering.
110
110
  *
111
111
  * Renders the dialect-neutral IR + operations to concrete SQL per dialect. This
112
112
  * is the ONLY place migration SQL is produced — the same operation yields the
113
- * right DDL for SQLite or PostgreSQL.
113
+ * right DDL for SQLite, PostgreSQL or MySQL.
114
114
  */
115
115
 
116
116
  /** Map a column type to its SQL type string for the dialect. */
@@ -126,7 +126,7 @@ declare function renderColumnDef(col: ColumnIR, dialect: Dialect): string;
126
126
  * @param dialect The target dialect.
127
127
  * @returns The SQL statements (usually one).
128
128
  * @throws Error When the operation is unsupported on the dialect (e.g. SQLite
129
- * `alter_column`, which needs the Phase 6e batch/table-rebuild path).
129
+ * `alter_column`, which needs the table-rebuild path).
130
130
  */
131
131
  declare function renderOperation(op: Operation, dialect: Dialect): string[];
132
132
 
@@ -280,6 +280,43 @@ declare class MigrationRunner {
280
280
  */
281
281
  downgrade(migrations: readonly Migration[], steps?: number): string[];
282
282
  }
283
+ /**
284
+ * Runs migrations against an **async** driver (PostgreSQL, or any async driver),
285
+ * tracking applied revisions. Mirrors {@link MigrationRunner} but every statement
286
+ * is awaited, and identifier quoting + placeholder style follow the dialect —
287
+ * so the version table and its bookkeeping are portable across SQLite/PG/MySQL.
288
+ */
289
+ declare class AsyncMigrationRunner {
290
+ private readonly driver;
291
+ private readonly dialect;
292
+ private readonly vt;
293
+ constructor(driver: AsyncDriver, dialect: Dialect);
294
+ /** Create the version-tracking table if it does not exist. */
295
+ ensureVersionTable(): Promise<void>;
296
+ /** A portable "text" column type for the version table. */
297
+ private textType;
298
+ /** The set of applied revision ids. */
299
+ applied(): Promise<Set<string>>;
300
+ private runOps;
301
+ private record;
302
+ private forget;
303
+ /**
304
+ * Apply all pending migrations up to the head(s), in DAG order.
305
+ *
306
+ * @param migrations All known migrations.
307
+ * @param appliedAt Timestamp string to stamp on each applied revision.
308
+ * @returns The revision ids that were applied this run.
309
+ */
310
+ upgrade(migrations: readonly Migration[], appliedAt: string): Promise<string[]>;
311
+ /**
312
+ * Revert the last `steps` applied migrations (default 1), newest first.
313
+ *
314
+ * @param migrations All known migrations.
315
+ * @param steps How many applied revisions to roll back.
316
+ * @returns The revision ids that were reverted.
317
+ */
318
+ downgrade(migrations: readonly Migration[], steps?: number): Promise<string[]>;
319
+ }
283
320
 
284
321
  /**
285
322
  * tempest-db-js — Phase 6d: SQLite introspection + drift detection.
@@ -462,4 +499,4 @@ declare function defineMigrationConfig(config: CliConfig): CliConfig;
462
499
  */
463
500
  declare function runMigrationCli(argv: readonly string[], config: CliConfig): CliResult;
464
501
 
465
- export { type CliConfig, type CliResult, type ColumnIR, CyclicMigrationGraph, type DefaultIR, IrreversibleMigration, type Migration, type MigrationDraft, MigrationRunner, Op, type Operation, type RenameCandidate, type RevisionNode, type SchemaIR, type SqliteAffinity, type TableIR, 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 };
502
+ export { AsyncMigrationRunner, type CliConfig, type CliResult, type ColumnIR, CyclicMigrationGraph, type DefaultIR, IrreversibleMigration, type Migration, type MigrationDraft, MigrationRunner, Op, type Operation, type RenameCandidate, type RevisionNode, type SchemaIR, type SqliteAffinity, type TableIR, 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 };
@@ -1,4 +1,4 @@
1
- import { ColumnType, DefaultValue, ModelClass, Dialect, SyncDriver, AsyncDriver } from '../index.js';
1
+ import { ColumnType, DefaultValue, ModelClass, Dialect, AsyncDriver, SyncDriver } from '../index.js';
2
2
 
3
3
  /**
4
4
  * tempest-db-js — Phase 6: the Schema IR (intermediate representation).
@@ -106,11 +106,11 @@ declare function invert(op: Operation): Operation;
106
106
  declare function invertAll(ops: readonly Operation[]): Operation[];
107
107
 
108
108
  /**
109
- * tempest-db-js — Phase 6: DDL rendering.
109
+ * tempest-db-js — Phase 6/9: DDL rendering.
110
110
  *
111
111
  * Renders the dialect-neutral IR + operations to concrete SQL per dialect. This
112
112
  * is the ONLY place migration SQL is produced — the same operation yields the
113
- * right DDL for SQLite or PostgreSQL.
113
+ * right DDL for SQLite, PostgreSQL or MySQL.
114
114
  */
115
115
 
116
116
  /** Map a column type to its SQL type string for the dialect. */
@@ -126,7 +126,7 @@ declare function renderColumnDef(col: ColumnIR, dialect: Dialect): string;
126
126
  * @param dialect The target dialect.
127
127
  * @returns The SQL statements (usually one).
128
128
  * @throws Error When the operation is unsupported on the dialect (e.g. SQLite
129
- * `alter_column`, which needs the Phase 6e batch/table-rebuild path).
129
+ * `alter_column`, which needs the table-rebuild path).
130
130
  */
131
131
  declare function renderOperation(op: Operation, dialect: Dialect): string[];
132
132
 
@@ -280,6 +280,43 @@ declare class MigrationRunner {
280
280
  */
281
281
  downgrade(migrations: readonly Migration[], steps?: number): string[];
282
282
  }
283
+ /**
284
+ * Runs migrations against an **async** driver (PostgreSQL, or any async driver),
285
+ * tracking applied revisions. Mirrors {@link MigrationRunner} but every statement
286
+ * is awaited, and identifier quoting + placeholder style follow the dialect —
287
+ * so the version table and its bookkeeping are portable across SQLite/PG/MySQL.
288
+ */
289
+ declare class AsyncMigrationRunner {
290
+ private readonly driver;
291
+ private readonly dialect;
292
+ private readonly vt;
293
+ constructor(driver: AsyncDriver, dialect: Dialect);
294
+ /** Create the version-tracking table if it does not exist. */
295
+ ensureVersionTable(): Promise<void>;
296
+ /** A portable "text" column type for the version table. */
297
+ private textType;
298
+ /** The set of applied revision ids. */
299
+ applied(): Promise<Set<string>>;
300
+ private runOps;
301
+ private record;
302
+ private forget;
303
+ /**
304
+ * Apply all pending migrations up to the head(s), in DAG order.
305
+ *
306
+ * @param migrations All known migrations.
307
+ * @param appliedAt Timestamp string to stamp on each applied revision.
308
+ * @returns The revision ids that were applied this run.
309
+ */
310
+ upgrade(migrations: readonly Migration[], appliedAt: string): Promise<string[]>;
311
+ /**
312
+ * Revert the last `steps` applied migrations (default 1), newest first.
313
+ *
314
+ * @param migrations All known migrations.
315
+ * @param steps How many applied revisions to roll back.
316
+ * @returns The revision ids that were reverted.
317
+ */
318
+ downgrade(migrations: readonly Migration[], steps?: number): Promise<string[]>;
319
+ }
283
320
 
284
321
  /**
285
322
  * tempest-db-js — Phase 6d: SQLite introspection + drift detection.
@@ -462,4 +499,4 @@ declare function defineMigrationConfig(config: CliConfig): CliConfig;
462
499
  */
463
500
  declare function runMigrationCli(argv: readonly string[], config: CliConfig): CliResult;
464
501
 
465
- export { type CliConfig, type CliResult, type ColumnIR, CyclicMigrationGraph, type DefaultIR, IrreversibleMigration, type Migration, type MigrationDraft, MigrationRunner, Op, type Operation, type RenameCandidate, type RevisionNode, type SchemaIR, type SqliteAffinity, type TableIR, 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 };
502
+ export { AsyncMigrationRunner, type CliConfig, type CliResult, type ColumnIR, CyclicMigrationGraph, type DefaultIR, IrreversibleMigration, type Migration, type MigrationDraft, MigrationRunner, Op, type Operation, type RenameCandidate, type RevisionNode, type SchemaIR, type SqliteAffinity, type TableIR, 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 };
@@ -1,4 +1,4 @@
1
- export { 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-QMW4NKMH.js';
2
- import '../chunk-AGDD7K3F.js';
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-OP7FRDI5.js';
2
+ import '../chunk-Q32CBI2A.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.2.0",
3
+ "version": "0.3.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,