actly 1.2.0 → 1.3.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.
- package/CHANGELOG.md +234 -0
- package/MIGRATION.md +141 -0
- package/README.md +326 -218
- package/SECURITY.md +56 -0
- package/dist/core/act.cjs +406 -220
- package/dist/core/act.d.ts +6 -84
- package/dist/core/act.d.ts.map +1 -1
- package/dist/core/act.js +405 -222
- package/dist/core/executor.cjs +0 -27
- package/dist/core/executor.d.ts +0 -41
- package/dist/core/executor.d.ts.map +1 -1
- package/dist/core/executor.js +0 -28
- package/dist/core/health.cjs +146 -17
- package/dist/core/health.d.ts +20 -5
- package/dist/core/health.d.ts.map +1 -1
- package/dist/core/health.js +140 -18
- package/dist/core/shutdown.cjs +19 -8
- package/dist/core/shutdown.d.ts +1 -4
- package/dist/core/shutdown.d.ts.map +1 -1
- package/dist/core/shutdown.js +18 -9
- package/dist/core/tenant.cjs +61 -19
- package/dist/core/tenant.d.ts +5 -10
- package/dist/core/tenant.d.ts.map +1 -1
- package/dist/core/tenant.js +61 -20
- package/dist/errors.cjs +70 -103
- package/dist/errors.d.ts +33 -90
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +66 -103
- package/dist/index.cjs +25 -22
- package/dist/index.d.ts +12 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -15
- package/dist/observability.cjs +0 -39
- package/dist/observability.d.ts +19 -78
- package/dist/observability.d.ts.map +1 -1
- package/dist/observability.js +0 -40
- package/dist/policies/bulkhead.cjs +44 -4
- package/dist/policies/bulkhead.d.ts +0 -0
- package/dist/policies/bulkhead.d.ts.map +1 -1
- package/dist/policies/bulkhead.js +44 -5
- package/dist/policies/cache.cjs +22 -142
- package/dist/policies/cache.d.ts +0 -46
- package/dist/policies/cache.d.ts.map +1 -1
- package/dist/policies/cache.js +22 -143
- package/dist/policies/circuitBreaker.cjs +125 -31
- package/dist/policies/circuitBreaker.d.ts +0 -0
- package/dist/policies/circuitBreaker.d.ts.map +1 -1
- package/dist/policies/circuitBreaker.js +125 -32
- package/dist/policies/dedupe.cjs +19 -66
- package/dist/policies/dedupe.d.ts +0 -23
- package/dist/policies/dedupe.d.ts.map +1 -1
- package/dist/policies/dedupe.js +19 -67
- package/dist/policies/noop.cjs +6 -0
- package/dist/policies/noop.d.ts +3 -0
- package/dist/policies/noop.d.ts.map +1 -0
- package/dist/policies/noop.js +3 -0
- package/dist/policies/rateLimit.cjs +15 -5
- package/dist/policies/rateLimit.d.ts +0 -0
- package/dist/policies/rateLimit.d.ts.map +1 -1
- package/dist/policies/rateLimit.js +15 -6
- package/dist/policies/retry.cjs +100 -65
- package/dist/policies/retry.d.ts +0 -27
- package/dist/policies/retry.d.ts.map +1 -1
- package/dist/policies/retry.js +100 -66
- package/dist/policies/timeout.cjs +32 -60
- package/dist/policies/timeout.d.ts +0 -13
- package/dist/policies/timeout.d.ts.map +1 -1
- package/dist/policies/timeout.js +32 -71
- package/dist/stores/base.cjs +0 -10
- package/dist/stores/base.d.ts +4 -67
- package/dist/stores/base.d.ts.map +1 -1
- package/dist/stores/base.js +0 -11
- package/dist/stores/memory.cjs +75 -88
- package/dist/stores/memory.d.ts +7 -74
- package/dist/stores/memory.d.ts.map +1 -1
- package/dist/stores/memory.js +75 -89
- package/dist/testing/index.cjs +56 -0
- package/dist/testing/index.d.ts +6 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +52 -0
- package/dist/types/index.cjs +0 -1
- package/dist/types/index.d.ts +17 -307
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -2
- package/dist/utils/abort.cjs +14 -111
- package/dist/utils/abort.d.ts +3 -74
- package/dist/utils/abort.d.ts.map +1 -1
- package/dist/utils/abort.js +14 -112
- package/dist/utils/abortPool.cjs +1 -2
- package/dist/utils/abortPool.d.ts +0 -0
- package/dist/utils/abortPool.d.ts.map +1 -1
- package/dist/utils/abortPool.js +1 -3
- package/dist/utils/backoff.cjs +3 -21
- package/dist/utils/backoff.d.ts +0 -11
- package/dist/utils/backoff.d.ts.map +1 -1
- package/dist/utils/backoff.js +3 -22
- package/dist/utils/decorator.cjs +44 -0
- package/dist/utils/decorator.d.ts +3 -0
- package/dist/utils/decorator.d.ts.map +1 -0
- package/dist/utils/decorator.js +41 -0
- package/dist/utils/key.cjs +13 -45
- package/dist/utils/key.d.ts +0 -27
- package/dist/utils/key.d.ts.map +1 -1
- package/dist/utils/key.js +13 -46
- package/dist/utils/limits.cjs +9 -27
- package/dist/utils/limits.d.ts +9 -27
- package/dist/utils/limits.d.ts.map +1 -1
- package/dist/utils/limits.js +9 -28
- package/dist/utils/safeCall.cjs +28 -0
- package/dist/utils/safeCall.d.ts +2 -0
- package/dist/utils/safeCall.d.ts.map +1 -0
- package/dist/utils/safeCall.js +25 -0
- package/dist/utils/sanitize.cjs +22 -1
- package/dist/utils/sanitize.d.ts +0 -0
- package/dist/utils/sanitize.d.ts.map +1 -1
- package/dist/utils/sanitize.js +22 -2
- package/dist/utils/validate.cjs +81 -18
- package/dist/utils/validate.d.ts +6 -19
- package/dist/utils/validate.d.ts.map +1 -1
- package/dist/utils/validate.js +81 -19
- package/package.json +38 -4
- package/dist/core/act.js.map +0 -1
- package/dist/core/executor.js.map +0 -1
- package/dist/core/health.js.map +0 -1
- package/dist/core/shutdown.js.map +0 -1
- package/dist/core/tenant.js.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/observability.js.map +0 -1
- package/dist/policies/bulkhead.js.map +0 -1
- package/dist/policies/cache.js.map +0 -1
- package/dist/policies/circuitBreaker.js.map +0 -1
- package/dist/policies/dedupe.js.map +0 -1
- package/dist/policies/rateLimit.js.map +0 -1
- package/dist/policies/retry.js.map +0 -1
- package/dist/policies/timeout.js.map +0 -1
- package/dist/state/store.cjs +0 -14
- package/dist/state/store.d.ts +0 -11
- package/dist/state/store.d.ts.map +0 -1
- package/dist/state/store.js +0 -11
- package/dist/state/store.js.map +0 -1
- package/dist/stores/base.js.map +0 -1
- package/dist/stores/memory.js.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/utils/abort.js.map +0 -1
- package/dist/utils/abortPool.js.map +0 -1
- package/dist/utils/backoff.js.map +0 -1
- package/dist/utils/key.js.map +0 -1
- package/dist/utils/limits.js.map +0 -1
- package/dist/utils/sanitize.js.map +0 -1
- package/dist/utils/validate.js.map +0 -1
package/dist/errors.d.ts
CHANGED
|
@@ -1,51 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Actly error taxonomy.
|
|
3
|
-
*
|
|
4
|
-
* Six classes (one abstract base + five concrete). Each carries a stable
|
|
5
|
-
* `code` field so consumers can switch on strings instead of brittle
|
|
6
|
-
* `instanceof` chains across realm boundaries (e.g. errors serialised
|
|
7
|
-
* over IPC).
|
|
8
|
-
*
|
|
9
|
-
* # Why these six?
|
|
10
|
-
*
|
|
11
|
-
* - `ActlyError` — abstract base for `instanceof ActlyError` checks
|
|
12
|
-
* - `ActlyAbortError` — caller / signal cancellation
|
|
13
|
-
* - `TimeoutError` — per-attempt deadline
|
|
14
|
-
* - `TotalTimeoutError` — operation-wide budget
|
|
15
|
-
* - `RetryExhaustedError`— last attempt's error wrapped with context
|
|
16
|
-
* - `ValidationError` — programmer error (invalid options)
|
|
17
|
-
*
|
|
18
|
-
* NO circuit/bulkhead/rate-limit errors — those policies don't exist in
|
|
19
|
-
* core. Adding orphan error classes violates the "every feature must map
|
|
20
|
-
* to a real runtime failure mode" rule.
|
|
21
|
-
*
|
|
22
|
-
* # `code` field
|
|
23
|
-
*
|
|
24
|
-
* Stable string identifier. Use this for switch statements and telemetry
|
|
25
|
-
* tags. The class name can change across versions; `code` won't.
|
|
26
|
-
*/
|
|
27
|
-
/** Base class for all actly errors. Enables `instanceof ActlyError` checks. */
|
|
28
1
|
export declare abstract class ActlyError extends Error {
|
|
29
|
-
/** Stable string identifier. Use for telemetry / switch statements. */
|
|
30
2
|
abstract readonly code: string;
|
|
31
|
-
/** The key associated with the failure, if applicable. */
|
|
32
3
|
readonly key?: string;
|
|
33
4
|
constructor(message: string, options?: {
|
|
34
5
|
key?: string;
|
|
35
6
|
cause?: unknown;
|
|
36
7
|
});
|
|
8
|
+
toJSON(opts?: {
|
|
9
|
+
redact?: boolean;
|
|
10
|
+
}): Record<string, unknown>;
|
|
37
11
|
}
|
|
38
|
-
|
|
39
|
-
* Thrown when the caller's signal, per-attempt timeout, or total timeout
|
|
40
|
-
* aborts the operation.
|
|
41
|
-
*
|
|
42
|
-
* `cause` carries the original abort reason (e.g. user-supplied
|
|
43
|
-
* `controller.abort(new Error('user-cancelled'))` → cause.message is
|
|
44
|
-
* 'user-cancelled').
|
|
45
|
-
*
|
|
46
|
-
* Wraps the raw abort reason in a typed error so consumers can
|
|
47
|
-
* `instanceof`-check it consistently across all abort sources.
|
|
48
|
-
*/
|
|
12
|
+
export declare function isActlyError(e: unknown): e is ActlyError;
|
|
49
13
|
export declare class ActlyAbortError extends ActlyError {
|
|
50
14
|
readonly code: "ACTLY_ABORT";
|
|
51
15
|
constructor(options?: {
|
|
@@ -53,56 +17,22 @@ export declare class ActlyAbortError extends ActlyError {
|
|
|
53
17
|
cause?: unknown;
|
|
54
18
|
});
|
|
55
19
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Thrown when a per-attempt `timeout` deadline fires.
|
|
58
|
-
*
|
|
59
|
-
* Carries the configured `ms` so callers can log/alert precisely:
|
|
60
|
-
*
|
|
61
|
-
* ```ts
|
|
62
|
-
* if (!result.ok && result.error instanceof TimeoutError) {
|
|
63
|
-
* console.log(`attempt timed out after ${result.error.ms}ms`)
|
|
64
|
-
* }
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
20
|
export declare class TimeoutError extends ActlyError {
|
|
68
21
|
readonly code: "ACTLY_TIMEOUT";
|
|
69
22
|
readonly ms: number;
|
|
70
23
|
constructor(ms: number, options?: {
|
|
71
24
|
key?: string;
|
|
25
|
+
cause?: unknown;
|
|
72
26
|
});
|
|
73
27
|
}
|
|
74
|
-
/**
|
|
75
|
-
* Thrown when the operation-wide `totalTimeout` budget fires.
|
|
76
|
-
*
|
|
77
|
-
* Distinct from `TimeoutError` (per-attempt) so callers can `instanceof`-check
|
|
78
|
-
* which deadline fired.
|
|
79
|
-
*/
|
|
80
28
|
export declare class TotalTimeoutError extends ActlyError {
|
|
81
29
|
readonly code: "ACTLY_TOTAL_TIMEOUT";
|
|
82
30
|
readonly ms: number;
|
|
83
31
|
constructor(ms: number, options?: {
|
|
84
32
|
key?: string;
|
|
33
|
+
cause?: unknown;
|
|
85
34
|
});
|
|
86
35
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Thrown when all retry attempts are exhausted. The `lastError` is the
|
|
89
|
-
* final attempt's error; `errors` is the array of all attempt errors
|
|
90
|
-
* (useful for debugging patterns across retries).
|
|
91
|
-
*
|
|
92
|
-
* Wraps retry exhaustion with context so consumers can distinguish "single
|
|
93
|
-
* fn error" from "retry exhausted after N attempts".
|
|
94
|
-
*
|
|
95
|
-
* # When is this thrown vs the raw error?
|
|
96
|
-
*
|
|
97
|
-
* `retryPolicy` throws `RetryExhaustedError` when:
|
|
98
|
-
* - `attempts > 1` AND
|
|
99
|
-
* - all attempts failed AND
|
|
100
|
-
* - the default `shouldRetry` (or user-supplied predicate) returned `true`
|
|
101
|
-
* for at least one failure
|
|
102
|
-
*
|
|
103
|
-
* If the user's `shouldRetry` returns `false` on the first attempt, the
|
|
104
|
-
* raw error is thrown (no retries happened — not "exhausted").
|
|
105
|
-
*/
|
|
106
36
|
export declare class RetryExhaustedError extends ActlyError {
|
|
107
37
|
readonly code: "ACTLY_RETRY_EXHAUSTED";
|
|
108
38
|
readonly attempts: number;
|
|
@@ -115,37 +45,50 @@ export declare class RetryExhaustedError extends ActlyError {
|
|
|
115
45
|
errors: readonly unknown[];
|
|
116
46
|
});
|
|
117
47
|
}
|
|
118
|
-
/**
|
|
119
|
-
* Thrown on invalid option shapes / keys / store contracts. Programmer
|
|
120
|
-
* errors — these surface synchronously, NOT as `ActFailure`, because the
|
|
121
|
-
* caller's code is broken.
|
|
122
|
-
*
|
|
123
|
-
* Wraps the underlying `TypeError` / `RangeError` so consumers catching
|
|
124
|
-
* `ActlyError` get a consistent type for all actly-thrown errors.
|
|
125
|
-
*/
|
|
126
48
|
export declare class ValidationError extends ActlyError {
|
|
127
49
|
readonly code: "ACTLY_VALIDATION";
|
|
128
50
|
constructor(message: string, options?: {
|
|
129
51
|
field?: string;
|
|
52
|
+
cause?: unknown;
|
|
130
53
|
});
|
|
131
54
|
readonly field?: string;
|
|
132
55
|
}
|
|
133
|
-
/** Thrown when a circuit breaker is open and blocks the call. */
|
|
134
56
|
export declare class CircuitBreakerOpenError extends ActlyError {
|
|
135
57
|
readonly code: "ACTLY_CIRCUIT_OPEN";
|
|
136
58
|
readonly key: string;
|
|
137
|
-
constructor(key: string, ms: number
|
|
59
|
+
constructor(key: string, ms: number, options?: {
|
|
60
|
+
cause?: unknown;
|
|
61
|
+
});
|
|
138
62
|
}
|
|
139
|
-
/** Thrown when a bulkhead is full (maxConcurrent reached, queue timed out). */
|
|
140
63
|
export declare class BulkheadOverflowError extends ActlyError {
|
|
141
64
|
readonly code: "ACTLY_BULKHEAD_FULL";
|
|
142
65
|
readonly key: string;
|
|
143
|
-
constructor(key: string, maxConcurrent: number
|
|
66
|
+
constructor(key: string, maxConcurrent: number, options?: {
|
|
67
|
+
cause?: unknown;
|
|
68
|
+
});
|
|
144
69
|
}
|
|
145
|
-
/** Thrown when a rate limit is exceeded. */
|
|
146
70
|
export declare class RateLimitError extends ActlyError {
|
|
147
71
|
readonly code: "ACTLY_RATE_LIMIT";
|
|
148
72
|
readonly key: string;
|
|
149
|
-
constructor(key: string, maxCalls: number, windowMs: number
|
|
73
|
+
constructor(key: string, maxCalls: number, windowMs: number, options?: {
|
|
74
|
+
cause?: unknown;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
export declare class ResourceExhaustedError extends ActlyError {
|
|
78
|
+
readonly code: "ACTLY_RESOURCE_EXHAUSTED";
|
|
79
|
+
readonly current: number;
|
|
80
|
+
readonly limit: number;
|
|
81
|
+
constructor(current: number, limit: number, options?: {
|
|
82
|
+
cause?: unknown;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
export declare class HedgeTimeoutError extends ActlyError {
|
|
86
|
+
readonly code: "ACTLY_HEDGE_TIMEOUT";
|
|
87
|
+
readonly delayMs: number;
|
|
88
|
+
constructor(options?: {
|
|
89
|
+
key?: string;
|
|
90
|
+
delayMs?: number;
|
|
91
|
+
cause?: unknown;
|
|
92
|
+
});
|
|
150
93
|
}
|
|
151
94
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"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"}
|
package/dist/errors.js
CHANGED
|
@@ -1,32 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Actly error taxonomy.
|
|
3
|
-
*
|
|
4
|
-
* Six classes (one abstract base + five concrete). Each carries a stable
|
|
5
|
-
* `code` field so consumers can switch on strings instead of brittle
|
|
6
|
-
* `instanceof` chains across realm boundaries (e.g. errors serialised
|
|
7
|
-
* over IPC).
|
|
8
|
-
*
|
|
9
|
-
* # Why these six?
|
|
10
|
-
*
|
|
11
|
-
* - `ActlyError` — abstract base for `instanceof ActlyError` checks
|
|
12
|
-
* - `ActlyAbortError` — caller / signal cancellation
|
|
13
|
-
* - `TimeoutError` — per-attempt deadline
|
|
14
|
-
* - `TotalTimeoutError` — operation-wide budget
|
|
15
|
-
* - `RetryExhaustedError`— last attempt's error wrapped with context
|
|
16
|
-
* - `ValidationError` — programmer error (invalid options)
|
|
17
|
-
*
|
|
18
|
-
* NO circuit/bulkhead/rate-limit errors — those policies don't exist in
|
|
19
|
-
* core. Adding orphan error classes violates the "every feature must map
|
|
20
|
-
* to a real runtime failure mode" rule.
|
|
21
|
-
*
|
|
22
|
-
* # `code` field
|
|
23
|
-
*
|
|
24
|
-
* Stable string identifier. Use this for switch statements and telemetry
|
|
25
|
-
* tags. The class name can change across versions; `code` won't.
|
|
26
|
-
*/
|
|
27
|
-
/** Base class for all actly errors. Enables `instanceof ActlyError` checks. */
|
|
28
1
|
export class ActlyError extends Error {
|
|
29
|
-
/** The key associated with the failure, if applicable. */
|
|
30
2
|
key;
|
|
31
3
|
constructor(message, options) {
|
|
32
4
|
super(message, options?.cause !== undefined ? { cause: options.cause } : undefined);
|
|
@@ -34,22 +6,48 @@ export class ActlyError extends Error {
|
|
|
34
6
|
if (options?.key !== undefined) {
|
|
35
7
|
Object.defineProperty(this, 'key', { value: options.key, enumerable: true });
|
|
36
8
|
}
|
|
37
|
-
// Restore prototype chain after Error inheritance (TS es2022 target
|
|
38
|
-
// may strip it). This ensures `instanceof` works correctly.
|
|
39
9
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
40
10
|
}
|
|
11
|
+
toJSON(opts) {
|
|
12
|
+
const obj = {
|
|
13
|
+
name: this.name,
|
|
14
|
+
code: this.code,
|
|
15
|
+
message: opts?.redact ? sanitizeErrorMessageForJSON(this.message) : this.message,
|
|
16
|
+
};
|
|
17
|
+
if (this.key !== undefined)
|
|
18
|
+
obj.key = this.key;
|
|
19
|
+
if (this.stack !== undefined)
|
|
20
|
+
obj.stack = this.stack;
|
|
21
|
+
for (const prop of Object.keys(this)) {
|
|
22
|
+
if (!(prop in obj)) {
|
|
23
|
+
try {
|
|
24
|
+
obj[prop] = this[prop];
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return obj;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function isActlyError(e) {
|
|
34
|
+
return (e != null &&
|
|
35
|
+
typeof e === 'object' &&
|
|
36
|
+
typeof e.code === 'string' &&
|
|
37
|
+
String(e.code).startsWith('ACTLY_'));
|
|
38
|
+
}
|
|
39
|
+
function sanitizeErrorMessageForJSON(msg) {
|
|
40
|
+
let str;
|
|
41
|
+
if (msg instanceof Error) {
|
|
42
|
+
str = String(msg.message ?? '');
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
str = String(msg ?? '');
|
|
46
|
+
}
|
|
47
|
+
if (str.length > 4096)
|
|
48
|
+
str = str.slice(0, 4096) + '…[truncated]';
|
|
49
|
+
return str.replace(/[<>]/g, (c) => (c === '<' ? '<' : '>'));
|
|
41
50
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Thrown when the caller's signal, per-attempt timeout, or total timeout
|
|
44
|
-
* aborts the operation.
|
|
45
|
-
*
|
|
46
|
-
* `cause` carries the original abort reason (e.g. user-supplied
|
|
47
|
-
* `controller.abort(new Error('user-cancelled'))` → cause.message is
|
|
48
|
-
* 'user-cancelled').
|
|
49
|
-
*
|
|
50
|
-
* Wraps the raw abort reason in a typed error so consumers can
|
|
51
|
-
* `instanceof`-check it consistently across all abort sources.
|
|
52
|
-
*/
|
|
53
51
|
export class ActlyAbortError extends ActlyError {
|
|
54
52
|
code = 'ACTLY_ABORT';
|
|
55
53
|
constructor(options) {
|
|
@@ -57,17 +55,6 @@ export class ActlyAbortError extends ActlyError {
|
|
|
57
55
|
super(`Actly operation aborted: ${causeMsg}`, options);
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Thrown when a per-attempt `timeout` deadline fires.
|
|
62
|
-
*
|
|
63
|
-
* Carries the configured `ms` so callers can log/alert precisely:
|
|
64
|
-
*
|
|
65
|
-
* ```ts
|
|
66
|
-
* if (!result.ok && result.error instanceof TimeoutError) {
|
|
67
|
-
* console.log(`attempt timed out after ${result.error.ms}ms`)
|
|
68
|
-
* }
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
58
|
export class TimeoutError extends ActlyError {
|
|
72
59
|
code = 'ACTLY_TIMEOUT';
|
|
73
60
|
ms;
|
|
@@ -76,12 +63,6 @@ export class TimeoutError extends ActlyError {
|
|
|
76
63
|
this.ms = ms;
|
|
77
64
|
}
|
|
78
65
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Thrown when the operation-wide `totalTimeout` budget fires.
|
|
81
|
-
*
|
|
82
|
-
* Distinct from `TimeoutError` (per-attempt) so callers can `instanceof`-check
|
|
83
|
-
* which deadline fired.
|
|
84
|
-
*/
|
|
85
66
|
export class TotalTimeoutError extends ActlyError {
|
|
86
67
|
code = 'ACTLY_TOTAL_TIMEOUT';
|
|
87
68
|
ms;
|
|
@@ -90,25 +71,6 @@ export class TotalTimeoutError extends ActlyError {
|
|
|
90
71
|
this.ms = ms;
|
|
91
72
|
}
|
|
92
73
|
}
|
|
93
|
-
/**
|
|
94
|
-
* Thrown when all retry attempts are exhausted. The `lastError` is the
|
|
95
|
-
* final attempt's error; `errors` is the array of all attempt errors
|
|
96
|
-
* (useful for debugging patterns across retries).
|
|
97
|
-
*
|
|
98
|
-
* Wraps retry exhaustion with context so consumers can distinguish "single
|
|
99
|
-
* fn error" from "retry exhausted after N attempts".
|
|
100
|
-
*
|
|
101
|
-
* # When is this thrown vs the raw error?
|
|
102
|
-
*
|
|
103
|
-
* `retryPolicy` throws `RetryExhaustedError` when:
|
|
104
|
-
* - `attempts > 1` AND
|
|
105
|
-
* - all attempts failed AND
|
|
106
|
-
* - the default `shouldRetry` (or user-supplied predicate) returned `true`
|
|
107
|
-
* for at least one failure
|
|
108
|
-
*
|
|
109
|
-
* If the user's `shouldRetry` returns `false` on the first attempt, the
|
|
110
|
-
* raw error is thrown (no retries happened — not "exhausted").
|
|
111
|
-
*/
|
|
112
74
|
export class RetryExhaustedError extends ActlyError {
|
|
113
75
|
code = 'ACTLY_RETRY_EXHAUSTED';
|
|
114
76
|
attempts;
|
|
@@ -122,50 +84,51 @@ export class RetryExhaustedError extends ActlyError {
|
|
|
122
84
|
this.errors = options.errors;
|
|
123
85
|
}
|
|
124
86
|
}
|
|
125
|
-
/**
|
|
126
|
-
* Thrown on invalid option shapes / keys / store contracts. Programmer
|
|
127
|
-
* errors — these surface synchronously, NOT as `ActFailure`, because the
|
|
128
|
-
* caller's code is broken.
|
|
129
|
-
*
|
|
130
|
-
* Wraps the underlying `TypeError` / `RangeError` so consumers catching
|
|
131
|
-
* `ActlyError` get a consistent type for all actly-thrown errors.
|
|
132
|
-
*/
|
|
133
87
|
export class ValidationError extends ActlyError {
|
|
134
88
|
code = 'ACTLY_VALIDATION';
|
|
135
89
|
constructor(message, options) {
|
|
136
|
-
super(message);
|
|
90
|
+
super(message, options);
|
|
137
91
|
if (options?.field !== undefined) {
|
|
138
92
|
Object.defineProperty(this, 'field', { value: options.field, enumerable: true });
|
|
139
93
|
}
|
|
140
94
|
}
|
|
141
95
|
field;
|
|
142
96
|
}
|
|
143
|
-
// ─── Hardening error classes ─────────────────────────────────────────────────
|
|
144
|
-
/** Thrown when a circuit breaker is open and blocks the call. */
|
|
145
97
|
export class CircuitBreakerOpenError extends ActlyError {
|
|
146
98
|
code = 'ACTLY_CIRCUIT_OPEN';
|
|
147
|
-
key
|
|
148
|
-
|
|
149
|
-
super(`Circuit breaker open for key "${key}" — retry after ${ms}ms`);
|
|
150
|
-
this.key = key;
|
|
99
|
+
constructor(key, ms, options) {
|
|
100
|
+
super(`Circuit breaker open for key "${key}" — retry after ${ms}ms`, { key, cause: options?.cause });
|
|
151
101
|
}
|
|
152
102
|
}
|
|
153
|
-
/** Thrown when a bulkhead is full (maxConcurrent reached, queue timed out). */
|
|
154
103
|
export class BulkheadOverflowError extends ActlyError {
|
|
155
104
|
code = 'ACTLY_BULKHEAD_FULL';
|
|
156
|
-
key
|
|
157
|
-
|
|
158
|
-
super(`Bulkhead full for key "${key}" — maxConcurrent ${maxConcurrent} reached`);
|
|
159
|
-
this.key = key;
|
|
105
|
+
constructor(key, maxConcurrent, options) {
|
|
106
|
+
super(`Bulkhead full for key "${key}" — maxConcurrent ${maxConcurrent} reached`, { key, cause: options?.cause });
|
|
160
107
|
}
|
|
161
108
|
}
|
|
162
|
-
/** Thrown when a rate limit is exceeded. */
|
|
163
109
|
export class RateLimitError extends ActlyError {
|
|
164
110
|
code = 'ACTLY_RATE_LIMIT';
|
|
165
|
-
key
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
111
|
+
constructor(key, maxCalls, windowMs, options) {
|
|
112
|
+
super(`Rate limit exceeded for key "${key}" — ${maxCalls} calls per ${windowMs}ms`, { key, cause: options?.cause });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
export class ResourceExhaustedError extends ActlyError {
|
|
116
|
+
code = 'ACTLY_RESOURCE_EXHAUSTED';
|
|
117
|
+
current;
|
|
118
|
+
limit;
|
|
119
|
+
constructor(current, limit, options) {
|
|
120
|
+
super(`Actly: resource exhausted — ${current} in-flight calls exceed process limit ${limit}. ` +
|
|
121
|
+
`Set ACTLY_NO_INFLIGHT_LIMIT=1 to disable this guard (at your own risk).`, options);
|
|
122
|
+
this.current = current;
|
|
123
|
+
this.limit = limit;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export class HedgeTimeoutError extends ActlyError {
|
|
127
|
+
code = 'ACTLY_HEDGE_TIMEOUT';
|
|
128
|
+
delayMs;
|
|
129
|
+
constructor(options) {
|
|
130
|
+
const ms = options?.delayMs ?? 0;
|
|
131
|
+
super(`ACT hedge timed out after ${ms}ms`, options);
|
|
132
|
+
this.delayMs = ms;
|
|
169
133
|
}
|
|
170
134
|
}
|
|
171
|
-
//# sourceMappingURL=errors.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,30 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// ─── Primary API ──────────────────────────────────────────────────────────────
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.poolSize = exports.releaseController = exports.acquireController = exports.sanitizeError = exports.sanitizeErrorMessage = exports.createAsyncTenantStore = exports.createTenantStore = exports.drain = exports.createHealthCheck = exports.RateLimitError = exports.BulkheadOverflowError = exports.CircuitBreakerOpenError = exports.LIMITS = exports.computeDelay = exports.sanitizeKey = exports.isAbortError = exports.linkSignal = exports.sleep = exports.raceAbort = exports.anySignal = exports.ValidationError = exports.RetryExhaustedError = exports.TotalTimeoutError = exports.TimeoutError = exports.ActlyAbortError = exports.ActlyError = exports.isAsyncStore = exports.isSyncStore = exports.InMemoryStore = exports.REQUIRES_SYNC_STORE = exports.execute = exports.withStore = exports.invalidate = exports.act = void 0;
|
|
3
|
+
exports.usePolicy = exports.noopPolicy = exports.poolSize = exports.releaseController = exports.acquireController = exports.sanitizeError = exports.sanitizeErrorMessage = exports.createAsyncTenantStore = exports.createTenantStore = exports.drainAll = exports.drain = exports.disableWatchdog = exports.unregisterWatchdogHooks = exports.registerWatchdogHooks = exports.enableWatchdog = exports.createHealthCheck = exports.ResourceExhaustedError = exports.RateLimitError = exports.BulkheadOverflowError = exports.CircuitBreakerOpenError = exports.LIMITS = exports.computeDelay = exports.sanitizeKey = exports.isAbortError = exports.linkSignal = exports.sleep = exports.raceAbort = exports.anySignal = exports.isActlyError = exports.ValidationError = exports.RetryExhaustedError = exports.TotalTimeoutError = exports.TimeoutError = exports.ActlyAbortError = exports.ActlyError = exports.isAsyncStore = exports.isSyncStore = exports.InMemoryStore = exports.REQUIRES_SYNC_STORE = exports.execute = exports.HedgeTimeoutError = exports.withStore = exports.invalidate = exports.act = void 0;
|
|
5
4
|
var act_js_1 = require("./core/act.js");
|
|
6
5
|
Object.defineProperty(exports, "act", { enumerable: true, get: function () { return act_js_1.act; } });
|
|
7
6
|
Object.defineProperty(exports, "invalidate", { enumerable: true, get: function () { return act_js_1.invalidate; } });
|
|
8
7
|
Object.defineProperty(exports, "withStore", { enumerable: true, get: function () { return act_js_1.withStore; } });
|
|
9
|
-
|
|
8
|
+
var errors_js_1 = require("./errors.js");
|
|
9
|
+
Object.defineProperty(exports, "HedgeTimeoutError", { enumerable: true, get: function () { return errors_js_1.HedgeTimeoutError; } });
|
|
10
10
|
var executor_js_1 = require("./core/executor.js");
|
|
11
11
|
Object.defineProperty(exports, "execute", { enumerable: true, get: function () { return executor_js_1.execute; } });
|
|
12
12
|
Object.defineProperty(exports, "REQUIRES_SYNC_STORE", { enumerable: true, get: function () { return executor_js_1.REQUIRES_SYNC_STORE; } });
|
|
13
|
-
// ─── Stores ───────────────────────────────────────────────────────────────────
|
|
14
13
|
var memory_js_1 = require("./stores/memory.js");
|
|
15
14
|
Object.defineProperty(exports, "InMemoryStore", { enumerable: true, get: function () { return memory_js_1.InMemoryStore; } });
|
|
16
15
|
var base_js_1 = require("./stores/base.js");
|
|
17
16
|
Object.defineProperty(exports, "isSyncStore", { enumerable: true, get: function () { return base_js_1.isSyncStore; } });
|
|
18
17
|
Object.defineProperty(exports, "isAsyncStore", { enumerable: true, get: function () { return base_js_1.isAsyncStore; } });
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Object.defineProperty(exports, "
|
|
22
|
-
Object.defineProperty(exports, "
|
|
23
|
-
Object.defineProperty(exports, "
|
|
24
|
-
Object.defineProperty(exports, "
|
|
25
|
-
Object.defineProperty(exports, "
|
|
26
|
-
Object.defineProperty(exports, "
|
|
27
|
-
// ─── Utilities (for custom policy authors) ────────────────────────────────────
|
|
18
|
+
var errors_js_2 = require("./errors.js");
|
|
19
|
+
Object.defineProperty(exports, "ActlyError", { enumerable: true, get: function () { return errors_js_2.ActlyError; } });
|
|
20
|
+
Object.defineProperty(exports, "ActlyAbortError", { enumerable: true, get: function () { return errors_js_2.ActlyAbortError; } });
|
|
21
|
+
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return errors_js_2.TimeoutError; } });
|
|
22
|
+
Object.defineProperty(exports, "TotalTimeoutError", { enumerable: true, get: function () { return errors_js_2.TotalTimeoutError; } });
|
|
23
|
+
Object.defineProperty(exports, "RetryExhaustedError", { enumerable: true, get: function () { return errors_js_2.RetryExhaustedError; } });
|
|
24
|
+
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return errors_js_2.ValidationError; } });
|
|
25
|
+
Object.defineProperty(exports, "isActlyError", { enumerable: true, get: function () { return errors_js_2.isActlyError; } });
|
|
28
26
|
var abort_js_1 = require("./utils/abort.js");
|
|
29
27
|
Object.defineProperty(exports, "anySignal", { enumerable: true, get: function () { return abort_js_1.anySignal; } });
|
|
30
28
|
Object.defineProperty(exports, "raceAbort", { enumerable: true, get: function () { return abort_js_1.raceAbort; } });
|
|
@@ -37,26 +35,31 @@ var backoff_js_1 = require("./utils/backoff.js");
|
|
|
37
35
|
Object.defineProperty(exports, "computeDelay", { enumerable: true, get: function () { return backoff_js_1.computeDelay; } });
|
|
38
36
|
var limits_js_1 = require("./utils/limits.js");
|
|
39
37
|
Object.defineProperty(exports, "LIMITS", { enumerable: true, get: function () { return limits_js_1.LIMITS; } });
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
Object.defineProperty(exports, "
|
|
43
|
-
Object.defineProperty(exports, "
|
|
44
|
-
Object.defineProperty(exports, "
|
|
45
|
-
// ─── Hardening: health check & graceful shutdown ─────────────────────────────
|
|
38
|
+
var errors_js_3 = require("./errors.js");
|
|
39
|
+
Object.defineProperty(exports, "CircuitBreakerOpenError", { enumerable: true, get: function () { return errors_js_3.CircuitBreakerOpenError; } });
|
|
40
|
+
Object.defineProperty(exports, "BulkheadOverflowError", { enumerable: true, get: function () { return errors_js_3.BulkheadOverflowError; } });
|
|
41
|
+
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return errors_js_3.RateLimitError; } });
|
|
42
|
+
Object.defineProperty(exports, "ResourceExhaustedError", { enumerable: true, get: function () { return errors_js_3.ResourceExhaustedError; } });
|
|
46
43
|
var health_js_1 = require("./core/health.js");
|
|
47
44
|
Object.defineProperty(exports, "createHealthCheck", { enumerable: true, get: function () { return health_js_1.createHealthCheck; } });
|
|
45
|
+
Object.defineProperty(exports, "enableWatchdog", { enumerable: true, get: function () { return health_js_1.enableWatchdog; } });
|
|
46
|
+
Object.defineProperty(exports, "registerWatchdogHooks", { enumerable: true, get: function () { return health_js_1.registerWatchdogHooks; } });
|
|
47
|
+
Object.defineProperty(exports, "unregisterWatchdogHooks", { enumerable: true, get: function () { return health_js_1.unregisterWatchdogHooks; } });
|
|
48
|
+
Object.defineProperty(exports, "disableWatchdog", { enumerable: true, get: function () { return health_js_1.disableWatchdog; } });
|
|
48
49
|
var shutdown_js_1 = require("./core/shutdown.js");
|
|
49
50
|
Object.defineProperty(exports, "drain", { enumerable: true, get: function () { return shutdown_js_1.drain; } });
|
|
50
|
-
|
|
51
|
+
Object.defineProperty(exports, "drainAll", { enumerable: true, get: function () { return shutdown_js_1.drainAll; } });
|
|
51
52
|
var tenant_js_1 = require("./core/tenant.js");
|
|
52
53
|
Object.defineProperty(exports, "createTenantStore", { enumerable: true, get: function () { return tenant_js_1.createTenantStore; } });
|
|
53
54
|
Object.defineProperty(exports, "createAsyncTenantStore", { enumerable: true, get: function () { return tenant_js_1.createAsyncTenantStore; } });
|
|
54
|
-
// ─── Hardening: error sanitization ───────────────────────────────────────────
|
|
55
55
|
var sanitize_js_1 = require("./utils/sanitize.js");
|
|
56
56
|
Object.defineProperty(exports, "sanitizeErrorMessage", { enumerable: true, get: function () { return sanitize_js_1.sanitizeErrorMessage; } });
|
|
57
57
|
Object.defineProperty(exports, "sanitizeError", { enumerable: true, get: function () { return sanitize_js_1.sanitizeError; } });
|
|
58
|
-
// ─── Hardening: AbortController pool ─────────────────────────────────────────
|
|
59
58
|
var abortPool_js_1 = require("./utils/abortPool.js");
|
|
60
59
|
Object.defineProperty(exports, "acquireController", { enumerable: true, get: function () { return abortPool_js_1.acquireController; } });
|
|
61
60
|
Object.defineProperty(exports, "releaseController", { enumerable: true, get: function () { return abortPool_js_1.releaseController; } });
|
|
62
61
|
Object.defineProperty(exports, "poolSize", { enumerable: true, get: function () { return abortPool_js_1.poolSize; } });
|
|
62
|
+
var noop_js_1 = require("./policies/noop.js");
|
|
63
|
+
Object.defineProperty(exports, "noopPolicy", { enumerable: true, get: function () { return noop_js_1.noopPolicy; } });
|
|
64
|
+
var decorator_js_1 = require("./utils/decorator.js");
|
|
65
|
+
Object.defineProperty(exports, "usePolicy", { enumerable: true, get: function () { return decorator_js_1.usePolicy; } });
|
package/dist/index.d.ts
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
export { act, invalidate, withStore, } from './core/act.js';
|
|
2
2
|
export type { ScopedActSync, ScopedActAsync, } from './core/act.js';
|
|
3
|
+
export { HedgeTimeoutError, } from './errors.js';
|
|
3
4
|
export { execute, REQUIRES_SYNC_STORE, } from './core/executor.js';
|
|
5
|
+
export type { ExecutorInput, } from './core/executor.js';
|
|
6
|
+
export type { ObservabilityContext, } from './observability.js';
|
|
4
7
|
export { InMemoryStore } from './stores/memory.js';
|
|
5
8
|
export type { InMemoryStoreOptions } from './stores/memory.js';
|
|
6
9
|
export { isSyncStore, isAsyncStore, } from './stores/base.js';
|
|
7
|
-
export { ActlyError, ActlyAbortError, TimeoutError, TotalTimeoutError, RetryExhaustedError, ValidationError, } from './errors.js';
|
|
8
|
-
export type { ActlyEventType, ActlyEventBase, AttemptEvent, RetryEvent, CacheHitEvent, CacheMissEvent, DedupeJoinEvent, TimeoutEvent, FinalSuccessEvent, FinalFailureEvent, ActlyEvent, ObservabilityHooks, } from './observability.js';
|
|
9
|
-
export type { ActFn, ActResult, ActSuccess, ActFailure, ActSource, ActOptions, RetryOptions, TimeoutOptions, DedupeOptions, CacheOptions, PolicyApplier, PolicyContext, RunMeta, StateStore,
|
|
10
|
-
SyncStateStore, AsyncStateStore, AnyStateStore, } from './types/index.js';
|
|
10
|
+
export { ActlyError, ActlyAbortError, TimeoutError, TotalTimeoutError, RetryExhaustedError, ValidationError, isActlyError, } from './errors.js';
|
|
11
|
+
export type { ActlyEventType, ActlyEventBase, AttemptEvent, RetryEvent, CacheHitEvent, CacheMissEvent, DedupeJoinEvent, TimeoutEvent, FinalSuccessEvent, FinalFailureEvent, BackpressureEvent, WatchdogEvent, ActlyEvent, ObservabilityHooks, } from './observability.js';
|
|
12
|
+
export type { ActFn, ActResult, ActSuccess, ActFailure, ActSource, ActOptions, RetryOptions, TimeoutOptions, DedupeOptions, CacheOptions, PolicyApplier, PolicyContext, RunMeta, StateStore, SyncStateStore, AsyncStateStore, AnyStateStore, } from './types/index.js';
|
|
11
13
|
export { anySignal, raceAbort, sleep, linkSignal, isAbortError, } from './utils/abort.js';
|
|
12
14
|
export { sanitizeKey, } from './utils/key.js';
|
|
13
15
|
export { computeDelay, } from './utils/backoff.js';
|
|
14
16
|
export { LIMITS, } from './utils/limits.js';
|
|
15
17
|
export type { Limits } from './utils/limits.js';
|
|
16
|
-
export { CircuitBreakerOpenError, BulkheadOverflowError, RateLimitError, } from './errors.js';
|
|
17
|
-
export { createHealthCheck, } from './core/health.js';
|
|
18
|
-
export type { HealthStatus } from './core/health.js';
|
|
19
|
-
export { drain, } from './core/shutdown.js';
|
|
18
|
+
export { CircuitBreakerOpenError, BulkheadOverflowError, RateLimitError, ResourceExhaustedError, } from './errors.js';
|
|
19
|
+
export { createHealthCheck, enableWatchdog, registerWatchdogHooks, unregisterWatchdogHooks, disableWatchdog, } from './core/health.js';
|
|
20
|
+
export type { HealthStatus, HealthCheckFn } from './core/health.js';
|
|
21
|
+
export { drain, drainAll, } from './core/shutdown.js';
|
|
20
22
|
export { createTenantStore, createAsyncTenantStore, } from './core/tenant.js';
|
|
21
23
|
export type { TenantStoreOptions, TenantManager } from './core/tenant.js';
|
|
22
24
|
export { sanitizeErrorMessage, sanitizeError, } from './utils/sanitize.js';
|
|
23
25
|
export { acquireController, releaseController, poolSize, } from './utils/abortPool.js';
|
|
24
26
|
export type { CircuitBreakerOptions, BulkheadOptions, RateLimitOptions, HedgeOptions, FallbackOptions, AuditOptions, AuditEntry, } from './types/index.js';
|
|
27
|
+
export { noopPolicy, } from './policies/noop.js';
|
|
28
|
+
export { usePolicy, } from './utils/decorator.js';
|
|
25
29
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,GAAG,EACH,UAAU,EACV,SAAS,GACV,MAAM,eAAe,CAAA;AAEtB,YAAY,EACV,aAAa,EACb,cAAc,GACf,MAAM,eAAe,CAAA;AAItB,OAAO,EACL,OAAO,EACP,mBAAmB,GACpB,MAAM,oBAAoB,CAAA;AAI3B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAE9D,OAAO,EACL,WAAW,EACX,YAAY,GACb,MAAM,kBAAkB,CAAA;AAIzB,OAAO,EACL,UAAU,EACV,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,GAAG,EACH,UAAU,EACV,SAAS,GACV,MAAM,eAAe,CAAA;AAEtB,YAAY,EACV,aAAa,EACb,cAAc,GACf,MAAM,eAAe,CAAA;AAItB,OAAO,EACL,iBAAiB,GAClB,MAAM,aAAa,CAAA;AAIpB,OAAO,EACL,OAAO,EACP,mBAAmB,GACpB,MAAM,oBAAoB,CAAA;AAI3B,YAAY,EACV,aAAa,GACd,MAAM,oBAAoB,CAAA;AAI3B,YAAY,EACV,oBAAoB,GACrB,MAAM,oBAAoB,CAAA;AAI3B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAE9D,OAAO,EACL,WAAW,EACX,YAAY,GACb,MAAM,kBAAkB,CAAA;AAIzB,OAAO,EACL,UAAU,EACV,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,YAAY,GACb,MAAM,aAAa,CAAA;AAIpB,YAAY,EACV,cAAc,EACd,cAAc,EACd,YAAY,EACZ,UAAU,EACV,aAAa,EACb,cAAc,EACd,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,kBAAkB,GACnB,MAAM,oBAAoB,CAAA;AAI3B,YAAY,EAEV,KAAK,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,EACT,UAAU,EAGV,YAAY,EACZ,cAAc,EACd,aAAa,EACb,YAAY,EAGZ,aAAa,EACb,aAAa,EACb,OAAO,EAGP,UAAU,EACV,cAAc,EACd,eAAe,EACf,aAAa,GACd,MAAM,kBAAkB,CAAA;AAIzB,OAAO,EACL,SAAS,EACT,SAAS,EACT,KAAK,EACL,UAAU,EACV,YAAY,GACb,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EACL,WAAW,GACZ,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EACL,YAAY,GACb,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EACL,MAAM,GACP,MAAM,mBAAmB,CAAA;AAE1B,YAAY,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAI/C,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,cAAc,EACd,sBAAsB,GACvB,MAAM,aAAa,CAAA;AAGpB,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,eAAe,GAChB,MAAM,kBAAkB,CAAA;AACzB,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEnE,OAAO,EACL,KAAK,EACL,QAAQ,GACT,MAAM,oBAAoB,CAAA;AAI3B,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,kBAAkB,CAAA;AACzB,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAIzE,OAAO,EACL,oBAAoB,EACpB,aAAa,GACd,MAAM,qBAAqB,CAAA;AAI5B,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,QAAQ,GACT,MAAM,sBAAsB,CAAA;AAI7B,YAAY,EACV,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,UAAU,GACX,MAAM,kBAAkB,CAAA;AAIzB,OAAO,EACL,UAAU,GACX,MAAM,oBAAoB,CAAA;AAI3B,OAAO,EACL,SAAS,GACV,MAAM,sBAAsB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,18 @@
|
|
|
1
|
-
// ─── Primary API ──────────────────────────────────────────────────────────────
|
|
2
1
|
export { act, invalidate, withStore, } from './core/act.js';
|
|
3
|
-
|
|
2
|
+
export { HedgeTimeoutError, } from './errors.js';
|
|
4
3
|
export { execute, REQUIRES_SYNC_STORE, } from './core/executor.js';
|
|
5
|
-
// ─── Stores ───────────────────────────────────────────────────────────────────
|
|
6
4
|
export { InMemoryStore } from './stores/memory.js';
|
|
7
5
|
export { isSyncStore, isAsyncStore, } from './stores/base.js';
|
|
8
|
-
|
|
9
|
-
export { ActlyError, ActlyAbortError, TimeoutError, TotalTimeoutError, RetryExhaustedError, ValidationError, } from './errors.js';
|
|
10
|
-
// ─── Utilities (for custom policy authors) ────────────────────────────────────
|
|
6
|
+
export { ActlyError, ActlyAbortError, TimeoutError, TotalTimeoutError, RetryExhaustedError, ValidationError, isActlyError, } from './errors.js';
|
|
11
7
|
export { anySignal, raceAbort, sleep, linkSignal, isAbortError, } from './utils/abort.js';
|
|
12
8
|
export { sanitizeKey, } from './utils/key.js';
|
|
13
9
|
export { computeDelay, } from './utils/backoff.js';
|
|
14
10
|
export { LIMITS, } from './utils/limits.js';
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
|
|
18
|
-
export { createHealthCheck, } from './core/health.js';
|
|
19
|
-
export { drain, } from './core/shutdown.js';
|
|
20
|
-
// ─── Hardening: tenant isolation ─────────────────────────────────────────────
|
|
11
|
+
export { CircuitBreakerOpenError, BulkheadOverflowError, RateLimitError, ResourceExhaustedError, } from './errors.js';
|
|
12
|
+
export { createHealthCheck, enableWatchdog, registerWatchdogHooks, unregisterWatchdogHooks, disableWatchdog, } from './core/health.js';
|
|
13
|
+
export { drain, drainAll, } from './core/shutdown.js';
|
|
21
14
|
export { createTenantStore, createAsyncTenantStore, } from './core/tenant.js';
|
|
22
|
-
// ─── Hardening: error sanitization ───────────────────────────────────────────
|
|
23
15
|
export { sanitizeErrorMessage, sanitizeError, } from './utils/sanitize.js';
|
|
24
|
-
// ─── Hardening: AbortController pool ─────────────────────────────────────────
|
|
25
16
|
export { acquireController, releaseController, poolSize, } from './utils/abortPool.js';
|
|
26
|
-
|
|
17
|
+
export { noopPolicy, } from './policies/noop.js';
|
|
18
|
+
export { usePolicy, } from './utils/decorator.js';
|
package/dist/observability.cjs
CHANGED
|
@@ -1,45 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Observability hooks.
|
|
4
|
-
*
|
|
5
|
-
* Eight event types covering the entire lifecycle of an `act()` call.
|
|
6
|
-
*
|
|
7
|
-
* # Contract
|
|
8
|
-
*
|
|
9
|
-
* When `options.observability` is `null`/`undefined` (the common case),
|
|
10
|
-
* no event objects are allocated and no function calls are made. The
|
|
11
|
-
* hot path is a single null-check per policy decision.
|
|
12
|
-
*
|
|
13
|
-
* When hooks ARE registered, events are allocated lazily — only when the
|
|
14
|
-
* corresponding event actually fires. A cache hit doesn't allocate an
|
|
15
|
-
* `onRetry` event, for example.
|
|
16
|
-
*
|
|
17
|
-
* # Event shape
|
|
18
|
-
*
|
|
19
|
-
* Every event carries `key`, `traceId`, and `timestamp` for correlation.
|
|
20
|
-
* Event-specific fields are on the same object (no nesting) for flat
|
|
21
|
-
* destructuring in user code.
|
|
22
|
-
*
|
|
23
|
-
* # Ordering
|
|
24
|
-
*
|
|
25
|
-
* For a successful fresh call with retries:
|
|
26
|
-
* onAttempt (1) → onAttempt (2) → onRetry (1→2) → onAttempt (3) → onFinalSuccess
|
|
27
|
-
*
|
|
28
|
-
* For a cache hit:
|
|
29
|
-
* onCacheHit → onFinalSuccess
|
|
30
|
-
*
|
|
31
|
-
* For a dedupe joiner:
|
|
32
|
-
* onDedupeJoin → onFinalSuccess (or onFinalFailure)
|
|
33
|
-
*
|
|
34
|
-
* For a timeout:
|
|
35
|
-
* onAttempt → onTimeout → onFinalFailure
|
|
36
|
-
*/
|
|
37
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
3
|
exports.hasObservers = hasObservers;
|
|
39
|
-
/**
|
|
40
|
-
* Quick null-check helper. Policies call this once at decision points; if
|
|
41
|
-
* it returns false, no further observability work is done.
|
|
42
|
-
*/
|
|
43
4
|
function hasObservers(ctx) {
|
|
44
5
|
return ctx.observability != null;
|
|
45
6
|
}
|