@vllnt/convex-reactions 0.1.0 → 0.1.1-canary.561d279

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 ADDED
@@ -0,0 +1,81 @@
1
+ # Changelog
2
+
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).
6
+
7
+ ## [Unreleased]
8
+
9
+ ### Changed
10
+
11
+ - `counts` reads one `reactionCounts` tally row per kind instead of every edge on the resource:
12
+ O(kinds) reads instead of O(edges). Tallies cover every resource whose first reaction came
13
+ after upgrade; a resource with earlier edges keeps the edge scan (no migration, and writes never
14
+ scan legacy edges). A tally row is deleted when its count reaches zero.
15
+ - `myReactions` uses the `by_author_resource_kind` prefix; the redundant `by_author_resource`
16
+ index is removed (one less index write per `react`/`unreact`).
17
+ - Development and test toolchain: `convex` 1.51, `convex-test` 0.0.73, Vitest 5.1.1, ESLint 10,
18
+ and `@vllnt/typescript` 3 (stricter compiler flags; the built JavaScript and `.d.ts` output is
19
+ unchanged). The `convex` peer range stays `^1.45.0`.
20
+
21
+ ### Documentation
22
+
23
+ - The npm package now ships `docs/API.md`, `CHANGELOG.md`, and `llms.txt` next to `README.md`, so
24
+ the docs under `node_modules/@vllnt/convex-reactions/` match the installed version. `llms.txt`
25
+ links shipped files relatively and repository-only files by URL; `docs/API.md` lists every entry
26
+ point and the component's tables. `pnpm lint` fails when a required doc is missing from the
27
+ tarball, a contributor file, internal doc, or test ships, or an `llms.txt` link points outside it.
28
+ - `reactors` docs no longer claim the 1000-row `maximumRowsRead` cap covers reactive cursor
29
+ ranges: with an `endCursor`, Convex returns the whole range between the cursors and ignores
30
+ `maximumRowsRead` (only its transaction read limits apply). Behavior is unchanged.
31
+
32
+ ## [0.1.1] - Unreleased
33
+
34
+ ### Fixed
35
+
36
+ - `react` and `unreact` now throw `ConvexError` `INVALID_REF` for an empty `authorRef` or
37
+ `resourceRef` and `INVALID_KIND` for an empty `kind`, instead of storing an edge no real subject,
38
+ resource, or kind can address. Previously accepted input that could never be valid.
39
+ - `@vllnt/convex-reactions/test` now type-checks for consumers using `moduleResolution`
40
+ `nodenext` as well as `bundler` (explicit `.js` relative imports, Vite client types reference).
41
+
42
+ ### Changed
43
+
44
+ - Pin GitHub Actions to commit SHAs, scope workflow permissions, and publish `@latest` only from a
45
+ `vX.Y.Z` tag on `main` through npm trusted publishing with provenance.
46
+ - Adopt pnpm 10 with a seven-day release-age gate; update `convex-test` to `^0.0.65`.
47
+
48
+ ### Documentation
49
+
50
+ - README gains a self-contained "Testing your app" snippet; the error table lists the new codes.
51
+ - Add tests that assert counts, reactor rows, and `hasReacted` agree under double react,
52
+ concurrent toggles, and removal of a non-existent reaction.
53
+
54
+ ## [0.1.0] - 2026-09-01
55
+
56
+ ### Added
57
+
58
+ - First release of `@vllnt/convex-reactions` — reactions, votes, and likes on any
59
+ resource, modeled as the opaque edge `(authorRef, resourceRef, kind)`.
60
+ - `react(authorRef, resourceRef, kind)` toggles the edge in one transaction (add
61
+ if absent, remove if present), returning `{ reacted, action }`. One edge per
62
+ subject per kind per resource is enforced inside the mutation transaction.
63
+ - `unreact(authorRef, resourceRef, kind)` removes the edge; removing one that does
64
+ not exist is an idempotent no-op returning `false`.
65
+ - `counts(resourceRef)` tallies edges per kind (sorted by kind); `reactors(
66
+ resourceRef, kind, paginationOpts)` pages the subjects who reacted oldest-first
67
+ via the standard Convex pagination envelope.
68
+ - `hasReacted(authorRef, resourceRef, kind)` and `myReactions(authorRef,
69
+ resourceRef)` expose a subject's own reaction state.
70
+ - Configurable reaction vocabulary: `new Reactions(component, { allowedKinds })`
71
+ rejects an unknown `kind` at the client boundary before the component is called.
72
+ - Server-sourced time: `createdAt` is stamped from `Date.now()` inside the
73
+ mutation — no caller-supplied clock.
74
+ - Opaque refs: `authorRef`, `resourceRef`, and `kind` are plain strings the
75
+ component never de-references; it never reads host or sibling tables.
76
+ - Mount-safe: correct under multiple `app.use(component, { name })` mounts — each
77
+ instance is sandboxed.
78
+ - `reactors` bounds pagination: `numItems` must be an integer from 1 through 1000
79
+ (otherwise it throws `ConvexError` `INVALID_PAGE_SIZE`), and `maximumRowsRead` is
80
+ validated and capped at 1000 for reactive cursor ranges.
81
+ - Requires `convex@^1.45.0`.
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-reactions.svg)](https://www.npmjs.com/package/@vllnt/convex-reactions)
4
5
  [![CI](https://github.com/vllnt/convex-reactions/actions/workflows/ci.yml/badge.svg)](https://github.com/vllnt/convex-reactions/actions/workflows/ci.yml)
@@ -11,35 +12,54 @@ Reactions, votes, and likes on any resource, as a Convex component.
11
12
  ```ts
12
13
  const reactions = new Reactions(components.reactions);
13
14
  await reactions.react(ctx, authorRef, resourceRef, "up"); // toggle the edge in one transaction
14
- await reactions.counts(ctx, resourceRef); // [{ kind, count }], reactive
15
+ await reactions.counts(ctx, resourceRef); // [{ kind, count }], reactive
15
16
  await reactions.hasReacted(ctx, authorRef, resourceRef, "up");
16
17
  ```
17
18
 
18
- A reaction is the opaque edge `(authorRef, resourceRef, kind)`. `react` toggles it (add if absent,
19
- remove if present); `counts` tallies a resource per kind; `reactors` pages who reacted. One edge per
20
- subject per kind per resource is enforced in the mutation transaction, so toggles and counts stay
21
- correct under concurrency.
19
+ A reaction is the opaque edge `(authorRef, resourceRef, kind)`. `react` toggles
20
+ it (add if absent, remove if present); `counts` tallies a resource per kind;
21
+ `reactors` pages who reacted. One edge per subject per kind per resource is
22
+ enforced in the mutation transaction, so toggles and counts stay correct under
23
+ concurrency.
22
24
 
23
25
  ## Features
24
26
 
25
- - **Toggle** — `react(authorRef, resourceRef, kind)` adds the edge if absent and removes it if present in one transaction, returning `{ reacted, action }`.
26
- - **Idempotent remove** — `unreact(authorRef, resourceRef, kind)` deletes the edge; removing an absent one is a safe no-op (`false`).
27
- - **Count by kind** — `counts(resourceRef)` returns `[{ kind, count }, ...]` sorted by kind; no reactions returns `[]`.
28
- - **List reactors** — `reactors(resourceRef, kind, paginationOpts)` pages who reacted with one kind, oldest first. `numItems` must be an integer from 1 through 1000 and `maximumRowsRead` is capped at 1000, including reactive cursor ranges.
29
- - **Per-subject state** — `hasReacted` and `myReactions` give the host the subject's own reaction state for rendering controls.
30
- - **Configurable vocabulary** — `allowedKinds` pins the reaction set (`["up", "down"]`, a fixed emoji list); an unknown kind is rejected at the boundary. Omit for freeform.
31
- - **Server-sourced time** — `createdAt` is stamped from the server clock; a caller can't supply a timestamp.
32
- - **Mount-safe** — correct under multiple named `app.use` mounts; each instance is an isolated sandbox.
27
+ - **Toggle** — `react(authorRef, resourceRef, kind)` adds the edge if absent and
28
+ removes it if present in one transaction, returning `{ reacted, action }`.
29
+ - **Idempotent remove** — `unreact(authorRef, resourceRef, kind)` deletes the
30
+ edge; removing an absent one is a safe no-op (`false`).
31
+ - **Count by kind** — `counts(resourceRef)` returns `[{ kind, count }, ...]`
32
+ sorted by kind; no reactions returns `[]`.
33
+ - **List reactors** — `reactors(resourceRef, kind, paginationOpts)` pages who
34
+ reacted with one kind, oldest first. `numItems` must be an integer from 1
35
+ through 1000 and `maximumRowsRead` is capped at 1000. A reactive re-run with
36
+ an `endCursor` returns the whole range between its cursors: Convex ignores
37
+ `maximumRowsRead` there, and only its transaction read limits apply.
38
+ - **Per-subject state** — `hasReacted` and `myReactions` give the host the
39
+ subject's own reaction state for rendering controls.
40
+ - **Configurable vocabulary** — `allowedKinds` pins the reaction set
41
+ (`["up", "down"]`, a fixed emoji list); an unknown kind is rejected at the
42
+ boundary. Omit for freeform.
43
+ - **Server-sourced time** — `createdAt` is stamped from the server clock; a
44
+ caller can't supply a timestamp.
45
+ - **Mount-safe** — correct under multiple named `app.use` mounts; each instance
46
+ is an isolated sandbox.
33
47
 
34
48
  ## Installation
35
49
 
36
50
  ```bash
37
- pnpm add @vllnt/convex-reactions
51
+ pnpm add @vllnt/convex-reactions convex@^1.45.0
38
52
  ```
39
53
 
40
- Peer dependency: `convex@^1.45.0`.
54
+ Peer dependency: `convex@^1.45.0`. The command installs the latest stable
55
+ release; use `@vllnt/convex-reactions@canary` for the newest pre-release build
56
+ from `main`, and pin a resolved canary version for reproducible installs.
57
+
58
+ ## Quick start
41
59
 
42
- ## Usage
60
+ After mounting, run `pnpm exec convex dev` to generate `components.reactions`.
61
+ The example exports internal functions for trusted server callers. Public
62
+ wrappers must resolve identity and authorize resource access.
43
63
 
44
64
  ```ts
45
65
  // convex/convex.config.ts
@@ -54,8 +74,7 @@ export default app;
54
74
  ```ts
55
75
  // convex/reactions.ts — host owns auth; pass opaque refs in.
56
76
  import { components } from "./_generated/api";
57
- import { mutation, query } from "./_generated/server";
58
- import { paginationOptsValidator } from "convex/server";
77
+ import { internalMutation, internalQuery } from "./_generated/server";
59
78
  import { v } from "convex/values";
60
79
  import { Reactions } from "@vllnt/convex-reactions";
61
80
 
@@ -63,15 +82,13 @@ const reactions = new Reactions(components.reactions, {
63
82
  allowedKinds: ["up", "down"], // pin the vocabulary (optional)
64
83
  });
65
84
 
66
- export const vote = mutation({
67
- args: { postId: v.string(), kind: v.string() },
68
- handler: async (ctx, { postId, kind }) => {
69
- const userId = await requireUser(ctx); // host auth
70
- return reactions.react(ctx, userId, postId, kind);
71
- },
85
+ export const vote = internalMutation({
86
+ args: { authorRef: v.string(), resourceRef: v.string(), kind: v.string() },
87
+ handler: (ctx, { authorRef, resourceRef, kind }) =>
88
+ reactions.react(ctx, authorRef, resourceRef, kind),
72
89
  });
73
90
 
74
- export const tally = query({
91
+ export const tally = internalQuery({
75
92
  args: { postId: v.string() },
76
93
  handler: (ctx, { postId }) => reactions.counts(ctx, postId),
77
94
  });
@@ -79,28 +96,51 @@ export const tally = query({
79
96
 
80
97
  ## API Reference
81
98
 
82
- | Method | Kind | Result |
83
- |--------|------|--------|
84
- | `react(ctx, authorRef, resourceRef, kind)` | mutation | `{ reacted, action }` (`action`: `"added" \| "removed"`) |
85
- | `unreact(ctx, authorRef, resourceRef, kind)` | mutation | `boolean` (true if an edge was removed) |
86
- | `counts(ctx, resourceRef)` | query | `{ kind, count }[]` (sorted by kind) |
87
- | `hasReacted(ctx, authorRef, resourceRef, kind)` | query | `boolean` |
88
- | `myReactions(ctx, authorRef, resourceRef)` | query | `string[]` (kinds the subject placed) |
89
- | `reactors(ctx, resourceRef, kind, paginationOpts)` | query | `PaginationResult<ReactionView>`; bounded to 1000 rows read |
90
-
91
- Invalid numeric pagination options throw `INVALID_PAGE_SIZE`.
99
+ | Method | Kind | Result |
100
+ | -------------------------------------------------- | -------- | ---------------------------------------------------------- |
101
+ | `react(ctx, authorRef, resourceRef, kind)` | mutation | `{ reacted, action }` (`action`: `"added" \| "removed"`) |
102
+ | `unreact(ctx, authorRef, resourceRef, kind)` | mutation | `boolean` (true if an edge was removed) |
103
+ | `counts(ctx, resourceRef)` | query | `{ kind, count }[]` (sorted by kind) |
104
+ | `hasReacted(ctx, authorRef, resourceRef, kind)` | query | `boolean` |
105
+ | `myReactions(ctx, authorRef, resourceRef)` | query | `string[]` (kinds the subject placed) |
106
+ | `reactors(ctx, resourceRef, kind, paginationOpts)` | query | `PaginationResult<ReactionView>`; 1 to 1000 items per page |
107
+
108
+ Invalid numeric pagination options throw coded `ConvexError`
109
+ `INVALID_PAGE_SIZE`; empty `authorRef`/`resourceRef` in `react`/`unreact` throw
110
+ `INVALID_REF` and an empty `kind` throws `INVALID_KIND`. Disallowed kinds in
111
+ `react`/`unreact` throw a plain client-side `Error`, not a component error code;
112
+ query methods do not apply the allowlist.
92
113
 
93
114
  Full reference: [docs/API.md](docs/API.md).
94
115
 
95
- ## React
116
+ ## Options and limitations
96
117
 
97
- Backend-only — no `./react` entry. A reaction tally or reactor list is an ordinary reactive `useQuery` over the host's own re-exported `counts` / `reactors` refs.
118
+ - `allowedKinds?: readonly string[]` is the sole constructor option. Omit it for
119
+ freeform kinds; an empty list rejects every write kind.
120
+ - `counts` reads one stored tally per kind, kept in step by `react` and
121
+ `unreact`, for every resource whose first reaction came after tallies existed.
122
+ A resource that already had reactions before then keeps being counted from
123
+ its edges (subject to Convex read limits) until all its edges are removed. Every write on a resource updates its tally row, so very high write rates
124
+ on one `(resource, kind)` contend on that row. `myReactions` collects the
125
+ subject's edges on the resource.
126
+ - `react` is a toggle, not an idempotent retry operation: calling twice removes
127
+ the edge. Use `unreact` to ensure absence.
128
+ - Mount another isolated instance with `app.use(reactions, { name: "votes" })`
129
+ and `new Reactions(components.votes)`.
130
+
131
+ ## Integrations
132
+
133
+ Backend-only — no `./react` entry. A reaction tally or reactor list is an
134
+ ordinary reactive `useQuery` over the host's own re-exported `counts` /
135
+ `reactors` refs.
98
136
 
99
137
  ## Security
100
138
 
101
139
  - Auth-agnostic — the host resolves identity and decides who may react.
102
- - Tables sandboxed — reached only through the exported functions; never touches host or sibling tables.
103
- - Uniqueness is transactional + time is server-sourced; refs and `kind` stay opaque to the component.
140
+ - Tables sandboxed — reached only through the exported functions; never touches
141
+ host or sibling tables.
142
+ - Uniqueness is transactional + time is server-sourced; refs and `kind` stay
143
+ opaque to the component.
104
144
 
105
145
  See [docs/API.md](docs/API.md).
106
146
 
@@ -111,20 +151,66 @@ pnpm test # single run
111
151
  pnpm test:coverage # enforced 100% on covered files
112
152
  ```
113
153
 
114
- Tests run against the real component runtime via `convex-test` (`@edge-runtime/vm`), not mocks.
154
+ Tests run against the real component runtime via `convex-test`
155
+ (`@edge-runtime/vm`), not mocks.
156
+
157
+ ### Testing your app
158
+
159
+ `@vllnt/convex-reactions/test` exports `register(t, name = "reactions")` to
160
+ mount the component in a `convex-test` instance. It needs `convex-test` and
161
+ `vitest` (with Vite's `import.meta.glob`) in the consuming app:
162
+
163
+ ```ts
164
+ /// <reference types="vite/client" />
165
+ import { convexTest } from "convex-test";
166
+ import { register } from "@vllnt/convex-reactions/test";
167
+ import schema from "./schema";
168
+
169
+ const t = convexTest(schema, import.meta.glob("./**/*.ts"));
170
+ register(t);
171
+ ```
172
+
173
+ ## Documentation
174
+
175
+ [API reference](docs/API.md) · [LLM index](llms.txt) ·
176
+ [Changelog](CHANGELOG.md) · [Security policy](https://github.com/vllnt/convex-reactions/blob/main/SECURITY.md)
177
+
178
+ `llms.txt` is the maintained discovery index. `pnpm generate:llms` checks its
179
+ heading and local links without generating a source bundle.
180
+
181
+ ### For coding agents
182
+
183
+ The docs are bundled at `node_modules/@vllnt/convex-reactions/docs/` and match
184
+ the installed version, as do `README.md`, `CHANGELOG.md`, `llms.txt`, and the
185
+ TypeScript source in `src/`. Read them before writing code.
186
+
187
+ ## Related packages
188
+
189
+ - [`@vllnt/convex-comments`](https://oss.vllnt.com/packages/convex-comments) —
190
+ threaded comments on a resource. Use it for written replies; use reactions for
191
+ one-tap votes, likes, and emoji.
192
+ - [`@vllnt/convex-notifications`](https://oss.vllnt.com/packages/convex-notifications)
193
+ — per-subject inbox. Use it to tell an author someone reacted; reactions only
194
+ stores and counts the edge.
195
+ - [`@vllnt/convex-events`](https://oss.vllnt.com/packages/convex-events) —
196
+ append-only activity feed. Use it to keep a history of who did what; reactions
197
+ keeps only the current toggle state.
115
198
 
116
199
  ## Contributing
117
200
 
118
- See [CONTRIBUTING.md](CONTRIBUTING.md).
201
+ See [CONTRIBUTING.md](https://github.com/vllnt/convex-reactions/blob/main/CONTRIBUTING.md).
119
202
 
120
203
  ## Author
121
204
 
122
- Built by [bntvllnt](https://github.com/bntvllnt) · [bntvllnt.com](https://bntvllnt.com) · [X @bntvllnt](https://x.com/bntvllnt)
123
-
124
- Part of the [@vllnt](https://github.com/vllnt) Convex component fleet — [vllnt.com](https://vllnt.com)
205
+ Built by [bntvllnt](https://github.com/bntvllnt) ·
206
+ [bntvllnt.com](https://bntvllnt.com) · [X @bntvllnt](https://x.com/bntvllnt)
125
207
 
126
208
  If this is useful, [sponsor the work](https://github.com/sponsors/bntvllnt).
127
209
 
128
210
  ## License
129
211
 
130
212
  MIT — see [LICENSE](LICENSE).
213
+
214
+ ---
215
+
216
+ Part of vllnt oss: https://oss.vllnt.com
@@ -8,11 +8,13 @@
8
8
  */
9
9
  import type * as mutations from "../mutations.js";
10
10
  import type * as queries from "../queries.js";
11
+ import type * as tally from "../tally.js";
11
12
  import type * as validators from "../validators.js";
12
13
  import type { ApiFromModules, FilterApi, FunctionReference } from "convex/server";
13
14
  declare const fullApi: ApiFromModules<{
14
15
  mutations: typeof mutations;
15
16
  queries: typeof queries;
17
+ tally: typeof tally;
16
18
  validators: typeof validators;
17
19
  }>;
18
20
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,KAAK,OAAO,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,iBAAiB,EAClB,MAAM,eAAe,CAAC;AAGvB,QAAA,MAAM,OAAO,EAAE,cAAc,CAAC;IAC5B,SAAS,EAAE,OAAO,SAAS,CAAC;IAC5B,OAAO,EAAE,OAAO,OAAO,CAAC;IACxB,UAAU,EAAE,OAAO,UAAU,CAAC;CAC/B,CAAiB,CAAC;AAEnB;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,EAAE,SAAS,CACzB,OAAO,OAAO,EACd,iBAAiB,CAAC,GAAG,EAAE,QAAQ,CAAC,CACjB,CAAC;AAElB;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS,CAC9B,OAAO,OAAO,EACd,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,CACnB,CAAC;AAElB,eAAO,MAAM,UAAU,EAAqC,EAAE,CAAC"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,KAAK,OAAO,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,iBAAiB,EAClB,MAAM,eAAe,CAAC;AAGvB,QAAA,MAAM,OAAO,EAAE,cAAc,CAAC;IAC5B,SAAS,EAAE,OAAO,SAAS,CAAC;IAC5B,OAAO,EAAE,OAAO,OAAO,CAAC;IACxB,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,UAAU,EAAE,OAAO,UAAU,CAAC;CAC/B,CAAiB,CAAC;AAEnB;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,EAAE,SAAS,CACzB,OAAO,OAAO,EACd,iBAAiB,CAAC,GAAG,EAAE,QAAQ,CAAC,CACjB,CAAC;AAElB;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS,CAC9B,OAAO,OAAO,EACd,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,CACnB,CAAC;AAElB,eAAO,MAAM,UAAU,EAAqC,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AAWH,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,OAAO,GAIR,MAAa,CAAC;AAEnB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,GAAG,GAGZ,MAAa,CAAC;AAElB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAGjB,MAAa,CAAC;AAElB,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,EAAmB,CAAC"}
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AAYH,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,OAAO,GAKR,MAAa,CAAC;AAEnB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,GAAG,GAGZ,MAAa,CAAC;AAElB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAGjB,MAAa,CAAC;AAElB,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,EAAmB,CAAC"}
@@ -9,6 +9,10 @@
9
9
  * `createdAt` is stamped from the server clock (`Date.now()` inside the handler
10
10
  * — never caller-supplied). `kind` vocabulary and any allowlist are the host's
11
11
  * concern, enforced at the client boundary before this call.
12
+ *
13
+ * @throws `ConvexError({ code: "INVALID_REF" })` when `authorRef` or `resourceRef`
14
+ * is empty.
15
+ * @throws `ConvexError({ code: "INVALID_KIND" })` when `kind` is empty.
12
16
  */
13
17
  export declare const react: import("convex/server").RegisteredMutation<"public", {
14
18
  authorRef: string;
@@ -25,7 +29,8 @@ export declare const react: import("convex/server").RegisteredMutation<"public",
25
29
  * Remove a subject's `(authorRef, resourceRef, kind)` reaction edge. Idempotent:
26
30
  * removing an edge that does not exist is a no-op that returns `false`, so a
27
31
  * duplicate or replayed `unreact` is safe. Returns `true` only when an edge was
28
- * actually deleted.
32
+ * actually deleted. Throws the same `INVALID_REF` / `INVALID_KIND` errors as
33
+ * {@link react} for empty arguments.
29
34
  */
30
35
  export declare const unreact: import("convex/server").RegisteredMutation<"public", {
31
36
  authorRef: string;
@@ -1 +1 @@
1
- {"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,KAAK;;;;;;YAoBqB,SAAS;;;YASZ,OAAO;GAEzC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,OAAO;;;;oBAuBlB,CAAC"}
1
+ {"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"AA6BA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,KAAK;;;;;;YAsBqB,SAAS;;;YAUZ,OAAO;GAEzC,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,OAAO;;;;oBAyBlB,CAAC"}
@@ -1,6 +1,25 @@
1
- import { v } from "convex/values";
2
- import { mutation } from "./_generated/server";
3
- import { reactResult } from "./validators";
1
+ import { ConvexError, v } from "convex/values";
2
+ import { mutation } from "./_generated/server.js";
3
+ import { reactResult } from "./validators.js";
4
+ import { adjustCount } from "./tally.js";
5
+ /**
6
+ * Reject empty refs and kind. An empty ref or kind is never a valid edge key and
7
+ * would silently create rows no real subject, resource, or kind can address.
8
+ */
9
+ function assertEdgeKey(args) {
10
+ if (args.authorRef === "" || args.resourceRef === "") {
11
+ throw new ConvexError({
12
+ code: "INVALID_REF",
13
+ message: "authorRef and resourceRef must be non-empty",
14
+ });
15
+ }
16
+ if (args.kind === "") {
17
+ throw new ConvexError({
18
+ code: "INVALID_KIND",
19
+ message: "kind must be non-empty",
20
+ });
21
+ }
22
+ }
4
23
  /**
5
24
  * Toggle a reaction edge in one transaction. If the subject has no
6
25
  * `(authorRef, resourceRef, kind)` edge it is inserted (`action: "added"`,
@@ -12,6 +31,10 @@ import { reactResult } from "./validators";
12
31
  * `createdAt` is stamped from the server clock (`Date.now()` inside the handler
13
32
  * — never caller-supplied). `kind` vocabulary and any allowlist are the host's
14
33
  * concern, enforced at the client boundary before this call.
34
+ *
35
+ * @throws `ConvexError({ code: "INVALID_REF" })` when `authorRef` or `resourceRef`
36
+ * is empty.
37
+ * @throws `ConvexError({ code: "INVALID_KIND" })` when `kind` is empty.
15
38
  */
16
39
  export const react = mutation({
17
40
  args: {
@@ -21,6 +44,7 @@ export const react = mutation({
21
44
  },
22
45
  returns: reactResult,
23
46
  handler: async (ctx, args) => {
47
+ assertEdgeKey(args);
24
48
  const existing = await ctx.db
25
49
  .query("reactions")
26
50
  .withIndex("by_author_resource_kind", (q) => q
@@ -29,9 +53,11 @@ export const react = mutation({
29
53
  .eq("kind", args.kind))
30
54
  .unique();
31
55
  if (existing !== null) {
56
+ await adjustCount(ctx, args.resourceRef, args.kind, -1);
32
57
  await ctx.db.delete("reactions", existing._id);
33
58
  return { reacted: false, action: "removed" };
34
59
  }
60
+ await adjustCount(ctx, args.resourceRef, args.kind, 1);
35
61
  await ctx.db.insert("reactions", {
36
62
  authorRef: args.authorRef,
37
63
  resourceRef: args.resourceRef,
@@ -45,7 +71,8 @@ export const react = mutation({
45
71
  * Remove a subject's `(authorRef, resourceRef, kind)` reaction edge. Idempotent:
46
72
  * removing an edge that does not exist is a no-op that returns `false`, so a
47
73
  * duplicate or replayed `unreact` is safe. Returns `true` only when an edge was
48
- * actually deleted.
74
+ * actually deleted. Throws the same `INVALID_REF` / `INVALID_KIND` errors as
75
+ * {@link react} for empty arguments.
49
76
  */
50
77
  export const unreact = mutation({
51
78
  args: {
@@ -55,6 +82,7 @@ export const unreact = mutation({
55
82
  },
56
83
  returns: v.boolean(),
57
84
  handler: async (ctx, args) => {
85
+ assertEdgeKey(args);
58
86
  const existing = await ctx.db
59
87
  .query("reactions")
60
88
  .withIndex("by_author_resource_kind", (q) => q
@@ -65,6 +93,7 @@ export const unreact = mutation({
65
93
  if (existing === null) {
66
94
  return false;
67
95
  }
96
+ await adjustCount(ctx, args.resourceRef, args.kind, -1);
68
97
  await ctx.db.delete("reactions", existing._id);
69
98
  return true;
70
99
  },
@@ -1 +1 @@
1
- {"version":3,"file":"mutations.js","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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C;aAC/B,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC;aACnC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CACzB;aACA,MAAM,EAAE,CAAC;QACZ,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;YACtB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACxD,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAC,CAAC"}
@@ -1,10 +1,3 @@
1
- /**
2
- * Tally reaction edges per `kind` on one resource. Reads every edge for
3
- * `resourceRef` via the `by_resource_kind` index (which is prefixed by
4
- * `resourceRef`, so a `resourceRef`-only range spans all kinds) and groups them
5
- * into `{ kind, count }` rows, sorted by `kind` for a stable order. A resource
6
- * with no reactions returns an empty array.
7
- */
8
1
  export declare const counts: import("convex/server").RegisteredQuery<"public", {
9
2
  resourceRef: string;
10
3
  }, Promise<{
@@ -23,8 +16,8 @@ export declare const hasReacted: import("convex/server").RegisteredQuery<"public
23
16
  }, Promise<boolean>>;
24
17
  /**
25
18
  * Every reaction kind a subject placed on one resource (their own reaction
26
- * state across kinds), via the `by_author_resource` index. Returns the list of
27
- * `kind` strings; empty when the subject has not reacted to the resource.
19
+ * state across kinds), via the `by_author_resource_kind` prefix. Returns the
20
+ * list of `kind` strings; empty when the subject has not reacted to the resource.
28
21
  */
29
22
  export declare const myReactions: import("convex/server").RegisteredQuery<"public", {
30
23
  authorRef: string;
@@ -1 +1 @@
1
- {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/component/queries.ts"],"names":[],"mappings":"AAmDA;;;;;;GAMG;AACH,eAAO,MAAM,MAAM;;;;;KAkBjB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,UAAU;;;;oBAmBrB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,WAAW;;;qBAYtB,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;GA8BnB,CAAC"}
1
+ {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/component/queries.ts"],"names":[],"mappings":"AAoDA,eAAO,MAAM,MAAM;;;;;KAqBjB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,UAAU;;;;oBAmBrB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,WAAW;;;qBAYtB,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;GA8BnB,CAAC"}
@@ -1,7 +1,8 @@
1
1
  import { ConvexError, v } from "convex/values";
2
2
  import { paginationOptsValidator } from "convex/server";
3
- import { query } from "./_generated/server";
4
- import { kindCount, reactionView } from "./validators";
3
+ import { query } from "./_generated/server.js";
4
+ import { tallyEdges } from "./tally.js";
5
+ import { kindCount, reactionView } from "./validators.js";
5
6
  const MAX_PAGE_SIZE = 1000;
6
7
  function boundedPaginationOptions(paginationOpts) {
7
8
  const { numItems, maximumRowsRead } = paginationOpts;
@@ -37,29 +38,24 @@ function view(row) {
37
38
  createdAt: row.createdAt,
38
39
  };
39
40
  }
40
- /**
41
- * Tally reaction edges per `kind` on one resource. Reads every edge for
42
- * `resourceRef` via the `by_resource_kind` index (which is prefixed by
43
- * `resourceRef`, so a `resourceRef`-only range spans all kinds) and groups them
44
- * into `{ kind, count }` rows, sorted by `kind` for a stable order. A resource
45
- * with no reactions returns an empty array.
46
- */
47
41
  export const counts = query({
48
42
  args: { resourceRef: v.string() },
49
43
  returns: v.array(kindCount),
50
44
  handler: async (ctx, args) => {
51
- const rows = await ctx.db
52
- .query("reactions")
45
+ const tallies = await ctx.db
46
+ .query("reactionCounts")
53
47
  .withIndex("by_resource_kind", (q) => q.eq("resourceRef", args.resourceRef))
54
48
  .collect();
55
- const tally = new Map();
56
- for (const row of rows) {
57
- tally.set(row.kind, (tally.get(row.kind) ?? 0) + 1);
58
- }
49
+ const rows = tallies.length > 0
50
+ ? tallies
51
+ : [...(await tallyEdges(ctx, args.resourceRef))].map(([kind, count]) => ({
52
+ kind,
53
+ count,
54
+ }));
59
55
  // Sort by kind for a stable, deterministic order. `localeCompare` is a
60
56
  // single expression (no comparator branch), so coverage stays exact.
61
- return [...tally.entries()]
62
- .map(([kind, count]) => ({ kind, count }))
57
+ return rows
58
+ .map(({ kind, count }) => ({ kind, count }))
63
59
  .sort((a, b) => a.kind.localeCompare(b.kind));
64
60
  },
65
61
  });
@@ -88,8 +84,8 @@ export const hasReacted = query({
88
84
  });
89
85
  /**
90
86
  * Every reaction kind a subject placed on one resource (their own reaction
91
- * state across kinds), via the `by_author_resource` index. Returns the list of
92
- * `kind` strings; empty when the subject has not reacted to the resource.
87
+ * state across kinds), via the `by_author_resource_kind` prefix. Returns the
88
+ * list of `kind` strings; empty when the subject has not reacted to the resource.
93
89
  */
94
90
  export const myReactions = query({
95
91
  args: { authorRef: v.string(), resourceRef: v.string() },
@@ -97,7 +93,7 @@ export const myReactions = query({
97
93
  handler: async (ctx, args) => {
98
94
  const rows = await ctx.db
99
95
  .query("reactions")
100
- .withIndex("by_author_resource", (q) => q.eq("authorRef", args.authorRef).eq("resourceRef", args.resourceRef))
96
+ .withIndex("by_author_resource_kind", (q) => q.eq("authorRef", args.authorRef).eq("resourceRef", args.resourceRef))
101
97
  .collect();
102
98
  return rows.map((row) => row.kind);
103
99
  },
@@ -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;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,EAAE,K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,KAAK,CAAC,WAAW,CAAC;aAClB,SAAS,CAAC,kBAAkB,EAAE,CAAC,CAAC,EAAE,EAAE,CACnC,CAAC,CAAC,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAC5D;aACA,KAAK,CAAC,KAAK,CAAC;aACZ,QAAQ,CAAC,cAAc,CAAC,CAAC;QAC5B,OAAO,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
@@ -11,8 +11,6 @@
11
11
  * transaction).
12
12
  * - `by_resource_kind` — count edges of one kind on a resource and page its
13
13
  * reactors oldest-first.
14
- * - `by_author_resource` — list every kind a subject placed on a resource
15
- * (`myReactions`).
16
14
  */
17
15
  declare const _default: import("convex/server").SchemaDefinition<{
18
16
  reactions: import("convex/server").TableDefinition<import("convex/values").VObject<{
@@ -26,10 +24,20 @@ declare const _default: import("convex/server").SchemaDefinition<{
26
24
  kind: import("convex/values").VString<string, "required">;
27
25
  createdAt: import("convex/values").VFloat64<number, "required">;
28
26
  }, "required", "authorRef" | "createdAt" | "kind" | "resourceRef">, {
29
- by_author_resource: ["authorRef", "resourceRef", "_creationTime"];
30
27
  by_author_resource_kind: ["authorRef", "resourceRef", "kind", "_creationTime"];
31
28
  by_resource_kind: ["resourceRef", "kind", "createdAt", "_creationTime"];
32
29
  }, {}, {}>;
30
+ reactionCounts: import("convex/server").TableDefinition<import("convex/values").VObject<{
31
+ count: number;
32
+ kind: string;
33
+ resourceRef: string;
34
+ }, {
35
+ resourceRef: import("convex/values").VString<string, "required">;
36
+ kind: import("convex/values").VString<string, "required">;
37
+ count: import("convex/values").VFloat64<number, "required">;
38
+ }, "required", "count" | "kind" | "resourceRef">, {
39
+ by_resource_kind: ["resourceRef", "kind", "_creationTime"];
40
+ }, {}, {}>;
33
41
  }, true>;
34
42
  export default _default;
35
43
  //# sourceMappingURL=schema.d.ts.map