@h3ravel/arquebus 0.5.0 → 0.6.1
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 +20 -1
- package/bin/index.cjs +197 -145
- package/bin/index.js +178 -95
- package/bin/seeders-8GJzfIIN.js +3 -0
- package/bin/seeders-ByeSoCAQ.cjs +131 -0
- package/bin/seeders-CltigymO.js +79 -0
- package/bin/seeders-_xJ6VGVS.cjs +3 -0
- package/dist/browser/index.cjs +9 -9
- package/dist/browser/index.d.cts +8 -8
- package/dist/browser/index.d.ts +8 -8
- package/dist/browser/index.js +9 -9
- package/dist/index.cjs +252 -121
- package/dist/index.d.cts +41 -9
- package/dist/index.d.ts +41 -9
- package/dist/index.js +245 -119
- package/dist/inspector/index.cjs +105 -33
- package/dist/inspector/index.js +102 -33
- package/dist/migrations/index.cjs +144 -126
- package/dist/migrations/index.d.cts +11 -11
- package/dist/migrations/index.d.ts +11 -11
- package/dist/migrations/index.js +148 -130
- package/dist/migrations/stubs/migration-js.stub +1 -1
- package/dist/migrations/stubs/migration-ts.stub +1 -1
- package/dist/migrations/stubs/migration.create-js.stub +5 -5
- package/dist/migrations/stubs/migration.create-ts.stub +5 -5
- package/dist/migrations/stubs/migration.update-js.stub +2 -2
- package/dist/migrations/stubs/migration.update-ts.stub +3 -3
- package/dist/seeders/index.cjs +141 -0
- package/dist/seeders/index.d.cts +4766 -0
- package/dist/seeders/index.d.ts +4766 -0
- package/dist/seeders/index.js +118 -0
- package/dist/seeders/index.ts +3 -0
- package/dist/seeders/runner.ts +101 -0
- package/dist/seeders/seeder-creator.ts +42 -0
- package/dist/seeders/seeder.ts +10 -0
- package/dist/stubs/seeder-js.stub +13 -0
- package/dist/stubs/seeder-ts.stub +9 -0
- package/package.json +14 -3
- package/types/builder.ts +153 -80
- package/types/container.ts +79 -66
- package/types/generics.ts +75 -37
- package/types/modeling.ts +213 -158
- package/types/query-builder.ts +221 -191
- package/types/query-methods.ts +145 -109
- package/types/utils.ts +64 -56
|
@@ -45,16 +45,16 @@ let path = require("path");
|
|
|
45
45
|
path = __toESM(path);
|
|
46
46
|
let fs = require("fs");
|
|
47
47
|
fs = __toESM(fs);
|
|
48
|
-
let pluralize = require("pluralize");
|
|
49
|
-
pluralize = __toESM(pluralize);
|
|
50
|
-
let node_fs_promises = require("node:fs/promises");
|
|
51
|
-
node_fs_promises = __toESM(node_fs_promises);
|
|
52
48
|
let fs_promises = require("fs/promises");
|
|
53
49
|
fs_promises = __toESM(fs_promises);
|
|
54
50
|
let escalade_sync = require("escalade/sync");
|
|
55
51
|
escalade_sync = __toESM(escalade_sync);
|
|
56
52
|
let resolve_from = require("resolve-from");
|
|
57
53
|
resolve_from = __toESM(resolve_from);
|
|
54
|
+
let pluralize = require("pluralize");
|
|
55
|
+
pluralize = __toESM(pluralize);
|
|
56
|
+
let node_fs_promises = require("node:fs/promises");
|
|
57
|
+
node_fs_promises = __toESM(node_fs_promises);
|
|
58
58
|
let node_path = require("node:path");
|
|
59
59
|
node_path = __toESM(node_path);
|
|
60
60
|
let node_url = require("node:url");
|
|
@@ -1449,7 +1449,7 @@ var InvalidArgumentError = class extends BaseError {};
|
|
|
1449
1449
|
var mixin_exports = /* @__PURE__ */ __export({ compose: () => compose$1 });
|
|
1450
1450
|
/**
|
|
1451
1451
|
* Compose function that merges multiple classes and mixins
|
|
1452
|
-
*
|
|
1452
|
+
*
|
|
1453
1453
|
* @example
|
|
1454
1454
|
* const SomePlugin = <TBase extends new (...args: any[]) => TGeneric> (Base: TBase) => {
|
|
1455
1455
|
* return class extends Base {
|
|
@@ -1486,10 +1486,10 @@ var mixin_exports = /* @__PURE__ */ __export({ compose: () => compose$1 });
|
|
|
1486
1486
|
* console.log(user.pluginMethod('w')) // "plugin"
|
|
1487
1487
|
* console.log(user.pluginMethod()) // "plugin"
|
|
1488
1488
|
* console.log(user.relationPosts()) // "hasMany Posts"
|
|
1489
|
-
*
|
|
1490
|
-
* @param Base
|
|
1491
|
-
* @param mixins
|
|
1492
|
-
* @returns
|
|
1489
|
+
*
|
|
1490
|
+
* @param Base
|
|
1491
|
+
* @param mixins
|
|
1492
|
+
* @returns
|
|
1493
1493
|
*/
|
|
1494
1494
|
function compose$1(Base, ...mixins) {
|
|
1495
1495
|
/**
|
|
@@ -1543,10 +1543,10 @@ const getSetterMethod = (attr) => {
|
|
|
1543
1543
|
};
|
|
1544
1544
|
/**
|
|
1545
1545
|
* Tap into a model a collection instance
|
|
1546
|
-
*
|
|
1547
|
-
* @param instance
|
|
1548
|
-
* @param callback
|
|
1549
|
-
* @returns
|
|
1546
|
+
*
|
|
1547
|
+
* @param instance
|
|
1548
|
+
* @param callback
|
|
1549
|
+
* @returns
|
|
1550
1550
|
*/
|
|
1551
1551
|
const tap = (instance, callback) => {
|
|
1552
1552
|
const result = callback(instance);
|
|
@@ -2997,6 +2997,59 @@ var QueryBuilder = class QueryBuilder extends Inference$2 {
|
|
|
2997
2997
|
};
|
|
2998
2998
|
var query_builder_default = QueryBuilder;
|
|
2999
2999
|
|
|
3000
|
+
//#endregion
|
|
3001
|
+
//#region src/cli/utils.ts
|
|
3002
|
+
const join = path.default.join;
|
|
3003
|
+
var Utils = class {
|
|
3004
|
+
/**
|
|
3005
|
+
* Wraps text with chalk
|
|
3006
|
+
*
|
|
3007
|
+
* @param txt
|
|
3008
|
+
* @param color
|
|
3009
|
+
* @returns
|
|
3010
|
+
*/
|
|
3011
|
+
static textFormat(txt, color) {
|
|
3012
|
+
return String(txt).split(":").map((e, i, a) => i == 0 && a.length > 1 ? color(" " + e + ": ") : e).join("");
|
|
3013
|
+
}
|
|
3014
|
+
static findModulePkg(moduleId, cwd) {
|
|
3015
|
+
const parts = moduleId.replace(/\\/g, "/").split("/");
|
|
3016
|
+
let packageName = "";
|
|
3017
|
+
if (parts.length > 0 && parts[0][0] === "@") packageName += parts.shift() + "/";
|
|
3018
|
+
packageName += parts.shift();
|
|
3019
|
+
const packageJson = path.default.join(packageName, "package.json");
|
|
3020
|
+
const resolved = resolve_from.default.silent(cwd ?? process.cwd(), packageJson);
|
|
3021
|
+
if (!resolved) return;
|
|
3022
|
+
return path.default.join(path.default.dirname(resolved), parts.join("/"));
|
|
3023
|
+
}
|
|
3024
|
+
static async getMigrationPaths(cwd, migrator, defaultPath, path$7) {
|
|
3025
|
+
if (path$7) return [join(cwd, path$7)];
|
|
3026
|
+
return [...migrator.getPaths(), join(cwd, defaultPath)];
|
|
3027
|
+
}
|
|
3028
|
+
/**
|
|
3029
|
+
* Check if file exists
|
|
3030
|
+
*
|
|
3031
|
+
* @param path
|
|
3032
|
+
* @returns
|
|
3033
|
+
*/
|
|
3034
|
+
static async fileExists(path$7) {
|
|
3035
|
+
try {
|
|
3036
|
+
await (0, fs_promises.access)(path$7);
|
|
3037
|
+
return true;
|
|
3038
|
+
} catch {
|
|
3039
|
+
return false;
|
|
3040
|
+
}
|
|
3041
|
+
}
|
|
3042
|
+
static findUpConfig(cwd, name, extensions) {
|
|
3043
|
+
return (0, escalade_sync.default)(cwd, (_dir, names) => {
|
|
3044
|
+
for (const ext of extensions) {
|
|
3045
|
+
const filename = `${name}.${ext}`;
|
|
3046
|
+
if (names.includes(filename)) return filename;
|
|
3047
|
+
}
|
|
3048
|
+
return false;
|
|
3049
|
+
});
|
|
3050
|
+
}
|
|
3051
|
+
};
|
|
3052
|
+
|
|
3000
3053
|
//#endregion
|
|
3001
3054
|
//#region src/arquebus.ts
|
|
3002
3055
|
var arquebus = class arquebus {
|
|
@@ -3018,22 +3071,22 @@ var arquebus = class arquebus {
|
|
|
3018
3071
|
return this.instance;
|
|
3019
3072
|
}
|
|
3020
3073
|
/**
|
|
3021
|
-
* Initialize a new database connection
|
|
3022
|
-
*
|
|
3023
|
-
* @returns
|
|
3074
|
+
* Initialize a new database connection
|
|
3075
|
+
*
|
|
3076
|
+
* @returns
|
|
3024
3077
|
*/
|
|
3025
3078
|
static fire(connection = null) {
|
|
3026
3079
|
return this.getInstance().getConnection(connection);
|
|
3027
3080
|
}
|
|
3028
3081
|
/**
|
|
3029
|
-
* Initialize a new database connection
|
|
3030
|
-
*
|
|
3082
|
+
* Initialize a new database connection
|
|
3083
|
+
*
|
|
3031
3084
|
* This is an alias of `arquebus.fire()` and will be removed in the future
|
|
3032
|
-
*
|
|
3085
|
+
*
|
|
3033
3086
|
* @deprecated since version 0.3.0
|
|
3034
3087
|
* @alias fire
|
|
3035
|
-
*
|
|
3036
|
-
* @returns
|
|
3088
|
+
*
|
|
3089
|
+
* @returns
|
|
3037
3090
|
*/
|
|
3038
3091
|
static connection(connection = null) {
|
|
3039
3092
|
return this.fire(connection);
|
|
@@ -3070,11 +3123,12 @@ var arquebus = class arquebus {
|
|
|
3070
3123
|
}
|
|
3071
3124
|
getConnection(name = null) {
|
|
3072
3125
|
name = name || "default";
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
this.
|
|
3126
|
+
const resolvedName = this.connections[name] ? name : "default";
|
|
3127
|
+
if (this.manager[resolvedName] === void 0) {
|
|
3128
|
+
const queryBuilder = new query_builder_default(this.connections[resolvedName], arquebus.getConnectorFactory());
|
|
3129
|
+
this.manager[resolvedName] = queryBuilder;
|
|
3076
3130
|
}
|
|
3077
|
-
return this.manager[
|
|
3131
|
+
return this.manager[resolvedName];
|
|
3078
3132
|
}
|
|
3079
3133
|
addConnection(config, name = "default") {
|
|
3080
3134
|
this.connections[name] = {
|
|
@@ -3091,13 +3145,13 @@ var arquebus = class arquebus {
|
|
|
3091
3145
|
}
|
|
3092
3146
|
/**
|
|
3093
3147
|
* Autoload the config file
|
|
3094
|
-
*
|
|
3095
|
-
* @param addConnection
|
|
3148
|
+
*
|
|
3149
|
+
* @param addConnection
|
|
3096
3150
|
* @default true
|
|
3097
|
-
* If set to `false` we will no attempt add the connection, we
|
|
3151
|
+
* If set to `false` we will no attempt add the connection, we
|
|
3098
3152
|
* will just go ahead and return the config
|
|
3099
|
-
*
|
|
3100
|
-
* @returns
|
|
3153
|
+
*
|
|
3154
|
+
* @returns
|
|
3101
3155
|
*/
|
|
3102
3156
|
static async autoLoad(addConnection = true) {
|
|
3103
3157
|
let config;
|
|
@@ -3114,6 +3168,23 @@ var arquebus = class arquebus {
|
|
|
3114
3168
|
if (addConnection) instance.addConnection(config, config.client);
|
|
3115
3169
|
return config;
|
|
3116
3170
|
} else throw new Error("arquebus.config.ts found in production without build step");
|
|
3171
|
+
const candidateDirs = [
|
|
3172
|
+
process.cwd(),
|
|
3173
|
+
path.default.join(process.cwd(), "test", "cli"),
|
|
3174
|
+
path.default.join(process.cwd(), "test")
|
|
3175
|
+
];
|
|
3176
|
+
for (const dir of candidateDirs) {
|
|
3177
|
+
const found = Utils.findUpConfig(dir, "arquebus.config", [
|
|
3178
|
+
"js",
|
|
3179
|
+
"ts",
|
|
3180
|
+
"cjs"
|
|
3181
|
+
]);
|
|
3182
|
+
if (found) if (!found.endsWith(".ts") || process.env.NODE_ENV !== "production") {
|
|
3183
|
+
config = (await import(found)).default;
|
|
3184
|
+
if (addConnection) instance.addConnection(config, config.client);
|
|
3185
|
+
return config;
|
|
3186
|
+
} else throw new Error("arquebus.config.ts found in production without build step");
|
|
3187
|
+
}
|
|
3117
3188
|
return {};
|
|
3118
3189
|
}
|
|
3119
3190
|
beginTransaction(connection = null) {
|
|
@@ -5083,9 +5154,9 @@ var Migrator = class {
|
|
|
5083
5154
|
}
|
|
5084
5155
|
/**
|
|
5085
5156
|
* Drop all tables and re-run all migrations
|
|
5086
|
-
*
|
|
5087
|
-
* @param paths
|
|
5088
|
-
* @param options
|
|
5157
|
+
*
|
|
5158
|
+
* @param paths
|
|
5159
|
+
* @param options
|
|
5089
5160
|
*/
|
|
5090
5161
|
async fresh(paths, options) {
|
|
5091
5162
|
/** Initialise connections */
|
|
@@ -5177,59 +5248,6 @@ var Migrator = class {
|
|
|
5177
5248
|
};
|
|
5178
5249
|
var migrator_default = Migrator;
|
|
5179
5250
|
|
|
5180
|
-
//#endregion
|
|
5181
|
-
//#region src/cli/utils.ts
|
|
5182
|
-
const join = path.default.join;
|
|
5183
|
-
var Utils = class {
|
|
5184
|
-
/**
|
|
5185
|
-
* Wraps text with chalk
|
|
5186
|
-
*
|
|
5187
|
-
* @param txt
|
|
5188
|
-
* @param color
|
|
5189
|
-
* @returns
|
|
5190
|
-
*/
|
|
5191
|
-
static textFormat(txt, color) {
|
|
5192
|
-
return String(txt).split(":").map((e, i, a) => i == 0 && a.length > 1 ? color(" " + e + ": ") : e).join("");
|
|
5193
|
-
}
|
|
5194
|
-
static findModulePkg(moduleId, cwd) {
|
|
5195
|
-
const parts = moduleId.replace(/\\/g, "/").split("/");
|
|
5196
|
-
let packageName = "";
|
|
5197
|
-
if (parts.length > 0 && parts[0][0] === "@") packageName += parts.shift() + "/";
|
|
5198
|
-
packageName += parts.shift();
|
|
5199
|
-
const packageJson = path.default.join(packageName, "package.json");
|
|
5200
|
-
const resolved = resolve_from.default.silent(cwd ?? process.cwd(), packageJson);
|
|
5201
|
-
if (!resolved) return;
|
|
5202
|
-
return path.default.join(path.default.dirname(resolved), parts.join("/"));
|
|
5203
|
-
}
|
|
5204
|
-
static async getMigrationPaths(cwd, migrator, defaultPath, path$5) {
|
|
5205
|
-
if (path$5) return [join(cwd, path$5)];
|
|
5206
|
-
return [...migrator.getPaths(), join(cwd, defaultPath)];
|
|
5207
|
-
}
|
|
5208
|
-
/**
|
|
5209
|
-
* Check if file exists
|
|
5210
|
-
*
|
|
5211
|
-
* @param path
|
|
5212
|
-
* @returns
|
|
5213
|
-
*/
|
|
5214
|
-
static async fileExists(path$5) {
|
|
5215
|
-
try {
|
|
5216
|
-
await (0, fs_promises.access)(path$5);
|
|
5217
|
-
return true;
|
|
5218
|
-
} catch {
|
|
5219
|
-
return false;
|
|
5220
|
-
}
|
|
5221
|
-
}
|
|
5222
|
-
static findUpConfig(cwd, name, extensions) {
|
|
5223
|
-
return (0, escalade_sync.default)(cwd, (_dir, names) => {
|
|
5224
|
-
for (const ext of extensions) {
|
|
5225
|
-
const filename = `${name}.${ext}`;
|
|
5226
|
-
if (names.includes(filename)) return filename;
|
|
5227
|
-
}
|
|
5228
|
-
return false;
|
|
5229
|
-
});
|
|
5230
|
-
}
|
|
5231
|
-
};
|
|
5232
|
-
|
|
5233
5251
|
//#endregion
|
|
5234
5252
|
//#region src/migrate.ts
|
|
5235
5253
|
var Migrate = class {
|
|
@@ -5241,10 +5259,10 @@ var Migrate = class {
|
|
|
5241
5259
|
}
|
|
5242
5260
|
/**
|
|
5243
5261
|
* Runs all pending migrations
|
|
5244
|
-
*
|
|
5245
|
-
* @param config
|
|
5246
|
-
* @param options
|
|
5247
|
-
* @param destroyAll
|
|
5262
|
+
*
|
|
5263
|
+
* @param config
|
|
5264
|
+
* @param options
|
|
5265
|
+
* @param destroyAll
|
|
5248
5266
|
*/
|
|
5249
5267
|
async run(config, options = {}, destroyAll = false) {
|
|
5250
5268
|
const { arquebus: arquebus$1, migrator } = await this.setupConnection(config);
|
|
@@ -5258,10 +5276,10 @@ var Migrate = class {
|
|
|
5258
5276
|
}
|
|
5259
5277
|
/**
|
|
5260
5278
|
* Rollback the last migration
|
|
5261
|
-
*
|
|
5262
|
-
* @param config
|
|
5263
|
-
* @param options
|
|
5264
|
-
* @param destroyAll
|
|
5279
|
+
*
|
|
5280
|
+
* @param config
|
|
5281
|
+
* @param options
|
|
5282
|
+
* @param destroyAll
|
|
5265
5283
|
*/
|
|
5266
5284
|
async rollback(config, options = {}, destroyAll = false) {
|
|
5267
5285
|
const { arquebus: arquebus$1, migrator } = await this.setupConnection(config);
|
|
@@ -5275,10 +5293,10 @@ var Migrate = class {
|
|
|
5275
5293
|
}
|
|
5276
5294
|
/**
|
|
5277
5295
|
* Rollback all database migrations
|
|
5278
|
-
*
|
|
5279
|
-
* @param config
|
|
5280
|
-
* @param options
|
|
5281
|
-
* @param destroyAll
|
|
5296
|
+
*
|
|
5297
|
+
* @param config
|
|
5298
|
+
* @param options
|
|
5299
|
+
* @param destroyAll
|
|
5282
5300
|
*/
|
|
5283
5301
|
async reset(config, options = {}, destroyAll = false) {
|
|
5284
5302
|
const { arquebus: arquebus$1, migrator } = await this.setupConnection(config);
|
|
@@ -5293,10 +5311,10 @@ var Migrate = class {
|
|
|
5293
5311
|
}
|
|
5294
5312
|
/**
|
|
5295
5313
|
* Reset and re-run all migrations
|
|
5296
|
-
*
|
|
5297
|
-
* @param config
|
|
5298
|
-
* @param options
|
|
5299
|
-
* @param destroyAll
|
|
5314
|
+
*
|
|
5315
|
+
* @param config
|
|
5316
|
+
* @param options
|
|
5317
|
+
* @param destroyAll
|
|
5300
5318
|
*/
|
|
5301
5319
|
async refresh(config, options = {}, destroyAll = false) {
|
|
5302
5320
|
await this.reset(config, Object.assign({}, options, { quiet: true }), false);
|
|
@@ -5305,10 +5323,10 @@ var Migrate = class {
|
|
|
5305
5323
|
}
|
|
5306
5324
|
/**
|
|
5307
5325
|
* Drop all tables and re-run all migrations
|
|
5308
|
-
*
|
|
5309
|
-
* @param config
|
|
5310
|
-
* @param options
|
|
5311
|
-
* @param destroyAll
|
|
5326
|
+
*
|
|
5327
|
+
* @param config
|
|
5328
|
+
* @param options
|
|
5329
|
+
* @param destroyAll
|
|
5312
5330
|
*/
|
|
5313
5331
|
async fresh(config, options = {}, destroyAll = false) {
|
|
5314
5332
|
const { arquebus: arquebus$1, migrator } = await this.setupConnection(config);
|
|
@@ -5318,8 +5336,8 @@ var Migrate = class {
|
|
|
5318
5336
|
}
|
|
5319
5337
|
/**
|
|
5320
5338
|
* Prepares the database for migration
|
|
5321
|
-
*
|
|
5322
|
-
* @param migrator
|
|
5339
|
+
*
|
|
5340
|
+
* @param migrator
|
|
5323
5341
|
*/
|
|
5324
5342
|
async prepareDatabase(migrator) {
|
|
5325
5343
|
if (!await migrator.repositoryExists()) {
|
|
@@ -5331,11 +5349,11 @@ var Migrate = class {
|
|
|
5331
5349
|
}
|
|
5332
5350
|
/**
|
|
5333
5351
|
* Check the status of available migrations
|
|
5334
|
-
*
|
|
5335
|
-
* @param config
|
|
5336
|
-
* @param options
|
|
5337
|
-
* @param destroyAll
|
|
5338
|
-
* @returns
|
|
5352
|
+
*
|
|
5353
|
+
* @param config
|
|
5354
|
+
* @param options
|
|
5355
|
+
* @param destroyAll
|
|
5356
|
+
* @returns
|
|
5339
5357
|
*/
|
|
5340
5358
|
async status(config, options = {}, destroyAll = false) {
|
|
5341
5359
|
const { arquebus: arquebus$1, migrator } = await this.setupConnection(config);
|
|
@@ -5362,9 +5380,9 @@ var Migrate = class {
|
|
|
5362
5380
|
}
|
|
5363
5381
|
/**
|
|
5364
5382
|
* Setup the database connection
|
|
5365
|
-
*
|
|
5366
|
-
* @param config
|
|
5367
|
-
* @returns
|
|
5383
|
+
*
|
|
5384
|
+
* @param config
|
|
5385
|
+
* @returns
|
|
5368
5386
|
*/
|
|
5369
5387
|
async setupConnection(config) {
|
|
5370
5388
|
var _config$migrations;
|
|
@@ -5394,12 +5412,12 @@ var MigrationCreator = class {
|
|
|
5394
5412
|
}
|
|
5395
5413
|
/**
|
|
5396
5414
|
* Create a new migration file
|
|
5397
|
-
*
|
|
5398
|
-
* @param name
|
|
5399
|
-
* @param dir
|
|
5400
|
-
* @param table
|
|
5401
|
-
* @param create
|
|
5402
|
-
* @returns
|
|
5415
|
+
*
|
|
5416
|
+
* @param name
|
|
5417
|
+
* @param dir
|
|
5418
|
+
* @param table
|
|
5419
|
+
* @param create
|
|
5420
|
+
* @returns
|
|
5403
5421
|
*/
|
|
5404
5422
|
async create(name, dir, table, create = false) {
|
|
5405
5423
|
const stub = await this.getStub(table, create);
|
|
@@ -5411,9 +5429,9 @@ var MigrationCreator = class {
|
|
|
5411
5429
|
}
|
|
5412
5430
|
/**
|
|
5413
5431
|
* Publish migrations from third party vendors
|
|
5414
|
-
*
|
|
5415
|
-
* @param dir
|
|
5416
|
-
* @param callback
|
|
5432
|
+
*
|
|
5433
|
+
* @param dir
|
|
5434
|
+
* @param callback
|
|
5417
5435
|
*/
|
|
5418
5436
|
async publish(dir, callback) {
|
|
5419
5437
|
const migrationFiles = await (0, node_fs_promises.readdir)(this.customStubPath ?? "");
|
|
@@ -5441,7 +5459,7 @@ var MigrationCreator = class {
|
|
|
5441
5459
|
return await (0, node_fs_promises.readFile)(stub, "utf-8");
|
|
5442
5460
|
}
|
|
5443
5461
|
populateStub(stub, table) {
|
|
5444
|
-
if (table
|
|
5462
|
+
if (table) stub = stub.replace(/DummyTable|{{\s*table\s*}}/g, table);
|
|
5445
5463
|
return stub;
|
|
5446
5464
|
}
|
|
5447
5465
|
getClassName(name) {
|
|
@@ -112,7 +112,7 @@ declare class Builder<M extends Model = Model, R = IModel | ICollection<M>> exte
|
|
|
112
112
|
enforceOrderBy(this: any): void;
|
|
113
113
|
clone(this: any): any;
|
|
114
114
|
forPage(this: any, page: number, perPage?: number): any;
|
|
115
|
-
insert(...args: Parameters<typeof
|
|
115
|
+
insert(...args: Parameters<typeof this.query.insert>): Promise<any>;
|
|
116
116
|
update<T extends TGeneric>(values: T): Promise<any>;
|
|
117
117
|
increment(column: string, amount?: number, extra?: {}): Promise<any>;
|
|
118
118
|
decrement(column: string, amount?: number, extra?: {}): Promise<any>;
|
|
@@ -219,7 +219,7 @@ declare class Relation$1 {
|
|
|
219
219
|
getEager(): any;
|
|
220
220
|
get(columns?: string | string[]): Promise<any>;
|
|
221
221
|
first(columns?: string[]): Promise<any>;
|
|
222
|
-
paginate(...args:
|
|
222
|
+
paginate(...args: unknown[]): Promise<any>;
|
|
223
223
|
count(...args: any[]): Promise<any>;
|
|
224
224
|
toSql(): string;
|
|
225
225
|
addConstraints(): void;
|
|
@@ -261,7 +261,7 @@ declare class arquebus<M extends Model = Model> {
|
|
|
261
261
|
static getConnectorFactory(): typeof Knex$1;
|
|
262
262
|
static addConnection(config: TConfig | TBaseConfig, name?: string): void;
|
|
263
263
|
static beginTransaction(connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]>>;
|
|
264
|
-
static transaction(callback: TFunction, connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]>> | undefined;
|
|
264
|
+
static transaction<A, R>(callback: TFunction<A[], R>, connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]>> | undefined;
|
|
265
265
|
static table(name: string, connection?: null): IQueryBuilder<Model, Model | Model[]>;
|
|
266
266
|
static schema(connection?: null): SchemaBuilder;
|
|
267
267
|
static destroyAll(): Promise<void>;
|
|
@@ -4081,7 +4081,7 @@ type ReturnTypeOfMethod<T, K extends keyof T> = T[K] extends ((...args: any[]) =
|
|
|
4081
4081
|
type SnakeToCamelCase<S extends string> = S extends `${infer T}_${infer U}` ? `${T}${Capitalize<SnakeToCamelCase<U>>}` : S;
|
|
4082
4082
|
type CamelToSnakeCase<S extends string> = S extends `${infer T}${infer U}` ? U extends Uncapitalize<U> ? `${Uncapitalize<T>}${CamelToSnakeCase<U>}` : `${Uncapitalize<T>}_${CamelToSnakeCase<U>}` : S;
|
|
4083
4083
|
type FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends ((...args: any[]) => any) ? K : never }[keyof T];
|
|
4084
|
-
type RelationNames<T> = FunctionPropertyNames<T> extends infer R ? R extends `relation${infer P}` ? P extends
|
|
4084
|
+
type RelationNames<T> = FunctionPropertyNames<T> extends infer R ? R extends `relation${infer P}` ? P extends 'sToData' | 'loaded' ? never : CamelToSnakeCase<P> : never : never;
|
|
4085
4085
|
type MixinConstructor<T = TGeneric> = new (...args: any[]) => T;
|
|
4086
4086
|
//#endregion
|
|
4087
4087
|
//#region src/browser/collection.d.ts
|
|
@@ -4718,7 +4718,7 @@ declare class QueryBuilder<M extends Model = Model, R = M[] | M> extends Inferen
|
|
|
4718
4718
|
chunk(count: number, callback: TFunction): Promise<boolean>;
|
|
4719
4719
|
paginate<F extends IPaginatorParams>(this: any, page: number | undefined, perPage: number | undefined, _pageName: string, _page: number): Promise<IPaginator<M, F>>;
|
|
4720
4720
|
forPage(this: any, page?: number, perPage?: number): any;
|
|
4721
|
-
toSQL(...args:
|
|
4721
|
+
toSQL(...args: any[]): Knex.Sql;
|
|
4722
4722
|
count(column: string): Promise<number>;
|
|
4723
4723
|
min(column: string): Promise<number>;
|
|
4724
4724
|
max(column: string): Promise<number>;
|
|
@@ -4726,9 +4726,9 @@ declare class QueryBuilder<M extends Model = Model, R = M[] | M> extends Inferen
|
|
|
4726
4726
|
avg(column: string): Promise<number>;
|
|
4727
4727
|
clone(): IQueryBuilder<M, R>;
|
|
4728
4728
|
delete(): Promise<number | boolean>;
|
|
4729
|
-
insert(...args: Parameters<typeof
|
|
4730
|
-
update(...args: Parameters<typeof
|
|
4731
|
-
destroy(...args: Parameters<typeof
|
|
4729
|
+
insert(...args: Parameters<typeof this.connector.insert>): Promise<unknown>;
|
|
4730
|
+
update(...args: Parameters<typeof this.connector.update>): Promise<number>;
|
|
4731
|
+
destroy(...args: Parameters<typeof this.connector.destroy>): Promise<number>;
|
|
4732
4732
|
get _statements(): IStatement[] & any[];
|
|
4733
4733
|
get _single(): any;
|
|
4734
4734
|
get from(): Knex.Table<any, any> & Knex.Table<any, any[]>;
|
|
@@ -4943,7 +4943,7 @@ declare class MigrationCreator {
|
|
|
4943
4943
|
* @param create
|
|
4944
4944
|
* @returns
|
|
4945
4945
|
*/
|
|
4946
|
-
create(name: string, dir: string, table
|
|
4946
|
+
create(name: string, dir: string, table?: string, create?: boolean): Promise<string>;
|
|
4947
4947
|
/**
|
|
4948
4948
|
* Publish migrations from third party vendors
|
|
4949
4949
|
*
|
|
@@ -4952,10 +4952,10 @@ declare class MigrationCreator {
|
|
|
4952
4952
|
*/
|
|
4953
4953
|
publish(dir: string, callback?: (name: string, source: string, dest: string) => void): Promise<void>;
|
|
4954
4954
|
getStub(table?: string, create?: boolean): Promise<string>;
|
|
4955
|
-
populateStub(stub: string, table
|
|
4955
|
+
populateStub(stub: string, table?: string): string;
|
|
4956
4956
|
getClassName(name: string): string;
|
|
4957
4957
|
getPath(name: string, dir: string): string;
|
|
4958
|
-
firePostCreateHooks(table: string, filePath: string): Promise<void>;
|
|
4958
|
+
firePostCreateHooks(table: string | undefined, filePath: string): Promise<void>;
|
|
4959
4959
|
afterCreate(callback: TFunction): void;
|
|
4960
4960
|
ensureDirectoryExists(dir: string): Promise<void>;
|
|
4961
4961
|
stubPath(stub?: string): string;
|
|
@@ -109,7 +109,7 @@ declare class Builder<M extends Model = Model, R = IModel | ICollection<M>> exte
|
|
|
109
109
|
enforceOrderBy(this: any): void;
|
|
110
110
|
clone(this: any): any;
|
|
111
111
|
forPage(this: any, page: number, perPage?: number): any;
|
|
112
|
-
insert(...args: Parameters<typeof
|
|
112
|
+
insert(...args: Parameters<typeof this.query.insert>): Promise<any>;
|
|
113
113
|
update<T extends TGeneric>(values: T): Promise<any>;
|
|
114
114
|
increment(column: string, amount?: number, extra?: {}): Promise<any>;
|
|
115
115
|
decrement(column: string, amount?: number, extra?: {}): Promise<any>;
|
|
@@ -216,7 +216,7 @@ declare class Relation$1 {
|
|
|
216
216
|
getEager(): any;
|
|
217
217
|
get(columns?: string | string[]): Promise<any>;
|
|
218
218
|
first(columns?: string[]): Promise<any>;
|
|
219
|
-
paginate(...args:
|
|
219
|
+
paginate(...args: unknown[]): Promise<any>;
|
|
220
220
|
count(...args: any[]): Promise<any>;
|
|
221
221
|
toSql(): string;
|
|
222
222
|
addConstraints(): void;
|
|
@@ -258,7 +258,7 @@ declare class arquebus<M extends Model = Model> {
|
|
|
258
258
|
static getConnectorFactory(): typeof Knex$1;
|
|
259
259
|
static addConnection(config: TConfig | TBaseConfig, name?: string): void;
|
|
260
260
|
static beginTransaction(connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]>>;
|
|
261
|
-
static transaction(callback: TFunction, connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]>> | undefined;
|
|
261
|
+
static transaction<A, R>(callback: TFunction<A[], R>, connection?: null): Promise<Knex$1.Knex.Transaction<any, any[]>> | undefined;
|
|
262
262
|
static table(name: string, connection?: null): IQueryBuilder<Model, Model | Model[]>;
|
|
263
263
|
static schema(connection?: null): SchemaBuilder;
|
|
264
264
|
static destroyAll(): Promise<void>;
|
|
@@ -4078,7 +4078,7 @@ type ReturnTypeOfMethod<T, K extends keyof T> = T[K] extends ((...args: any[]) =
|
|
|
4078
4078
|
type SnakeToCamelCase<S extends string> = S extends `${infer T}_${infer U}` ? `${T}${Capitalize<SnakeToCamelCase<U>>}` : S;
|
|
4079
4079
|
type CamelToSnakeCase<S extends string> = S extends `${infer T}${infer U}` ? U extends Uncapitalize<U> ? `${Uncapitalize<T>}${CamelToSnakeCase<U>}` : `${Uncapitalize<T>}_${CamelToSnakeCase<U>}` : S;
|
|
4080
4080
|
type FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends ((...args: any[]) => any) ? K : never }[keyof T];
|
|
4081
|
-
type RelationNames<T> = FunctionPropertyNames<T> extends infer R ? R extends `relation${infer P}` ? P extends
|
|
4081
|
+
type RelationNames<T> = FunctionPropertyNames<T> extends infer R ? R extends `relation${infer P}` ? P extends 'sToData' | 'loaded' ? never : CamelToSnakeCase<P> : never : never;
|
|
4082
4082
|
type MixinConstructor<T = TGeneric> = new (...args: any[]) => T;
|
|
4083
4083
|
//#endregion
|
|
4084
4084
|
//#region src/browser/collection.d.ts
|
|
@@ -4715,7 +4715,7 @@ declare class QueryBuilder<M extends Model = Model, R = M[] | M> extends Inferen
|
|
|
4715
4715
|
chunk(count: number, callback: TFunction): Promise<boolean>;
|
|
4716
4716
|
paginate<F extends IPaginatorParams>(this: any, page: number | undefined, perPage: number | undefined, _pageName: string, _page: number): Promise<IPaginator<M, F>>;
|
|
4717
4717
|
forPage(this: any, page?: number, perPage?: number): any;
|
|
4718
|
-
toSQL(...args:
|
|
4718
|
+
toSQL(...args: any[]): Knex.Sql;
|
|
4719
4719
|
count(column: string): Promise<number>;
|
|
4720
4720
|
min(column: string): Promise<number>;
|
|
4721
4721
|
max(column: string): Promise<number>;
|
|
@@ -4723,9 +4723,9 @@ declare class QueryBuilder<M extends Model = Model, R = M[] | M> extends Inferen
|
|
|
4723
4723
|
avg(column: string): Promise<number>;
|
|
4724
4724
|
clone(): IQueryBuilder<M, R>;
|
|
4725
4725
|
delete(): Promise<number | boolean>;
|
|
4726
|
-
insert(...args: Parameters<typeof
|
|
4727
|
-
update(...args: Parameters<typeof
|
|
4728
|
-
destroy(...args: Parameters<typeof
|
|
4726
|
+
insert(...args: Parameters<typeof this.connector.insert>): Promise<unknown>;
|
|
4727
|
+
update(...args: Parameters<typeof this.connector.update>): Promise<number>;
|
|
4728
|
+
destroy(...args: Parameters<typeof this.connector.destroy>): Promise<number>;
|
|
4729
4729
|
get _statements(): IStatement[] & any[];
|
|
4730
4730
|
get _single(): any;
|
|
4731
4731
|
get from(): Knex.Table<any, any> & Knex.Table<any, any[]>;
|
|
@@ -4940,7 +4940,7 @@ declare class MigrationCreator {
|
|
|
4940
4940
|
* @param create
|
|
4941
4941
|
* @returns
|
|
4942
4942
|
*/
|
|
4943
|
-
create(name: string, dir: string, table
|
|
4943
|
+
create(name: string, dir: string, table?: string, create?: boolean): Promise<string>;
|
|
4944
4944
|
/**
|
|
4945
4945
|
* Publish migrations from third party vendors
|
|
4946
4946
|
*
|
|
@@ -4949,10 +4949,10 @@ declare class MigrationCreator {
|
|
|
4949
4949
|
*/
|
|
4950
4950
|
publish(dir: string, callback?: (name: string, source: string, dest: string) => void): Promise<void>;
|
|
4951
4951
|
getStub(table?: string, create?: boolean): Promise<string>;
|
|
4952
|
-
populateStub(stub: string, table
|
|
4952
|
+
populateStub(stub: string, table?: string): string;
|
|
4953
4953
|
getClassName(name: string): string;
|
|
4954
4954
|
getPath(name: string, dir: string): string;
|
|
4955
|
-
firePostCreateHooks(table: string, filePath: string): Promise<void>;
|
|
4955
|
+
firePostCreateHooks(table: string | undefined, filePath: string): Promise<void>;
|
|
4956
4956
|
afterCreate(callback: TFunction): void;
|
|
4957
4957
|
ensureDirectoryExists(dir: string): Promise<void>;
|
|
4958
4958
|
stubPath(stub?: string): string;
|