@burdenoff/fe-libs 2026.1114.3 → 2026.1114.5
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/ui/AIAssistantPanel.js +149 -156
- package/dist/shared/assistant/ui/AssistantChatArea.js +0 -1
- package/dist/shared/assistant/ui/assistantPageLayout.d.ts +1 -1
- package/dist/shared/assistant/ui/avatar/AssistantCompactAvatar.d.ts +0 -6
- package/dist/shared/assistant/ui/avatar/AssistantCompactAvatar.js +71 -77
- package/dist/shared/assistant/ui/compact/AssistantPageBar.d.ts +0 -2
- package/dist/shared/assistant/ui/compact/AssistantPageBar.js +9 -10
- package/dist/shared/assistant/ui/compact/AssistantViewSwitch.d.ts +0 -5
- package/dist/shared/assistant/ui/compact/AssistantViewSwitch.js +11 -11
- package/dist/shared/graphql/client.js +188 -185
- package/dist/shared/graphql/links/sse-link.d.ts +16 -0
- package/dist/shared/graphql/links/sse-link.js +37 -27
- package/dist/shared/utils/backendErrors.js +1 -1
- package/package.json +1 -1
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
import { GATEWAYS as e, getGatewayUrl as t } from "../../shared-config.js";
|
|
2
2
|
import { clearGraphqlFetchResponseCache as n, enqueueGraphQLFetch as r, ensureWorkspaceToken as i, evictGraphqlFetchResponses as a } from "./fetch.js";
|
|
3
|
-
import { SSELink as o } from "./links/sse-link.js";
|
|
4
|
-
import { isOperationRetryable as
|
|
5
|
-
import { validateGatewayBaseUrl as
|
|
6
|
-
import { isWorkspaceTokenValidForContext as
|
|
7
|
-
import { WORKSPACE_CONTEXT_MISMATCH_EVENT as
|
|
8
|
-
import { dispatchBackendErrorEvent as
|
|
3
|
+
import { SSELink as o, isSSEHttpError as s } from "./links/sse-link.js";
|
|
4
|
+
import { isOperationRetryable as c } from "./retryPolicy.js";
|
|
5
|
+
import { validateGatewayBaseUrl as l } from "./security.js";
|
|
6
|
+
import { isWorkspaceTokenValidForContext as u } from "./workspaceToken.js";
|
|
7
|
+
import { WORKSPACE_CONTEXT_MISMATCH_EVENT as d, WORKSPACE_WRITE_REFUSED_EVENT as f, WorkspaceContextChangedError as p, findWorkspaceContextMismatch as m, isWorkspaceContextChangedError as h, normalizeWorkspaceOperationGuardMode as g, refetchActiveQueries as _ } from "./workspaceOperationGuard.js";
|
|
8
|
+
import { dispatchBackendErrorEvent as v, markConnectionHealthy as y } from "../utils/backendErrors.js";
|
|
9
9
|
import { onError as ee } from "@apollo/client/link/error";
|
|
10
|
-
import { RetryLink as
|
|
11
|
-
import { setContext as
|
|
12
|
-
import { ApolloClient as
|
|
13
|
-
import { getMainDefinition as
|
|
14
|
-
import { print as
|
|
10
|
+
import { RetryLink as b } from "@apollo/client/link/retry";
|
|
11
|
+
import { setContext as x } from "@apollo/client/link/context";
|
|
12
|
+
import { ApolloClient as S, ApolloLink as C, InMemoryCache as te, Observable as w, from as T, split as E } from "@apollo/client/core";
|
|
13
|
+
import { getMainDefinition as D } from "@apollo/client/utilities";
|
|
14
|
+
import { print as O } from "graphql";
|
|
15
15
|
// src/shared/graphql/client.ts
|
|
16
|
-
var
|
|
16
|
+
var k = {
|
|
17
17
|
consecutiveFailures: 0,
|
|
18
18
|
lastFailureTime: 0,
|
|
19
19
|
isOpen: !1,
|
|
20
20
|
openCount: 0,
|
|
21
21
|
nextRetryTime: 0
|
|
22
|
-
},
|
|
23
|
-
function
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
let e = Math.min(
|
|
27
|
-
|
|
22
|
+
}, A = 20, j = 5e3, M = 3e4;
|
|
23
|
+
function ne() {
|
|
24
|
+
if (k.consecutiveFailures++, k.lastFailureTime = Date.now(), !k.isOpen && k.consecutiveFailures >= A) {
|
|
25
|
+
k.isOpen = !0, k.openCount++;
|
|
26
|
+
let e = Math.min(j * 2 ** (k.openCount - 1), M);
|
|
27
|
+
k.nextRetryTime = Date.now() + e;
|
|
28
28
|
}
|
|
29
|
-
return
|
|
29
|
+
return k.isOpen;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
31
|
+
function N() {
|
|
32
|
+
k.consecutiveFailures = 0, k.isOpen = !1, k.openCount = 0, k.nextRetryTime = 0, y();
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
return !(!
|
|
34
|
+
function P() {
|
|
35
|
+
return !(!k.isOpen || Date.now() >= k.nextRetryTime);
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
if (n || !e ||
|
|
37
|
+
function F(e, t, n) {
|
|
38
|
+
if (n || !e || h(e)) return !1;
|
|
39
39
|
let r = e.message?.toLowerCase?.() ?? "";
|
|
40
|
-
return !(r.includes("401") || r.includes("403") || r.includes("unauthorized") || r.includes("forbidden") || r.includes("unauthenticated") || !
|
|
40
|
+
return !(r.includes("401") || r.includes("403") || r.includes("unauthorized") || r.includes("forbidden") || r.includes("unauthenticated") || !c(t));
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
return new
|
|
42
|
+
function re({ maxAttempts: e, delay: t }) {
|
|
43
|
+
return new b({
|
|
44
44
|
delay: t ?? {
|
|
45
45
|
initial: 1e3,
|
|
46
46
|
max: 8e3,
|
|
@@ -48,57 +48,61 @@ function P({ maxAttempts: e, delay: t }) {
|
|
|
48
48
|
},
|
|
49
49
|
attempts: {
|
|
50
50
|
max: e,
|
|
51
|
-
retryIf: (e, t) =>
|
|
51
|
+
retryIf: (e, t) => F(e, t, P())
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
-
var
|
|
56
|
-
function
|
|
55
|
+
var I = /(?:\b40[13]\b|status code 40[13]|unauthori[sz]ed|unauthenticated|forbidden|invalid email or password)/i;
|
|
56
|
+
function L(e) {
|
|
57
57
|
return typeof e == "number" && Number.isInteger(e) ? e : typeof e == "string" && /^\d{3}$/.test(e) ? Number(e) : null;
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function ie(e) {
|
|
60
60
|
let t = /* @__PURE__ */ new Set(), n = (e, r) => {
|
|
61
61
|
if (r > 3 || e == null || t.has(e)) return !1;
|
|
62
|
-
if (typeof e == "string") return
|
|
62
|
+
if (typeof e == "string") return I.test(e);
|
|
63
63
|
if (typeof e != "object") return !1;
|
|
64
64
|
t.add(e);
|
|
65
|
-
let i = e, a =
|
|
65
|
+
let i = e, a = L(i.status) ?? L(i.statusCode) ?? L(i.response?.status);
|
|
66
66
|
if (a === 401 || a === 403) return !0;
|
|
67
67
|
let o = i.message;
|
|
68
|
-
return typeof o == "string" &&
|
|
68
|
+
return typeof o == "string" && I.test(o) ? !0 : n(i.cause, r + 1);
|
|
69
69
|
};
|
|
70
70
|
return n(e, 0);
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function ae(e) {
|
|
73
73
|
if (!e || typeof e != "object") return null;
|
|
74
74
|
let t = e, n = t.workspaceId || t.input?.workspaceId;
|
|
75
75
|
return typeof n == "string" && n.trim() ? n : null;
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
function oe(e) {
|
|
78
78
|
let t = e.workspaceDecision;
|
|
79
79
|
return t && typeof t == "object" ? t : null;
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function se(e) {
|
|
82
82
|
if (!e || typeof e != "object") return null;
|
|
83
83
|
let t = e.projectId;
|
|
84
84
|
return typeof t == "string" && t.trim() ? t : null;
|
|
85
85
|
}
|
|
86
|
-
function
|
|
87
|
-
let t =
|
|
86
|
+
function ce({ query: e }) {
|
|
87
|
+
let t = D(e);
|
|
88
|
+
return t.kind === "OperationDefinition" && t.operation === "subscription";
|
|
89
|
+
}
|
|
90
|
+
function le(e) {
|
|
91
|
+
let t = D(e);
|
|
88
92
|
return t.kind === "OperationDefinition" && t.operation === "mutation";
|
|
89
93
|
}
|
|
90
|
-
function
|
|
94
|
+
function ue(e) {
|
|
91
95
|
let t = e.errors;
|
|
92
96
|
return Array.isArray(t) && t.length > 0;
|
|
93
97
|
}
|
|
94
|
-
function
|
|
98
|
+
function de(e) {
|
|
95
99
|
let t = e.headers;
|
|
96
100
|
if (!t || typeof t != "object" || Array.isArray(t)) return {};
|
|
97
101
|
let n = {};
|
|
98
102
|
for (let [e, r] of Object.entries(t)) typeof r == "string" && (n[e] = r);
|
|
99
103
|
return n;
|
|
100
104
|
}
|
|
101
|
-
function
|
|
105
|
+
function fe(e) {
|
|
102
106
|
let t = e.fetchOptions;
|
|
103
107
|
if (!t || typeof t != "object" || !("signal" in t)) return;
|
|
104
108
|
let n = t.signal;
|
|
@@ -114,7 +118,7 @@ function V(e, t) {
|
|
|
114
118
|
}
|
|
115
119
|
} : e;
|
|
116
120
|
}
|
|
117
|
-
var
|
|
121
|
+
var pe = class extends S {
|
|
118
122
|
constructor(e) {
|
|
119
123
|
super(e), H(this);
|
|
120
124
|
}
|
|
@@ -124,7 +128,7 @@ function H(e) {
|
|
|
124
128
|
e.query = (n) => t(V(n, e.defaultOptions.query?.fetchPolicy));
|
|
125
129
|
let n = e.watchQuery;
|
|
126
130
|
e.watchQuery = (t) => {
|
|
127
|
-
let r = n(V(t, e.defaultOptions.watchQuery?.fetchPolicy)), i =
|
|
131
|
+
let r = n(V(t, e.defaultOptions.watchQuery?.fetchPolicy)), i = D(t.query).name?.value;
|
|
128
132
|
if (i) {
|
|
129
133
|
let e = r.refetch.bind(r);
|
|
130
134
|
r.refetch = (t) => (a(i), e(t));
|
|
@@ -132,9 +136,9 @@ function H(e) {
|
|
|
132
136
|
return r;
|
|
133
137
|
};
|
|
134
138
|
}
|
|
135
|
-
function
|
|
136
|
-
return new
|
|
137
|
-
let o = i.getContext(), s = { query:
|
|
139
|
+
function me({ uri: e, batchMax: t, batchInterval: n }) {
|
|
140
|
+
return new C((i) => new w((a) => {
|
|
141
|
+
let o = i.getContext(), s = { query: O(i.query) };
|
|
138
142
|
i.operationName && (s.operationName = i.operationName);
|
|
139
143
|
let c = i.variables ?? {}, l = i.extensions ?? {};
|
|
140
144
|
Object.keys(c).length > 0 && (s.variables = c), Object.keys(l).length > 0 && (s.extensions = l);
|
|
@@ -142,8 +146,8 @@ function fe({ uri: e, batchMax: t, batchInterval: n }) {
|
|
|
142
146
|
return r(e, {
|
|
143
147
|
"content-type": "application/json",
|
|
144
148
|
"Apollo-Require-Preflight": "true",
|
|
145
|
-
...
|
|
146
|
-
}, s,
|
|
149
|
+
...de(o)
|
|
150
|
+
}, s, fe(o), {
|
|
147
151
|
batchMax: o.sendUnbatched === !0 ? 1 : t,
|
|
148
152
|
batchInterval: n,
|
|
149
153
|
...o.bypassFetchResponseCache === !0 ? { responseCache: "reload" } : {}
|
|
@@ -157,14 +161,14 @@ function fe({ uri: e, batchMax: t, batchInterval: n }) {
|
|
|
157
161
|
}));
|
|
158
162
|
}
|
|
159
163
|
function U(r) {
|
|
160
|
-
let { gateway: a, baseUrl:
|
|
161
|
-
workspaceId: (typeof
|
|
162
|
-
organizationId: (typeof
|
|
163
|
-
tenantId: (typeof
|
|
164
|
-
projectId: (typeof
|
|
165
|
-
}),
|
|
166
|
-
|
|
167
|
-
|
|
164
|
+
let { gateway: a, baseUrl: c, authToken: y, workspaceToken: b, locale: S, geography: O, organizationId: A, productId: j, productSlug: M, workspaceId: F, projectId: I, tenantId: L, cache: de, enableSubscriptions: fe = !1, sseUrl: R, onAuthError: z, onRefreshToken: B, onNetworkError: V, onNetworkStatusChange: H, onMutationSuccess: U, maxRetryAttempts: W = 3, batchMax: G = 10, batchInterval: he, debug: K = !1 } = r, q = g(r.workspaceOperationGuard), J = null, ge = null, Y = () => ({
|
|
165
|
+
workspaceId: (typeof F == "function" ? F() : F) || null,
|
|
166
|
+
organizationId: (typeof A == "function" ? A() : A) || null,
|
|
167
|
+
tenantId: (typeof L == "function" ? L() : L) || null,
|
|
168
|
+
projectId: (typeof I == "function" ? I() : I) || null
|
|
169
|
+
}), _e = (e) => {
|
|
170
|
+
ge ||= setTimeout(() => {
|
|
171
|
+
ge = null, J && _(J, q, () => Y().workspaceId).catch((t) => {
|
|
168
172
|
K && console.warn("[GraphQL] Active query refresh failed after mutation:", {
|
|
169
173
|
gateway: a,
|
|
170
174
|
operationName: e,
|
|
@@ -172,94 +176,94 @@ function U(r) {
|
|
|
172
176
|
});
|
|
173
177
|
});
|
|
174
178
|
}, 0);
|
|
175
|
-
},
|
|
176
|
-
uri:
|
|
179
|
+
}, ve = e[a], ye = l(t(c, a)), be = me({
|
|
180
|
+
uri: ye,
|
|
177
181
|
batchMax: G,
|
|
178
|
-
batchInterval:
|
|
179
|
-
}),
|
|
180
|
-
let n = t.headers ?? {}, r = typeof
|
|
182
|
+
batchInterval: he
|
|
183
|
+
}), xe = x((e, t) => {
|
|
184
|
+
let n = t.headers ?? {}, r = typeof y == "function" ? y() : y;
|
|
181
185
|
return { headers: {
|
|
182
186
|
...n,
|
|
183
187
|
...r ? { authorization: `Bearer ${r}` } : {}
|
|
184
188
|
} };
|
|
185
|
-
}),
|
|
186
|
-
let n = t.headers ?? {}, r = typeof
|
|
189
|
+
}), Se = x((e, t) => {
|
|
190
|
+
let n = t.headers ?? {}, r = typeof S == "function" ? S() : S;
|
|
187
191
|
return { headers: {
|
|
188
192
|
...n,
|
|
189
193
|
...r ? { "accept-language": r } : {}
|
|
190
194
|
} };
|
|
191
|
-
}),
|
|
192
|
-
let n = t.headers ?? {}, r = typeof
|
|
195
|
+
}), Ce = x((e, t) => {
|
|
196
|
+
let n = t.headers ?? {}, r = typeof O == "function" ? O() : null;
|
|
193
197
|
return { headers: {
|
|
194
198
|
...n,
|
|
195
199
|
...r?.country ? { "x-geo-country": r.country } : {},
|
|
196
200
|
...r?.currency ? { "x-geo-currency": r.currency } : {},
|
|
197
201
|
...r?.timezone ? { "x-geo-timezone": r.timezone } : {}
|
|
198
202
|
} };
|
|
199
|
-
}),
|
|
200
|
-
let n = t.headers ?? {}, r = typeof
|
|
203
|
+
}), we = x((e, t) => {
|
|
204
|
+
let n = t.headers ?? {}, r = typeof A == "function" ? A() : A;
|
|
201
205
|
return { headers: {
|
|
202
206
|
...n,
|
|
203
207
|
...r ? { "x-org-id": r } : {}
|
|
204
208
|
} };
|
|
205
|
-
}),
|
|
206
|
-
let n = t.headers ?? {}, r = typeof
|
|
209
|
+
}), Te = x((e, t) => {
|
|
210
|
+
let n = t.headers ?? {}, r = typeof j == "function" ? j() : j, i = typeof M == "function" ? M() : M;
|
|
207
211
|
return { headers: {
|
|
208
212
|
...n,
|
|
209
213
|
...r ? { "x-product-id": r } : {},
|
|
210
214
|
...i ? { "x-product-slug": i } : {}
|
|
211
215
|
} };
|
|
212
|
-
}),
|
|
213
|
-
let n = t.headers ?? {}, r =
|
|
216
|
+
}), Ee = x((e, t) => {
|
|
217
|
+
let n = t.headers ?? {}, r = oe(t), i = (r ? r.workspaceId : typeof F == "function" ? F() : F) || ae(e.variables);
|
|
214
218
|
return { headers: {
|
|
215
219
|
...n,
|
|
216
220
|
...i ? { "x-workspace-id": i } : {}
|
|
217
221
|
} };
|
|
218
|
-
}),
|
|
219
|
-
let n = t.headers ?? {}, r =
|
|
222
|
+
}), De = x((e, t) => {
|
|
223
|
+
let n = t.headers ?? {}, r = oe(t), i = (r ? r.projectId : typeof I == "function" ? I() : I) || se(e.variables);
|
|
220
224
|
return { headers: {
|
|
221
225
|
...n,
|
|
222
226
|
...i ? { "x-project-id": i } : {}
|
|
223
227
|
} };
|
|
224
|
-
}),
|
|
225
|
-
let n = t.headers ?? {}, r = typeof
|
|
228
|
+
}), Oe = x((e, t) => {
|
|
229
|
+
let n = t.headers ?? {}, r = typeof L == "function" ? L() : L;
|
|
226
230
|
return { headers: {
|
|
227
231
|
...n,
|
|
228
232
|
...r ? { "x-tenant-id": r } : {}
|
|
229
233
|
} };
|
|
230
|
-
}),
|
|
234
|
+
}), ke = (e, t, n) => {
|
|
231
235
|
if (a !== "workspace" || q === "off") return;
|
|
232
|
-
let r =
|
|
236
|
+
let r = m(e, t, n);
|
|
233
237
|
if (r) {
|
|
234
|
-
if (q === "enforce") throw new
|
|
235
|
-
typeof window < "u" && window.dispatchEvent(new CustomEvent(
|
|
238
|
+
if (q === "enforce") throw new p(r);
|
|
239
|
+
typeof window < "u" && window.dispatchEvent(new CustomEvent(d, { detail: r }));
|
|
236
240
|
}
|
|
237
|
-
},
|
|
241
|
+
}, Ae = x(async (e, n) => {
|
|
238
242
|
let r = n.headers ?? {}, o = n.requiredWorkspaceAuth === !0, s = !o && n.preferWorkspaceAuth === !0;
|
|
239
243
|
if (a === "global" && !o && !s) return { headers: r };
|
|
240
|
-
let c = typeof
|
|
241
|
-
|
|
242
|
-
let g = !1, _ = l
|
|
244
|
+
let c = typeof y == "function" ? y() : y, l = typeof b == "function" ? b() : b, d = Y(), { workspaceId: f, organizationId: p, tenantId: m, projectId: h } = d;
|
|
245
|
+
ke(e, f, "before-send");
|
|
246
|
+
let g = !1, _ = u(l, {
|
|
243
247
|
workspaceId: f,
|
|
244
248
|
organizationId: p,
|
|
245
249
|
tenantId: m,
|
|
246
250
|
projectId: h
|
|
247
|
-
}) ?
|
|
251
|
+
}) ? l : null;
|
|
248
252
|
if (o && n.requiredWorkspaceId && n.requiredWorkspaceId !== f) throw Error("The active workspace changed; retry the request");
|
|
249
253
|
if (o && !f) throw Error("Workspace authentication requires an active workspace");
|
|
250
254
|
if (!_ && (a === "workspace" || o || s && f)) try {
|
|
251
|
-
let n = typeof
|
|
255
|
+
let n = typeof y == "function" ? y() : y;
|
|
252
256
|
if (n) {
|
|
253
257
|
g = !0;
|
|
254
258
|
let r = await Promise.race([i({
|
|
255
|
-
url: a === "workspace" ?
|
|
259
|
+
url: a === "workspace" ? ye : t(void 0, "workspace"),
|
|
256
260
|
authToken: n,
|
|
257
261
|
workspaceId: f ?? void 0,
|
|
258
262
|
organizationId: p ?? void 0,
|
|
259
263
|
projectId: h ?? void 0,
|
|
260
264
|
currentQuery: e.operationName ?? ""
|
|
261
265
|
}), new Promise((e) => setTimeout(() => e(null), 4e3))]);
|
|
262
|
-
|
|
266
|
+
u(r, {
|
|
263
267
|
workspaceId: f,
|
|
264
268
|
organizationId: p,
|
|
265
269
|
tenantId: m,
|
|
@@ -270,11 +274,11 @@ function U(r) {
|
|
|
270
274
|
if (o) {
|
|
271
275
|
if (!_) throw Error("Workspace authentication is unavailable; retry the request");
|
|
272
276
|
let e = Y();
|
|
273
|
-
if (c !== (typeof
|
|
277
|
+
if (c !== (typeof y == "function" ? y() : y) || e.workspaceId !== f || e.organizationId !== p || e.projectId !== h || e.tenantId !== m) throw Error("The active workspace changed; retry the request");
|
|
274
278
|
}
|
|
275
279
|
if (g) {
|
|
276
280
|
let t = Y().workspaceId;
|
|
277
|
-
t !== f &&
|
|
281
|
+
t !== f && ke(e, t, "after-token-mint");
|
|
278
282
|
}
|
|
279
283
|
return {
|
|
280
284
|
headers: {
|
|
@@ -283,18 +287,18 @@ function U(r) {
|
|
|
283
287
|
},
|
|
284
288
|
workspaceDecision: d
|
|
285
289
|
};
|
|
286
|
-
}),
|
|
287
|
-
if (
|
|
290
|
+
}), X = re({ maxAttempts: W }), je = new C((e, t) => {
|
|
291
|
+
if (P()) {
|
|
288
292
|
K && console.warn("[CircuitBreaker] Circuit is open, blocking request:", e.operationName);
|
|
289
|
-
let t = Math.max(0, Math.ceil((
|
|
290
|
-
return V?.(n), new
|
|
293
|
+
let t = Math.max(0, Math.ceil((k.nextRetryTime - Date.now()) / 1e3)), n = /* @__PURE__ */ Error(`Network circuit breaker is open — backend appears unreachable. Retrying in ${t} seconds.`);
|
|
294
|
+
return V?.(n), new w((e) => {
|
|
291
295
|
e.error(n);
|
|
292
296
|
});
|
|
293
297
|
}
|
|
294
|
-
return new
|
|
298
|
+
return new w((n) => {
|
|
295
299
|
let r = t(e).subscribe({
|
|
296
300
|
next: (e) => {
|
|
297
|
-
|
|
301
|
+
N(), k.consecutiveFailures === 0 && H?.(!1), n.next(e);
|
|
298
302
|
},
|
|
299
303
|
error: (e) => {
|
|
300
304
|
n.error(e);
|
|
@@ -307,28 +311,50 @@ function U(r) {
|
|
|
307
311
|
r.unsubscribe();
|
|
308
312
|
};
|
|
309
313
|
});
|
|
310
|
-
}),
|
|
311
|
-
function
|
|
312
|
-
|
|
314
|
+
}), Z = !1, Q = [];
|
|
315
|
+
function Me(e) {
|
|
316
|
+
Q.forEach(({ resolve: t }) => t(e)), Q = [];
|
|
313
317
|
}
|
|
314
|
-
let
|
|
315
|
-
|
|
316
|
-
},
|
|
318
|
+
let Ne = (e) => {
|
|
319
|
+
h(e) && e.detail?.operationKind === "mutation" && typeof window < "u" && window.dispatchEvent(new CustomEvent(f, { detail: e.detail }));
|
|
320
|
+
}, Pe = (e, t, n) => t(e).subscribe({
|
|
317
321
|
next: (e) => n.next(e),
|
|
318
322
|
error: (e) => {
|
|
319
|
-
|
|
323
|
+
Ne(e), n.error(e);
|
|
320
324
|
},
|
|
321
325
|
complete: () => n.complete()
|
|
322
|
-
}),
|
|
323
|
-
|
|
324
|
-
|
|
326
|
+
}), Fe = (e, t, n, r) => new w((i) => {
|
|
327
|
+
let a = null, o = !1, s = () => {
|
|
328
|
+
o || (a = Pe(e, t, i));
|
|
329
|
+
}, c = () => {
|
|
330
|
+
z?.(), o || i.error(n);
|
|
331
|
+
};
|
|
332
|
+
return (async () => {
|
|
333
|
+
if (Z) await new Promise((e) => {
|
|
334
|
+
Q.push({ resolve: e });
|
|
335
|
+
}) ? s() : c();
|
|
336
|
+
else {
|
|
337
|
+
Z = !0;
|
|
338
|
+
try {
|
|
339
|
+
let e = await r();
|
|
340
|
+
Z = !1, Me(e), e ? s() : c();
|
|
341
|
+
} catch {
|
|
342
|
+
Z = !1, Me(!1), c();
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
})(), () => {
|
|
346
|
+
o = !0, a?.unsubscribe();
|
|
347
|
+
};
|
|
348
|
+
}), Ie = ee(({ error: e, operation: t, forward: n }) => {
|
|
349
|
+
if (h(e)) {
|
|
350
|
+
Ne(e);
|
|
325
351
|
return;
|
|
326
352
|
}
|
|
327
353
|
let r = e.errors;
|
|
328
354
|
if (r) {
|
|
329
355
|
let i = r.some((e) => e.extensions?.code === "UNAUTHENTICATED" || e.message.includes("Unauthorized") || e.message.includes("Unauthenticated"));
|
|
330
356
|
for (let e of r) K && console.error("[GraphQL Error]:", e.message);
|
|
331
|
-
i && B ||
|
|
357
|
+
i && B || v({ errors: r }, { operationName: t.operationName });
|
|
332
358
|
let a = /* @__PURE__ */ new Set(["STORAGE_QUOTA_EXCEEDED", "RESOURCE_CAP_EXCEEDED"]);
|
|
333
359
|
for (let e of r) {
|
|
334
360
|
let t = e.extensions?.code;
|
|
@@ -337,58 +363,38 @@ function U(r) {
|
|
|
337
363
|
break;
|
|
338
364
|
}
|
|
339
365
|
}
|
|
340
|
-
if (i && B) return
|
|
341
|
-
|
|
342
|
-
if (X) {
|
|
343
|
-
if (await new Promise((e) => {
|
|
344
|
-
Z.push({ resolve: e });
|
|
345
|
-
})) {
|
|
346
|
-
let e = je(t, n, r);
|
|
347
|
-
return () => e.unsubscribe();
|
|
348
|
-
}
|
|
349
|
-
return z?.(), r.error(e), () => {};
|
|
350
|
-
}
|
|
351
|
-
X = !0;
|
|
352
|
-
try {
|
|
353
|
-
let i = await B();
|
|
354
|
-
if (X = !1, i) {
|
|
355
|
-
Q(!0);
|
|
356
|
-
let e = je(t, n, r);
|
|
357
|
-
return () => e.unsubscribe();
|
|
358
|
-
}
|
|
359
|
-
return Q(!1), z?.(), r.error(e), () => {};
|
|
360
|
-
} catch {
|
|
361
|
-
return X = !1, Q(!1), z?.(), r.error(e), () => {};
|
|
362
|
-
}
|
|
363
|
-
})();
|
|
364
|
-
});
|
|
365
|
-
i && z?.(), j();
|
|
366
|
+
if (i && B) return Fe(t, n, e, B);
|
|
367
|
+
i && z?.(), N();
|
|
366
368
|
} else {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
+
K && console.error("[Network Error]:", e);
|
|
370
|
+
let r = ce(t);
|
|
371
|
+
if (r && s(e) && e.status === 401 && B) return N(), Fe(t, n, e, B);
|
|
372
|
+
if (ie(e)) {
|
|
373
|
+
N(), r ? console.warn("[GraphQL] Subscription refused by the gateway:", {
|
|
374
|
+
operationName: t.operationName,
|
|
375
|
+
error: e
|
|
376
|
+
}) : e instanceof Error && v(e, {
|
|
369
377
|
operationName: t.operationName,
|
|
370
378
|
fallbackMessage: "Your session is no longer valid. Please sign in again."
|
|
371
379
|
});
|
|
372
380
|
return;
|
|
373
381
|
}
|
|
374
|
-
|
|
382
|
+
ne() && H?.(!0);
|
|
383
|
+
let i = e instanceof Error ? e : Error(String(e));
|
|
384
|
+
V?.(i), r ? console.warn("[GraphQL] Subscription stream failed:", {
|
|
385
|
+
operationName: t.operationName,
|
|
386
|
+
error: i
|
|
387
|
+
}) : v(i, {
|
|
375
388
|
operationName: t.operationName,
|
|
376
389
|
fallbackMessage: "We could not reach the server. Please check your connection and try again."
|
|
377
390
|
});
|
|
378
|
-
else {
|
|
379
|
-
let n = Error(String(e));
|
|
380
|
-
V?.(n), _(n, {
|
|
381
|
-
operationName: t.operationName,
|
|
382
|
-
fallbackMessage: "We could not reach the server. Please check your connection and try again."
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
391
|
}
|
|
386
|
-
}),
|
|
387
|
-
let r =
|
|
388
|
-
return new
|
|
392
|
+
}), Le = new C((e, t) => {
|
|
393
|
+
let r = le(e.query), i = r && e.getContext().autoRefreshAfterMutation !== !1 && e.getContext().skipMutationAutoRefresh !== !0;
|
|
394
|
+
return new w((o) => {
|
|
389
395
|
let s = t(e).subscribe({
|
|
390
396
|
next: (t) => {
|
|
391
|
-
if (r && n(), o.next(t),
|
|
397
|
+
if (r && n(), o.next(t), ue(t) || !i) return;
|
|
392
398
|
let s = e.operationName || "anonymous mutation";
|
|
393
399
|
U ? Promise.resolve(U({
|
|
394
400
|
gateway: a,
|
|
@@ -399,7 +405,7 @@ function U(r) {
|
|
|
399
405
|
operationName: s,
|
|
400
406
|
error: e
|
|
401
407
|
});
|
|
402
|
-
}) :
|
|
408
|
+
}) : _e(s);
|
|
403
409
|
},
|
|
404
410
|
error: (e) => {
|
|
405
411
|
r && n(), o.error(e);
|
|
@@ -412,57 +418,54 @@ function U(r) {
|
|
|
412
418
|
s.unsubscribe();
|
|
413
419
|
};
|
|
414
420
|
});
|
|
415
|
-
}),
|
|
416
|
-
let t = T(e);
|
|
417
|
-
return t.kind === "OperationDefinition" && t.operation === "subscription";
|
|
418
|
-
}, Fe = new S((e) => new C((t) => {
|
|
421
|
+
}), Re = new C((e) => new w((t) => {
|
|
419
422
|
t.error(/* @__PURE__ */ Error(`[graphql] Refusing to send subscription "${e.operationName ?? "anonymous"}" over the batched HTTP transport — this gateway client was created without enableSubscriptions/SSE. Enable subscriptions on this client so it routes over SSE.`));
|
|
420
|
-
})),
|
|
421
|
-
|
|
423
|
+
})), ze = E(ce, Re, be), $ = T([
|
|
424
|
+
X,
|
|
425
|
+
je,
|
|
426
|
+
Ie,
|
|
427
|
+
Le,
|
|
428
|
+
xe,
|
|
422
429
|
Ae,
|
|
423
|
-
Me,
|
|
424
|
-
Ne,
|
|
425
|
-
ye,
|
|
426
|
-
Oe,
|
|
427
|
-
Se,
|
|
428
|
-
Ce,
|
|
429
430
|
we,
|
|
430
431
|
Te,
|
|
431
432
|
Ee,
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
433
|
+
De,
|
|
434
|
+
Oe,
|
|
435
|
+
Se,
|
|
436
|
+
Ce,
|
|
437
|
+
ze
|
|
435
438
|
]);
|
|
436
|
-
if (
|
|
437
|
-
let e =
|
|
439
|
+
if (fe) {
|
|
440
|
+
let e = ve.sse, t = R || (e ? l(c || ve.defaultBaseUrl) + e : void 0);
|
|
438
441
|
if (t) {
|
|
439
442
|
let e = new o({
|
|
440
443
|
url: t,
|
|
441
444
|
headers: {},
|
|
442
445
|
debug: K
|
|
443
|
-
}), n =
|
|
444
|
-
let t =
|
|
446
|
+
}), n = E(({ query: e }) => {
|
|
447
|
+
let t = D(e);
|
|
445
448
|
return t.kind === "OperationDefinition" && t.operation === "subscription";
|
|
446
|
-
}, e,
|
|
447
|
-
|
|
448
|
-
|
|
449
|
+
}, e, be);
|
|
450
|
+
$ = T([
|
|
451
|
+
X,
|
|
452
|
+
je,
|
|
453
|
+
Ie,
|
|
454
|
+
Le,
|
|
455
|
+
xe,
|
|
449
456
|
Ae,
|
|
450
|
-
Me,
|
|
451
|
-
Ne,
|
|
452
|
-
ye,
|
|
453
|
-
Oe,
|
|
454
|
-
Se,
|
|
455
|
-
Ce,
|
|
456
457
|
we,
|
|
457
458
|
Te,
|
|
458
459
|
Ee,
|
|
459
|
-
|
|
460
|
-
|
|
460
|
+
De,
|
|
461
|
+
Oe,
|
|
462
|
+
Se,
|
|
463
|
+
Ce,
|
|
461
464
|
n
|
|
462
465
|
]);
|
|
463
466
|
}
|
|
464
467
|
}
|
|
465
|
-
let
|
|
468
|
+
let Be = new te({ typePolicies: {
|
|
466
469
|
File: { keyFields: ["id"] },
|
|
467
470
|
Folder: { keyFields: ["id"] },
|
|
468
471
|
Tag: { keyFields: ["id"] },
|
|
@@ -497,9 +500,9 @@ function U(r) {
|
|
|
497
500
|
VibecontrolsAgent: { keyFields: ["id"] },
|
|
498
501
|
Query: { fields: { vibes: { keyArgs: ["filter"] } } }
|
|
499
502
|
} });
|
|
500
|
-
return J = new
|
|
501
|
-
link:
|
|
502
|
-
cache:
|
|
503
|
+
return J = new pe({
|
|
504
|
+
link: $,
|
|
505
|
+
cache: de ?? Be,
|
|
503
506
|
defaultOptions: {
|
|
504
507
|
watchQuery: {
|
|
505
508
|
fetchPolicy: "cache-and-network",
|
|
@@ -514,7 +517,7 @@ function U(r) {
|
|
|
514
517
|
}), J;
|
|
515
518
|
}
|
|
516
519
|
var W = null, G = null;
|
|
517
|
-
function
|
|
520
|
+
function he(e) {
|
|
518
521
|
let { workspaceBaseUrl: t, globalBaseUrl: n, authToken: r, enableSubscriptions: i = !1, onAuthError: a, debug: o = !1 } = e;
|
|
519
522
|
W = U({
|
|
520
523
|
gateway: "workspace",
|
|
@@ -542,4 +545,4 @@ function q() {
|
|
|
542
545
|
function J() {
|
|
543
546
|
W &&= (W.clearStore(), null), G &&= (G.clearStore(), null);
|
|
544
547
|
}
|
|
545
|
-
export { R as BYPASS_FETCH_RESPONSE_CACHE_CONTEXT_KEY, z as SEND_UNBATCHED_CONTEXT_KEY, U as createGraphQLClient,
|
|
548
|
+
export { R as BYPASS_FETCH_RESPONSE_CACHE_CONTEXT_KEY, z as SEND_UNBATCHED_CONTEXT_KEY, U as createGraphQLClient, re as createRetryLink, q as getGlobalClient, K as getWorkspaceClient, he as initializeAppClients, H as installFetchPolicyAwareEntryPoints, ie as isAuthProtocolError, J as resetAppClients, F as shouldRetryOperationError };
|
|
@@ -30,6 +30,22 @@ export interface SSELinkOptions {
|
|
|
30
30
|
*/
|
|
31
31
|
schedule?: SSEReconnectSchedule;
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* The gateway refused the subscription request with a non-2xx HTTP status.
|
|
35
|
+
*
|
|
36
|
+
* The status travels on the error (`status`, and `statusCode` for readers that
|
|
37
|
+
* use that spelling) so the client's error link can tell an expired or
|
|
38
|
+
* not-yet-ready session (401) apart from every other refusal and run the same
|
|
39
|
+
* refresh-and-retry it runs for queries (BOFF-10517). The message stays
|
|
40
|
+
* technical on purpose: it is for the console, never for a toast.
|
|
41
|
+
*/
|
|
42
|
+
export declare class SSEHttpError extends Error {
|
|
43
|
+
readonly status: number;
|
|
44
|
+
readonly statusCode: number;
|
|
45
|
+
constructor(status: number);
|
|
46
|
+
}
|
|
47
|
+
/** True for the error SSELink raises when the gateway answers with a non-2xx status. */
|
|
48
|
+
export declare function isSSEHttpError(error: unknown): error is SSEHttpError;
|
|
33
49
|
/**
|
|
34
50
|
* SSE Link for GraphQL Yoga subscriptions
|
|
35
51
|
*
|