@xylabs/retry 7.0.2 → 7.0.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.
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ > **Deprecated.** Use [`@ariestools/sdk`](../../ariestools-sdk/README.md) instead. This package is a backward-compatibility re-export shim.
2
+
1
3
  [![logo][]](https://xylabs.com)
2
4
 
3
5
  # @xylabs/retry
@@ -12,25 +14,25 @@
12
14
  Using npm:
13
15
 
14
16
  ```sh
15
- npm install {{name}}
17
+ npm install @xylabs/retry
16
18
  ```
17
19
 
18
20
  Using yarn:
19
21
 
20
22
  ```sh
21
- yarn add {{name}}
23
+ yarn add @xylabs/retry
22
24
  ```
23
25
 
24
26
  Using pnpm:
25
27
 
26
28
  ```sh
27
- pnpm add {{name}}
29
+ pnpm add @xylabs/retry
28
30
  ```
29
31
 
30
32
  Using bun:
31
33
 
32
34
  ```sh
33
- bun add {{name}}
35
+ bun add @xylabs/retry
34
36
  ```
35
37
 
36
38
 
@@ -1,2 +1,2 @@
1
- export * from './retry.ts';
1
+ export * from '@ariestools/sdk/retry';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA"}
@@ -1,28 +1,3 @@
1
- // src/retry.ts
2
- import { delay } from "@xylabs/delay";
3
- var retry = async (func, config) => {
4
- const {
5
- complete = (value) => value !== void 0,
6
- retries = 0,
7
- interval = 100,
8
- backoff = 2
9
- } = config ?? {};
10
- const result = await func();
11
- if (complete(result)) {
12
- return result;
13
- }
14
- if (retries <= 0) {
15
- return void 0;
16
- }
17
- await delay(interval);
18
- return retry(func, {
19
- backoff,
20
- complete,
21
- interval: interval * backoff,
22
- retries: retries - 1
23
- });
24
- };
25
- export {
26
- retry
27
- };
1
+ // src/index.ts
2
+ export * from "@ariestools/sdk/retry";
28
3
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/retry.ts"],
4
- "sourcesContent": ["import { delay } from '@xylabs/delay'\nimport type { Promisable } from '@xylabs/promise'\n\n/** Configuration for retry behavior. */\nexport interface RetryConfig {\n /** Multiplier applied to the interval after each retry. Defaults to 2. */\n backoff?: number\n /** Initial delay in milliseconds between retries. Defaults to 100. */\n interval?: number\n /** Maximum number of retry attempts. Defaults to 0 (no retries). */\n retries?: number\n}\n\n/** Retry configuration extended with a custom completion check. */\nexport interface RetryConfigWithComplete<T = unknown> extends RetryConfig {\n /** Determines whether the result is considered complete. Defaults to checking for a defined value. */\n complete?: (result?: T) => boolean\n}\n\n/**\n * Retries an async function with exponential backoff until it completes or retries are exhausted.\n * @param func - The function to retry.\n * @param config - Optional retry configuration including backoff, interval, retries, and completion check.\n * @returns The result of the function, or undefined if all retries were exhausted.\n */\nexport const retry = async <T = unknown>(func: () => Promisable<T | undefined>, config?: RetryConfigWithComplete<T>): Promise<T | undefined> => {\n const {\n complete = (value: T | undefined) => value !== undefined, retries = 0, interval = 100, backoff = 2,\n } = config ?? {}\n const result = await func()\n if (complete(result)) {\n return result\n }\n if (retries <= 0) {\n return undefined\n }\n await delay(interval)\n return retry(func, {\n backoff, complete, interval: interval * backoff, retries: retries - 1,\n })\n}\n"],
5
- "mappings": ";AAAA,SAAS,aAAa;AAyBf,IAAM,QAAQ,OAAoB,MAAuC,WAAgE;AAC9I,QAAM;AAAA,IACJ,WAAW,CAAC,UAAyB,UAAU;AAAA,IAAW,UAAU;AAAA,IAAG,WAAW;AAAA,IAAK,UAAU;AAAA,EACnG,IAAI,UAAU,CAAC;AACf,QAAM,SAAS,MAAM,KAAK;AAC1B,MAAI,SAAS,MAAM,GAAG;AACpB,WAAO;AAAA,EACT;AACA,MAAI,WAAW,GAAG;AAChB,WAAO;AAAA,EACT;AACA,QAAM,MAAM,QAAQ;AACpB,SAAO,MAAM,MAAM;AAAA,IACjB;AAAA,IAAS;AAAA,IAAU,UAAU,WAAW;AAAA,IAAS,SAAS,UAAU;AAAA,EACtE,CAAC;AACH;",
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from '@ariestools/sdk/retry'\n"],
5
+ "mappings": ";AAAA,cAAc;",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- export type { RetryConfig, RetryConfigWithComplete, } from './retry.ts';
1
+ export type * from '@ariestools/sdk/retry/model';
2
2
  //# sourceMappingURL=model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,WAAW,EACX,uBAAuB,GACxB,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model.ts"],"names":[],"mappings":"AAAA,mBAAmB,6BAA6B,CAAA"}
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "@xylabs/retry",
3
- "version": "7.0.2",
4
- "description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
3
+ "version": "7.0.3",
4
+ "description": "DEPRECATED use @ariestools/sdk/retry. Backward-compatibility re-export shim.",
5
5
  "keywords": [
6
- "delay",
7
6
  "xylabs",
8
7
  "utility",
9
8
  "typescript",
@@ -31,11 +30,11 @@
31
30
  "types": "./dist/neutral/index.d.ts",
32
31
  "default": "./dist/neutral/index.mjs"
33
32
  },
33
+ "./package.json": "./package.json",
34
34
  "./model": {
35
35
  "types": "./dist/neutral/model.d.ts",
36
36
  "default": "./dist/neutral/model.mjs"
37
- },
38
- "./package.json": "./package.json"
37
+ }
39
38
  },
40
39
  "files": [
41
40
  "dist",
@@ -45,23 +44,31 @@
45
44
  "README.md"
46
45
  ],
47
46
  "dependencies": {
48
- "@xylabs/delay": "~7.0.2",
49
- "@xylabs/promise": "~7.0.2"
47
+ "@ariestools/sdk": "~7.0.3"
50
48
  },
51
49
  "devDependencies": {
52
- "@xylabs/toolchain": "^8.5.3",
53
- "@xylabs/tsconfig": "^8.5.3",
50
+ "@opentelemetry/api": "^1.9.1",
51
+ "@opentelemetry/sdk-trace-base": "^2.8.0",
52
+ "@xylabs/toolchain": "^8.5.5",
53
+ "@xylabs/tsconfig": "^8.5.5",
54
+ "async-mutex": "^0.5.0",
54
55
  "browserslist": "4.28.4",
55
56
  "eslint": "^10.6.0",
56
57
  "eslint-import-resolver-typescript": "^4.4.5",
57
58
  "typescript": "^6.0.3",
58
- "vite": "^8.1.0",
59
- "vitest": "^4.1.9"
59
+ "zod": "^4.4.3"
60
+ },
61
+ "peerDependencies": {
62
+ "@opentelemetry/api": "^1.9",
63
+ "@opentelemetry/sdk-trace-base": "^2.7",
64
+ "async-mutex": "^0.5",
65
+ "zod": "^4.4"
60
66
  },
61
67
  "engines": {
62
68
  "node": ">=18"
63
69
  },
64
70
  "publishConfig": {
65
71
  "access": "public"
66
- }
72
+ },
73
+ "deprecated": "Use @ariestools/sdk/retry instead. @xylabs/retry is a compatibility shim only and will not receive further updates."
67
74
  }
@@ -1,23 +0,0 @@
1
- import type { Promisable } from '@xylabs/promise';
2
- /** Configuration for retry behavior. */
3
- export interface RetryConfig {
4
- /** Multiplier applied to the interval after each retry. Defaults to 2. */
5
- backoff?: number;
6
- /** Initial delay in milliseconds between retries. Defaults to 100. */
7
- interval?: number;
8
- /** Maximum number of retry attempts. Defaults to 0 (no retries). */
9
- retries?: number;
10
- }
11
- /** Retry configuration extended with a custom completion check. */
12
- export interface RetryConfigWithComplete<T = unknown> extends RetryConfig {
13
- /** Determines whether the result is considered complete. Defaults to checking for a defined value. */
14
- complete?: (result?: T) => boolean;
15
- }
16
- /**
17
- * Retries an async function with exponential backoff until it completes or retries are exhausted.
18
- * @param func - The function to retry.
19
- * @param config - Optional retry configuration including backoff, interval, retries, and completion check.
20
- * @returns The result of the function, or undefined if all retries were exhausted.
21
- */
22
- export declare const retry: <T = unknown>(func: () => Promisable<T | undefined>, config?: RetryConfigWithComplete<T>) => Promise<T | undefined>;
23
- //# sourceMappingURL=retry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/retry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,wCAAwC;AACxC,MAAM,WAAW,WAAW;IAC1B,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,mEAAmE;AACnE,MAAM,WAAW,uBAAuB,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,WAAW;IACvE,sGAAsG;IACtG,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,OAAO,CAAA;CACnC;AAED;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAAU,CAAC,GAAG,OAAO,EAAE,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,SAAS,uBAAuB,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAe1I,CAAA"}