diff --git a/tests/siax-access/idempotency.test.ts b/tests/siax-access/idempotency.test.ts index b85f5fe..674e9a0 100644 --- a/tests/siax-access/idempotency.test.ts +++ b/tests/siax-access/idempotency.test.ts @@ -1,5 +1,10 @@ import { describe, expect, it } from "vitest"; -import { operationFingerprint, operationIdentity, runIdempotentOperation } from "../../packages/siax-access/src/idempotency"; +import { + operationFingerprint, + operationIdentity, + runIdempotentOperation, + type IdempotencyStore, +} from "../../packages/siax-access/src/idempotency"; describe("@siax/access universal idempotency", () => { it("binds every result-affecting input into the fingerprint", () => { @@ -18,7 +23,7 @@ describe("@siax/access universal idempotency", () => { }); it("replays a stored receipt verbatim on the exact fingerprint", async () => { const stored = { x: 1 }; - const store: any = { + const store: IdempotencyStore = { start: async () => false, save: async () => {}, receipt: async () => stored, @@ -32,7 +37,7 @@ describe("@siax/access universal idempotency", () => { }); it("claims once and saves only after the dispatch", async () => { const order: string[] = []; - const store: any = { + const store: IdempotencyStore = { start: async () => { order.push("start"); return true; }, save: async () => { order.push("save"); }, receipt: async () => { order.push("receipt"); return undefined; }, @@ -47,7 +52,7 @@ describe("@siax/access universal idempotency", () => { expect(order).toEqual(["start", "dispatch", "save"]); }); it("reports a store error as conflict, never as a fresh start", async () => { - const store: any = { + const store: IdempotencyStore = { start: async () => { throw new Error("db down"); }, save: async () => {}, receipt: async () => { throw new Error("db down"); }, @@ -61,7 +66,7 @@ describe("@siax/access universal idempotency", () => { expect(dispatched).toBe(0); }); it("does not rerun the dispatch when start succeeds but save later fails", async () => { - const store: any = { start: async () => true, save: async () => { throw new Error("journal write failed"); }, receipt: async () => undefined }; + const store: IdempotencyStore = { start: async () => true, save: async () => { throw new Error("journal write failed"); }, receipt: async () => undefined }; let dispatched = 0; const outcome = await runIdempotentOperation({ store, identity: {}, fingerprint: "fp",