durability 1.0.0 → 2.1.0

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.
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Calculates a capped exponential retry delay.
3
+ *
4
+ * @param attempt One-based attempt number.
5
+ * @param initialDelayMs Delay after the first failed attempt. Defaults to 1 second.
6
+ * @param maxDelayMs Maximum returned delay. Defaults to 5 minutes.
7
+ */
8
+ export declare const exponential: (attempt: number, initialDelayMs?: number, maxDelayMs?: number) => number;
9
+ /** Applies equal jitter, returning a value between half and all of the delay. */
10
+ export declare const jitter: (delayMs: number) => number;
package/dist/utils.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Calculates a capped exponential retry delay.
3
+ *
4
+ * @param attempt One-based attempt number.
5
+ * @param initialDelayMs Delay after the first failed attempt. Defaults to 1 second.
6
+ * @param maxDelayMs Maximum returned delay. Defaults to 5 minutes.
7
+ */
8
+ export const exponential = (attempt, initialDelayMs = 1000, maxDelayMs = 300000) => Math.min(initialDelayMs * 2 ** (attempt - 1), maxDelayMs);
9
+ /** Applies equal jitter, returning a value between half and all of the delay. */
10
+ export const jitter = (delayMs) => delayMs / 2 + Math.random() * (delayMs / 2);
package/package.json CHANGED
@@ -1,13 +1,72 @@
1
1
  {
2
2
  "name": "durability",
3
- "version": "1.0.0",
4
- "description": "",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "keywords": [],
10
- "author": "",
3
+ "version": "2.1.0",
4
+ "description": "Alarm-backed durable operations for Cloudflare Durable Objects",
5
+ "type": "module",
11
6
  "license": "ISC",
12
- "type": "commonjs"
13
- }
7
+ "sideEffects": false,
8
+ "files": [
9
+ "dist",
10
+ "LICENSE",
11
+ "README.md"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ },
18
+ "./utils": {
19
+ "types": "./dist/utils.d.ts",
20
+ "import": "./dist/utils.js"
21
+ }
22
+ },
23
+ "publishConfig": {
24
+ "access": "public",
25
+ "registry": "https://registry.npmjs.org/"
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/avenceslau/durability.git",
30
+ "directory": "packages/durability"
31
+ },
32
+ "homepage": "https://github.com/avenceslau/durability#readme",
33
+ "bugs": {
34
+ "url": "https://github.com/avenceslau/durability/issues"
35
+ },
36
+ "keywords": [
37
+ "alarms",
38
+ "cloudflare",
39
+ "durable-objects",
40
+ "idempotency",
41
+ "retries",
42
+ "workers"
43
+ ],
44
+ "dependencies": {
45
+ "workers-qb": "1.11.2",
46
+ "zod": "^4.4.3",
47
+ "@durability/storage": "^0.1.1"
48
+ },
49
+ "peerDependencies": {
50
+ "@cloudflare/workers-types": "^4.20260702.1"
51
+ },
52
+ "peerDependenciesMeta": {
53
+ "@cloudflare/workers-types": {
54
+ "optional": true
55
+ }
56
+ },
57
+ "devDependencies": {
58
+ "@cloudflare/vitest-pool-workers": "^0.17.0",
59
+ "@cloudflare/workers-types": "^4.20260702.1",
60
+ "@types/node": "^24.12.0",
61
+ "typescript": "6.0.3",
62
+ "vite": "^8.0.0",
63
+ "vitest": "^4.1.5",
64
+ "@durability/typescript-config": "0.0.0"
65
+ },
66
+ "scripts": {
67
+ "build": "rm -rf dist && tsc -p tsconfig.build.json",
68
+ "lint": "oxlint",
69
+ "test": "vitest run && vitest run --config vitest.workers.config.ts",
70
+ "typecheck": "tsc --noEmit"
71
+ }
72
+ }
package/index.js DELETED
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- function durability() {
4
- return "durability";
5
- }
6
-
7
- module.exports = {
8
- durability,
9
- };