@ai-matrx/records 0.46.0 → 0.47.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,35 @@
1
1
  # Changelog — @ai-matrx/records
2
2
 
3
+ ## 0.47.0
4
+
5
+ **A refusal this package does not recognise no longer becomes a sentence about this package.**
6
+ (lane TAILS-6.)
7
+
8
+ * **`mapPgError` wrote its own note ONTO `hint` — and `hint` is what every screen treats as
9
+ THE REMEDY.** So when the client met a code it did not know, the person acting on the screen
10
+ was handed this to act on:
11
+
12
+ > `@ai-matrx/records did not recognise SQLSTATE from checklistTemplates`
13
+
14
+ Watched on the live seat by the GUIDE lane on 2026-09-21, on the Checklists tab of a table's
15
+ rail, under the title "Something went wrong at our end". Reproduced here from the shapes
16
+ supabase-js actually returns.
17
+ * **The note moves to `RecordsError.diagnostic`, with `unmapped: true` beside it.** It is still
18
+ said out loud — nobody reads the silence as "handled" — but it is said to whoever debugs
19
+ this and to nobody else. `hint` is the STORE's own words or it is absent.
20
+ * **New code `unreachable`, and it is how the bug got out.** A SQLSTATE is five characters;
21
+ supabase-js puts `""` in `code` for a `FetchError` and the HTTP status (`"404"`, `"502"`) when
22
+ the gateway answers with no body. Neither is a SQLSTATE, both used to land in `internal`, and
23
+ `""` is not nullish so it was carried as one. They now classify as `unreachable` — the call
24
+ never reached the store, nothing was written, and the same call can simply be made again,
25
+ which is a thing a screen can honestly offer. `TypeError: Failed to fetch` is the browser
26
+ talking to itself, so the message becomes "We could not reach your data." and the raw text
27
+ goes to `diagnostic`.
28
+
29
+ **Consumer action:** none required. A host that reads `error.hint` gets the store's hint or
30
+ nothing, never this package's commentary; a host that switches on `error.code` should add
31
+ `unreachable` beside `internal` (`@ai-matrx/records-ui` 0.66.0 already has its title and remedy).
32
+
3
33
  ## 0.46.0
4
34
 
5
35
  **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
  }