@vllnt/convex-comments 0.1.0-canary.3e5064a
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/LICENSE +21 -0
- package/README.md +130 -0
- package/dist/client/index.d.ts +146 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +133 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/types.d.ts +51 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +3 -0
- package/dist/client/types.js.map +1 -0
- package/dist/component/_generated/api.d.ts +40 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +31 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +98 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +121 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +78 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/convex.config.d.ts +3 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +7 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/crons.d.ts +16 -0
- package/dist/component/crons.d.ts.map +1 -0
- package/dist/component/crons.js +19 -0
- package/dist/component/crons.js.map +1 -0
- package/dist/component/mutations.d.ts +81 -0
- package/dist/component/mutations.d.ts.map +1 -0
- package/dist/component/mutations.js +223 -0
- package/dist/component/mutations.js.map +1 -0
- package/dist/component/queries.d.ts +61 -0
- package/dist/component/queries.d.ts.map +1 -0
- package/dist/component/queries.js +82 -0
- package/dist/component/queries.js.map +1 -0
- package/dist/component/schema.d.ts +42 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +34 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/validators.d.ts +46 -0
- package/dist/component/validators.d.ts.map +1 -0
- package/dist/component/validators.js +37 -0
- package/dist/component/validators.js.map +1 -0
- package/dist/shared.d.ts +25 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +26 -0
- package/dist/shared.js.map +1 -0
- package/package.json +98 -0
- package/src/client/index.ts +299 -0
- package/src/client/types.ts +55 -0
- package/src/component/_generated/api.ts +56 -0
- package/src/component/_generated/component.ts +129 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +156 -0
- package/src/component/convex.config.ts +9 -0
- package/src/component/crons.ts +23 -0
- package/src/component/mutations.ts +234 -0
- package/src/component/queries.ts +96 -0
- package/src/component/schema.ts +34 -0
- package/src/component/validators.ts +44 -0
- package/src/shared.ts +33 -0
- package/src/test.ts +15 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 bntvllnt
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
<!-- Badges -->
|
|
2
|
+
[](https://www.convex.dev/components)
|
|
3
|
+
[](https://www.npmjs.com/package/@vllnt/convex-comments)
|
|
4
|
+
[](https://github.com/vllnt/convex-comments/actions/workflows/ci.yml)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
|
|
7
|
+
# @vllnt/convex-comments
|
|
8
|
+
|
|
9
|
+
Threaded comments / annotations on any resource, as a Convex component.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
const comments = new Comments(components.comments);
|
|
13
|
+
await comments.post(ctx, resourceRef, authorRef, body, parentId); // parentId threads a reply
|
|
14
|
+
await comments.list(ctx, resourceRef, paginationOpts); // reactive thread
|
|
15
|
+
await comments.resolve(ctx, commentId, authorRef); // author-gated
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
A host attaches a comment to an opaque `resourceRef` (an article, a doc, a clip — anything); replies
|
|
19
|
+
thread under a parent; the author edits, resolves, and soft-deletes their own comments; clients page a
|
|
20
|
+
resource's thread or subscribe reactively.
|
|
21
|
+
|
|
22
|
+
## Features
|
|
23
|
+
|
|
24
|
+
- **Post on any resource** — `post(resourceRef, authorRef, body, parentId?)` inserts an `open` comment; `parentId` threads it as a reply.
|
|
25
|
+
- **Author-gated edits** — `edit`, `remove` (soft-delete), and `resolve` require the original `authorRef`, else `NOT_AUTHOR`.
|
|
26
|
+
- **Threaded** — a reply links to a parent on the same resource (cross-resource or deleted parent rejected); `list(..., { parentId })` pages direct replies.
|
|
27
|
+
- **Soft-delete + retention** — `remove` keeps the row and replies but marks it `deleted` and clears the body; a daily cron prunes deleted rows past retention.
|
|
28
|
+
- **Page or subscribe** — `list` pages oldest-first (deleted excluded by default), `count` tallies visible ones. Reactive in a Convex query.
|
|
29
|
+
- **Server-sourced time** — `createdAt`/`updatedAt`/`editedAt` are stamped from the server clock; a caller can't supply a timestamp.
|
|
30
|
+
- **Typed, opaque body** — `Comments<TBody>` types the stored `body`; `bodyValidator` narrows plain text vs rich blocks at the boundary.
|
|
31
|
+
- **Mount-safe** — correct under multiple named `app.use` mounts (e.g. a `comments` mount + an `annotations` mount); each is an isolated sandbox.
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pnpm add @vllnt/convex-comments
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Peer dependency: `convex@^1.41.0`.
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
// convex/convex.config.ts
|
|
45
|
+
import { defineApp } from "convex/server";
|
|
46
|
+
import comments from "@vllnt/convex-comments/convex.config";
|
|
47
|
+
|
|
48
|
+
const app = defineApp();
|
|
49
|
+
app.use(comments);
|
|
50
|
+
export default app;
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
// convex/comments.ts — host owns auth; resolve identity, pass opaque refs in.
|
|
55
|
+
import { components } from "./_generated/api";
|
|
56
|
+
import { mutation, query } from "./_generated/server";
|
|
57
|
+
import { paginationOptsValidator } from "convex/server";
|
|
58
|
+
import { v } from "convex/values";
|
|
59
|
+
import { Comments } from "@vllnt/convex-comments";
|
|
60
|
+
|
|
61
|
+
const comments = new Comments<string>(components.comments, {
|
|
62
|
+
bodyValidator: v.string().parse, // narrow at the boundary (plain text here)
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export const postComment = mutation({
|
|
66
|
+
args: { resourceRef: v.string(), body: v.string(), parentId: v.optional(v.string()) },
|
|
67
|
+
handler: async (ctx, { resourceRef, body, parentId }) => {
|
|
68
|
+
const authorRef = await requireUser(ctx); // host auth
|
|
69
|
+
return comments.post(ctx, resourceRef, authorRef, body, parentId);
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
export const listComments = query({
|
|
74
|
+
args: { resourceRef: v.string(), paginationOpts: paginationOptsValidator },
|
|
75
|
+
handler: (ctx, { resourceRef, paginationOpts }) =>
|
|
76
|
+
comments.list(ctx, resourceRef, paginationOpts),
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## API Reference
|
|
81
|
+
|
|
82
|
+
| Method | Kind | Result |
|
|
83
|
+
|--------|------|--------|
|
|
84
|
+
| `post(ctx, resourceRef, authorRef, body, parentId?)` | mutation | `{ commentId }` |
|
|
85
|
+
| `edit(ctx, commentId, authorRef, body)` | mutation | `null` (author-gated) |
|
|
86
|
+
| `remove(ctx, commentId, authorRef)` | mutation | `null` (soft-delete, author-gated) |
|
|
87
|
+
| `resolve(ctx, commentId, authorRef, resolved?)` | mutation | `null` (toggle, author-gated; `resolved` defaults `true`) |
|
|
88
|
+
| `get(ctx, commentId)` | query | `CommentView \| null` |
|
|
89
|
+
| `list(ctx, resourceRef, paginationOpts, opts?)` | query | `PaginationResult<CommentView>` (`opts`: `{ parentId?; includeDeleted? }`) |
|
|
90
|
+
| `count(ctx, resourceRef)` | query | `number` (visible comments) |
|
|
91
|
+
| `prune(ctx, opts?)` | mutation | `number` (deleted comments removed in the first bounded pass) |
|
|
92
|
+
|
|
93
|
+
Full reference: [docs/API.md](docs/API.md).
|
|
94
|
+
|
|
95
|
+
## React
|
|
96
|
+
|
|
97
|
+
Backend-only — no `./react` entry. A comment thread is an ordinary reactive `useQuery` / `usePaginatedQuery` over the host's own re-exported `list` / `count` refs.
|
|
98
|
+
|
|
99
|
+
## Security
|
|
100
|
+
|
|
101
|
+
- Auth-agnostic for access; the component enforces only **authorship** (`edit`/`remove`/`resolve` require the original `authorRef`). The host owns who may post or moderate.
|
|
102
|
+
- Tables sandboxed — reached only through the exported functions; never touches host or sibling tables.
|
|
103
|
+
- Server-sourced time; `resourceRef` / `authorRef` / `body` stay opaque to the component.
|
|
104
|
+
|
|
105
|
+
See [docs/API.md](docs/API.md).
|
|
106
|
+
|
|
107
|
+
## Testing
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
pnpm test # single run
|
|
111
|
+
pnpm test:coverage # enforced 100% on covered files
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Tests run against the real component runtime via `convex-test` (`@edge-runtime/vm`), not mocks.
|
|
115
|
+
|
|
116
|
+
## Contributing
|
|
117
|
+
|
|
118
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
119
|
+
|
|
120
|
+
## Author
|
|
121
|
+
|
|
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)
|
|
125
|
+
|
|
126
|
+
If this is useful, [sponsor the work](https://github.com/sponsors/bntvllnt).
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type { FunctionArgs, FunctionReference, FunctionReturnType, PaginationOptions, PaginationResult } from "convex/server";
|
|
2
|
+
import type { CommentStatus, CommentView, CommentsOptions, ListOptions, Parser } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* The component's raw comment view, before the client narrows the opaque host
|
|
5
|
+
* body. `body` is `unknown` here; the {@link Comments} client runs the host
|
|
6
|
+
* validator over it at its typed boundary.
|
|
7
|
+
*/
|
|
8
|
+
type RawView = {
|
|
9
|
+
commentId: string;
|
|
10
|
+
resourceRef: string;
|
|
11
|
+
authorRef: string;
|
|
12
|
+
parentId?: string;
|
|
13
|
+
body?: unknown;
|
|
14
|
+
status: CommentStatus;
|
|
15
|
+
editedAt?: number;
|
|
16
|
+
createdAt: number;
|
|
17
|
+
updatedAt: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The comments component's function references, as exposed on the host via
|
|
21
|
+
* `components.comments`. The host's stored `body` is opaque here (`unknown`); the
|
|
22
|
+
* {@link Comments} client narrows it at its own typed boundary.
|
|
23
|
+
*/
|
|
24
|
+
export interface CommentsComponent {
|
|
25
|
+
mutations: {
|
|
26
|
+
post: FunctionReference<"mutation", "internal", {
|
|
27
|
+
resourceRef: string;
|
|
28
|
+
authorRef: string;
|
|
29
|
+
body: unknown;
|
|
30
|
+
parentId?: string;
|
|
31
|
+
}, {
|
|
32
|
+
commentId: string;
|
|
33
|
+
}>;
|
|
34
|
+
edit: FunctionReference<"mutation", "internal", {
|
|
35
|
+
commentId: string;
|
|
36
|
+
authorRef: string;
|
|
37
|
+
body: unknown;
|
|
38
|
+
}, null>;
|
|
39
|
+
remove: FunctionReference<"mutation", "internal", {
|
|
40
|
+
commentId: string;
|
|
41
|
+
authorRef: string;
|
|
42
|
+
}, null>;
|
|
43
|
+
resolve: FunctionReference<"mutation", "internal", {
|
|
44
|
+
commentId: string;
|
|
45
|
+
authorRef: string;
|
|
46
|
+
resolved: boolean;
|
|
47
|
+
}, null>;
|
|
48
|
+
prune: FunctionReference<"mutation", "internal", {
|
|
49
|
+
before?: number;
|
|
50
|
+
batch: number;
|
|
51
|
+
}, number>;
|
|
52
|
+
};
|
|
53
|
+
queries: {
|
|
54
|
+
get: FunctionReference<"query", "internal", {
|
|
55
|
+
commentId: string;
|
|
56
|
+
}, RawView | null>;
|
|
57
|
+
list: FunctionReference<"query", "internal", {
|
|
58
|
+
resourceRef: string;
|
|
59
|
+
parentId?: string;
|
|
60
|
+
includeDeleted?: boolean;
|
|
61
|
+
paginationOpts: PaginationOptions;
|
|
62
|
+
}, PaginationResult<RawView>>;
|
|
63
|
+
count: FunctionReference<"query", "internal", {
|
|
64
|
+
resourceRef: string;
|
|
65
|
+
}, number>;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
interface RunQueryCtx {
|
|
69
|
+
runQuery<Q extends FunctionReference<"query", "internal">>(reference: Q, args: FunctionArgs<Q>): Promise<FunctionReturnType<Q>>;
|
|
70
|
+
}
|
|
71
|
+
interface RunMutationCtx {
|
|
72
|
+
runMutation<M extends FunctionReference<"mutation", "internal">>(reference: M, args: FunctionArgs<M>): Promise<FunctionReturnType<M>>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Consumer-facing client for threaded comments / annotations on any resource. A
|
|
76
|
+
* host mutation calls `post(resourceRef, authorRef, body, parentId?)` to attach a
|
|
77
|
+
* comment to an opaque resource; `edit` / `remove` / `resolve` mutate it
|
|
78
|
+
* (author-gated by the component); `list` pages a resource's thread and `count`
|
|
79
|
+
* tallies it. The host owns meaning and auth — it resolves identity, decides
|
|
80
|
+
* access, and passes opaque `resourceRef` / `authorRef`. The body is opaque host
|
|
81
|
+
* data the component stores without inspecting; pass `bodyValidator` to narrow it
|
|
82
|
+
* to `TBody` at the boundary (plain text vs rich blocks — the host decides).
|
|
83
|
+
*
|
|
84
|
+
* @typeParam TBody - The host's comment body type (defaults to `unknown`).
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* const comments = new Comments(components.comments, {
|
|
89
|
+
* bodyValidator: v.string().parse,
|
|
90
|
+
* });
|
|
91
|
+
* const { commentId } = await comments.post(ctx, "post:42", "user:7", "hello");
|
|
92
|
+
* const reply = await comments.post(ctx, "post:42", "user:9", "hi", commentId);
|
|
93
|
+
* const thread = await comments.list(ctx, "post:42", { cursor: null, numItems: 50 });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare class Comments<TBody = unknown> {
|
|
97
|
+
private readonly component;
|
|
98
|
+
private readonly bodyValidator;
|
|
99
|
+
constructor(component: CommentsComponent, options?: CommentsOptions<TBody>);
|
|
100
|
+
/** Narrow an opaque value through the host parser; pass `undefined` and an unset parser through. */
|
|
101
|
+
private parse;
|
|
102
|
+
/** Project a raw component view into the typed, validated client view. */
|
|
103
|
+
private view;
|
|
104
|
+
/**
|
|
105
|
+
* Post a comment on `resourceRef` authored by `authorRef` and return its id.
|
|
106
|
+
* `body` is opaque host data validated against `bodyValidator` before storage.
|
|
107
|
+
* `parentId`, when given, threads the comment as a reply. The comment starts
|
|
108
|
+
* `open`.
|
|
109
|
+
*/
|
|
110
|
+
post(ctx: RunMutationCtx, resourceRef: string, authorRef: string, body: TBody, parentId?: string): Promise<{
|
|
111
|
+
commentId: string;
|
|
112
|
+
}>;
|
|
113
|
+
/**
|
|
114
|
+
* Edit a comment's body. The component rejects a non-author caller and a
|
|
115
|
+
* soft-deleted comment. `body` is validated against `bodyValidator` before
|
|
116
|
+
* storage.
|
|
117
|
+
*/
|
|
118
|
+
edit(ctx: RunMutationCtx, commentId: string, authorRef: string, body: TBody): Promise<null>;
|
|
119
|
+
/** Soft-delete a comment (author-gated by the component); replies are preserved. */
|
|
120
|
+
remove(ctx: RunMutationCtx, commentId: string, authorRef: string): Promise<null>;
|
|
121
|
+
/** Toggle a comment's resolved state (author-gated); `resolved` defaults to `true`. */
|
|
122
|
+
resolve(ctx: RunMutationCtx, commentId: string, authorRef: string, resolved?: boolean): Promise<null>;
|
|
123
|
+
/** The current view of `commentId`, or `null` if no such comment is held. */
|
|
124
|
+
get(ctx: RunQueryCtx, commentId: string): Promise<CommentView<TBody> | null>;
|
|
125
|
+
/**
|
|
126
|
+
* Page a resource's comments oldest first. By default pages the resource's
|
|
127
|
+
* top level (excluding soft-deleted); pass `opts.parentId` to page one
|
|
128
|
+
* comment's replies, or `opts.includeDeleted` to include removed comments.
|
|
129
|
+
* Returns the standard Convex pagination envelope with each row narrowed.
|
|
130
|
+
*/
|
|
131
|
+
list(ctx: RunQueryCtx, resourceRef: string, paginationOpts: PaginationOptions, opts?: ListOptions): Promise<PaginationResult<CommentView<TBody>>>;
|
|
132
|
+
/** Count the visible (non-deleted) comments on `resourceRef`. */
|
|
133
|
+
count(ctx: RunQueryCtx, resourceRef: string): Promise<number>;
|
|
134
|
+
/**
|
|
135
|
+
* Delete soft-deleted comments whose `updatedAt < before` in bounded batches,
|
|
136
|
+
* oldest first. `before` defaults to the server clock; `batch` caps each pass
|
|
137
|
+
* and the sweep self-reschedules until the tail is clean. Returns the count
|
|
138
|
+
* removed in the first pass. The built-in daily cron drives this automatically.
|
|
139
|
+
*/
|
|
140
|
+
prune(ctx: RunMutationCtx, opts?: {
|
|
141
|
+
before?: number;
|
|
142
|
+
batch?: number;
|
|
143
|
+
}): Promise<number>;
|
|
144
|
+
}
|
|
145
|
+
export type { CommentStatus, CommentView, CommentsOptions, ListOptions, Parser, };
|
|
146
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,EAClB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,eAAe,EACf,WAAW,EACX,MAAM,EACP,MAAM,YAAY,CAAC;AAGpB;;;;GAIG;AACH,KAAK,OAAO,GAAG;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,aAAa,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;GAI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MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,KAAK,GACV,OAAO,CAAC,IAAI,CAAC;IAQhB,oFAAoF;IACpF,MAAM,CACJ,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC;IAOhB,uFAAuF;IACvF,OAAO,CACL,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,QAAQ,UAAO,GACd,OAAO,CAAC,IAAI,CAAC;IAQhB,6EAA6E;IACvE,GAAG,CACP,GAAG,EAAE,WAAW,EAChB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAKrC;;;;;OAKG;IACG,IAAI,CACR,GAAG,EAAE,WAAW,EAChB,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,iBAAiB,EACjC,IAAI,GAAE,WAAgB,GACrB,OAAO,CAAC,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;IAUhD,iEAAiE;IACjE,KAAK,CAAC,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI7D;;;;;OAKG;IACH,KAAK,CACH,GAAG,EAAE,cAAc,EACnB,IAAI,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO,GAC7C,OAAO,CAAC,MAAM,CAAC;CAMnB;AAED,YAAY,EACV,aAAa,EACb,WAAW,EACX,eAAe,EACf,WAAW,EACX,MAAM,GACP,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { DEFAULT_PRUNE_BATCH } from "../shared.js";
|
|
2
|
+
/**
|
|
3
|
+
* Consumer-facing client for threaded comments / annotations on any resource. A
|
|
4
|
+
* host mutation calls `post(resourceRef, authorRef, body, parentId?)` to attach a
|
|
5
|
+
* comment to an opaque resource; `edit` / `remove` / `resolve` mutate it
|
|
6
|
+
* (author-gated by the component); `list` pages a resource's thread and `count`
|
|
7
|
+
* tallies it. The host owns meaning and auth — it resolves identity, decides
|
|
8
|
+
* access, and passes opaque `resourceRef` / `authorRef`. The body is opaque host
|
|
9
|
+
* data the component stores without inspecting; pass `bodyValidator` to narrow it
|
|
10
|
+
* to `TBody` at the boundary (plain text vs rich blocks — the host decides).
|
|
11
|
+
*
|
|
12
|
+
* @typeParam TBody - The host's comment body type (defaults to `unknown`).
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const comments = new Comments(components.comments, {
|
|
17
|
+
* bodyValidator: v.string().parse,
|
|
18
|
+
* });
|
|
19
|
+
* const { commentId } = await comments.post(ctx, "post:42", "user:7", "hello");
|
|
20
|
+
* const reply = await comments.post(ctx, "post:42", "user:9", "hi", commentId);
|
|
21
|
+
* const thread = await comments.list(ctx, "post:42", { cursor: null, numItems: 50 });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export class Comments {
|
|
25
|
+
component;
|
|
26
|
+
bodyValidator;
|
|
27
|
+
constructor(component, options = {}) {
|
|
28
|
+
this.component = component;
|
|
29
|
+
this.bodyValidator = options.bodyValidator;
|
|
30
|
+
}
|
|
31
|
+
/** Narrow an opaque value through the host parser; pass `undefined` and an unset parser through. */
|
|
32
|
+
parse(value) {
|
|
33
|
+
if (value === undefined) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
if (this.bodyValidator === undefined) {
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
return this.bodyValidator(value);
|
|
40
|
+
}
|
|
41
|
+
/** Project a raw component view into the typed, validated client view. */
|
|
42
|
+
view(raw) {
|
|
43
|
+
return {
|
|
44
|
+
commentId: raw.commentId,
|
|
45
|
+
resourceRef: raw.resourceRef,
|
|
46
|
+
authorRef: raw.authorRef,
|
|
47
|
+
parentId: raw.parentId,
|
|
48
|
+
body: this.parse(raw.body),
|
|
49
|
+
status: raw.status,
|
|
50
|
+
editedAt: raw.editedAt,
|
|
51
|
+
createdAt: raw.createdAt,
|
|
52
|
+
updatedAt: raw.updatedAt,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Post a comment on `resourceRef` authored by `authorRef` and return its id.
|
|
57
|
+
* `body` is opaque host data validated against `bodyValidator` before storage.
|
|
58
|
+
* `parentId`, when given, threads the comment as a reply. The comment starts
|
|
59
|
+
* `open`.
|
|
60
|
+
*/
|
|
61
|
+
async post(ctx, resourceRef, authorRef, body, parentId) {
|
|
62
|
+
return ctx.runMutation(this.component.mutations.post, {
|
|
63
|
+
resourceRef,
|
|
64
|
+
authorRef,
|
|
65
|
+
body: this.parse(body),
|
|
66
|
+
parentId,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Edit a comment's body. The component rejects a non-author caller and a
|
|
71
|
+
* soft-deleted comment. `body` is validated against `bodyValidator` before
|
|
72
|
+
* storage.
|
|
73
|
+
*/
|
|
74
|
+
edit(ctx, commentId, authorRef, body) {
|
|
75
|
+
return ctx.runMutation(this.component.mutations.edit, {
|
|
76
|
+
commentId,
|
|
77
|
+
authorRef,
|
|
78
|
+
body: this.parse(body),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/** Soft-delete a comment (author-gated by the component); replies are preserved. */
|
|
82
|
+
remove(ctx, commentId, authorRef) {
|
|
83
|
+
return ctx.runMutation(this.component.mutations.remove, {
|
|
84
|
+
commentId,
|
|
85
|
+
authorRef,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/** Toggle a comment's resolved state (author-gated); `resolved` defaults to `true`. */
|
|
89
|
+
resolve(ctx, commentId, authorRef, resolved = true) {
|
|
90
|
+
return ctx.runMutation(this.component.mutations.resolve, {
|
|
91
|
+
commentId,
|
|
92
|
+
authorRef,
|
|
93
|
+
resolved,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/** The current view of `commentId`, or `null` if no such comment is held. */
|
|
97
|
+
async get(ctx, commentId) {
|
|
98
|
+
const raw = await ctx.runQuery(this.component.queries.get, { commentId });
|
|
99
|
+
return raw === null ? null : this.view(raw);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Page a resource's comments oldest first. By default pages the resource's
|
|
103
|
+
* top level (excluding soft-deleted); pass `opts.parentId` to page one
|
|
104
|
+
* comment's replies, or `opts.includeDeleted` to include removed comments.
|
|
105
|
+
* Returns the standard Convex pagination envelope with each row narrowed.
|
|
106
|
+
*/
|
|
107
|
+
async list(ctx, resourceRef, paginationOpts, opts = {}) {
|
|
108
|
+
const result = await ctx.runQuery(this.component.queries.list, {
|
|
109
|
+
resourceRef,
|
|
110
|
+
parentId: opts.parentId,
|
|
111
|
+
includeDeleted: opts.includeDeleted,
|
|
112
|
+
paginationOpts,
|
|
113
|
+
});
|
|
114
|
+
return { ...result, page: result.page.map((raw) => this.view(raw)) };
|
|
115
|
+
}
|
|
116
|
+
/** Count the visible (non-deleted) comments on `resourceRef`. */
|
|
117
|
+
count(ctx, resourceRef) {
|
|
118
|
+
return ctx.runQuery(this.component.queries.count, { resourceRef });
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Delete soft-deleted comments whose `updatedAt < before` in bounded batches,
|
|
122
|
+
* oldest first. `before` defaults to the server clock; `batch` caps each pass
|
|
123
|
+
* and the sweep self-reschedules until the tail is clean. Returns the count
|
|
124
|
+
* removed in the first pass. The built-in daily cron drives this automatically.
|
|
125
|
+
*/
|
|
126
|
+
prune(ctx, opts = {}) {
|
|
127
|
+
return ctx.runMutation(this.component.mutations.prune, {
|
|
128
|
+
before: opts.before,
|
|
129
|
+
batch: opts.batch ?? DEFAULT_PRUNE_BATCH,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=index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GAAgB,EAChB,WAAmB,EACnB,cAAiC,EACjC,OAAoB,EAAE;QAEtB,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE;YAC7D,WAAW;YACX,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,cAAc;SACf,CAAC,CAAC;QACH,OAAO,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;IACvE,CAAC;IAED,iEAAiE;IACjE,KAAK,CAAC,GAAgB,EAAE,WAAmB;QACzC,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACH,KAAK,CACH,GAAmB,EACnB,OAA4C,EAAE;QAE9C,OAAO,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,EAAE;YACrD,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,mBAAmB;SACzC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** Public TypeScript surface for the comments client. */
|
|
2
|
+
/** The three lifecycle statuses a comment moves through. */
|
|
3
|
+
export type CommentStatus = "open" | "resolved" | "deleted";
|
|
4
|
+
/**
|
|
5
|
+
* Validates and narrows an opaque stored comment `body` to a host type `T` at the
|
|
6
|
+
* client boundary. Receives the raw value the component returned (`unknown`) and
|
|
7
|
+
* MUST return a typed `T` or throw. A `convex/values` validator's `.parse` (or a
|
|
8
|
+
* Zod `.parse`) fits directly; omit it to keep the value unvalidated.
|
|
9
|
+
*
|
|
10
|
+
* @typeParam T - The host's stored comment body type.
|
|
11
|
+
*/
|
|
12
|
+
export type Parser<T> = (value: unknown) => T;
|
|
13
|
+
/** The public view returned by {@link Comments.get} / {@link Comments.list}. */
|
|
14
|
+
export interface CommentView<TBody = unknown> {
|
|
15
|
+
/** The component-assigned opaque id naming this comment. */
|
|
16
|
+
commentId: string;
|
|
17
|
+
/** The host-supplied ref of the resource this comment is attached to. */
|
|
18
|
+
resourceRef: string;
|
|
19
|
+
/** The host-supplied ref of the comment's author. */
|
|
20
|
+
authorRef: string;
|
|
21
|
+
/** The opaque id of the comment this one replies to, when threaded. */
|
|
22
|
+
parentId?: string;
|
|
23
|
+
/** The opaque host body (narrowed if a `bodyValidator` is set); absent once deleted. */
|
|
24
|
+
body?: TBody;
|
|
25
|
+
/** The current lifecycle status. */
|
|
26
|
+
status: CommentStatus;
|
|
27
|
+
/** Absolute ms timestamp of the last body edit, if any. */
|
|
28
|
+
editedAt?: number;
|
|
29
|
+
/** Absolute ms timestamp the comment was posted. */
|
|
30
|
+
createdAt: number;
|
|
31
|
+
/** Absolute ms timestamp of the last write (edit, resolve, or delete). */
|
|
32
|
+
updatedAt: number;
|
|
33
|
+
}
|
|
34
|
+
/** Per-call options for {@link Comments.list}. */
|
|
35
|
+
export interface ListOptions {
|
|
36
|
+
/** Page one parent comment's direct replies instead of the resource's top level. */
|
|
37
|
+
parentId?: string;
|
|
38
|
+
/** Include soft-deleted comments in the page (excluded by default). */
|
|
39
|
+
includeDeleted?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/** Construction options for the {@link Comments} client. */
|
|
42
|
+
export interface CommentsOptions<TBody> {
|
|
43
|
+
/**
|
|
44
|
+
* Validates/narrows a stored comment `body` to `TBody` at the boundary — applied
|
|
45
|
+
* to the `body` passed into `post` / `edit` (before storage) and the `body`
|
|
46
|
+
* returned by `get` / `list`. Throws on a mismatch. Omit to leave bodies
|
|
47
|
+
* unvalidated (plain text needs no validator; rich-block hosts pass their schema).
|
|
48
|
+
*/
|
|
49
|
+
bodyValidator?: Parser<TBody>;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,yDAAyD;AAEzD,4DAA4D;AAC5D,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC,CAAC;AAE9C,gFAAgF;AAChF,MAAM,WAAW,WAAW,CAAC,KAAK,GAAG,OAAO;IAC1C,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wFAAwF;IACxF,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,oCAAoC;IACpC,MAAM,EAAE,aAAa,CAAC;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B,oFAAoF;IACpF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,4DAA4D;AAC5D,MAAM,WAAW,eAAe,CAAC,KAAK;IACpC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,yDAAyD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated `api` utility.
|
|
3
|
+
*
|
|
4
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
5
|
+
*
|
|
6
|
+
* To regenerate, run `npx convex dev`.
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type * as crons from "../crons.js";
|
|
10
|
+
import type * as mutations from "../mutations.js";
|
|
11
|
+
import type * as queries from "../queries.js";
|
|
12
|
+
import type * as validators from "../validators.js";
|
|
13
|
+
import type { ApiFromModules, FilterApi, FunctionReference } from "convex/server";
|
|
14
|
+
declare const fullApi: ApiFromModules<{
|
|
15
|
+
crons: typeof crons;
|
|
16
|
+
mutations: typeof mutations;
|
|
17
|
+
queries: typeof queries;
|
|
18
|
+
validators: typeof validators;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* A utility for referencing Convex functions in your app's public API.
|
|
22
|
+
*
|
|
23
|
+
* Usage:
|
|
24
|
+
* ```js
|
|
25
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const api: FilterApi<typeof fullApi, FunctionReference<any, "public">>;
|
|
29
|
+
/**
|
|
30
|
+
* A utility for referencing Convex functions in your app's internal API.
|
|
31
|
+
*
|
|
32
|
+
* Usage:
|
|
33
|
+
* ```js
|
|
34
|
+
* const myFunctionReference = internal.myModule.myFunction;
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare const internal: FilterApi<typeof fullApi, FunctionReference<any, "internal">>;
|
|
38
|
+
export declare const components: {};
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAC1C,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,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,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"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated `api` utility.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { anyApi, componentsGeneric } from "convex/server";
|
|
11
|
+
const fullApi = anyApi;
|
|
12
|
+
/**
|
|
13
|
+
* A utility for referencing Convex functions in your app's public API.
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* ```js
|
|
17
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export const api = anyApi;
|
|
21
|
+
/**
|
|
22
|
+
* A utility for referencing Convex functions in your app's internal API.
|
|
23
|
+
*
|
|
24
|
+
* Usage:
|
|
25
|
+
* ```js
|
|
26
|
+
* const myFunctionReference = internal.myModule.myFunction;
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export const internal = anyApi;
|
|
30
|
+
export const components = componentsGeneric();
|
|
31
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|