@h3ravel/arquebus 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1041,8 +1041,8 @@ var HasManyThrough = class extends relation_default {
1041
1041
  const results = await this.take(1).get(columns);
1042
1042
  return results.count() > 0 ? results.first() : null;
1043
1043
  }
1044
- async firstOrFail(columns = ["*"]) {
1045
- const model = await this.first(columns);
1044
+ async firstOrFail(...columns) {
1045
+ const model = await this.first(...columns);
1046
1046
  if (model) return model;
1047
1047
  throw new ModelNotFoundError().setModel(this.related.constructor);
1048
1048
  }
@@ -1081,7 +1081,7 @@ var HasManyThrough = class extends relation_default {
1081
1081
  }
1082
1082
  async paginate(perPage = null, columns = ["*"], pageName = "page", page = null) {
1083
1083
  this.query.addSelect(this.shouldSelect(columns));
1084
- return await this.query.paginate(perPage, columns, pageName, page);
1084
+ return await this.query.paginate(perPage ?? 15, columns, pageName, page);
1085
1085
  }
1086
1086
  shouldSelect(columns = ["*"]) {
1087
1087
  if ((columns === null || columns === void 0 ? void 0 : columns.at(0)) == "*") columns = [this.related.getTable() + ".*"];
@@ -1359,9 +1359,6 @@ const UniqueIds = (Model$1) => {
1359
1359
  uniqueIds() {
1360
1360
  return [];
1361
1361
  }
1362
- newUniqueId() {
1363
- return null;
1364
- }
1365
1362
  setUniqueIds() {
1366
1363
  const uniqueIds = this.uniqueIds();
1367
1364
  for (const column of uniqueIds) if (this[column] === null || this[column] === void 0) this[column] = this.newUniqueId();
@@ -1383,6 +1380,7 @@ var Paginator = class {
1383
1380
  options = {};
1384
1381
  static setFormatter(formatter) {
1385
1382
  if (typeof formatter !== "function" && formatter !== null && formatter !== void 0) throw new Error("Paginator formatter must be a function or null");
1383
+ if (!formatter) return;
1386
1384
  this.formatter = formatter;
1387
1385
  }
1388
1386
  constructor(items, total, perPage, currentPage = 1, options = {}) {
@@ -1471,8 +1469,10 @@ var QueryBuilder = class QueryBuilder extends Inference$2 {
1471
1469
  asProxy() {
1472
1470
  return new Proxy(this, {
1473
1471
  get: function(target, prop) {
1472
+ var _target$connector$cli;
1474
1473
  if (typeof target[prop] !== "undefined") return target[prop];
1475
1474
  if (["destroy", "schema"].includes(prop)) return target.connector.schema;
1475
+ const skipReturning = !!((_target$connector$cli = target.connector.client.config) === null || _target$connector$cli === void 0 || (_target$connector$cli = _target$connector$cli.client) === null || _target$connector$cli === void 0 ? void 0 : _target$connector$cli.includes("mysql")) && prop === "returning";
1476
1476
  if ([
1477
1477
  "select",
1478
1478
  "from",
@@ -1535,7 +1535,7 @@ var QueryBuilder = class QueryBuilder extends Inference$2 {
1535
1535
  "clearWhere",
1536
1536
  "clearHaving",
1537
1537
  "clearGroup"
1538
- ].includes(prop)) return (...args) => {
1538
+ ].includes(prop) && !skipReturning) return (...args) => {
1539
1539
  target.connector[prop](...args);
1540
1540
  return target.asProxy();
1541
1541
  };
@@ -1592,7 +1592,7 @@ var QueryBuilder = class QueryBuilder extends Inference$2 {
1592
1592
  } while (countResults === count);
1593
1593
  return true;
1594
1594
  }
1595
- async paginate(page = 1, perPage = 15) {
1595
+ async paginate(page = 1, perPage = 15, _pageName, _page) {
1596
1596
  const total = await this.clone().clearOrder().count("*");
1597
1597
  let results;
1598
1598
  if (total > 0) {
@@ -1831,14 +1831,15 @@ var arquebus_default = arquebus;
1831
1831
 
1832
1832
  //#endregion
1833
1833
  //#region src/model.ts
1834
- const BaseModel = compose(class {}, has_attributes_default, hides_attributes_default, has_relations_default, has_timestamps_default, has_hooks_default, has_global_scopes_default, unique_ids_default);
1834
+ const ModelClass = class {};
1835
+ 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);
1835
1836
  var Model = class Model extends BaseModel {
1836
- primaryKey = "id";
1837
1837
  builder = null;
1838
1838
  table = null;
1839
1839
  keyType = "int";
1840
1840
  incrementing = true;
1841
1841
  withCount = [];
1842
+ primaryKey = "id";
1842
1843
  perPage = 15;
1843
1844
  static globalScopes = {};
1844
1845
  static pluginInitializers = {};
@@ -1848,6 +1849,7 @@ var Model = class Model extends BaseModel {
1848
1849
  eagerLoad = {};
1849
1850
  exists = false;
1850
1851
  with = [];
1852
+ name;
1851
1853
  trx = null;
1852
1854
  constructor(attributes = {}) {
1853
1855
  super();
@@ -2619,8 +2621,8 @@ var BelongsToMany = class extends compose(relation_default, interacts_with_pivot
2619
2621
  const results = await this.take(1).get(columns);
2620
2622
  return results.count() > 0 ? results.first() : null;
2621
2623
  }
2622
- async firstOrFail(columns = ["*"]) {
2623
- const model = await this.first(columns);
2624
+ async firstOrFail(...columns) {
2625
+ const model = await this.first(...columns);
2624
2626
  if (model !== null) return model;
2625
2627
  throw new ModelNotFoundError().setModel(this.related.constructor);
2626
2628
  }
@@ -2796,7 +2798,9 @@ var Builder = class Builder extends Inference$1 {
2796
2798
  }
2797
2799
  asProxy() {
2798
2800
  return new Proxy(this, { get(target, prop) {
2801
+ var _target$query$connect;
2799
2802
  if (typeof target[prop] !== "undefined") return target[prop];
2803
+ const skipReturning = !!((_target$query$connect = target.query.connector) === null || _target$query$connect === void 0 || (_target$query$connect = _target$query$connect.client.config) === null || _target$query$connect === void 0 || (_target$query$connect = _target$query$connect.client) === null || _target$query$connect === void 0 ? void 0 : _target$query$connect.includes("mysql")) && prop === "returning";
2800
2804
  if ([
2801
2805
  "select",
2802
2806
  "from",
@@ -2859,7 +2863,7 @@ var Builder = class Builder extends Inference$1 {
2859
2863
  "clearWhere",
2860
2864
  "clearHaving",
2861
2865
  "clearGroup"
2862
- ].includes(prop)) return (...args) => {
2866
+ ].includes(prop) && !skipReturning) return (...args) => {
2863
2867
  target.query[prop](...args);
2864
2868
  return target.asProxy();
2865
2869
  };
@@ -5543,7 +5547,7 @@ const make = (model, data, options = {}) => {
5543
5547
  return model.make(data);
5544
5548
  };
5545
5549
  const makeCollection = (model, data) => new collection_default(data.map((item) => model.make(item)));
5546
- const makePaginator = (model, data) => new paginator_default(data.data.map((item) => model.make(item)), data.total, data.per_page, data.current_page);
5550
+ const makePaginator = (model, data, _) => new paginator_default(data.data.map((item) => model.make(item)), data.total, data.per_page, data.current_page);
5547
5551
 
5548
5552
  //#endregion
5549
5553
  export { attribute_default as Attribute, builder_default as Builder, casts_attributes_default as CastsAttributes, collection_default as Collection, has_unique_ids_default as HasUniqueIds, InvalidArgumentError, Migrate, migration_default as Migration, model_default as Model, ModelNotFoundError, paginator_default as Paginator, pivot_default as Pivot, query_builder_default as QueryBuilder, RelationNotFoundError, scope_default as Scope, soft_deletes_default as SoftDeletes, arquebus_default as arquebus, compose, defineConfig, flatten, flattenDeep, getAttrMethod, getAttrName, getGetterMethod, getRelationMethod, getRelationName, getScopeMethod, getScopeName, getSetterMethod, kebabCase, make, makeCollection, makePaginator, now, snakeCase, tap };
@@ -2304,8 +2304,8 @@ var HasManyThrough = class extends relation_default {
2304
2304
  const results = await this.take(1).get(columns);
2305
2305
  return results.count() > 0 ? results.first() : null;
2306
2306
  }
2307
- async firstOrFail(columns = ["*"]) {
2308
- const model = await this.first(columns);
2307
+ async firstOrFail(...columns) {
2308
+ const model = await this.first(...columns);
2309
2309
  if (model) return model;
2310
2310
  throw new ModelNotFoundError().setModel(this.related.constructor);
2311
2311
  }
@@ -2344,7 +2344,7 @@ var HasManyThrough = class extends relation_default {
2344
2344
  }
2345
2345
  async paginate(perPage = null, columns = ["*"], pageName = "page", page = null) {
2346
2346
  this.query.addSelect(this.shouldSelect(columns));
2347
- return await this.query.paginate(perPage, columns, pageName, page);
2347
+ return await this.query.paginate(perPage ?? 15, columns, pageName, page);
2348
2348
  }
2349
2349
  shouldSelect(columns = ["*"]) {
2350
2350
  if ((columns === null || columns === void 0 ? void 0 : columns.at(0)) == "*") columns = [this.related.getTable() + ".*"];
@@ -2622,9 +2622,6 @@ const UniqueIds = (Model$1) => {
2622
2622
  uniqueIds() {
2623
2623
  return [];
2624
2624
  }
2625
- newUniqueId() {
2626
- return null;
2627
- }
2628
2625
  setUniqueIds() {
2629
2626
  const uniqueIds = this.uniqueIds();
2630
2627
  for (const column of uniqueIds) if (this[column] === null || this[column] === void 0) this[column] = this.newUniqueId();
@@ -2646,6 +2643,7 @@ var Paginator = class {
2646
2643
  options = {};
2647
2644
  static setFormatter(formatter) {
2648
2645
  if (typeof formatter !== "function" && formatter !== null && formatter !== void 0) throw new Error("Paginator formatter must be a function or null");
2646
+ if (!formatter) return;
2649
2647
  this.formatter = formatter;
2650
2648
  }
2651
2649
  constructor(items, total, perPage, currentPage = 1, options = {}) {
@@ -2734,8 +2732,10 @@ var QueryBuilder = class QueryBuilder extends Inference$1 {
2734
2732
  asProxy() {
2735
2733
  return new Proxy(this, {
2736
2734
  get: function(target, prop) {
2735
+ var _target$connector$cli;
2737
2736
  if (typeof target[prop] !== "undefined") return target[prop];
2738
2737
  if (["destroy", "schema"].includes(prop)) return target.connector.schema;
2738
+ const skipReturning = !!((_target$connector$cli = target.connector.client.config) === null || _target$connector$cli === void 0 || (_target$connector$cli = _target$connector$cli.client) === null || _target$connector$cli === void 0 ? void 0 : _target$connector$cli.includes("mysql")) && prop === "returning";
2739
2739
  if ([
2740
2740
  "select",
2741
2741
  "from",
@@ -2798,7 +2798,7 @@ var QueryBuilder = class QueryBuilder extends Inference$1 {
2798
2798
  "clearWhere",
2799
2799
  "clearHaving",
2800
2800
  "clearGroup"
2801
- ].includes(prop)) return (...args) => {
2801
+ ].includes(prop) && !skipReturning) return (...args) => {
2802
2802
  target.connector[prop](...args);
2803
2803
  return target.asProxy();
2804
2804
  };
@@ -2855,7 +2855,7 @@ var QueryBuilder = class QueryBuilder extends Inference$1 {
2855
2855
  } while (countResults === count);
2856
2856
  return true;
2857
2857
  }
2858
- async paginate(page = 1, perPage = 15) {
2858
+ async paginate(page = 1, perPage = 15, _pageName, _page) {
2859
2859
  const total = await this.clone().clearOrder().count("*");
2860
2860
  let results;
2861
2861
  if (total > 0) {
@@ -3094,14 +3094,15 @@ var arquebus_default = arquebus;
3094
3094
 
3095
3095
  //#endregion
3096
3096
  //#region src/model.ts
3097
- const BaseModel = compose(class {}, has_attributes_default, hides_attributes_default, has_relations_default, has_timestamps_default, has_hooks_default, has_global_scopes_default, unique_ids_default);
3097
+ const ModelClass = class {};
3098
+ 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);
3098
3099
  var Model = class Model extends BaseModel {
3099
- primaryKey = "id";
3100
3100
  builder = null;
3101
3101
  table = null;
3102
3102
  keyType = "int";
3103
3103
  incrementing = true;
3104
3104
  withCount = [];
3105
+ primaryKey = "id";
3105
3106
  perPage = 15;
3106
3107
  static globalScopes = {};
3107
3108
  static pluginInitializers = {};
@@ -3111,6 +3112,7 @@ var Model = class Model extends BaseModel {
3111
3112
  eagerLoad = {};
3112
3113
  exists = false;
3113
3114
  with = [];
3115
+ name;
3114
3116
  trx = null;
3115
3117
  constructor(attributes = {}) {
3116
3118
  super();
@@ -3882,8 +3884,8 @@ var BelongsToMany = class extends compose(relation_default, interacts_with_pivot
3882
3884
  const results = await this.take(1).get(columns);
3883
3885
  return results.count() > 0 ? results.first() : null;
3884
3886
  }
3885
- async firstOrFail(columns = ["*"]) {
3886
- const model = await this.first(columns);
3887
+ async firstOrFail(...columns) {
3888
+ const model = await this.first(...columns);
3887
3889
  if (model !== null) return model;
3888
3890
  throw new ModelNotFoundError().setModel(this.related.constructor);
3889
3891
  }
@@ -4059,7 +4061,9 @@ var Builder = class Builder extends Inference {
4059
4061
  }
4060
4062
  asProxy() {
4061
4063
  return new Proxy(this, { get(target, prop) {
4064
+ var _target$query$connect;
4062
4065
  if (typeof target[prop] !== "undefined") return target[prop];
4066
+ const skipReturning = !!((_target$query$connect = target.query.connector) === null || _target$query$connect === void 0 || (_target$query$connect = _target$query$connect.client.config) === null || _target$query$connect === void 0 || (_target$query$connect = _target$query$connect.client) === null || _target$query$connect === void 0 ? void 0 : _target$query$connect.includes("mysql")) && prop === "returning";
4063
4067
  if ([
4064
4068
  "select",
4065
4069
  "from",
@@ -4122,7 +4126,7 @@ var Builder = class Builder extends Inference {
4122
4126
  "clearWhere",
4123
4127
  "clearHaving",
4124
4128
  "clearGroup"
4125
- ].includes(prop)) return (...args) => {
4129
+ ].includes(prop) && !skipReturning) return (...args) => {
4126
4130
  target.query[prop](...args);
4127
4131
  return target.asProxy();
4128
4132
  };
@@ -2278,8 +2278,8 @@ var HasManyThrough = class extends relation_default {
2278
2278
  const results = await this.take(1).get(columns);
2279
2279
  return results.count() > 0 ? results.first() : null;
2280
2280
  }
2281
- async firstOrFail(columns = ["*"]) {
2282
- const model = await this.first(columns);
2281
+ async firstOrFail(...columns) {
2282
+ const model = await this.first(...columns);
2283
2283
  if (model) return model;
2284
2284
  throw new ModelNotFoundError().setModel(this.related.constructor);
2285
2285
  }
@@ -2318,7 +2318,7 @@ var HasManyThrough = class extends relation_default {
2318
2318
  }
2319
2319
  async paginate(perPage = null, columns = ["*"], pageName = "page", page = null) {
2320
2320
  this.query.addSelect(this.shouldSelect(columns));
2321
- return await this.query.paginate(perPage, columns, pageName, page);
2321
+ return await this.query.paginate(perPage ?? 15, columns, pageName, page);
2322
2322
  }
2323
2323
  shouldSelect(columns = ["*"]) {
2324
2324
  if ((columns === null || columns === void 0 ? void 0 : columns.at(0)) == "*") columns = [this.related.getTable() + ".*"];
@@ -2596,9 +2596,6 @@ const UniqueIds = (Model$1) => {
2596
2596
  uniqueIds() {
2597
2597
  return [];
2598
2598
  }
2599
- newUniqueId() {
2600
- return null;
2601
- }
2602
2599
  setUniqueIds() {
2603
2600
  const uniqueIds = this.uniqueIds();
2604
2601
  for (const column of uniqueIds) if (this[column] === null || this[column] === void 0) this[column] = this.newUniqueId();
@@ -2620,6 +2617,7 @@ var Paginator = class {
2620
2617
  options = {};
2621
2618
  static setFormatter(formatter) {
2622
2619
  if (typeof formatter !== "function" && formatter !== null && formatter !== void 0) throw new Error("Paginator formatter must be a function or null");
2620
+ if (!formatter) return;
2623
2621
  this.formatter = formatter;
2624
2622
  }
2625
2623
  constructor(items, total, perPage, currentPage = 1, options = {}) {
@@ -2708,8 +2706,10 @@ var QueryBuilder = class QueryBuilder extends Inference$1 {
2708
2706
  asProxy() {
2709
2707
  return new Proxy(this, {
2710
2708
  get: function(target, prop) {
2709
+ var _target$connector$cli;
2711
2710
  if (typeof target[prop] !== "undefined") return target[prop];
2712
2711
  if (["destroy", "schema"].includes(prop)) return target.connector.schema;
2712
+ const skipReturning = !!((_target$connector$cli = target.connector.client.config) === null || _target$connector$cli === void 0 || (_target$connector$cli = _target$connector$cli.client) === null || _target$connector$cli === void 0 ? void 0 : _target$connector$cli.includes("mysql")) && prop === "returning";
2713
2713
  if ([
2714
2714
  "select",
2715
2715
  "from",
@@ -2772,7 +2772,7 @@ var QueryBuilder = class QueryBuilder extends Inference$1 {
2772
2772
  "clearWhere",
2773
2773
  "clearHaving",
2774
2774
  "clearGroup"
2775
- ].includes(prop)) return (...args) => {
2775
+ ].includes(prop) && !skipReturning) return (...args) => {
2776
2776
  target.connector[prop](...args);
2777
2777
  return target.asProxy();
2778
2778
  };
@@ -2829,7 +2829,7 @@ var QueryBuilder = class QueryBuilder extends Inference$1 {
2829
2829
  } while (countResults === count);
2830
2830
  return true;
2831
2831
  }
2832
- async paginate(page = 1, perPage = 15) {
2832
+ async paginate(page = 1, perPage = 15, _pageName, _page) {
2833
2833
  const total = await this.clone().clearOrder().count("*");
2834
2834
  let results;
2835
2835
  if (total > 0) {
@@ -3068,14 +3068,15 @@ var arquebus_default = arquebus;
3068
3068
 
3069
3069
  //#endregion
3070
3070
  //#region src/model.ts
3071
- const BaseModel = compose(class {}, has_attributes_default, hides_attributes_default, has_relations_default, has_timestamps_default, has_hooks_default, has_global_scopes_default, unique_ids_default);
3071
+ const ModelClass = class {};
3072
+ 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);
3072
3073
  var Model = class Model extends BaseModel {
3073
- primaryKey = "id";
3074
3074
  builder = null;
3075
3075
  table = null;
3076
3076
  keyType = "int";
3077
3077
  incrementing = true;
3078
3078
  withCount = [];
3079
+ primaryKey = "id";
3079
3080
  perPage = 15;
3080
3081
  static globalScopes = {};
3081
3082
  static pluginInitializers = {};
@@ -3085,6 +3086,7 @@ var Model = class Model extends BaseModel {
3085
3086
  eagerLoad = {};
3086
3087
  exists = false;
3087
3088
  with = [];
3089
+ name;
3088
3090
  trx = null;
3089
3091
  constructor(attributes = {}) {
3090
3092
  super();
@@ -3856,8 +3858,8 @@ var BelongsToMany = class extends compose(relation_default, interacts_with_pivot
3856
3858
  const results = await this.take(1).get(columns);
3857
3859
  return results.count() > 0 ? results.first() : null;
3858
3860
  }
3859
- async firstOrFail(columns = ["*"]) {
3860
- const model = await this.first(columns);
3861
+ async firstOrFail(...columns) {
3862
+ const model = await this.first(...columns);
3861
3863
  if (model !== null) return model;
3862
3864
  throw new ModelNotFoundError().setModel(this.related.constructor);
3863
3865
  }
@@ -4033,7 +4035,9 @@ var Builder = class Builder extends Inference {
4033
4035
  }
4034
4036
  asProxy() {
4035
4037
  return new Proxy(this, { get(target, prop) {
4038
+ var _target$query$connect;
4036
4039
  if (typeof target[prop] !== "undefined") return target[prop];
4040
+ const skipReturning = !!((_target$query$connect = target.query.connector) === null || _target$query$connect === void 0 || (_target$query$connect = _target$query$connect.client.config) === null || _target$query$connect === void 0 || (_target$query$connect = _target$query$connect.client) === null || _target$query$connect === void 0 ? void 0 : _target$query$connect.includes("mysql")) && prop === "returning";
4037
4041
  if ([
4038
4042
  "select",
4039
4043
  "from",
@@ -4096,7 +4100,7 @@ var Builder = class Builder extends Inference {
4096
4100
  "clearWhere",
4097
4101
  "clearHaving",
4098
4102
  "clearGroup"
4099
- ].includes(prop)) return (...args) => {
4103
+ ].includes(prop) && !skipReturning) return (...args) => {
4100
4104
  target.query[prop](...args);
4101
4105
  return target.asProxy();
4102
4106
  };
@@ -55,8 +55,6 @@ let escalade_sync = require("escalade/sync");
55
55
  escalade_sync = __toESM(escalade_sync);
56
56
  let resolve_from = require("resolve-from");
57
57
  resolve_from = __toESM(resolve_from);
58
- let node_fs = require("node:fs");
59
- node_fs = __toESM(node_fs);
60
58
  let node_path = require("node:path");
61
59
  node_path = __toESM(node_path);
62
60
  let node_url = require("node:url");
@@ -2384,8 +2382,8 @@ var HasManyThrough = class extends relation_default {
2384
2382
  const results = await this.take(1).get(columns);
2385
2383
  return results.count() > 0 ? results.first() : null;
2386
2384
  }
2387
- async firstOrFail(columns = ["*"]) {
2388
- const model = await this.first(columns);
2385
+ async firstOrFail(...columns) {
2386
+ const model = await this.first(...columns);
2389
2387
  if (model) return model;
2390
2388
  throw new ModelNotFoundError().setModel(this.related.constructor);
2391
2389
  }
@@ -2424,7 +2422,7 @@ var HasManyThrough = class extends relation_default {
2424
2422
  }
2425
2423
  async paginate(perPage = null, columns = ["*"], pageName = "page", page = null) {
2426
2424
  this.query.addSelect(this.shouldSelect(columns));
2427
- return await this.query.paginate(perPage, columns, pageName, page);
2425
+ return await this.query.paginate(perPage ?? 15, columns, pageName, page);
2428
2426
  }
2429
2427
  shouldSelect(columns = ["*"]) {
2430
2428
  if ((columns === null || columns === void 0 ? void 0 : columns.at(0)) == "*") columns = [this.related.getTable() + ".*"];
@@ -2702,9 +2700,6 @@ const UniqueIds = (Model$1) => {
2702
2700
  uniqueIds() {
2703
2701
  return [];
2704
2702
  }
2705
- newUniqueId() {
2706
- return null;
2707
- }
2708
2703
  setUniqueIds() {
2709
2704
  const uniqueIds = this.uniqueIds();
2710
2705
  for (const column of uniqueIds) if (this[column] === null || this[column] === void 0) this[column] = this.newUniqueId();
@@ -2726,6 +2721,7 @@ var Paginator = class {
2726
2721
  options = {};
2727
2722
  static setFormatter(formatter) {
2728
2723
  if (typeof formatter !== "function" && formatter !== null && formatter !== void 0) throw new Error("Paginator formatter must be a function or null");
2724
+ if (!formatter) return;
2729
2725
  this.formatter = formatter;
2730
2726
  }
2731
2727
  constructor(items, total, perPage, currentPage = 1, options = {}) {
@@ -2814,8 +2810,10 @@ var QueryBuilder = class QueryBuilder extends Inference$2 {
2814
2810
  asProxy() {
2815
2811
  return new Proxy(this, {
2816
2812
  get: function(target, prop) {
2813
+ var _target$connector$cli;
2817
2814
  if (typeof target[prop] !== "undefined") return target[prop];
2818
2815
  if (["destroy", "schema"].includes(prop)) return target.connector.schema;
2816
+ const skipReturning = !!((_target$connector$cli = target.connector.client.config) === null || _target$connector$cli === void 0 || (_target$connector$cli = _target$connector$cli.client) === null || _target$connector$cli === void 0 ? void 0 : _target$connector$cli.includes("mysql")) && prop === "returning";
2819
2817
  if ([
2820
2818
  "select",
2821
2819
  "from",
@@ -2878,7 +2876,7 @@ var QueryBuilder = class QueryBuilder extends Inference$2 {
2878
2876
  "clearWhere",
2879
2877
  "clearHaving",
2880
2878
  "clearGroup"
2881
- ].includes(prop)) return (...args) => {
2879
+ ].includes(prop) && !skipReturning) return (...args) => {
2882
2880
  target.connector[prop](...args);
2883
2881
  return target.asProxy();
2884
2882
  };
@@ -2935,7 +2933,7 @@ var QueryBuilder = class QueryBuilder extends Inference$2 {
2935
2933
  } while (countResults === count);
2936
2934
  return true;
2937
2935
  }
2938
- async paginate(page = 1, perPage = 15) {
2936
+ async paginate(page = 1, perPage = 15, _pageName, _page) {
2939
2937
  const total = await this.clone().clearOrder().count("*");
2940
2938
  let results;
2941
2939
  if (total > 0) {
@@ -3174,14 +3172,15 @@ var arquebus_default = arquebus;
3174
3172
 
3175
3173
  //#endregion
3176
3174
  //#region src/model.ts
3177
- const BaseModel = compose(class {}, has_attributes_default, hides_attributes_default, has_relations_default, has_timestamps_default, has_hooks_default, has_global_scopes_default, unique_ids_default);
3175
+ const ModelClass = class {};
3176
+ 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);
3178
3177
  var Model = class Model extends BaseModel {
3179
- primaryKey = "id";
3180
3178
  builder = null;
3181
3179
  table = null;
3182
3180
  keyType = "int";
3183
3181
  incrementing = true;
3184
3182
  withCount = [];
3183
+ primaryKey = "id";
3185
3184
  perPage = 15;
3186
3185
  static globalScopes = {};
3187
3186
  static pluginInitializers = {};
@@ -3191,6 +3190,7 @@ var Model = class Model extends BaseModel {
3191
3190
  eagerLoad = {};
3192
3191
  exists = false;
3193
3192
  with = [];
3193
+ name;
3194
3194
  trx = null;
3195
3195
  constructor(attributes = {}) {
3196
3196
  super();
@@ -3962,8 +3962,8 @@ var BelongsToMany = class extends compose(relation_default, interacts_with_pivot
3962
3962
  const results = await this.take(1).get(columns);
3963
3963
  return results.count() > 0 ? results.first() : null;
3964
3964
  }
3965
- async firstOrFail(columns = ["*"]) {
3966
- const model = await this.first(columns);
3965
+ async firstOrFail(...columns) {
3966
+ const model = await this.first(...columns);
3967
3967
  if (model !== null) return model;
3968
3968
  throw new ModelNotFoundError().setModel(this.related.constructor);
3969
3969
  }
@@ -4139,7 +4139,9 @@ var Builder = class Builder extends Inference$1 {
4139
4139
  }
4140
4140
  asProxy() {
4141
4141
  return new Proxy(this, { get(target, prop) {
4142
+ var _target$query$connect;
4142
4143
  if (typeof target[prop] !== "undefined") return target[prop];
4144
+ const skipReturning = !!((_target$query$connect = target.query.connector) === null || _target$query$connect === void 0 || (_target$query$connect = _target$query$connect.client.config) === null || _target$query$connect === void 0 || (_target$query$connect = _target$query$connect.client) === null || _target$query$connect === void 0 ? void 0 : _target$query$connect.includes("mysql")) && prop === "returning";
4143
4145
  if ([
4144
4146
  "select",
4145
4147
  "from",
@@ -4202,7 +4204,7 @@ var Builder = class Builder extends Inference$1 {
4202
4204
  "clearWhere",
4203
4205
  "clearHaving",
4204
4206
  "clearGroup"
4205
- ].includes(prop)) return (...args) => {
4207
+ ].includes(prop) && !skipReturning) return (...args) => {
4206
4208
  target.query[prop](...args);
4207
4209
  return target.asProxy();
4208
4210
  };
@@ -5400,10 +5402,10 @@ var MigrationCreator = class {
5400
5402
  * @returns
5401
5403
  */
5402
5404
  async create(name, dir, table, create = false) {
5403
- const stub = this.getStub(table, create);
5405
+ const stub = await this.getStub(table, create);
5404
5406
  const filePath = this.getPath(name, dir);
5405
5407
  await this.ensureDirectoryExists(path.default.dirname(filePath));
5406
- await node_fs_promises.default.writeFile(filePath, this.populateStub(stub, table));
5408
+ await (0, node_fs_promises.writeFile)(filePath, this.populateStub(stub, table));
5407
5409
  await this.firePostCreateHooks(table, filePath);
5408
5410
  return filePath;
5409
5411
  }
@@ -5414,29 +5416,29 @@ var MigrationCreator = class {
5414
5416
  * @param callback
5415
5417
  */
5416
5418
  async publish(dir, callback) {
5417
- const migrationFiles = await node_fs_promises.default.readdir(this.customStubPath ?? "");
5419
+ const migrationFiles = await (0, node_fs_promises.readdir)(this.customStubPath ?? "");
5418
5420
  await this.ensureDirectoryExists(dir);
5419
5421
  for (const migrationFile of migrationFiles) {
5420
5422
  const sourceFilePath = path.default.join(this.customStubPath ?? "", migrationFile);
5421
5423
  const destinationFilePath = path.default.join(dir, migrationFile);
5422
- await node_fs_promises.default.copyFile(sourceFilePath, destinationFilePath);
5424
+ await (0, node_fs_promises.copyFile)(sourceFilePath, destinationFilePath);
5423
5425
  if (callback) callback(migrationFile, sourceFilePath, destinationFilePath);
5424
5426
  }
5425
5427
  }
5426
- getStub(table, create = false) {
5428
+ async getStub(table, create = false) {
5427
5429
  let stub;
5428
5430
  if (!table) {
5429
5431
  const customPath = path.default.join(this.customStubPath ?? "", `migration-${this.type}.stub`);
5430
5432
  console.log("\n", customPath, "---");
5431
- stub = (0, node_fs.existsSync)(customPath) ? customPath : this.stubPath(`/migration-${this.type}.stub`);
5433
+ stub = await __h3ravel_shared.FileSystem.fileExists(customPath) ? customPath : this.stubPath(`/migration-${this.type}.stub`);
5432
5434
  } else if (create) {
5433
5435
  const customPath = path.default.join(this.customStubPath ?? "", `migration.create-${this.type}.stub`);
5434
- stub = (0, node_fs.existsSync)(customPath) ? customPath : this.stubPath(`/migration.create-${this.type}.stub`);
5436
+ stub = await __h3ravel_shared.FileSystem.fileExists(customPath) ? customPath : this.stubPath(`/migration.create-${this.type}.stub`);
5435
5437
  } else {
5436
5438
  const customPath = path.default.join(this.customStubPath ?? "", `migration.update-${this.type}.stub`);
5437
- stub = (0, node_fs.existsSync)(customPath) ? customPath : this.stubPath(`/migration.update-${this.type}.stub`);
5439
+ stub = await __h3ravel_shared.FileSystem.fileExists(customPath) ? customPath : this.stubPath(`/migration.update-${this.type}.stub`);
5438
5440
  }
5439
- return (0, node_fs.readFileSync)(stub, "utf-8");
5441
+ return await (0, node_fs_promises.readFile)(stub, "utf-8");
5440
5442
  }
5441
5443
  populateStub(stub, table) {
5442
5444
  if (table !== null) stub = stub.replace(/DummyTable|{{\s*table\s*}}/g, table);
@@ -5456,7 +5458,7 @@ var MigrationCreator = class {
5456
5458
  this.postCreate.push(callback);
5457
5459
  }
5458
5460
  async ensureDirectoryExists(dir) {
5459
- await node_fs_promises.default.mkdir(dir, { recursive: true });
5461
+ await (0, node_fs_promises.mkdir)(dir, { recursive: true });
5460
5462
  }
5461
5463
  stubPath(stub = "") {
5462
5464
  const __dirname$1 = this.getDirname({});