actly 1.1.0 → 1.2.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/LICENSE +0 -0
- package/README.md +262 -232
- package/dist/core/act.cjs +505 -39
- package/dist/core/act.d.ts +81 -10
- package/dist/core/act.d.ts.map +1 -1
- package/dist/core/act.js +504 -40
- package/dist/core/act.js.map +1 -1
- package/dist/core/executor.cjs +21 -9
- package/dist/core/executor.d.ts +31 -6
- package/dist/core/executor.d.ts.map +1 -1
- package/dist/core/executor.js +21 -9
- package/dist/core/executor.js.map +1 -1
- package/dist/core/health.cjs +34 -0
- package/dist/core/health.d.ts +18 -0
- package/dist/core/health.d.ts.map +1 -0
- package/dist/core/health.js +28 -0
- package/dist/core/health.js.map +1 -0
- package/dist/core/shutdown.cjs +60 -0
- package/dist/core/shutdown.d.ts +8 -0
- package/dist/core/shutdown.d.ts.map +1 -0
- package/dist/core/shutdown.js +56 -0
- package/dist/core/shutdown.js.map +1 -0
- package/dist/core/tenant.cjs +71 -0
- package/dist/core/tenant.d.ts +29 -0
- package/dist/core/tenant.d.ts.map +1 -0
- package/dist/core/tenant.js +68 -0
- package/dist/core/tenant.js.map +1 -0
- package/dist/errors.cjs +182 -0
- package/dist/errors.d.ts +151 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +171 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.cjs +56 -6
- package/dist/index.d.ts +22 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -4
- package/dist/index.js.map +1 -1
- package/dist/observability.cjs +45 -0
- package/dist/observability.d.ts +145 -0
- package/dist/observability.d.ts.map +1 -0
- package/dist/observability.js +43 -0
- package/dist/observability.js.map +1 -0
- package/dist/policies/bulkhead.cjs +97 -0
- package/dist/policies/bulkhead.d.ts +3 -0
- package/dist/policies/bulkhead.d.ts.map +1 -0
- package/dist/policies/bulkhead.js +95 -0
- package/dist/policies/bulkhead.js.map +1 -0
- package/dist/policies/cache.cjs +223 -22
- package/dist/policies/cache.d.ts +42 -7
- package/dist/policies/cache.d.ts.map +1 -1
- package/dist/policies/cache.js +223 -22
- package/dist/policies/cache.js.map +1 -1
- package/dist/policies/circuitBreaker.cjs +85 -0
- package/dist/policies/circuitBreaker.d.ts +3 -0
- package/dist/policies/circuitBreaker.d.ts.map +1 -0
- package/dist/policies/circuitBreaker.js +83 -0
- package/dist/policies/circuitBreaker.js.map +1 -0
- package/dist/policies/dedupe.cjs +98 -21
- package/dist/policies/dedupe.d.ts +20 -13
- package/dist/policies/dedupe.d.ts.map +1 -1
- package/dist/policies/dedupe.js +98 -21
- package/dist/policies/dedupe.js.map +1 -1
- package/dist/policies/rateLimit.cjs +35 -0
- package/dist/policies/rateLimit.d.ts +3 -0
- package/dist/policies/rateLimit.d.ts.map +1 -0
- package/dist/policies/rateLimit.js +33 -0
- package/dist/policies/rateLimit.js.map +1 -0
- package/dist/policies/retry.cjs +103 -26
- package/dist/policies/retry.d.ts +25 -2
- package/dist/policies/retry.d.ts.map +1 -1
- package/dist/policies/retry.js +103 -26
- package/dist/policies/retry.js.map +1 -1
- package/dist/policies/timeout.cjs +78 -36
- package/dist/policies/timeout.d.ts +7 -18
- package/dist/policies/timeout.d.ts.map +1 -1
- package/dist/policies/timeout.js +84 -31
- package/dist/policies/timeout.js.map +1 -1
- package/dist/state/store.cjs +9 -2
- package/dist/state/store.d.ts +9 -0
- package/dist/state/store.d.ts.map +1 -1
- package/dist/state/store.js +9 -2
- package/dist/state/store.js.map +1 -1
- package/dist/stores/base.cjs +4 -4
- package/dist/stores/base.d.ts +32 -56
- package/dist/stores/base.d.ts.map +1 -1
- package/dist/stores/base.js +4 -4
- package/dist/stores/base.js.map +1 -1
- package/dist/stores/memory.cjs +161 -39
- package/dist/stores/memory.d.ts +64 -24
- package/dist/stores/memory.d.ts.map +1 -1
- package/dist/stores/memory.js +160 -39
- package/dist/stores/memory.js.map +1 -1
- package/dist/types/index.d.ts +315 -37
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/abort.cjs +212 -0
- package/dist/utils/abort.d.ts +79 -0
- package/dist/utils/abort.d.ts.map +1 -0
- package/dist/utils/abort.js +206 -0
- package/dist/utils/abort.js.map +1 -0
- package/dist/utils/abortPool.cjs +26 -0
- package/dist/utils/abortPool.d.ts +4 -0
- package/dist/utils/abortPool.d.ts.map +1 -0
- package/dist/utils/abortPool.js +22 -0
- package/dist/utils/abortPool.js.map +1 -0
- package/dist/utils/backoff.cjs +54 -0
- package/dist/utils/backoff.d.ts +14 -0
- package/dist/utils/backoff.d.ts.map +1 -0
- package/dist/utils/backoff.js +52 -0
- package/dist/utils/backoff.js.map +1 -0
- package/dist/utils/key.cjs +77 -0
- package/dist/utils/key.d.ts +29 -0
- package/dist/utils/key.d.ts.map +1 -0
- package/dist/utils/key.js +75 -0
- package/dist/utils/key.js.map +1 -0
- package/dist/utils/limits.cjs +40 -0
- package/dist/utils/limits.d.ts +39 -0
- package/dist/utils/limits.d.ts.map +1 -0
- package/dist/utils/limits.js +38 -0
- package/dist/utils/limits.js.map +1 -0
- package/dist/utils/sanitize.cjs +29 -0
- package/dist/utils/sanitize.d.ts +3 -0
- package/dist/utils/sanitize.d.ts.map +1 -0
- package/dist/utils/sanitize.js +26 -0
- package/dist/utils/sanitize.js.map +1 -0
- package/dist/utils/validate.cjs +153 -0
- package/dist/utils/validate.d.ts +26 -0
- package/dist/utils/validate.d.ts.map +1 -0
- package/dist/utils/validate.js +141 -0
- package/dist/utils/validate.js.map +1 -0
- package/package.json +20 -37
package/dist/errors.cjs
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Actly error taxonomy.
|
|
4
|
+
*
|
|
5
|
+
* Six classes (one abstract base + five concrete). Each carries a stable
|
|
6
|
+
* `code` field so consumers can switch on strings instead of brittle
|
|
7
|
+
* `instanceof` chains across realm boundaries (e.g. errors serialised
|
|
8
|
+
* over IPC).
|
|
9
|
+
*
|
|
10
|
+
* # Why these six?
|
|
11
|
+
*
|
|
12
|
+
* - `ActlyError` — abstract base for `instanceof ActlyError` checks
|
|
13
|
+
* - `ActlyAbortError` — caller / signal cancellation
|
|
14
|
+
* - `TimeoutError` — per-attempt deadline
|
|
15
|
+
* - `TotalTimeoutError` — operation-wide budget
|
|
16
|
+
* - `RetryExhaustedError`— last attempt's error wrapped with context
|
|
17
|
+
* - `ValidationError` — programmer error (invalid options)
|
|
18
|
+
*
|
|
19
|
+
* NO circuit/bulkhead/rate-limit errors — those policies don't exist in
|
|
20
|
+
* core. Adding orphan error classes violates the "every feature must map
|
|
21
|
+
* to a real runtime failure mode" rule.
|
|
22
|
+
*
|
|
23
|
+
* # `code` field
|
|
24
|
+
*
|
|
25
|
+
* Stable string identifier. Use this for switch statements and telemetry
|
|
26
|
+
* tags. The class name can change across versions; `code` won't.
|
|
27
|
+
*/
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.RateLimitError = exports.BulkheadOverflowError = exports.CircuitBreakerOpenError = exports.ValidationError = exports.RetryExhaustedError = exports.TotalTimeoutError = exports.TimeoutError = exports.ActlyAbortError = exports.ActlyError = void 0;
|
|
30
|
+
/** Base class for all actly errors. Enables `instanceof ActlyError` checks. */
|
|
31
|
+
class ActlyError extends Error {
|
|
32
|
+
/** The key associated with the failure, if applicable. */
|
|
33
|
+
key;
|
|
34
|
+
constructor(message, options) {
|
|
35
|
+
super(message, options?.cause !== undefined ? { cause: options.cause } : undefined);
|
|
36
|
+
this.name = new.target.name;
|
|
37
|
+
if (options?.key !== undefined) {
|
|
38
|
+
Object.defineProperty(this, 'key', { value: options.key, enumerable: true });
|
|
39
|
+
}
|
|
40
|
+
// Restore prototype chain after Error inheritance (TS es2022 target
|
|
41
|
+
// may strip it). This ensures `instanceof` works correctly.
|
|
42
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.ActlyError = ActlyError;
|
|
46
|
+
/**
|
|
47
|
+
* Thrown when the caller's signal, per-attempt timeout, or total timeout
|
|
48
|
+
* aborts the operation.
|
|
49
|
+
*
|
|
50
|
+
* `cause` carries the original abort reason (e.g. user-supplied
|
|
51
|
+
* `controller.abort(new Error('user-cancelled'))` → cause.message is
|
|
52
|
+
* 'user-cancelled').
|
|
53
|
+
*
|
|
54
|
+
* Wraps the raw abort reason in a typed error so consumers can
|
|
55
|
+
* `instanceof`-check it consistently across all abort sources.
|
|
56
|
+
*/
|
|
57
|
+
class ActlyAbortError extends ActlyError {
|
|
58
|
+
code = 'ACTLY_ABORT';
|
|
59
|
+
constructor(options) {
|
|
60
|
+
const causeMsg = options?.cause instanceof Error ? options.cause.message : String(options?.cause ?? 'aborted');
|
|
61
|
+
super(`Actly operation aborted: ${causeMsg}`, options);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.ActlyAbortError = ActlyAbortError;
|
|
65
|
+
/**
|
|
66
|
+
* Thrown when a per-attempt `timeout` deadline fires.
|
|
67
|
+
*
|
|
68
|
+
* Carries the configured `ms` so callers can log/alert precisely:
|
|
69
|
+
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* if (!result.ok && result.error instanceof TimeoutError) {
|
|
72
|
+
* console.log(`attempt timed out after ${result.error.ms}ms`)
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
class TimeoutError extends ActlyError {
|
|
77
|
+
code = 'ACTLY_TIMEOUT';
|
|
78
|
+
ms;
|
|
79
|
+
constructor(ms, options) {
|
|
80
|
+
super(`ACT timed out after ${ms}ms`, options);
|
|
81
|
+
this.ms = ms;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.TimeoutError = TimeoutError;
|
|
85
|
+
/**
|
|
86
|
+
* Thrown when the operation-wide `totalTimeout` budget fires.
|
|
87
|
+
*
|
|
88
|
+
* Distinct from `TimeoutError` (per-attempt) so callers can `instanceof`-check
|
|
89
|
+
* which deadline fired.
|
|
90
|
+
*/
|
|
91
|
+
class TotalTimeoutError extends ActlyError {
|
|
92
|
+
code = 'ACTLY_TOTAL_TIMEOUT';
|
|
93
|
+
ms;
|
|
94
|
+
constructor(ms, options) {
|
|
95
|
+
super(`ACT total timeout exceeded after ${ms}ms`, options);
|
|
96
|
+
this.ms = ms;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.TotalTimeoutError = TotalTimeoutError;
|
|
100
|
+
/**
|
|
101
|
+
* Thrown when all retry attempts are exhausted. The `lastError` is the
|
|
102
|
+
* final attempt's error; `errors` is the array of all attempt errors
|
|
103
|
+
* (useful for debugging patterns across retries).
|
|
104
|
+
*
|
|
105
|
+
* Wraps retry exhaustion with context so consumers can distinguish "single
|
|
106
|
+
* fn error" from "retry exhausted after N attempts".
|
|
107
|
+
*
|
|
108
|
+
* # When is this thrown vs the raw error?
|
|
109
|
+
*
|
|
110
|
+
* `retryPolicy` throws `RetryExhaustedError` when:
|
|
111
|
+
* - `attempts > 1` AND
|
|
112
|
+
* - all attempts failed AND
|
|
113
|
+
* - the default `shouldRetry` (or user-supplied predicate) returned `true`
|
|
114
|
+
* for at least one failure
|
|
115
|
+
*
|
|
116
|
+
* If the user's `shouldRetry` returns `false` on the first attempt, the
|
|
117
|
+
* raw error is thrown (no retries happened — not "exhausted").
|
|
118
|
+
*/
|
|
119
|
+
class RetryExhaustedError extends ActlyError {
|
|
120
|
+
code = 'ACTLY_RETRY_EXHAUSTED';
|
|
121
|
+
attempts;
|
|
122
|
+
lastError;
|
|
123
|
+
errors;
|
|
124
|
+
constructor(options) {
|
|
125
|
+
const lastMsg = options.lastError instanceof Error ? options.lastError.message : String(options.lastError);
|
|
126
|
+
super(`ACT retry exhausted after ${options.attempts} attempts; last error: ${lastMsg}`, { key: options.key, cause: options.lastError });
|
|
127
|
+
this.attempts = options.attempts;
|
|
128
|
+
this.lastError = options.lastError;
|
|
129
|
+
this.errors = options.errors;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.RetryExhaustedError = RetryExhaustedError;
|
|
133
|
+
/**
|
|
134
|
+
* Thrown on invalid option shapes / keys / store contracts. Programmer
|
|
135
|
+
* errors — these surface synchronously, NOT as `ActFailure`, because the
|
|
136
|
+
* caller's code is broken.
|
|
137
|
+
*
|
|
138
|
+
* Wraps the underlying `TypeError` / `RangeError` so consumers catching
|
|
139
|
+
* `ActlyError` get a consistent type for all actly-thrown errors.
|
|
140
|
+
*/
|
|
141
|
+
class ValidationError extends ActlyError {
|
|
142
|
+
code = 'ACTLY_VALIDATION';
|
|
143
|
+
constructor(message, options) {
|
|
144
|
+
super(message);
|
|
145
|
+
if (options?.field !== undefined) {
|
|
146
|
+
Object.defineProperty(this, 'field', { value: options.field, enumerable: true });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
field;
|
|
150
|
+
}
|
|
151
|
+
exports.ValidationError = ValidationError;
|
|
152
|
+
// ─── Hardening error classes ─────────────────────────────────────────────────
|
|
153
|
+
/** Thrown when a circuit breaker is open and blocks the call. */
|
|
154
|
+
class CircuitBreakerOpenError extends ActlyError {
|
|
155
|
+
code = 'ACTLY_CIRCUIT_OPEN';
|
|
156
|
+
key;
|
|
157
|
+
constructor(key, ms) {
|
|
158
|
+
super(`Circuit breaker open for key "${key}" — retry after ${ms}ms`);
|
|
159
|
+
this.key = key;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
exports.CircuitBreakerOpenError = CircuitBreakerOpenError;
|
|
163
|
+
/** Thrown when a bulkhead is full (maxConcurrent reached, queue timed out). */
|
|
164
|
+
class BulkheadOverflowError extends ActlyError {
|
|
165
|
+
code = 'ACTLY_BULKHEAD_FULL';
|
|
166
|
+
key;
|
|
167
|
+
constructor(key, maxConcurrent) {
|
|
168
|
+
super(`Bulkhead full for key "${key}" — maxConcurrent ${maxConcurrent} reached`);
|
|
169
|
+
this.key = key;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
exports.BulkheadOverflowError = BulkheadOverflowError;
|
|
173
|
+
/** Thrown when a rate limit is exceeded. */
|
|
174
|
+
class RateLimitError extends ActlyError {
|
|
175
|
+
code = 'ACTLY_RATE_LIMIT';
|
|
176
|
+
key;
|
|
177
|
+
constructor(key, maxCalls, windowMs) {
|
|
178
|
+
super(`Rate limit exceeded for key "${key}" — ${maxCalls} calls per ${windowMs}ms`);
|
|
179
|
+
this.key = key;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
exports.RateLimitError = RateLimitError;
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
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
|
+
export declare abstract class ActlyError extends Error {
|
|
29
|
+
/** Stable string identifier. Use for telemetry / switch statements. */
|
|
30
|
+
abstract readonly code: string;
|
|
31
|
+
/** The key associated with the failure, if applicable. */
|
|
32
|
+
readonly key?: string;
|
|
33
|
+
constructor(message: string, options?: {
|
|
34
|
+
key?: string;
|
|
35
|
+
cause?: unknown;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
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
|
+
*/
|
|
49
|
+
export declare class ActlyAbortError extends ActlyError {
|
|
50
|
+
readonly code: "ACTLY_ABORT";
|
|
51
|
+
constructor(options?: {
|
|
52
|
+
key?: string;
|
|
53
|
+
cause?: unknown;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
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
|
+
export declare class TimeoutError extends ActlyError {
|
|
68
|
+
readonly code: "ACTLY_TIMEOUT";
|
|
69
|
+
readonly ms: number;
|
|
70
|
+
constructor(ms: number, options?: {
|
|
71
|
+
key?: string;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
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
|
+
export declare class TotalTimeoutError extends ActlyError {
|
|
81
|
+
readonly code: "ACTLY_TOTAL_TIMEOUT";
|
|
82
|
+
readonly ms: number;
|
|
83
|
+
constructor(ms: number, options?: {
|
|
84
|
+
key?: string;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
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
|
+
export declare class RetryExhaustedError extends ActlyError {
|
|
107
|
+
readonly code: "ACTLY_RETRY_EXHAUSTED";
|
|
108
|
+
readonly attempts: number;
|
|
109
|
+
readonly lastError: unknown;
|
|
110
|
+
readonly errors: readonly unknown[];
|
|
111
|
+
constructor(options: {
|
|
112
|
+
key?: string;
|
|
113
|
+
attempts: number;
|
|
114
|
+
lastError: unknown;
|
|
115
|
+
errors: readonly unknown[];
|
|
116
|
+
});
|
|
117
|
+
}
|
|
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
|
+
export declare class ValidationError extends ActlyError {
|
|
127
|
+
readonly code: "ACTLY_VALIDATION";
|
|
128
|
+
constructor(message: string, options?: {
|
|
129
|
+
field?: string;
|
|
130
|
+
});
|
|
131
|
+
readonly field?: string;
|
|
132
|
+
}
|
|
133
|
+
/** Thrown when a circuit breaker is open and blocks the call. */
|
|
134
|
+
export declare class CircuitBreakerOpenError extends ActlyError {
|
|
135
|
+
readonly code: "ACTLY_CIRCUIT_OPEN";
|
|
136
|
+
readonly key: string;
|
|
137
|
+
constructor(key: string, ms: number);
|
|
138
|
+
}
|
|
139
|
+
/** Thrown when a bulkhead is full (maxConcurrent reached, queue timed out). */
|
|
140
|
+
export declare class BulkheadOverflowError extends ActlyError {
|
|
141
|
+
readonly code: "ACTLY_BULKHEAD_FULL";
|
|
142
|
+
readonly key: string;
|
|
143
|
+
constructor(key: string, maxConcurrent: number);
|
|
144
|
+
}
|
|
145
|
+
/** Thrown when a rate limit is exceeded. */
|
|
146
|
+
export declare class RateLimitError extends ActlyError {
|
|
147
|
+
readonly code: "ACTLY_RATE_LIMIT";
|
|
148
|
+
readonly key: string;
|
|
149
|
+
constructor(key: string, maxCalls: number, windowMs: number);
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,+EAA+E;AAC/E,8BAAsB,UAAW,SAAQ,KAAK;IAC5C,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAC9B,0DAA0D;IAC1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O,CAAA;QAClB,MAAM,EAAE,SAAS,OAAO,EAAE,CAAA;KAC3B;CAWF;AAED;;;;;;;GAOG;AACH,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,QAAQ,CAAC,IAAI,EAAG,kBAAkB,CAAS;gBAE/B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;IAMzD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB;AAID,iEAAiE;AACjE,qBAAa,uBAAwB,SAAQ,UAAU;IACrD,QAAQ,CAAC,IAAI,EAAG,oBAAoB,CAAS;IAC7C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;gBAER,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;CAIpC;AAED,+EAA+E;AAC/E,qBAAa,qBAAsB,SAAQ,UAAU;IACnD,QAAQ,CAAC,IAAI,EAAG,qBAAqB,CAAS;IAC9C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;gBAER,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;CAI/C;AAED,4CAA4C;AAC5C,qBAAa,cAAe,SAAQ,UAAU;IAC5C,QAAQ,CAAC,IAAI,EAAG,kBAAkB,CAAS;IAC3C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;gBAER,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAI5D"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
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
|
+
export class ActlyError extends Error {
|
|
29
|
+
/** The key associated with the failure, if applicable. */
|
|
30
|
+
key;
|
|
31
|
+
constructor(message, options) {
|
|
32
|
+
super(message, options?.cause !== undefined ? { cause: options.cause } : undefined);
|
|
33
|
+
this.name = new.target.name;
|
|
34
|
+
if (options?.key !== undefined) {
|
|
35
|
+
Object.defineProperty(this, 'key', { value: options.key, enumerable: true });
|
|
36
|
+
}
|
|
37
|
+
// Restore prototype chain after Error inheritance (TS es2022 target
|
|
38
|
+
// may strip it). This ensures `instanceof` works correctly.
|
|
39
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
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
|
+
export class ActlyAbortError extends ActlyError {
|
|
54
|
+
code = 'ACTLY_ABORT';
|
|
55
|
+
constructor(options) {
|
|
56
|
+
const causeMsg = options?.cause instanceof Error ? options.cause.message : String(options?.cause ?? 'aborted');
|
|
57
|
+
super(`Actly operation aborted: ${causeMsg}`, options);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
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
|
+
export class TimeoutError extends ActlyError {
|
|
72
|
+
code = 'ACTLY_TIMEOUT';
|
|
73
|
+
ms;
|
|
74
|
+
constructor(ms, options) {
|
|
75
|
+
super(`ACT timed out after ${ms}ms`, options);
|
|
76
|
+
this.ms = ms;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
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
|
+
export class TotalTimeoutError extends ActlyError {
|
|
86
|
+
code = 'ACTLY_TOTAL_TIMEOUT';
|
|
87
|
+
ms;
|
|
88
|
+
constructor(ms, options) {
|
|
89
|
+
super(`ACT total timeout exceeded after ${ms}ms`, options);
|
|
90
|
+
this.ms = ms;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
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
|
+
export class RetryExhaustedError extends ActlyError {
|
|
113
|
+
code = 'ACTLY_RETRY_EXHAUSTED';
|
|
114
|
+
attempts;
|
|
115
|
+
lastError;
|
|
116
|
+
errors;
|
|
117
|
+
constructor(options) {
|
|
118
|
+
const lastMsg = options.lastError instanceof Error ? options.lastError.message : String(options.lastError);
|
|
119
|
+
super(`ACT retry exhausted after ${options.attempts} attempts; last error: ${lastMsg}`, { key: options.key, cause: options.lastError });
|
|
120
|
+
this.attempts = options.attempts;
|
|
121
|
+
this.lastError = options.lastError;
|
|
122
|
+
this.errors = options.errors;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
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
|
+
export class ValidationError extends ActlyError {
|
|
134
|
+
code = 'ACTLY_VALIDATION';
|
|
135
|
+
constructor(message, options) {
|
|
136
|
+
super(message);
|
|
137
|
+
if (options?.field !== undefined) {
|
|
138
|
+
Object.defineProperty(this, 'field', { value: options.field, enumerable: true });
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
field;
|
|
142
|
+
}
|
|
143
|
+
// ─── Hardening error classes ─────────────────────────────────────────────────
|
|
144
|
+
/** Thrown when a circuit breaker is open and blocks the call. */
|
|
145
|
+
export class CircuitBreakerOpenError extends ActlyError {
|
|
146
|
+
code = 'ACTLY_CIRCUIT_OPEN';
|
|
147
|
+
key;
|
|
148
|
+
constructor(key, ms) {
|
|
149
|
+
super(`Circuit breaker open for key "${key}" — retry after ${ms}ms`);
|
|
150
|
+
this.key = key;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/** Thrown when a bulkhead is full (maxConcurrent reached, queue timed out). */
|
|
154
|
+
export class BulkheadOverflowError extends ActlyError {
|
|
155
|
+
code = 'ACTLY_BULKHEAD_FULL';
|
|
156
|
+
key;
|
|
157
|
+
constructor(key, maxConcurrent) {
|
|
158
|
+
super(`Bulkhead full for key "${key}" — maxConcurrent ${maxConcurrent} reached`);
|
|
159
|
+
this.key = key;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/** Thrown when a rate limit is exceeded. */
|
|
163
|
+
export class RateLimitError extends ActlyError {
|
|
164
|
+
code = 'ACTLY_RATE_LIMIT';
|
|
165
|
+
key;
|
|
166
|
+
constructor(key, maxCalls, windowMs) {
|
|
167
|
+
super(`Rate limit exceeded for key "${key}" — ${maxCalls} calls per ${windowMs}ms`);
|
|
168
|
+
this.key = key;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,+EAA+E;AAC/E,MAAM,OAAgB,UAAW,SAAQ,KAAK;IAG5C,0DAA0D;I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AO,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA;QAClF,CAAC;IACH,CAAC;IACQ,KAAK,CAAS;CACxB;AAED,gFAAgF;AAEhF,iEAAiE;AACjE,MAAM,OAAO,uBAAwB,SAAQ,UAAU;IAC5C,IAAI,GAAG,oBAA6B,CAAA;IACpC,GAAG,CAAQ;IAEpB,YAAY,GAAW,EAAE,EAAU;QACjC,KAAK,CAAC,iCAAiC,GAAG,mBAAmB,EAAE,IAAI,CAAC,CAAA;QACpE,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;CACF;AAED,+EAA+E;AAC/E,MAAM,OAAO,qBAAsB,SAAQ,UAAU;IAC1C,IAAI,GAAG,qBAA8B,CAAA;IACrC,GAAG,CAAQ;IAEpB,YAAY,GAAW,EAAE,aAAqB;QAC5C,KAAK,CAAC,0BAA0B,GAAG,qBAAqB,aAAa,UAAU,CAAC,CAAA;QAChF,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;CACF;AAED,4CAA4C;AAC5C,MAAM,OAAO,cAAe,SAAQ,UAAU;IACnC,IAAI,GAAG,kBAA2B,CAAA;IAClC,GAAG,CAAQ;IAEpB,YAAY,GAAW,EAAE,QAAgB,EAAE,QAAgB;QACzD,KAAK,CAAC,gCAAgC,GAAG,OAAO,QAAQ,cAAc,QAAQ,IAAI,CAAC,CAAA;QACnF,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;CACF"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// ─── Primary API ──────────────────────────────────────────────────────────────
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TotalTimeoutError = exports.TimeoutError = exports.InMemoryStore = exports.act = void 0;
|
|
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;
|
|
4
5
|
var act_js_1 = require("./core/act.js");
|
|
5
6
|
Object.defineProperty(exports, "act", { enumerable: true, get: function () { return act_js_1.act; } });
|
|
6
|
-
|
|
7
|
+
Object.defineProperty(exports, "invalidate", { enumerable: true, get: function () { return act_js_1.invalidate; } });
|
|
8
|
+
Object.defineProperty(exports, "withStore", { enumerable: true, get: function () { return act_js_1.withStore; } });
|
|
9
|
+
// ─── Execution engine (for custom policy chains) ──────────────────────────────
|
|
10
|
+
var executor_js_1 = require("./core/executor.js");
|
|
11
|
+
Object.defineProperty(exports, "execute", { enumerable: true, get: function () { return executor_js_1.execute; } });
|
|
12
|
+
Object.defineProperty(exports, "REQUIRES_SYNC_STORE", { enumerable: true, get: function () { return executor_js_1.REQUIRES_SYNC_STORE; } });
|
|
13
|
+
// ─── Stores ───────────────────────────────────────────────────────────────────
|
|
7
14
|
var memory_js_1 = require("./stores/memory.js");
|
|
8
15
|
Object.defineProperty(exports, "InMemoryStore", { enumerable: true, get: function () { return memory_js_1.InMemoryStore; } });
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Object.defineProperty(exports, "
|
|
12
|
-
|
|
16
|
+
var base_js_1 = require("./stores/base.js");
|
|
17
|
+
Object.defineProperty(exports, "isSyncStore", { enumerable: true, get: function () { return base_js_1.isSyncStore; } });
|
|
18
|
+
Object.defineProperty(exports, "isAsyncStore", { enumerable: true, get: function () { return base_js_1.isAsyncStore; } });
|
|
19
|
+
// ─── Error classes ────────────────────────────────────────────────────────────
|
|
20
|
+
var errors_js_1 = require("./errors.js");
|
|
21
|
+
Object.defineProperty(exports, "ActlyError", { enumerable: true, get: function () { return errors_js_1.ActlyError; } });
|
|
22
|
+
Object.defineProperty(exports, "ActlyAbortError", { enumerable: true, get: function () { return errors_js_1.ActlyAbortError; } });
|
|
23
|
+
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return errors_js_1.TimeoutError; } });
|
|
24
|
+
Object.defineProperty(exports, "TotalTimeoutError", { enumerable: true, get: function () { return errors_js_1.TotalTimeoutError; } });
|
|
25
|
+
Object.defineProperty(exports, "RetryExhaustedError", { enumerable: true, get: function () { return errors_js_1.RetryExhaustedError; } });
|
|
26
|
+
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return errors_js_1.ValidationError; } });
|
|
27
|
+
// ─── Utilities (for custom policy authors) ────────────────────────────────────
|
|
28
|
+
var abort_js_1 = require("./utils/abort.js");
|
|
29
|
+
Object.defineProperty(exports, "anySignal", { enumerable: true, get: function () { return abort_js_1.anySignal; } });
|
|
30
|
+
Object.defineProperty(exports, "raceAbort", { enumerable: true, get: function () { return abort_js_1.raceAbort; } });
|
|
31
|
+
Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return abort_js_1.sleep; } });
|
|
32
|
+
Object.defineProperty(exports, "linkSignal", { enumerable: true, get: function () { return abort_js_1.linkSignal; } });
|
|
33
|
+
Object.defineProperty(exports, "isAbortError", { enumerable: true, get: function () { return abort_js_1.isAbortError; } });
|
|
34
|
+
var key_js_1 = require("./utils/key.js");
|
|
35
|
+
Object.defineProperty(exports, "sanitizeKey", { enumerable: true, get: function () { return key_js_1.sanitizeKey; } });
|
|
36
|
+
var backoff_js_1 = require("./utils/backoff.js");
|
|
37
|
+
Object.defineProperty(exports, "computeDelay", { enumerable: true, get: function () { return backoff_js_1.computeDelay; } });
|
|
38
|
+
var limits_js_1 = require("./utils/limits.js");
|
|
39
|
+
Object.defineProperty(exports, "LIMITS", { enumerable: true, get: function () { return limits_js_1.LIMITS; } });
|
|
40
|
+
// ─── Hardening: new error classes ────────────────────────────────────────────
|
|
41
|
+
var errors_js_2 = require("./errors.js");
|
|
42
|
+
Object.defineProperty(exports, "CircuitBreakerOpenError", { enumerable: true, get: function () { return errors_js_2.CircuitBreakerOpenError; } });
|
|
43
|
+
Object.defineProperty(exports, "BulkheadOverflowError", { enumerable: true, get: function () { return errors_js_2.BulkheadOverflowError; } });
|
|
44
|
+
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return errors_js_2.RateLimitError; } });
|
|
45
|
+
// ─── Hardening: health check & graceful shutdown ─────────────────────────────
|
|
46
|
+
var health_js_1 = require("./core/health.js");
|
|
47
|
+
Object.defineProperty(exports, "createHealthCheck", { enumerable: true, get: function () { return health_js_1.createHealthCheck; } });
|
|
48
|
+
var shutdown_js_1 = require("./core/shutdown.js");
|
|
49
|
+
Object.defineProperty(exports, "drain", { enumerable: true, get: function () { return shutdown_js_1.drain; } });
|
|
50
|
+
// ─── Hardening: tenant isolation ─────────────────────────────────────────────
|
|
51
|
+
var tenant_js_1 = require("./core/tenant.js");
|
|
52
|
+
Object.defineProperty(exports, "createTenantStore", { enumerable: true, get: function () { return tenant_js_1.createTenantStore; } });
|
|
53
|
+
Object.defineProperty(exports, "createAsyncTenantStore", { enumerable: true, get: function () { return tenant_js_1.createAsyncTenantStore; } });
|
|
54
|
+
// ─── Hardening: error sanitization ───────────────────────────────────────────
|
|
55
|
+
var sanitize_js_1 = require("./utils/sanitize.js");
|
|
56
|
+
Object.defineProperty(exports, "sanitizeErrorMessage", { enumerable: true, get: function () { return sanitize_js_1.sanitizeErrorMessage; } });
|
|
57
|
+
Object.defineProperty(exports, "sanitizeError", { enumerable: true, get: function () { return sanitize_js_1.sanitizeError; } });
|
|
58
|
+
// ─── Hardening: AbortController pool ─────────────────────────────────────────
|
|
59
|
+
var abortPool_js_1 = require("./utils/abortPool.js");
|
|
60
|
+
Object.defineProperty(exports, "acquireController", { enumerable: true, get: function () { return abortPool_js_1.acquireController; } });
|
|
61
|
+
Object.defineProperty(exports, "releaseController", { enumerable: true, get: function () { return abortPool_js_1.releaseController; } });
|
|
62
|
+
Object.defineProperty(exports, "poolSize", { enumerable: true, get: function () { return abortPool_js_1.poolSize; } });
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
|
-
export { act } from './core/act.js';
|
|
2
|
-
export type {
|
|
1
|
+
export { act, invalidate, withStore, } from './core/act.js';
|
|
2
|
+
export type { ScopedActSync, ScopedActAsync, } from './core/act.js';
|
|
3
|
+
export { execute, REQUIRES_SYNC_STORE, } from './core/executor.js';
|
|
3
4
|
export { InMemoryStore } from './stores/memory.js';
|
|
4
5
|
export type { InMemoryStoreOptions } from './stores/memory.js';
|
|
5
|
-
export {
|
|
6
|
+
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, // alias for SyncStateStore (backwards compat)
|
|
10
|
+
SyncStateStore, AsyncStateStore, AnyStateStore, } from './types/index.js';
|
|
11
|
+
export { anySignal, raceAbort, sleep, linkSignal, isAbortError, } from './utils/abort.js';
|
|
12
|
+
export { sanitizeKey, } from './utils/key.js';
|
|
13
|
+
export { computeDelay, } from './utils/backoff.js';
|
|
14
|
+
export { LIMITS, } from './utils/limits.js';
|
|
15
|
+
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';
|
|
20
|
+
export { createTenantStore, createAsyncTenantStore, } from './core/tenant.js';
|
|
21
|
+
export type { TenantStoreOptions, TenantManager } from './core/tenant.js';
|
|
22
|
+
export { sanitizeErrorMessage, sanitizeError, } from './utils/sanitize.js';
|
|
23
|
+
export { acquireController, releaseController, poolSize, } from './utils/abortPool.js';
|
|
24
|
+
export type { CircuitBreakerOptions, BulkheadOptions, RateLimitOptions, HedgeOptions, FallbackOptions, AuditOptions, AuditEntry, } from './types/index.js';
|
|
6
25
|
//# 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":"
|
|
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,GAChB,MAAM,aAAa,CAAA;AAIpB,YAAY,EACV,cAAc,EACd,cAAc,EACd,YAAY,EACZ,UAAU,EACV,aAAa,EACb,cAAc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