@timardex/cluemart-shared 1.7.0 → 1.7.2
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/ad-BUYzE6zx.d.ts +181 -0
- package/dist/ad-BhLoEul3.d.mts +181 -0
- package/dist/affiliate-BbtjeUP4.d.mts +73 -0
- package/dist/affiliate-C51nzKsw.d.ts +73 -0
- package/dist/apollo/index.cjs +1383 -0
- package/dist/apollo/index.cjs.map +1 -0
- package/dist/apollo/index.d.mts +323 -0
- package/dist/apollo/index.d.ts +323 -0
- package/dist/apollo/index.mjs +1295 -0
- package/dist/apollo/index.mjs.map +1 -0
- package/dist/auth/index.cjs +1727 -0
- package/dist/auth/index.cjs.map +1 -0
- package/dist/auth/index.d.mts +166 -0
- package/dist/auth/index.d.ts +166 -0
- package/dist/auth/index.mjs +380 -0
- package/dist/auth/index.mjs.map +1 -0
- package/dist/chunk-32MKHJTX.mjs +1207 -0
- package/dist/chunk-32MKHJTX.mjs.map +1 -0
- package/dist/{chunk-HZMP7GXC.mjs → chunk-447EYKHL.mjs} +1010 -2671
- package/dist/chunk-447EYKHL.mjs.map +1 -0
- package/dist/{chunk-RKIRWZCH.mjs → chunk-AYO3E4DM.mjs} +39 -183
- package/dist/chunk-AYO3E4DM.mjs.map +1 -0
- package/dist/{chunk-ZZJSCYJK.mjs → chunk-BIJ5NDXW.mjs} +46 -42
- package/dist/chunk-BIJ5NDXW.mjs.map +1 -0
- package/dist/chunk-DQ7ZHIXW.mjs +26 -0
- package/dist/chunk-DQ7ZHIXW.mjs.map +1 -0
- package/dist/{chunk-MVQ3CFQR.mjs → chunk-ILILH7E2.mjs} +12 -23
- package/dist/chunk-ILILH7E2.mjs.map +1 -0
- package/dist/{chunk-TAECMXM4.mjs → chunk-LBEJECG3.mjs} +249 -219
- package/dist/{chunk-TAECMXM4.mjs.map → chunk-LBEJECG3.mjs.map} +1 -1
- package/dist/chunk-RAYUJODN.mjs +45 -0
- package/dist/chunk-RAYUJODN.mjs.map +1 -0
- package/dist/chunk-SD42WIMV.mjs +297 -0
- package/dist/chunk-SD42WIMV.mjs.map +1 -0
- package/dist/chunk-VPANTTZI.mjs +262 -0
- package/dist/chunk-VPANTTZI.mjs.map +1 -0
- package/dist/{chunk-KZTOISPA.mjs → chunk-X3OLM35T.mjs} +14 -8
- package/dist/chunk-X3OLM35T.mjs.map +1 -0
- package/dist/{contactUs-H7799pWe.d.ts → contactUs--NoohZBu.d.ts} +1 -1
- package/dist/{contactUs-DGrDzJaM.d.mts → contactUs-CBWzefUS.d.mts} +1 -1
- package/dist/enums/index.cjs +13 -7
- package/dist/enums/index.cjs.map +1 -1
- package/dist/enums/index.d.mts +15 -9
- package/dist/enums/index.d.ts +15 -9
- package/dist/enums/index.mjs +1 -1
- package/dist/formFields/index.cjs +136 -73
- package/dist/formFields/index.cjs.map +1 -1
- package/dist/formFields/index.d.mts +3 -2
- package/dist/formFields/index.d.ts +3 -2
- package/dist/formFields/index.mjs +9 -4
- package/dist/{global-fKbMmluy.d.ts → global-CUYYxpy2.d.ts} +12 -11
- package/dist/{global-BUUfmCo7.d.mts → global-DePDtOFt.d.mts} +12 -11
- package/dist/graphql/index.cjs +734 -1271
- package/dist/graphql/index.cjs.map +1 -1
- package/dist/graphql/index.d.mts +434 -176
- package/dist/graphql/index.d.ts +434 -176
- package/dist/graphql/index.mjs +37 -23
- package/dist/hooks/index.cjs +947 -309
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.mts +10 -4
- package/dist/hooks/index.d.ts +10 -4
- package/dist/hooks/index.mjs +170 -58
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/images/apple-maps-icon.webp.d.ts +8 -1
- package/dist/images/banner-horizontal.webp.d.ts +8 -1
- package/dist/images/banner-vertical.webp.d.ts +8 -1
- package/dist/images/cluiTui.webp.d.ts +8 -1
- package/dist/images/corporate.webp.d.ts +8 -1
- package/dist/images/facebook.webp.d.ts +8 -1
- package/dist/images/gazebo-top.webp.d.ts +8 -1
- package/dist/images/google-maps-icon.webp.d.ts +8 -1
- package/dist/images/googleMaps-logo-dark.webp.d.ts +8 -1
- package/dist/images/googleMaps-logo-light.webp.d.ts +8 -1
- package/dist/images/instagram.webp.d.ts +8 -1
- package/dist/images/logo-atr.webp.d.ts +8 -1
- package/dist/images/logo-dark.webp.d.ts +8 -1
- package/dist/images/logo.webp.d.ts +8 -1
- package/dist/images/meet.webp.d.ts +8 -1
- package/dist/images/mini-market1.webp.d.ts +8 -1
- package/dist/images/mini-market2.webp.d.ts +8 -1
- package/dist/images/mini-market3.webp.d.ts +8 -1
- package/dist/images/mini-market4.webp.d.ts +8 -1
- package/dist/images/mini-market5.webp.d.ts +8 -1
- package/dist/images/poll.webp.d.ts +8 -1
- package/dist/images/poster1.webp.d.ts +8 -1
- package/dist/images/poster2.webp.d.ts +8 -1
- package/dist/images/poster3.webp.d.ts +8 -1
- package/dist/images/poster4.webp.d.ts +8 -1
- package/dist/images/private.webp.d.ts +8 -1
- package/dist/images/qr-code.webp.d.ts +8 -1
- package/dist/images/school.webp.d.ts +8 -1
- package/dist/images/sima.webp.d.ts +8 -1
- package/dist/images/store-android.webp.d.ts +8 -1
- package/dist/images/store-ios.webp.d.ts +8 -1
- package/dist/images/tablas.webp.d.ts +8 -1
- package/dist/images/telefonos.webp.d.ts +8 -1
- package/dist/images/tiktok.webp.d.ts +8 -1
- package/dist/images/tip.webp.d.ts +8 -1
- package/dist/images/ugralos.webp.d.ts +8 -1
- package/dist/images/waze-maps-icon.webp.d.ts +8 -1
- package/dist/images/website.webp.d.ts +8 -1
- package/dist/images/youtube.webp.d.ts +8 -1
- package/dist/index.cjs +1751 -1781
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +665 -243
- package/dist/index.d.ts +665 -243
- package/dist/index.mjs +1711 -1779
- package/dist/index.mjs.map +1 -1
- package/dist/map/index.cjs +14 -9
- package/dist/map/index.cjs.map +1 -1
- package/dist/map/index.d.mts +16 -13
- package/dist/map/index.d.ts +16 -13
- package/dist/map/index.mjs +14 -9
- package/dist/map/index.mjs.map +1 -1
- package/dist/{resourceActivities-BL_12IAo.d.ts → resourceActivities-CMUcn2P7.d.ts} +9 -4
- package/dist/{resourceActivities-zczOntNk.d.mts → resourceActivities-CwbJFGIp.d.mts} +9 -4
- package/dist/sharing/index.cjs +39 -1252
- package/dist/sharing/index.cjs.map +1 -1
- package/dist/sharing/index.d.mts +17 -5
- package/dist/sharing/index.d.ts +17 -5
- package/dist/sharing/index.mjs +34 -30
- package/dist/subscription-BU8GvH2K.d.ts +12 -0
- package/dist/subscription-bmAdrnfi.d.mts +12 -0
- package/dist/types/index.cjs +15 -2
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.mts +10 -23
- package/dist/types/index.d.ts +10 -23
- package/dist/types/index.mjs +9 -5
- package/dist/user-D47MLFyH.d.ts +134 -0
- package/dist/user-DE8edl3u.d.mts +134 -0
- package/dist/utils/index.cjs +355 -136
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.mts +87 -35
- package/dist/utils/index.d.ts +87 -35
- package/dist/utils/index.mjs +42 -15
- package/package.json +31 -10
- package/dist/ad-CVkVX_z5.d.ts +0 -296
- package/dist/ad-DA9ECAhK.d.mts +0 -296
- package/dist/affiliate-1RtkLnLP.d.ts +0 -35
- package/dist/affiliate-Cos2Syz5.d.mts +0 -35
- package/dist/chunk-HZMP7GXC.mjs.map +0 -1
- package/dist/chunk-KZTOISPA.mjs.map +0 -1
- package/dist/chunk-MVQ3CFQR.mjs.map +0 -1
- package/dist/chunk-RKIRWZCH.mjs.map +0 -1
- package/dist/chunk-ZZJSCYJK.mjs.map +0 -1
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import * as _apollo_client from '@apollo/client';
|
|
2
|
+
import { ApolloLink } from '@apollo/client';
|
|
3
|
+
import { Client } from 'graphql-ws';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Optional auth-recovery telemetry for shared Apollo factories.
|
|
7
|
+
* Apps map this to Sentry breadcrumbs (mobile) or console (admin).
|
|
8
|
+
* Omitted adapter = no-op (zero behavior change).
|
|
9
|
+
*/
|
|
10
|
+
type AuthRecoveryEvent = {
|
|
11
|
+
type: "refresh_succeeded";
|
|
12
|
+
} | {
|
|
13
|
+
type: "refresh_failed";
|
|
14
|
+
reason: string;
|
|
15
|
+
errorCode?: string;
|
|
16
|
+
retryable?: boolean;
|
|
17
|
+
} | {
|
|
18
|
+
type: "stale_clear_skipped";
|
|
19
|
+
reason: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: "logout_scheduled";
|
|
22
|
+
reason: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: "reset_client";
|
|
25
|
+
};
|
|
26
|
+
type OnAuthRecoveryEvent = (event: AuthRecoveryEvent) => void;
|
|
27
|
+
|
|
28
|
+
type ApolloManager = {
|
|
29
|
+
resetClient: () => void;
|
|
30
|
+
setResetClient: (fn: (() => void) | null) => void;
|
|
31
|
+
};
|
|
32
|
+
type CreateApolloManagerAdapters = {
|
|
33
|
+
/** Optional recovery telemetry when resetClient runs (default: no-op). */
|
|
34
|
+
onAuthRecoveryEvent?: OnAuthRecoveryEvent;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Lets logout recreate the Apollo client without importing React hooks.
|
|
38
|
+
* Apps register a reset handler (mobile: useApolloRecovery).
|
|
39
|
+
*/
|
|
40
|
+
declare function createApolloManager(adapters?: CreateApolloManagerAdapters): ApolloManager;
|
|
41
|
+
|
|
42
|
+
type RefreshErrorCode = "UNAUTHENTICATED" | "TOKEN_EXPIRED" | "FORBIDDEN";
|
|
43
|
+
type RefreshAccessTokenResult = {
|
|
44
|
+
hadRefreshToken: boolean;
|
|
45
|
+
token: string | null;
|
|
46
|
+
/**
|
|
47
|
+
* True when refresh failed due to transient issues and callers should NOT
|
|
48
|
+
* log the user out yet.
|
|
49
|
+
*/
|
|
50
|
+
retryable?: boolean;
|
|
51
|
+
/** Set when refresh failed due to GraphQL errors. */
|
|
52
|
+
errorCode?: string;
|
|
53
|
+
};
|
|
54
|
+
type ApolloTokenStorage = {
|
|
55
|
+
getAccessToken: () => Promise<string | null>;
|
|
56
|
+
getRefreshToken: () => Promise<string | null>;
|
|
57
|
+
setTokens: (access: string, refresh: string) => Promise<void>;
|
|
58
|
+
clearTokens: () => Promise<void>;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Optional cross-realm refresh serialization (e.g. admin multi-tab via Web Locks).
|
|
62
|
+
* When omitted, behavior is single-realm coalescing only (mobile).
|
|
63
|
+
*/
|
|
64
|
+
type RefreshCoordination = {
|
|
65
|
+
withLock: <T>(fn: () => Promise<T>) => Promise<T>;
|
|
66
|
+
};
|
|
67
|
+
type CreateRefreshAccessTokenAdapters = {
|
|
68
|
+
apiUrl: string;
|
|
69
|
+
storage: ApolloTokenStorage;
|
|
70
|
+
/** Called after tokens are persisted (mobile: tokenManager + wsManager). */
|
|
71
|
+
onTokensUpdated?: (accessToken: string) => void;
|
|
72
|
+
/** Called after tokens are cleared (mobile: tokenManager.clear + wsManager.close). */
|
|
73
|
+
onTokensCleared?: (reason: string) => void;
|
|
74
|
+
onError?: (error: unknown, meta: {
|
|
75
|
+
action: string;
|
|
76
|
+
[key: string]: unknown;
|
|
77
|
+
}) => void;
|
|
78
|
+
/** Optional debug logging (mobile may gate with __DEV__). */
|
|
79
|
+
onDebug?: (message: string, meta?: Record<string, unknown>) => void;
|
|
80
|
+
/**
|
|
81
|
+
* Optional multi-tab / cross-context lock. Mobile should omit this.
|
|
82
|
+
* Admin may supply Web Locks (`navigator.locks`).
|
|
83
|
+
*/
|
|
84
|
+
refreshCoordination?: RefreshCoordination;
|
|
85
|
+
/** Optional recovery telemetry (default: no-op). */
|
|
86
|
+
onAuthRecoveryEvent?: OnAuthRecoveryEvent;
|
|
87
|
+
};
|
|
88
|
+
type CreateAuthLinkAdapters = {
|
|
89
|
+
/** Wait until tokens are loaded (mobile tokenManager.awaitReady). */
|
|
90
|
+
awaitReady?: () => Promise<void>;
|
|
91
|
+
getAccessToken: () => string | null | Promise<string | null>;
|
|
92
|
+
onError?: (error: unknown, meta: {
|
|
93
|
+
action: string;
|
|
94
|
+
}) => void;
|
|
95
|
+
onDebug?: (message: string, meta?: Record<string, unknown>) => void;
|
|
96
|
+
};
|
|
97
|
+
type CreateErrorLinkAdapters = {
|
|
98
|
+
refreshAccessToken: () => Promise<RefreshAccessTokenResult>;
|
|
99
|
+
/** Clear in-memory access token before logout (mobile tokenManager.clear). */
|
|
100
|
+
clearAccessToken?: (reason: string) => void;
|
|
101
|
+
logout: () => Promise<void>;
|
|
102
|
+
onError?: (error: unknown, meta: {
|
|
103
|
+
action: string;
|
|
104
|
+
}) => void;
|
|
105
|
+
onDebug?: (message: string, meta?: Record<string, unknown>) => void;
|
|
106
|
+
/** Optional recovery telemetry (default: no-op). */
|
|
107
|
+
onAuthRecoveryEvent?: OnAuthRecoveryEvent;
|
|
108
|
+
};
|
|
109
|
+
type GraphQLErrorLike = {
|
|
110
|
+
extensions?: {
|
|
111
|
+
code?: string;
|
|
112
|
+
retryable?: unknown;
|
|
113
|
+
[key: string]: unknown;
|
|
114
|
+
};
|
|
115
|
+
locations?: ReadonlyArray<{
|
|
116
|
+
line: number;
|
|
117
|
+
column: number;
|
|
118
|
+
}>;
|
|
119
|
+
message?: string;
|
|
120
|
+
path?: ReadonlyArray<string | number>;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Auth link that attaches Bearer token after optional awaitReady.
|
|
125
|
+
* Does not overwrite an Authorization header already set on the operation.
|
|
126
|
+
*/
|
|
127
|
+
declare function createAuthLink(adapters: CreateAuthLinkAdapters): ApolloLink;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Error link with mobile auth recovery: refresh once, retry op, or deferred logout.
|
|
131
|
+
*/
|
|
132
|
+
declare function createErrorLink(adapters: CreateErrorLinkAdapters): _apollo_client.ApolloLink;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Creates a coalesced refreshAccessToken() using mobile multi-attempt behavior.
|
|
136
|
+
* Storage and token/WS side effects are injected via adapters.
|
|
137
|
+
*
|
|
138
|
+
* Optional `refreshCoordination` serializes refresh across realms (admin tabs).
|
|
139
|
+
* Before clearing credentials on terminal failure, skips wipe if storage already
|
|
140
|
+
* holds a newer access token (another actor recovered).
|
|
141
|
+
*/
|
|
142
|
+
declare function createRefreshAccessToken(adapters: CreateRefreshAccessTokenAdapters): () => Promise<RefreshAccessTokenResult>;
|
|
143
|
+
|
|
144
|
+
type ApolloErrorLogLevel = "debug" | "info" | "warn" | "error";
|
|
145
|
+
type CreateApolloErrorLoggingLinkAdapters = {
|
|
146
|
+
/** When true, variables/extensions are redacted but still included. */
|
|
147
|
+
isDev: boolean | (() => boolean);
|
|
148
|
+
onLog: (level: ApolloErrorLogLevel, scope: string, message: string, details?: Record<string, unknown>) => void;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Logging-only Apollo `onError` link with secret redaction.
|
|
152
|
+
* Does not retry or forward — place before auth recovery links.
|
|
153
|
+
*/
|
|
154
|
+
declare function createApolloErrorLoggingLink(adapters: CreateApolloErrorLoggingLinkAdapters): _apollo_client.ApolloLink;
|
|
155
|
+
|
|
156
|
+
type CreateNetworkRecoveryLinkAdapters = {
|
|
157
|
+
forceRefreshIsOnline: () => Promise<boolean> | boolean;
|
|
158
|
+
subscribeIsOnline: (listener: (online: boolean) => void) => () => void;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Apollo link that pauses and retries **queries** after transient network failures.
|
|
162
|
+
* Mutations and subscriptions pass through unchanged.
|
|
163
|
+
*/
|
|
164
|
+
declare function createNetworkRecoveryLink(adapters: CreateNetworkRecoveryLinkAdapters): ApolloLink;
|
|
165
|
+
|
|
166
|
+
type NetworkLogLevel = "debug" | "info" | "warn" | "error";
|
|
167
|
+
type CreateNetworkLogAdapters = {
|
|
168
|
+
enabled: boolean | (() => boolean);
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Structured network/auth/WS console logger (mobile format: prefix + JSON payload).
|
|
172
|
+
*/
|
|
173
|
+
declare function createNetworkLog(adapters: CreateNetworkLogAdapters): (level: NetworkLogLevel, scope: string, message: string, details?: Record<string, unknown>) => void;
|
|
174
|
+
|
|
175
|
+
type CreateWsManagerAdapters = {
|
|
176
|
+
getWsUrl: () => string;
|
|
177
|
+
awaitReady: () => Promise<void>;
|
|
178
|
+
getAccessToken: () => string | null;
|
|
179
|
+
isActive: () => boolean;
|
|
180
|
+
/** Subscribe to inactive/active transitions; return unsubscribe. */
|
|
181
|
+
subscribeLifecycle: (handlers: {
|
|
182
|
+
onInactive: () => void;
|
|
183
|
+
onActive: () => void;
|
|
184
|
+
}) => () => void;
|
|
185
|
+
onLog?: (level: NetworkLogLevel, scope: string, message: string, details?: Record<string, unknown>) => void;
|
|
186
|
+
isDev?: boolean | (() => boolean);
|
|
187
|
+
};
|
|
188
|
+
type WsManager = {
|
|
189
|
+
initLifecycleListener: () => void;
|
|
190
|
+
getClient: () => Client;
|
|
191
|
+
ensureConnected: (reason: string) => void;
|
|
192
|
+
onAuthTokenChanged: (reason: string) => void;
|
|
193
|
+
close: (reason: string) => void;
|
|
194
|
+
dispose: () => void;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Platform-agnostic graphql-ws client manager (mobile-shaped).
|
|
198
|
+
* Apps supply lifecycle (AppState / visibility), token access, and logging.
|
|
199
|
+
*/
|
|
200
|
+
declare function createWsManager(adapters: CreateWsManagerAdapters): WsManager;
|
|
201
|
+
|
|
202
|
+
type CreateRecoveryCoreAdapters = {
|
|
203
|
+
/** Refresh tokens / user; `true` = schedule active-query refetch. */
|
|
204
|
+
refreshSession: () => Promise<boolean>;
|
|
205
|
+
ensureWsConnected: (reason: string) => void;
|
|
206
|
+
disposeWs: () => void;
|
|
207
|
+
refetchActiveQueries: () => void;
|
|
208
|
+
/** Foreground / visible check (AppState active, document visible, …). */
|
|
209
|
+
isActive: () => boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Optional online check. When omitted, treated as online (current app behavior —
|
|
212
|
+
* query pause is handled by networkRecoveryLink).
|
|
213
|
+
*/
|
|
214
|
+
isOnline?: () => boolean;
|
|
215
|
+
/** Same shape as createWsManager lifecycle adapter. */
|
|
216
|
+
subscribeLifecycle: (handlers: {
|
|
217
|
+
onInactive: () => void;
|
|
218
|
+
onActive: () => void;
|
|
219
|
+
}) => () => void;
|
|
220
|
+
/** WS ensureConnected reason after a short background hop. */
|
|
221
|
+
shortBackgroundWsReason?: string;
|
|
222
|
+
/** WS ensureConnected reason after full recovery. */
|
|
223
|
+
recoverWsReason?: string;
|
|
224
|
+
now?: () => number;
|
|
225
|
+
schedule?: (fn: () => void, ms: number) => ReturnType<typeof setTimeout>;
|
|
226
|
+
cancelSchedule?: (id: ReturnType<typeof setTimeout>) => void;
|
|
227
|
+
};
|
|
228
|
+
type RecoveryCore = {
|
|
229
|
+
/** Subscribe to lifecycle; idempotent. */
|
|
230
|
+
start: () => void;
|
|
231
|
+
/** Unsubscribe + clear timers; does not dispose WS (hook cleanup does). */
|
|
232
|
+
stop: () => void;
|
|
233
|
+
/** Full recovery: refresh → WS → deferred refetch. */
|
|
234
|
+
recoverApollo: () => Promise<void>;
|
|
235
|
+
/**
|
|
236
|
+
* Call at the start of client reset/logout: bump generation, clear timers,
|
|
237
|
+
* drop recovering guard so in-flight recovery cannot touch the new client.
|
|
238
|
+
*/
|
|
239
|
+
prepareClientReset: () => void;
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Platform-agnostic Apollo idle recovery orchestration (mobile/admin parity).
|
|
243
|
+
*
|
|
244
|
+
* Apps supply lifecycle (AppState / visibility), session refresh, and WS/query
|
|
245
|
+
* side effects. React client ownership stays in each app's useApolloRecovery.
|
|
246
|
+
*/
|
|
247
|
+
declare function createRecoveryCore(adapters: CreateRecoveryCoreAdapters): RecoveryCore;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Idle / background thresholds for Apollo recovery after the app or tab
|
|
251
|
+
* returns to the foreground.
|
|
252
|
+
*
|
|
253
|
+
* These are **independent of the server access-token TTL** (currently 15
|
|
254
|
+
* minutes on the ClueMart auth service). Recovery is driven by how long the
|
|
255
|
+
* client was backgrounded/hidden, not by JWT `exp`.
|
|
256
|
+
*
|
|
257
|
+
* Any future proactive refresh-near-expiry logic is a separate mechanism and
|
|
258
|
+
* must not reuse these constants as a stand-in for token lifetime.
|
|
259
|
+
*/
|
|
260
|
+
declare const MIN_BACKGROUND_MS = 30000;
|
|
261
|
+
/**
|
|
262
|
+
* Delay after a successful long-background recovery before refetching active
|
|
263
|
+
* Apollo queries (gives networking a moment to stabilize, especially on iOS).
|
|
264
|
+
*
|
|
265
|
+
* Independent of the server's access-token TTL (see `MIN_BACKGROUND_MS`).
|
|
266
|
+
*/
|
|
267
|
+
declare const REFETCH_DELAY_MS = 500;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Reads AC3 ErrorResponse fields via property access instead of destructuring
|
|
271
|
+
* (`graphQLErrors`, `networkError`, `response`) to avoid Apollo Client warnings.
|
|
272
|
+
*/
|
|
273
|
+
declare function readErrorResponseFields(errorResponse: unknown): {
|
|
274
|
+
graphQLErrors: GraphQLErrorLike[] | undefined;
|
|
275
|
+
networkError: unknown;
|
|
276
|
+
response: unknown;
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
type Json = null | boolean | number | string | Json[] | {
|
|
280
|
+
[key: string]: Json;
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* JSON.stringify that tolerates circular refs, Errors, bigint, and functions.
|
|
284
|
+
* Always returns a string — top-level `undefined` / `symbol` become `"null"`
|
|
285
|
+
* (native `JSON.stringify` would return `undefined`).
|
|
286
|
+
*/
|
|
287
|
+
declare function safeJsonStringify(value: unknown): string;
|
|
288
|
+
/** Best-effort JSON-safe shape for logging network / GraphQL / WS errors. */
|
|
289
|
+
declare function toStructuredError(err: unknown): Json;
|
|
290
|
+
|
|
291
|
+
declare function getStatusCode(networkError: unknown): number | null;
|
|
292
|
+
declare function isUnauthenticatedGraphQLError(graphQLErrors?: ReadonlyArray<GraphQLErrorLike> | null): boolean;
|
|
293
|
+
/**
|
|
294
|
+
* True when GraphQL unauth signals and/or HTTP 401/403 indicate auth recovery is needed.
|
|
295
|
+
*/
|
|
296
|
+
declare function isUnauthenticatedError(input: {
|
|
297
|
+
graphQLErrors?: ReadonlyArray<GraphQLErrorLike> | null;
|
|
298
|
+
networkError?: unknown;
|
|
299
|
+
}): boolean;
|
|
300
|
+
declare const NON_RETRYABLE_REFRESH_AUTH_CODES: ReadonlySet<string>;
|
|
301
|
+
declare function isRefreshAuthFailureMessage(message: string | undefined): boolean;
|
|
302
|
+
declare function getRefreshErrorCode(errors: ReadonlyArray<GraphQLErrorLike>): string | undefined;
|
|
303
|
+
declare function isExpectedRefreshAuthFailure(errors: ReadonlyArray<GraphQLErrorLike>, errorCode: string | undefined): boolean;
|
|
304
|
+
/**
|
|
305
|
+
* Whether GraphQL `errors` from the refresh mutation warrant another HTTP attempt.
|
|
306
|
+
*/
|
|
307
|
+
declare function refreshGraphqlErrorsWarrantRetry(errors: ReadonlyArray<GraphQLErrorLike>): boolean;
|
|
308
|
+
type RefreshDecision = {
|
|
309
|
+
kind: "complete";
|
|
310
|
+
} | {
|
|
311
|
+
kind: "logout";
|
|
312
|
+
} | {
|
|
313
|
+
kind: "retry";
|
|
314
|
+
token: string;
|
|
315
|
+
};
|
|
316
|
+
/** Maps refresh outcome to error-link next step (mobile behavior). */
|
|
317
|
+
declare function decideRefreshNextStep(result: {
|
|
318
|
+
hadRefreshToken?: boolean;
|
|
319
|
+
token: string | null;
|
|
320
|
+
retryable?: boolean;
|
|
321
|
+
}): RefreshDecision;
|
|
322
|
+
|
|
323
|
+
export { type ApolloErrorLogLevel, type ApolloManager, type ApolloTokenStorage, type AuthRecoveryEvent, type CreateApolloErrorLoggingLinkAdapters, type CreateApolloManagerAdapters, type CreateAuthLinkAdapters, type CreateErrorLinkAdapters, type CreateNetworkLogAdapters, type CreateNetworkRecoveryLinkAdapters, type CreateRecoveryCoreAdapters, type CreateRefreshAccessTokenAdapters, type CreateWsManagerAdapters, type GraphQLErrorLike, MIN_BACKGROUND_MS, NON_RETRYABLE_REFRESH_AUTH_CODES, type NetworkLogLevel, type OnAuthRecoveryEvent, REFETCH_DELAY_MS, type RecoveryCore, type RefreshAccessTokenResult, type RefreshCoordination, type RefreshDecision, type RefreshErrorCode, type WsManager, createApolloErrorLoggingLink, createApolloManager, createAuthLink, createErrorLink, createNetworkLog, createNetworkRecoveryLink, createRecoveryCore, createRefreshAccessToken, createWsManager, decideRefreshNextStep, getRefreshErrorCode, getStatusCode, isExpectedRefreshAuthFailure, isRefreshAuthFailureMessage, isUnauthenticatedError, isUnauthenticatedGraphQLError, readErrorResponseFields, refreshGraphqlErrorsWarrantRetry, safeJsonStringify, toStructuredError };
|