@vllnt/convex-comments 0.1.0 → 0.1.1-canary.1036f78
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 +112 -43
- package/dist/component/crons.js +1 -1
- package/dist/component/crons.js.map +1 -1
- package/dist/component/mutations.d.ts +3 -0
- package/dist/component/mutations.d.ts.map +1 -1
- package/dist/component/mutations.js +13 -4
- package/dist/component/mutations.js.map +1 -1
- package/dist/component/queries.js +3 -3
- package/dist/component/queries.js.map +1 -1
- package/dist/component/schema.js +1 -1
- package/dist/component/schema.js.map +1 -1
- package/package.json +25 -15
- package/src/component/crons.ts +1 -1
- package/src/component/mutations.ts +13 -4
- package/src/component/queries.ts +4 -4
- package/src/component/schema.ts +1 -1
- package/src/test.ts +2 -1
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<!-- Badges -->
|
|
2
|
+
|
|
2
3
|
[](https://www.convex.dev/components)
|
|
3
4
|
[](https://www.npmjs.com/package/@vllnt/convex-comments)
|
|
4
5
|
[](https://github.com/vllnt/convex-comments/actions/workflows/ci.yml)
|
|
@@ -11,34 +12,50 @@ Threaded comments / annotations on any resource, as a Convex component.
|
|
|
11
12
|
```ts
|
|
12
13
|
const comments = new Comments(components.comments);
|
|
13
14
|
await comments.post(ctx, resourceRef, authorRef, body, parentId); // parentId threads a reply
|
|
14
|
-
await comments.list(ctx, resourceRef, paginationOpts);
|
|
15
|
-
await comments.resolve(ctx, commentId, authorRef);
|
|
15
|
+
await comments.list(ctx, resourceRef, paginationOpts); // reactive thread
|
|
16
|
+
await comments.resolve(ctx, commentId, authorRef); // author-gated
|
|
16
17
|
```
|
|
17
18
|
|
|
18
|
-
A host attaches a comment to an opaque `resourceRef` (an article, a doc, a clip
|
|
19
|
-
thread under a parent; the author edits, resolves, and
|
|
20
|
-
resource's thread or subscribe
|
|
19
|
+
A host attaches a comment to an opaque `resourceRef` (an article, a doc, a clip
|
|
20
|
+
— anything); replies thread under a parent; the author edits, resolves, and
|
|
21
|
+
soft-deletes their own comments; clients page a resource's thread or subscribe
|
|
22
|
+
reactively.
|
|
21
23
|
|
|
22
24
|
## Features
|
|
23
25
|
|
|
24
|
-
- **Post on any resource** — `post(resourceRef, authorRef, body, parentId?)`
|
|
25
|
-
|
|
26
|
-
- **
|
|
27
|
-
|
|
28
|
-
- **
|
|
29
|
-
|
|
30
|
-
- **
|
|
31
|
-
|
|
26
|
+
- **Post on any resource** — `post(resourceRef, authorRef, body, parentId?)`
|
|
27
|
+
inserts an `open` comment; `parentId` threads it as a reply.
|
|
28
|
+
- **Author-gated edits** — `edit`, `remove` (soft-delete), and `resolve` require
|
|
29
|
+
the original `authorRef`, else `NOT_AUTHOR`.
|
|
30
|
+
- **Threaded** — a reply links to a parent on the same resource (cross-resource
|
|
31
|
+
or deleted parent rejected); `list(..., { parentId })` pages direct replies.
|
|
32
|
+
- **Soft-delete + retention** — `remove` keeps the row and replies but marks it
|
|
33
|
+
`deleted` and clears the body; a daily cron prunes deleted leaf rows past
|
|
34
|
+
retention, preserving parents with replies.
|
|
35
|
+
- **Page or subscribe** — `list` pages oldest-first (deleted excluded by
|
|
36
|
+
default), `count` tallies visible ones. Reactive in a Convex query.
|
|
37
|
+
- **Server-sourced time** — `createdAt`/`updatedAt`/`editedAt` are stamped from
|
|
38
|
+
the server clock; a caller can't supply a timestamp.
|
|
39
|
+
- **Typed, opaque body** — `Comments<TBody>` types the stored `body`;
|
|
40
|
+
`bodyValidator` narrows plain text vs rich blocks at the boundary.
|
|
41
|
+
- **Mount-safe** — correct under multiple named `app.use` mounts (e.g. a
|
|
42
|
+
`comments` mount + an `annotations` mount); each is an isolated sandbox.
|
|
32
43
|
|
|
33
44
|
## Installation
|
|
34
45
|
|
|
35
46
|
```bash
|
|
36
|
-
pnpm add @vllnt/convex-comments
|
|
47
|
+
pnpm add @vllnt/convex-comments@canary convex@^1.45.0
|
|
37
48
|
```
|
|
38
49
|
|
|
39
|
-
Peer dependency: `convex@^1.
|
|
50
|
+
Peer dependency: `convex@^1.45.0`. This README follows `main` and the canary
|
|
51
|
+
channel; `latest` is the separate stable release. Pin an exact canary version
|
|
52
|
+
for reproducible installs.
|
|
53
|
+
|
|
54
|
+
## Quick start
|
|
40
55
|
|
|
41
|
-
|
|
56
|
+
After mounting, run `pnpm exec convex dev` to generate `components.comments`.
|
|
57
|
+
The example exports internal functions for trusted server callers; public
|
|
58
|
+
wrappers must resolve the caller and authorize access to the resource.
|
|
42
59
|
|
|
43
60
|
```ts
|
|
44
61
|
// convex/convex.config.ts
|
|
@@ -51,26 +68,32 @@ export default app;
|
|
|
51
68
|
```
|
|
52
69
|
|
|
53
70
|
```ts
|
|
54
|
-
// convex/comments.ts —
|
|
71
|
+
// convex/comments.ts — trusted server-only example.
|
|
55
72
|
import { components } from "./_generated/api";
|
|
56
|
-
import {
|
|
73
|
+
import { internalMutation, internalQuery } from "./_generated/server";
|
|
57
74
|
import { paginationOptsValidator } from "convex/server";
|
|
58
75
|
import { v } from "convex/values";
|
|
59
76
|
import { Comments } from "@vllnt/convex-comments";
|
|
60
77
|
|
|
61
78
|
const comments = new Comments<string>(components.comments, {
|
|
62
|
-
bodyValidator:
|
|
79
|
+
bodyValidator: (value) => {
|
|
80
|
+
if (typeof value !== "string") throw new Error("Expected a string body");
|
|
81
|
+
return value;
|
|
82
|
+
},
|
|
63
83
|
});
|
|
64
84
|
|
|
65
|
-
export const postComment =
|
|
66
|
-
args: {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
85
|
+
export const postComment = internalMutation({
|
|
86
|
+
args: {
|
|
87
|
+
resourceRef: v.string(),
|
|
88
|
+
authorRef: v.string(),
|
|
89
|
+
body: v.string(),
|
|
90
|
+
parentId: v.optional(v.string()),
|
|
70
91
|
},
|
|
92
|
+
handler: (ctx, { resourceRef, authorRef, body, parentId }) =>
|
|
93
|
+
comments.post(ctx, resourceRef, authorRef, body, parentId),
|
|
71
94
|
});
|
|
72
95
|
|
|
73
|
-
export const listComments =
|
|
96
|
+
export const listComments = internalQuery({
|
|
74
97
|
args: { resourceRef: v.string(), paginationOpts: paginationOptsValidator },
|
|
75
98
|
handler: (ctx, { resourceRef, paginationOpts }) =>
|
|
76
99
|
comments.list(ctx, resourceRef, paginationOpts),
|
|
@@ -79,28 +102,47 @@ export const listComments = query({
|
|
|
79
102
|
|
|
80
103
|
## API Reference
|
|
81
104
|
|
|
82
|
-
| Method
|
|
83
|
-
|
|
84
|
-
| `post(ctx, resourceRef, authorRef, body, parentId?)` | mutation | `{ commentId }`
|
|
85
|
-
| `edit(ctx, commentId, authorRef, body)`
|
|
86
|
-
| `remove(ctx, commentId, authorRef)`
|
|
87
|
-
| `resolve(ctx, commentId, authorRef, resolved?)`
|
|
88
|
-
| `get(ctx, commentId)`
|
|
89
|
-
| `list(ctx, resourceRef, paginationOpts, opts?)`
|
|
90
|
-
| `count(ctx, resourceRef)`
|
|
91
|
-
| `prune(ctx, opts?)`
|
|
105
|
+
| Method | Kind | Result |
|
|
106
|
+
| ---------------------------------------------------- | -------- | -------------------------------------------------------------------------- |
|
|
107
|
+
| `post(ctx, resourceRef, authorRef, body, parentId?)` | mutation | `{ commentId }` |
|
|
108
|
+
| `edit(ctx, commentId, authorRef, body)` | mutation | `null` (author-gated) |
|
|
109
|
+
| `remove(ctx, commentId, authorRef)` | mutation | `null` (soft-delete, author-gated) |
|
|
110
|
+
| `resolve(ctx, commentId, authorRef, resolved?)` | mutation | `null` (toggle, author-gated; `resolved` defaults `true`) |
|
|
111
|
+
| `get(ctx, commentId)` | query | `CommentView \| null` |
|
|
112
|
+
| `list(ctx, resourceRef, paginationOpts, opts?)` | query | `PaginationResult<CommentView>` (`opts`: `{ parentId?; includeDeleted? }`) |
|
|
113
|
+
| `count(ctx, resourceRef)` | query | `number` (visible comments) |
|
|
114
|
+
| `prune(ctx, opts?)` | mutation | `number` (deleted comments removed in the first bounded pass) |
|
|
92
115
|
|
|
93
116
|
Full reference: [docs/API.md](docs/API.md).
|
|
94
117
|
|
|
95
|
-
##
|
|
118
|
+
## Options and limitations
|
|
119
|
+
|
|
120
|
+
- The constructor accepts only `bodyValidator`, a parser `(unknown) => TBody`
|
|
121
|
+
that returns or throws; Convex `v.*` validators do not have a `.parse` method.
|
|
122
|
+
- `prune({ before?, batch? })` defaults to 30-day retention and 200 rows per
|
|
123
|
+
pass; batch must be an integer from 1–500 and `before` must be finite. These
|
|
124
|
+
are per-call options, not mount settings; the built-in daily cron keeps its
|
|
125
|
+
default retention.
|
|
126
|
+
- Deleted parents remain while any replies exist. `count` scans the resource's
|
|
127
|
+
comments; it is not a constant-time aggregate.
|
|
128
|
+
- Multiple static instances use `app.use(comments, { name: "annotations" })` and
|
|
129
|
+
`new Comments(components.annotations)`.
|
|
96
130
|
|
|
97
|
-
|
|
131
|
+
## Integrations
|
|
132
|
+
|
|
133
|
+
Backend-only — no `./react` entry. A comment thread is an ordinary reactive
|
|
134
|
+
`useQuery` / `usePaginatedQuery` over the host's own re-exported `list` /
|
|
135
|
+
`count` refs.
|
|
98
136
|
|
|
99
137
|
## Security
|
|
100
138
|
|
|
101
|
-
- Auth-agnostic for access; the component enforces only **authorship**
|
|
102
|
-
|
|
103
|
-
|
|
139
|
+
- Auth-agnostic for access; the component enforces only **authorship**
|
|
140
|
+
(`edit`/`remove`/`resolve` require the original `authorRef`). The host owns
|
|
141
|
+
who may post or moderate.
|
|
142
|
+
- Tables sandboxed — reached only through the exported functions; never touches
|
|
143
|
+
host or sibling tables.
|
|
144
|
+
- Server-sourced time; `resourceRef` / `authorRef` / `body` stay opaque to the
|
|
145
|
+
component.
|
|
104
146
|
|
|
105
147
|
See [docs/API.md](docs/API.md).
|
|
106
148
|
|
|
@@ -111,7 +153,32 @@ pnpm test # single run
|
|
|
111
153
|
pnpm test:coverage # enforced 100% on covered files
|
|
112
154
|
```
|
|
113
155
|
|
|
114
|
-
Tests run against the real component runtime via `convex-test`
|
|
156
|
+
Tests run against the real component runtime via `convex-test`
|
|
157
|
+
(`@edge-runtime/vm`), not mocks.
|
|
158
|
+
|
|
159
|
+
### Testing your app
|
|
160
|
+
|
|
161
|
+
`@vllnt/convex-comments/test` exports `register(t, name = "comments")` to mount
|
|
162
|
+
the component in a `convex-test` instance. It needs `convex-test` and `vitest`
|
|
163
|
+
(with Vite's `import.meta.glob`) in the consuming app:
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
/// <reference types="vite/client" />
|
|
167
|
+
import { convexTest } from "convex-test";
|
|
168
|
+
import { register } from "@vllnt/convex-comments/test";
|
|
169
|
+
import schema from "./schema";
|
|
170
|
+
|
|
171
|
+
const t = convexTest(schema, import.meta.glob("./**/*.ts"));
|
|
172
|
+
register(t);
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Documentation
|
|
176
|
+
|
|
177
|
+
`llms.txt` is the maintained discovery index. `pnpm generate:llms` checks its
|
|
178
|
+
heading and local links without generating a source bundle.
|
|
179
|
+
|
|
180
|
+
[API reference](docs/API.md) · [LLM index](llms.txt) ·
|
|
181
|
+
[Security policy](SECURITY.md)
|
|
115
182
|
|
|
116
183
|
## Contributing
|
|
117
184
|
|
|
@@ -119,9 +186,11 @@ See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
|
119
186
|
|
|
120
187
|
## Author
|
|
121
188
|
|
|
122
|
-
Built by [bntvllnt](https://github.com/bntvllnt) ·
|
|
189
|
+
Built by [bntvllnt](https://github.com/bntvllnt) ·
|
|
190
|
+
[bntvllnt.com](https://bntvllnt.com) · [X @bntvllnt](https://x.com/bntvllnt)
|
|
123
191
|
|
|
124
|
-
Part of the [@vllnt](https://github.com/vllnt) Convex component fleet —
|
|
192
|
+
Part of the [@vllnt](https://github.com/vllnt) Convex component fleet —
|
|
193
|
+
[vllnt.com](https://vllnt.com)
|
|
125
194
|
|
|
126
195
|
If this is useful, [sponsor the work](https://github.com/sponsors/bntvllnt).
|
|
127
196
|
|
package/dist/component/crons.js
CHANGED
|
@@ -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,
|
|
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,gBAAgB,EAAE,cAAc,EAAE,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE;IACpE,KAAK,EAAE,WAAW;CACnB,CAAC,CAAC;AAEH,eAAe,KAAK,CAAC"}
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
* boundary. `parentId`, when given, threads this comment as a reply to an existing
|
|
8
8
|
* comment.
|
|
9
9
|
*
|
|
10
|
+
* @throws `ConvexError({ code: "INVALID_REF" })` when `resourceRef` or `authorRef` is
|
|
11
|
+
* empty — an empty author ref would make the comment editable by any caller that
|
|
12
|
+
* also passes an empty ref.
|
|
10
13
|
* @throws `ConvexError({ code: "PARENT_NOT_FOUND" })` when `parentId` names no
|
|
11
14
|
* comment.
|
|
12
15
|
* @throws `ConvexError({ code: "PARENT_MISMATCH" })` when the parent belongs to a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"AAMA
|
|
1
|
+
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,IAAI;;;;;;;GAiDf,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,IAAI;;;;iBAoCf,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM;;;iBA2BjB,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,OAAO;;;;iBAkClB,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,KAAK;;;;;mBA8DhB,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ConvexError, v } from "convex/values";
|
|
2
|
-
import { api } from "./_generated/api";
|
|
3
|
-
import { mutation } from "./_generated/server";
|
|
4
|
-
import { DEFAULT_RETENTION_MS } from "../shared";
|
|
5
|
-
import { jsonValue } from "./validators";
|
|
2
|
+
import { api } from "./_generated/api.js";
|
|
3
|
+
import { mutation } from "./_generated/server.js";
|
|
4
|
+
import { DEFAULT_RETENTION_MS } from "../shared.js";
|
|
5
|
+
import { jsonValue } from "./validators.js";
|
|
6
6
|
/**
|
|
7
7
|
* Post a comment on a resource and return its id. The comment is inserted `open`
|
|
8
8
|
* with `createdAt`/`updatedAt` stamped from the server clock (`Date.now()` inside
|
|
@@ -12,6 +12,9 @@ import { jsonValue } from "./validators";
|
|
|
12
12
|
* boundary. `parentId`, when given, threads this comment as a reply to an existing
|
|
13
13
|
* comment.
|
|
14
14
|
*
|
|
15
|
+
* @throws `ConvexError({ code: "INVALID_REF" })` when `resourceRef` or `authorRef` is
|
|
16
|
+
* empty — an empty author ref would make the comment editable by any caller that
|
|
17
|
+
* also passes an empty ref.
|
|
15
18
|
* @throws `ConvexError({ code: "PARENT_NOT_FOUND" })` when `parentId` names no
|
|
16
19
|
* comment.
|
|
17
20
|
* @throws `ConvexError({ code: "PARENT_MISMATCH" })` when the parent belongs to a
|
|
@@ -28,6 +31,12 @@ export const post = mutation({
|
|
|
28
31
|
},
|
|
29
32
|
returns: v.object({ commentId: v.id("comments") }),
|
|
30
33
|
handler: async (ctx, args) => {
|
|
34
|
+
if (args.resourceRef === "" || args.authorRef === "") {
|
|
35
|
+
throw new ConvexError({
|
|
36
|
+
code: "INVALID_REF",
|
|
37
|
+
message: "resourceRef and authorRef must be non-empty",
|
|
38
|
+
});
|
|
39
|
+
}
|
|
31
40
|
if (args.parentId !== undefined) {
|
|
32
41
|
const parent = await ctx.db.get("comments", args.parentId);
|
|
33
42
|
if (parent === null) {
|
|
@@ -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,
|
|
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,qBAAqB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,QAAQ,CAAC;IAC3B,IAAI,EAAE;QACJ,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;QACvB,SAAS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AE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;QACvE,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC3E,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;QAE9B,MAAM,cAAc,GAAG,CAAC,IAAI,CAAC,cAAc,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC;QAC5D,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE;gBACnD,MAAM;gBACN,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE,IAAI,CAAC,cAAc;gBAC3B,cAAc;aACf,CAAC,CAAC;QACL,CAAC;aAAM,IAAI,cAAc,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE;gBACnD,MAAM;gBACN,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE,IAAI;gBACZ,cAAc,EAAE,CAAC;aAClB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { v } from "convex/values";
|
|
2
2
|
import { paginationOptsValidator } from "convex/server";
|
|
3
|
-
import { query } from "./_generated/server";
|
|
4
|
-
import { commentView } from "./validators";
|
|
5
|
-
import { VISIBLE_STATUSES } from "../shared";
|
|
3
|
+
import { query } from "./_generated/server.js";
|
|
4
|
+
import { commentView } from "./validators.js";
|
|
5
|
+
import { VISIBLE_STATUSES } from "../shared.js";
|
|
6
6
|
/** Project a stored comment row to its public view (exposes the id as a string). */
|
|
7
7
|
function view(comment) {
|
|
8
8
|
return {
|
|
@@ -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,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,
|
|
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,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,oFAAoF;AACpF,SAAS,IAAI,CAAC,OAAwB;IACpC,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,GAAG;QACtB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC;AACJ,CAAC;AAED,wEAAwE;AACxE,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC;IACvB,IAAI,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE;IACrC,OA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Aa,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;aACtE,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;IAClE,CAAC;CACF,CAAC,CAAC"}
|
package/dist/component/schema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineSchema, defineTable } from "convex/server";
|
|
2
2
|
import { v } from "convex/values";
|
|
3
|
-
import { commentStatus, jsonValue } from "./validators";
|
|
3
|
+
import { commentStatus, jsonValue } from "./validators.js";
|
|
4
4
|
/**
|
|
5
5
|
* Sandboxed table — the comment tree's own concern. A comment is attached to an
|
|
6
6
|
* opaque host `resourceRef` (the thing being commented on) and authored by an
|
|
@@ -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,aAAa,EAAE,SAAS,EAAE,MAAM,
|
|
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,aAAa,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE3D;;;;;;;;;;;;;GAaG;AACH,eAAe,YAAY,CAAC;IAC1B,QAAQ,EAAE,WAAW,CAAC;QACpB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;QACvB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;QACrB,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;QACtC,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC3B,MAAM,EAAE,aAAa;QACrB,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAChC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;QACrB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;KACtB,CAAC;SACC,KAAK,CAAC,aAAa,EAAE,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;SAClD,KAAK,CAAC,oBAAoB,EAAE,CAAC,aAAa,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;SACrE,KAAK,CAAC,WAAW,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;SAC9C,KAAK,CAAC,mBAAmB,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;CACvD,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vllnt/convex-comments",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1-canary.1036f78",
|
|
4
4
|
"description": "Threaded comments / annotations on any resource — post, reply, edit, resolve, and soft-delete as a Convex component",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"packageManager": "pnpm@
|
|
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,16 @@
|
|
|
57
54
|
"devDependencies": {
|
|
58
55
|
"@edge-runtime/vm": "^5.0.0",
|
|
59
56
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
60
|
-
"@vitest/coverage-v8": "^
|
|
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.
|
|
64
|
-
"convex-test": "^0.0.
|
|
60
|
+
"convex": "^1.48.0",
|
|
61
|
+
"convex-test": "^0.0.65",
|
|
65
62
|
"eslint": "^9.39.5",
|
|
66
|
-
"prettier": "^3.9.
|
|
63
|
+
"prettier": "^3.9.10",
|
|
67
64
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
68
|
-
"vite": "^8.
|
|
69
|
-
"vitest": "^
|
|
65
|
+
"vite": "^8.3.5",
|
|
66
|
+
"vitest": "^5.0.5"
|
|
70
67
|
},
|
|
71
68
|
"homepage": "https://github.com/vllnt/convex-comments#readme",
|
|
72
69
|
"bugs": {
|
|
@@ -97,5 +94,18 @@
|
|
|
97
94
|
"comments",
|
|
98
95
|
"threads",
|
|
99
96
|
"annotations"
|
|
100
|
-
]
|
|
97
|
+
],
|
|
98
|
+
"pnpm": {
|
|
99
|
+
"minimumReleaseAge": 10080,
|
|
100
|
+
"minimumReleaseAgeExclude": [
|
|
101
|
+
"@vllnt/*"
|
|
102
|
+
],
|
|
103
|
+
"ignoredBuiltDependencies": [
|
|
104
|
+
"esbuild"
|
|
105
|
+
],
|
|
106
|
+
"overrides": {
|
|
107
|
+
"deepmerge-ts@<8.0.0": "8.0.2",
|
|
108
|
+
"handlebars@<4.7.10": "4.7.10"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
101
111
|
}
|
package/src/component/crons.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ConvexError, v } from "convex/values";
|
|
2
|
-
import { api } from "./_generated/api";
|
|
3
|
-
import { mutation } from "./_generated/server";
|
|
4
|
-
import { DEFAULT_RETENTION_MS } from "../shared";
|
|
5
|
-
import { jsonValue } from "./validators";
|
|
2
|
+
import { api } from "./_generated/api.js";
|
|
3
|
+
import { mutation } from "./_generated/server.js";
|
|
4
|
+
import { DEFAULT_RETENTION_MS } from "../shared.js";
|
|
5
|
+
import { jsonValue } from "./validators.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Post a comment on a resource and return its id. The comment is inserted `open`
|
|
@@ -13,6 +13,9 @@ import { jsonValue } from "./validators";
|
|
|
13
13
|
* boundary. `parentId`, when given, threads this comment as a reply to an existing
|
|
14
14
|
* comment.
|
|
15
15
|
*
|
|
16
|
+
* @throws `ConvexError({ code: "INVALID_REF" })` when `resourceRef` or `authorRef` is
|
|
17
|
+
* empty — an empty author ref would make the comment editable by any caller that
|
|
18
|
+
* also passes an empty ref.
|
|
16
19
|
* @throws `ConvexError({ code: "PARENT_NOT_FOUND" })` when `parentId` names no
|
|
17
20
|
* comment.
|
|
18
21
|
* @throws `ConvexError({ code: "PARENT_MISMATCH" })` when the parent belongs to a
|
|
@@ -29,6 +32,12 @@ export const post = mutation({
|
|
|
29
32
|
},
|
|
30
33
|
returns: v.object({ commentId: v.id("comments") }),
|
|
31
34
|
handler: async (ctx, args) => {
|
|
35
|
+
if (args.resourceRef === "" || args.authorRef === "") {
|
|
36
|
+
throw new ConvexError({
|
|
37
|
+
code: "INVALID_REF",
|
|
38
|
+
message: "resourceRef and authorRef must be non-empty",
|
|
39
|
+
});
|
|
40
|
+
}
|
|
32
41
|
if (args.parentId !== undefined) {
|
|
33
42
|
const parent = await ctx.db.get("comments", args.parentId);
|
|
34
43
|
if (parent === null) {
|
package/src/component/queries.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { v } from "convex/values";
|
|
2
2
|
import { paginationOptsValidator } from "convex/server";
|
|
3
|
-
import { query } from "./_generated/server";
|
|
4
|
-
import { commentView } from "./validators";
|
|
5
|
-
import { VISIBLE_STATUSES } from "../shared";
|
|
6
|
-
import type { Doc } from "./_generated/dataModel";
|
|
3
|
+
import { query } from "./_generated/server.js";
|
|
4
|
+
import { commentView } from "./validators.js";
|
|
5
|
+
import { VISIBLE_STATUSES } from "../shared.js";
|
|
6
|
+
import type { Doc } from "./_generated/dataModel.js";
|
|
7
7
|
|
|
8
8
|
/** Project a stored comment row to its public view (exposes the id as a string). */
|
|
9
9
|
function view(comment: Doc<"comments">) {
|
package/src/component/schema.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineSchema, defineTable } from "convex/server";
|
|
2
2
|
import { v } from "convex/values";
|
|
3
|
-
import { commentStatus, jsonValue } from "./validators";
|
|
3
|
+
import { commentStatus, jsonValue } from "./validators.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Sandboxed table — the comment tree's own concern. A comment is attached to an
|