@ai-matrx/meet 0.7.8 → 0.7.9

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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog — `@ai-matrx/meet`
2
2
 
3
+ ## 0.7.9
4
+ ### (next patch)
5
+
6
+ - **Fix — a database refusal reads as a sentence for a person** (verifier, 2026-09-27, the
7
+ class behind raw toast text): `normalizeMeetError`'s `message` was
8
+ "meet.x: denied by the database (42501: …)" with a remedy about RLS and service-role
9
+ clients, and hosts render `message` + `remedy` in toasts. Now our RPC's own sentence
10
+ (`RAISE EXCEPTION 'Only the host …'`) is the message; Postgres wording, SQLSTATEs and class
11
+ names become a plain sentence ("You don't have access to do that in this meeting.", "This
12
+ meeting changed a moment ago…", "The server could not be reached."); the raw error stays on
13
+ `cause`. `SERVER_FAILED_SENTENCE` / `isRawServerText` now live in `core/errors.ts`
14
+ (still re-exported from the root).
15
+ - **Consumer action:** none.
16
+
3
17
  ## 0.7.8
4
18
  ### (next patch)
5
19
 
package/dist/index.cjs CHANGED
@@ -220,6 +220,20 @@ var MeetError = class extends Error {
220
220
  return this.code === "permission-denied" || this.code === "device-not-found" || this.code === "device-in-use" || this.code === "insecure-context";
221
221
  }
222
222
  };
223
+ var SERVER_FAILED_SENTENCE = "The server hit an unexpected problem and nothing was changed.";
224
+ function isRawServerText(value) {
225
+ const text3 = value.trim();
226
+ return /^internal server error\b/i.test(text3) || /^[A-Z][A-Za-z0-9]*(Error|Exception)$/.test(text3) || /^[a-z][a-z0-9]*(_[a-z0-9]+)+$/.test(text3);
227
+ }
228
+ function humanDatabaseSentence(message) {
229
+ const text3 = message.trim();
230
+ if (text3.length === 0 || isRawServerText(text3)) return null;
231
+ if (/permission denied for|violates|relation "|does not exist|syntax error|column "|jwt|pgrst|duplicate key|null value in/i.test(
232
+ text3
233
+ ))
234
+ return null;
235
+ return text3;
236
+ }
223
237
  var FORBIDDEN_CODES = /* @__PURE__ */ new Set(["42501", "PGRST301", "PGRST302"]);
224
238
  var NOT_FOUND_CODES = /* @__PURE__ */ new Set(["PGRST116", "PGRST205"]);
225
239
  var CONFLICT_CODES = /* @__PURE__ */ new Set(["23505", "40001", "55000"]);
@@ -247,8 +261,8 @@ function normalizeMeetError(error, operation) {
247
261
  if (code !== void 0 && FORBIDDEN_CODES.has(code)) {
248
262
  return new MeetError(
249
263
  "forbidden",
250
- `${operation}: denied by the database (${code}: ${message})`,
251
- "Authorization is RLS plus auth-checked RPCs (R5). Fix the policy or the caller's membership \u2014 never route around it with a service-role client in a browser.",
264
+ humanDatabaseSentence(message) ?? "You don't have access to do that in this meeting.",
265
+ "Ask the meeting's host to do it, or to give you access.",
252
266
  error
253
267
  );
254
268
  }
@@ -263,15 +277,16 @@ function normalizeMeetError(error, operation) {
263
277
  if (code !== void 0 && CONFLICT_CODES.has(code)) {
264
278
  return new MeetError(
265
279
  "conflict",
266
- `${operation}: unique violation (${code}: ${message})`,
267
- "A concurrent writer won. Re-read the meeting rather than retrying the insert \u2014 for a call invite this is the idempotency key doing its job.",
280
+ humanDatabaseSentence(message) ?? "This meeting changed a moment ago, so nothing was saved.",
281
+ "Reload to see the latest, then try again.",
268
282
  error
269
283
  );
270
284
  }
285
+ const hint = error?.hint;
271
286
  return new MeetError(
272
287
  "transport",
273
- `${operation}: ${message}`,
274
- "Transient transport failure. Reads retry once; a join failure surfaces to the room phase as `failed` with this message rather than hanging on a spinner.",
288
+ /failed to fetch|networkerror|load failed|network request failed/i.test(message) ? "The server could not be reached." : humanDatabaseSentence(message) ?? SERVER_FAILED_SENTENCE,
289
+ typeof hint === "string" && humanDatabaseSentence(hint) !== null ? hint.trim() : "Nothing was changed \u2014 retry in a moment; if it keeps happening, reload the page.",
275
290
  error
276
291
  );
277
292
  }
@@ -679,11 +694,6 @@ function readText(data) {
679
694
  }
680
695
  return "";
681
696
  }
682
- var SERVER_FAILED_SENTENCE = "The server hit an unexpected problem and nothing was changed.";
683
- function isRawServerText(value) {
684
- const text3 = value.trim();
685
- return /^internal server error\b/i.test(text3) || /^[A-Z][A-Za-z0-9]*(Error|Exception)$/.test(text3) || /^[a-z][a-z0-9]*(_[a-z0-9]+)+$/.test(text3);
686
- }
687
697
  async function refusalFromResponse(response, operation, fallbackRemedy) {
688
698
  let body = null;
689
699
  try {