@vllnt/convex-reactions 0.2.0 → 0.2.1-canary.046f9f6
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 +10 -0
- package/README.md +12 -10
- package/dist/client/index.d.ts +4 -4
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +4 -5
- package/dist/client/index.js.map +1 -1
- package/dist/client/types.d.ts +4 -3
- package/dist/client/types.d.ts.map +1 -1
- package/dist/component/queries.d.ts +2 -2
- package/dist/component/queries.js +3 -3
- package/dist/component/queries.js.map +1 -1
- package/docs/API.md +14 -10
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/src/client/index.ts +4 -5
- package/src/client/types.ts +4 -3
- package/src/component/queries.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,16 @@ All notable changes to this project are documented here. The format is based on
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
|
|
5
5
|
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- `myReactions` now returns kinds in the same order as `counts` (sorted with
|
|
12
|
+
`localeCompare`); it used raw index order, so mixed-case kinds came back in a
|
|
13
|
+
different order.
|
|
14
|
+
- `unreact` no longer checks `allowedKinds`, so users can remove a reaction
|
|
15
|
+
whose kind the host has since dropped from the list. `react` still checks it.
|
|
16
|
+
|
|
7
17
|
## [0.2.0] - 2026-11-28
|
|
8
18
|
|
|
9
19
|
**Breaking:** `react` and `unreact` now throw `ConvexError` `INVALID_REF` for an
|
package/README.md
CHANGED
|
@@ -242,14 +242,14 @@ for an invalid edge key (an empty value, or an over-limit value when adding); `r
|
|
|
242
242
|
options. Catch it in the host with `error instanceof ConvexError` and read
|
|
243
243
|
`error.data.code`.
|
|
244
244
|
|
|
245
|
-
| Error | Thrown by
|
|
246
|
-
| -------------------------------------------------------------------------------- |
|
|
247
|
-
| `INVALID_REF` | `react`, `unreact`
|
|
248
|
-
| `INVALID_REF`: `authorRef and resourceRef must be at most 512 UTF-16 code units` | `react` when adding an edge
|
|
249
|
-
| `INVALID_KIND` | `react`, `unreact`
|
|
250
|
-
| `INVALID_KIND`: `kind must be at most 128 UTF-16 code units` | `react` when adding an edge
|
|
251
|
-
| `INVALID_PAGE_SIZE` | `reactors`
|
|
252
|
-
| `Error`: `invalid reaction kind "<kind>": not in the configured allowlist` | `react
|
|
245
|
+
| Error | Thrown by | Cause | Fix |
|
|
246
|
+
| -------------------------------------------------------------------------------- | --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
|
|
247
|
+
| `INVALID_REF` | `react`, `unreact` | `authorRef` or `resourceRef` is the empty string | Pass a non-empty ref (a user id, a row id, a namespaced key) |
|
|
248
|
+
| `INVALID_REF`: `authorRef and resourceRef must be at most 512 UTF-16 code units` | `react` when adding an edge | `authorRef` or `resourceRef` is longer than 512 UTF-16 code units (JavaScript string length; most emoji count as 2) | Pass a shorter ref, such as a row id or a hash of a long key |
|
|
249
|
+
| `INVALID_KIND` | `react`, `unreact` | `kind` is the empty string | Pass a non-empty kind |
|
|
250
|
+
| `INVALID_KIND`: `kind must be at most 128 UTF-16 code units` | `react` when adding an edge | `kind` is longer than 128 UTF-16 code units (JavaScript string length; most emoji count as 2) | Pass a shorter kind |
|
|
251
|
+
| `INVALID_PAGE_SIZE` | `reactors` | `paginationOpts.numItems` is not an integer from 1 to 1000, or `maximumRowsRead` is not a positive integer | Keep `numItems` in 1..1000; omit `maximumRowsRead` or pass a positive integer |
|
|
252
|
+
| `Error`: `invalid reaction kind "<kind>": not in the configured allowlist` | `react` on a client with `allowedKinds` | `kind` is not in `allowedKinds`; thrown by the client before the component is called; a plain `Error`, not a `ConvexError` | Pass a listed kind or add it to `allowedKinds`; validate user input in the host first |
|
|
253
253
|
|
|
254
254
|
Arguments of the wrong type (for example a number `kind`) are rejected by Convex
|
|
255
255
|
argument validation before the component runs. Queries do not validate refs or
|
|
@@ -272,8 +272,10 @@ kinds and do not throw on empty strings.
|
|
|
272
272
|
the same arguments removes the edge again. Use `unreact` for "ensure absent",
|
|
273
273
|
and `hasReacted` before `react` for "ensure present".
|
|
274
274
|
- `allowedKinds` is enforced only in the `Reactions` client, and only for
|
|
275
|
-
`react` and
|
|
276
|
-
|
|
275
|
+
`react`. `unreact` and queries accept any kind, so a reaction whose kind was
|
|
276
|
+
later dropped from the list can still be removed. A direct call to the
|
|
277
|
+
component's functions skips the check. `allowedKinds: []` rejects every
|
|
278
|
+
`react`.
|
|
277
279
|
- `counts` reads stored tally rows, one per kind. A resource whose reactions
|
|
278
280
|
were written by 0.1.0 (before tallies existed) has no tally rows; `counts`
|
|
279
281
|
counts its edges instead, one read per edge, until all its edges are removed.
|
package/dist/client/index.d.ts
CHANGED
|
@@ -87,10 +87,10 @@ export declare class Reactions {
|
|
|
87
87
|
react(ctx: RunMutationCtx, authorRef: string, resourceRef: string, kind: string): Promise<ReactResult>;
|
|
88
88
|
/**
|
|
89
89
|
* Remove a subject's reaction edge. Idempotent — removing an edge that does
|
|
90
|
-
* not exist returns `false`; a real removal returns `true`.
|
|
91
|
-
* `
|
|
92
|
-
* the component's `ConvexError` `INVALID_REF` /
|
|
93
|
-
* ref or kind (no length cap on removal).
|
|
90
|
+
* not exist returns `false`; a real removal returns `true`. Not checked
|
|
91
|
+
* against `allowedKinds`, so an edge of a kind the host has since dropped can
|
|
92
|
+
* still be removed. Throws the component's `ConvexError` `INVALID_REF` /
|
|
93
|
+
* `INVALID_KIND` for an empty ref or kind (no length cap on removal).
|
|
94
94
|
*/
|
|
95
95
|
unreact(ctx: RunMutationCtx, authorRef: string, resourceRef: string, kind: string): Promise<boolean>;
|
|
96
96
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"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AC,CAMlB;IAED,gFAAgF;IAChF,WAAW,CACT,GAAG,EAAE,WAAW,EAChB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,EAAE,CAAC,CAKnB;IAED;;;OAGG;IACH,QAAQ,CACN,GAAG,EAAE,WAAW,EAChB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,iBAAiB,GAChC,OAAO,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAMzC;CACF;AAED,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
|
package/dist/client/index.js
CHANGED
|
@@ -58,13 +58,12 @@ export class Reactions {
|
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* Remove a subject's reaction edge. Idempotent — removing an edge that does
|
|
61
|
-
* not exist returns `false`; a real removal returns `true`.
|
|
62
|
-
* `
|
|
63
|
-
* the component's `ConvexError` `INVALID_REF` /
|
|
64
|
-
* ref or kind (no length cap on removal).
|
|
61
|
+
* not exist returns `false`; a real removal returns `true`. Not checked
|
|
62
|
+
* against `allowedKinds`, so an edge of a kind the host has since dropped can
|
|
63
|
+
* still be removed. Throws the component's `ConvexError` `INVALID_REF` /
|
|
64
|
+
* `INVALID_KIND` for an empty ref or kind (no length cap on removal).
|
|
65
65
|
*/
|
|
66
66
|
unreact(ctx, authorRef, resourceRef, kind) {
|
|
67
|
-
this.assertKind(kind);
|
|
68
67
|
return ctx.runMutation(this.component.mutations.unreact, {
|
|
69
68
|
authorRef,
|
|
70
69
|
resourceRef,
|
package/dist/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AA4EA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,OAAO,SAAS;IAID,SAAS;IAHX,YAAY,CAAkC;IAE/D,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SAAS,CAAC,OAAO,CAAC,WAAW,EAAE;YACtD,SAAS;YACT,WAAW;SACZ,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,QAAQ,CACN,GAAgB,EAChB,WAAmB,EACnB,IAAY,EACZ,cAAiC;QAEjC,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE;YACnD,WAAW;YACX,IAAI;YACJ,cAAc;SACf,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/client/types.d.ts
CHANGED
|
@@ -28,9 +28,10 @@ export interface ReactResult {
|
|
|
28
28
|
export interface ReactionsOptions {
|
|
29
29
|
/**
|
|
30
30
|
* Optional allowlist of permitted reaction `kind` values. When set, `react`
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* throws before calling the component if `kind` is not in the list — the
|
|
32
|
+
* host pins its reaction vocabulary (e.g. `["up", "down"]` or a fixed emoji
|
|
33
|
+
* set). `unreact` is not checked, so edges of a dropped kind stay removable.
|
|
34
|
+
* Omit to accept any freeform `kind`.
|
|
34
35
|
*/
|
|
35
36
|
allowedKinds?: readonly string[];
|
|
36
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAE1D,wEAAwE;AACxE,MAAM,WAAW,YAAY;IAC3B,kEAAkE;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,WAAW,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,6DAA6D;AAC7D,MAAM,WAAW,SAAS;IACxB,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAC;CACf;AAED,4DAA4D;AAC5D,MAAM,WAAW,WAAW;IAC1B,mFAAmF;IACnF,OAAO,EAAE,OAAO,CAAC;IACjB,oCAAoC;IACpC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;CAC7B;AAED,6DAA6D;AAC7D,MAAM,WAAW,gBAAgB;IAC/B
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAE1D,wEAAwE;AACxE,MAAM,WAAW,YAAY;IAC3B,kEAAkE;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,WAAW,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,6DAA6D;AAC7D,MAAM,WAAW,SAAS;IACxB,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAC;CACf;AAED,4DAA4D;AAC5D,MAAM,WAAW,WAAW;IAC1B,mFAAmF;IACnF,OAAO,EAAE,OAAO,CAAC;IACjB,oCAAoC;IACpC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;CAC7B;AAED,6DAA6D;AAC7D,MAAM,WAAW,gBAAgB;IAC/B;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC"}
|
|
@@ -22,8 +22,8 @@ export declare const hasReacted: import("convex/server").RegisteredQuery<"public
|
|
|
22
22
|
/**
|
|
23
23
|
* Every reaction kind a subject placed on one resource (their own reaction
|
|
24
24
|
* state across kinds), via the `by_author_resource_kind` prefix. Returns the
|
|
25
|
-
* list of `kind` strings sorted by `kind
|
|
26
|
-
* to the resource.
|
|
25
|
+
* list of `kind` strings sorted by `kind` with `localeCompare`, the same order as
|
|
26
|
+
* `counts`; empty when the subject has not reacted to the resource.
|
|
27
27
|
*/
|
|
28
28
|
export declare const myReactions: import("convex/server").RegisteredQuery<"public", {
|
|
29
29
|
authorRef: string;
|
|
@@ -90,8 +90,8 @@ export const hasReacted = query({
|
|
|
90
90
|
/**
|
|
91
91
|
* Every reaction kind a subject placed on one resource (their own reaction
|
|
92
92
|
* state across kinds), via the `by_author_resource_kind` prefix. Returns the
|
|
93
|
-
* list of `kind` strings sorted by `kind
|
|
94
|
-
* to the resource.
|
|
93
|
+
* list of `kind` strings sorted by `kind` with `localeCompare`, the same order as
|
|
94
|
+
* `counts`; empty when the subject has not reacted to the resource.
|
|
95
95
|
*/
|
|
96
96
|
export const myReactions = query({
|
|
97
97
|
args: { authorRef: v.string(), resourceRef: v.string() },
|
|
@@ -101,7 +101,7 @@ export const myReactions = query({
|
|
|
101
101
|
.query("reactions")
|
|
102
102
|
.withIndex("by_author_resource_kind", (q) => q.eq("authorRef", args.authorRef).eq("resourceRef", args.resourceRef))
|
|
103
103
|
.collect();
|
|
104
|
-
return rows.map((row) => row.kind);
|
|
104
|
+
return rows.map((row) => row.kind).sort((a, b) => a.localeCompare(b));
|
|
105
105
|
},
|
|
106
106
|
});
|
|
107
107
|
/**
|
|
@@ -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,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG1D,MAAM,aAAa,GAAG,IAAI,CAAC;AAE3B,SAAS,wBAAwB,CAC/B,cAAiC;IAEjC,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,cAAc,CAAC;IACrD,IACE,CAAC,MAAM,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C;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"}
|
package/docs/API.md
CHANGED
|
@@ -44,10 +44,12 @@ the component mutation; no method accepts a caller-supplied timestamp.
|
|
|
44
44
|
|
|
45
45
|
`{ allowedKinds?: readonly string[] }`, the only constructor option.
|
|
46
46
|
|
|
47
|
-
When `allowedKinds` is set, `react`
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
When `allowedKinds` is set, `react` throws a plain `Error` before calling the
|
|
48
|
+
component if `kind` is not in the list. Omit it to accept any non-empty `kind`.
|
|
49
|
+
An empty list rejects every `react`. `unreact` is not checked, so a user can
|
|
50
|
+
still remove a reaction whose kind the host has since dropped from the list. The
|
|
51
|
+
allowlist does not restrict queries, and direct component calls bypass this
|
|
52
|
+
client-only check.
|
|
51
53
|
|
|
52
54
|
## Mutations
|
|
53
55
|
|
|
@@ -78,8 +80,9 @@ existing edge is never size-checked.
|
|
|
78
80
|
Remove a subject's `(authorRef, resourceRef, kind)` edge. Returns `true` when an
|
|
79
81
|
edge was deleted, `false` when none existed, so a duplicate or replayed
|
|
80
82
|
`unreact` changes nothing. Throws `INVALID_REF` and `INVALID_KIND` for empty
|
|
81
|
-
arguments
|
|
82
|
-
|
|
83
|
+
arguments. It never applies the client allowlist or the length caps, so an edge
|
|
84
|
+
of a kind dropped from `allowedKinds`, or an over-limit edge stored before
|
|
85
|
+
0.2.0, can always be removed.
|
|
83
86
|
|
|
84
87
|
## Queries
|
|
85
88
|
|
|
@@ -105,8 +108,9 @@ toggle state the host renders next to a reaction control.
|
|
|
105
108
|
|
|
106
109
|
`myReactions(ctx, authorRef, resourceRef): Promise<string[]>`
|
|
107
110
|
|
|
108
|
-
Every reaction `kind` a subject placed on one resource, sorted by `kind
|
|
109
|
-
|
|
111
|
+
Every reaction `kind` a subject placed on one resource, sorted by `kind`
|
|
112
|
+
(`localeCompare`), the same order as `counts`. Empty when the subject has not
|
|
113
|
+
reacted to the resource.
|
|
110
114
|
|
|
111
115
|
### `reactors`
|
|
112
116
|
|
|
@@ -210,5 +214,5 @@ Lengths are JavaScript string lengths (UTF-16 code units; most emoji count as
|
|
|
210
214
|
on size, and an over-limit edge stored before 0.2.0 stays readable and
|
|
211
215
|
removable. The `Reactions` client throws a plain
|
|
212
216
|
`Error('invalid reaction kind "<kind>": not in the configured allowlist')` when
|
|
213
|
-
`allowedKinds` is set and `kind` is not in it, before the component is called
|
|
214
|
-
Queries do not validate refs or kinds.
|
|
217
|
+
`allowedKinds` is set and `kind` is not in it, before the component is called
|
|
218
|
+
(`react` only). Queries do not validate refs or kinds.
|
package/llms.txt
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> TypeScript Convex component for emoji reactions, up/down votes and likes on any resource: toggle a reaction, count per kind, page who reacted.
|
|
4
4
|
|
|
5
|
-
Install `@vllnt/convex-reactions` (builds from `main` use the `canary` dist-tag). Peer dependency `convex@^1.45.0`. Mount it with `app.use(reactions)` from `@vllnt/convex-reactions/convex.config` and call it through `new Reactions(components.reactions, { allowedKinds })` from host mutations and queries. A reaction is the edge `(authorRef, resourceRef, kind)` of opaque host strings. Mutations: `react` toggles the edge (add if absent, remove if present) and returns `{ reacted, action }`; it is not retry-idempotent. `unreact` removes it and returns `false` when there was nothing to remove. Queries: `counts` (`{ kind, count }[]` sorted by kind, read from one stored tally row per kind), `hasReacted`, `myReactions`, and `reactors` (oldest-first Convex pagination, `numItems` 1 through 1000, `maximumRowsRead` capped at 1000 except on reactive re-runs with an `endCursor`). One edge per subject per kind per resource is enforced inside the mutation transaction; `createdAt` comes from the server clock. Errors: `ConvexError` with `data.code` `INVALID_REF` or `INVALID_KIND` (empty refs or kind in `react`/`unreact`, or, when `react` adds an edge, a ref over 512 or a kind over 128 UTF-16 code units) and `INVALID_PAGE_SIZE` (`reactors`); a kind outside `allowedKinds` throws a plain `Error` in the client, for `react
|
|
5
|
+
Install `@vllnt/convex-reactions` (builds from `main` use the `canary` dist-tag). Peer dependency `convex@^1.45.0`. Mount it with `app.use(reactions)` from `@vllnt/convex-reactions/convex.config` and call it through `new Reactions(components.reactions, { allowedKinds })` from host mutations and queries. A reaction is the edge `(authorRef, resourceRef, kind)` of opaque host strings. Mutations: `react` toggles the edge (add if absent, remove if present) and returns `{ reacted, action }`; it is not retry-idempotent. `unreact` removes it and returns `false` when there was nothing to remove. Queries: `counts` (`{ kind, count }[]` sorted by kind, read from one stored tally row per kind), `hasReacted`, `myReactions`, and `reactors` (oldest-first Convex pagination, `numItems` 1 through 1000, `maximumRowsRead` capped at 1000 except on reactive re-runs with an `endCursor`). One edge per subject per kind per resource is enforced inside the mutation transaction; `createdAt` comes from the server clock. Errors: `ConvexError` with `data.code` `INVALID_REF` or `INVALID_KIND` (empty refs or kind in `react`/`unreact`, or, when `react` adds an edge, a ref over 512 or a kind over 128 UTF-16 code units) and `INVALID_PAGE_SIZE` (`reactors`); a kind outside `allowedKinds` throws a plain `Error` in the client, for `react` only (`unreact` can always remove an edge). The host owns the subject, the resource, the vocabulary and auth; the component never reads host tables. Backend-only: no React entry.
|
|
6
6
|
|
|
7
7
|
## When to use
|
|
8
8
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vllnt/convex-reactions",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1-canary.046f9f6",
|
|
4
4
|
"description": "TypeScript Convex component for emoji reactions, up/down votes and likes on any resource: toggle a reaction, count per kind, page who reacted.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/client/index.ts
CHANGED
|
@@ -146,10 +146,10 @@ export class Reactions {
|
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
148
|
* Remove a subject's reaction edge. Idempotent — removing an edge that does
|
|
149
|
-
* not exist returns `false`; a real removal returns `true`.
|
|
150
|
-
* `
|
|
151
|
-
* the component's `ConvexError` `INVALID_REF` /
|
|
152
|
-
* ref or kind (no length cap on removal).
|
|
149
|
+
* not exist returns `false`; a real removal returns `true`. Not checked
|
|
150
|
+
* against `allowedKinds`, so an edge of a kind the host has since dropped can
|
|
151
|
+
* still be removed. Throws the component's `ConvexError` `INVALID_REF` /
|
|
152
|
+
* `INVALID_KIND` for an empty ref or kind (no length cap on removal).
|
|
153
153
|
*/
|
|
154
154
|
unreact(
|
|
155
155
|
ctx: RunMutationCtx,
|
|
@@ -157,7 +157,6 @@ export class Reactions {
|
|
|
157
157
|
resourceRef: string,
|
|
158
158
|
kind: string,
|
|
159
159
|
): Promise<boolean> {
|
|
160
|
-
this.assertKind(kind);
|
|
161
160
|
return ctx.runMutation(this.component.mutations.unreact, {
|
|
162
161
|
authorRef,
|
|
163
162
|
resourceRef,
|
package/src/client/types.ts
CHANGED
|
@@ -32,9 +32,10 @@ export interface ReactResult {
|
|
|
32
32
|
export interface ReactionsOptions {
|
|
33
33
|
/**
|
|
34
34
|
* Optional allowlist of permitted reaction `kind` values. When set, `react`
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
35
|
+
* throws before calling the component if `kind` is not in the list — the
|
|
36
|
+
* host pins its reaction vocabulary (e.g. `["up", "down"]` or a fixed emoji
|
|
37
|
+
* set). `unreact` is not checked, so edges of a dropped kind stay removable.
|
|
38
|
+
* Omit to accept any freeform `kind`.
|
|
38
39
|
*/
|
|
39
40
|
allowedKinds?: readonly string[];
|
|
40
41
|
}
|
package/src/component/queries.ts
CHANGED
|
@@ -112,8 +112,8 @@ export const hasReacted = query({
|
|
|
112
112
|
/**
|
|
113
113
|
* Every reaction kind a subject placed on one resource (their own reaction
|
|
114
114
|
* state across kinds), via the `by_author_resource_kind` prefix. Returns the
|
|
115
|
-
* list of `kind` strings sorted by `kind
|
|
116
|
-
* to the resource.
|
|
115
|
+
* list of `kind` strings sorted by `kind` with `localeCompare`, the same order as
|
|
116
|
+
* `counts`; empty when the subject has not reacted to the resource.
|
|
117
117
|
*/
|
|
118
118
|
export const myReactions = query({
|
|
119
119
|
args: { authorRef: v.string(), resourceRef: v.string() },
|
|
@@ -125,7 +125,7 @@ export const myReactions = query({
|
|
|
125
125
|
q.eq("authorRef", args.authorRef).eq("resourceRef", args.resourceRef),
|
|
126
126
|
)
|
|
127
127
|
.collect();
|
|
128
|
-
return rows.map((row) => row.kind);
|
|
128
|
+
return rows.map((row) => row.kind).sort((a, b) => a.localeCompare(b));
|
|
129
129
|
},
|
|
130
130
|
});
|
|
131
131
|
|