@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/dist/index.js CHANGED
@@ -1,20 +1,20 @@
1
1
  import { ChatError as e, chatError as t } from "./errors.js";
2
- import { chatAdmissionsTable as n } from "./admissions.entity.js";
3
- import { chatEvidenceTable as r } from "./evidence.entity.js";
4
- import { CHAT_MAX_MESSAGE_VERSION as i, CHAT_MEDIA_SWEEP_BATCH_SIZE as a, CHAT_RETENTION_BATCH_SIZE as o, CHAT_RETENTION_RUN_BATCHES as s } from "./contract.js";
5
- import { chatMediaTable as c } from "./media.entity.js";
6
- import { chatRetentionTable as l } from "./retention.entity.js";
7
- import { mentioned as u, messageChanged as d, typing as f } from "./events.js";
8
- import { chatChannelsTable as p } from "./channels.entity.js";
9
- import { chatMembersTable as m } from "./members.entity.js";
10
- import { chatMessagesTable as h } from "./messages.entity.js";
11
- import { dataStoreChat as g } from "./service.js";
12
- import { BASE_NAME as _, chatRpcClientImports as v, chatVoiceRpcClientImports as y, voiceJoinDescriptor as b } from "./rpc.js";
13
- import { chatRpcRoutes as x } from "./rpcRoutes.js";
14
- import { devVoiceProvider as S, liveKitVoiceProvider as C, resolveChatVoice as w } from "./voice.js";
15
- import { defaultChatStrategies as T, resolveChatOptions as E } from "./strategies.js";
16
- import { chatStatus as D } from "./inspect.js";
17
- import { ChatAdministration as O } from "./server.js";
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
- d.name,
50
- u.name,
51
- f.name
49
+ v.name,
50
+ _.name,
51
+ y.name
52
52
  ]
53
- }, I = (i = {}) => {
54
- let { voice: a, ...o } = i, s = E(o), u = P(s.rateLimit), d = a === void 0 ? void 0 : w(a), S, C, T = !1, F = (e) => {
55
- let n = C;
56
- return A.suspend(() => n === void 0 || n !== C ? A.fail(t("unavailable")) : e(n).pipe(A.flatMap((e) => n === C ? A.succeed(e) : A.fail(t("unavailable")))));
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: f.clientPolicy,
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(O, {
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: [...x(L), ...d === void 0 ? [] : [{
108
- ...b,
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) => d.join({
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: d === void 0 ? v : [...v, ...y],
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
- p,
129
- m,
130
- h,
128
+ s,
129
+ c,
131
130
  l,
131
+ o,
132
+ i,
132
133
  r,
133
- n,
134
- c
134
+ a
135
135
  ] },
136
136
  subjectPrivacy: {
137
137
  tables: [
138
- p.tableName,
139
- m.tableName,
140
- h.tableName,
138
+ s.tableName,
139
+ c.tableName,
141
140
  l.tableName,
141
+ o.tableName,
142
+ i.tableName,
142
143
  r.tableName,
143
- n.tableName,
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: D(s, C !== void 0, T)
156
+ data: g(_, D !== void 0, O)
157
157
  }),
158
158
  catch: () => t("unavailable")
159
159
  })
160
160
  }],
161
161
  bindDataStore: (e) => {
162
- if (S !== void 0 && S !== e) throw Error("Chat plugin instance cannot cross app stores");
163
- S = e, C ??= g(e, s, u);
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 (s.rateLimit?.hotStore !== void 0 && N(e.env) !== null) throw t("unavailable");
168
- await u.activate(e.env, e.connectionRegistry), T = !0;
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
- p,
185
- m,
186
- h,
184
+ s,
185
+ c,
187
186
  l,
187
+ o,
188
+ i,
188
189
  r,
189
- n,
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
- C?.disposeTyping();
198
+ D?.disposeTyping();
199
199
  } finally {
200
- C = void 0, S = void 0, T = !1, await u.deactivate();
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 { i as CHAT_MAX_MESSAGE_VERSION, a as CHAT_MEDIA_SWEEP_BATCH_SIZE, o as CHAT_RETENTION_BATCH_SIZE, s as CHAT_RETENTION_RUN_BATCHES, e as ChatError, n as chatAdmissionsTable, p as chatChannelsTable, r as chatEvidenceTable, c as chatMediaTable, m as chatMembersTable, h as chatMessagesTable, I as chatPlugin, l as chatRetentionTable, F as chatSystemContract, g as dataStoreChat, T as defaultChatStrategies, S as devVoiceProvider, C as liveKitVoiceProvider, E as resolveChatOptions };
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 { chatError as e } from "./errors.js";
2
- import { defaultChatStrategies as t } from "./strategies.js";
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 e("unavailable");
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(t).map(([e, t]) => [e, r.strategies[e] === t ? "default" : "custom"])),
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 { chatError as e } from "./errors.js";
2
- import { MESSAGES_TABLE as t } from "./contract.js";
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 { ChatAdministration as i } from "./server.js";
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 = (e) => v(a.flatMap(i, (t) => t.canNotifyMention(m, e))), C = async (e) => {
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 (t) => {
63
- let n = o.decodeUnknownSync(g)(t.payload);
64
- if (t.tenantId !== n.tenantId) throw e("identity_required");
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 e("unavailable");
67
+ if (!r) throw t("unavailable");
68
68
  return d({
69
69
  notifications: [_],
70
- service: () => ({ send: async (t) => {
70
+ service: () => ({ send: async (e) => {
71
71
  let i = await r.send({
72
- ...t,
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 e("unavailable");
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: t,
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 { chatChannelId as e } from "./service.js";
2
- import { CHAT_MENTION_NOTIFICATION_EFFECT as t, CHAT_MENTION_NOTIFICATION_GUARD as n, createChatMentionNotifications as r } from "./mentionNotifications.js";
3
- import { chatSanctionEvidenceCollector as i } from "./reportEvidence.js";
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 { t as CHAT_MENTION_NOTIFICATION_EFFECT, n as CHAT_MENTION_NOTIFICATION_GUARD, o as ChatAdministration, e as chatChannelId, i as chatSanctionEvidenceCollector, r as createChatMentionNotifications };
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 };