@voltro/plugin-comments 0.85.0 → 0.86.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 +666 -0
- package/THIRD-PARTY-NOTICES.md +5 -33
- package/dist/index.js +123 -125
- package/dist/quote.js +25 -0
- package/dist/rpc.js +194 -2
- package/dist/web.js +4 -3
- package/package.json +5 -5
- package/dist/rpc-BTQBcdhT.js +0 -214
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Third-Party Notices — @voltro/plugin-comments
|
|
2
2
|
|
|
3
|
-
This package
|
|
3
|
+
This package uses the open-source software listed below. Each is the
|
|
4
4
|
property of its respective copyright holders and is used under the terms of
|
|
5
5
|
its license. This file is provided for attribution; it grants no rights in
|
|
6
6
|
@voltro/plugin-comments itself, which is proprietary (see LICENSE).
|
|
7
7
|
|
|
8
|
-
Generated from the resolved runtime dependency closure (
|
|
8
|
+
Generated from the resolved runtime dependency closure (10 packages).
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
@@ -177,34 +177,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
177
177
|
SOFTWARE.
|
|
178
178
|
```
|
|
179
179
|
|
|
180
|
-
## layerr@3.0.0
|
|
181
|
-
|
|
182
|
-
License: MIT
|
|
183
|
-
|
|
184
|
-
```
|
|
185
|
-
MIT License
|
|
186
|
-
|
|
187
|
-
Copyright (c) 2020 Perry Mitchell
|
|
188
|
-
|
|
189
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
190
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
191
|
-
in the Software without restriction, including without limitation the rights
|
|
192
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
193
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
194
|
-
furnished to do so, subject to the following conditions:
|
|
195
|
-
|
|
196
|
-
The above copyright notice and this permission notice shall be included in all
|
|
197
|
-
copies or substantial portions of the Software.
|
|
198
|
-
|
|
199
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
200
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
201
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
202
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
203
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
204
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
205
|
-
SOFTWARE.
|
|
206
|
-
```
|
|
207
|
-
|
|
208
180
|
## typeid-js@1.2.0
|
|
209
181
|
|
|
210
182
|
License: Apache-2.0
|
|
@@ -413,14 +385,14 @@ Apache License
|
|
|
413
385
|
limitations under the License.
|
|
414
386
|
```
|
|
415
387
|
|
|
416
|
-
##
|
|
388
|
+
## ulid@3.0.2
|
|
417
389
|
|
|
418
390
|
License: MIT
|
|
419
391
|
|
|
420
392
|
```
|
|
421
|
-
MIT License
|
|
393
|
+
The MIT License (MIT)
|
|
422
394
|
|
|
423
|
-
Copyright (c)
|
|
395
|
+
Copyright (c) 2017 Alizain Feerasta
|
|
424
396
|
|
|
425
397
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
426
398
|
of this software and associated documentation files (the "Software"), to deal
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CommentAccessRefused as e, CommentNotFound as t, CommentNotYours as n, CommentStatusRefused as r } from "./errors.js";
|
|
2
|
-
import {
|
|
2
|
+
import { QUOTE_MAX_LENGTH as i, findQuote as a, textQuote as o } from "./quote.js";
|
|
3
|
+
import { BASE_NAME as s, COMMENT_THREAD_KINDS as c, commentsFeed as l, commentsRpcClientImports as u, createDescriptor as d, deleteDescriptor as f, editDescriptor as p, listDescriptor as m, markReadDescriptor as h, mentionSearchDescriptor as g, reactDescriptor as _, resolveDescriptor as v } from "./rpc.js";
|
|
3
4
|
import { Effect as y, Option as b } from "effect";
|
|
4
5
|
import { and as x, contains as S, eq as C, generateId as w, id as T, inSet as E, json as D, neq as O, or as k, table as A, text as j, timestamp as M } from "@voltro/database";
|
|
5
6
|
import { definePlugin as N, pluginInstanceName as P, publishReactivity as F } from "@voltro/protocol";
|
|
@@ -46,19 +47,19 @@ var L = A("_voltro_comment_threads", {
|
|
|
46
47
|
threadId: j(),
|
|
47
48
|
subjectId: j(),
|
|
48
49
|
lastReadAt: M()
|
|
49
|
-
}).unique("byReadThreadSubject", ["threadId", "subjectId"]), H =
|
|
50
|
+
}).unique("byReadThreadSubject", ["threadId", "subjectId"]), H = s, U = (e) => {
|
|
50
51
|
let t = e.request.subject ?? {};
|
|
51
52
|
return {
|
|
52
53
|
id: t.id ?? null,
|
|
53
54
|
tenantId: t.tenantId ?? null,
|
|
54
55
|
scopes: t.scopes ?? []
|
|
55
56
|
};
|
|
56
|
-
}, W = (
|
|
57
|
-
let
|
|
57
|
+
}, W = (i = {}) => {
|
|
58
|
+
let a = P({
|
|
58
59
|
base: H,
|
|
59
|
-
alias:
|
|
60
|
-
instance:
|
|
61
|
-
}),
|
|
60
|
+
alias: i.alias,
|
|
61
|
+
instance: i.name
|
|
62
|
+
}), o, s, T = async (e, t, n) => o === void 0 ? [] : o.query({
|
|
62
63
|
table: e,
|
|
63
64
|
predicate: t,
|
|
64
65
|
order: [],
|
|
@@ -80,21 +81,21 @@ var L = A("_voltro_comment_threads", {
|
|
|
80
81
|
}
|
|
81
82
|
return n;
|
|
82
83
|
}, j = () => {
|
|
83
|
-
F(
|
|
84
|
+
F(s, l);
|
|
84
85
|
}, M = (t, n) => y.gen(function* () {
|
|
85
86
|
let r = U(n);
|
|
86
|
-
return
|
|
87
|
+
return i.access?.viaEntity === void 0 ? i.access?.scope === void 0 ? yield* y.fail(new e({
|
|
87
88
|
anchor: t,
|
|
88
89
|
reason: "no access rule declared — set commentsPlugin({ access: { viaEntity } }) or { access: { scope } }"
|
|
89
|
-
})) : r.scopes.includes(
|
|
90
|
+
})) : r.scopes.includes(i.access.scope) ? void 0 : yield* y.fail(new e({
|
|
90
91
|
anchor: t,
|
|
91
|
-
reason: `missing scope '${
|
|
92
|
+
reason: `missing scope '${i.access.scope}'`
|
|
92
93
|
})) : (yield* y.promise(async () => {
|
|
93
94
|
try {
|
|
94
|
-
return await
|
|
95
|
+
return await i.access.viaEntity({
|
|
95
96
|
anchor: t,
|
|
96
97
|
subject: r,
|
|
97
|
-
store:
|
|
98
|
+
store: o
|
|
98
99
|
});
|
|
99
100
|
} catch {
|
|
100
101
|
return !1;
|
|
@@ -106,10 +107,10 @@ var L = A("_voltro_comment_threads", {
|
|
|
106
107
|
}), W = async (e) => (await T("_voltro_comment_threads", C("id", e), 1))[0], G = (e) => ({
|
|
107
108
|
id: String(e.id),
|
|
108
109
|
anchor: String(e.anchor),
|
|
109
|
-
kind:
|
|
110
|
+
kind: c.includes(String(e.kind)) ? e.kind : "discussion",
|
|
110
111
|
status: e.status === "resolved" ? "resolved" : "open",
|
|
111
112
|
createdBy: String(e.createdBy)
|
|
112
|
-
}), K = (e, t) =>
|
|
113
|
+
}), K = (e, t) => i.visibleTo === void 0 || i.visibleTo({
|
|
113
114
|
thread: G(e),
|
|
114
115
|
subject: U(t)
|
|
115
116
|
}), q = async (e, t) => {
|
|
@@ -132,13 +133,10 @@ var L = A("_voltro_comment_threads", {
|
|
|
132
133
|
}, Y = (e) => e instanceof Date ? e.toISOString() : typeof e == "string" ? e : "", X = (e) => y.gen(function* () {
|
|
133
134
|
if (e.mentions.length === 0) return;
|
|
134
135
|
let t = yield* y.serviceOption(I);
|
|
135
|
-
if (b.isNone(t))
|
|
136
|
-
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
for (let n of e.mentions) n !== e.author && (yield* y.promise(() => t.value.send({
|
|
136
|
+
if (b.isNone(t)) yield* y.logInfo("comments: mention recorded without notification — @voltro/plugin-notifications is not configured");
|
|
137
|
+
else for (let n of e.mentions) n !== e.author && (yield* y.promise(() => t.value.send({
|
|
140
138
|
to: n,
|
|
141
|
-
category:
|
|
139
|
+
category: i.mentionCategory ?? "mention",
|
|
142
140
|
title: "You were mentioned",
|
|
143
141
|
body: e.body.length > 200 ? `${e.body.slice(0, 200)}…` : e.body,
|
|
144
142
|
data: {
|
|
@@ -148,14 +146,14 @@ var L = A("_voltro_comment_threads", {
|
|
|
148
146
|
tenantId: e.tenantId
|
|
149
147
|
}).then(() => void 0).catch(() => void 0)));
|
|
150
148
|
}), Z = async (e, t) => {
|
|
151
|
-
if (e.length === 0 ||
|
|
149
|
+
if (e.length === 0 || i.resolveMentions === void 0) return [];
|
|
152
150
|
let n = [];
|
|
153
151
|
for (let r of [...new Set(e)].slice(0, 20)) {
|
|
154
|
-
let e = (await
|
|
152
|
+
let e = (await i.resolveMentions({
|
|
155
153
|
query: r,
|
|
156
154
|
subject: t
|
|
157
155
|
}).catch(() => [])).find((e) => e.subjectId === r);
|
|
158
|
-
e !== void 0 && (
|
|
156
|
+
e !== void 0 && (i.crossTenant === !0 || e.tenantId === void 0 || e.tenantId === null || e.tenantId === t.tenantId) && n.push(r);
|
|
159
157
|
}
|
|
160
158
|
return n;
|
|
161
159
|
}, Q = async (e, t) => {
|
|
@@ -219,7 +217,7 @@ var L = A("_voltro_comment_threads", {
|
|
|
219
217
|
return p.sort((e, t) => String(e.createdAt) < String(t.createdAt) ? -1 : 1), p;
|
|
220
218
|
}, ee = [
|
|
221
219
|
{
|
|
222
|
-
...
|
|
220
|
+
...m,
|
|
223
221
|
description: "Threads + comments + reactions + unread for one anchor, live.",
|
|
224
222
|
execute: (e, t) => y.gen(function* () {
|
|
225
223
|
let { anchor: n } = e;
|
|
@@ -227,149 +225,149 @@ var L = A("_voltro_comment_threads", {
|
|
|
227
225
|
})
|
|
228
226
|
},
|
|
229
227
|
{
|
|
230
|
-
...
|
|
228
|
+
...d,
|
|
231
229
|
description: "Comment on an anchor — a reply into a thread, or a new thread.",
|
|
232
230
|
execute: (n, r) => y.gen(function* () {
|
|
233
231
|
let i = n;
|
|
234
232
|
yield* M(i.anchor, r);
|
|
235
|
-
let a = U(r),
|
|
236
|
-
if (
|
|
237
|
-
let
|
|
238
|
-
if (
|
|
239
|
-
let e = yield* y.promise(() => q(
|
|
240
|
-
if (e === void 0 || String(e.anchor) !== i.anchor) return yield* y.fail(new t({ id:
|
|
233
|
+
let a = U(r), s = a.id ?? "anonymous", c = o;
|
|
234
|
+
if (c === void 0) return yield* y.fail(new t({ id: i.anchor }));
|
|
235
|
+
let l = i.threadId;
|
|
236
|
+
if (l !== void 0) {
|
|
237
|
+
let e = yield* y.promise(() => q(l, r));
|
|
238
|
+
if (e === void 0 || String(e.anchor) !== i.anchor) return yield* y.fail(new t({ id: l }));
|
|
241
239
|
} else {
|
|
242
240
|
let t = w({
|
|
243
241
|
kind: "typeid",
|
|
244
242
|
prefix: "cmtthr"
|
|
245
243
|
}, "_voltro_comment_threads");
|
|
246
|
-
|
|
244
|
+
l = t;
|
|
247
245
|
let n = i.kind ?? "discussion";
|
|
248
246
|
if (!K({
|
|
249
247
|
id: t,
|
|
250
248
|
anchor: i.anchor,
|
|
251
249
|
kind: n,
|
|
252
250
|
status: "open",
|
|
253
|
-
createdBy:
|
|
251
|
+
createdBy: s
|
|
254
252
|
}, r)) return yield* y.fail(new e({
|
|
255
253
|
anchor: i.anchor,
|
|
256
254
|
reason: `a ${n} thread here would not be visible to its author`
|
|
257
255
|
}));
|
|
258
256
|
yield* y.promise(async () => {
|
|
259
|
-
await
|
|
257
|
+
await c.insert("_voltro_comment_threads", {
|
|
260
258
|
id: t,
|
|
261
259
|
anchor: i.anchor,
|
|
262
260
|
quote: i.quote ?? null,
|
|
263
261
|
kind: n,
|
|
264
262
|
status: "open",
|
|
265
|
-
createdBy:
|
|
263
|
+
createdBy: s,
|
|
266
264
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
267
265
|
tenantId: a.tenantId
|
|
268
|
-
}), await J(
|
|
266
|
+
}), await J(c, {
|
|
269
267
|
threadId: t,
|
|
270
268
|
from: null,
|
|
271
269
|
to: "open",
|
|
272
|
-
actor:
|
|
270
|
+
actor: s,
|
|
273
271
|
reason: null,
|
|
274
272
|
tenantId: a.tenantId
|
|
275
273
|
});
|
|
276
274
|
});
|
|
277
275
|
}
|
|
278
|
-
let
|
|
276
|
+
let u = yield* y.promise(() => Z(i.mentions ?? [], a)), d = w({
|
|
279
277
|
kind: "typeid",
|
|
280
278
|
prefix: "cmt"
|
|
281
279
|
}, "_voltro_comments");
|
|
282
|
-
return yield* y.promise(() =>
|
|
283
|
-
id:
|
|
284
|
-
threadId:
|
|
280
|
+
return yield* y.promise(() => c.insert("_voltro_comments", {
|
|
281
|
+
id: d,
|
|
282
|
+
threadId: l,
|
|
285
283
|
body: i.body,
|
|
286
|
-
authorSubjectId:
|
|
287
|
-
mentions:
|
|
284
|
+
authorSubjectId: s,
|
|
285
|
+
mentions: u,
|
|
288
286
|
editedAt: null,
|
|
289
287
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
290
288
|
tenantId: a.tenantId
|
|
291
289
|
})), j(), yield* X({
|
|
292
|
-
mentions:
|
|
293
|
-
author:
|
|
290
|
+
mentions: u,
|
|
291
|
+
author: s,
|
|
294
292
|
anchor: i.anchor,
|
|
295
|
-
threadId:
|
|
293
|
+
threadId: l,
|
|
296
294
|
body: i.body,
|
|
297
295
|
tenantId: a.tenantId
|
|
298
296
|
}), {
|
|
299
|
-
threadId:
|
|
300
|
-
commentId:
|
|
297
|
+
threadId: l,
|
|
298
|
+
commentId: d
|
|
301
299
|
};
|
|
302
300
|
})
|
|
303
301
|
},
|
|
304
302
|
{
|
|
305
|
-
...
|
|
303
|
+
...p,
|
|
306
304
|
description: "Edit your own comment.",
|
|
307
305
|
execute: (e, r) => y.gen(function* () {
|
|
308
306
|
let i = e, a = (yield* y.promise(() => T("_voltro_comments", C("id", i.commentId), 1)))[0];
|
|
309
307
|
if (a === void 0) return yield* y.fail(new t({ id: i.commentId }));
|
|
310
|
-
let
|
|
311
|
-
return
|
|
308
|
+
let s = yield* y.promise(() => q(String(a.threadId), r));
|
|
309
|
+
return s === void 0 ? yield* y.fail(new t({ id: i.commentId })) : (yield* M(String(s.anchor), r), String(a.authorSubjectId) === (U(r).id ?? "anonymous") ? (yield* y.promise(() => o.update("_voltro_comments", i.commentId, {
|
|
312
310
|
body: i.body,
|
|
313
311
|
editedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
314
312
|
})), j(), { ok: !0 }) : yield* y.fail(new n({ id: i.commentId })));
|
|
315
313
|
})
|
|
316
314
|
},
|
|
317
315
|
{
|
|
318
|
-
...
|
|
316
|
+
...v,
|
|
319
317
|
description: "Resolve or reopen a thread.",
|
|
320
318
|
execute: (e, n) => y.gen(function* () {
|
|
321
|
-
let
|
|
322
|
-
if (
|
|
323
|
-
yield* M(String(
|
|
324
|
-
let
|
|
325
|
-
if (
|
|
326
|
-
let
|
|
327
|
-
if (
|
|
319
|
+
let a = e, s = yield* y.promise(() => q(a.threadId, n));
|
|
320
|
+
if (s === void 0) return yield* y.fail(new t({ id: a.threadId }));
|
|
321
|
+
yield* M(String(s.anchor), n);
|
|
322
|
+
let c = G(s), l = a.resolved ? "resolved" : "open";
|
|
323
|
+
if (c.status === l) return { ok: !0 };
|
|
324
|
+
let u = U(n);
|
|
325
|
+
if (i.statusPolicy !== void 0 && !(yield* y.promise(async () => {
|
|
328
326
|
try {
|
|
329
|
-
return await
|
|
330
|
-
thread:
|
|
331
|
-
to:
|
|
332
|
-
subject:
|
|
333
|
-
store:
|
|
327
|
+
return await i.statusPolicy({
|
|
328
|
+
thread: c,
|
|
329
|
+
to: l,
|
|
330
|
+
subject: u,
|
|
331
|
+
store: o
|
|
334
332
|
});
|
|
335
333
|
} catch {
|
|
336
334
|
return !1;
|
|
337
335
|
}
|
|
338
336
|
}))) return yield* y.fail(new r({
|
|
339
|
-
threadId:
|
|
340
|
-
reason: `the status policy does not let this caller ${
|
|
337
|
+
threadId: a.threadId,
|
|
338
|
+
reason: `the status policy does not let this caller ${a.resolved ? "resolve" : "reopen"} this ${c.kind} thread`
|
|
341
339
|
}));
|
|
342
|
-
let
|
|
340
|
+
let d = a.reason?.trim() ? a.reason.trim() : null;
|
|
343
341
|
return yield* y.promise(async () => {
|
|
344
|
-
await
|
|
345
|
-
threadId:
|
|
346
|
-
from:
|
|
347
|
-
to:
|
|
348
|
-
actor:
|
|
349
|
-
reason:
|
|
350
|
-
tenantId:
|
|
342
|
+
await o.update("_voltro_comment_threads", a.threadId, { status: l }), await J(o, {
|
|
343
|
+
threadId: a.threadId,
|
|
344
|
+
from: c.status,
|
|
345
|
+
to: l,
|
|
346
|
+
actor: u.id ?? "anonymous",
|
|
347
|
+
reason: d,
|
|
348
|
+
tenantId: u.tenantId
|
|
351
349
|
});
|
|
352
350
|
}), j(), { ok: !0 };
|
|
353
351
|
})
|
|
354
352
|
},
|
|
355
353
|
{
|
|
356
|
-
...
|
|
354
|
+
...f,
|
|
357
355
|
description: "Delete your own comment (comments:moderate deletes any).",
|
|
358
356
|
execute: (e, r) => y.gen(function* () {
|
|
359
357
|
let i = e, a = (yield* y.promise(() => T("_voltro_comments", C("id", i.commentId), 1)))[0];
|
|
360
358
|
if (a === void 0) return yield* y.fail(new t({ id: i.commentId }));
|
|
361
|
-
let
|
|
362
|
-
if (
|
|
363
|
-
yield* M(String(
|
|
364
|
-
let
|
|
365
|
-
return String(a.authorSubjectId) !== (
|
|
366
|
-
for (let e of await T("_voltro_comment_reactions", C("commentId", i.commentId))) await
|
|
367
|
-
await
|
|
359
|
+
let s = yield* y.promise(() => q(String(a.threadId), r));
|
|
360
|
+
if (s === void 0) return yield* y.fail(new t({ id: i.commentId }));
|
|
361
|
+
yield* M(String(s.anchor), r);
|
|
362
|
+
let c = U(r);
|
|
363
|
+
return String(a.authorSubjectId) !== (c.id ?? "anonymous") && !c.scopes.includes("comments:moderate") ? yield* y.fail(new n({ id: i.commentId })) : (yield* y.promise(async () => {
|
|
364
|
+
for (let e of await T("_voltro_comment_reactions", C("commentId", i.commentId))) await o.delete("_voltro_comment_reactions", String(e.id));
|
|
365
|
+
await o.delete("_voltro_comments", i.commentId);
|
|
368
366
|
}), j(), { ok: !0 });
|
|
369
367
|
})
|
|
370
368
|
},
|
|
371
369
|
{
|
|
372
|
-
...
|
|
370
|
+
..._,
|
|
373
371
|
description: "Toggle an emoji reaction on a comment.",
|
|
374
372
|
execute: (e, n) => y.gen(function* () {
|
|
375
373
|
let r = e, i = (yield* y.promise(() => T("_voltro_comments", C("id", r.commentId), 1)))[0];
|
|
@@ -377,22 +375,22 @@ var L = A("_voltro_comment_threads", {
|
|
|
377
375
|
let a = yield* y.promise(() => q(String(i.threadId), n));
|
|
378
376
|
if (a === void 0) return yield* y.fail(new t({ id: r.commentId }));
|
|
379
377
|
yield* M(String(a.anchor), n);
|
|
380
|
-
let
|
|
381
|
-
if (
|
|
382
|
-
let
|
|
378
|
+
let s = U(n).id ?? "anonymous", c = (yield* y.promise(() => T("_voltro_comment_reactions", x(C("commentId", r.commentId), x(C("subjectId", s), C("emoji", r.emoji))), 1)))[0];
|
|
379
|
+
if (c !== void 0) return yield* y.promise(() => o.delete("_voltro_comment_reactions", String(c.id))), j(), { reacted: !1 };
|
|
380
|
+
let l = w({
|
|
383
381
|
kind: "typeid",
|
|
384
382
|
prefix: "cmtrx"
|
|
385
383
|
}, "_voltro_comment_reactions");
|
|
386
|
-
return yield* y.promise(() =>
|
|
387
|
-
id:
|
|
384
|
+
return yield* y.promise(() => o.insert("_voltro_comment_reactions", {
|
|
385
|
+
id: l,
|
|
388
386
|
commentId: r.commentId,
|
|
389
|
-
subjectId:
|
|
387
|
+
subjectId: s,
|
|
390
388
|
emoji: r.emoji
|
|
391
389
|
})), j(), { reacted: !0 };
|
|
392
390
|
})
|
|
393
391
|
},
|
|
394
392
|
{
|
|
395
|
-
...
|
|
393
|
+
...h,
|
|
396
394
|
description: "Stamp the caller's read marker for a thread.",
|
|
397
395
|
execute: (e, n) => y.gen(function* () {
|
|
398
396
|
let r = e;
|
|
@@ -401,7 +399,7 @@ var L = A("_voltro_comment_threads", {
|
|
|
401
399
|
kind: "typeid",
|
|
402
400
|
prefix: "cmtread"
|
|
403
401
|
}, "_voltro_comment_reads");
|
|
404
|
-
return yield* y.promise(() =>
|
|
402
|
+
return yield* y.promise(() => o.upsert("_voltro_comment_reads", {
|
|
405
403
|
id: a,
|
|
406
404
|
threadId: r.threadId,
|
|
407
405
|
subjectId: i,
|
|
@@ -413,19 +411,19 @@ var L = A("_voltro_comment_threads", {
|
|
|
413
411
|
})
|
|
414
412
|
},
|
|
415
413
|
{
|
|
416
|
-
...
|
|
414
|
+
...g,
|
|
417
415
|
description: "@-mention autocomplete over the app-declared directory, tenant-filtered.",
|
|
418
416
|
execute: (e, t) => y.promise(async () => {
|
|
419
417
|
let { query: n } = e;
|
|
420
|
-
if (
|
|
418
|
+
if (i.resolveMentions === void 0) return [];
|
|
421
419
|
let r = U(t);
|
|
422
|
-
return (await
|
|
420
|
+
return (await i.resolveMentions({
|
|
423
421
|
query: n,
|
|
424
422
|
subject: {
|
|
425
423
|
id: r.id,
|
|
426
424
|
tenantId: r.tenantId
|
|
427
425
|
}
|
|
428
|
-
}).catch(() => [])).filter((e) =>
|
|
426
|
+
}).catch(() => [])).filter((e) => i.crossTenant === !0 || e.tenantId === void 0 || e.tenantId === null || e.tenantId === r.tenantId).map((e) => ({
|
|
429
427
|
subjectId: e.subjectId,
|
|
430
428
|
label: e.label
|
|
431
429
|
}));
|
|
@@ -436,7 +434,7 @@ var L = A("_voltro_comment_threads", {
|
|
|
436
434
|
data: e
|
|
437
435
|
});
|
|
438
436
|
return N({
|
|
439
|
-
name:
|
|
437
|
+
name: a,
|
|
440
438
|
baseName: H,
|
|
441
439
|
description: "Comment threads on any app entity — replies, resolve/reopen, @-mentions with notifications, reactions, unread — live over the reactive engine.",
|
|
442
440
|
permissions: ["inspect:read", "store:write"],
|
|
@@ -448,7 +446,7 @@ var L = A("_voltro_comment_threads", {
|
|
|
448
446
|
V
|
|
449
447
|
] },
|
|
450
448
|
routes: ee,
|
|
451
|
-
rpcClientDescriptors:
|
|
449
|
+
rpcClientDescriptors: u,
|
|
452
450
|
inspectEndpoints: [{
|
|
453
451
|
method: "GET",
|
|
454
452
|
path: "/threads",
|
|
@@ -457,7 +455,7 @@ var L = A("_voltro_comment_threads", {
|
|
|
457
455
|
handler: (e) => y.promise(async () => {
|
|
458
456
|
let t = new URL(e.url, "http://inspect.local").searchParams, n = t.get("threadId"), r = Number(t.get("offset") ?? 0), i = Number.isSafeInteger(r) && r >= 0 ? r : 0, a = (t.get("search") ?? "").trim().slice(0, 200);
|
|
459
457
|
if (n) {
|
|
460
|
-
let e = (await T("_voltro_comment_threads", C("id", n), 1))[0], t = C("threadId", n), [r, a] = e &&
|
|
458
|
+
let e = (await T("_voltro_comment_threads", C("id", n), 1))[0], t = C("threadId", n), [r, a] = e && o ? await Promise.all([o.query({
|
|
461
459
|
table: "_voltro_comments",
|
|
462
460
|
predicate: t,
|
|
463
461
|
order: [{
|
|
@@ -470,7 +468,7 @@ var L = A("_voltro_comment_threads", {
|
|
|
470
468
|
take: 50,
|
|
471
469
|
skip: i,
|
|
472
470
|
projection: void 0
|
|
473
|
-
}),
|
|
471
|
+
}), o.query({
|
|
474
472
|
table: "_voltro_comments",
|
|
475
473
|
predicate: t,
|
|
476
474
|
order: [],
|
|
@@ -481,19 +479,19 @@ var L = A("_voltro_comment_threads", {
|
|
|
481
479
|
op: "count",
|
|
482
480
|
alias: "count"
|
|
483
481
|
}]
|
|
484
|
-
})]) : [[], []],
|
|
482
|
+
})]) : [[], []], s = Number(a[0]?.count ?? 0);
|
|
485
483
|
return $({
|
|
486
484
|
stats: {
|
|
487
485
|
threads: +!!e,
|
|
488
486
|
open: e && e.status !== "resolved" ? 1 : 0,
|
|
489
|
-
comments:
|
|
487
|
+
comments: s
|
|
490
488
|
},
|
|
491
489
|
recent: [],
|
|
492
490
|
detail: {
|
|
493
491
|
threadId: n,
|
|
494
492
|
found: !!e,
|
|
495
493
|
offset: i,
|
|
496
|
-
total:
|
|
494
|
+
total: s,
|
|
497
495
|
messages: r.map((e) => ({
|
|
498
496
|
id: String(e.id),
|
|
499
497
|
body: String(e.body),
|
|
@@ -504,9 +502,9 @@ var L = A("_voltro_comment_threads", {
|
|
|
504
502
|
}
|
|
505
503
|
});
|
|
506
504
|
}
|
|
507
|
-
if (!
|
|
508
|
-
let
|
|
509
|
-
let n = await
|
|
505
|
+
if (!o) throw Error("Comments store is not available");
|
|
506
|
+
let s = async (e, t) => {
|
|
507
|
+
let n = await o.query({
|
|
510
508
|
table: e,
|
|
511
509
|
predicate: t,
|
|
512
510
|
order: [],
|
|
@@ -519,10 +517,10 @@ var L = A("_voltro_comment_threads", {
|
|
|
519
517
|
}]
|
|
520
518
|
});
|
|
521
519
|
return Number(n[0]?.count ?? 0);
|
|
522
|
-
},
|
|
523
|
-
|
|
520
|
+
}, c = a ? k(S("anchor", a), S("id", a), S("createdBy", a)) : void 0, [l, u, d, f, p] = await Promise.all([
|
|
521
|
+
o.query({
|
|
524
522
|
table: "_voltro_comment_threads",
|
|
525
|
-
predicate:
|
|
523
|
+
predicate: c,
|
|
526
524
|
order: [{
|
|
527
525
|
column: "createdAt",
|
|
528
526
|
direction: "desc"
|
|
@@ -534,13 +532,13 @@ var L = A("_voltro_comment_threads", {
|
|
|
534
532
|
skip: i,
|
|
535
533
|
projection: void 0
|
|
536
534
|
}),
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
]),
|
|
535
|
+
s("_voltro_comment_threads"),
|
|
536
|
+
s("_voltro_comment_threads", O("status", "resolved")),
|
|
537
|
+
s("_voltro_comments"),
|
|
538
|
+
s("_voltro_comment_threads", c)
|
|
539
|
+
]), m = l.length === 0 ? [] : await o.query({
|
|
542
540
|
table: "_voltro_comments",
|
|
543
|
-
predicate: E("threadId",
|
|
541
|
+
predicate: E("threadId", l.map((e) => String(e.id))),
|
|
544
542
|
order: [],
|
|
545
543
|
take: void 0,
|
|
546
544
|
skip: void 0,
|
|
@@ -554,20 +552,20 @@ var L = A("_voltro_comment_threads", {
|
|
|
554
552
|
alias: "count"
|
|
555
553
|
}],
|
|
556
554
|
groupBy: ["threadId"]
|
|
557
|
-
}), h = new Map(
|
|
555
|
+
}), h = new Map(m.map((e) => [String(e.threadId), Number(e.count)]));
|
|
558
556
|
return $({
|
|
559
557
|
stats: {
|
|
560
|
-
threads:
|
|
561
|
-
open:
|
|
562
|
-
comments:
|
|
558
|
+
threads: u,
|
|
559
|
+
open: d,
|
|
560
|
+
comments: f
|
|
563
561
|
},
|
|
564
562
|
page: {
|
|
565
563
|
offset: i,
|
|
566
564
|
search: a,
|
|
567
|
-
total:
|
|
565
|
+
total: p,
|
|
568
566
|
pageSize: 50
|
|
569
567
|
},
|
|
570
|
-
recent:
|
|
568
|
+
recent: l.map((e) => ({
|
|
571
569
|
id: String(e.id),
|
|
572
570
|
anchor: String(e.anchor),
|
|
573
571
|
status: String(e.status),
|
|
@@ -579,13 +577,13 @@ var L = A("_voltro_comment_threads", {
|
|
|
579
577
|
})
|
|
580
578
|
}],
|
|
581
579
|
bindDataStore: (e) => {
|
|
582
|
-
|
|
580
|
+
o = e, s = e;
|
|
583
581
|
},
|
|
584
582
|
onActivate: (e) => y.sync(() => {
|
|
585
|
-
|
|
583
|
+
i.access?.viaEntity === void 0 && i.access?.scope === void 0 && e.logger.warn("comments: no access rule declared — EVERY read and write will be refused (fail-closed). Set commentsPlugin({ access: { viaEntity } }) or { access: { scope } }."), e.logger.info("comments active", { mentions: i.resolveMentions !== void 0 });
|
|
586
584
|
}),
|
|
587
585
|
onDeactivate: () => y.sync(() => {
|
|
588
|
-
|
|
586
|
+
o = void 0, s = void 0;
|
|
589
587
|
})
|
|
590
588
|
});
|
|
591
589
|
}, G = async (e, t, n = /* @__PURE__ */ new Date()) => {
|
|
@@ -634,4 +632,4 @@ var L = A("_voltro_comment_threads", {
|
|
|
634
632
|
};
|
|
635
633
|
}, K = () => "plugin-comments";
|
|
636
634
|
//#endregion
|
|
637
|
-
export {
|
|
635
|
+
export { c as COMMENT_THREAD_KINDS, e as CommentAccessRefused, t as CommentNotFound, n as CommentNotYours, r as CommentStatusRefused, i as QUOTE_MAX_LENGTH, G as applyCommentRetention, B as commentReactionsTable, V as commentReadsTable, z as commentThreadEventsTable, L as commentThreadsTable, l as commentsFeed, W as commentsPlugin, R as commentsTable, a as findQuote, K as pluginComments, o as textQuote };
|
package/dist/quote.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/quote.ts
|
|
2
|
+
var e = 1e3, t = (t, n, r) => {
|
|
3
|
+
let i = Math.max(0, Math.min(n, r)), a = Math.min(t.length, Math.max(n, r), i + e), o = t.slice(Math.max(0, i - 32), i), s = t.slice(a, a + 32);
|
|
4
|
+
return {
|
|
5
|
+
exact: t.slice(i, a),
|
|
6
|
+
...o === "" ? {} : { prefix: o },
|
|
7
|
+
...s === "" ? {} : { suffix: s }
|
|
8
|
+
};
|
|
9
|
+
}, n = (e, t) => {
|
|
10
|
+
if (t.exact === "") return null;
|
|
11
|
+
let n = null;
|
|
12
|
+
for (let r = e.indexOf(t.exact); r !== -1; r = e.indexOf(t.exact, r + 1)) {
|
|
13
|
+
let i = e.slice(0, r), a = e.slice(r + t.exact.length), o = (t.prefix !== void 0 && i.endsWith(t.prefix) ? 1 : 0) + (t.suffix !== void 0 && a.startsWith(t.suffix) ? 1 : 0);
|
|
14
|
+
(n === null || o > n.score) && (n = {
|
|
15
|
+
start: r,
|
|
16
|
+
score: o
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return n === null ? null : {
|
|
20
|
+
start: n.start,
|
|
21
|
+
end: n.start + t.exact.length
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { e as QUOTE_MAX_LENGTH, n as findQuote, t as textQuote };
|