@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __export } from "./chunk-
|
|
1
|
+
import { t as __export } from "./chunk-BD38OWEx.mjs";
|
|
2
2
|
import { FileSystem, Logger, TaskManager } from "@h3ravel/shared";
|
|
3
3
|
import { assign, camel, diff, flat, get, isArray, isEmpty, isEqual, isString, omit, pick, set, snake, trim } from "radashi";
|
|
4
4
|
import advancedFormat from "dayjs/plugin/advancedFormat.js";
|
|
@@ -551,10 +551,7 @@ var MSSQL = class {
|
|
|
551
551
|
AND ISNULL([i].[index_column_count], 1) = 1
|
|
552
552
|
AND ISNULL([i].[index_priority], 1) = 1`).where({ "s.name": this.schema });
|
|
553
553
|
if (table) query.andWhere({ "o.name": table });
|
|
554
|
-
if (column) {
|
|
555
|
-
const rawColumn = await query.andWhere({ "c.name": column }).first();
|
|
556
|
-
return rawColumnToColumn$2(rawColumn);
|
|
557
|
-
}
|
|
554
|
+
if (column) return rawColumnToColumn$2(await query.andWhere({ "c.name": column }).first());
|
|
558
555
|
return (await query).map(rawColumnToColumn$2);
|
|
559
556
|
}
|
|
560
557
|
/**
|
|
@@ -705,10 +702,7 @@ var MySQL = class {
|
|
|
705
702
|
this.on("rc.TABLE_NAME", "=", "fk.TABLE_NAME").andOn("rc.CONSTRAINT_NAME", "=", "fk.CONSTRAINT_NAME").andOn("rc.CONSTRAINT_SCHEMA", "=", "fk.CONSTRAINT_SCHEMA");
|
|
706
703
|
}).where({ "c.TABLE_SCHEMA": this.knex.client.database() });
|
|
707
704
|
if (table) query.andWhere({ "c.TABLE_NAME": table });
|
|
708
|
-
if (column) {
|
|
709
|
-
const rawColumn = await query.andWhere({ "c.column_name": column }).first();
|
|
710
|
-
return rawColumnToColumn$1(rawColumn);
|
|
711
|
-
}
|
|
705
|
+
if (column) return rawColumnToColumn$1(await query.andWhere({ "c.column_name": column }).first());
|
|
712
706
|
return (await query).map(rawColumnToColumn$1).sort((column$1) => +!column$1.foreign_key_column).filter((column$1, index, records) => {
|
|
713
707
|
return records.findIndex((_column) => {
|
|
714
708
|
return column$1.name === _column.name && column$1.table === _column.table;
|
|
@@ -894,10 +888,7 @@ var oracleDB = class {
|
|
|
894
888
|
ON "ct"."R_CONSTRAINT_NAME" = "fk"."CONSTRAINT_NAME"
|
|
895
889
|
`)).where({ "c.HIDDEN_COLUMN": "NO" });
|
|
896
890
|
if (table) query.andWhere({ "c.TABLE_NAME": table });
|
|
897
|
-
if (column) {
|
|
898
|
-
const rawColumn = await query.andWhere({ "c.COLUMN_NAME": column }).first();
|
|
899
|
-
return rawColumnToColumn(rawColumn);
|
|
900
|
-
}
|
|
891
|
+
if (column) return rawColumnToColumn(await query.andWhere({ "c.COLUMN_NAME": column }).first());
|
|
901
892
|
return (await query).map(rawColumnToColumn);
|
|
902
893
|
}
|
|
903
894
|
/**
|
|
@@ -1784,9 +1775,7 @@ const HasAttributes = (Model$1) => {
|
|
|
1784
1775
|
}
|
|
1785
1776
|
originalIsEquivalent(key) {
|
|
1786
1777
|
if (this.original[key] === void 0) return false;
|
|
1787
|
-
|
|
1788
|
-
const original = this.original[key];
|
|
1789
|
-
if (attribute === original) return true;
|
|
1778
|
+
if (this.attributes[key] === this.original[key]) return true;
|
|
1790
1779
|
else return false;
|
|
1791
1780
|
}
|
|
1792
1781
|
setAttributes(attributes) {
|
|
@@ -1968,8 +1957,7 @@ const HasAttributes = (Model$1) => {
|
|
|
1968
1957
|
return new Date(value);
|
|
1969
1958
|
}
|
|
1970
1959
|
asDate(value) {
|
|
1971
|
-
|
|
1972
|
-
return dayjs(date).startOf("day").toDate();
|
|
1960
|
+
return dayjs(this.asDateTime(value)).startOf("day").toDate();
|
|
1973
1961
|
}
|
|
1974
1962
|
};
|
|
1975
1963
|
};
|
|
@@ -2483,10 +2471,7 @@ const HasRelations = (Model$1) => {
|
|
|
2483
2471
|
return this.relations[relation] !== void 0;
|
|
2484
2472
|
}
|
|
2485
2473
|
related(relation) {
|
|
2486
|
-
if (typeof this[getRelationMethod(relation)] !== "function") {
|
|
2487
|
-
const message = `Model [${this.constructor.name}]'s relation [${relation}] doesn't exist.`;
|
|
2488
|
-
throw new RelationNotFoundError(message);
|
|
2489
|
-
}
|
|
2474
|
+
if (typeof this[getRelationMethod(relation)] !== "function") throw new RelationNotFoundError(`Model [${this.constructor.name}]'s relation [${relation}] doesn't exist.`);
|
|
2490
2475
|
return this[getRelationMethod(relation)]();
|
|
2491
2476
|
}
|
|
2492
2477
|
async getRelated(relation) {
|
|
@@ -3987,8 +3972,7 @@ var BelongsToMany = class extends compose(relation_default, interacts_with_pivot
|
|
|
3987
3972
|
return columns.concat(this.aliasedPivotColumns());
|
|
3988
3973
|
}
|
|
3989
3974
|
aliasedPivotColumns() {
|
|
3990
|
-
|
|
3991
|
-
return collect$1(defaults.concat(this.pivotColumns)).map((column) => {
|
|
3975
|
+
return collect$1([this.foreignPivotKey, this.relatedPivotKey].concat(this.pivotColumns)).map((column) => {
|
|
3992
3976
|
return this.qualifyPivotColumn(column) + " as pivot_" + column;
|
|
3993
3977
|
}).unique().all();
|
|
3994
3978
|
}
|
|
@@ -4281,8 +4265,7 @@ var Builder = class Builder extends Inference$1 {
|
|
|
4281
4265
|
}
|
|
4282
4266
|
addUpdatedAtColumn(values) {
|
|
4283
4267
|
if (!this.model.usesTimestamps() || this.model.getUpdatedAtColumn() === null) return values;
|
|
4284
|
-
|
|
4285
|
-
values = assign({ [column]: this.model.freshTimestampString() }, values);
|
|
4268
|
+
values = assign({ [this.model.getUpdatedAtColumn()]: this.model.freshTimestampString() }, values);
|
|
4286
4269
|
return values;
|
|
4287
4270
|
}
|
|
4288
4271
|
delete() {
|
|
@@ -4597,10 +4580,7 @@ var Builder = class Builder extends Inference$1 {
|
|
|
4597
4580
|
}];
|
|
4598
4581
|
}
|
|
4599
4582
|
related(relation) {
|
|
4600
|
-
if (typeof this.model[getRelationMethod(relation)] !== "function") {
|
|
4601
|
-
const message = `Model [${this.model.constructor.name}]'s relation [${relation}] doesn't exist.`;
|
|
4602
|
-
throw new RelationNotFoundError(message);
|
|
4603
|
-
}
|
|
4583
|
+
if (typeof this.model[getRelationMethod(relation)] !== "function") throw new RelationNotFoundError(`Model [${this.model.constructor.name}]'s relation [${relation}] doesn't exist.`);
|
|
4604
4584
|
return this.model[getRelationMethod(relation)]();
|
|
4605
4585
|
}
|
|
4606
4586
|
take(...args) {
|
|
@@ -4673,8 +4653,7 @@ var Builder = class Builder extends Inference$1 {
|
|
|
4673
4653
|
return await this.whereIn(this.model.getKeyName(), ids).get(columns);
|
|
4674
4654
|
}
|
|
4675
4655
|
async pluck(column) {
|
|
4676
|
-
|
|
4677
|
-
return new collection_default(data);
|
|
4656
|
+
return new collection_default(await this.query.pluck(column));
|
|
4678
4657
|
}
|
|
4679
4658
|
async destroy(ids) {
|
|
4680
4659
|
if (ids instanceof collection_default) ids = ids.modelKeys();
|
|
@@ -4719,10 +4698,7 @@ var Builder = class Builder extends Inference$1 {
|
|
|
4719
4698
|
return this.hydrate(await this.query.get()).all();
|
|
4720
4699
|
}
|
|
4721
4700
|
getRelation(name) {
|
|
4722
|
-
if (typeof this.model[getRelationMethod(name)] !== "function") {
|
|
4723
|
-
const message = `Model [${this.model.constructor.name}]'s relation [${name}] doesn't exist.`;
|
|
4724
|
-
throw new RelationNotFoundError(message);
|
|
4725
|
-
}
|
|
4701
|
+
if (typeof this.model[getRelationMethod(name)] !== "function") throw new RelationNotFoundError(`Model [${this.model.constructor.name}]'s relation [${name}] doesn't exist.`);
|
|
4726
4702
|
const relation = relation_default.noConstraints(() => this.model.newInstance(this.model.attributes)[getRelationMethod(name)]());
|
|
4727
4703
|
const nested = this.relationsNestedUnder(name);
|
|
4728
4704
|
if (Object.keys(nested).length > 0) relation.query.with(nested);
|
|
@@ -4778,7 +4754,7 @@ var Migration = class extends Inference {
|
|
|
4778
4754
|
var migration_default = Migration;
|
|
4779
4755
|
|
|
4780
4756
|
//#endregion
|
|
4781
|
-
//#region node_modules/.pnpm/tsdown@0.
|
|
4757
|
+
//#region node_modules/.pnpm/tsdown@0.16.0_typescript@5.9.3/node_modules/tsdown/esm-shims.js
|
|
4782
4758
|
const getFilename = () => fileURLToPath(import.meta.url);
|
|
4783
4759
|
const getDirname = () => path$1.dirname(getFilename());
|
|
4784
4760
|
const __dirname = /* @__PURE__ */ getDirname();
|
|
@@ -4829,8 +4805,7 @@ var SQLite = class {
|
|
|
4829
4805
|
column: column.name
|
|
4830
4806
|
}));
|
|
4831
4807
|
const tables = await this.tables();
|
|
4832
|
-
|
|
4833
|
-
return flatten(columnsPerTable);
|
|
4808
|
+
return flatten(await Promise.all(tables.map(async (table$1) => await this.columns(table$1))));
|
|
4834
4809
|
}
|
|
4835
4810
|
async columnInfo(table, column) {
|
|
4836
4811
|
const getColumnsForTable = async (table$1) => {
|
|
@@ -4865,8 +4840,7 @@ var SQLite = class {
|
|
|
4865
4840
|
};
|
|
4866
4841
|
if (!table) {
|
|
4867
4842
|
const tables = await this.tables();
|
|
4868
|
-
|
|
4869
|
-
return flatten(columnsPerTable);
|
|
4843
|
+
return flatten(await Promise.all(tables.map(async (table$1) => await getColumnsForTable(table$1))));
|
|
4870
4844
|
}
|
|
4871
4845
|
if (table && !column) return await getColumnsForTable(table);
|
|
4872
4846
|
return (await getColumnsForTable(table)).find((columnInfo) => columnInfo.name === column);
|
|
@@ -4897,8 +4871,7 @@ var SQLite = class {
|
|
|
4897
4871
|
constraint_name: null
|
|
4898
4872
|
}));
|
|
4899
4873
|
const tables = await this.tables();
|
|
4900
|
-
|
|
4901
|
-
return flatten(keysPerTable);
|
|
4874
|
+
return flatten(await Promise.all(tables.map(async (table$1) => await this.foreignKeys(table$1))));
|
|
4902
4875
|
}
|
|
4903
4876
|
async uniqueConstraints(table) {
|
|
4904
4877
|
if (table) {
|
|
@@ -4914,8 +4887,7 @@ var SQLite = class {
|
|
|
4914
4887
|
});
|
|
4915
4888
|
}
|
|
4916
4889
|
const tables = await this.tables();
|
|
4917
|
-
|
|
4918
|
-
return flatten(constraintsPerTable);
|
|
4890
|
+
return flatten(await Promise.all(tables.map(async (table$1) => await this.uniqueConstraints(table$1))));
|
|
4919
4891
|
}
|
|
4920
4892
|
};
|
|
4921
4893
|
|
|
@@ -5286,21 +5258,19 @@ var Migrate = class {
|
|
|
5286
5258
|
const getAllMigrationFiles = async () => {
|
|
5287
5259
|
return await migrator.getMigrationFiles(await Utils.getMigrationPaths(this.basePath ?? process.cwd(), migrator, config.migrations.path, options.path));
|
|
5288
5260
|
};
|
|
5289
|
-
async function getStatusFor(ran
|
|
5261
|
+
async function getStatusFor(ran, batches) {
|
|
5290
5262
|
const files = await getAllMigrationFiles();
|
|
5291
5263
|
return Object.values(files).map((migration) => {
|
|
5292
5264
|
const migrationName = migrator.getMigrationName(migration);
|
|
5293
5265
|
return {
|
|
5294
5266
|
name: migrationName,
|
|
5295
|
-
ran: ran
|
|
5296
|
-
batch: ran
|
|
5267
|
+
ran: ran.includes(migrationName),
|
|
5268
|
+
batch: ran.includes(migrationName) ? batches[migrationName] : null
|
|
5297
5269
|
};
|
|
5298
5270
|
});
|
|
5299
5271
|
}
|
|
5300
5272
|
if (!await migrator.repositoryExists()) this.callback("ERROR: Migration table does not exist.", "error");
|
|
5301
|
-
const
|
|
5302
|
-
const batches = await migrator.getRepository().getMigrationBatches();
|
|
5303
|
-
const migrations = await getStatusFor(ran, batches);
|
|
5273
|
+
const migrations = await getStatusFor(await migrator.repository.getRan(), await migrator.getRepository().getMigrationBatches());
|
|
5304
5274
|
if (destroyAll) await arquebus$1.destroyAll();
|
|
5305
5275
|
return migrations;
|
|
5306
5276
|
}
|
|
@@ -5319,11 +5289,9 @@ var Migrate = class {
|
|
|
5319
5289
|
arquebus_default.addConnection(connection, name);
|
|
5320
5290
|
});
|
|
5321
5291
|
}
|
|
5322
|
-
const repository = new MigrationRepository(arquebus_default, table);
|
|
5323
|
-
const migrator = new migrator_default(repository, arquebus_default);
|
|
5324
5292
|
return {
|
|
5325
5293
|
arquebus: arquebus_default,
|
|
5326
|
-
migrator
|
|
5294
|
+
migrator: new migrator_default(new MigrationRepository(arquebus_default, table), arquebus_default)
|
|
5327
5295
|
};
|
|
5328
5296
|
}
|
|
5329
5297
|
};
|
package/dist/seeders/index.cjs
CHANGED
|
@@ -22,13 +22,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
|
|
23
23
|
//#endregion
|
|
24
24
|
let node_fs_promises = require("node:fs/promises");
|
|
25
|
-
node_fs_promises = __toESM(node_fs_promises);
|
|
26
25
|
let path = require("path");
|
|
27
26
|
path = __toESM(path);
|
|
28
27
|
let node_path = require("node:path");
|
|
29
|
-
node_path = __toESM(node_path);
|
|
30
28
|
let node_url = require("node:url");
|
|
31
|
-
node_url = __toESM(node_url);
|
|
32
29
|
|
|
33
30
|
//#region src/seeders/seeder.ts
|
|
34
31
|
var Seeder = class {};
|
|
@@ -115,8 +112,7 @@ var SeederCreator = class {
|
|
|
115
112
|
}
|
|
116
113
|
async create(dir, name, type = "js") {
|
|
117
114
|
await (0, node_fs_promises.mkdir)(dir, { recursive: true });
|
|
118
|
-
|
|
119
|
-
let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
|
|
115
|
+
let stub = await (0, node_fs_promises.readFile)(this.getStubPath(type), "utf-8");
|
|
120
116
|
stub = stub.replace(/{{ name }}/g, name);
|
|
121
117
|
const filePath = path.default.join(dir, `${name}.${type}`);
|
|
122
118
|
await (0, node_fs_promises.writeFile)(filePath, stub);
|