@h3ravel/arquebus 0.3.5 → 0.4.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/bin/index.cjs +4272 -2738
- package/bin/index.js +4367 -2833
- package/dist/browser/index.cjs +2 -0
- package/dist/browser/index.d.cts +94 -7
- package/dist/browser/index.d.ts +94 -7
- package/dist/browser/index.js +2 -1
- package/dist/index.cjs +1502 -17
- package/dist/index.d.cts +130 -10
- package/dist/index.d.ts +130 -10
- package/dist/index.js +1502 -18
- package/dist/inspector/index.cjs +4885 -0
- package/dist/inspector/index.d.cts +83 -0
- package/dist/inspector/index.d.ts +83 -0
- package/dist/inspector/index.js +4859 -0
- package/dist/migrations/index.cjs +4426 -2958
- package/dist/migrations/index.d.cts +134 -17
- package/dist/migrations/index.d.ts +135 -18
- package/dist/migrations/index.js +4354 -2876
- package/package.json +12 -3
- package/types/query-builder.ts +37 -1
- package/src/migrations/stubs/migration-js.stub +0 -21
- package/src/migrations/stubs/migration-ts.stub +0 -18
- package/src/migrations/stubs/migration.create-js.stub +0 -24
- package/src/migrations/stubs/migration.create-ts.stub +0 -21
- package/src/migrations/stubs/migration.update-js.stub +0 -25
- package/src/migrations/stubs/migration.update-ts.stub +0 -22
- package/src/stubs/arquebus.config-js.stub +0 -25
- package/src/stubs/arquebus.config-ts.stub +0 -24
- package/src/stubs/model-js.stub +0 -5
- package/src/stubs/model-ts.stub +0 -5
|
@@ -248,7 +248,7 @@ declare class arquebus<M extends Model = Model> {
|
|
|
248
248
|
static setConnectorFactory(connectorFactory: typeof Knex$1): void;
|
|
249
249
|
static getConnectorFactory(): typeof Knex$1;
|
|
250
250
|
static addConnection(config: TConfig | TBaseConfig, name?: string): void;
|
|
251
|
-
static beginTransaction(connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]
|
|
251
|
+
static beginTransaction(connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]>>;
|
|
252
252
|
static transaction(callback: TFunction, connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]>> | undefined;
|
|
253
253
|
static table(name: string, connection?: null): IQueryBuilder<Model, Model | Model[]>;
|
|
254
254
|
static schema(connection?: null): SchemaBuilder;
|
|
@@ -268,7 +268,7 @@ declare class arquebus<M extends Model = Model> {
|
|
|
268
268
|
* @returns
|
|
269
269
|
*/
|
|
270
270
|
static autoLoad(addConnection?: boolean): Promise<TBaseConfig>;
|
|
271
|
-
beginTransaction(connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]
|
|
271
|
+
beginTransaction(connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]>>;
|
|
272
272
|
transaction(callback: TFunction, connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]>> | undefined;
|
|
273
273
|
table(name: string, connection?: null): IQueryBuilder<M, M | M[]>;
|
|
274
274
|
schema(connection?: null): SchemaBuilder;
|
|
@@ -989,9 +989,92 @@ interface JoinMethod<QB extends AnyQueryBuilder> {
|
|
|
989
989
|
(raw: Raw): QB;
|
|
990
990
|
}
|
|
991
991
|
//#endregion
|
|
992
|
+
//#region src/inspector/types/column.d.ts
|
|
993
|
+
interface Column {
|
|
994
|
+
name: string;
|
|
995
|
+
table: string;
|
|
996
|
+
data_type: string;
|
|
997
|
+
default_value: string | null;
|
|
998
|
+
max_length: number | null;
|
|
999
|
+
numeric_precision: number | null;
|
|
1000
|
+
numeric_scale: number | null;
|
|
1001
|
+
is_nullable: boolean;
|
|
1002
|
+
is_unique: boolean;
|
|
1003
|
+
is_primary_key: boolean;
|
|
1004
|
+
is_generated: boolean;
|
|
1005
|
+
generation_expression?: string | null;
|
|
1006
|
+
has_auto_increment: boolean;
|
|
1007
|
+
foreign_key_table: string | null;
|
|
1008
|
+
foreign_key_column: string | null;
|
|
1009
|
+
comment?: string | null;
|
|
1010
|
+
schema?: string;
|
|
1011
|
+
foreign_key_schema?: string | null;
|
|
1012
|
+
collation?: string | null;
|
|
1013
|
+
}
|
|
1014
|
+
//#endregion
|
|
1015
|
+
//#region src/inspector/types/foreign-key.d.ts
|
|
1016
|
+
type ForeignKey = {
|
|
1017
|
+
table: string;
|
|
1018
|
+
column: string;
|
|
1019
|
+
foreign_key_table: string;
|
|
1020
|
+
foreign_key_column: string;
|
|
1021
|
+
foreign_key_schema?: string;
|
|
1022
|
+
constraint_name: null | string;
|
|
1023
|
+
on_update: null | 'NO ACTION' | 'RESTRICT' | 'CASCADE' | 'SET NULL' | 'SET DEFAULT';
|
|
1024
|
+
on_delete: null | 'NO ACTION' | 'RESTRICT' | 'CASCADE' | 'SET NULL' | 'SET DEFAULT';
|
|
1025
|
+
};
|
|
1026
|
+
//#endregion
|
|
1027
|
+
//#region src/inspector/types/table.d.ts
|
|
1028
|
+
interface Table {
|
|
1029
|
+
name: string;
|
|
1030
|
+
comment?: string | null;
|
|
1031
|
+
schema?: string;
|
|
1032
|
+
collation?: string;
|
|
1033
|
+
engine?: string;
|
|
1034
|
+
owner?: string;
|
|
1035
|
+
sql?: string;
|
|
1036
|
+
catalog?: string;
|
|
1037
|
+
}
|
|
1038
|
+
//#endregion
|
|
992
1039
|
//#region types/query-builder.d.ts
|
|
993
1040
|
interface SchemaBuilder extends Knex.SchemaBuilder {
|
|
994
1041
|
[k: string]: any;
|
|
1042
|
+
/**
|
|
1043
|
+
* Retrieve all tables in the current database.
|
|
1044
|
+
*/
|
|
1045
|
+
tables(): Promise<string[]>;
|
|
1046
|
+
/**
|
|
1047
|
+
* Retrieve the table info for the given table, or all tables if no table is specified.
|
|
1048
|
+
*
|
|
1049
|
+
* @param table
|
|
1050
|
+
*/
|
|
1051
|
+
tableInfo(table?: string): Promise<Table | Table[]>;
|
|
1052
|
+
/**
|
|
1053
|
+
* Retrieve all columns in a given table, or all columns if no table is specified.
|
|
1054
|
+
*
|
|
1055
|
+
* @param table
|
|
1056
|
+
*/
|
|
1057
|
+
columns(table?: string): Promise<{
|
|
1058
|
+
table: string;
|
|
1059
|
+
column: string;
|
|
1060
|
+
}[]>;
|
|
1061
|
+
/**
|
|
1062
|
+
* Retrieve all columns from a given table. Returns all columns if table parameter is undefined.
|
|
1063
|
+
*
|
|
1064
|
+
* @param table
|
|
1065
|
+
* @param column
|
|
1066
|
+
*/
|
|
1067
|
+
columnInfo(table?: string, column?: string): Promise<Column[] | Column>;
|
|
1068
|
+
/**
|
|
1069
|
+
* Retrieve the primary key column for a given table.
|
|
1070
|
+
*
|
|
1071
|
+
* @param table
|
|
1072
|
+
*/
|
|
1073
|
+
primary(table: string): Promise<string>;
|
|
1074
|
+
/**
|
|
1075
|
+
* Retrieve all configured foreign key constraints
|
|
1076
|
+
*/
|
|
1077
|
+
foreignKeys(): Promise<ForeignKey>;
|
|
995
1078
|
}
|
|
996
1079
|
interface AsMethod<QB extends AnyQueryBuilder> {
|
|
997
1080
|
(alias: string): QB;
|
|
@@ -1122,7 +1205,7 @@ interface IQueryBuilder<M extends Model | Model$1 = Model, R = M[] | M> {
|
|
|
1122
1205
|
take(count: number): this;
|
|
1123
1206
|
limit(count: number): this;
|
|
1124
1207
|
offset(count: number): this;
|
|
1125
|
-
pluck<X extends Model = any>(column: string): Promise<
|
|
1208
|
+
pluck<X extends Model = any>(column: string): Promise<Array<X>>;
|
|
1126
1209
|
chunk(count: number, callback: (rows: M[]) => any): Promise<boolean>;
|
|
1127
1210
|
forPage(page: number, perPage?: number): this;
|
|
1128
1211
|
paginate<F extends IPaginatorParams>(page?: number, perPage?: number): Promise<IPaginator<M, F>>;
|
|
@@ -1135,10 +1218,13 @@ declare const Inference$1: {
|
|
|
1135
1218
|
declare class QueryBuilder<M extends Model = Model, R = M[] | M> extends Inference$1<M, R> {
|
|
1136
1219
|
model: M;
|
|
1137
1220
|
schema: SchemaBuilder;
|
|
1138
|
-
|
|
1221
|
+
connector: IQueryBuilder<M, R> & Knex.QueryBuilder & {
|
|
1222
|
+
_statements: any[];
|
|
1223
|
+
_single: any;
|
|
1224
|
+
} & Knex;
|
|
1139
1225
|
constructor(config: TConfig | null, connector: TFunction);
|
|
1140
1226
|
asProxy(): any;
|
|
1141
|
-
beginTransaction(): Promise<Knex.Transaction<any, any[]
|
|
1227
|
+
beginTransaction(): Promise<Knex.Transaction<any, any[]>>;
|
|
1142
1228
|
table<X extends M>(table: string): IQueryBuilder<X, R>;
|
|
1143
1229
|
transaction(callback?: TFunction): Promise<Knex.Transaction> | undefined;
|
|
1144
1230
|
find(id: string | number, columns?: string[]): Promise<any>;
|
|
@@ -1162,7 +1248,7 @@ declare class QueryBuilder<M extends Model = Model, R = M[] | M> extends Inferen
|
|
|
1162
1248
|
destroy(...args: Parameters<typeof (void 0).connector.destroy>): Promise<number>;
|
|
1163
1249
|
get _statements(): IStatement[] & any[];
|
|
1164
1250
|
get _single(): any;
|
|
1165
|
-
get from(): Knex.Table<any, any>;
|
|
1251
|
+
get from(): Knex.Table<any, any> & Knex.Table<any, any[]>;
|
|
1166
1252
|
}
|
|
1167
1253
|
declare namespace migration_d_exports {
|
|
1168
1254
|
export { IMigration, Migration, Migration as default };
|
|
@@ -1181,15 +1267,14 @@ declare class Migration extends Inference {
|
|
|
1181
1267
|
withinTransaction: boolean;
|
|
1182
1268
|
getConnection(): TBaseConfig['client'];
|
|
1183
1269
|
}
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
}
|
|
1270
|
+
//#endregion
|
|
1271
|
+
//#region src/migrations/migration-repository.d.ts
|
|
1187
1272
|
declare class MigrationRepository {
|
|
1188
1273
|
resolver: typeof arquebus;
|
|
1189
1274
|
table: string;
|
|
1190
1275
|
connection: TBaseConfig['client'] | null;
|
|
1191
1276
|
constructor(resolver: typeof arquebus, table: string);
|
|
1192
|
-
getRan(): Promise<
|
|
1277
|
+
getRan(): Promise<any[]>;
|
|
1193
1278
|
getMigrations(steps: number): Promise<any>;
|
|
1194
1279
|
getMigrationsByBatch(batch: number): Promise<any>;
|
|
1195
1280
|
getLast(): Promise<any>;
|
|
@@ -1206,12 +1291,13 @@ declare class MigrationRepository {
|
|
|
1206
1291
|
setSource(name: TBaseConfig['client']): void;
|
|
1207
1292
|
}
|
|
1208
1293
|
declare namespace migrator_d_exports {
|
|
1209
|
-
export { MigrationOptions, Migrator as default };
|
|
1294
|
+
export { MigrationOptions, Migrator, Migrator as default };
|
|
1210
1295
|
}
|
|
1211
1296
|
interface MigrationOptions {
|
|
1212
1297
|
pretend?: boolean;
|
|
1213
1298
|
step?: number;
|
|
1214
1299
|
batch?: number;
|
|
1300
|
+
quiet?: boolean;
|
|
1215
1301
|
}
|
|
1216
1302
|
declare class Migrator {
|
|
1217
1303
|
events: any;
|
|
@@ -1236,7 +1322,14 @@ declare class Migrator {
|
|
|
1236
1322
|
rollbackMigrations(migrations: {
|
|
1237
1323
|
migration: string;
|
|
1238
1324
|
}[], paths: string[], options: MigrationOptions): Promise<string[]>;
|
|
1239
|
-
reset(
|
|
1325
|
+
reset(paths: string[] | undefined, options: MigrationOptions, pretend?: boolean): Promise<string[]>;
|
|
1326
|
+
/**
|
|
1327
|
+
* Drop all tables and re-run all migrations
|
|
1328
|
+
*
|
|
1329
|
+
* @param paths
|
|
1330
|
+
* @param options
|
|
1331
|
+
*/
|
|
1332
|
+
fresh(paths: string[], options: MigrationOptions): Promise<void>;
|
|
1240
1333
|
resetMigrations(migrations: {
|
|
1241
1334
|
migration: string;
|
|
1242
1335
|
}[], paths: string[], pretend?: boolean): Promise<string[]>;
|
|
@@ -1256,7 +1349,7 @@ declare class Migrator {
|
|
|
1256
1349
|
deleteRepository(): void;
|
|
1257
1350
|
setOutput(output: boolean): this;
|
|
1258
1351
|
write(...args: any[]): void;
|
|
1259
|
-
|
|
1352
|
+
taskRunner(description: string, task: (() => Promise<any>) | (() => any)): Promise<void>;
|
|
1260
1353
|
}
|
|
1261
1354
|
//#endregion
|
|
1262
1355
|
//#region src/migrate.d.ts
|
|
@@ -1270,6 +1363,7 @@ interface MigrateOptions {
|
|
|
1270
1363
|
step?: number;
|
|
1271
1364
|
pretend?: boolean;
|
|
1272
1365
|
batch?: number;
|
|
1366
|
+
quiet?: boolean;
|
|
1273
1367
|
}
|
|
1274
1368
|
type TXBaseConfig<S = boolean> = (S extends true ? Partial<TBaseConfig> : TBaseConfig) & {
|
|
1275
1369
|
/**
|
|
@@ -1301,6 +1395,30 @@ declare class Migrate {
|
|
|
1301
1395
|
* @param destroyAll
|
|
1302
1396
|
*/
|
|
1303
1397
|
rollback(config: TXBaseConfig, options?: MigrateOptions, destroyAll?: boolean): Promise<void>;
|
|
1398
|
+
/**
|
|
1399
|
+
* Rollback all database migrations
|
|
1400
|
+
*
|
|
1401
|
+
* @param config
|
|
1402
|
+
* @param options
|
|
1403
|
+
* @param destroyAll
|
|
1404
|
+
*/
|
|
1405
|
+
reset(config: TXBaseConfig, options?: MigrateOptions, destroyAll?: boolean): Promise<void>;
|
|
1406
|
+
/**
|
|
1407
|
+
* Reset and re-run all migrations
|
|
1408
|
+
*
|
|
1409
|
+
* @param config
|
|
1410
|
+
* @param options
|
|
1411
|
+
* @param destroyAll
|
|
1412
|
+
*/
|
|
1413
|
+
refresh(config: TXBaseConfig, options?: MigrateOptions, destroyAll?: boolean): Promise<void>;
|
|
1414
|
+
/**
|
|
1415
|
+
* Drop all tables and re-run all migrations
|
|
1416
|
+
*
|
|
1417
|
+
* @param config
|
|
1418
|
+
* @param options
|
|
1419
|
+
* @param destroyAll
|
|
1420
|
+
*/
|
|
1421
|
+
fresh(config: TXBaseConfig, options?: MigrateOptions, destroyAll?: boolean): Promise<void>;
|
|
1304
1422
|
/**
|
|
1305
1423
|
* Prepares the database for migration
|
|
1306
1424
|
*
|
|
@@ -1327,9 +1445,8 @@ declare class Migrate {
|
|
|
1327
1445
|
migrator: Migrator;
|
|
1328
1446
|
}>;
|
|
1329
1447
|
}
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
}
|
|
1448
|
+
//#endregion
|
|
1449
|
+
//#region src/migrations/migration-creator.d.ts
|
|
1333
1450
|
declare class MigrationCreator {
|
|
1334
1451
|
private customStubPath?;
|
|
1335
1452
|
private type;
|
|
@@ -1363,4 +1480,4 @@ declare class MigrationCreator {
|
|
|
1363
1480
|
getDirname(meta: ImportMeta | null): string;
|
|
1364
1481
|
}
|
|
1365
1482
|
//#endregion
|
|
1366
|
-
export { Migrate, migration_d_exports as Migration,
|
|
1483
|
+
export { Migrate, migration_d_exports as Migration, MigrationCreator, MigrationRepository, migrator_d_exports as Migrator };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Knex$1, { Knex } from "knex";
|
|
2
1
|
import { Collection } from "collect.js";
|
|
2
|
+
import Knex$1, { Knex } from "knex";
|
|
3
3
|
|
|
4
4
|
//#region src/collection.d.ts
|
|
5
5
|
declare class Collection$1<I extends Model | Model$1> extends Collection<I> implements ICollection<I> {
|
|
@@ -245,7 +245,7 @@ declare class arquebus<M extends Model = Model> {
|
|
|
245
245
|
static setConnectorFactory(connectorFactory: typeof Knex$1): void;
|
|
246
246
|
static getConnectorFactory(): typeof Knex$1;
|
|
247
247
|
static addConnection(config: TConfig | TBaseConfig, name?: string): void;
|
|
248
|
-
static beginTransaction(connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]
|
|
248
|
+
static beginTransaction(connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]>>;
|
|
249
249
|
static transaction(callback: TFunction, connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]>> | undefined;
|
|
250
250
|
static table(name: string, connection?: null): IQueryBuilder<Model, Model | Model[]>;
|
|
251
251
|
static schema(connection?: null): SchemaBuilder;
|
|
@@ -265,7 +265,7 @@ declare class arquebus<M extends Model = Model> {
|
|
|
265
265
|
* @returns
|
|
266
266
|
*/
|
|
267
267
|
static autoLoad(addConnection?: boolean): Promise<TBaseConfig>;
|
|
268
|
-
beginTransaction(connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]
|
|
268
|
+
beginTransaction(connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]>>;
|
|
269
269
|
transaction(callback: TFunction, connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]>> | undefined;
|
|
270
270
|
table(name: string, connection?: null): IQueryBuilder<M, M | M[]>;
|
|
271
271
|
schema(connection?: null): SchemaBuilder;
|
|
@@ -986,9 +986,92 @@ interface JoinMethod<QB extends AnyQueryBuilder> {
|
|
|
986
986
|
(raw: Raw): QB;
|
|
987
987
|
}
|
|
988
988
|
//#endregion
|
|
989
|
+
//#region src/inspector/types/column.d.ts
|
|
990
|
+
interface Column {
|
|
991
|
+
name: string;
|
|
992
|
+
table: string;
|
|
993
|
+
data_type: string;
|
|
994
|
+
default_value: string | null;
|
|
995
|
+
max_length: number | null;
|
|
996
|
+
numeric_precision: number | null;
|
|
997
|
+
numeric_scale: number | null;
|
|
998
|
+
is_nullable: boolean;
|
|
999
|
+
is_unique: boolean;
|
|
1000
|
+
is_primary_key: boolean;
|
|
1001
|
+
is_generated: boolean;
|
|
1002
|
+
generation_expression?: string | null;
|
|
1003
|
+
has_auto_increment: boolean;
|
|
1004
|
+
foreign_key_table: string | null;
|
|
1005
|
+
foreign_key_column: string | null;
|
|
1006
|
+
comment?: string | null;
|
|
1007
|
+
schema?: string;
|
|
1008
|
+
foreign_key_schema?: string | null;
|
|
1009
|
+
collation?: string | null;
|
|
1010
|
+
}
|
|
1011
|
+
//#endregion
|
|
1012
|
+
//#region src/inspector/types/foreign-key.d.ts
|
|
1013
|
+
type ForeignKey = {
|
|
1014
|
+
table: string;
|
|
1015
|
+
column: string;
|
|
1016
|
+
foreign_key_table: string;
|
|
1017
|
+
foreign_key_column: string;
|
|
1018
|
+
foreign_key_schema?: string;
|
|
1019
|
+
constraint_name: null | string;
|
|
1020
|
+
on_update: null | 'NO ACTION' | 'RESTRICT' | 'CASCADE' | 'SET NULL' | 'SET DEFAULT';
|
|
1021
|
+
on_delete: null | 'NO ACTION' | 'RESTRICT' | 'CASCADE' | 'SET NULL' | 'SET DEFAULT';
|
|
1022
|
+
};
|
|
1023
|
+
//#endregion
|
|
1024
|
+
//#region src/inspector/types/table.d.ts
|
|
1025
|
+
interface Table {
|
|
1026
|
+
name: string;
|
|
1027
|
+
comment?: string | null;
|
|
1028
|
+
schema?: string;
|
|
1029
|
+
collation?: string;
|
|
1030
|
+
engine?: string;
|
|
1031
|
+
owner?: string;
|
|
1032
|
+
sql?: string;
|
|
1033
|
+
catalog?: string;
|
|
1034
|
+
}
|
|
1035
|
+
//#endregion
|
|
989
1036
|
//#region types/query-builder.d.ts
|
|
990
1037
|
interface SchemaBuilder extends Knex.SchemaBuilder {
|
|
991
1038
|
[k: string]: any;
|
|
1039
|
+
/**
|
|
1040
|
+
* Retrieve all tables in the current database.
|
|
1041
|
+
*/
|
|
1042
|
+
tables(): Promise<string[]>;
|
|
1043
|
+
/**
|
|
1044
|
+
* Retrieve the table info for the given table, or all tables if no table is specified.
|
|
1045
|
+
*
|
|
1046
|
+
* @param table
|
|
1047
|
+
*/
|
|
1048
|
+
tableInfo(table?: string): Promise<Table | Table[]>;
|
|
1049
|
+
/**
|
|
1050
|
+
* Retrieve all columns in a given table, or all columns if no table is specified.
|
|
1051
|
+
*
|
|
1052
|
+
* @param table
|
|
1053
|
+
*/
|
|
1054
|
+
columns(table?: string): Promise<{
|
|
1055
|
+
table: string;
|
|
1056
|
+
column: string;
|
|
1057
|
+
}[]>;
|
|
1058
|
+
/**
|
|
1059
|
+
* Retrieve all columns from a given table. Returns all columns if table parameter is undefined.
|
|
1060
|
+
*
|
|
1061
|
+
* @param table
|
|
1062
|
+
* @param column
|
|
1063
|
+
*/
|
|
1064
|
+
columnInfo(table?: string, column?: string): Promise<Column[] | Column>;
|
|
1065
|
+
/**
|
|
1066
|
+
* Retrieve the primary key column for a given table.
|
|
1067
|
+
*
|
|
1068
|
+
* @param table
|
|
1069
|
+
*/
|
|
1070
|
+
primary(table: string): Promise<string>;
|
|
1071
|
+
/**
|
|
1072
|
+
* Retrieve all configured foreign key constraints
|
|
1073
|
+
*/
|
|
1074
|
+
foreignKeys(): Promise<ForeignKey>;
|
|
992
1075
|
}
|
|
993
1076
|
interface AsMethod<QB extends AnyQueryBuilder> {
|
|
994
1077
|
(alias: string): QB;
|
|
@@ -1119,7 +1202,7 @@ interface IQueryBuilder<M extends Model | Model$1 = Model, R = M[] | M> {
|
|
|
1119
1202
|
take(count: number): this;
|
|
1120
1203
|
limit(count: number): this;
|
|
1121
1204
|
offset(count: number): this;
|
|
1122
|
-
pluck<X extends Model = any>(column: string): Promise<
|
|
1205
|
+
pluck<X extends Model = any>(column: string): Promise<Array<X>>;
|
|
1123
1206
|
chunk(count: number, callback: (rows: M[]) => any): Promise<boolean>;
|
|
1124
1207
|
forPage(page: number, perPage?: number): this;
|
|
1125
1208
|
paginate<F extends IPaginatorParams>(page?: number, perPage?: number): Promise<IPaginator<M, F>>;
|
|
@@ -1132,10 +1215,13 @@ declare const Inference$1: {
|
|
|
1132
1215
|
declare class QueryBuilder<M extends Model = Model, R = M[] | M> extends Inference$1<M, R> {
|
|
1133
1216
|
model: M;
|
|
1134
1217
|
schema: SchemaBuilder;
|
|
1135
|
-
|
|
1218
|
+
connector: IQueryBuilder<M, R> & Knex.QueryBuilder & {
|
|
1219
|
+
_statements: any[];
|
|
1220
|
+
_single: any;
|
|
1221
|
+
} & Knex;
|
|
1136
1222
|
constructor(config: TConfig | null, connector: TFunction);
|
|
1137
1223
|
asProxy(): any;
|
|
1138
|
-
beginTransaction(): Promise<Knex.Transaction<any, any[]
|
|
1224
|
+
beginTransaction(): Promise<Knex.Transaction<any, any[]>>;
|
|
1139
1225
|
table<X extends M>(table: string): IQueryBuilder<X, R>;
|
|
1140
1226
|
transaction(callback?: TFunction): Promise<Knex.Transaction> | undefined;
|
|
1141
1227
|
find(id: string | number, columns?: string[]): Promise<any>;
|
|
@@ -1159,7 +1245,7 @@ declare class QueryBuilder<M extends Model = Model, R = M[] | M> extends Inferen
|
|
|
1159
1245
|
destroy(...args: Parameters<typeof (void 0).connector.destroy>): Promise<number>;
|
|
1160
1246
|
get _statements(): IStatement[] & any[];
|
|
1161
1247
|
get _single(): any;
|
|
1162
|
-
get from(): Knex.Table<any, any>;
|
|
1248
|
+
get from(): Knex.Table<any, any> & Knex.Table<any, any[]>;
|
|
1163
1249
|
}
|
|
1164
1250
|
declare namespace migration_d_exports {
|
|
1165
1251
|
export { IMigration, Migration, Migration as default };
|
|
@@ -1178,15 +1264,14 @@ declare class Migration extends Inference {
|
|
|
1178
1264
|
withinTransaction: boolean;
|
|
1179
1265
|
getConnection(): TBaseConfig['client'];
|
|
1180
1266
|
}
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
}
|
|
1267
|
+
//#endregion
|
|
1268
|
+
//#region src/migrations/migration-repository.d.ts
|
|
1184
1269
|
declare class MigrationRepository {
|
|
1185
1270
|
resolver: typeof arquebus;
|
|
1186
1271
|
table: string;
|
|
1187
1272
|
connection: TBaseConfig['client'] | null;
|
|
1188
1273
|
constructor(resolver: typeof arquebus, table: string);
|
|
1189
|
-
getRan(): Promise<
|
|
1274
|
+
getRan(): Promise<any[]>;
|
|
1190
1275
|
getMigrations(steps: number): Promise<any>;
|
|
1191
1276
|
getMigrationsByBatch(batch: number): Promise<any>;
|
|
1192
1277
|
getLast(): Promise<any>;
|
|
@@ -1203,12 +1288,13 @@ declare class MigrationRepository {
|
|
|
1203
1288
|
setSource(name: TBaseConfig['client']): void;
|
|
1204
1289
|
}
|
|
1205
1290
|
declare namespace migrator_d_exports {
|
|
1206
|
-
export { MigrationOptions, Migrator as default };
|
|
1291
|
+
export { MigrationOptions, Migrator, Migrator as default };
|
|
1207
1292
|
}
|
|
1208
1293
|
interface MigrationOptions {
|
|
1209
1294
|
pretend?: boolean;
|
|
1210
1295
|
step?: number;
|
|
1211
1296
|
batch?: number;
|
|
1297
|
+
quiet?: boolean;
|
|
1212
1298
|
}
|
|
1213
1299
|
declare class Migrator {
|
|
1214
1300
|
events: any;
|
|
@@ -1233,7 +1319,14 @@ declare class Migrator {
|
|
|
1233
1319
|
rollbackMigrations(migrations: {
|
|
1234
1320
|
migration: string;
|
|
1235
1321
|
}[], paths: string[], options: MigrationOptions): Promise<string[]>;
|
|
1236
|
-
reset(
|
|
1322
|
+
reset(paths: string[] | undefined, options: MigrationOptions, pretend?: boolean): Promise<string[]>;
|
|
1323
|
+
/**
|
|
1324
|
+
* Drop all tables and re-run all migrations
|
|
1325
|
+
*
|
|
1326
|
+
* @param paths
|
|
1327
|
+
* @param options
|
|
1328
|
+
*/
|
|
1329
|
+
fresh(paths: string[], options: MigrationOptions): Promise<void>;
|
|
1237
1330
|
resetMigrations(migrations: {
|
|
1238
1331
|
migration: string;
|
|
1239
1332
|
}[], paths: string[], pretend?: boolean): Promise<string[]>;
|
|
@@ -1253,7 +1346,7 @@ declare class Migrator {
|
|
|
1253
1346
|
deleteRepository(): void;
|
|
1254
1347
|
setOutput(output: boolean): this;
|
|
1255
1348
|
write(...args: any[]): void;
|
|
1256
|
-
|
|
1349
|
+
taskRunner(description: string, task: (() => Promise<any>) | (() => any)): Promise<void>;
|
|
1257
1350
|
}
|
|
1258
1351
|
//#endregion
|
|
1259
1352
|
//#region src/migrate.d.ts
|
|
@@ -1267,6 +1360,7 @@ interface MigrateOptions {
|
|
|
1267
1360
|
step?: number;
|
|
1268
1361
|
pretend?: boolean;
|
|
1269
1362
|
batch?: number;
|
|
1363
|
+
quiet?: boolean;
|
|
1270
1364
|
}
|
|
1271
1365
|
type TXBaseConfig<S = boolean> = (S extends true ? Partial<TBaseConfig> : TBaseConfig) & {
|
|
1272
1366
|
/**
|
|
@@ -1298,6 +1392,30 @@ declare class Migrate {
|
|
|
1298
1392
|
* @param destroyAll
|
|
1299
1393
|
*/
|
|
1300
1394
|
rollback(config: TXBaseConfig, options?: MigrateOptions, destroyAll?: boolean): Promise<void>;
|
|
1395
|
+
/**
|
|
1396
|
+
* Rollback all database migrations
|
|
1397
|
+
*
|
|
1398
|
+
* @param config
|
|
1399
|
+
* @param options
|
|
1400
|
+
* @param destroyAll
|
|
1401
|
+
*/
|
|
1402
|
+
reset(config: TXBaseConfig, options?: MigrateOptions, destroyAll?: boolean): Promise<void>;
|
|
1403
|
+
/**
|
|
1404
|
+
* Reset and re-run all migrations
|
|
1405
|
+
*
|
|
1406
|
+
* @param config
|
|
1407
|
+
* @param options
|
|
1408
|
+
* @param destroyAll
|
|
1409
|
+
*/
|
|
1410
|
+
refresh(config: TXBaseConfig, options?: MigrateOptions, destroyAll?: boolean): Promise<void>;
|
|
1411
|
+
/**
|
|
1412
|
+
* Drop all tables and re-run all migrations
|
|
1413
|
+
*
|
|
1414
|
+
* @param config
|
|
1415
|
+
* @param options
|
|
1416
|
+
* @param destroyAll
|
|
1417
|
+
*/
|
|
1418
|
+
fresh(config: TXBaseConfig, options?: MigrateOptions, destroyAll?: boolean): Promise<void>;
|
|
1301
1419
|
/**
|
|
1302
1420
|
* Prepares the database for migration
|
|
1303
1421
|
*
|
|
@@ -1324,9 +1442,8 @@ declare class Migrate {
|
|
|
1324
1442
|
migrator: Migrator;
|
|
1325
1443
|
}>;
|
|
1326
1444
|
}
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
}
|
|
1445
|
+
//#endregion
|
|
1446
|
+
//#region src/migrations/migration-creator.d.ts
|
|
1330
1447
|
declare class MigrationCreator {
|
|
1331
1448
|
private customStubPath?;
|
|
1332
1449
|
private type;
|
|
@@ -1360,4 +1477,4 @@ declare class MigrationCreator {
|
|
|
1360
1477
|
getDirname(meta: ImportMeta | null): string;
|
|
1361
1478
|
}
|
|
1362
1479
|
//#endregion
|
|
1363
|
-
export { Migrate, migration_d_exports as Migration,
|
|
1480
|
+
export { Migrate, migration_d_exports as Migration, MigrationCreator, MigrationRepository, migrator_d_exports as Migrator };
|