@palbase/backend 23.1.0 → 24.0.1

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 (73) hide show
  1. package/dist/bin/palbase-backend.cjs +400 -47
  2. package/dist/bin/palbase-backend.cjs.map +1 -1
  3. package/dist/bin/palbase-backend.js +4 -5
  4. package/dist/bin/palbase-backend.js.map +1 -1
  5. package/dist/{chunk-OHALWEOG.js → chunk-7Z6MGMXQ.js} +57 -2
  6. package/dist/chunk-7Z6MGMXQ.js.map +1 -0
  7. package/dist/{chunk-RCLNBJCM.js → chunk-H3JAISUY.js} +136 -1
  8. package/dist/chunk-H3JAISUY.js.map +1 -0
  9. package/dist/{chunk-PY7YJDCT.js → chunk-LCL7TUAI.js} +32 -3
  10. package/dist/chunk-LCL7TUAI.js.map +1 -0
  11. package/dist/{chunk-NS5V43YQ.js → chunk-P2Q27SGP.js} +19 -3
  12. package/dist/chunk-P2Q27SGP.js.map +1 -0
  13. package/dist/{chunk-R3KN6RHD.js → chunk-T5IOSOE5.js} +7 -2
  14. package/dist/chunk-T5IOSOE5.js.map +1 -0
  15. package/dist/{chunk-M5MCBWJI.js → chunk-YSQBC2VL.js} +275 -31
  16. package/dist/chunk-YSQBC2VL.js.map +1 -0
  17. package/dist/db/index.cjs +48 -3
  18. package/dist/db/index.cjs.map +1 -1
  19. package/dist/db/index.d.cts +2 -2
  20. package/dist/db/index.d.ts +2 -2
  21. package/dist/db/index.js +2 -2
  22. package/dist/{endpoint-CVWXh6oG.d.ts → endpoint-0_DGBajf.d.ts} +100 -3
  23. package/dist/{endpoint-c9h5jriX.d.cts → endpoint-CcQ1a36a.d.cts} +100 -3
  24. package/dist/engine/index.cjs +389 -34
  25. package/dist/engine/index.cjs.map +1 -1
  26. package/dist/engine/index.d.cts +4 -4
  27. package/dist/engine/index.d.ts +4 -4
  28. package/dist/engine/index.js +4 -4
  29. package/dist/{index-CwAJ7HEe.d.ts → index-BOS_rFBO.d.ts} +125 -21
  30. package/dist/{index-CxeQSfJP.d.cts → index-C84bLgeO.d.cts} +134 -9
  31. package/dist/{index-By8Dle5U.d.cts → index-MoQ31B6M.d.cts} +125 -21
  32. package/dist/{index-BZrJXnVh.d.ts → index-dJNhDZ7j.d.ts} +134 -9
  33. package/dist/index.cjs +166 -5
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +54 -12
  36. package/dist/index.d.ts +54 -12
  37. package/dist/index.js +28 -11
  38. package/dist/index.js.map +1 -1
  39. package/dist/openapi/index.cjs +16 -1
  40. package/dist/openapi/index.cjs.map +1 -1
  41. package/dist/openapi/index.d.cts +6 -4
  42. package/dist/openapi/index.d.ts +6 -4
  43. package/dist/openapi/index.js +6 -7
  44. package/dist/openapi/index.js.map +1 -1
  45. package/dist/{registry-CqPK2Qby.d.cts → registry-1X-skBNu.d.cts} +1 -1
  46. package/dist/{registry-B3niOVYp.d.ts → registry-CEod_5sz.d.ts} +1 -1
  47. package/dist/test/index.cjs +27 -0
  48. package/dist/test/index.cjs.map +1 -1
  49. package/dist/test/index.d.cts +1 -1
  50. package/dist/test/index.d.ts +1 -1
  51. package/dist/test/index.js +27 -0
  52. package/dist/test/index.js.map +1 -1
  53. package/docs/README.md +4 -4
  54. package/docs/database.md +115 -11
  55. package/docs/getting-started.md +5 -4
  56. package/docs/llms-full.txt +385 -89
  57. package/docs/migrations.md +81 -59
  58. package/docs/schema.md +82 -2
  59. package/docs/services.md +98 -9
  60. package/package.json +2 -2
  61. package/template/AGENTS.md +121 -41
  62. package/template/controllers/notes.controller.ts +64 -0
  63. package/template/package.json +1 -1
  64. package/template/services/note.service.ts +74 -0
  65. package/template/tsconfig.json +11 -1
  66. package/dist/chunk-HQRJDARQ.js +0 -90
  67. package/dist/chunk-HQRJDARQ.js.map +0 -1
  68. package/dist/chunk-M5MCBWJI.js.map +0 -1
  69. package/dist/chunk-NS5V43YQ.js.map +0 -1
  70. package/dist/chunk-OHALWEOG.js.map +0 -1
  71. package/dist/chunk-PY7YJDCT.js.map +0 -1
  72. package/dist/chunk-R3KN6RHD.js.map +0 -1
  73. package/dist/chunk-RCLNBJCM.js.map +0 -1
package/dist/db/index.cjs CHANGED
@@ -424,6 +424,28 @@ var ColumnBuilder = class _ColumnBuilder {
424
424
  this._def.unique = true;
425
425
  return new _ColumnBuilder(this._def.type, this._def);
426
426
  }
427
+ /**
428
+ * Declare how this column's value is projected in and out of the process.
429
+ *
430
+ * The DDL does not move: `numeric` stays `numeric`, and the driver still hands
431
+ * back what Postgres sent. What changes is the type the row surface exposes —
432
+ * it becomes `Target`:
433
+ *
434
+ * amount: numeric().transform<number>({ fromDb: Number, toDb: String })
435
+ *
436
+ * `numeric` surfacing as `string` is CORRECT (a JS number cannot hold
437
+ * arbitrary precision), and that is exactly why this exists: application code
438
+ * that does arithmetic on the column otherwise rewrites the same
439
+ * `Number(row.amount)` / `String(x)` pair in every controller that touches it,
440
+ * and each rewrite is a place the two directions can drift apart.
441
+ *
442
+ * A transform is a PROJECTION, never a constraint: it lives only in this
443
+ * process, so it can neither validate nor migrate what is stored.
444
+ */
445
+ transform(fns) {
446
+ this._def.transform = fns;
447
+ return new _ColumnBuilder(this._def.type, this._def);
448
+ }
427
449
  };
428
450
  function uuid() {
429
451
  return new ColumnBuilder("uuid");
@@ -734,7 +756,7 @@ var TxPlanBuilder = class {
734
756
  `${name}.upsert()`
735
757
  );
736
758
  },
737
- insertMany: (rows) => {
759
+ insertMany: (rows, opts) => {
738
760
  if (rows.length === 0) {
739
761
  return new TxRowsImpl(this, SKIPPED_OP, `${name}.insertMany()`);
740
762
  }
@@ -745,7 +767,23 @@ var TxPlanBuilder = class {
745
767
  }
746
768
  const encoded = rows.map((row) => encodeMap(row, false));
747
769
  assertUniformRows(encoded, name);
748
- return this.push({ op: "insertMany", table: name, rows: encoded }, `${name}.insertMany()`);
770
+ if (opts !== void 0 && opts.onConflict.length === 0) {
771
+ throw new TxPlanError(
772
+ `${name}.insertMany() was given a conflict action with no onConflict columns. Postgres matches a collision on columns, so name them.`
773
+ );
774
+ }
775
+ return this.push(
776
+ {
777
+ op: "insertMany",
778
+ table: name,
779
+ rows: encoded,
780
+ // Omitted entirely when no options were given, so the op a plain
781
+ // insertMany produces is byte-identical to the one it produced
782
+ // before this option existed.
783
+ ...opts !== void 0 ? { onConflict: opts.onConflict, action: opts.action ?? "ignore" } : {}
784
+ },
785
+ `${name}.insertMany()`
786
+ );
749
787
  },
750
788
  updateWhere: (where, set) => {
751
789
  const encodedWhere = encodeMap(where, false);
@@ -911,7 +949,14 @@ function makeTypedTable(name, raw2) {
911
949
  update: (id, data) => raw2.update(name, id, data),
912
950
  delete: (id) => raw2.delete(name, id),
913
951
  findById: (id) => raw2.findById(name, id),
914
- findMany: (query, opts) => raw2.findMany(name, query, opts)
952
+ findMany: (query, opts) => raw2.findMany(name, query, opts),
953
+ updateMany: (where, set) => raw2.updateMany(
954
+ name,
955
+ where,
956
+ set
957
+ ),
958
+ deleteMany: (where) => raw2.deleteMany(name, where),
959
+ count: (where) => raw2.count(name, where)
915
960
  };
916
961
  }
917
962
  function makeTypedDB(schema, raw2) {