@burdenoff/fe-libs 2026.1114.5 → 2026.1114.7
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/shared/assistant/index.d.ts +1 -0
- package/dist/shared/assistant/permissionError.js +5 -2
- package/dist/shared/assistant/ui/AssistantChatArea.js +1261 -1250
- package/dist/shared/assistant/ui/AssistantPageHost.d.ts +10 -1
- package/dist/shared/assistant/ui/AssistantPageHost.js +21 -13
- package/dist/shared/assistant/ui/assistantPageStart.d.ts +9 -0
- package/dist/shared/assistant/ui/assistantPageStart.js +36 -0
- package/dist/shared/providers/AppShellProvider.js +195 -191
- package/dist/shared/utils/backendErrors.d.ts +18 -0
- package/dist/shared/utils/backendErrors.js +128 -81
- package/dist/shared-assistant.js +67 -66
- package/package.json +1 -1
|
@@ -26,6 +26,12 @@ export interface GraphQLBackendErrorLike {
|
|
|
26
26
|
}
|
|
27
27
|
export interface BackendErrorDisplay {
|
|
28
28
|
message: string;
|
|
29
|
+
/**
|
|
30
|
+
* i18n key for `message`, when the message came from fe-libs' own copy (the
|
|
31
|
+
* gateway auth-failure table below). The toast resolves it through the shell
|
|
32
|
+
* dictionary and falls back to `message`, the English (BOFF-10107).
|
|
33
|
+
*/
|
|
34
|
+
messageKey?: string;
|
|
29
35
|
subtitle?: string;
|
|
30
36
|
technicalMessage?: string;
|
|
31
37
|
code?: string;
|
|
@@ -39,6 +45,18 @@ export interface ExtractBackendErrorOptions {
|
|
|
39
45
|
operationName?: string;
|
|
40
46
|
fallbackMessage?: string;
|
|
41
47
|
}
|
|
48
|
+
/** A message fe-libs owns: an i18n key and its English. */
|
|
49
|
+
export interface BackendErrorCopy {
|
|
50
|
+
readonly key: string;
|
|
51
|
+
readonly english: string;
|
|
52
|
+
}
|
|
53
|
+
export declare const AUTH_FAILURE_COPY: Readonly<Record<string, BackendErrorCopy>>;
|
|
54
|
+
/** Every message key the backend-error toast can resolve, for the shell label seed. */
|
|
55
|
+
export declare const BACKEND_ERROR_COPY: readonly BackendErrorCopy[];
|
|
56
|
+
/** True when fe-libs knows what this gateway `authFailure` class means. */
|
|
57
|
+
export declare function isKnownAuthFailure(value: string): boolean;
|
|
58
|
+
/** Test hook: forget which unmapped classes were already reported. */
|
|
59
|
+
export declare function resetUnmappedAuthFailureReportsForTests(): void;
|
|
42
60
|
/** AbortError in either form — a user/navigation cancellation, never surfaced. */
|
|
43
61
|
export declare function isAbortError(input: unknown): boolean;
|
|
44
62
|
/**
|
|
@@ -23,15 +23,58 @@ var e = "burdenoff:backend-error", t = "burdenoff:connection-status", n = "Somet
|
|
|
23
23
|
RBAC_SERVICE_UNAVAILABLE: "We couldn't verify your access just now. Please try again in a moment.",
|
|
24
24
|
DOWNSTREAM_SERVICE_ERROR: "A service is temporarily unavailable. Please try again in a moment."
|
|
25
25
|
}, i = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
key: "backendErrors.generic",
|
|
27
|
+
english: n
|
|
28
|
+
}, a = Object.freeze({
|
|
29
|
+
UNAUTHENTICATED_ACTOR: {
|
|
30
|
+
key: "backendErrors.sessionExpired",
|
|
31
|
+
english: "Your session has expired. Please sign in again."
|
|
32
|
+
},
|
|
33
|
+
WORKSPACE_SESSION_UNRESOLVED: {
|
|
34
|
+
key: "backendErrors.workspaceSessionExpired",
|
|
35
|
+
english: "Your workspace session has expired. Refresh the page to continue."
|
|
36
|
+
},
|
|
37
|
+
WORKSPACE_CONTEXT_MISSING: {
|
|
38
|
+
key: "backendErrors.chooseWorkspace",
|
|
39
|
+
english: "Please choose a workspace and try again."
|
|
40
|
+
},
|
|
41
|
+
CREDENTIAL_EXPIRED: {
|
|
42
|
+
key: "backendErrors.sessionExpired",
|
|
43
|
+
english: "Your session has expired. Please sign in again."
|
|
44
|
+
},
|
|
45
|
+
CREDENTIAL_REVOKED: {
|
|
46
|
+
key: "backendErrors.signedOut",
|
|
47
|
+
english: "You were signed out. Please sign in again."
|
|
48
|
+
},
|
|
49
|
+
CREDENTIAL_INVALID: {
|
|
50
|
+
key: "backendErrors.sessionInvalid",
|
|
51
|
+
english: "Your session is no longer valid. Please sign in again."
|
|
52
|
+
},
|
|
53
|
+
AUTH_SERVICE_UNAVAILABLE: {
|
|
54
|
+
key: "backendErrors.accessCheckUnavailable",
|
|
55
|
+
english: "We couldn't verify your access just now. Please try again in a moment."
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
Object.freeze([i, ...Object.values(a).filter((e, t, n) => n.findIndex((t) => t.key === e.key) === t)]);
|
|
59
|
+
function o(e) {
|
|
60
|
+
return Object.prototype.hasOwnProperty.call(a, e);
|
|
61
|
+
}
|
|
62
|
+
var s = /* @__PURE__ */ new Set(), c = class extends Error {
|
|
63
|
+
constructor(e) {
|
|
64
|
+
super(`Unmapped gateway authFailure: ${e}`), this.name = "UnmappedAuthFailureError";
|
|
65
|
+
}
|
|
29
66
|
};
|
|
30
|
-
function
|
|
67
|
+
function l(e) {
|
|
68
|
+
if (s.has(e)) return;
|
|
69
|
+
s.add(e), console.warn("[Burdenoff backend error] The gateway sent an authFailure class this app does not know; showing the neutral message. Add it to AUTH_FAILURE_COPY in fe-libs backendErrors.ts.", { authFailure: e });
|
|
70
|
+
let t = new c(e);
|
|
71
|
+
import("../providers/shell/crashReporting.js").then(({ reportError: e }) => e(t)).catch(() => void 0);
|
|
72
|
+
}
|
|
73
|
+
function u(e) {
|
|
31
74
|
let t = e?.authFailure;
|
|
32
|
-
if (typeof t == "string") return
|
|
75
|
+
if (typeof t == "string" && t.trim().length !== 0) return o(t) ? a[t] : (l(t), i);
|
|
33
76
|
}
|
|
34
|
-
var
|
|
77
|
+
var d = [
|
|
35
78
|
/^Syntax Error:/i,
|
|
36
79
|
/^Cannot query field\b/i,
|
|
37
80
|
/^Cannot return null for non-nullable field\b/i,
|
|
@@ -43,124 +86,124 @@ var o = [
|
|
|
43
86
|
/^Fragment "[^"]+" cannot be spread here/i,
|
|
44
87
|
/^There can be only one/i,
|
|
45
88
|
/Did you mean /i
|
|
46
|
-
],
|
|
89
|
+
], f = /* @__PURE__ */ new Set([
|
|
47
90
|
"UNAUTHENTICATED",
|
|
48
91
|
"TOKEN_EXPIRED",
|
|
49
92
|
"RESOURCE_CAP_EXCEEDED",
|
|
50
93
|
"STORAGE_QUOTA_EXCEEDED",
|
|
51
94
|
"QUOTA_EXHAUSTED"
|
|
52
|
-
]),
|
|
95
|
+
]), p = /* @__PURE__ */ new Set([
|
|
53
96
|
"ExportTranslations",
|
|
54
97
|
"exportTranslations",
|
|
55
98
|
"AdminEntityCounts",
|
|
56
99
|
"GetTenants",
|
|
57
100
|
"NodeManifest"
|
|
58
|
-
]),
|
|
101
|
+
]), m = ["exportTranslations"], h = ["No translation keys found for the specified criteria"], g = [
|
|
59
102
|
/failed to fetch/i,
|
|
60
103
|
/networkerror when attempting to fetch/i,
|
|
61
104
|
/network request failed/i,
|
|
62
105
|
/the network connection was lost/i,
|
|
63
106
|
/\bECONNREFUSED\b|\bECONNRESET\b|\bETIMEDOUT\b|\bENOTFOUND\b|\bEAI_AGAIN\b|\bEHOSTUNREACH\b|\bENETUNREACH\b/i,
|
|
64
107
|
/network circuit breaker is open/i
|
|
65
|
-
],
|
|
108
|
+
], _ = [
|
|
66
109
|
"We could not reach the server. Please check your connection and try again.",
|
|
67
110
|
"The server is having trouble right now. Please try again in a moment.",
|
|
68
111
|
"The server took too long to respond. Please try again."
|
|
69
|
-
],
|
|
112
|
+
], v = [
|
|
70
113
|
/\bunauthori[sz]ed\b|\bunauthenticated\b|\btoken[\s_-]?expired\b|\b401\b|\b403\b/i,
|
|
71
114
|
/invalid email or password/i,
|
|
72
115
|
/you do not have permission/i
|
|
73
116
|
];
|
|
74
|
-
function
|
|
117
|
+
function y(e) {
|
|
75
118
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
76
119
|
}
|
|
77
|
-
function
|
|
120
|
+
function b(e) {
|
|
78
121
|
if (!e) return !1;
|
|
79
122
|
let t = e.trim();
|
|
80
|
-
return t.length === 0 ||
|
|
123
|
+
return t.length === 0 || v.some((e) => e.test(t)) ? !1 : _.includes(t) || t.toLowerCase() === "load failed" ? !0 : g.some((e) => e.test(t));
|
|
81
124
|
}
|
|
82
|
-
function
|
|
83
|
-
return !!(e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError" ||
|
|
125
|
+
function x(e) {
|
|
126
|
+
return !!(e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError" || y(e) && e.name === "AbortError");
|
|
84
127
|
}
|
|
85
|
-
function
|
|
128
|
+
function S(e) {
|
|
86
129
|
if (typeof e == "string") return e;
|
|
87
130
|
if (e instanceof Error) return e.message;
|
|
88
|
-
if (
|
|
89
|
-
let t =
|
|
131
|
+
if (y(e)) {
|
|
132
|
+
let t = A(e, "message");
|
|
90
133
|
if (t) return t;
|
|
91
|
-
let n =
|
|
134
|
+
let n = M(e);
|
|
92
135
|
if (n && n.length > 0 && typeof n[0]?.message == "string") return n[0].message ?? void 0;
|
|
93
136
|
let r = e.networkError;
|
|
94
|
-
if (
|
|
137
|
+
if (y(r)) return A(r, "message");
|
|
95
138
|
}
|
|
96
139
|
}
|
|
97
|
-
function
|
|
98
|
-
if (!
|
|
140
|
+
function C(e) {
|
|
141
|
+
if (!y(e)) return;
|
|
99
142
|
let t = e.statusCode ?? e.status;
|
|
100
143
|
if (typeof t == "number") return t;
|
|
101
144
|
let n = e.networkError;
|
|
102
|
-
if (
|
|
145
|
+
if (y(n)) {
|
|
103
146
|
let e = n.statusCode ?? n.status;
|
|
104
147
|
if (typeof e == "number") return e;
|
|
105
148
|
}
|
|
106
149
|
}
|
|
107
|
-
function
|
|
108
|
-
if (e == null ||
|
|
109
|
-
let t =
|
|
110
|
-
if (
|
|
111
|
-
let n =
|
|
112
|
-
return n === 401 || n === 403 ? !1 : typeof navigator < "u" && navigator.onLine === !1 || e instanceof TypeError &&
|
|
113
|
-
}
|
|
114
|
-
var
|
|
115
|
-
function
|
|
116
|
-
let r = Date.now(), i =
|
|
117
|
-
r -
|
|
150
|
+
function w(e) {
|
|
151
|
+
if (e == null || x(e)) return !1;
|
|
152
|
+
let t = N(e);
|
|
153
|
+
if (j(t?.extensions?.code ?? t?.extensions?.errorCode)) return !1;
|
|
154
|
+
let n = C(e);
|
|
155
|
+
return n === 401 || n === 403 ? !1 : typeof navigator < "u" && navigator.onLine === !1 || e instanceof TypeError && b(e.message) ? !0 : b(S(e));
|
|
156
|
+
}
|
|
157
|
+
var T = 1e4, E = 0, D = !1;
|
|
158
|
+
function O(e, n) {
|
|
159
|
+
let r = Date.now(), i = S(e) ?? "Network request failed", a = typeof navigator > "u" || navigator.onLine;
|
|
160
|
+
r - E > T && (E = r, console.warn("[Burdenoff network] request could not reach the server", {
|
|
118
161
|
message: i,
|
|
119
162
|
operationName: n.operationName,
|
|
120
163
|
online: a
|
|
121
|
-
})), typeof window < "u" && !
|
|
164
|
+
})), typeof window < "u" && !D && (D = !0, window.dispatchEvent(new CustomEvent(t, { detail: {
|
|
122
165
|
online: !1,
|
|
123
166
|
since: r
|
|
124
167
|
} })));
|
|
125
168
|
}
|
|
126
|
-
function
|
|
127
|
-
typeof window < "u" && (
|
|
169
|
+
function k() {
|
|
170
|
+
typeof window < "u" && (D && (D = !1, E = 0), window.dispatchEvent(new CustomEvent(t, { detail: {
|
|
128
171
|
online: !0,
|
|
129
172
|
since: Date.now()
|
|
130
173
|
} })));
|
|
131
174
|
}
|
|
132
|
-
function
|
|
175
|
+
function A(e, t) {
|
|
133
176
|
let n = e[t];
|
|
134
177
|
return typeof n == "string" && n.trim().length > 0 ? n : void 0;
|
|
135
178
|
}
|
|
136
|
-
function
|
|
179
|
+
function j(e) {
|
|
137
180
|
if (typeof e == "string" && e.trim().length !== 0) return e.trim().replace(/[\s-]+/g, "_").toUpperCase();
|
|
138
181
|
}
|
|
139
|
-
function
|
|
140
|
-
if (!
|
|
182
|
+
function M(e) {
|
|
183
|
+
if (!y(e)) return;
|
|
141
184
|
let t = e.errors;
|
|
142
185
|
if (Array.isArray(t)) return t;
|
|
143
186
|
let n = e.graphQLErrors;
|
|
144
187
|
if (Array.isArray(n)) return n;
|
|
145
188
|
let r = e.networkError;
|
|
146
|
-
if (
|
|
189
|
+
if (y(r)) {
|
|
147
190
|
let e = r.result;
|
|
148
|
-
if (
|
|
191
|
+
if (y(e) && Array.isArray(e.errors)) return e.errors;
|
|
149
192
|
}
|
|
150
193
|
}
|
|
151
|
-
function
|
|
152
|
-
let t =
|
|
194
|
+
function N(e) {
|
|
195
|
+
let t = M(e);
|
|
153
196
|
if (t && t.length > 0) return t[0];
|
|
154
|
-
if (
|
|
197
|
+
if (y(e) && ("message" in e || "extensions" in e)) return e;
|
|
155
198
|
}
|
|
156
|
-
function
|
|
199
|
+
function P(e) {
|
|
157
200
|
if (e) return e.userMessage ?? e.humanMessage ?? e.displayMessage;
|
|
158
201
|
}
|
|
159
|
-
function
|
|
160
|
-
return e.length > 220 || e.includes("\n") ||
|
|
202
|
+
function F(e) {
|
|
203
|
+
return e.length > 220 || e.includes("\n") || d.some((t) => t.test(e)) || /\b(prisma|sql|constraint|undefined|null|ECONN[A-Z_]*|ETIMEDOUT|ENOTFOUND)\b/i.test(e) || /failed to fetch|network error|graphql fetch failed/i.test(e) || /socket connection was closed|pass `?verbose: true`?/i.test(e) || /^HTTP error!?\s*(status)?:?\s*\d{3}\b/i.test(e) || /Cannot (read|set|find|access|query)/i.test(e);
|
|
161
204
|
}
|
|
162
|
-
function
|
|
163
|
-
if (
|
|
205
|
+
function I(e) {
|
|
206
|
+
if (d.some((t) => t.test(e))) return "BAD_USER_INPUT";
|
|
164
207
|
let t = e.toLowerCase();
|
|
165
208
|
if (t.includes("unauthenticated") || t.includes("unauthorized")) return "UNAUTHENTICATED";
|
|
166
209
|
if (t.includes("workspace context")) return "WORKSPACE_REQUIRED";
|
|
@@ -169,25 +212,29 @@ function j(e) {
|
|
|
169
212
|
if (t.includes("quota") || t.includes("limit reached")) return "QUOTA_EXCEEDED";
|
|
170
213
|
if (t.includes("required") || t.includes("invalid") || t.includes("missing")) return "BAD_USER_INPUT";
|
|
171
214
|
}
|
|
172
|
-
function
|
|
173
|
-
let
|
|
174
|
-
if (
|
|
175
|
-
let
|
|
176
|
-
if (
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
215
|
+
function L(e, t, i, a) {
|
|
216
|
+
let o = P(e?.extensions ?? void 0);
|
|
217
|
+
if (o) return { message: o };
|
|
218
|
+
let s = u(e?.extensions ?? void 0);
|
|
219
|
+
if (s) return {
|
|
220
|
+
message: s.english,
|
|
221
|
+
messageKey: s.key
|
|
222
|
+
};
|
|
223
|
+
if (t && r[t]) return { message: r[t] };
|
|
224
|
+
if (i) return { message: i };
|
|
225
|
+
let c = e ? void 0 : a;
|
|
226
|
+
return c && !F(c) ? { message: c } : e?.message && !F(e.message) ? { message: e.message } : { message: n };
|
|
181
227
|
}
|
|
182
|
-
function
|
|
228
|
+
function R(e) {
|
|
183
229
|
if (e && e.length !== 0) return e.map((e) => String(e)).join(".");
|
|
184
230
|
}
|
|
185
|
-
function
|
|
231
|
+
function z(e, t = {}) {
|
|
186
232
|
if (e == null) return null;
|
|
187
|
-
let n =
|
|
233
|
+
let n = N(e), r = n?.extensions ?? void 0, i = e instanceof Error ? e.message : y(e) ? A(e, "message") : void 0, a = j(r?.code ?? r?.errorCode) ?? I(i ?? n?.message ?? ""), o = r?.serviceName, s = R(n?.path), c = r?.requestId ?? r?.correlationId ?? r?.traceId, { message: l, messageKey: u } = L(n, a, t.fallbackMessage, i), d = r?.technicalMessage ?? (n?.message && n.message !== l ? n.message : void 0) ?? (i && i !== l ? i : void 0);
|
|
188
234
|
return {
|
|
189
235
|
message: l,
|
|
190
|
-
|
|
236
|
+
...u ? { messageKey: u } : {},
|
|
237
|
+
technicalMessage: d,
|
|
191
238
|
code: a,
|
|
192
239
|
operationName: t.operationName,
|
|
193
240
|
serviceName: o,
|
|
@@ -196,30 +243,30 @@ function P(e, t = {}) {
|
|
|
196
243
|
extensions: r
|
|
197
244
|
};
|
|
198
245
|
}
|
|
199
|
-
function
|
|
200
|
-
return
|
|
246
|
+
function B(e) {
|
|
247
|
+
return y(e) && typeof e.message == "string";
|
|
201
248
|
}
|
|
202
|
-
var
|
|
203
|
-
function
|
|
249
|
+
var V = /* @__PURE__ */ new Set(["RBAC_SERVICE_UNAVAILABLE", "AUTH_SERVICE_UNAVAILABLE"]), H = 4e3, U = 3e4;
|
|
250
|
+
function W(e) {
|
|
204
251
|
let t = e.code ?? "";
|
|
205
|
-
return
|
|
252
|
+
return V.has(t) ? {
|
|
206
253
|
key: t,
|
|
207
|
-
windowMs:
|
|
254
|
+
windowMs: U
|
|
208
255
|
} : {
|
|
209
256
|
key: `${t}|${e.message}`,
|
|
210
|
-
windowMs:
|
|
257
|
+
windowMs: H
|
|
211
258
|
};
|
|
212
259
|
}
|
|
213
|
-
function
|
|
214
|
-
return !e || e.code &&
|
|
260
|
+
function G(e) {
|
|
261
|
+
return !e || e.code && f.has(e.code) || e.operationName && p.has(e.operationName) || e.path && m.some((t) => e.path === t || e.path?.startsWith(`${t}.`)) || e.technicalMessage && h.some((t) => e.technicalMessage.includes(t)) || !e.code && b(e.technicalMessage ?? e.message) ? !1 : e.message.trim().length > 0;
|
|
215
262
|
}
|
|
216
|
-
function
|
|
217
|
-
if (typeof window > "u" ||
|
|
218
|
-
if (
|
|
219
|
-
|
|
263
|
+
function K(t, n = {}) {
|
|
264
|
+
if (typeof window > "u" || x(t)) return;
|
|
265
|
+
if (w(t)) {
|
|
266
|
+
O(t, n);
|
|
220
267
|
return;
|
|
221
268
|
}
|
|
222
|
-
let r =
|
|
223
|
-
|
|
269
|
+
let r = B(t) ? t : z(t, n);
|
|
270
|
+
G(r) && window.dispatchEvent(new CustomEvent(e, { detail: r }));
|
|
224
271
|
}
|
|
225
|
-
export { e as BACKEND_ERROR_EVENT, t as CONNECTION_STATUS_EVENT,
|
|
272
|
+
export { a as AUTH_FAILURE_COPY, e as BACKEND_ERROR_EVENT, t as CONNECTION_STATUS_EVENT, K as dispatchBackendErrorEvent, z as extractBackendError, W as getBackendErrorToastDedupe, x as isAbortError, B as isBackendErrorDisplay, o as isKnownAuthFailure, w as isTransportError, k as markConnectionHealthy, G as shouldToastBackendError };
|