@pol-studios/powersync 1.0.24 → 1.0.30

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 (53) hide show
  1. package/README.md +0 -1
  2. package/dist/attachments/index.d.ts +1 -1
  3. package/dist/{background-sync-ChCXW-EV.d.ts → background-sync-CVR3PkFi.d.ts} +1 -1
  4. package/dist/{chunk-BGBQYQV3.js → chunk-BC2SRII2.js} +180 -299
  5. package/dist/chunk-BC2SRII2.js.map +1 -0
  6. package/dist/{chunk-YSTEESEG.js → chunk-C2ACBYBZ.js} +208 -11
  7. package/dist/chunk-C2ACBYBZ.js.map +1 -0
  8. package/dist/{chunk-24RDMMCL.js → chunk-FNYQFILT.js} +1 -1
  9. package/dist/chunk-FNYQFILT.js.map +1 -0
  10. package/dist/{chunk-YVX3A36I.js → chunk-JCGOZVWL.js} +406 -331
  11. package/dist/chunk-JCGOZVWL.js.map +1 -0
  12. package/dist/{chunk-WGHNIAF7.js → chunk-QREWE3NR.js} +2 -2
  13. package/dist/{chunk-TIFL2KWE.js → chunk-RBPWEOIV.js} +3 -3
  14. package/dist/{chunk-55DKCJV4.js → chunk-RE5HWLCB.js} +124 -13
  15. package/dist/chunk-RE5HWLCB.js.map +1 -0
  16. package/dist/connector/index.d.ts +4 -4
  17. package/dist/connector/index.js +1 -2
  18. package/dist/core/index.d.ts +2 -2
  19. package/dist/generator/cli.js +6 -1
  20. package/dist/generator/index.d.ts +1 -0
  21. package/dist/generator/index.js +9 -1
  22. package/dist/generator/index.js.map +1 -1
  23. package/dist/index.d.ts +7 -7
  24. package/dist/index.js +27 -17
  25. package/dist/index.native.d.ts +5 -5
  26. package/dist/index.native.js +27 -17
  27. package/dist/index.web.d.ts +5 -5
  28. package/dist/index.web.js +27 -17
  29. package/dist/maintenance/index.d.ts +2 -2
  30. package/dist/maintenance/index.js +2 -2
  31. package/dist/platform/index.d.ts +1 -1
  32. package/dist/platform/index.native.d.ts +1 -1
  33. package/dist/platform/index.web.d.ts +1 -1
  34. package/dist/provider/index.d.ts +188 -28
  35. package/dist/provider/index.js +17 -7
  36. package/dist/react/index.d.ts +2 -2
  37. package/dist/react/index.js +3 -3
  38. package/dist/storage/index.d.ts +1 -1
  39. package/dist/storage/index.native.d.ts +1 -1
  40. package/dist/storage/index.web.d.ts +1 -1
  41. package/dist/{supabase-connector-D2oIl2t8.d.ts → supabase-connector-C4YpH_l3.d.ts} +23 -25
  42. package/dist/sync/index.d.ts +42 -5
  43. package/dist/sync/index.js +2 -2
  44. package/dist/{types-DiBvmGEi.d.ts → types-CpM2_LhU.d.ts} +17 -24
  45. package/dist/{types-CDqWh56B.d.ts → types-Dv1uf0LZ.d.ts} +16 -1
  46. package/package.json +2 -2
  47. package/dist/chunk-24RDMMCL.js.map +0 -1
  48. package/dist/chunk-55DKCJV4.js.map +0 -1
  49. package/dist/chunk-BGBQYQV3.js.map +0 -1
  50. package/dist/chunk-YSTEESEG.js.map +0 -1
  51. package/dist/chunk-YVX3A36I.js.map +0 -1
  52. /package/dist/{chunk-WGHNIAF7.js.map → chunk-QREWE3NR.js.map} +0 -0
  53. /package/dist/{chunk-TIFL2KWE.js.map → chunk-RBPWEOIV.js.map} +0 -0
@@ -1,15 +1,15 @@
1
1
  import { SupabaseClient } from '@supabase/supabase-js';
2
2
  import { QueryClient } from '@tanstack/react-query';
3
- import { A as AbstractPowerSyncDatabase, a as SyncStatus, C as CrudEntry, S as SyncMode, F as FailedTransaction, h as CompletedTransaction, b as ConnectionHealth, e as SyncMetrics, D as DownloadProgress, E as EntitySyncState, f as SyncError } from '../types-CDqWh56B.js';
3
+ import { A as AbstractPowerSyncDatabase, a as SyncStatus, C as CrudEntry, S as SyncMode, F as FailedTransaction, h as CompletedTransaction, b as ConnectionHealth, e as SyncMetrics, D as DownloadProgress, E as EntitySyncState, f as SyncError, U as UploadBlockReason } from '../types-Dv1uf0LZ.js';
4
4
  import { PlatformAdapter } from '../platform/index.js';
5
- import { a as ConnectorConfig, i as ConflictBus } from '../types-DiBvmGEi.js';
5
+ import { a as ConnectorConfig, i as ConflictBus } from '../types-CpM2_LhU.js';
6
6
  import { f as AttachmentConfig, P as PolAttachmentQueue, A as AttachmentSourceConfig, F as AttachmentRecord, C as CompressionConfig, j as DownloadConfig } from '../pol-attachment-queue-BE2HU3Us.js';
7
- import { S as SupabaseConnector } from '../supabase-connector-D2oIl2t8.js';
7
+ import { S as SupabaseConnector } from '../supabase-connector-C4YpH_l3.js';
8
8
  import * as react from 'react';
9
9
  import react__default, { ReactNode } from 'react';
10
10
  import { Schema } from '@powersync/react-native';
11
11
  import { a as StorageBackend } from '../types-D0WcHrq6.js';
12
- import { h as BackgroundSyncSystem, c as SyncControlActions } from '../background-sync-ChCXW-EV.js';
12
+ import { h as BackgroundSyncSystem, c as SyncControlActions } from '../background-sync-CVR3PkFi.js';
13
13
  import '@powersync/attachments';
14
14
  import '@powersync/common';
15
15
 
@@ -232,10 +232,6 @@ interface SyncStatusContextValue {
232
232
  * Clear a specific failure by its ID.
233
233
  */
234
234
  clearFailure: (failureId: string) => void;
235
- /**
236
- * Clear all failures.
237
- */
238
- clearAllFailures: () => void;
239
235
  /**
240
236
  * Completed transactions history.
241
237
  */
@@ -261,20 +257,31 @@ interface SyncStatusContextValue {
261
257
  */
262
258
  discardPendingMutation: (clientId: number) => Promise<void>;
263
259
  /**
264
- * Discard all pending mutations.
265
- * Uses safe disconnect/reconnect pattern to avoid transaction conflicts.
266
- * @throws Error if upload is in progress
260
+ * Whether we're currently waiting for a retry after upload failure.
261
+ */
262
+ isWaitingForUploadRetry: boolean;
263
+ /**
264
+ * When the next retry will occur (null if not waiting).
265
+ */
266
+ nextUploadRetryAt: Date | null;
267
+ /**
268
+ * Whether the maximum retry attempts have been reached.
269
+ */
270
+ maxUploadRetriesReached: boolean;
271
+ /**
272
+ * Current retry attempt count.
267
273
  */
268
- discardAllPendingMutations: () => Promise<void>;
274
+ uploadRetryCount: number;
269
275
  /**
270
- * Pause automatic retry of failed uploads.
271
- * Useful when user is actively resolving conflicts.
276
+ * Force a manual retry after max retries reached.
272
277
  */
273
- pauseAutoRetry: () => void;
278
+ manualUploadRetry: () => Promise<void>;
274
279
  /**
275
- * Resume automatic retry of failed uploads.
280
+ * Discard a specific failed entry by its ps_crud ID and reconnect.
281
+ * Use this when a single entry is causing upload failures.
282
+ * @param entryId - The ps_crud entry ID (clientId) to discard
276
283
  */
277
- resumeAutoRetry: () => void;
284
+ discardFailedEntryAndReconnect: (entryId: number) => Promise<void>;
278
285
  }
279
286
  /**
280
287
  * Connection state - changes rarely (on connect/disconnect).
@@ -315,8 +322,6 @@ interface PendingMutationsContextValue {
315
322
  pendingCount: number;
316
323
  /** Discard a specific pending mutation by its client ID */
317
324
  discardPendingMutation: (clientId: number) => Promise<void>;
318
- /** Discard all pending mutations */
319
- discardAllPendingMutations: () => Promise<void>;
320
325
  /**
321
326
  * Add a pending mutation to the list.
322
327
  * Called by mutation hooks (useDbInsert, useDbUpdate, useDbDelete, useDbUpsert)
@@ -342,12 +347,6 @@ interface FailedTransactionsContextValue {
342
347
  permanentErrorCount: number;
343
348
  /** Clear a specific failure by its ID */
344
349
  clearFailure: (failureId: string) => void;
345
- /** Clear all failures */
346
- clearAllFailures: () => void;
347
- /** Pause automatic retry of failed uploads */
348
- pauseAutoRetry: () => void;
349
- /** Resume automatic retry of failed uploads */
350
- resumeAutoRetry: () => void;
351
350
  /**
352
351
  * Retry a specific failed transaction.
353
352
  *
@@ -405,6 +404,36 @@ interface SyncModeContextValue {
405
404
  setSyncMode: (mode: SyncMode) => Promise<void>;
406
405
  /** Set the force next upload flag */
407
406
  setForceNextUpload: (force: boolean) => void;
407
+ /**
408
+ * Whether we're currently waiting for a retry after upload failure.
409
+ * When true, PowerSync is disconnected and waiting for the backoff timer.
410
+ */
411
+ isWaitingForUploadRetry: boolean;
412
+ /**
413
+ * When the next retry will occur (null if not waiting).
414
+ * Use this to display a countdown to the user.
415
+ */
416
+ nextUploadRetryAt: Date | null;
417
+ /**
418
+ * Whether the maximum retry attempts have been reached.
419
+ * When true, the system won't automatically retry - user must intervene.
420
+ */
421
+ maxUploadRetriesReached: boolean;
422
+ /**
423
+ * Current retry attempt count (0 when no retries have occurred).
424
+ */
425
+ uploadRetryCount: number;
426
+ /**
427
+ * Force a manual retry after max retries reached.
428
+ * Resets retry state and attempts to reconnect.
429
+ */
430
+ manualUploadRetry: () => Promise<void>;
431
+ /**
432
+ * Discard a specific failed entry by its ps_crud ID and reconnect.
433
+ * Use this when a single entry is causing upload failures.
434
+ * @param entryId - The ps_crud entry ID (clientId) to discard
435
+ */
436
+ discardFailedEntryAndReconnect: (entryId: number) => Promise<void>;
408
437
  }
409
438
  /**
410
439
  * Value provided by ConnectionHealthContext.
@@ -1164,6 +1193,58 @@ declare function useSyncMode(): {
1164
1193
  canDownload: boolean;
1165
1194
  networkReachable: boolean;
1166
1195
  };
1196
+ /**
1197
+ * Hook to access upload retry state for exponential backoff handling.
1198
+ *
1199
+ * When an upload fails, the provider disconnects and waits with exponential backoff
1200
+ * before reconnecting. After 7 failed attempts (256s backoff), it stays disconnected
1201
+ * and lets the user decide.
1202
+ *
1203
+ * @returns Upload retry state and control functions
1204
+ * @throws Error if used outside of PowerSyncProvider
1205
+ *
1206
+ * @example
1207
+ * ```typescript
1208
+ * function UploadRetryBanner() {
1209
+ * const {
1210
+ * isWaiting,
1211
+ * nextRetryAt,
1212
+ * maxRetriesReached,
1213
+ * retryCount,
1214
+ * manualRetry,
1215
+ * discardAndReconnect,
1216
+ * } = useUploadRetry();
1217
+ *
1218
+ * if (maxRetriesReached) {
1219
+ * return (
1220
+ * <View>
1221
+ * <Text>Upload failed after {retryCount} attempts</Text>
1222
+ * <Button onPress={manualRetry}>Try Again</Button>
1223
+ * <Button onPress={discardAndReconnect}>Discard Changes</Button>
1224
+ * </View>
1225
+ * );
1226
+ * }
1227
+ *
1228
+ * if (isWaiting && nextRetryAt) {
1229
+ * return (
1230
+ * <View>
1231
+ * <Text>Retrying in {Math.ceil((nextRetryAt.getTime() - Date.now()) / 1000)}s</Text>
1232
+ * </View>
1233
+ * );
1234
+ * }
1235
+ *
1236
+ * return null;
1237
+ * }
1238
+ * ```
1239
+ */
1240
+ declare function useUploadRetry(): {
1241
+ isWaiting: boolean;
1242
+ nextRetryAt: Date | null;
1243
+ maxRetriesReached: boolean;
1244
+ retryCount: number;
1245
+ manualRetry: () => Promise<void>;
1246
+ discardEntryAndReconnect: (entryId: number) => Promise<void>;
1247
+ };
1167
1248
  /**
1168
1249
  * Hook to access connection health status.
1169
1250
  *
@@ -1469,8 +1550,8 @@ interface UploadStatusResult {
1469
1550
  failedTransactions: FailedTransaction[];
1470
1551
  /** Trigger sync retry (reconnect) */
1471
1552
  retryAll: () => Promise<void>;
1472
- /** Dismiss all failures */
1473
- dismissAll: () => void;
1553
+ /** Dismiss a specific failure by its ID */
1554
+ dismissFailure: (failureId: string) => void;
1474
1555
  }
1475
1556
  /**
1476
1557
  * Hook to get overall upload status across all entities.
@@ -1559,5 +1640,84 @@ declare const useFailedTransactions: typeof useFailedTransactionsContext;
1559
1640
  * Alias for useCompletedTransactionsContext.
1560
1641
  */
1561
1642
  declare const useCompletedTransactions: typeof useCompletedTransactionsContext;
1643
+ /**
1644
+ * Return type for useUploadBlockedReason hook.
1645
+ */
1646
+ interface UploadBlockedReasonResult {
1647
+ /** Whether uploads are currently blocked */
1648
+ isBlocked: boolean;
1649
+ /** The reason uploads are blocked */
1650
+ reason: UploadBlockReason;
1651
+ /** Human-readable description of why uploads are blocked */
1652
+ description: string | null;
1653
+ /** Whether an upload is actively in progress */
1654
+ isUploading: boolean;
1655
+ }
1656
+ /**
1657
+ * Hook to get why uploads are blocked.
1658
+ * Derives block reason from existing sync mode, network, and connection state.
1659
+ *
1660
+ * @returns Upload blocked status with reason and description
1661
+ *
1662
+ * @example
1663
+ * ```typescript
1664
+ * function UploadBlockedBanner() {
1665
+ * const { isBlocked, reason, description } = useUploadBlockedReason();
1666
+ *
1667
+ * if (!isBlocked) return null;
1668
+ *
1669
+ * return <Banner>{description}</Banner>;
1670
+ * }
1671
+ * ```
1672
+ */
1673
+ declare function useUploadBlockedReason(): UploadBlockedReasonResult;
1674
+ /**
1675
+ * Return type for useRetryCountdown hook.
1676
+ */
1677
+ interface RetryCountdownResult {
1678
+ /** The soonest next retry time from all failed transactions */
1679
+ nextRetryAt: Date | null;
1680
+ /** Milliseconds until the next retry (0 if already past) */
1681
+ timeUntilRetryMs: number;
1682
+ /** Formatted countdown string (e.g., "5s", "1m 30s", "2m") or null if no retry scheduled */
1683
+ formattedCountdown: string | null;
1684
+ }
1685
+ /**
1686
+ * Hook for retry countdown display.
1687
+ * Returns the soonest nextRetryAt from all failed transactions.
1688
+ * Re-renders every second when countdown is active.
1689
+ *
1690
+ * @returns Retry countdown information
1691
+ *
1692
+ * @example
1693
+ * ```typescript
1694
+ * function RetryTimer() {
1695
+ * const { nextRetryAt, formattedCountdown } = useRetryCountdown();
1696
+ *
1697
+ * if (!nextRetryAt) return null;
1698
+ *
1699
+ * return <Text>Retrying in {formattedCountdown}</Text>;
1700
+ * }
1701
+ * ```
1702
+ */
1703
+ declare function useRetryCountdown(): RetryCountdownResult;
1704
+
1705
+ /**
1706
+ * Provider Constants for @pol-studios/powersync
1707
+ *
1708
+ * Exports constants used in the provider that may need to be accessed by UI components.
1709
+ */
1710
+ /**
1711
+ * Maximum number of upload retry attempts before stopping automatic retries.
1712
+ * After this many attempts, the user must manually retry or discard the failed entries.
1713
+ *
1714
+ * Backoff delays: 4s, 8s, 16s, 32s, 64s, 128s, 256s (total: ~8.5 minutes)
1715
+ */
1716
+ declare const UPLOAD_MAX_RETRIES = 7;
1717
+ /**
1718
+ * Backoff delays in seconds for each retry attempt.
1719
+ * Uses exponential backoff: 4s, 8s, 16s, 32s, 64s, 128s, 256s
1720
+ */
1721
+ declare const UPLOAD_BACKOFF_DELAYS: readonly [4, 8, 16, 32, 64, 128, 256];
1562
1722
 
1563
- export { AttachmentQueueContext, type BackgroundSyncCallbacks, type BackgroundSyncConfig, type BackgroundSyncStatus, CompletedTransactionsContext, type CompletedTransactionsContextValue, ConnectionHealthContext, type ConnectionHealthContextValue, ConnectionStatusContext, type ConnectionStatusContextValue, DEFAULT_CONNECTION_HEALTH, DEFAULT_SYNC_CONFIG, DEFAULT_SYNC_METRICS, DEFAULT_SYNC_STATUS, type DataLayerConfig, type DataLayerIntegration, type EntitySyncStatusResult, FailedTransactionsContext, type FailedTransactionsContextValue, type OfflineDataAttachmentConfig, OfflineDataProvider, type OfflineDataProviderConfig, type OfflineDataProviderProps, PendingMutationsContext, type PendingMutationsContextValue, type PowerSyncConfig, PowerSyncContext, type PowerSyncContextValue, PowerSyncProvider, type PowerSyncProviderProps, type PowerSyncSyncStatusSnapshot, ProviderBridge, type ProviderBridgeProps, SyncActivityContext, type SyncActivityContextValue, type SyncActivityResult, type SyncConfig, SyncMetricsContext, type SyncMetricsContextValue, SyncModeContext, type SyncModeContextValue, SyncStatusContext, type SyncStatusContextValue, type UploadStatusResult, useAttachmentQueue, useAttachmentQueueReady, useCompletedTransactions, useCompletedTransactionsContext, useConnectionHealth, useConnectionStatus, useDatabase, useDownloadProgress, useEntitySyncStatus, useFailedTransactions, useFailedTransactionsContext, useIsSyncing, useOnlineStatus, usePendingMutations, usePendingMutationsContext, usePlatform, usePowerSync, useSyncActivity, useSyncActivityContext, useSyncControl, useSyncMetrics, useSyncMode, useSyncModeContext, useSyncStatus, useUploadStatus };
1723
+ export { AttachmentQueueContext, type BackgroundSyncCallbacks, type BackgroundSyncConfig, type BackgroundSyncStatus, CompletedTransactionsContext, type CompletedTransactionsContextValue, ConnectionHealthContext, type ConnectionHealthContextValue, ConnectionStatusContext, type ConnectionStatusContextValue, DEFAULT_CONNECTION_HEALTH, DEFAULT_SYNC_CONFIG, DEFAULT_SYNC_METRICS, DEFAULT_SYNC_STATUS, type DataLayerConfig, type DataLayerIntegration, type EntitySyncStatusResult, FailedTransactionsContext, type FailedTransactionsContextValue, type OfflineDataAttachmentConfig, OfflineDataProvider, type OfflineDataProviderConfig, type OfflineDataProviderProps, PendingMutationsContext, type PendingMutationsContextValue, type PowerSyncConfig, PowerSyncContext, type PowerSyncContextValue, PowerSyncProvider, type PowerSyncProviderProps, type PowerSyncSyncStatusSnapshot, ProviderBridge, type ProviderBridgeProps, type RetryCountdownResult, SyncActivityContext, type SyncActivityContextValue, type SyncActivityResult, type SyncConfig, SyncMetricsContext, type SyncMetricsContextValue, SyncModeContext, type SyncModeContextValue, SyncStatusContext, type SyncStatusContextValue, UPLOAD_BACKOFF_DELAYS, UPLOAD_MAX_RETRIES, type UploadBlockedReasonResult, type UploadStatusResult, useAttachmentQueue, useAttachmentQueueReady, useCompletedTransactions, useCompletedTransactionsContext, useConnectionHealth, useConnectionStatus, useDatabase, useDownloadProgress, useEntitySyncStatus, useFailedTransactions, useFailedTransactionsContext, useIsSyncing, useOnlineStatus, usePendingMutations, usePendingMutationsContext, usePlatform, usePowerSync, useRetryCountdown, useSyncActivity, useSyncActivityContext, useSyncControl, useSyncMetrics, useSyncMode, useSyncModeContext, useSyncStatus, useUploadBlockedReason, useUploadRetry, useUploadStatus };
@@ -1,18 +1,20 @@
1
1
  import {
2
2
  OfflineDataProvider,
3
3
  PowerSyncProvider,
4
- ProviderBridge
5
- } from "../chunk-YVX3A36I.js";
4
+ ProviderBridge,
5
+ UPLOAD_BACKOFF_DELAYS,
6
+ UPLOAD_MAX_RETRIES
7
+ } from "../chunk-JCGOZVWL.js";
6
8
  import "../chunk-YHTZ7VMV.js";
7
9
  import "../chunk-P6WOZO7H.js";
8
10
  import "../chunk-CACKC6XG.js";
9
- import "../chunk-55DKCJV4.js";
11
+ import "../chunk-RE5HWLCB.js";
10
12
  import {
11
13
  DEFAULT_CONNECTION_HEALTH,
12
14
  DEFAULT_SYNC_CONFIG,
13
15
  DEFAULT_SYNC_METRICS,
14
16
  DEFAULT_SYNC_STATUS
15
- } from "../chunk-24RDMMCL.js";
17
+ } from "../chunk-FNYQFILT.js";
16
18
  import {
17
19
  AttachmentQueueContext,
18
20
  CompletedTransactionsContext,
@@ -42,6 +44,7 @@ import {
42
44
  usePendingMutationsContext,
43
45
  usePlatform,
44
46
  usePowerSync,
47
+ useRetryCountdown,
45
48
  useSyncActivity,
46
49
  useSyncActivityContext,
47
50
  useSyncControl,
@@ -49,15 +52,17 @@ import {
49
52
  useSyncMode,
50
53
  useSyncModeContext,
51
54
  useSyncStatus,
55
+ useUploadBlockedReason,
56
+ useUploadRetry,
52
57
  useUploadStatus
53
- } from "../chunk-YSTEESEG.js";
58
+ } from "../chunk-C2ACBYBZ.js";
54
59
  import "../chunk-CAB26E6F.js";
55
60
  import "../chunk-XAEII4ZX.js";
56
61
  import "../chunk-Z6VOBGTU.js";
62
+ import "../chunk-FV2HXEIY.js";
57
63
  import "../chunk-CGL33PL4.js";
58
64
  import "../chunk-WN5ZJ3E2.js";
59
- import "../chunk-BGBQYQV3.js";
60
- import "../chunk-FV2HXEIY.js";
65
+ import "../chunk-BC2SRII2.js";
61
66
  import "../chunk-I2AYMY5O.js";
62
67
  export {
63
68
  AttachmentQueueContext,
@@ -78,6 +83,8 @@ export {
78
83
  SyncMetricsContext,
79
84
  SyncModeContext,
80
85
  SyncStatusContext,
86
+ UPLOAD_BACKOFF_DELAYS,
87
+ UPLOAD_MAX_RETRIES,
81
88
  useAttachmentQueue,
82
89
  useAttachmentQueueReady,
83
90
  useCompletedTransactions,
@@ -95,6 +102,7 @@ export {
95
102
  usePendingMutationsContext,
96
103
  usePlatform,
97
104
  usePowerSync,
105
+ useRetryCountdown,
98
106
  useSyncActivity,
99
107
  useSyncActivityContext,
100
108
  useSyncControl,
@@ -102,6 +110,8 @@ export {
102
110
  useSyncMode,
103
111
  useSyncModeContext,
104
112
  useSyncStatus,
113
+ useUploadBlockedReason,
114
+ useUploadRetry,
105
115
  useUploadStatus
106
116
  };
107
117
  //# sourceMappingURL=index.js.map
@@ -1,11 +1,11 @@
1
1
  import * as react from 'react';
2
2
  import react__default, { ReactNode } from 'react';
3
3
  import { Schema } from '@powersync/react-native';
4
- import { A as AuthProvider } from '../types-DiBvmGEi.js';
4
+ import { A as AuthProvider } from '../types-CpM2_LhU.js';
5
5
  import { a as StorageBackend } from '../types-D0WcHrq6.js';
6
6
  import { f as AttachmentConfig, P as PolAttachmentQueue } from '../pol-attachment-queue-BE2HU3Us.js';
7
7
  import { PlatformAdapter } from '../platform/index.js';
8
- import { f as SyncError, a as SyncStatus, A as AbstractPowerSyncDatabase } from '../types-CDqWh56B.js';
8
+ import { f as SyncError, a as SyncStatus, A as AbstractPowerSyncDatabase } from '../types-Dv1uf0LZ.js';
9
9
  import '@supabase/supabase-js';
10
10
  import '@powersync/attachments';
11
11
  import '@powersync/common';
@@ -6,11 +6,11 @@ import {
6
6
  useAttachmentQueueContext,
7
7
  usePowerSyncContext,
8
8
  useSyncStatusContext
9
- } from "../chunk-TIFL2KWE.js";
9
+ } from "../chunk-RBPWEOIV.js";
10
10
  import "../chunk-CACKC6XG.js";
11
- import "../chunk-24RDMMCL.js";
12
- import "../chunk-BGBQYQV3.js";
11
+ import "../chunk-FNYQFILT.js";
13
12
  import "../chunk-FV2HXEIY.js";
13
+ import "../chunk-BC2SRII2.js";
14
14
  import "../chunk-I2AYMY5O.js";
15
15
  export {
16
16
  AttachmentQueueContext,
@@ -3,4 +3,4 @@ export { f as CacheSettings, C as CacheSettingsManager, h as CacheSettingsManage
3
3
  export { D as DEFAULT_UPLOAD_NOTIFICATION, S as SupabaseUploadHandlerOptions, U as UploadEventHandlers, a as UploadNotificationConfig } from '../types-CyvBaAl8.js';
4
4
  export { SupabaseUploadHandler, createSupabaseUploadHandler } from './upload/index.js';
5
5
  import '../platform/index.js';
6
- import '../types-CDqWh56B.js';
6
+ import '../types-Dv1uf0LZ.js';
@@ -3,4 +3,4 @@ export { f as CacheSettings, C as CacheSettingsManager, h as CacheSettingsManage
3
3
  export { D as DEFAULT_UPLOAD_NOTIFICATION, S as SupabaseUploadHandlerOptions, U as UploadEventHandlers, a as UploadNotificationConfig } from '../types-CyvBaAl8.js';
4
4
  export { SupabaseUploadHandler, createSupabaseUploadHandler } from './upload/index.native.js';
5
5
  import '../platform/index.js';
6
- import '../types-CDqWh56B.js';
6
+ import '../types-Dv1uf0LZ.js';
@@ -3,4 +3,4 @@ export { f as CacheSettings, C as CacheSettingsManager, h as CacheSettingsManage
3
3
  export { D as DEFAULT_UPLOAD_NOTIFICATION, S as SupabaseUploadHandlerOptions, U as UploadEventHandlers, a as UploadNotificationConfig } from '../types-CyvBaAl8.js';
4
4
  export { SupabaseUploadHandler, createSupabaseUploadHandler } from './upload/index.js';
5
5
  import '../platform/index.js';
6
- import '../types-CDqWh56B.js';
6
+ import '../types-Dv1uf0LZ.js';
@@ -1,5 +1,5 @@
1
- import { P as PowerSyncBackendConnector, A as AbstractPowerSyncDatabase } from './types-CDqWh56B.js';
2
- import { S as SupabaseConnectorOptions, P as PowerSyncCredentials } from './types-DiBvmGEi.js';
1
+ import { P as PowerSyncBackendConnector, A as AbstractPowerSyncDatabase } from './types-Dv1uf0LZ.js';
2
+ import { S as SupabaseConnectorOptions, P as PowerSyncCredentials } from './types-CpM2_LhU.js';
3
3
 
4
4
  /**
5
5
  * Supabase Connector for PowerSync
@@ -10,6 +10,12 @@ import { S as SupabaseConnectorOptions, P as PowerSyncCredentials } from './type
10
10
  * - Schema routing for multi-schema databases
11
11
  * - Custom CRUD handling for complex operations
12
12
  * - Version-based conflict detection (when enabled)
13
+ *
14
+ * Error Handling Architecture (Simplified):
15
+ * - NO internal retry loops - PowerSync SDK handles all retries naturally
16
+ * - Middleware decides once: success/discard/retry/fail_transaction
17
+ * - ALL errors throw to let PowerSync retry naturally
18
+ * - ALL errors call onTransactionFailure (at outer level) for UI visibility
13
19
  */
14
20
 
15
21
  /**
@@ -78,15 +84,10 @@ declare class SupabaseConnector implements PowerSyncBackendConnector {
78
84
  private unsubscribeResolution?;
79
85
  private versionColumnPromises;
80
86
  private isDestroyed;
81
- private retryConfig;
82
87
  private completionFailures;
83
88
  private static readonly COMPLETION_MAX_FAILURES;
84
89
  private static readonly COMPLETION_EXTENDED_TIMEOUT_MS;
85
90
  private static readonly MAX_STORED_RESOLUTIONS;
86
- private autoRetryPaused;
87
- private entryCooldowns;
88
- private static readonly COOLDOWN_DURATION_MS;
89
- private static readonly MAX_ENTRY_COOLDOWNS;
90
91
  private readonly uploadErrorMiddleware;
91
92
  constructor(options: SupabaseConnectorOptions);
92
93
  /**
@@ -100,28 +101,25 @@ declare class SupabaseConnector implements PowerSyncBackendConnector {
100
101
  */
101
102
  private generateTransactionFingerprint;
102
103
  /**
103
- * Pause automatic retry of failed uploads.
104
- * Use this when the user goes offline intentionally or wants manual control.
105
- */
106
- pauseAutoRetry(): void;
107
- /**
108
- * Resume automatic retry of failed uploads.
109
- */
110
- resumeAutoRetry(): void;
111
- /**
112
- * Process a single CRUD entry with exponential backoff retry.
113
- *
114
- * This method uses a two-phase approach:
115
- * 1. First attempt - try the operation to classify the error type
116
- * 2. Retry phase - use the appropriate config (transient vs permanent) based on classification
104
+ * Process a single CRUD entry once (no internal retries).
117
105
  *
118
- * This fixes the issue where reassigning selectedConfig inside withExponentialBackoff's
119
- * callback had no effect because the config was already destructured at call time.
106
+ * On failure, middleware classifies the error:
107
+ * - 'success': Treat as completed (e.g., idempotent duplicate)
108
+ * - 'discard': Remove from queue silently
109
+ * - 'retry': Throw to let PowerSync retry on next sync cycle
110
+ * - 'fail_transaction': Throw TransactionAbortError immediately
111
+ * - 'continue': Throw original error (PowerSync will retry)
120
112
  *
121
113
  * @param entry - The CRUD entry to process
122
- * @throws Error if all retries exhausted (for critical failures)
114
+ * @throws Error for all errors (PowerSync will retry)
115
+ * @throws TransactionAbortError when middleware returns 'fail_transaction'
116
+ * @throws DiscardEntryError for discarded entries
117
+ */
118
+ private processEntryOnce;
119
+ /**
120
+ * Handle an entry error by running middleware and deciding what to do.
123
121
  */
124
- private processWithRetry;
122
+ private handleEntryError;
125
123
  /**
126
124
  * Set the active project IDs for scoped sync.
127
125
  * Call this when user selects/opens projects.
@@ -1,6 +1,6 @@
1
- import { b as SyncStatusTrackerOptions, P as PowerSyncRawStatus, U as Unsubscribe, M as MetricsCollectorOptions, d as SyncOperationData, H as HealthMonitorOptions, e as HealthCheckResult } from '../background-sync-ChCXW-EV.js';
2
- export { B as BackgroundSyncOptions, h as BackgroundSyncSystem, c as SyncControlActions, f as SyncEvent, g as SyncEventListener, S as SyncScope, a as SyncStatusState, i as defineBackgroundSyncTask, j as initializeBackgroundSync, k as isBackgroundSyncRegistered, r as registerBackgroundSync, u as unregisterBackgroundSync } from '../background-sync-ChCXW-EV.js';
3
- import { a as SyncStatus, S as SyncMode, C as CrudEntry, f as SyncError, F as FailedTransaction, h as CompletedTransaction, e as SyncMetrics, A as AbstractPowerSyncDatabase, b as ConnectionHealth } from '../types-CDqWh56B.js';
1
+ import { b as SyncStatusTrackerOptions, P as PowerSyncRawStatus, U as Unsubscribe, M as MetricsCollectorOptions, d as SyncOperationData, H as HealthMonitorOptions, e as HealthCheckResult } from '../background-sync-CVR3PkFi.js';
2
+ export { B as BackgroundSyncOptions, h as BackgroundSyncSystem, c as SyncControlActions, f as SyncEvent, g as SyncEventListener, S as SyncScope, a as SyncStatusState, i as defineBackgroundSyncTask, j as initializeBackgroundSync, k as isBackgroundSyncRegistered, r as registerBackgroundSync, u as unregisterBackgroundSync } from '../background-sync-CVR3PkFi.js';
3
+ import { a as SyncStatus, S as SyncMode, U as UploadBlockReason, C as CrudEntry, f as SyncError, F as FailedTransaction, h as CompletedTransaction, e as SyncMetrics, A as AbstractPowerSyncDatabase, b as ConnectionHealth } from '../types-Dv1uf0LZ.js';
4
4
  import { AsyncStorageAdapter, LoggerAdapter } from '../platform/index.js';
5
5
 
6
6
  /**
@@ -53,6 +53,9 @@ declare class SyncStatusTracker {
53
53
  private readonly _networkRestoreDelayMs;
54
54
  private _persistDebounceTimer;
55
55
  private _lastProgress;
56
+ private readonly _backoffBaseMs;
57
+ private readonly _backoffMaxMs;
58
+ private readonly _backoffMultiplier;
56
59
  private _failedTransactions;
57
60
  private readonly _maxStoredFailures;
58
61
  private readonly _failureTTLMs;
@@ -79,6 +82,26 @@ declare class SyncStatusTracker {
79
82
  * Get the current sync mode.
80
83
  */
81
84
  getSyncMode(): SyncMode;
85
+ /**
86
+ * Get the reason why uploads are currently blocked.
87
+ * Returns 'none' if uploads are ready to proceed.
88
+ *
89
+ * Priority order (first match wins):
90
+ * 1. offline_mode - User explicitly chose offline mode
91
+ * 2. auto_offline - System went offline automatically (network loss with auto-offline flag)
92
+ * 3. pull_only_mode - Pull-only mode active
93
+ * 4. network_unreachable - No internet connection
94
+ * 5. disconnected - PowerSync not connected
95
+ * 6. connecting - PowerSync is connecting
96
+ * 7. uploading - Actively uploading
97
+ * 8. none - Ready to sync
98
+ */
99
+ getUploadBlockReason(): UploadBlockReason;
100
+ /**
101
+ * Get a human-readable description of why uploads are blocked.
102
+ * Returns null if uploads are not blocked.
103
+ */
104
+ getUploadBlockDescription(): string | null;
82
105
  /**
83
106
  * Check if uploads are allowed based on current sync mode and network reachability.
84
107
  */
@@ -157,6 +180,14 @@ declare class SyncStatusTracker {
157
180
  * @returns Unsubscribe function
158
181
  */
159
182
  onSyncModeChange(listener: (mode: SyncMode) => void): Unsubscribe;
183
+ /**
184
+ * Compute exponential backoff delay for a given retry count.
185
+ * Uses base 1s, max 60s, multiplier 2.
186
+ *
187
+ * @param retryCount - Number of retries (1-based)
188
+ * @returns Backoff delay in milliseconds
189
+ */
190
+ private _computeBackoffMs;
160
191
  /**
161
192
  * Record a transaction failure.
162
193
  * If a failure for the same entries already exists, updates the retry count.
@@ -173,9 +204,15 @@ declare class SyncStatusTracker {
173
204
  */
174
205
  clearFailure(failureId: string): void;
175
206
  /**
176
- * Clear all failures.
207
+ * Clear failures for successfully synced entries.
208
+ * Removes any failed transaction that contains entries with the given IDs.
209
+ *
210
+ * This is called when `onTransactionSuccess` fires - if any entry in a failed
211
+ * transaction has now succeeded, we remove that entire failure record.
212
+ *
213
+ * @param entryIds - Array of CrudEntry.id values that succeeded
177
214
  */
178
- clearAllFailures(): void;
215
+ clearSuccessfulEntries(entryIds: string[]): void;
179
216
  /**
180
217
  * Remove a failed transaction from tracking and return its entries.
181
218
  * This is a "pop" operation - the failure is removed from the list.
@@ -12,8 +12,8 @@ import {
12
12
  HealthMonitor,
13
13
  MetricsCollector,
14
14
  SyncStatusTracker
15
- } from "../chunk-55DKCJV4.js";
16
- import "../chunk-24RDMMCL.js";
15
+ } from "../chunk-RE5HWLCB.js";
16
+ import "../chunk-FNYQFILT.js";
17
17
  import "../chunk-CGL33PL4.js";
18
18
  import "../chunk-I2AYMY5O.js";
19
19
  export {