@voltro/plugin-comments 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9987 -0
- package/LICENSE +61 -0
- package/README.md +26 -0
- package/SECURITY.md +56 -0
- package/THIRD-PARTY-NOTICES.md +627 -0
- package/dist/errors.d.ts +40 -0
- package/dist/errors.js +8 -0
- package/dist/index.d.ts +161 -0
- package/dist/index.js +364 -0
- package/dist/rpc.d.ts +129 -0
- package/dist/rpc.js +161 -0
- package/dist/web.d.ts +60 -0
- package/dist/web.js +35 -0
- package/package.json +62 -0
package/dist/rpc.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { CommentAccessRefused as e, CommentNotFound as t, CommentNotYours as n } from "./errors.js";
|
|
2
|
+
import { Schema as r } from "effect";
|
|
3
|
+
import { defineMutation as i, defineQuery as a, reactivityChannel as o } from "@voltro/protocol";
|
|
4
|
+
//#region src/rpc.ts
|
|
5
|
+
var s = o("comments"), c = r.Struct({
|
|
6
|
+
id: r.String,
|
|
7
|
+
threadId: r.String,
|
|
8
|
+
body: r.String,
|
|
9
|
+
authorSubjectId: r.String,
|
|
10
|
+
mentions: r.Array(r.String),
|
|
11
|
+
editedAt: r.NullOr(r.String),
|
|
12
|
+
createdAt: r.String,
|
|
13
|
+
reactions: r.Array(r.Struct({
|
|
14
|
+
emoji: r.String,
|
|
15
|
+
count: r.Number,
|
|
16
|
+
mine: r.Boolean
|
|
17
|
+
}))
|
|
18
|
+
}), l = r.Struct({
|
|
19
|
+
id: r.String,
|
|
20
|
+
anchor: r.String,
|
|
21
|
+
status: r.Literal("open", "resolved"),
|
|
22
|
+
createdBy: r.String,
|
|
23
|
+
createdAt: r.String,
|
|
24
|
+
comments: r.Array(c),
|
|
25
|
+
unreadCount: r.Number
|
|
26
|
+
}), u = a({
|
|
27
|
+
name: "comments.list",
|
|
28
|
+
source: s,
|
|
29
|
+
input: r.Struct({ anchor: r.String }),
|
|
30
|
+
output: r.Array(l),
|
|
31
|
+
error: e,
|
|
32
|
+
openAccess: "delegated: the executor runs the app-declared anchor access rule (viaEntity guard or scope) and is fail-closed — an undeclared rule refuses every read"
|
|
33
|
+
}), d = i({
|
|
34
|
+
name: "comments.create",
|
|
35
|
+
input: r.Struct({
|
|
36
|
+
anchor: r.String,
|
|
37
|
+
body: r.String,
|
|
38
|
+
threadId: r.optional(r.String),
|
|
39
|
+
mentions: r.optional(r.Array(r.String))
|
|
40
|
+
}),
|
|
41
|
+
output: r.Struct({
|
|
42
|
+
threadId: r.String,
|
|
43
|
+
commentId: r.String
|
|
44
|
+
}),
|
|
45
|
+
error: r.Union(e, t),
|
|
46
|
+
openAccess: "delegated: the executor runs the app-declared anchor access rule before any write; the author is always the calling subject"
|
|
47
|
+
}), f = i({
|
|
48
|
+
name: "comments.edit",
|
|
49
|
+
input: r.Struct({
|
|
50
|
+
commentId: r.String,
|
|
51
|
+
body: r.String
|
|
52
|
+
}),
|
|
53
|
+
output: r.Struct({ ok: r.Boolean }),
|
|
54
|
+
error: r.Union(e, t, n),
|
|
55
|
+
openAccess: "author-scoped: only the comment's own author may edit, checked in the executor on top of the anchor access rule"
|
|
56
|
+
}), p = i({
|
|
57
|
+
name: "comments.resolve",
|
|
58
|
+
input: r.Struct({
|
|
59
|
+
threadId: r.String,
|
|
60
|
+
resolved: r.Boolean
|
|
61
|
+
}),
|
|
62
|
+
output: r.Struct({ ok: r.Boolean }),
|
|
63
|
+
error: r.Union(e, t),
|
|
64
|
+
openAccess: "delegated: anchor access rule in the executor — anyone who may read the anchor may resolve/reopen (the Liveblocks semantic)"
|
|
65
|
+
}), m = i({
|
|
66
|
+
name: "comments.delete",
|
|
67
|
+
input: r.Struct({ commentId: r.String }),
|
|
68
|
+
output: r.Struct({ ok: r.Boolean }),
|
|
69
|
+
error: r.Union(e, t, n),
|
|
70
|
+
openAccess: "author-scoped, with a comments:moderate scope override — both checked in the executor on top of the anchor access rule"
|
|
71
|
+
}), h = i({
|
|
72
|
+
name: "comments.react",
|
|
73
|
+
input: r.Struct({
|
|
74
|
+
commentId: r.String,
|
|
75
|
+
emoji: r.String
|
|
76
|
+
}),
|
|
77
|
+
output: r.Struct({ reacted: r.Boolean }),
|
|
78
|
+
error: r.Union(e, t),
|
|
79
|
+
openAccess: "delegated: anchor access rule in the executor; the toggle writes only the calling subject's own reaction row"
|
|
80
|
+
}), g = i({
|
|
81
|
+
name: "comments.markRead",
|
|
82
|
+
input: r.Struct({ threadId: r.String }),
|
|
83
|
+
output: r.Struct({ ok: r.Boolean }),
|
|
84
|
+
error: t,
|
|
85
|
+
openAccess: "self-scoped write: stamps only the calling subject's own read marker for the thread"
|
|
86
|
+
}), _ = a({
|
|
87
|
+
name: "comments.mentionSearch",
|
|
88
|
+
input: r.Struct({ query: r.String }),
|
|
89
|
+
output: r.Array(r.Struct({
|
|
90
|
+
subjectId: r.String,
|
|
91
|
+
label: r.String
|
|
92
|
+
})),
|
|
93
|
+
openAccess: "delegated: the app-declared mention resolver receives the CALLING subject and its default filters to the caller's tenant — cross-tenant subjects are structurally unreachable"
|
|
94
|
+
}), v = [
|
|
95
|
+
{
|
|
96
|
+
tag: "comments.list",
|
|
97
|
+
kind: "query",
|
|
98
|
+
import: {
|
|
99
|
+
module: "@voltro/plugin-comments/rpc",
|
|
100
|
+
name: "listDescriptor"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
tag: "comments.create",
|
|
105
|
+
kind: "mutation",
|
|
106
|
+
import: {
|
|
107
|
+
module: "@voltro/plugin-comments/rpc",
|
|
108
|
+
name: "createDescriptor"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
tag: "comments.edit",
|
|
113
|
+
kind: "mutation",
|
|
114
|
+
import: {
|
|
115
|
+
module: "@voltro/plugin-comments/rpc",
|
|
116
|
+
name: "editDescriptor"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
tag: "comments.resolve",
|
|
121
|
+
kind: "mutation",
|
|
122
|
+
import: {
|
|
123
|
+
module: "@voltro/plugin-comments/rpc",
|
|
124
|
+
name: "resolveDescriptor"
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
tag: "comments.delete",
|
|
129
|
+
kind: "mutation",
|
|
130
|
+
import: {
|
|
131
|
+
module: "@voltro/plugin-comments/rpc",
|
|
132
|
+
name: "deleteDescriptor"
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
tag: "comments.react",
|
|
137
|
+
kind: "mutation",
|
|
138
|
+
import: {
|
|
139
|
+
module: "@voltro/plugin-comments/rpc",
|
|
140
|
+
name: "reactDescriptor"
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
tag: "comments.markRead",
|
|
145
|
+
kind: "mutation",
|
|
146
|
+
import: {
|
|
147
|
+
module: "@voltro/plugin-comments/rpc",
|
|
148
|
+
name: "markReadDescriptor"
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
tag: "comments.mentionSearch",
|
|
153
|
+
kind: "query",
|
|
154
|
+
import: {
|
|
155
|
+
module: "@voltro/plugin-comments/rpc",
|
|
156
|
+
name: "mentionSearchDescriptor"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
];
|
|
160
|
+
//#endregion
|
|
161
|
+
export { s as commentsFeed, v as commentsRpcClientImports, d as createDescriptor, m as deleteDescriptor, f as editDescriptor, u as listDescriptor, g as markReadDescriptor, _ as mentionSearchDescriptor, h as reactDescriptor, p as resolveDescriptor };
|
package/dist/web.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export declare interface CommentReactionView {
|
|
2
|
+
readonly emoji: string;
|
|
3
|
+
readonly count: number;
|
|
4
|
+
readonly mine: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export declare interface CommentView {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly threadId: string;
|
|
10
|
+
readonly body: string;
|
|
11
|
+
readonly authorSubjectId: string;
|
|
12
|
+
readonly mentions: ReadonlyArray<string>;
|
|
13
|
+
readonly editedAt: string | null;
|
|
14
|
+
readonly createdAt: string;
|
|
15
|
+
readonly reactions: ReadonlyArray<CommentReactionView>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export declare interface ThreadView {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly anchor: string;
|
|
21
|
+
readonly status: 'open' | 'resolved';
|
|
22
|
+
readonly createdBy: string;
|
|
23
|
+
readonly createdAt: string;
|
|
24
|
+
readonly comments: ReadonlyArray<CommentView>;
|
|
25
|
+
readonly unreadCount: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The threads on one anchor, LIVE — `comments.list` declares the plugin's
|
|
30
|
+
* reactivity channel as its `source:`, so a second client sees a new comment
|
|
31
|
+
* without a reload; every mutation below re-runs the list for all subscribers.
|
|
32
|
+
*/
|
|
33
|
+
export declare const useComments: (anchor: string, apiName?: string) => UseCommentsResult;
|
|
34
|
+
|
|
35
|
+
export declare interface UseCommentsResult {
|
|
36
|
+
readonly threads: ReadonlyArray<ThreadView>;
|
|
37
|
+
readonly pending: boolean;
|
|
38
|
+
/** Sum of the threads' unread counters — the badge number. */
|
|
39
|
+
readonly unreadCount: number;
|
|
40
|
+
readonly create: (body: string, opts?: {
|
|
41
|
+
threadId?: string;
|
|
42
|
+
mentions?: ReadonlyArray<string>;
|
|
43
|
+
}) => Promise<unknown>;
|
|
44
|
+
readonly edit: (commentId: string, body: string) => Promise<unknown>;
|
|
45
|
+
readonly resolve: (threadId: string, resolved?: boolean) => Promise<unknown>;
|
|
46
|
+
readonly remove: (commentId: string) => Promise<unknown>;
|
|
47
|
+
readonly react: (commentId: string, emoji: string) => Promise<unknown>;
|
|
48
|
+
readonly markRead: (threadId: string) => Promise<unknown>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** @-mention autocomplete over the app-declared, tenant-filtered directory. */
|
|
52
|
+
export declare const useMentionSearch: (query: string, apiName?: string) => ReadonlyArray<{
|
|
53
|
+
subjectId: string;
|
|
54
|
+
label: string;
|
|
55
|
+
}>;
|
|
56
|
+
|
|
57
|
+
/** One thread by id (a projection over the same live list). */
|
|
58
|
+
export declare const useThread: (anchor: string, threadId: string, apiName?: string) => ThreadView | undefined;
|
|
59
|
+
|
|
60
|
+
export { }
|
package/dist/web.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useMutation as e, useSubscription as t } from "@voltro/client";
|
|
2
|
+
//#region src/web.ts
|
|
3
|
+
var n = (n, r = "app") => {
|
|
4
|
+
let { data: i, loading: a } = t(r, "comments.list", { anchor: n }), o = e(r, "comments.create"), s = e(r, "comments.edit"), c = e(r, "comments.resolve"), l = e(r, "comments.delete"), u = e(r, "comments.react"), d = e(r, "comments.markRead"), f = i ?? [];
|
|
5
|
+
return {
|
|
6
|
+
threads: f,
|
|
7
|
+
pending: a,
|
|
8
|
+
unreadCount: f.reduce((e, t) => e + t.unreadCount, 0),
|
|
9
|
+
create: (e, t) => o.mutate({
|
|
10
|
+
anchor: n,
|
|
11
|
+
body: e,
|
|
12
|
+
...t?.threadId === void 0 ? {} : { threadId: t.threadId },
|
|
13
|
+
...t?.mentions === void 0 ? {} : { mentions: t.mentions }
|
|
14
|
+
}),
|
|
15
|
+
edit: (e, t) => s.mutate({
|
|
16
|
+
commentId: e,
|
|
17
|
+
body: t
|
|
18
|
+
}),
|
|
19
|
+
resolve: (e, t = !0) => c.mutate({
|
|
20
|
+
threadId: e,
|
|
21
|
+
resolved: t
|
|
22
|
+
}),
|
|
23
|
+
remove: (e) => l.mutate({ commentId: e }),
|
|
24
|
+
react: (e, t) => u.mutate({
|
|
25
|
+
commentId: e,
|
|
26
|
+
emoji: t
|
|
27
|
+
}),
|
|
28
|
+
markRead: (e) => d.mutate({ threadId: e })
|
|
29
|
+
};
|
|
30
|
+
}, r = (e, t, r = "app") => n(e, r).threads.find((e) => e.id === t), i = (e, n = "app") => {
|
|
31
|
+
let { data: r } = t(n, "comments.mentionSearch", { query: e });
|
|
32
|
+
return r ?? [];
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
export { n as useComments, i as useMentionSearch, r as useThread };
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voltro/plugin-comments",
|
|
3
|
+
"version": "0.53.0",
|
|
4
|
+
"description": "plugin-comments package",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"voltro",
|
|
7
|
+
"typescript",
|
|
8
|
+
"framework"
|
|
9
|
+
],
|
|
10
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
11
|
+
"homepage": "https://voltro.dev",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"email": "support@voltro.dev"
|
|
14
|
+
},
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Voltro UG",
|
|
17
|
+
"url": "https://voltro.dev"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./errors": {
|
|
27
|
+
"types": "./dist/errors.d.ts",
|
|
28
|
+
"import": "./dist/errors.js",
|
|
29
|
+
"default": "./dist/errors.js"
|
|
30
|
+
},
|
|
31
|
+
"./rpc": {
|
|
32
|
+
"types": "./dist/rpc.d.ts",
|
|
33
|
+
"import": "./dist/rpc.js",
|
|
34
|
+
"default": "./dist/rpc.js"
|
|
35
|
+
},
|
|
36
|
+
"./web": {
|
|
37
|
+
"types": "./dist/web.d.ts",
|
|
38
|
+
"import": "./dist/web.js",
|
|
39
|
+
"default": "./dist/web.js"
|
|
40
|
+
},
|
|
41
|
+
"./package.json": "./package.json"
|
|
42
|
+
},
|
|
43
|
+
"main": "./dist/index.js",
|
|
44
|
+
"module": "./dist/index.js",
|
|
45
|
+
"types": "./dist/index.d.ts",
|
|
46
|
+
"sideEffects": false,
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=24.0.0"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@voltro/database": "0.53.0",
|
|
52
|
+
"@voltro/protocol": "0.53.0",
|
|
53
|
+
"@voltro/plugin-notifications": "0.53.0",
|
|
54
|
+
"effect": "^3.22.0"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"react": "^19.0.0"
|
|
58
|
+
},
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"access": "public"
|
|
61
|
+
}
|
|
62
|
+
}
|