@pol-studios/powersync 1.0.25 → 1.0.32

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 (118) hide show
  1. package/README.md +0 -1
  2. package/dist/{CacheSettingsManager-uz-kbnRH.d.ts → CacheSettingsManager-0H_7thHW.d.ts} +21 -3
  3. package/dist/attachments/index.d.ts +30 -30
  4. package/dist/attachments/index.js +13 -4
  5. package/dist/{background-sync-ChCXW-EV.d.ts → background-sync-BujnI3IR.d.ts} +1 -1
  6. package/dist/{chunk-55DKCJV4.js → chunk-2RDWLXJW.js} +408 -78
  7. package/dist/chunk-2RDWLXJW.js.map +1 -0
  8. package/dist/{chunk-P4HZA6ZT.js → chunk-4665ZSE5.js} +2 -2
  9. package/dist/chunk-4665ZSE5.js.map +1 -0
  10. package/dist/{chunk-XOY2CJ67.js → chunk-4F5B5CZ7.js} +3 -3
  11. package/dist/chunk-5WRI5ZAA.js +31 -0
  12. package/dist/{chunk-BGBQYQV3.js → chunk-65A3SYJZ.js} +193 -299
  13. package/dist/chunk-65A3SYJZ.js.map +1 -0
  14. package/dist/chunk-6SZ64KCZ.js +755 -0
  15. package/dist/chunk-6SZ64KCZ.js.map +1 -0
  16. package/dist/{chunk-YSTEESEG.js → chunk-74TBHWJ4.js} +122 -11
  17. package/dist/chunk-74TBHWJ4.js.map +1 -0
  18. package/dist/chunk-ANXWYQEJ.js +1 -0
  19. package/dist/chunk-ANXWYQEJ.js.map +1 -0
  20. package/dist/{chunk-CAB26E6F.js → chunk-C4J4MLER.js} +29 -24
  21. package/dist/chunk-C4J4MLER.js.map +1 -0
  22. package/dist/{chunk-C5ODS3XH.js → chunk-EOW7JK7Q.js} +9 -16
  23. package/dist/chunk-EOW7JK7Q.js.map +1 -0
  24. package/dist/chunk-HRAVPIAZ.js +220 -0
  25. package/dist/chunk-HRAVPIAZ.js.map +1 -0
  26. package/dist/{chunk-XAEII4ZX.js → chunk-NUGQOTEM.js} +32 -4
  27. package/dist/chunk-NUGQOTEM.js.map +1 -0
  28. package/dist/chunk-OGUFUZSY.js +5415 -0
  29. package/dist/chunk-OGUFUZSY.js.map +1 -0
  30. package/dist/{chunk-VB737IVN.js → chunk-P4D6BQ4X.js} +328 -706
  31. package/dist/chunk-P4D6BQ4X.js.map +1 -0
  32. package/dist/{chunk-CACKC6XG.js → chunk-PGEDE6IM.js} +136 -89
  33. package/dist/chunk-PGEDE6IM.js.map +1 -0
  34. package/dist/{chunk-A4IBBWGO.js → chunk-RALHHPTU.js} +1 -1
  35. package/dist/chunk-RIDSPLE5.js +42 -0
  36. package/dist/chunk-RIDSPLE5.js.map +1 -0
  37. package/dist/{chunk-Z6VOBGTU.js → chunk-UOMHWUHV.js} +2 -12
  38. package/dist/chunk-UOMHWUHV.js.map +1 -0
  39. package/dist/{chunk-WGHNIAF7.js → chunk-YONQYTVH.js} +2 -2
  40. package/dist/chunk-ZAN22NGL.js +13 -0
  41. package/dist/chunk-ZAN22NGL.js.map +1 -0
  42. package/dist/config/index.d.ts +200 -0
  43. package/dist/config/index.js +23 -0
  44. package/dist/config/index.js.map +1 -0
  45. package/dist/connector/index.d.ts +23 -5
  46. package/dist/connector/index.js +4 -2
  47. package/dist/core/index.d.ts +2 -2
  48. package/dist/core/index.js +1 -0
  49. package/dist/error/index.js +1 -0
  50. package/dist/generator/index.js +2 -0
  51. package/dist/generator/index.js.map +1 -1
  52. package/dist/index.d.ts +19 -16
  53. package/dist/index.js +88 -46
  54. package/dist/index.native.d.ts +18 -14
  55. package/dist/index.native.js +93 -44
  56. package/dist/index.web.d.ts +17 -14
  57. package/dist/index.web.js +88 -46
  58. package/dist/maintenance/index.d.ts +2 -2
  59. package/dist/maintenance/index.js +3 -2
  60. package/dist/platform/index.d.ts +1 -1
  61. package/dist/platform/index.js +2 -0
  62. package/dist/platform/index.js.map +1 -1
  63. package/dist/platform/index.native.d.ts +1 -1
  64. package/dist/platform/index.native.js +1 -0
  65. package/dist/platform/index.web.d.ts +1 -1
  66. package/dist/platform/index.web.js +1 -0
  67. package/dist/pol-attachment-queue-DqBvLAEY.d.ts +255 -0
  68. package/dist/provider/index.d.ts +319 -124
  69. package/dist/provider/index.js +21 -16
  70. package/dist/provider/index.native.d.ts +108 -0
  71. package/dist/provider/index.native.js +121 -0
  72. package/dist/provider/index.native.js.map +1 -0
  73. package/dist/provider/index.web.d.ts +16 -0
  74. package/dist/provider/index.web.js +112 -0
  75. package/dist/provider/index.web.js.map +1 -0
  76. package/dist/react/index.d.ts +16 -65
  77. package/dist/react/index.js +2 -9
  78. package/dist/storage/index.d.ts +5 -4
  79. package/dist/storage/index.js +12 -9
  80. package/dist/storage/index.native.d.ts +5 -4
  81. package/dist/storage/index.native.js +8 -5
  82. package/dist/storage/index.web.d.ts +5 -4
  83. package/dist/storage/index.web.js +11 -8
  84. package/dist/storage/upload/index.d.ts +4 -3
  85. package/dist/storage/upload/index.js +4 -2
  86. package/dist/storage/upload/index.native.d.ts +4 -3
  87. package/dist/storage/upload/index.native.js +4 -2
  88. package/dist/storage/upload/index.web.d.ts +2 -1
  89. package/dist/storage/upload/index.web.js +4 -2
  90. package/dist/{supabase-connector-D2oIl2t8.d.ts → supabase-connector-HMxBA9Kg.d.ts} +23 -25
  91. package/dist/sync/index.d.ts +183 -11
  92. package/dist/sync/index.js +13 -3
  93. package/dist/{types-CyvBaAl8.d.ts → types-6QHGELuY.d.ts} +4 -1
  94. package/dist/{types-CDqWh56B.d.ts → types-B9MptP7E.d.ts} +13 -1
  95. package/dist/types-BhAEsJj-.d.ts +330 -0
  96. package/dist/{types-D0WcHrq6.d.ts → types-CGMibJKD.d.ts} +8 -0
  97. package/dist/{types-DiBvmGEi.d.ts → types-DqJnP50o.d.ts} +22 -24
  98. package/dist/{pol-attachment-queue-BE2HU3Us.d.ts → types-JCEhw2Lf.d.ts} +139 -346
  99. package/package.json +18 -4
  100. package/dist/chunk-24RDMMCL.js +0 -44
  101. package/dist/chunk-24RDMMCL.js.map +0 -1
  102. package/dist/chunk-55DKCJV4.js.map +0 -1
  103. package/dist/chunk-654ERHA7.js +0 -1
  104. package/dist/chunk-BGBQYQV3.js.map +0 -1
  105. package/dist/chunk-C5ODS3XH.js.map +0 -1
  106. package/dist/chunk-CAB26E6F.js.map +0 -1
  107. package/dist/chunk-CACKC6XG.js.map +0 -1
  108. package/dist/chunk-P4HZA6ZT.js.map +0 -1
  109. package/dist/chunk-TIFL2KWE.js +0 -358
  110. package/dist/chunk-TIFL2KWE.js.map +0 -1
  111. package/dist/chunk-VB737IVN.js.map +0 -1
  112. package/dist/chunk-XAEII4ZX.js.map +0 -1
  113. package/dist/chunk-YSTEESEG.js.map +0 -1
  114. package/dist/chunk-Z6VOBGTU.js.map +0 -1
  115. /package/dist/{chunk-XOY2CJ67.js.map → chunk-4F5B5CZ7.js.map} +0 -0
  116. /package/dist/{chunk-654ERHA7.js.map → chunk-5WRI5ZAA.js.map} +0 -0
  117. /package/dist/{chunk-A4IBBWGO.js.map → chunk-RALHHPTU.js.map} +0 -0
  118. /package/dist/{chunk-WGHNIAF7.js.map → chunk-YONQYTVH.js.map} +0 -0
@@ -1,5 +1,6 @@
1
- import { S as SupabaseUploadHandlerOptions, B as BucketConfig } from '../../types-CyvBaAl8.js';
2
- export { D as DEFAULT_UPLOAD_NOTIFICATION, U as UploadEventHandlers, a as UploadNotificationConfig } from '../../types-CyvBaAl8.js';
1
+ import { S as SupabaseUploadHandlerOptions, B as BucketConfig } from '../../types-6QHGELuY.js';
2
+ export { D as DEFAULT_UPLOAD_NOTIFICATION, U as UploadEventHandlers, a as UploadNotificationConfig } from '../../types-6QHGELuY.js';
3
+ import { SupabaseClient } from '@supabase/supabase-js';
3
4
 
4
5
  /**
5
6
  * Supabase Upload Handler for Web
@@ -49,6 +50,6 @@ declare class SupabaseUploadHandler {
49
50
  /**
50
51
  * Factory function for creating a SupabaseUploadHandler.
51
52
  */
52
- declare function createSupabaseUploadHandler(supabaseClient: any, bucketConfig: BucketConfig): SupabaseUploadHandler;
53
+ declare function createSupabaseUploadHandler(supabaseClient: SupabaseClient, bucketConfig: BucketConfig): SupabaseUploadHandler;
53
54
 
54
55
  export { BucketConfig, SupabaseUploadHandler, SupabaseUploadHandlerOptions, createSupabaseUploadHandler };
@@ -2,11 +2,13 @@ import "../../chunk-TGBT5XBE.js";
2
2
  import {
3
3
  SupabaseUploadHandler,
4
4
  createSupabaseUploadHandler
5
- } from "../../chunk-P4HZA6ZT.js";
5
+ } from "../../chunk-4665ZSE5.js";
6
6
  import {
7
7
  DEFAULT_UPLOAD_NOTIFICATION
8
- } from "../../chunk-Z6VOBGTU.js";
8
+ } from "../../chunk-ZAN22NGL.js";
9
+ import "../../chunk-UOMHWUHV.js";
9
10
  import "../../chunk-FV2HXEIY.js";
11
+ import "../../chunk-5WRI5ZAA.js";
10
12
  export {
11
13
  DEFAULT_UPLOAD_NOTIFICATION,
12
14
  SupabaseUploadHandler,
@@ -1,5 +1,6 @@
1
- import { S as SupabaseUploadHandlerOptions, a as UploadNotificationConfig, B as BucketConfig } from '../../types-CyvBaAl8.js';
2
- export { D as DEFAULT_UPLOAD_NOTIFICATION, U as UploadEventHandlers } from '../../types-CyvBaAl8.js';
1
+ import { S as SupabaseUploadHandlerOptions, a as UploadNotificationConfig, B as BucketConfig } from '../../types-6QHGELuY.js';
2
+ export { D as DEFAULT_UPLOAD_NOTIFICATION, U as UploadEventHandlers } from '../../types-6QHGELuY.js';
3
+ import { SupabaseClient } from '@supabase/supabase-js';
3
4
 
4
5
  /**
5
6
  * Supabase Upload Handler for React Native
@@ -51,6 +52,6 @@ declare class SupabaseUploadHandler {
51
52
  /**
52
53
  * Factory function for creating a SupabaseUploadHandler.
53
54
  */
54
- declare function createSupabaseUploadHandler(supabaseClient: any, bucketConfig: BucketConfig, notificationConfig?: Partial<UploadNotificationConfig>): SupabaseUploadHandler;
55
+ declare function createSupabaseUploadHandler(supabaseClient: SupabaseClient, bucketConfig: BucketConfig, notificationConfig?: Partial<UploadNotificationConfig>): SupabaseUploadHandler;
55
56
 
56
57
  export { BucketConfig, SupabaseUploadHandler, SupabaseUploadHandlerOptions, UploadNotificationConfig, createSupabaseUploadHandler };
@@ -2,11 +2,13 @@ import "../../chunk-YHTZ7VMV.js";
2
2
  import {
3
3
  SupabaseUploadHandler,
4
4
  createSupabaseUploadHandler
5
- } from "../../chunk-CAB26E6F.js";
5
+ } from "../../chunk-C4J4MLER.js";
6
6
  import {
7
7
  DEFAULT_UPLOAD_NOTIFICATION
8
- } from "../../chunk-Z6VOBGTU.js";
8
+ } from "../../chunk-ZAN22NGL.js";
9
+ import "../../chunk-UOMHWUHV.js";
9
10
  import "../../chunk-FV2HXEIY.js";
11
+ import "../../chunk-5WRI5ZAA.js";
10
12
  export {
11
13
  DEFAULT_UPLOAD_NOTIFICATION,
12
14
  SupabaseUploadHandler,
@@ -1,2 +1,3 @@
1
- export { B as BucketConfig, D as DEFAULT_UPLOAD_NOTIFICATION, S as SupabaseUploadHandlerOptions, U as UploadEventHandlers, a as UploadNotificationConfig } from '../../types-CyvBaAl8.js';
1
+ export { B as BucketConfig, D as DEFAULT_UPLOAD_NOTIFICATION, S as SupabaseUploadHandlerOptions, U as UploadEventHandlers, a as UploadNotificationConfig } from '../../types-6QHGELuY.js';
2
2
  export { SupabaseUploadHandler, createSupabaseUploadHandler } from './index.js';
3
+ import '@supabase/supabase-js';
@@ -1,11 +1,13 @@
1
1
  import {
2
2
  SupabaseUploadHandler,
3
3
  createSupabaseUploadHandler
4
- } from "../../chunk-P4HZA6ZT.js";
4
+ } from "../../chunk-4665ZSE5.js";
5
5
  import {
6
6
  DEFAULT_UPLOAD_NOTIFICATION
7
- } from "../../chunk-Z6VOBGTU.js";
7
+ } from "../../chunk-ZAN22NGL.js";
8
+ import "../../chunk-UOMHWUHV.js";
8
9
  import "../../chunk-FV2HXEIY.js";
10
+ import "../../chunk-5WRI5ZAA.js";
9
11
  export {
10
12
  DEFAULT_UPLOAD_NOTIFICATION,
11
13
  SupabaseUploadHandler,
@@ -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-B9MptP7E.js';
2
+ import { S as SupabaseConnectorOptions, P as PowerSyncCredentials } from './types-DqJnP50o.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,13 +1,18 @@
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-BujnI3IR.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-BujnI3IR.js';
3
+ import { A as AbstractPowerSyncDatabase, a as SyncStatus, S as SyncMode, U as UploadBlockReason, C as CrudEntry, f as SyncError, F as FailedTransaction, h as CompletedTransaction, e as SyncMetrics, b as ConnectionHealth } from '../types-B9MptP7E.js';
4
4
  import { AsyncStorageAdapter, LoggerAdapter } from '../platform/index.js';
5
+ import * as _powersync_common from '@powersync/common';
6
+ import { Table } from '@powersync/common';
5
7
 
6
8
  /**
7
9
  * Sync Status Tracker for @pol-studios/powersync
8
10
  *
9
11
  * Tracks and normalizes PowerSync status changes, providing a consistent
10
12
  * interface for status updates with throttling support.
13
+ *
14
+ * Transaction persistence uses local-only SQLite tables instead of AsyncStorage
15
+ * for better integration with PowerSync's database.
11
16
  */
12
17
 
13
18
  /**
@@ -41,6 +46,7 @@ declare class SyncStatusTracker {
41
46
  private readonly logger;
42
47
  private readonly notifyThrottleMs;
43
48
  private readonly onStatusChange?;
49
+ private _db;
44
50
  private _state;
45
51
  private _pendingMutations;
46
52
  private _lastNotifyTime;
@@ -62,11 +68,64 @@ declare class SyncStatusTracker {
62
68
  private _lastNotificationTime;
63
69
  private _isAutoOffline;
64
70
  constructor(storage: AsyncStorageAdapter, logger: LoggerAdapter, options?: SyncStatusTrackerOptions);
71
+ private _dbInitializing;
72
+ private _dbReady;
73
+ private _persistenceErrorCount;
74
+ private readonly _maxPersistenceErrors;
75
+ /**
76
+ * Set the PowerSync database instance AND initialize transactions atomically.
77
+ * This prevents race conditions between setDatabase() and initTransactions().
78
+ *
79
+ * @param db - The PowerSync database instance
80
+ * @returns Promise that resolves when initialization is complete
81
+ */
82
+ setDatabaseAndInit(db: AbstractPowerSyncDatabase): Promise<void>;
83
+ /**
84
+ * Set the PowerSync database instance for local-only table persistence.
85
+ * @deprecated Use setDatabaseAndInit() instead to avoid race conditions.
86
+ */
87
+ setDatabase(db: AbstractPowerSyncDatabase): void;
88
+ /**
89
+ * Get the PowerSync database instance.
90
+ */
91
+ getDatabase(): AbstractPowerSyncDatabase | null;
92
+ /**
93
+ * Check if the database is ready for persistence operations.
94
+ */
95
+ isDatabaseReady(): boolean;
96
+ /**
97
+ * Check if persistence is in a degraded state (too many errors).
98
+ */
99
+ isPersistenceDegraded(): boolean;
100
+ /**
101
+ * Track a persistence error and log if we enter degraded mode.
102
+ */
103
+ private _trackPersistenceError;
104
+ /**
105
+ * Reset persistence error count (e.g., after successful operation).
106
+ */
107
+ private _resetPersistenceErrors;
65
108
  /**
66
109
  * Initialize the tracker by loading persisted state.
67
110
  * Includes migration from old isPaused boolean to new syncMode.
111
+ *
112
+ * Note: Transaction data is loaded from SQLite after the database is set.
113
+ * Call initTransactions() after setDatabase() to load transaction history.
68
114
  */
69
115
  init(): Promise<void>;
116
+ /**
117
+ * Initialize transactions from SQLite local-only tables.
118
+ * Must be called after setDatabase() has been called.
119
+ */
120
+ initTransactions(): Promise<void>;
121
+ /**
122
+ * Load completed transactions from SQLite local-only table.
123
+ */
124
+ private _loadCompletedTransactionsFromDb;
125
+ /**
126
+ * Load failed transactions from SQLite local-only table.
127
+ */
128
+ private _loadFailedTransactionsFromDb;
70
129
  /**
71
130
  * Dispose the tracker and clear timers.
72
131
  */
@@ -79,6 +138,26 @@ declare class SyncStatusTracker {
79
138
  * Get the current sync mode.
80
139
  */
81
140
  getSyncMode(): SyncMode;
141
+ /**
142
+ * Get the reason why uploads are currently blocked.
143
+ * Returns 'none' if uploads are ready to proceed.
144
+ *
145
+ * Priority order (first match wins):
146
+ * 1. offline_mode - User explicitly chose offline mode
147
+ * 2. auto_offline - System went offline automatically (network loss with auto-offline flag)
148
+ * 3. pull_only_mode - Pull-only mode active
149
+ * 4. network_unreachable - No internet connection
150
+ * 5. disconnected - PowerSync not connected
151
+ * 6. connecting - PowerSync is connecting
152
+ * 7. uploading - Actively uploading
153
+ * 8. none - Ready to sync
154
+ */
155
+ getUploadBlockReason(): UploadBlockReason;
156
+ /**
157
+ * Get a human-readable description of why uploads are blocked.
158
+ * Returns null if uploads are not blocked.
159
+ */
160
+ getUploadBlockDescription(): string | null;
82
161
  /**
83
162
  * Check if uploads are allowed based on current sync mode and network reachability.
84
163
  */
@@ -173,9 +252,15 @@ declare class SyncStatusTracker {
173
252
  */
174
253
  clearFailure(failureId: string): void;
175
254
  /**
176
- * Clear all failures.
255
+ * Clear failures for successfully synced entries.
256
+ * Removes any failed transaction that contains entries with the given IDs.
257
+ *
258
+ * This is called when `onTransactionSuccess` fires - if any entry in a failed
259
+ * transaction has now succeeded, we remove that entire failure record.
260
+ *
261
+ * @param entryIds - Array of CrudEntry.id values that succeeded
177
262
  */
178
- clearAllFailures(): void;
263
+ clearSuccessfulEntries(entryIds: string[]): void;
179
264
  /**
180
265
  * Remove a failed transaction from tracking and return its entries.
181
266
  * This is a "pop" operation - the failure is removed from the list.
@@ -250,14 +335,30 @@ declare class SyncStatusTracker {
250
335
  */
251
336
  getLastNotificationTime(): number;
252
337
  /**
253
- * Schedule a debounced persist operation.
254
- * This prevents race conditions from multiple rapid persist calls.
338
+ * Insert a completed transaction into SQLite.
255
339
  */
256
- private _schedulePersist;
340
+ private _insertCompletedTransaction;
341
+ /**
342
+ * Delete a completed transaction from SQLite.
343
+ */
344
+ private _deleteCompletedTransaction;
345
+ /**
346
+ * Delete all completed transactions from SQLite.
347
+ */
348
+ private _deleteAllCompletedTransactions;
349
+ /**
350
+ * Insert a failed transaction into SQLite.
351
+ */
352
+ private _insertFailedTransaction;
353
+ /**
354
+ * Delete a failed transaction from SQLite.
355
+ */
356
+ private _deleteFailedTransaction;
257
357
  /**
258
- * Persist completed and failed transactions to storage.
358
+ * Enforce the max completed transactions limit in SQLite.
359
+ * Removes oldest entries beyond the limit.
259
360
  */
260
- private _persistTransactions;
361
+ private _enforceCompletedTransactionsLimit;
261
362
  private _hasStatusChanged;
262
363
  /**
263
364
  * Notify all listeners of status changes with throttling.
@@ -495,6 +596,77 @@ declare class HealthMonitor {
495
596
  private _withTimeout;
496
597
  }
497
598
 
599
+ /**
600
+ * Local-only table for storing failed upload transactions.
601
+ * Not synced to server - purely client-side persistence.
602
+ *
603
+ * Replaces AsyncStorage key '@pol-powersync:failed_transactions'.
604
+ */
605
+ declare const FailedTransactionsTable: Table<{
606
+ entries: _powersync_common.BaseColumnType<string>;
607
+ errorType: _powersync_common.BaseColumnType<string>;
608
+ errorMessage: _powersync_common.BaseColumnType<string>;
609
+ errorUserMessage: _powersync_common.BaseColumnType<string>;
610
+ errorPgCode: _powersync_common.BaseColumnType<string>;
611
+ errorTimestamp: _powersync_common.BaseColumnType<string>;
612
+ errorIsPermanent: _powersync_common.BaseColumnType<number>;
613
+ affectedEntityIds: _powersync_common.BaseColumnType<string>;
614
+ affectedTables: _powersync_common.BaseColumnType<string>;
615
+ retryCount: _powersync_common.BaseColumnType<number>;
616
+ isPermanent: _powersync_common.BaseColumnType<number>;
617
+ firstFailedAt: _powersync_common.BaseColumnType<string>;
618
+ lastFailedAt: _powersync_common.BaseColumnType<string>;
619
+ }>;
620
+ /**
621
+ * Local-only table for storing completed upload transactions.
622
+ * Used for sync history/activity display.
623
+ *
624
+ * Replaces AsyncStorage key '@pol-powersync:completed_transactions'.
625
+ */
626
+ declare const CompletedTransactionsTable: Table<{
627
+ entries: _powersync_common.BaseColumnType<string>;
628
+ affectedEntityIds: _powersync_common.BaseColumnType<string>;
629
+ affectedTables: _powersync_common.BaseColumnType<string>;
630
+ completedAt: _powersync_common.BaseColumnType<string>;
631
+ }>;
632
+ /**
633
+ * Local-only tables to be merged into the PowerSync schema.
634
+ *
635
+ * These use the naming convention `ps_local_*` to clearly indicate
636
+ * they are local-only tables managed by the sync system.
637
+ */
638
+ declare const LOCAL_ONLY_TABLES: {
639
+ ps_local_failed_transactions: Table<{
640
+ entries: _powersync_common.BaseColumnType<string>;
641
+ errorType: _powersync_common.BaseColumnType<string>;
642
+ errorMessage: _powersync_common.BaseColumnType<string>;
643
+ errorUserMessage: _powersync_common.BaseColumnType<string>;
644
+ errorPgCode: _powersync_common.BaseColumnType<string>;
645
+ errorTimestamp: _powersync_common.BaseColumnType<string>;
646
+ errorIsPermanent: _powersync_common.BaseColumnType<number>;
647
+ affectedEntityIds: _powersync_common.BaseColumnType<string>;
648
+ affectedTables: _powersync_common.BaseColumnType<string>;
649
+ retryCount: _powersync_common.BaseColumnType<number>;
650
+ isPermanent: _powersync_common.BaseColumnType<number>;
651
+ firstFailedAt: _powersync_common.BaseColumnType<string>;
652
+ lastFailedAt: _powersync_common.BaseColumnType<string>;
653
+ }>;
654
+ ps_local_completed_transactions: Table<{
655
+ entries: _powersync_common.BaseColumnType<string>;
656
+ affectedEntityIds: _powersync_common.BaseColumnType<string>;
657
+ affectedTables: _powersync_common.BaseColumnType<string>;
658
+ completedAt: _powersync_common.BaseColumnType<string>;
659
+ }>;
660
+ };
661
+ /**
662
+ * Table names for the local-only tables.
663
+ * Use these constants when querying the tables.
664
+ */
665
+ declare const LOCAL_TABLE_NAMES: {
666
+ readonly FAILED_TRANSACTIONS: "ps_local_failed_transactions";
667
+ readonly COMPLETED_TRANSACTIONS: "ps_local_completed_transactions";
668
+ };
669
+
498
670
  /**
499
671
  * Dead Letter Queue (DLQ) for PowerSync
500
672
  *
@@ -687,4 +859,4 @@ declare function generateDLQEntryId(entries: CrudEntry[]): string;
687
859
  */
688
860
  declare function createDeadLetterEntry(entries: CrudEntry[], error: SyncError, reason: DeadLetterReason, retryAttempts?: number): DeadLetterEntry;
689
861
 
690
- export { type DeadLetterEntry, DeadLetterQueue, type DeadLetterQueueListener, type DeadLetterQueueOptions, type DeadLetterReason, HealthCheckResult, HealthMonitor, HealthMonitorOptions, MetricsCollector, MetricsCollectorOptions, PowerSyncRawStatus, SyncOperationData, SyncStatusTracker, SyncStatusTrackerOptions, Unsubscribe, createDeadLetterEntry, generateDLQEntryId };
862
+ export { CompletedTransactionsTable, type DeadLetterEntry, DeadLetterQueue, type DeadLetterQueueListener, type DeadLetterQueueOptions, type DeadLetterReason, FailedTransactionsTable, HealthCheckResult, HealthMonitor, HealthMonitorOptions, LOCAL_ONLY_TABLES, LOCAL_TABLE_NAMES, MetricsCollector, MetricsCollectorOptions, PowerSyncRawStatus, SyncOperationData, SyncStatusTracker, SyncStatusTrackerOptions, Unsubscribe, createDeadLetterEntry, generateDLQEntryId };
@@ -7,18 +7,28 @@ import {
7
7
  isBackgroundSyncRegistered,
8
8
  registerBackgroundSync,
9
9
  unregisterBackgroundSync
10
- } from "../chunk-A4IBBWGO.js";
10
+ } from "../chunk-RALHHPTU.js";
11
11
  import {
12
12
  HealthMonitor,
13
13
  MetricsCollector,
14
14
  SyncStatusTracker
15
- } from "../chunk-55DKCJV4.js";
16
- import "../chunk-24RDMMCL.js";
15
+ } from "../chunk-2RDWLXJW.js";
16
+ import {
17
+ CompletedTransactionsTable,
18
+ FailedTransactionsTable,
19
+ LOCAL_ONLY_TABLES,
20
+ LOCAL_TABLE_NAMES
21
+ } from "../chunk-OGUFUZSY.js";
17
22
  import "../chunk-CGL33PL4.js";
18
23
  import "../chunk-I2AYMY5O.js";
24
+ import "../chunk-5WRI5ZAA.js";
19
25
  export {
26
+ CompletedTransactionsTable,
20
27
  DeadLetterQueue,
28
+ FailedTransactionsTable,
21
29
  HealthMonitor,
30
+ LOCAL_ONLY_TABLES,
31
+ LOCAL_TABLE_NAMES,
22
32
  MetricsCollector,
23
33
  SyncStatusTracker,
24
34
  createDeadLetterEntry,
@@ -1,8 +1,11 @@
1
+ import { SupabaseClient } from '@supabase/supabase-js';
2
+
1
3
  /**
2
4
  * Upload Handler Types for @pol-studios/powersync
3
5
  *
4
6
  * Defines types for platform-specific upload handlers.
5
7
  */
8
+
6
9
  /**
7
10
  * Bucket configuration for multi-bucket routing.
8
11
  */
@@ -19,7 +22,7 @@ interface BucketConfig {
19
22
  */
20
23
  interface SupabaseUploadHandlerOptions {
21
24
  /** Supabase client instance */
22
- supabaseClient: any;
25
+ supabaseClient: SupabaseClient;
23
26
  /** Bucket configuration for multi-bucket routing */
24
27
  bucketConfig: BucketConfig;
25
28
  }
@@ -23,6 +23,11 @@ type EntitySyncState = 'idle' | 'saving' | 'syncing' | 'synced' | 'error';
23
23
  * - 'offline': No sync at all (fully disconnected)
24
24
  */
25
25
  type SyncMode = 'push-pull' | 'pull-only' | 'offline';
26
+ /**
27
+ * Reason why uploads are currently blocked.
28
+ * Used by getUploadBlockReason() to provide detailed status for UI.
29
+ */
30
+ type UploadBlockReason = 'offline_mode' | 'pull_only_mode' | 'network_unreachable' | 'auto_offline' | 'disconnected' | 'connecting' | 'uploading' | 'none';
26
31
  /**
27
32
  * CrudEntry represents a pending CRUD operation in the sync queue
28
33
  */
@@ -317,6 +322,13 @@ interface AbstractPowerSyncDatabase {
317
322
  connect(connector: PowerSyncBackendConnector): Promise<void>;
318
323
  /** Disconnect from the PowerSync service */
319
324
  disconnect(): Promise<void>;
325
+ /**
326
+ * Disconnect and clear all synced data.
327
+ * @param options.clearLocal - If false, preserves local mutations in ps_crud. Default: true
328
+ */
329
+ disconnectAndClear(options?: {
330
+ clearLocal?: boolean;
331
+ }): Promise<void>;
320
332
  /** Register a listener for status changes */
321
333
  registerListener(listener: {
322
334
  statusChanged?: (status: unknown) => void;
@@ -390,4 +402,4 @@ interface IntegrityCheckRow {
390
402
  [key: string]: unknown;
391
403
  }
392
404
 
393
- export type { AbstractPowerSyncDatabase as A, CrudEntry as C, DownloadProgress as D, EntitySyncState as E, FailedTransaction as F, IntegrityResult as I, PowerSyncBackendConnector as P, SyncMode as S, TableCacheStats as T, SyncStatus as a, ConnectionHealth as b, StorageInfo as c, StorageQuota as d, SyncMetrics as e, SyncError as f, SyncErrorType as g, CompletedTransaction as h, ClassifiedError as i, CompactResult as j, CacheStats as k, CrudTransaction as l, SqliteTableRow as m, DbStatRow as n, CountRow as o, PageSizeRow as p, PageCountRow as q, FreelistCountRow as r, IntegrityCheckRow as s };
405
+ export type { AbstractPowerSyncDatabase as A, CrudEntry as C, DownloadProgress as D, EntitySyncState as E, FailedTransaction as F, IntegrityResult as I, PowerSyncBackendConnector as P, SyncMode as S, TableCacheStats as T, UploadBlockReason as U, SyncStatus as a, ConnectionHealth as b, StorageInfo as c, StorageQuota as d, SyncMetrics as e, SyncError as f, SyncErrorType as g, CompletedTransaction as h, ClassifiedError as i, CompactResult as j, CacheStats as k, CrudTransaction as l, SqliteTableRow as m, DbStatRow as n, CountRow as o, PageSizeRow as p, PageCountRow as q, FreelistCountRow as r, IntegrityCheckRow as s };