@revealui/resilience 0.2.0 → 0.2.1

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.
@@ -9,9 +9,8 @@ TERMS AND CONDITIONS
9
9
 
10
10
  "Software" means the RevealUI source code, documentation, and associated
11
11
  files contained in directories and packages designated as commercial,
12
- including but not limited to: packages/ai, packages/mcp, packages/editors,
13
- packages/services, packages/harnesses, and any directory named "ee" within
14
- the repository.
12
+ including but not limited to: packages/ai, packages/harnesses, and any
13
+ directory named "ee" within the repository.
15
14
 
16
15
  "License Key" means a valid RevealUI license key obtained through an active
17
16
  paid subscription at https://revealui.com.
package/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # @revealui/resilience
2
+
3
+ Resilience infrastructure for RevealUI applications. Implements circuit breaker, retry with exponential backoff, and bulkhead patterns for fault-tolerant service communication.
4
+
5
+ ## When to Use This
6
+
7
+ - You're calling external APIs (Stripe, Supabase, AI providers) and need fault tolerance
8
+ - You want automatic retry with backoff for transient failures
9
+ - You need circuit breakers to prevent cascading failures across services
10
+
11
+ If your code only talks to the local database via Drizzle, you don't need this — Drizzle handles connection pooling internally.
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pnpm add @revealui/resilience
17
+ ```
18
+
19
+ Zero runtime dependencies.
20
+
21
+ ## API Reference
22
+
23
+ ### Circuit Breaker
24
+
25
+ | Export | Type | Purpose |
26
+ |--------|------|---------|
27
+ | `CircuitBreaker` | Class | Basic circuit breaker (closed/open/half-open states) |
28
+ | `AdaptiveCircuitBreaker` | Class | Self-tuning thresholds based on error rate |
29
+ | `Bulkhead` | Class | Concurrency limiter to isolate resource pools |
30
+ | `CircuitBreakerRegistry` | Class | Named registry for managing multiple breakers |
31
+ | `CircuitBreak` | Decorator | Apply circuit breaker to class methods |
32
+ | `createCircuitBreakerMiddleware` | Function | Hono middleware for route-level protection |
33
+ | `fetchWithCircuitBreaker` | Function | Fetch wrapper with automatic circuit breaking |
34
+ | `withCircuitBreaker` | Function | Wrap any async function with a circuit breaker |
35
+ | `createResilientFunction` | Function | Combine circuit breaker + retry in one wrapper |
36
+ | `ResilientOperation` | Class | Composable resilience pipeline |
37
+
38
+ ### Retry
39
+
40
+ | Export | Type | Purpose |
41
+ |--------|------|---------|
42
+ | `retry` | Function | Retry an async operation with configurable policy |
43
+ | `retryBatch` | Function | Retry multiple operations with shared policy |
44
+ | `retryIf` | Function | Retry only when predicate matches the error |
45
+ | `retryUntil` | Function | Retry until success condition is met |
46
+ | `retryWithFallback` | Function | Retry with fallback value on exhaustion |
47
+ | `ExponentialBackoff` | Class | Configurable backoff calculator |
48
+ | `RetryPolicies` | Object | Pre-built policies (aggressive, conservative, network) |
49
+ | `RetryPolicyBuilder` | Class | Fluent API for building custom retry policies |
50
+ | `Retryable` | Decorator | Apply retry to class methods |
51
+ | `RetryableOperation` | Class | Stateful retry with event hooks |
52
+ | `createRetryMiddleware` | Function | Hono middleware for automatic request retry |
53
+ | `fetchWithRetry` | Function | Fetch wrapper with retry |
54
+
55
+ ### Configuration
56
+
57
+ | Export | Type | Purpose |
58
+ |--------|------|---------|
59
+ | `configureResilienceLogger` | Function | Set custom logger (defaults to console) |
60
+ | `globalRetryConfig` | Object | Global retry defaults |
61
+
62
+ ## Usage
63
+
64
+ ```typescript
65
+ import { retry, CircuitBreaker, RetryPolicies } from '@revealui/resilience';
66
+
67
+ // Simple retry
68
+ const result = await retry(() => fetch('https://api.stripe.com/...'), {
69
+ maxRetries: 3,
70
+ baseDelay: 1000,
71
+ });
72
+
73
+ // Circuit breaker for external service
74
+ const breaker = new CircuitBreaker({ failureThreshold: 5, resetTimeout: 30000 });
75
+ const data = await breaker.execute(() => callExternalAPI());
76
+ ```
77
+
78
+ ## JOSHUA Alignment
79
+
80
+ - **Hermetic**: Isolates failure domains — one service's outage doesn't cascade to others
81
+ - **Adaptive**: Self-tuning circuit breakers adjust thresholds based on observed error rates
82
+ - **Orthogonal**: Resilience patterns are composable and independent of business logic
83
+
84
+ ## Related Packages
85
+
86
+ - `@revealui/core` — Uses resilience patterns for CMS API calls
87
+ - `apps/api` — Applies circuit breakers to external service routes
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@revealui/resilience",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Resilience infrastructure for RevealUI - circuit breaker, retry, bulkhead patterns",
5
5
  "license": "MIT",
6
6
  "dependencies": {},
7
7
  "devDependencies": {
8
- "@types/node": "^25.3.0",
8
+ "@types/node": "^25.5.0",
9
9
  "tsup": "^8.5.1",
10
- "typescript": "^5.9.3",
11
- "vitest": "^4.0.18",
10
+ "typescript": "^6.0.2",
11
+ "vitest": "^4.1.0",
12
12
  "dev": "0.0.1"
13
13
  },
14
14
  "engines": {