@pol-studios/powersync 1.0.6 → 1.0.10

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 (128) hide show
  1. package/README.md +933 -0
  2. package/dist/CacheSettingsManager-uz-kbnRH.d.ts +461 -0
  3. package/dist/attachments/index.d.ts +745 -332
  4. package/dist/attachments/index.js +152 -6
  5. package/dist/{types-Cd7RhNqf.d.ts → background-sync-ChCXW-EV.d.ts} +53 -2
  6. package/dist/chunk-24RDMMCL.js +44 -0
  7. package/dist/chunk-24RDMMCL.js.map +1 -0
  8. package/dist/chunk-4TXTAEF2.js +2060 -0
  9. package/dist/chunk-4TXTAEF2.js.map +1 -0
  10. package/dist/chunk-63PXSPIN.js +358 -0
  11. package/dist/chunk-63PXSPIN.js.map +1 -0
  12. package/dist/chunk-654ERHA7.js +1 -0
  13. package/dist/chunk-A4IBBWGO.js +377 -0
  14. package/dist/chunk-A4IBBWGO.js.map +1 -0
  15. package/dist/chunk-BRXQNASY.js +1720 -0
  16. package/dist/chunk-BRXQNASY.js.map +1 -0
  17. package/dist/chunk-CAB26E6F.js +142 -0
  18. package/dist/chunk-CAB26E6F.js.map +1 -0
  19. package/dist/{chunk-EJ23MXPQ.js → chunk-CGL33PL4.js} +3 -1
  20. package/dist/chunk-CGL33PL4.js.map +1 -0
  21. package/dist/{chunk-R4YFWQ3Q.js → chunk-CUCAYK7Z.js} +309 -92
  22. package/dist/chunk-CUCAYK7Z.js.map +1 -0
  23. package/dist/chunk-FV2HXEIY.js +124 -0
  24. package/dist/chunk-FV2HXEIY.js.map +1 -0
  25. package/dist/chunk-HWSNV45P.js +279 -0
  26. package/dist/chunk-HWSNV45P.js.map +1 -0
  27. package/dist/{chunk-62J2DPKX.js → chunk-KN2IZERF.js} +530 -413
  28. package/dist/chunk-KN2IZERF.js.map +1 -0
  29. package/dist/{chunk-7EMDVIZX.js → chunk-N75DEF5J.js} +19 -1
  30. package/dist/chunk-N75DEF5J.js.map +1 -0
  31. package/dist/chunk-P4HZA6ZT.js +83 -0
  32. package/dist/chunk-P4HZA6ZT.js.map +1 -0
  33. package/dist/chunk-P6WOZO7H.js +49 -0
  34. package/dist/chunk-P6WOZO7H.js.map +1 -0
  35. package/dist/chunk-T4AO7JIG.js +1 -0
  36. package/dist/chunk-TGBT5XBE.js +1 -0
  37. package/dist/{chunk-FPTDATY5.js → chunk-VACPAAQZ.js} +54 -12
  38. package/dist/chunk-VACPAAQZ.js.map +1 -0
  39. package/dist/chunk-WGHNIAF7.js +329 -0
  40. package/dist/chunk-WGHNIAF7.js.map +1 -0
  41. package/dist/{chunk-3AYXHQ4W.js → chunk-WN5ZJ3E2.js} +108 -47
  42. package/dist/chunk-WN5ZJ3E2.js.map +1 -0
  43. package/dist/chunk-XAEII4ZX.js +456 -0
  44. package/dist/chunk-XAEII4ZX.js.map +1 -0
  45. package/dist/chunk-XOY2CJ67.js +289 -0
  46. package/dist/chunk-XOY2CJ67.js.map +1 -0
  47. package/dist/chunk-YHTZ7VMV.js +1 -0
  48. package/dist/chunk-YSTEESEG.js +676 -0
  49. package/dist/chunk-YSTEESEG.js.map +1 -0
  50. package/dist/chunk-Z6VOBGTU.js +32 -0
  51. package/dist/chunk-Z6VOBGTU.js.map +1 -0
  52. package/dist/chunk-ZM4ENYMF.js +230 -0
  53. package/dist/chunk-ZM4ENYMF.js.map +1 -0
  54. package/dist/connector/index.d.ts +236 -4
  55. package/dist/connector/index.js +15 -4
  56. package/dist/core/index.d.ts +16 -3
  57. package/dist/core/index.js +6 -2
  58. package/dist/error/index.d.ts +54 -0
  59. package/dist/error/index.js +7 -0
  60. package/dist/error/index.js.map +1 -0
  61. package/dist/index.d.ts +102 -12
  62. package/dist/index.js +309 -37
  63. package/dist/index.native.d.ts +22 -10
  64. package/dist/index.native.js +309 -38
  65. package/dist/index.web.d.ts +22 -10
  66. package/dist/index.web.js +310 -38
  67. package/dist/maintenance/index.d.ts +118 -0
  68. package/dist/maintenance/index.js +16 -0
  69. package/dist/maintenance/index.js.map +1 -0
  70. package/dist/platform/index.d.ts +16 -1
  71. package/dist/platform/index.js.map +1 -1
  72. package/dist/platform/index.native.d.ts +2 -2
  73. package/dist/platform/index.native.js +1 -1
  74. package/dist/platform/index.web.d.ts +1 -1
  75. package/dist/platform/index.web.js +1 -1
  76. package/dist/pol-attachment-queue-BVAIueoP.d.ts +817 -0
  77. package/dist/provider/index.d.ts +451 -21
  78. package/dist/provider/index.js +32 -13
  79. package/dist/react/index.d.ts +372 -0
  80. package/dist/react/index.js +25 -0
  81. package/dist/react/index.js.map +1 -0
  82. package/dist/storage/index.d.ts +6 -0
  83. package/dist/storage/index.js +42 -0
  84. package/dist/storage/index.js.map +1 -0
  85. package/dist/storage/index.native.d.ts +6 -0
  86. package/dist/storage/index.native.js +40 -0
  87. package/dist/storage/index.native.js.map +1 -0
  88. package/dist/storage/index.web.d.ts +6 -0
  89. package/dist/storage/index.web.js +40 -0
  90. package/dist/storage/index.web.js.map +1 -0
  91. package/dist/storage/upload/index.d.ts +54 -0
  92. package/dist/storage/upload/index.js +15 -0
  93. package/dist/storage/upload/index.js.map +1 -0
  94. package/dist/storage/upload/index.native.d.ts +56 -0
  95. package/dist/storage/upload/index.native.js +15 -0
  96. package/dist/storage/upload/index.native.js.map +1 -0
  97. package/dist/storage/upload/index.web.d.ts +2 -0
  98. package/dist/storage/upload/index.web.js +14 -0
  99. package/dist/storage/upload/index.web.js.map +1 -0
  100. package/dist/supabase-connector-T9vHq_3i.d.ts +202 -0
  101. package/dist/sync/index.d.ts +288 -23
  102. package/dist/sync/index.js +22 -10
  103. package/dist/{index-l3iL9Jte.d.ts → types-B212hgfA.d.ts} +101 -158
  104. package/dist/{types-afHtE1U_.d.ts → types-CDqWh56B.d.ts} +2 -0
  105. package/dist/types-CyvBaAl8.d.ts +60 -0
  106. package/dist/types-D0WcHrq6.d.ts +234 -0
  107. package/package.json +89 -5
  108. package/dist/chunk-32OLICZO.js +0 -1
  109. package/dist/chunk-3AYXHQ4W.js.map +0 -1
  110. package/dist/chunk-5FIMA26D.js +0 -1
  111. package/dist/chunk-62J2DPKX.js.map +0 -1
  112. package/dist/chunk-7EMDVIZX.js.map +0 -1
  113. package/dist/chunk-EJ23MXPQ.js.map +0 -1
  114. package/dist/chunk-FPTDATY5.js.map +0 -1
  115. package/dist/chunk-KCDG2MNP.js +0 -1431
  116. package/dist/chunk-KCDG2MNP.js.map +0 -1
  117. package/dist/chunk-OLHGI472.js +0 -1
  118. package/dist/chunk-PAFBKNL3.js +0 -99
  119. package/dist/chunk-PAFBKNL3.js.map +0 -1
  120. package/dist/chunk-R4YFWQ3Q.js.map +0 -1
  121. package/dist/chunk-V6LJ6MR2.js +0 -740
  122. package/dist/chunk-V6LJ6MR2.js.map +0 -1
  123. package/dist/chunk-VJCL2SWD.js +0 -1
  124. package/dist/failed-upload-store-C0cLxxPz.d.ts +0 -33
  125. /package/dist/{chunk-32OLICZO.js.map → chunk-654ERHA7.js.map} +0 -0
  126. /package/dist/{chunk-5FIMA26D.js.map → chunk-T4AO7JIG.js.map} +0 -0
  127. /package/dist/{chunk-OLHGI472.js.map → chunk-TGBT5XBE.js.map} +0 -0
  128. /package/dist/{chunk-VJCL2SWD.js.map → chunk-YHTZ7VMV.js.map} +0 -0
package/dist/index.web.js CHANGED
@@ -1,26 +1,159 @@
1
- import "./chunk-OLHGI472.js";
2
- import "./chunk-32OLICZO.js";
1
+ import "./chunk-654ERHA7.js";
2
+ import {
3
+ SlimPowerSyncProvider,
4
+ useAttachmentQueueContext,
5
+ usePowerSyncContext,
6
+ useSyncStatusContext
7
+ } from "./chunk-63PXSPIN.js";
8
+ import {
9
+ DOWNLOAD_WORKFLOW_STATES,
10
+ STATE_MAPPING,
11
+ STATE_NAMES,
12
+ TERMINAL_STATES,
13
+ UPLOAD_WORKFLOW_STATES,
14
+ VALID_STATES,
15
+ buildIdOnlyWatchQuery,
16
+ buildRecordFetchQuery,
17
+ buildWatchQuery,
18
+ createMigrationStats,
19
+ formatMigrationStats,
20
+ getStateName,
21
+ isDownloadWorkflowState,
22
+ isTerminalState,
23
+ isUploadWorkflowState,
24
+ isValidAttachmentState,
25
+ migrateAttachmentState,
26
+ migrateAttachmentStateSafe,
27
+ recordMigration,
28
+ validateSqlIdentifier as validateSqlIdentifier2,
29
+ validateWhereClause,
30
+ watchConfigToSourceConfig
31
+ } from "./chunk-ZM4ENYMF.js";
32
+ import {
33
+ ConflictBus,
34
+ OfflineDataProvider,
35
+ PowerSyncProvider,
36
+ ProviderBridge
37
+ } from "./chunk-BRXQNASY.js";
38
+ import "./chunk-YHTZ7VMV.js";
39
+ import {
40
+ PowerSyncErrorBoundary
41
+ } from "./chunk-P6WOZO7H.js";
42
+ import {
43
+ ATTACHMENT_TABLE,
44
+ AbstractAttachmentQueue,
45
+ AttachmentState,
46
+ AttachmentTable,
47
+ CACHE_SIZE_PRESETS,
48
+ DEFAULT_ATTACHMENT_QUEUE_OPTIONS,
49
+ DEFAULT_CACHE_CONFIG,
50
+ DEFAULT_COMPRESSION_CONFIG,
51
+ DEFAULT_DOWNLOAD_CONFIG,
52
+ DEFAULT_UPLOAD_CONFIG,
53
+ EncodingType,
54
+ LOCALLY_AVAILABLE_STATES,
55
+ PENDING_DOWNLOAD_STATES,
56
+ PROTECTED_UPLOAD_STATES,
57
+ PolAttachmentQueue,
58
+ PolAttachmentState,
59
+ PolStorageAdapter,
60
+ blobToArrayBuffer,
61
+ cacheLocalFile,
62
+ clearCache,
63
+ clearUploadCallback,
64
+ copyToManagedCache,
65
+ createCacheManagerDeps,
66
+ createPolAttachmentQueue,
67
+ createUploadManagerDeps,
68
+ createUploadManagerState,
69
+ determineAttachmentState,
70
+ downloadRecord,
71
+ enforceCacheLimit,
72
+ ensureFileUri,
73
+ extractErrorCode,
74
+ formatCacheSize,
75
+ getCachedSize,
76
+ getEvictionCandidates,
77
+ getExcludeProtectedStatesCondition,
78
+ getExtensionFromMimeType,
79
+ getFailedPermanentUploads,
80
+ getLocalUriForStoragePath,
81
+ getMimeType,
82
+ getMimeTypeFromPath,
83
+ getPendingUploads,
84
+ getProtectedStatesInClause,
85
+ getSoonestRetryTime,
86
+ getStaleUploads,
87
+ getSyncedUploadsWithPendingCallback,
88
+ isAudioMimeType,
89
+ isCacheNearCapacity,
90
+ isDocumentMimeType,
91
+ isImageMimeType,
92
+ isLocallyAvailable,
93
+ isPendingDownloadState,
94
+ isPermanentError,
95
+ isProtectedUploadState,
96
+ isStateTransitionAllowed,
97
+ isVideoMimeType,
98
+ markUploadPermanentFailure,
99
+ markUploadSynced,
100
+ scheduleUploadRetry,
101
+ startUploadProcessing,
102
+ stripFileUri,
103
+ uploadOne,
104
+ validateSqlIdentifier
105
+ } from "./chunk-4TXTAEF2.js";
106
+ import {
107
+ DeadLetterQueue,
108
+ createDeadLetterEntry,
109
+ defineBackgroundSyncTask,
110
+ generateDLQEntryId,
111
+ initializeBackgroundSync,
112
+ isBackgroundSyncRegistered,
113
+ registerBackgroundSync,
114
+ unregisterBackgroundSync
115
+ } from "./chunk-A4IBBWGO.js";
116
+ import {
117
+ HealthMonitor,
118
+ MetricsCollector,
119
+ SyncStatusTracker
120
+ } from "./chunk-CUCAYK7Z.js";
121
+ import {
122
+ DEFAULT_CONNECTION_HEALTH,
123
+ DEFAULT_SYNC_CONFIG,
124
+ DEFAULT_SYNC_METRICS,
125
+ DEFAULT_SYNC_STATUS
126
+ } from "./chunk-24RDMMCL.js";
127
+ import {
128
+ checkIntegrityImpl,
129
+ checkStorageQuotaImpl,
130
+ compactDatabaseImpl,
131
+ formatBytes,
132
+ getCacheStatsImpl,
133
+ useDatabaseMaintenance
134
+ } from "./chunk-WGHNIAF7.js";
3
135
  import {
4
136
  AttachmentQueueContext,
5
137
  CompletedTransactionsContext,
6
- ConflictBus,
7
138
  ConnectionHealthContext,
8
139
  ConnectionStatusContext,
9
140
  FailedTransactionsContext,
10
141
  PendingMutationsContext,
11
142
  PowerSyncContext,
12
- PowerSyncProvider,
13
143
  SyncActivityContext,
14
144
  SyncMetricsContext,
15
145
  SyncModeContext,
16
146
  SyncStatusContext,
17
147
  useAttachmentQueue,
148
+ useAttachmentQueueReady,
149
+ useCompletedTransactions,
18
150
  useCompletedTransactionsContext,
19
151
  useConnectionHealth,
20
152
  useConnectionStatus,
21
153
  useDatabase,
22
154
  useDownloadProgress,
23
155
  useEntitySyncStatus,
156
+ useFailedTransactions,
24
157
  useFailedTransactionsContext,
25
158
  useIsSyncing,
26
159
  useOnlineStatus,
@@ -36,24 +169,32 @@ import {
36
169
  useSyncModeContext,
37
170
  useSyncStatus,
38
171
  useUploadStatus
39
- } from "./chunk-KCDG2MNP.js";
172
+ } from "./chunk-YSTEESEG.js";
173
+ import "./chunk-T4AO7JIG.js";
174
+ import "./chunk-CAB26E6F.js";
40
175
  import {
41
- AttachmentQueue,
42
- AttachmentState,
43
- DEFAULT_CACHE_CONFIG,
44
- DEFAULT_COMPRESSION_CONFIG,
45
- DEFAULT_DOWNLOAD_CONFIG
46
- } from "./chunk-V6LJ6MR2.js";
47
- import "./chunk-5FIMA26D.js";
176
+ CacheSettingsManager,
177
+ DEFAULT_CACHE_SETTINGS,
178
+ createSupabaseStorage,
179
+ isBlobResult,
180
+ isFileResult
181
+ } from "./chunk-XOY2CJ67.js";
48
182
  import {
49
- DEFAULT_CONNECTION_HEALTH,
50
- DEFAULT_SYNC_CONFIG,
51
- DEFAULT_SYNC_METRICS,
52
- DEFAULT_SYNC_STATUS,
53
- HealthMonitor,
54
- MetricsCollector,
55
- SyncStatusTracker
56
- } from "./chunk-R4YFWQ3Q.js";
183
+ SupabaseStorageAdapter,
184
+ createSupabaseStorageAdapter,
185
+ getStorageErrorMessage,
186
+ isStorageAuthError,
187
+ normalizeStoragePath
188
+ } from "./chunk-XAEII4ZX.js";
189
+ import "./chunk-TGBT5XBE.js";
190
+ import {
191
+ SupabaseUploadHandler,
192
+ createSupabaseUploadHandler
193
+ } from "./chunk-P4HZA6ZT.js";
194
+ import {
195
+ DEFAULT_UPLOAD_NOTIFICATION,
196
+ resolveBucket
197
+ } from "./chunk-Z6VOBGTU.js";
57
198
  import "./chunk-W7HSR35B.js";
58
199
  import {
59
200
  ATTACHMENT_DOWNLOAD_TIMEOUT_MS,
@@ -80,37 +221,44 @@ import {
80
221
  STATUS_NOTIFY_THROTTLE_MS,
81
222
  STORAGE_CRITICAL_THRESHOLD,
82
223
  STORAGE_KEY_ATTACHMENT_SETTINGS,
224
+ STORAGE_KEY_AUTO_OFFLINE,
83
225
  STORAGE_KEY_ENABLED,
84
226
  STORAGE_KEY_METRICS,
85
227
  STORAGE_KEY_PAUSED,
86
228
  STORAGE_KEY_PREFIX,
87
229
  STORAGE_KEY_SYNC_MODE,
88
230
  STORAGE_WARNING_THRESHOLD
89
- } from "./chunk-EJ23MXPQ.js";
231
+ } from "./chunk-CGL33PL4.js";
232
+ import "./chunk-WN5ZJ3E2.js";
90
233
  import {
91
234
  createWebPlatformAdapter
92
- } from "./chunk-7EMDVIZX.js";
93
- import "./chunk-VJCL2SWD.js";
235
+ } from "./chunk-N75DEF5J.js";
94
236
  import {
95
- AbortError,
96
- DEFAULT_BACKOFF_CONFIG,
237
+ AuthRefreshError,
238
+ CircuitBreaker,
239
+ CircuitOpenError,
240
+ DEFAULT_CIRCUIT_BREAKER_CONFIG,
241
+ createSupabaseAuth
242
+ } from "./chunk-HWSNV45P.js";
243
+ import {
244
+ ConflictDetectionError,
97
245
  DEFAULT_RETRY_CONFIG,
98
- RetryExhaustedError,
99
246
  SupabaseConnector,
100
- addJitter,
101
- calculateBackoffDelay,
102
247
  defaultSchemaRouter,
103
248
  detectConflicts,
104
249
  fetchServerVersion,
105
250
  getLocalVersion,
106
- hasVersionColumn,
251
+ hasVersionColumn
252
+ } from "./chunk-KN2IZERF.js";
253
+ import {
254
+ AbortError,
255
+ DEFAULT_BACKOFF_CONFIG,
256
+ RetryExhaustedError,
257
+ addJitter,
258
+ calculateBackoffDelay,
107
259
  sleep,
108
260
  withExponentialBackoff
109
- } from "./chunk-62J2DPKX.js";
110
- import {
111
- FailedUploadStore,
112
- failedUploadStore
113
- } from "./chunk-PAFBKNL3.js";
261
+ } from "./chunk-FV2HXEIY.js";
114
262
  import {
115
263
  AttachmentError,
116
264
  ConfigurationError,
@@ -125,29 +273,41 @@ import {
125
273
  extractEntityIds,
126
274
  extractTableNames,
127
275
  generateFailureId,
276
+ isRlsError,
128
277
  toSyncOperationError
129
- } from "./chunk-FPTDATY5.js";
278
+ } from "./chunk-VACPAAQZ.js";
130
279
  export {
131
280
  ATTACHMENT_DOWNLOAD_TIMEOUT_MS,
132
281
  ATTACHMENT_RETRY_DELAY_MS,
282
+ ATTACHMENT_TABLE,
133
283
  AbortError,
284
+ AbstractAttachmentQueue,
134
285
  AttachmentError,
135
- AttachmentQueue,
136
286
  AttachmentQueueContext,
137
287
  AttachmentState,
288
+ AttachmentTable,
289
+ AuthRefreshError,
290
+ CACHE_SIZE_PRESETS,
138
291
  COMPRESSION_MAX_WIDTH,
139
292
  COMPRESSION_SKIP_SIZE_BYTES,
140
293
  COMPRESSION_TARGET_SIZE_BYTES,
294
+ CacheSettingsManager,
295
+ CircuitBreaker,
296
+ CircuitOpenError,
141
297
  CompletedTransactionsContext,
142
298
  ConfigurationError,
143
299
  ConflictBus,
300
+ ConflictDetectionError,
144
301
  ConnectionHealthContext,
145
302
  ConnectionStatusContext,
146
303
  ConnectorError,
147
304
  DEFAULT_ATTACHMENT_CACHE_SIZE,
148
305
  DEFAULT_ATTACHMENT_CONCURRENCY,
306
+ DEFAULT_ATTACHMENT_QUEUE_OPTIONS,
149
307
  DEFAULT_BACKOFF_CONFIG,
150
308
  DEFAULT_CACHE_CONFIG,
309
+ DEFAULT_CACHE_SETTINGS,
310
+ DEFAULT_CIRCUIT_BREAKER_CONFIG,
151
311
  DEFAULT_COMPRESSION_CONFIG,
152
312
  DEFAULT_COMPRESSION_QUALITY,
153
313
  DEFAULT_CONNECTION_HEALTH,
@@ -162,64 +322,170 @@ export {
162
322
  DEFAULT_SYNC_METRICS,
163
323
  DEFAULT_SYNC_MODE,
164
324
  DEFAULT_SYNC_STATUS,
325
+ DEFAULT_UPLOAD_CONFIG,
326
+ DEFAULT_UPLOAD_NOTIFICATION,
165
327
  DOWNLOAD_STOP_THRESHOLD,
328
+ DOWNLOAD_WORKFLOW_STATES,
329
+ DeadLetterQueue,
166
330
  EVICTION_TRIGGER_THRESHOLD,
331
+ EncodingType,
167
332
  FailedTransactionsContext,
168
- FailedUploadStore,
169
333
  HEALTH_CHECK_INTERVAL_MS,
170
334
  HEALTH_CHECK_TIMEOUT_MS,
171
335
  HealthMonitor,
172
336
  InitializationError,
173
337
  LATENCY_DEGRADED_THRESHOLD_MS,
338
+ LOCALLY_AVAILABLE_STATES,
174
339
  MAX_CONSECUTIVE_FAILURES,
175
340
  MetricsCollector,
341
+ OfflineDataProvider,
342
+ PENDING_DOWNLOAD_STATES,
343
+ PROTECTED_UPLOAD_STATES,
176
344
  PendingMutationsContext,
177
345
  PlatformAdapterError,
346
+ PolAttachmentQueue,
347
+ PolAttachmentState,
348
+ PolStorageAdapter,
178
349
  PowerSyncContext,
179
350
  PowerSyncError,
351
+ PowerSyncErrorBoundary,
180
352
  PowerSyncProvider,
353
+ ProviderBridge,
181
354
  RetryExhaustedError,
355
+ STATE_MAPPING,
356
+ STATE_NAMES,
182
357
  STATS_CACHE_TTL_MS,
183
358
  STATUS_NOTIFY_THROTTLE_MS,
184
359
  STORAGE_CRITICAL_THRESHOLD,
185
360
  STORAGE_KEY_ATTACHMENT_SETTINGS,
361
+ STORAGE_KEY_AUTO_OFFLINE,
186
362
  STORAGE_KEY_ENABLED,
187
363
  STORAGE_KEY_METRICS,
188
364
  STORAGE_KEY_PAUSED,
189
365
  STORAGE_KEY_PREFIX,
190
366
  STORAGE_KEY_SYNC_MODE,
191
367
  STORAGE_WARNING_THRESHOLD,
368
+ SlimPowerSyncProvider,
192
369
  SupabaseConnector,
370
+ SupabaseStorageAdapter,
371
+ SupabaseUploadHandler,
193
372
  SyncActivityContext,
194
373
  SyncMetricsContext,
195
374
  SyncModeContext,
196
375
  SyncOperationError,
197
376
  SyncStatusContext,
198
377
  SyncStatusTracker,
378
+ TERMINAL_STATES,
379
+ UPLOAD_WORKFLOW_STATES,
380
+ VALID_STATES,
199
381
  addJitter,
382
+ blobToArrayBuffer,
383
+ buildIdOnlyWatchQuery,
384
+ buildRecordFetchQuery,
385
+ buildWatchQuery,
386
+ cacheLocalFile,
200
387
  calculateBackoffDelay,
388
+ checkIntegrityImpl,
389
+ checkStorageQuotaImpl,
201
390
  classifyError,
202
391
  classifySupabaseError,
392
+ clearCache,
393
+ clearUploadCallback,
394
+ compactDatabaseImpl,
395
+ copyToManagedCache,
396
+ createCacheManagerDeps,
397
+ createDeadLetterEntry,
398
+ createMigrationStats,
399
+ createPolAttachmentQueue,
400
+ createSupabaseAuth,
401
+ createSupabaseStorage,
402
+ createSupabaseStorageAdapter,
403
+ createSupabaseUploadHandler,
203
404
  createSyncError,
405
+ createUploadManagerDeps,
406
+ createUploadManagerState,
204
407
  createWebPlatformAdapter,
205
408
  defaultSchemaRouter,
409
+ defineBackgroundSyncTask,
206
410
  detectConflicts,
411
+ determineAttachmentState,
412
+ downloadRecord,
413
+ enforceCacheLimit,
414
+ ensureFileUri,
207
415
  extractEntityIds,
416
+ extractErrorCode,
208
417
  extractTableNames,
209
- failedUploadStore,
210
418
  fetchServerVersion,
419
+ formatBytes,
420
+ formatCacheSize,
421
+ formatMigrationStats,
422
+ generateDLQEntryId,
211
423
  generateFailureId,
424
+ getCacheStatsImpl,
425
+ getCachedSize,
426
+ getEvictionCandidates,
427
+ getExcludeProtectedStatesCondition,
428
+ getExtensionFromMimeType,
429
+ getFailedPermanentUploads,
430
+ getLocalUriForStoragePath,
212
431
  getLocalVersion,
432
+ getMimeType,
433
+ getMimeTypeFromPath,
434
+ getPendingUploads,
435
+ getProtectedStatesInClause,
436
+ getSoonestRetryTime,
437
+ getStaleUploads,
438
+ getStateName,
439
+ getStorageErrorMessage,
440
+ getSyncedUploadsWithPendingCallback,
213
441
  hasVersionColumn,
442
+ initializeBackgroundSync,
443
+ isAudioMimeType,
444
+ isBackgroundSyncRegistered,
445
+ isBlobResult,
446
+ isCacheNearCapacity,
447
+ isDocumentMimeType,
448
+ isDownloadWorkflowState,
449
+ isFileResult,
450
+ isImageMimeType,
451
+ isLocallyAvailable,
452
+ isPendingDownloadState,
453
+ isPermanentError,
454
+ isProtectedUploadState,
455
+ isRlsError,
456
+ isStateTransitionAllowed,
457
+ isStorageAuthError,
458
+ isTerminalState,
459
+ isUploadWorkflowState,
460
+ isValidAttachmentState,
461
+ isVideoMimeType,
462
+ markUploadPermanentFailure,
463
+ markUploadSynced,
464
+ migrateAttachmentState,
465
+ migrateAttachmentStateSafe,
466
+ normalizeStoragePath,
467
+ recordMigration,
468
+ registerBackgroundSync,
469
+ resolveBucket,
470
+ scheduleUploadRetry,
214
471
  sleep,
472
+ startUploadProcessing,
473
+ stripFileUri,
215
474
  toSyncOperationError,
475
+ unregisterBackgroundSync,
476
+ uploadOne,
216
477
  useAttachmentQueue,
478
+ useAttachmentQueueContext,
479
+ useAttachmentQueueReady,
480
+ useCompletedTransactions,
217
481
  useCompletedTransactionsContext,
218
482
  useConnectionHealth,
219
483
  useConnectionStatus,
220
484
  useDatabase,
485
+ useDatabaseMaintenance,
221
486
  useDownloadProgress,
222
487
  useEntitySyncStatus,
488
+ useFailedTransactions,
223
489
  useFailedTransactionsContext,
224
490
  useIsSyncing,
225
491
  useOnlineStatus,
@@ -227,6 +493,7 @@ export {
227
493
  usePendingMutationsContext,
228
494
  usePlatform,
229
495
  usePowerSync,
496
+ usePowerSyncContext,
230
497
  useSyncActivity,
231
498
  useSyncActivityContext,
232
499
  useSyncControl,
@@ -234,7 +501,12 @@ export {
234
501
  useSyncMode,
235
502
  useSyncModeContext,
236
503
  useSyncStatus,
504
+ useSyncStatusContext,
237
505
  useUploadStatus,
506
+ validateSqlIdentifier2 as validateSqlIdentifier,
507
+ validateSqlIdentifier as validateSqlIdentifierFromStateMachine,
508
+ validateWhereClause,
509
+ watchConfigToSourceConfig,
238
510
  withExponentialBackoff
239
511
  };
240
512
  //# sourceMappingURL=index.web.js.map
@@ -0,0 +1,118 @@
1
+ import { k as CacheStats, j as CompactResult, I as IntegrityResult, d as StorageQuota, A as AbstractPowerSyncDatabase } from '../types-CDqWh56B.js';
2
+ export { c as StorageInfo } from '../types-CDqWh56B.js';
3
+ import { LoggerAdapter } from '../platform/index.js';
4
+
5
+ /**
6
+ * Database Maintenance Module Types for @pol-studios/powersync
7
+ *
8
+ * This module provides types for database maintenance operations including
9
+ * cache inspection, compaction, integrity checking, and storage quota monitoring.
10
+ */
11
+
12
+ /**
13
+ * Return type for the useDatabaseMaintenance hook.
14
+ * Provides utilities for inspecting and maintaining the PowerSync database.
15
+ */
16
+ interface DatabaseMaintenanceUtils {
17
+ /**
18
+ * Get detailed cache statistics for all tables.
19
+ * Returns null if the database is not available.
20
+ *
21
+ * @returns Cache statistics including table-level details and storage info
22
+ */
23
+ getCacheStats: () => Promise<CacheStats | null>;
24
+ /**
25
+ * Compact the database by running VACUUM.
26
+ * This reclaims free pages and reduces the database file size.
27
+ *
28
+ * @returns Result of the compaction operation
29
+ */
30
+ compactDatabase: () => Promise<CompactResult>;
31
+ /**
32
+ * Check the integrity of the database.
33
+ * Runs SQLite integrity_check pragma.
34
+ *
35
+ * @returns Result indicating health status and any issues found
36
+ */
37
+ checkIntegrity: () => Promise<IntegrityResult>;
38
+ /**
39
+ * Check device storage quota and database size.
40
+ * Useful for warning users about low storage situations.
41
+ *
42
+ * @returns Storage quota information with status
43
+ */
44
+ checkStorageQuota: () => Promise<StorageQuota>;
45
+ }
46
+
47
+ /**
48
+ * Pure Database Maintenance Functions for @pol-studios/powersync
49
+ *
50
+ * This module contains stateless, pure functions for database maintenance operations.
51
+ * These functions can be called by hooks or used directly in other contexts.
52
+ *
53
+ * All functions accept the database as a parameter rather than accessing it from context,
54
+ * making them testable and reusable across different environments.
55
+ */
56
+
57
+ /**
58
+ * Get detailed cache statistics for all tables in the database.
59
+ *
60
+ * This function:
61
+ * - Queries all tables from sqlite_master
62
+ * - Tries to get table sizes from dbstat (with fallback estimation)
63
+ * - Batches table row counts in groups of 50
64
+ * - Calculates storage info from PRAGMA page_size, page_count, freelist_count
65
+ *
66
+ * @param db - The PowerSync database instance
67
+ * @param logger - Optional logger for debug output
68
+ * @returns Cache statistics or null if operation times out or fails
69
+ */
70
+ declare function getCacheStatsImpl(db: AbstractPowerSyncDatabase, logger?: LoggerAdapter): Promise<CacheStats | null>;
71
+ /**
72
+ * Compact the database by running VACUUM.
73
+ * This reclaims free pages and reduces the database file size.
74
+ *
75
+ * @param db - The PowerSync database instance
76
+ * @returns Result of the compaction operation including bytes reclaimed
77
+ */
78
+ declare function compactDatabaseImpl(db: AbstractPowerSyncDatabase): Promise<CompactResult>;
79
+ /**
80
+ * Check the integrity of the database.
81
+ * Runs SQLite's PRAGMA integrity_check.
82
+ *
83
+ * @param db - The PowerSync database instance
84
+ * @returns Result indicating health status and any issues found
85
+ */
86
+ declare function checkIntegrityImpl(db: AbstractPowerSyncDatabase): Promise<IntegrityResult>;
87
+ /**
88
+ * Check device storage quota and database size.
89
+ * Useful for warning users about low storage situations.
90
+ *
91
+ * @param db - The PowerSync database instance (can be null)
92
+ * @param getFreeDiskSpace - Callback to get free disk space in bytes
93
+ * @returns Storage quota information with status
94
+ */
95
+ declare function checkStorageQuotaImpl(db: AbstractPowerSyncDatabase | null, getFreeDiskSpace: () => Promise<number>): Promise<StorageQuota>;
96
+
97
+ /**
98
+ * React Hook for Database Maintenance Utilities
99
+ *
100
+ * This module provides a React hook that wraps the pure database maintenance
101
+ * functions with stable function references via useCallback.
102
+ */
103
+
104
+ /**
105
+ * Hook for database maintenance utilities.
106
+ *
107
+ * Use this hook when you need to perform database maintenance operations.
108
+ * These operations are expensive - call sparingly (e.g., settings screens).
109
+ *
110
+ * Each function has a stable reference via useCallback.
111
+ *
112
+ * @example
113
+ * const { getCacheStats, compactDatabase } = useDatabaseMaintenance();
114
+ * const stats = await getCacheStats();
115
+ */
116
+ declare function useDatabaseMaintenance(): DatabaseMaintenanceUtils;
117
+
118
+ export { CacheStats, CompactResult, type DatabaseMaintenanceUtils, IntegrityResult, StorageQuota, checkIntegrityImpl, checkStorageQuotaImpl, compactDatabaseImpl, getCacheStatsImpl, useDatabaseMaintenance };
@@ -0,0 +1,16 @@
1
+ import {
2
+ checkIntegrityImpl,
3
+ checkStorageQuotaImpl,
4
+ compactDatabaseImpl,
5
+ getCacheStatsImpl,
6
+ useDatabaseMaintenance
7
+ } from "../chunk-WGHNIAF7.js";
8
+ import "../chunk-YSTEESEG.js";
9
+ export {
10
+ checkIntegrityImpl,
11
+ checkStorageQuotaImpl,
12
+ compactDatabaseImpl,
13
+ getCacheStatsImpl,
14
+ useDatabaseMaintenance
15
+ };
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,4 +1,4 @@
1
- import { A as AbstractPowerSyncDatabase } from '../types-afHtE1U_.js';
1
+ import { A as AbstractPowerSyncDatabase } from '../types-CDqWh56B.js';
2
2
 
3
3
  /**
4
4
  * Platform Adapter Types for @pol-studios/powersync
@@ -95,6 +95,21 @@ interface FileSystemAdapter {
95
95
  * Get the free disk space in bytes
96
96
  */
97
97
  getFreeDiskSpace(): Promise<number>;
98
+ /**
99
+ * Download a file from a URL directly to a local path.
100
+ *
101
+ * React Native: Uses expo-file-system downloadAsync which streams
102
+ * directly to disk without loading the entire file into memory,
103
+ * making it suitable for large files.
104
+ *
105
+ * Web: Uses fetch + blob + base64 conversion to IndexedDB. Note that
106
+ * the file is temporarily held in memory during conversion, so very
107
+ * large files (>50MB) may cause memory pressure on web platforms.
108
+ *
109
+ * @param url - The URL to download from
110
+ * @param localPath - The local path to save the file to
111
+ */
112
+ downloadFile(url: string, localPath: string): Promise<void>;
98
113
  }
99
114
  /**
100
115
  * Key-value storage interface for persisting preferences and state.