@h3ravel/arquebus 1.29.0-alpha.11 → 2.0.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.
Files changed (39) hide show
  1. package/bin/index.cjs +229 -300
  2. package/bin/index.js +215 -286
  3. package/dist/browser/index.cjs +66 -100
  4. package/dist/browser/index.d.ts +191 -192
  5. package/dist/browser/index.js +58 -96
  6. package/dist/concerns/index.cjs +131 -187
  7. package/dist/concerns/index.d.ts +195 -196
  8. package/dist/concerns/index.js +135 -193
  9. package/dist/index.cjs +258 -340
  10. package/dist/index.d.ts +190 -191
  11. package/dist/index.js +203 -287
  12. package/dist/inspector/index.cjs +172 -240
  13. package/dist/inspector/index.js +136 -206
  14. package/dist/migrations/index.cjs +221 -287
  15. package/dist/migrations/index.d.ts +235 -237
  16. package/dist/migrations/index.js +160 -228
  17. package/dist/migrations/{chunk-Bop6jNiL.js → rolldown-runtime-D7D4PA-g.js} +4 -6
  18. package/dist/relations/index.cjs +131 -185
  19. package/dist/relations/index.d.ts +315 -316
  20. package/dist/relations/index.js +135 -191
  21. package/dist/seeders/index.cjs +9 -15
  22. package/dist/seeders/index.d.ts +232 -233
  23. package/dist/seeders/index.js +5 -12
  24. package/package.json +16 -16
  25. package/bin/.gitkeep +0 -0
  26. package/bin/seeders-D-v59HCz.cjs +0 -3
  27. package/bin/seeders-DIkcRliK.js +0 -3
  28. /package/dist/migrations/stubs/{migration-js.stub → stubs/migration-js.stub} +0 -0
  29. /package/dist/migrations/stubs/{migration-ts.stub → stubs/migration-ts.stub} +0 -0
  30. /package/dist/migrations/stubs/{migration.create-js.stub → stubs/migration.create-js.stub} +0 -0
  31. /package/dist/migrations/stubs/{migration.create-ts.stub → stubs/migration.create-ts.stub} +0 -0
  32. /package/dist/migrations/stubs/{migration.update-js.stub → stubs/migration.update-js.stub} +0 -0
  33. /package/dist/migrations/stubs/{migration.update-ts.stub → stubs/migration.update-ts.stub} +0 -0
  34. /package/dist/stubs/{arquebus.config-js.stub → stubs/arquebus.config-js.stub} +0 -0
  35. /package/dist/stubs/{arquebus.config-ts.stub → stubs/arquebus.config-ts.stub} +0 -0
  36. /package/dist/stubs/{model-js.stub → stubs/model-js.stub} +0 -0
  37. /package/dist/stubs/{model-ts.stub → stubs/model-ts.stub} +0 -0
  38. /package/dist/stubs/{seeder-js.stub → stubs/seeder-js.stub} +0 -0
  39. /package/dist/stubs/{seeder-ts.stub → stubs/seeder-ts.stub} +0 -0
package/bin/index.cjs CHANGED
@@ -1,17 +1,18 @@
1
1
  #!/usr/bin/env node
2
- //#region rolldown:runtime
2
+ //#region \0rolldown/runtime.js
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __export = (all) => {
9
+ var __exportAll = (all, no_symbols) => {
10
10
  let target = {};
11
11
  for (var name in all) __defProp(target, name, {
12
12
  get: all[name],
13
13
  enumerable: true
14
14
  });
15
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
15
16
  return target;
16
17
  };
17
18
  var __copyProps = (to, from, except, desc) => {
@@ -28,33 +29,31 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
29
  value: mod,
29
30
  enumerable: true
30
31
  }) : target, mod));
31
-
32
32
  //#endregion
33
33
  let commander = require("commander");
34
- let __h3ravel_shared = require("@h3ravel/shared");
34
+ let _h3ravel_shared = require("@h3ravel/shared");
35
35
  let path = require("path");
36
- path = __toESM(path);
36
+ path = __toESM(path, 1);
37
37
  let resolve_from = require("resolve-from");
38
- resolve_from = __toESM(resolve_from);
38
+ resolve_from = __toESM(resolve_from, 1);
39
39
  let node_fs_promises = require("node:fs/promises");
40
- node_fs_promises = __toESM(node_fs_promises);
40
+ node_fs_promises = __toESM(node_fs_promises, 1);
41
41
  let node_path = require("node:path");
42
42
  let node_url = require("node:url");
43
43
  let radashi = require("radashi");
44
44
  let dayjs_plugin_advancedFormat_js = require("dayjs/plugin/advancedFormat.js");
45
- dayjs_plugin_advancedFormat_js = __toESM(dayjs_plugin_advancedFormat_js);
45
+ dayjs_plugin_advancedFormat_js = __toESM(dayjs_plugin_advancedFormat_js, 1);
46
46
  let dayjs = require("dayjs");
47
- dayjs = __toESM(dayjs);
47
+ dayjs = __toESM(dayjs, 1);
48
48
  let collect_js = require("collect.js");
49
- collect_js = __toESM(collect_js);
49
+ collect_js = __toESM(collect_js, 1);
50
50
  let knex = require("knex");
51
- knex = __toESM(knex);
51
+ knex = __toESM(knex, 1);
52
52
  let fs = require("fs");
53
53
  let pluralize = require("pluralize");
54
- pluralize = __toESM(pluralize);
55
- let __h3ravel_support = require("@h3ravel/support");
54
+ pluralize = __toESM(pluralize, 1);
55
+ let _h3ravel_support = require("@h3ravel/support");
56
56
  let dotenv = require("dotenv");
57
-
58
57
  //#region src/cli/utils.ts
59
58
  const join = path.default.join;
60
59
  var Utils = class {
@@ -68,8 +67,8 @@ var Utils = class {
68
67
  if (!resolved) return;
69
68
  return path.default.join(path.default.dirname(resolved), parts.join("/"));
70
69
  }
71
- static async getMigrationPaths(cwd, migrator, defaultPath, path$8) {
72
- if (path$8) return [join(cwd, path$8)];
70
+ static async getMigrationPaths(cwd, migrator, defaultPath, path$7) {
71
+ if (path$7) return [join(cwd, path$7)];
73
72
  return [...migrator.getPaths(), join(cwd, defaultPath)];
74
73
  }
75
74
  };
@@ -88,7 +87,6 @@ var TableGuesser = class TableGuesser {
88
87
  return [];
89
88
  }
90
89
  };
91
-
92
90
  //#endregion
93
91
  //#region src/migrations/migration-repository.ts
94
92
  var MigrationRepository = class {
@@ -157,7 +155,6 @@ var MigrationRepository = class {
157
155
  this.connection = name;
158
156
  }
159
157
  };
160
-
161
158
  //#endregion
162
159
  //#region src/inspector/utils/strip-quotes.ts
163
160
  /**
@@ -169,7 +166,6 @@ function stripQuotes(value) {
169
166
  if (trimmed.startsWith("'") && trimmed.endsWith("'") || trimmed.startsWith("\"") && trimmed.endsWith("\"")) return trimmed.slice(1, -1);
170
167
  return value;
171
168
  }
172
-
173
169
  //#endregion
174
170
  //#region src/inspector/dialects/cockroachdb.ts
175
171
  /**
@@ -186,9 +182,9 @@ var CockroachDB = class {
186
182
  knex;
187
183
  schema;
188
184
  explodedSchema;
189
- constructor(knex$1) {
190
- this.knex = knex$1;
191
- const config = knex$1.client.config;
185
+ constructor(knex) {
186
+ this.knex = knex;
187
+ const config = knex.client.config;
192
188
  if (!config.searchPath) {
193
189
  this.schema = "public";
194
190
  this.explodedSchema = [this.schema];
@@ -252,12 +248,12 @@ var CockroachDB = class {
252
248
  }));
253
249
  }
254
250
  async columnInfo(table, column) {
255
- const { knex: knex$1 } = this;
251
+ const { knex } = this;
256
252
  const bindings = [];
257
253
  if (table) bindings.push(table);
258
254
  if (column) bindings.push(column);
259
255
  const schemaIn = this.explodedSchema.map((schemaName) => `${this.knex.raw("?", [schemaName])}::regnamespace`);
260
- const [columns, constraints] = await Promise.all([knex$1.raw(`
256
+ const [columns, constraints] = await Promise.all([knex.raw(`
261
257
  SELECT *, CASE WHEN res.is_generated THEN (
262
258
  SELECT
263
259
  generation_expression
@@ -317,7 +313,7 @@ var CockroachDB = class {
317
313
  AND att.attnum > 0
318
314
  AND NOT att.attisdropped
319
315
  ORDER BY rel.relname, att.attnum) res;
320
- `, bindings), knex$1.raw(`
316
+ `, bindings), knex.raw(`
321
317
  SELECT
322
318
  con.contype AS type,
323
319
  rel.relname AS table,
@@ -470,7 +466,6 @@ var CockroachDB = class {
470
466
  }
471
467
  }
472
468
  };
473
-
474
469
  //#endregion
475
470
  //#region src/inspector/dialects/mssql.ts
476
471
  function rawColumnToColumn$2(rawColumn) {
@@ -487,14 +482,14 @@ function rawColumnToColumn$2(rawColumn) {
487
482
  numeric_scale: rawColumn.numeric_scale || null,
488
483
  max_length: parseMaxLength(rawColumn)
489
484
  };
490
- function parseMaxLength(rawColumn$1) {
491
- const max_length = Number(rawColumn$1.max_length);
492
- if (Number.isNaN(max_length) || rawColumn$1.max_length === null || rawColumn$1.max_length === void 0) return null;
485
+ function parseMaxLength(rawColumn) {
486
+ const max_length = Number(rawColumn.max_length);
487
+ if (Number.isNaN(max_length) || rawColumn.max_length === null || rawColumn.max_length === void 0) return null;
493
488
  if ([
494
489
  "nvarchar",
495
490
  "nchar",
496
491
  "ntext"
497
- ].includes(rawColumn$1.data_type)) return max_length === -1 ? max_length : max_length / 2;
492
+ ].includes(rawColumn.data_type)) return max_length === -1 ? max_length : max_length / 2;
498
493
  return max_length;
499
494
  }
500
495
  }
@@ -507,8 +502,8 @@ function parseDefaultValue$4(value) {
507
502
  var MSSQL = class {
508
503
  knex;
509
504
  _schema;
510
- constructor(knex$1) {
511
- this.knex = knex$1;
505
+ constructor(knex) {
506
+ this.knex = knex;
512
507
  }
513
508
  /**
514
509
  * Set the schema to be used in other methods
@@ -681,7 +676,6 @@ var MSSQL = class {
681
676
  return result;
682
677
  }
683
678
  };
684
-
685
679
  //#endregion
686
680
  //#region src/inspector/dialects/mysql.ts
687
681
  function rawColumnToColumn$1(rawColumn) {
@@ -714,8 +708,8 @@ function parseDefaultValue$3(value) {
714
708
  }
715
709
  var MySQL = class {
716
710
  knex;
717
- constructor(knex$1) {
718
- this.knex = knex$1;
711
+ constructor(knex) {
712
+ this.knex = knex;
719
713
  }
720
714
  /**
721
715
  * List all existing tables in the current schema/database
@@ -780,9 +774,9 @@ var MySQL = class {
780
774
  }).where({ "c.TABLE_SCHEMA": this.knex.client.database() });
781
775
  if (table) query.andWhere({ "c.TABLE_NAME": table });
782
776
  if (column) return rawColumnToColumn$1(await query.andWhere({ "c.column_name": column }).first());
783
- return (await query).map(rawColumnToColumn$1).sort((column$1) => +!column$1.foreign_key_column).filter((column$1, index, records) => {
777
+ return (await query).map(rawColumnToColumn$1).sort((column) => +!column.foreign_key_column).filter((column, index, records) => {
784
778
  return records.findIndex((_column) => {
785
- return column$1.name === _column.name && column$1.table === _column.table;
779
+ return column.name === _column.name && column.table === _column.table;
786
780
  }) === index;
787
781
  });
788
782
  }
@@ -816,10 +810,10 @@ var MySQL = class {
816
810
  return await query;
817
811
  }
818
812
  async uniqueConstraints(table) {
819
- const { knex: knex$1 } = this;
820
- const query = knex$1.select("stat.table_name AS table_name", "stat.index_name AS constraint_name", knex$1.raw("group_concat(stat.column_name ORDER BY stat.seq_in_index separator ', ') AS columns")).from("information_schema.statistics stat").join("information_schema.table_constraints tco", function() {
813
+ const { knex } = this;
814
+ const query = knex.select("stat.table_name AS table_name", "stat.index_name AS constraint_name", knex.raw("group_concat(stat.column_name ORDER BY stat.seq_in_index separator ', ') AS columns")).from("information_schema.statistics stat").join("information_schema.table_constraints tco", function() {
821
815
  this.on("stat.table_schema", "=", "tco.table_schema").andOn("stat.table_name", "=", "tco.table_name").andOn("stat.index_name", "=", "tco.constraint_name");
822
- }).where("stat.non_unique", "=", 0).andWhere("tco.constraint_type", "=", "UNIQUE").andWhere("stat.table_schema", knex$1.client.database()).groupBy([
816
+ }).where("stat.non_unique", "=", 0).andWhere("tco.constraint_type", "=", "UNIQUE").andWhere("stat.table_schema", knex.client.database()).groupBy([
823
817
  "stat.table_name",
824
818
  "stat.index_name",
825
819
  "tco.constraint_type"
@@ -832,7 +826,6 @@ var MySQL = class {
832
826
  }));
833
827
  }
834
828
  };
835
-
836
829
  //#endregion
837
830
  //#region src/inspector/dialects/oracledb.ts
838
831
  /**
@@ -868,8 +861,8 @@ function parseDefaultValue$2(value) {
868
861
  }
869
862
  var oracleDB = class {
870
863
  knex;
871
- constructor(knex$1) {
872
- this.knex = knex$1;
864
+ constructor(knex) {
865
+ this.knex = knex;
873
866
  }
874
867
  /**
875
868
  * List all existing tables in the current schema/database
@@ -1030,7 +1023,6 @@ var oracleDB = class {
1030
1023
  return await query;
1031
1024
  }
1032
1025
  };
1033
-
1034
1026
  //#endregion
1035
1027
  //#region src/inspector/dialects/postgres.ts
1036
1028
  /**
@@ -1048,9 +1040,9 @@ var Postgres = class {
1048
1040
  knex;
1049
1041
  schema;
1050
1042
  explodedSchema;
1051
- constructor(knex$1) {
1052
- this.knex = knex$1;
1053
- const config = knex$1.client.config;
1043
+ constructor(knex) {
1044
+ this.knex = knex;
1045
+ const config = knex.client.config;
1054
1046
  if (!config.searchPath) {
1055
1047
  this.schema = "public";
1056
1048
  this.explodedSchema = [this.schema];
@@ -1148,7 +1140,7 @@ var Postgres = class {
1148
1140
  }
1149
1141
  async columnInfo(table, column) {
1150
1142
  var _versionResponse$rows;
1151
- const { knex: knex$1 } = this;
1143
+ const { knex } = this;
1152
1144
  const bindings = [];
1153
1145
  if (table) bindings.push(table);
1154
1146
  if (column) bindings.push(column);
@@ -1164,7 +1156,7 @@ var Postgres = class {
1164
1156
  CASE WHEN att.attgenerated = '' THEN pg_get_expr(ad.adbin, ad.adrelid) ELSE null END AS default_value,
1165
1157
  att.attgenerated = 's' AS is_generated,
1166
1158
  `;
1167
- const [columns, constraints] = await Promise.all([knex$1.raw(`
1159
+ const [columns, constraints] = await Promise.all([knex.raw(`
1168
1160
  SELECT
1169
1161
  att.attname AS name,
1170
1162
  rel.relname AS table,
@@ -1212,7 +1204,7 @@ var Postgres = class {
1212
1204
  AND att.attnum > 0
1213
1205
  AND NOT att.attisdropped
1214
1206
  ORDER BY rel.relname, att.attnum;
1215
- `, bindings), knex$1.raw(`
1207
+ `, bindings), knex.raw(`
1216
1208
  SELECT
1217
1209
  con.contype AS type,
1218
1210
  rel.relname AS table,
@@ -1346,11 +1338,11 @@ var Postgres = class {
1346
1338
  `, bindings)).rows;
1347
1339
  }
1348
1340
  async uniqueConstraints(table) {
1349
- const { knex: knex$1 } = this;
1341
+ const { knex } = this;
1350
1342
  const schemaIn = this.explodedSchema.map((schemaName) => `${this.knex.raw("?", [schemaName])}::regnamespace`);
1351
1343
  const bindings = [];
1352
1344
  if (table) bindings.push(table);
1353
- return (await knex$1.raw(`
1345
+ return (await knex.raw(`
1354
1346
  SELECT
1355
1347
  con.conrelid::regclass AS table_name,
1356
1348
  con.conname AS constraint_name,
@@ -1374,7 +1366,6 @@ var Postgres = class {
1374
1366
  });
1375
1367
  }
1376
1368
  };
1377
-
1378
1369
  //#endregion
1379
1370
  //#region src/inspector/utils/extract-max-length.ts
1380
1371
  /**
@@ -1386,7 +1377,6 @@ function extractMaxLength(type) {
1386
1377
  if (matches && matches.length > 0 && matches[1]) return Number(matches[1]);
1387
1378
  return null;
1388
1379
  }
1389
-
1390
1380
  //#endregion
1391
1381
  //#region src/inspector/utils/extract-type.ts
1392
1382
  /**
@@ -1396,7 +1386,6 @@ function extractMaxLength(type) {
1396
1386
  function extractType(type) {
1397
1387
  return type.replace(/[^a-zA-Z]/g, "").toLowerCase();
1398
1388
  }
1399
-
1400
1389
  //#endregion
1401
1390
  //#region src/seeders/runner.ts
1402
1391
  async function glob$1(folderPath) {
@@ -1468,8 +1457,9 @@ var SeederRunner = class {
1468
1457
  }
1469
1458
  }
1470
1459
  };
1471
- var runner_default = SeederRunner;
1472
-
1460
+ //#endregion
1461
+ //#region src/seeders/index.ts
1462
+ var seeders_exports = /* @__PURE__ */ __exportAll({ SeederRunner: () => SeederRunner });
1473
1463
  //#endregion
1474
1464
  //#region src/casts/attribute.ts
1475
1465
  var Attribute = class Attribute {
@@ -1477,21 +1467,21 @@ var Attribute = class Attribute {
1477
1467
  set;
1478
1468
  withCaching = false;
1479
1469
  withObjectCaching = true;
1480
- constructor({ get: get$1 = null, set: set$1 = null }) {
1481
- this.get = get$1;
1482
- this.set = set$1;
1470
+ constructor({ get = null, set = null }) {
1471
+ this.get = get;
1472
+ this.set = set;
1483
1473
  }
1484
- static make({ get: get$1 = null, set: set$1 = null }) {
1474
+ static make({ get = null, set = null }) {
1485
1475
  return new Attribute({
1486
- get: get$1,
1487
- set: set$1
1476
+ get,
1477
+ set
1488
1478
  });
1489
1479
  }
1490
- static get(get$1) {
1491
- return new Attribute({ get: get$1 });
1480
+ static get(get) {
1481
+ return new Attribute({ get });
1492
1482
  }
1493
- static set(set$1) {
1494
- return new Attribute({ set: set$1 });
1483
+ static set(set) {
1484
+ return new Attribute({ set });
1495
1485
  }
1496
1486
  withoutObjectCaching() {
1497
1487
  this.withObjectCaching = false;
@@ -1502,8 +1492,6 @@ var Attribute = class Attribute {
1502
1492
  return this;
1503
1493
  }
1504
1494
  };
1505
- var attribute_default = Attribute;
1506
-
1507
1495
  //#endregion
1508
1496
  //#region src/errors.ts
1509
1497
  var BaseError = class extends Error {
@@ -1537,10 +1525,9 @@ var ModelNotFoundError = class extends BaseError {
1537
1525
  };
1538
1526
  var RelationNotFoundError = class extends BaseError {};
1539
1527
  var InvalidArgumentError = class extends BaseError {};
1540
-
1541
1528
  //#endregion
1542
1529
  //#region src/mixin.ts
1543
- var mixin_exports = /* @__PURE__ */ __export({ compose: () => compose$1 });
1530
+ var mixin_exports = /* @__PURE__ */ __exportAll({ compose: () => compose$1 });
1544
1531
  /**
1545
1532
  * Compose function that merges multiple classes and mixins
1546
1533
  *
@@ -1613,7 +1600,6 @@ function compose$1(Base, ...mixins) {
1613
1600
  return acc;
1614
1601
  }, Base);
1615
1602
  }
1616
-
1617
1603
  //#endregion
1618
1604
  //#region src/utils.ts
1619
1605
  dayjs.default.extend(dayjs_plugin_advancedFormat_js.default);
@@ -1647,10 +1633,9 @@ const tap = (instance, callback) => {
1647
1633
  return result instanceof Promise ? result.then(() => instance) : instance;
1648
1634
  };
1649
1635
  const { compose } = mixin_exports;
1650
- const flatten = (arr) => arr.flat();
1636
+ const flatten$2 = (arr) => arr.flat();
1651
1637
  const flattenDeep = (arr) => Array.isArray(arr) ? arr.reduce((a, b) => a.concat(flattenDeep(b)), []) : [arr];
1652
1638
  const snakeCase = (str) => (0, radashi.trim)((0, radashi.snake)(str.replace(/[^a-zA-Z0-9_-]/g, "-")), "_-");
1653
-
1654
1639
  //#endregion
1655
1640
  //#region src/relations/relation.ts
1656
1641
  var Relation = class {
@@ -1741,12 +1726,10 @@ var Relation = class {
1741
1726
  return (_this$getQualifiedFor = this.getQualifiedForeignKeyName) === null || _this$getQualifiedFor === void 0 ? void 0 : _this$getQualifiedFor.call(this);
1742
1727
  }
1743
1728
  };
1744
- var relation_default = Relation;
1745
-
1746
1729
  //#endregion
1747
1730
  //#region src/relations/concerns/supports-default-models.ts
1748
- const SupportsDefaultModels = (Relation$1) => {
1749
- return class extends Relation$1 {
1731
+ const SupportsDefaultModels = (Relation) => {
1732
+ return class extends Relation {
1750
1733
  _withDefault;
1751
1734
  withDefault(callback = true) {
1752
1735
  this._withDefault = callback;
@@ -1761,11 +1744,9 @@ const SupportsDefaultModels = (Relation$1) => {
1761
1744
  }
1762
1745
  };
1763
1746
  };
1764
- var supports_default_models_default = SupportsDefaultModels;
1765
-
1766
1747
  //#endregion
1767
1748
  //#region src/relations/belongs-to.ts
1768
- var BelongsTo = class extends compose(relation_default, supports_default_models_default) {
1749
+ var BelongsTo = class extends compose(Relation, SupportsDefaultModels) {
1769
1750
  foreignKey;
1770
1751
  ownerKey;
1771
1752
  child;
@@ -1850,8 +1831,6 @@ var BelongsTo = class extends compose(relation_default, supports_default_models_
1850
1831
  return this.related.newInstance();
1851
1832
  }
1852
1833
  };
1853
- var belongs_to_default = BelongsTo;
1854
-
1855
1834
  //#endregion
1856
1835
  //#region src/casts-attributes.ts
1857
1836
  var CastsAttributes = class CastsAttributes {
@@ -1865,12 +1844,10 @@ var CastsAttributes = class CastsAttributes {
1865
1844
  throw new Error("set not implemented");
1866
1845
  }
1867
1846
  };
1868
- var casts_attributes_default = CastsAttributes;
1869
-
1870
1847
  //#endregion
1871
1848
  //#region src/concerns/has-attributes.ts
1872
- const HasAttributes = (Model$1) => {
1873
- return class extends Model$1 {
1849
+ const HasAttributes = (Model) => {
1850
+ return class extends Model {
1874
1851
  static castTypeCache = {};
1875
1852
  attributes = {};
1876
1853
  original = {};
@@ -1947,8 +1924,8 @@ const HasAttributes = (Model$1) => {
1947
1924
  }
1948
1925
  const attrMethod = getAttrMethod(key);
1949
1926
  if (typeof this[attrMethod] === "function") {
1950
- const callback = this[attrMethod]().set || ((value$1) => {
1951
- this.attributes[key] = value$1;
1927
+ const callback = this[attrMethod]().set || ((value) => {
1928
+ this.attributes[key] = value;
1952
1929
  });
1953
1930
  this.attributes = {
1954
1931
  ...this.attributes,
@@ -2058,7 +2035,7 @@ const HasAttributes = (Model$1) => {
2058
2035
  const castType = this.getCasts()[key];
2059
2036
  let castTypeCacheKey;
2060
2037
  if (typeof castType === "string") castTypeCacheKey = castType;
2061
- else if (new castType() instanceof casts_attributes_default) castTypeCacheKey = castType.name;
2038
+ else if (new castType() instanceof CastsAttributes) castTypeCacheKey = castType.name;
2062
2039
  if (castTypeCacheKey && this.getConstructor().castTypeCache[castTypeCacheKey] !== void 0) return this.getConstructor().castTypeCache[castTypeCacheKey];
2063
2040
  let convertedCastType;
2064
2041
  if (this.isCustomDateTimeCast(castType)) convertedCastType = "custom_datetime";
@@ -2078,7 +2055,7 @@ const HasAttributes = (Model$1) => {
2078
2055
  return (0, dayjs.default)(date);
2079
2056
  }
2080
2057
  isCustomCast(cast) {
2081
- return typeof cast === "function" && new cast() instanceof casts_attributes_default;
2058
+ return typeof cast === "function" && new cast() instanceof CastsAttributes;
2082
2059
  }
2083
2060
  isCustomDateTimeCast(cast) {
2084
2061
  if (typeof cast !== "string") return false;
@@ -2111,8 +2088,6 @@ const HasAttributes = (Model$1) => {
2111
2088
  }
2112
2089
  };
2113
2090
  };
2114
- var has_attributes_default = HasAttributes;
2115
-
2116
2091
  //#endregion
2117
2092
  //#region src/scope.ts
2118
2093
  var Scope = class Scope {
@@ -2123,18 +2098,16 @@ var Scope = class Scope {
2123
2098
  throw new Error("apply not implemented");
2124
2099
  }
2125
2100
  };
2126
- var scope_default = Scope;
2127
-
2128
2101
  //#endregion
2129
2102
  //#region src/concerns/has-global-scopes.ts
2130
- const HasGlobalScopes = (Model$1) => {
2131
- return class extends Model$1 {
2103
+ const HasGlobalScopes = (Model) => {
2104
+ return class extends Model {
2132
2105
  static globalScopes;
2133
2106
  static addGlobalScope(scope, implementation = null) {
2134
- if (typeof scope === "string" && implementation instanceof scope_default) {
2107
+ if (typeof scope === "string" && implementation instanceof Scope) {
2135
2108
  this.globalScopes = (0, radashi.set)(this.globalScopes ?? {}, this.name + "." + scope, implementation);
2136
2109
  return implementation;
2137
- } else if (scope instanceof scope_default) {
2110
+ } else if (scope instanceof Scope) {
2138
2111
  this.globalScopes = (0, radashi.set)(this.globalScopes ?? {}, this.name + "." + scope.constructor.name, scope);
2139
2112
  return scope;
2140
2113
  }
@@ -2158,8 +2131,6 @@ const HasGlobalScopes = (Model$1) => {
2158
2131
  }
2159
2132
  };
2160
2133
  };
2161
- var has_global_scopes_default = HasGlobalScopes;
2162
-
2163
2134
  //#endregion
2164
2135
  //#region src/hooks.ts
2165
2136
  var Hooks = class {
@@ -2187,15 +2158,13 @@ var Hooks = class {
2187
2158
  return true;
2188
2159
  }
2189
2160
  };
2190
- var hooks_default = Hooks;
2191
-
2192
2161
  //#endregion
2193
2162
  //#region src/concerns/has-hooks.ts
2194
- const HasHooks = (Model$1) => {
2195
- return class extends Model$1 {
2163
+ const HasHooks = (Model) => {
2164
+ return class extends Model {
2196
2165
  static hooks = null;
2197
2166
  static addHook(hook, callback) {
2198
- if (this.hooks instanceof hooks_default === false) this.hooks = new hooks_default();
2167
+ if (this.hooks instanceof Hooks === false) this.hooks = new Hooks();
2199
2168
  this.hooks.add(hook, callback);
2200
2169
  }
2201
2170
  static creating(callback) {
@@ -2235,20 +2204,18 @@ const HasHooks = (Model$1) => {
2235
2204
  this.addHook("forceDeleted", callback);
2236
2205
  }
2237
2206
  async execHooks(hook, options) {
2238
- if (this.constructor.hooks instanceof hooks_default === false) return;
2207
+ if (this.constructor.hooks instanceof Hooks === false) return;
2239
2208
  return await this.constructor.hooks.exec(hook, [this, options]);
2240
2209
  }
2241
2210
  };
2242
2211
  };
2243
- var has_hooks_default = HasHooks;
2244
-
2245
2212
  //#endregion
2246
2213
  //#region src/relations/has-one-or-many.ts
2247
- const HasOneOrMany = (Relation$1) => {
2248
- return class extends Relation$1 {
2214
+ const HasOneOrMany = (Relation) => {
2215
+ return class extends Relation {
2249
2216
  getRelationValue(dictionary, key, type) {
2250
2217
  const value = dictionary[key];
2251
- return type === "one" ? value[0] : new collection_default(value);
2218
+ return type === "one" ? value[0] : new Collection(value);
2252
2219
  }
2253
2220
  matchOneOrMany(models, results, relation, type) {
2254
2221
  const dictionary = this.buildDictionary(results);
@@ -2270,7 +2237,7 @@ const HasOneOrMany = (Relation$1) => {
2270
2237
  await Promise.all(models.map(async (model) => {
2271
2238
  await this.save(model);
2272
2239
  }));
2273
- return models instanceof collection_default ? models : new collection_default(models);
2240
+ return models instanceof Collection ? models : new Collection(models);
2274
2241
  }
2275
2242
  async create(attributes = {}) {
2276
2243
  return await tap(this.related.constructor.init(attributes), async (instance) => {
@@ -2282,7 +2249,7 @@ const HasOneOrMany = (Relation$1) => {
2282
2249
  const instances = await Promise.all(records.map(async (record) => {
2283
2250
  return await this.create(record);
2284
2251
  }));
2285
- return instances instanceof collection_default ? instances : new collection_default(instances);
2252
+ return instances instanceof Collection ? instances : new Collection(instances);
2286
2253
  }
2287
2254
  setForeignAttributesForCreate(model) {
2288
2255
  model[this.getForeignKeyName()] = this.getParentKey();
@@ -2309,11 +2276,9 @@ const HasOneOrMany = (Relation$1) => {
2309
2276
  }
2310
2277
  };
2311
2278
  };
2312
- var has_one_or_many_default = HasOneOrMany;
2313
-
2314
2279
  //#endregion
2315
2280
  //#region src/relations/has-many.ts
2316
- var HasMany = class extends compose(relation_default, has_one_or_many_default) {
2281
+ var HasMany = class extends compose(Relation, HasOneOrMany) {
2317
2282
  foreignKey;
2318
2283
  localKey;
2319
2284
  constructor(query, parent, foreignKey, localKey) {
@@ -2325,12 +2290,12 @@ var HasMany = class extends compose(relation_default, has_one_or_many_default) {
2325
2290
  }
2326
2291
  initRelation(models, relation) {
2327
2292
  models.map((model) => {
2328
- model.setRelation(relation, new collection_default([]));
2293
+ model.setRelation(relation, new Collection([]));
2329
2294
  });
2330
2295
  return models;
2331
2296
  }
2332
2297
  async getResults() {
2333
- return this.getParentKey() !== null ? await this.query.get() : new collection_default([]);
2298
+ return this.getParentKey() !== null ? await this.query.get() : new Collection([]);
2334
2299
  }
2335
2300
  getForeignKeyName() {
2336
2301
  var _this$foreignKey;
@@ -2348,11 +2313,9 @@ var HasMany = class extends compose(relation_default, has_one_or_many_default) {
2348
2313
  this.query.whereIn(this.foreignKey, this.getKeys(models, this.localKey));
2349
2314
  }
2350
2315
  };
2351
- var has_many_default = HasMany;
2352
-
2353
2316
  //#endregion
2354
2317
  //#region src/relations/has-one.ts
2355
- var HasOne = class extends compose(relation_default, has_one_or_many_default, supports_default_models_default) {
2318
+ var HasOne = class extends compose(Relation, HasOneOrMany, SupportsDefaultModels) {
2356
2319
  foreignKey;
2357
2320
  localKey;
2358
2321
  constructor(query, parent, foreignKey, localKey) {
@@ -2390,11 +2353,9 @@ var HasOne = class extends compose(relation_default, has_one_or_many_default, su
2390
2353
  return this.related.newInstance().setAttribute(this.getForeignKeyName(), parent[this.localKey]);
2391
2354
  }
2392
2355
  };
2393
- var has_one_default = HasOne;
2394
-
2395
2356
  //#endregion
2396
2357
  //#region src/relations/has-many-through.ts
2397
- var HasManyThrough = class extends relation_default {
2358
+ var HasManyThrough = class extends Relation {
2398
2359
  throughParent;
2399
2360
  farParent;
2400
2361
  firstKey;
@@ -2420,8 +2381,8 @@ var HasManyThrough = class extends relation_default {
2420
2381
  query = query || this.query;
2421
2382
  const farKey = this.getQualifiedFarKeyName();
2422
2383
  query.join(this.throughParent.getTable(), this.getQualifiedParentKeyName(), "=", farKey);
2423
- if (this.throughParentSoftDeletes()) query.withGlobalScope("SoftDeletableHasManyThrough", (query$1) => {
2424
- query$1.whereNull(this.throughParent.getQualifiedDeletedAtColumn());
2384
+ if (this.throughParentSoftDeletes()) query.withGlobalScope("SoftDeletableHasManyThrough", (query) => {
2385
+ query.whereNull(this.throughParent.getQualifiedDeletedAtColumn());
2425
2386
  });
2426
2387
  }
2427
2388
  getQualifiedParentKeyName() {
@@ -2572,11 +2533,9 @@ var HasManyThrough = class extends relation_default {
2572
2533
  return this.secondLocalKey;
2573
2534
  }
2574
2535
  };
2575
- var has_many_through_default = HasManyThrough;
2576
-
2577
2536
  //#endregion
2578
2537
  //#region src/relations/has-one-through.ts
2579
- var HasOneThrough = class extends compose(has_many_through_default, supports_default_models_default) {
2538
+ var HasOneThrough = class extends compose(HasManyThrough, SupportsDefaultModels) {
2580
2539
  async getResults() {
2581
2540
  return await this.first() || this.getDefaultFor(this.farParent);
2582
2541
  }
@@ -2599,12 +2558,10 @@ var HasOneThrough = class extends compose(has_many_through_default, supports_def
2599
2558
  return this.related.newInstance();
2600
2559
  }
2601
2560
  };
2602
- var has_one_through_default = HasOneThrough;
2603
-
2604
2561
  //#endregion
2605
2562
  //#region src/concerns/has-relations.ts
2606
- const HasRelations = (Model$1) => {
2607
- return class extends Model$1 {
2563
+ const HasRelations = (Model) => {
2564
+ return class extends Model {
2608
2565
  relations = {};
2609
2566
  getRelation(relation) {
2610
2567
  return this.relations[relation];
@@ -2652,14 +2609,14 @@ const HasRelations = (Model$1) => {
2652
2609
  const instance = new related();
2653
2610
  foreignKey = foreignKey || this.getForeignKey();
2654
2611
  localKey = localKey || this.getKeyName();
2655
- return new has_one_default(query, this, instance.getTable() + "." + foreignKey, localKey);
2612
+ return new HasOne(query, this, instance.getTable() + "." + foreignKey, localKey);
2656
2613
  }
2657
2614
  hasMany(related, foreignKey, localKey) {
2658
2615
  const query = related.query();
2659
2616
  const instance = new related();
2660
2617
  foreignKey = foreignKey || this.getForeignKey();
2661
2618
  localKey = localKey || this.getKeyName();
2662
- return new has_many_default(query, this, instance.getTable() + "." + foreignKey, localKey);
2619
+ return new HasMany(query, this, instance.getTable() + "." + foreignKey, localKey);
2663
2620
  }
2664
2621
  belongsTo(related, foreignKey, ownerKey, relation) {
2665
2622
  const query = related.query();
@@ -2667,7 +2624,7 @@ const HasRelations = (Model$1) => {
2667
2624
  foreignKey = foreignKey || instance.getForeignKey();
2668
2625
  ownerKey = ownerKey || instance.getKeyName();
2669
2626
  relation = relation || this.guessBelongsToRelation();
2670
- return new belongs_to_default(query, this, foreignKey, ownerKey, relation);
2627
+ return new BelongsTo(query, this, foreignKey, ownerKey, relation);
2671
2628
  }
2672
2629
  belongsToMany(related, table, foreignPivotKey, relatedPivotKey, parentKey, relatedKey) {
2673
2630
  const query = related.query();
@@ -2677,30 +2634,28 @@ const HasRelations = (Model$1) => {
2677
2634
  relatedPivotKey = relatedPivotKey || instance.getForeignKey();
2678
2635
  parentKey = parentKey || this.getKeyName();
2679
2636
  relatedKey = relatedKey || instance.getKeyName();
2680
- return new belongs_to_many_default(query, this, table, foreignPivotKey, relatedPivotKey, parentKey, relatedKey);
2637
+ return new BelongsToMany(query, this, table, foreignPivotKey, relatedPivotKey, parentKey, relatedKey);
2681
2638
  }
2682
2639
  hasOneThrough(related, through, firstKey, secondKey, localKey, secondLocalKey) {
2683
2640
  through = new through();
2684
2641
  const query = related.query();
2685
2642
  firstKey = firstKey || this.getForeignKey();
2686
2643
  secondKey = secondKey || through.getForeignKey();
2687
- return new has_one_through_default(query, this, through, firstKey, secondKey, localKey || this.getKeyName(), secondLocalKey || through.getKeyName());
2644
+ return new HasOneThrough(query, this, through, firstKey, secondKey, localKey || this.getKeyName(), secondLocalKey || through.getKeyName());
2688
2645
  }
2689
2646
  hasManyThrough(related, through, firstKey, secondKey, localKey, secondLocalKey) {
2690
2647
  through = new through();
2691
2648
  const query = related.query();
2692
2649
  firstKey = firstKey || this.getForeignKey();
2693
2650
  secondKey = secondKey || through.getForeignKey();
2694
- return new has_many_through_default(query, this, through, firstKey, secondKey, localKey || this.getKeyName(), secondLocalKey || through.getKeyName());
2651
+ return new HasManyThrough(query, this, through, firstKey, secondKey, localKey || this.getKeyName(), secondLocalKey || through.getKeyName());
2695
2652
  }
2696
2653
  };
2697
2654
  };
2698
- var has_relations_default = HasRelations;
2699
-
2700
2655
  //#endregion
2701
2656
  //#region src/concerns/has-timestamps.ts
2702
- const HasTimestamps = (Model$1) => {
2703
- return class extends Model$1 {
2657
+ const HasTimestamps = (Model) => {
2658
+ return class extends Model {
2704
2659
  static CREATED_AT = "created_at";
2705
2660
  static UPDATED_AT = "updated_at";
2706
2661
  static DELETED_AT = "deleted_at";
@@ -2741,12 +2696,10 @@ const HasTimestamps = (Model$1) => {
2741
2696
  }
2742
2697
  };
2743
2698
  };
2744
- var has_timestamps_default = HasTimestamps;
2745
-
2746
2699
  //#endregion
2747
2700
  //#region src/concerns/hides-attributes.ts
2748
- const HidesAttributes = (Model$1) => {
2749
- return class extends Model$1 {
2701
+ const HidesAttributes = (Model) => {
2702
+ return class extends Model {
2750
2703
  hidden = [];
2751
2704
  visible = [];
2752
2705
  makeVisible(...keys) {
@@ -2776,12 +2729,10 @@ const HidesAttributes = (Model$1) => {
2776
2729
  }
2777
2730
  };
2778
2731
  };
2779
- var hides_attributes_default = HidesAttributes;
2780
-
2781
2732
  //#endregion
2782
2733
  //#region src/concerns/unique-ids.ts
2783
- const UniqueIds = (Model$1) => {
2784
- return class extends Model$1 {
2734
+ const UniqueIds = (Model) => {
2735
+ return class extends Model {
2785
2736
  useUniqueIds = false;
2786
2737
  usesUniqueIds() {
2787
2738
  return this.useUniqueIds;
@@ -2795,8 +2746,6 @@ const UniqueIds = (Model$1) => {
2795
2746
  }
2796
2747
  };
2797
2748
  };
2798
- var unique_ids_default = UniqueIds;
2799
-
2800
2749
  //#endregion
2801
2750
  //#region src/paginator.ts
2802
2751
  var Paginator = class {
@@ -2815,8 +2764,11 @@ var Paginator = class {
2815
2764
  }
2816
2765
  constructor(items, total, perPage, currentPage = 1, options = {}) {
2817
2766
  this.options = options;
2818
- for (const key in options) this[key] = options[key];
2819
- this._items = new collection_default([]);
2767
+ for (const key in options) {
2768
+ const value = options[key];
2769
+ this[key] = value;
2770
+ }
2771
+ this._items = new Collection([]);
2820
2772
  this._total = total;
2821
2773
  this._perPage = parseInt(String(perPage));
2822
2774
  this._lastPage = Math.max(Math.ceil(total / perPage), 1);
@@ -2824,7 +2776,7 @@ var Paginator = class {
2824
2776
  this.setItems(items);
2825
2777
  }
2826
2778
  setItems(items) {
2827
- this._items = items instanceof collection_default ? items : new collection_default(items);
2779
+ this._items = items instanceof Collection ? items : new Collection(items);
2828
2780
  this.hasMore = this._items.count() > this._perPage;
2829
2781
  this._items = this._items.slice(0, this._perPage);
2830
2782
  }
@@ -2882,8 +2834,6 @@ var Paginator = class {
2882
2834
  return JSON.stringify(this.toData(), ...args);
2883
2835
  }
2884
2836
  };
2885
- var paginator_default = Paginator;
2886
-
2887
2837
  //#endregion
2888
2838
  //#region src/query-builder.ts
2889
2839
  const Inference$1 = class {};
@@ -3031,7 +2981,7 @@ var QueryBuilder = class QueryBuilder extends Inference$1 {
3031
2981
  this.take(perPage).skip(skip);
3032
2982
  results = await this.get();
3033
2983
  } else results = [];
3034
- return new paginator_default(results, parseInt(total), perPage, page);
2984
+ return new Paginator(results, parseInt(total), perPage, page);
3035
2985
  }
3036
2986
  forPage(page = 1, perPage = 15) {
3037
2987
  return this.offset((page - 1) * perPage).limit(perPage);
@@ -3085,8 +3035,6 @@ var QueryBuilder = class QueryBuilder extends Inference$1 {
3085
3035
  return this.connector.from;
3086
3036
  }
3087
3037
  };
3088
- var query_builder_default = QueryBuilder;
3089
-
3090
3038
  //#endregion
3091
3039
  //#region src/arquebus.ts
3092
3040
  var arquebus = class arquebus {
@@ -3162,7 +3110,7 @@ var arquebus = class arquebus {
3162
3110
  name = name || "default";
3163
3111
  const resolvedName = this.connections[name] ? name : "default";
3164
3112
  if (this.manager[resolvedName] === void 0) {
3165
- const queryBuilder = new query_builder_default(this.connections[resolvedName], arquebus.getConnectorFactory());
3113
+ const queryBuilder = new QueryBuilder(this.connections[resolvedName], arquebus.getConnectorFactory());
3166
3114
  this.manager[resolvedName] = queryBuilder;
3167
3115
  }
3168
3116
  return this.manager[resolvedName];
@@ -3211,7 +3159,7 @@ var arquebus = class arquebus {
3211
3159
  path.default.join(process.cwd(), "test")
3212
3160
  ];
3213
3161
  for (const dir of candidateDirs) {
3214
- const found = __h3ravel_shared.FileSystem.resolveFileUp("arquebus.config", [
3162
+ const found = _h3ravel_shared.FileSystem.resolveFileUp("arquebus.config", [
3215
3163
  "js",
3216
3164
  "ts",
3217
3165
  "cjs"
@@ -3242,11 +3190,11 @@ var arquebus = class arquebus {
3242
3190
  }));
3243
3191
  }
3244
3192
  createModel(name, options = {}) {
3245
- let BaseModel$1 = Model;
3246
- if ("plugins" in options) BaseModel$1 = compose(BaseModel$1, ...options.plugins ?? []);
3193
+ let BaseModel = Model;
3194
+ if ("plugins" in options) BaseModel = compose(BaseModel, ...options.plugins ?? []);
3247
3195
  this.models = {
3248
3196
  ...this.models,
3249
- [name]: class extends BaseModel$1 {
3197
+ [name]: class extends BaseModel {
3250
3198
  table = (options === null || options === void 0 ? void 0 : options.table) ?? null;
3251
3199
  connection = (options === null || options === void 0 ? void 0 : options.connection) ?? null;
3252
3200
  timestamps = (options === null || options === void 0 ? void 0 : options.timestamps) ?? true;
@@ -3261,7 +3209,7 @@ var arquebus = class arquebus {
3261
3209
  }
3262
3210
  };
3263
3211
  if ("attributes" in options) for (const attribute in options.attributes) {
3264
- if (options.attributes[attribute] instanceof attribute_default === false) throw new Error("Attribute must be an instance of \"Attribute\"");
3212
+ if (options.attributes[attribute] instanceof Attribute === false) throw new Error("Attribute must be an instance of \"Attribute\"");
3265
3213
  this.models[name].prototype[getAttrMethod(attribute)] = () => {
3266
3214
  var _options$attributes;
3267
3215
  return (_options$attributes = options.attributes) === null || _options$attributes === void 0 ? void 0 : _options$attributes[attribute];
@@ -3276,12 +3224,10 @@ var arquebus = class arquebus {
3276
3224
  return this.models[name];
3277
3225
  }
3278
3226
  };
3279
- var arquebus_default = arquebus;
3280
-
3281
3227
  //#endregion
3282
3228
  //#region src/model.ts
3283
3229
  const ModelClass = class {};
3284
- const BaseModel = compose(ModelClass, has_attributes_default, hides_attributes_default, has_relations_default, has_timestamps_default, has_hooks_default, has_global_scopes_default, unique_ids_default);
3230
+ const BaseModel = compose(ModelClass, HasAttributes, HidesAttributes, HasRelations, HasTimestamps, HasHooks, HasGlobalScopes, UniqueIds);
3285
3231
  var Model = class Model extends BaseModel {
3286
3232
  builder = null;
3287
3233
  table = null;
@@ -3333,8 +3279,8 @@ var Model = class Model extends BaseModel {
3333
3279
  else {
3334
3280
  const relation = this[getRelationMethod(attribute)]();
3335
3281
  const related = relation.getRelated().constructor;
3336
- if (relation instanceof has_one_default || relation instanceof belongs_to_default) this.setRelation(attribute, related.make(attributes[attribute]));
3337
- else if ((relation instanceof has_many_default || relation instanceof belongs_to_many_default) && Array.isArray(attributes[attribute])) this.setRelation(attribute, new collection_default(attributes[attribute].map((item) => related.make(item))));
3282
+ if (relation instanceof HasOne || relation instanceof BelongsTo) this.setRelation(attribute, related.make(attributes[attribute]));
3283
+ else if ((relation instanceof HasMany || relation instanceof BelongsToMany) && Array.isArray(attributes[attribute])) this.setRelation(attribute, new Collection(attributes[attribute].map((item) => related.make(item))));
3338
3284
  }
3339
3285
  }
3340
3286
  getConstructor() {
@@ -3411,7 +3357,7 @@ var Model = class Model extends BaseModel {
3411
3357
  }
3412
3358
  getConnection() {
3413
3359
  if (this.constructor.resolver) return this.constructor.resolver.getConnection(this.connection);
3414
- return arquebus_default.fire(this.connection);
3360
+ return arquebus.fire(this.connection);
3415
3361
  }
3416
3362
  setConnection(connection) {
3417
3363
  this.connection = connection;
@@ -3427,7 +3373,7 @@ var Model = class Model extends BaseModel {
3427
3373
  return this.newModelQuery(trx).with(this.with).withCount(this.withCount);
3428
3374
  }
3429
3375
  newModelQuery(trx = null) {
3430
- return new builder_default(trx || this.getConnection()).setModel(this);
3376
+ return new Builder(trx || this.getConnection()).setModel(this);
3431
3377
  }
3432
3378
  addGlobalScopes(builder) {
3433
3379
  const globalScopes = this.getGlobalScopes();
@@ -3450,14 +3396,14 @@ var Model = class Model extends BaseModel {
3450
3396
  return this;
3451
3397
  }
3452
3398
  newCollection(models = []) {
3453
- return new collection_default(models);
3399
+ return new Collection(models);
3454
3400
  }
3455
3401
  async load(...relations) {
3456
3402
  await this.constructor.query().with(...relations).eagerLoadRelations([this]);
3457
3403
  return this;
3458
3404
  }
3459
3405
  async loadAggregate(relations, column, callback = null) {
3460
- await new collection_default([this]).loadAggregate(relations, column, callback);
3406
+ await new Collection([this]).loadAggregate(relations, column, callback);
3461
3407
  return this;
3462
3408
  }
3463
3409
  async loadCount(...relations) {
@@ -3586,7 +3532,8 @@ var Model = class Model extends BaseModel {
3586
3532
  }
3587
3533
  async refresh() {
3588
3534
  if (!this.exists) return Promise.resolve(void 0);
3589
- this.attributes = { ...(await this.constructor.query().where(this.getKeyName(), this.getKey()).first()).attributes };
3535
+ const model = await this.constructor.query().where(this.getKeyName(), this.getKey()).first();
3536
+ this.attributes = { ...model.attributes };
3590
3537
  await this.load((0, collect_js.default)(this.relations).reject((relation) => {
3591
3538
  return relation instanceof Pivot;
3592
3539
  }).keys().all());
@@ -3607,7 +3554,7 @@ var Model = class Model extends BaseModel {
3607
3554
  if (!await this.save(options)) return false;
3608
3555
  for (const relation in this.relations) {
3609
3556
  let models = this.relations[relation];
3610
- models = models instanceof collection_default ? models.all() : [models];
3557
+ models = models instanceof Collection ? models.all() : [models];
3611
3558
  for (const model of models) if (!await model.push(options)) return false;
3612
3559
  }
3613
3560
  return true;
@@ -3649,8 +3596,6 @@ var Pivot = class extends Model {
3649
3596
  return (attributes || this.attributes)[this.constructor.CREATED_AT] !== void 0;
3650
3597
  }
3651
3598
  };
3652
- var model_default = Model;
3653
-
3654
3599
  //#endregion
3655
3600
  //#region src/collection.ts
3656
3601
  var Collection = class Collection extends collect_js.Collection {
@@ -3700,7 +3645,7 @@ var Collection = class Collection extends collect_js.Collection {
3700
3645
  }
3701
3646
  contains(key, operator, value) {
3702
3647
  if (arguments.length > 1) return super.contains(key, value ?? operator);
3703
- if (key instanceof model_default) return super.contains((model) => {
3648
+ if (key instanceof Model) return super.contains((model) => {
3704
3649
  return model.is(key);
3705
3650
  });
3706
3651
  return super.contains((model) => {
@@ -3731,7 +3676,7 @@ var Collection = class Collection extends collect_js.Collection {
3731
3676
  return new this.constructor(Object.values(this.getDictionary()));
3732
3677
  }
3733
3678
  find(key, defaultValue = null) {
3734
- if (key instanceof model_default) key = key.getKey();
3679
+ if (key instanceof Model) key = key.getKey();
3735
3680
  if ((0, radashi.isArray)(key)) {
3736
3681
  if (this.isEmpty()) return new this.constructor();
3737
3682
  return this.whereIn(this.first().getKeyName(), key);
@@ -3747,10 +3692,10 @@ var Collection = class Collection extends collect_js.Collection {
3747
3692
  if (this.isEmpty()) return new this.constructor();
3748
3693
  const model = this.first();
3749
3694
  const freshModels = (await model.newQuery().with(...args).whereIn(model.getKeyName(), this.modelKeys()).get()).getDictionary();
3750
- return this.filter((model$1) => {
3751
- return model$1.exists && freshModels[model$1.getKey()] !== void 0;
3752
- }).map((model$1) => {
3753
- return freshModels[model$1.getKey()];
3695
+ return this.filter((model) => {
3696
+ return model.exists && freshModels[model.getKey()] !== void 0;
3697
+ }).map((model) => {
3698
+ return freshModels[model.getKey()];
3754
3699
  });
3755
3700
  }
3756
3701
  makeVisible(attributes) {
@@ -3785,8 +3730,8 @@ var Collection = class Collection extends collect_js.Collection {
3785
3730
  const model = this.first();
3786
3731
  if (!model) throw new Error("Unable to create query for empty collection.");
3787
3732
  const modelName = model.constructor.name;
3788
- if (this.filter((model$1) => {
3789
- return !(model$1 instanceof modelName);
3733
+ if (this.filter((model) => {
3734
+ return !(model instanceof modelName);
3790
3735
  }).isNotEmpty()) throw new Error("Unable to create query for collection with mixed types.");
3791
3736
  return model.newModelQuery().whereKey(this.modelKeys());
3792
3737
  }
@@ -3811,12 +3756,10 @@ var Collection = class Collection extends collect_js.Collection {
3811
3756
  } };
3812
3757
  };
3813
3758
  };
3814
- var collection_default = Collection;
3815
-
3816
3759
  //#endregion
3817
3760
  //#region src/relations/concerns/interacts-with-pivot-table.ts
3818
- const InteractsWithPivotTable = (Relation$1) => {
3819
- return class extends Relation$1 {
3761
+ const InteractsWithPivotTable = (Relation) => {
3762
+ return class extends Relation {
3820
3763
  newExistingPivot(attributes = []) {
3821
3764
  return this.newPivot(attributes, true);
3822
3765
  }
@@ -3998,16 +3941,14 @@ const InteractsWithPivotTable = (Relation$1) => {
3998
3941
  }
3999
3942
  parseIds(value) {
4000
3943
  if (value instanceof Model) return [value[this.relatedKey]];
4001
- if (value instanceof collection_default) return value.pluck(this.relatedKey).all();
3944
+ if (value instanceof Collection) return value.pluck(this.relatedKey).all();
4002
3945
  return (0, radashi.isArray)(value) ? value : [value];
4003
3946
  }
4004
3947
  };
4005
3948
  };
4006
- var interacts_with_pivot_table_default = InteractsWithPivotTable;
4007
-
4008
3949
  //#endregion
4009
3950
  //#region src/relations/belongs-to-many.ts
4010
- var BelongsToMany = class extends compose(relation_default, interacts_with_pivot_table_default) {
3951
+ var BelongsToMany = class extends compose(Relation, InteractsWithPivotTable) {
4011
3952
  table;
4012
3953
  foreignPivotKey;
4013
3954
  relatedPivotKey;
@@ -4034,7 +3975,7 @@ var BelongsToMany = class extends compose(relation_default, interacts_with_pivot
4034
3975
  }
4035
3976
  initRelation(models, relation) {
4036
3977
  models.map((model) => {
4037
- model.setRelation(relation, new collection_default([]));
3978
+ model.setRelation(relation, new Collection([]));
4038
3979
  });
4039
3980
  return models;
4040
3981
  }
@@ -4054,7 +3995,7 @@ var BelongsToMany = class extends compose(relation_default, interacts_with_pivot
4054
3995
  return this.related.qualifyColumn(this.relatedKey);
4055
3996
  }
4056
3997
  async getResults() {
4057
- return this.parent[this.parentKey] !== null ? await this.get() : new collection_default([]);
3998
+ return this.parent[this.parentKey] !== null ? await this.get() : new Collection([]);
4058
3999
  }
4059
4000
  addWhereConstraints() {
4060
4001
  this.query.where(this.getQualifiedForeignPivotKeyName(), "=", this.parent[this.parentKey]);
@@ -4067,7 +4008,7 @@ var BelongsToMany = class extends compose(relation_default, interacts_with_pivot
4067
4008
  let models = await builder.select(this.shouldSelect(columns)).getModels();
4068
4009
  this.hydratePivotRelation(models);
4069
4010
  if (models.length > 0) models = await builder.eagerLoadRelations(models);
4070
- return new collection_default(models);
4011
+ return new Collection(models);
4071
4012
  }
4072
4013
  async first(columns = ["*"]) {
4073
4014
  const results = await this.take(1).get(columns);
@@ -4146,7 +4087,7 @@ var BelongsToMany = class extends compose(relation_default, interacts_with_pivot
4146
4087
  const dictionary = {};
4147
4088
  results.map((result) => {
4148
4089
  const value = result[this.accessor][this.foreignPivotKey];
4149
- if (dictionary[value] === void 0) dictionary[value] = new collection_default([]);
4090
+ if (dictionary[value] === void 0) dictionary[value] = new Collection([]);
4150
4091
  dictionary[value].push(result);
4151
4092
  });
4152
4093
  return dictionary;
@@ -4228,8 +4169,6 @@ var BelongsToMany = class extends compose(relation_default, interacts_with_pivot
4228
4169
  return super.getRelationExistenceQuery(query, parentQuery, columns);
4229
4170
  }
4230
4171
  };
4231
- var belongs_to_many_default = BelongsToMany;
4232
-
4233
4172
  //#endregion
4234
4173
  //#region src/builder.ts
4235
4174
  const Inference = class {};
@@ -4465,7 +4404,7 @@ var Builder = class Builder extends Inference {
4465
4404
  if (!this.globalScopes) return this;
4466
4405
  for (const identifier in this.globalScopes) {
4467
4406
  const scope = this.globalScopes[identifier];
4468
- if (scope instanceof scope_default) scope.apply(this, this.getModel());
4407
+ if (scope instanceof Scope) scope.apply(this, this.getModel());
4469
4408
  else scope(this);
4470
4409
  }
4471
4410
  return this;
@@ -4644,7 +4583,7 @@ var Builder = class Builder extends Inference {
4644
4583
  return this.parseSub(query);
4645
4584
  }
4646
4585
  parseSub(query) {
4647
- if (query instanceof Builder || query instanceof relation_default) return [query.toSql().sql, query.toSql().bindings];
4586
+ if (query instanceof Builder || query instanceof Relation) return [query.toSql().sql, query.toSql().bindings];
4648
4587
  else if ((0, radashi.isString)(query)) return [query, []];
4649
4588
  else throw new Error("A subquery must be a query builder instance, a Closure, or a string.");
4650
4589
  }
@@ -4656,7 +4595,7 @@ var Builder = class Builder extends Inference {
4656
4595
  return query;
4657
4596
  }
4658
4597
  getRelationWithoutConstraints(relation) {
4659
- return relation_default.noConstraints(() => {
4598
+ return Relation.noConstraints(() => {
4660
4599
  return this.getModel()[relation]();
4661
4600
  });
4662
4601
  }
@@ -4730,7 +4669,7 @@ var Builder = class Builder extends Inference {
4730
4669
  return [name.split(":")[0], (query) => {
4731
4670
  query.select(name.split(":")[1].split(",").map((column) => {
4732
4671
  if (column.includes(".")) return column;
4733
- return query instanceof belongs_to_many_default ? query.related.getTable() + "." + column : column;
4672
+ return query instanceof BelongsToMany ? query.related.getTable() + "." + column : column;
4734
4673
  }));
4735
4674
  }];
4736
4675
  }
@@ -4778,8 +4717,8 @@ var Builder = class Builder extends Inference {
4778
4717
  async firstOrCreate(attributes = {}, values = {}) {
4779
4718
  const instance = await this.where(attributes).first();
4780
4719
  if (instance !== null) return instance;
4781
- return tap(this.newModelInstance((0, radashi.assign)(attributes, values)), async (instance$1) => {
4782
- await instance$1.save({ client: this.query });
4720
+ return tap(this.newModelInstance((0, radashi.assign)(attributes, values)), async (instance) => {
4721
+ await instance.save({ client: this.query });
4783
4722
  });
4784
4723
  }
4785
4724
  async updateOrCreate(attributes, values = {}) {
@@ -4798,20 +4737,20 @@ var Builder = class Builder extends Inference {
4798
4737
  return this;
4799
4738
  }
4800
4739
  async find(id, columns) {
4801
- if ((0, radashi.isArray)(id) || id instanceof collection_default) return await this.findMany(id, columns);
4740
+ if ((0, radashi.isArray)(id) || id instanceof Collection) return await this.findMany(id, columns);
4802
4741
  return await this.where(this.model.getKeyName(), id).first(columns);
4803
4742
  }
4804
4743
  async findMany(ids, columns = ["*"]) {
4805
- if (ids instanceof collection_default) ids = ids.modelKeys();
4744
+ if (ids instanceof Collection) ids = ids.modelKeys();
4806
4745
  ids = (0, radashi.isArray)(ids) ? ids : [ids];
4807
- if (ids.length === 0) return new collection_default([]);
4746
+ if (ids.length === 0) return new Collection([]);
4808
4747
  return await this.whereIn(this.model.getKeyName(), ids).get(columns);
4809
4748
  }
4810
4749
  async pluck(column) {
4811
- return new collection_default(await this.query.pluck(column));
4750
+ return new Collection(await this.query.pluck(column));
4812
4751
  }
4813
4752
  async destroy(ids) {
4814
- if (ids instanceof collection_default) ids = ids.modelKeys();
4753
+ if (ids instanceof Collection) ids = ids.modelKeys();
4815
4754
  if (ids instanceof collect_js.Collection) ids = ids.all();
4816
4755
  ids = (0, radashi.isArray)(ids) ? ids : Array.prototype.slice.call(ids);
4817
4756
  if (ids.length === 0) return 0;
@@ -4825,7 +4764,7 @@ var Builder = class Builder extends Inference {
4825
4764
  this.applyScopes();
4826
4765
  let models = await this.getModels(columns);
4827
4766
  if (models.length > 0) models = await this.eagerLoadRelations(models);
4828
- return new collection_default(models);
4767
+ return new Collection(models);
4829
4768
  }
4830
4769
  async all(columns = ["*"]) {
4831
4770
  return await this.model.newModelQuery().get(columns);
@@ -4843,7 +4782,7 @@ var Builder = class Builder extends Inference {
4843
4782
  results = await this.getModels();
4844
4783
  if (results.length > 0) results = await this.eagerLoadRelations(results);
4845
4784
  } else results = [];
4846
- return new paginator_default(results, parseInt(total), perPage, page);
4785
+ return new Paginator(results, parseInt(total), perPage, page);
4847
4786
  }
4848
4787
  async getModels(...columns) {
4849
4788
  columns = (0, radashi.flat)(columns);
@@ -4854,7 +4793,7 @@ var Builder = class Builder extends Inference {
4854
4793
  }
4855
4794
  getRelation(name) {
4856
4795
  if (typeof this.model[getRelationMethod(name)] !== "function") throw new RelationNotFoundError(`Model [${this.model.constructor.name}]'s relation [${name}] doesn't exist.`);
4857
- const relation = relation_default.noConstraints(() => this.model.newInstance(this.model.attributes)[getRelationMethod(name)]());
4796
+ const relation = Relation.noConstraints(() => this.model.newInstance(this.model.attributes)[getRelationMethod(name)]());
4858
4797
  const nested = this.relationsNestedUnder(name);
4859
4798
  if (Object.keys(nested).length > 0) relation.query.with(nested);
4860
4799
  return relation.asProxy();
@@ -4884,14 +4823,12 @@ var Builder = class Builder extends Inference {
4884
4823
  return models;
4885
4824
  }
4886
4825
  hydrate(items) {
4887
- return new collection_default(items.map((item) => {
4826
+ return new Collection(items.map((item) => {
4888
4827
  if (!this.model) return item;
4889
4828
  return this.model.newFromBuilder(item);
4890
4829
  }));
4891
4830
  }
4892
4831
  };
4893
- var builder_default = Builder;
4894
-
4895
4832
  //#endregion
4896
4833
  //#region src/inspector/dialects/sqlite.ts
4897
4834
  function parseDefaultValue(value) {
@@ -4900,8 +4837,8 @@ function parseDefaultValue(value) {
4900
4837
  }
4901
4838
  var SQLite = class {
4902
4839
  knex;
4903
- constructor(knex$1) {
4904
- this.knex = knex$1;
4840
+ constructor(knex) {
4841
+ this.knex = knex;
4905
4842
  }
4906
4843
  /**
4907
4844
  * List all existing tables in the current schema/database
@@ -4913,9 +4850,9 @@ var SQLite = class {
4913
4850
  const query = this.knex.select("name", "sql").from("sqlite_master").where({ type: "table" }).andWhereRaw("name NOT LIKE 'sqlite_%'");
4914
4851
  if (table) query.andWhere({ name: table });
4915
4852
  let records = await query;
4916
- records = records.map((table$1) => ({
4917
- name: table$1.name,
4918
- sql: table$1.sql
4853
+ records = records.map((table) => ({
4854
+ name: table.name,
4855
+ sql: table.sql
4919
4856
  }));
4920
4857
  if (table) return records[0];
4921
4858
  return records;
@@ -4938,14 +4875,14 @@ var SQLite = class {
4938
4875
  column: column.name
4939
4876
  }));
4940
4877
  const tables = await this.tables();
4941
- return flatten(await Promise.all(tables.map(async (table$1) => await this.columns(table$1))));
4878
+ return flatten$2(await Promise.all(tables.map(async (table) => await this.columns(table))));
4942
4879
  }
4943
4880
  async columnInfo(table, column) {
4944
- const getColumnsForTable = async (table$1) => {
4881
+ const getColumnsForTable = async (table) => {
4945
4882
  const tablesWithAutoIncrementPrimaryKeys = (await this.knex.select("name").from("sqlite_master").whereRaw("sql LIKE '%AUTOINCREMENT%'")).map(({ name }) => name);
4946
- const columns = await this.knex.raw("PRAGMA table_xinfo(??)", table$1);
4947
- const foreignKeys = await this.knex.raw("PRAGMA foreign_key_list(??)", table$1);
4948
- const indexList = await this.knex.raw("PRAGMA index_list(??)", table$1);
4883
+ const columns = await this.knex.raw("PRAGMA table_xinfo(??)", table);
4884
+ const foreignKeys = await this.knex.raw("PRAGMA foreign_key_list(??)", table);
4885
+ const indexList = await this.knex.raw("PRAGMA index_list(??)", table);
4949
4886
  const indexInfoList = await Promise.all(indexList.map((index) => this.knex.raw("PRAGMA index_info(??)", index.name)));
4950
4887
  return columns.map((raw) => {
4951
4888
  const foreignKey = foreignKeys.find((fk) => fk.from === raw.name);
@@ -4954,10 +4891,11 @@ var SQLite = class {
4954
4891
  const indexInfo = indexInfoList[indexIndex];
4955
4892
  return {
4956
4893
  name: raw.name,
4957
- table: table$1,
4894
+ table,
4958
4895
  data_type: extractType(raw.type),
4959
4896
  default_value: parseDefaultValue(raw.dflt_value),
4960
4897
  max_length: extractMaxLength(raw.type),
4898
+ /** @NOTE SQLite3 doesn't support precision/scale */
4961
4899
  numeric_precision: null,
4962
4900
  numeric_scale: null,
4963
4901
  is_generated: raw.hidden !== 0,
@@ -4965,7 +4903,7 @@ var SQLite = class {
4965
4903
  is_nullable: raw.notnull === 0,
4966
4904
  is_unique: !!(index === null || index === void 0 ? void 0 : index.unique) && (indexInfo === null || indexInfo === void 0 ? void 0 : indexInfo.length) === 1,
4967
4905
  is_primary_key: raw.pk === 1,
4968
- has_auto_increment: raw.pk === 1 && tablesWithAutoIncrementPrimaryKeys.includes(table$1),
4906
+ has_auto_increment: raw.pk === 1 && tablesWithAutoIncrementPrimaryKeys.includes(table),
4969
4907
  foreign_key_column: (foreignKey === null || foreignKey === void 0 ? void 0 : foreignKey.to) || null,
4970
4908
  foreign_key_table: (foreignKey === null || foreignKey === void 0 ? void 0 : foreignKey.table) || null
4971
4909
  };
@@ -4973,7 +4911,7 @@ var SQLite = class {
4973
4911
  };
4974
4912
  if (!table) {
4975
4913
  const tables = await this.tables();
4976
- return flatten(await Promise.all(tables.map(async (table$1) => await getColumnsForTable(table$1))));
4914
+ return flatten$2(await Promise.all(tables.map(async (table) => await getColumnsForTable(table))));
4977
4915
  }
4978
4916
  if (table && !column) return await getColumnsForTable(table);
4979
4917
  return (await getColumnsForTable(table)).find((columnInfo) => columnInfo.name === column);
@@ -5004,7 +4942,7 @@ var SQLite = class {
5004
4942
  constraint_name: null
5005
4943
  }));
5006
4944
  const tables = await this.tables();
5007
- return flatten(await Promise.all(tables.map(async (table$1) => await this.foreignKeys(table$1))));
4945
+ return flatten$2(await Promise.all(tables.map(async (table) => await this.foreignKeys(table))));
5008
4946
  }
5009
4947
  async uniqueConstraints(table) {
5010
4948
  if (table) {
@@ -5020,16 +4958,15 @@ var SQLite = class {
5020
4958
  });
5021
4959
  }
5022
4960
  const tables = await this.tables();
5023
- return flatten(await Promise.all(tables.map(async (table$1) => await this.uniqueConstraints(table$1))));
4961
+ return flatten$2(await Promise.all(tables.map(async (table) => await this.uniqueConstraints(table))));
5024
4962
  }
5025
4963
  };
5026
-
5027
4964
  //#endregion
5028
4965
  //#region src/inspector/index.ts
5029
4966
  var SchemaInspector = class {
5030
- static inspect(knex$1) {
4967
+ static inspect(knex) {
5031
4968
  let constructor;
5032
- switch (knex$1.client.constructor.name) {
4969
+ switch (knex.client.constructor.name) {
5033
4970
  case "Client_MySQL":
5034
4971
  case "Client_MySQL2":
5035
4972
  constructor = MySQL;
@@ -5051,12 +4988,11 @@ var SchemaInspector = class {
5051
4988
  case "Client_MSSQL":
5052
4989
  constructor = MSSQL;
5053
4990
  break;
5054
- default: throw Error("Unsupported driver used: " + knex$1.client.constructor.name);
4991
+ default: throw Error("Unsupported driver used: " + knex.client.constructor.name);
5055
4992
  }
5056
- return new constructor(knex$1);
4993
+ return new constructor(knex);
5057
4994
  }
5058
4995
  };
5059
-
5060
4996
  //#endregion
5061
4997
  //#region src/migrations/migrator.ts
5062
4998
  async function glob(folderPath) {
@@ -5099,13 +5035,13 @@ var Migrator = class {
5099
5035
  }
5100
5036
  async runPending(migrations, options = {}) {
5101
5037
  if (migrations.length === 0 && !options.quiet) {
5102
- __h3ravel_shared.Logger.info("INFO: Nothing to migrate.");
5038
+ _h3ravel_shared.Logger.info("INFO: Nothing to migrate.");
5103
5039
  return;
5104
5040
  }
5105
5041
  let batch = await this.repository.getNextBatchNumber();
5106
5042
  const pretend = options.pretend || false;
5107
5043
  const step = options.step || false;
5108
- __h3ravel_shared.Logger.info("INFO: Running migrations...");
5044
+ _h3ravel_shared.Logger.info("INFO: Running migrations...");
5109
5045
  for (const file of migrations) {
5110
5046
  await this.runUp(file, batch, pretend);
5111
5047
  if (step) batch++;
@@ -5114,19 +5050,19 @@ var Migrator = class {
5114
5050
  async runUp(file, batch, _pretend) {
5115
5051
  const migration = await this.resolvePath(file);
5116
5052
  const name = this.getMigrationName(file);
5117
- await __h3ravel_shared.TaskManager.taskRunner(name, () => this.runMigration(migration, "up"));
5053
+ await _h3ravel_shared.TaskManager.taskRunner(name, () => this.runMigration(migration, "up"));
5118
5054
  await this.repository.log(name, batch);
5119
5055
  }
5120
5056
  async runDown(file, migration, _pretend) {
5121
5057
  const instance = await this.resolvePath(file);
5122
5058
  const name = this.getMigrationName(file);
5123
- await __h3ravel_shared.TaskManager.taskRunner(name, () => this.runMigration(instance, "down"));
5059
+ await _h3ravel_shared.TaskManager.taskRunner(name, () => this.runMigration(instance, "down"));
5124
5060
  await this.repository.delete(migration);
5125
5061
  }
5126
5062
  async rollback(paths = [], options = {}) {
5127
5063
  const migrations = await this.getMigrationsForRollback(options);
5128
5064
  if (migrations.length === 0) {
5129
- __h3ravel_shared.Logger.info("INFO: Nothing to rollback");
5065
+ _h3ravel_shared.Logger.info("INFO: Nothing to rollback");
5130
5066
  return [];
5131
5067
  }
5132
5068
  return await this.rollbackMigrations(migrations, paths, options);
@@ -5139,11 +5075,11 @@ var Migrator = class {
5139
5075
  async rollbackMigrations(migrations, paths, options) {
5140
5076
  const rolledBack = [];
5141
5077
  const files = await this.getMigrationFiles(paths);
5142
- __h3ravel_shared.Logger.info("INFO: Rolling back migrations...");
5078
+ _h3ravel_shared.Logger.info("INFO: Rolling back migrations...");
5143
5079
  for (const migration of migrations) {
5144
5080
  const file = files[migration.migration];
5145
5081
  if (!file) {
5146
- __h3ravel_shared.Logger.twoColumnDetail(__h3ravel_shared.Logger.parse([[migration.migration, "green"]], "", false), __h3ravel_shared.Logger.parse([["Migration not found", "yellow"]], "", false));
5082
+ _h3ravel_shared.Logger.twoColumnDetail(_h3ravel_shared.Logger.parse([[migration.migration, "green"]], "", false), _h3ravel_shared.Logger.parse([["Migration not found", "yellow"]], "", false));
5147
5083
  continue;
5148
5084
  }
5149
5085
  rolledBack.push(file);
@@ -5154,7 +5090,7 @@ var Migrator = class {
5154
5090
  async reset(paths = [], options, pretend = false) {
5155
5091
  const migrations = await this.repository.getRan().then((r) => r.map((e) => ({ migration: e })).reverse());
5156
5092
  if (migrations.length === 0) {
5157
- if (!options.quiet) __h3ravel_shared.Logger.info("INFO: Nothing to reset.");
5093
+ if (!options.quiet) _h3ravel_shared.Logger.info("INFO: Nothing to reset.");
5158
5094
  return [];
5159
5095
  }
5160
5096
  return this.resetMigrations(migrations, paths, pretend);
@@ -5171,7 +5107,7 @@ var Migrator = class {
5171
5107
  const inspector = SchemaInspector.inspect(connection);
5172
5108
  await connection.raw("SET foreign_key_checks = 0");
5173
5109
  /** Drop all existing tables */
5174
- for (const table of await inspector.tables()) await __h3ravel_shared.TaskManager.taskRunner(`Dropping ${__h3ravel_shared.Logger.parse([[table, "grey"]], "", false)} table`, () => connection.schema.dropTableIfExists(table));
5110
+ for (const table of await inspector.tables()) await _h3ravel_shared.TaskManager.taskRunner(`Dropping ${_h3ravel_shared.Logger.parse([[table, "grey"]], "", false)} table`, () => connection.schema.dropTableIfExists(table));
5175
5111
  await connection.raw("SET foreign_key_checks = 1");
5176
5112
  /** Create the migration repository */
5177
5113
  await this.repository.createRepository();
@@ -5253,11 +5189,11 @@ var Migrator = class {
5253
5189
  if (this.output) console.log(...args);
5254
5190
  }
5255
5191
  };
5256
- var migrator_default = Migrator;
5257
-
5258
5192
  //#endregion
5259
5193
  //#region src/migrate.ts
5260
5194
  var Migrate = class {
5195
+ basePath;
5196
+ customStubPath;
5261
5197
  callback;
5262
5198
  constructor(basePath, customStubPath, callback) {
5263
5199
  this.basePath = basePath;
@@ -5272,14 +5208,14 @@ var Migrate = class {
5272
5208
  * @param destroyAll
5273
5209
  */
5274
5210
  async run(config, options = {}, destroyAll = false) {
5275
- const { arquebus: arquebus$1, migrator } = await this.setupConnection(config);
5211
+ const { arquebus, migrator } = await this.setupConnection(config);
5276
5212
  await this.prepareDatabase(migrator);
5277
5213
  const paths = await Utils.getMigrationPaths(this.basePath ?? process.cwd(), migrator, config.migrations.path, options.path);
5278
5214
  await migrator.setOutput(true).run(paths, {
5279
5215
  step: options.step,
5280
5216
  pretend: options.pretend
5281
5217
  });
5282
- if (destroyAll) await arquebus$1.destroyAll();
5218
+ if (destroyAll) await arquebus.destroyAll();
5283
5219
  }
5284
5220
  /**
5285
5221
  * Rollback the last migration
@@ -5289,14 +5225,14 @@ var Migrate = class {
5289
5225
  * @param destroyAll
5290
5226
  */
5291
5227
  async rollback(config, options = {}, destroyAll = false) {
5292
- const { arquebus: arquebus$1, migrator } = await this.setupConnection(config);
5228
+ const { arquebus, migrator } = await this.setupConnection(config);
5293
5229
  const paths = await Utils.getMigrationPaths(this.basePath ?? process.cwd(), migrator, config.migrations.path, options.path);
5294
5230
  await migrator.setOutput(true).rollback(paths, {
5295
5231
  step: options.step || 0,
5296
5232
  pretend: options.pretend,
5297
5233
  batch: options.batch || 0
5298
5234
  });
5299
- if (destroyAll) await arquebus$1.destroyAll();
5235
+ if (destroyAll) await arquebus.destroyAll();
5300
5236
  }
5301
5237
  /**
5302
5238
  * Rollback all database migrations
@@ -5306,7 +5242,7 @@ var Migrate = class {
5306
5242
  * @param destroyAll
5307
5243
  */
5308
5244
  async reset(config, options = {}, destroyAll = false) {
5309
- const { arquebus: arquebus$1, migrator } = await this.setupConnection(config);
5245
+ const { arquebus, migrator } = await this.setupConnection(config);
5310
5246
  const paths = await Utils.getMigrationPaths(this.basePath ?? process.cwd(), migrator, config.migrations.path, options.path);
5311
5247
  await migrator.setOutput(true).reset(paths, {
5312
5248
  step: options.step || 0,
@@ -5314,7 +5250,7 @@ var Migrate = class {
5314
5250
  batch: options.batch || 0,
5315
5251
  quiet: options.quiet || false
5316
5252
  });
5317
- if (destroyAll) await arquebus$1.destroyAll();
5253
+ if (destroyAll) await arquebus.destroyAll();
5318
5254
  }
5319
5255
  /**
5320
5256
  * Reset and re-run all migrations
@@ -5336,10 +5272,10 @@ var Migrate = class {
5336
5272
  * @param destroyAll
5337
5273
  */
5338
5274
  async fresh(config, options = {}, destroyAll = false) {
5339
- const { arquebus: arquebus$1, migrator } = await this.setupConnection(config);
5275
+ const { arquebus, migrator } = await this.setupConnection(config);
5340
5276
  const paths = await Utils.getMigrationPaths(this.basePath ?? process.cwd(), migrator, config.migrations.path, options.path);
5341
5277
  await migrator.setOutput(true).fresh(paths, { pretend: options.pretend });
5342
- if (destroyAll) await arquebus$1.destroyAll();
5278
+ if (destroyAll) await arquebus.destroyAll();
5343
5279
  }
5344
5280
  /**
5345
5281
  * Prepares the database for migration
@@ -5363,7 +5299,7 @@ var Migrate = class {
5363
5299
  * @returns
5364
5300
  */
5365
5301
  async status(config, options = {}, destroyAll = false) {
5366
- const { arquebus: arquebus$1, migrator } = await this.setupConnection(config);
5302
+ const { arquebus, migrator } = await this.setupConnection(config);
5367
5303
  const getAllMigrationFiles = async () => {
5368
5304
  return await migrator.getMigrationFiles(await Utils.getMigrationPaths(this.basePath ?? process.cwd(), migrator, config.migrations.path, options.path));
5369
5305
  };
@@ -5380,7 +5316,7 @@ var Migrate = class {
5380
5316
  }
5381
5317
  if (!await migrator.repositoryExists()) this.callback("ERROR: Migration table does not exist.", "error");
5382
5318
  const migrations = await getStatusFor(await migrator.repository.getRan(), await migrator.getRepository().getMigrationBatches());
5383
- if (destroyAll) await arquebus$1.destroyAll();
5319
+ if (destroyAll) await arquebus.destroyAll();
5384
5320
  return migrations;
5385
5321
  }
5386
5322
  /**
@@ -5393,21 +5329,22 @@ var Migrate = class {
5393
5329
  var _config$migrations;
5394
5330
  const table = (config === null || config === void 0 || (_config$migrations = config.migrations) === null || _config$migrations === void 0 ? void 0 : _config$migrations.table) || "migrations";
5395
5331
  if (config.skipConnection !== true) {
5396
- arquebus_default.addConnection(config, "default");
5332
+ arquebus.addConnection(config, "default");
5397
5333
  Object.entries(config.connections || {}).forEach(([name, connection]) => {
5398
- arquebus_default.addConnection(connection, name);
5334
+ arquebus.addConnection(connection, name);
5399
5335
  });
5400
5336
  }
5401
5337
  return {
5402
- arquebus: arquebus_default,
5403
- migrator: new migrator_default(new MigrationRepository(arquebus_default, table), arquebus_default)
5338
+ arquebus,
5339
+ migrator: new Migrator(new MigrationRepository(arquebus, table), arquebus)
5404
5340
  };
5405
5341
  }
5406
5342
  };
5407
-
5408
5343
  //#endregion
5409
5344
  //#region src/migrations/migration-creator.ts
5410
5345
  var MigrationCreator = class {
5346
+ customStubPath;
5347
+ type;
5411
5348
  postCreate = [];
5412
5349
  constructor(customStubPath, type = "js") {
5413
5350
  this.customStubPath = customStubPath;
@@ -5451,13 +5388,13 @@ var MigrationCreator = class {
5451
5388
  if (!table) {
5452
5389
  const customPath = path.default.join(this.customStubPath ?? "", `migration-${this.type}.stub`);
5453
5390
  console.log("\n", customPath, "---");
5454
- stub = await __h3ravel_shared.FileSystem.fileExists(customPath) ? customPath : this.stubPath(`/migration-${this.type}.stub`);
5391
+ stub = await _h3ravel_shared.FileSystem.fileExists(customPath) ? customPath : this.stubPath(`/migration-${this.type}.stub`);
5455
5392
  } else if (create) {
5456
5393
  const customPath = path.default.join(this.customStubPath ?? "", `migration.create-${this.type}.stub`);
5457
- stub = await __h3ravel_shared.FileSystem.fileExists(customPath) ? customPath : this.stubPath(`/migration.create-${this.type}.stub`);
5394
+ stub = await _h3ravel_shared.FileSystem.fileExists(customPath) ? customPath : this.stubPath(`/migration.create-${this.type}.stub`);
5458
5395
  } else {
5459
5396
  const customPath = path.default.join(this.customStubPath ?? "", `migration.update-${this.type}.stub`);
5460
- stub = await __h3ravel_shared.FileSystem.fileExists(customPath) ? customPath : this.stubPath(`/migration.update-${this.type}.stub`);
5397
+ stub = await _h3ravel_shared.FileSystem.fileExists(customPath) ? customPath : this.stubPath(`/migration.update-${this.type}.stub`);
5461
5398
  }
5462
5399
  return await (0, node_fs_promises.readFile)(stub, "utf-8");
5463
5400
  }
@@ -5482,8 +5419,8 @@ var MigrationCreator = class {
5482
5419
  await (0, node_fs_promises.mkdir)(dir, { recursive: true });
5483
5420
  }
5484
5421
  stubPath(stub = "") {
5485
- const __dirname$1 = this.getDirname({});
5486
- return path.default.join(__dirname$1, "stubs", stub);
5422
+ const __dirname = this.getDirname({});
5423
+ return path.default.join(__dirname, "stubs", stub);
5487
5424
  }
5488
5425
  getDirname(meta) {
5489
5426
  if (typeof __dirname !== "undefined") return __dirname;
@@ -5491,16 +5428,14 @@ var MigrationCreator = class {
5491
5428
  throw new Error("Unable to determine dirname");
5492
5429
  }
5493
5430
  };
5494
-
5495
5431
  //#endregion
5496
5432
  //#region package.json
5497
- var version = "0.8.0-alpha.6";
5498
-
5433
+ var version = "2.0.0";
5499
5434
  //#endregion
5500
- //#region src/cli/cli.ts
5501
- var Cli = class Cli {
5435
+ //#region src/cli/index.ts
5436
+ (class Cli {
5502
5437
  cwd;
5503
- output = __h3ravel_shared.Logger.log();
5438
+ output = _h3ravel_shared.Logger.log();
5504
5439
  config = {};
5505
5440
  basePath = "";
5506
5441
  modulePath;
@@ -5510,7 +5445,7 @@ var Cli = class Cli {
5510
5445
  this.basePath = basePath ?? (process.env.TEST === "true" ? "test/cli" : "");
5511
5446
  }
5512
5447
  terminateNotFound() {
5513
- const cmd = __h3ravel_shared.Logger.log([["arquebus init", [
5448
+ const cmd = _h3ravel_shared.Logger.log([["arquebus init", [
5514
5449
  "italic",
5515
5450
  "black",
5516
5451
  "bgGray"
@@ -5524,7 +5459,7 @@ var Cli = class Cli {
5524
5459
  }
5525
5460
  async loadPaths() {
5526
5461
  this.cwd = path.default.join(process.cwd(), this.basePath);
5527
- this.configPath = __h3ravel_shared.FileSystem.resolveFileUp("arquebus.config", [
5462
+ this.configPath = _h3ravel_shared.FileSystem.resolveFileUp("arquebus.config", [
5528
5463
  "js",
5529
5464
  "ts",
5530
5465
  "cjs"
@@ -5551,8 +5486,8 @@ var Cli = class Cli {
5551
5486
  return this;
5552
5487
  }
5553
5488
  async run() {
5554
- const cliVersion = ["Arquebus CLI version:", __h3ravel_shared.Logger.log(version, "green", false)].join(" ");
5555
- const localVersion = ["Arquebus Local version:", __h3ravel_shared.Logger.log(this.modulePackage.version || "None", "green", false)].join(" ");
5489
+ const cliVersion = ["Arquebus CLI version:", _h3ravel_shared.Logger.log(version, "green", false)].join(" ");
5490
+ const localVersion = ["Arquebus Local version:", _h3ravel_shared.Logger.log(this.modulePackage.version || "None", "green", false)].join(" ");
5556
5491
  commander.program.name("arquebus").version(`${cliVersion}\n${localVersion}`);
5557
5492
  commander.program.command("init").description("Create a fresh Arquebus config.").addArgument(new commander.Argument("[type]", "Type of config to generate.").choices(["js", "ts"]).default("js", "generates a js config")).action(async (type) => {
5558
5493
  if (!this.modulePath) this.output.error(["ERROR: No local arquebus install found", " Try running: npm install arquebus --save"]);
@@ -5585,7 +5520,7 @@ var Cli = class Cli {
5585
5520
  }
5586
5521
  this.output.info("INFO: Creating Migration");
5587
5522
  const fileName = await new MigrationCreator(void 0, opts.type).create(name, migrationPath, table, create);
5588
- this.output.success(`INFO: Migration Created \n ${__h3ravel_shared.Logger.log(path.default.basename(fileName), "gray", false)}`, true);
5523
+ this.output.success(`INFO: Migration Created \n ${_h3ravel_shared.Logger.log(path.default.basename(fileName), "gray", false)}`, true);
5589
5524
  } catch (e) {
5590
5525
  this.output.error("ERROR: " + e);
5591
5526
  }
@@ -5602,7 +5537,7 @@ var Cli = class Cli {
5602
5537
  const pkgJson = await import(path.default.join(packagePath, "package.json"));
5603
5538
  if (!packagePath) this.output.error(`ERROR: package ${pkg} not found`);
5604
5539
  const creator = new MigrationCreator(path.default.join(packagePath, pkgJson.migrations ?? "migrations"));
5605
- const pkgInf = __h3ravel_shared.Logger.log(path.default.basename(pkgJson.name + "@" + pkgJson.version), ["italic", "gray"], false);
5540
+ const pkgInf = _h3ravel_shared.Logger.log(path.default.basename(pkgJson.name + "@" + pkgJson.version), ["italic", "gray"], false);
5606
5541
  this.output.info(`INFO: Publishing migrations from ${pkgInf}`);
5607
5542
  await creator.publish(basePath, (fileName) => {
5608
5543
  this.output.split("INFO: Migration Published", fileName, "success");
@@ -5697,10 +5632,10 @@ var Cli = class Cli {
5697
5632
  if (sts) this.output[sts](msg);
5698
5633
  }).status(this.config, opts, true);
5699
5634
  if (migrations.length > 0) {
5700
- __h3ravel_shared.Logger.twoColumnDetail(__h3ravel_shared.Logger.log("Migration name", "gray", false), __h3ravel_shared.Logger.log("Batch / Status", "gray", false));
5635
+ _h3ravel_shared.Logger.twoColumnDetail(_h3ravel_shared.Logger.log("Migration name", "gray", false), _h3ravel_shared.Logger.log("Batch / Status", "gray", false));
5701
5636
  migrations.forEach((migration) => {
5702
- const status = migration.ran ? `[${migration.batch}] ${__h3ravel_shared.Logger.log("Ran", "green", false)}` : __h3ravel_shared.Logger.log("Pending", "yellow", false);
5703
- __h3ravel_shared.Logger.twoColumnDetail(migration.name, status);
5637
+ const status = migration.ran ? `[${migration.batch}] ${_h3ravel_shared.Logger.log("Ran", "green", false)}` : _h3ravel_shared.Logger.log("Pending", "yellow", false);
5638
+ _h3ravel_shared.Logger.twoColumnDetail(migration.name, status);
5704
5639
  });
5705
5640
  } else console.log("No migrations found");
5706
5641
  } catch (e) {
@@ -5715,12 +5650,12 @@ var Cli = class Cli {
5715
5650
  const basePath = opts.path ? path.default.join(this.cwd, opts.path) : this.cwd;
5716
5651
  try {
5717
5652
  var _this$config$seeders;
5718
- const { arquebus: arquebus$1 } = await new Migrate(basePath).setupConnection({
5653
+ const { arquebus } = await new Migrate(basePath).setupConnection({
5719
5654
  ...this.config,
5720
5655
  skipConnection: false
5721
5656
  });
5722
- const { SeederRunner: SeederRunner$1 } = await Promise.resolve().then(() => require("./seeders-D-v59HCz.cjs"));
5723
- const runner = new SeederRunner$1(arquebus$1);
5657
+ const { SeederRunner } = await Promise.resolve().then(() => seeders_exports);
5658
+ const runner = new SeederRunner(arquebus);
5724
5659
  const seederPath = path.default.join(basePath, ((_this$config$seeders = this.config.seeders) === null || _this$config$seeders === void 0 ? void 0 : _this$config$seeders.path) ?? "./seeders");
5725
5660
  await runner.setConnection(this.config.client).run([seederPath]);
5726
5661
  this.output.success("Seeders executed successfully.");
@@ -5734,9 +5669,9 @@ var Cli = class Cli {
5734
5669
  commander.program.command("make:seeder <name>").description("Create a new Seeder file.").addOption(new commander.Option("-l, --type [string]", "Type of seeder file to generate.").choices(["js", "ts"]).default("js", "generates a js seeder file")).option("--force", "Force creation if seeder already exists.", false).option("-p, --path [path]", "The path to the seeders directory.").action(async (name, opts) => {
5735
5670
  var _this$config$seeders2;
5736
5671
  if (!this.configPath) this.terminateNotFound();
5737
- const seederPath = path.default.join(this.cwd, opts.path ?? ((_this$config$seeders2 = this.config.seeders) === null || _this$config$seeders2 === void 0 ? void 0 : _this$config$seeders2.path) ?? "./seeders", __h3ravel_support.Str.of(name).snake("-") + "." + opts.type);
5672
+ const seederPath = path.default.join(this.cwd, opts.path ?? ((_this$config$seeders2 = this.config.seeders) === null || _this$config$seeders2 === void 0 ? void 0 : _this$config$seeders2.path) ?? "./seeders", _h3ravel_support.Str.of(name).snake("-") + "." + opts.type);
5738
5673
  try {
5739
- if (!opts.force && await __h3ravel_shared.FileSystem.fileExists(seederPath)) this.output.error("ERROR: Seeder already exists.");
5674
+ if (!opts.force && await _h3ravel_shared.FileSystem.fileExists(seederPath)) this.output.error("ERROR: Seeder already exists.");
5740
5675
  await (0, node_fs_promises.mkdir)(path.default.dirname(seederPath), { recursive: true });
5741
5676
  let stub = await (0, node_fs_promises.readFile)(path.default.join(this.modulePath, `src/stubs/seeder-${opts.type}.stub`), "utf-8");
5742
5677
  stub = stub.replace(/{{ name }}/g, name);
@@ -5754,7 +5689,7 @@ var Cli = class Cli {
5754
5689
  if (!this.configPath) this.terminateNotFound();
5755
5690
  const modelPath = path.default.join(this.cwd, opts.path ?? ((_this$config$models = this.config.models) === null || _this$config$models === void 0 ? void 0 : _this$config$models.path) ?? "./models", name.toLowerCase() + "." + opts.type);
5756
5691
  try {
5757
- if (!opts.force && await __h3ravel_shared.FileSystem.fileExists(modelPath)) this.output.error("ERROR: Model already exists.");
5692
+ if (!opts.force && await _h3ravel_shared.FileSystem.fileExists(modelPath)) this.output.error("ERROR: Model already exists.");
5758
5693
  await (0, node_fs_promises.mkdir)(path.default.dirname(modelPath), { recursive: true });
5759
5694
  let stub = await (0, node_fs_promises.readFile)(path.default.join(this.modulePath, `src/stubs/model-${opts.type}.stub`), "utf-8");
5760
5695
  stub = stub.replace(/{{ name }}/g, name);
@@ -5767,11 +5702,5 @@ var Cli = class Cli {
5767
5702
  await commander.program.parseAsync(process.argv);
5768
5703
  process.exit(0);
5769
5704
  }
5770
- };
5771
-
5772
- //#endregion
5773
- //#region src/cli/index.ts
5774
- Cli.init();
5775
-
5705
+ }).init();
5776
5706
  //#endregion
5777
- exports.runner_default = runner_default;