@voltro/plugin-chat 0.0.0-stage → 0.87.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 +24329 -0
- package/LICENSE +61 -0
- package/README.md +516 -2
- package/SECURITY.md +56 -0
- package/THIRD-PARTY-NOTICES.md +14931 -0
- package/dist/admissions.entity.js +11 -0
- package/dist/channels.entity.js +20 -0
- package/dist/chat-app/events/chat.mentioned.event.ts +1 -0
- package/dist/chat-app/events/chat.messageChanged.event.ts +1 -0
- package/dist/chat-app/events/chat.typing.event.ts +1 -0
- package/dist/chat-app/schedules/chat.retention.cron.tsx +16 -0
- package/dist/chat-app/subscribers/chat.messages.subscribe.ts +4 -0
- package/dist/components.js +432 -0
- package/dist/contract.js +92 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.js +21 -0
- package/dist/eventProducer.d.ts +18 -0
- package/dist/eventProducer.js +46 -0
- package/dist/events.d.ts +38 -0
- package/dist/events.js +36 -0
- package/dist/evidence.entity.js +25 -0
- package/dist/index.d.ts +623 -0
- package/dist/index.js +181 -0
- package/dist/inspect.js +38 -0
- package/dist/media.entity.js +15 -0
- package/dist/members.entity.js +22 -0
- package/dist/mentionDraft.js +21 -0
- package/dist/mentionNotifications.js +110 -0
- package/dist/messages.entity.js +28 -0
- package/dist/reportEvidence.js +16 -0
- package/dist/retention.entity.js +11 -0
- package/dist/rpc.d.ts +295 -0
- package/dist/rpc.js +267 -0
- package/dist/rpcRoutes.js +97 -0
- package/dist/server.d.ts +200 -0
- package/dist/server.js +7 -0
- package/dist/service.js +1412 -0
- package/dist/strategies.d.ts +148 -0
- package/dist/strategies.js +90 -0
- package/dist/testing.d.ts +139 -0
- package/dist/testing.js +111 -0
- package/dist/typing.js +88 -0
- package/dist/typingInvalidation.js +86 -0
- package/dist/typingLease.js +59 -0
- package/dist/typingPublisher.js +59 -0
- package/dist/useChatTypingPublisher.js +33 -0
- package/dist/useTyping.js +24 -0
- package/dist/web.d.ts +354 -0
- package/dist/web.js +19 -0
- package/package.json +98 -4
package/dist/rpc.d.ts
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { ActionProcedureDescriptor } from '@voltro/protocol';
|
|
2
|
+
import { PluginRpcClientDescriptor } from '@voltro/protocol';
|
|
3
|
+
import { QueryProcedureDescriptor } from '@voltro/protocol';
|
|
4
|
+
import { Schema } from 'effect';
|
|
5
|
+
import { YieldableError } from 'effect/Cause';
|
|
6
|
+
|
|
7
|
+
export declare const authorsDescriptor: QueryProcedureDescriptor<"chat.authors", Schema.Struct<{
|
|
8
|
+
readonly channelId: Schema.NonEmptyString;
|
|
9
|
+
readonly subjectIds: Schema.$Array<Schema.NonEmptyString>;
|
|
10
|
+
}>, Schema.$Array<Schema.Struct<{
|
|
11
|
+
readonly subjectId: Schema.String;
|
|
12
|
+
readonly displayName: Schema.String;
|
|
13
|
+
readonly avatar: Schema.NullOr<Schema.String>;
|
|
14
|
+
}>>, typeof ChatError>;
|
|
15
|
+
|
|
16
|
+
export declare const BASE_NAME = "@voltro/plugin-chat";
|
|
17
|
+
|
|
18
|
+
export declare const channelDescriptor: QueryProcedureDescriptor<"chat.channel", Schema.Struct<{
|
|
19
|
+
readonly channelId: Schema.NonEmptyString;
|
|
20
|
+
}>, Schema.Struct<{
|
|
21
|
+
readonly id: Schema.String;
|
|
22
|
+
readonly kind: Schema.Literals<readonly ["global", "lobby", "party", "guild", "match", "dm", "custom"]>;
|
|
23
|
+
readonly refId: Schema.String;
|
|
24
|
+
readonly name: Schema.String;
|
|
25
|
+
readonly slowModeMs: Schema.Number;
|
|
26
|
+
readonly retentionMs: Schema.NullOr<Schema.Number>;
|
|
27
|
+
readonly maxMembers: Schema.Number;
|
|
28
|
+
readonly frozen: Schema.Boolean;
|
|
29
|
+
readonly createdAt: Schema.Number;
|
|
30
|
+
readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
31
|
+
}>, typeof ChatError>;
|
|
32
|
+
|
|
33
|
+
export declare const channelsDescriptor: QueryProcedureDescriptor<"chat.channels", Schema.Struct<{}>, Schema.$Array<Schema.Struct<{
|
|
34
|
+
readonly id: Schema.String;
|
|
35
|
+
readonly kind: Schema.Literals<readonly ["global", "lobby", "party", "guild", "match", "dm", "custom"]>;
|
|
36
|
+
readonly refId: Schema.String;
|
|
37
|
+
readonly name: Schema.String;
|
|
38
|
+
readonly slowModeMs: Schema.Number;
|
|
39
|
+
readonly retentionMs: Schema.NullOr<Schema.Number>;
|
|
40
|
+
readonly maxMembers: Schema.Number;
|
|
41
|
+
readonly frozen: Schema.Boolean;
|
|
42
|
+
readonly createdAt: Schema.Number;
|
|
43
|
+
readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
44
|
+
}>>, typeof ChatError>;
|
|
45
|
+
|
|
46
|
+
declare class ChatError extends ChatError_base {
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare const ChatError_base: Schema.Class<ChatError, Schema.TaggedStruct<"ChatError", {
|
|
50
|
+
readonly code: Schema.Literals<readonly ["identity_required", "invalid_input", "not_found", "forbidden", "blocked", "sanctioned", "muted", "slow_mode", "rate_limited", "content_rejected", "conflict", "frozen", "member_limit", "unavailable", "export_limit"]>;
|
|
51
|
+
}>, YieldableError>;
|
|
52
|
+
|
|
53
|
+
export declare const chatRpcClientImports: ReadonlyArray<PluginRpcClientDescriptor>;
|
|
54
|
+
|
|
55
|
+
export declare const configureDescriptor: ActionProcedureDescriptor<"chat.configure", Schema.Struct<{
|
|
56
|
+
readonly channelId: Schema.NonEmptyString;
|
|
57
|
+
readonly slowModeMs: Schema.optional<Schema.Number>;
|
|
58
|
+
readonly frozen: Schema.optional<Schema.Boolean>;
|
|
59
|
+
}>, Schema.Struct<{
|
|
60
|
+
readonly id: Schema.String;
|
|
61
|
+
readonly kind: Schema.Literals<readonly ["global", "lobby", "party", "guild", "match", "dm", "custom"]>;
|
|
62
|
+
readonly refId: Schema.String;
|
|
63
|
+
readonly name: Schema.String;
|
|
64
|
+
readonly slowModeMs: Schema.Number;
|
|
65
|
+
readonly retentionMs: Schema.NullOr<Schema.Number>;
|
|
66
|
+
readonly maxMembers: Schema.Number;
|
|
67
|
+
readonly frozen: Schema.Boolean;
|
|
68
|
+
readonly createdAt: Schema.Number;
|
|
69
|
+
readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
70
|
+
}>, typeof ChatError>;
|
|
71
|
+
|
|
72
|
+
export declare const dmDescriptor: ActionProcedureDescriptor<"chat.dm", Schema.Struct<{
|
|
73
|
+
readonly otherId: Schema.NonEmptyString;
|
|
74
|
+
}>, Schema.Struct<{
|
|
75
|
+
readonly id: Schema.String;
|
|
76
|
+
readonly kind: Schema.Literals<readonly ["global", "lobby", "party", "guild", "match", "dm", "custom"]>;
|
|
77
|
+
readonly refId: Schema.String;
|
|
78
|
+
readonly name: Schema.String;
|
|
79
|
+
readonly slowModeMs: Schema.Number;
|
|
80
|
+
readonly retentionMs: Schema.NullOr<Schema.Number>;
|
|
81
|
+
readonly maxMembers: Schema.Number;
|
|
82
|
+
readonly frozen: Schema.Boolean;
|
|
83
|
+
readonly createdAt: Schema.Number;
|
|
84
|
+
readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
85
|
+
}>, typeof ChatError>;
|
|
86
|
+
|
|
87
|
+
export declare const editDescriptor: ActionProcedureDescriptor<"chat.edit", Schema.Struct<{
|
|
88
|
+
readonly messageId: Schema.NonEmptyString;
|
|
89
|
+
readonly baseVersion: Schema.Number;
|
|
90
|
+
readonly body: Schema.String;
|
|
91
|
+
}>, Schema.Struct<{
|
|
92
|
+
readonly id: Schema.String;
|
|
93
|
+
readonly channelId: Schema.String;
|
|
94
|
+
readonly authorId: Schema.NullOr<Schema.String>;
|
|
95
|
+
readonly kind: Schema.Literals<readonly ["text", "emote", "system", "media"]>;
|
|
96
|
+
readonly body: Schema.String;
|
|
97
|
+
readonly payload: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
98
|
+
readonly replyToId: Schema.NullOr<Schema.String>;
|
|
99
|
+
readonly editedAt: Schema.NullOr<Schema.Number>;
|
|
100
|
+
readonly deletedAt: Schema.NullOr<Schema.Number>;
|
|
101
|
+
readonly flagged: Schema.Boolean;
|
|
102
|
+
readonly createdAt: Schema.Number;
|
|
103
|
+
readonly version: Schema.Number;
|
|
104
|
+
readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
105
|
+
}>, typeof ChatError>;
|
|
106
|
+
|
|
107
|
+
export declare const joinDescriptor: ActionProcedureDescriptor<"chat.join", Schema.Struct<{
|
|
108
|
+
readonly channelId: Schema.NonEmptyString;
|
|
109
|
+
}>, Schema.Struct<{
|
|
110
|
+
readonly id: Schema.String;
|
|
111
|
+
readonly channelId: Schema.String;
|
|
112
|
+
readonly subjectId: Schema.String;
|
|
113
|
+
readonly role: Schema.Literals<readonly ["member", "mod", "owner"]>;
|
|
114
|
+
readonly mutedUntil: Schema.NullOr<Schema.Number>;
|
|
115
|
+
readonly lastReadAt: Schema.Number;
|
|
116
|
+
readonly lastReadId: Schema.NullOr<Schema.String>;
|
|
117
|
+
readonly notify: Schema.Boolean;
|
|
118
|
+
readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
119
|
+
}>, typeof ChatError>;
|
|
120
|
+
|
|
121
|
+
export declare const leaveDescriptor: ActionProcedureDescriptor<"chat.leave", Schema.Struct<{
|
|
122
|
+
readonly channelId: Schema.NonEmptyString;
|
|
123
|
+
}>, Schema.Void, typeof ChatError>;
|
|
124
|
+
|
|
125
|
+
export declare const markReadDescriptor: ActionProcedureDescriptor<"chat.markRead", Schema.Struct<{
|
|
126
|
+
readonly channelId: Schema.NonEmptyString;
|
|
127
|
+
readonly messageId: Schema.NonEmptyString;
|
|
128
|
+
}>, Schema.Struct<{
|
|
129
|
+
readonly id: Schema.String;
|
|
130
|
+
readonly channelId: Schema.String;
|
|
131
|
+
readonly subjectId: Schema.String;
|
|
132
|
+
readonly role: Schema.Literals<readonly ["member", "mod", "owner"]>;
|
|
133
|
+
readonly mutedUntil: Schema.NullOr<Schema.Number>;
|
|
134
|
+
readonly lastReadAt: Schema.Number;
|
|
135
|
+
readonly lastReadId: Schema.NullOr<Schema.String>;
|
|
136
|
+
readonly notify: Schema.Boolean;
|
|
137
|
+
readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
138
|
+
}>, typeof ChatError>;
|
|
139
|
+
|
|
140
|
+
export declare const mediaUrlDescriptor: ActionProcedureDescriptor<"chat.mediaUrl", Schema.Struct<{
|
|
141
|
+
readonly messageId: Schema.NonEmptyString;
|
|
142
|
+
}>, Schema.Struct<{
|
|
143
|
+
readonly url: Schema.String;
|
|
144
|
+
readonly expiresAt: Schema.Number;
|
|
145
|
+
}>, typeof ChatError>;
|
|
146
|
+
|
|
147
|
+
export declare const membershipDescriptor: QueryProcedureDescriptor<"chat.membership", Schema.Struct<{
|
|
148
|
+
readonly channelId: Schema.NonEmptyString;
|
|
149
|
+
}>, Schema.Struct<{
|
|
150
|
+
readonly id: Schema.String;
|
|
151
|
+
readonly channelId: Schema.String;
|
|
152
|
+
readonly subjectId: Schema.String;
|
|
153
|
+
readonly role: Schema.Literals<readonly ["member", "mod", "owner"]>;
|
|
154
|
+
readonly mutedUntil: Schema.NullOr<Schema.Number>;
|
|
155
|
+
readonly lastReadAt: Schema.Number;
|
|
156
|
+
readonly lastReadId: Schema.NullOr<Schema.String>;
|
|
157
|
+
readonly notify: Schema.Boolean;
|
|
158
|
+
readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
159
|
+
}>, typeof ChatError>;
|
|
160
|
+
|
|
161
|
+
export declare const mentionCandidatesDescriptor: QueryProcedureDescriptor<"chat.mentionCandidates", Schema.Struct<{
|
|
162
|
+
readonly channelId: Schema.NonEmptyString;
|
|
163
|
+
readonly after: Schema.optional<Schema.NonEmptyString>;
|
|
164
|
+
}>, Schema.Struct<{
|
|
165
|
+
readonly authors: Schema.$Array<Schema.Struct<{
|
|
166
|
+
readonly subjectId: Schema.String;
|
|
167
|
+
readonly displayName: Schema.String;
|
|
168
|
+
readonly avatar: Schema.NullOr<Schema.String>;
|
|
169
|
+
}>>;
|
|
170
|
+
readonly after: Schema.NullOr<Schema.String>;
|
|
171
|
+
}>, typeof ChatError>;
|
|
172
|
+
|
|
173
|
+
export declare const messagesDescriptor: QueryProcedureDescriptor<"chat.messages", Schema.Struct<{
|
|
174
|
+
readonly channelId: Schema.NonEmptyString;
|
|
175
|
+
readonly before: Schema.optional<Schema.Struct<{
|
|
176
|
+
readonly at: Schema.Number;
|
|
177
|
+
readonly id: Schema.NonEmptyString;
|
|
178
|
+
}>>;
|
|
179
|
+
}>, Schema.Struct<{
|
|
180
|
+
readonly messages: Schema.$Array<Schema.Struct<{
|
|
181
|
+
readonly id: Schema.String;
|
|
182
|
+
readonly channelId: Schema.String;
|
|
183
|
+
readonly authorId: Schema.NullOr<Schema.String>;
|
|
184
|
+
readonly kind: Schema.Literals<readonly ["text", "emote", "system", "media"]>;
|
|
185
|
+
readonly body: Schema.String;
|
|
186
|
+
readonly payload: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
187
|
+
readonly replyToId: Schema.NullOr<Schema.String>;
|
|
188
|
+
readonly editedAt: Schema.NullOr<Schema.Number>;
|
|
189
|
+
readonly deletedAt: Schema.NullOr<Schema.Number>;
|
|
190
|
+
readonly flagged: Schema.Boolean;
|
|
191
|
+
readonly createdAt: Schema.Number;
|
|
192
|
+
readonly version: Schema.Number;
|
|
193
|
+
readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
194
|
+
}>>;
|
|
195
|
+
readonly before: Schema.NullOr<Schema.Struct<{
|
|
196
|
+
readonly at: Schema.Number;
|
|
197
|
+
readonly id: Schema.String;
|
|
198
|
+
}>>;
|
|
199
|
+
}>, typeof ChatError>;
|
|
200
|
+
|
|
201
|
+
export declare const muteDescriptor: ActionProcedureDescriptor<"chat.mute", Schema.Struct<{
|
|
202
|
+
readonly channelId: Schema.NonEmptyString;
|
|
203
|
+
readonly subjectId: Schema.NonEmptyString;
|
|
204
|
+
readonly mutedUntil: Schema.NullOr<Schema.Number>;
|
|
205
|
+
}>, Schema.Struct<{
|
|
206
|
+
readonly id: Schema.String;
|
|
207
|
+
readonly channelId: Schema.String;
|
|
208
|
+
readonly subjectId: Schema.String;
|
|
209
|
+
readonly role: Schema.Literals<readonly ["member", "mod", "owner"]>;
|
|
210
|
+
readonly mutedUntil: Schema.NullOr<Schema.Number>;
|
|
211
|
+
readonly lastReadAt: Schema.Number;
|
|
212
|
+
readonly lastReadId: Schema.NullOr<Schema.String>;
|
|
213
|
+
readonly notify: Schema.Boolean;
|
|
214
|
+
readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
215
|
+
}>, typeof ChatError>;
|
|
216
|
+
|
|
217
|
+
export declare const originalDescriptor: ActionProcedureDescriptor<"chat.original", Schema.Struct<{
|
|
218
|
+
readonly messageId: Schema.NonEmptyString;
|
|
219
|
+
}>, Schema.Struct<{
|
|
220
|
+
readonly message: Schema.Struct<{
|
|
221
|
+
readonly id: Schema.String;
|
|
222
|
+
readonly channelId: Schema.String;
|
|
223
|
+
readonly authorId: Schema.NullOr<Schema.String>;
|
|
224
|
+
readonly kind: Schema.Literals<readonly ["text", "emote", "system", "media"]>;
|
|
225
|
+
readonly body: Schema.String;
|
|
226
|
+
readonly payload: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
227
|
+
readonly replyToId: Schema.NullOr<Schema.String>;
|
|
228
|
+
readonly editedAt: Schema.NullOr<Schema.Number>;
|
|
229
|
+
readonly deletedAt: Schema.NullOr<Schema.Number>;
|
|
230
|
+
readonly flagged: Schema.Boolean;
|
|
231
|
+
readonly createdAt: Schema.Number;
|
|
232
|
+
readonly version: Schema.Number;
|
|
233
|
+
readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
234
|
+
}>;
|
|
235
|
+
readonly originalBody: Schema.String;
|
|
236
|
+
}>, typeof ChatError>;
|
|
237
|
+
|
|
238
|
+
export declare const removeDescriptor: ActionProcedureDescriptor<"chat.remove", Schema.Struct<{
|
|
239
|
+
readonly messageId: Schema.NonEmptyString;
|
|
240
|
+
readonly baseVersion: Schema.Number;
|
|
241
|
+
}>, Schema.Struct<{
|
|
242
|
+
readonly id: Schema.String;
|
|
243
|
+
readonly channelId: Schema.String;
|
|
244
|
+
readonly authorId: Schema.NullOr<Schema.String>;
|
|
245
|
+
readonly kind: Schema.Literals<readonly ["text", "emote", "system", "media"]>;
|
|
246
|
+
readonly body: Schema.String;
|
|
247
|
+
readonly payload: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
248
|
+
readonly replyToId: Schema.NullOr<Schema.String>;
|
|
249
|
+
readonly editedAt: Schema.NullOr<Schema.Number>;
|
|
250
|
+
readonly deletedAt: Schema.NullOr<Schema.Number>;
|
|
251
|
+
readonly flagged: Schema.Boolean;
|
|
252
|
+
readonly createdAt: Schema.Number;
|
|
253
|
+
readonly version: Schema.Number;
|
|
254
|
+
readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
255
|
+
}>, typeof ChatError>;
|
|
256
|
+
|
|
257
|
+
export declare const sendDescriptor: ActionProcedureDescriptor<"chat.send", Schema.Struct<{
|
|
258
|
+
readonly channelId: Schema.NonEmptyString;
|
|
259
|
+
readonly requestId: Schema.NonEmptyString;
|
|
260
|
+
readonly body: Schema.String;
|
|
261
|
+
readonly replyToId: Schema.optional<Schema.NonEmptyString>;
|
|
262
|
+
readonly mediaId: Schema.optional<Schema.NonEmptyString>;
|
|
263
|
+
}>, Schema.Struct<{
|
|
264
|
+
readonly id: Schema.String;
|
|
265
|
+
readonly channelId: Schema.String;
|
|
266
|
+
readonly authorId: Schema.NullOr<Schema.String>;
|
|
267
|
+
readonly kind: Schema.Literals<readonly ["text", "emote", "system", "media"]>;
|
|
268
|
+
readonly body: Schema.String;
|
|
269
|
+
readonly payload: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
270
|
+
readonly replyToId: Schema.NullOr<Schema.String>;
|
|
271
|
+
readonly editedAt: Schema.NullOr<Schema.Number>;
|
|
272
|
+
readonly deletedAt: Schema.NullOr<Schema.Number>;
|
|
273
|
+
readonly flagged: Schema.Boolean;
|
|
274
|
+
readonly createdAt: Schema.Number;
|
|
275
|
+
readonly version: Schema.Number;
|
|
276
|
+
readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
277
|
+
}>, typeof ChatError>;
|
|
278
|
+
|
|
279
|
+
export declare const setTypingDescriptor: ActionProcedureDescriptor<"chat.setTyping", Schema.Struct<{
|
|
280
|
+
readonly channelId: Schema.NonEmptyString;
|
|
281
|
+
readonly active: Schema.Boolean;
|
|
282
|
+
}>, Schema.Void, typeof ChatError>;
|
|
283
|
+
|
|
284
|
+
export declare const transferOwnershipDescriptor: ActionProcedureDescriptor<"chat.transferOwnership", Schema.Struct<{
|
|
285
|
+
readonly channelId: Schema.NonEmptyString;
|
|
286
|
+
readonly targetId: Schema.NonEmptyString;
|
|
287
|
+
}>, Schema.Void, typeof ChatError>;
|
|
288
|
+
|
|
289
|
+
export declare const unreadDescriptor: QueryProcedureDescriptor<"chat.unread", Schema.Struct<{}>, Schema.$Array<Schema.Struct<{
|
|
290
|
+
readonly channelId: Schema.String;
|
|
291
|
+
readonly count: Schema.Number;
|
|
292
|
+
readonly truncated: Schema.Boolean;
|
|
293
|
+
}>>, typeof ChatError>;
|
|
294
|
+
|
|
295
|
+
export { }
|
package/dist/rpc.js
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { ChatError as e } from "./errors.js";
|
|
2
|
+
import { CHANNELS_TABLE as t, ChatAuthorProjectionSchema as n, ChatChannelSchema as r, ChatMediaUrlSchema as i, ChatMemberSchema as a, ChatMentionCandidatesSchema as o, ChatMessagePageSchema as s, ChatMessageSchema as c, ChatOriginalSchema as l, ChatUnreadSchema as u, MEMBERS_TABLE as d, MESSAGES_TABLE as f } from "./contract.js";
|
|
3
|
+
import { Schema as p } from "effect";
|
|
4
|
+
import { defineAction as m, defineQuery as h } from "@voltro/protocol";
|
|
5
|
+
//#region src/rpc.ts
|
|
6
|
+
var g = "@voltro/plugin-chat", _ = "The handler verifies human identity, same-tenant channel membership and the required author/mod role; input is an intention only.", v = p.Number.pipe(p.check(p.isInt()), p.check(p.isGreaterThanOrEqualTo(0))), y = p.Struct({ channelId: p.NonEmptyString }), b = m({
|
|
7
|
+
name: "chat.setTyping",
|
|
8
|
+
input: p.Struct({
|
|
9
|
+
channelId: p.NonEmptyString,
|
|
10
|
+
active: p.Boolean
|
|
11
|
+
}),
|
|
12
|
+
output: p.Void,
|
|
13
|
+
error: e,
|
|
14
|
+
openAccess: _
|
|
15
|
+
}), x = m({
|
|
16
|
+
name: "chat.dm",
|
|
17
|
+
input: p.Struct({ otherId: p.NonEmptyString }),
|
|
18
|
+
output: r,
|
|
19
|
+
error: e,
|
|
20
|
+
openAccess: _
|
|
21
|
+
}), S = m({
|
|
22
|
+
name: "chat.send",
|
|
23
|
+
input: p.Struct({
|
|
24
|
+
channelId: p.NonEmptyString,
|
|
25
|
+
requestId: p.NonEmptyString,
|
|
26
|
+
body: p.String,
|
|
27
|
+
replyToId: p.optional(p.NonEmptyString),
|
|
28
|
+
mediaId: p.optional(p.NonEmptyString.pipe(p.check(p.isMaxLength(256))))
|
|
29
|
+
}),
|
|
30
|
+
output: c,
|
|
31
|
+
error: e,
|
|
32
|
+
openAccess: _
|
|
33
|
+
}), C = m({
|
|
34
|
+
name: "chat.edit",
|
|
35
|
+
input: p.Struct({
|
|
36
|
+
messageId: p.NonEmptyString,
|
|
37
|
+
baseVersion: v,
|
|
38
|
+
body: p.String
|
|
39
|
+
}),
|
|
40
|
+
output: c,
|
|
41
|
+
error: e,
|
|
42
|
+
openAccess: _
|
|
43
|
+
}), w = m({
|
|
44
|
+
name: "chat.remove",
|
|
45
|
+
input: p.Struct({
|
|
46
|
+
messageId: p.NonEmptyString,
|
|
47
|
+
baseVersion: v
|
|
48
|
+
}),
|
|
49
|
+
output: c,
|
|
50
|
+
error: e,
|
|
51
|
+
openAccess: _
|
|
52
|
+
}), T = h({
|
|
53
|
+
name: "chat.messages",
|
|
54
|
+
input: p.Struct({
|
|
55
|
+
channelId: p.NonEmptyString,
|
|
56
|
+
before: p.optional(p.Struct({
|
|
57
|
+
at: v,
|
|
58
|
+
id: p.NonEmptyString
|
|
59
|
+
}))
|
|
60
|
+
}),
|
|
61
|
+
output: s,
|
|
62
|
+
source: [
|
|
63
|
+
f,
|
|
64
|
+
d,
|
|
65
|
+
t,
|
|
66
|
+
"_voltro_social_relations",
|
|
67
|
+
"_voltro_guild_members",
|
|
68
|
+
"_voltro_mm_party_members"
|
|
69
|
+
],
|
|
70
|
+
optionalSource: [
|
|
71
|
+
"_voltro_social_relations",
|
|
72
|
+
"_voltro_guild_members",
|
|
73
|
+
"_voltro_mm_party_members"
|
|
74
|
+
],
|
|
75
|
+
error: e,
|
|
76
|
+
openAccess: _
|
|
77
|
+
}), E = h({
|
|
78
|
+
name: "chat.mentionCandidates",
|
|
79
|
+
input: p.Struct({
|
|
80
|
+
channelId: p.NonEmptyString,
|
|
81
|
+
after: p.optional(p.NonEmptyString.pipe(p.check(p.isMaxLength(256))))
|
|
82
|
+
}),
|
|
83
|
+
output: o,
|
|
84
|
+
source: [
|
|
85
|
+
d,
|
|
86
|
+
t,
|
|
87
|
+
"_voltro_players",
|
|
88
|
+
"_voltro_social_relations"
|
|
89
|
+
],
|
|
90
|
+
optionalSource: ["_voltro_players", "_voltro_social_relations"],
|
|
91
|
+
error: e,
|
|
92
|
+
openAccess: _
|
|
93
|
+
}), D = h({
|
|
94
|
+
name: "chat.authors",
|
|
95
|
+
input: p.Struct({
|
|
96
|
+
channelId: p.NonEmptyString,
|
|
97
|
+
subjectIds: p.Array(p.NonEmptyString.pipe(p.check(p.isMaxLength(256)))).pipe(p.check(p.isMaxLength(128)))
|
|
98
|
+
}),
|
|
99
|
+
output: p.Array(n),
|
|
100
|
+
source: [
|
|
101
|
+
d,
|
|
102
|
+
t,
|
|
103
|
+
"_voltro_players",
|
|
104
|
+
"_voltro_social_relations"
|
|
105
|
+
],
|
|
106
|
+
optionalSource: ["_voltro_players", "_voltro_social_relations"],
|
|
107
|
+
error: e,
|
|
108
|
+
openAccess: _
|
|
109
|
+
}), O = h({
|
|
110
|
+
name: "chat.channel",
|
|
111
|
+
input: y,
|
|
112
|
+
output: r,
|
|
113
|
+
source: [
|
|
114
|
+
t,
|
|
115
|
+
d,
|
|
116
|
+
"_voltro_guild_members",
|
|
117
|
+
"_voltro_mm_party_members"
|
|
118
|
+
],
|
|
119
|
+
optionalSource: ["_voltro_guild_members", "_voltro_mm_party_members"],
|
|
120
|
+
error: e,
|
|
121
|
+
openAccess: _
|
|
122
|
+
}), k = h({
|
|
123
|
+
name: "chat.membership",
|
|
124
|
+
input: y,
|
|
125
|
+
output: a,
|
|
126
|
+
source: [
|
|
127
|
+
d,
|
|
128
|
+
t,
|
|
129
|
+
"_voltro_guild_members",
|
|
130
|
+
"_voltro_mm_party_members"
|
|
131
|
+
],
|
|
132
|
+
optionalSource: ["_voltro_guild_members", "_voltro_mm_party_members"],
|
|
133
|
+
error: e,
|
|
134
|
+
openAccess: _
|
|
135
|
+
}), A = h({
|
|
136
|
+
name: "chat.channels",
|
|
137
|
+
input: p.Struct({}),
|
|
138
|
+
output: p.Array(r),
|
|
139
|
+
source: [
|
|
140
|
+
t,
|
|
141
|
+
d,
|
|
142
|
+
"_voltro_guild_members",
|
|
143
|
+
"_voltro_mm_party_members"
|
|
144
|
+
],
|
|
145
|
+
optionalSource: ["_voltro_guild_members", "_voltro_mm_party_members"],
|
|
146
|
+
error: e,
|
|
147
|
+
openAccess: _
|
|
148
|
+
}), j = h({
|
|
149
|
+
name: "chat.unread",
|
|
150
|
+
input: p.Struct({}),
|
|
151
|
+
output: p.Array(u),
|
|
152
|
+
source: [
|
|
153
|
+
f,
|
|
154
|
+
d,
|
|
155
|
+
t,
|
|
156
|
+
"_voltro_social_relations",
|
|
157
|
+
"_voltro_guild_members",
|
|
158
|
+
"_voltro_mm_party_members"
|
|
159
|
+
],
|
|
160
|
+
optionalSource: [
|
|
161
|
+
"_voltro_social_relations",
|
|
162
|
+
"_voltro_guild_members",
|
|
163
|
+
"_voltro_mm_party_members"
|
|
164
|
+
],
|
|
165
|
+
error: e,
|
|
166
|
+
openAccess: _
|
|
167
|
+
}), M = m({
|
|
168
|
+
name: "chat.original",
|
|
169
|
+
input: p.Struct({ messageId: p.NonEmptyString }),
|
|
170
|
+
output: l,
|
|
171
|
+
error: e,
|
|
172
|
+
openAccess: _
|
|
173
|
+
}), N = m({
|
|
174
|
+
name: "chat.mediaUrl",
|
|
175
|
+
input: p.Struct({ messageId: p.NonEmptyString }),
|
|
176
|
+
output: i,
|
|
177
|
+
error: e,
|
|
178
|
+
openAccess: _
|
|
179
|
+
}), P = m({
|
|
180
|
+
name: "chat.markRead",
|
|
181
|
+
input: p.Struct({
|
|
182
|
+
channelId: p.NonEmptyString,
|
|
183
|
+
messageId: p.NonEmptyString
|
|
184
|
+
}),
|
|
185
|
+
output: a,
|
|
186
|
+
error: e,
|
|
187
|
+
openAccess: _
|
|
188
|
+
}), F = m({
|
|
189
|
+
name: "chat.mute",
|
|
190
|
+
input: p.Struct({
|
|
191
|
+
channelId: p.NonEmptyString,
|
|
192
|
+
subjectId: p.NonEmptyString,
|
|
193
|
+
mutedUntil: p.NullOr(v)
|
|
194
|
+
}),
|
|
195
|
+
output: a,
|
|
196
|
+
error: e,
|
|
197
|
+
openAccess: _
|
|
198
|
+
}), I = m({
|
|
199
|
+
name: "chat.configure",
|
|
200
|
+
input: p.Struct({
|
|
201
|
+
channelId: p.NonEmptyString,
|
|
202
|
+
slowModeMs: p.optional(v),
|
|
203
|
+
frozen: p.optional(p.Boolean)
|
|
204
|
+
}),
|
|
205
|
+
output: r,
|
|
206
|
+
error: e,
|
|
207
|
+
openAccess: _
|
|
208
|
+
}), L = m({
|
|
209
|
+
name: "chat.join",
|
|
210
|
+
input: y,
|
|
211
|
+
output: a,
|
|
212
|
+
error: e,
|
|
213
|
+
openAccess: "The handler admits only the verified caller, only into an open global channel of the caller's own tenant, behind the Sanctions checkpoint and member cap."
|
|
214
|
+
}), R = m({
|
|
215
|
+
name: "chat.leave",
|
|
216
|
+
input: y,
|
|
217
|
+
output: p.Void,
|
|
218
|
+
error: e,
|
|
219
|
+
openAccess: _
|
|
220
|
+
}), z = m({
|
|
221
|
+
name: "chat.transferOwnership",
|
|
222
|
+
input: p.Struct({
|
|
223
|
+
channelId: p.NonEmptyString,
|
|
224
|
+
targetId: p.NonEmptyString
|
|
225
|
+
}),
|
|
226
|
+
output: p.Void,
|
|
227
|
+
error: e,
|
|
228
|
+
openAccess: _
|
|
229
|
+
}), B = [...[
|
|
230
|
+
"setTyping",
|
|
231
|
+
"dm",
|
|
232
|
+
"send",
|
|
233
|
+
"edit",
|
|
234
|
+
"remove",
|
|
235
|
+
"markRead",
|
|
236
|
+
"mute",
|
|
237
|
+
"configure",
|
|
238
|
+
"original",
|
|
239
|
+
"mediaUrl",
|
|
240
|
+
"join",
|
|
241
|
+
"leave",
|
|
242
|
+
"transferOwnership"
|
|
243
|
+
].map((e) => ({
|
|
244
|
+
tag: "chat." + e,
|
|
245
|
+
kind: "action",
|
|
246
|
+
import: {
|
|
247
|
+
module: "@voltro/plugin-chat/rpc",
|
|
248
|
+
name: e + "Descriptor"
|
|
249
|
+
}
|
|
250
|
+
})), ...[
|
|
251
|
+
"mentionCandidates",
|
|
252
|
+
"authors",
|
|
253
|
+
"messages",
|
|
254
|
+
"channel",
|
|
255
|
+
"membership",
|
|
256
|
+
"channels",
|
|
257
|
+
"unread"
|
|
258
|
+
].map((e) => ({
|
|
259
|
+
tag: "chat." + e,
|
|
260
|
+
kind: "query",
|
|
261
|
+
import: {
|
|
262
|
+
module: "@voltro/plugin-chat/rpc",
|
|
263
|
+
name: e + "Descriptor"
|
|
264
|
+
}
|
|
265
|
+
}))];
|
|
266
|
+
//#endregion
|
|
267
|
+
export { g as BASE_NAME, D as authorsDescriptor, O as channelDescriptor, A as channelsDescriptor, B as chatRpcClientImports, 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 };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { chatError as e } from "./errors.js";
|
|
2
|
+
import { typing as t } from "./events.js";
|
|
3
|
+
import { authorsDescriptor as n, channelDescriptor as r, channelsDescriptor as i, configureDescriptor as a, dmDescriptor as o, editDescriptor as s, joinDescriptor as c, leaveDescriptor as l, markReadDescriptor as u, mediaUrlDescriptor as d, membershipDescriptor as f, mentionCandidatesDescriptor as p, messagesDescriptor as m, muteDescriptor as h, originalDescriptor as g, removeDescriptor as _, sendDescriptor as v, setTypingDescriptor as y, transferOwnershipDescriptor as b, unreadDescriptor as x } from "./rpc.js";
|
|
4
|
+
import { Effect as S } from "effect";
|
|
5
|
+
//#region src/rpcRoutes.ts
|
|
6
|
+
var C = (C) => [
|
|
7
|
+
{
|
|
8
|
+
...y,
|
|
9
|
+
execute: (n, r) => {
|
|
10
|
+
let i = r.events;
|
|
11
|
+
if (!i) return S.fail(e("unavailable"));
|
|
12
|
+
let a = {
|
|
13
|
+
channelId: n.channelId,
|
|
14
|
+
active: n.active
|
|
15
|
+
};
|
|
16
|
+
return C.prepareTyping(r.request.subject, a).pipe(S.flatMap((n) => i.publish(t, { channelId: a.channelId }, n).pipe(S.asVoid, S.mapError(() => e("unavailable")), S.catchDefect(() => S.fail(e("unavailable"))))));
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
...p,
|
|
21
|
+
execute: (e, t) => C.mentionCandidates(t.request.subject, e)
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
...n,
|
|
25
|
+
execute: (e, t) => C.authors(t.request.subject, e)
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
...o,
|
|
29
|
+
execute: (e, t) => C.dm(t.request.subject, e.otherId)
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
...v,
|
|
33
|
+
execute: (e, t) => C.send(t.request.subject, e)
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
...s,
|
|
37
|
+
execute: (e, t) => C.edit(t.request.subject, e)
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
..._,
|
|
41
|
+
execute: (e, t) => C.remove(t.request.subject, e)
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
...m,
|
|
45
|
+
execute: (e, t) => C.messages(t.request.subject, e)
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
...r,
|
|
49
|
+
execute: (e, t) => C.channel(t.request.subject, e.channelId)
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
...f,
|
|
53
|
+
execute: (e, t) => C.membership(t.request.subject, e.channelId)
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
...i,
|
|
57
|
+
execute: (e, t) => C.channels(t.request.subject)
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
...x,
|
|
61
|
+
execute: (e, t) => C.unread(t.request.subject)
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
...g,
|
|
65
|
+
execute: (e, t) => C.original(t.request.subject, e.messageId)
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
...d,
|
|
69
|
+
execute: (e, t) => C.mediaUrl(t.request.subject, e.messageId)
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
...u,
|
|
73
|
+
execute: (e, t) => C.markRead(t.request.subject, e.channelId, e.messageId)
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
...h,
|
|
77
|
+
execute: (e, t) => C.moderateMember(t.request.subject, e)
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
...a,
|
|
81
|
+
execute: (e, t) => C.configure(t.request.subject, e)
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
...c,
|
|
85
|
+
execute: (e, t) => C.join(t.request.subject, e.channelId)
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
...l,
|
|
89
|
+
execute: (e, t) => C.leave(t.request.subject, e.channelId)
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
...b,
|
|
93
|
+
execute: (e, t) => C.transferOwnership(t.request.subject, e.channelId, e.targetId)
|
|
94
|
+
}
|
|
95
|
+
];
|
|
96
|
+
//#endregion
|
|
97
|
+
export { C as chatRpcRoutes };
|