@nivaro/react 0.3.46 → 0.3.47
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/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +248 -16
- package/dist/index.js +679 -659
- package/dist/shared/components/CollectionBrowserView.js +813 -826
- package/dist/shared/components/ErrorNotice.js +169 -0
- package/dist/shared/components/ErrorSurface.js +23 -17
- package/dist/shared/components/ListLoadError.js +8 -29
- package/dist/shared/components/LoadErrorNote.js +38 -21
- package/dist/shared/components/QueryErrorState.js +8 -11
- package/dist/shared/components/ReportView.js +1320 -1291
- package/dist/shared/components/chat/ChannelArchive.js +60 -60
- package/dist/shared/components/chat/ChannelExtras.js +74 -74
- package/dist/shared/components/chat/ChatPanel.js +368 -367
- package/dist/shared/components/command-center/PeekPanel.js +33 -32
- package/dist/shared/components/command-center/panels/BoardSettings.js +41 -40
- package/dist/shared/components/command-center/panels/PeoplePanel.js +32 -31
- package/dist/shared/components/help-videos/editor/ClipsPanel.js +49 -48
- package/dist/shared/components/help-videos/editor/PublishButton.js +37 -36
- package/dist/shared/components/help-videos/editor/StatsTab.js +45 -44
- package/dist/shared/components/help-videos/editor/VersionsTab.js +29 -28
- package/dist/shared/components/help-videos/library/AuthorRolesButton.js +19 -18
- package/dist/shared/components/help-videos/library/HelpVideoLibrary.js +132 -129
- package/dist/shared/components/help-videos/library/LearningPathsPanel.js +42 -41
- package/dist/shared/components/help-videos/settings/HouseStyleButton.js +21 -20
- package/dist/shared/components/help-videos/settings/RenderSettingsButton.js +22 -21
- package/dist/shared/components/import/DocumentAutofillButton.js +24 -20
- package/dist/shared/components/import/ImportFromFileButton.js +61 -60
- package/dist/shared/components/imports/ImportStalenessControl.js +20 -21
- package/dist/shared/components/imports/NewImportDialog.js +29 -28
- package/dist/shared/components/imports/RunDetailSheet.js +63 -63
- package/dist/shared/components/item-edit/FieldRow.js +329 -329
- package/dist/shared/components/item-edit/InlineTableField.js +898 -898
- package/dist/shared/components/item-edit/PersonalDefaultControl.js +57 -56
- package/dist/shared/components/item-edit/PlanGrid.js +220 -221
- package/dist/shared/components/item-edit/RecordGrantTools.js +49 -48
- package/dist/shared/components/item-edit/placement-behaviour.js +68 -67
- package/dist/shared/components/layout-editor/inspector/ColumnFit.js +24 -23
- package/dist/shared/components/layout-editor/inspector/PickerPreview.js +17 -16
- package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +41 -41
- package/dist/shared/components/layout-editor/outputs/output-api.js +33 -31
- package/dist/shared/components/layout-editor/overview/overview-api.js +84 -83
- package/dist/shared/components/layout-editor/useLayoutDraft.js +47 -42
- package/dist/shared/components/monitoring/InactiveUserLinksView.js +10 -9
- package/dist/shared/components/panels/SlaClock.js +35 -36
- package/dist/shared/components/pipeline/PipelineEditorView.js +311 -312
- package/dist/shared/components/pipeline/TeamSuggestions.js +31 -30
- package/dist/shared/components/profile/AgentsPanel.js +73 -72
- package/dist/shared/components/profile/MailSuppressedPill.js +22 -21
- package/dist/shared/components/support/SupportRequestDialog.js +85 -81
- package/dist/shared/components/support/SupportView.js +94 -87
- package/dist/shared/lib/autofill-poll.js +21 -18
- package/dist/shared/lib/error-actions.js +85 -0
- package/dist/shared/lib/error-message.js +223 -82
- package/dist/shared/lib/error-toast.js +71 -13
- package/dist/shared/lib/safe-error.js +136 -38
- package/package.json +1 -1
|
@@ -1,105 +1,246 @@
|
|
|
1
|
-
import { fieldsFromBody as
|
|
2
|
-
import { isCodeError as
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
1
|
+
import { fieldsFromBody as x, hintFor as L } from "./error-hints.js";
|
|
2
|
+
import { isCodeError as y, isRawErrorText as I, plainErrorText as N, STATUS_TITLES as p, errorStatusOf as F, isBareStatusText as D, SOMETHING_WENT_WRONG as U, statusTitle as P } from "./safe-error.js";
|
|
3
|
+
const _ = "x-nivaro-request-id", H = /^[A-Z][A-Z0-9_]{2,}$/, B = /^(ERR_|E[A-Z]+$)/, W = /failed to fetch|load failed|networkerror|network request failed|network error|cannot reach/i, O = "Try again. If it keeps happening, ask for help.", u = {
|
|
4
|
+
retry: { kind: "retry", label: "Try again" },
|
|
5
|
+
signIn: { kind: "sign-in", label: "Sign in again" },
|
|
6
|
+
reload: { kind: "reload", label: "Reload" },
|
|
7
|
+
reloadPage: { kind: "reload", label: "Reload the page" },
|
|
8
|
+
askAccess: { kind: "contact", label: "Ask for access" },
|
|
9
|
+
back: { kind: "go-back", label: "Go back" }
|
|
10
|
+
}, d = (t) => !!t && typeof t == "object" && !Array.isArray(t);
|
|
11
|
+
function j(t) {
|
|
12
|
+
if (!d(t)) return null;
|
|
13
|
+
const e = t.response;
|
|
14
|
+
return d(e) ? d(e.data) ? e.data : "data" in e && typeof e.data == "string" ? null : e : d(t.extensions) || !(t instanceof Error) && ("error" in t || "message" in t || "code" in t) ? t : null;
|
|
15
|
+
}
|
|
16
|
+
function k(t) {
|
|
10
17
|
return typeof t == "string" && t.trim() ? t.trim() : void 0;
|
|
11
18
|
}
|
|
12
|
-
function
|
|
13
|
-
const
|
|
14
|
-
for (const i of [
|
|
15
|
-
if (typeof i == "string" &&
|
|
19
|
+
function K(t, e) {
|
|
20
|
+
const n = d(e == null ? void 0 : e.extensions) ? e.extensions : null;
|
|
21
|
+
for (const i of [e == null ? void 0 : e.code, n == null ? void 0 : n.code, d(t) ? t.code : void 0])
|
|
22
|
+
if (typeof i == "string" && H.test(i) && !B.test(i)) return i;
|
|
16
23
|
}
|
|
17
|
-
function
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
if (!
|
|
21
|
-
const i =
|
|
24
|
+
function Y(t, e) {
|
|
25
|
+
const n = k(e == null ? void 0 : e.request_id) ?? k(e == null ? void 0 : e.requestId);
|
|
26
|
+
if (n) return n;
|
|
27
|
+
if (!d(t)) return;
|
|
28
|
+
const i = k(t.requestId) ?? k(t.request_id);
|
|
22
29
|
if (i) return i;
|
|
23
|
-
const
|
|
24
|
-
if (r
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
function D(t, n) {
|
|
29
|
-
const e = S(t) ?? (n == null ? void 0 : n.statusCode) ?? (n == null ? void 0 : n.status), i = r(n == null ? void 0 : n.extensions) ? n.extensions.status : void 0, s = typeof e == "number" ? e : typeof i == "number" ? i : void 0;
|
|
30
|
-
return s && s >= 100 && s < 600 ? s : void 0;
|
|
31
|
-
}
|
|
32
|
-
function _(t) {
|
|
33
|
-
for (const n of ["error", "message"]) {
|
|
34
|
-
const e = u(t[n]);
|
|
35
|
-
if (e && !h(e)) return e;
|
|
30
|
+
const r = d(t.response) ? t.response.headers : void 0;
|
|
31
|
+
if (d(r)) {
|
|
32
|
+
const m = r.get;
|
|
33
|
+
return k(typeof m == "function" ? m.call(r, _) : r[_]);
|
|
36
34
|
}
|
|
37
35
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
36
|
+
function G(t, e) {
|
|
37
|
+
const n = F(t) ?? (e == null ? void 0 : e.statusCode) ?? (e == null ? void 0 : e.status), i = d(e == null ? void 0 : e.extensions) ? e.extensions.status : void 0, r = typeof n == "number" ? n : typeof i == "number" ? i : void 0;
|
|
38
|
+
return r && r >= 100 && r < 600 ? r : void 0;
|
|
39
|
+
}
|
|
40
|
+
function M(t) {
|
|
41
|
+
for (const e of ["error", "message"]) {
|
|
42
|
+
const n = k(t[e]);
|
|
43
|
+
if (n && !D(n)) return n;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function Z(t) {
|
|
47
|
+
return d(t) ? t.name === "TimeoutError" || t.code === "ECONNABORTED" || t.code === "ETIMEDOUT" || /timed out|timeout of \d+ms exceeded|took too long/i.test(String(t.message ?? "")) : !1;
|
|
48
|
+
}
|
|
49
|
+
function Q() {
|
|
50
|
+
return typeof navigator < "u" && navigator.onLine === !1;
|
|
51
|
+
}
|
|
52
|
+
function V(t, e, n) {
|
|
53
|
+
return t === 500 && !!e && typeof e.statusCode == "number" && !n;
|
|
54
|
+
}
|
|
55
|
+
function z(t, e) {
|
|
56
|
+
const n = typeof e == "function" ? e(t) : e == null ? void 0 : e[t];
|
|
57
|
+
if (n) return n;
|
|
58
|
+
const r = (t.split(".").filter((m) => !/^\d+$/.test(m)).pop() ?? t).replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_$]+/g, " ").replace(/\s+/g, " ").trim().toLowerCase();
|
|
59
|
+
return r ? r[0].toUpperCase() + r.slice(1) : t;
|
|
60
|
+
}
|
|
61
|
+
function J(t, e) {
|
|
62
|
+
const n = [...new Set(t.map((r) => z(r, e)))], i = n.length > 4 ? [...n.slice(0, 3), `${n.length - 3} more`] : n;
|
|
63
|
+
return i.length < 2 ? i[0] ?? "" : `${i.slice(0, -1).join(", ")} and ${i[i.length - 1]}`;
|
|
64
|
+
}
|
|
65
|
+
function X(t, e = 500) {
|
|
66
|
+
return t.length > e ? `${t.slice(0, e - 1)}…` : t;
|
|
67
|
+
}
|
|
68
|
+
function R(t, e = "Something went wrong", n = {}) {
|
|
69
|
+
const i = j(t), r = d(t) && typeof t.message == "string" ? t.message : void 0, m = d(t) && t.status === 0, o = G(t, i), h = K(t, i), S = Y(t, i), E = { title: e };
|
|
70
|
+
o && (E.status = o), h && (E.code = h), S && (E.requestId = S);
|
|
71
|
+
const T = (s) => {
|
|
72
|
+
const w = [
|
|
73
|
+
i ? k(i.message) : void 0,
|
|
74
|
+
i ? k(i.error) : void 0,
|
|
75
|
+
r,
|
|
76
|
+
typeof t == "string" ? t : ""
|
|
77
|
+
].filter((g) => !!(g != null && g.trim()) && !D(g)).find((g) => I(g) || !!o && o >= 500 && g !== s.title);
|
|
78
|
+
return w && w !== s.title && (s.technical = X(w.trim())), I(s.title) && (s.title = N(s.title, e, o)), s.hint && (I(s.hint) || s.title.includes(s.hint)) && delete s.hint, s;
|
|
79
|
+
};
|
|
80
|
+
if (y(t))
|
|
81
|
+
return T({
|
|
82
|
+
...E,
|
|
83
|
+
kind: "bug",
|
|
84
|
+
title: U,
|
|
85
|
+
hint: "Try again. If it keeps happening, reload the page.",
|
|
86
|
+
action: u.reloadPage
|
|
87
|
+
});
|
|
88
|
+
const $ = r ?? (typeof t == "string" ? t : "");
|
|
89
|
+
if (!o && !h) {
|
|
90
|
+
if (Z(t))
|
|
91
|
+
return T({
|
|
92
|
+
...E,
|
|
93
|
+
kind: "timeout",
|
|
94
|
+
title: "The server took too long to answer",
|
|
95
|
+
hint: "Try again in a minute. If it keeps happening, ask for less at once.",
|
|
96
|
+
action: u.retry
|
|
97
|
+
});
|
|
98
|
+
if (Q() && (m || !i))
|
|
99
|
+
return T({
|
|
100
|
+
...E,
|
|
101
|
+
kind: "offline",
|
|
102
|
+
title: "You’re offline",
|
|
103
|
+
hint: "Check your internet connection, then try again. Nothing you entered is lost.",
|
|
104
|
+
action: u.retry
|
|
105
|
+
});
|
|
106
|
+
if (m || !i && W.test($))
|
|
107
|
+
return T({
|
|
108
|
+
...E,
|
|
109
|
+
kind: "network",
|
|
110
|
+
title: "Cannot reach the server",
|
|
111
|
+
hint: "Check your connection, then try again.",
|
|
112
|
+
action: u.retry
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const A = (i ? M(i) : void 0) ?? (r && !i ? r : void 0), l = A && !I(A) && !V(o, i, h) ? A.trim() : void 0, a = k(i == null ? void 0 : i.hint) ?? k(i == null ? void 0 : i.explanation), c = o || h ? L(h, o ?? 400) : void 0, v = i ? x(i) : [];
|
|
116
|
+
v.length && (E.fields = v);
|
|
117
|
+
const f = (s, w, g, C) => T({
|
|
118
|
+
...E,
|
|
119
|
+
kind: w,
|
|
120
|
+
title: s,
|
|
121
|
+
...g ? { hint: g } : {},
|
|
122
|
+
...C ? { action: C } : {}
|
|
123
|
+
});
|
|
124
|
+
if (h === "MAINTENANCE")
|
|
125
|
+
return f(
|
|
126
|
+
l ?? "The system is down for maintenance",
|
|
127
|
+
"maintenance",
|
|
128
|
+
a ?? c,
|
|
129
|
+
u.reload
|
|
130
|
+
);
|
|
131
|
+
if (o === 401)
|
|
132
|
+
return f(
|
|
133
|
+
l ?? p[401],
|
|
134
|
+
"signed-out",
|
|
135
|
+
a ?? c ?? "Sign in again, then try once more.",
|
|
136
|
+
u.signIn
|
|
137
|
+
);
|
|
138
|
+
if (o === 403)
|
|
139
|
+
return f(
|
|
140
|
+
l ?? p[403],
|
|
141
|
+
"forbidden",
|
|
142
|
+
a ?? c,
|
|
143
|
+
h && !/ask/i.test(a ?? c ?? "") ? void 0 : u.askAccess
|
|
144
|
+
);
|
|
145
|
+
if (o === 404 || o === 410)
|
|
146
|
+
return f(l ?? p[404], "not-found", a ?? c, u.back);
|
|
147
|
+
if (o === 409 || o === 412) {
|
|
148
|
+
const s = a ?? (h ? c : "Reload to see their changes, then make yours again.");
|
|
149
|
+
return f(
|
|
150
|
+
l ?? p[409],
|
|
151
|
+
"conflict",
|
|
152
|
+
s,
|
|
153
|
+
!s || /\breload\b/i.test(s) ? u.reload : void 0
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
if (o === 423)
|
|
157
|
+
return f(l ?? p[423], "locked", a ?? c, u.reload);
|
|
158
|
+
if (o === 413) return f(l ?? p[413], "too-large", a ?? c);
|
|
159
|
+
if (o === 429)
|
|
160
|
+
return f(l ?? p[429], "rate-limited", a ?? c, u.retry);
|
|
161
|
+
if (o === 400 || o === 422) {
|
|
162
|
+
const s = v.length ? J(v, n.fieldLabels) : "", w = a ?? (s && (!h || /highlighted/i.test(c ?? "")) ? `Check ${s}, then try again.` : c), g = v.length > 0 || /^(VALIDATION|REQUIRED)/.test(h ?? "");
|
|
163
|
+
return f(
|
|
164
|
+
l ?? (g ? p[422] : p[400]),
|
|
165
|
+
g ? "validation" : "refused",
|
|
166
|
+
w
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
if (o === 502 || o === 503 || o === 504)
|
|
170
|
+
return f(
|
|
171
|
+
l ?? p[o],
|
|
172
|
+
o === 504 ? "timeout" : "unavailable",
|
|
173
|
+
a ?? c,
|
|
174
|
+
u.retry
|
|
175
|
+
);
|
|
176
|
+
if (o && o >= 500)
|
|
177
|
+
return f(
|
|
178
|
+
l ?? p[500],
|
|
179
|
+
"server",
|
|
180
|
+
a && !/copy the details/i.test(a) ? a : O,
|
|
181
|
+
u.retry
|
|
182
|
+
);
|
|
183
|
+
if (o && o >= 400)
|
|
184
|
+
return f(l ?? P(o) ?? e, "refused", a ?? c);
|
|
185
|
+
if (l) return f(l, h ? "refused" : "unknown", a ?? c);
|
|
186
|
+
const q = $.trim() ? N($, e) : e;
|
|
187
|
+
return f(q, "unknown", a ?? c ?? O, u.retry);
|
|
188
|
+
}
|
|
189
|
+
function it(t, e = "this", n = {}) {
|
|
190
|
+
const i = `Couldn’t load ${e}`, r = R(t, i, n);
|
|
191
|
+
return (r.kind === "bug" || r.kind === "server" && r.title === p[500] || r.title === i) && (r.kind === "server" || r.kind === "bug" || r.kind === "unknown") && (r.title = i, r.hint = r.kind === "bug" ? r.hint : O, r.kind !== "bug" && (r.action = u.retry)), r;
|
|
192
|
+
}
|
|
193
|
+
function b(t, e = {}) {
|
|
194
|
+
var m;
|
|
195
|
+
const n = tt(t) ? t : R(t), i = e.page ?? (typeof window < "u" && window.location ? window.location.pathname : void 0);
|
|
60
196
|
return [
|
|
61
|
-
|
|
62
|
-
`What happened: ${
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
(
|
|
66
|
-
|
|
197
|
+
e.action ? `Action: ${e.action}` : null,
|
|
198
|
+
`What happened: ${n.title}`,
|
|
199
|
+
n.hint ? `What to do: ${n.hint}` : null,
|
|
200
|
+
n.code || n.status ? `Code: ${[n.code, n.status ? `HTTP ${n.status}` : null].filter(Boolean).join(" · ")}` : null,
|
|
201
|
+
(m = n.fields) != null && m.length ? `Fields: ${n.fields.join(", ")}` : null,
|
|
202
|
+
n.requestId ? `Request id: ${n.requestId}` : null,
|
|
203
|
+
n.technical ? `Technical: ${n.technical}` : null,
|
|
67
204
|
i ? `Page: ${i}` : null,
|
|
68
|
-
`When: ${(
|
|
205
|
+
`When: ${(e.now ?? /* @__PURE__ */ new Date()).toISOString()}`
|
|
69
206
|
].filter((o) => !!o).join(`
|
|
70
207
|
`);
|
|
71
208
|
}
|
|
72
|
-
function
|
|
73
|
-
return
|
|
209
|
+
function tt(t) {
|
|
210
|
+
return d(t) && typeof t.title == "string" && !("response" in t) && !("stack" in t);
|
|
74
211
|
}
|
|
75
|
-
async function
|
|
212
|
+
async function rt(t, e) {
|
|
76
213
|
try {
|
|
77
|
-
const
|
|
78
|
-
return typeof navigator > "u" || !navigator.clipboard ? !1 : (await navigator.clipboard.writeText(
|
|
214
|
+
const n = b(t, e);
|
|
215
|
+
return typeof navigator > "u" || !navigator.clipboard ? !1 : (await navigator.clipboard.writeText(n), !0);
|
|
79
216
|
} catch {
|
|
80
217
|
return !1;
|
|
81
218
|
}
|
|
82
219
|
}
|
|
83
|
-
function
|
|
84
|
-
const
|
|
85
|
-
if (!
|
|
86
|
-
let
|
|
87
|
-
const i =
|
|
88
|
-
if (i > 0 && /^(insert|update|delete|merge|select|exec)\s/i.test(
|
|
220
|
+
function ot(t) {
|
|
221
|
+
const e = typeof t == "string" ? t.trim() : String(t ?? "").trim();
|
|
222
|
+
if (!e) return "This row was not imported";
|
|
223
|
+
let n = e;
|
|
224
|
+
const i = e.lastIndexOf(" - ");
|
|
225
|
+
if (i > 0 && /^(insert|update|delete|merge|select|exec)\s/i.test(e) && (n = e.slice(i + 3)), /conflicted with the (FOREIGN KEY|REFERENCE)/i.test(n))
|
|
89
226
|
return "A linked value in this row does not exist — check the spelling or add that record first";
|
|
90
|
-
if (/Violation of (UNIQUE KEY|PRIMARY KEY)|Cannot insert duplicate key/i.test(
|
|
227
|
+
if (/Violation of (UNIQUE KEY|PRIMARY KEY)|Cannot insert duplicate key/i.test(n))
|
|
91
228
|
return "Another record already has a value from this row — change it in the file, or import with Overwrite";
|
|
92
|
-
const
|
|
93
|
-
return
|
|
229
|
+
const r = /Cannot insert the value NULL into column '([^']+)'/i.exec(n);
|
|
230
|
+
return r ? `${r[1].replace(/_/g, " ")} is empty — fill it in the file or map a column to it` : n.replace(/,? table '[^']*'/gi, "").replace(/\s*(INSERT|UPDATE) fails\./gi, "").trim();
|
|
94
231
|
}
|
|
95
|
-
function
|
|
96
|
-
const
|
|
97
|
-
return
|
|
232
|
+
function st(t, e) {
|
|
233
|
+
const n = R(t, e);
|
|
234
|
+
return n.hint ? `${n.title.replace(/[.!?]\s*$/, "")}. ${n.hint}` : n.title;
|
|
98
235
|
}
|
|
99
236
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
237
|
+
O as ASK_FOR_HELP_HINT,
|
|
238
|
+
rt as copyErrorDetails,
|
|
239
|
+
R as describeError,
|
|
240
|
+
it as describeLoadError,
|
|
241
|
+
b as errorDetailsText,
|
|
242
|
+
J as errorFieldList,
|
|
243
|
+
z as errorFieldName,
|
|
244
|
+
st as errorSentence,
|
|
245
|
+
ot as rowErrorSentence
|
|
105
246
|
};
|
|
@@ -1,22 +1,80 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { isValidElement as y } from "react";
|
|
2
|
+
import { toast as l } from "sonner";
|
|
3
|
+
import { runErrorAction as p, openSupportForError as E } from "./error-actions.js";
|
|
4
|
+
import { STATUS_HINTS as d } from "./error-hints.js";
|
|
5
|
+
import { describeError as f, copyErrorDetails as T } from "./error-message.js";
|
|
6
|
+
import { isRawErrorText as k, statusInText as h, plainErrorText as C } from "./safe-error.js";
|
|
7
|
+
function m(r, o) {
|
|
8
|
+
const t = r.action;
|
|
9
|
+
if ((t == null ? void 0 : t.kind) === "retry" && o.retry) return { label: t.label, onClick: () => {
|
|
10
|
+
var n;
|
|
11
|
+
return (n = o.retry) == null ? void 0 : n.call(o);
|
|
12
|
+
} };
|
|
13
|
+
if (t && (t.kind === "sign-in" || t.kind === "contact"))
|
|
14
|
+
return { label: t.label, onClick: () => p(t.kind, r, o) };
|
|
15
|
+
if ((t == null ? void 0 : t.kind) === "reload" && r.kind !== "bug")
|
|
16
|
+
return { label: t.label, onClick: () => p("reload", r, o) };
|
|
17
|
+
if (r.kind === "server" || r.kind === "bug" || r.kind === "unknown" && r.action)
|
|
18
|
+
return {
|
|
19
|
+
label: "Get help",
|
|
20
|
+
onClick: () => E(r, { action: o.action })
|
|
21
|
+
};
|
|
22
|
+
if (r.requestId)
|
|
23
|
+
return {
|
|
8
24
|
label: "Copy details",
|
|
9
25
|
onClick: () => {
|
|
10
|
-
|
|
11
|
-
(
|
|
26
|
+
T(r, o).then(
|
|
27
|
+
(n) => n ? l.success("Details copied") : l.error("Could not copy the details")
|
|
12
28
|
);
|
|
13
29
|
}
|
|
14
|
-
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function a(r, o = {}) {
|
|
33
|
+
const t = w(r) ? r : f(r), n = m(t, o);
|
|
34
|
+
return {
|
|
35
|
+
...t.hint ? { description: t.hint } : {},
|
|
36
|
+
...n ? { action: n } : {}
|
|
15
37
|
};
|
|
16
38
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
39
|
+
function _(r, o, t = {}) {
|
|
40
|
+
const n = f(r, o);
|
|
41
|
+
return l.error(n.title, a(n, t)), n;
|
|
42
|
+
}
|
|
43
|
+
function w(r) {
|
|
44
|
+
return !!r && typeof r == "object" && typeof r.title == "string" && !(r instanceof Error) && !("response" in r);
|
|
45
|
+
}
|
|
46
|
+
let b = !1;
|
|
47
|
+
function q(r = l) {
|
|
48
|
+
if (b) return;
|
|
49
|
+
b = !0;
|
|
50
|
+
const o = r.error, t = ((n, e) => {
|
|
51
|
+
try {
|
|
52
|
+
if (n && typeof n == "object" && !y(n)) {
|
|
53
|
+
const i = f(n);
|
|
54
|
+
return o(i.title, { ...a(i), ...u(e) });
|
|
55
|
+
}
|
|
56
|
+
if (typeof n == "string" && k(n)) {
|
|
57
|
+
const i = h(n), s = i ? d[i] ?? d[i >= 500 ? 500 : 400] : void 0, c = u(e);
|
|
58
|
+
return o(C(n), {
|
|
59
|
+
...s && !(c != null && c.description) ? { description: s } : {},
|
|
60
|
+
...c
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return o(n, u(e));
|
|
64
|
+
} catch {
|
|
65
|
+
return o(n, e);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
r.error = t;
|
|
69
|
+
}
|
|
70
|
+
function u(r) {
|
|
71
|
+
if (!r || typeof r.description != "string" || !k(r.description))
|
|
72
|
+
return r;
|
|
73
|
+
const { description: o, ...t } = r;
|
|
74
|
+
return t;
|
|
19
75
|
}
|
|
20
76
|
export {
|
|
21
|
-
|
|
77
|
+
a as errorToastOptions,
|
|
78
|
+
q as guardErrorToasts,
|
|
79
|
+
_ as toastError
|
|
22
80
|
};
|
|
@@ -1,38 +1,46 @@
|
|
|
1
|
-
import { reportClientCrash as
|
|
2
|
-
const d = "Something went wrong — it’s been reported",
|
|
3
|
-
function
|
|
4
|
-
var
|
|
5
|
-
const t = e, o = (t == null ? void 0 : t.status) ?? ((
|
|
1
|
+
import { reportClientCrash as T } from "./client-crash.js";
|
|
2
|
+
const d = "Something went wrong — it’s been reported", m = /failed to fetch|load failed|networkerror|network request failed|network error/i;
|
|
3
|
+
function h(e) {
|
|
4
|
+
var r;
|
|
5
|
+
const t = e, o = (t == null ? void 0 : t.status) ?? ((r = t == null ? void 0 : t.response) == null ? void 0 : r.status);
|
|
6
6
|
return typeof o == "number" ? o : null;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
return !(e instanceof Error) ||
|
|
8
|
+
function w(e) {
|
|
9
|
+
return !(e instanceof Error) || h(e) != null || e.response != null || m.test(e.message) ? !1 : e instanceof TypeError || e instanceof ReferenceError || e instanceof RangeError;
|
|
10
10
|
}
|
|
11
|
-
const
|
|
12
|
-
function
|
|
13
|
-
var
|
|
14
|
-
const t = e, o = [(
|
|
15
|
-
for (const
|
|
16
|
-
const
|
|
17
|
-
if (typeof
|
|
11
|
+
const g = /^(bad request|unauthorized|forbidden|not found|conflict|unprocessable entity|too many requests|internal server error|bad gateway|service unavailable|gateway timeout)$/i;
|
|
12
|
+
function y(e) {
|
|
13
|
+
var r;
|
|
14
|
+
const t = e, o = [(r = t == null ? void 0 : t.response) == null ? void 0 : r.data, t == null ? void 0 : t.response];
|
|
15
|
+
for (const n of o) {
|
|
16
|
+
const i = n == null ? void 0 : n.error;
|
|
17
|
+
if (typeof i == "string" && i.trim() && !g.test(i.trim())) return i.trim();
|
|
18
18
|
}
|
|
19
|
-
for (const
|
|
20
|
-
const
|
|
21
|
-
if (typeof
|
|
19
|
+
for (const n of o) {
|
|
20
|
+
const i = n == null ? void 0 : n.message;
|
|
21
|
+
if (typeof i == "string" && i.trim()) return i.trim();
|
|
22
22
|
}
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
const o = h(e);
|
|
27
|
-
|
|
25
|
+
function A(e, t = "Failed") {
|
|
26
|
+
const o = h(e), r = y(e);
|
|
27
|
+
if (r && !c(r) && !S(e, o)) return r;
|
|
28
|
+
if (w(e)) return d;
|
|
29
|
+
const n = e instanceof Error ? e.message : typeof e == "string" ? e : "";
|
|
30
|
+
return !o && m.test(n) ? "Cannot reach the server" : n.trim() && !c(n) ? n.trim() : n.trim() ? C(n, t || d, o) : r ? f(o) ?? (t || d) : t;
|
|
28
31
|
}
|
|
29
|
-
|
|
32
|
+
function S(e, t) {
|
|
33
|
+
if (t !== 500) return !1;
|
|
34
|
+
const o = e, r = o == null ? void 0 : o.response, n = r && typeof r.data == "object" && r.data ? r.data : r;
|
|
35
|
+
return !!n && typeof n.statusCode == "number" && typeof n.code != "string";
|
|
36
|
+
}
|
|
37
|
+
const E = {
|
|
30
38
|
400: "That request could not be completed",
|
|
31
|
-
401: "You
|
|
39
|
+
401: "You’ve been signed out",
|
|
32
40
|
403: "You do not have access to do this",
|
|
33
|
-
404: "
|
|
41
|
+
404: "This could not be found",
|
|
34
42
|
408: "The server took too long to answer",
|
|
35
|
-
409: "
|
|
43
|
+
409: "Someone else changed this",
|
|
36
44
|
413: "That is too large to send",
|
|
37
45
|
422: "Some values need fixing",
|
|
38
46
|
423: "Someone else is working on this",
|
|
@@ -42,26 +50,116 @@ const i = {
|
|
|
42
50
|
503: "The server is not answering right now",
|
|
43
51
|
504: "The server took too long to answer"
|
|
44
52
|
};
|
|
45
|
-
function
|
|
46
|
-
return e == null ? null :
|
|
53
|
+
function f(e) {
|
|
54
|
+
return e == null ? null : E[e] ?? (e >= 500 ? E[500] : e >= 400 ? E[400] : null);
|
|
47
55
|
}
|
|
48
|
-
function
|
|
56
|
+
function v(e) {
|
|
49
57
|
if (typeof e != "string") return !1;
|
|
50
58
|
const t = e.trim();
|
|
51
|
-
return /^request failed with status( code)? \d{3}$/i.test(t) ||
|
|
59
|
+
return /^request failed with status( code)? \d{3}$/i.test(t) || // apiFetch-style "Request failed (500)", the SDK's "HTTP 500", "Error 404", "500 Internal Server Error"
|
|
60
|
+
/^(\w+ )?failed \(\d{3}\)$/i.test(t) || /^(http|error|status)( code)?:? ?\d{3}$/i.test(t) || /^\d{3}( [a-z][a-z ]+)?$/i.test(t) || g.test(t) || /^(payload too large|request entity too large|locked|request timeout|method not allowed|not acceptable|precondition failed|unsupported media type)$/i.test(
|
|
61
|
+
t
|
|
62
|
+
);
|
|
52
63
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
function b(e) {
|
|
65
|
+
if (typeof e != "string") return null;
|
|
66
|
+
const t = /\b([45]\d{2})\b/.exec(e);
|
|
67
|
+
return t ? Number(t[1]) : null;
|
|
68
|
+
}
|
|
69
|
+
const R = [
|
|
70
|
+
// Status lines inside a sentence ("Not saved — Request failed (500)")
|
|
71
|
+
/request failed( with status( code)?)? ?\(?\d{3}\)?/i,
|
|
72
|
+
/\bHTTP\/?\d?(\.\d)? ?[45]\d{2}\b/,
|
|
73
|
+
/\bstatus( code)? [45]\d{2}\b/i,
|
|
74
|
+
/\((HTTP )?[45]\d{2}\)\.?$/,
|
|
75
|
+
// JavaScript / runtime errors
|
|
76
|
+
/^(TypeError|ReferenceError|RangeError|SyntaxError|EvalError|URIError|AxiosError|FetchError|AbortError)\b/,
|
|
77
|
+
/cannot read propert(y|ies) of/i,
|
|
78
|
+
/cannot set propert(y|ies) of/i,
|
|
79
|
+
/\bis not a function\b/i,
|
|
80
|
+
/\bis not defined\b/i,
|
|
81
|
+
/\bis not iterable\b/i,
|
|
82
|
+
/\bundefined is not\b/i,
|
|
83
|
+
/unexpected (token|end of (json|input))/i,
|
|
84
|
+
/\bJSON\.parse\b|is not valid JSON/i,
|
|
85
|
+
/Minified React error/i,
|
|
86
|
+
/Maximum call stack/i,
|
|
87
|
+
/\[object \w+\]/,
|
|
88
|
+
/^(undefined|null|NaN|true|false|\{\}|\[\])$/,
|
|
89
|
+
// Stack frames and source paths
|
|
90
|
+
/\n\s*at\s+\S/,
|
|
91
|
+
/\bat\s+[\w$.<>]+\s+\(.*:\d+:\d+\)/,
|
|
92
|
+
/\.(m?[jt]sx?|cjs):\d+(:\d+)?\b/,
|
|
93
|
+
/node_modules\//,
|
|
94
|
+
// SQL and the database's own words
|
|
95
|
+
/\b(select\s[\s\S]+\sfrom|insert\s+into|update\s+\[?[\w.]+\]?\s+set|delete\s+from|merge\s+(into\s+)?\[?[\w.]+\]?\s+(as\s+)?\w*\s*using|exec(ute)?\s+\[?dbo)\b/i,
|
|
96
|
+
/invalid (column|object) name/i,
|
|
97
|
+
/conflicted with the (FOREIGN KEY|REFERENCE|CHECK) constraint/i,
|
|
98
|
+
/violation of (UNIQUE|PRIMARY) KEY/i,
|
|
99
|
+
/cannot insert (the value NULL|duplicate key|explicit value)/i,
|
|
100
|
+
/conversion failed when converting/i,
|
|
101
|
+
/arithmetic overflow/i,
|
|
102
|
+
/string or binary data would be truncated/i,
|
|
103
|
+
/\bdeadlock(ed)? victim/i,
|
|
104
|
+
/incorrect syntax near/i,
|
|
105
|
+
/\bmust declare the scalar variable/i,
|
|
106
|
+
/\b(dbo|sys)\.\w+/i,
|
|
107
|
+
/\b(nivaro|directus)_\w+/i,
|
|
108
|
+
/\bknex\b/i,
|
|
109
|
+
// Drivers, sockets and the network stack
|
|
110
|
+
/\b(ECONNREFUSED|ECONNRESET|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|EPIPE|EHOSTUNREACH|ENETUNREACH|ERR_[A-Z_]+)\b/,
|
|
111
|
+
/socket hang up/i,
|
|
112
|
+
/\b(ConnectionError|RequestError|TediousError|SequelizeError|PrismaClient\w*)\b/,
|
|
113
|
+
/timeout: request failed to complete in \d+ms/i,
|
|
114
|
+
/failed to connect to [\w.-]+:\d+/i,
|
|
115
|
+
/\b\d{1,3}(\.\d{1,3}){3}(:\d+)?\b/,
|
|
116
|
+
/^(failed to fetch|load failed|network ?error|network request failed)$/i,
|
|
117
|
+
// Internal ids
|
|
118
|
+
/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/i
|
|
119
|
+
];
|
|
120
|
+
function c(e) {
|
|
121
|
+
if (typeof e != "string") return e != null;
|
|
122
|
+
const t = e.trim();
|
|
123
|
+
return t ? v(t) ? !0 : R.some((o) => o.test(t)) : !1;
|
|
124
|
+
}
|
|
125
|
+
const N = /\s+[—–-]\s+|:\s+|\.\s+/;
|
|
126
|
+
function C(e, t = d, o) {
|
|
127
|
+
if (typeof e != "string" || !e.trim()) return t;
|
|
128
|
+
const r = e.trim();
|
|
129
|
+
if (!c(r)) return r;
|
|
130
|
+
if (!o && m.test(r) && !/\d{3}/.test(r)) return "Cannot reach the server";
|
|
131
|
+
const n = /^(.*\S)\s*\((?:HTTP )?([45]\d{2})\)\.?$/.exec(r);
|
|
132
|
+
if (n) {
|
|
133
|
+
const s = n[1].replace(/\s*[—–:-]?\s*request failed$/i, "").trim(), a = f(o ?? Number(n[2]));
|
|
134
|
+
if (!s) return a ?? t;
|
|
135
|
+
if (!c(s)) return a ? `${s.replace(/[.!?]\s*$/, "")}. ${a}` : s;
|
|
136
|
+
}
|
|
137
|
+
const i = r.split(N), u = [];
|
|
138
|
+
for (const s of i) {
|
|
139
|
+
if (!s.trim() || c(s)) break;
|
|
140
|
+
u.push(s.trim());
|
|
141
|
+
}
|
|
142
|
+
if (u.length && u.join(" ").length >= 4 && i.length > u.length) {
|
|
143
|
+
const s = o ?? b(r.slice(u.join(" ").length)), a = s ? f(s) : null, l = u.join(". ").replace(/[.!?]\s*$/, "");
|
|
144
|
+
return a && a.toLowerCase() !== l.toLowerCase() ? `${l}. ${a}` : l;
|
|
145
|
+
}
|
|
146
|
+
return f(o ?? b(r)) ?? t;
|
|
147
|
+
}
|
|
148
|
+
const p = /* @__PURE__ */ new WeakSet();
|
|
149
|
+
function O(e, t) {
|
|
150
|
+
!e || !w(t) || p.has(t) || (p.add(t), T(e, t, null).catch(() => {
|
|
56
151
|
}));
|
|
57
152
|
}
|
|
58
153
|
export {
|
|
59
154
|
d as SOMETHING_WENT_WRONG,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
155
|
+
E as STATUS_TITLES,
|
|
156
|
+
h as errorStatusOf,
|
|
157
|
+
v as isBareStatusText,
|
|
158
|
+
w as isCodeError,
|
|
159
|
+
c as isRawErrorText,
|
|
160
|
+
C as plainErrorText,
|
|
161
|
+
O as reportCodeError,
|
|
162
|
+
b as statusInText,
|
|
163
|
+
f as statusTitle,
|
|
164
|
+
A as userErrorMessage
|
|
67
165
|
};
|