Skip to content

Commit 305d86f

Browse files
committed
fix(rest): pin the test double's write verbs and drop two test-layer type errors (#7134)
Two CI gates on the previous head, both in the test file added by this PR: `check:engine-double-contract` — the stub engine's `delete()` / `update()` did not route through the producer's own dispatch predicates, so the double was free to accept calls `ObjectQL` itself refuses. A fake looser than the real implementation is a defect generator (#4434 shipped a dead REST route with a green suite that way), which is the exact failure mode this card is about. Both verbs now open with `assertEngineDeleteDispatch` / `assertEngineUpdateDispatch` from `@objectstack/metadata-core` — already a dependency of this package, and the right side of the edge: importing them from `@objectstack/objectql` would invert a dependency turbo refuses. `check:type-check-debt --re-measure` — `@objectstack/rest`'s TEST_DEBT records 155 and the branch measured 157. Both new errors came from ONE cause: the extensionless `./rest-server` import does not resolve under `moduleResolution: nodenext`, so `RestServer` became `any` and the callback over it reported TS7006. Adding the `.js` extension takes the package back to exactly 155 — the ledger is untouched, which is what a shrink-only ratchet requires. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LBDWUuXmTrHe1o13eik3bT
1 parent 161f5ec commit 305d86f

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

packages/rest/src/public-form-routes.stored-row.test.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,24 @@
4444
* That is a deliberate scope line, not an oversight.
4545
*/
4646
import { describe, expect, it, vi } from 'vitest';
47+
// The producer's OWN write-verb dispatch decisions (#4550 delete / #5480
48+
// update), so this fake cannot accept a call ObjectQL itself refuses — a double
49+
// LOOSER than the real engine is a defect generator, which is how #4434 shipped
50+
// a dead REST route with a green suite. That failure mode is this very card's
51+
// subject, so the gate is defending the thing being fixed here.
52+
//
53+
// From `@objectstack/metadata-core` and NOT `@objectstack/objectql`: objectql
54+
// depends in this direction, and that reverse edge is a cycle turbo refuses.
55+
import {
56+
assertEngineDeleteDispatch,
57+
assertEngineUpdateDispatch,
58+
} from '@objectstack/metadata-core';
4759
import { ObjectStackProtocolImplementation } from '@objectstack/metadata-protocol';
48-
import { RestServer } from './rest-server';
60+
// `.js` extension required under `moduleResolution: nodenext`. Without it the
61+
// import does not resolve, `RestServer` becomes `any`, and every callback over
62+
// it reports TS7006 — one broken extension reading as two type errors in this
63+
// package's TEST_DEBT re-measure.
64+
import { RestServer } from './rest-server.js';
4965

5066
// ─── the real save path ──────────────────────────────────────────────────────
5167

@@ -64,8 +80,14 @@ function stubEngine() {
6480
rows.push({ id: `r_${nextId}`, ...data });
6581
return { id: `r_${nextId}` };
6682
},
67-
async update() { return { id: null }; },
68-
async delete() { return { deleted: 0 }; },
83+
async update(_table: string, data: Record<string, any>, options: Record<string, any>) {
84+
assertEngineUpdateDispatch(data, options);
85+
return { id: null };
86+
},
87+
async delete(_table: string, options: Record<string, any>) {
88+
assertEngineDeleteDispatch(options);
89+
return { deleted: 0 };
90+
},
6991
registry: { registerItem: () => {}, registerObject: () => {}, listItems: () => [] },
7092
} as any,
7193
};

0 commit comments

Comments
 (0)