@palbase/backend 36.0.1 → 37.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.
package/docs/README.md CHANGED
@@ -82,7 +82,7 @@ service the controllers call.
82
82
 
83
83
  > **Never** emit `defineController`, `defineHandler`, `defineEndpoint`, `route.get(...)`,
84
84
  > `req.input`, `req.params`, or `req.errors` — those are the removed legacy model
85
- > and will not compile against `@palbase/backend` 36.
85
+ > and will not compile against `@palbase/backend` 37.
86
86
 
87
87
  ### Complete CRUD example (copy-pasteable, compiles)
88
88
 
@@ -90,7 +90,7 @@ service the controllers call.
90
90
 
91
91
  > **Never** emit `defineController`, `defineHandler`, `defineEndpoint`, `route.get(...)`,
92
92
  > `req.input`, `req.params`, or `req.errors` — those are the removed legacy model
93
- > and will not compile against `@palbase/backend` 36.
93
+ > and will not compile against `@palbase/backend` 37.
94
94
 
95
95
  ### Complete CRUD example (copy-pasteable, compiles)
96
96
 
@@ -0,0 +1,75 @@
1
+ # Fake pagination and claim: verification sources
2
+
3
+ Verified 2026-09-06. Scope: repair the two existing in-memory fake contracts,
4
+ using the repository's existing runtime and test runner. No new dependency or
5
+ public API is introduced.
6
+
7
+ | ID | Existing tool | Stakes | Tier | Status | Evidence |
8
+ | --- | --- | --- | --- | --- | --- |
9
+ | UD-001 | Bun 1.3.9 for independent consumer probes | 1 | quick | verified | `bun --version`; published-package and built-package probe executions |
10
+ | UD-002 | Vitest 3.2.4 for SDK regressions | 1 | quick | verified | `backend/package.json`, runtime version output, Context7 CLI documentation |
11
+
12
+ CLAIM: Bun supports direct TypeScript execution and reports test/runtime failures
13
+ with a nonzero exit status. SOURCE:
14
+ https://github.com/oven-sh/bun/blob/main/docs/test/runtime-behavior.mdx
15
+ VERIFIED: 2026-09-06 via Context7 and actual Bun 1.3.9 probe exits 1/0.
16
+ TIER: quick. Current docs are not an assertion that their latest Bun version is
17
+ the installed version; the installed runtime was measured separately.
18
+
19
+ CLAIM: Vitest's file arguments select test paths; `run` performs a single run.
20
+ SOURCE: https://github.com/vitest-dev/vitest/blob/v3.2.4/docs/guide/cli.md
21
+ VERIFIED: 2026-09-06 via Context7 and focused red/green executions.
22
+ TIER: quick.
23
+
24
+ CLAIM: `--no-file-parallelism` runs test files without file concurrency.
25
+ SOURCE: https://github.com/vitest-dev/vitest/blob/v3.2.4/docs/guide/debugging.md
26
+ VERIFIED: 2026-09-06 via Context7 and installed
27
+ `pnpm --filter @palbase/backend exec vitest --help --fileParallelism`.
28
+ TIER: quick. This flag changes scheduling, preserving test assertions, selected
29
+ files, type checking, and timeouts.
30
+
31
+ The SDK contracts were checked against local primary sources:
32
+
33
+ - `docs/database.md:179`: `now()` works in `claim` and other insert operations.
34
+ - `docs/database.md:355`: offset requires limit.
35
+ - `src/engine/db.ts:1403`: nonnegative integer limit validation.
36
+ - `src/engine/db.ts:1417`: nonnegative integer offset validation and limit requirement.
37
+ - `src/engine/db.ts:2362`: claim merges unique/extra and compiles insert expressions.
38
+ - `src/__tests__/helpers/mock-db.ts:277`: existing insert-expression resolver.
39
+
40
+ Runtime evidence separating the hypotheses is in `verification.md`.
41
+
42
+ ## Publication follow-up
43
+
44
+ The user requested publication after the source fix was verified. Publication
45
+ uses the repository's existing Changesets workflow; stakes 3, standard tier.
46
+ Context7 was attempted twice but its transport was unavailable, so the official
47
+ Changesets CLI documentation was read directly and checked against the local
48
+ workflow and a successful live run.
49
+
50
+ | ID | Existing approach | Stakes | Tier | Status | Evidence |
51
+ | --- | --- | --- | --- | --- | --- |
52
+ | UD-003 | Changesets version commit followed by the main release workflow | 3 | standard | verified | `.github/workflows/release.yml`, `package.json`, official CLI docs and run 34035374818 |
53
+
54
+ CLAIM: `changeset version` updates package versions/changelogs, and `publish`
55
+ publishes package versions absent from npm. SOURCE:
56
+ https://github.com/changesets/changesets/blob/main/docs/command-line-options.md
57
+ VERIFIED: 2026-09-06 via official documentation, installed CLI 2.30.0, and the
58
+ repository's `ci:version`/`ci:publish` scripts. TIER: standard.
59
+
60
+ CLAIM: This repository versions locally, pushes to main, verifies matching core
61
+ images first, then publishes npm and advances latest/next. SOURCE:
62
+ https://github.com/palgroup/palbase-ts/blob/e9765e8460bbe9c4a20641f805a5e682f0097174/.github/workflows/release.yml
63
+ and https://github.com/palgroup/palbase-ts/actions/runs/34035374818
64
+ VERIFIED: 2026-09-06 via the workflow source and GitHub run state. TIER: standard.
65
+
66
+ Registry evidence: `latest` and `next` both resolve to 36.0.1; querying 36.0.2
67
+ returned E404 before versioning. Only the backend package is selected for a
68
+ patch release, with the existing image-before-npm order preserved.
69
+
70
+ Publication preflight observation: `ci:version` initially failed in the GitHub
71
+ changelog adapter because the local fix commit was not yet on GitHub. The commit
72
+ API returned HTTP 422 for `bfd6060` and resolved the existing base commit, ruling
73
+ out an authentication failure. Publishing the fix commit to a temporary branch
74
+ made the same `ci:version` command succeed without changing tooling or workflow.
75
+ Only backend package version/changelog and the consumed changeset changed.
@@ -0,0 +1,145 @@
1
+ # Backend fake defects: proof, fix, proof
2
+
3
+ Date: 2026-09-06. Runtime: Bun 1.3.9, macOS arm64.
4
+ Published baseline: `@palbase/backend@36.0.0` from npm, unchanged.
5
+ Source baseline: nested `palbase-ts` repository, commit `295958d`, package 36.0.1.
6
+ The source checkout still contained both reported defects.
7
+
8
+ ## Reproduction
9
+
10
+ The supplied `scripts/reproduce-sdk-bugs.ts` was absent from this workspace.
11
+ `backend/scripts/reproduce-sdk-bugs.ts` reconstructs the two supplied independent
12
+ contracts with public package imports and no application fixtures or credentials.
13
+ An identical copy was run in a scratch consumer of the published npm tarball.
14
+
15
+ Published baseline commands:
16
+
17
+ ```sh
18
+ npm pack @palbase/backend@36.0.0 --ignore-scripts --pack-destination /tmp/palbase-sdk-fake-proof.CaHHuo --json
19
+ # Scratch package depends on that unchanged tarball.
20
+ bun install --ignore-scripts
21
+ bun reproduce-sdk-bugs.ts
22
+ ```
23
+
24
+ Observed before any source fix:
25
+
26
+ ```text
27
+ FAIL findMany honors offset before limit
28
+ actual: [{ id: 'a' }], expected: [{ id: 'b' }]
29
+ FAIL claim evaluates now() in returned and stored rows
30
+ actual typeof created_at: 'object', expected: 'string'
31
+ 0 passed, 2 failed
32
+ exit 1
33
+ ```
34
+
35
+ The raw claim's returned AND stored rows carried `Symbol(palbase.tx.expr)`.
36
+ Tarball SHA-1 from npm pack: `0c665f63e2a9b98f5f736df050d17038305a5399`.
37
+
38
+ ## Hypotheses and runtime discrimination
39
+
40
+ Pagination hypotheses: ignored offset, lost typed forwarding, wrong ordering.
41
+ With deliberately unsorted `c,a,b` seeds, raw calls at offsets 0, 1, 2 and 3
42
+ all returned `a`. Sorting therefore ran, and bypassing the typed wrapper still
43
+ failed. The source pagination step used `slice(0, limit)` and its local option
44
+ type omitted offset.
45
+
46
+ Claim hypotheses: skipped insert-expression evaluation, incompatible expression
47
+ marker, accidental materialization during reading. Passing the SAME `now()`
48
+ object to insert and claim returned a timestamp from insert, while claim stored
49
+ that original expression object by identity. A later read also returned the
50
+ expression, excluding a return-only formatting error.
51
+
52
+ Observed paths, cross-checked against the source:
53
+
54
+ - Public `/test` export → `src/test/fake-db.ts:65` → shared
55
+ `src/__tests__/helpers/mock-db.ts` operation implementation.
56
+ - Typed `fake.db.public.<table>.findMany` → `src/runtime.ts:498` → the same
57
+ raw operation, with offset forwarded.
58
+ - Typed claim → `src/runtime.ts:531` → raw claim.
59
+ - The helper is bundled into the shipped `/test` entry by `tsup.config.ts`;
60
+ its `__tests__` directory name does not make it an unused test-only copy.
61
+
62
+ ## Source regression proof and changes
63
+
64
+ Command before and after the implementation change, from `backend`:
65
+
66
+ ```sh
67
+ pnpm test src/test/fake-db.test.ts src/test/fake-db-parity.test.ts
68
+ ```
69
+
70
+ | Tree | Result | Exit |
71
+ | --- | --- | --- |
72
+ | Original existing focused suite | 37 passed | 0 |
73
+ | New regressions, original implementation | 12 failed, 38 passed | 1 |
74
+ | Same tests, fixed implementation | 50 passed, no type errors | 0 |
75
+
76
+ The repair applies offset after filtering/ordering and before projection, and
77
+ uses the engine's existing limit/offset validation contract. Claim reuses the
78
+ insert-expression resolver and write-value guards before storing a new row.
79
+ Existing-row claims still return the original row without recording a new write.
80
+
81
+ Coverage includes raw and typed calls, filter/sort/projection ordering, distinct
82
+ pages, omitted/zero offset, an empty tail, zero limit, invalid pagination,
83
+ timestamp validity in returned/stored/tracked rows, repeated claims, and refusal
84
+ of invalid insert values without side effects. Explicit `id` lookup/deletion
85
+ semantics are unaffected.
86
+
87
+ ## Built package and review
88
+
89
+ Fresh build: `pnpm -w turbo run build --filter=@palbase/backend` → exit 0,
90
+ backend cache miss, ESM/CJS/declarations generated.
91
+
92
+ From `backend`, against the built public package entry points:
93
+
94
+ ```text
95
+ $ bun scripts/reproduce-sdk-bugs.ts
96
+ PASS findMany honors offset before limit
97
+ PASS claim evaluates now() in returned and stored rows
98
+ 2 passed, 0 failed
99
+ exit 0
100
+ ```
101
+
102
+ `pnpm typecheck` → exit 0.
103
+ `pnpm check:api` → exit 0; 424 exports and 421 signatures unchanged.
104
+ Independent reviewer: no actionable findings; separate source probe and
105
+ 42-test fake suite both passed.
106
+
107
+ ## Full-suite environment findings
108
+
109
+ The first shared-workspace `pnpm test` exited 1: 6 failed / 1900 passed tests,
110
+ 3 collection failures and 3 worker RPC errors. It included ignored generated
111
+ Bun consumer tests under `bench/database-dx/generated/...`, which Vitest cannot
112
+ load (`bun:test`), plus five timeouts under concurrent load.
113
+
114
+ The sixth failure was an existing probabilistic cursor-test assertion:
115
+ `src/engine/cursor.test.ts:15` replaces character 10 with `x`, even when it
116
+ already is `x`. An independent loop observed this at attempt 82: the
117
+ "changed" token equalled the original, and decoding correctly accepted it.
118
+ Neither this test nor cursor implementation is changed by this fix.
119
+
120
+ Final suite verification uses a detached temporary checkout at the same commit,
121
+ with identical fix/test/probe files and the existing installed dependencies.
122
+ File scheduling is serial; no assertions, timeouts or test selections are changed.
123
+ The copied implementation, regression tests, and independent probe were checked
124
+ byte-for-byte against the working files with `cmp` (all exit 0).
125
+
126
+ Final command, from the isolated checkout's `backend` directory:
127
+
128
+ ```text
129
+ $ pnpm test --no-file-parallelism
130
+ Test Files 128 passed (128)
131
+ Tests 1906 passed (1906)
132
+ Type Errors no errors
133
+ Duration 38.41s
134
+ exit 0
135
+ ```
136
+
137
+ The isolated checkout was also freshly built (backend cache miss, exit 0), and
138
+ `bun scripts/reproduce-sdk-bugs.ts` there returned 2 passed / 0 failed, exit 0.
139
+ The shared workspace's generated Bun tests are not tracked SDK test files; their
140
+ absence in this checkout accounts for the three fewer collected files.
141
+
142
+ Full raw command logs are retained in `/tmp/palbase-sdk-fake-proof.CaHHuo`.
143
+ This initial verification covered source and local build artifacts, with no live
144
+ PostgreSQL run. The user subsequently requested publication as backend 36.0.2;
145
+ its registry installation is checked with the same independent contract probes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@palbase/backend",
3
- "version": "36.0.1",
3
+ "version": "37.0.0",
4
4
  "description": "Palbase Backend SDK — class controllers (@Controller/@Get/@Post + @Body/@QueryParams/@Param), error classes, schema DSL",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -18,7 +18,7 @@
18
18
  * foo(): Promise<TodoSchema> → schema = TodoSchema
19
19
  * foo(): Promise<TodoSchema[]> → schema = z.array(TodoSchema)
20
20
  * foo(): TodoSchema / TodoSchema[] → (Promise optional)
21
- * - `void` / `Promise<void>` / no annotation no 200 body (allowed)
21
+ * - `void` / `Promise<void>` explicit z.void() binding, bodyless 204
22
22
  * - anything else (inline object, union, intersection, a type with no
23
23
  * same-named exported zod) → HARD error naming <Controller>.<method>.
24
24
  *
@@ -76,7 +76,7 @@ const RETURN_BUFFER_SYMBOL_KEY = 'palbase.backend.returnBuffer';
76
76
  * @param {string} sourceText the controller's .ts source
77
77
  * @param {string} fileLabel path/name for error messages
78
78
  * @returns {{ className: string, methods: Array<{ fnName, typeName, isArray }>, imports: Record<string,string> }}
79
- * - methods: only routes that HAVE a resolvable named return type (void/none omitted)
79
+ * - methods: named schemas or expressions, including explicit no-body schemas
80
80
  * - imports: local-binding-name → module-specifier (for the injector's import)
81
81
  * Throws ReturnTypeError on an un-resolvable/disallowed return type.
82
82
  */
@@ -251,7 +251,7 @@ function readReturnTypes(sourceText, fileLabel, inferReturn) {
251
251
  if (!m.type) {
252
252
  if (inferReturn) {
253
253
  const expression = inferReturn(fileLabel, className, fnName);
254
- if (expression !== null) methods.push({ fnName, expression });
254
+ methods.push({ fnName, expression: expression ?? 'z.void()' });
255
255
  continue;
256
256
  }
257
257
  throw err(
@@ -261,7 +261,12 @@ function readReturnTypes(sourceText, fileLabel, inferReturn) {
261
261
  );
262
262
  }
263
263
  const resolved = resolveType(m.type, fnName);
264
- if (!resolved) continue; // explicit void/Promise<void> — no 200 body, allowed
264
+ if (!resolved) {
265
+ // Absence of a binding means unknown, not no content. Keep the written
266
+ // contract so OpenAPI can emit 204 and the runtime can reject a body.
267
+ methods.push({ fnName, expression: 'z.void()' });
268
+ continue;
269
+ }
265
270
 
266
271
  const { typeName, isArray } = resolved;
267
272
  // The schema name must be an imported (or locally-defined) value. If it's
@@ -9,7 +9,7 @@
9
9
  "typecheck": "tsc --noEmit"
10
10
  },
11
11
  "dependencies": {
12
- "@palbase/backend": "^36.0.0",
12
+ "@palbase/backend": "^37.0.0",
13
13
  "reflect-metadata": "^0.2.2"
14
14
  },
15
15
  "engines": {