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