@thru/replay 0.2.32 → 0.2.33

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/dist/index.d.cts CHANGED
@@ -205,6 +205,47 @@ interface EventReplayOptions {
205
205
  }
206
206
  declare function createEventReplay(options: EventReplayOptions): ReplayStream<Event, string>;
207
207
 
208
+ /**
209
+ * Retry utilities for stream reconnection with exponential backoff.
210
+ */
211
+ interface RetryConfig {
212
+ /** Initial delay before first retry (default: 1000ms) */
213
+ initialDelayMs: number;
214
+ /** Maximum delay between retries (default: 30000ms) */
215
+ maxDelayMs: number;
216
+ /** Timeout for connection/read operations (default: 30000ms) */
217
+ connectionTimeoutMs: number;
218
+ }
219
+ declare const DEFAULT_RETRY_CONFIG: RetryConfig;
220
+ /**
221
+ * Calculate exponential backoff delay for a given attempt number.
222
+ * Starts at initialDelayMs and doubles each attempt, capped at maxDelayMs.
223
+ *
224
+ * @param attempt - Zero-based attempt number (0 = first retry)
225
+ * @param config - Retry configuration
226
+ * @returns Delay in milliseconds
227
+ */
228
+ declare function calculateBackoff(attempt: number, config: RetryConfig): number;
229
+ /**
230
+ * Wrap a promise with a timeout. Rejects with TimeoutError if the promise
231
+ * doesn't resolve within the specified time.
232
+ *
233
+ * @param promise - Promise to wrap
234
+ * @param timeoutMs - Timeout in milliseconds
235
+ * @returns Promise that resolves with the original value or rejects on timeout
236
+ */
237
+ declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T>;
238
+ /**
239
+ * Error thrown when an operation times out.
240
+ */
241
+ declare class TimeoutError extends Error {
242
+ constructor(message: string);
243
+ }
244
+ /**
245
+ * Delay execution for a specified number of milliseconds.
246
+ */
247
+ declare function delay(ms: number): Promise<void>;
248
+
208
249
  /**
209
250
  * Account Replay - streaming account state with backfill reconciliation.
210
251
  *
@@ -310,6 +351,10 @@ interface AccountsByOwnerReplayOptions {
310
351
  };
311
352
  /** Cleanup interval for page assembler (default: 10000ms) */
312
353
  cleanupInterval?: number;
354
+ /** Maximum time to wait for stale reconnect cleanup before creating a fresh stream. */
355
+ reconnectCleanupTimeoutMs?: number;
356
+ /** Retry timings for live stream reconnects (default: DEFAULT_RETRY_CONFIG). */
357
+ retryConfig?: RetryConfig;
313
358
  /** Called when backfill queue is drained. Returns the highest slot seen during backfill. */
314
359
  onBackfillComplete?: (highestSlot: bigint) => void;
315
360
  /** Logger for debug/info/warn/error messages (default: NOOP_LOGGER) */
@@ -546,47 +591,6 @@ declare class PageAssembler {
546
591
  declare const NOOP_LOGGER: ReplayLogger;
547
592
  declare function createConsoleLogger(prefix?: string): ReplayLogger;
548
593
 
549
- /**
550
- * Retry utilities for stream reconnection with exponential backoff.
551
- */
552
- interface RetryConfig {
553
- /** Initial delay before first retry (default: 1000ms) */
554
- initialDelayMs: number;
555
- /** Maximum delay between retries (default: 30000ms) */
556
- maxDelayMs: number;
557
- /** Timeout for connection/read operations (default: 30000ms) */
558
- connectionTimeoutMs: number;
559
- }
560
- declare const DEFAULT_RETRY_CONFIG: RetryConfig;
561
- /**
562
- * Calculate exponential backoff delay for a given attempt number.
563
- * Starts at initialDelayMs and doubles each attempt, capped at maxDelayMs.
564
- *
565
- * @param attempt - Zero-based attempt number (0 = first retry)
566
- * @param config - Retry configuration
567
- * @returns Delay in milliseconds
568
- */
569
- declare function calculateBackoff(attempt: number, config: RetryConfig): number;
570
- /**
571
- * Wrap a promise with a timeout. Rejects with TimeoutError if the promise
572
- * doesn't resolve within the specified time.
573
- *
574
- * @param promise - Promise to wrap
575
- * @param timeoutMs - Timeout in milliseconds
576
- * @returns Promise that resolves with the original value or rejects on timeout
577
- */
578
- declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T>;
579
- /**
580
- * Error thrown when an operation times out.
581
- */
582
- declare class TimeoutError extends Error {
583
- constructor(message: string);
584
- }
585
- /**
586
- * Delay execution for a specified number of milliseconds.
587
- */
588
- declare function delay(ms: number): Promise<void>;
589
-
590
594
  interface ReplaySinkContext {
591
595
  slot: Slot;
592
596
  phase: "backfill" | "live";
package/dist/index.d.ts CHANGED
@@ -205,6 +205,47 @@ interface EventReplayOptions {
205
205
  }
206
206
  declare function createEventReplay(options: EventReplayOptions): ReplayStream<Event, string>;
207
207
 
208
+ /**
209
+ * Retry utilities for stream reconnection with exponential backoff.
210
+ */
211
+ interface RetryConfig {
212
+ /** Initial delay before first retry (default: 1000ms) */
213
+ initialDelayMs: number;
214
+ /** Maximum delay between retries (default: 30000ms) */
215
+ maxDelayMs: number;
216
+ /** Timeout for connection/read operations (default: 30000ms) */
217
+ connectionTimeoutMs: number;
218
+ }
219
+ declare const DEFAULT_RETRY_CONFIG: RetryConfig;
220
+ /**
221
+ * Calculate exponential backoff delay for a given attempt number.
222
+ * Starts at initialDelayMs and doubles each attempt, capped at maxDelayMs.
223
+ *
224
+ * @param attempt - Zero-based attempt number (0 = first retry)
225
+ * @param config - Retry configuration
226
+ * @returns Delay in milliseconds
227
+ */
228
+ declare function calculateBackoff(attempt: number, config: RetryConfig): number;
229
+ /**
230
+ * Wrap a promise with a timeout. Rejects with TimeoutError if the promise
231
+ * doesn't resolve within the specified time.
232
+ *
233
+ * @param promise - Promise to wrap
234
+ * @param timeoutMs - Timeout in milliseconds
235
+ * @returns Promise that resolves with the original value or rejects on timeout
236
+ */
237
+ declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T>;
238
+ /**
239
+ * Error thrown when an operation times out.
240
+ */
241
+ declare class TimeoutError extends Error {
242
+ constructor(message: string);
243
+ }
244
+ /**
245
+ * Delay execution for a specified number of milliseconds.
246
+ */
247
+ declare function delay(ms: number): Promise<void>;
248
+
208
249
  /**
209
250
  * Account Replay - streaming account state with backfill reconciliation.
210
251
  *
@@ -310,6 +351,10 @@ interface AccountsByOwnerReplayOptions {
310
351
  };
311
352
  /** Cleanup interval for page assembler (default: 10000ms) */
312
353
  cleanupInterval?: number;
354
+ /** Maximum time to wait for stale reconnect cleanup before creating a fresh stream. */
355
+ reconnectCleanupTimeoutMs?: number;
356
+ /** Retry timings for live stream reconnects (default: DEFAULT_RETRY_CONFIG). */
357
+ retryConfig?: RetryConfig;
313
358
  /** Called when backfill queue is drained. Returns the highest slot seen during backfill. */
314
359
  onBackfillComplete?: (highestSlot: bigint) => void;
315
360
  /** Logger for debug/info/warn/error messages (default: NOOP_LOGGER) */
@@ -546,47 +591,6 @@ declare class PageAssembler {
546
591
  declare const NOOP_LOGGER: ReplayLogger;
547
592
  declare function createConsoleLogger(prefix?: string): ReplayLogger;
548
593
 
549
- /**
550
- * Retry utilities for stream reconnection with exponential backoff.
551
- */
552
- interface RetryConfig {
553
- /** Initial delay before first retry (default: 1000ms) */
554
- initialDelayMs: number;
555
- /** Maximum delay between retries (default: 30000ms) */
556
- maxDelayMs: number;
557
- /** Timeout for connection/read operations (default: 30000ms) */
558
- connectionTimeoutMs: number;
559
- }
560
- declare const DEFAULT_RETRY_CONFIG: RetryConfig;
561
- /**
562
- * Calculate exponential backoff delay for a given attempt number.
563
- * Starts at initialDelayMs and doubles each attempt, capped at maxDelayMs.
564
- *
565
- * @param attempt - Zero-based attempt number (0 = first retry)
566
- * @param config - Retry configuration
567
- * @returns Delay in milliseconds
568
- */
569
- declare function calculateBackoff(attempt: number, config: RetryConfig): number;
570
- /**
571
- * Wrap a promise with a timeout. Rejects with TimeoutError if the promise
572
- * doesn't resolve within the specified time.
573
- *
574
- * @param promise - Promise to wrap
575
- * @param timeoutMs - Timeout in milliseconds
576
- * @returns Promise that resolves with the original value or rejects on timeout
577
- */
578
- declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T>;
579
- /**
580
- * Error thrown when an operation times out.
581
- */
582
- declare class TimeoutError extends Error {
583
- constructor(message: string);
584
- }
585
- /**
586
- * Delay execution for a specified number of milliseconds.
587
- */
588
- declare function delay(ms: number): Promise<void>;
589
-
590
594
  interface ReplaySinkContext {
591
595
  slot: Slot;
592
596
  phase: "backfill" | "live";