@palbase/backend 27.1.0 → 28.0.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.
Files changed (52) hide show
  1. package/dist/bin/palbase-backend.cjs +133 -38
  2. package/dist/bin/palbase-backend.cjs.map +1 -1
  3. package/dist/bin/palbase-backend.js +4 -4
  4. package/dist/{chunk-JVZQCC77.js → chunk-3TUJWHC2.js} +8 -3
  5. package/dist/chunk-3TUJWHC2.js.map +1 -0
  6. package/dist/{chunk-EB3TUX5J.js → chunk-75YROPRZ.js} +102 -38
  7. package/dist/chunk-75YROPRZ.js.map +1 -0
  8. package/dist/{chunk-XABHGMUT.js → chunk-IVZERLTM.js} +2 -2
  9. package/dist/{chunk-BQN723PL.js → chunk-RVP6BTEZ.js} +63 -6
  10. package/dist/chunk-RVP6BTEZ.js.map +1 -0
  11. package/dist/{chunk-OZKSM3JW.js → chunk-SNDXY565.js} +3 -2
  12. package/dist/chunk-SNDXY565.js.map +1 -0
  13. package/dist/db/index.cjs +4 -1
  14. package/dist/db/index.cjs.map +1 -1
  15. package/dist/db/index.d.cts +1 -1
  16. package/dist/db/index.d.ts +1 -1
  17. package/dist/db/index.js +3 -3
  18. package/dist/engine/index.cjs +143 -38
  19. package/dist/engine/index.cjs.map +1 -1
  20. package/dist/engine/index.d.cts +3 -3
  21. package/dist/engine/index.d.ts +3 -3
  22. package/dist/engine/index.js +11 -4
  23. package/dist/{index-H-0qv5d4.d.cts → index-9C3JHxg-.d.cts} +112 -5
  24. package/dist/{index-CAKOgAlP.d.ts → index-BbvOoZFr.d.ts} +112 -5
  25. package/dist/{index-CgE4sVhg.d.cts → index-DtISj9QX.d.cts} +94 -11
  26. package/dist/{index-V7QRh1wg.d.ts → index-dTTLlHIn.d.ts} +94 -11
  27. package/dist/index.cjs +67 -4
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +6 -22
  30. package/dist/index.d.ts +6 -22
  31. package/dist/index.js +10 -4
  32. package/dist/index.js.map +1 -1
  33. package/dist/openapi/index.d.cts +2 -2
  34. package/dist/openapi/index.d.ts +2 -2
  35. package/dist/{registry-4EI8aaFs.d.ts → registry-JQNIX-eA.d.ts} +1 -1
  36. package/dist/{registry-DHsPDY0_.d.cts → registry-qIPM5BQe.d.cts} +1 -1
  37. package/dist/test/index.cjs +73 -6
  38. package/dist/test/index.cjs.map +1 -1
  39. package/dist/test/index.d.cts +1 -1
  40. package/dist/test/index.d.ts +1 -1
  41. package/dist/test/index.js +70 -6
  42. package/dist/test/index.js.map +1 -1
  43. package/docs/README.md +1 -1
  44. package/docs/database.md +69 -1
  45. package/docs/llms-full.txt +70 -2
  46. package/package.json +1 -1
  47. package/template/package.json +1 -1
  48. package/dist/chunk-BQN723PL.js.map +0 -1
  49. package/dist/chunk-EB3TUX5J.js.map +0 -1
  50. package/dist/chunk-JVZQCC77.js.map +0 -1
  51. package/dist/chunk-OZKSM3JW.js.map +0 -1
  52. /package/dist/{chunk-XABHGMUT.js.map → chunk-IVZERLTM.js.map} +0 -0
@@ -1,5 +1,5 @@
1
1
  import { T as Token } from '../module-Dl1KFVtc.cjs';
2
- import { D as DBClient } from '../index-CgE4sVhg.cjs';
2
+ import { D as DBClient } from '../index-DtISj9QX.cjs';
3
3
  import '../db/env.cjs';
4
4
  import '../stack.cjs';
5
5
  import 'zod';
@@ -1,5 +1,5 @@
1
1
  import { T as Token } from '../module-Dl1KFVtc.js';
2
- import { D as DBClient } from '../index-V7QRh1wg.js';
2
+ import { D as DBClient } from '../index-dTTLlHIn.js';
3
3
  import '../db/env.js';
4
4
  import '../stack.js';
5
5
  import 'zod';
@@ -7,7 +7,7 @@ import {
7
7
  isColumnExpr,
8
8
  isNowExpr,
9
9
  isSqlFragment
10
- } from "../chunk-JVZQCC77.js";
10
+ } from "../chunk-3TUJWHC2.js";
11
11
  import {
12
12
  __name
13
13
  } from "../chunk-VXPNPVAG.js";
@@ -506,6 +506,22 @@ function createMockDB() {
506
506
  ]);
507
507
  }
508
508
  __name(track, "track");
509
+ function resolveInsertValues(caller, table, data) {
510
+ const out = {};
511
+ for (const [k, v] of Object.entries(data)) {
512
+ const expr = columnExprOf(v);
513
+ if (expr !== null && expr.fn === "now") {
514
+ out[k] = (/* @__PURE__ */ new Date()).toISOString();
515
+ continue;
516
+ }
517
+ if (expr !== null) {
518
+ throw new Error(`${caller}(${table}): "${k}" ${expr.fn === "inc" ? "increment()" : "decrement()"} ald\u0131 \u2014 sat\u0131r HEN\xDCZ YOK, yani "kolonun \u015Fu anki de\u011Feri" diye bir \u015Fey yok.`);
519
+ }
520
+ out[k] = v;
521
+ }
522
+ return out;
523
+ }
524
+ __name(resolveInsertValues, "resolveInsertValues");
509
525
  const ops = {
510
526
  // The bulk ops and count run against the SAME in-memory store the direct
511
527
  // ops write to, so a test that writes three rows and counts them gets 3 —
@@ -568,7 +584,8 @@ function createMockDB() {
568
584
  async query(_sql, _params) {
569
585
  return [];
570
586
  },
571
- async insert(table, data) {
587
+ async insert(table, raw) {
588
+ const data = resolveInsertValues("insert", table, raw);
572
589
  assertUsableWriteValues("insert", table, Object.keys(data), data);
573
590
  assertNoExpressionHandles("insert", table, Object.keys(data), data);
574
591
  const record = {
@@ -580,6 +597,38 @@ function createMockDB() {
580
597
  return record;
581
598
  },
582
599
  /**
600
+ * `insertMany` — motorla PARİTE, ANAHTAR KÜMESİ kuralı dahil.
601
+ *
602
+ * Fake bu kuralı bilmeseydi farklı şekilli satırları kabul eder, test yeşil
603
+ * kalır, üretimde motor adıyla reddederdi — yani fake, sürüm atlamayı
604
+ * kolaylaştırmak yerine gizlerdi.
605
+ */
606
+ async insertMany(table, rows) {
607
+ if (rows.length === 0) return [];
608
+ const cols = Object.keys(rows[0]);
609
+ for (let i = 1; i < rows.length; i++) {
610
+ const missing = cols.filter((c) => !(c in rows[i]));
611
+ const extra = Object.keys(rows[i]).filter((k) => !cols.includes(k));
612
+ if (missing.length > 0 || extra.length > 0) {
613
+ throw new Error(`insertMany(${table}): ${i}. sat\u0131r\u0131n kolonlar\u0131 ilk sat\u0131rla ayn\u0131 de\u011Fil` + (missing.length > 0 ? ` (eksik: ${missing.join(", ")})` : "") + (extra.length > 0 ? ` (fazla: ${extra.join(", ")})` : "") + `. Eksikler i\xE7in null yaz\u0131n, ya da farkl\u0131 \u015Fekilli sat\u0131rlar\u0131 ayr\u0131 \xE7a\u011Fr\u0131larda ekleyin.`);
614
+ }
615
+ }
616
+ const out = [];
617
+ for (const rawRow of rows) {
618
+ const data = resolveInsertValues("insertMany", table, rawRow);
619
+ assertUsableWriteValues("insertMany", table, cols, data);
620
+ assertNoExpressionHandles("insertMany", table, cols, data);
621
+ const record = {
622
+ id: crypto.randomUUID(),
623
+ ...data
624
+ };
625
+ rowsOf(table).push(record);
626
+ track(tracked.inserted, table, record);
627
+ out.push(record);
628
+ }
629
+ return out;
630
+ },
631
+ /**
583
632
  * `claim` — motorla PARİTE (FR-033).
584
633
  *
585
634
  * Fake bunu sunmasaydı `claim` ile yazılmış bir servis, iskelenin yazarlara
@@ -638,10 +687,11 @@ function createMockDB() {
638
687
  },
639
688
  // Same semantics the engine's SQL has: match on the conflict columns, update
640
689
  // everything else, and return the resulting row either way.
641
- async put(table, data, opts) {
690
+ async put(table, rawData, opts) {
642
691
  if (opts.onConflict.length === 0) {
643
692
  throw new Error(`put into ${table}: onConflict en az bir kolon ad\u0131 ister`);
644
693
  }
694
+ const data = resolveInsertValues("put", table, rawData);
645
695
  assertUsableWriteValues("upsert", table, Object.keys(data), data);
646
696
  assertNoExpressionHandles("upsert", table, Object.keys(data), data);
647
697
  const rows = rowsOf(table);
@@ -662,15 +712,29 @@ function createMockDB() {
662
712
  },
663
713
  async update(table, id, data) {
664
714
  assertUsableWriteValues("update", table, Object.keys(data), data);
665
- assertNoExpressionHandles("update", table, Object.keys(data), data);
666
715
  const rows = store.get(table) ?? [];
667
716
  const idx = rows.findIndex((r) => r["id"] === id);
717
+ const current = idx >= 0 ? rows[idx] : {};
718
+ const applied = {};
719
+ for (const [k, v] of Object.entries(data)) {
720
+ const expr = columnExprOf(v);
721
+ if (expr !== null && expr.fn === "now") {
722
+ applied[k] = /* @__PURE__ */ new Date();
723
+ continue;
724
+ }
725
+ if (expr !== null) {
726
+ applied[k] = addDecimal(current[k], expr.by, expr.fn === "inc" ? 1 : -1);
727
+ continue;
728
+ }
729
+ applied[k] = v;
730
+ }
731
+ assertNoExpressionHandles("update", table, Object.keys(applied), applied);
668
732
  const updated = idx >= 0 ? {
669
733
  ...rows[idx],
670
- ...data
734
+ ...applied
671
735
  } : {
672
736
  id,
673
- ...data
737
+ ...applied
674
738
  };
675
739
  if (idx >= 0) {
676
740
  rows[idx] = updated;