arkormx 0.2.7 → 0.2.9

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
@@ -281,8 +281,14 @@ var TableBuilder = class {
281
281
  * @returns
282
282
  */
283
283
  timestamps() {
284
- this.timestamp("createdAt", { nullable: false });
285
- this.timestamp("updatedAt", { nullable: false });
284
+ this.timestamp("createdAt", {
285
+ nullable: false,
286
+ default: "now()"
287
+ });
288
+ this.timestamp("updatedAt", {
289
+ nullable: false,
290
+ updatedAt: true
291
+ });
286
292
  return this;
287
293
  }
288
294
  /**
@@ -317,6 +323,18 @@ var TableBuilder = class {
317
323
  return this;
318
324
  }
319
325
  /**
326
+ * Sets a default value for a column.
327
+ *
328
+ * @param value The default scalar value or Prisma expression (e.g. 'now()').
329
+ * @param columnName Optional explicit column name. When omitted, applies to the latest defined column.
330
+ * @returns The current TableBuilder instance for chaining.
331
+ */
332
+ default(value, columnName) {
333
+ const column = this.resolveColumn(columnName);
334
+ column.default = value;
335
+ return this;
336
+ }
337
+ /**
320
338
  * Sets the column position to appear after another column when possible.
321
339
  *
322
340
  * @param referenceColumn The column that the target column should be placed after.
@@ -434,7 +452,8 @@ var TableBuilder = class {
434
452
  primary: options.primary,
435
453
  autoIncrement: options.autoIncrement,
436
454
  after: options.after,
437
- default: options.default
455
+ default: options.default,
456
+ updatedAt: options.updatedAt
438
457
  });
439
458
  this.latestColumnName = name;
440
459
  return this;
@@ -595,6 +614,7 @@ const resolvePrismaType = (column) => {
595
614
  */
596
615
  const formatDefaultValue = (value) => {
597
616
  if (value == null) return void 0;
617
+ if (value === "now()") return "@default(now())";
598
618
  if (typeof value === "string") return `@default("${value.replace(/"/g, "\\\"")}")`;
599
619
  if (typeof value === "number" || typeof value === "bigint") return `@default(${value})`;
600
620
  if (typeof value === "boolean") return `@default(${value ? "true" : "false"})`;
@@ -619,9 +639,10 @@ const buildFieldLine = (column) => {
619
639
  const unique = column.unique ? " @unique" : "";
620
640
  const primary = column.primary ? " @id" : "";
621
641
  const mapped = typeof column.map === "string" && column.map.trim().length > 0 ? ` @map("${column.map.replace(/"/g, "\\\"")}")` : "";
642
+ const updatedAt = column.updatedAt ? " @updatedAt" : "";
622
643
  const defaultValue = formatDefaultValue(column.default) ?? (column.type === "uuid" && column.primary ? "@default(uuid())" : void 0);
623
644
  const defaultSuffix = defaultValue ? ` ${defaultValue}` : "";
624
- return ` ${column.name} ${scalar}${nullable}${primary}${unique}${defaultSuffix}${mapped}`;
645
+ return ` ${column.name} ${scalar}${nullable}${primary}${unique}${defaultSuffix}${updatedAt}${mapped}`;
625
646
  };
626
647
  /**
627
648
  * Build a Prisma model-level @@index definition line.
@@ -2235,7 +2256,7 @@ var MigrationHistoryCommand = class extends Command {
2235
2256
  return;
2236
2257
  }
2237
2258
  state.migrations.sort((left, right) => left.appliedAt.localeCompare(right.appliedAt)).forEach((migration) => {
2238
- this.success(this.app.splitLogger("Applied:", `${migration.id} @ ${migration.appliedAt}`));
2259
+ this.success(this.app.splitLogger("Applied:", `${migration.id.split(":").at(0)} @ ${migration.appliedAt}`));
2239
2260
  });
2240
2261
  }
2241
2262
  };
package/dist/index.cjs CHANGED
@@ -372,8 +372,14 @@ var TableBuilder = class {
372
372
  * @returns
373
373
  */
374
374
  timestamps() {
375
- this.timestamp("createdAt", { nullable: false });
376
- this.timestamp("updatedAt", { nullable: false });
375
+ this.timestamp("createdAt", {
376
+ nullable: false,
377
+ default: "now()"
378
+ });
379
+ this.timestamp("updatedAt", {
380
+ nullable: false,
381
+ updatedAt: true
382
+ });
377
383
  return this;
378
384
  }
379
385
  /**
@@ -408,6 +414,18 @@ var TableBuilder = class {
408
414
  return this;
409
415
  }
410
416
  /**
417
+ * Sets a default value for a column.
418
+ *
419
+ * @param value The default scalar value or Prisma expression (e.g. 'now()').
420
+ * @param columnName Optional explicit column name. When omitted, applies to the latest defined column.
421
+ * @returns The current TableBuilder instance for chaining.
422
+ */
423
+ default(value, columnName) {
424
+ const column = this.resolveColumn(columnName);
425
+ column.default = value;
426
+ return this;
427
+ }
428
+ /**
411
429
  * Sets the column position to appear after another column when possible.
412
430
  *
413
431
  * @param referenceColumn The column that the target column should be placed after.
@@ -525,7 +543,8 @@ var TableBuilder = class {
525
543
  primary: options.primary,
526
544
  autoIncrement: options.autoIncrement,
527
545
  after: options.after,
528
- default: options.default
546
+ default: options.default,
547
+ updatedAt: options.updatedAt
529
548
  });
530
549
  this.latestColumnName = name;
531
550
  return this;
@@ -686,6 +705,7 @@ const resolvePrismaType = (column) => {
686
705
  */
687
706
  const formatDefaultValue = (value) => {
688
707
  if (value == null) return void 0;
708
+ if (value === "now()") return "@default(now())";
689
709
  if (typeof value === "string") return `@default("${value.replace(/"/g, "\\\"")}")`;
690
710
  if (typeof value === "number" || typeof value === "bigint") return `@default(${value})`;
691
711
  if (typeof value === "boolean") return `@default(${value ? "true" : "false"})`;
@@ -710,9 +730,10 @@ const buildFieldLine = (column) => {
710
730
  const unique = column.unique ? " @unique" : "";
711
731
  const primary = column.primary ? " @id" : "";
712
732
  const mapped = typeof column.map === "string" && column.map.trim().length > 0 ? ` @map("${column.map.replace(/"/g, "\\\"")}")` : "";
733
+ const updatedAt = column.updatedAt ? " @updatedAt" : "";
713
734
  const defaultValue = formatDefaultValue(column.default) ?? (column.type === "uuid" && column.primary ? "@default(uuid())" : void 0);
714
735
  const defaultSuffix = defaultValue ? ` ${defaultValue}` : "";
715
- return ` ${column.name} ${scalar}${nullable}${primary}${unique}${defaultSuffix}${mapped}`;
736
+ return ` ${column.name} ${scalar}${nullable}${primary}${unique}${defaultSuffix}${updatedAt}${mapped}`;
716
737
  };
717
738
  /**
718
739
  * Build a Prisma model-level @@index definition line.
@@ -2443,7 +2464,7 @@ var MigrationHistoryCommand = class extends _h3ravel_musket.Command {
2443
2464
  return;
2444
2465
  }
2445
2466
  state.migrations.sort((left, right) => left.appliedAt.localeCompare(right.appliedAt)).forEach((migration) => {
2446
- this.success(this.app.splitLogger("Applied:", `${migration.id} @ ${migration.appliedAt}`));
2467
+ this.success(this.app.splitLogger("Applied:", `${migration.id.split(":").at(0)} @ ${migration.appliedAt}`));
2447
2468
  });
2448
2469
  }
2449
2470
  };
package/dist/index.d.cts CHANGED
@@ -22,6 +22,7 @@ interface SchemaColumn {
22
22
  autoIncrement?: boolean;
23
23
  after?: string;
24
24
  default?: unknown;
25
+ updatedAt?: boolean;
25
26
  }
26
27
  interface SchemaIndex {
27
28
  columns: string[];
@@ -2564,6 +2565,14 @@ declare class TableBuilder {
2564
2565
  * @returns The current TableBuilder instance for chaining.
2565
2566
  */
2566
2567
  nullable(columnName?: string): this;
2568
+ /**
2569
+ * Sets a default value for a column.
2570
+ *
2571
+ * @param value The default scalar value or Prisma expression (e.g. 'now()').
2572
+ * @param columnName Optional explicit column name. When omitted, applies to the latest defined column.
2573
+ * @returns The current TableBuilder instance for chaining.
2574
+ */
2575
+ default(value: unknown, columnName?: string): this;
2567
2576
  /**
2568
2577
  * Sets the column position to appear after another column when possible.
2569
2578
  *
package/dist/index.d.mts CHANGED
@@ -22,6 +22,7 @@ interface SchemaColumn {
22
22
  autoIncrement?: boolean;
23
23
  after?: string;
24
24
  default?: unknown;
25
+ updatedAt?: boolean;
25
26
  }
26
27
  interface SchemaIndex {
27
28
  columns: string[];
@@ -2564,6 +2565,14 @@ declare class TableBuilder {
2564
2565
  * @returns The current TableBuilder instance for chaining.
2565
2566
  */
2566
2567
  nullable(columnName?: string): this;
2568
+ /**
2569
+ * Sets a default value for a column.
2570
+ *
2571
+ * @param value The default scalar value or Prisma expression (e.g. 'now()').
2572
+ * @param columnName Optional explicit column name. When omitted, applies to the latest defined column.
2573
+ * @returns The current TableBuilder instance for chaining.
2574
+ */
2575
+ default(value: unknown, columnName?: string): this;
2567
2576
  /**
2568
2577
  * Sets the column position to appear after another column when possible.
2569
2578
  *
package/dist/index.mjs CHANGED
@@ -343,8 +343,14 @@ var TableBuilder = class {
343
343
  * @returns
344
344
  */
345
345
  timestamps() {
346
- this.timestamp("createdAt", { nullable: false });
347
- this.timestamp("updatedAt", { nullable: false });
346
+ this.timestamp("createdAt", {
347
+ nullable: false,
348
+ default: "now()"
349
+ });
350
+ this.timestamp("updatedAt", {
351
+ nullable: false,
352
+ updatedAt: true
353
+ });
348
354
  return this;
349
355
  }
350
356
  /**
@@ -379,6 +385,18 @@ var TableBuilder = class {
379
385
  return this;
380
386
  }
381
387
  /**
388
+ * Sets a default value for a column.
389
+ *
390
+ * @param value The default scalar value or Prisma expression (e.g. 'now()').
391
+ * @param columnName Optional explicit column name. When omitted, applies to the latest defined column.
392
+ * @returns The current TableBuilder instance for chaining.
393
+ */
394
+ default(value, columnName) {
395
+ const column = this.resolveColumn(columnName);
396
+ column.default = value;
397
+ return this;
398
+ }
399
+ /**
382
400
  * Sets the column position to appear after another column when possible.
383
401
  *
384
402
  * @param referenceColumn The column that the target column should be placed after.
@@ -496,7 +514,8 @@ var TableBuilder = class {
496
514
  primary: options.primary,
497
515
  autoIncrement: options.autoIncrement,
498
516
  after: options.after,
499
- default: options.default
517
+ default: options.default,
518
+ updatedAt: options.updatedAt
500
519
  });
501
520
  this.latestColumnName = name;
502
521
  return this;
@@ -657,6 +676,7 @@ const resolvePrismaType = (column) => {
657
676
  */
658
677
  const formatDefaultValue = (value) => {
659
678
  if (value == null) return void 0;
679
+ if (value === "now()") return "@default(now())";
660
680
  if (typeof value === "string") return `@default("${value.replace(/"/g, "\\\"")}")`;
661
681
  if (typeof value === "number" || typeof value === "bigint") return `@default(${value})`;
662
682
  if (typeof value === "boolean") return `@default(${value ? "true" : "false"})`;
@@ -681,9 +701,10 @@ const buildFieldLine = (column) => {
681
701
  const unique = column.unique ? " @unique" : "";
682
702
  const primary = column.primary ? " @id" : "";
683
703
  const mapped = typeof column.map === "string" && column.map.trim().length > 0 ? ` @map("${column.map.replace(/"/g, "\\\"")}")` : "";
704
+ const updatedAt = column.updatedAt ? " @updatedAt" : "";
684
705
  const defaultValue = formatDefaultValue(column.default) ?? (column.type === "uuid" && column.primary ? "@default(uuid())" : void 0);
685
706
  const defaultSuffix = defaultValue ? ` ${defaultValue}` : "";
686
- return ` ${column.name} ${scalar}${nullable}${primary}${unique}${defaultSuffix}${mapped}`;
707
+ return ` ${column.name} ${scalar}${nullable}${primary}${unique}${defaultSuffix}${updatedAt}${mapped}`;
687
708
  };
688
709
  /**
689
710
  * Build a Prisma model-level @@index definition line.
@@ -2414,7 +2435,7 @@ var MigrationHistoryCommand = class extends Command {
2414
2435
  return;
2415
2436
  }
2416
2437
  state.migrations.sort((left, right) => left.appliedAt.localeCompare(right.appliedAt)).forEach((migration) => {
2417
- this.success(this.app.splitLogger("Applied:", `${migration.id} @ ${migration.appliedAt}`));
2438
+ this.success(this.app.splitLogger("Applied:", `${migration.id.split(":").at(0)} @ ${migration.appliedAt}`));
2418
2439
  });
2419
2440
  }
2420
2441
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkormx",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "description": "Modern TypeScript-first ORM for Node.js.",
5
5
  "keywords": [
6
6
  "orm",