@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.
- package/README.md +933 -0
- package/dist/CacheSettingsManager-uz-kbnRH.d.ts +461 -0
- package/dist/attachments/index.d.ts +745 -332
- package/dist/attachments/index.js +152 -6
- package/dist/{types-Cd7RhNqf.d.ts → background-sync-ChCXW-EV.d.ts} +53 -2
- package/dist/chunk-24RDMMCL.js +44 -0
- package/dist/chunk-24RDMMCL.js.map +1 -0
- package/dist/chunk-4TXTAEF2.js +2060 -0
- package/dist/chunk-4TXTAEF2.js.map +1 -0
- package/dist/chunk-63PXSPIN.js +358 -0
- package/dist/chunk-63PXSPIN.js.map +1 -0
- package/dist/chunk-654ERHA7.js +1 -0
- package/dist/chunk-A4IBBWGO.js +377 -0
- package/dist/chunk-A4IBBWGO.js.map +1 -0
- package/dist/chunk-BRXQNASY.js +1720 -0
- package/dist/chunk-BRXQNASY.js.map +1 -0
- package/dist/chunk-CAB26E6F.js +142 -0
- package/dist/chunk-CAB26E6F.js.map +1 -0
- package/dist/{chunk-EJ23MXPQ.js → chunk-CGL33PL4.js} +3 -1
- package/dist/chunk-CGL33PL4.js.map +1 -0
- package/dist/{chunk-R4YFWQ3Q.js → chunk-CUCAYK7Z.js} +309 -92
- package/dist/chunk-CUCAYK7Z.js.map +1 -0
- package/dist/chunk-FV2HXEIY.js +124 -0
- package/dist/chunk-FV2HXEIY.js.map +1 -0
- package/dist/chunk-HWSNV45P.js +279 -0
- package/dist/chunk-HWSNV45P.js.map +1 -0
- package/dist/{chunk-62J2DPKX.js → chunk-KN2IZERF.js} +530 -413
- package/dist/chunk-KN2IZERF.js.map +1 -0
- package/dist/{chunk-7EMDVIZX.js → chunk-N75DEF5J.js} +19 -1
- package/dist/chunk-N75DEF5J.js.map +1 -0
- package/dist/chunk-P4HZA6ZT.js +83 -0
- package/dist/chunk-P4HZA6ZT.js.map +1 -0
- package/dist/chunk-P6WOZO7H.js +49 -0
- package/dist/chunk-P6WOZO7H.js.map +1 -0
- package/dist/chunk-T4AO7JIG.js +1 -0
- package/dist/chunk-TGBT5XBE.js +1 -0
- package/dist/{chunk-FPTDATY5.js → chunk-VACPAAQZ.js} +54 -12
- package/dist/chunk-VACPAAQZ.js.map +1 -0
- package/dist/chunk-WGHNIAF7.js +329 -0
- package/dist/chunk-WGHNIAF7.js.map +1 -0
- package/dist/{chunk-3AYXHQ4W.js → chunk-WN5ZJ3E2.js} +108 -47
- package/dist/chunk-WN5ZJ3E2.js.map +1 -0
- package/dist/chunk-XAEII4ZX.js +456 -0
- package/dist/chunk-XAEII4ZX.js.map +1 -0
- package/dist/chunk-XOY2CJ67.js +289 -0
- package/dist/chunk-XOY2CJ67.js.map +1 -0
- package/dist/chunk-YHTZ7VMV.js +1 -0
- package/dist/chunk-YSTEESEG.js +676 -0
- package/dist/chunk-YSTEESEG.js.map +1 -0
- package/dist/chunk-Z6VOBGTU.js +32 -0
- package/dist/chunk-Z6VOBGTU.js.map +1 -0
- package/dist/chunk-ZM4ENYMF.js +230 -0
- package/dist/chunk-ZM4ENYMF.js.map +1 -0
- package/dist/connector/index.d.ts +236 -4
- package/dist/connector/index.js +15 -4
- package/dist/core/index.d.ts +16 -3
- package/dist/core/index.js +6 -2
- package/dist/error/index.d.ts +54 -0
- package/dist/error/index.js +7 -0
- package/dist/error/index.js.map +1 -0
- package/dist/index.d.ts +102 -12
- package/dist/index.js +309 -37
- package/dist/index.native.d.ts +22 -10
- package/dist/index.native.js +309 -38
- package/dist/index.web.d.ts +22 -10
- package/dist/index.web.js +310 -38
- package/dist/maintenance/index.d.ts +118 -0
- package/dist/maintenance/index.js +16 -0
- package/dist/maintenance/index.js.map +1 -0
- package/dist/platform/index.d.ts +16 -1
- package/dist/platform/index.js.map +1 -1
- package/dist/platform/index.native.d.ts +2 -2
- package/dist/platform/index.native.js +1 -1
- package/dist/platform/index.web.d.ts +1 -1
- package/dist/platform/index.web.js +1 -1
- package/dist/pol-attachment-queue-BVAIueoP.d.ts +817 -0
- package/dist/provider/index.d.ts +451 -21
- package/dist/provider/index.js +32 -13
- package/dist/react/index.d.ts +372 -0
- package/dist/react/index.js +25 -0
- package/dist/react/index.js.map +1 -0
- package/dist/storage/index.d.ts +6 -0
- package/dist/storage/index.js +42 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/index.native.d.ts +6 -0
- package/dist/storage/index.native.js +40 -0
- package/dist/storage/index.native.js.map +1 -0
- package/dist/storage/index.web.d.ts +6 -0
- package/dist/storage/index.web.js +40 -0
- package/dist/storage/index.web.js.map +1 -0
- package/dist/storage/upload/index.d.ts +54 -0
- package/dist/storage/upload/index.js +15 -0
- package/dist/storage/upload/index.js.map +1 -0
- package/dist/storage/upload/index.native.d.ts +56 -0
- package/dist/storage/upload/index.native.js +15 -0
- package/dist/storage/upload/index.native.js.map +1 -0
- package/dist/storage/upload/index.web.d.ts +2 -0
- package/dist/storage/upload/index.web.js +14 -0
- package/dist/storage/upload/index.web.js.map +1 -0
- package/dist/supabase-connector-T9vHq_3i.d.ts +202 -0
- package/dist/sync/index.d.ts +288 -23
- package/dist/sync/index.js +22 -10
- package/dist/{index-l3iL9Jte.d.ts → types-B212hgfA.d.ts} +101 -158
- package/dist/{types-afHtE1U_.d.ts → types-CDqWh56B.d.ts} +2 -0
- package/dist/types-CyvBaAl8.d.ts +60 -0
- package/dist/types-D0WcHrq6.d.ts +234 -0
- package/package.json +89 -5
- package/dist/chunk-32OLICZO.js +0 -1
- package/dist/chunk-3AYXHQ4W.js.map +0 -1
- package/dist/chunk-5FIMA26D.js +0 -1
- package/dist/chunk-62J2DPKX.js.map +0 -1
- package/dist/chunk-7EMDVIZX.js.map +0 -1
- package/dist/chunk-EJ23MXPQ.js.map +0 -1
- package/dist/chunk-FPTDATY5.js.map +0 -1
- package/dist/chunk-KCDG2MNP.js +0 -1431
- package/dist/chunk-KCDG2MNP.js.map +0 -1
- package/dist/chunk-OLHGI472.js +0 -1
- package/dist/chunk-PAFBKNL3.js +0 -99
- package/dist/chunk-PAFBKNL3.js.map +0 -1
- package/dist/chunk-R4YFWQ3Q.js.map +0 -1
- package/dist/chunk-V6LJ6MR2.js +0 -740
- package/dist/chunk-V6LJ6MR2.js.map +0 -1
- package/dist/chunk-VJCL2SWD.js +0 -1
- package/dist/failed-upload-store-C0cLxxPz.d.ts +0 -33
- /package/dist/{chunk-32OLICZO.js.map → chunk-654ERHA7.js.map} +0 -0
- /package/dist/{chunk-5FIMA26D.js.map → chunk-T4AO7JIG.js.map} +0 -0
- /package/dist/{chunk-OLHGI472.js.map → chunk-TGBT5XBE.js.map} +0 -0
- /package/dist/{chunk-VJCL2SWD.js.map → chunk-YHTZ7VMV.js.map} +0 -0
|
@@ -1,5 +1,237 @@
|
|
|
1
|
-
|
|
2
|
-
export { P as
|
|
3
|
-
|
|
1
|
+
import { A as AuthProvider } from '../types-B212hgfA.js';
|
|
2
|
+
export { g as ConflictBus, C as ConnectorCircuitBreakerConfig, a as ConnectorConfig, c as CrudHandler, D as DEFAULT_RETRY_CONFIG, P as PowerSyncCredentials, e as RetryConfig, R as RetryStrategyConfig, b as SchemaRouter, f as Session, S as SupabaseConnectorOptions, d as defaultSchemaRouter } from '../types-B212hgfA.js';
|
|
3
|
+
export { S as SupabaseConnector } from '../supabase-connector-T9vHq_3i.js';
|
|
4
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
5
|
+
export { P as PowerSyncBackendConnector } from '../types-CDqWh56B.js';
|
|
4
6
|
import '../platform/index.js';
|
|
5
|
-
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Supabase Auth Provider for @pol-studios/powersync
|
|
10
|
+
*
|
|
11
|
+
* Factory function that wraps a Supabase client's auth methods
|
|
12
|
+
* to implement the AuthProvider interface.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Options for createSupabaseAuth
|
|
17
|
+
*/
|
|
18
|
+
interface SupabaseAuthOptions {
|
|
19
|
+
/**
|
|
20
|
+
* Called when a session refresh fails.
|
|
21
|
+
* Use this to trigger logout flows or show error UI.
|
|
22
|
+
*/
|
|
23
|
+
onRefreshError?: (error: Error) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates an AuthProvider that wraps Supabase auth.
|
|
27
|
+
*
|
|
28
|
+
* @param supabase - Supabase client instance
|
|
29
|
+
* @param options - Optional configuration
|
|
30
|
+
* @returns AuthProvider implementation
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import { createSupabaseAuth } from '@pol-studios/powersync';
|
|
35
|
+
*
|
|
36
|
+
* const auth = createSupabaseAuth(supabaseClient, {
|
|
37
|
+
* onRefreshError: (error) => {
|
|
38
|
+
* console.error('Session refresh failed:', error);
|
|
39
|
+
* // Navigate to login screen
|
|
40
|
+
* },
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* // Use with PowerSyncProvider
|
|
44
|
+
* <PowerSyncProvider auth={auth} ... />
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
declare function createSupabaseAuth(supabase: SupabaseClient, options?: SupabaseAuthOptions): AuthProvider;
|
|
48
|
+
/**
|
|
49
|
+
* Error thrown when session refresh fails.
|
|
50
|
+
*/
|
|
51
|
+
declare class AuthRefreshError extends Error {
|
|
52
|
+
readonly name = "AuthRefreshError";
|
|
53
|
+
readonly cause?: Error;
|
|
54
|
+
constructor(message: string, options?: {
|
|
55
|
+
cause?: Error;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Circuit Breaker Pattern for PowerSync Connector
|
|
61
|
+
*
|
|
62
|
+
* Prevents cascading failures by temporarily stopping requests when
|
|
63
|
+
* a service is experiencing high failure rates.
|
|
64
|
+
*
|
|
65
|
+
* States:
|
|
66
|
+
* - CLOSED: Normal operation, requests flow through
|
|
67
|
+
* - OPEN: Service is failing, requests are blocked
|
|
68
|
+
* - HALF_OPEN: Testing if service has recovered
|
|
69
|
+
*
|
|
70
|
+
* Transitions:
|
|
71
|
+
* - CLOSED -> OPEN: After failureThreshold failures within failureWindowMs
|
|
72
|
+
* - OPEN -> HALF_OPEN: After timeout (exponential backoff)
|
|
73
|
+
* - HALF_OPEN -> CLOSED: On successful request
|
|
74
|
+
* - HALF_OPEN -> OPEN: On failed request (with reset backoff multiplier)
|
|
75
|
+
*/
|
|
76
|
+
/**
|
|
77
|
+
* Circuit breaker states
|
|
78
|
+
*/
|
|
79
|
+
type CircuitState = 'CLOSED' | 'OPEN' | 'HALF_OPEN';
|
|
80
|
+
/**
|
|
81
|
+
* Configuration for the circuit breaker
|
|
82
|
+
*/
|
|
83
|
+
interface CircuitBreakerConfig {
|
|
84
|
+
/**
|
|
85
|
+
* Number of failures required to trip the circuit
|
|
86
|
+
* @default 5
|
|
87
|
+
*/
|
|
88
|
+
failureThreshold: number;
|
|
89
|
+
/**
|
|
90
|
+
* Time window in ms for counting failures
|
|
91
|
+
* @default 60000 (60 seconds)
|
|
92
|
+
*/
|
|
93
|
+
failureWindowMs: number;
|
|
94
|
+
/**
|
|
95
|
+
* Initial delay before transitioning from OPEN to HALF_OPEN
|
|
96
|
+
* @default 1000 (1 second)
|
|
97
|
+
*/
|
|
98
|
+
initialRecoveryDelayMs: number;
|
|
99
|
+
/**
|
|
100
|
+
* Maximum delay for exponential backoff
|
|
101
|
+
* @default 32000 (32 seconds)
|
|
102
|
+
*/
|
|
103
|
+
maxRecoveryDelayMs: number;
|
|
104
|
+
/**
|
|
105
|
+
* Multiplier for exponential backoff
|
|
106
|
+
* @default 2
|
|
107
|
+
*/
|
|
108
|
+
backoffMultiplier: number;
|
|
109
|
+
/**
|
|
110
|
+
* Optional callback when state changes
|
|
111
|
+
*/
|
|
112
|
+
onStateChange?: (state: CircuitState, previousState: CircuitState) => void;
|
|
113
|
+
/**
|
|
114
|
+
* Optional logger
|
|
115
|
+
*/
|
|
116
|
+
logger?: {
|
|
117
|
+
debug: (...args: unknown[]) => void;
|
|
118
|
+
info: (...args: unknown[]) => void;
|
|
119
|
+
warn: (...args: unknown[]) => void;
|
|
120
|
+
error: (...args: unknown[]) => void;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Default circuit breaker configuration
|
|
125
|
+
*/
|
|
126
|
+
declare const DEFAULT_CIRCUIT_BREAKER_CONFIG: CircuitBreakerConfig;
|
|
127
|
+
/**
|
|
128
|
+
* Statistics about the circuit breaker state
|
|
129
|
+
*/
|
|
130
|
+
interface CircuitBreakerStats {
|
|
131
|
+
/** Current state */
|
|
132
|
+
state: CircuitState;
|
|
133
|
+
/** Number of failures in current window */
|
|
134
|
+
failureCount: number;
|
|
135
|
+
/** Number of successful requests since last state change */
|
|
136
|
+
successCount: number;
|
|
137
|
+
/** Number of times circuit has opened */
|
|
138
|
+
openCount: number;
|
|
139
|
+
/** Time when circuit last opened */
|
|
140
|
+
lastOpenedAt: Date | null;
|
|
141
|
+
/** Time when circuit last closed */
|
|
142
|
+
lastClosedAt: Date | null;
|
|
143
|
+
/** Current recovery delay (when OPEN) */
|
|
144
|
+
currentRecoveryDelayMs: number;
|
|
145
|
+
/** Time until next HALF_OPEN attempt (when OPEN) */
|
|
146
|
+
timeUntilHalfOpenMs: number | null;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Error thrown when circuit is open
|
|
150
|
+
*/
|
|
151
|
+
declare class CircuitOpenError extends Error {
|
|
152
|
+
readonly timeUntilRetryMs: number;
|
|
153
|
+
readonly stats: CircuitBreakerStats;
|
|
154
|
+
constructor(timeUntilRetryMs: number, stats: CircuitBreakerStats);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Circuit Breaker implementation
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* const breaker = new CircuitBreaker({
|
|
162
|
+
* failureThreshold: 5,
|
|
163
|
+
* failureWindowMs: 60000,
|
|
164
|
+
* onStateChange: (state) => console.log('Circuit state:', state),
|
|
165
|
+
* });
|
|
166
|
+
*
|
|
167
|
+
* // Wrap your async operations
|
|
168
|
+
* try {
|
|
169
|
+
* const result = await breaker.execute(() => fetchData());
|
|
170
|
+
* } catch (error) {
|
|
171
|
+
* if (error instanceof CircuitOpenError) {
|
|
172
|
+
* console.log('Service unavailable, retry later');
|
|
173
|
+
* }
|
|
174
|
+
* }
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
declare class CircuitBreaker {
|
|
178
|
+
private state;
|
|
179
|
+
private failures;
|
|
180
|
+
private successCount;
|
|
181
|
+
private openCount;
|
|
182
|
+
private lastOpenedAt;
|
|
183
|
+
private lastClosedAt;
|
|
184
|
+
private currentRecoveryDelay;
|
|
185
|
+
private halfOpenTimer;
|
|
186
|
+
private halfOpenScheduledAt;
|
|
187
|
+
private readonly config;
|
|
188
|
+
constructor(config?: Partial<CircuitBreakerConfig>);
|
|
189
|
+
/**
|
|
190
|
+
* Get current state
|
|
191
|
+
*/
|
|
192
|
+
getState(): CircuitState;
|
|
193
|
+
/**
|
|
194
|
+
* Get circuit breaker statistics
|
|
195
|
+
*/
|
|
196
|
+
getStats(): CircuitBreakerStats;
|
|
197
|
+
/**
|
|
198
|
+
* Check if requests are allowed through the circuit
|
|
199
|
+
*/
|
|
200
|
+
isAllowed(): boolean;
|
|
201
|
+
/**
|
|
202
|
+
* Check if request can proceed, throws if not
|
|
203
|
+
*/
|
|
204
|
+
checkAllowed(): void;
|
|
205
|
+
/**
|
|
206
|
+
* Record a successful operation
|
|
207
|
+
*/
|
|
208
|
+
recordSuccess(): void;
|
|
209
|
+
/**
|
|
210
|
+
* Record a failed operation
|
|
211
|
+
*/
|
|
212
|
+
recordFailure(): void;
|
|
213
|
+
/**
|
|
214
|
+
* Execute an async operation through the circuit breaker
|
|
215
|
+
*/
|
|
216
|
+
execute<T>(operation: () => Promise<T>): Promise<T>;
|
|
217
|
+
/**
|
|
218
|
+
* Manually reset the circuit breaker to CLOSED state
|
|
219
|
+
*/
|
|
220
|
+
reset(): void;
|
|
221
|
+
/**
|
|
222
|
+
* Force the circuit to OPEN state (e.g., for manual intervention)
|
|
223
|
+
*/
|
|
224
|
+
forceOpen(): void;
|
|
225
|
+
/**
|
|
226
|
+
* Dispose the circuit breaker (clear timers)
|
|
227
|
+
*/
|
|
228
|
+
dispose(): void;
|
|
229
|
+
private transition;
|
|
230
|
+
private scheduleHalfOpen;
|
|
231
|
+
private clearHalfOpenTimer;
|
|
232
|
+
private getTimeUntilHalfOpen;
|
|
233
|
+
private cleanupOldFailures;
|
|
234
|
+
private log;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export { AuthProvider, AuthRefreshError, CircuitBreaker, type CircuitBreakerConfig, type CircuitBreakerStats, CircuitOpenError, type CircuitState, DEFAULT_CIRCUIT_BREAKER_CONFIG, type SupabaseAuthOptions, createSupabaseAuth };
|
package/dist/connector/index.js
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
AuthRefreshError,
|
|
3
|
+
CircuitBreaker,
|
|
4
|
+
CircuitOpenError,
|
|
5
|
+
DEFAULT_CIRCUIT_BREAKER_CONFIG,
|
|
6
|
+
createSupabaseAuth
|
|
7
|
+
} from "../chunk-HWSNV45P.js";
|
|
2
8
|
import {
|
|
3
9
|
DEFAULT_RETRY_CONFIG,
|
|
4
10
|
SupabaseConnector,
|
|
5
11
|
defaultSchemaRouter
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
12
|
+
} from "../chunk-KN2IZERF.js";
|
|
13
|
+
import "../chunk-FV2HXEIY.js";
|
|
14
|
+
import "../chunk-VACPAAQZ.js";
|
|
9
15
|
export {
|
|
16
|
+
AuthRefreshError,
|
|
17
|
+
CircuitBreaker,
|
|
18
|
+
CircuitOpenError,
|
|
19
|
+
DEFAULT_CIRCUIT_BREAKER_CONFIG,
|
|
10
20
|
DEFAULT_RETRY_CONFIG,
|
|
11
21
|
SupabaseConnector,
|
|
22
|
+
createSupabaseAuth,
|
|
12
23
|
defaultSchemaRouter
|
|
13
24
|
};
|
|
14
25
|
//# sourceMappingURL=index.js.map
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as SyncErrorType, i as ClassifiedError, f as SyncError, C as CrudEntry } from '../types-
|
|
2
|
-
export { A as AbstractPowerSyncDatabase, k as CacheStats, j as CompactResult, h as CompletedTransaction, b as ConnectionHealth, o as CountRow, l as CrudTransaction, n as DbStatRow, D as DownloadProgress, E as EntitySyncState, F as FailedTransaction, r as FreelistCountRow, s as IntegrityCheckRow, I as IntegrityResult, q as PageCountRow, p as PageSizeRow, P as PowerSyncBackendConnector, m as SqliteTableRow, c as StorageInfo, d as StorageQuota, e as SyncMetrics, S as SyncMode, a as SyncStatus, T as TableCacheStats } from '../types-
|
|
1
|
+
import { g as SyncErrorType, i as ClassifiedError, f as SyncError, C as CrudEntry } from '../types-CDqWh56B.js';
|
|
2
|
+
export { A as AbstractPowerSyncDatabase, k as CacheStats, j as CompactResult, h as CompletedTransaction, b as ConnectionHealth, o as CountRow, l as CrudTransaction, n as DbStatRow, D as DownloadProgress, E as EntitySyncState, F as FailedTransaction, r as FreelistCountRow, s as IntegrityCheckRow, I as IntegrityResult, q as PageCountRow, p as PageSizeRow, P as PowerSyncBackendConnector, m as SqliteTableRow, c as StorageInfo, d as StorageQuota, e as SyncMetrics, S as SyncMode, a as SyncStatus, T as TableCacheStats } from '../types-CDqWh56B.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Constants for @pol-studios/powersync
|
|
@@ -19,6 +19,8 @@ declare const STORAGE_KEY_METRICS = "@pol-studios/powersync-metrics";
|
|
|
19
19
|
declare const STORAGE_KEY_ATTACHMENT_SETTINGS = "@pol-studios/powersync-attachment-settings";
|
|
20
20
|
/** Storage key for sync mode */
|
|
21
21
|
declare const STORAGE_KEY_SYNC_MODE = "@pol-studios/powersync-sync-mode";
|
|
22
|
+
/** Storage key for auto-offline flag (tracks if offline was set automatically vs manually) */
|
|
23
|
+
declare const STORAGE_KEY_AUTO_OFFLINE = "@pol-studios/powersync-auto-offline";
|
|
22
24
|
/** Default sync mode */
|
|
23
25
|
declare const DEFAULT_SYNC_MODE: "push-pull";
|
|
24
26
|
/** Interval between health checks in milliseconds */
|
|
@@ -193,5 +195,16 @@ declare function extractEntityIds(entries: CrudEntry[]): string[];
|
|
|
193
195
|
* Extract unique table names from CRUD entries.
|
|
194
196
|
*/
|
|
195
197
|
declare function extractTableNames(entries: CrudEntry[]): string[];
|
|
198
|
+
/**
|
|
199
|
+
* Check if an error is an RLS/permission error (PostgreSQL 42501 - insufficient_privilege).
|
|
200
|
+
*
|
|
201
|
+
* RLS errors are special because they may resolve when parent data syncs.
|
|
202
|
+
* For example, inserting a child record may fail until the parent record syncs
|
|
203
|
+
* and satisfies the RLS policy conditions.
|
|
204
|
+
*
|
|
205
|
+
* @param error - The error to check
|
|
206
|
+
* @returns true if the error is an RLS/permission error
|
|
207
|
+
*/
|
|
208
|
+
declare function isRlsError(error: unknown): boolean;
|
|
196
209
|
|
|
197
|
-
export { ATTACHMENT_DOWNLOAD_TIMEOUT_MS, ATTACHMENT_RETRY_DELAY_MS, AttachmentError, COMPRESSION_MAX_WIDTH, COMPRESSION_SKIP_SIZE_BYTES, COMPRESSION_TARGET_SIZE_BYTES, ClassifiedError, ConfigurationError, ConnectorError, CrudEntry, DEFAULT_ATTACHMENT_CACHE_SIZE, DEFAULT_ATTACHMENT_CONCURRENCY, DEFAULT_COMPRESSION_QUALITY, DEFAULT_MAX_RETRY_ATTEMPTS, DEFAULT_RETRY_BACKOFF_MULTIPLIER, DEFAULT_RETRY_BASE_DELAY_MS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_SYNC_INTERVAL_MS, DEFAULT_SYNC_MODE, DOWNLOAD_STOP_THRESHOLD, EVICTION_TRIGGER_THRESHOLD, HEALTH_CHECK_INTERVAL_MS, HEALTH_CHECK_TIMEOUT_MS, InitializationError, LATENCY_DEGRADED_THRESHOLD_MS, MAX_CONSECUTIVE_FAILURES, PlatformAdapterError, PowerSyncError, STATS_CACHE_TTL_MS, STATUS_NOTIFY_THROTTLE_MS, STORAGE_CRITICAL_THRESHOLD, STORAGE_KEY_ATTACHMENT_SETTINGS, STORAGE_KEY_ENABLED, STORAGE_KEY_METRICS, STORAGE_KEY_PAUSED, STORAGE_KEY_PREFIX, STORAGE_KEY_SYNC_MODE, STORAGE_WARNING_THRESHOLD, SyncError, SyncErrorType, SyncOperationError, classifyError, classifySupabaseError, createSyncError, extractEntityIds, extractTableNames, generateFailureId, toSyncOperationError };
|
|
210
|
+
export { ATTACHMENT_DOWNLOAD_TIMEOUT_MS, ATTACHMENT_RETRY_DELAY_MS, AttachmentError, COMPRESSION_MAX_WIDTH, COMPRESSION_SKIP_SIZE_BYTES, COMPRESSION_TARGET_SIZE_BYTES, ClassifiedError, ConfigurationError, ConnectorError, CrudEntry, DEFAULT_ATTACHMENT_CACHE_SIZE, DEFAULT_ATTACHMENT_CONCURRENCY, DEFAULT_COMPRESSION_QUALITY, DEFAULT_MAX_RETRY_ATTEMPTS, DEFAULT_RETRY_BACKOFF_MULTIPLIER, DEFAULT_RETRY_BASE_DELAY_MS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_SYNC_INTERVAL_MS, DEFAULT_SYNC_MODE, DOWNLOAD_STOP_THRESHOLD, EVICTION_TRIGGER_THRESHOLD, HEALTH_CHECK_INTERVAL_MS, HEALTH_CHECK_TIMEOUT_MS, InitializationError, LATENCY_DEGRADED_THRESHOLD_MS, MAX_CONSECUTIVE_FAILURES, PlatformAdapterError, PowerSyncError, STATS_CACHE_TTL_MS, STATUS_NOTIFY_THROTTLE_MS, STORAGE_CRITICAL_THRESHOLD, STORAGE_KEY_ATTACHMENT_SETTINGS, STORAGE_KEY_AUTO_OFFLINE, STORAGE_KEY_ENABLED, STORAGE_KEY_METRICS, STORAGE_KEY_PAUSED, STORAGE_KEY_PREFIX, STORAGE_KEY_SYNC_MODE, STORAGE_WARNING_THRESHOLD, SyncError, SyncErrorType, SyncOperationError, classifyError, classifySupabaseError, createSyncError, extractEntityIds, extractTableNames, generateFailureId, isRlsError, toSyncOperationError };
|
package/dist/core/index.js
CHANGED
|
@@ -24,13 +24,14 @@ import {
|
|
|
24
24
|
STATUS_NOTIFY_THROTTLE_MS,
|
|
25
25
|
STORAGE_CRITICAL_THRESHOLD,
|
|
26
26
|
STORAGE_KEY_ATTACHMENT_SETTINGS,
|
|
27
|
+
STORAGE_KEY_AUTO_OFFLINE,
|
|
27
28
|
STORAGE_KEY_ENABLED,
|
|
28
29
|
STORAGE_KEY_METRICS,
|
|
29
30
|
STORAGE_KEY_PAUSED,
|
|
30
31
|
STORAGE_KEY_PREFIX,
|
|
31
32
|
STORAGE_KEY_SYNC_MODE,
|
|
32
33
|
STORAGE_WARNING_THRESHOLD
|
|
33
|
-
} from "../chunk-
|
|
34
|
+
} from "../chunk-CGL33PL4.js";
|
|
34
35
|
import {
|
|
35
36
|
AttachmentError,
|
|
36
37
|
ConfigurationError,
|
|
@@ -45,8 +46,9 @@ import {
|
|
|
45
46
|
extractEntityIds,
|
|
46
47
|
extractTableNames,
|
|
47
48
|
generateFailureId,
|
|
49
|
+
isRlsError,
|
|
48
50
|
toSyncOperationError
|
|
49
|
-
} from "../chunk-
|
|
51
|
+
} from "../chunk-VACPAAQZ.js";
|
|
50
52
|
export {
|
|
51
53
|
ATTACHMENT_DOWNLOAD_TIMEOUT_MS,
|
|
52
54
|
ATTACHMENT_RETRY_DELAY_MS,
|
|
@@ -78,6 +80,7 @@ export {
|
|
|
78
80
|
STATUS_NOTIFY_THROTTLE_MS,
|
|
79
81
|
STORAGE_CRITICAL_THRESHOLD,
|
|
80
82
|
STORAGE_KEY_ATTACHMENT_SETTINGS,
|
|
83
|
+
STORAGE_KEY_AUTO_OFFLINE,
|
|
81
84
|
STORAGE_KEY_ENABLED,
|
|
82
85
|
STORAGE_KEY_METRICS,
|
|
83
86
|
STORAGE_KEY_PAUSED,
|
|
@@ -91,6 +94,7 @@ export {
|
|
|
91
94
|
extractEntityIds,
|
|
92
95
|
extractTableNames,
|
|
93
96
|
generateFailureId,
|
|
97
|
+
isRlsError,
|
|
94
98
|
toSyncOperationError
|
|
95
99
|
};
|
|
96
100
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Component, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
interface PowerSyncErrorBoundaryProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/**
|
|
6
|
+
* Custom fallback UI when an error occurs.
|
|
7
|
+
* Must be provided since there is no platform-agnostic default.
|
|
8
|
+
*/
|
|
9
|
+
fallback: (error: Error, retry: () => void) => ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Callback when an error is caught.
|
|
12
|
+
*/
|
|
13
|
+
onError?: (error: Error) => void;
|
|
14
|
+
}
|
|
15
|
+
interface PowerSyncErrorBoundaryState {
|
|
16
|
+
hasError: boolean;
|
|
17
|
+
error: Error | null;
|
|
18
|
+
retryKey: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Error boundary for PowerSync initialization errors.
|
|
22
|
+
*
|
|
23
|
+
* Catches errors during PowerSync initialization and provides
|
|
24
|
+
* a retry mechanism to attempt reinitialization.
|
|
25
|
+
*
|
|
26
|
+
* Note: The fallback prop is required because there is no
|
|
27
|
+
* platform-agnostic default UI.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* <PowerSyncErrorBoundary
|
|
32
|
+
* fallback={(error, retry) => (
|
|
33
|
+
* <View>
|
|
34
|
+
* <Text>Error: {error.message}</Text>
|
|
35
|
+
* <Button onPress={retry}>Retry</Button>
|
|
36
|
+
* </View>
|
|
37
|
+
* )}
|
|
38
|
+
* onError={(error) => console.error('PowerSync error:', error)}
|
|
39
|
+
* >
|
|
40
|
+
* <PowerSyncProvider config={config}>
|
|
41
|
+
* <App />
|
|
42
|
+
* </PowerSyncProvider>
|
|
43
|
+
* </PowerSyncErrorBoundary>
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare class PowerSyncErrorBoundary extends Component<PowerSyncErrorBoundaryProps, PowerSyncErrorBoundaryState> {
|
|
47
|
+
constructor(props: PowerSyncErrorBoundaryProps);
|
|
48
|
+
static getDerivedStateFromError(error: Error): Partial<PowerSyncErrorBoundaryState>;
|
|
49
|
+
componentDidCatch(error: Error): void;
|
|
50
|
+
handleRetry: () => void;
|
|
51
|
+
render(): ReactNode;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { PowerSyncErrorBoundary };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,29 @@
|
|
|
1
|
-
import { A as AbstractPowerSyncDatabase } from './types-
|
|
2
|
-
export { k as CacheStats, i as ClassifiedError, j as CompactResult, h as CompletedTransaction, b as ConnectionHealth, o as CountRow, C as CrudEntry, l as CrudTransaction, n as DbStatRow, D as DownloadProgress, E as EntitySyncState, F as FailedTransaction, r as FreelistCountRow, s as IntegrityCheckRow, I as IntegrityResult, q as PageCountRow, p as PageSizeRow, P as PowerSyncBackendConnector, m as SqliteTableRow, c as StorageInfo, d as StorageQuota, f as SyncError, g as SyncErrorType, e as SyncMetrics, S as SyncMode, a as SyncStatus, T as TableCacheStats } from './types-
|
|
3
|
-
export { ATTACHMENT_DOWNLOAD_TIMEOUT_MS, ATTACHMENT_RETRY_DELAY_MS, AttachmentError, COMPRESSION_MAX_WIDTH, COMPRESSION_SKIP_SIZE_BYTES, COMPRESSION_TARGET_SIZE_BYTES, ConfigurationError, ConnectorError, DEFAULT_ATTACHMENT_CACHE_SIZE, DEFAULT_ATTACHMENT_CONCURRENCY, DEFAULT_COMPRESSION_QUALITY, DEFAULT_MAX_RETRY_ATTEMPTS, DEFAULT_RETRY_BACKOFF_MULTIPLIER, DEFAULT_RETRY_BASE_DELAY_MS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_SYNC_INTERVAL_MS, DEFAULT_SYNC_MODE, DOWNLOAD_STOP_THRESHOLD, EVICTION_TRIGGER_THRESHOLD, HEALTH_CHECK_INTERVAL_MS, HEALTH_CHECK_TIMEOUT_MS, InitializationError, LATENCY_DEGRADED_THRESHOLD_MS, MAX_CONSECUTIVE_FAILURES, PlatformAdapterError, PowerSyncError, STATS_CACHE_TTL_MS, STATUS_NOTIFY_THROTTLE_MS, STORAGE_CRITICAL_THRESHOLD, STORAGE_KEY_ATTACHMENT_SETTINGS, STORAGE_KEY_ENABLED, STORAGE_KEY_METRICS, STORAGE_KEY_PAUSED, STORAGE_KEY_PREFIX, STORAGE_KEY_SYNC_MODE, STORAGE_WARNING_THRESHOLD, SyncOperationError, classifyError, classifySupabaseError, createSyncError, extractEntityIds, extractTableNames, generateFailureId, toSyncOperationError } from './core/index.js';
|
|
4
|
-
import {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
1
|
+
import { A as AbstractPowerSyncDatabase } from './types-CDqWh56B.js';
|
|
2
|
+
export { k as CacheStats, i as ClassifiedError, j as CompactResult, h as CompletedTransaction, b as ConnectionHealth, o as CountRow, C as CrudEntry, l as CrudTransaction, n as DbStatRow, D as DownloadProgress, E as EntitySyncState, F as FailedTransaction, r as FreelistCountRow, s as IntegrityCheckRow, I as IntegrityResult, q as PageCountRow, p as PageSizeRow, P as PowerSyncBackendConnector, m as SqliteTableRow, c as StorageInfo, d as StorageQuota, f as SyncError, g as SyncErrorType, e as SyncMetrics, S as SyncMode, a as SyncStatus, T as TableCacheStats } from './types-CDqWh56B.js';
|
|
3
|
+
export { ATTACHMENT_DOWNLOAD_TIMEOUT_MS, ATTACHMENT_RETRY_DELAY_MS, AttachmentError, COMPRESSION_MAX_WIDTH, COMPRESSION_SKIP_SIZE_BYTES, COMPRESSION_TARGET_SIZE_BYTES, ConfigurationError, ConnectorError, DEFAULT_ATTACHMENT_CACHE_SIZE, DEFAULT_ATTACHMENT_CONCURRENCY, DEFAULT_COMPRESSION_QUALITY, DEFAULT_MAX_RETRY_ATTEMPTS, DEFAULT_RETRY_BACKOFF_MULTIPLIER, DEFAULT_RETRY_BASE_DELAY_MS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_SYNC_INTERVAL_MS, DEFAULT_SYNC_MODE, DOWNLOAD_STOP_THRESHOLD, EVICTION_TRIGGER_THRESHOLD, HEALTH_CHECK_INTERVAL_MS, HEALTH_CHECK_TIMEOUT_MS, InitializationError, LATENCY_DEGRADED_THRESHOLD_MS, MAX_CONSECUTIVE_FAILURES, PlatformAdapterError, PowerSyncError, STATS_CACHE_TTL_MS, STATUS_NOTIFY_THROTTLE_MS, STORAGE_CRITICAL_THRESHOLD, STORAGE_KEY_ATTACHMENT_SETTINGS, STORAGE_KEY_AUTO_OFFLINE, STORAGE_KEY_ENABLED, STORAGE_KEY_METRICS, STORAGE_KEY_PAUSED, STORAGE_KEY_PREFIX, STORAGE_KEY_SYNC_MODE, STORAGE_WARNING_THRESHOLD, SyncOperationError, classifyError, classifySupabaseError, createSyncError, extractEntityIds, extractTableNames, generateFailureId, isRlsError, toSyncOperationError } from './core/index.js';
|
|
4
|
+
import { k as ConflictDetectionConfig, h as ConflictCheckResult } from './types-B212hgfA.js';
|
|
5
|
+
export { A as AuthProvider, g as ConflictBus, j as ConflictHandler, l as ConflictListener, i as ConflictResolution, C as ConnectorCircuitBreakerConfig, a as ConnectorConfig, c as CrudHandler, D as DEFAULT_RETRY_CONFIG, F as FieldConflict, P as PowerSyncCredentials, m as ResolutionListener, e as RetryConfig, R as RetryStrategyConfig, b as SchemaRouter, f as Session, S as SupabaseConnectorOptions, d as defaultSchemaRouter } from './types-B212hgfA.js';
|
|
6
|
+
export { S as SupabaseConnector } from './supabase-connector-T9vHq_3i.js';
|
|
7
|
+
export { AuthRefreshError, CircuitBreaker, CircuitBreakerConfig, CircuitBreakerStats, CircuitOpenError, CircuitState, DEFAULT_CIRCUIT_BREAKER_CONFIG, SupabaseAuthOptions, createSupabaseAuth } from './connector/index.js';
|
|
8
|
+
export { e as AttachmentConfig, z as AttachmentRecord, A as AttachmentSourceConfig, w as AttachmentStatsRow, f as AttachmentStorageAdapter, v as AttachmentSyncStats, u as AttachmentSyncStatus, B as BatchFilterContext, m as CACHE_SIZE_PRESETS, k as CacheConfig, x as CacheFileRow, n as CacheSizePreset, o as CacheSizeValue, y as CachedSizeRow, C as CompressionConfig, l as DEFAULT_CACHE_CONFIG, D as DEFAULT_COMPRESSION_CONFIG, j as DEFAULT_DOWNLOAD_CONFIG, g as DEFAULT_UPLOAD_CONFIG, i as DownloadConfig, q as DownloadPhase, r as DownloadStatus, E as EvictRow, I as IdRow, P as PolAttachmentQueue, a as PolAttachmentQueueOptions, d as PolAttachmentRecord, b as PolAttachmentState, S as SkipDownloadContext, U as UploadConfig, h as UploadHandler, s as UploadPhase, t as UploadStatus, W as WatchConfig, c as createPolAttachmentQueue, p as formatCacheSize } from './pol-attachment-queue-BVAIueoP.js';
|
|
9
|
+
export { CacheManagerDeps, DOWNLOAD_WORKFLOW_STATES, DownloadManagerDeps, LOCALLY_AVAILABLE_STATES, MigrationStats, PENDING_DOWNLOAD_STATES, PROTECTED_UPLOAD_STATES, PolStorageAdapter, PolStorageAdapterOptions, STATE_MAPPING, STATE_NAMES, TERMINAL_STATES, UPLOAD_WORKFLOW_STATES, UploadManagerDeps, UploadManagerState, VALID_STATES, blobToArrayBuffer, buildIdOnlyWatchQuery, buildRecordFetchQuery, buildWatchQuery, cacheLocalFile, clearCache, clearUploadCallback, copyToManagedCache, createCacheManagerDeps, createMigrationStats, createUploadManagerDeps, createUploadManagerState, determineAttachmentState, downloadRecord, enforceCacheLimit, ensureFileUri, extractErrorCode, formatMigrationStats, getCachedSize, getEvictionCandidates, getExcludeProtectedStatesCondition, getFailedPermanentUploads, getLocalUriForStoragePath, getPendingUploads, getProtectedStatesInClause, getSoonestRetryTime, getStaleUploads, getStateName, getSyncedUploadsWithPendingCallback, isCacheNearCapacity, isDownloadWorkflowState, isLocallyAvailable, isPendingDownloadState, isPermanentError, isProtectedUploadState, isStateTransitionAllowed, isTerminalState, isUploadWorkflowState, isValidAttachmentState, markUploadPermanentFailure, markUploadSynced, migrateAttachmentState, migrateAttachmentStateSafe, recordMigration, scheduleUploadRetry, startUploadProcessing, stripFileUri, uploadOne, validateSqlIdentifier, validateSqlIdentifierFromStateMachine, validateWhereClause, watchConfigToSourceConfig } from './attachments/index.js';
|
|
10
|
+
export { B as BackgroundSyncOptions, h as BackgroundSyncSystem, e as HealthCheckResult, H as HealthMonitorOptions, M as MetricsCollectorOptions, P as PowerSyncRawStatus, c as SyncControlActions, f as SyncEvent, g as SyncEventListener, d as SyncOperationData, S as SyncScope, a as SyncStatusState, b as SyncStatusTrackerOptions, U as Unsubscribe, i as defineBackgroundSyncTask, j as initializeBackgroundSync, k as isBackgroundSyncRegistered, r as registerBackgroundSync, u as unregisterBackgroundSync } from './background-sync-ChCXW-EV.js';
|
|
11
|
+
export { DeadLetterEntry, DeadLetterQueue, DeadLetterQueueListener, DeadLetterQueueOptions, DeadLetterReason, HealthMonitor, MetricsCollector, SyncStatusTracker, createDeadLetterEntry, generateDLQEntryId } from './sync/index.js';
|
|
10
12
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
11
|
-
export {
|
|
13
|
+
export { DatabaseMaintenanceUtils, checkIntegrityImpl, checkStorageQuotaImpl, compactDatabaseImpl, getCacheStatsImpl, useDatabaseMaintenance } from './maintenance/index.js';
|
|
14
|
+
export { D as DownloadResult, a as StorageBackend, b as StorageUploadOptions, d as SupabaseClient, S as SupabaseStorage, c as SupabaseStorageOptions, e as SupabaseTransformOptions, U as UploadProgress, r as resolveBucket } from './types-D0WcHrq6.js';
|
|
15
|
+
export { f as CacheSettings, C as CacheSettingsManager, h as CacheSettingsManagerOptions, D as DEFAULT_CACHE_SETTINGS, I as ImageTransformOptions, S as SupabaseStorageAdapter, e as SupabaseStorageAdapterOptions, c as createSupabaseStorage, d as createSupabaseStorageAdapter, g as getStorageErrorMessage, a as isBlobResult, i as isFileResult, b as isStorageAuthError, n as normalizeStoragePath } from './CacheSettingsManager-uz-kbnRH.js';
|
|
16
|
+
export { D as DEFAULT_UPLOAD_NOTIFICATION, S as SupabaseUploadHandlerOptions, U as UploadEventHandlers, a as UploadNotificationConfig } from './types-CyvBaAl8.js';
|
|
17
|
+
export { SupabaseUploadHandler, createSupabaseUploadHandler } from './storage/upload/index.js';
|
|
18
|
+
export { PowerSyncErrorBoundary } from './error/index.js';
|
|
19
|
+
export { AttachmentQueueContext, BackgroundSyncCallbacks, BackgroundSyncConfig, BackgroundSyncStatus, CompletedTransactionsContext, CompletedTransactionsContextValue, ConnectionHealthContext, ConnectionHealthContextValue, ConnectionStatusContext, ConnectionStatusContextValue, DEFAULT_CONNECTION_HEALTH, DEFAULT_SYNC_CONFIG, DEFAULT_SYNC_METRICS, DEFAULT_SYNC_STATUS, DataLayerConfig, DataLayerIntegration, EntitySyncStatusResult, FailedTransactionsContext, FailedTransactionsContextValue, OfflineDataAttachmentConfig, OfflineDataProvider, OfflineDataProviderConfig, OfflineDataProviderProps, PendingMutationsContext, PendingMutationsContextValue, PowerSyncConfig, PowerSyncContext, PowerSyncContextValue, PowerSyncProvider, PowerSyncProviderProps, PowerSyncSyncStatusSnapshot, ProviderBridge, ProviderBridgeProps, SyncActivityContext, SyncActivityContextValue, SyncActivityResult, SyncConfig, SyncMetricsContext, SyncMetricsContextValue, SyncModeContext, SyncModeContextValue, SyncStatusContext, SyncStatusContextValue, 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 } from './provider/index.js';
|
|
20
|
+
export { AttachmentQueueContextValue, SlimPowerSyncProvider, useAttachmentQueueContext, usePowerSyncContext, useSyncStatusContext } from './react/index.js';
|
|
12
21
|
export { AsyncStorageAdapter, CompressedImage, CompressionOptions, ConnectionType, DatabaseOptions, FileInfo, FileSystemAdapter, ImageProcessorAdapter, LoggerAdapter, NetworkAdapter, PlatformAdapter, PlatformType, detectPlatform } from './platform/index.js';
|
|
13
|
-
|
|
22
|
+
export { ATTACHMENT_TABLE, AbstractAttachmentQueue, AttachmentState, AttachmentTable, AttachmentTableOptions, AttachmentQueueOptions as BaseAttachmentQueueOptions, DEFAULT_ATTACHMENT_QUEUE_OPTIONS, EncodingType, AttachmentRecord as OfficialAttachmentRecord, StorageAdapter } from '@powersync/attachments';
|
|
23
|
+
export { AbstractPowerSyncDatabase as PowerSyncDBInterface } from '@powersync/common';
|
|
14
24
|
import 'react';
|
|
25
|
+
import '@tanstack/react-query';
|
|
26
|
+
import '@powersync/react-native';
|
|
15
27
|
|
|
16
28
|
/**
|
|
17
29
|
* Exponential backoff retry utilities for resilient network operations.
|
|
@@ -150,6 +162,74 @@ declare const DEFAULT_BACKOFF_CONFIG: BackoffConfig;
|
|
|
150
162
|
*/
|
|
151
163
|
declare function withExponentialBackoff<T>(fn: () => Promise<T>, config: BackoffConfig, options?: BackoffOptions): Promise<T>;
|
|
152
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Format bytes to human-readable string
|
|
167
|
+
*
|
|
168
|
+
* @param bytes - Number of bytes to format
|
|
169
|
+
* @param decimals - Number of decimal places (default: 2)
|
|
170
|
+
* @returns Formatted string like "1.5 MB", "256 KB", etc.
|
|
171
|
+
*/
|
|
172
|
+
declare function formatBytes(bytes: number, decimals?: number): string;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* MIME Type Utilities for @pol-studios/powersync
|
|
176
|
+
*
|
|
177
|
+
* Provides file extension to MIME type mapping for storage operations.
|
|
178
|
+
*/
|
|
179
|
+
/**
|
|
180
|
+
* Get MIME type from file extension.
|
|
181
|
+
*
|
|
182
|
+
* @param extension - File extension (with or without leading dot)
|
|
183
|
+
* @returns MIME type string
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* getMimeType('jpg'); // 'image/jpeg'
|
|
188
|
+
* getMimeType('.png'); // 'image/png'
|
|
189
|
+
* getMimeType('unknown'); // 'application/octet-stream'
|
|
190
|
+
* getMimeType(undefined); // 'application/octet-stream'
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
declare function getMimeType(extension: string | undefined | null): string;
|
|
194
|
+
/**
|
|
195
|
+
* Get MIME type from a file path or filename.
|
|
196
|
+
*
|
|
197
|
+
* @param filePath - Full file path or filename
|
|
198
|
+
* @returns MIME type string
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```typescript
|
|
202
|
+
* getMimeTypeFromPath('/path/to/image.jpg'); // 'image/jpeg'
|
|
203
|
+
* getMimeTypeFromPath('document.pdf'); // 'application/pdf'
|
|
204
|
+
* getMimeTypeFromPath('file-without-extension'); // 'application/octet-stream'
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
declare function getMimeTypeFromPath(filePath: string | undefined | null): string;
|
|
208
|
+
/**
|
|
209
|
+
* Check if a MIME type represents an image.
|
|
210
|
+
*/
|
|
211
|
+
declare function isImageMimeType(mimeType: string): boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Check if a MIME type represents a video.
|
|
214
|
+
*/
|
|
215
|
+
declare function isVideoMimeType(mimeType: string): boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Check if a MIME type represents audio.
|
|
218
|
+
*/
|
|
219
|
+
declare function isAudioMimeType(mimeType: string): boolean;
|
|
220
|
+
/**
|
|
221
|
+
* Check if a MIME type represents a document (PDF, Office, etc.).
|
|
222
|
+
*/
|
|
223
|
+
declare function isDocumentMimeType(mimeType: string): boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Get file extension from MIME type (reverse lookup).
|
|
226
|
+
* Returns the most common extension for the given MIME type.
|
|
227
|
+
*
|
|
228
|
+
* @param mimeType - MIME type string
|
|
229
|
+
* @returns File extension without leading dot, or undefined if unknown
|
|
230
|
+
*/
|
|
231
|
+
declare function getExtensionFromMimeType(mimeType: string): string | undefined;
|
|
232
|
+
|
|
153
233
|
/**
|
|
154
234
|
* Conflict Detection for @pol-studios/powersync
|
|
155
235
|
*
|
|
@@ -157,6 +237,16 @@ declare function withExponentialBackoff<T>(fn: () => Promise<T>, config: Backoff
|
|
|
157
237
|
* Only queries AuditLog when version mismatch is detected.
|
|
158
238
|
*/
|
|
159
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Error thrown when conflict detection fails due to external issues
|
|
242
|
+
* (e.g., AuditLog query failure). Callers should handle this and decide
|
|
243
|
+
* whether to retry, fail the sync, or escalate to the user.
|
|
244
|
+
*/
|
|
245
|
+
declare class ConflictDetectionError extends Error {
|
|
246
|
+
constructor(message: string, options?: {
|
|
247
|
+
cause?: unknown;
|
|
248
|
+
});
|
|
249
|
+
}
|
|
160
250
|
/**
|
|
161
251
|
* Detect conflicts between local pending changes and server state.
|
|
162
252
|
*
|
|
@@ -202,4 +292,4 @@ declare function fetchServerVersion(table: string, recordId: string, schema: str
|
|
|
202
292
|
*/
|
|
203
293
|
declare function getLocalVersion(table: string, recordId: string, db: AbstractPowerSyncDatabase): Promise<number | null>;
|
|
204
294
|
|
|
205
|
-
export { AbortError, AbstractPowerSyncDatabase, type BackoffConfig, type BackoffOptions, ConflictCheckResult, ConflictDetectionConfig, DEFAULT_BACKOFF_CONFIG, RetryExhaustedError, addJitter, calculateBackoffDelay, detectConflicts, fetchServerVersion, getLocalVersion, hasVersionColumn, sleep, withExponentialBackoff };
|
|
295
|
+
export { AbortError, AbstractPowerSyncDatabase, type BackoffConfig, type BackoffOptions, ConflictCheckResult, ConflictDetectionConfig, ConflictDetectionError, DEFAULT_BACKOFF_CONFIG, RetryExhaustedError, addJitter, calculateBackoffDelay, detectConflicts, fetchServerVersion, formatBytes, getExtensionFromMimeType, getLocalVersion, getMimeType, getMimeTypeFromPath, hasVersionColumn, isAudioMimeType, isDocumentMimeType, isImageMimeType, isVideoMimeType, sleep, withExponentialBackoff };
|