@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/dist/react.cjs CHANGED
@@ -321,6 +321,20 @@ var MeetError = class extends Error {
321
321
  return this.code === "permission-denied" || this.code === "device-not-found" || this.code === "device-in-use" || this.code === "insecure-context";
322
322
  }
323
323
  };
324
+ var SERVER_FAILED_SENTENCE = "The server hit an unexpected problem and nothing was changed.";
325
+ function isRawServerText(value) {
326
+ const text3 = value.trim();
327
+ 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);
328
+ }
329
+ function humanDatabaseSentence(message) {
330
+ const text3 = message.trim();
331
+ if (text3.length === 0 || isRawServerText(text3)) return null;
332
+ if (/permission denied for|violates|relation "|does not exist|syntax error|column "|jwt|pgrst|duplicate key|null value in/i.test(
333
+ text3
334
+ ))
335
+ return null;
336
+ return text3;
337
+ }
324
338
  var FORBIDDEN_CODES = /* @__PURE__ */ new Set(["42501", "PGRST301", "PGRST302"]);
325
339
  var NOT_FOUND_CODES = /* @__PURE__ */ new Set(["PGRST116", "PGRST205"]);
326
340
  var CONFLICT_CODES = /* @__PURE__ */ new Set(["23505", "40001", "55000"]);
@@ -348,8 +362,8 @@ function normalizeMeetError(error, operation) {
348
362
  if (code !== void 0 && FORBIDDEN_CODES.has(code)) {
349
363
  return new MeetError(
350
364
  "forbidden",
351
- `${operation}: denied by the database (${code}: ${message})`,
352
- "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.",
365
+ humanDatabaseSentence(message) ?? "You don't have access to do that in this meeting.",
366
+ "Ask the meeting's host to do it, or to give you access.",
353
367
  error
354
368
  );
355
369
  }
@@ -364,15 +378,16 @@ function normalizeMeetError(error, operation) {
364
378
  if (code !== void 0 && CONFLICT_CODES.has(code)) {
365
379
  return new MeetError(
366
380
  "conflict",
367
- `${operation}: unique violation (${code}: ${message})`,
368
- "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.",
381
+ humanDatabaseSentence(message) ?? "This meeting changed a moment ago, so nothing was saved.",
382
+ "Reload to see the latest, then try again.",
369
383
  error
370
384
  );
371
385
  }
386
+ const hint = error?.hint;
372
387
  return new MeetError(
373
388
  "transport",
374
- `${operation}: ${message}`,
375
- "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.",
389
+ /failed to fetch|networkerror|load failed|network request failed/i.test(message) ? "The server could not be reached." : humanDatabaseSentence(message) ?? SERVER_FAILED_SENTENCE,
390
+ typeof hint === "string" && humanDatabaseSentence(hint) !== null ? hint.trim() : "Nothing was changed \u2014 retry in a moment; if it keeps happening, reload the page.",
376
391
  error
377
392
  );
378
393
  }
@@ -780,11 +795,6 @@ function readText(data) {
780
795
  }
781
796
  return "";
782
797
  }
783
- var SERVER_FAILED_SENTENCE = "The server hit an unexpected problem and nothing was changed.";
784
- function isRawServerText(value) {
785
- const text3 = value.trim();
786
- 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);
787
- }
788
798
  async function refusalFromResponse(response, operation, fallbackRemedy) {
789
799
  let body = null;
790
800
  try {