@vllnt/convex-quota 0.1.0-canary.cbb12fa → 0.1.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/CHANGELOG.md CHANGED
@@ -1,29 +1,41 @@
1
1
  # Changelog
2
2
 
3
3
  All notable changes to this project are documented here. The format is based on
4
- [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to
5
- [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
5
+ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
- ### Added
10
-
11
- - Initial implementation of `@vllnt/convex-quota` (not yet released).
12
- - Calendar (day / week / month), rolling, and epoch windows.
13
- - `consume`, `remaining`, `refund`, `eraseSubject` (batched).
14
- - Ref length limits (1..256). Server-sourced window math.
9
+ ## [0.1.0] - 2026-11-23
15
10
 
16
- ### Fixed
11
+ First stable release.
17
12
 
18
- - Reject unsafe numeric allowance values, invalid query inputs, unbounded scopes,
19
- and overflowing or sub-millisecond durations.
20
- - Bind each allowance to its window policy and reject policy reinterpretation.
21
- - Resolve skipped/repeated civil midnights and reject refunds of expired rows.
22
- - Correct mock-backend testing claims and document refund deduplication,
23
- subscription expiry, erasure races, and multi-mount behavior.
24
-
25
- ### Migration note
13
+ ### Added
26
14
 
27
- - The unreleased allowance schema now requires `policyKey`. Existing development
28
- rows must be cleared in an isolated development deployment before updating;
29
- no production migration has been performed.
15
+ - `Quota` client with `consume`, `remaining`, `refund` and `eraseSubject`
16
+ (batched, reschedules until clean). `consume` returns
17
+ `{ allowed, used, remaining, limit, periodKey, resetsAt }`, `remaining` the
18
+ same without `allowed`, `refund` `{ refunded, used, remaining }`, and
19
+ `eraseSubject` the number of rows deleted in that pass.
20
+ - Window kinds: calendar (`day` / `week` / `month` in an IANA timezone, Monday
21
+ or Sunday week start), rolling (starts at the first allowed consume) and
22
+ epoch. Time is read on the server. Skipped and repeated civil midnights
23
+ resolve deterministically.
24
+ - A fixed window policy per `(scope, subjectRef, key)`; changing it throws
25
+ `POLICY_MISMATCH`. The limit may change without resetting usage.
26
+ - Fail-closed input validation with `ConvexError` codes: `INVALID_REF`,
27
+ `INVALID_LIMIT`, `INVALID_AMOUNT`, `INVALID_DURATION`, `INVALID_TIME_ZONE`,
28
+ `INVALID_BATCH`. Refs and scopes are 1..256 UTF-16 code units; limits, amounts
29
+ and durations are positive safe integers.
30
+ - `refund` only applies to the stored, unexpired period; otherwise it returns
31
+ `refunded: false`.
32
+ - `@vllnt/convex-quota/test` registers the component with `convex-test`; the
33
+ consuming app needs `convex-test` and `vitest`. It type-checks under both
34
+ `bundler` and `nodenext` module resolution.
35
+ - Multiple named mounts and runtime scopes.
36
+
37
+ ### Notes
38
+
39
+ - `consume` and `refund` are not idempotent. See the README host rules.
40
+ - Releases are published only from `v*.*.*` tags through npm trusted publishing
41
+ with provenance. Builds from `main` use the `canary` dist-tag.
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-quota.svg)](https://www.npmjs.com/package/@vllnt/convex-quota)
4
5
  [![CI](https://github.com/vllnt/convex-quota/actions/workflows/ci.yml/badge.svg)](https://github.com/vllnt/convex-quota/actions/workflows/ci.yml)
@@ -11,12 +12,16 @@ Scheduled-reset per-subject allowances as a Convex component.
11
12
  Readable remaining in a window — calendar day/week/month, rolling, or epoch.
12
13
  Daily/weekly play caps, free-tier slots, Codex-style limits.
13
14
 
14
- The official `@convex-dev/rate-limiter` already supports fixed windows, token
15
- buckets, readable status and React hooks. Prefer it for general throttling.
16
- This experimental component explores the narrower calendar/timezone reset and
17
- privileged allowance-refund surface. It is not billable metering or a persistent
18
- balance. Publication remains blocked on demonstrated independent consumers and
19
- justification of this boundary; readable remaining alone is not a distinction.
15
+ ## When to use it
16
+
17
+ Use it for allowances that reset on a schedule and that your UI needs to read:
18
+ "3 plays left today", a weekly cap in the subject's own timezone, free-tier
19
+ slots, a refund when an action is cancelled.
20
+
21
+ - General throttling (token buckets, fixed windows, React hooks): use the
22
+ official `@convex-dev/rate-limiter`.
23
+ - Billable usage records: use `@vllnt/convex-metering`.
24
+ - Balances that persist and are spent down: use `@vllnt/convex-wallet`.
20
25
 
21
26
  ```ts
22
27
  const quota = new Quota(components.quota);
@@ -30,11 +35,16 @@ if (!r.allowed) throw new Error(`try again at ${r.resetsAt}`);
30
35
 
31
36
  ## Features
32
37
 
33
- - **Readable remaining** — both return `{ used, remaining, limit, periodKey, resetsAt }`; only `consume` includes `allowed`.
34
- - **Window kinds** — calendar (`day` / `week` / `month` + IANA timezone), rolling (from first consume), epoch (`floor(now / durationMs)`).
38
+ - **Readable remaining** — `consume` and `remaining` both return
39
+ `{ used, remaining, limit, periodKey, resetsAt }`; only `consume` includes
40
+ `allowed`.
41
+ - **Window kinds** — calendar (`day` / `week` / `month` + IANA timezone),
42
+ rolling (from first consume), epoch (`floor(now / durationMs)`).
35
43
  - **Server-sourced time** — window math uses `Date.now()` inside the component.
36
- - **Opaque refs** — `subjectRef`, `key`, and `scope` are host strings (1..256 UTF-16 code units).
37
- - **Bounded erase** — `eraseSubject` deletes in batches and reschedules until clean.
44
+ - **Opaque refs** — `subjectRef`, `key`, and `scope` are host strings (1..256
45
+ UTF-16 code units).
46
+ - **Bounded erase** — `eraseSubject` deletes in batches and reschedules until
47
+ clean.
38
48
  - **Scopes** — default `"global"`, or namespace per tenant / product.
39
49
 
40
50
  ## Installation
@@ -43,7 +53,9 @@ if (!r.allowed) throw new Error(`try again at ${r.resetsAt}`);
43
53
  pnpm add @vllnt/convex-quota
44
54
  ```
45
55
 
46
- Node.js >=22.12.0; peer dependency: `convex@^1.45.0`.
56
+ Node.js >=22.12.0; required peer: `convex@^1.45.0`. Stable releases are
57
+ published to the `latest` dist-tag with npm provenance. Unreleased builds from
58
+ `main` go to the `canary` dist-tag (`pnpm add @vllnt/convex-quota@canary`).
47
59
 
48
60
  ## Usage
49
61
 
@@ -57,47 +69,238 @@ app.use(quota);
57
69
  export default app;
58
70
  ```
59
71
 
72
+ The host authenticates, derives the `subjectRef`, and owns the limit and window.
73
+ The component never sees the end-user's request.
74
+
60
75
  ```ts
76
+ // convex/plays.ts
77
+ import { v } from "convex/values";
61
78
  import { components } from "./_generated/api";
62
- import { mutation } from "./_generated/server";
79
+ import { mutation, query } from "./_generated/server";
63
80
  import { Quota } from "@vllnt/convex-quota";
64
81
 
65
82
  const quota = new Quota(components.quota);
83
+ const DAILY_PLAYS = 5; // host-owned, never from the client
84
+ const daily = {
85
+ kind: "calendar",
86
+ period: "day",
87
+ timeZone: "Europe/Paris",
88
+ } as const;
66
89
 
67
90
  export const play = mutation({
68
91
  args: {},
92
+ returns: v.null(),
69
93
  handler: async (ctx) => {
70
- const subjectRef = /* host-resolved identity */ "user_1";
71
- const r = await quota.consume(ctx, subjectRef, "plays", 5, {
72
- kind: "calendar",
73
- period: "day",
74
- timeZone: "Europe/Paris",
75
- });
94
+ const identity = await ctx.auth.getUserIdentity();
95
+ if (!identity) throw new Error("Unauthenticated");
96
+ const subjectRef = identity.tokenIdentifier;
97
+ const r = await quota.consume(ctx, subjectRef, "plays", DAILY_PLAYS, daily);
76
98
  if (!r.allowed) throw new Error("daily cap reached");
99
+ return null;
100
+ },
101
+ });
102
+
103
+ export const playsLeft = query({
104
+ args: {},
105
+ returns: v.object({ remaining: v.number(), resetsAt: v.number() }),
106
+ handler: async (ctx) => {
107
+ const identity = await ctx.auth.getUserIdentity();
108
+ if (!identity) throw new Error("Unauthenticated");
109
+ const { remaining, resetsAt } = await quota.remaining(
110
+ ctx,
111
+ identity.tokenIdentifier,
112
+ "plays",
113
+ DAILY_PLAYS,
114
+ daily,
115
+ );
116
+ return { remaining, resetsAt };
77
117
  },
78
118
  });
79
119
  ```
80
120
 
121
+ After mounting, run `pnpm convex dev` to generate the host's component
122
+ references.
123
+
81
124
  **Host rules:**
82
125
 
83
126
  - Never take `limit` or `amount` from the end-user. The host supplies them.
84
- - `consume` is not idempotent. Wrap retries with `@vllnt/convex-idempotency`.
85
- - `refund` is privileged and **not idempotent**. Deduplicate refund events in the host transaction; `periodKey` is a window label, not a receipt or replay token.
86
- - Keep window policy fixed for each `(scope, subjectRef, key)`; changes throw `POLICY_MISMATCH`. Use a new key for a new policy. Limits may change without resetting usage.
87
- - Stop new consumes before erasing a subject and keep them stopped until scheduled passes drain. Erasure is not a tombstone; concurrent writes can survive or be swept.
88
- - The example wrappers are unauthenticated test fixtures, not production endpoints.
127
+ - `consume` is not idempotent. Pair it with `@vllnt/convex-idempotency` (see
128
+ [Retries and idempotency](#retries-and-idempotency)).
129
+ - `refund` is privileged and **not idempotent**. Deduplicate refund events in
130
+ the host transaction; `periodKey` is a window label, not a receipt or replay
131
+ token.
132
+ - Keep window policy fixed for each `(scope, subjectRef, key)`; changes throw
133
+ `POLICY_MISMATCH`. Use a new key for a new policy. Limits may change without
134
+ resetting usage.
135
+ - Stop new consumes before erasing a subject and keep them stopped until
136
+ scheduled passes drain. Erasure is not a tombstone; concurrent writes can
137
+ survive or be swept.
138
+ - The example wrappers are unauthenticated test fixtures, not production
139
+ endpoints.
140
+
141
+ ## Configuration and limits
142
+
143
+ `new Quota(component, { defaultScope: "global" })` sets the only client option.
144
+ `consume` accepts `{ amount?: number, scope?: string }`; amount defaults to 1.
145
+ Limits and amounts must be positive safe integers. Erase batches default to 200
146
+ and are capped at 500. Calendar weeks default to Monday; set `weekStartsOn` to
147
+ `"sunday"` when needed. Rolling and epoch windows require a positive safe
148
+ integer `durationMs`. See the API reference for timezone transitions and error
149
+ codes.
89
150
 
90
151
  ## API Reference
91
152
 
92
- | Method | Kind | Result |
93
- |--------|------|--------|
94
- | `consume(ctx, subjectRef, key, limit, window, opts?)` | mutation | `{ allowed, remaining, used, limit, periodKey, resetsAt }` |
95
- | `remaining(ctx, subjectRef, key, limit, window, scope?)` | query | same fields without `allowed` |
96
- | `refund(ctx, subjectRef, key, amount, periodKey, scope?)` | mutation | `{ refunded, used, remaining }` |
97
- | `eraseSubject(ctx, subjectRef, scope?, batch?)` | mutation | `number` deleted this pass |
153
+ | Method | Kind | Result |
154
+ | --------------------------------------------------------- | -------- | ---------------------------------------------------------- |
155
+ | `consume(ctx, subjectRef, key, limit, window, opts?)` | mutation | `{ allowed, remaining, used, limit, periodKey, resetsAt }` |
156
+ | `remaining(ctx, subjectRef, key, limit, window, scope?)` | query | same fields without `allowed` |
157
+ | `refund(ctx, subjectRef, key, amount, periodKey, scope?)` | mutation | `{ refunded, used, remaining }` |
158
+ | `eraseSubject(ctx, subjectRef, scope?, batch?)` | mutation | `number` deleted this pass |
98
159
 
99
160
  Full reference: [docs/API.md](docs/API.md).
100
161
 
162
+ ## Retries and idempotency
163
+
164
+ `consume` is not idempotent: a retried mutation consumes again. When a retry
165
+ must not double-count, claim the request with `@vllnt/convex-idempotency` inside
166
+ the **same host mutation**. The claim, the consume and the completion commit or
167
+ roll back together, so a failed attempt leaves nothing behind and a successful
168
+ one is replayed instead of re-run.
169
+
170
+ Install it next to this component:
171
+
172
+ ```bash
173
+ pnpm add @vllnt/convex-idempotency
174
+ ```
175
+
176
+ ```ts
177
+ // convex/convex.config.ts — mount both components
178
+ import idempotency from "@vllnt/convex-idempotency/convex.config";
179
+ app.use(quota);
180
+ app.use(idempotency);
181
+ ```
182
+
183
+ ```ts
184
+ // convex/plays.ts
185
+ import { v } from "convex/values";
186
+ import { Idempotency } from "@vllnt/convex-idempotency";
187
+ import {
188
+ Quota,
189
+ type ConsumeResult,
190
+ type RefundResult,
191
+ } from "@vllnt/convex-quota";
192
+ import { components } from "./_generated/api";
193
+ import { internalMutation, mutation } from "./_generated/server";
194
+
195
+ const quota = new Quota(components.quota);
196
+ const consumeIdempotency = new Idempotency<ConsumeResult>(
197
+ components.idempotency,
198
+ );
199
+ const DAILY_PLAYS = 5;
200
+ const daily = {
201
+ kind: "calendar",
202
+ period: "day",
203
+ timeZone: "Europe/Paris",
204
+ } as const;
205
+ const consumeResult = v.object({
206
+ allowed: v.boolean(),
207
+ limit: v.number(),
208
+ periodKey: v.string(),
209
+ remaining: v.number(),
210
+ resetsAt: v.number(),
211
+ used: v.number(),
212
+ });
213
+
214
+ export const play = mutation({
215
+ args: { requestId: v.string() },
216
+ returns: consumeResult,
217
+ handler: async (ctx, { requestId }) => {
218
+ const identity = await ctx.auth.getUserIdentity();
219
+ if (!identity) throw new Error("Unauthenticated");
220
+ const scope = identity.tokenIdentifier; // dedupe per caller
221
+ const key = `consume:${requestId}`; // namespaced per operation
222
+ const claim = await consumeIdempotency.begin(ctx, key, { scope });
223
+ if (claim.state === "done" && claim.result !== undefined) {
224
+ return claim.result;
225
+ }
226
+ if (claim.state !== "fresh") throw new Error("Retry shortly");
227
+ const result = await quota.consume(
228
+ ctx,
229
+ identity.tokenIdentifier,
230
+ "plays",
231
+ DAILY_PLAYS,
232
+ daily,
233
+ );
234
+ const done = await consumeIdempotency.complete(ctx, key, result, {
235
+ scope,
236
+ claimId: claim.claimId,
237
+ });
238
+ if (!done.recorded) throw new Error(`Claim lost: ${done.reason}`);
239
+ return result;
240
+ },
241
+ });
242
+ ```
243
+
244
+ Refunds are privileged; trigger them only from verified host events. Expose them
245
+ as an `internalMutation` that a trusted caller (a webhook or a scheduled job
246
+ after a verified cancellation) invokes with values from the host's own record of
247
+ the play, never with a public argument chosen by the end user:
248
+
249
+ ```ts
250
+ const refundIdempotency = new Idempotency<RefundResult>(components.idempotency);
251
+
252
+ export const refundPlay = internalMutation({
253
+ args: {
254
+ subjectRef: v.string(), // from the host's record of the play
255
+ requestId: v.string(), // the request being cancelled
256
+ periodKey: v.string(), // from the same record
257
+ },
258
+ returns: v.object({
259
+ refunded: v.boolean(),
260
+ used: v.number(),
261
+ remaining: v.number(),
262
+ }),
263
+ handler: async (ctx, { subjectRef, requestId, periodKey }) => {
264
+ const scope = subjectRef;
265
+ const key = `refund:${requestId}`; // namespaced per operation
266
+ const claim = await refundIdempotency.begin(ctx, key, { scope });
267
+ if (claim.state === "done" && claim.result !== undefined) {
268
+ return claim.result;
269
+ }
270
+ if (claim.state !== "fresh") throw new Error("Retry shortly");
271
+ const result = await quota.refund(ctx, subjectRef, "plays", 1, periodKey);
272
+ const done = await refundIdempotency.complete(ctx, key, result, {
273
+ scope,
274
+ claimId: claim.claimId,
275
+ });
276
+ if (!done.recorded) throw new Error(`Claim lost: ${done.reason}`);
277
+ return result;
278
+ },
279
+ });
280
+ ```
281
+
282
+ This exact pattern is exercised in
283
+ [`example/convex/idempotency.test.ts`](example/convex/idempotency.test.ts): a
284
+ duplicate `requestId` replays the stored result and consumes once, a new
285
+ `requestId` consumes again, the caller `scope` isolates identical request ids, a
286
+ host failure after `consume` rolls back both the allowance and the claim, and a
287
+ refund event deduplicated by `requestId` refunds once.
288
+
289
+ Caveats:
290
+
291
+ - A denied consume (`allowed: false`) is recorded too, so a replay returns the
292
+ same denial even if the allowance was freed in between.
293
+ - The claim lives for the idempotency component's done-grace TTL (24 hours by
294
+ default). A retry after that is a new request and consumes again, so pick a
295
+ TTL longer than your clients' retry horizon.
296
+ - Do no external work between `begin` and `complete`. Keep it to transactional
297
+ host writes; use a separate action for network calls.
298
+ - Namespace the idempotency key per operation (`consume:${requestId}`,
299
+ `refund:${requestId}`). The ledger is keyed by caller scope and key only, so
300
+ two operations sharing a key would replay each other's stored result.
301
+ - Never accept refund ids or a `periodKey` from the end user: a public refund
302
+ endpoint lets a caller fabricate cancellations and clear their own quota.
303
+
101
304
  ## Multiple mounts
102
305
 
103
306
  ```ts
@@ -121,7 +324,8 @@ scheduled-function failures. Erasure returns only its first pass count.
121
324
 
122
325
  ## React
123
326
 
124
- Backend-only — no `./react` entry. Remaining is typically shown through the host's own query.
327
+ Backend-only — no `./react` entry. Remaining is typically shown through the
328
+ host's own query.
125
329
 
126
330
  ## Security
127
331
 
@@ -138,8 +342,25 @@ pnpm test
138
342
  pnpm test:coverage
139
343
  ```
140
344
 
141
- Unit/integration tests use the **mock backend** `convex-test` (`@edge-runtime/vm`).
142
- They do not establish real-backend OCC or scheduler guarantees.
345
+ Unit/integration tests use the **mock backend** `convex-test`
346
+ (`@edge-runtime/vm`). They do not establish real-backend OCC or scheduler
347
+ guarantees.
348
+
349
+ ### Testing your app
350
+
351
+ `@vllnt/convex-quota/test` exports `register(t, name = "quota")` to mount the
352
+ component in a `convex-test` instance. It needs `convex-test` and `vitest` (with
353
+ Vite's `import.meta.glob`) in the consuming app:
354
+
355
+ ```ts
356
+ /// <reference types="vite/client" />
357
+ import { convexTest } from "convex-test";
358
+ import { register } from "@vllnt/convex-quota/test";
359
+ import schema from "./schema";
360
+
361
+ const t = convexTest(schema, import.meta.glob("./**/*.ts"));
362
+ register(t);
363
+ ```
143
364
 
144
365
  ## Contributing
145
366
 
@@ -147,9 +368,11 @@ See [CONTRIBUTING.md](CONTRIBUTING.md).
147
368
 
148
369
  ## Author
149
370
 
150
- Built by [bntvllnt](https://github.com/bntvllnt) · [bntvllnt.com](https://bntvllnt.com) · [X @bntvllnt](https://x.com/bntvllnt)
371
+ Built by [bntvllnt](https://github.com/bntvllnt) ·
372
+ [bntvllnt.com](https://bntvllnt.com) · [X @bntvllnt](https://x.com/bntvllnt)
151
373
 
152
- Part of the [@vllnt](https://github.com/vllnt) Convex component fleet — [vllnt.com](https://vllnt.com)
374
+ Part of the [@vllnt](https://github.com/vllnt) Convex component fleet —
375
+ [vllnt.com](https://vllnt.com)
153
376
 
154
377
  If this is useful, [sponsor the work](https://github.com/sponsors/bntvllnt).
155
378
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AAIvB,OAAO,KAAK,EACV,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AAC,CAMjB;CACF;AAED,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AAIvB,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE;QACT,OAAO,EAAE,iBAAiB,CACxB,UAAU,EACV,UAAU,EACV;YACE,MAAM,EAAE,MAAM,CAAC;YACf,GAAG,EAAE,MAAM,CAAC;YACZ,KAAK,EAAE,MAAM,CAAC;YACd,KAAK,EAAE,MAAM,CAAC;YACd,UAAU,EAAE,MAAM,CAAC;YACnB,MAAM,EAAE,UAAU,CAAC;SACpB,EACD,aAAa,CACd,CAAC;QACF,YAAY,EAAE,iBAAiB,CAC7B,UAAU,EACV,UAAU,EACV;YAAE,KAAK,CAAC,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAA;SAAE,EACrD,MAAM,CACP,CAAC;QACF,MAAM,EAAE,iBAAiB,CACvB,UAAU,EACV,UAAU,EACV;YACE,MAAM,EAAE,MAAM,CAAC;YACf,GAAG,EAAE,MAAM,CAAC;YACZ,SAAS,EAAE,MAAM,CAAC;YAClB,KAAK,EAAE,MAAM,CAAC;YACd,UAAU,EAAE,MAAM,CAAC;SACpB,EACD,YAAY,CACb,CAAC;KACH,CAAC;IACF,OAAO,EAAE;QACP,SAAS,EAAE,iBAAiB,CAC1B,OAAO,EACP,UAAU,EACV;YACE,GAAG,EAAE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,MAAM,CACJ,GAAG,EAAE,cAAc,EACnB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,YAAY,CAAC,CAQvB;IAED,YAAY,CACV,GAAG,EAAE,cAAc,EACnB,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,CAMjB;CACF;AAED,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC"}
@@ -15,7 +15,6 @@ export class Quota {
15
15
  scopeOf(scope) {
16
16
  return scope ?? this.defaultScope;
17
17
  }
18
- // eslint-disable-next-line max-params -- Preserve the published positional client contract.
19
18
  consume(ctx, subjectRef, key, limit, window, options = {}) {
20
19
  return ctx.runMutation(this.component.mutations.consume, {
21
20
  amount: options.amount ?? 1,
@@ -26,7 +25,6 @@ export class Quota {
26
25
  window,
27
26
  });
28
27
  }
29
- // eslint-disable-next-line max-params -- Preserve the published positional client contract.
30
28
  remaining(ctx, subjectRef, key, limit, window, scope) {
31
29
  return ctx.runQuery(this.component.queries.remaining, {
32
30
  key,
@@ -36,7 +34,6 @@ export class Quota {
36
34
  window,
37
35
  });
38
36
  }
39
- // eslint-disable-next-line max-params -- Preserve the published positional client contract.
40
37
  refund(ctx, subjectRef, key, amount, periodKey, scope) {
41
38
  return ctx.runMutation(this.component.mutations.refund, {
42
39
  amount,
@@ -46,7 +43,6 @@ export class Quota {
46
43
  subjectRef,
47
44
  });
48
45
  }
49
- // eslint-disable-next-line max-params -- Preserve the published positional client contract.
50
46
  eraseSubject(ctx, subjectRef, scope, batch) {
51
47
  return ctx.runMutation(this.component.mutations.eraseSubject, {
52
48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SACP,CAAC,CAAC;IACL,CAAC;IAED,SAAS,CACP,GAAgB,EAChB,UAAkB,EAClB,GAAW,EACX,KAAa,EACb,MAAkB,EAClB,KAAc;QAEd,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE;YACpD,GAAG;YACH,KAAK;YACL,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;YAC1B,UAAU;YACV,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CACJ,GAAmB,EACnB,UAAkB,EAClB,GAAW,EACX,MAAc,EACd,SAAiB,EACjB,KAAc;QAEd,OAAO,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE;YACtD,MAAM;YACN,GAAG;YACH,SAAS;YACT,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;YAC1B,UAAU;SACX,CAAC,CAAC;IACL,CAAC;IAED,YAAY,CACV,GAAmB,EACnB,UAAkB,EAClB,KAAc,EACd,KAAc;QAEd,OAAO,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,YAAY,EAAE;YAC5D,KAAK;YACL,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;YAC1B,UAAU;SACX,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"AA+FA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;GAyClB,CAAC;AAEH,eAAO,MAAM,MAAM;;;;;;;;;;GA4CjB,CAAC;AAEH,eAAO,MAAM,YAAY;;;;mBAkCvB,CAAC"}
1
+ {"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"AA+EA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;GAyClB,CAAC;AAEH,eAAO,MAAM,MAAM;;;;;;;;;;GA4CjB,CAAC;AAEH,eAAO,MAAM,YAAY;;;;mBA+BvB,CAAC"}
@@ -1,20 +1,8 @@
1
- import { ConvexError, v } from "convex/values";
2
- import { DEFAULT_ERASE_BATCH, interpretWindowError, MAX_ERASE_BATCH, resolveWindow, windowPolicyKey, } from "../shared";
3
- import { api } from "./_generated/api";
4
- import { mutation } from "./_generated/server";
5
- import { consumeResult, requireAllowanceInput, requirePositiveInt, requireRef, windowSpec, } from "./validators";
6
- function fail(code, message) {
7
- throw new ConvexError({ code, message });
8
- }
9
- function currentWindow(spec, rollingStartAt) {
10
- try {
11
- return resolveWindow(Date.now(), spec, rollingStartAt);
12
- }
13
- catch (error) {
14
- const parsed = interpretWindowError(error);
15
- fail(parsed.code, parsed.message);
16
- }
17
- }
1
+ import { v } from "convex/values";
2
+ import { DEFAULT_ERASE_BATCH, MAX_ERASE_BATCH, windowPolicyKey, } from "../shared.js";
3
+ import { api } from "./_generated/api.js";
4
+ import { mutation } from "./_generated/server.js";
5
+ import { consumeResult, currentWindow, fail, requireAllowanceInput, requirePositiveInt, requireRef, windowSpec, } from "./validators.js";
18
6
  async function loadAllowance(ctx, { key, scope, subjectRef, }) {
19
7
  return ctx.db
20
8
  .query("allowances")
@@ -138,10 +126,7 @@ export const eraseSubject = mutation({
138
126
  requireRef(arguments_.subjectRef, "subjectRef");
139
127
  requireRef(arguments_.scope, "scope");
140
128
  const raw = arguments_.batch ?? DEFAULT_ERASE_BATCH;
141
- if (!Number.isInteger(raw)) {
142
- fail("INVALID_BATCH", "batch must be a positive integer");
143
- }
144
- if (raw < 1) {
129
+ if (!Number.isInteger(raw) || raw < 1) {
145
130
  fail("INVALID_BATCH", "batch must be a positive integer");
146
131
  }
147
132
  const batch = Math.min(raw, MAX_ERASE_BATCH);
@@ -1 +1 @@
1
- {"version":3,"file":"mutations.js","sourceRoot":"","sources":["../../src/component/mutations.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CAAC;aACnB,SAAS,CAAC,sBAAsB,EAAE,CAAC,CAAC,EAAE,EAAE,CACvC,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,YAAY,EAAE,UAAU,CAAC,UAAU,CAAC,CACxE;aACA,IAAI,CAAC,KAAK,CAAC,CAAC;QACf,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC3E,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;YAC1B,MAAM,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,YAAY,EAAE;gBAC1D,KAAK;gBACL,KAAK,EAAE,UAAU,CAAC,KAAK;gBACvB,UAAU,EAAE,UAAU,CAAC,UAAU;aAClC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IACD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/component/queries.ts"],"names":[],"mappings":"AAiCA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;GAsCpB,CAAC"}
1
+ {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/component/queries.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;GAsCpB,CAAC"}
@@ -1,19 +1,7 @@
1
- import { ConvexError, v } from "convex/values";
2
- import { interpretWindowError, resolveWindow, windowPolicyKey, } from "../shared";
3
- import { query } from "./_generated/server";
4
- import { remainingState, requireAllowanceInput, windowSpec, } from "./validators";
5
- function fail(code, message) {
6
- throw new ConvexError({ code, message });
7
- }
8
- function currentWindow(spec, rollingStartAt) {
9
- try {
10
- return resolveWindow(Date.now(), spec, rollingStartAt);
11
- }
12
- catch (error) {
13
- const parsed = interpretWindowError(error);
14
- fail(parsed.code, parsed.message);
15
- }
16
- }
1
+ import { v } from "convex/values";
2
+ import { windowPolicyKey } from "../shared.js";
3
+ import { query } from "./_generated/server.js";
4
+ import { currentWindow, fail, remainingState, requireAllowanceInput, windowSpec, } from "./validators.js";
17
5
  export const remaining = query({
18
6
  args: {
19
7
  key: v.string(),
@@ -1 +1 @@
1
- {"version":3,"file":"queries.js","sourceRoot":"","sources":["../../src/component/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EACL,oBAAoB,EAEpB,aAAa,EACb,eAAe,GAEhB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,UAAU,GACX,MAAM,cAAc,CAAC;AAEtB,SAAS,IAAI,CAAC,IAAY,EAAE,OAAe;IACzC,MAAM,IAAI,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,aAAa,CACpB,IAAgB,EAChB,cAAkC;IAElC,IAAI,CAAC;QACH,OAAO,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IACzD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAC3C,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,CAAC;IAC7B,IAAI,EAAE;QACJ,G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,CAC7B;aACA,KAAK,EAAE,CAAC;QACX,MAAM,YAAY,GAChB,GAAG,KAAK,IAAI,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS;YAClD,CAAC,CAAC,GAAG,CAAC,aAAa;YACnB,CAAC,CAAC,SAAS,CAAC;QAChB,MAAM,MAAM,GAAG,aAAa,CAAC,UAAU,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAC9D,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,SAAS,KAAK,eAAe,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YACzE,IAAI,CAAC,iBAAiB,EAAE,uCAAuC,CAAC,CAAC;QACnE,CAAC;QACD,MAAM,IAAI,GACR,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,SAAS,KAAK,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACpE,OAAO;YACL,KAAK,EAAE,UAAU,CAAC,KAAK;YACvB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;YAC/C,QAAQ,EAAE,MAAM,CAAC,KAAK;YACtB,IAAI;SACL,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,cAAc;CACxB,CAAC,CAAC"}
@@ -1,5 +1,9 @@
1
+ import { type ResolvedWindow, type WindowSpec } from "../shared.js";
2
+ export declare function fail(code: string, message: string): never;
1
3
  export declare function requireRef(value: string, name: string): void;
2
4
  export declare function requirePositiveInt(value: number, name: string, code: string): void;
5
+ /** Resolve the current window at server time, mapping failures to ConvexError. */
6
+ export declare function currentWindow(spec: WindowSpec, rollingStartAt: number | undefined): ResolvedWindow;
3
7
  export declare function requireAllowanceInput(input: {
4
8
  key: string;
5
9
  limit: number;
@@ -1 +1 @@
1
- {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/component/validators.ts"],"names":[],"mappings":"AAIA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAO5D;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,IAAI,CAON;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,IAAI,CAKP;AAED,eAAO,MAAM,cAAc,iPAI1B,CAAC;AAEF,eAAO,MAAM,YAAY,0LAAoD,CAAC;AAE9E,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mHAetB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0KAiBzB,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;;;;;;;;yEAMzB,CAAC"}
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/component/validators.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,cAAc,EAEnB,KAAK,UAAU,EAChB,MAAM,cAAc,CAAC;AAEtB,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,CAEzD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAO5D;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,IAAI,CAIN;AAED,kFAAkF;AAClF,wBAAgB,aAAa,CAC3B,IAAI,EAAE,UAAU,EAChB,cAAc,EAAE,MAAM,GAAG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