@voltro/plugin-chat 0.90.0 → 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 +121 -0
- package/THIRD-PARTY-NOTICES.md +247 -1418
- package/dist/index.js +53 -53
- package/dist/inspect.js +4 -4
- package/dist/mentionNotifications.js +12 -12
- package/dist/server.js +4 -4
- package/dist/service.js +745 -745
- package/dist/typing.js +40 -40
- package/dist/typingInvalidation.js +1 -1
- package/dist/web.js +5 -5
- package/package.json +18 -18
package/dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
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 {
|
|
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
18
|
import { defineLicensedGamePlugin as k } from "@voltro/plugin-licensing/gate";
|
|
19
19
|
import { Effect as A, Layer as j } from "effect";
|
|
20
20
|
import { fileURLToPath as M } from "node:url";
|
|
@@ -46,14 +46,14 @@ var F = {
|
|
|
46
46
|
},
|
|
47
47
|
ports: {},
|
|
48
48
|
events: [
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
v.name,
|
|
50
|
+
_.name,
|
|
51
|
+
y.name
|
|
52
52
|
]
|
|
53
|
-
}, I = (
|
|
54
|
-
let { voice:
|
|
55
|
-
let n =
|
|
56
|
-
return A.suspend(() => n === void 0 || n !==
|
|
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
57
|
}, I = (e, n, r) => {
|
|
58
58
|
try {
|
|
59
59
|
let t = structuredClone(e), i = structuredClone(n);
|
|
@@ -84,15 +84,15 @@ var F = {
|
|
|
84
84
|
transferOwnership: (e, t, n) => F((r) => r.service.transferOwnership(e, t, n))
|
|
85
85
|
};
|
|
86
86
|
return k({
|
|
87
|
-
name:
|
|
87
|
+
name: x,
|
|
88
88
|
description: "Membership-filtered durable chat with replaceable rule slots.",
|
|
89
89
|
eventClientPolicies: [{
|
|
90
|
-
id:
|
|
90
|
+
id: y.clientPolicy,
|
|
91
91
|
admit: (e) => F((t) => t.typingPolicy.admit(e)),
|
|
92
92
|
deliver: (e) => F((t) => t.typingPolicy.deliver(e)),
|
|
93
93
|
monitor: (e) => F((t) => t.typingPolicy.monitor(e))
|
|
94
94
|
}],
|
|
95
|
-
services: j.succeed(
|
|
95
|
+
services: j.succeed(b, {
|
|
96
96
|
readReportEvidence: (e, t) => I(e, t, (e, t, n) => e.readReportEvidence(t, n)),
|
|
97
97
|
collectReportContext: (e, t) => I(e, t, (e, t, n) => e.collectReportContext(t, n)),
|
|
98
98
|
prune: (e) => I(e, null, (e, t) => e.prune(t)),
|
|
@@ -104,18 +104,18 @@ var F = {
|
|
|
104
104
|
archiveMatch: (e, t) => I(e, t, (e, t, n) => e.archiveMatch(t, n))
|
|
105
105
|
}),
|
|
106
106
|
permissions: ["store:write", "inspect:read"],
|
|
107
|
-
routes: [...
|
|
108
|
-
...
|
|
107
|
+
routes: [...u(L), ...T === void 0 ? [] : [{
|
|
108
|
+
...w,
|
|
109
109
|
execute: (e, n) => {
|
|
110
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) =>
|
|
111
|
+
return r.type !== "user" || typeof r.tenantId != "string" ? A.fail(t("forbidden")) : A.flatMap(L.membership(r, e.channelId), (t) => T.join({
|
|
112
112
|
tenantId: r.tenantId,
|
|
113
113
|
subjectId: String(r.id),
|
|
114
114
|
channelId: e.channelId
|
|
115
115
|
}, t));
|
|
116
116
|
}
|
|
117
117
|
}]],
|
|
118
|
-
rpcClientDescriptors:
|
|
118
|
+
rpcClientDescriptors: T === void 0 ? S : [...S, ...C],
|
|
119
119
|
sources: M(new URL("./chat-app", "" + import.meta.url)),
|
|
120
120
|
errorSchemas: [{
|
|
121
121
|
schema: e,
|
|
@@ -125,23 +125,23 @@ var F = {
|
|
|
125
125
|
}
|
|
126
126
|
}],
|
|
127
127
|
extendSchema: { tables: [
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
h,
|
|
128
|
+
s,
|
|
129
|
+
c,
|
|
131
130
|
l,
|
|
131
|
+
o,
|
|
132
|
+
i,
|
|
132
133
|
r,
|
|
133
|
-
|
|
134
|
-
c
|
|
134
|
+
a
|
|
135
135
|
] },
|
|
136
136
|
subjectPrivacy: {
|
|
137
137
|
tables: [
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
h.tableName,
|
|
138
|
+
s.tableName,
|
|
139
|
+
c.tableName,
|
|
141
140
|
l.tableName,
|
|
141
|
+
o.tableName,
|
|
142
|
+
i.tableName,
|
|
142
143
|
r.tableName,
|
|
143
|
-
|
|
144
|
-
c.tableName
|
|
144
|
+
a.tableName
|
|
145
145
|
],
|
|
146
146
|
kinds: ["user", "guest"]
|
|
147
147
|
},
|
|
@@ -153,19 +153,19 @@ var F = {
|
|
|
153
153
|
handler: () => A.try({
|
|
154
154
|
try: () => ({
|
|
155
155
|
kind: "json",
|
|
156
|
-
data:
|
|
156
|
+
data: g(_, D !== void 0, O)
|
|
157
157
|
}),
|
|
158
158
|
catch: () => t("unavailable")
|
|
159
159
|
})
|
|
160
160
|
}],
|
|
161
161
|
bindDataStore: (e) => {
|
|
162
|
-
if (
|
|
163
|
-
|
|
162
|
+
if (E !== void 0 && E !== e) throw Error("Chat plugin instance cannot cross app stores");
|
|
163
|
+
E = e, D ??= n(e, _, v);
|
|
164
164
|
},
|
|
165
165
|
onActivate: (e) => A.tryPromise({
|
|
166
166
|
try: async () => {
|
|
167
|
-
if (
|
|
168
|
-
await
|
|
167
|
+
if (_.rateLimit?.hotStore !== void 0 && N(e.env) !== null) throw t("unavailable");
|
|
168
|
+
await v.activate(e.env, e.connectionRegistry), O = !0;
|
|
169
169
|
},
|
|
170
170
|
catch: () => t("unavailable")
|
|
171
171
|
}),
|
|
@@ -181,13 +181,13 @@ var F = {
|
|
|
181
181
|
})),
|
|
182
182
|
subjectMerge: {
|
|
183
183
|
tables: [
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
h,
|
|
184
|
+
s,
|
|
185
|
+
c,
|
|
187
186
|
l,
|
|
187
|
+
o,
|
|
188
|
+
i,
|
|
188
189
|
r,
|
|
189
|
-
|
|
190
|
-
c
|
|
190
|
+
a
|
|
191
191
|
].map((e) => e.tableName),
|
|
192
192
|
kinds: ["guest"]
|
|
193
193
|
},
|
|
@@ -195,13 +195,13 @@ var F = {
|
|
|
195
195
|
onDeactivate: () => A.tryPromise({
|
|
196
196
|
try: async () => {
|
|
197
197
|
try {
|
|
198
|
-
|
|
198
|
+
D?.disposeTyping();
|
|
199
199
|
} finally {
|
|
200
|
-
|
|
200
|
+
D = void 0, E = void 0, O = !1, await v.deactivate();
|
|
201
201
|
}
|
|
202
202
|
},
|
|
203
203
|
catch: () => t("unavailable")
|
|
204
204
|
})
|
|
205
205
|
});
|
|
206
206
|
};
|
|
207
|
-
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,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { defaultChatStrategies as e } from "./strategies.js";
|
|
2
|
+
import { chatError as t } from "./errors.js";
|
|
3
3
|
import { decodeChatStatus as n } from "@voltro/protocol/inspect";
|
|
4
4
|
// src/inspect.ts
|
|
5
5
|
var r = (r, i, a) => {
|
|
6
6
|
let o = r.now();
|
|
7
|
-
if (!Number.isSafeInteger(o) || o < 0 || o > 864e13) throw
|
|
7
|
+
if (!Number.isSafeInteger(o) || o < 0 || o > 864e13) throw t("unavailable");
|
|
8
8
|
return n({
|
|
9
9
|
observedAt: o,
|
|
10
10
|
bound: i,
|
|
@@ -23,7 +23,7 @@ var r = (r, i, a) => {
|
|
|
23
23
|
mediaContentTypes: r.mediaContentTypes,
|
|
24
24
|
maxMediaBytes: r.maxMediaBytes,
|
|
25
25
|
mediaUrlTtlSec: r.mediaUrlTtlSec,
|
|
26
|
-
slots: Object.fromEntries(Object.entries(
|
|
26
|
+
slots: Object.fromEntries(Object.entries(e).map(([e, t]) => [e, r.strategies[e] === t ? "default" : "custom"])),
|
|
27
27
|
tables: [
|
|
28
28
|
"_voltro_chat_channels",
|
|
29
29
|
"_voltro_chat_members",
|
|
@@ -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,
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { CHAT_MENTION_NOTIFICATION_EFFECT as e, CHAT_MENTION_NOTIFICATION_GUARD as t, createChatMentionNotifications as n } from "./mentionNotifications.js";
|
|
2
|
+
import { chatSanctionEvidenceCollector as r } from "./reportEvidence.js";
|
|
3
|
+
import { chatChannelId as i } from "./service.js";
|
|
4
4
|
import { Context as a } from "effect";
|
|
5
5
|
// src/server.ts
|
|
6
6
|
var o = class extends a.Service()("@voltro/ChatAdministration") {};
|
|
7
|
-
export {
|
|
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 };
|