@voltro/plugin-chat 0.0.0-stage → 0.88.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +24492 -0
  2. package/LICENSE +61 -0
  3. package/README.md +516 -2
  4. package/SECURITY.md +56 -0
  5. package/THIRD-PARTY-NOTICES.md +16105 -0
  6. package/dist/admissions.entity.js +10 -0
  7. package/dist/channels.entity.js +19 -0
  8. package/dist/chat-app/events/chat.mentioned.event.ts +1 -0
  9. package/dist/chat-app/events/chat.messageChanged.event.ts +1 -0
  10. package/dist/chat-app/events/chat.typing.event.ts +1 -0
  11. package/dist/chat-app/schedules/chat.retention.cron.tsx +16 -0
  12. package/dist/chat-app/subscribers/chat.messages.subscribe.ts +4 -0
  13. package/dist/components.js +431 -0
  14. package/dist/contract.js +91 -0
  15. package/dist/errors.d.ts +13 -0
  16. package/dist/errors.js +20 -0
  17. package/dist/eventProducer.d.ts +18 -0
  18. package/dist/eventProducer.js +45 -0
  19. package/dist/events.d.ts +38 -0
  20. package/dist/events.js +35 -0
  21. package/dist/evidence.entity.js +24 -0
  22. package/dist/index.d.ts +623 -0
  23. package/dist/index.js +180 -0
  24. package/dist/inspect.js +37 -0
  25. package/dist/media.entity.js +14 -0
  26. package/dist/members.entity.js +21 -0
  27. package/dist/mentionDraft.js +20 -0
  28. package/dist/mentionNotifications.js +109 -0
  29. package/dist/messages.entity.js +27 -0
  30. package/dist/reportEvidence.js +15 -0
  31. package/dist/retention.entity.js +10 -0
  32. package/dist/rpc.d.ts +295 -0
  33. package/dist/rpc.js +266 -0
  34. package/dist/rpcRoutes.js +96 -0
  35. package/dist/server.d.ts +200 -0
  36. package/dist/server.js +6 -0
  37. package/dist/service.js +1411 -0
  38. package/dist/strategies.d.ts +148 -0
  39. package/dist/strategies.js +89 -0
  40. package/dist/testing.d.ts +139 -0
  41. package/dist/testing.js +110 -0
  42. package/dist/typing.js +87 -0
  43. package/dist/typingInvalidation.js +85 -0
  44. package/dist/typingLease.js +58 -0
  45. package/dist/typingPublisher.js +58 -0
  46. package/dist/useChatTypingPublisher.js +32 -0
  47. package/dist/useTyping.js +23 -0
  48. package/dist/web.d.ts +354 -0
  49. package/dist/web.js +18 -0
  50. package/package.json +98 -4
@@ -0,0 +1,200 @@
1
+ import { Context } from 'effect';
2
+ import { Effect } from 'effect';
3
+ import { EvidenceCollectorInput } from '@voltro/plugin-sanctions/strategies';
4
+ import { NotificationDeliveryGuard } from '@voltro/plugin-notifications';
5
+ import { NotificationServiceShape } from '@voltro/plugin-notifications';
6
+ import { OutboxEnqueue } from '@voltro/plugin-notifications';
7
+ import { OutboxHandlerDefinition } from '@voltro/protocol';
8
+ import { SanctionsError } from '@voltro/plugin-sanctions/errors';
9
+ import { Schema } from 'effect';
10
+ import { Subject } from '@voltro/protocol';
11
+ import { SubscriberDefinition } from '@voltro/runtime';
12
+ import { YieldableError } from 'effect/Cause';
13
+
14
+ /** Server integrations supply verified membership and transcripts, never browser rows. */
15
+ export declare interface ArchiveMatchInput {
16
+ readonly tenantId: string;
17
+ readonly matchId: string;
18
+ readonly name: string;
19
+ readonly members: CreateChatChannelInput['members'];
20
+ readonly messages: ReadonlyArray<{
21
+ readonly id: string;
22
+ readonly authorId: string;
23
+ readonly body: string;
24
+ readonly at: number;
25
+ }>;
26
+ readonly retentionMs?: number | null;
27
+ }
28
+
29
+ declare const CHANNEL_KINDS: readonly ["global", "lobby", "party", "guild", "match", "dm", "custom"];
30
+
31
+ export declare const CHAT_MENTION_NOTIFICATION_EFFECT = "voltro.chat.mention.notify";
32
+
33
+ export declare const CHAT_MENTION_NOTIFICATION_GUARD = "chat.mention";
34
+
35
+ /** App-bound server service. It borrows the plugin's SQL store and owns no connection. */
36
+ export declare class ChatAdministration extends ChatAdministration_base {
37
+ }
38
+
39
+ declare const ChatAdministration_base: Context.ServiceClass<ChatAdministration, "@voltro/ChatAdministration", ChatAdministrationService>;
40
+
41
+ export declare interface ChatAdministrationService {
42
+ readonly readReportEvidence: (subject: Subject, input: {
43
+ readonly tenantId: string;
44
+ readonly evidenceIds: ReadonlyArray<string>;
45
+ }) => Effect.Effect<ReadonlyArray<ChatEvidenceSnapshot>, ChatError>;
46
+ /** Server-only bounded capture; cases receive references, never transcript/author copies. */
47
+ readonly collectReportContext: (subject: Subject, input: ChatReportContextInput) => Effect.Effect<ChatReportContextEvidence, ChatError>;
48
+ /** One bounded, persisted sweep step. System scans app channels; service accounts only their tenant. */
49
+ readonly prune: (subject: Subject) => Effect.Effect<ChatRetentionBatch, ChatError>;
50
+ /** One bounded step deleting queued media blobs from plugin-storage; failed deletes stay queued. Same subject rules as prune. */
51
+ readonly sweepMedia: (subject: Subject) => Effect.Effect<ChatMediaSweep, ChatError>;
52
+ /** Check committed, retained mention ownership and current recipient authorization before delivery. */
53
+ readonly canNotifyMention: (subject: Subject, input: ChatMentionDeliveryInput) => Effect.Effect<boolean, ChatError>;
54
+ readonly createChannel: (subject: Subject, input: CreateChatChannelInput) => Effect.Effect<ChatChannel, ChatError>;
55
+ readonly addMember: (subject: Subject, input: {
56
+ readonly tenantId: string;
57
+ readonly channelId: string;
58
+ readonly subjectId: string;
59
+ readonly role: 'member' | 'mod';
60
+ }) => Effect.Effect<ChatMember, ChatError>;
61
+ readonly removeMember: (subject: Subject, input: {
62
+ readonly tenantId: string;
63
+ readonly channelId: string;
64
+ readonly subjectId: string;
65
+ }) => Effect.Effect<void, ChatError>;
66
+ readonly archiveMatch: (subject: Subject, input: ArchiveMatchInput) => Effect.Effect<ChatChannel, ChatError>;
67
+ }
68
+
69
+ declare type ChatChannel = typeof ChatChannelSchema.Type;
70
+
71
+ declare const ChatChannelSchema: Schema.Struct<{
72
+ readonly id: Schema.String;
73
+ readonly kind: Schema.Literals<readonly ["global", "lobby", "party", "guild", "match", "dm", "custom"]>;
74
+ readonly refId: Schema.String;
75
+ readonly name: Schema.String;
76
+ readonly slowModeMs: Schema.Number;
77
+ readonly retentionMs: Schema.NullOr<Schema.Number>;
78
+ readonly maxMembers: Schema.Number;
79
+ readonly frozen: Schema.Boolean;
80
+ readonly createdAt: Schema.Number;
81
+ readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
82
+ }>;
83
+
84
+ declare class ChatError extends ChatError_base {
85
+ }
86
+
87
+ declare const ChatError_base: Schema.Class<ChatError, Schema.TaggedStruct<"ChatError", {
88
+ 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"]>;
89
+ }>, YieldableError>;
90
+
91
+ export declare interface ChatEvidenceSnapshot {
92
+ readonly id: string;
93
+ readonly channelId: string;
94
+ readonly messageId: string;
95
+ readonly messageVersion: number;
96
+ readonly kind: string;
97
+ readonly authorId: string | null;
98
+ readonly body: string | null;
99
+ readonly originalBody: string | null;
100
+ readonly createdAt: number;
101
+ readonly editedAt: number | null;
102
+ readonly deletedAt: number | null;
103
+ readonly capturedAt: number;
104
+ readonly expiresAt: number;
105
+ readonly erasedAt: number | null;
106
+ }
107
+
108
+ export declare interface ChatMediaSweep {
109
+ readonly removed: number;
110
+ readonly failed: number;
111
+ readonly remaining: boolean;
112
+ }
113
+
114
+ declare type ChatMember = typeof ChatMemberSchema.Type;
115
+
116
+ declare const ChatMemberSchema: Schema.Struct<{
117
+ readonly id: Schema.String;
118
+ readonly channelId: Schema.String;
119
+ readonly subjectId: Schema.String;
120
+ readonly role: Schema.Literals<readonly ["member", "mod", "owner"]>;
121
+ readonly mutedUntil: Schema.NullOr<Schema.Number>;
122
+ readonly lastReadAt: Schema.Number;
123
+ readonly lastReadId: Schema.NullOr<Schema.String>;
124
+ readonly notify: Schema.Boolean;
125
+ readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
126
+ }>;
127
+
128
+ export declare interface ChatMentionDeliveryInput {
129
+ readonly tenantId: string;
130
+ readonly channelId: string;
131
+ readonly messageId: string;
132
+ readonly recipientId: string;
133
+ }
134
+
135
+ export declare interface ChatMentionNotificationsOptions {
136
+ /** Trusted system or same-tenant chat:notifications:send service principal, never a browser identity. */
137
+ readonly subject: Subject;
138
+ /** Borrow the app runtime so actual ChatAdministration and Social services stay installed. */
139
+ readonly run: (effect: Effect.Effect<boolean, ChatError, ChatAdministration>) => Promise<boolean>;
140
+ readonly service: () => Pick<NotificationServiceShape, 'send'> | undefined;
141
+ /** The existing outbox facade must be bound to exactly this tenant. No independent connection. */
142
+ readonly outboxForTenant: (tenantId: string) => OutboxEnqueue;
143
+ readonly localeFor?: (recipientId: string, tenantId: string) => Promise<string | null>;
144
+ }
145
+
146
+ export declare interface ChatReportContextEvidence {
147
+ readonly kind: 'chat.context';
148
+ readonly channelId: string;
149
+ readonly anchorMessageId: string;
150
+ readonly observedAt: number;
151
+ readonly messages: ReadonlyArray<{
152
+ readonly evidenceId: string | null;
153
+ readonly messageId: string;
154
+ readonly version: number;
155
+ readonly createdAt: number;
156
+ readonly deletedAt: number | null;
157
+ }>;
158
+ }
159
+
160
+ export declare interface ChatReportContextInput {
161
+ readonly channelId: string;
162
+ readonly messageId: string;
163
+ readonly targetId: string;
164
+ }
165
+
166
+ export declare interface ChatRetentionBatch {
167
+ readonly deleted: number;
168
+ readonly evidenceDeleted: number;
169
+ readonly channelId: string | null;
170
+ readonly remainingInChannel: boolean;
171
+ readonly evidenceRemainingInChannel: boolean;
172
+ readonly cycleComplete: boolean;
173
+ }
174
+
175
+ /** Configure the existing Sanctions evidence slot. Human reports remain review-only. */
176
+ export declare const chatSanctionEvidenceCollector: (input: EvidenceCollectorInput) => Effect.Effect<ReadonlyArray<Record<string, unknown>>, SanctionsError>;
177
+
178
+ declare interface CreateChatChannelInput {
179
+ readonly tenantId: string;
180
+ readonly kind: typeof CHANNEL_KINDS[number];
181
+ readonly refId: string;
182
+ readonly name: string;
183
+ readonly members: ReadonlyArray<{
184
+ readonly subjectId: string;
185
+ readonly role: ChatMember['role'];
186
+ }>;
187
+ readonly slowModeMs?: number;
188
+ readonly retentionMs?: number | null;
189
+ readonly maxMembers?: number;
190
+ }
191
+
192
+ /** Optional composition: export subscriber/outboxHandler in app discovery and register deliveryGuard with Notifications. */
193
+ export declare const createChatMentionNotifications: (options: ChatMentionNotificationsOptions) => {
194
+ deliveryGuard: NotificationDeliveryGuard;
195
+ enqueue: (input: ChatMentionDeliveryInput) => Promise<string | null>;
196
+ outboxHandler: OutboxHandlerDefinition<never>;
197
+ subscriber: SubscriberDefinition;
198
+ };
199
+
200
+ export { }
package/dist/server.js ADDED
@@ -0,0 +1,6 @@
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 { Context as i } from "effect";
4
+ // src/server.ts
5
+ var a = class extends i.Service()("@voltro/ChatAdministration") {};
6
+ export { e as CHAT_MENTION_NOTIFICATION_EFFECT, t as CHAT_MENTION_NOTIFICATION_GUARD, a as ChatAdministration, r as chatSanctionEvidenceCollector, n as createChatMentionNotifications };