@vrplatform/api 1.2.32 → 1.2.33-stage.663

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.2.32",
6
+ "version": "1.2.33-stage.663",
7
7
  "description": "",
8
8
  "main": "build/main/index.js",
9
9
  "module": "build/module/index.js",
@@ -38,23 +38,6 @@ export interface paths {
38
38
  patch?: never;
39
39
  trace?: never;
40
40
  };
41
- "/healthz": {
42
- parameters: {
43
- query?: never;
44
- header?: never;
45
- path?: never;
46
- cookie?: never;
47
- };
48
- /** @description HealthZ Endpoint */
49
- get: operations["healthz"];
50
- put?: never;
51
- post?: never;
52
- delete?: never;
53
- options?: never;
54
- head?: never;
55
- patch?: never;
56
- trace?: never;
57
- };
58
41
  "/legacy/payouts": {
59
42
  parameters: {
60
43
  query?: never;
@@ -2188,76 +2171,6 @@ export interface operations {
2188
2171
  };
2189
2172
  };
2190
2173
  };
2191
- healthz: {
2192
- parameters: {
2193
- query?: never;
2194
- header?: {
2195
- "X-Team-Id"?: string;
2196
- };
2197
- path?: never;
2198
- cookie?: never;
2199
- };
2200
- requestBody?: never;
2201
- responses: {
2202
- /** @description Successful response */
2203
- 200: {
2204
- headers: {
2205
- [name: string]: unknown;
2206
- };
2207
- content: {
2208
- "application/json": {
2209
- status: string;
2210
- metadata?: unknown;
2211
- };
2212
- };
2213
- };
2214
- /** @description Invalid input data */
2215
- 400: {
2216
- headers: {
2217
- [name: string]: unknown;
2218
- };
2219
- content: {
2220
- "application/json": components["schemas"]["error.BAD_REQUEST"];
2221
- };
2222
- };
2223
- /** @description Authorization not provided */
2224
- 401: {
2225
- headers: {
2226
- [name: string]: unknown;
2227
- };
2228
- content: {
2229
- "application/json": components["schemas"]["error.UNAUTHORIZED"];
2230
- };
2231
- };
2232
- /** @description Insufficient access */
2233
- 403: {
2234
- headers: {
2235
- [name: string]: unknown;
2236
- };
2237
- content: {
2238
- "application/json": components["schemas"]["error.FORBIDDEN"];
2239
- };
2240
- };
2241
- /** @description Not found */
2242
- 404: {
2243
- headers: {
2244
- [name: string]: unknown;
2245
- };
2246
- content: {
2247
- "application/json": components["schemas"]["error.NOT_FOUND"];
2248
- };
2249
- };
2250
- /** @description Internal server error */
2251
- 500: {
2252
- headers: {
2253
- [name: string]: unknown;
2254
- };
2255
- content: {
2256
- "application/json": components["schemas"]["error.INTERNAL_SERVER_ERROR"];
2257
- };
2258
- };
2259
- };
2260
- };
2261
2174
  getLegacyPayouts: {
2262
2175
  parameters: {
2263
2176
  query?: {
@@ -6217,7 +6130,7 @@ export interface operations {
6217
6130
  data: {
6218
6131
  /** Format: uuid */
6219
6132
  listingId: string;
6220
- /** @default 2025-09-26 */
6133
+ /** @default 2025-09-29 */
6221
6134
  startAt: string;
6222
6135
  endAt?: string | null;
6223
6136
  setListingInactive?: boolean | null;
@@ -6299,7 +6212,7 @@ export interface operations {
6299
6212
  "application/json": {
6300
6213
  /** Format: uuid */
6301
6214
  listingId: string;
6302
- /** @default 2025-09-26 */
6215
+ /** @default 2025-09-29 */
6303
6216
  startAt?: string;
6304
6217
  endAt?: string | null;
6305
6218
  members: {
@@ -6333,7 +6246,7 @@ export interface operations {
6333
6246
  "application/json": {
6334
6247
  /** Format: uuid */
6335
6248
  listingId: string;
6336
- /** @default 2025-09-26 */
6249
+ /** @default 2025-09-29 */
6337
6250
  startAt: string;
6338
6251
  endAt?: string | null;
6339
6252
  setListingInactive?: boolean | null;
@@ -6413,7 +6326,7 @@ export interface operations {
6413
6326
  "application/json": {
6414
6327
  /** Format: uuid */
6415
6328
  listingId: string;
6416
- /** @default 2025-09-26 */
6329
+ /** @default 2025-09-29 */
6417
6330
  startAt: string;
6418
6331
  endAt?: string | null;
6419
6332
  setListingInactive?: boolean | null;
@@ -6496,7 +6409,7 @@ export interface operations {
6496
6409
  "application/json": {
6497
6410
  /** Format: uuid */
6498
6411
  listingId?: string;
6499
- /** @default 2025-09-26 */
6412
+ /** @default 2025-09-29 */
6500
6413
  startAt?: string;
6501
6414
  endAt?: string | null;
6502
6415
  members?: {
@@ -6525,7 +6438,7 @@ export interface operations {
6525
6438
  "application/json": {
6526
6439
  /** Format: uuid */
6527
6440
  listingId: string;
6528
- /** @default 2025-09-26 */
6441
+ /** @default 2025-09-29 */
6529
6442
  startAt: string;
6530
6443
  endAt?: string | null;
6531
6444
  setListingInactive?: boolean | null;
@@ -6711,7 +6624,7 @@ export interface operations {
6711
6624
  /** Format: uuid */
6712
6625
  sourceId?: string | null;
6713
6626
  initialOwnership?: {
6714
- /** @default 2025-09-26 */
6627
+ /** @default 2025-09-29 */
6715
6628
  startAt?: string;
6716
6629
  endAt?: string | null;
6717
6630
  members: {
@@ -6769,7 +6682,7 @@ export interface operations {
6769
6682
  status: "active" | "inactive";
6770
6683
  defaultCurrency?: string | null;
6771
6684
  activeOwnership?: {
6772
- /** @default 2025-09-26 */
6685
+ /** @default 2025-09-29 */
6773
6686
  startAt: string;
6774
6687
  endAt?: string | null;
6775
6688
  setListingInactive?: boolean | null;
@@ -7001,7 +6914,7 @@ export interface operations {
7001
6914
  status: "active" | "inactive";
7002
6915
  defaultCurrency?: string | null;
7003
6916
  activeOwnership?: {
7004
- /** @default 2025-09-26 */
6917
+ /** @default 2025-09-29 */
7005
6918
  startAt: string;
7006
6919
  endAt?: string | null;
7007
6920
  setListingInactive?: boolean | null;
@@ -7131,7 +7044,7 @@ export interface operations {
7131
7044
  /** Format: uuid */
7132
7045
  sourceId?: string | null;
7133
7046
  initialOwnership?: {
7134
- /** @default 2025-09-26 */
7047
+ /** @default 2025-09-29 */
7135
7048
  startAt?: string;
7136
7049
  endAt?: string | null;
7137
7050
  members: {
@@ -7185,7 +7098,7 @@ export interface operations {
7185
7098
  status: "active" | "inactive";
7186
7099
  defaultCurrency?: string | null;
7187
7100
  activeOwnership?: {
7188
- /** @default 2025-09-26 */
7101
+ /** @default 2025-09-29 */
7189
7102
  startAt: string;
7190
7103
  endAt?: string | null;
7191
7104
  setListingInactive?: boolean | null;
@@ -7393,7 +7306,7 @@ export interface operations {
7393
7306
  status: "active" | "inactive";
7394
7307
  defaultCurrency?: string | null;
7395
7308
  activeOwnership?: {
7396
- /** @default 2025-09-26 */
7309
+ /** @default 2025-09-29 */
7397
7310
  startAt: string;
7398
7311
  endAt?: string | null;
7399
7312
  setListingInactive?: boolean | null;
@@ -7531,7 +7444,7 @@ export interface operations {
7531
7444
  /** Format: uuid */
7532
7445
  sourceId?: string | null;
7533
7446
  initialOwnership?: {
7534
- /** @default 2025-09-26 */
7447
+ /** @default 2025-09-29 */
7535
7448
  startAt?: string;
7536
7449
  endAt?: string | null;
7537
7450
  members: {
@@ -7585,7 +7498,7 @@ export interface operations {
7585
7498
  status: "active" | "inactive";
7586
7499
  defaultCurrency?: string | null;
7587
7500
  activeOwnership?: {
7588
- /** @default 2025-09-26 */
7501
+ /** @default 2025-09-29 */
7589
7502
  startAt: string;
7590
7503
  endAt?: string | null;
7591
7504
  setListingInactive?: boolean | null;
@@ -1,18 +0,0 @@
1
- import type { ClientOptions, HeadersOptions } from 'openapi-fetch';
2
- import type { CacheResult } from './cache';
3
- import type { ApiClientAuth } from './types';
4
- export declare function createQueryFetcher({
5
- attempts,
6
- auth,
7
- fetch: f,
8
- sessionId,
9
- headers: h,
10
- cache,
11
- }: {
12
- attempts?: number;
13
- auth?: ApiClientAuth | (() => ApiClientAuth);
14
- sessionId: string;
15
- fetch?: ClientOptions['fetch'];
16
- headers?: HeadersOptions | (() => HeadersOptions);
17
- cache: CacheResult<string, string>;
18
- }): (req: Request) => Promise<Response>;
@@ -1,68 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
- exports.createQueryFetcher = createQueryFetcher;
3
- const utils_1 = require('@finalytic/utils');
4
- const error_1 = require('./error');
5
- const headers_1 = require('./headers');
6
- const retryable_errors_1 = require('./retryable-errors');
7
- // Create query fetcher with retry logic
8
- function createQueryFetcher({
9
- attempts = 3,
10
- auth,
11
- fetch: f,
12
- sessionId,
13
- headers: h,
14
- cache,
15
- }) {
16
- return async (req) => {
17
- // Implement retry logic with exponential backoff
18
- let lastError = null;
19
- for (let attempt = 0; attempt < attempts; attempt++) {
20
- const isLastAttempt = attempt === attempts - 1;
21
- try {
22
- const dup = new Request(req);
23
- await (0, headers_1.injectHeaders)(dup.headers, {
24
- auth,
25
- headers: h,
26
- sessionId,
27
- cache,
28
- });
29
- const response = await (f || fetch)(dup);
30
- if (!isLastAttempt)
31
- (0, retryable_errors_1.assertRetryableResponse)(
32
- response.status,
33
- response.headers.has('Retry-After')
34
- ? Number(response.headers.get('Retry-After')) * 1000
35
- : undefined
36
- );
37
- return response;
38
- } catch (e) {
39
- const error = e instanceof Error ? e : new Error(String(e));
40
- lastError = error;
41
- // Only retry if this is a retryable error and we haven't exceeded max retries
42
- if (
43
- (0, retryable_errors_1.isRetryableError)(lastError) &&
44
- !isLastAttempt
45
- ) {
46
- // Exponential backoff: 2^retries * 100ms + some random jitter
47
- const backoff =
48
- typeof lastError.retryAfterMs === 'number'
49
- ? lastError.retryAfterMs
50
- : Math.min(100 * 2 ** attempt + Math.random() * 100, 10000);
51
- // Wait before the next retry
52
- await (0, utils_1.waitFor)(backoff);
53
- cache.invalidate();
54
- } else break;
55
- }
56
- }
57
- const e = lastError || new Error('Max retries exceeded');
58
- const error = new error_1.ApiClientError({
59
- code: 'FETCH_ERROR',
60
- message: e.message,
61
- context: e,
62
- issues: [],
63
- });
64
- error.stack = e.stack;
65
- throw error;
66
- };
67
- }
68
- //# sourceMappingURL=fetcher.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetcher.js","sourceRoot":"src/","sources":["fetcher.ts"],"names":[],"mappings":";;AAaA,gDAkEC;AA/ED,4CAA2C;AAG3C,mCAAyC;AACzC,uCAA0C;AAC1C,yDAI4B;AAG5B,wCAAwC;AACxC,SAAgB,kBAAkB,CAAC,EACjC,QAAQ,GAAG,CAAC,EACZ,IAAI,EACJ,KAAK,EAAE,CAAC,EACR,SAAS,EACT,OAAO,EAAE,CAAC,EACV,KAAK,GAQN;IACC,OAAO,KAAK,EAAE,GAAY,EAAE,EAAE;QAC5B,iDAAiD;QACjD,IAAI,SAAS,GAAiB,IAAI,CAAC;QAEnC,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC;YACpD,MAAM,aAAa,GAAG,OAAO,KAAK,QAAQ,GAAG,CAAC,CAAC;YAC/C,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;gBAC7B,MAAM,IAAA,uBAAa,EAAC,GAAG,CAAC,OAAO,EAAE;oBAC/B,IAAI;oBACJ,OAAO,EAAE,CAAC;oBACV,SAAS;oBACT,KAAK;iBACN,CAAC,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;gBACzC,IAAI,CAAC,aAAa;oBAChB,IAAA,0CAAuB,EACrB,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;wBACjC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,GAAG,IAAI;wBACpD,CAAC,CAAC,SAAS,CACd,CAAC;gBACJ,OAAO,QAAQ,CAAC;YAClB,CAAC;YAAC,OAAO,CAAM,EAAE,CAAC;gBAChB,MAAM,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC5D,SAAS,GAAG,KAAK,CAAC;gBAElB,8EAA8E;gBAC9E,IAAI,IAAA,mCAAgB,EAAC,SAAS,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;oBAClD,8DAA8D;oBAC9D,MAAM,OAAO,GACX,OAAQ,SAA4B,CAAC,YAAY,KAAK,QAAQ;wBAC5D,CAAC,CAAE,SAA4B,CAAC,YAAa;wBAC7C,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,IAAI,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC;oBAEhE,6BAA6B;oBAC7B,MAAM,IAAA,eAAO,EAAC,OAAO,CAAC,CAAC;oBACvB,KAAK,CAAC,UAAU,EAAE,CAAC;gBACrB,CAAC;;oBAAM,MAAM;YACf,CAAC;QACH,CAAC;QACD,MAAM,CAAC,GAAG,SAAS,IAAI,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACzD,MAAM,KAAK,GAAG,IAAI,sBAAc,CAAC;YAC/B,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,OAAO,EAAE,CAAC;YACV,MAAM,EAAE,EAAE;SACX,CAAC,CAAC;QACH,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;QACtB,MAAM,KAAK,CAAC;IACd,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { waitFor } from '@finalytic/utils';\nimport type { ClientOptions, HeadersOptions } from 'openapi-fetch';\nimport type { CacheResult } from './cache';\nimport { ApiClientError } from './error';\nimport { injectHeaders } from './headers';\nimport {\n type RetryableError,\n assertRetryableResponse,\n isRetryableError,\n} from './retryable-errors';\nimport type { ApiClientAuth } from './types';\n\n// Create query fetcher with retry logic\nexport function createQueryFetcher({\n attempts = 3,\n auth,\n fetch: f,\n sessionId,\n headers: h,\n cache,\n}: {\n attempts?: number;\n auth?: ApiClientAuth | (() => ApiClientAuth);\n sessionId: string;\n fetch?: ClientOptions['fetch'];\n headers?: HeadersOptions | (() => HeadersOptions);\n cache: CacheResult<string, string>;\n}) {\n return async (req: Request) => {\n // Implement retry logic with exponential backoff\n let lastError: Error | null = null;\n\n for (let attempt = 0; attempt < attempts; attempt++) {\n const isLastAttempt = attempt === attempts - 1;\n try {\n const dup = new Request(req);\n await injectHeaders(dup.headers, {\n auth,\n headers: h,\n sessionId,\n cache,\n });\n const response = await (f || fetch)(dup);\n if (!isLastAttempt)\n assertRetryableResponse(\n response.status,\n response.headers.has('Retry-After')\n ? Number(response.headers.get('Retry-After')) * 1000\n : undefined\n );\n return response;\n } catch (e: any) {\n const error = e instanceof Error ? e : new Error(String(e));\n lastError = error;\n\n // Only retry if this is a retryable error and we haven't exceeded max retries\n if (isRetryableError(lastError) && !isLastAttempt) {\n // Exponential backoff: 2^retries * 100ms + some random jitter\n const backoff =\n typeof (lastError as RetryableError).retryAfterMs === 'number'\n ? (lastError as RetryableError).retryAfterMs!\n : Math.min(100 * 2 ** attempt + Math.random() * 100, 10000);\n\n // Wait before the next retry\n await waitFor(backoff);\n cache.invalidate();\n } else break;\n }\n }\n const e = lastError || new Error('Max retries exceeded');\n const error = new ApiClientError({\n code: 'FETCH_ERROR',\n message: e.message,\n context: e,\n issues: [],\n });\n error.stack = e.stack;\n throw error;\n };\n}\n"]}
@@ -1,18 +0,0 @@
1
- import type { HeadersOptions } from 'openapi-fetch';
2
- import type { CacheResult } from './cache';
3
- import type { ApiClientAuth } from './types';
4
- export type HeaderInject = ReturnType<typeof injectHeaders>;
5
- export declare function injectHeaders(
6
- head: Headers,
7
- {
8
- auth,
9
- headers,
10
- sessionId,
11
- cache,
12
- }: {
13
- auth?: ApiClientAuth | (() => ApiClientAuth);
14
- headers?: HeadersOptions | (() => HeadersOptions);
15
- sessionId: string;
16
- cache: CacheResult<string, string>;
17
- }
18
- ): Promise<void>;
@@ -1,25 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
- exports.injectHeaders = injectHeaders;
3
- async function injectHeaders(head, { auth, headers, sessionId, cache }) {
4
- const temporary = new Headers(
5
- typeof headers === 'function' ? headers() : headers
6
- );
7
- const a = (typeof auth === 'function' ? auth() : auth) || {};
8
- if (sessionId) temporary.set('X-Session-Id', sessionId);
9
- if (a.sec) temporary.set('X-Api-Key', `Sec ${await cache.current(a.sec)}`);
10
- if (a.apiKey) temporary.set('X-Api-Key', a.apiKey);
11
- if (a.tenantId) temporary.set('X-Team-Id', a.tenantId);
12
- if (a.accessToken)
13
- temporary.set(
14
- 'Authorization',
15
- a.accessToken.startsWith('Bearer ')
16
- ? a.accessToken
17
- : `Bearer ${a.accessToken}`
18
- );
19
- temporary.forEach((value, key) => {
20
- if (!head.has(key)) {
21
- head.set(key, value);
22
- }
23
- });
24
- }
25
- //# sourceMappingURL=headers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"headers.js","sourceRoot":"src/","sources":["headers.ts"],"names":[],"mappings":";;AAKA,sCAkCC;AAlCM,KAAK,UAAU,aAAa,CACjC,IAAa,EACb,EACE,IAAI,EACJ,OAAO,EACP,SAAS,EACT,KAAK,GAMN;IAED,MAAM,SAAS,GAAG,IAAI,OAAO,CAC3B,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAE,OAAe,CAC7D,CAAC;IACF,MAAM,CAAC,GAAG,CAAC,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAC7D,IAAI,SAAS;QAAE,SAAS,CAAC,GAAG,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;IACxD,IAAI,CAAC,CAAC,GAAG;QAAE,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC3E,IAAI,CAAC,CAAC,MAAM;QAAE,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IACnD,IAAI,CAAC,CAAC,QAAQ;QAAE,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;IACvD,IAAI,CAAC,CAAC,WAAW;QACf,SAAS,CAAC,GAAG,CACX,eAAe,EACf,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC;YACjC,CAAC,CAAC,CAAC,CAAC,WAAW;YACf,CAAC,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAC9B,CAAC;IACJ,SAAS,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC/B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACnB,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { HeadersOptions } from 'openapi-fetch';\nimport type { CacheResult } from './cache';\nimport type { ApiClientAuth } from './types';\n\nexport type HeaderInject = ReturnType<typeof injectHeaders>;\nexport async function injectHeaders(\n head: Headers,\n {\n auth,\n headers,\n sessionId,\n cache,\n }: {\n auth?: ApiClientAuth | (() => ApiClientAuth);\n headers?: HeadersOptions | (() => HeadersOptions);\n sessionId: string;\n cache: CacheResult<string, string>;\n }\n) {\n const temporary = new Headers(\n typeof headers === 'function' ? headers() : (headers as any)\n );\n const a = (typeof auth === 'function' ? auth() : auth) || {};\n if (sessionId) temporary.set('X-Session-Id', sessionId);\n if (a.sec) temporary.set('X-Api-Key', `Sec ${await cache.current(a.sec)}`);\n if (a.apiKey) temporary.set('X-Api-Key', a.apiKey);\n if (a.tenantId) temporary.set('X-Team-Id', a.tenantId);\n if (a.accessToken)\n temporary.set(\n 'Authorization',\n a.accessToken.startsWith('Bearer ')\n ? a.accessToken\n : `Bearer ${a.accessToken}`\n );\n temporary.forEach((value, key) => {\n if (!head.has(key)) {\n head.set(key, value);\n }\n });\n}\n"]}
@@ -1,9 +0,0 @@
1
- export declare function isRetryableError(error: Error): boolean;
2
- export declare class RetryableError extends Error {
3
- readonly retryAfterMs?: number | undefined;
4
- constructor(message: string, retryAfterMs?: number | undefined);
5
- }
6
- export declare function assertRetryableResponse(
7
- status: number,
8
- retryAfterMs?: number
9
- ): void;
@@ -1,38 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
- exports.RetryableError = void 0;
3
- exports.isRetryableError = isRetryableError;
4
- exports.assertRetryableResponse = assertRetryableResponse;
5
- // Add helper to check if an error is retryable
6
- function isRetryableError(error) {
7
- // Network errors, connection timeouts, and other temporary issues
8
- if (error instanceof RetryableError) return true;
9
- const lowerCaseMessage = error.message?.toLowerCase() || '';
10
- return (
11
- lowerCaseMessage.includes('network connection lost') ||
12
- lowerCaseMessage.includes('failed to fetch') ||
13
- lowerCaseMessage.includes('network request failed') ||
14
- lowerCaseMessage.includes('timeout') ||
15
- lowerCaseMessage.includes('fetch failed') ||
16
- lowerCaseMessage.includes('econnrefused') ||
17
- lowerCaseMessage.includes('econnreset')
18
- );
19
- }
20
- class RetryableError extends Error {
21
- constructor(message, retryAfterMs) {
22
- super(message);
23
- this.retryAfterMs = retryAfterMs;
24
- }
25
- }
26
- exports.RetryableError = RetryableError;
27
- // Status codes that should trigger a retry
28
- const RETRYABLE_STATUS_CODES = new Set([408, 429, 500, 502, 503, 504, 520]);
29
- function assertRetryableResponse(status, retryAfterMs) {
30
- if (RETRYABLE_STATUS_CODES.has(status) || typeof retryAfterMs === 'number') {
31
- // Throw an error that will be caught by the catch block below
32
- throw new RetryableError(
33
- `Retryable HTTP status code: ${status}`,
34
- retryAfterMs
35
- );
36
- }
37
- }
38
- //# sourceMappingURL=retryable-errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"retryable-errors.js","sourceRoot":"src/","sources":["retryable-errors.ts"],"names":[],"mappings":";;;AACA,4CAaC;AAaD,0DAQC;AAnCD,+CAA+C;AAC/C,SAAgB,gBAAgB,CAAC,KAAY;IAC3C,kEAAkE;IAClE,IAAI,KAAK,YAAY,cAAc;QAAE,OAAO,IAAI,CAAC;IACjD,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IAC5D,OAAO,CACL,gBAAgB,CAAC,QAAQ,CAAC,yBAAyB,CAAC;QACpD,gBAAgB,CAAC,QAAQ,CAAC,iBAAiB,CAAC;QAC5C,gBAAgB,CAAC,QAAQ,CAAC,wBAAwB,CAAC;QACnD,gBAAgB,CAAC,QAAQ,CAAC,SAAS,CAAC;QACpC,gBAAgB,CAAC,QAAQ,CAAC,cAAc,CAAC;QACzC,gBAAgB,CAAC,QAAQ,CAAC,cAAc,CAAC;QACzC,gBAAgB,CAAC,QAAQ,CAAC,YAAY,CAAC,CACxC,CAAC;AACJ,CAAC;AACD,MAAa,cAAe,SAAQ,KAAK;IACvC,YACE,OAAe,EACC,YAAqB;QAErC,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,iBAAY,GAAZ,YAAY,CAAS;IAGvC,CAAC;CACF;AAPD,wCAOC;AAED,2CAA2C;AAC3C,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAE5E,SAAgB,uBAAuB,CAAC,MAAc,EAAE,YAAqB;IAC3E,IAAI,sBAAsB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;QAC3E,8DAA8D;QAC9D,MAAM,IAAI,cAAc,CACtB,+BAA+B,MAAM,EAAE,EACvC,YAAY,CACb,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["// Add helper to check if an error is retryable\nexport function isRetryableError(error: Error): boolean {\n // Network errors, connection timeouts, and other temporary issues\n if (error instanceof RetryableError) return true;\n const lowerCaseMessage = error.message?.toLowerCase() || '';\n return (\n lowerCaseMessage.includes('network connection lost') ||\n lowerCaseMessage.includes('failed to fetch') ||\n lowerCaseMessage.includes('network request failed') ||\n lowerCaseMessage.includes('timeout') ||\n lowerCaseMessage.includes('fetch failed') ||\n lowerCaseMessage.includes('econnrefused') ||\n lowerCaseMessage.includes('econnreset')\n );\n}\nexport class RetryableError extends Error {\n constructor(\n message: string,\n public readonly retryAfterMs?: number\n ) {\n super(message);\n }\n}\n\n// Status codes that should trigger a retry\nconst RETRYABLE_STATUS_CODES = new Set([408, 429, 500, 502, 503, 504, 520]);\n\nexport function assertRetryableResponse(status: number, retryAfterMs?: number) {\n if (RETRYABLE_STATUS_CODES.has(status) || typeof retryAfterMs === 'number') {\n // Throw an error that will be caught by the catch block below\n throw new RetryableError(\n `Retryable HTTP status code: ${status}`,\n retryAfterMs\n );\n }\n}\n"]}
@@ -1,18 +0,0 @@
1
- import type { ClientOptions, HeadersOptions } from 'openapi-fetch';
2
- import type { CacheResult } from './cache';
3
- import type { ApiClientAuth } from './types';
4
- export declare function createQueryFetcher({
5
- attempts,
6
- auth,
7
- fetch: f,
8
- sessionId,
9
- headers: h,
10
- cache,
11
- }: {
12
- attempts?: number;
13
- auth?: ApiClientAuth | (() => ApiClientAuth);
14
- sessionId: string;
15
- fetch?: ClientOptions['fetch'];
16
- headers?: HeadersOptions | (() => HeadersOptions);
17
- cache: CacheResult<string, string>;
18
- }): (req: Request) => Promise<Response>;
@@ -1,63 +0,0 @@
1
- import { waitFor } from '@finalytic/utils';
2
- import { ApiClientError } from './error';
3
- import { injectHeaders } from './headers';
4
- import { assertRetryableResponse, isRetryableError } from './retryable-errors';
5
- // Create query fetcher with retry logic
6
- export function createQueryFetcher({
7
- attempts = 3,
8
- auth,
9
- fetch: f,
10
- sessionId,
11
- headers: h,
12
- cache,
13
- }) {
14
- return async (req) => {
15
- // Implement retry logic with exponential backoff
16
- let lastError = null;
17
- for (let attempt = 0; attempt < attempts; attempt++) {
18
- const isLastAttempt = attempt === attempts - 1;
19
- try {
20
- const dup = new Request(req);
21
- await injectHeaders(dup.headers, {
22
- auth,
23
- headers: h,
24
- sessionId,
25
- cache,
26
- });
27
- const response = await (f || fetch)(dup);
28
- if (!isLastAttempt)
29
- assertRetryableResponse(
30
- response.status,
31
- response.headers.has('Retry-After')
32
- ? Number(response.headers.get('Retry-After')) * 1000
33
- : undefined
34
- );
35
- return response;
36
- } catch (e) {
37
- const error = e instanceof Error ? e : new Error(String(e));
38
- lastError = error;
39
- // Only retry if this is a retryable error and we haven't exceeded max retries
40
- if (isRetryableError(lastError) && !isLastAttempt) {
41
- // Exponential backoff: 2^retries * 100ms + some random jitter
42
- const backoff =
43
- typeof lastError.retryAfterMs === 'number'
44
- ? lastError.retryAfterMs
45
- : Math.min(100 * 2 ** attempt + Math.random() * 100, 10000);
46
- // Wait before the next retry
47
- await waitFor(backoff);
48
- cache.invalidate();
49
- } else break;
50
- }
51
- }
52
- const e = lastError || new Error('Max retries exceeded');
53
- const error = new ApiClientError({
54
- code: 'FETCH_ERROR',
55
- message: e.message,
56
- context: e,
57
- issues: [],
58
- });
59
- error.stack = e.stack;
60
- throw error;
61
- };
62
- }
63
- //# sourceMappingURL=fetcher.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetcher.js","sourceRoot":"src/","sources":["fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAG3C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAEL,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAG5B,wCAAwC;AACxC,MAAM,UAAU,kBAAkB,CAAC,EACjC,QAAQ,GAAG,CAAC,EACZ,IAAI,EACJ,KAAK,EAAE,CAAC,EACR,SAAS,EACT,OAAO,EAAE,CAAC,EACV,KAAK,GAQN;IACC,OAAO,KAAK,EAAE,GAAY,EAAE,EAAE;QAC5B,iDAAiD;QACjD,IAAI,SAAS,GAAiB,IAAI,CAAC;QAEnC,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC;YACpD,MAAM,aAAa,GAAG,OAAO,KAAK,QAAQ,GAAG,CAAC,CAAC;YAC/C,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;gBAC7B,MAAM,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE;oBAC/B,IAAI;oBACJ,OAAO,EAAE,CAAC;oBACV,SAAS;oBACT,KAAK;iBACN,CAAC,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;gBACzC,IAAI,CAAC,aAAa;oBAChB,uBAAuB,CACrB,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;wBACjC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,GAAG,IAAI;wBACpD,CAAC,CAAC,SAAS,CACd,CAAC;gBACJ,OAAO,QAAQ,CAAC;YAClB,CAAC;YAAC,OAAO,CAAM,EAAE,CAAC;gBAChB,MAAM,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC5D,SAAS,GAAG,KAAK,CAAC;gBAElB,8EAA8E;gBAC9E,IAAI,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;oBAClD,8DAA8D;oBAC9D,MAAM,OAAO,GACX,OAAQ,SAA4B,CAAC,YAAY,KAAK,QAAQ;wBAC5D,CAAC,CAAE,SAA4B,CAAC,YAAa;wBAC7C,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,IAAI,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC;oBAEhE,6BAA6B;oBAC7B,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;oBACvB,KAAK,CAAC,UAAU,EAAE,CAAC;gBACrB,CAAC;;oBAAM,MAAM;YACf,CAAC;QACH,CAAC;QACD,MAAM,CAAC,GAAG,SAAS,IAAI,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACzD,MAAM,KAAK,GAAG,IAAI,cAAc,CAAC;YAC/B,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,OAAO,EAAE,CAAC;YACV,MAAM,EAAE,EAAE;SACX,CAAC,CAAC;QACH,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;QACtB,MAAM,KAAK,CAAC;IACd,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { waitFor } from '@finalytic/utils';\nimport type { ClientOptions, HeadersOptions } from 'openapi-fetch';\nimport type { CacheResult } from './cache';\nimport { ApiClientError } from './error';\nimport { injectHeaders } from './headers';\nimport {\n type RetryableError,\n assertRetryableResponse,\n isRetryableError,\n} from './retryable-errors';\nimport type { ApiClientAuth } from './types';\n\n// Create query fetcher with retry logic\nexport function createQueryFetcher({\n attempts = 3,\n auth,\n fetch: f,\n sessionId,\n headers: h,\n cache,\n}: {\n attempts?: number;\n auth?: ApiClientAuth | (() => ApiClientAuth);\n sessionId: string;\n fetch?: ClientOptions['fetch'];\n headers?: HeadersOptions | (() => HeadersOptions);\n cache: CacheResult<string, string>;\n}) {\n return async (req: Request) => {\n // Implement retry logic with exponential backoff\n let lastError: Error | null = null;\n\n for (let attempt = 0; attempt < attempts; attempt++) {\n const isLastAttempt = attempt === attempts - 1;\n try {\n const dup = new Request(req);\n await injectHeaders(dup.headers, {\n auth,\n headers: h,\n sessionId,\n cache,\n });\n const response = await (f || fetch)(dup);\n if (!isLastAttempt)\n assertRetryableResponse(\n response.status,\n response.headers.has('Retry-After')\n ? Number(response.headers.get('Retry-After')) * 1000\n : undefined\n );\n return response;\n } catch (e: any) {\n const error = e instanceof Error ? e : new Error(String(e));\n lastError = error;\n\n // Only retry if this is a retryable error and we haven't exceeded max retries\n if (isRetryableError(lastError) && !isLastAttempt) {\n // Exponential backoff: 2^retries * 100ms + some random jitter\n const backoff =\n typeof (lastError as RetryableError).retryAfterMs === 'number'\n ? (lastError as RetryableError).retryAfterMs!\n : Math.min(100 * 2 ** attempt + Math.random() * 100, 10000);\n\n // Wait before the next retry\n await waitFor(backoff);\n cache.invalidate();\n } else break;\n }\n }\n const e = lastError || new Error('Max retries exceeded');\n const error = new ApiClientError({\n code: 'FETCH_ERROR',\n message: e.message,\n context: e,\n issues: [],\n });\n error.stack = e.stack;\n throw error;\n };\n}\n"]}
@@ -1,18 +0,0 @@
1
- import type { HeadersOptions } from 'openapi-fetch';
2
- import type { CacheResult } from './cache';
3
- import type { ApiClientAuth } from './types';
4
- export type HeaderInject = ReturnType<typeof injectHeaders>;
5
- export declare function injectHeaders(
6
- head: Headers,
7
- {
8
- auth,
9
- headers,
10
- sessionId,
11
- cache,
12
- }: {
13
- auth?: ApiClientAuth | (() => ApiClientAuth);
14
- headers?: HeadersOptions | (() => HeadersOptions);
15
- sessionId: string;
16
- cache: CacheResult<string, string>;
17
- }
18
- ): Promise<void>;
@@ -1,23 +0,0 @@
1
- export async function injectHeaders(head, { auth, headers, sessionId, cache }) {
2
- const temporary = new Headers(
3
- typeof headers === 'function' ? headers() : headers
4
- );
5
- const a = (typeof auth === 'function' ? auth() : auth) || {};
6
- if (sessionId) temporary.set('X-Session-Id', sessionId);
7
- if (a.sec) temporary.set('X-Api-Key', `Sec ${await cache.current(a.sec)}`);
8
- if (a.apiKey) temporary.set('X-Api-Key', a.apiKey);
9
- if (a.tenantId) temporary.set('X-Team-Id', a.tenantId);
10
- if (a.accessToken)
11
- temporary.set(
12
- 'Authorization',
13
- a.accessToken.startsWith('Bearer ')
14
- ? a.accessToken
15
- : `Bearer ${a.accessToken}`
16
- );
17
- temporary.forEach((value, key) => {
18
- if (!head.has(key)) {
19
- head.set(key, value);
20
- }
21
- });
22
- }
23
- //# sourceMappingURL=headers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"headers.js","sourceRoot":"src/","sources":["headers.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,IAAa,EACb,EACE,IAAI,EACJ,OAAO,EACP,SAAS,EACT,KAAK,GAMN;IAED,MAAM,SAAS,GAAG,IAAI,OAAO,CAC3B,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAE,OAAe,CAC7D,CAAC;IACF,MAAM,CAAC,GAAG,CAAC,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAC7D,IAAI,SAAS;QAAE,SAAS,CAAC,GAAG,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;IACxD,IAAI,CAAC,CAAC,GAAG;QAAE,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC3E,IAAI,CAAC,CAAC,MAAM;QAAE,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IACnD,IAAI,CAAC,CAAC,QAAQ;QAAE,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;IACvD,IAAI,CAAC,CAAC,WAAW;QACf,SAAS,CAAC,GAAG,CACX,eAAe,EACf,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC;YACjC,CAAC,CAAC,CAAC,CAAC,WAAW;YACf,CAAC,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAC9B,CAAC;IACJ,SAAS,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC/B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACnB,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { HeadersOptions } from 'openapi-fetch';\nimport type { CacheResult } from './cache';\nimport type { ApiClientAuth } from './types';\n\nexport type HeaderInject = ReturnType<typeof injectHeaders>;\nexport async function injectHeaders(\n head: Headers,\n {\n auth,\n headers,\n sessionId,\n cache,\n }: {\n auth?: ApiClientAuth | (() => ApiClientAuth);\n headers?: HeadersOptions | (() => HeadersOptions);\n sessionId: string;\n cache: CacheResult<string, string>;\n }\n) {\n const temporary = new Headers(\n typeof headers === 'function' ? headers() : (headers as any)\n );\n const a = (typeof auth === 'function' ? auth() : auth) || {};\n if (sessionId) temporary.set('X-Session-Id', sessionId);\n if (a.sec) temporary.set('X-Api-Key', `Sec ${await cache.current(a.sec)}`);\n if (a.apiKey) temporary.set('X-Api-Key', a.apiKey);\n if (a.tenantId) temporary.set('X-Team-Id', a.tenantId);\n if (a.accessToken)\n temporary.set(\n 'Authorization',\n a.accessToken.startsWith('Bearer ')\n ? a.accessToken\n : `Bearer ${a.accessToken}`\n );\n temporary.forEach((value, key) => {\n if (!head.has(key)) {\n head.set(key, value);\n }\n });\n}\n"]}
@@ -1,9 +0,0 @@
1
- export declare function isRetryableError(error: Error): boolean;
2
- export declare class RetryableError extends Error {
3
- readonly retryAfterMs?: number | undefined;
4
- constructor(message: string, retryAfterMs?: number | undefined);
5
- }
6
- export declare function assertRetryableResponse(
7
- status: number,
8
- retryAfterMs?: number
9
- ): void;
@@ -1,34 +0,0 @@
1
- // Add helper to check if an error is retryable
2
- export function isRetryableError(error) {
3
- // Network errors, connection timeouts, and other temporary issues
4
- if (error instanceof RetryableError) return true;
5
- const lowerCaseMessage = error.message?.toLowerCase() || '';
6
- return (
7
- lowerCaseMessage.includes('network connection lost') ||
8
- lowerCaseMessage.includes('failed to fetch') ||
9
- lowerCaseMessage.includes('network request failed') ||
10
- lowerCaseMessage.includes('timeout') ||
11
- lowerCaseMessage.includes('fetch failed') ||
12
- lowerCaseMessage.includes('econnrefused') ||
13
- lowerCaseMessage.includes('econnreset')
14
- );
15
- }
16
- export class RetryableError extends Error {
17
- retryAfterMs;
18
- constructor(message, retryAfterMs) {
19
- super(message);
20
- this.retryAfterMs = retryAfterMs;
21
- }
22
- }
23
- // Status codes that should trigger a retry
24
- const RETRYABLE_STATUS_CODES = new Set([408, 429, 500, 502, 503, 504, 520]);
25
- export function assertRetryableResponse(status, retryAfterMs) {
26
- if (RETRYABLE_STATUS_CODES.has(status) || typeof retryAfterMs === 'number') {
27
- // Throw an error that will be caught by the catch block below
28
- throw new RetryableError(
29
- `Retryable HTTP status code: ${status}`,
30
- retryAfterMs
31
- );
32
- }
33
- }
34
- //# sourceMappingURL=retryable-errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"retryable-errors.js","sourceRoot":"src/","sources":["retryable-errors.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,MAAM,UAAU,gBAAgB,CAAC,KAAY;IAC3C,kEAAkE;IAClE,IAAI,KAAK,YAAY,cAAc;QAAE,OAAO,IAAI,CAAC;IACjD,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IAC5D,OAAO,CACL,gBAAgB,CAAC,QAAQ,CAAC,yBAAyB,CAAC;QACpD,gBAAgB,CAAC,QAAQ,CAAC,iBAAiB,CAAC;QAC5C,gBAAgB,CAAC,QAAQ,CAAC,wBAAwB,CAAC;QACnD,gBAAgB,CAAC,QAAQ,CAAC,SAAS,CAAC;QACpC,gBAAgB,CAAC,QAAQ,CAAC,cAAc,CAAC;QACzC,gBAAgB,CAAC,QAAQ,CAAC,cAAc,CAAC;QACzC,gBAAgB,CAAC,QAAQ,CAAC,YAAY,CAAC,CACxC,CAAC;AACJ,CAAC;AACD,MAAM,OAAO,cAAe,SAAQ,KAAK;IAGrB;IAFlB,YACE,OAAe,EACC,YAAqB;QAErC,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,iBAAY,GAAZ,YAAY,CAAS;IAGvC,CAAC;CACF;AAED,2CAA2C;AAC3C,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAE5E,MAAM,UAAU,uBAAuB,CAAC,MAAc,EAAE,YAAqB;IAC3E,IAAI,sBAAsB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;QAC3E,8DAA8D;QAC9D,MAAM,IAAI,cAAc,CACtB,+BAA+B,MAAM,EAAE,EACvC,YAAY,CACb,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["// Add helper to check if an error is retryable\nexport function isRetryableError(error: Error): boolean {\n // Network errors, connection timeouts, and other temporary issues\n if (error instanceof RetryableError) return true;\n const lowerCaseMessage = error.message?.toLowerCase() || '';\n return (\n lowerCaseMessage.includes('network connection lost') ||\n lowerCaseMessage.includes('failed to fetch') ||\n lowerCaseMessage.includes('network request failed') ||\n lowerCaseMessage.includes('timeout') ||\n lowerCaseMessage.includes('fetch failed') ||\n lowerCaseMessage.includes('econnrefused') ||\n lowerCaseMessage.includes('econnreset')\n );\n}\nexport class RetryableError extends Error {\n constructor(\n message: string,\n public readonly retryAfterMs?: number\n ) {\n super(message);\n }\n}\n\n// Status codes that should trigger a retry\nconst RETRYABLE_STATUS_CODES = new Set([408, 429, 500, 502, 503, 504, 520]);\n\nexport function assertRetryableResponse(status: number, retryAfterMs?: number) {\n if (RETRYABLE_STATUS_CODES.has(status) || typeof retryAfterMs === 'number') {\n // Throw an error that will be caught by the catch block below\n throw new RetryableError(\n `Retryable HTTP status code: ${status}`,\n retryAfterMs\n );\n }\n}\n"]}