arkormx 2.6.1 → 2.8.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.
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_relationship = require('../relationship-CxCQj_Pg.cjs');
2
+ const require_relationship = require('../relationship-WiXlopzY.cjs');
3
3
 
4
4
  exports.BelongsToManyRelation = require_relationship.BelongsToManyRelation;
5
5
  exports.BelongsToRelation = require_relationship.BelongsToRelation;
@@ -1,2 +1,2 @@
1
- import { Co as BelongsToRelation, Do as RelationTableLoader, Eo as Relation, So as HasManyRelation, To as BelongsToManyRelation, _o as MorphOneRelation, bo as HasOneRelation, go as MorphToManyRelation, ho as MorphToRelation, mo as SetBasedEagerLoader, vo as MorphManyRelation, wo as SingleResultRelation, xo as HasManyThroughRelation, yo as HasOneThroughRelation } from "../index-CBh5Z2sS.cjs";
1
+ import { Ao as MorphManyRelation, Do as MorphToRelation, Eo as SetBasedEagerLoader, Fo as BelongsToRelation, Io as SingleResultRelation, Lo as BelongsToManyRelation, Mo as HasOneRelation, No as HasManyThroughRelation, Oo as MorphToManyRelation, Po as HasManyRelation, Ro as Relation, jo as HasOneThroughRelation, ko as MorphOneRelation, zo as RelationTableLoader } from "../index-4mi5sLRA.cjs";
2
2
  export { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, HasOneThroughRelation, MorphManyRelation, MorphOneRelation, MorphToManyRelation, MorphToRelation, Relation, RelationTableLoader, SetBasedEagerLoader, SingleResultRelation };
@@ -1,2 +1,2 @@
1
- import { Co as BelongsToRelation, Do as RelationTableLoader, Eo as Relation, So as HasManyRelation, To as BelongsToManyRelation, _o as MorphOneRelation, bo as HasOneRelation, go as MorphToManyRelation, ho as MorphToRelation, mo as SetBasedEagerLoader, vo as MorphManyRelation, wo as SingleResultRelation, xo as HasManyThroughRelation, yo as HasOneThroughRelation } from "../index-BTBfGF_o.mjs";
1
+ import { Ao as MorphManyRelation, Do as MorphToRelation, Eo as SetBasedEagerLoader, Fo as BelongsToRelation, Io as SingleResultRelation, Lo as BelongsToManyRelation, Mo as HasOneRelation, No as HasManyThroughRelation, Oo as MorphToManyRelation, Po as HasManyRelation, Ro as Relation, jo as HasOneThroughRelation, ko as MorphOneRelation, zo as RelationTableLoader } from "../index-De8zXqTD.mjs";
2
2
  export { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, HasOneThroughRelation, MorphManyRelation, MorphOneRelation, MorphToManyRelation, MorphToRelation, Relation, RelationTableLoader, SetBasedEagerLoader, SingleResultRelation };
@@ -1,3 +1,3 @@
1
- import { Nn as SetBasedEagerLoader, Pn as RelationTableLoader, a as HasOneThroughRelation, c as HasManyRelation, d as BelongsToManyRelation, f as Relation, i as MorphManyRelation, l as BelongsToRelation, n as MorphToManyRelation, o as HasOneRelation, r as MorphOneRelation, s as HasManyThroughRelation, t as MorphToRelation, u as SingleResultRelation } from "../relationship-DT4myOWX.mjs";
1
+ import { Nn as SetBasedEagerLoader, Pn as RelationTableLoader, a as HasOneThroughRelation, c as HasManyRelation, d as BelongsToManyRelation, f as Relation, i as MorphManyRelation, l as BelongsToRelation, n as MorphToManyRelation, o as HasOneRelation, r as MorphOneRelation, s as HasManyThroughRelation, t as MorphToRelation, u as SingleResultRelation } from "../relationship--l8RA_yy.mjs";
2
2
 
3
3
  export { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, HasOneThroughRelation, MorphManyRelation, MorphOneRelation, MorphToManyRelation, MorphToRelation, Relation, RelationTableLoader, SetBasedEagerLoader, SingleResultRelation };
@@ -1101,6 +1101,10 @@ var PrimaryKeyGenerationPlanner = class {
1101
1101
  //#endregion
1102
1102
  //#region src/database/TableBuilder.ts
1103
1103
  const PRISMA_ENUM_MEMBER_REGEX$1 = /^[A-Za-z][A-Za-z0-9_]*$/;
1104
+ const defaultTimestampNames = {
1105
+ createdAt: "createdAt",
1106
+ updatedAt: "updatedAt"
1107
+ };
1104
1108
  const normalizeEnumMember = (columnName, value) => {
1105
1109
  const normalized = value.trim();
1106
1110
  if (!normalized) throw new Error(`Enum column [${columnName}] must define only non-empty values.`);
@@ -1412,21 +1416,59 @@ var TableBuilder = class {
1412
1416
  }
1413
1417
  /**
1414
1418
  * Defines both createdAt and updatedAt timestamp columns in the table.
1415
- *
1416
- * @returns
1419
+ *
1420
+ * The attribute casing (the names exposed on the model) is controlled by the
1421
+ * first argument, while the optional second argument controls the casing used
1422
+ * for the persisted database column names via `.map()`.
1423
+ *
1424
+ * @example
1425
+ * table.timestamps() // createdAt / updatedAt
1426
+ * table.timestamps('snake') // created_at / updated_at
1427
+ * table.timestamps('camel', 'snake') // createdAt -> created_at (mapped)
1428
+ * table.timestamps({ createdAt: 'createdOn' })
1429
+ * table.timestamps('camel', { createdAt: 'created_on' })
1430
+ *
1431
+ * @param casing The casing (or explicit names) used for the attribute names.
1432
+ * @param mapCasing The casing (or explicit names) used for the mapped database columns.
1433
+ * @returns
1417
1434
  */
1418
- timestamps() {
1419
- this.timestamp("createdAt", {
1435
+ timestamps(casing = "camel", mapCasing) {
1436
+ const names = this.resolveTimestampNames(casing, defaultTimestampNames);
1437
+ const maps = mapCasing === void 0 ? void 0 : this.resolveTimestampNames(mapCasing, names);
1438
+ this.timestamp(names.createdAt, {
1420
1439
  nullable: false,
1421
- default: "now()"
1440
+ default: "now()",
1441
+ ...maps && maps.createdAt !== names.createdAt ? { map: maps.createdAt } : {}
1422
1442
  });
1423
- this.timestamp("updatedAt", {
1443
+ this.timestamp(names.updatedAt, {
1424
1444
  nullable: false,
1425
- updatedAt: true
1445
+ updatedAt: true,
1446
+ ...maps && maps.updatedAt !== names.updatedAt ? { map: maps.updatedAt } : {}
1426
1447
  });
1427
1448
  return this;
1428
1449
  }
1429
1450
  /**
1451
+ * Resolves a timestamp naming option into concrete createdAt / updatedAt names.
1452
+ *
1453
+ * @param naming The casing keyword or explicit name overrides.
1454
+ * @param fallback The names used when an explicit override is omitted.
1455
+ * @returns
1456
+ */
1457
+ resolveTimestampNames(naming, fallback) {
1458
+ if (naming === "snake") return {
1459
+ createdAt: "created_at",
1460
+ updatedAt: "updated_at"
1461
+ };
1462
+ if (naming === "camel") return {
1463
+ createdAt: "createdAt",
1464
+ updatedAt: "updatedAt"
1465
+ };
1466
+ return {
1467
+ createdAt: naming.createdAt ?? fallback.createdAt,
1468
+ updatedAt: naming.updatedAt ?? fallback.updatedAt
1469
+ };
1470
+ }
1471
+ /**
1430
1472
  * Defines a soft delete timestamp column in the table.
1431
1473
  *
1432
1474
  * @param column The name of the soft delete column.
@@ -4301,7 +4343,9 @@ var Relation = class {
4301
4343
  * @returns
4302
4344
  */
4303
4345
  make(attributes = {}) {
4304
- return this.getRelatedModelConstructor().hydrate(this.mergeCreationAttributes(attributes));
4346
+ const model = this.getRelatedModelConstructor().hydrate(this.mergeCreationAttributes(attributes));
4347
+ model.exists = false;
4348
+ return model;
4305
4349
  }
4306
4350
  /**
4307
4351
  * Create new instances of the related model with the given attributes and relationship
@@ -1129,6 +1129,10 @@ var PrimaryKeyGenerationPlanner = class {
1129
1129
  //#endregion
1130
1130
  //#region src/database/TableBuilder.ts
1131
1131
  const PRISMA_ENUM_MEMBER_REGEX$1 = /^[A-Za-z][A-Za-z0-9_]*$/;
1132
+ const defaultTimestampNames = {
1133
+ createdAt: "createdAt",
1134
+ updatedAt: "updatedAt"
1135
+ };
1132
1136
  const normalizeEnumMember = (columnName, value) => {
1133
1137
  const normalized = value.trim();
1134
1138
  if (!normalized) throw new Error(`Enum column [${columnName}] must define only non-empty values.`);
@@ -1440,21 +1444,59 @@ var TableBuilder = class {
1440
1444
  }
1441
1445
  /**
1442
1446
  * Defines both createdAt and updatedAt timestamp columns in the table.
1443
- *
1444
- * @returns
1447
+ *
1448
+ * The attribute casing (the names exposed on the model) is controlled by the
1449
+ * first argument, while the optional second argument controls the casing used
1450
+ * for the persisted database column names via `.map()`.
1451
+ *
1452
+ * @example
1453
+ * table.timestamps() // createdAt / updatedAt
1454
+ * table.timestamps('snake') // created_at / updated_at
1455
+ * table.timestamps('camel', 'snake') // createdAt -> created_at (mapped)
1456
+ * table.timestamps({ createdAt: 'createdOn' })
1457
+ * table.timestamps('camel', { createdAt: 'created_on' })
1458
+ *
1459
+ * @param casing The casing (or explicit names) used for the attribute names.
1460
+ * @param mapCasing The casing (or explicit names) used for the mapped database columns.
1461
+ * @returns
1445
1462
  */
1446
- timestamps() {
1447
- this.timestamp("createdAt", {
1463
+ timestamps(casing = "camel", mapCasing) {
1464
+ const names = this.resolveTimestampNames(casing, defaultTimestampNames);
1465
+ const maps = mapCasing === void 0 ? void 0 : this.resolveTimestampNames(mapCasing, names);
1466
+ this.timestamp(names.createdAt, {
1448
1467
  nullable: false,
1449
- default: "now()"
1468
+ default: "now()",
1469
+ ...maps && maps.createdAt !== names.createdAt ? { map: maps.createdAt } : {}
1450
1470
  });
1451
- this.timestamp("updatedAt", {
1471
+ this.timestamp(names.updatedAt, {
1452
1472
  nullable: false,
1453
- updatedAt: true
1473
+ updatedAt: true,
1474
+ ...maps && maps.updatedAt !== names.updatedAt ? { map: maps.updatedAt } : {}
1454
1475
  });
1455
1476
  return this;
1456
1477
  }
1457
1478
  /**
1479
+ * Resolves a timestamp naming option into concrete createdAt / updatedAt names.
1480
+ *
1481
+ * @param naming The casing keyword or explicit name overrides.
1482
+ * @param fallback The names used when an explicit override is omitted.
1483
+ * @returns
1484
+ */
1485
+ resolveTimestampNames(naming, fallback) {
1486
+ if (naming === "snake") return {
1487
+ createdAt: "created_at",
1488
+ updatedAt: "updated_at"
1489
+ };
1490
+ if (naming === "camel") return {
1491
+ createdAt: "createdAt",
1492
+ updatedAt: "updatedAt"
1493
+ };
1494
+ return {
1495
+ createdAt: naming.createdAt ?? fallback.createdAt,
1496
+ updatedAt: naming.updatedAt ?? fallback.updatedAt
1497
+ };
1498
+ }
1499
+ /**
1458
1500
  * Defines a soft delete timestamp column in the table.
1459
1501
  *
1460
1502
  * @param column The name of the soft delete column.
@@ -4329,7 +4371,9 @@ var Relation = class {
4329
4371
  * @returns
4330
4372
  */
4331
4373
  make(attributes = {}) {
4332
- return this.getRelatedModelConstructor().hydrate(this.mergeCreationAttributes(attributes));
4374
+ const model = this.getRelatedModelConstructor().hydrate(this.mergeCreationAttributes(attributes));
4375
+ model.exists = false;
4376
+ return model;
4333
4377
  }
4334
4378
  /**
4335
4379
  * Create new instances of the related model with the given attributes and relationship
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkormx",
3
- "version": "2.6.1",
3
+ "version": "2.8.0",
4
4
  "description": "Modern TypeScript-first ORM for Node.js.",
5
5
  "keywords": [
6
6
  "orm",