@h3ravel/arquebus 0.6.6 → 0.6.8
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 +5 -4
- package/bin/index.cjs +270 -425
- package/bin/{index.js → index.mjs} +230 -409
- package/bin/seeders-C0schOjT.mjs +3 -0
- package/bin/seeders-D-v59HCz.cjs +3 -0
- package/dist/browser/index.cjs +4 -12
- package/dist/browser/index.d.cts +203 -203
- package/dist/browser/{index.d.ts → index.d.mts} +203 -203
- package/dist/browser/{index.js → index.mjs} +4 -11
- package/dist/index.cjs +21 -59
- package/dist/index.d.cts +133 -133
- package/dist/{index.d.ts → index.d.mts} +133 -133
- package/dist/{index.js → index.mjs} +21 -54
- package/dist/inspector/index.cjs +15 -46
- package/dist/inspector/{index.js → index.mjs} +15 -43
- package/dist/migrations/{chunk-PECeCxCb.js → chunk-BD38OWEx.mjs} +1 -1
- package/dist/migrations/index.cjs +20 -57
- package/dist/migrations/index.d.cts +186 -186
- package/dist/migrations/{index.d.ts → index.d.mts} +186 -186
- package/dist/migrations/{index.js → index.mjs} +22 -54
- package/dist/seeders/index.cjs +1 -5
- package/dist/seeders/index.d.cts +184 -184
- package/dist/seeders/{index.d.ts → index.d.mts} +184 -184
- package/dist/seeders/{index.js → index.mjs} +2 -3
- package/dist/stubs/seeder-js.stub +4 -4
- package/dist/stubs/seeder-ts.stub +5 -0
- package/package.json +5 -4
- package/bin/seeders-8GJzfIIN.js +0 -3
- package/bin/seeders-ByeSoCAQ.cjs +0 -131
- package/bin/seeders-CltigymO.js +0 -79
- package/bin/seeders-_xJ6VGVS.cjs +0 -3
- /package/bin/{index.d.ts → index.d.mts} +0 -0
- /package/dist/inspector/{index.d.ts → index.d.mts} +0 -0
|
@@ -30,9 +30,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
|
|
31
31
|
//#endregion
|
|
32
32
|
let __h3ravel_shared = require("@h3ravel/shared");
|
|
33
|
-
__h3ravel_shared = __toESM(__h3ravel_shared);
|
|
34
33
|
let radashi = require("radashi");
|
|
35
|
-
radashi = __toESM(radashi);
|
|
36
34
|
let dayjs_plugin_advancedFormat_js = require("dayjs/plugin/advancedFormat.js");
|
|
37
35
|
dayjs_plugin_advancedFormat_js = __toESM(dayjs_plugin_advancedFormat_js);
|
|
38
36
|
let dayjs = require("dayjs");
|
|
@@ -44,15 +42,12 @@ knex = __toESM(knex);
|
|
|
44
42
|
let path = require("path");
|
|
45
43
|
path = __toESM(path);
|
|
46
44
|
let fs = require("fs");
|
|
47
|
-
fs = __toESM(fs);
|
|
48
45
|
let pluralize = require("pluralize");
|
|
49
46
|
pluralize = __toESM(pluralize);
|
|
50
47
|
let node_fs_promises = require("node:fs/promises");
|
|
51
48
|
node_fs_promises = __toESM(node_fs_promises);
|
|
52
49
|
let node_path = require("node:path");
|
|
53
|
-
node_path = __toESM(node_path);
|
|
54
50
|
let node_url = require("node:url");
|
|
55
|
-
node_url = __toESM(node_url);
|
|
56
51
|
let resolve_from = require("resolve-from");
|
|
57
52
|
resolve_from = __toESM(resolve_from);
|
|
58
53
|
|
|
@@ -594,10 +589,7 @@ var MSSQL = class {
|
|
|
594
589
|
AND ISNULL([i].[index_column_count], 1) = 1
|
|
595
590
|
AND ISNULL([i].[index_priority], 1) = 1`).where({ "s.name": this.schema });
|
|
596
591
|
if (table) query.andWhere({ "o.name": table });
|
|
597
|
-
if (column) {
|
|
598
|
-
const rawColumn = await query.andWhere({ "c.name": column }).first();
|
|
599
|
-
return rawColumnToColumn$2(rawColumn);
|
|
600
|
-
}
|
|
592
|
+
if (column) return rawColumnToColumn$2(await query.andWhere({ "c.name": column }).first());
|
|
601
593
|
return (await query).map(rawColumnToColumn$2);
|
|
602
594
|
}
|
|
603
595
|
/**
|
|
@@ -748,10 +740,7 @@ var MySQL = class {
|
|
|
748
740
|
this.on("rc.TABLE_NAME", "=", "fk.TABLE_NAME").andOn("rc.CONSTRAINT_NAME", "=", "fk.CONSTRAINT_NAME").andOn("rc.CONSTRAINT_SCHEMA", "=", "fk.CONSTRAINT_SCHEMA");
|
|
749
741
|
}).where({ "c.TABLE_SCHEMA": this.knex.client.database() });
|
|
750
742
|
if (table) query.andWhere({ "c.TABLE_NAME": table });
|
|
751
|
-
if (column) {
|
|
752
|
-
const rawColumn = await query.andWhere({ "c.column_name": column }).first();
|
|
753
|
-
return rawColumnToColumn$1(rawColumn);
|
|
754
|
-
}
|
|
743
|
+
if (column) return rawColumnToColumn$1(await query.andWhere({ "c.column_name": column }).first());
|
|
755
744
|
return (await query).map(rawColumnToColumn$1).sort((column$1) => +!column$1.foreign_key_column).filter((column$1, index, records) => {
|
|
756
745
|
return records.findIndex((_column) => {
|
|
757
746
|
return column$1.name === _column.name && column$1.table === _column.table;
|
|
@@ -937,10 +926,7 @@ var oracleDB = class {
|
|
|
937
926
|
ON "ct"."R_CONSTRAINT_NAME" = "fk"."CONSTRAINT_NAME"
|
|
938
927
|
`)).where({ "c.HIDDEN_COLUMN": "NO" });
|
|
939
928
|
if (table) query.andWhere({ "c.TABLE_NAME": table });
|
|
940
|
-
if (column) {
|
|
941
|
-
const rawColumn = await query.andWhere({ "c.COLUMN_NAME": column }).first();
|
|
942
|
-
return rawColumnToColumn(rawColumn);
|
|
943
|
-
}
|
|
929
|
+
if (column) return rawColumnToColumn(await query.andWhere({ "c.COLUMN_NAME": column }).first());
|
|
944
930
|
return (await query).map(rawColumnToColumn);
|
|
945
931
|
}
|
|
946
932
|
/**
|
|
@@ -1827,9 +1813,7 @@ const HasAttributes = (Model$1) => {
|
|
|
1827
1813
|
}
|
|
1828
1814
|
originalIsEquivalent(key) {
|
|
1829
1815
|
if (this.original[key] === void 0) return false;
|
|
1830
|
-
|
|
1831
|
-
const original = this.original[key];
|
|
1832
|
-
if (attribute === original) return true;
|
|
1816
|
+
if (this.attributes[key] === this.original[key]) return true;
|
|
1833
1817
|
else return false;
|
|
1834
1818
|
}
|
|
1835
1819
|
setAttributes(attributes) {
|
|
@@ -2011,8 +1995,7 @@ const HasAttributes = (Model$1) => {
|
|
|
2011
1995
|
return new Date(value);
|
|
2012
1996
|
}
|
|
2013
1997
|
asDate(value) {
|
|
2014
|
-
|
|
2015
|
-
return (0, dayjs.default)(date).startOf("day").toDate();
|
|
1998
|
+
return (0, dayjs.default)(this.asDateTime(value)).startOf("day").toDate();
|
|
2016
1999
|
}
|
|
2017
2000
|
};
|
|
2018
2001
|
};
|
|
@@ -2526,10 +2509,7 @@ const HasRelations = (Model$1) => {
|
|
|
2526
2509
|
return this.relations[relation] !== void 0;
|
|
2527
2510
|
}
|
|
2528
2511
|
related(relation) {
|
|
2529
|
-
if (typeof this[getRelationMethod(relation)] !== "function") {
|
|
2530
|
-
const message = `Model [${this.constructor.name}]'s relation [${relation}] doesn't exist.`;
|
|
2531
|
-
throw new RelationNotFoundError(message);
|
|
2532
|
-
}
|
|
2512
|
+
if (typeof this[getRelationMethod(relation)] !== "function") throw new RelationNotFoundError(`Model [${this.constructor.name}]'s relation [${relation}] doesn't exist.`);
|
|
2533
2513
|
return this[getRelationMethod(relation)]();
|
|
2534
2514
|
}
|
|
2535
2515
|
async getRelated(relation) {
|
|
@@ -4030,8 +4010,7 @@ var BelongsToMany = class extends compose(relation_default, interacts_with_pivot
|
|
|
4030
4010
|
return columns.concat(this.aliasedPivotColumns());
|
|
4031
4011
|
}
|
|
4032
4012
|
aliasedPivotColumns() {
|
|
4033
|
-
|
|
4034
|
-
return (0, collect_js.collect)(defaults.concat(this.pivotColumns)).map((column) => {
|
|
4013
|
+
return (0, collect_js.collect)([this.foreignPivotKey, this.relatedPivotKey].concat(this.pivotColumns)).map((column) => {
|
|
4035
4014
|
return this.qualifyPivotColumn(column) + " as pivot_" + column;
|
|
4036
4015
|
}).unique().all();
|
|
4037
4016
|
}
|
|
@@ -4324,8 +4303,7 @@ var Builder = class Builder extends Inference$1 {
|
|
|
4324
4303
|
}
|
|
4325
4304
|
addUpdatedAtColumn(values) {
|
|
4326
4305
|
if (!this.model.usesTimestamps() || this.model.getUpdatedAtColumn() === null) return values;
|
|
4327
|
-
|
|
4328
|
-
values = (0, radashi.assign)({ [column]: this.model.freshTimestampString() }, values);
|
|
4306
|
+
values = (0, radashi.assign)({ [this.model.getUpdatedAtColumn()]: this.model.freshTimestampString() }, values);
|
|
4329
4307
|
return values;
|
|
4330
4308
|
}
|
|
4331
4309
|
delete() {
|
|
@@ -4640,10 +4618,7 @@ var Builder = class Builder extends Inference$1 {
|
|
|
4640
4618
|
}];
|
|
4641
4619
|
}
|
|
4642
4620
|
related(relation) {
|
|
4643
|
-
if (typeof this.model[getRelationMethod(relation)] !== "function") {
|
|
4644
|
-
const message = `Model [${this.model.constructor.name}]'s relation [${relation}] doesn't exist.`;
|
|
4645
|
-
throw new RelationNotFoundError(message);
|
|
4646
|
-
}
|
|
4621
|
+
if (typeof this.model[getRelationMethod(relation)] !== "function") throw new RelationNotFoundError(`Model [${this.model.constructor.name}]'s relation [${relation}] doesn't exist.`);
|
|
4647
4622
|
return this.model[getRelationMethod(relation)]();
|
|
4648
4623
|
}
|
|
4649
4624
|
take(...args) {
|
|
@@ -4716,8 +4691,7 @@ var Builder = class Builder extends Inference$1 {
|
|
|
4716
4691
|
return await this.whereIn(this.model.getKeyName(), ids).get(columns);
|
|
4717
4692
|
}
|
|
4718
4693
|
async pluck(column) {
|
|
4719
|
-
|
|
4720
|
-
return new collection_default(data);
|
|
4694
|
+
return new collection_default(await this.query.pluck(column));
|
|
4721
4695
|
}
|
|
4722
4696
|
async destroy(ids) {
|
|
4723
4697
|
if (ids instanceof collection_default) ids = ids.modelKeys();
|
|
@@ -4762,10 +4736,7 @@ var Builder = class Builder extends Inference$1 {
|
|
|
4762
4736
|
return this.hydrate(await this.query.get()).all();
|
|
4763
4737
|
}
|
|
4764
4738
|
getRelation(name) {
|
|
4765
|
-
if (typeof this.model[getRelationMethod(name)] !== "function") {
|
|
4766
|
-
const message = `Model [${this.model.constructor.name}]'s relation [${name}] doesn't exist.`;
|
|
4767
|
-
throw new RelationNotFoundError(message);
|
|
4768
|
-
}
|
|
4739
|
+
if (typeof this.model[getRelationMethod(name)] !== "function") throw new RelationNotFoundError(`Model [${this.model.constructor.name}]'s relation [${name}] doesn't exist.`);
|
|
4769
4740
|
const relation = relation_default.noConstraints(() => this.model.newInstance(this.model.attributes)[getRelationMethod(name)]());
|
|
4770
4741
|
const nested = this.relationsNestedUnder(name);
|
|
4771
4742
|
if (Object.keys(nested).length > 0) relation.query.with(nested);
|
|
@@ -4866,8 +4837,7 @@ var SQLite = class {
|
|
|
4866
4837
|
column: column.name
|
|
4867
4838
|
}));
|
|
4868
4839
|
const tables = await this.tables();
|
|
4869
|
-
|
|
4870
|
-
return flatten(columnsPerTable);
|
|
4840
|
+
return flatten(await Promise.all(tables.map(async (table$1) => await this.columns(table$1))));
|
|
4871
4841
|
}
|
|
4872
4842
|
async columnInfo(table, column) {
|
|
4873
4843
|
const getColumnsForTable = async (table$1) => {
|
|
@@ -4902,8 +4872,7 @@ var SQLite = class {
|
|
|
4902
4872
|
};
|
|
4903
4873
|
if (!table) {
|
|
4904
4874
|
const tables = await this.tables();
|
|
4905
|
-
|
|
4906
|
-
return flatten(columnsPerTable);
|
|
4875
|
+
return flatten(await Promise.all(tables.map(async (table$1) => await getColumnsForTable(table$1))));
|
|
4907
4876
|
}
|
|
4908
4877
|
if (table && !column) return await getColumnsForTable(table);
|
|
4909
4878
|
return (await getColumnsForTable(table)).find((columnInfo) => columnInfo.name === column);
|
|
@@ -4934,8 +4903,7 @@ var SQLite = class {
|
|
|
4934
4903
|
constraint_name: null
|
|
4935
4904
|
}));
|
|
4936
4905
|
const tables = await this.tables();
|
|
4937
|
-
|
|
4938
|
-
return flatten(keysPerTable);
|
|
4906
|
+
return flatten(await Promise.all(tables.map(async (table$1) => await this.foreignKeys(table$1))));
|
|
4939
4907
|
}
|
|
4940
4908
|
async uniqueConstraints(table) {
|
|
4941
4909
|
if (table) {
|
|
@@ -4951,8 +4919,7 @@ var SQLite = class {
|
|
|
4951
4919
|
});
|
|
4952
4920
|
}
|
|
4953
4921
|
const tables = await this.tables();
|
|
4954
|
-
|
|
4955
|
-
return flatten(constraintsPerTable);
|
|
4922
|
+
return flatten(await Promise.all(tables.map(async (table$1) => await this.uniqueConstraints(table$1))));
|
|
4956
4923
|
}
|
|
4957
4924
|
};
|
|
4958
4925
|
|
|
@@ -5323,21 +5290,19 @@ var Migrate = class {
|
|
|
5323
5290
|
const getAllMigrationFiles = async () => {
|
|
5324
5291
|
return await migrator.getMigrationFiles(await Utils.getMigrationPaths(this.basePath ?? process.cwd(), migrator, config.migrations.path, options.path));
|
|
5325
5292
|
};
|
|
5326
|
-
async function getStatusFor(ran
|
|
5293
|
+
async function getStatusFor(ran, batches) {
|
|
5327
5294
|
const files = await getAllMigrationFiles();
|
|
5328
5295
|
return Object.values(files).map((migration) => {
|
|
5329
5296
|
const migrationName = migrator.getMigrationName(migration);
|
|
5330
5297
|
return {
|
|
5331
5298
|
name: migrationName,
|
|
5332
|
-
ran: ran
|
|
5333
|
-
batch: ran
|
|
5299
|
+
ran: ran.includes(migrationName),
|
|
5300
|
+
batch: ran.includes(migrationName) ? batches[migrationName] : null
|
|
5334
5301
|
};
|
|
5335
5302
|
});
|
|
5336
5303
|
}
|
|
5337
5304
|
if (!await migrator.repositoryExists()) this.callback("ERROR: Migration table does not exist.", "error");
|
|
5338
|
-
const
|
|
5339
|
-
const batches = await migrator.getRepository().getMigrationBatches();
|
|
5340
|
-
const migrations = await getStatusFor(ran, batches);
|
|
5305
|
+
const migrations = await getStatusFor(await migrator.repository.getRan(), await migrator.getRepository().getMigrationBatches());
|
|
5341
5306
|
if (destroyAll) await arquebus$1.destroyAll();
|
|
5342
5307
|
return migrations;
|
|
5343
5308
|
}
|
|
@@ -5356,11 +5321,9 @@ var Migrate = class {
|
|
|
5356
5321
|
arquebus_default.addConnection(connection, name);
|
|
5357
5322
|
});
|
|
5358
5323
|
}
|
|
5359
|
-
const repository = new MigrationRepository(arquebus_default, table);
|
|
5360
|
-
const migrator = new migrator_default(repository, arquebus_default);
|
|
5361
5324
|
return {
|
|
5362
5325
|
arquebus: arquebus_default,
|
|
5363
|
-
migrator
|
|
5326
|
+
migrator: new migrator_default(new MigrationRepository(arquebus_default, table), arquebus_default)
|
|
5364
5327
|
};
|
|
5365
5328
|
}
|
|
5366
5329
|
};
|