Skip to content

Commit 547a672

Browse files
committed
test(plugin-security): type the real-engine rig explicitly
Claude-Session: https://claude.ai/code/session_011K3zqE8Pv1Evw5hc8tZCnN Co-authored-by: Claude <noreply@anthropic.com>
1 parent 18eacb3 commit 547a672

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

‎packages/plugins/plugin-security/src/by-id-write-unreadable-not-found.test.ts‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,22 @@ const ME = 'usr_nf_member';
4545
const OTHER = 'usr_nf_other';
4646
const CALLER = { userId: ME, positions: ['qa_pos'], permissions: ['qa_nf_guard'], posture: 'MEMBER' };
4747

48-
type Rig = Awaited<ReturnType<typeof boot>>;
48+
interface Refusal { code?: string; status?: number; message: string; name?: string }
49+
type Outcome = { kind: 'landed' } | ({ kind: 'refused' } & Refusal);
50+
51+
interface Rig {
52+
engine: ObjectQL;
53+
update: (object: string, id: string, data?: Record<string, unknown>) => Promise<Outcome>;
54+
remove: (object: string, id: string) => Promise<Outcome>;
55+
stored: (object: string, id: string) => Promise<Record<string, unknown> | null>;
56+
teardown: () => Promise<void>;
57+
}
4958
const rigs: Rig[] = [];
5059
afterEach(async () => {
5160
for (const rig of rigs.splice(0)) await rig.teardown();
5261
});
5362

54-
async function boot() {
63+
async function boot(): Promise<Rig> {
5564
const engine = new ObjectQL();
5665
engine.registerDriver(
5766
new SqlDriver({ client: 'better-sqlite3', connection: { filename: ':memory:' }, useNullAsDefault: true }) as never,
@@ -134,7 +143,7 @@ async function boot() {
134143
await plugin.init(ctx as never);
135144
await plugin.start(ctx as never);
136145

137-
const rig = {
146+
const rig: Rig = {
138147
engine,
139148
update: (object: string, id: string, data: Record<string, unknown> = { name: 'renamed' }) =>
140149
outcome(engine.update(object, data, { where: { id }, context: { ...CALLER } } as never)),
@@ -148,9 +157,6 @@ async function boot() {
148157
return rig;
149158
}
150159

151-
interface Refusal { code?: string; status?: number; message: string; name?: string }
152-
type Outcome = { kind: 'landed' } | ({ kind: 'refused' } & Refusal);
153-
154160
function outcome(p: Promise<unknown>): Promise<Outcome> {
155161
return p.then(
156162
() => ({ kind: 'landed' as const }),

0 commit comments

Comments
 (0)