request-ledger 0.1.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/README.md +282 -0
- package/dist/index.cjs +1059 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +575 -0
- package/dist/index.js +1044 -0
- package/dist/index.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/types.ts","../src/storage/indexeddb.ts","../src/online/checker.ts","../src/utils/backoff.ts","../src/replay/engine.ts","../src/ledger.ts"],"sourcesContent":[null,null,null,null,null,null],"names":[],"mappings":";;AAAA;;;;;AAKG;AA0XH;AACA;AACA;AAEA;;AAEG;AACG,MAAO,WAAY,SAAQ,KAAK,CAAA;AACpC,IAAA,WAAA,CAAY,OAAe,EAAA;QACzB,KAAK,CAAC,OAAO,CAAC;AACd,QAAA,IAAI,CAAC,IAAI,GAAG,aAAa;IAC3B;AACD;AAED;;AAEG;AACG,MAAO,gBAAiB,SAAQ,WAAW,CAAA;IAC/C,WAAA,CAAY,OAAe,EAAkB,KAAa,EAAA;QACxD,KAAK,CAAC,OAAO,CAAC;QAD6B,IAAA,CAAA,KAAK,GAAL,KAAK;AAEhD,QAAA,IAAI,CAAC,IAAI,GAAG,kBAAkB;IAChC;AACD;AAED;;AAEG;AACG,MAAO,YAAa,SAAQ,WAAW,CAAA;IAC3C,WAAA,CAAY,OAAe,EAAkB,KAAa,EAAA;QACxD,KAAK,CAAC,OAAO,CAAC;QAD6B,IAAA,CAAA,KAAK,GAAL,KAAK;AAEhD,QAAA,IAAI,CAAC,IAAI,GAAG,cAAc;IAC5B;AACD;AAED;;AAEG;AACG,MAAO,kBAAmB,SAAQ,WAAW,CAAA;AACjD,IAAA,WAAA,CAA4B,OAAe,EAAA;AACzC,QAAA,KAAK,CAAC,CAAA,iBAAA,EAAoB,OAAO,CAAA,CAAE,CAAC;QADV,IAAA,CAAA,OAAO,GA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;;;;;;;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request Ledger - Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* This file contains all public TypeScript interfaces and types
|
|
5
|
+
* for the request-ledger library.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Supported HTTP methods for ledger requests.
|
|
9
|
+
*/
|
|
10
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
11
|
+
/**
|
|
12
|
+
* The status of a ledger entry.
|
|
13
|
+
*
|
|
14
|
+
* - `pending`: Request is queued and waiting to be processed
|
|
15
|
+
* - `processing`: Request is currently being executed
|
|
16
|
+
* - `completed`: Request completed successfully (transient, removed after success)
|
|
17
|
+
* - `failed`: Request failed after all retry attempts
|
|
18
|
+
*/
|
|
19
|
+
type EntryStatus = 'pending' | 'processing' | 'completed' | 'failed';
|
|
20
|
+
/**
|
|
21
|
+
* Error information stored with a failed entry.
|
|
22
|
+
*/
|
|
23
|
+
interface EntryError {
|
|
24
|
+
/** Human-readable error message */
|
|
25
|
+
message: string;
|
|
26
|
+
/** Optional error code (e.g., HTTP status code or error type) */
|
|
27
|
+
code?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The HTTP request data stored in a ledger entry.
|
|
31
|
+
*/
|
|
32
|
+
interface StoredRequest {
|
|
33
|
+
url: string;
|
|
34
|
+
method: HttpMethod;
|
|
35
|
+
headers: Record<string, string>;
|
|
36
|
+
body: unknown;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A single entry in the request ledger.
|
|
40
|
+
*
|
|
41
|
+
* This schema is public and will not have hidden fields.
|
|
42
|
+
* All fields are explicitly documented.
|
|
43
|
+
*/
|
|
44
|
+
interface LedgerEntry {
|
|
45
|
+
/** Unique identifier for this entry (provided by caller) */
|
|
46
|
+
id: string;
|
|
47
|
+
/** The HTTP request data */
|
|
48
|
+
request: StoredRequest;
|
|
49
|
+
/** Current status of this entry */
|
|
50
|
+
status: EntryStatus;
|
|
51
|
+
/** Number of times this request has been attempted */
|
|
52
|
+
attemptCount: number;
|
|
53
|
+
/** Timestamp when entry was created (ms since epoch) */
|
|
54
|
+
createdAt: number;
|
|
55
|
+
/** Timestamp of last attempt (ms since epoch) */
|
|
56
|
+
lastAttemptAt?: number;
|
|
57
|
+
/** Error information if status is 'failed' */
|
|
58
|
+
error?: EntryError;
|
|
59
|
+
/** Optional idempotency key for safe replay */
|
|
60
|
+
idempotencyKey?: string;
|
|
61
|
+
/** Optional user-provided metadata */
|
|
62
|
+
metadata?: Record<string, unknown>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Patch type for updating ledger entries.
|
|
66
|
+
* Allows undefined values for optional fields to support clearing them.
|
|
67
|
+
*/
|
|
68
|
+
type LedgerEntryPatch = {
|
|
69
|
+
status?: EntryStatus;
|
|
70
|
+
attemptCount?: number;
|
|
71
|
+
lastAttemptAt?: number;
|
|
72
|
+
error?: EntryError | undefined;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Options for making a request through the ledger.
|
|
76
|
+
*/
|
|
77
|
+
interface RequestOptions {
|
|
78
|
+
/** Unique identifier for this request (required) */
|
|
79
|
+
id: string;
|
|
80
|
+
/** Target URL for the request */
|
|
81
|
+
url: string;
|
|
82
|
+
/** HTTP method */
|
|
83
|
+
method: HttpMethod;
|
|
84
|
+
/** Optional HTTP headers */
|
|
85
|
+
headers?: Record<string, string>;
|
|
86
|
+
/** Optional request body (will be JSON serialized) */
|
|
87
|
+
body?: unknown;
|
|
88
|
+
/** Optional idempotency key for safe replay */
|
|
89
|
+
idempotencyKey?: string;
|
|
90
|
+
/** Optional user-provided metadata */
|
|
91
|
+
metadata?: Record<string, unknown>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Options for processing the ledger queue.
|
|
95
|
+
*/
|
|
96
|
+
interface ProcessOptions {
|
|
97
|
+
/**
|
|
98
|
+
* Number of concurrent requests to process.
|
|
99
|
+
* @default 1
|
|
100
|
+
*/
|
|
101
|
+
concurrency?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Whether to stop processing on first error.
|
|
104
|
+
* @default true
|
|
105
|
+
*/
|
|
106
|
+
stopOnError?: boolean;
|
|
107
|
+
/** Callback invoked when an entry completes successfully */
|
|
108
|
+
onSuccess?: (entry: LedgerEntry) => void;
|
|
109
|
+
/** Callback invoked when an entry fails */
|
|
110
|
+
onFailure?: (entry: LedgerEntry, error: Error) => void;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The current state of the ledger processor.
|
|
114
|
+
*
|
|
115
|
+
* - `idle`: No pending entries, not processing
|
|
116
|
+
* - `pending`: Has pending entries, not currently processing
|
|
117
|
+
* - `processing`: Currently processing entries
|
|
118
|
+
* - `paused`: Processing is paused by user
|
|
119
|
+
* - `error`: Last processing run encountered an error
|
|
120
|
+
*/
|
|
121
|
+
type LedgerState = 'idle' | 'pending' | 'processing' | 'paused' | 'error';
|
|
122
|
+
/**
|
|
123
|
+
* Fixed delay retry strategy.
|
|
124
|
+
*/
|
|
125
|
+
interface FixedRetryStrategy {
|
|
126
|
+
type: 'fixed';
|
|
127
|
+
/** Delay between retries in milliseconds */
|
|
128
|
+
delayMs: number;
|
|
129
|
+
/** Maximum number of retry attempts */
|
|
130
|
+
maxAttempts: number;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Exponential backoff retry strategy.
|
|
134
|
+
*/
|
|
135
|
+
interface ExponentialRetryStrategy {
|
|
136
|
+
type: 'exponential';
|
|
137
|
+
/** Base delay in milliseconds */
|
|
138
|
+
baseMs: number;
|
|
139
|
+
/** Maximum delay in milliseconds */
|
|
140
|
+
maxMs: number;
|
|
141
|
+
/** Maximum number of retry attempts */
|
|
142
|
+
maxAttempts: number;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Manual retry strategy - user controls when to retry.
|
|
146
|
+
*/
|
|
147
|
+
interface ManualRetryStrategy {
|
|
148
|
+
type: 'manual';
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Retry strategy configuration.
|
|
152
|
+
*/
|
|
153
|
+
type RetryStrategy = FixedRetryStrategy | ExponentialRetryStrategy | ManualRetryStrategy;
|
|
154
|
+
/**
|
|
155
|
+
* Lifecycle hooks for observability.
|
|
156
|
+
*/
|
|
157
|
+
interface LedgerHooks {
|
|
158
|
+
/** Called when a request is persisted to the ledger */
|
|
159
|
+
onPersist?: (entry: LedgerEntry) => void;
|
|
160
|
+
/** Called when replay starts for an entry */
|
|
161
|
+
onReplayStart?: (entry: LedgerEntry) => void;
|
|
162
|
+
/** Called when replay succeeds for an entry */
|
|
163
|
+
onReplaySuccess?: (entry: LedgerEntry, response: Response) => void;
|
|
164
|
+
/** Called when replay fails for an entry */
|
|
165
|
+
onReplayFailure?: (entry: LedgerEntry, error: Error) => void;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Custom online check function.
|
|
169
|
+
* Should return true if online, false if offline.
|
|
170
|
+
*/
|
|
171
|
+
type OnlineCheckFn = () => Promise<boolean>;
|
|
172
|
+
/**
|
|
173
|
+
* Configuration for online detection.
|
|
174
|
+
*/
|
|
175
|
+
interface OnlineCheckConfig {
|
|
176
|
+
/**
|
|
177
|
+
* URL to ping for online detection.
|
|
178
|
+
* If not provided, only navigator.onLine is used.
|
|
179
|
+
*/
|
|
180
|
+
pingUrl?: string;
|
|
181
|
+
/**
|
|
182
|
+
* Timeout for ping requests in milliseconds.
|
|
183
|
+
* @default 5000
|
|
184
|
+
*/
|
|
185
|
+
pingTimeout?: number;
|
|
186
|
+
/**
|
|
187
|
+
* Custom online check function.
|
|
188
|
+
* If provided, overrides default behavior.
|
|
189
|
+
*/
|
|
190
|
+
customCheck?: OnlineCheckFn;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Configuration for IndexedDB storage.
|
|
194
|
+
*/
|
|
195
|
+
interface IndexedDBStorageConfig {
|
|
196
|
+
/**
|
|
197
|
+
* Name of the IndexedDB database.
|
|
198
|
+
* @default "request-ledger"
|
|
199
|
+
*/
|
|
200
|
+
dbName?: string;
|
|
201
|
+
/**
|
|
202
|
+
* Name of the object store.
|
|
203
|
+
* @default "entries"
|
|
204
|
+
*/
|
|
205
|
+
storeName?: string;
|
|
206
|
+
/**
|
|
207
|
+
* Maximum number of entries to store.
|
|
208
|
+
* When exceeded, oldest entries are evicted.
|
|
209
|
+
* @default 1000
|
|
210
|
+
*/
|
|
211
|
+
maxEntries?: number;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Configuration options for creating a ledger instance.
|
|
215
|
+
*/
|
|
216
|
+
interface LedgerConfig {
|
|
217
|
+
/**
|
|
218
|
+
* Custom storage adapter.
|
|
219
|
+
* If not provided, IndexedDB storage is used.
|
|
220
|
+
*/
|
|
221
|
+
storage?: LedgerStorage;
|
|
222
|
+
/**
|
|
223
|
+
* Configuration for IndexedDB storage (ignored if custom storage provided).
|
|
224
|
+
*/
|
|
225
|
+
storageConfig?: IndexedDBStorageConfig;
|
|
226
|
+
/**
|
|
227
|
+
* Retry strategy configuration.
|
|
228
|
+
* @default { type: 'exponential', baseMs: 1000, maxMs: 30000, maxAttempts: 3 }
|
|
229
|
+
*/
|
|
230
|
+
retry?: RetryStrategy;
|
|
231
|
+
/**
|
|
232
|
+
* Online detection configuration.
|
|
233
|
+
*/
|
|
234
|
+
onlineCheck?: OnlineCheckConfig;
|
|
235
|
+
/**
|
|
236
|
+
* Lifecycle hooks for observability.
|
|
237
|
+
*/
|
|
238
|
+
hooks?: LedgerHooks;
|
|
239
|
+
/**
|
|
240
|
+
* Header name for idempotency key.
|
|
241
|
+
* @default "X-Idempotency-Key"
|
|
242
|
+
*/
|
|
243
|
+
idempotencyHeader?: string;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Pluggable storage interface for the ledger.
|
|
247
|
+
*
|
|
248
|
+
* Implementations must ensure:
|
|
249
|
+
* - Writes are atomic
|
|
250
|
+
* - Entries survive page reloads
|
|
251
|
+
* - Proper error handling
|
|
252
|
+
*/
|
|
253
|
+
interface LedgerStorage {
|
|
254
|
+
/**
|
|
255
|
+
* Store a new entry.
|
|
256
|
+
* Should throw if entry with same ID already exists.
|
|
257
|
+
*/
|
|
258
|
+
put(entry: LedgerEntry): Promise<void>;
|
|
259
|
+
/**
|
|
260
|
+
* Get all entries, ordered by createdAt ascending.
|
|
261
|
+
*/
|
|
262
|
+
getAll(): Promise<LedgerEntry[]>;
|
|
263
|
+
/**
|
|
264
|
+
* Get a single entry by ID.
|
|
265
|
+
*/
|
|
266
|
+
get(id: string): Promise<LedgerEntry | undefined>;
|
|
267
|
+
/**
|
|
268
|
+
* Update an existing entry.
|
|
269
|
+
* Should throw if entry does not exist.
|
|
270
|
+
*/
|
|
271
|
+
update(id: string, patch: LedgerEntryPatch): Promise<void>;
|
|
272
|
+
/**
|
|
273
|
+
* Remove an entry by ID.
|
|
274
|
+
*/
|
|
275
|
+
remove(id: string): Promise<void>;
|
|
276
|
+
/**
|
|
277
|
+
* Remove all entries.
|
|
278
|
+
*/
|
|
279
|
+
clear(): Promise<void>;
|
|
280
|
+
/**
|
|
281
|
+
* Get the count of entries.
|
|
282
|
+
*/
|
|
283
|
+
count(): Promise<number>;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Base error class for request-ledger errors.
|
|
287
|
+
*/
|
|
288
|
+
declare class LedgerError extends Error {
|
|
289
|
+
constructor(message: string);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Error thrown when persistence fails.
|
|
293
|
+
*/
|
|
294
|
+
declare class PersistenceError extends LedgerError {
|
|
295
|
+
readonly cause?: Error | undefined;
|
|
296
|
+
constructor(message: string, cause?: Error | undefined);
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Error thrown when a network request fails.
|
|
300
|
+
*/
|
|
301
|
+
declare class NetworkError extends LedgerError {
|
|
302
|
+
readonly cause?: Error | undefined;
|
|
303
|
+
constructor(message: string, cause?: Error | undefined);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Error thrown when an entry is not found.
|
|
307
|
+
*/
|
|
308
|
+
declare class EntryNotFoundError extends LedgerError {
|
|
309
|
+
readonly entryId: string;
|
|
310
|
+
constructor(entryId: string);
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Error thrown when a duplicate entry is detected.
|
|
314
|
+
*/
|
|
315
|
+
declare class DuplicateEntryError extends LedgerError {
|
|
316
|
+
readonly entryId: string;
|
|
317
|
+
constructor(entryId: string);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Request Ledger
|
|
322
|
+
*
|
|
323
|
+
* A durable, client-side HTTP request ledger for web applications
|
|
324
|
+
* operating on unreliable networks.
|
|
325
|
+
*
|
|
326
|
+
* Core behaviors:
|
|
327
|
+
* - Records API request intent when offline or network is unstable
|
|
328
|
+
* - Persists requests across page reloads, crashes, and browser restarts
|
|
329
|
+
* - Replays requests deterministically when connectivity is restored
|
|
330
|
+
* - Never silently drops requests
|
|
331
|
+
* - Never assumes business-level conflict resolution
|
|
332
|
+
*/
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* The main RequestLedger class.
|
|
336
|
+
*
|
|
337
|
+
* Provides a durable request queue that persists across page reloads
|
|
338
|
+
* and replays requests when connectivity is restored.
|
|
339
|
+
*/
|
|
340
|
+
declare class RequestLedger {
|
|
341
|
+
private readonly storage;
|
|
342
|
+
private readonly onlineCheck;
|
|
343
|
+
private readonly retryStrategy;
|
|
344
|
+
private readonly hooks;
|
|
345
|
+
private readonly idempotencyHeader;
|
|
346
|
+
private readonly replayEngine;
|
|
347
|
+
private isDestroyed;
|
|
348
|
+
constructor(config?: LedgerConfig);
|
|
349
|
+
/**
|
|
350
|
+
* Make a request through the ledger.
|
|
351
|
+
*
|
|
352
|
+
* Behavior:
|
|
353
|
+
* - If online → attempt immediately
|
|
354
|
+
* - If offline or request fails due to network → persist to ledger
|
|
355
|
+
* - If persistence fails → throw explicitly
|
|
356
|
+
*
|
|
357
|
+
* @param options The request options
|
|
358
|
+
* @returns Response if request succeeded immediately, void if queued
|
|
359
|
+
*/
|
|
360
|
+
request(options: RequestOptions): Promise<Response | void>;
|
|
361
|
+
/**
|
|
362
|
+
* Execute an HTTP request.
|
|
363
|
+
*/
|
|
364
|
+
private executeRequest;
|
|
365
|
+
/**
|
|
366
|
+
* Persist a request to the ledger.
|
|
367
|
+
*/
|
|
368
|
+
private persistRequest;
|
|
369
|
+
/**
|
|
370
|
+
* Process pending entries in the ledger.
|
|
371
|
+
*
|
|
372
|
+
* @param options Processing options
|
|
373
|
+
*/
|
|
374
|
+
process(options?: ProcessOptions): Promise<void>;
|
|
375
|
+
/**
|
|
376
|
+
* Pause processing.
|
|
377
|
+
*/
|
|
378
|
+
pause(): void;
|
|
379
|
+
/**
|
|
380
|
+
* Resume processing.
|
|
381
|
+
*/
|
|
382
|
+
resume(): void;
|
|
383
|
+
/**
|
|
384
|
+
* Clear all completed entries.
|
|
385
|
+
*
|
|
386
|
+
* Note: In this implementation, completed entries are automatically
|
|
387
|
+
* removed, so this is a no-op. Provided for API completeness.
|
|
388
|
+
*/
|
|
389
|
+
clearCompleted(): Promise<void>;
|
|
390
|
+
/**
|
|
391
|
+
* Get the current state of the ledger.
|
|
392
|
+
*/
|
|
393
|
+
getState(): Promise<LedgerState>;
|
|
394
|
+
/**
|
|
395
|
+
* List all entries in the ledger.
|
|
396
|
+
*/
|
|
397
|
+
list(): Promise<LedgerEntry[]>;
|
|
398
|
+
/**
|
|
399
|
+
* Get a single entry by ID.
|
|
400
|
+
*/
|
|
401
|
+
get(id: string): Promise<LedgerEntry | undefined>;
|
|
402
|
+
/**
|
|
403
|
+
* Manually retry a failed entry.
|
|
404
|
+
*
|
|
405
|
+
* This is useful when using the 'manual' retry strategy.
|
|
406
|
+
*
|
|
407
|
+
* @param id The entry ID to retry
|
|
408
|
+
*/
|
|
409
|
+
retry(id: string): Promise<void>;
|
|
410
|
+
/**
|
|
411
|
+
* Remove a specific entry from the ledger.
|
|
412
|
+
*
|
|
413
|
+
* @param id The entry ID to remove
|
|
414
|
+
*/
|
|
415
|
+
remove(id: string): Promise<void>;
|
|
416
|
+
/**
|
|
417
|
+
* Clear all entries from the ledger.
|
|
418
|
+
*/
|
|
419
|
+
clear(): Promise<void>;
|
|
420
|
+
/**
|
|
421
|
+
* Destroy the ledger instance.
|
|
422
|
+
*
|
|
423
|
+
* This closes the storage connection and prevents further operations.
|
|
424
|
+
*/
|
|
425
|
+
destroy(): Promise<void>;
|
|
426
|
+
/**
|
|
427
|
+
* Ensure the ledger is not destroyed.
|
|
428
|
+
*/
|
|
429
|
+
private ensureNotDestroyed;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Create a new RequestLedger instance.
|
|
433
|
+
*
|
|
434
|
+
* @param config Configuration options
|
|
435
|
+
* @returns A new RequestLedger instance
|
|
436
|
+
*/
|
|
437
|
+
declare function createLedger(config?: LedgerConfig): RequestLedger;
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* IndexedDB Storage Adapter
|
|
441
|
+
*
|
|
442
|
+
* Implements the LedgerStorage interface using IndexedDB for
|
|
443
|
+
* persistent, reliable storage that survives page reloads.
|
|
444
|
+
*/
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* IndexedDB implementation of LedgerStorage.
|
|
448
|
+
*
|
|
449
|
+
* Features:
|
|
450
|
+
* - Atomic writes using transactions
|
|
451
|
+
* - Entries ordered by createdAt
|
|
452
|
+
* - Max size enforcement with oldest-first eviction
|
|
453
|
+
* - Proper error handling
|
|
454
|
+
*/
|
|
455
|
+
declare class IndexedDBStorage implements LedgerStorage {
|
|
456
|
+
private readonly dbName;
|
|
457
|
+
private readonly storeName;
|
|
458
|
+
private readonly maxEntries;
|
|
459
|
+
private db;
|
|
460
|
+
private dbPromise;
|
|
461
|
+
constructor(config?: IndexedDBStorageConfig);
|
|
462
|
+
/**
|
|
463
|
+
* Get or initialize the database connection.
|
|
464
|
+
*/
|
|
465
|
+
private getDb;
|
|
466
|
+
/**
|
|
467
|
+
* Execute a transaction and return a promise.
|
|
468
|
+
*/
|
|
469
|
+
private transaction;
|
|
470
|
+
/**
|
|
471
|
+
* Store a new entry.
|
|
472
|
+
* Throws DuplicateEntryError if entry with same ID exists.
|
|
473
|
+
* Evicts oldest entries if maxEntries is exceeded.
|
|
474
|
+
*/
|
|
475
|
+
put(entry: LedgerEntry): Promise<void>;
|
|
476
|
+
/**
|
|
477
|
+
* Evict oldest entries if count exceeds maxEntries.
|
|
478
|
+
*/
|
|
479
|
+
private evictIfNeeded;
|
|
480
|
+
/**
|
|
481
|
+
* Get all entries ordered by createdAt ascending.
|
|
482
|
+
*/
|
|
483
|
+
getAll(): Promise<LedgerEntry[]>;
|
|
484
|
+
/**
|
|
485
|
+
* Get a single entry by ID.
|
|
486
|
+
*/
|
|
487
|
+
get(id: string): Promise<LedgerEntry | undefined>;
|
|
488
|
+
/**
|
|
489
|
+
* Update an existing entry.
|
|
490
|
+
*/
|
|
491
|
+
update(id: string, patch: LedgerEntryPatch): Promise<void>;
|
|
492
|
+
/**
|
|
493
|
+
* Remove an entry by ID.
|
|
494
|
+
*/
|
|
495
|
+
remove(id: string): Promise<void>;
|
|
496
|
+
/**
|
|
497
|
+
* Remove all entries.
|
|
498
|
+
*/
|
|
499
|
+
clear(): Promise<void>;
|
|
500
|
+
/**
|
|
501
|
+
* Get the count of entries.
|
|
502
|
+
*/
|
|
503
|
+
count(): Promise<number>;
|
|
504
|
+
/**
|
|
505
|
+
* Deserialize an entry from storage.
|
|
506
|
+
*/
|
|
507
|
+
private deserializeEntry;
|
|
508
|
+
/**
|
|
509
|
+
* Close the database connection.
|
|
510
|
+
*/
|
|
511
|
+
close(): void;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Online Detection Module
|
|
516
|
+
*
|
|
517
|
+
* Provides reliable online detection that doesn't rely solely on navigator.onLine.
|
|
518
|
+
* Supports custom ping endpoints and user-provided check functions.
|
|
519
|
+
*/
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Creates an online checker function based on the provided configuration.
|
|
523
|
+
*
|
|
524
|
+
* The checker combines multiple signals:
|
|
525
|
+
* 1. navigator.onLine (fast but unreliable)
|
|
526
|
+
* 2. Optional ping endpoint (reliable but slower)
|
|
527
|
+
* 3. Custom check function (user-defined)
|
|
528
|
+
*
|
|
529
|
+
* @param config Online check configuration
|
|
530
|
+
* @returns Function that returns true if online, false if offline
|
|
531
|
+
*/
|
|
532
|
+
declare function createOnlineChecker(config?: OnlineCheckConfig): OnlineCheckFn;
|
|
533
|
+
/**
|
|
534
|
+
* Check if an error indicates a network failure (vs application error).
|
|
535
|
+
*
|
|
536
|
+
* This is used to determine if a request should be queued vs reported as failed.
|
|
537
|
+
*/
|
|
538
|
+
declare function isNetworkError(error: unknown): boolean;
|
|
539
|
+
/**
|
|
540
|
+
* Check if an HTTP status code indicates a retryable server error.
|
|
541
|
+
*
|
|
542
|
+
* Returns true for 5xx errors (server errors).
|
|
543
|
+
* Returns false for 4xx errors (client errors - these should not be retried).
|
|
544
|
+
*/
|
|
545
|
+
declare function isRetryableStatusCode(status: number): boolean;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Backoff Utilities
|
|
549
|
+
*
|
|
550
|
+
* Provides delay calculation for retry strategies.
|
|
551
|
+
*/
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Calculate the delay before the next retry attempt.
|
|
555
|
+
*
|
|
556
|
+
* @param strategy The retry strategy configuration
|
|
557
|
+
* @param attemptCount The number of attempts made so far (1-indexed)
|
|
558
|
+
* @returns Delay in milliseconds, or null if max attempts reached
|
|
559
|
+
*/
|
|
560
|
+
declare function calculateBackoffDelay(strategy: RetryStrategy, attemptCount: number): number | null;
|
|
561
|
+
/**
|
|
562
|
+
* Check if more retry attempts are allowed.
|
|
563
|
+
*
|
|
564
|
+
* @param strategy The retry strategy configuration
|
|
565
|
+
* @param attemptCount The number of attempts made so far
|
|
566
|
+
* @returns true if more attempts are allowed
|
|
567
|
+
*/
|
|
568
|
+
declare function canRetry(strategy: RetryStrategy, attemptCount: number): boolean;
|
|
569
|
+
/**
|
|
570
|
+
* Create a promise that resolves after the specified delay.
|
|
571
|
+
*/
|
|
572
|
+
declare function delay(ms: number): Promise<void>;
|
|
573
|
+
|
|
574
|
+
export { DuplicateEntryError, EntryNotFoundError, IndexedDBStorage, LedgerError, NetworkError, PersistenceError, RequestLedger, calculateBackoffDelay, canRetry, createLedger, createOnlineChecker, delay, isNetworkError, isRetryableStatusCode };
|
|
575
|
+
export type { EntryError, EntryStatus, ExponentialRetryStrategy, FixedRetryStrategy, HttpMethod, IndexedDBStorageConfig, LedgerConfig, LedgerEntry, LedgerEntryPatch, LedgerHooks, LedgerState, LedgerStorage, ManualRetryStrategy, OnlineCheckConfig, OnlineCheckFn, ProcessOptions, RequestOptions, RetryStrategy, StoredRequest };
|