@palbase/backend 33.0.2 → 34.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 (81) hide show
  1. package/dist/bin/palbase-backend.cjs +2020 -350
  2. package/dist/bin/palbase-backend.cjs.map +1 -1
  3. package/dist/bin/palbase-backend.js +9 -7
  4. package/dist/bin/palbase-backend.js.map +1 -1
  5. package/dist/{chunk-SI4KGEM3.js → chunk-FOWA7PF4.js} +97 -96
  6. package/dist/chunk-FOWA7PF4.js.map +1 -0
  7. package/dist/chunk-GHNC2UHS.js +20 -0
  8. package/dist/chunk-GHNC2UHS.js.map +1 -0
  9. package/dist/{chunk-AAT5G7KY.js → chunk-JJW3L62T.js} +2 -2
  10. package/dist/chunk-JJW3L62T.js.map +1 -0
  11. package/dist/{chunk-TVCCR6SO.js → chunk-LOGL2ZHD.js} +58 -9
  12. package/dist/chunk-LOGL2ZHD.js.map +1 -0
  13. package/dist/{chunk-C6COAB3E.js → chunk-MNGZE2MM.js} +1651 -186
  14. package/dist/chunk-MNGZE2MM.js.map +1 -0
  15. package/dist/{chunk-XOX6RFPZ.js → chunk-PRH45NZU.js} +46 -3
  16. package/dist/chunk-PRH45NZU.js.map +1 -0
  17. package/dist/{chunk-26GH54D2.js → chunk-RZLY4BOY.js} +5 -3
  18. package/dist/{chunk-26GH54D2.js.map → chunk-RZLY4BOY.js.map} +1 -1
  19. package/dist/{chunk-YIQ4RS4F.js → chunk-SEM36BWY.js} +283 -5
  20. package/dist/chunk-SEM36BWY.js.map +1 -0
  21. package/dist/{chunk-KATPXCJ5.js → chunk-UMESJJRS.js} +19 -40
  22. package/dist/chunk-UMESJJRS.js.map +1 -0
  23. package/dist/chunk-VXPNPVAG.js +40 -0
  24. package/dist/chunk-VXPNPVAG.js.map +1 -0
  25. package/dist/{chunk-WWUG2QXF.js → chunk-YX7UA7VC.js} +53 -4
  26. package/dist/chunk-YX7UA7VC.js.map +1 -0
  27. package/dist/db/env.cjs.map +1 -1
  28. package/dist/db/env.d.cts +2 -0
  29. package/dist/db/env.d.ts +2 -0
  30. package/dist/db/index.cjs +261 -2
  31. package/dist/db/index.cjs.map +1 -1
  32. package/dist/db/index.d.cts +46 -3
  33. package/dist/db/index.d.ts +46 -3
  34. package/dist/db/index.js +14 -5
  35. package/dist/{index-DMZG3kpo.d.ts → endpoint-DpNUx-ON.d.ts} +315 -57
  36. package/dist/{index-DB_nW-AV.d.cts → endpoint-kYgEHrrV.d.cts} +315 -57
  37. package/dist/engine/index.cjs +2026 -348
  38. package/dist/engine/index.cjs.map +1 -1
  39. package/dist/engine/index.d.cts +5 -5
  40. package/dist/engine/index.d.ts +5 -5
  41. package/dist/engine/index.js +17 -7
  42. package/dist/{index-D-3duy8Y.d.ts → index-JrHqNsjQ.d.ts} +108 -50
  43. package/dist/{index-DLveQoOf.d.cts → index-pnDsEfxJ.d.cts} +108 -50
  44. package/dist/index.cjs +616 -254
  45. package/dist/index.cjs.map +1 -1
  46. package/dist/index.d.cts +7 -6
  47. package/dist/index.d.ts +7 -6
  48. package/dist/index.js +25 -15
  49. package/dist/index.js.map +1 -1
  50. package/dist/openapi/index.cjs +7 -0
  51. package/dist/openapi/index.cjs.map +1 -1
  52. package/dist/openapi/index.d.cts +3 -3
  53. package/dist/openapi/index.d.ts +3 -3
  54. package/dist/openapi/index.js +4 -3
  55. package/dist/openapi/index.js.map +1 -1
  56. package/dist/{registry-DSTThhKf.d.cts → registry-BcOd8Zhf.d.cts} +3 -1
  57. package/dist/{registry-JjF5lcj4.d.ts → registry-BoX5iNyY.d.ts} +3 -1
  58. package/dist/test/index.cjs +103 -66
  59. package/dist/test/index.cjs.map +1 -1
  60. package/dist/test/index.d.cts +3 -3
  61. package/dist/test/index.d.ts +3 -3
  62. package/dist/test/index.js +33 -7
  63. package/dist/test/index.js.map +1 -1
  64. package/docs/README.md +1 -1
  65. package/docs/database.md +308 -0
  66. package/docs/examples/check-query-contracts.ts +5 -0
  67. package/docs/examples/database-dx.contract.json +65 -0
  68. package/docs/examples/database-dx.ts +63 -0
  69. package/docs/examples/money-transfer.ts +73 -0
  70. package/docs/llms-full.txt +309 -1
  71. package/package.json +1 -2
  72. package/template/package.json +1 -1
  73. package/dist/chunk-AAT5G7KY.js.map +0 -1
  74. package/dist/chunk-C6COAB3E.js.map +0 -1
  75. package/dist/chunk-KATPXCJ5.js.map +0 -1
  76. package/dist/chunk-SI4KGEM3.js.map +0 -1
  77. package/dist/chunk-TVCCR6SO.js.map +0 -1
  78. package/dist/chunk-WWUG2QXF.js.map +0 -1
  79. package/dist/chunk-XOX6RFPZ.js.map +0 -1
  80. package/dist/chunk-YIQ4RS4F.js.map +0 -1
  81. package/stack-images.json +0 -24
@@ -1,8 +1,8 @@
1
1
  import { T as Token } from '../module-Dl1KFVtc.cjs';
2
- import { E as EnvServiceDatabase, D as DBClient, a as RuntimeServices } from '../index-DB_nW-AV.cjs';
3
- import '../db/env.cjs';
4
- import '../stack.cjs';
2
+ import { E as EnvServiceDatabase, a as DBClient, b as RuntimeServices } from '../endpoint-kYgEHrrV.cjs';
5
3
  import 'zod';
4
+ import '../stack.cjs';
5
+ import '../db/env.cjs';
6
6
  import 'node:async_hooks';
7
7
 
8
8
  /** The client a tenant's tests use to call their own backend.
@@ -1,8 +1,8 @@
1
1
  import { T as Token } from '../module-Dl1KFVtc.js';
2
- import { E as EnvServiceDatabase, D as DBClient, a as RuntimeServices } from '../index-DMZG3kpo.js';
3
- import '../db/env.js';
4
- import '../stack.js';
2
+ import { E as EnvServiceDatabase, a as DBClient, b as RuntimeServices } from '../endpoint-DpNUx-ON.js';
5
3
  import 'zod';
4
+ import '../stack.js';
5
+ import '../db/env.js';
6
6
  import 'node:async_hooks';
7
7
 
8
8
  /** The client a tenant's tests use to call their own backend.
@@ -1,7 +1,10 @@
1
+ import {
2
+ validateInsertManyOptions
3
+ } from "../chunk-GHNC2UHS.js";
1
4
  import {
2
5
  __requestALS,
3
6
  makeTypedSurface
4
- } from "../chunk-TVCCR6SO.js";
7
+ } from "../chunk-LOGL2ZHD.js";
5
8
  import {
6
9
  assertNoExpressionHandles,
7
10
  assertUsableFilter,
@@ -11,10 +14,10 @@ import {
11
14
  isColumnExpr,
12
15
  isNowExpr,
13
16
  isSqlFragment
14
- } from "../chunk-SI4KGEM3.js";
17
+ } from "../chunk-FOWA7PF4.js";
15
18
  import {
16
19
  __name
17
- } from "../chunk-KATPXCJ5.js";
20
+ } from "../chunk-VXPNPVAG.js";
18
21
 
19
22
  // ../node_modules/.pnpm/@hpke+common@1.10.1/node_modules/@hpke/common/esm/_dnt.shims.js
20
23
  var dntGlobals = {};
@@ -1636,6 +1639,14 @@ function createMockDB() {
1636
1639
  }
1637
1640
  __name(resolveInsertValues, "resolveInsertValues");
1638
1641
  const ops = {
1642
+ diagnostics: /* @__PURE__ */ __name(() => null, "diagnostics"),
1643
+ readQuery: /* @__PURE__ */ __name((query) => ops.findMany(query.table, query.where, query.options), "readQuery"),
1644
+ compileQuery() {
1645
+ throw new Error("MockDB cannot compile PostgreSQL query plans; use the real engine to inspect SQL");
1646
+ },
1647
+ async explainQuery() {
1648
+ throw new Error("MockDB cannot EXPLAIN PostgreSQL plans; use a PostgreSQL integration test");
1649
+ },
1639
1650
  // The bulk ops and count run against the SAME in-memory store the direct
1640
1651
  // ops write to, so a test that writes three rows and counts them gets 3 —
1641
1652
  // a mock that answered 0 would make the surface look broken in exactly the
@@ -1773,8 +1784,10 @@ function createMockDB() {
1773
1784
  return out;
1774
1785
  });
1775
1786
  },
1776
- async insertMany(table, rows) {
1777
- if (rows.length === 0) return [];
1787
+ insertMany: /* @__PURE__ */ __name(async function(table, rows, opts) {
1788
+ validateInsertManyOptions(opts);
1789
+ if (opts?.onConflict?.length) throw new Error("fakeDatabase insertMany cannot enforce PostgreSQL unique constraints; use an integration test for onConflict");
1790
+ if (rows.length === 0) return opts?.returning === false ? 0 : [];
1778
1791
  const cols = Object.keys(rows[0]);
1779
1792
  for (let i = 1; i < rows.length; i++) {
1780
1793
  const missing = cols.filter((c) => !(c in rows[i]));
@@ -1796,8 +1809,8 @@ function createMockDB() {
1796
1809
  track(tracked.inserted, table, record);
1797
1810
  out.push(record);
1798
1811
  }
1799
- return out;
1800
- },
1812
+ return opts?.returning === false ? out.length : out;
1813
+ }, "insertMany"),
1801
1814
  /**
1802
1815
  * `claim` — motorla PARİTE (FR-033).
1803
1816
  *
@@ -1919,6 +1932,9 @@ function createMockDB() {
1919
1932
  id
1920
1933
  ]);
1921
1934
  },
1935
+ async findUnique() {
1936
+ throw new Error("MockDB.findUnique cannot verify declared PostgreSQL unique constraints; use a PostgreSQL integration test");
1937
+ },
1922
1938
  async findById(table, id) {
1923
1939
  const rows = store.get(table) ?? [];
1924
1940
  return rows.find((r) => r["id"] === id) ?? null;
@@ -1927,6 +1943,9 @@ function createMockDB() {
1927
1943
  // equality, an object is an operator set. A fake that understood less would
1928
1944
  // pass a service test that the live database then fails — which is the one
1929
1945
  // thing a stand-in must never do.
1946
+ async page() {
1947
+ throw new Error("fakeDatabase cannot reproduce PostgreSQL cursor ordering, collations or RLS; use a PostgreSQL integration test or inject an explicit page response");
1948
+ },
1930
1949
  async findMany(table, query, opts) {
1931
1950
  assertUsableFilter("findMany", table, query);
1932
1951
  refuseFragment("findMany", table, query);
@@ -2121,6 +2140,13 @@ function createMockDB() {
2121
2140
  __name(applyOp, "applyOp");
2122
2141
  const client = {
2123
2142
  ...ops,
2143
+ async command(plan, options) {
2144
+ if (options?.mode === "compiled") throw new Error("fakeDatabase does not run the PostgreSQL command executor; verify compiled mode against PostgreSQL");
2145
+ return client.txPlan(plan);
2146
+ },
2147
+ async atomic() {
2148
+ throw new Error("fakeDatabase cannot verify physical transaction isolation, COMMIT or retry; test $atomic against PostgreSQL or inject a transaction test double explicitly");
2149
+ },
2124
2150
  // No real savepoint in memory: the fake runs the callback against the SAME
2125
2151
  // store. An assertion about rollback here would be asserting the fake.
2126
2152
  attempt: /* @__PURE__ */ __name((fn) => fn(ops), "attempt"),