rake-db 2.25.12 → 2.25.13

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/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as orchid_core from 'orchid-core';
2
2
  import { MaybeArray, RawSQLBase, ColumnDataCheckBase, RecordString, ColumnTypeBase, EmptyObject, ColumnSchemaConfig, QueryLogObject, QueryLogOptions, MaybePromise, RecordOptionalString, ForeignKeyTable, SingleSql } from 'orchid-core';
3
3
  import * as pqb from 'pqb';
4
- import { TableData, ColumnsShape, NoPrimaryKeyOption, ColumnType, EnumColumn, raw, Adapter, DbResult, TransactionAdapter, TableDataFn, TableDataItem, DbDomainArg, Db as Db$1, QueryArraysResult, AdapterOptions, DefaultColumnTypes, DefaultSchemaConfig, SearchWeight, ColumnsByType, DbStructureDomainsMap } from 'pqb';
4
+ import { TableData, ColumnsShape, NoPrimaryKeyOption, ColumnType, EnumColumn, raw, Adapter, DbResult, TransactionAdapter, TableDataFn, TableDataItem, DbDomainArg, Db, QueryArraysResult, AdapterOptions, DefaultColumnTypes, DefaultSchemaConfig, SearchWeight, ColumnsByType, DbStructureDomainsMap } from 'pqb';
5
5
 
6
6
  type RakeDbAst = RakeDbAst.Table | RakeDbAst.ChangeTable | RakeDbAst.RenameType | RakeDbAst.Schema | RakeDbAst.RenameSchema | RakeDbAst.Extension | RakeDbAst.Enum | RakeDbAst.EnumValues | RakeDbAst.RenameEnumValues | RakeDbAst.ChangeEnumValues | RakeDbAst.Domain | RakeDbAst.Collation | RakeDbAst.Constraint | RakeDbAst.RenameTableItem | RakeDbAst.View;
7
7
  declare namespace RakeDbAst {
@@ -1229,7 +1229,7 @@ interface TableQuery {
1229
1229
  then?(result: QueryArraysResult): void;
1230
1230
  }
1231
1231
  interface CreateTableResult<Table extends string, Shape extends ColumnsShape> {
1232
- table: Db$1<Table, Shape>;
1232
+ table: Db<Table, Shape>;
1233
1233
  }
1234
1234
 
1235
1235
  interface RakeDbCtx {
@@ -1285,17 +1285,15 @@ interface MigrationsSet {
1285
1285
  migrations: MigrationItem[];
1286
1286
  }
1287
1287
 
1288
- type CommandFn<SchemaConfig extends ColumnSchemaConfig, CT> = (options: AdapterOptions[], config: RakeDbConfig<SchemaConfig, CT>, args: string[]) => void | Promise<void>;
1289
- interface RakeDbConfig<SchemaConfig extends ColumnSchemaConfig, CT = DefaultColumnTypes<DefaultSchemaConfig>> extends QueryLogOptions {
1288
+ interface CommandFn<SchemaConfig extends ColumnSchemaConfig, CT> {
1289
+ (options: AdapterOptions[], config: RakeDbConfig<SchemaConfig, CT>, args: string[]): void | Promise<void>;
1290
+ }
1291
+ interface RakeDbBaseConfig<SchemaConfig extends ColumnSchemaConfig, CT = DefaultColumnTypes<DefaultSchemaConfig>> extends QueryLogOptions {
1290
1292
  schemaConfig: SchemaConfig;
1291
- columnTypes: CT;
1292
- basePath: string;
1293
- dbScript: string;
1294
1293
  migrationsPath: string;
1295
1294
  migrationId: RakeDbMigrationId;
1296
1295
  migrations?: ModuleExportsRecord;
1297
1296
  renameMigrations?: RakeDbRenameMigrationsInput;
1298
- recurrentPath: string;
1299
1297
  migrationsTable: string;
1300
1298
  snakeCase: boolean;
1301
1299
  language?: string;
@@ -1312,6 +1310,12 @@ interface RakeDbConfig<SchemaConfig extends ColumnSchemaConfig, CT = DefaultColu
1312
1310
  beforeRollback?: MigrationCallback;
1313
1311
  afterRollback?: MigrationCallback;
1314
1312
  }
1313
+ interface RakeDbConfig<SchemaConfig extends ColumnSchemaConfig, CT = DefaultColumnTypes<DefaultSchemaConfig>> extends RakeDbBaseConfig<SchemaConfig, CT> {
1314
+ columnTypes: CT;
1315
+ basePath: string;
1316
+ dbScript: string;
1317
+ recurrentPath: string;
1318
+ }
1315
1319
  interface InputRakeDbConfigBase<SchemaConfig extends ColumnSchemaConfig, CT> extends QueryLogOptions {
1316
1320
  columnTypes?: CT | ((t: DefaultColumnTypes<DefaultSchemaConfig>) => CT);
1317
1321
  baseTable?: RakeDbBaseTable<CT>;
@@ -1324,7 +1328,7 @@ interface InputRakeDbConfigBase<SchemaConfig extends ColumnSchemaConfig, CT> ext
1324
1328
  migrationsTable?: string;
1325
1329
  snakeCase?: boolean;
1326
1330
  language?: string;
1327
- commands?: Record<string, (options: AdapterOptions[], config: RakeDbConfig<SchemaConfig, CT extends undefined ? DefaultColumnTypes<DefaultSchemaConfig> : CT>, args: string[]) => void | Promise<void>>;
1331
+ commands?: Record<string, (options: AdapterOptions[], config: RakeDbConfig<SchemaConfig, CT>, args: string[]) => void | Promise<void>>;
1328
1332
  noPrimaryKey?: NoPrimaryKeyOption;
1329
1333
  forceDefaultExports?: boolean;
1330
1334
  /**
@@ -1385,12 +1389,13 @@ interface InputRakeDbConfigBase<SchemaConfig extends ColumnSchemaConfig, CT> ext
1385
1389
  */
1386
1390
  afterRollback?: MigrationCallback;
1387
1391
  }
1388
- type InputRakeDbConfig<SchemaConfig extends ColumnSchemaConfig, CT> = InputRakeDbConfigBase<SchemaConfig, CT> & ({
1392
+ interface InputRakeDbConfigFileBased<SchemaConfig extends ColumnSchemaConfig, CT> extends InputRakeDbConfigBase<SchemaConfig, CT> {
1389
1393
  /**
1390
1394
  * It may look odd, but it's required for `tsx` and other bundlers to have such `import` config specified explicitly.
1391
1395
  */
1392
1396
  import(path: string): Promise<unknown>;
1393
- } | {
1397
+ }
1398
+ interface InputRakeDbConfigCodeBased<SchemaConfig extends ColumnSchemaConfig, CT> extends InputRakeDbConfigBase<SchemaConfig, CT> {
1394
1399
  /**
1395
1400
  * To specify array of migrations explicitly, without loading them from files.
1396
1401
  */
@@ -1400,24 +1405,30 @@ type InputRakeDbConfig<SchemaConfig extends ColumnSchemaConfig, CT> = InputRakeD
1400
1405
  * It may look odd, but it's required for `tsx` and other bundlers to have such `import` config specified explicitly.
1401
1406
  */
1402
1407
  import?(path: string): Promise<unknown>;
1403
- });
1404
- type ChangeCallback$1 = (arg: {
1405
- db: Db;
1406
- up: boolean;
1407
- redo: boolean;
1408
- migrations: MigrationItem[];
1409
- }) => void | Promise<void>;
1410
- type ChangeCommitCallback = (arg: {
1411
- options: AdapterOptions;
1412
- up: boolean;
1413
- migrations: MigrationItem[];
1414
- }) => void | Promise<void>;
1415
- type MigrationCallback = (arg: {
1416
- db: Db;
1417
- migrations: MigrationItem[];
1418
- }) => void | Promise<void>;
1408
+ }
1409
+ type InputRakeDbConfig<SchemaConfig extends ColumnSchemaConfig, CT> = InputRakeDbConfigFileBased<SchemaConfig, CT> | InputRakeDbConfigCodeBased<SchemaConfig, CT>;
1410
+ interface ChangeCallback$1 {
1411
+ (arg: {
1412
+ db: DbResult<unknown>;
1413
+ up: boolean;
1414
+ redo: boolean;
1415
+ migrations: MigrationItem[];
1416
+ }): void | Promise<void>;
1417
+ }
1418
+ interface ChangeCommitCallback {
1419
+ (arg: {
1420
+ options: AdapterOptions;
1421
+ up: boolean;
1422
+ migrations: MigrationItem[];
1423
+ }): void | Promise<void>;
1424
+ }
1425
+ interface MigrationCallback {
1426
+ (arg: {
1427
+ db: DbResult<unknown>;
1428
+ migrations: MigrationItem[];
1429
+ }): void | Promise<void>;
1430
+ }
1419
1431
  type AnyRakeDbConfig = RakeDbConfig<any, any>;
1420
- type Db = DbResult<unknown>;
1421
1432
  interface RakeDbBaseTable<CT> {
1422
1433
  exportAs: string;
1423
1434
  getFilePath(): string;
@@ -1445,19 +1456,7 @@ interface RakeDbRenameMigrationsInput {
1445
1456
  to: RakeDbMigrationId;
1446
1457
  map: RakeDbRenameMigrationsMap;
1447
1458
  }
1448
- declare const migrationConfigDefaults: {
1449
- schemaConfig: DefaultSchemaConfig;
1450
- migrationsPath: string;
1451
- migrationId: {
1452
- serial: number;
1453
- };
1454
- migrationsTable: string;
1455
- snakeCase: false;
1456
- commands: {};
1457
- log: true;
1458
- logger: Console;
1459
- import(): never;
1460
- };
1459
+ declare const migrationConfigDefaults: RakeDbBaseConfig<ColumnSchemaConfig>;
1461
1460
  declare const processRakeDbConfig: <SchemaConfig extends ColumnSchemaConfig<orchid_core.ColumnTypeBase<orchid_core.ColumnTypeSchemaArg, unknown, any, any, unknown, unknown, any, unknown, any, orchid_core.ColumnDataBase>>, CT>(config: InputRakeDbConfig<SchemaConfig, CT>) => RakeDbConfig<SchemaConfig, CT>;
1462
1461
  declare const getDatabaseAndUserFromOptions: (options: AdapterOptions) => {
1463
1462
  database: string;
@@ -1765,7 +1764,8 @@ declare const cmpRawSql: (a: RawSQLBase, b: RawSQLBase) => boolean;
1765
1764
  /**
1766
1765
  * Type of {@link rakeDb} function
1767
1766
  */
1768
- type RakeDbFn = (<SchemaConfig extends ColumnSchemaConfig, CT = undefined>(options: MaybeArray<AdapterOptions>, partialConfig: InputRakeDbConfig<SchemaConfig, CT>, args?: string[]) => RakeDbFnReturns<CT>) & {
1767
+ interface RakeDbFn {
1768
+ <SchemaConfig extends ColumnSchemaConfig, CT = DefaultColumnTypes<DefaultSchemaConfig>>(options: MaybeArray<AdapterOptions>, partialConfig: InputRakeDbConfig<SchemaConfig, CT>, args?: string[]): RakeDbChangeFnWithPromise<CT>;
1769
1769
  /**
1770
1770
  * Unlike the original `rakeDb` that executes immediately,
1771
1771
  * `rakeDb.lazy` returns the `run` function to be later called programmatically.
@@ -1774,29 +1774,27 @@ type RakeDbFn = (<SchemaConfig extends ColumnSchemaConfig, CT = undefined>(optio
1774
1774
  * @param config - {@link RakeDbConfig}
1775
1775
  * @returns `change` is to be used in migrations, `run` takes an array cli args to execute a command
1776
1776
  */
1777
- lazy: RakeDbLazyFn;
1778
- };
1779
- type RakeDbFnReturns<CT> = RakeDbChangeFn<CT extends undefined ? DefaultColumnTypes<DefaultSchemaConfig> : CT> & {
1780
- promise: Promise<RakeDbResult>;
1781
- };
1777
+ lazy<SchemaConfig extends ColumnSchemaConfig, CT = DefaultColumnTypes<DefaultSchemaConfig>>(options: MaybeArray<AdapterOptions>, config: InputRakeDbConfig<SchemaConfig, CT>): {
1778
+ change: RakeDbChangeFn<CT>;
1779
+ run(args: string[], config?: Partial<RakeDbConfig<SchemaConfig, CT>>): Promise<RakeDbResult>;
1780
+ };
1781
+ }
1782
1782
  interface RakeDbResult {
1783
1783
  options: AdapterOptions[];
1784
1784
  config: AnyRakeDbConfig;
1785
1785
  args: string[];
1786
1786
  }
1787
- /**
1788
- * Type of {@link rakeDb.lazy} function
1789
- */
1790
- type RakeDbLazyFn = <SchemaConfig extends ColumnSchemaConfig, CT>(options: MaybeArray<AdapterOptions>, partialConfig: InputRakeDbConfig<SchemaConfig, CT>) => {
1791
- change: RakeDbChangeFn<CT>;
1792
- run(args: string[], config?: Partial<RakeDbConfig<SchemaConfig, CT>>): Promise<RakeDbResult>;
1793
- };
1794
1787
  /**
1795
1788
  * Function to use in migrations to wrap database changes
1796
1789
  * Saves the given callback to an internal queue,
1797
1790
  * and also returns the callback in case you want to export it from migration.
1798
1791
  */
1799
- type RakeDbChangeFn<CT> = (fn: ChangeCallback<CT>) => ChangeCallback<CT>;
1792
+ interface RakeDbChangeFn<CT> {
1793
+ (fn: ChangeCallback<CT>): ChangeCallback<CT>;
1794
+ }
1795
+ interface RakeDbChangeFnWithPromise<CT> extends RakeDbChangeFn<CT> {
1796
+ promise: Promise<RakeDbResult>;
1797
+ }
1800
1798
  /**
1801
1799
  * Function to configure and run `rakeDb`.
1802
1800
  *
@@ -1846,4 +1844,4 @@ declare const promptText: ({ message, default: def, password, min, }: {
1846
1844
  min?: number;
1847
1845
  }) => Promise<string>;
1848
1846
 
1849
- export { type AnyRakeDbConfig, type ChangeCallback, type ChangeTableCallback, type ChangeTableOptions, type ColumnChecks, type ColumnComment, type ColumnNamedCheck, type ColumnsShapeCallback, type CommandFn, type DbMigration, DbStructure, type DropMode, type GetIndexOrExcludeName, type InputRakeDbConfig, type InputRakeDbConfigBase, type IntrospectedStructure, Migration, type MigrationAdapter, type MigrationColumnTypes, type ModuleExportsRecord, NoMigrationsTableError, RAKE_DB_LOCK_KEY, type RakeDbAppliedVersions, RakeDbAst, type RakeDbBaseTable, type RakeDbChangeFn, type RakeDbConfig, type RakeDbCtx, type RakeDbFn, type RakeDbFnReturns, type RakeDbLazyFn, type RakeDbMigrationId, type RakeDbRenameMigrations, type RakeDbRenameMigrationsInput, type RakeDbRenameMigrationsMap, type RakeDbResult, type SilentQueries, type StructureToAstCtx, type StructureToAstTableData, type TableOptions, addColumnComment, addColumnExclude, addColumnIndex, addOrDropEnumValues, astToMigration, changeCache, changeEnumValues, clearChanges, cmpRawSql, colors, columnToSql, columnTypeToSql, commentsToQuery, concatSchemaAndName, constraintToSql, createDb, createMigrationInterface, dbColumnToAst, deleteMigratedVersion, dropDb, encodeColumnDefault, excludesToQuery, exhaustive, generateTimeStamp, getColumnName, getConstraintName, getCurrentChanges, getDatabaseAndUserFromOptions, getDbStructureTableData, getDbTableColumnsChecks, getExcludeName, getFirstWordAndRest, getForeignKeyTable, getIndexName, getMigratedVersionsMap, getSchemaAndTableFromName, getTextAfterFrom, getTextAfterTo, identityToSql, indexesToQuery, instantiateDbColumn, interpolateSqlValues, introspectDbSchema, joinColumns, joinWords, makeDbStructureColumnsShape, makeDomainsMap, makeFileVersion, makePopulateEnumQuery, makeStructureToAstCtx, migrate, migrateOrRollback, migrationConfigDefaults, nameColumnChecks, newMigration, pluralize, primaryKeyToSql, processRakeDbConfig, promptConfirm, promptSelect, promptText, pushChange, queryLock, quoteCustomType, quoteNameFromString, quoteSchemaTable, quoteTable, quoteWithSchema, rakeDb, rakeDbAliases, rakeDbCommands, redo, referencesToSql, renameType, resetDb, rollback, saveMigratedVersion, structureToAst, tableToAst, transaction, versionToString, writeMigrationFile };
1847
+ export { type AnyRakeDbConfig, type ChangeCallback, type ChangeTableCallback, type ChangeTableOptions, type ColumnChecks, type ColumnComment, type ColumnNamedCheck, type ColumnsShapeCallback, type CommandFn, type DbMigration, DbStructure, type DropMode, type GetIndexOrExcludeName, type InputRakeDbConfig, type InputRakeDbConfigBase, type IntrospectedStructure, Migration, type MigrationAdapter, type MigrationColumnTypes, type ModuleExportsRecord, NoMigrationsTableError, RAKE_DB_LOCK_KEY, type RakeDbAppliedVersions, RakeDbAst, type RakeDbBaseTable, type RakeDbConfig, type RakeDbCtx, type RakeDbFn, type RakeDbMigrationId, type RakeDbRenameMigrations, type RakeDbRenameMigrationsInput, type RakeDbRenameMigrationsMap, type RakeDbResult, type SilentQueries, type StructureToAstCtx, type StructureToAstTableData, type TableOptions, addColumnComment, addColumnExclude, addColumnIndex, addOrDropEnumValues, astToMigration, changeCache, changeEnumValues, clearChanges, cmpRawSql, colors, columnToSql, columnTypeToSql, commentsToQuery, concatSchemaAndName, constraintToSql, createDb, createMigrationInterface, dbColumnToAst, deleteMigratedVersion, dropDb, encodeColumnDefault, excludesToQuery, exhaustive, generateTimeStamp, getColumnName, getConstraintName, getCurrentChanges, getDatabaseAndUserFromOptions, getDbStructureTableData, getDbTableColumnsChecks, getExcludeName, getFirstWordAndRest, getForeignKeyTable, getIndexName, getMigratedVersionsMap, getSchemaAndTableFromName, getTextAfterFrom, getTextAfterTo, identityToSql, indexesToQuery, instantiateDbColumn, interpolateSqlValues, introspectDbSchema, joinColumns, joinWords, makeDbStructureColumnsShape, makeDomainsMap, makeFileVersion, makePopulateEnumQuery, makeStructureToAstCtx, migrate, migrateOrRollback, migrationConfigDefaults, nameColumnChecks, newMigration, pluralize, primaryKeyToSql, processRakeDbConfig, promptConfirm, promptSelect, promptText, pushChange, queryLock, quoteCustomType, quoteNameFromString, quoteSchemaTable, quoteTable, quoteWithSchema, rakeDb, rakeDbAliases, rakeDbCommands, redo, referencesToSql, renameType, resetDb, rollback, saveMigratedVersion, structureToAst, tableToAst, transaction, versionToString, writeMigrationFile };