@pol-studios/powersync 1.0.7 → 1.0.11

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 (103) 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 +709 -6
  4. package/dist/attachments/index.js +133 -5
  5. package/dist/chunk-24RDMMCL.js +44 -0
  6. package/dist/chunk-24RDMMCL.js.map +1 -0
  7. package/dist/chunk-4TXTAEF2.js +2060 -0
  8. package/dist/chunk-4TXTAEF2.js.map +1 -0
  9. package/dist/chunk-63PXSPIN.js +358 -0
  10. package/dist/chunk-63PXSPIN.js.map +1 -0
  11. package/dist/chunk-654ERHA7.js +1 -0
  12. package/dist/{chunk-BREGB4WL.js → chunk-BRXQNASY.js} +287 -335
  13. package/dist/chunk-BRXQNASY.js.map +1 -0
  14. package/dist/{chunk-DHYUBVP7.js → chunk-CAB26E6F.js} +20 -9
  15. package/dist/chunk-CAB26E6F.js.map +1 -0
  16. package/dist/{chunk-H772V6XQ.js → chunk-CUCAYK7Z.js} +7 -43
  17. package/dist/chunk-CUCAYK7Z.js.map +1 -0
  18. package/dist/{chunk-4C3RY5SU.js → chunk-HWSNV45P.js} +76 -1
  19. package/dist/chunk-HWSNV45P.js.map +1 -0
  20. package/dist/{chunk-HFOFLW5F.js → chunk-KN2IZERF.js} +139 -6
  21. package/dist/chunk-KN2IZERF.js.map +1 -0
  22. package/dist/{chunk-UEYRTLKE.js → chunk-P4HZA6ZT.js} +20 -9
  23. package/dist/chunk-P4HZA6ZT.js.map +1 -0
  24. package/dist/chunk-T4AO7JIG.js +1 -0
  25. package/dist/{chunk-XQAJM2MW.js → chunk-VACPAAQZ.js} +33 -2
  26. package/dist/{chunk-XQAJM2MW.js.map → chunk-VACPAAQZ.js.map} +1 -1
  27. package/dist/{chunk-53WH2JJV.js → chunk-WN5ZJ3E2.js} +5 -8
  28. package/dist/chunk-WN5ZJ3E2.js.map +1 -0
  29. package/dist/chunk-XAEII4ZX.js +456 -0
  30. package/dist/chunk-XAEII4ZX.js.map +1 -0
  31. package/dist/chunk-XOY2CJ67.js +289 -0
  32. package/dist/chunk-XOY2CJ67.js.map +1 -0
  33. package/dist/chunk-YHTZ7VMV.js +1 -0
  34. package/dist/{chunk-MKD2VCX3.js → chunk-Z6VOBGTU.js} +8 -8
  35. package/dist/chunk-Z6VOBGTU.js.map +1 -0
  36. package/dist/chunk-ZM4ENYMF.js +230 -0
  37. package/dist/chunk-ZM4ENYMF.js.map +1 -0
  38. package/dist/connector/index.d.ts +56 -3
  39. package/dist/connector/index.js +8 -5
  40. package/dist/core/index.d.ts +12 -1
  41. package/dist/core/index.js +3 -2
  42. package/dist/error/index.js +0 -1
  43. package/dist/generator/cli.js +527 -0
  44. package/dist/generator/index.d.ts +168 -0
  45. package/dist/generator/index.js +370 -0
  46. package/dist/generator/index.js.map +1 -0
  47. package/dist/index.d.ts +12 -10
  48. package/dist/index.js +191 -29
  49. package/dist/index.native.d.ts +11 -9
  50. package/dist/index.native.js +191 -29
  51. package/dist/index.web.d.ts +11 -9
  52. package/dist/index.web.js +191 -29
  53. package/dist/maintenance/index.js +0 -1
  54. package/dist/platform/index.js +0 -2
  55. package/dist/platform/index.js.map +1 -1
  56. package/dist/platform/index.native.js +1 -2
  57. package/dist/platform/index.web.js +0 -1
  58. package/dist/pol-attachment-queue-BVAIueoP.d.ts +817 -0
  59. package/dist/provider/index.d.ts +38 -34
  60. package/dist/provider/index.js +11 -12
  61. package/dist/react/index.d.ts +372 -0
  62. package/dist/react/index.js +25 -0
  63. package/dist/storage/index.d.ts +3 -3
  64. package/dist/storage/index.js +22 -8
  65. package/dist/storage/index.native.d.ts +3 -3
  66. package/dist/storage/index.native.js +21 -7
  67. package/dist/storage/index.web.d.ts +3 -3
  68. package/dist/storage/index.web.js +21 -7
  69. package/dist/storage/upload/index.d.ts +7 -8
  70. package/dist/storage/upload/index.js +3 -3
  71. package/dist/storage/upload/index.native.d.ts +7 -8
  72. package/dist/storage/upload/index.native.js +4 -3
  73. package/dist/storage/upload/index.web.d.ts +1 -4
  74. package/dist/storage/upload/index.web.js +3 -3
  75. package/dist/supabase-connector-T9vHq_3i.d.ts +202 -0
  76. package/dist/sync/index.js +3 -3
  77. package/dist/{supabase-connector-qLm-WHkM.d.ts → types-B212hgfA.d.ts} +48 -170
  78. package/dist/{types-BVacP54t.d.ts → types-CyvBaAl8.d.ts} +12 -4
  79. package/dist/types-D0WcHrq6.d.ts +234 -0
  80. package/package.json +28 -4
  81. package/dist/CacheSettingsManager-1exbOC6S.d.ts +0 -261
  82. package/dist/chunk-4C3RY5SU.js.map +0 -1
  83. package/dist/chunk-53WH2JJV.js.map +0 -1
  84. package/dist/chunk-BREGB4WL.js.map +0 -1
  85. package/dist/chunk-DGUM43GV.js +0 -11
  86. package/dist/chunk-DHYUBVP7.js.map +0 -1
  87. package/dist/chunk-GKF7TOMT.js +0 -1
  88. package/dist/chunk-H772V6XQ.js.map +0 -1
  89. package/dist/chunk-HFOFLW5F.js.map +0 -1
  90. package/dist/chunk-KGSFAE5B.js +0 -1
  91. package/dist/chunk-LNL64IJZ.js +0 -1
  92. package/dist/chunk-MKD2VCX3.js.map +0 -1
  93. package/dist/chunk-UEYRTLKE.js.map +0 -1
  94. package/dist/chunk-WQ5MPAVC.js +0 -449
  95. package/dist/chunk-WQ5MPAVC.js.map +0 -1
  96. package/dist/chunk-ZEOKPWUC.js +0 -1165
  97. package/dist/chunk-ZEOKPWUC.js.map +0 -1
  98. package/dist/pol-attachment-queue-C7YNXXhK.d.ts +0 -676
  99. package/dist/types-Bgvx7-E8.d.ts +0 -187
  100. /package/dist/{chunk-DGUM43GV.js.map → chunk-654ERHA7.js.map} +0 -0
  101. /package/dist/{chunk-GKF7TOMT.js.map → chunk-T4AO7JIG.js.map} +0 -0
  102. /package/dist/{chunk-KGSFAE5B.js.map → chunk-YHTZ7VMV.js.map} +0 -0
  103. /package/dist/{chunk-LNL64IJZ.js.map → react/index.js.map} +0 -0
@@ -1,34 +1,162 @@
1
- import "../chunk-GKF7TOMT.js";
1
+ import {
2
+ DOWNLOAD_WORKFLOW_STATES,
3
+ STATE_MAPPING,
4
+ STATE_NAMES,
5
+ TERMINAL_STATES,
6
+ UPLOAD_WORKFLOW_STATES,
7
+ VALID_STATES,
8
+ buildIdOnlyWatchQuery,
9
+ buildRecordFetchQuery,
10
+ buildWatchQuery,
11
+ createMigrationStats,
12
+ formatMigrationStats,
13
+ getStateName,
14
+ isDownloadWorkflowState,
15
+ isTerminalState,
16
+ isUploadWorkflowState,
17
+ isValidAttachmentState,
18
+ migrateAttachmentState,
19
+ migrateAttachmentStateSafe,
20
+ recordMigration,
21
+ validateSqlIdentifier as validateSqlIdentifier2,
22
+ validateWhereClause,
23
+ watchConfigToSourceConfig
24
+ } from "../chunk-ZM4ENYMF.js";
2
25
  import {
3
26
  ATTACHMENT_TABLE,
4
27
  AbstractAttachmentQueue,
5
28
  AttachmentState,
6
29
  AttachmentTable,
30
+ CACHE_SIZE_PRESETS,
7
31
  DEFAULT_ATTACHMENT_QUEUE_OPTIONS,
8
32
  DEFAULT_CACHE_CONFIG,
9
33
  DEFAULT_COMPRESSION_CONFIG,
34
+ DEFAULT_DOWNLOAD_CONFIG,
10
35
  DEFAULT_UPLOAD_CONFIG,
11
36
  EncodingType,
37
+ LOCALLY_AVAILABLE_STATES,
38
+ PENDING_DOWNLOAD_STATES,
39
+ PROTECTED_UPLOAD_STATES,
12
40
  PolAttachmentQueue,
13
41
  PolAttachmentState,
14
42
  PolStorageAdapter,
15
- createPolAttachmentQueue
16
- } from "../chunk-ZEOKPWUC.js";
43
+ blobToArrayBuffer,
44
+ cacheLocalFile,
45
+ clearCache,
46
+ clearUploadCallback,
47
+ copyToManagedCache,
48
+ createCacheManagerDeps,
49
+ createPolAttachmentQueue,
50
+ createUploadManagerDeps,
51
+ createUploadManagerState,
52
+ determineAttachmentState,
53
+ downloadRecord,
54
+ enforceCacheLimit,
55
+ ensureFileUri,
56
+ extractErrorCode,
57
+ formatCacheSize,
58
+ getCachedSize,
59
+ getEvictionCandidates,
60
+ getExcludeProtectedStatesCondition,
61
+ getFailedPermanentUploads,
62
+ getLocalUriForStoragePath,
63
+ getPendingUploads,
64
+ getProtectedStatesInClause,
65
+ getSoonestRetryTime,
66
+ getStaleUploads,
67
+ getSyncedUploadsWithPendingCallback,
68
+ isCacheNearCapacity,
69
+ isLocallyAvailable,
70
+ isPendingDownloadState,
71
+ isPermanentError,
72
+ isProtectedUploadState,
73
+ isStateTransitionAllowed,
74
+ markUploadPermanentFailure,
75
+ markUploadSynced,
76
+ scheduleUploadRetry,
77
+ startUploadProcessing,
78
+ stripFileUri,
79
+ uploadOne,
80
+ validateSqlIdentifier
81
+ } from "../chunk-4TXTAEF2.js";
17
82
  import "../chunk-FV2HXEIY.js";
18
- import "../chunk-DGUM43GV.js";
19
83
  export {
20
84
  ATTACHMENT_TABLE,
21
85
  AbstractAttachmentQueue,
22
86
  AttachmentState,
23
87
  AttachmentTable,
88
+ CACHE_SIZE_PRESETS,
24
89
  DEFAULT_ATTACHMENT_QUEUE_OPTIONS,
25
90
  DEFAULT_CACHE_CONFIG,
26
91
  DEFAULT_COMPRESSION_CONFIG,
92
+ DEFAULT_DOWNLOAD_CONFIG,
27
93
  DEFAULT_UPLOAD_CONFIG,
94
+ DOWNLOAD_WORKFLOW_STATES,
28
95
  EncodingType,
96
+ LOCALLY_AVAILABLE_STATES,
97
+ PENDING_DOWNLOAD_STATES,
98
+ PROTECTED_UPLOAD_STATES,
29
99
  PolAttachmentQueue,
30
100
  PolAttachmentState,
31
101
  PolStorageAdapter,
32
- createPolAttachmentQueue
102
+ STATE_MAPPING,
103
+ STATE_NAMES,
104
+ TERMINAL_STATES,
105
+ UPLOAD_WORKFLOW_STATES,
106
+ VALID_STATES,
107
+ blobToArrayBuffer,
108
+ buildIdOnlyWatchQuery,
109
+ buildRecordFetchQuery,
110
+ buildWatchQuery,
111
+ cacheLocalFile,
112
+ clearCache,
113
+ clearUploadCallback,
114
+ copyToManagedCache,
115
+ createCacheManagerDeps,
116
+ createMigrationStats,
117
+ createPolAttachmentQueue,
118
+ createUploadManagerDeps,
119
+ createUploadManagerState,
120
+ determineAttachmentState,
121
+ downloadRecord,
122
+ enforceCacheLimit,
123
+ ensureFileUri,
124
+ extractErrorCode,
125
+ formatCacheSize,
126
+ formatMigrationStats,
127
+ getCachedSize,
128
+ getEvictionCandidates,
129
+ getExcludeProtectedStatesCondition,
130
+ getFailedPermanentUploads,
131
+ getLocalUriForStoragePath,
132
+ getPendingUploads,
133
+ getProtectedStatesInClause,
134
+ getSoonestRetryTime,
135
+ getStaleUploads,
136
+ getStateName,
137
+ getSyncedUploadsWithPendingCallback,
138
+ isCacheNearCapacity,
139
+ isDownloadWorkflowState,
140
+ isLocallyAvailable,
141
+ isPendingDownloadState,
142
+ isPermanentError,
143
+ isProtectedUploadState,
144
+ isStateTransitionAllowed,
145
+ isTerminalState,
146
+ isUploadWorkflowState,
147
+ isValidAttachmentState,
148
+ markUploadPermanentFailure,
149
+ markUploadSynced,
150
+ migrateAttachmentState,
151
+ migrateAttachmentStateSafe,
152
+ recordMigration,
153
+ scheduleUploadRetry,
154
+ startUploadProcessing,
155
+ stripFileUri,
156
+ uploadOne,
157
+ validateSqlIdentifier2 as validateSqlIdentifier,
158
+ validateSqlIdentifier as validateSqlIdentifierFromStateMachine,
159
+ validateWhereClause,
160
+ watchConfigToSourceConfig
33
161
  };
34
162
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,44 @@
1
+ // src/provider/types.ts
2
+ var DEFAULT_SYNC_STATUS = {
3
+ connected: false,
4
+ connecting: false,
5
+ hasSynced: false,
6
+ lastSyncedAt: null,
7
+ uploading: false,
8
+ downloading: false,
9
+ downloadProgress: null,
10
+ failedTransactions: [],
11
+ hasUploadErrors: false,
12
+ permanentErrorCount: 0
13
+ };
14
+ var DEFAULT_CONNECTION_HEALTH = {
15
+ status: "disconnected",
16
+ latency: null,
17
+ lastHealthCheck: null,
18
+ consecutiveFailures: 0,
19
+ reconnectAttempts: 0
20
+ };
21
+ var DEFAULT_SYNC_METRICS = {
22
+ totalSyncs: 0,
23
+ successfulSyncs: 0,
24
+ failedSyncs: 0,
25
+ lastSyncDuration: null,
26
+ averageSyncDuration: null,
27
+ totalDataDownloaded: 0,
28
+ totalDataUploaded: 0,
29
+ lastError: null
30
+ };
31
+ var DEFAULT_SYNC_CONFIG = {
32
+ autoConnect: true,
33
+ syncInterval: 0,
34
+ enableHealthMonitoring: true,
35
+ enableMetrics: true
36
+ };
37
+
38
+ export {
39
+ DEFAULT_SYNC_STATUS,
40
+ DEFAULT_CONNECTION_HEALTH,
41
+ DEFAULT_SYNC_METRICS,
42
+ DEFAULT_SYNC_CONFIG
43
+ };
44
+ //# sourceMappingURL=chunk-24RDMMCL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/provider/types.ts"],"sourcesContent":["/**\n * Provider Types for @pol-studios/powersync\n *\n * Defines configuration and context interfaces for the PowerSyncProvider.\n */\n\nimport type { SupabaseClient } from '@supabase/supabase-js';\nimport type { QueryClient } from '@tanstack/react-query';\nimport type { AbstractPowerSyncDatabase, SyncStatus, ConnectionHealth, SyncMetrics, CrudEntry, FailedTransaction, CompletedTransaction, SyncMode, DownloadProgress } from '../core/types';\nimport type { PlatformAdapter } from '../platform/types';\nimport type { ConnectorConfig } from '../connector/types';\nimport type { AttachmentConfig } from '../attachments/types';\nimport type { PolAttachmentQueue } from '../attachments/pol-attachment-queue';\nimport type { SupabaseConnector } from '../connector/supabase-connector';\nimport type { ConflictBus } from '../conflicts/conflict-bus';\n\n// ─── Provider Configuration ──────────────────────────────────────────────────\n\n/**\n * Main configuration for PowerSyncProvider.\n *\n * @template TSchema - The PowerSync schema type\n *\n * @example\n * ```typescript\n * const config: PowerSyncConfig<AppSchema> = {\n * platform: createNativePlatformAdapter(logger),\n * schema: AppSchema,\n * powerSyncUrl: 'https://your-powersync-instance.com',\n * supabaseClient: supabase,\n * dbFilename: 'myapp.db',\n * sync: {\n * autoConnect: true,\n * },\n * };\n * ```\n */\nexport interface PowerSyncConfig<TSchema = unknown> {\n /**\n * Platform adapter for platform-specific operations.\n * Use createNativePlatformAdapter() for React Native or createWebPlatformAdapter() for Web.\n */\n platform: PlatformAdapter;\n\n /**\n * PowerSync schema definition.\n * This defines the tables and their structure for the local database.\n */\n schema: TSchema;\n\n /**\n * PowerSync service URL.\n * @example \"https://your-instance.powersync.journeyapps.com\"\n */\n powerSyncUrl: string;\n\n /**\n * Supabase client instance.\n * Used for authentication and as the backend for CRUD uploads.\n */\n supabaseClient: SupabaseClient;\n\n /**\n * Optional: TanStack Query client for cache invalidation.\n * If provided, will invalidate queries when sync completes.\n */\n queryClient?: QueryClient;\n\n /**\n * Optional: Database filename.\n * @default \"powersync.db\"\n */\n dbFilename?: string;\n\n /**\n * Optional: Connector configuration for custom CRUD handling.\n */\n connector?: ConnectorConfig;\n\n /**\n * Optional: Attachment queue configuration for offline file caching.\n *\n * @example\n * ```typescript\n * attachments: {\n * source: { table: 'photos', idColumn: 'storage_path' },\n * remoteStorage: supabaseStorageAdapter,\n * }\n * ```\n */\n attachments?: AttachmentConfig;\n\n /**\n * Optional: Sync behavior configuration.\n */\n sync?: SyncConfig;\n}\n\n/**\n * Sync behavior configuration.\n */\nexport interface SyncConfig {\n /**\n * Automatically connect when the provider mounts and there's an authenticated session.\n * @default true\n */\n autoConnect?: boolean;\n\n /**\n * Sync interval for periodic sync checks (in milliseconds).\n * Set to 0 to disable periodic sync.\n * @default 0 (disabled)\n */\n syncInterval?: number;\n\n /**\n * Enable health monitoring.\n * @default true\n */\n enableHealthMonitoring?: boolean;\n\n /**\n * Enable metrics collection.\n * @default true\n */\n enableMetrics?: boolean;\n}\n\n// ─── Context Types ───────────────────────────────────────────────────────────\n\n/**\n * Value provided by the main PowerSyncContext.\n *\n * @template TSchema - The PowerSync schema type\n */\nexport interface PowerSyncContextValue<TSchema = unknown> {\n /**\n * The PowerSync database instance.\n * Will be null if not initialized or if initialization failed.\n */\n db: AbstractPowerSyncDatabase | null;\n\n /**\n * The Supabase connector instance.\n * Will be null if not initialized.\n */\n connector: SupabaseConnector | null;\n\n /**\n * The attachment queue instance.\n * Will be null if attachments are not configured or not initialized.\n */\n attachmentQueue: PolAttachmentQueue | null;\n\n /**\n * Whether the PowerSync database is ready for use.\n */\n isReady: boolean;\n\n /**\n * Whether the provider is currently initializing.\n */\n isInitializing: boolean;\n\n /**\n * Whether the attachment queue is ready for use.\n * This is separate from isReady because the attachment queue initializes\n * asynchronously after the database is ready.\n *\n * States:\n * - `false`: Attachment queue is still initializing\n * - `true` with `attachmentQueue !== null`: Ready and available\n * - `true` with `attachmentQueue === null`: Either attachments not configured, OR initialization failed\n */\n attachmentQueueReady: boolean;\n\n /**\n * Error that occurred during initialization, if any.\n */\n error: Error | null;\n\n /**\n * The schema used for this database.\n */\n schema: TSchema;\n\n /**\n * The platform adapter instance.\n */\n platform: PlatformAdapter;\n\n /**\n * The conflict bus for subscribing to conflict events.\n * Use this to wire up conflict UI components.\n */\n conflictBus: ConflictBus;\n}\n\n/**\n * Value provided by SyncStatusContext.\n */\nexport interface SyncStatusContextValue {\n /**\n * Current sync status.\n */\n status: SyncStatus;\n\n /**\n * Pending mutations waiting to be uploaded.\n */\n pendingMutations: CrudEntry[];\n\n /**\n * Number of pending mutations.\n */\n pendingCount: number;\n\n /**\n * Whether data is currently being uploaded to the server.\n * This is the authoritative source for upload activity.\n */\n isUploading: boolean;\n\n /**\n * Whether data is currently being downloaded from the server.\n * This is the authoritative source for download activity.\n */\n isDownloading: boolean;\n\n /**\n * Whether sync is currently paused (offline mode).\n */\n isPaused: boolean;\n\n /**\n * Current sync mode: 'push-pull' (full sync), 'pull-only' (download only), or 'offline' (no sync).\n */\n syncMode: SyncMode;\n\n /**\n * Timestamp of the last successful sync.\n */\n lastSyncedAt: Date | null;\n\n /**\n * Error that occurred during connection, if any.\n */\n connectionError: Error | null;\n\n /**\n * Failed transactions that need attention.\n */\n failedTransactions: FailedTransaction[];\n\n /**\n * Whether there are any upload errors.\n */\n hasUploadErrors: boolean;\n\n /**\n * Count of permanent errors that need user action.\n */\n permanentErrorCount: number;\n\n /**\n * Clear a specific failure by its ID.\n */\n clearFailure: (failureId: string) => void;\n\n /**\n * Clear all failures.\n */\n clearAllFailures: () => void;\n\n /**\n * Completed transactions history.\n */\n completedTransactions: CompletedTransaction[];\n\n /**\n * Clear the completed transaction history.\n */\n clearCompletedHistory: () => void;\n\n /**\n * Set the sync mode.\n * @param mode - The sync mode to set\n */\n setSyncMode: (mode: SyncMode) => Promise<void>;\n\n /**\n * Set the force next upload flag.\n * When true, the next sync cycle will upload regardless of sync mode.\n */\n setForceNextUpload: (force: boolean) => void;\n\n /**\n * Discard a specific pending mutation by its client ID.\n * Uses safe disconnect/reconnect pattern to avoid transaction conflicts.\n * @throws Error if upload is in progress\n */\n discardPendingMutation: (clientId: number) => Promise<void>;\n\n /**\n * Discard all pending mutations.\n * Uses safe disconnect/reconnect pattern to avoid transaction conflicts.\n * @throws Error if upload is in progress\n */\n discardAllPendingMutations: () => Promise<void>;\n\n /**\n * Pause automatic retry of failed uploads.\n * Useful when user is actively resolving conflicts.\n */\n pauseAutoRetry: () => void;\n\n /**\n * Resume automatic retry of failed uploads.\n */\n resumeAutoRetry: () => void;\n}\n\n// ─── Split Context Types (Performance Optimization) ─────────────────────────\n// These focused contexts allow components to subscribe to only the data they need,\n// preventing re-renders when unrelated data changes.\n\n/**\n * Connection state - changes rarely (on connect/disconnect).\n * Use this for components that only need to display connection status.\n */\nexport interface ConnectionStatusContextValue {\n /** Whether connected to the PowerSync service */\n connected: boolean;\n /** Whether currently attempting to connect */\n connecting: boolean;\n /** Whether initial sync has completed */\n hasSynced: boolean;\n /** Timestamp of last successful sync */\n lastSyncedAt: Date | null;\n /** Error that occurred during connection, if any */\n connectionError: Error | null;\n}\n\n/**\n * Sync activity - changes during active sync.\n * Use this for components that display sync progress.\n */\nexport interface SyncActivityContextValue {\n /** Whether data is currently being uploaded to the server */\n uploading: boolean;\n /** Whether data is currently being downloaded from the server */\n downloading: boolean;\n /** Download progress details */\n downloadProgress: DownloadProgress | null;\n}\n\n/**\n * Pending mutations - changes on local writes.\n * Use this for components that display pending upload count or list.\n */\nexport interface PendingMutationsContextValue {\n /** Pending mutations waiting to be uploaded */\n pendingMutations: CrudEntry[];\n /** Number of pending mutations */\n pendingCount: number;\n /** Discard a specific pending mutation by its client ID */\n discardPendingMutation: (clientId: number) => Promise<void>;\n /** Discard all pending mutations */\n discardAllPendingMutations: () => Promise<void>;\n /**\n * Add a pending mutation to the list.\n * Called by mutation hooks (useDbInsert, useDbUpdate, useDbDelete, useDbUpsert)\n * after a successful write. Includes createdAt timestamp for display.\n */\n addPendingMutation: (entry: CrudEntry) => void;\n /**\n * Remove a pending mutation by its entity ID.\n * Called when a transaction completes sync.\n */\n removePendingMutation: (id: string) => void;\n}\n\n/**\n * Failed transactions - changes on failures.\n * Use this for components that display sync errors.\n */\nexport interface FailedTransactionsContextValue {\n /** Failed transactions that need attention */\n failedTransactions: FailedTransaction[];\n /** Whether there are any upload errors */\n hasUploadErrors: boolean;\n /** Count of permanent errors that need user action */\n permanentErrorCount: number;\n /** Clear a specific failure by its ID */\n clearFailure: (failureId: string) => void;\n /** Clear all failures */\n clearAllFailures: () => void;\n /** Pause automatic retry of failed uploads */\n pauseAutoRetry: () => void;\n /** Resume automatic retry of failed uploads */\n resumeAutoRetry: () => void;\n /**\n * Retry a specific failed transaction.\n *\n * This removes the failure from tracking and triggers a sync.\n * The actual CRUD entries remain in PowerSync's queue - this just\n * clears our error tracking so the sync can retry them.\n *\n * If the sync fails to start, the failure is re-recorded.\n */\n retryFailure: (failureId: string) => Promise<void>;\n}\n\n/**\n * Completed transactions - changes on successful syncs.\n * Use this for components that display sync history.\n */\nexport interface CompletedTransactionsContextValue {\n /** Recently completed transactions */\n completedTransactions: CompletedTransaction[];\n /** Clear the completed transaction history */\n clearCompletedHistory: () => void;\n /** Clear a specific completed transaction by ID */\n clearCompletedItem: (completedId: string) => void;\n /**\n * Completed transactions that occurred AFTER the last notification display.\n * Use this for toast/banner notifications to avoid showing stale historical counts.\n */\n newCompletedTransactions: CompletedTransaction[];\n /**\n * Mark notifications as seen (updates the lastNotificationTime).\n * Call this when a sync notification is displayed or auto-dismissed.\n */\n markNotificationsAsSeen: () => void;\n}\n\n/**\n * Sync mode control - changes rarely (user action).\n * Use this for components that display/control sync mode.\n */\nexport interface SyncModeContextValue {\n /** Current sync mode */\n syncMode: SyncMode;\n /** Whether sync is currently paused (offline mode) */\n isPaused: boolean;\n /**\n * Whether offline mode was automatically set due to network loss.\n * When true, sync will auto-resume when network returns.\n * When false (user manually chose offline), sync won't auto-resume.\n */\n isAutoOffline: boolean;\n /**\n * Whether the network is currently reachable.\n * This is used as a gate to block uploads even when syncMode is 'push-pull'.\n */\n networkReachable: boolean;\n /** Set the sync mode (manual - won't auto-resume) */\n setSyncMode: (mode: SyncMode) => Promise<void>;\n /** Set the force next upload flag */\n setForceNextUpload: (force: boolean) => void;\n}\n\n/**\n * Value provided by ConnectionHealthContext.\n */\nexport interface ConnectionHealthContextValue {\n /**\n * Current connection health status.\n */\n health: ConnectionHealth;\n}\n\n/**\n * Value provided by SyncMetricsContext.\n */\nexport interface SyncMetricsContextValue {\n /**\n * Current sync metrics.\n */\n metrics: SyncMetrics;\n}\n\n// ─── Provider Props ──────────────────────────────────────────────────────────\n\n/**\n * Props for the PowerSyncProvider component.\n *\n * @template TSchema - The PowerSync schema type\n */\nexport interface PowerSyncProviderProps<TSchema = unknown> {\n /**\n * PowerSync configuration.\n */\n config: PowerSyncConfig<TSchema>;\n\n /**\n * Child components to render.\n */\n children: React.ReactNode;\n\n /**\n * Called when the database is initialized and ready.\n */\n onReady?: () => void;\n\n /**\n * Called when an error occurs during initialization.\n */\n onError?: (error: Error) => void;\n\n /**\n * Called when sync status changes.\n */\n onSyncStatusChange?: (status: SyncStatus) => void;\n}\n\n// ─── Default Values ──────────────────────────────────────────────────────────\n\n/**\n * Default sync status.\n */\nexport const DEFAULT_SYNC_STATUS: SyncStatus = {\n connected: false,\n connecting: false,\n hasSynced: false,\n lastSyncedAt: null,\n uploading: false,\n downloading: false,\n downloadProgress: null,\n failedTransactions: [],\n hasUploadErrors: false,\n permanentErrorCount: 0\n};\n\n/**\n * Default connection health.\n */\nexport const DEFAULT_CONNECTION_HEALTH: ConnectionHealth = {\n status: 'disconnected',\n latency: null,\n lastHealthCheck: null,\n consecutiveFailures: 0,\n reconnectAttempts: 0\n};\n\n/**\n * Default sync metrics.\n */\nexport const DEFAULT_SYNC_METRICS: SyncMetrics = {\n totalSyncs: 0,\n successfulSyncs: 0,\n failedSyncs: 0,\n lastSyncDuration: null,\n averageSyncDuration: null,\n totalDataDownloaded: 0,\n totalDataUploaded: 0,\n lastError: null\n};\n\n/**\n * Default sync configuration.\n */\nexport const DEFAULT_SYNC_CONFIG: Required<SyncConfig> = {\n autoConnect: true,\n syncInterval: 0,\n enableHealthMonitoring: true,\n enableMetrics: true\n};"],"mappings":";AAygBO,IAAM,sBAAkC;AAAA,EAC7C,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,cAAc;AAAA,EACd,WAAW;AAAA,EACX,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,oBAAoB,CAAC;AAAA,EACrB,iBAAiB;AAAA,EACjB,qBAAqB;AACvB;AAKO,IAAM,4BAA8C;AAAA,EACzD,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,qBAAqB;AAAA,EACrB,mBAAmB;AACrB;AAKO,IAAM,uBAAoC;AAAA,EAC/C,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,WAAW;AACb;AAKO,IAAM,sBAA4C;AAAA,EACvD,aAAa;AAAA,EACb,cAAc;AAAA,EACd,wBAAwB;AAAA,EACxB,eAAe;AACjB;","names":[]}