@palbase/backend 27.0.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 +165 -39
  2. package/dist/bin/palbase-backend.cjs.map +1 -1
  3. package/dist/bin/palbase-backend.js +4 -4
  4. package/dist/{chunk-GYK6QYS4.js → chunk-3TUJWHC2.js} +28 -3
  5. package/dist/chunk-3TUJWHC2.js.map +1 -0
  6. package/dist/{chunk-OO7R25AI.js → chunk-75YROPRZ.js} +118 -39
  7. package/dist/chunk-75YROPRZ.js.map +1 -0
  8. package/dist/{chunk-TS4U7NBD.js → chunk-IVZERLTM.js} +2 -2
  9. package/dist/{chunk-I3C4PFIW.js → chunk-RVP6BTEZ.js} +63 -6
  10. package/dist/chunk-RVP6BTEZ.js.map +1 -0
  11. package/dist/{chunk-DRZFQRJI.js → chunk-SNDXY565.js} +3 -2
  12. package/dist/chunk-SNDXY565.js.map +1 -0
  13. package/dist/db/index.cjs +30 -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 +175 -39
  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-VtToZmUm.d.cts → index-9C3JHxg-.d.cts} +112 -5
  24. package/dist/{index-NuzRCuxe.d.ts → index-BbvOoZFr.d.ts} +112 -5
  25. package/dist/{index-Bve7BBTL.d.cts → index-DtISj9QX.d.cts} +125 -22
  26. package/dist/{index-BrvvxSpn.d.ts → index-dTTLlHIn.d.ts} +125 -22
  27. package/dist/index.cjs +93 -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-B0eyOF9x.d.ts → registry-JQNIX-eA.d.ts} +1 -1
  36. package/dist/{registry-Bk9_rbNd.d.cts → registry-qIPM5BQe.d.cts} +1 -1
  37. package/dist/test/index.cjs +100 -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 +88 -6
  42. package/dist/test/index.js.map +1 -1
  43. package/docs/README.md +1 -1
  44. package/docs/database.md +103 -1
  45. package/docs/llms-full.txt +104 -2
  46. package/package.json +1 -1
  47. package/template/package.json +1 -1
  48. package/dist/chunk-DRZFQRJI.js.map +0 -1
  49. package/dist/chunk-GYK6QYS4.js.map +0 -1
  50. package/dist/chunk-I3C4PFIW.js.map +0 -1
  51. package/dist/chunk-OO7R25AI.js.map +0 -1
  52. /package/dist/{chunk-TS4U7NBD.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-Bve7BBTL.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-BrvvxSpn.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';
@@ -4,8 +4,10 @@ import {
4
4
  assertUsableWriteValues,
5
5
  columnExprOf,
6
6
  isColRef,
7
+ isColumnExpr,
8
+ isNowExpr,
7
9
  isSqlFragment
8
- } from "../chunk-GYK6QYS4.js";
10
+ } from "../chunk-3TUJWHC2.js";
9
11
  import {
10
12
  __name
11
13
  } from "../chunk-VXPNPVAG.js";
@@ -410,9 +412,25 @@ function cmp(a, b, op) {
410
412
  __name(cmp, "cmp");
411
413
  function matchesCell(caller, table, row, key, cond) {
412
414
  if (isColRef(cond)) return cmp(row[key], row[cond.$col], "eq");
415
+ if (isNowExpr(cond)) return cmp(row[key], (/* @__PURE__ */ new Date()).toISOString(), "eq");
413
416
  if (cond !== null && typeof cond === "object" && !Array.isArray(cond)) {
414
417
  return Object.entries(cond).every(([op, v]) => {
415
418
  const cell = row[key];
419
+ if (isNowExpr(v)) {
420
+ if (![
421
+ "neq",
422
+ "gt",
423
+ "gte",
424
+ "lt",
425
+ "lte"
426
+ ].includes(op)) {
427
+ throw new Error(`${caller}(${table}): where.${key}.${op} now() ile kullan\u0131lamaz`);
428
+ }
429
+ return cmp(cell, (/* @__PURE__ */ new Date()).toISOString(), op);
430
+ }
431
+ if (isColumnExpr(v)) {
432
+ throw new Error(`${caller}(${table}): where.${key}.${op} bir YAZMA ifadesi ald\u0131 (increment/decrement) \u2014 kar\u015F\u0131la\u015Ft\u0131rma de\u011Feri de\u011Fil. Sunucu saati i\xE7in now() kullan\u0131n.`);
433
+ }
416
434
  if (isColRef(v)) {
417
435
  if (![
418
436
  "neq",
@@ -488,6 +506,22 @@ function createMockDB() {
488
506
  ]);
489
507
  }
490
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");
491
525
  const ops = {
492
526
  // The bulk ops and count run against the SAME in-memory store the direct
493
527
  // ops write to, so a test that writes three rows and counts them gets 3 —
@@ -550,7 +584,8 @@ function createMockDB() {
550
584
  async query(_sql, _params) {
551
585
  return [];
552
586
  },
553
- async insert(table, data) {
587
+ async insert(table, raw) {
588
+ const data = resolveInsertValues("insert", table, raw);
554
589
  assertUsableWriteValues("insert", table, Object.keys(data), data);
555
590
  assertNoExpressionHandles("insert", table, Object.keys(data), data);
556
591
  const record = {
@@ -562,6 +597,38 @@ function createMockDB() {
562
597
  return record;
563
598
  },
564
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
+ /**
565
632
  * `claim` — motorla PARİTE (FR-033).
566
633
  *
567
634
  * Fake bunu sunmasaydı `claim` ile yazılmış bir servis, iskelenin yazarlara
@@ -620,10 +687,11 @@ function createMockDB() {
620
687
  },
621
688
  // Same semantics the engine's SQL has: match on the conflict columns, update
622
689
  // everything else, and return the resulting row either way.
623
- async put(table, data, opts) {
690
+ async put(table, rawData, opts) {
624
691
  if (opts.onConflict.length === 0) {
625
692
  throw new Error(`put into ${table}: onConflict en az bir kolon ad\u0131 ister`);
626
693
  }
694
+ const data = resolveInsertValues("put", table, rawData);
627
695
  assertUsableWriteValues("upsert", table, Object.keys(data), data);
628
696
  assertNoExpressionHandles("upsert", table, Object.keys(data), data);
629
697
  const rows = rowsOf(table);
@@ -644,15 +712,29 @@ function createMockDB() {
644
712
  },
645
713
  async update(table, id, data) {
646
714
  assertUsableWriteValues("update", table, Object.keys(data), data);
647
- assertNoExpressionHandles("update", table, Object.keys(data), data);
648
715
  const rows = store.get(table) ?? [];
649
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);
650
732
  const updated = idx >= 0 ? {
651
733
  ...rows[idx],
652
- ...data
734
+ ...applied
653
735
  } : {
654
736
  id,
655
- ...data
737
+ ...applied
656
738
  };
657
739
  if (idx >= 0) {
658
740
  rows[idx] = updated;