@revealui/core 0.3.0 → 0.5.2

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.
Files changed (155) hide show
  1. package/dist/client/admin/components/AdminDashboard.d.ts.map +1 -1
  2. package/dist/client/admin/components/AdminDashboard.js +20 -3
  3. package/dist/client/richtext/index.d.ts.map +1 -1
  4. package/dist/client/richtext/plugins/FloatingToolbarPlugin.js +1 -3
  5. package/dist/collections/operations/create.d.ts +2 -1
  6. package/dist/collections/operations/create.d.ts.map +1 -1
  7. package/dist/collections/operations/create.js +28 -1
  8. package/dist/database/type-adapter.d.ts.map +1 -1
  9. package/dist/features.d.ts +13 -3
  10. package/dist/features.d.ts.map +1 -1
  11. package/dist/features.js +17 -0
  12. package/dist/globals/GlobalOperations.d.ts.map +1 -1
  13. package/dist/globals/GlobalOperations.js +12 -2
  14. package/dist/index.d.ts +11 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +11 -1
  17. package/dist/license.d.ts +6 -0
  18. package/dist/license.d.ts.map +1 -1
  19. package/dist/license.js +14 -1
  20. package/dist/monitoring/alerts.d.ts +4 -4
  21. package/dist/monitoring/alerts.d.ts.map +1 -1
  22. package/dist/plugins/nested-docs.d.ts.map +1 -1
  23. package/dist/plugins/nested-docs.js +0 -1
  24. package/dist/queries/queryBuilder.d.ts.map +1 -1
  25. package/dist/queries/queryBuilder.js +4 -3
  26. package/dist/richtext/index.d.ts.map +1 -1
  27. package/dist/storage/vercel-blob.d.ts.map +1 -1
  28. package/dist/storage/vercel-blob.js +3 -0
  29. package/dist/types/api.d.ts.map +1 -1
  30. package/dist/types/config.d.ts.map +1 -1
  31. package/dist/types/core.d.ts +1 -1
  32. package/dist/types/core.d.ts.map +1 -1
  33. package/dist/types/extensions.d.ts.map +1 -1
  34. package/dist/types/frontend.d.ts.map +1 -1
  35. package/dist/types/legacy.d.ts.map +1 -1
  36. package/dist/types/query.d.ts.map +1 -1
  37. package/dist/types/runtime.d.ts +1 -0
  38. package/dist/types/runtime.d.ts.map +1 -1
  39. package/dist/utils/error-responses.d.ts.map +1 -1
  40. package/dist/utils/error-responses.js +2 -3
  41. package/package.json +24 -24
  42. package/dist/caching/app-cache.d.ts +0 -242
  43. package/dist/caching/app-cache.d.ts.map +0 -1
  44. package/dist/caching/app-cache.js +0 -438
  45. package/dist/caching/cdn-config.d.ts +0 -155
  46. package/dist/caching/cdn-config.d.ts.map +0 -1
  47. package/dist/caching/cdn-config.js +0 -415
  48. package/dist/caching/edge-cache.d.ts +0 -177
  49. package/dist/caching/edge-cache.d.ts.map +0 -1
  50. package/dist/caching/edge-cache.js +0 -414
  51. package/dist/caching/service-worker.d.ts +0 -157
  52. package/dist/caching/service-worker.d.ts.map +0 -1
  53. package/dist/caching/service-worker.js +0 -438
  54. package/dist/client/admin/utils/auth.d.ts +0 -23
  55. package/dist/client/admin/utils/auth.d.ts.map +0 -1
  56. package/dist/client/admin/utils/auth.js +0 -52
  57. package/dist/client/http/client.d.ts +0 -15
  58. package/dist/client/http/client.d.ts.map +0 -1
  59. package/dist/client/http/client.js +0 -49
  60. package/dist/client/http/fetchBanner.d.ts +0 -18
  61. package/dist/client/http/fetchBanner.d.ts.map +0 -1
  62. package/dist/client/http/fetchBanner.js +0 -44
  63. package/dist/client/http/fetchCard.d.ts +0 -18
  64. package/dist/client/http/fetchCard.d.ts.map +0 -1
  65. package/dist/client/http/fetchCard.js +0 -46
  66. package/dist/client/http/fetchEvents.d.ts +0 -18
  67. package/dist/client/http/fetchEvents.d.ts.map +0 -1
  68. package/dist/client/http/fetchEvents.js +0 -44
  69. package/dist/client/http/fetchHero.d.ts +0 -17
  70. package/dist/client/http/fetchHero.d.ts.map +0 -1
  71. package/dist/client/http/fetchHero.js +0 -55
  72. package/dist/client/http/fetchMainInfos.d.ts +0 -17
  73. package/dist/client/http/fetchMainInfos.d.ts.map +0 -1
  74. package/dist/client/http/fetchMainInfos.js +0 -44
  75. package/dist/client/http/fetchVideos.d.ts +0 -13
  76. package/dist/client/http/fetchVideos.d.ts.map +0 -1
  77. package/dist/client/http/fetchVideos.js +0 -36
  78. package/dist/client/http/index.d.ts +0 -19
  79. package/dist/client/http/index.d.ts.map +0 -1
  80. package/dist/client/http/index.js +0 -11
  81. package/dist/error-handling/circuit-breaker.d.ts +0 -262
  82. package/dist/error-handling/circuit-breaker.d.ts.map +0 -1
  83. package/dist/error-handling/circuit-breaker.js +0 -550
  84. package/dist/error-handling/retry.d.ts +0 -194
  85. package/dist/error-handling/retry.d.ts.map +0 -1
  86. package/dist/error-handling/retry.js +0 -455
  87. package/dist/errors/index.d.ts +0 -23
  88. package/dist/errors/index.d.ts.map +0 -1
  89. package/dist/errors/index.js +0 -40
  90. package/dist/generated/agents/index.d.ts +0 -8
  91. package/dist/generated/agents/index.d.ts.map +0 -1
  92. package/dist/generated/agents/index.js +0 -7
  93. package/dist/generated/components/index.d.ts +0 -8
  94. package/dist/generated/components/index.d.ts.map +0 -1
  95. package/dist/generated/components/index.js +0 -7
  96. package/dist/generated/functions/index.d.ts +0 -8
  97. package/dist/generated/functions/index.d.ts.map +0 -1
  98. package/dist/generated/functions/index.js +0 -7
  99. package/dist/generated/hooks/index.d.ts +0 -8
  100. package/dist/generated/hooks/index.d.ts.map +0 -1
  101. package/dist/generated/hooks/index.js +0 -7
  102. package/dist/generated/plans/index.d.ts +0 -8
  103. package/dist/generated/plans/index.d.ts.map +0 -1
  104. package/dist/generated/plans/index.js +0 -7
  105. package/dist/generated/prompts/index.d.ts +0 -8
  106. package/dist/generated/prompts/index.d.ts.map +0 -1
  107. package/dist/generated/prompts/index.js +0 -7
  108. package/dist/generated/tools/index.d.ts +0 -8
  109. package/dist/generated/tools/index.d.ts.map +0 -1
  110. package/dist/generated/tools/index.js +0 -7
  111. package/dist/generated/types/supabase.d.ts +0 -193
  112. package/dist/generated/types/supabase.d.ts.map +0 -1
  113. package/dist/generated/types/supabase.js +0 -5
  114. package/dist/optimization/asset-optimizer.d.ts +0 -206
  115. package/dist/optimization/asset-optimizer.d.ts.map +0 -1
  116. package/dist/optimization/asset-optimizer.js +0 -336
  117. package/dist/optimization/build-optimizer.d.ts +0 -202
  118. package/dist/optimization/build-optimizer.d.ts.map +0 -1
  119. package/dist/optimization/build-optimizer.js +0 -271
  120. package/dist/optimization/bundle-analyzer.d.ts +0 -98
  121. package/dist/optimization/bundle-analyzer.d.ts.map +0 -1
  122. package/dist/optimization/bundle-analyzer.js +0 -346
  123. package/dist/optimization/code-splitting.d.ts +0 -121
  124. package/dist/optimization/code-splitting.d.ts.map +0 -1
  125. package/dist/optimization/code-splitting.js +0 -261
  126. package/dist/plugin/index.d.ts +0 -12
  127. package/dist/plugin/index.d.ts.map +0 -1
  128. package/dist/plugin/index.js +0 -4
  129. package/dist/security/audit.d.ts +0 -188
  130. package/dist/security/audit.d.ts.map +0 -1
  131. package/dist/security/audit.js +0 -433
  132. package/dist/security/auth.d.ts +0 -110
  133. package/dist/security/auth.d.ts.map +0 -1
  134. package/dist/security/auth.js +0 -257
  135. package/dist/security/authorization.d.ts +0 -211
  136. package/dist/security/authorization.d.ts.map +0 -1
  137. package/dist/security/authorization.js +0 -492
  138. package/dist/security/encryption.d.ts +0 -226
  139. package/dist/security/encryption.d.ts.map +0 -1
  140. package/dist/security/encryption.js +0 -534
  141. package/dist/security/gdpr-storage.d.ts +0 -102
  142. package/dist/security/gdpr-storage.d.ts.map +0 -1
  143. package/dist/security/gdpr-storage.js +0 -65
  144. package/dist/security/gdpr.d.ts +0 -320
  145. package/dist/security/gdpr.d.ts.map +0 -1
  146. package/dist/security/gdpr.js +0 -531
  147. package/dist/security/headers.d.ts +0 -184
  148. package/dist/security/headers.d.ts.map +0 -1
  149. package/dist/security/headers.js +0 -420
  150. package/dist/utils/jwt-validation.d.ts +0 -14
  151. package/dist/utils/jwt-validation.d.ts.map +0 -1
  152. package/dist/utils/jwt-validation.js +0 -36
  153. package/dist/utils/request-headers.d.ts +0 -15
  154. package/dist/utils/request-headers.d.ts.map +0 -1
  155. package/dist/utils/request-headers.js +0 -31
@@ -1,194 +0,0 @@
1
- /**
2
- * Retry Logic for API Calls
3
- *
4
- * Implements exponential backoff and retry strategies
5
- */
6
- export interface HttpError extends Error {
7
- statusCode?: number;
8
- response?: Response;
9
- }
10
- export interface RetryConfig {
11
- maxRetries?: number;
12
- baseDelay?: number;
13
- maxDelay?: number;
14
- exponentialBackoff?: boolean;
15
- jitter?: boolean;
16
- retryableErrors?: (error: Error) => boolean;
17
- onRetry?: (error: Error, attempt: number) => void;
18
- }
19
- export interface RetryOptions {
20
- signal?: AbortSignal;
21
- }
22
- /**
23
- * Retry a function with exponential backoff
24
- */
25
- export declare function retry<T>(fn: () => Promise<T>, config?: RetryConfig, options?: RetryOptions): Promise<T>;
26
- /**
27
- * Calculate retry delay with exponential backoff
28
- */
29
- export declare function calculateDelay(attempt: number, baseDelay: number, maxDelay: number, exponentialBackoff: boolean, jitter: boolean): number;
30
- /**
31
- * Sleep with abort support
32
- */
33
- export declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
34
- /**
35
- * Retry wrapper for fetch
36
- */
37
- export declare function fetchWithRetry(url: string, init?: RequestInit, config?: RetryConfig): Promise<Response>;
38
- /**
39
- * Retry wrapper class
40
- */
41
- export declare class RetryableOperation<T> {
42
- private fn;
43
- private config;
44
- private abortController;
45
- private attempts;
46
- private lastError?;
47
- constructor(fn: () => Promise<T>, config?: RetryConfig);
48
- /**
49
- * Execute with retry
50
- */
51
- execute(): Promise<T>;
52
- /**
53
- * Abort operation
54
- */
55
- abort(): void;
56
- /**
57
- * Get retry statistics
58
- */
59
- getStats(): {
60
- attempts: number;
61
- lastError?: Error;
62
- };
63
- }
64
- /**
65
- * Retry decorator
66
- */
67
- export declare function Retryable(config?: RetryConfig): (_target: object, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
68
- /**
69
- * Create retry middleware for API client
70
- */
71
- export declare function createRetryMiddleware<TRequest = unknown, TResponse = unknown>(config?: RetryConfig): (_request: TRequest, next: () => Promise<TResponse>) => Promise<TResponse>;
72
- /**
73
- * Batch retry - retry multiple operations
74
- */
75
- export declare function retryBatch<T>(operations: Array<() => Promise<T>>, config?: RetryConfig): Promise<Array<T | Error>>;
76
- /**
77
- * Retry with fallback
78
- */
79
- export declare function retryWithFallback<T>(primary: () => Promise<T>, fallback: () => Promise<T>, config?: RetryConfig): Promise<T>;
80
- /**
81
- * Conditional retry - only retry if condition is met
82
- */
83
- export declare function retryIf<T>(fn: () => Promise<T>, condition: (error: Error, attempt: number) => boolean, config?: RetryConfig): Promise<T>;
84
- /**
85
- * Retry until condition is met
86
- */
87
- export declare function retryUntil<T>(fn: () => Promise<T>, predicate: (result: T) => boolean, config?: RetryConfig, maxAttempts?: number): Promise<T>;
88
- /**
89
- * Exponential backoff iterator
90
- */
91
- export declare class ExponentialBackoff implements AsyncIterable<number> {
92
- private baseDelay;
93
- private maxDelay;
94
- private maxAttempts;
95
- private jitter;
96
- constructor(baseDelay?: number, maxDelay?: number, maxAttempts?: number, jitter?: boolean);
97
- [Symbol.asyncIterator](): AsyncIterator<number>;
98
- }
99
- /**
100
- * Retry policy builder
101
- */
102
- export declare class RetryPolicyBuilder {
103
- private config;
104
- /**
105
- * Set max retries
106
- */
107
- maxRetries(count: number): this;
108
- /**
109
- * Set base delay
110
- */
111
- baseDelay(ms: number): this;
112
- /**
113
- * Set max delay
114
- */
115
- maxDelay(ms: number): this;
116
- /**
117
- * Enable/disable exponential backoff
118
- */
119
- exponentialBackoff(enabled?: boolean): this;
120
- /**
121
- * Enable/disable jitter
122
- */
123
- jitter(enabled?: boolean): this;
124
- /**
125
- * Set custom retryable errors function
126
- */
127
- retryOn(fn: (error: Error) => boolean): this;
128
- /**
129
- * Set retry callback
130
- */
131
- onRetry(fn: (error: Error, attempt: number) => void): this;
132
- /**
133
- * Build retry config
134
- */
135
- build(): RetryConfig;
136
- /**
137
- * Execute function with built policy
138
- */
139
- execute<T>(fn: () => Promise<T>): Promise<T>;
140
- }
141
- /**
142
- * Common retry policies
143
- */
144
- export declare const RetryPolicies: {
145
- /**
146
- * Default policy - 3 retries with exponential backoff
147
- */
148
- default: () => RetryConfig;
149
- /**
150
- * Aggressive policy - more retries, faster backoff
151
- */
152
- aggressive: () => RetryConfig;
153
- /**
154
- * Conservative policy - fewer retries, longer backoff
155
- */
156
- conservative: () => RetryConfig;
157
- /**
158
- * Linear backoff policy
159
- */
160
- linear: () => RetryConfig;
161
- /**
162
- * Immediate retry policy - no delay
163
- */
164
- immediate: () => RetryConfig;
165
- /**
166
- * Network error only policy
167
- */
168
- networkOnly: () => RetryConfig;
169
- /**
170
- * Idempotent operations policy (safe to retry)
171
- */
172
- idempotent: () => RetryConfig;
173
- };
174
- /**
175
- * Global retry configuration
176
- */
177
- declare class GlobalRetryConfig {
178
- private config;
179
- /**
180
- * Set global retry config
181
- */
182
- setConfig(config: RetryConfig): void;
183
- /**
184
- * Get global retry config
185
- */
186
- getConfig(): RetryConfig;
187
- /**
188
- * Reset to default config
189
- */
190
- reset(): void;
191
- }
192
- export declare const globalRetryConfig: GlobalRetryConfig;
193
- export {};
194
- //# sourceMappingURL=retry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/error-handling/retry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,MAAM,WAAW,SAAU,SAAQ,KAAK;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;IAC5C,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AAW;IAQvB;;OAEG;qBACY,WAAW;IAQ1B;;OAEG;uBACc,WAAW;IAS5B;;OAEG;sBACa,WAAW;CAO5B,CAAC;AAEF;;GAEG;AACH,cAAM,iBAAiB;IACrB,OAAO,CAAC,MAAM,CAAwC;IAEtD;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAIpC;;OAEG;IACH,SAAS,IAAI,WAAW;IAIxB;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd;AAED,eAAO,MAAM,iBAAiB,mBAA0B,CAAC"}
@@ -1,455 +0,0 @@
1
- /**
2
- * Retry Logic for API Calls
3
- *
4
- * Implements exponential backoff and retry strategies
5
- */
6
- import { randomInt } from 'node:crypto';
7
- import { logger } from '../observability/logger.js';
8
- const DEFAULT_CONFIG = {
9
- maxRetries: 3,
10
- baseDelay: 1000,
11
- maxDelay: 30000,
12
- exponentialBackoff: true,
13
- jitter: true,
14
- retryableErrors: (error) => {
15
- // Check for explicit non-retryable status codes (4xx client errors)
16
- if ('statusCode' in error) {
17
- const statusCode = error.statusCode;
18
- // Don't retry 4xx errors except 408 (timeout) and 429 (rate limit)
19
- if (statusCode !== undefined && statusCode >= 400 && statusCode < 500) {
20
- return statusCode === 408 || statusCode === 429;
21
- }
22
- }
23
- // Retry all other errors by default (network errors, 5xx, generic errors)
24
- return true;
25
- },
26
- onRetry: () => {
27
- // No-op default — consumers override via config
28
- },
29
- };
30
- /**
31
- * Retry a function with exponential backoff
32
- */
33
- export async function retry(fn, config = {}, options = {}) {
34
- const mergedConfig = { ...DEFAULT_CONFIG, ...config };
35
- let lastError = new Error('Retry failed');
36
- for (let attempt = 0; attempt <= mergedConfig.maxRetries; attempt++) {
37
- try {
38
- // Check if aborted
39
- if (options.signal?.aborted) {
40
- throw new Error('Request aborted');
41
- }
42
- return await fn();
43
- }
44
- catch (error) {
45
- lastError = error instanceof Error ? error : new Error(String(error));
46
- // Don't retry if it's the last attempt
47
- if (attempt === mergedConfig.maxRetries) {
48
- throw lastError;
49
- }
50
- // Don't retry if error is not retryable
51
- if (!mergedConfig.retryableErrors(lastError)) {
52
- throw lastError;
53
- }
54
- // Call retry callback
55
- mergedConfig.onRetry(lastError, attempt + 1);
56
- // Calculate delay
57
- const delay = calculateDelay(attempt, mergedConfig.baseDelay, mergedConfig.maxDelay, mergedConfig.exponentialBackoff, mergedConfig.jitter);
58
- // Wait before retrying
59
- await sleep(delay, options.signal);
60
- }
61
- }
62
- throw lastError;
63
- }
64
- /**
65
- * Calculate retry delay with exponential backoff
66
- */
67
- export function calculateDelay(attempt, baseDelay, maxDelay, exponentialBackoff, jitter) {
68
- let delay = baseDelay;
69
- if (exponentialBackoff) {
70
- // Exponential backoff: 2^attempt * baseDelay
71
- delay = Math.min(baseDelay * 2 ** attempt, maxDelay);
72
- }
73
- if (jitter) {
74
- // Add cryptographically random jitter (±25%), clamped to maxDelay
75
- const jitterAmount = Math.ceil(delay * 0.25);
76
- if (jitterAmount > 0) {
77
- delay = delay + randomInt(jitterAmount * 2 + 1) - jitterAmount;
78
- }
79
- }
80
- return Math.floor(Math.min(delay, maxDelay));
81
- }
82
- /**
83
- * Sleep with abort support
84
- */
85
- export function sleep(ms, signal) {
86
- return new Promise((resolve, reject) => {
87
- if (signal?.aborted) {
88
- reject(new Error('Request aborted'));
89
- return;
90
- }
91
- const timeout = setTimeout(resolve, ms);
92
- if (signal) {
93
- signal.addEventListener('abort', () => {
94
- clearTimeout(timeout);
95
- reject(new Error('Request aborted'));
96
- });
97
- }
98
- });
99
- }
100
- /**
101
- * Retry wrapper for fetch
102
- */
103
- export async function fetchWithRetry(url, init, config) {
104
- const abortController = new AbortController();
105
- const signal = init?.signal || abortController.signal;
106
- return retry(async () => {
107
- const response = await fetch(url, {
108
- ...init,
109
- signal,
110
- });
111
- // Throw on error status
112
- if (!response.ok) {
113
- const error = new Error(`HTTP ${response.status}: ${response.statusText}`);
114
- error.statusCode = response.status;
115
- error.response = response;
116
- throw error;
117
- }
118
- return response;
119
- }, {
120
- ...config,
121
- retryableErrors: (error) => {
122
- // Check custom retryable errors first
123
- if (config?.retryableErrors && !config.retryableErrors(error)) {
124
- return false;
125
- }
126
- // Don't retry 4xx errors (except 408, 429)
127
- if ('statusCode' in error) {
128
- const statusCode = error.statusCode;
129
- if (statusCode !== undefined && statusCode >= 400 && statusCode < 500) {
130
- return statusCode === 408 || statusCode === 429;
131
- }
132
- }
133
- return true;
134
- },
135
- }, { signal });
136
- }
137
- /**
138
- * Retry wrapper class
139
- */
140
- export class RetryableOperation {
141
- fn;
142
- config;
143
- abortController;
144
- attempts = 0;
145
- lastError;
146
- constructor(fn, config = {}) {
147
- this.fn = fn;
148
- this.config = { ...DEFAULT_CONFIG, ...config };
149
- this.abortController = new AbortController();
150
- }
151
- /**
152
- * Execute with retry
153
- */
154
- async execute() {
155
- return retry(this.fn, this.config, { signal: this.abortController.signal });
156
- }
157
- /**
158
- * Abort operation
159
- */
160
- abort() {
161
- this.abortController.abort();
162
- }
163
- /**
164
- * Get retry statistics
165
- */
166
- getStats() {
167
- return {
168
- attempts: this.attempts,
169
- lastError: this.lastError,
170
- };
171
- }
172
- }
173
- /**
174
- * Retry decorator
175
- */
176
- export function Retryable(config) {
177
- return (_target, _propertyKey, descriptor) => {
178
- const originalMethod = descriptor.value;
179
- descriptor.value = async function (...args) {
180
- return retry(() => originalMethod.apply(this, args), config);
181
- };
182
- return descriptor;
183
- };
184
- }
185
- /**
186
- * Create retry middleware for API client
187
- */
188
- export function createRetryMiddleware(config = {}) {
189
- return async (_request, next) => {
190
- return retry(next, config);
191
- };
192
- }
193
- /**
194
- * Batch retry - retry multiple operations
195
- */
196
- export async function retryBatch(operations, config = {}) {
197
- return Promise.all(operations.map(async (op) => {
198
- try {
199
- return await retry(op, config);
200
- }
201
- catch (error) {
202
- return error instanceof Error ? error : new Error(String(error));
203
- }
204
- }));
205
- }
206
- /**
207
- * Retry with fallback
208
- */
209
- export async function retryWithFallback(primary, fallback, config = {}) {
210
- try {
211
- return await retry(primary, config);
212
- }
213
- catch (error) {
214
- logger.warn('Primary operation failed, trying fallback', {
215
- error: error instanceof Error ? error.message : String(error),
216
- });
217
- return fallback();
218
- }
219
- }
220
- /**
221
- * Conditional retry - only retry if condition is met
222
- */
223
- export async function retryIf(fn, condition, config = {}) {
224
- return retry(fn, {
225
- ...config,
226
- retryableErrors: (error) => {
227
- // Check original retryable condition first
228
- const originalCheck = config.retryableErrors?.(error) ?? DEFAULT_CONFIG.retryableErrors(error);
229
- if (!originalCheck)
230
- return false;
231
- // Then check custom condition
232
- return condition(error, 0);
233
- },
234
- });
235
- }
236
- /**
237
- * Retry until condition is met
238
- */
239
- export async function retryUntil(fn, predicate, config = {}, maxAttempts = 10) {
240
- let attempts = 0;
241
- while (attempts < maxAttempts) {
242
- try {
243
- const result = await fn();
244
- if (predicate(result)) {
245
- return result;
246
- }
247
- // Result doesn't match predicate, treat as retryable error
248
- attempts++;
249
- if (attempts >= maxAttempts) {
250
- throw new Error('Max attempts reached without matching predicate');
251
- }
252
- const delay = calculateDelay(attempts - 1, config.baseDelay ?? DEFAULT_CONFIG.baseDelay, config.maxDelay ?? DEFAULT_CONFIG.maxDelay, config.exponentialBackoff ?? DEFAULT_CONFIG.exponentialBackoff, config.jitter ?? DEFAULT_CONFIG.jitter);
253
- await sleep(delay);
254
- }
255
- catch (error) {
256
- attempts++;
257
- if (attempts >= maxAttempts) {
258
- throw error;
259
- }
260
- const delay = calculateDelay(attempts - 1, config.baseDelay ?? DEFAULT_CONFIG.baseDelay, config.maxDelay ?? DEFAULT_CONFIG.maxDelay, config.exponentialBackoff ?? DEFAULT_CONFIG.exponentialBackoff, config.jitter ?? DEFAULT_CONFIG.jitter);
261
- await sleep(delay);
262
- }
263
- }
264
- throw new Error('Max attempts reached');
265
- }
266
- /**
267
- * Exponential backoff iterator
268
- */
269
- export class ExponentialBackoff {
270
- baseDelay;
271
- maxDelay;
272
- maxAttempts;
273
- jitter;
274
- constructor(baseDelay = 1000, maxDelay = 30000, maxAttempts = 10, jitter = true) {
275
- this.baseDelay = baseDelay;
276
- this.maxDelay = maxDelay;
277
- this.maxAttempts = maxAttempts;
278
- this.jitter = jitter;
279
- }
280
- async *[Symbol.asyncIterator]() {
281
- for (let attempt = 0; attempt < this.maxAttempts; attempt++) {
282
- const delay = calculateDelay(attempt, this.baseDelay, this.maxDelay, true, this.jitter);
283
- yield delay;
284
- await sleep(delay);
285
- }
286
- }
287
- }
288
- /**
289
- * Retry policy builder
290
- */
291
- export class RetryPolicyBuilder {
292
- config = {};
293
- /**
294
- * Set max retries
295
- */
296
- maxRetries(count) {
297
- this.config.maxRetries = count;
298
- return this;
299
- }
300
- /**
301
- * Set base delay
302
- */
303
- baseDelay(ms) {
304
- this.config.baseDelay = ms;
305
- return this;
306
- }
307
- /**
308
- * Set max delay
309
- */
310
- maxDelay(ms) {
311
- this.config.maxDelay = ms;
312
- return this;
313
- }
314
- /**
315
- * Enable/disable exponential backoff
316
- */
317
- exponentialBackoff(enabled = true) {
318
- this.config.exponentialBackoff = enabled;
319
- return this;
320
- }
321
- /**
322
- * Enable/disable jitter
323
- */
324
- jitter(enabled = true) {
325
- this.config.jitter = enabled;
326
- return this;
327
- }
328
- /**
329
- * Set custom retryable errors function
330
- */
331
- retryOn(fn) {
332
- this.config.retryableErrors = fn;
333
- return this;
334
- }
335
- /**
336
- * Set retry callback
337
- */
338
- onRetry(fn) {
339
- this.config.onRetry = fn;
340
- return this;
341
- }
342
- /**
343
- * Build retry config
344
- */
345
- build() {
346
- return this.config;
347
- }
348
- /**
349
- * Execute function with built policy
350
- */
351
- async execute(fn) {
352
- return retry(fn, this.build());
353
- }
354
- }
355
- /**
356
- * Common retry policies
357
- */
358
- export const RetryPolicies = {
359
- /**
360
- * Default policy - 3 retries with exponential backoff
361
- */
362
- default: () => ({
363
- maxRetries: 3,
364
- baseDelay: 1000,
365
- maxDelay: 30000,
366
- exponentialBackoff: true,
367
- jitter: true,
368
- }),
369
- /**
370
- * Aggressive policy - more retries, faster backoff
371
- */
372
- aggressive: () => ({
373
- maxRetries: 5,
374
- baseDelay: 500,
375
- maxDelay: 10000,
376
- exponentialBackoff: true,
377
- jitter: true,
378
- }),
379
- /**
380
- * Conservative policy - fewer retries, longer backoff
381
- */
382
- conservative: () => ({
383
- maxRetries: 2,
384
- baseDelay: 2000,
385
- maxDelay: 60000,
386
- exponentialBackoff: true,
387
- jitter: true,
388
- }),
389
- /**
390
- * Linear backoff policy
391
- */
392
- linear: () => ({
393
- maxRetries: 3,
394
- baseDelay: 1000,
395
- maxDelay: 10000,
396
- exponentialBackoff: false,
397
- jitter: false,
398
- }),
399
- /**
400
- * Immediate retry policy - no delay
401
- */
402
- immediate: () => ({
403
- maxRetries: 3,
404
- baseDelay: 0,
405
- maxDelay: 0,
406
- exponentialBackoff: false,
407
- jitter: false,
408
- }),
409
- /**
410
- * Network error only policy
411
- */
412
- networkOnly: () => ({
413
- maxRetries: 3,
414
- baseDelay: 1000,
415
- maxDelay: 30000,
416
- exponentialBackoff: true,
417
- jitter: true,
418
- retryableErrors: (error) => error.name === 'NetworkError',
419
- }),
420
- /**
421
- * Idempotent operations policy (safe to retry)
422
- */
423
- idempotent: () => ({
424
- maxRetries: 5,
425
- baseDelay: 1000,
426
- maxDelay: 30000,
427
- exponentialBackoff: true,
428
- jitter: true,
429
- }),
430
- };
431
- /**
432
- * Global retry configuration
433
- */
434
- class GlobalRetryConfig {
435
- config = RetryPolicies.default();
436
- /**
437
- * Set global retry config
438
- */
439
- setConfig(config) {
440
- this.config = { ...this.config, ...config };
441
- }
442
- /**
443
- * Get global retry config
444
- */
445
- getConfig() {
446
- return this.config;
447
- }
448
- /**
449
- * Reset to default config
450
- */
451
- reset() {
452
- this.config = RetryPolicies.default();
453
- }
454
- }
455
- export const globalRetryConfig = new GlobalRetryConfig();
@@ -1,23 +0,0 @@
1
- /**
2
- * RevealUI CMS Errors
3
- * @module @revealui/core/errors
4
- */
5
- export declare class RevealUIError extends Error {
6
- constructor(message: string);
7
- }
8
- export declare class MissingEditorProp extends RevealUIError {
9
- constructor(fieldName?: string);
10
- }
11
- export declare class ValidationError extends RevealUIError {
12
- constructor(message: string);
13
- }
14
- export declare class ConfigurationError extends RevealUIError {
15
- constructor(message: string);
16
- }
17
- export declare class AccessDeniedError extends RevealUIError {
18
- constructor(message?: string);
19
- }
20
- export declare class NotFoundError extends RevealUIError {
21
- constructor(resource?: string);
22
- }
23
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,iBAAkB,SAAQ,aAAa;gBACtC,SAAS,CAAC,EAAE,MAAM;CAI/B;AAED,qBAAa,eAAgB,SAAQ,aAAa;gBACpC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,kBAAmB,SAAQ,aAAa;gBACvC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,iBAAkB,SAAQ,aAAa;gBACtC,OAAO,SAAkB;CAItC;AAED,qBAAa,aAAc,SAAQ,aAAa;gBAClC,QAAQ,CAAC,EAAE,MAAM;CAI9B"}