@burdenoff/fe-libs 2026.1119.2 → 2026.1119.4

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.
@@ -9,37 +9,37 @@ import { dispatchBackendErrorEvent as v, markConnectionHealthy as y } from "../u
9
9
  import { onError as ee } from "@apollo/client/link/error";
10
10
  import { RetryLink as b } from "@apollo/client/link/retry";
11
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";
12
+ import { ApolloClient as S, ApolloLink as C, InMemoryCache as te, Observable as w, from as T, split as ne } from "@apollo/client/core";
13
+ import { getMainDefinition as E } from "@apollo/client/utilities";
14
+ import { print as D } from "graphql";
15
15
  // src/shared/graphql/client.ts
16
- var k = {
16
+ var O = {
17
17
  consecutiveFailures: 0,
18
18
  lastFailureTime: 0,
19
19
  isOpen: !1,
20
20
  openCount: 0,
21
21
  nextRetryTime: 0
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;
22
+ }, k = 20, A = 5e3, j = 3e4;
23
+ function re() {
24
+ if (O.consecutiveFailures++, O.lastFailureTime = Date.now(), !O.isOpen && O.consecutiveFailures >= k) {
25
+ O.isOpen = !0, O.openCount++;
26
+ let e = Math.min(A * 2 ** (O.openCount - 1), j);
27
+ O.nextRetryTime = Date.now() + e;
28
28
  }
29
- return k.isOpen;
29
+ return O.isOpen;
30
30
  }
31
- function N() {
32
- k.consecutiveFailures = 0, k.isOpen = !1, k.openCount = 0, k.nextRetryTime = 0, y();
31
+ function M() {
32
+ O.consecutiveFailures = 0, O.isOpen = !1, O.openCount = 0, O.nextRetryTime = 0, y();
33
33
  }
34
- function P() {
35
- return !(!k.isOpen || Date.now() >= k.nextRetryTime);
34
+ function N() {
35
+ return !(!O.isOpen || Date.now() >= O.nextRetryTime);
36
36
  }
37
- function F(e, t, n) {
37
+ function P(e, t, n) {
38
38
  if (n || !e || h(e)) return !1;
39
39
  let r = e.message?.toLowerCase?.() ?? "";
40
40
  return !(r.includes("401") || r.includes("403") || r.includes("unauthorized") || r.includes("forbidden") || r.includes("unauthenticated") || !c(t));
41
41
  }
42
- function re({ maxAttempts: e, delay: t }) {
42
+ function ie({ maxAttempts: e, delay: t }) {
43
43
  return new b({
44
44
  delay: t ?? {
45
45
  initial: 1e3,
@@ -48,87 +48,90 @@ function re({ maxAttempts: e, delay: t }) {
48
48
  },
49
49
  attempts: {
50
50
  max: e,
51
- retryIf: (e, t) => F(e, t, P())
51
+ retryIf: (e, t) => P(e, t, N())
52
52
  }
53
53
  });
54
54
  }
55
- var I = /(?:\b40[13]\b|status code 40[13]|unauthori[sz]ed|unauthenticated|forbidden|invalid email or password)/i;
56
- function L(e) {
55
+ var F = /(?:\b40[13]\b|status code 40[13]|unauthori[sz]ed|unauthenticated|forbidden|invalid email or password)/i;
56
+ function I(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 ie(e) {
59
+ function ae(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 I.test(e);
62
+ if (typeof e == "string") return F.test(e);
63
63
  if (typeof e != "object") return !1;
64
64
  t.add(e);
65
- let i = e, a = L(i.status) ?? L(i.statusCode) ?? L(i.response?.status);
65
+ let i = e, a = I(i.status) ?? I(i.statusCode) ?? I(i.response?.status);
66
66
  if (a === 401 || a === 403) return !0;
67
67
  let o = i.message;
68
- return typeof o == "string" && I.test(o) ? !0 : n(i.cause, r + 1);
68
+ return typeof o == "string" && F.test(o) ? !0 : n(i.cause, r + 1);
69
69
  };
70
70
  return n(e, 0);
71
71
  }
72
- function ae(e) {
72
+ function oe(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 oe(e) {
77
+ function se(e) {
78
78
  let t = e.workspaceDecision;
79
79
  return t && typeof t == "object" ? t : null;
80
80
  }
81
- function se(e) {
81
+ function ce(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 ce({ query: e }) {
87
- let t = D(e);
86
+ function L({ query: e }) {
87
+ let t = E(e);
88
88
  return t.kind === "OperationDefinition" && t.operation === "subscription";
89
89
  }
90
90
  function le(e) {
91
- let t = D(e);
92
- return t.kind === "OperationDefinition" && t.operation === "mutation";
91
+ return e.getContext().suppressGlobalErrorEvent === !0;
93
92
  }
94
93
  function ue(e) {
94
+ let t = E(e);
95
+ return t.kind === "OperationDefinition" && t.operation === "mutation";
96
+ }
97
+ function de(e) {
95
98
  let t = e.errors;
96
99
  return Array.isArray(t) && t.length > 0;
97
100
  }
98
- function de(e) {
101
+ function fe(e) {
99
102
  let t = e.headers;
100
103
  if (!t || typeof t != "object" || Array.isArray(t)) return {};
101
104
  let n = {};
102
105
  for (let [e, r] of Object.entries(t)) typeof r == "string" && (n[e] = r);
103
106
  return n;
104
107
  }
105
- function fe(e) {
108
+ function R(e) {
106
109
  let t = e.fetchOptions;
107
110
  if (!t || typeof t != "object" || !("signal" in t)) return;
108
111
  let n = t.signal;
109
112
  return n instanceof AbortSignal ? n : void 0;
110
113
  }
111
- var R = "bypassFetchResponseCache", z = "sendUnbatched", B = /* @__PURE__ */ new Set(["network-only", "no-cache"]);
112
- function V(e, t) {
113
- return B.has(e.fetchPolicy ?? t) ? {
114
+ var z = "bypassFetchResponseCache", B = "sendUnbatched", V = /* @__PURE__ */ new Set(["network-only", "no-cache"]);
115
+ function H(e, t) {
116
+ return V.has(e.fetchPolicy ?? t) ? {
114
117
  ...e,
115
118
  context: {
116
119
  ...e.context,
117
- [R]: !0
120
+ [z]: !0
118
121
  }
119
122
  } : e;
120
123
  }
121
124
  var pe = class extends S {
122
125
  constructor(e) {
123
- super(e), H(this);
126
+ super(e), U(this);
124
127
  }
125
128
  };
126
- function H(e) {
129
+ function U(e) {
127
130
  let t = e.query;
128
- e.query = (n) => t(V(n, e.defaultOptions.query?.fetchPolicy));
131
+ e.query = (n) => t(H(n, e.defaultOptions.query?.fetchPolicy));
129
132
  let n = e.watchQuery;
130
133
  e.watchQuery = (t) => {
131
- let r = n(V(t, e.defaultOptions.watchQuery?.fetchPolicy)), i = D(t.query).name?.value;
134
+ let r = n(H(t, e.defaultOptions.watchQuery?.fetchPolicy)), i = E(t.query).name?.value;
132
135
  if (i) {
133
136
  let e = r.refetch.bind(r);
134
137
  r.refetch = (t) => (a(i), e(t));
@@ -138,7 +141,7 @@ function H(e) {
138
141
  }
139
142
  function me({ uri: e, batchMax: t, batchInterval: n }) {
140
143
  return new C((i) => new w((a) => {
141
- let o = i.getContext(), s = { query: O(i.query) };
144
+ let o = i.getContext(), s = { query: D(i.query) };
142
145
  i.operationName && (s.operationName = i.operationName);
143
146
  let c = i.variables ?? {}, l = i.extensions ?? {};
144
147
  Object.keys(c).length > 0 && (s.variables = c), Object.keys(l).length > 0 && (s.extensions = l);
@@ -146,8 +149,8 @@ function me({ uri: e, batchMax: t, batchInterval: n }) {
146
149
  return r(e, {
147
150
  "content-type": "application/json",
148
151
  "Apollo-Require-Preflight": "true",
149
- ...de(o)
150
- }, s, fe(o), {
152
+ ...fe(o)
153
+ }, s, R(o), {
151
154
  batchMax: o.sendUnbatched === !0 ? 1 : t,
152
155
  batchInterval: n,
153
156
  ...o.bypassFetchResponseCache === !0 ? { responseCache: "reload" } : {}
@@ -160,89 +163,89 @@ function me({ uri: e, batchMax: t, batchInterval: n }) {
160
163
  };
161
164
  }));
162
165
  }
163
- function U(r) {
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
166
+ function W(r) {
167
+ let { gateway: a, baseUrl: c, authToken: y, workspaceToken: b, locale: S, geography: D, organizationId: k, productId: A, productSlug: j, workspaceId: P, projectId: F, tenantId: I, cache: fe, enableSubscriptions: R = !1, sseUrl: z, onAuthError: B, onRefreshToken: V, onNetworkError: H, onNetworkStatusChange: U, onMutationSuccess: W, maxRetryAttempts: G = 3, batchMax: K = 10, batchInterval: he, debug: q = !1 } = r, J = g(r.workspaceOperationGuard), Y = null, ge = null, X = () => ({
168
+ workspaceId: (typeof P == "function" ? P() : P) || null,
169
+ organizationId: (typeof k == "function" ? k() : k) || null,
170
+ tenantId: (typeof I == "function" ? I() : I) || null,
171
+ projectId: (typeof F == "function" ? F() : F) || null
169
172
  }), _e = (e) => {
170
173
  ge ||= setTimeout(() => {
171
- ge = null, J && _(J, q, () => Y().workspaceId).catch((t) => {
172
- K && console.warn("[GraphQL] Active query refresh failed after mutation:", {
174
+ ge = null, Y && _(Y, J, () => X().workspaceId).catch((t) => {
175
+ q && console.warn("[GraphQL] Active query refresh failed after mutation:", {
173
176
  gateway: a,
174
177
  operationName: e,
175
178
  error: t
176
179
  });
177
180
  });
178
181
  }, 0);
179
- }, ve = e[a], ye = l(t(c, a)), be = me({
180
- uri: ye,
181
- batchMax: G,
182
+ }, Z = e[a], ve = l(t(c, a)), ye = me({
183
+ uri: ve,
184
+ batchMax: K,
182
185
  batchInterval: he
183
- }), xe = x((e, t) => {
186
+ }), be = x((e, t) => {
184
187
  let n = t.headers ?? {}, r = typeof y == "function" ? y() : y;
185
188
  return { headers: {
186
189
  ...n,
187
190
  ...r ? { authorization: `Bearer ${r}` } : {}
188
191
  } };
189
- }), Se = x((e, t) => {
192
+ }), xe = x((e, t) => {
190
193
  let n = t.headers ?? {}, r = typeof S == "function" ? S() : S;
191
194
  return { headers: {
192
195
  ...n,
193
196
  ...r ? { "accept-language": r } : {}
194
197
  } };
195
- }), Ce = x((e, t) => {
196
- let n = t.headers ?? {}, r = typeof O == "function" ? O() : null;
198
+ }), Se = x((e, t) => {
199
+ let n = t.headers ?? {}, r = typeof D == "function" ? D() : null;
197
200
  return { headers: {
198
201
  ...n,
199
202
  ...r?.country ? { "x-geo-country": r.country } : {},
200
203
  ...r?.currency ? { "x-geo-currency": r.currency } : {},
201
204
  ...r?.timezone ? { "x-geo-timezone": r.timezone } : {}
202
205
  } };
203
- }), we = x((e, t) => {
204
- let n = t.headers ?? {}, r = typeof A == "function" ? A() : A;
206
+ }), Ce = x((e, t) => {
207
+ let n = t.headers ?? {}, r = typeof k == "function" ? k() : k;
205
208
  return { headers: {
206
209
  ...n,
207
210
  ...r ? { "x-org-id": r } : {}
208
211
  } };
209
- }), Te = x((e, t) => {
210
- let n = t.headers ?? {}, r = typeof j == "function" ? j() : j, i = typeof M == "function" ? M() : M;
212
+ }), we = x((e, t) => {
213
+ let n = t.headers ?? {}, r = typeof A == "function" ? A() : A, i = typeof j == "function" ? j() : j;
211
214
  return { headers: {
212
215
  ...n,
213
216
  ...r ? { "x-product-id": r } : {},
214
217
  ...i ? { "x-product-slug": i } : {}
215
218
  } };
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);
219
+ }), Te = x((e, t) => {
220
+ let n = t.headers ?? {}, r = se(t), i = (r ? r.workspaceId : typeof P == "function" ? P() : P) || oe(e.variables);
218
221
  return { headers: {
219
222
  ...n,
220
223
  ...i ? { "x-workspace-id": i } : {}
221
224
  } };
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);
225
+ }), Ee = x((e, t) => {
226
+ let n = t.headers ?? {}, r = se(t), i = (r ? r.projectId : typeof F == "function" ? F() : F) || ce(e.variables);
224
227
  return { headers: {
225
228
  ...n,
226
229
  ...i ? { "x-project-id": i } : {}
227
230
  } };
228
- }), Oe = x((e, t) => {
229
- let n = t.headers ?? {}, r = typeof L == "function" ? L() : L;
231
+ }), De = x((e, t) => {
232
+ let n = t.headers ?? {}, r = typeof I == "function" ? I() : I;
230
233
  return { headers: {
231
234
  ...n,
232
235
  ...r ? { "x-tenant-id": r } : {}
233
236
  } };
234
- }), ke = (e, t, n) => {
235
- if (a !== "workspace" || q === "off") return;
237
+ }), Oe = (e, t, n) => {
238
+ if (a !== "workspace" || J === "off") return;
236
239
  let r = m(e, t, n);
237
240
  if (r) {
238
- if (q === "enforce") throw new p(r);
241
+ if (J === "enforce") throw new p(r);
239
242
  typeof window < "u" && window.dispatchEvent(new CustomEvent(d, { detail: r }));
240
243
  }
241
- }, Ae = x(async (e, n) => {
244
+ }, ke = x(async (e, n) => {
242
245
  let r = n.headers ?? {}, o = n.requiredWorkspaceAuth === !0, s = !o && n.preferWorkspaceAuth === !0;
243
246
  if (a === "global" && !o && !s) return { headers: r };
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");
247
+ let c = typeof y == "function" ? y() : y, l = typeof b == "function" ? b() : b, d = X(), { workspaceId: f, organizationId: p, tenantId: m, projectId: h } = d;
248
+ Oe(e, f, "before-send");
246
249
  let g = !1, _ = u(l, {
247
250
  workspaceId: f,
248
251
  organizationId: p,
@@ -256,7 +259,7 @@ function U(r) {
256
259
  if (n) {
257
260
  g = !0;
258
261
  let r = await Promise.race([i({
259
- url: a === "workspace" ? ye : t(void 0, "workspace"),
262
+ url: a === "workspace" ? ve : t(void 0, "workspace"),
260
263
  authToken: n,
261
264
  workspaceId: f ?? void 0,
262
265
  organizationId: p ?? void 0,
@@ -273,12 +276,12 @@ function U(r) {
273
276
  } catch {}
274
277
  if (o) {
275
278
  if (!_) throw Error("Workspace authentication is unavailable; retry the request");
276
- let e = Y();
279
+ let e = X();
277
280
  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");
278
281
  }
279
282
  if (g) {
280
- let t = Y().workspaceId;
281
- t !== f && ke(e, t, "after-token-mint");
283
+ let t = X().workspaceId;
284
+ t !== f && Oe(e, t, "after-token-mint");
282
285
  }
283
286
  return {
284
287
  headers: {
@@ -287,18 +290,18 @@ function U(r) {
287
290
  },
288
291
  workspaceDecision: d
289
292
  };
290
- }), X = re({ maxAttempts: W }), je = new C((e, t) => {
291
- if (P()) {
292
- K && console.warn("[CircuitBreaker] Circuit is open, blocking request:", e.operationName);
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) => {
293
+ }), Ae = ie({ maxAttempts: G }), je = new C((e, t) => {
294
+ if (N()) {
295
+ q && console.warn("[CircuitBreaker] Circuit is open, blocking request:", e.operationName);
296
+ let t = Math.max(0, Math.ceil((O.nextRetryTime - Date.now()) / 1e3)), n = /* @__PURE__ */ Error(`Network circuit breaker is open — backend appears unreachable. Retrying in ${t} seconds.`);
297
+ return H?.(n), new w((e) => {
295
298
  e.error(n);
296
299
  });
297
300
  }
298
301
  return new w((n) => {
299
302
  let r = t(e).subscribe({
300
303
  next: (e) => {
301
- N(), k.consecutiveFailures === 0 && H?.(!1), n.next(e);
304
+ M(), O.consecutiveFailures === 0 && U?.(!1), n.next(e);
302
305
  },
303
306
  error: (e) => {
304
307
  n.error(e);
@@ -311,9 +314,9 @@ function U(r) {
311
314
  r.unsubscribe();
312
315
  };
313
316
  });
314
- }), Z = !1, Q = [];
317
+ }), Q = !1, $ = [];
315
318
  function Me(e) {
316
- Q.forEach(({ resolve: t }) => t(e)), Q = [];
319
+ $.forEach(({ resolve: t }) => t(e)), $ = [];
317
320
  }
318
321
  let Ne = (e) => {
319
322
  h(e) && e.detail?.operationKind === "mutation" && typeof window < "u" && window.dispatchEvent(new CustomEvent(f, { detail: e.detail }));
@@ -327,19 +330,19 @@ function U(r) {
327
330
  let a = null, o = !1, s = () => {
328
331
  o || (a = Pe(e, t, i));
329
332
  }, c = () => {
330
- z?.(), o || i.error(n);
333
+ B?.(), o || i.error(n);
331
334
  };
332
335
  return (async () => {
333
- if (Z) await new Promise((e) => {
334
- Q.push({ resolve: e });
336
+ if (Q) await new Promise((e) => {
337
+ $.push({ resolve: e });
335
338
  }) ? s() : c();
336
339
  else {
337
- Z = !0;
340
+ Q = !0;
338
341
  try {
339
342
  let e = await r();
340
- Z = !1, Me(e), e ? s() : c();
343
+ Q = !1, Me(e), e ? s() : c();
341
344
  } catch {
342
- Z = !1, Me(!1), c();
345
+ Q = !1, Me(!1), c();
343
346
  }
344
347
  }
345
348
  })(), () => {
@@ -350,57 +353,58 @@ function U(r) {
350
353
  Ne(e);
351
354
  return;
352
355
  }
353
- let r = e.errors;
354
- if (r) {
355
- let i = r.some((e) => e.extensions?.code === "UNAUTHENTICATED" || e.message.includes("Unauthorized") || e.message.includes("Unauthenticated"));
356
- for (let e of r) K && console.error("[GraphQL Error]:", e.message);
357
- i && B || v({ errors: r }, { operationName: t.operationName });
358
- let a = /* @__PURE__ */ new Set(["STORAGE_QUOTA_EXCEEDED", "RESOURCE_CAP_EXCEEDED"]);
359
- for (let e of r) {
356
+ let r = L(t), i = r || le(t), a = e.errors;
357
+ if (a) {
358
+ let o = a.some((e) => e.extensions?.code === "UNAUTHENTICATED" || e.message.includes("Unauthorized") || e.message.includes("Unauthenticated"));
359
+ for (let e of a) q && console.error("[GraphQL Error]:", e.message);
360
+ r ? console.warn("[GraphQL] Subscription returned errors:", {
361
+ operationName: t.operationName,
362
+ errors: a
363
+ }) : !(o && V) && !i && v({ errors: a }, { operationName: t.operationName });
364
+ let s = /* @__PURE__ */ new Set(["STORAGE_QUOTA_EXCEEDED", "RESOURCE_CAP_EXCEEDED"]);
365
+ for (let e of a) {
360
366
  let t = e.extensions?.code;
361
- if (t && a.has(t) && typeof window < "u") {
367
+ if (t && s.has(t) && typeof window < "u") {
362
368
  window.dispatchEvent(new CustomEvent("burdenoff:upgrade-prompt", { detail: { extensions: e.extensions } }));
363
369
  break;
364
370
  }
365
371
  }
366
- if (i && B) return Fe(t, n, e, B);
367
- i && z?.(), N();
372
+ if (o && V) return Fe(t, n, e, V);
373
+ o && B?.(), M();
368
374
  } else {
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:", {
375
+ if (q && console.error("[Network Error]:", e), r && s(e) && e.status === 401 && V) return M(), Fe(t, n, e, V);
376
+ if (ae(e)) {
377
+ M(), r ? console.warn("[GraphQL] Subscription refused by the gateway:", {
374
378
  operationName: t.operationName,
375
379
  error: e
376
- }) : e instanceof Error && v(e, {
380
+ }) : e instanceof Error && !i && v(e, {
377
381
  operationName: t.operationName,
378
382
  fallbackMessage: "Your session is no longer valid. Please sign in again."
379
383
  });
380
384
  return;
381
385
  }
382
- ne() && H?.(!0);
383
- let i = e instanceof Error ? e : Error(String(e));
384
- V?.(i), r ? console.warn("[GraphQL] Subscription stream failed:", {
386
+ re() && U?.(!0);
387
+ let a = e instanceof Error ? e : Error(String(e));
388
+ H?.(a), r ? console.warn("[GraphQL] Subscription stream failed:", {
385
389
  operationName: t.operationName,
386
- error: i
387
- }) : v(i, {
390
+ error: a
391
+ }) : i || v(a, {
388
392
  operationName: t.operationName,
389
393
  fallbackMessage: "We could not reach the server. Please check your connection and try again."
390
394
  });
391
395
  }
392
396
  }), Le = new C((e, t) => {
393
- let r = le(e.query), i = r && e.getContext().autoRefreshAfterMutation !== !1 && e.getContext().skipMutationAutoRefresh !== !0;
397
+ let r = ue(e.query), i = r && e.getContext().autoRefreshAfterMutation !== !1 && e.getContext().skipMutationAutoRefresh !== !0;
394
398
  return new w((o) => {
395
399
  let s = t(e).subscribe({
396
400
  next: (t) => {
397
- if (r && n(), o.next(t), ue(t) || !i) return;
401
+ if (r && n(), o.next(t), de(t) || !i) return;
398
402
  let s = e.operationName || "anonymous mutation";
399
- U ? Promise.resolve(U({
403
+ W ? Promise.resolve(W({
400
404
  gateway: a,
401
405
  operationName: s
402
406
  })).catch((e) => {
403
- K && console.warn("[GraphQL] Mutation refresh callback failed:", {
407
+ q && console.warn("[GraphQL] Mutation refresh callback failed:", {
404
408
  gateway: a,
405
409
  operationName: s,
406
410
  error: e
@@ -420,52 +424,52 @@ function U(r) {
420
424
  });
421
425
  }), Re = new C((e) => new w((t) => {
422
426
  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.`));
423
- })), ze = E(ce, Re, be), $ = T([
424
- X,
427
+ })), ze = ne(L, Re, ye), Be = T([
428
+ Ae,
425
429
  je,
426
430
  Ie,
427
431
  Le,
428
- xe,
429
- Ae,
432
+ be,
433
+ ke,
434
+ Ce,
430
435
  we,
431
436
  Te,
432
437
  Ee,
433
438
  De,
434
- Oe,
439
+ xe,
435
440
  Se,
436
- Ce,
437
441
  ze
438
442
  ]);
439
- if (fe) {
440
- let e = ve.sse, t = R || (e ? l(c || ve.defaultBaseUrl) + e : void 0);
443
+ if (R) {
444
+ let e = Z.sse, t = z || (e ? l(c || Z.defaultBaseUrl) + e : void 0);
441
445
  if (t) {
442
446
  let e = new o({
443
447
  url: t,
444
448
  headers: {},
445
- debug: K
446
- }), n = E(({ query: e }) => {
447
- let t = D(e);
449
+ debug: q
450
+ }), n = ne(({ query: e }) => {
451
+ let t = E(e);
448
452
  return t.kind === "OperationDefinition" && t.operation === "subscription";
449
- }, e, be);
450
- $ = T([
451
- X,
453
+ }, e, ye);
454
+ Be = T([
455
+ Ae,
452
456
  je,
453
457
  Ie,
454
458
  Le,
455
- xe,
456
- Ae,
459
+ be,
460
+ ke,
461
+ Ce,
457
462
  we,
458
463
  Te,
459
464
  Ee,
460
465
  De,
461
- Oe,
466
+ xe,
462
467
  Se,
463
- Ce,
464
468
  n
465
469
  ]);
466
470
  }
467
471
  }
468
- let Be = new te({ typePolicies: {
472
+ let Ve = new te({ typePolicies: {
469
473
  File: { keyFields: ["id"] },
470
474
  Folder: { keyFields: ["id"] },
471
475
  Tag: { keyFields: ["id"] },
@@ -500,9 +504,9 @@ function U(r) {
500
504
  VibecontrolsAgent: { keyFields: ["id"] },
501
505
  Query: { fields: { vibes: { keyArgs: ["filter"] } } }
502
506
  } });
503
- return J = new pe({
504
- link: $,
505
- cache: de ?? Be,
507
+ return Y = new pe({
508
+ link: Be,
509
+ cache: fe ?? Ve,
506
510
  defaultOptions: {
507
511
  watchQuery: {
508
512
  fetchPolicy: "cache-and-network",
@@ -514,19 +518,19 @@ function U(r) {
514
518
  },
515
519
  mutate: { errorPolicy: "all" }
516
520
  }
517
- }), J;
521
+ }), Y;
518
522
  }
519
- var W = null, G = null;
523
+ var G = null, K = null;
520
524
  function he(e) {
521
525
  let { workspaceBaseUrl: t, globalBaseUrl: n, authToken: r, enableSubscriptions: i = !1, onAuthError: a, debug: o = !1 } = e;
522
- W = U({
526
+ G = W({
523
527
  gateway: "workspace",
524
528
  baseUrl: t,
525
529
  authToken: r,
526
530
  enableSubscriptions: i,
527
531
  onAuthError: a,
528
532
  debug: o
529
- }), G = U({
533
+ }), K = W({
530
534
  gateway: "global",
531
535
  baseUrl: n,
532
536
  authToken: r,
@@ -534,15 +538,15 @@ function he(e) {
534
538
  debug: o
535
539
  });
536
540
  }
537
- function K() {
538
- if (!W) throw Error("Workspace client not initialized. Call initializeAppClients first.");
539
- return W;
540
- }
541
541
  function q() {
542
- if (!G) throw Error("Global client not initialized. Call initializeAppClients first.");
542
+ if (!G) throw Error("Workspace client not initialized. Call initializeAppClients first.");
543
543
  return G;
544
544
  }
545
545
  function J() {
546
- W &&= (W.clearStore(), null), G &&= (G.clearStore(), null);
546
+ if (!K) throw Error("Global client not initialized. Call initializeAppClients first.");
547
+ return K;
548
+ }
549
+ function Y() {
550
+ G &&= (G.clearStore(), null), K &&= (K.clearStore(), null);
547
551
  }
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 };
552
+ export { z as BYPASS_FETCH_RESPONSE_CACHE_CONTEXT_KEY, B as SEND_UNBATCHED_CONTEXT_KEY, W as createGraphQLClient, ie as createRetryLink, J as getGlobalClient, q as getWorkspaceClient, he as initializeAppClients, U as installFetchPolicyAwareEntryPoints, ae as isAuthProtocolError, Y as resetAppClients, P as shouldRetryOperationError };