@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 +54 -0
- package/dist/core/index.cjs +20 -5
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +20 -5
- package/dist/core/index.js.map +1 -1
- package/dist/{field-N0ExInZA.d.cts → field-CFK39l0H.d.cts} +32 -0
- package/dist/{field-N0ExInZA.d.ts → field-CFK39l0H.d.ts} +32 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +20 -5
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +45 -0
- package/dist/react/index.d.ts +45 -0
- package/dist/react/index.js +20 -5
- package/dist/react/index.js.map +1 -1
- package/dist/use-cases/index.d.cts +1 -1
- package/dist/use-cases/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/react/index.cjs
CHANGED
|
@@ -2439,19 +2439,34 @@ function parseDetail(details) {
|
|
|
2439
2439
|
return details;
|
|
2440
2440
|
}
|
|
2441
2441
|
}
|
|
2442
|
+
function isNotASqlstate(code) {
|
|
2443
|
+
if (!code) return true;
|
|
2444
|
+
return /^[0-9]{3}$/.test(code);
|
|
2445
|
+
}
|
|
2442
2446
|
function mapPgError(error, where) {
|
|
2443
|
-
const
|
|
2444
|
-
const
|
|
2447
|
+
const raw = error.code ?? void 0;
|
|
2448
|
+
const sqlstate = raw && raw !== "" ? raw : void 0;
|
|
2445
2449
|
const mapped = {
|
|
2446
|
-
code,
|
|
2450
|
+
code: "internal",
|
|
2447
2451
|
message: error.message,
|
|
2448
2452
|
...error.hint ? { hint: error.hint } : {},
|
|
2449
2453
|
...sqlstate ? { sqlstate } : {}
|
|
2450
2454
|
};
|
|
2455
|
+
if (isNotASqlstate(sqlstate)) {
|
|
2456
|
+
mapped.code = "unreachable";
|
|
2457
|
+
} else {
|
|
2458
|
+
mapped.code = BY_SQLSTATE[sqlstate] ?? "internal";
|
|
2459
|
+
}
|
|
2451
2460
|
const detail = parseDetail(error.details);
|
|
2452
2461
|
if (detail !== void 0) mapped.detail = detail;
|
|
2453
|
-
if (code === "internal") {
|
|
2454
|
-
mapped.
|
|
2462
|
+
if (mapped.code === "internal") {
|
|
2463
|
+
mapped.unmapped = true;
|
|
2464
|
+
mapped.diagnostic = `@ai-matrx/records did not recognise SQLSTATE ${sqlstate ?? "(none)"} from ${where}; the store's own message is the thing to act on.`;
|
|
2465
|
+
} else if (mapped.code === "unreachable") {
|
|
2466
|
+
mapped.unmapped = true;
|
|
2467
|
+
mapped.diagnostic = `@ai-matrx/records never reached the store from ${where}: ${raw ? `the transport answered ${raw}` : "no response"} \u2014 ${error.message}`;
|
|
2468
|
+
mapped.message = "We could not reach your data.";
|
|
2469
|
+
delete mapped.hint;
|
|
2455
2470
|
}
|
|
2456
2471
|
return mapped;
|
|
2457
2472
|
}
|