@burdenoff/fe-libs 2026.1023.11 → 2026.1023.13

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