@vllnt/convex-idempotency 0.1.0 → 0.1.1-canary.1d25c30

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/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  <!-- Badges -->
2
+
2
3
  [![convex-component](https://img.shields.io/badge/convex-component-EE342F.svg)](https://www.convex.dev/components)
3
4
  [![npm](https://img.shields.io/npm/v/@vllnt/convex-idempotency.svg)](https://www.npmjs.com/package/@vllnt/convex-idempotency)
4
5
  [![CI](https://github.com/vllnt/convex-idempotency/actions/workflows/ci.yml/badge.svg)](https://github.com/vllnt/convex-idempotency/actions/workflows/ci.yml)
@@ -6,31 +7,51 @@
6
7
 
7
8
  # @vllnt/convex-idempotency
8
9
 
9
- Exactly-once idempotency key ledger for retried operations, as a Convex component.
10
+ Lease-based idempotency key ledger for retried operations, as a Convex
11
+ component.
10
12
 
11
13
  ```ts
12
14
  const idem = new Idempotency(components.idempotency);
13
- const claim = await idem.begin(ctx, requestId); // mints a claim, or short-circuits a replay
14
- if (claim.state === "done") return claim.result; // replayed — skip the work
15
- // ... run the work ...
16
- await idem.complete(ctx, requestId, result); // record the outcome for next time
15
+ const claim = await idem.begin(ctx, requestId); // mints a claim, or short-circuits a replay
16
+ if (claim.state === "done") return claim.result; // replayed — skip the work
17
+ if (claim.state === "inflight") throw new Error("Retry later");
18
+ // ... run the work only for a fresh claim ...
19
+ const completion = await idem.complete(ctx, requestId, result, {
20
+ claimId: claim.claimId,
21
+ });
22
+ if (!completion.recorded) throw new Error(`Claim lost: ${completion.reason}`);
17
23
  ```
18
24
 
19
- Record an idempotency `key` with a grace TTL; on a replay short-circuit and return the prior outcome
20
- instead of re-running the work. Domain-neutral: payment intents, webhook deliveries, queue consumers,
21
- double-submit guards — any operation that must run **at most once** per key.
25
+ Record an idempotency `key` with a grace TTL; on a replay short-circuit and
26
+ return the prior outcome instead of re-running the work. Domain-neutral: payment
27
+ intents, webhook deliveries, queue consumers, double-submit guards. The ledger
28
+ fences completion of replaced leases; it does not guarantee exactly-once
29
+ external side effects. A worker can finish an external operation and crash
30
+ before recording it. Use the provider's idempotency key too.
22
31
 
23
32
  ## Features
24
33
 
25
- - **Exactly-once** per `(scope, key)` — `begin` mints an inflight claim that rides the mutation transaction; a concurrent retry sees `inflight` with a `retryAfterMs` backoff hint.
26
- - **Replay** — once `complete` records an outcome, a later `begin` returns `{ state: "done", result }` for a short-circuit.
27
- - **Split TTLs** — a short **inflight lease** (default 60s) so a crashed worker's claim self-heals, and a longer **done grace** (default 24h) after which a key may be re-minted.
28
- - **Lost-claim detection** — `complete` returns `{ recorded: true } | { recorded: false, reason }` so a host knows when its work finished but the row was gone. Opt into `upsertOnMissing`.
29
- - **Server-sourced time** — expiry is read from the server clock; a caller can't supply `now`, so an adversarial clock can't force a key to look live or expired.
30
- - **TTL validation** — non-positive or infinite TTLs throw `INVALID_TTL` before any write.
31
- - **Typed result** — `Idempotency<TResult>` types the stored outcome; a `resultValidator` narrows it at the boundary.
34
+ - **Exclusive live claim** per `(scope, key)` — `begin` mints an inflight claim
35
+ that rides the mutation transaction; a concurrent retry sees `inflight` with a
36
+ `retryAfterMs` backoff hint.
37
+ - **Replay** — once `complete` records an outcome, a later `begin` returns
38
+ `{ state: "done", result }` for a short-circuit.
39
+ - **Split TTLs** — a short **inflight lease** (default 60s) so a crashed
40
+ worker's claim self-heals, and a longer **done grace** (default 24h) after
41
+ which a key may be re-minted.
42
+ - **Lost-claim detection** — `complete` returns
43
+ `{ recorded: true } | { recorded: false, reason }` so a host knows when its
44
+ work finished but the row was gone. Opt into `upsertOnMissing`.
45
+ - **Server-sourced time** — expiry is read from the server clock; a caller can't
46
+ supply `now`, so an adversarial clock can't force a key to look live or
47
+ expired.
48
+ - **Input validation** — empty keys or scopes and non-positive or infinite TTLs
49
+ throw `INVALID_KEY` / `INVALID_SCOPE` / `INVALID_TTL` before any write.
50
+ - **Typed result** — `Idempotency<TResult>` types the stored outcome; a
51
+ `resultValidator` narrows it at the boundary.
32
52
  - **Scopes** — global by default, or namespace per tenant / operation type.
33
- - **Bounded purge + cron** — a daily cron sweeps expired keys in batches and self-reschedules until clean.
53
+ - **Bounded purge + cron** — a daily cron sweeps expired keys in batches and
54
+ self-reschedules until clean.
34
55
 
35
56
  ## Installation
36
57
 
@@ -38,7 +59,7 @@ double-submit guards — any operation that must run **at most once** per key.
38
59
  pnpm add @vllnt/convex-idempotency
39
60
  ```
40
61
 
41
- Peer dependency: `convex@^1.41.0`.
62
+ Requires `convex@^1.45.0`.
42
63
 
43
64
  ## Usage
44
65
 
@@ -53,51 +74,76 @@ export default app;
53
74
  ```
54
75
 
55
76
  ```ts
56
- // convex/charge.ts — host owns auth; pass an opaque idempotency key in.
77
+ // convex/requests.ts — record a result in one authenticated mutation.
57
78
  import { components } from "./_generated/api";
58
79
  import { mutation } from "./_generated/server";
59
80
  import { v } from "convex/values";
60
81
  import { Idempotency } from "@vllnt/convex-idempotency";
61
82
 
62
- const idem = new Idempotency<{ chargeId: string }>(components.idempotency, {
63
- resultValidator: v.object({ chargeId: v.string() }).parse, // narrow at the boundary
83
+ const idem = new Idempotency<{ accepted: boolean }>(components.idempotency, {
84
+ resultValidator: (value) => {
85
+ if (
86
+ typeof value !== "object" ||
87
+ value === null ||
88
+ !("accepted" in value) ||
89
+ typeof value.accepted !== "boolean"
90
+ ) {
91
+ throw new Error("Invalid stored result");
92
+ }
93
+ return { accepted: value.accepted };
94
+ },
64
95
  });
65
96
 
66
- export const charge = mutation({
67
- args: { requestId: v.string(), amount: v.number() },
68
- handler: async (ctx, { requestId, amount }) => {
69
- const claim = await idem.begin(ctx, requestId);
70
- if (claim.state === "done") return claim.result; // typed replay
97
+ export const accept = mutation({
98
+ args: { requestId: v.string() },
99
+ handler: async (ctx, { requestId }) => {
100
+ const identity = await ctx.auth.getUserIdentity();
101
+ if (!identity) throw new Error("Unauthenticated");
102
+ const scope = identity.tokenIdentifier;
103
+ const claim = await idem.begin(ctx, requestId, { scope });
104
+ if (claim.state === "done") return claim.result;
71
105
  if (claim.state === "inflight")
72
- throw new Error(`retry in ${claim.retryAfterMs}ms`); // backoff hint
73
- const result = { chargeId: await doCharge(amount) }; // state === "fresh"
74
- const done = await idem.complete(ctx, requestId, result);
75
- if (!done.recorded) console.warn("claim lost:", done.reason); // work ran, row gone
106
+ throw new Error(`Retry in ${claim.retryAfterMs}ms`);
107
+ // Put transactional host database writes here, not external network calls.
108
+ const result = { accepted: true };
109
+ const done = await idem.complete(ctx, requestId, result, {
110
+ scope,
111
+ claimId: claim.claimId,
112
+ });
113
+ if (!done.recorded) throw new Error(`Claim lost: ${done.reason}`);
76
114
  return result;
77
115
  },
78
116
  });
79
117
  ```
80
118
 
119
+ For external work, use a host action with separate claim/completion mutations;
120
+ carry the same `scope` and `claimId` through both. Do not execute work for an
121
+ `inflight` response, and handle a failed completion without blindly repeating
122
+ the side effect. After either TTL expires, the key can be claimed again.
123
+
81
124
  ## API Reference
82
125
 
83
- | Method | Kind | Result |
84
- |--------|------|--------|
85
- | `begin(ctx, key, opts?)` | mutation | `{ state: "fresh"; claimId } \| { state: "inflight"; expiresAt; retryAfterMs } \| { state: "done"; result? }` |
126
+ | Method | Kind | Result |
127
+ | ------------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------- |
128
+ | `begin(ctx, key, opts?)` | mutation | `{ state: "fresh"; claimId } \| { state: "inflight"; expiresAt; retryAfterMs } \| { state: "done"; result? }` |
86
129
  | `complete(ctx, key, result?, opts?)` | mutation | `{ recorded: true } \| { recorded: false; reason: "missing" \| "expired" \| "superseded" \| "already_done" }` |
87
- | `get(ctx, key, scope?)` | query | `{ status, result?, expiresAt } \| null` |
88
- | `purge(ctx, opts?)` | mutation | `number` (keys removed in the first bounded pass) |
130
+ | `get(ctx, key, scope?)` | query | `{ status, result?, expiresAt } \| null` |
131
+ | `purge(ctx, opts?)` | mutation | `number` (keys removed in the first bounded pass) |
89
132
 
90
133
  Full reference: [docs/API.md](docs/API.md).
91
134
 
92
135
  ## React
93
136
 
94
- Backend-only — no `./react` entry. Pure infra dedup with no user-facing reactive surface.
137
+ Backend-only — no `./react` entry. Pure infra dedup with no user-facing reactive
138
+ surface.
95
139
 
96
140
  ## Security
97
141
 
98
- - Auth-agnostic — the host resolves identity and decides who may run an operation.
142
+ - Auth-agnostic — the host resolves identity and decides who may run an
143
+ operation.
99
144
  - Tables sandboxed — reached only through the exported functions.
100
- - Server-sourced expiry — a skewed client clock can't hijack a replay or bypass dedup; `key` / `scope` / `result` stay opaque.
145
+ - Server-sourced expiry — a skewed client clock can't hijack a replay or bypass
146
+ dedup; `key` / `scope` / `result` stay opaque.
101
147
 
102
148
  See [docs/API.md](docs/API.md).
103
149
 
@@ -108,7 +154,24 @@ pnpm test # single run
108
154
  pnpm test:coverage # enforced 100% on covered files
109
155
  ```
110
156
 
111
- Tests run against the real component runtime via `convex-test` (`@edge-runtime/vm`), not mocks.
157
+ Tests run against the real component runtime via `convex-test`
158
+ (`@edge-runtime/vm`), not mocks.
159
+
160
+ ### Testing your app
161
+
162
+ `@vllnt/convex-idempotency/test` exports `register(t, name = "idempotency")` to
163
+ mount the component in a `convex-test` instance. It needs `convex-test` and
164
+ `vitest` (with Vite's `import.meta.glob`) in the consuming app:
165
+
166
+ ```ts
167
+ /// <reference types="vite/client" />
168
+ import { convexTest } from "convex-test";
169
+ import { register } from "@vllnt/convex-idempotency/test";
170
+ import schema from "./schema";
171
+
172
+ const t = convexTest(schema, import.meta.glob("./**/*.ts"));
173
+ register(t);
174
+ ```
112
175
 
113
176
  ## Contributing
114
177
 
@@ -116,9 +179,11 @@ See [CONTRIBUTING.md](CONTRIBUTING.md).
116
179
 
117
180
  ## Author
118
181
 
119
- Built by [bntvllnt](https://github.com/bntvllnt) · [bntvllnt.com](https://bntvllnt.com) · [X @bntvllnt](https://x.com/bntvllnt)
182
+ Built by [bntvllnt](https://github.com/bntvllnt) ·
183
+ [bntvllnt.com](https://bntvllnt.com) · [X @bntvllnt](https://x.com/bntvllnt)
120
184
 
121
- Part of the [@vllnt](https://github.com/vllnt) Convex component fleet — [vllnt.com](https://vllnt.com)
185
+ Part of the [@vllnt](https://github.com/vllnt) Convex component fleet —
186
+ [vllnt.com](https://vllnt.com)
122
187
 
123
188
  If this is useful, [sponsor the work](https://github.com/sponsors/bntvllnt).
124
189
 
@@ -1,5 +1,5 @@
1
1
  import { cronJobs } from "convex/server";
2
- import { api } from "./_generated/api";
2
+ import { api } from "./_generated/api.js";
3
3
  /**
4
4
  * Default sweep cadence and page size for the built-in prune cron. The cron is
5
5
  * the component's own self-healing safety net — a host that wants a different
@@ -1 +1 @@
1
- {"version":3,"file":"crons.js","sourceRoot":"","sources":["../../src/component/crons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAEvC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,KAAK,EAAE,EAAE,EAAW,CAAC;AAErD,uEAAuE;AACvE,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC;AAE/B,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;AAEzB,KAAK,CAAC,QAAQ,CAAC,mBAAmB,EAAE,cAAc,EAAE,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE;IACvE,KAAK,EAAE,WAAW;CACnB,CAAC,CAAC;AAEH,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"crons.js","sourceRoot":"","sources":["../../src/component/crons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAE1C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,KAAK,EAAE,EAAE,EAAW,CAAC;AAErD,uEAAuE;AACvE,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC;AAE/B,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;AAEzB,KAAK,CAAC,QAAQ,CAAC,mBAAmB,EAAE,cAAc,EAAE,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE;IACvE,KAAK,EAAE,WAAW;CACnB,CAAC,CAAC;AAEH,eAAe,KAAK,CAAC"}
@@ -11,6 +11,8 @@
11
11
  * correct recovery path — the done grace exists precisely to replay within the
12
12
  * window; outside it the operation may safely re-run.
13
13
  *
14
+ * @throws `ConvexError({ code: "INVALID_KEY" | "INVALID_SCOPE" })` when `key` or
15
+ * `scope` is the empty string.
14
16
  * @throws `ConvexError({ code: "INVALID_TTL" })` when `inflightTtlMs` is not a
15
17
  * positive finite number (≤ 0 or non-finite would produce `expiresAt ≤ now`,
16
18
  * immediately expiring the claim and breaking the dedup window).
@@ -55,6 +57,8 @@ export declare const begin: import("convex/server").RegisteredMutation<"public",
55
57
  * The `expired` reason is reserved for inflight keys whose lease lapsed before
56
58
  * the holder could complete; it does not apply to keys already marked done.
57
59
  *
60
+ * @throws `ConvexError({ code: "INVALID_KEY" | "INVALID_SCOPE" })` when `key` or
61
+ * `scope` is the empty string.
58
62
  * @throws `ConvexError({ code: "INVALID_TTL" })` when `doneTtlMs` is not a
59
63
  * positive finite number (≤ 0 or non-finite would produce `expiresAt ≤ now`,
60
64
  * immediately expiring the done grace window on creation).
@@ -1 +1 @@
1
- {"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,KAAK;;;;;WAmCI,OAAO;;;;;;;WAiBP,MAAM;;;;;;;WAIf,UAAU;;;GAKrB,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;YAyC4B,SAAS;;;YAIT,cAAc;;;YAOd,YAAY;;;YAYZ,SAAS;GAUxD,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,KAAK;;;mBAwBhB,CAAC"}
1
+ {"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"AAwBA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,KAAK;;;;;WAoCI,OAAO;;;;;;;WAiBP,MAAM;;;;;;;WAIf,UAAU;;;GAKrB,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;YA0C4B,SAAS;;;YAIT,cAAc;;;YAOd,YAAY;;;YAYZ,SAAS;GAUxD,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,KAAK;;;mBAwBhB,CAAC"}
@@ -1,8 +1,16 @@
1
1
  import { ConvexError, v } from "convex/values";
2
- import { api } from "./_generated/api";
3
- import { mutation } from "./_generated/server";
4
- import { MAX_PURGE_BATCH } from "../shared";
5
- import { beginResult, completeResult, jsonValue } from "./validators";
2
+ import { api } from "./_generated/api.js";
3
+ import { mutation } from "./_generated/server.js";
4
+ import { MAX_PURGE_BATCH } from "../shared.js";
5
+ import { beginResult, completeResult, jsonValue } from "./validators.js";
6
+ function validateKeyAndScope(key, scope) {
7
+ if (key === "") {
8
+ throw new ConvexError({ code: "INVALID_KEY", message: "key must not be empty" });
9
+ }
10
+ if (scope === "") {
11
+ throw new ConvexError({ code: "INVALID_SCOPE", message: "scope must not be empty" });
12
+ }
13
+ }
6
14
  function validateBatch(batch) {
7
15
  if (!Number.isFinite(batch) || !Number.isInteger(batch) || batch < 1 || batch > MAX_PURGE_BATCH) {
8
16
  throw new ConvexError({
@@ -24,6 +32,8 @@ function validateBatch(batch) {
24
32
  * correct recovery path — the done grace exists precisely to replay within the
25
33
  * window; outside it the operation may safely re-run.
26
34
  *
35
+ * @throws `ConvexError({ code: "INVALID_KEY" | "INVALID_SCOPE" })` when `key` or
36
+ * `scope` is the empty string.
27
37
  * @throws `ConvexError({ code: "INVALID_TTL" })` when `inflightTtlMs` is not a
28
38
  * positive finite number (≤ 0 or non-finite would produce `expiresAt ≤ now`,
29
39
  * immediately expiring the claim and breaking the dedup window).
@@ -36,6 +46,7 @@ export const begin = mutation({
36
46
  },
37
47
  returns: beginResult,
38
48
  handler: async (ctx, args) => {
49
+ validateKeyAndScope(args.key, args.scope);
39
50
  if (!(args.inflightTtlMs > 0 && isFinite(args.inflightTtlMs))) {
40
51
  throw new ConvexError({
41
52
  code: "INVALID_TTL",
@@ -99,6 +110,8 @@ export const begin = mutation({
99
110
  * The `expired` reason is reserved for inflight keys whose lease lapsed before
100
111
  * the holder could complete; it does not apply to keys already marked done.
101
112
  *
113
+ * @throws `ConvexError({ code: "INVALID_KEY" | "INVALID_SCOPE" })` when `key` or
114
+ * `scope` is the empty string.
102
115
  * @throws `ConvexError({ code: "INVALID_TTL" })` when `doneTtlMs` is not a
103
116
  * positive finite number (≤ 0 or non-finite would produce `expiresAt ≤ now`,
104
117
  * immediately expiring the done grace window on creation).
@@ -114,6 +127,7 @@ export const complete = mutation({
114
127
  },
115
128
  returns: completeResult,
116
129
  handler: async (ctx, args) => {
130
+ validateKeyAndScope(args.key, args.scope);
117
131
  if (!(args.doneTtlMs > 0 && isFinite(args.doneTtlMs))) {
118
132
  throw new ConvexError({
119
133
  code: "INVALID_TTL",
@@ -1 +1 @@
1
- {"version":3,"file":"mutations.js","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEtE,SAAS,aAAa,CAAC,KAAa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zD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;YACxB,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;QACvC,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;YAChC,MAAM,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE;gBACnD,MAAM;gBACN,KAAK,EAAE,IAAI,CAAC,KAAK;aAClB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC,MAAM,CAAC;IACtB,CAAC;CACF,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { v } from "convex/values";
2
- import { query } from "./_generated/server";
3
- import { keyState } from "./validators";
2
+ import { query } from "./_generated/server.js";
3
+ import { keyState } from "./validators.js";
4
4
  export const get = query({
5
5
  args: { key: v.string(), scope: v.string() },
6
6
  returns: v.union(v.null(), keyState),
@@ -1 +1 @@
1
- {"version":3,"file":"queries.js","sourceRoot":"","sources":["../../src/component/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC;IACvB,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE;IAC5C,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,QAAQ,CAAC;IACpC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;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,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAC9C;aACA,MAAM,EAAE,CAAC;QACZ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO;YACL,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,SAAS,EAAE,GAAG,CAAC,SAAS;SACzB,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { defineSchema, defineTable } from "convex/server";
2
2
  import { v } from "convex/values";
3
- import { jsonValue } from "./validators";
3
+ import { jsonValue } from "./validators.js";
4
4
  /**
5
5
  * Sandboxed tables — the idempotency ledger's own concern. A `key` is unique
6
6
  * within a `scope`; `result` carries the opaque host-owned outcome (never
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;;;;GAKG;AACH,eAAe,YAAY,CAAC;IAC1B,IAAI,EAAE,WAAW,CAAC;QAChB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;QACf,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;QACjB,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACzD,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC/B,eAAe,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACvC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC7B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;KACtB,CAAC;SACC,KAAK,CAAC,cAAc,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;SACvC,KAAK,CAAC,YAAY,EAAE,CAAC,WAAW,CAAC,CAAC;CACtC,CAAC,CAAC"}
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;GAKG;AACH,eAAe,YAAY,CAAC;IAC1B,IAAI,EAAE,WAAW,CAAC;QAChB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;QACf,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;QACjB,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACzD,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC/B,eAAe,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACvC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC7B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;KACtB,CAAC;SACC,KAAK,CAAC,cAAc,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;SACvC,KAAK,CAAC,YAAY,EAAE,CAAC,WAAW,CAAC,CAAC;CACtC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@vllnt/convex-idempotency",
3
- "version": "0.1.0",
3
+ "version": "0.1.1-canary.1d25c30",
4
4
  "description": "Exactly-once idempotency key ledger for retried operations, as a Convex component",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "packageManager": "pnpm@9.15.4",
7
+ "packageManager": "pnpm@10.34.8",
8
8
  "files": [
9
9
  "dist",
10
10
  "src"
@@ -37,17 +37,14 @@
37
37
  "build": "tsc --project ./tsconfig.build.json",
38
38
  "build:codegen": "pnpm codegen && pnpm build",
39
39
  "build:clean": "rm -rf dist *.tsbuildinfo && pnpm build:codegen",
40
- "typecheck": "tsc --noEmit",
41
- "typecheck:ci": "tsc --noEmit --project tsconfig.ci.json",
42
- "lint": "pnpm check:agents && eslint .",
40
+ "typecheck": "tsc --noEmit --incremental --tsBuildInfoFile node_modules/.cache/tsc/typecheck.tsbuildinfo",
41
+ "typecheck:ci": "tsc --noEmit --incremental --tsBuildInfoFile node_modules/.cache/tsc/typecheck-ci.tsbuildinfo --project tsconfig.ci.json",
42
+ "lint": "pnpm check:agents && eslint --cache --cache-location node_modules/.cache/eslint/ .",
43
43
  "test": "vitest run --passWithNoTests",
44
44
  "test:watch": "vitest --typecheck --clearScreen false",
45
45
  "test:coverage": "vitest run --coverage --coverage.reporter=text",
46
46
  "generate:llms": "node scripts/generate-llms.mjs",
47
47
  "preversion": "pnpm install --frozen-lockfile && pnpm build && pnpm test:coverage && pnpm typecheck && pnpm generate:llms",
48
- "prepublishOnly": "npm whoami || npm login",
49
- "alpha": "npm version prerelease --preid alpha && npm publish --tag alpha && git push --follow-tags",
50
- "release": "npm version patch && npm publish && git push --follow-tags",
51
48
  "check:agents": "node -e \"const f=require('node:fs');if(!f.existsSync('AGENTS.md')||f.existsSync('CLAUDE.md')||f.existsSync('.claude'))process.exit(1)\"",
52
49
  "codegen": "pnpm convex codegen --component-dir ./src/component"
53
50
  },
@@ -57,16 +54,30 @@
57
54
  "devDependencies": {
58
55
  "@edge-runtime/vm": "^5.0.0",
59
56
  "@typescript/native": "npm:typescript@7.0.2",
60
- "@vitest/coverage-v8": "^4.1.11",
57
+ "@vitest/coverage-v8": "^5.0.5",
61
58
  "@vllnt/eslint-config": "2.0.0",
62
59
  "@vllnt/typescript": "2.0.0",
63
- "convex": "^1.45.0",
64
- "convex-test": "^0.0.56",
60
+ "convex": "^1.48.0",
61
+ "convex-test": "^0.0.65",
65
62
  "eslint": "^9.39.5",
66
- "prettier": "^3.9.6",
63
+ "prettier": "^3.9.10",
67
64
  "typescript": "npm:@typescript/typescript6@^6.0.2",
68
- "vite": "^8.2.2",
69
- "vitest": "^4.1.11"
65
+ "vite": "^8.3.5",
66
+ "vitest": "^5.0.5"
67
+ },
68
+ "pnpm": {
69
+ "minimumReleaseAge": 10080,
70
+ "minimumReleaseAgeExclude": [
71
+ "@vllnt/*"
72
+ ],
73
+ "ignoredBuiltDependencies": [
74
+ "esbuild"
75
+ ],
76
+ "overrides": {
77
+ "deepmerge-ts@<8.0.0": "8.0.2",
78
+ "esbuild@>=0.27.3 <0.28.1": "0.28.1",
79
+ "handlebars@<4.7.10": "4.7.10"
80
+ }
70
81
  },
71
82
  "homepage": "https://github.com/vllnt/convex-idempotency#readme",
72
83
  "bugs": {
@@ -1,5 +1,5 @@
1
1
  import { cronJobs } from "convex/server";
2
- import { api } from "./_generated/api";
2
+ import { api } from "./_generated/api.js";
3
3
 
4
4
  /**
5
5
  * Default sweep cadence and page size for the built-in prune cron. The cron is
@@ -1,8 +1,17 @@
1
1
  import { ConvexError, v } from "convex/values";
2
- import { api } from "./_generated/api";
3
- import { mutation } from "./_generated/server";
4
- import { MAX_PURGE_BATCH } from "../shared";
5
- import { beginResult, completeResult, jsonValue } from "./validators";
2
+ import { api } from "./_generated/api.js";
3
+ import { mutation } from "./_generated/server.js";
4
+ import { MAX_PURGE_BATCH } from "../shared.js";
5
+ import { beginResult, completeResult, jsonValue } from "./validators.js";
6
+
7
+ function validateKeyAndScope(key: string, scope: string): void {
8
+ if (key === "") {
9
+ throw new ConvexError({ code: "INVALID_KEY", message: "key must not be empty" });
10
+ }
11
+ if (scope === "") {
12
+ throw new ConvexError({ code: "INVALID_SCOPE", message: "scope must not be empty" });
13
+ }
14
+ }
6
15
 
7
16
  function validateBatch(batch: number): void {
8
17
  if (!Number.isFinite(batch) || !Number.isInteger(batch) || batch < 1 || batch > MAX_PURGE_BATCH) {
@@ -26,6 +35,8 @@ function validateBatch(batch: number): void {
26
35
  * correct recovery path — the done grace exists precisely to replay within the
27
36
  * window; outside it the operation may safely re-run.
28
37
  *
38
+ * @throws `ConvexError({ code: "INVALID_KEY" | "INVALID_SCOPE" })` when `key` or
39
+ * `scope` is the empty string.
29
40
  * @throws `ConvexError({ code: "INVALID_TTL" })` when `inflightTtlMs` is not a
30
41
  * positive finite number (≤ 0 or non-finite would produce `expiresAt ≤ now`,
31
42
  * immediately expiring the claim and breaking the dedup window).
@@ -38,6 +49,7 @@ export const begin = mutation({
38
49
  },
39
50
  returns: beginResult,
40
51
  handler: async (ctx, args) => {
52
+ validateKeyAndScope(args.key, args.scope);
41
53
  if (!(args.inflightTtlMs > 0 && isFinite(args.inflightTtlMs))) {
42
54
  throw new ConvexError({
43
55
  code: "INVALID_TTL",
@@ -110,6 +122,8 @@ export const begin = mutation({
110
122
  * The `expired` reason is reserved for inflight keys whose lease lapsed before
111
123
  * the holder could complete; it does not apply to keys already marked done.
112
124
  *
125
+ * @throws `ConvexError({ code: "INVALID_KEY" | "INVALID_SCOPE" })` when `key` or
126
+ * `scope` is the empty string.
113
127
  * @throws `ConvexError({ code: "INVALID_TTL" })` when `doneTtlMs` is not a
114
128
  * positive finite number (≤ 0 or non-finite would produce `expiresAt ≤ now`,
115
129
  * immediately expiring the done grace window on creation).
@@ -125,6 +139,7 @@ export const complete = mutation({
125
139
  },
126
140
  returns: completeResult,
127
141
  handler: async (ctx, args) => {
142
+ validateKeyAndScope(args.key, args.scope);
128
143
  if (!(args.doneTtlMs > 0 && isFinite(args.doneTtlMs))) {
129
144
  throw new ConvexError({
130
145
  code: "INVALID_TTL",
@@ -1,6 +1,6 @@
1
1
  import { v } from "convex/values";
2
- import { query } from "./_generated/server";
3
- import { keyState } from "./validators";
2
+ import { query } from "./_generated/server.js";
3
+ import { keyState } from "./validators.js";
4
4
 
5
5
  export const get = query({
6
6
  args: { key: v.string(), scope: v.string() },
@@ -1,6 +1,6 @@
1
1
  import { defineSchema, defineTable } from "convex/server";
2
2
  import { v } from "convex/values";
3
- import { jsonValue } from "./validators";
3
+ import { jsonValue } from "./validators.js";
4
4
 
5
5
  /**
6
6
  * Sandboxed tables — the idempotency ledger's own concern. A `key` is unique
package/src/test.ts CHANGED
@@ -1,5 +1,6 @@
1
+ /// <reference types="vite/client" />
1
2
  import type { TestConvex } from "convex-test";
2
- import schema from "./component/schema";
3
+ import schema from "./component/schema.js";
3
4
 
4
5
  const modules = import.meta.glob("./component/**/*.ts");
5
6