@nivaro/react 0.3.146 → 0.3.148
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 +28 -0
- package/dist/index.js +767 -764
- package/dist/shared/components/AnnouncementBanner.js +91 -42
- package/dist/shared/components/hub-switcher/HubSwitcher.js +101 -0
- package/dist/shared/components/item-edit/PlanGrid.js +989 -953
- package/dist/shared/components/ops-report/DigestSections.js +119 -112
- package/dist/shared/components/panels/PipelinePanel.js +71 -71
- package/dist/shared/lib/error-hints.js +8 -1
- package/dist/shared/lib/error-message.js +73 -66
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fieldsFromBody as q, hintFor as F } from "./error-hints.js";
|
|
2
|
-
import { isCodeError as L, isRawErrorText as I, plainErrorText as N, STATUS_TITLES as p, errorStatusOf as
|
|
3
|
-
const _ = "x-nivaro-request-id", H = /^[A-Z][A-Z0-9_]{2,}$/, W = /^(ERR_|E[A-Z]+$)/, B = /failed to fetch|load failed|networkerror|network request failed|network error|cannot reach/i,
|
|
2
|
+
import { isCodeError as L, isRawErrorText as I, plainErrorText as N, STATUS_TITLES as p, errorStatusOf as P, isBareStatusText as D, SOMETHING_WENT_WRONG as U, statusTitle as x } from "./safe-error.js";
|
|
3
|
+
const _ = "x-nivaro-request-id", H = /^[A-Z][A-Z0-9_]{2,}$/, W = /^(ERR_|E[A-Z]+$)/, B = /failed to fetch|load failed|networkerror|network request failed|network error|cannot reach/i, O = "Try again. If it keeps happening, ask for help.", l = {
|
|
4
4
|
retry: { kind: "retry", label: "Try again" },
|
|
5
5
|
signIn: { kind: "sign-in", label: "Sign in again" },
|
|
6
6
|
reload: { kind: "reload", label: "Reload" },
|
|
@@ -13,7 +13,7 @@ function j(t) {
|
|
|
13
13
|
const e = t.response;
|
|
14
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
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function E(t) {
|
|
17
17
|
return typeof t == "string" && t.trim() ? t.trim() : void 0;
|
|
18
18
|
}
|
|
19
19
|
function K(t, e) {
|
|
@@ -21,25 +21,25 @@ function K(t, e) {
|
|
|
21
21
|
for (const i of [e == null ? void 0 : e.code, n == null ? void 0 : n.code, d(t) ? t.code : void 0])
|
|
22
22
|
if (typeof i == "string" && H.test(i) && !W.test(i)) return i;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
const n =
|
|
24
|
+
function M(t, e) {
|
|
25
|
+
const n = E(e == null ? void 0 : e.request_id) ?? E(e == null ? void 0 : e.requestId);
|
|
26
26
|
if (n) return n;
|
|
27
27
|
if (!d(t)) return;
|
|
28
|
-
const i =
|
|
28
|
+
const i = E(t.requestId) ?? E(t.request_id);
|
|
29
29
|
if (i) return i;
|
|
30
30
|
const r = d(t.response) ? t.response.headers : void 0;
|
|
31
31
|
if (d(r)) {
|
|
32
32
|
const m = r.get;
|
|
33
|
-
return
|
|
33
|
+
return E(typeof m == "function" ? m.call(r, _) : r[_]);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
const n =
|
|
36
|
+
function Y(t, e) {
|
|
37
|
+
const n = P(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
38
|
return r && r >= 100 && r < 600 ? r : void 0;
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function G(t) {
|
|
41
41
|
for (const e of ["error", "message"]) {
|
|
42
|
-
const n =
|
|
42
|
+
const n = E(t[e]);
|
|
43
43
|
if (n && !D(n)) return n;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -65,134 +65,141 @@ function J(t, e) {
|
|
|
65
65
|
function X(t, e = 500) {
|
|
66
66
|
return t.length > e ? `${t.slice(0, e - 1)}…` : t;
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
const i = j(t), r = d(t) && typeof t.message == "string" ? t.message : void 0, m = d(t) && t.status === 0, o =
|
|
70
|
-
o && (
|
|
68
|
+
function S(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 = Y(t, i), g = K(t, i), R = M(t, i), k = { title: e };
|
|
70
|
+
o && (k.status = o), g && (k.code = g), R && (k.requestId = R);
|
|
71
71
|
const T = (s) => {
|
|
72
72
|
const w = [
|
|
73
|
-
i ?
|
|
74
|
-
i ?
|
|
73
|
+
i ? E(i.message) : void 0,
|
|
74
|
+
i ? E(i.error) : void 0,
|
|
75
75
|
r,
|
|
76
76
|
typeof t == "string" ? t : ""
|
|
77
|
-
].filter((
|
|
77
|
+
].filter((h) => !!(h != null && h.trim()) && !D(h)).find((h) => I(h) || !!o && o >= 500 && h !== s.title);
|
|
78
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
79
|
};
|
|
80
80
|
if (L(t))
|
|
81
81
|
return T({
|
|
82
|
-
...
|
|
82
|
+
...k,
|
|
83
83
|
kind: "bug",
|
|
84
|
-
title:
|
|
84
|
+
title: U,
|
|
85
85
|
hint: "Try again. If it keeps happening, reload the page.",
|
|
86
|
-
action:
|
|
86
|
+
action: l.reloadPage
|
|
87
87
|
});
|
|
88
|
-
const
|
|
89
|
-
if (!o && !
|
|
88
|
+
const A = r ?? (typeof t == "string" ? t : "");
|
|
89
|
+
if (!o && !g) {
|
|
90
90
|
if (Z(t))
|
|
91
91
|
return T({
|
|
92
|
-
...
|
|
92
|
+
...k,
|
|
93
93
|
kind: "timeout",
|
|
94
94
|
title: "The server took too long to answer",
|
|
95
95
|
hint: "Try again in a minute. If it keeps happening, ask for less at once.",
|
|
96
|
-
action:
|
|
96
|
+
action: l.retry
|
|
97
97
|
});
|
|
98
98
|
if (Q() && (m || !i))
|
|
99
99
|
return T({
|
|
100
|
-
...
|
|
100
|
+
...k,
|
|
101
101
|
kind: "offline",
|
|
102
102
|
title: "You’re offline",
|
|
103
103
|
hint: "Check your internet connection, then try again. Nothing you entered is lost.",
|
|
104
|
-
action:
|
|
104
|
+
action: l.retry
|
|
105
105
|
});
|
|
106
|
-
if (m || !i && B.test(
|
|
106
|
+
if (m || !i && B.test(A))
|
|
107
107
|
return T({
|
|
108
|
-
...
|
|
108
|
+
...k,
|
|
109
109
|
kind: "network",
|
|
110
110
|
title: "Cannot reach the server",
|
|
111
111
|
hint: "Check your connection, then try again.",
|
|
112
|
-
action:
|
|
112
|
+
action: l.retry
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
|
-
const
|
|
116
|
-
v.length && (
|
|
117
|
-
const f = (s, w,
|
|
118
|
-
...
|
|
115
|
+
const $ = (i ? G(i) : void 0) ?? (r && !i ? r : void 0), u = $ && !I($) && !V(o, i, g) ? $.trim() : void 0, a = E(i == null ? void 0 : i.hint) ?? E(i == null ? void 0 : i.explanation), c = o || g ? F(g, o ?? 400) : void 0, v = i ? q(i) : [];
|
|
116
|
+
v.length && (k.fields = v);
|
|
117
|
+
const f = (s, w, h, C) => T({
|
|
118
|
+
...k,
|
|
119
119
|
kind: w,
|
|
120
120
|
title: s,
|
|
121
|
-
...
|
|
121
|
+
...h ? { hint: h } : {},
|
|
122
122
|
...C ? { action: C } : {}
|
|
123
123
|
});
|
|
124
|
-
if (
|
|
124
|
+
if (g === "MAINTENANCE")
|
|
125
125
|
return f(
|
|
126
|
-
|
|
126
|
+
u ?? "The system is down for maintenance",
|
|
127
127
|
"maintenance",
|
|
128
128
|
a ?? c,
|
|
129
|
-
|
|
129
|
+
l.reload
|
|
130
|
+
);
|
|
131
|
+
if (g === "APP_MOVED")
|
|
132
|
+
return f(
|
|
133
|
+
u ?? "This app has moved to another server",
|
|
134
|
+
"unavailable",
|
|
135
|
+
a ?? c,
|
|
136
|
+
l.reloadPage
|
|
130
137
|
);
|
|
131
138
|
if (o === 401)
|
|
132
139
|
return f(
|
|
133
|
-
|
|
140
|
+
u ?? p[401],
|
|
134
141
|
"signed-out",
|
|
135
142
|
a ?? c ?? "Sign in again, then try once more.",
|
|
136
|
-
|
|
143
|
+
l.signIn
|
|
137
144
|
);
|
|
138
145
|
if (o === 403)
|
|
139
146
|
return f(
|
|
140
|
-
|
|
147
|
+
u ?? p[403],
|
|
141
148
|
"forbidden",
|
|
142
149
|
a ?? c,
|
|
143
|
-
|
|
150
|
+
g && !/ask/i.test(a ?? c ?? "") ? void 0 : l.askAccess
|
|
144
151
|
);
|
|
145
152
|
if (o === 404 || o === 410)
|
|
146
|
-
return f(
|
|
153
|
+
return f(u ?? p[404], "not-found", a ?? c, l.back);
|
|
147
154
|
if (o === 409 || o === 412) {
|
|
148
|
-
const s = a ?? (
|
|
155
|
+
const s = a ?? (g ? c : "Reload to see their changes, then make yours again.");
|
|
149
156
|
return f(
|
|
150
|
-
|
|
157
|
+
u ?? p[409],
|
|
151
158
|
"conflict",
|
|
152
159
|
s,
|
|
153
|
-
!s || /\breload\b/i.test(s) ?
|
|
160
|
+
!s || /\breload\b/i.test(s) ? l.reload : void 0
|
|
154
161
|
);
|
|
155
162
|
}
|
|
156
163
|
if (o === 423)
|
|
157
|
-
return f(
|
|
158
|
-
if (o === 413) return f(
|
|
164
|
+
return f(u ?? p[423], "locked", a ?? c, l.reload);
|
|
165
|
+
if (o === 413) return f(u ?? p[413], "too-large", a ?? c);
|
|
159
166
|
if (o === 429)
|
|
160
|
-
return f(
|
|
167
|
+
return f(u ?? p[429], "rate-limited", a ?? c, l.retry);
|
|
161
168
|
if (o === 400 || o === 422) {
|
|
162
|
-
const s = v.length ? J(v, n.fieldLabels) : "", w = a ?? (s && (!
|
|
169
|
+
const s = v.length ? J(v, n.fieldLabels) : "", w = a ?? (s && (!g || /highlighted/i.test(c ?? "")) ? `Check ${s}, then try again.` : c), h = v.length > 0 || /^(VALIDATION|REQUIRED)/.test(g ?? "");
|
|
163
170
|
return f(
|
|
164
|
-
|
|
165
|
-
|
|
171
|
+
u ?? (h ? p[422] : p[400]),
|
|
172
|
+
h ? "validation" : "refused",
|
|
166
173
|
w
|
|
167
174
|
);
|
|
168
175
|
}
|
|
169
176
|
if (o === 502 || o === 503 || o === 504)
|
|
170
177
|
return f(
|
|
171
|
-
|
|
178
|
+
u ?? p[o],
|
|
172
179
|
o === 504 ? "timeout" : "unavailable",
|
|
173
180
|
a ?? c,
|
|
174
|
-
|
|
181
|
+
l.retry
|
|
175
182
|
);
|
|
176
183
|
if (o && o >= 500)
|
|
177
184
|
return f(
|
|
178
|
-
|
|
185
|
+
u ?? p[500],
|
|
179
186
|
"server",
|
|
180
|
-
a && !/copy the details/i.test(a) ? a :
|
|
181
|
-
|
|
187
|
+
a && !/copy the details/i.test(a) ? a : O,
|
|
188
|
+
l.retry
|
|
182
189
|
);
|
|
183
190
|
if (o && o >= 400)
|
|
184
|
-
return f(
|
|
185
|
-
if (
|
|
186
|
-
const y =
|
|
187
|
-
return f(y, "unknown", a ?? c ??
|
|
191
|
+
return f(u ?? x(o) ?? e, "refused", a ?? c);
|
|
192
|
+
if (u) return f(u, g ? "refused" : "unknown", a ?? c);
|
|
193
|
+
const y = A.trim() ? N(A, e) : e;
|
|
194
|
+
return f(y, "unknown", a ?? c ?? O, l.retry);
|
|
188
195
|
}
|
|
189
196
|
function rt(t, e = "this", n = {}) {
|
|
190
|
-
const i = `Couldn’t load ${e}`, r =
|
|
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 :
|
|
197
|
+
const i = `Couldn’t load ${e}`, r = S(t, i, n);
|
|
198
|
+
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 = l.retry)), r;
|
|
192
199
|
}
|
|
193
200
|
function b(t, e = {}) {
|
|
194
201
|
var m;
|
|
195
|
-
const n = et(t) ? t :
|
|
202
|
+
const n = et(t) ? t : S(t), i = e.page ?? (typeof window < "u" && window.location ? window.location.pathname : void 0);
|
|
196
203
|
return [
|
|
197
204
|
e.action ? `Action: ${e.action}` : null,
|
|
198
205
|
`What happened: ${n.title}`,
|
|
@@ -241,13 +248,13 @@ function st(t) {
|
|
|
241
248
|
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();
|
|
242
249
|
}
|
|
243
250
|
function at(t, e) {
|
|
244
|
-
const n =
|
|
251
|
+
const n = S(t, e);
|
|
245
252
|
return n.hint ? `${n.title.replace(/[.!?]\s*$/, "")}. ${n.hint}` : n.title;
|
|
246
253
|
}
|
|
247
254
|
export {
|
|
248
|
-
|
|
255
|
+
O as ASK_FOR_HELP_HINT,
|
|
249
256
|
ot as copyErrorDetails,
|
|
250
|
-
|
|
257
|
+
S as describeError,
|
|
251
258
|
rt as describeLoadError,
|
|
252
259
|
b as errorDetailsText,
|
|
253
260
|
J as errorFieldList,
|