@voltro/plugin-chat 0.89.2 → 0.91.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 +1943 -0
- package/README.md +16 -507
- package/THIRD-PARTY-NOTICES.md +248 -1419
- package/dist/components.js +160 -149
- package/dist/index.d.ts +66 -1
- package/dist/index.js +118 -91
- package/dist/inspect.js +27 -26
- package/dist/mentionNotifications.js +12 -12
- package/dist/messageLinks.js +29 -0
- package/dist/rpc.d.ts +14 -0
- package/dist/rpc.js +22 -2
- package/dist/server.d.ts +3 -0
- package/dist/server.js +4 -3
- package/dist/service.js +992 -905
- package/dist/strategies.d.ts +34 -0
- package/dist/typing.js +40 -40
- package/dist/typingInvalidation.js +1 -1
- package/dist/voice.js +76 -0
- package/dist/web.d.ts +49 -4
- package/dist/web.js +8 -7
- package/package.json +18 -18
package/dist/index.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { ChatError as e, chatError as t } from "./errors.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { chatMediaTable as
|
|
6
|
-
import { chatRetentionTable as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
2
|
+
import { dataStoreChat as n } from "./service.js";
|
|
3
|
+
import { chatAdmissionsTable as r } from "./admissions.entity.js";
|
|
4
|
+
import { chatEvidenceTable as i } from "./evidence.entity.js";
|
|
5
|
+
import { chatMediaTable as a } from "./media.entity.js";
|
|
6
|
+
import { chatRetentionTable as o } from "./retention.entity.js";
|
|
7
|
+
import { chatChannelsTable as s } from "./channels.entity.js";
|
|
8
|
+
import { chatMembersTable as c } from "./members.entity.js";
|
|
9
|
+
import { chatMessagesTable as l } from "./messages.entity.js";
|
|
10
|
+
import { chatRpcRoutes as u } from "./rpcRoutes.js";
|
|
11
|
+
import { devVoiceProvider as d, liveKitVoiceProvider as f, resolveChatVoice as p } from "./voice.js";
|
|
12
|
+
import { defaultChatStrategies as m, resolveChatOptions as h } from "./strategies.js";
|
|
13
|
+
import { chatStatus as g } from "./inspect.js";
|
|
14
|
+
import { mentioned as _, messageChanged as v, typing as y } from "./events.js";
|
|
15
|
+
import { ChatAdministration as b } from "./server.js";
|
|
16
|
+
import { BASE_NAME as x, chatRpcClientImports as S, chatVoiceRpcClientImports as C, voiceJoinDescriptor as w } from "./rpc.js";
|
|
17
|
+
import { CHAT_MAX_MESSAGE_VERSION as T, CHAT_MEDIA_SWEEP_BATCH_SIZE as E, CHAT_RETENTION_BATCH_SIZE as D, CHAT_RETENTION_RUN_BATCHES as O } from "./contract.js";
|
|
18
|
+
import { defineLicensedGamePlugin as k } from "@voltro/plugin-licensing/gate";
|
|
19
|
+
import { Effect as A, Layer as j } from "effect";
|
|
20
|
+
import { fileURLToPath as M } from "node:url";
|
|
21
|
+
import { replicaEvidence as N } from "@voltro/protocol/identity";
|
|
22
|
+
import { redisStore as P } from "@voltro/plugin-ratelimit";
|
|
22
23
|
// src/index.ts
|
|
23
|
-
var
|
|
24
|
+
var F = {
|
|
24
25
|
slots: {
|
|
25
26
|
moderate: {
|
|
26
27
|
defaultExport: "keywordChatModeration",
|
|
@@ -45,64 +46,77 @@ var A = {
|
|
|
45
46
|
},
|
|
46
47
|
ports: {},
|
|
47
48
|
events: [
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
v.name,
|
|
50
|
+
_.name,
|
|
51
|
+
y.name
|
|
51
52
|
]
|
|
52
|
-
},
|
|
53
|
-
let
|
|
53
|
+
}, I = (d = {}) => {
|
|
54
|
+
let { voice: f, ...m } = d, _ = h(m), v = P(_.rateLimit), T = f === void 0 ? void 0 : p(f), E, D, O = !1, F = (e) => {
|
|
55
|
+
let n = D;
|
|
56
|
+
return A.suspend(() => n === void 0 || n !== D ? A.fail(t("unavailable")) : e(n).pipe(A.flatMap((e) => n === D ? A.succeed(e) : A.fail(t("unavailable")))));
|
|
57
|
+
}, I = (e, n, r) => {
|
|
54
58
|
try {
|
|
55
59
|
let t = structuredClone(e), i = structuredClone(n);
|
|
56
|
-
return
|
|
60
|
+
return F((e) => r(e, t, i));
|
|
57
61
|
} catch {
|
|
58
|
-
return
|
|
62
|
+
return A.fail(t("invalid_input"));
|
|
59
63
|
}
|
|
64
|
+
}, L = {
|
|
65
|
+
mentionCandidates: (e, t) => I(e, t, (e, t, n) => e.service.mentionCandidates(t, n)),
|
|
66
|
+
authors: (e, t) => I(e, t, (e, t, n) => e.service.authors(t, n)),
|
|
67
|
+
prepareTyping: (e, t) => F((n) => n.service.prepareTyping(e, t)),
|
|
68
|
+
dm: (e, t) => F((n) => n.service.dm(e, t)),
|
|
69
|
+
send: (e, t) => F((n) => n.service.send(e, t)),
|
|
70
|
+
edit: (e, t) => F((n) => n.service.edit(e, t)),
|
|
71
|
+
remove: (e, t) => F((n) => n.service.remove(e, t)),
|
|
72
|
+
messages: (e, t) => F((n) => n.service.messages(e, t)),
|
|
73
|
+
channel: (e, t) => F((n) => n.service.channel(e, t)),
|
|
74
|
+
membership: (e, t) => F((n) => n.service.membership(e, t)),
|
|
75
|
+
unread: (e) => F((t) => t.service.unread(e)),
|
|
76
|
+
original: (e, t) => F((n) => n.service.original(e, t)),
|
|
77
|
+
mediaUrl: (e, t) => F((n) => n.service.mediaUrl(e, t)),
|
|
78
|
+
channels: (e) => F((t) => t.service.channels(e)),
|
|
79
|
+
markRead: (e, t, n) => F((r) => r.service.markRead(e, t, n)),
|
|
80
|
+
moderateMember: (e, t) => F((n) => n.service.moderateMember(e, t)),
|
|
81
|
+
configure: (e, t) => F((n) => n.service.configure(e, t)),
|
|
82
|
+
join: (e, t) => F((n) => n.service.join(e, t)),
|
|
83
|
+
leave: (e, t) => F((n) => n.service.leave(e, t)),
|
|
84
|
+
transferOwnership: (e, t, n) => F((r) => r.service.transferOwnership(e, t, n))
|
|
60
85
|
};
|
|
61
|
-
return
|
|
62
|
-
name:
|
|
86
|
+
return k({
|
|
87
|
+
name: x,
|
|
63
88
|
description: "Membership-filtered durable chat with replaceable rule slots.",
|
|
64
89
|
eventClientPolicies: [{
|
|
65
|
-
id:
|
|
66
|
-
admit: (e) =>
|
|
67
|
-
deliver: (e) =>
|
|
68
|
-
monitor: (e) =>
|
|
90
|
+
id: y.clientPolicy,
|
|
91
|
+
admit: (e) => F((t) => t.typingPolicy.admit(e)),
|
|
92
|
+
deliver: (e) => F((t) => t.typingPolicy.deliver(e)),
|
|
93
|
+
monitor: (e) => F((t) => t.typingPolicy.monitor(e))
|
|
69
94
|
}],
|
|
70
|
-
services:
|
|
71
|
-
readReportEvidence: (e, t) =>
|
|
72
|
-
collectReportContext: (e, t) =>
|
|
73
|
-
prune: (e) =>
|
|
74
|
-
sweepMedia: (e) =>
|
|
75
|
-
canNotifyMention: (e, t) =>
|
|
76
|
-
createChannel: (e, t) =>
|
|
77
|
-
addMember: (e, t) =>
|
|
78
|
-
removeMember: (e, t) =>
|
|
79
|
-
archiveMatch: (e, t) =>
|
|
95
|
+
services: j.succeed(b, {
|
|
96
|
+
readReportEvidence: (e, t) => I(e, t, (e, t, n) => e.readReportEvidence(t, n)),
|
|
97
|
+
collectReportContext: (e, t) => I(e, t, (e, t, n) => e.collectReportContext(t, n)),
|
|
98
|
+
prune: (e) => I(e, null, (e, t) => e.prune(t)),
|
|
99
|
+
sweepMedia: (e) => I(e, null, (e, t) => e.sweepMedia(t)),
|
|
100
|
+
canNotifyMention: (e, t) => I(e, t, (e, t, n) => e.canNotifyMention(t, n)),
|
|
101
|
+
createChannel: (e, t) => I(e, t, (e, t, n) => e.createChannel(t, n)),
|
|
102
|
+
addMember: (e, t) => I(e, t, (e, t, n) => e.addMember(t, n)),
|
|
103
|
+
removeMember: (e, t) => I(e, t, (e, t, n) => e.removeMember(t, n)),
|
|
104
|
+
archiveMatch: (e, t) => I(e, t, (e, t, n) => e.archiveMatch(t, n))
|
|
80
105
|
}),
|
|
81
106
|
permissions: ["store:write", "inspect:read"],
|
|
82
|
-
routes:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
mediaUrl: (e, t) => b((n) => n.service.mediaUrl(e, t)),
|
|
96
|
-
channels: (e) => b((t) => t.service.channels(e)),
|
|
97
|
-
markRead: (e, t, n) => b((r) => r.service.markRead(e, t, n)),
|
|
98
|
-
moderateMember: (e, t) => b((n) => n.service.moderateMember(e, t)),
|
|
99
|
-
configure: (e, t) => b((n) => n.service.configure(e, t)),
|
|
100
|
-
join: (e, t) => b((n) => n.service.join(e, t)),
|
|
101
|
-
leave: (e, t) => b((n) => n.service.leave(e, t)),
|
|
102
|
-
transferOwnership: (e, t, n) => b((r) => r.service.transferOwnership(e, t, n))
|
|
103
|
-
}),
|
|
104
|
-
rpcClientDescriptors: v,
|
|
105
|
-
sources: D(new URL("./chat-app", "" + import.meta.url)),
|
|
107
|
+
routes: [...u(L), ...T === void 0 ? [] : [{
|
|
108
|
+
...w,
|
|
109
|
+
execute: (e, n) => {
|
|
110
|
+
let r = n.request.subject;
|
|
111
|
+
return r.type !== "user" || typeof r.tenantId != "string" ? A.fail(t("forbidden")) : A.flatMap(L.membership(r, e.channelId), (t) => T.join({
|
|
112
|
+
tenantId: r.tenantId,
|
|
113
|
+
subjectId: String(r.id),
|
|
114
|
+
channelId: e.channelId
|
|
115
|
+
}, t));
|
|
116
|
+
}
|
|
117
|
+
}]],
|
|
118
|
+
rpcClientDescriptors: T === void 0 ? S : [...S, ...C],
|
|
119
|
+
sources: M(new URL("./chat-app", "" + import.meta.url)),
|
|
106
120
|
errorSchemas: [{
|
|
107
121
|
schema: e,
|
|
108
122
|
import: {
|
|
@@ -111,23 +125,23 @@ var A = {
|
|
|
111
125
|
}
|
|
112
126
|
}],
|
|
113
127
|
extendSchema: { tables: [
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
h,
|
|
128
|
+
s,
|
|
129
|
+
c,
|
|
117
130
|
l,
|
|
131
|
+
o,
|
|
132
|
+
i,
|
|
118
133
|
r,
|
|
119
|
-
|
|
120
|
-
c
|
|
134
|
+
a
|
|
121
135
|
] },
|
|
122
136
|
subjectPrivacy: {
|
|
123
137
|
tables: [
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
h.tableName,
|
|
138
|
+
s.tableName,
|
|
139
|
+
c.tableName,
|
|
127
140
|
l.tableName,
|
|
141
|
+
o.tableName,
|
|
142
|
+
i.tableName,
|
|
128
143
|
r.tableName,
|
|
129
|
-
|
|
130
|
-
c.tableName
|
|
144
|
+
a.tableName
|
|
131
145
|
],
|
|
132
146
|
kinds: ["user", "guest"]
|
|
133
147
|
},
|
|
@@ -136,45 +150,58 @@ var A = {
|
|
|
136
150
|
path: "/status",
|
|
137
151
|
scope: "process",
|
|
138
152
|
description: "Declared chat budgets and process binding; no channel/message/body enumeration.",
|
|
139
|
-
handler: () =>
|
|
153
|
+
handler: () => A.try({
|
|
140
154
|
try: () => ({
|
|
141
155
|
kind: "json",
|
|
142
|
-
data:
|
|
156
|
+
data: g(_, D !== void 0, O)
|
|
143
157
|
}),
|
|
144
158
|
catch: () => t("unavailable")
|
|
145
159
|
})
|
|
146
160
|
}],
|
|
147
161
|
bindDataStore: (e) => {
|
|
148
|
-
if (
|
|
149
|
-
|
|
162
|
+
if (E !== void 0 && E !== e) throw Error("Chat plugin instance cannot cross app stores");
|
|
163
|
+
E = e, D ??= n(e, _, v);
|
|
150
164
|
},
|
|
151
|
-
onActivate: (e) =>
|
|
165
|
+
onActivate: (e) => A.tryPromise({
|
|
152
166
|
try: async () => {
|
|
153
|
-
if (
|
|
154
|
-
await
|
|
167
|
+
if (_.rateLimit?.hotStore !== void 0 && N(e.env) !== null) throw t("unavailable");
|
|
168
|
+
await v.activate(e.env, e.connectionRegistry), O = !0;
|
|
155
169
|
},
|
|
156
170
|
catch: () => t("unavailable")
|
|
157
171
|
}),
|
|
158
|
-
onExport: (e, t) =>
|
|
172
|
+
onExport: (e, t) => F((n) => n.exportSubject({
|
|
159
173
|
subjectId: e,
|
|
160
174
|
tenantId: t.tenantId,
|
|
161
175
|
kind: t.kind
|
|
162
176
|
})),
|
|
163
|
-
onErase: (e, t) =>
|
|
177
|
+
onErase: (e, t) => F((n) => n.eraseSubject({
|
|
164
178
|
subjectId: e,
|
|
165
179
|
tenantId: t.tenantId,
|
|
166
180
|
kind: t.kind
|
|
167
181
|
})),
|
|
168
|
-
|
|
182
|
+
subjectMerge: {
|
|
183
|
+
tables: [
|
|
184
|
+
s,
|
|
185
|
+
c,
|
|
186
|
+
l,
|
|
187
|
+
o,
|
|
188
|
+
i,
|
|
189
|
+
r,
|
|
190
|
+
a
|
|
191
|
+
].map((e) => e.tableName),
|
|
192
|
+
kinds: ["guest"]
|
|
193
|
+
},
|
|
194
|
+
onMergeAccounts: (e) => F((t) => t.mergeSubject(e)),
|
|
195
|
+
onDeactivate: () => A.tryPromise({
|
|
169
196
|
try: async () => {
|
|
170
197
|
try {
|
|
171
|
-
|
|
198
|
+
D?.disposeTyping();
|
|
172
199
|
} finally {
|
|
173
|
-
|
|
200
|
+
D = void 0, E = void 0, O = !1, await v.deactivate();
|
|
174
201
|
}
|
|
175
202
|
},
|
|
176
203
|
catch: () => t("unavailable")
|
|
177
204
|
})
|
|
178
205
|
});
|
|
179
206
|
};
|
|
180
|
-
export {
|
|
207
|
+
export { T as CHAT_MAX_MESSAGE_VERSION, E as CHAT_MEDIA_SWEEP_BATCH_SIZE, D as CHAT_RETENTION_BATCH_SIZE, O as CHAT_RETENTION_RUN_BATCHES, e as ChatError, r as chatAdmissionsTable, s as chatChannelsTable, i as chatEvidenceTable, a as chatMediaTable, c as chatMembersTable, l as chatMessagesTable, I as chatPlugin, o as chatRetentionTable, F as chatSystemContract, n as dataStoreChat, m as defaultChatStrategies, d as devVoiceProvider, f as liveKitVoiceProvider, h as resolveChatOptions };
|
package/dist/inspect.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { defaultChatStrategies as e } from "./strategies.js";
|
|
2
|
+
import { chatError as t } from "./errors.js";
|
|
3
|
+
import { decodeChatStatus as n } from "@voltro/protocol/inspect";
|
|
3
4
|
// src/inspect.ts
|
|
4
|
-
var
|
|
5
|
-
let
|
|
6
|
-
if (!Number.isSafeInteger(
|
|
7
|
-
return {
|
|
8
|
-
observedAt:
|
|
9
|
-
bound:
|
|
10
|
-
rateActive:
|
|
11
|
-
maxBodyLength:
|
|
12
|
-
pageSize:
|
|
13
|
-
maxMembers:
|
|
14
|
-
maxChannelsPerSubject:
|
|
15
|
-
retentionMs:
|
|
16
|
-
evidenceRetentionMs:
|
|
17
|
-
perChannelRate:
|
|
18
|
-
globalRate:
|
|
19
|
-
maxMentions:
|
|
20
|
-
moderationAction:
|
|
21
|
-
denyWordCount:
|
|
22
|
-
mediaContentTypes:
|
|
23
|
-
maxMediaBytes:
|
|
24
|
-
mediaUrlTtlSec:
|
|
25
|
-
slots: Object.fromEntries(Object.entries(
|
|
5
|
+
var r = (r, i, a) => {
|
|
6
|
+
let o = r.now();
|
|
7
|
+
if (!Number.isSafeInteger(o) || o < 0 || o > 864e13) throw t("unavailable");
|
|
8
|
+
return n({
|
|
9
|
+
observedAt: o,
|
|
10
|
+
bound: i,
|
|
11
|
+
rateActive: a,
|
|
12
|
+
maxBodyLength: r.maxBodyLength,
|
|
13
|
+
pageSize: r.pageSize,
|
|
14
|
+
maxMembers: r.maxMembers,
|
|
15
|
+
maxChannelsPerSubject: r.maxChannelsPerSubject,
|
|
16
|
+
retentionMs: r.retentionMs,
|
|
17
|
+
evidenceRetentionMs: r.evidenceRetentionMs,
|
|
18
|
+
perChannelRate: r.perChannelRate,
|
|
19
|
+
globalRate: r.globalRate,
|
|
20
|
+
maxMentions: r.maxMentions,
|
|
21
|
+
moderationAction: r.moderationAction,
|
|
22
|
+
denyWordCount: r.denyWords.length,
|
|
23
|
+
mediaContentTypes: r.mediaContentTypes,
|
|
24
|
+
maxMediaBytes: r.maxMediaBytes,
|
|
25
|
+
mediaUrlTtlSec: r.mediaUrlTtlSec,
|
|
26
|
+
slots: Object.fromEntries(Object.entries(e).map(([e, t]) => [e, r.strategies[e] === t ? "default" : "custom"])),
|
|
26
27
|
tables: [
|
|
27
28
|
"_voltro_chat_channels",
|
|
28
29
|
"_voltro_chat_members",
|
|
@@ -32,6 +33,6 @@ var n = (n, r, i) => {
|
|
|
32
33
|
"_voltro_chat_admissions",
|
|
33
34
|
"_voltro_chat_media"
|
|
34
35
|
]
|
|
35
|
-
};
|
|
36
|
+
});
|
|
36
37
|
};
|
|
37
|
-
export {
|
|
38
|
+
export { r as chatStatus };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ChatAdministration as e } from "./server.js";
|
|
2
|
+
import { chatError as t } from "./errors.js";
|
|
3
3
|
import { chatEventTenant as n, committedChatMentions as r } from "./eventProducer.js";
|
|
4
|
-
import {
|
|
4
|
+
import { MESSAGES_TABLE as i } from "./contract.js";
|
|
5
5
|
import { Effect as a, Schema as o } from "effect";
|
|
6
6
|
import { createHash as s } from "node:crypto";
|
|
7
7
|
import { defineOutboxHandler as c, defineSubscriber as l } from "@voltro/runtime";
|
|
@@ -34,7 +34,7 @@ var f = "voltro.chat.mention.notify", p = "chat.mention", m = o.NonEmptyString.p
|
|
|
34
34
|
}
|
|
35
35
|
})
|
|
36
36
|
}), v = (u) => {
|
|
37
|
-
let m = structuredClone(u.subject), v = u.run, y = u.service, b = u.outboxForTenant, x = u.localeFor, S = (
|
|
37
|
+
let m = structuredClone(u.subject), v = u.run, y = u.service, b = u.outboxForTenant, x = u.localeFor, S = (t) => v(a.flatMap(e, (e) => e.canNotifyMention(m, t))), C = async (e) => {
|
|
38
38
|
let t = o.decodeUnknownSync(h)(e.payload);
|
|
39
39
|
return e.tenantId !== t.tenantId || e.recipientId !== t.recipientId ? !1 : S(t);
|
|
40
40
|
}, w = async (e) => {
|
|
@@ -59,17 +59,17 @@ var f = "voltro.chat.mention.notify", p = "chat.mention", m = o.NonEmptyString.p
|
|
|
59
59
|
outboxHandler: c({
|
|
60
60
|
effect: f,
|
|
61
61
|
maxAttempts: 5,
|
|
62
|
-
handler: async (
|
|
63
|
-
let n = o.decodeUnknownSync(g)(
|
|
64
|
-
if (
|
|
62
|
+
handler: async (e) => {
|
|
63
|
+
let n = o.decodeUnknownSync(g)(e.payload);
|
|
64
|
+
if (e.tenantId !== n.tenantId) throw t("identity_required");
|
|
65
65
|
if (!await S(n)) return { skipped: !0 };
|
|
66
66
|
let r = y();
|
|
67
|
-
if (!r) throw
|
|
67
|
+
if (!r) throw t("unavailable");
|
|
68
68
|
return d({
|
|
69
69
|
notifications: [_],
|
|
70
|
-
service: () => ({ send: async (
|
|
70
|
+
service: () => ({ send: async (e) => {
|
|
71
71
|
let i = await r.send({
|
|
72
|
-
...
|
|
72
|
+
...e,
|
|
73
73
|
deliveryGuard: {
|
|
74
74
|
id: p,
|
|
75
75
|
payload: {
|
|
@@ -80,7 +80,7 @@ var f = "voltro.chat.mention.notify", p = "chat.mention", m = o.NonEmptyString.p
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
|
-
if (i.failed.length > 0) throw
|
|
83
|
+
if (i.failed.length > 0) throw t("unavailable");
|
|
84
84
|
return i;
|
|
85
85
|
} })
|
|
86
86
|
}).handler({ payload: {
|
|
@@ -96,7 +96,7 @@ var f = "voltro.chat.mention.notify", p = "chat.mention", m = o.NonEmptyString.p
|
|
|
96
96
|
}
|
|
97
97
|
}),
|
|
98
98
|
subscriber: l({
|
|
99
|
-
table:
|
|
99
|
+
table: i,
|
|
100
100
|
on: ["insert"],
|
|
101
101
|
once: !0,
|
|
102
102
|
eventTenant: n,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/messageLinks.ts
|
|
2
|
+
var e = /\bhttps?:\/\/[^\s<>"'`]+/gi, t = /[.,;:!?)\]}'"»”’]+$/, n = (n, r = 20) => {
|
|
3
|
+
if (typeof n != "string" || n === "") return [];
|
|
4
|
+
let i = [], a = 0, o = 0;
|
|
5
|
+
for (let s of n.matchAll(e)) {
|
|
6
|
+
if (o >= r) break;
|
|
7
|
+
let e = s.index ?? 0, c = s[0].replace(t, ""), l;
|
|
8
|
+
try {
|
|
9
|
+
let e = new URL(c);
|
|
10
|
+
if (e.protocol !== "http:" && e.protocol !== "https:" || e.username || e.password || !e.hostname) continue;
|
|
11
|
+
l = e.href;
|
|
12
|
+
} catch {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
e > a && i.push({
|
|
16
|
+
kind: "text",
|
|
17
|
+
text: n.slice(a, e)
|
|
18
|
+
}), i.push({
|
|
19
|
+
kind: "link",
|
|
20
|
+
text: c,
|
|
21
|
+
href: l
|
|
22
|
+
}), a = e + c.length, o++;
|
|
23
|
+
}
|
|
24
|
+
return a < n.length && i.push({
|
|
25
|
+
kind: "text",
|
|
26
|
+
text: n.slice(a)
|
|
27
|
+
}), i;
|
|
28
|
+
};
|
|
29
|
+
export { n as chatMessageSegments };
|
package/dist/rpc.d.ts
CHANGED
|
@@ -52,6 +52,8 @@ declare const ChatError_base: Schema.Class<ChatError, Schema.TaggedStruct<"ChatE
|
|
|
52
52
|
|
|
53
53
|
export declare const chatRpcClientImports: ReadonlyArray<PluginRpcClientDescriptor>;
|
|
54
54
|
|
|
55
|
+
export declare const chatVoiceRpcClientImports: ReadonlyArray<PluginRpcClientDescriptor>;
|
|
56
|
+
|
|
55
57
|
export declare const configureDescriptor: ActionProcedureDescriptor<"chat.configure", Schema.Struct<{
|
|
56
58
|
readonly channelId: Schema.NonEmptyString;
|
|
57
59
|
readonly slowModeMs: Schema.optional<Schema.Number>;
|
|
@@ -292,4 +294,16 @@ export declare const unreadDescriptor: QueryProcedureDescriptor<"chat.unread", S
|
|
|
292
294
|
readonly truncated: Schema.Boolean;
|
|
293
295
|
}>>, typeof ChatError>;
|
|
294
296
|
|
|
297
|
+
/** Voice chat (`chatPlugin({ voice })`): a join ticket for the channel's voice room at the configured SFU. */
|
|
298
|
+
export declare const voiceJoinDescriptor: ActionProcedureDescriptor<"chat.voice.join", Schema.Struct<{
|
|
299
|
+
readonly channelId: Schema.NonEmptyString;
|
|
300
|
+
}>, Schema.Struct<{
|
|
301
|
+
readonly provider: Schema.String;
|
|
302
|
+
readonly room: Schema.String;
|
|
303
|
+
readonly canPublish: Schema.Boolean;
|
|
304
|
+
readonly url: Schema.String;
|
|
305
|
+
readonly token: Schema.String;
|
|
306
|
+
readonly expiresAt: Schema.Number;
|
|
307
|
+
}>, typeof ChatError>;
|
|
308
|
+
|
|
295
309
|
export { }
|
package/dist/rpc.js
CHANGED
|
@@ -226,7 +226,27 @@ var g = "@voltro/plugin-chat", _ = "The handler verifies human identity, same-te
|
|
|
226
226
|
output: p.Void,
|
|
227
227
|
error: e,
|
|
228
228
|
openAccess: _
|
|
229
|
-
}), B =
|
|
229
|
+
}), B = m({
|
|
230
|
+
name: "chat.voice.join",
|
|
231
|
+
input: y,
|
|
232
|
+
output: p.Struct({
|
|
233
|
+
provider: p.String,
|
|
234
|
+
room: p.String,
|
|
235
|
+
canPublish: p.Boolean,
|
|
236
|
+
url: p.String,
|
|
237
|
+
token: p.String,
|
|
238
|
+
expiresAt: p.Number
|
|
239
|
+
}),
|
|
240
|
+
error: e,
|
|
241
|
+
openAccess: "Channel member; a muted member may listen only. The token is short-lived and for this channel only."
|
|
242
|
+
}), V = [{
|
|
243
|
+
tag: "chat.voice.join",
|
|
244
|
+
kind: "action",
|
|
245
|
+
import: {
|
|
246
|
+
module: "@voltro/plugin-chat/rpc",
|
|
247
|
+
name: "voiceJoinDescriptor"
|
|
248
|
+
}
|
|
249
|
+
}], H = [...[
|
|
230
250
|
"setTyping",
|
|
231
251
|
"dm",
|
|
232
252
|
"send",
|
|
@@ -263,4 +283,4 @@ var g = "@voltro/plugin-chat", _ = "The handler verifies human identity, same-te
|
|
|
263
283
|
name: e + "Descriptor"
|
|
264
284
|
}
|
|
265
285
|
}))];
|
|
266
|
-
export { g as BASE_NAME, D as authorsDescriptor, O as channelDescriptor, A as channelsDescriptor,
|
|
286
|
+
export { g as BASE_NAME, D as authorsDescriptor, O as channelDescriptor, A as channelsDescriptor, H as chatRpcClientImports, V as chatVoiceRpcClientImports, I as configureDescriptor, x as dmDescriptor, C as editDescriptor, L as joinDescriptor, R as leaveDescriptor, P as markReadDescriptor, N as mediaUrlDescriptor, k as membershipDescriptor, E as mentionCandidatesDescriptor, T as messagesDescriptor, F as muteDescriptor, M as originalDescriptor, w as removeDescriptor, S as sendDescriptor, b as setTypingDescriptor, z as transferOwnershipDescriptor, j as unreadDescriptor, B as voiceJoinDescriptor };
|
package/dist/server.d.ts
CHANGED
|
@@ -68,6 +68,9 @@ export declare interface ChatAdministrationService {
|
|
|
68
68
|
|
|
69
69
|
declare type ChatChannel = typeof ChatChannelSchema.Type;
|
|
70
70
|
|
|
71
|
+
/** The id of the channel `createChannel` makes for one tenant, kind and reference. */
|
|
72
|
+
export declare const chatChannelId: (tenantId: string, kind: string, refId: string) => string;
|
|
73
|
+
|
|
71
74
|
declare const ChatChannelSchema: Schema.Struct<{
|
|
72
75
|
readonly id: Schema.String;
|
|
73
76
|
readonly kind: Schema.Literals<readonly ["global", "lobby", "party", "guild", "match", "dm", "custom"]>;
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CHAT_MENTION_NOTIFICATION_EFFECT as e, CHAT_MENTION_NOTIFICATION_GUARD as t, createChatMentionNotifications as n } from "./mentionNotifications.js";
|
|
2
2
|
import { chatSanctionEvidenceCollector as r } from "./reportEvidence.js";
|
|
3
|
-
import {
|
|
3
|
+
import { chatChannelId as i } from "./service.js";
|
|
4
|
+
import { Context as a } from "effect";
|
|
4
5
|
// src/server.ts
|
|
5
|
-
var
|
|
6
|
-
export { e as CHAT_MENTION_NOTIFICATION_EFFECT, t as CHAT_MENTION_NOTIFICATION_GUARD,
|
|
6
|
+
var o = class extends a.Service()("@voltro/ChatAdministration") {};
|
|
7
|
+
export { e as CHAT_MENTION_NOTIFICATION_EFFECT, t as CHAT_MENTION_NOTIFICATION_GUARD, o as ChatAdministration, i as chatChannelId, r as chatSanctionEvidenceCollector, n as createChatMentionNotifications };
|