@burdenoff/fe-libs 2026.1010.1 → 2026.1010.3

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.
@@ -1,4 +1,5 @@
1
1
  import { ApolloClient, InMemoryCache } from '@apollo/client';
2
+ import { RetryPolicyOperation } from '../graphql/retryPolicy';
2
3
  export interface CreateApolloClientOptions {
3
4
  uri: string;
4
5
  getAuthToken?: () => string | null | undefined;
@@ -15,11 +16,14 @@ export declare function withBrowserTraceHeader(headersInit?: HeadersInit): Heade
15
16
  *
16
17
  * Retries any unrecognised error (default-true) so genuine transient
17
18
  * network / 5xx failures still benefit from the link's retry budget;
18
- * permanent failures are filtered via three signals, in order:
19
+ * permanent failures are filtered via three signals, in order.
20
+ * Mutations are never retried (an ambiguous 5xx/timeout may have committed the
21
+ * write) unless the operation context sets `retryMutation: true`.
22
+ * Signals:
19
23
  * 1. Numeric `statusCode` (Apollo Client 4's `ServerError`)
20
24
  * 2. `errors[].extensions.code` (GraphQL response auth codes)
21
25
  * 3. Substring match on `message` (fallback for link errors that
22
26
  * surface auth codes only in their message string)
23
27
  */
24
- export declare function shouldRetryApolloError(error: unknown): boolean;
28
+ export declare function shouldRetryApolloError(error: unknown, operation?: RetryPolicyOperation): boolean;
25
29
  export declare function createApolloClient(options: CreateApolloClientOptions): ApolloClient;
@@ -1,28 +1,29 @@
1
1
  import { createBrowserTraceContext as e } from "../events/metadata.js";
2
- import { ApolloClient as t, InMemoryCache as n, from as r } from "@apollo/client";
3
- import { BatchHttpLink as i } from "@apollo/client/link/batch-http";
4
- import { onError as a } from "@apollo/client/link/error";
5
- import { RetryLink as o } from "@apollo/client/link/retry";
6
- import { setContext as s } from "@apollo/client/link/context";
2
+ import { isOperationRetryable as t } from "../graphql/retryPolicy.js";
3
+ import { ApolloClient as n, InMemoryCache as r, from as i } from "@apollo/client";
4
+ import { BatchHttpLink as a } from "@apollo/client/link/batch-http";
5
+ import { onError as o } from "@apollo/client/link/error";
6
+ import { RetryLink as s } from "@apollo/client/link/retry";
7
+ import { setContext as c } from "@apollo/client/link/context";
7
8
  //#region src/shared/utils/apollo.ts
8
- function c(t) {
9
+ function l(t) {
9
10
  let n = new Headers(t);
10
11
  return n.has("traceparent") || n.set("traceparent", e().traceparent), n;
11
12
  }
12
- var l = new Set([
13
+ var u = new Set([
13
14
  401,
14
15
  403,
15
16
  413
16
17
  ]);
17
- function u(e) {
18
- if (!e) return !1;
19
- let t = e.statusCode;
20
- if (typeof t == "number" && l.has(t) || e.errors?.some((e) => e.extensions?.code === "UNAUTHENTICATED" || e.extensions?.code === "FORBIDDEN")) return !1;
21
- let n = e.message;
22
- return !(n && /UNAUTHENTICATED|FORBIDDEN/.test(n));
18
+ function d(e, n) {
19
+ if (!e || !t(n)) return !1;
20
+ let r = e.statusCode;
21
+ if (typeof r == "number" && u.has(r) || e.errors?.some((e) => e.extensions?.code === "UNAUTHENTICATED" || e.extensions?.code === "FORBIDDEN")) return !1;
22
+ let i = e.message;
23
+ return !(i && /UNAUTHENTICATED|FORBIDDEN/.test(i));
23
24
  }
24
- function d(e) {
25
- let { uri: l, getAuthToken: d, onAuthError: f, onNetworkError: p, cache: m = new n(), retryAttempts: h = 3, retryDelay: g = 1e3 } = e, _ = new o({
25
+ function f(e) {
26
+ let { uri: t, getAuthToken: u, onAuthError: f, onNetworkError: p, cache: m = new r(), retryAttempts: h = 3, retryDelay: g = 1e3 } = e, _ = new s({
26
27
  delay: {
27
28
  initial: g,
28
29
  max: g * 4,
@@ -30,15 +31,15 @@ function d(e) {
30
31
  },
31
32
  attempts: {
32
33
  max: h,
33
- retryIf: u
34
+ retryIf: d
34
35
  }
35
- }), v = a(({ error: e }) => {
36
+ }), v = o(({ error: e }) => {
36
37
  let t = e.errors;
37
38
  t ? t.forEach((e) => {
38
39
  console.error(`[GraphQL error]: Message: ${e.message}, Location: ${JSON.stringify(e.locations)}, Path: ${e.path}`), e.extensions?.code === "UNAUTHENTICATED" && f?.();
39
40
  }) : e && (console.error(`[Network error]: ${e.message}`), p?.(e));
40
- }), y = s((e, { headers: t }) => {
41
- let n = d?.();
41
+ }), y = c((e, { headers: t }) => {
42
+ let n = u?.();
42
43
  console.log("[fe-libs apollo] getAuthToken returned:", n ? n.substring(0, 20) + "..." : "null");
43
44
  let r = { headers: {
44
45
  ...t,
@@ -47,15 +48,15 @@ function d(e) {
47
48
  return console.log("[fe-libs apollo] Authorization header:", r.headers.authorization ? r.headers.authorization.substring(0, 30) + "..." : "MISSING"), r;
48
49
  }), b = fetch, x = ((e, t) => fetch(e, {
49
50
  ...t,
50
- headers: c(t?.headers)
51
+ headers: l(t?.headers)
51
52
  }));
52
- return b.preconnect && (x.preconnect = b.preconnect), new t({
53
- link: r([
53
+ return b.preconnect && (x.preconnect = b.preconnect), new n({
54
+ link: i([
54
55
  _,
55
56
  v,
56
57
  y,
57
- new i({
58
- uri: l,
58
+ new a({
59
+ uri: t,
59
60
  credentials: "include",
60
61
  batchMax: 10,
61
62
  batchInterval: 100,
@@ -77,4 +78,4 @@ function d(e) {
77
78
  });
78
79
  }
79
80
  //#endregion
80
- export { d as createApolloClient };
81
+ export { f as createApolloClient };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/fe-libs",
3
- "version": "2026.1010.1",
3
+ "version": "2026.1010.3",
4
4
  "description": "Burdenoff frontend primitives and domain libraries",
5
5
  "type": "module",
6
6
  "bin": {
@@ -314,7 +314,7 @@
314
314
  "test:package-css-exports": "node scripts/validate-package-css-exports.mjs",
315
315
  "verify:package": "node scripts/verify-package-contents.mjs",
316
316
  "test:handsfree-browser": "node scripts/handsfree-browser-run.mjs",
317
- "test": "bun test scripts/graphql-schema-drift/__tests__ scripts/a11y-audit/__tests__ src/credentials src/connections src/storage src/shared/assistant src/shared/components src/shared/graphql/links/sse-link.test.ts src/shared/graphql/fetch.test.ts src/shared/graphql/tourWorkspaceAuth.test.ts src/shared/config/gatewayUrls.test.ts src/shared/config/authBridgeUrls.test.ts src/shared/config/gatewayFallback.test.ts scripts/__tests__ src/shared/config/products.test.ts src/shared/config/productSlug.test.ts src/shared/hooks/shell/useProducts.test.ts src/shared/providers/shell/brandAttribute.test.ts src/chrome/ProductSwitcher.test.ts src/shared/utils/gatewayFetchRewrite.test.ts src/shared/utils/authCookie.test.ts src/shared/providers/AppShellProvider.test.ts src/shared/providers/shell/interpolate.test.ts src/shared/providers/shell/resolveTranslation.test.ts src/shared/providers/shell/I18nProvider.render.test.tsx src/shared/providers/shell/I18nProvider.client.test.tsx src/shared/providers/shell/translationStore.test.ts src/shared/providers/shell/translationLayers.test.ts src/shared/providers/shell/directionMode.test.ts src/shared/providers/shell/authProvider/ssoRelay.test.ts src/shared/providers/shell/personaSurfaceRemote.test.ts src/shared/providers/shell/workspaceSwitch.client.test.tsx src/shared/events/sinks/RybbitSink.test.ts src/shell-native src/shared/native src/shared/navigation src/shared/tours src/chrome/__tests__ src/ui/__tests__",
317
+ "test": "bun test scripts/graphql-schema-drift/__tests__ scripts/a11y-audit/__tests__ src/credentials src/connections src/storage src/shared/assistant src/shared/components src/shared/graphql/links/sse-link.test.ts src/shared/graphql/fetch.test.ts src/shared/graphql/client.test.ts src/shared/utils/apollo.test.ts src/shared/graphql/tourWorkspaceAuth.test.ts src/shared/config/gatewayUrls.test.ts src/shared/config/authBridgeUrls.test.ts src/shared/config/gatewayFallback.test.ts scripts/__tests__ src/shared/config/products.test.ts src/shared/config/productSlug.test.ts src/shared/hooks/shell/useProducts.test.ts src/shared/providers/shell/brandAttribute.test.ts src/chrome/ProductSwitcher.test.ts src/shared/utils/gatewayFetchRewrite.test.ts src/shared/utils/authCookie.test.ts src/shared/providers/AppShellProvider.test.ts src/shared/providers/shell/interpolate.test.ts src/shared/providers/shell/resolveTranslation.test.ts src/shared/providers/shell/I18nProvider.render.test.tsx src/shared/providers/shell/I18nProvider.client.test.tsx src/shared/providers/shell/translationStore.test.ts src/shared/providers/shell/translationLayers.test.ts src/shared/providers/shell/directionMode.test.ts src/shared/providers/shell/authProvider/ssoRelay.test.ts src/shared/providers/shell/personaSurfaceRemote.test.ts src/shared/providers/shell/workspaceSwitch.client.test.tsx src/shared/events/sinks/RybbitSink.test.ts src/shell-native src/shared/native src/shared/navigation src/shared/tours src/chrome/__tests__ src/ui/__tests__",
318
318
  "sanity": "bash scripts/build-limits.sh --gate bash -c 'bun run lint:sanity && bun run format && bun run type:check && bun run test && bun run build && bun run verify:package'",
319
319
  "switch:status": "bun scripts/deps-mode.ts status",
320
320
  "switch:remote": "bun scripts/deps-mode.ts remote",