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.
package/dist/cli.mjs CHANGED
@@ -366,6 +366,10 @@ var PrimaryKeyGenerationPlanner = class {
366
366
  //#endregion
367
367
  //#region src/database/TableBuilder.ts
368
368
  const PRISMA_ENUM_MEMBER_REGEX$1 = /^[A-Za-z][A-Za-z0-9_]*$/;
369
+ const defaultTimestampNames = {
370
+ createdAt: "createdAt",
371
+ updatedAt: "updatedAt"
372
+ };
369
373
  const normalizeEnumMember = (columnName, value) => {
370
374
  const normalized = value.trim();
371
375
  if (!normalized) throw new Error(`Enum column [${columnName}] must define only non-empty values.`);
@@ -677,21 +681,59 @@ var TableBuilder = class {
677
681
  }
678
682
  /**
679
683
  * Defines both createdAt and updatedAt timestamp columns in the table.
680
- *
681
- * @returns
684
+ *
685
+ * The attribute casing (the names exposed on the model) is controlled by the
686
+ * first argument, while the optional second argument controls the casing used
687
+ * for the persisted database column names via `.map()`.
688
+ *
689
+ * @example
690
+ * table.timestamps() // createdAt / updatedAt
691
+ * table.timestamps('snake') // created_at / updated_at
692
+ * table.timestamps('camel', 'snake') // createdAt -> created_at (mapped)
693
+ * table.timestamps({ createdAt: 'createdOn' })
694
+ * table.timestamps('camel', { createdAt: 'created_on' })
695
+ *
696
+ * @param casing The casing (or explicit names) used for the attribute names.
697
+ * @param mapCasing The casing (or explicit names) used for the mapped database columns.
698
+ * @returns
682
699
  */
683
- timestamps() {
684
- this.timestamp("createdAt", {
700
+ timestamps(casing = "camel", mapCasing) {
701
+ const names = this.resolveTimestampNames(casing, defaultTimestampNames);
702
+ const maps = mapCasing === void 0 ? void 0 : this.resolveTimestampNames(mapCasing, names);
703
+ this.timestamp(names.createdAt, {
685
704
  nullable: false,
686
- default: "now()"
705
+ default: "now()",
706
+ ...maps && maps.createdAt !== names.createdAt ? { map: maps.createdAt } : {}
687
707
  });
688
- this.timestamp("updatedAt", {
708
+ this.timestamp(names.updatedAt, {
689
709
  nullable: false,
690
- updatedAt: true
710
+ updatedAt: true,
711
+ ...maps && maps.updatedAt !== names.updatedAt ? { map: maps.updatedAt } : {}
691
712
  });
692
713
  return this;
693
714
  }
694
715
  /**
716
+ * Resolves a timestamp naming option into concrete createdAt / updatedAt names.
717
+ *
718
+ * @param naming The casing keyword or explicit name overrides.
719
+ * @param fallback The names used when an explicit override is omitted.
720
+ * @returns
721
+ */
722
+ resolveTimestampNames(naming, fallback) {
723
+ if (naming === "snake") return {
724
+ createdAt: "created_at",
725
+ updatedAt: "updated_at"
726
+ };
727
+ if (naming === "camel") return {
728
+ createdAt: "createdAt",
729
+ updatedAt: "updatedAt"
730
+ };
731
+ return {
732
+ createdAt: naming.createdAt ?? fallback.createdAt,
733
+ updatedAt: naming.updatedAt ?? fallback.updatedAt
734
+ };
735
+ }
736
+ /**
695
737
  * Defines a soft delete timestamp column in the table.
696
738
  *
697
739
  * @param column The name of the soft delete column.
@@ -2670,6 +2712,10 @@ var PrismaDatabaseAdapter = class PrismaDatabaseAdapter {
2670
2712
  operation: "adapter.select",
2671
2713
  meta: { feature: "groupBy" }
2672
2714
  });
2715
+ if (spec.joins?.length) throw new UnsupportedAdapterFeatureException("Join clauses are not supported by the Prisma compatibility adapter; use a SQL-backed adapter or DB.raw().", {
2716
+ operation: "adapter.select",
2717
+ meta: { feature: "joins" }
2718
+ });
2673
2719
  return {
2674
2720
  include: this.toQueryInclude(spec.relationLoads),
2675
2721
  where: this.toQueryWhere(spec.where),