@pol-studios/powersync 1.0.3 → 1.0.6
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/chunk-5FIMA26D.js +1 -0
- package/dist/{chunk-C2RSTGDC.js → chunk-62J2DPKX.js} +497 -43
- package/dist/chunk-62J2DPKX.js.map +1 -0
- package/dist/{chunk-GMFDCVMZ.js → chunk-KCDG2MNP.js} +161 -15
- package/dist/chunk-KCDG2MNP.js.map +1 -0
- package/dist/chunk-PAFBKNL3.js +99 -0
- package/dist/chunk-PAFBKNL3.js.map +1 -0
- package/dist/{chunk-OTJXIRWX.js → chunk-R4YFWQ3Q.js} +1 -1
- package/dist/chunk-R4YFWQ3Q.js.map +1 -0
- package/dist/connector/index.d.ts +2 -1
- package/dist/connector/index.js +4 -1
- package/dist/failed-upload-store-C0cLxxPz.d.ts +33 -0
- package/dist/{index-Cb-NI0Ct.d.ts → index-l3iL9Jte.d.ts} +72 -1
- package/dist/index.d.ts +142 -4
- package/dist/index.js +52 -6
- package/dist/index.native.d.ts +4 -3
- package/dist/index.native.js +52 -6
- package/dist/index.web.d.ts +4 -3
- package/dist/index.web.js +52 -6
- package/dist/provider/index.d.ts +258 -3
- package/dist/provider/index.js +28 -3
- package/dist/sync/index.d.ts +1 -0
- package/dist/sync/index.js +9 -3
- package/package.json +1 -1
- package/dist/chunk-7JQZBZ5N.js +0 -1
- package/dist/chunk-C2RSTGDC.js.map +0 -1
- package/dist/chunk-GMFDCVMZ.js.map +0 -1
- package/dist/chunk-OTJXIRWX.js.map +0 -1
- /package/dist/{chunk-7JQZBZ5N.js.map → chunk-5FIMA26D.js.map} +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
interface FailedUpload {
|
|
2
|
+
id: string;
|
|
3
|
+
table: string;
|
|
4
|
+
operation: 'PUT' | 'PATCH' | 'DELETE';
|
|
5
|
+
data: Record<string, unknown>;
|
|
6
|
+
error: {
|
|
7
|
+
message: string;
|
|
8
|
+
code?: string;
|
|
9
|
+
category: 'transient' | 'permanent' | 'unknown';
|
|
10
|
+
};
|
|
11
|
+
retryCount: number;
|
|
12
|
+
lastAttempt: number;
|
|
13
|
+
nextRetryAt: number;
|
|
14
|
+
}
|
|
15
|
+
declare class FailedUploadStore {
|
|
16
|
+
private uploads;
|
|
17
|
+
private initialized;
|
|
18
|
+
private asyncStorageAvailable;
|
|
19
|
+
constructor();
|
|
20
|
+
private checkAsyncStorageAvailability;
|
|
21
|
+
private generateId;
|
|
22
|
+
add(upload: Omit<FailedUpload, 'id'>): string;
|
|
23
|
+
update(id: string, updates: Partial<FailedUpload>): void;
|
|
24
|
+
remove(id: string): void;
|
|
25
|
+
getAll(): FailedUpload[];
|
|
26
|
+
getRetryable(): FailedUpload[];
|
|
27
|
+
clear(): void;
|
|
28
|
+
load(): Promise<void>;
|
|
29
|
+
persist(): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
declare const failedUploadStore: FailedUploadStore;
|
|
32
|
+
|
|
33
|
+
export { type FailedUpload as F, FailedUploadStore as a, failedUploadStore as f };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
2
|
import { C as CrudEntry, i as ClassifiedError, P as PowerSyncBackendConnector, A as AbstractPowerSyncDatabase } from './types-afHtE1U_.js';
|
|
3
3
|
import { LoggerAdapter } from './platform/index.js';
|
|
4
|
+
import { F as FailedUpload } from './failed-upload-store-C0cLxxPz.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Conflict Types for @pol-studios/powersync
|
|
@@ -161,6 +162,12 @@ interface SupabaseConnectorOptions {
|
|
|
161
162
|
* Use this to notify the UI layer about detected conflicts.
|
|
162
163
|
*/
|
|
163
164
|
conflictBus?: ConflictBus;
|
|
165
|
+
/**
|
|
166
|
+
* Optional: Configuration for retry behavior on upload failures.
|
|
167
|
+
* Allows customizing retry attempts, delays, and backoff for different error types.
|
|
168
|
+
* @default DEFAULT_RETRY_CONFIG
|
|
169
|
+
*/
|
|
170
|
+
retryConfig?: Partial<RetryConfig>;
|
|
164
171
|
}
|
|
165
172
|
/**
|
|
166
173
|
* Configuration passed to PowerSyncProvider for connector setup
|
|
@@ -192,6 +199,12 @@ interface ConnectorConfig {
|
|
|
192
199
|
/** Refresh token when it expires within this many seconds (default: 60) */
|
|
193
200
|
refreshThresholdSeconds?: number;
|
|
194
201
|
};
|
|
202
|
+
/**
|
|
203
|
+
* Optional retry configuration for upload failures.
|
|
204
|
+
* Allows customizing retry attempts, delays, and backoff for different error types.
|
|
205
|
+
* @default DEFAULT_RETRY_CONFIG
|
|
206
|
+
*/
|
|
207
|
+
retryConfig?: Partial<RetryConfig>;
|
|
195
208
|
}
|
|
196
209
|
/**
|
|
197
210
|
* Function that determines which Supabase schema a table belongs to.
|
|
@@ -247,6 +260,32 @@ interface PowerSyncCredentials {
|
|
|
247
260
|
/** When the token expires */
|
|
248
261
|
expiresAt?: Date;
|
|
249
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* Configuration for a single retry category
|
|
265
|
+
*/
|
|
266
|
+
interface RetryStrategyConfig {
|
|
267
|
+
/** Maximum number of retry attempts */
|
|
268
|
+
maxRetries: number;
|
|
269
|
+
/** Initial delay in milliseconds */
|
|
270
|
+
baseDelayMs: number;
|
|
271
|
+
/** Maximum delay cap in milliseconds */
|
|
272
|
+
maxDelayMs: number;
|
|
273
|
+
/** Multiplier for exponential backoff */
|
|
274
|
+
backoffMultiplier: number;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Full retry configuration for the connector
|
|
278
|
+
*/
|
|
279
|
+
interface RetryConfig {
|
|
280
|
+
/** Retry config for transient errors (network, server 5xx) */
|
|
281
|
+
transient: RetryStrategyConfig;
|
|
282
|
+
/** Retry config for permanent errors (RLS, validation, constraints) */
|
|
283
|
+
permanent: RetryStrategyConfig;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Default retry configuration
|
|
287
|
+
*/
|
|
288
|
+
declare const DEFAULT_RETRY_CONFIG: RetryConfig;
|
|
250
289
|
|
|
251
290
|
/**
|
|
252
291
|
* Supabase Connector for PowerSync
|
|
@@ -323,12 +362,44 @@ declare class SupabaseConnector implements PowerSyncBackendConnector {
|
|
|
323
362
|
private activeProjectIds;
|
|
324
363
|
private resolvedConflicts;
|
|
325
364
|
private unsubscribeResolution?;
|
|
365
|
+
private retryConfig;
|
|
366
|
+
private autoRetryPaused;
|
|
326
367
|
constructor(options: SupabaseConnectorOptions);
|
|
327
368
|
/**
|
|
328
369
|
* Clean up resources (unsubscribe from event listeners).
|
|
329
370
|
* Call this when the connector is no longer needed.
|
|
330
371
|
*/
|
|
331
372
|
destroy(): void;
|
|
373
|
+
/**
|
|
374
|
+
* Pause automatic retry of failed uploads.
|
|
375
|
+
* Use this when the user goes offline intentionally or wants manual control.
|
|
376
|
+
*/
|
|
377
|
+
pauseAutoRetry(): void;
|
|
378
|
+
/**
|
|
379
|
+
* Resume automatic retry of failed uploads.
|
|
380
|
+
*/
|
|
381
|
+
resumeAutoRetry(): void;
|
|
382
|
+
/**
|
|
383
|
+
* Manually retry all failed uploads that are ready for retry.
|
|
384
|
+
* This processes entries from the failed upload store.
|
|
385
|
+
*/
|
|
386
|
+
retryFailedUploads(): Promise<void>;
|
|
387
|
+
/**
|
|
388
|
+
* Clear all failed uploads from the store.
|
|
389
|
+
* Use with caution - this discards all pending retries.
|
|
390
|
+
*/
|
|
391
|
+
clearFailedUploads(): void;
|
|
392
|
+
/**
|
|
393
|
+
* Get all failed uploads from the store.
|
|
394
|
+
*/
|
|
395
|
+
getFailedUploads(): FailedUpload[];
|
|
396
|
+
/**
|
|
397
|
+
* Process a single CRUD entry with exponential backoff retry.
|
|
398
|
+
*
|
|
399
|
+
* @param entry - The CRUD entry to process
|
|
400
|
+
* @throws Error if all retries exhausted (for critical failures)
|
|
401
|
+
*/
|
|
402
|
+
private processWithRetry;
|
|
332
403
|
/**
|
|
333
404
|
* Set the active project IDs for scoped sync.
|
|
334
405
|
* Call this when user selects/opens projects.
|
|
@@ -386,4 +457,4 @@ declare class SupabaseConnector implements PowerSyncBackendConnector {
|
|
|
386
457
|
private processCrudEntry;
|
|
387
458
|
}
|
|
388
459
|
|
|
389
|
-
export { type ConnectorConfig as C, type FieldConflict as F, type PowerSyncCredentials as P, type
|
|
460
|
+
export { type ConnectorConfig as C, DEFAULT_RETRY_CONFIG as D, type FieldConflict as F, type PowerSyncCredentials as P, type RetryStrategyConfig as R, SupabaseConnector as S, type SupabaseConnectorOptions as a, type SchemaRouter as b, type CrudHandler as c, defaultSchemaRouter as d, type RetryConfig as e, ConflictBus as f, type ConflictCheckResult as g, type ConflictResolution as h, type ConflictHandler as i, type ConflictDetectionConfig as j, type ConflictListener as k, type ResolutionListener as l };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,155 @@
|
|
|
1
1
|
import { A as AbstractPowerSyncDatabase } from './types-afHtE1U_.js';
|
|
2
2
|
export { k as CacheStats, i as ClassifiedError, j as CompactResult, h as CompletedTransaction, b as ConnectionHealth, o as CountRow, C as CrudEntry, l as CrudTransaction, n as DbStatRow, D as DownloadProgress, E as EntitySyncState, F as FailedTransaction, r as FreelistCountRow, s as IntegrityCheckRow, I as IntegrityResult, q as PageCountRow, p as PageSizeRow, P as PowerSyncBackendConnector, m as SqliteTableRow, c as StorageInfo, d as StorageQuota, f as SyncError, g as SyncErrorType, e as SyncMetrics, S as SyncMode, a as SyncStatus, T as TableCacheStats } from './types-afHtE1U_.js';
|
|
3
3
|
export { ATTACHMENT_DOWNLOAD_TIMEOUT_MS, ATTACHMENT_RETRY_DELAY_MS, AttachmentError, COMPRESSION_MAX_WIDTH, COMPRESSION_SKIP_SIZE_BYTES, COMPRESSION_TARGET_SIZE_BYTES, ConfigurationError, ConnectorError, DEFAULT_ATTACHMENT_CACHE_SIZE, DEFAULT_ATTACHMENT_CONCURRENCY, DEFAULT_COMPRESSION_QUALITY, DEFAULT_MAX_RETRY_ATTEMPTS, DEFAULT_RETRY_BACKOFF_MULTIPLIER, DEFAULT_RETRY_BASE_DELAY_MS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_SYNC_INTERVAL_MS, DEFAULT_SYNC_MODE, DOWNLOAD_STOP_THRESHOLD, EVICTION_TRIGGER_THRESHOLD, HEALTH_CHECK_INTERVAL_MS, HEALTH_CHECK_TIMEOUT_MS, InitializationError, LATENCY_DEGRADED_THRESHOLD_MS, MAX_CONSECUTIVE_FAILURES, PlatformAdapterError, PowerSyncError, STATS_CACHE_TTL_MS, STATUS_NOTIFY_THROTTLE_MS, STORAGE_CRITICAL_THRESHOLD, STORAGE_KEY_ATTACHMENT_SETTINGS, STORAGE_KEY_ENABLED, STORAGE_KEY_METRICS, STORAGE_KEY_PAUSED, STORAGE_KEY_PREFIX, STORAGE_KEY_SYNC_MODE, STORAGE_WARNING_THRESHOLD, SyncOperationError, classifyError, classifySupabaseError, createSyncError, extractEntityIds, extractTableNames, generateFailureId, toSyncOperationError } from './core/index.js';
|
|
4
|
-
import {
|
|
5
|
-
export {
|
|
4
|
+
import { j as ConflictDetectionConfig, g as ConflictCheckResult } from './index-l3iL9Jte.js';
|
|
5
|
+
export { f as ConflictBus, i as ConflictHandler, k as ConflictListener, h as ConflictResolution, C as ConnectorConfig, c as CrudHandler, D as DEFAULT_RETRY_CONFIG, F as FieldConflict, P as PowerSyncCredentials, l as ResolutionListener, e as RetryConfig, R as RetryStrategyConfig, b as SchemaRouter, S as SupabaseConnector, a as SupabaseConnectorOptions, d as defaultSchemaRouter } from './index-l3iL9Jte.js';
|
|
6
6
|
export { AttachmentQueue, AttachmentQueueConfig, AttachmentRecord, AttachmentSourceConfig, AttachmentState, AttachmentStatsRow, AttachmentStorageAdapter, AttachmentSyncStats, AttachmentSyncStatus, CacheConfig, CacheFileRow, CachedSizeRow, CompressionConfig, DEFAULT_CACHE_CONFIG, DEFAULT_COMPRESSION_CONFIG, DEFAULT_DOWNLOAD_CONFIG, DownloadConfig, DownloadPhase, DownloadStatus, EvictRow, IdRow } from './attachments/index.js';
|
|
7
7
|
export { e as HealthCheckResult, H as HealthMonitorOptions, M as MetricsCollectorOptions, P as PowerSyncRawStatus, c as SyncControlActions, f as SyncEvent, g as SyncEventListener, d as SyncOperationData, S as SyncScope, a as SyncStatusState, b as SyncStatusTrackerOptions, U as Unsubscribe } from './types-Cd7RhNqf.js';
|
|
8
8
|
export { HealthMonitor, MetricsCollector, SyncStatusTracker } from './sync/index.js';
|
|
9
|
+
export { F as FailedUpload, a as FailedUploadStore, f as failedUploadStore } from './failed-upload-store-C0cLxxPz.js';
|
|
9
10
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
10
|
-
export { AttachmentQueueContext, ConnectionHealthContext, ConnectionHealthContextValue, DEFAULT_CONNECTION_HEALTH, DEFAULT_SYNC_CONFIG, DEFAULT_SYNC_METRICS, DEFAULT_SYNC_STATUS, EntitySyncStatusResult, PowerSyncConfig, PowerSyncContext, PowerSyncContextValue, PowerSyncProvider, PowerSyncProviderProps, SyncActivityResult, SyncConfig, SyncMetricsContext, SyncMetricsContextValue, SyncStatusContext, SyncStatusContextValue, UploadStatusResult, useAttachmentQueue, useConnectionHealth, useDatabase, useDownloadProgress, useEntitySyncStatus, useIsSyncing, useOnlineStatus, usePendingMutations, usePlatform, usePowerSync, useSyncActivity, useSyncControl, useSyncMetrics, useSyncMode, useSyncStatus, useUploadStatus } from './provider/index.js';
|
|
11
|
+
export { AttachmentQueueContext, CompletedTransactionsContext, CompletedTransactionsContextValue, ConnectionHealthContext, ConnectionHealthContextValue, ConnectionStatusContext, ConnectionStatusContextValue, DEFAULT_CONNECTION_HEALTH, DEFAULT_SYNC_CONFIG, DEFAULT_SYNC_METRICS, DEFAULT_SYNC_STATUS, EntitySyncStatusResult, FailedTransactionsContext, FailedTransactionsContextValue, PendingMutationsContext, PendingMutationsContextValue, PowerSyncConfig, PowerSyncContext, PowerSyncContextValue, PowerSyncProvider, PowerSyncProviderProps, SyncActivityContext, SyncActivityContextValue, SyncActivityResult, SyncConfig, SyncMetricsContext, SyncMetricsContextValue, SyncModeContext, SyncModeContextValue, SyncStatusContext, SyncStatusContextValue, UploadStatusResult, useAttachmentQueue, useCompletedTransactionsContext, useConnectionHealth, useConnectionStatus, useDatabase, useDownloadProgress, useEntitySyncStatus, useFailedTransactionsContext, useIsSyncing, useOnlineStatus, usePendingMutations, usePendingMutationsContext, usePlatform, usePowerSync, useSyncActivity, useSyncActivityContext, useSyncControl, useSyncMetrics, useSyncMode, useSyncModeContext, useSyncStatus, useUploadStatus } from './provider/index.js';
|
|
11
12
|
export { AsyncStorageAdapter, CompressedImage, CompressionOptions, ConnectionType, DatabaseOptions, FileInfo, FileSystemAdapter, ImageProcessorAdapter, LoggerAdapter, NetworkAdapter, PlatformAdapter, PlatformType, detectPlatform } from './platform/index.js';
|
|
12
13
|
import '@tanstack/react-query';
|
|
13
14
|
import 'react';
|
|
14
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Exponential backoff retry utilities for resilient network operations.
|
|
18
|
+
*
|
|
19
|
+
* Provides configurable retry logic with exponential backoff, jitter,
|
|
20
|
+
* and abort signal support for cancellation.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Configuration for exponential backoff retry behavior.
|
|
24
|
+
*/
|
|
25
|
+
interface BackoffConfig {
|
|
26
|
+
/** Maximum number of retry attempts (0 = no retries, just one attempt) */
|
|
27
|
+
maxRetries: number;
|
|
28
|
+
/** Base delay in milliseconds before first retry */
|
|
29
|
+
baseDelayMs: number;
|
|
30
|
+
/** Maximum delay cap in milliseconds */
|
|
31
|
+
maxDelayMs: number;
|
|
32
|
+
/** Multiplier applied to delay for each subsequent retry (typically 2) */
|
|
33
|
+
backoffMultiplier: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Options for the withExponentialBackoff function.
|
|
37
|
+
*/
|
|
38
|
+
interface BackoffOptions {
|
|
39
|
+
/** Optional AbortSignal for cancellation support */
|
|
40
|
+
signal?: AbortSignal;
|
|
41
|
+
/** Callback invoked before each retry attempt */
|
|
42
|
+
onRetry?: (attempt: number, delay: number, error: Error) => void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Error thrown when an operation is aborted via AbortSignal.
|
|
46
|
+
*/
|
|
47
|
+
declare class AbortError extends Error {
|
|
48
|
+
constructor(message?: string);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Error thrown when all retry attempts have been exhausted.
|
|
52
|
+
*/
|
|
53
|
+
declare class RetryExhaustedError extends Error {
|
|
54
|
+
/** The last error that caused the final retry to fail */
|
|
55
|
+
readonly cause: Error;
|
|
56
|
+
/** Total number of attempts made */
|
|
57
|
+
readonly attempts: number;
|
|
58
|
+
constructor(cause: Error, attempts: number);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Calculates the delay for a given retry attempt using exponential backoff.
|
|
62
|
+
*
|
|
63
|
+
* Formula: min(baseDelay * (multiplier ^ attempt), maxDelay)
|
|
64
|
+
*
|
|
65
|
+
* @param attempt - The current attempt number (0-indexed)
|
|
66
|
+
* @param config - Backoff configuration
|
|
67
|
+
* @returns Delay in milliseconds (without jitter)
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* const config = { baseDelayMs: 1000, maxDelayMs: 30000, backoffMultiplier: 2 };
|
|
72
|
+
* calculateBackoffDelay(0, config); // 1000
|
|
73
|
+
* calculateBackoffDelay(1, config); // 2000
|
|
74
|
+
* calculateBackoffDelay(2, config); // 4000
|
|
75
|
+
* calculateBackoffDelay(5, config); // 30000 (capped at maxDelayMs)
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
declare function calculateBackoffDelay(attempt: number, config: Pick<BackoffConfig, 'baseDelayMs' | 'maxDelayMs' | 'backoffMultiplier'>): number;
|
|
79
|
+
/**
|
|
80
|
+
* Adds jitter (±10%) to a delay value to prevent thundering herd.
|
|
81
|
+
*
|
|
82
|
+
* @param delay - Base delay in milliseconds
|
|
83
|
+
* @returns Delay with random jitter applied
|
|
84
|
+
*/
|
|
85
|
+
declare function addJitter(delay: number): number;
|
|
86
|
+
/**
|
|
87
|
+
* Sleep utility that respects AbortSignal for cancellation.
|
|
88
|
+
*
|
|
89
|
+
* @param ms - Duration to sleep in milliseconds
|
|
90
|
+
* @param signal - Optional AbortSignal for cancellation
|
|
91
|
+
* @returns Promise that resolves after the delay or rejects if aborted
|
|
92
|
+
* @throws {AbortError} If the signal is aborted during sleep
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* const controller = new AbortController();
|
|
97
|
+
*
|
|
98
|
+
* // Sleep for 1 second
|
|
99
|
+
* await sleep(1000);
|
|
100
|
+
*
|
|
101
|
+
* // Sleep with cancellation support
|
|
102
|
+
* await sleep(1000, controller.signal);
|
|
103
|
+
*
|
|
104
|
+
* // Cancel the sleep
|
|
105
|
+
* controller.abort();
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Default backoff configuration suitable for most network operations.
|
|
111
|
+
*/
|
|
112
|
+
declare const DEFAULT_BACKOFF_CONFIG: BackoffConfig;
|
|
113
|
+
/**
|
|
114
|
+
* Executes a function with exponential backoff retry logic.
|
|
115
|
+
*
|
|
116
|
+
* Retries the provided function on failure using exponential backoff with jitter.
|
|
117
|
+
* Supports cancellation via AbortSignal and provides hooks for retry observation.
|
|
118
|
+
*
|
|
119
|
+
* @param fn - Async function to execute with retry logic
|
|
120
|
+
* @param config - Backoff configuration (maxRetries, delays, multiplier)
|
|
121
|
+
* @param options - Optional abort signal and retry callback
|
|
122
|
+
* @returns Promise resolving to the function result
|
|
123
|
+
* @throws {AbortError} If operation is aborted via signal
|
|
124
|
+
* @throws {RetryExhaustedError} If all retry attempts fail
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* const controller = new AbortController();
|
|
129
|
+
*
|
|
130
|
+
* const result = await withExponentialBackoff(
|
|
131
|
+
* async () => {
|
|
132
|
+
* const response = await fetch('https://api.example.com/data');
|
|
133
|
+
* if (!response.ok) throw new Error('Request failed');
|
|
134
|
+
* return response.json();
|
|
135
|
+
* },
|
|
136
|
+
* {
|
|
137
|
+
* maxRetries: 3,
|
|
138
|
+
* baseDelayMs: 1000,
|
|
139
|
+
* maxDelayMs: 30000,
|
|
140
|
+
* backoffMultiplier: 2,
|
|
141
|
+
* },
|
|
142
|
+
* {
|
|
143
|
+
* signal: controller.signal,
|
|
144
|
+
* onRetry: (attempt, delay, error) => {
|
|
145
|
+
* console.log(`Retry ${attempt} in ${delay}ms: ${error.message}`);
|
|
146
|
+
* },
|
|
147
|
+
* }
|
|
148
|
+
* );
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
declare function withExponentialBackoff<T>(fn: () => Promise<T>, config: BackoffConfig, options?: BackoffOptions): Promise<T>;
|
|
152
|
+
|
|
15
153
|
/**
|
|
16
154
|
* Conflict Detection for @pol-studios/powersync
|
|
17
155
|
*
|
|
@@ -64,4 +202,4 @@ declare function fetchServerVersion(table: string, recordId: string, schema: str
|
|
|
64
202
|
*/
|
|
65
203
|
declare function getLocalVersion(table: string, recordId: string, db: AbstractPowerSyncDatabase): Promise<number | null>;
|
|
66
204
|
|
|
67
|
-
export { AbstractPowerSyncDatabase, ConflictCheckResult, ConflictDetectionConfig, detectConflicts, fetchServerVersion, getLocalVersion, hasVersionColumn };
|
|
205
|
+
export { AbortError, AbstractPowerSyncDatabase, type BackoffConfig, type BackoffOptions, ConflictCheckResult, ConflictDetectionConfig, DEFAULT_BACKOFF_CONFIG, RetryExhaustedError, addJitter, calculateBackoffDelay, detectConflicts, fetchServerVersion, getLocalVersion, hasVersionColumn, sleep, withExponentialBackoff };
|
package/dist/index.js
CHANGED
|
@@ -2,29 +2,41 @@ import "./chunk-OLHGI472.js";
|
|
|
2
2
|
import "./chunk-32OLICZO.js";
|
|
3
3
|
import {
|
|
4
4
|
AttachmentQueueContext,
|
|
5
|
+
CompletedTransactionsContext,
|
|
5
6
|
ConflictBus,
|
|
6
7
|
ConnectionHealthContext,
|
|
8
|
+
ConnectionStatusContext,
|
|
9
|
+
FailedTransactionsContext,
|
|
10
|
+
PendingMutationsContext,
|
|
7
11
|
PowerSyncContext,
|
|
8
12
|
PowerSyncProvider,
|
|
13
|
+
SyncActivityContext,
|
|
9
14
|
SyncMetricsContext,
|
|
15
|
+
SyncModeContext,
|
|
10
16
|
SyncStatusContext,
|
|
11
17
|
useAttachmentQueue,
|
|
18
|
+
useCompletedTransactionsContext,
|
|
12
19
|
useConnectionHealth,
|
|
20
|
+
useConnectionStatus,
|
|
13
21
|
useDatabase,
|
|
14
22
|
useDownloadProgress,
|
|
15
23
|
useEntitySyncStatus,
|
|
24
|
+
useFailedTransactionsContext,
|
|
16
25
|
useIsSyncing,
|
|
17
26
|
useOnlineStatus,
|
|
18
27
|
usePendingMutations,
|
|
28
|
+
usePendingMutationsContext,
|
|
19
29
|
usePlatform,
|
|
20
30
|
usePowerSync,
|
|
21
31
|
useSyncActivity,
|
|
32
|
+
useSyncActivityContext,
|
|
22
33
|
useSyncControl,
|
|
23
34
|
useSyncMetrics,
|
|
24
35
|
useSyncMode,
|
|
36
|
+
useSyncModeContext,
|
|
25
37
|
useSyncStatus,
|
|
26
38
|
useUploadStatus
|
|
27
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-KCDG2MNP.js";
|
|
28
40
|
import {
|
|
29
41
|
AttachmentQueue,
|
|
30
42
|
AttachmentState,
|
|
@@ -32,7 +44,7 @@ import {
|
|
|
32
44
|
DEFAULT_COMPRESSION_CONFIG,
|
|
33
45
|
DEFAULT_DOWNLOAD_CONFIG
|
|
34
46
|
} from "./chunk-V6LJ6MR2.js";
|
|
35
|
-
import "./chunk-
|
|
47
|
+
import "./chunk-5FIMA26D.js";
|
|
36
48
|
import {
|
|
37
49
|
DEFAULT_CONNECTION_HEALTH,
|
|
38
50
|
DEFAULT_SYNC_CONFIG,
|
|
@@ -41,7 +53,7 @@ import {
|
|
|
41
53
|
HealthMonitor,
|
|
42
54
|
MetricsCollector,
|
|
43
55
|
SyncStatusTracker
|
|
44
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-R4YFWQ3Q.js";
|
|
45
57
|
import "./chunk-W7HSR35B.js";
|
|
46
58
|
import {
|
|
47
59
|
ATTACHMENT_DOWNLOAD_TIMEOUT_MS,
|
|
@@ -77,13 +89,25 @@ import {
|
|
|
77
89
|
} from "./chunk-EJ23MXPQ.js";
|
|
78
90
|
import "./chunk-VJCL2SWD.js";
|
|
79
91
|
import {
|
|
92
|
+
AbortError,
|
|
93
|
+
DEFAULT_BACKOFF_CONFIG,
|
|
94
|
+
DEFAULT_RETRY_CONFIG,
|
|
95
|
+
RetryExhaustedError,
|
|
80
96
|
SupabaseConnector,
|
|
97
|
+
addJitter,
|
|
98
|
+
calculateBackoffDelay,
|
|
81
99
|
defaultSchemaRouter,
|
|
82
100
|
detectConflicts,
|
|
83
101
|
fetchServerVersion,
|
|
84
102
|
getLocalVersion,
|
|
85
|
-
hasVersionColumn
|
|
86
|
-
|
|
103
|
+
hasVersionColumn,
|
|
104
|
+
sleep,
|
|
105
|
+
withExponentialBackoff
|
|
106
|
+
} from "./chunk-62J2DPKX.js";
|
|
107
|
+
import {
|
|
108
|
+
FailedUploadStore,
|
|
109
|
+
failedUploadStore
|
|
110
|
+
} from "./chunk-PAFBKNL3.js";
|
|
87
111
|
import {
|
|
88
112
|
AttachmentError,
|
|
89
113
|
ConfigurationError,
|
|
@@ -103,6 +127,7 @@ import {
|
|
|
103
127
|
export {
|
|
104
128
|
ATTACHMENT_DOWNLOAD_TIMEOUT_MS,
|
|
105
129
|
ATTACHMENT_RETRY_DELAY_MS,
|
|
130
|
+
AbortError,
|
|
106
131
|
AttachmentError,
|
|
107
132
|
AttachmentQueue,
|
|
108
133
|
AttachmentQueueContext,
|
|
@@ -110,12 +135,15 @@ export {
|
|
|
110
135
|
COMPRESSION_MAX_WIDTH,
|
|
111
136
|
COMPRESSION_SKIP_SIZE_BYTES,
|
|
112
137
|
COMPRESSION_TARGET_SIZE_BYTES,
|
|
138
|
+
CompletedTransactionsContext,
|
|
113
139
|
ConfigurationError,
|
|
114
140
|
ConflictBus,
|
|
115
141
|
ConnectionHealthContext,
|
|
142
|
+
ConnectionStatusContext,
|
|
116
143
|
ConnectorError,
|
|
117
144
|
DEFAULT_ATTACHMENT_CACHE_SIZE,
|
|
118
145
|
DEFAULT_ATTACHMENT_CONCURRENCY,
|
|
146
|
+
DEFAULT_BACKOFF_CONFIG,
|
|
119
147
|
DEFAULT_CACHE_CONFIG,
|
|
120
148
|
DEFAULT_COMPRESSION_CONFIG,
|
|
121
149
|
DEFAULT_COMPRESSION_QUALITY,
|
|
@@ -124,6 +152,7 @@ export {
|
|
|
124
152
|
DEFAULT_MAX_RETRY_ATTEMPTS,
|
|
125
153
|
DEFAULT_RETRY_BACKOFF_MULTIPLIER,
|
|
126
154
|
DEFAULT_RETRY_BASE_DELAY_MS,
|
|
155
|
+
DEFAULT_RETRY_CONFIG,
|
|
127
156
|
DEFAULT_RETRY_MAX_DELAY_MS,
|
|
128
157
|
DEFAULT_SYNC_CONFIG,
|
|
129
158
|
DEFAULT_SYNC_INTERVAL_MS,
|
|
@@ -132,6 +161,8 @@ export {
|
|
|
132
161
|
DEFAULT_SYNC_STATUS,
|
|
133
162
|
DOWNLOAD_STOP_THRESHOLD,
|
|
134
163
|
EVICTION_TRIGGER_THRESHOLD,
|
|
164
|
+
FailedTransactionsContext,
|
|
165
|
+
FailedUploadStore,
|
|
135
166
|
HEALTH_CHECK_INTERVAL_MS,
|
|
136
167
|
HEALTH_CHECK_TIMEOUT_MS,
|
|
137
168
|
HealthMonitor,
|
|
@@ -139,10 +170,12 @@ export {
|
|
|
139
170
|
LATENCY_DEGRADED_THRESHOLD_MS,
|
|
140
171
|
MAX_CONSECUTIVE_FAILURES,
|
|
141
172
|
MetricsCollector,
|
|
173
|
+
PendingMutationsContext,
|
|
142
174
|
PlatformAdapterError,
|
|
143
175
|
PowerSyncContext,
|
|
144
176
|
PowerSyncError,
|
|
145
177
|
PowerSyncProvider,
|
|
178
|
+
RetryExhaustedError,
|
|
146
179
|
STATS_CACHE_TTL_MS,
|
|
147
180
|
STATUS_NOTIFY_THROTTLE_MS,
|
|
148
181
|
STORAGE_CRITICAL_THRESHOLD,
|
|
@@ -154,10 +187,14 @@ export {
|
|
|
154
187
|
STORAGE_KEY_SYNC_MODE,
|
|
155
188
|
STORAGE_WARNING_THRESHOLD,
|
|
156
189
|
SupabaseConnector,
|
|
190
|
+
SyncActivityContext,
|
|
157
191
|
SyncMetricsContext,
|
|
192
|
+
SyncModeContext,
|
|
158
193
|
SyncOperationError,
|
|
159
194
|
SyncStatusContext,
|
|
160
195
|
SyncStatusTracker,
|
|
196
|
+
addJitter,
|
|
197
|
+
calculateBackoffDelay,
|
|
161
198
|
classifyError,
|
|
162
199
|
classifySupabaseError,
|
|
163
200
|
createSyncError,
|
|
@@ -165,26 +202,35 @@ export {
|
|
|
165
202
|
detectConflicts,
|
|
166
203
|
extractEntityIds,
|
|
167
204
|
extractTableNames,
|
|
205
|
+
failedUploadStore,
|
|
168
206
|
fetchServerVersion,
|
|
169
207
|
generateFailureId,
|
|
170
208
|
getLocalVersion,
|
|
171
209
|
hasVersionColumn,
|
|
210
|
+
sleep,
|
|
172
211
|
toSyncOperationError,
|
|
173
212
|
useAttachmentQueue,
|
|
213
|
+
useCompletedTransactionsContext,
|
|
174
214
|
useConnectionHealth,
|
|
215
|
+
useConnectionStatus,
|
|
175
216
|
useDatabase,
|
|
176
217
|
useDownloadProgress,
|
|
177
218
|
useEntitySyncStatus,
|
|
219
|
+
useFailedTransactionsContext,
|
|
178
220
|
useIsSyncing,
|
|
179
221
|
useOnlineStatus,
|
|
180
222
|
usePendingMutations,
|
|
223
|
+
usePendingMutationsContext,
|
|
181
224
|
usePlatform,
|
|
182
225
|
usePowerSync,
|
|
183
226
|
useSyncActivity,
|
|
227
|
+
useSyncActivityContext,
|
|
184
228
|
useSyncControl,
|
|
185
229
|
useSyncMetrics,
|
|
186
230
|
useSyncMode,
|
|
231
|
+
useSyncModeContext,
|
|
187
232
|
useSyncStatus,
|
|
188
|
-
useUploadStatus
|
|
233
|
+
useUploadStatus,
|
|
234
|
+
withExponentialBackoff
|
|
189
235
|
};
|
|
190
236
|
//# sourceMappingURL=index.js.map
|
package/dist/index.native.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export { A as AbstractPowerSyncDatabase, k as CacheStats, i as ClassifiedError, j as CompactResult, h as CompletedTransaction, b as ConnectionHealth, o as CountRow, C as CrudEntry, l as CrudTransaction, n as DbStatRow, D as DownloadProgress, E as EntitySyncState, F as FailedTransaction, r as FreelistCountRow, s as IntegrityCheckRow, I as IntegrityResult, q as PageCountRow, p as PageSizeRow, P as PowerSyncBackendConnector, m as SqliteTableRow, c as StorageInfo, d as StorageQuota, f as SyncError, g as SyncErrorType, e as SyncMetrics, S as SyncMode, a as SyncStatus, T as TableCacheStats } from './types-afHtE1U_.js';
|
|
2
2
|
export { ATTACHMENT_DOWNLOAD_TIMEOUT_MS, ATTACHMENT_RETRY_DELAY_MS, AttachmentError, COMPRESSION_MAX_WIDTH, COMPRESSION_SKIP_SIZE_BYTES, COMPRESSION_TARGET_SIZE_BYTES, ConfigurationError, ConnectorError, DEFAULT_ATTACHMENT_CACHE_SIZE, DEFAULT_ATTACHMENT_CONCURRENCY, DEFAULT_COMPRESSION_QUALITY, DEFAULT_MAX_RETRY_ATTEMPTS, DEFAULT_RETRY_BACKOFF_MULTIPLIER, DEFAULT_RETRY_BASE_DELAY_MS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_SYNC_INTERVAL_MS, DEFAULT_SYNC_MODE, DOWNLOAD_STOP_THRESHOLD, EVICTION_TRIGGER_THRESHOLD, HEALTH_CHECK_INTERVAL_MS, HEALTH_CHECK_TIMEOUT_MS, InitializationError, LATENCY_DEGRADED_THRESHOLD_MS, MAX_CONSECUTIVE_FAILURES, PlatformAdapterError, PowerSyncError, STATS_CACHE_TTL_MS, STATUS_NOTIFY_THROTTLE_MS, STORAGE_CRITICAL_THRESHOLD, STORAGE_KEY_ATTACHMENT_SETTINGS, STORAGE_KEY_ENABLED, STORAGE_KEY_METRICS, STORAGE_KEY_PAUSED, STORAGE_KEY_PREFIX, STORAGE_KEY_SYNC_MODE, STORAGE_WARNING_THRESHOLD, SyncOperationError, classifyError, classifySupabaseError, createSyncError, extractEntityIds, extractTableNames, generateFailureId, toSyncOperationError } from './core/index.js';
|
|
3
|
-
export {
|
|
3
|
+
export { f as ConflictBus, g as ConflictCheckResult, j as ConflictDetectionConfig, i as ConflictHandler, k as ConflictListener, h as ConflictResolution, C as ConnectorConfig, c as CrudHandler, D as DEFAULT_RETRY_CONFIG, F as FieldConflict, P as PowerSyncCredentials, l as ResolutionListener, e as RetryConfig, R as RetryStrategyConfig, b as SchemaRouter, S as SupabaseConnector, a as SupabaseConnectorOptions, d as defaultSchemaRouter } from './index-l3iL9Jte.js';
|
|
4
4
|
export { AttachmentQueue, AttachmentQueueConfig, AttachmentRecord, AttachmentSourceConfig, AttachmentState, AttachmentStatsRow, AttachmentStorageAdapter, AttachmentSyncStats, AttachmentSyncStatus, CacheConfig, CacheFileRow, CachedSizeRow, CompressionConfig, DEFAULT_CACHE_CONFIG, DEFAULT_COMPRESSION_CONFIG, DEFAULT_DOWNLOAD_CONFIG, DownloadConfig, DownloadPhase, DownloadStatus, EvictRow, IdRow } from './attachments/index.js';
|
|
5
5
|
export { e as HealthCheckResult, H as HealthMonitorOptions, M as MetricsCollectorOptions, P as PowerSyncRawStatus, c as SyncControlActions, f as SyncEvent, g as SyncEventListener, d as SyncOperationData, S as SyncScope, a as SyncStatusState, b as SyncStatusTrackerOptions, U as Unsubscribe } from './types-Cd7RhNqf.js';
|
|
6
6
|
export { HealthMonitor, MetricsCollector, SyncStatusTracker } from './sync/index.js';
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
7
|
+
export { F as FailedUpload, a as FailedUploadStore, f as failedUploadStore } from './failed-upload-store-C0cLxxPz.js';
|
|
8
|
+
export { AbortError, BackoffConfig, BackoffOptions, DEFAULT_BACKOFF_CONFIG, RetryExhaustedError, addJitter, calculateBackoffDelay, detectConflicts, fetchServerVersion, getLocalVersion, hasVersionColumn, sleep, withExponentialBackoff } from './index.js';
|
|
9
|
+
export { AttachmentQueueContext, CompletedTransactionsContext, CompletedTransactionsContextValue, ConnectionHealthContext, ConnectionHealthContextValue, ConnectionStatusContext, ConnectionStatusContextValue, DEFAULT_CONNECTION_HEALTH, DEFAULT_SYNC_CONFIG, DEFAULT_SYNC_METRICS, DEFAULT_SYNC_STATUS, EntitySyncStatusResult, FailedTransactionsContext, FailedTransactionsContextValue, PendingMutationsContext, PendingMutationsContextValue, PowerSyncConfig, PowerSyncContext, PowerSyncContextValue, PowerSyncProvider, PowerSyncProviderProps, SyncActivityContext, SyncActivityContextValue, SyncActivityResult, SyncConfig, SyncMetricsContext, SyncMetricsContextValue, SyncModeContext, SyncModeContextValue, SyncStatusContext, SyncStatusContextValue, UploadStatusResult, useAttachmentQueue, useCompletedTransactionsContext, useConnectionHealth, useConnectionStatus, useDatabase, useDownloadProgress, useEntitySyncStatus, useFailedTransactionsContext, useIsSyncing, useOnlineStatus, usePendingMutations, usePendingMutationsContext, usePlatform, usePowerSync, useSyncActivity, useSyncActivityContext, useSyncControl, useSyncMetrics, useSyncMode, useSyncModeContext, useSyncStatus, useUploadStatus } from './provider/index.js';
|
|
9
10
|
export { AsyncStorageAdapter, CompressedImage, CompressionOptions, ConnectionType, DatabaseOptions, FileInfo, FileSystemAdapter, ImageProcessorAdapter, LoggerAdapter, NetworkAdapter, PlatformAdapter, PlatformType, detectPlatform } from './platform/index.js';
|
|
10
11
|
export { createNativePlatformAdapter } from './platform/index.native.js';
|
|
11
12
|
import '@supabase/supabase-js';
|