@ai-matrx/records 0.46.0 → 0.48.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 CHANGED
@@ -1,5 +1,59 @@
1
1
  # Changelog — @ai-matrx/records
2
2
 
3
+ ## 0.48.0
4
+
5
+ **A portal principal carries the link the office copies for them.** (lane TAILS-5.)
6
+
7
+ * **`PortalPrincipal.accept_path`** — `/invitations/portal/accept/<token>`, the same path
8
+ `custom.portal_invite` hands back when somebody is asked, read off the same `iam.invitations`
9
+ row and never re-templated. `custom.portal_card` carries it per person as of the migration
10
+ `tails5b_the_portal_card_carries_the_link.sql`.
11
+ * **`null` is an answer, not an absence.** It is null when they have already followed the link,
12
+ when the office took it back (a revoke withdraws the invitation in the same statement), when
13
+ it expired, or when they arrived through the server's own magic-link route, which binds
14
+ without an invitation at all. A screen that meets `null` says so in words — it never draws a
15
+ dead control.
16
+ * **Why it exists**: PORTAL-BIND left this named — *"the office's own copy-link is one line
17
+ short"*. The door answered the office once, with one sentence and one link, and the moment
18
+ that sentence scrolled away the link was gone: the panel redraws from `portal_card`, which
19
+ knew somebody was "invited and waiting" and had no way to say what they were waiting on. So
20
+ texting a customer their link — which INVITE-DELIVERY measured as the ORDINARY case, not the
21
+ fallback — meant inviting them a second time to see it again.
22
+
23
+ **Consumer action:** none. `accept_path` is a new field on an existing answer; nothing that
24
+ reads `PortalPrincipal` today has to change. A surface that offers a copy-link must handle the
25
+ `null` case with a sentence.
26
+
27
+ ## 0.47.0
28
+
29
+ **A refusal this package does not recognise no longer becomes a sentence about this package.**
30
+ (lane TAILS-6.)
31
+
32
+ * **`mapPgError` wrote its own note ONTO `hint` — and `hint` is what every screen treats as
33
+ THE REMEDY.** So when the client met a code it did not know, the person acting on the screen
34
+ was handed this to act on:
35
+
36
+ > `@ai-matrx/records did not recognise SQLSTATE from checklistTemplates`
37
+
38
+ Watched on the live seat by the GUIDE lane on 2026-09-21, on the Checklists tab of a table's
39
+ rail, under the title "Something went wrong at our end". Reproduced here from the shapes
40
+ supabase-js actually returns.
41
+ * **The note moves to `RecordsError.diagnostic`, with `unmapped: true` beside it.** It is still
42
+ said out loud — nobody reads the silence as "handled" — but it is said to whoever debugs
43
+ this and to nobody else. `hint` is the STORE's own words or it is absent.
44
+ * **New code `unreachable`, and it is how the bug got out.** A SQLSTATE is five characters;
45
+ supabase-js puts `""` in `code` for a `FetchError` and the HTTP status (`"404"`, `"502"`) when
46
+ the gateway answers with no body. Neither is a SQLSTATE, both used to land in `internal`, and
47
+ `""` is not nullish so it was carried as one. They now classify as `unreachable` — the call
48
+ never reached the store, nothing was written, and the same call can simply be made again,
49
+ which is a thing a screen can honestly offer. `TypeError: Failed to fetch` is the browser
50
+ talking to itself, so the message becomes "We could not reach your data." and the raw text
51
+ goes to `diagnostic`.
52
+
53
+ **Consumer action:** none required. A host that reads `error.hint` gets the store's hint or
54
+ nothing, never this package's commentary; a host that switches on `error.code` should add
55
+ `unreachable` beside `internal` (`@ai-matrx/records-ui` 0.66.0 already has its title and remedy).
56
+
3
57
  ## 0.46.0
4
58
 
5
59
  **A portal can say which Tables it shows.**
@@ -3070,19 +3070,34 @@ function parseDetail(details) {
3070
3070
  return details;
3071
3071
  }
3072
3072
  }
3073
+ function isNotASqlstate(code) {
3074
+ if (!code) return true;
3075
+ return /^[0-9]{3}$/.test(code);
3076
+ }
3073
3077
  function mapPgError(error, where) {
3074
- const sqlstate = error.code ?? void 0;
3075
- const code = (sqlstate ? BY_SQLSTATE[sqlstate] : void 0) ?? "internal";
3078
+ const raw = error.code ?? void 0;
3079
+ const sqlstate = raw && raw !== "" ? raw : void 0;
3076
3080
  const mapped = {
3077
- code,
3081
+ code: "internal",
3078
3082
  message: error.message,
3079
3083
  ...error.hint ? { hint: error.hint } : {},
3080
3084
  ...sqlstate ? { sqlstate } : {}
3081
3085
  };
3086
+ if (isNotASqlstate(sqlstate)) {
3087
+ mapped.code = "unreachable";
3088
+ } else {
3089
+ mapped.code = BY_SQLSTATE[sqlstate] ?? "internal";
3090
+ }
3082
3091
  const detail = parseDetail(error.details);
3083
3092
  if (detail !== void 0) mapped.detail = detail;
3084
- if (code === "internal") {
3085
- mapped.hint = (mapped.hint ? `${mapped.hint} ` : "") + `(@ai-matrx/records did not recognise SQLSTATE ${sqlstate ?? "(none)"} from ${where}; the message above is the store's own and is the thing to act on.)`;
3093
+ if (mapped.code === "internal") {
3094
+ mapped.unmapped = true;
3095
+ mapped.diagnostic = `@ai-matrx/records did not recognise SQLSTATE ${sqlstate ?? "(none)"} from ${where}; the store's own message is the thing to act on.`;
3096
+ } else if (mapped.code === "unreachable") {
3097
+ mapped.unmapped = true;
3098
+ mapped.diagnostic = `@ai-matrx/records never reached the store from ${where}: ${raw ? `the transport answered ${raw}` : "no response"} \u2014 ${error.message}`;
3099
+ mapped.message = "We could not reach your data.";
3100
+ delete mapped.hint;
3086
3101
  }
3087
3102
  return mapped;
3088
3103
  }