@pol-studios/db 1.0.58 → 1.0.61
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/dist/DataLayerContext-V5FotiSk.d.ts +563 -0
- package/dist/auth/context.js +2 -2
- package/dist/auth/hooks.js +3 -3
- package/dist/auth/index.js +3 -3
- package/dist/{chunk-YRIPM2AN.js → chunk-4PZ744G2.js} +207 -6
- package/dist/chunk-4PZ744G2.js.map +1 -0
- package/dist/{chunk-OK2C54B6.js → chunk-7PBTPCRN.js} +340 -386
- package/dist/chunk-7PBTPCRN.js.map +1 -0
- package/dist/{chunk-6SDH7M7J.js → chunk-ARALLEDJ.js} +2 -2
- package/dist/{chunk-Z456IHCB.js → chunk-F4HW4NT5.js} +1 -1
- package/dist/chunk-F4HW4NT5.js.map +1 -0
- package/dist/{chunk-LG3OHLGB.js → chunk-FWCHS5NN.js} +16 -337
- package/dist/chunk-FWCHS5NN.js.map +1 -0
- package/dist/{chunk-4EO55YV2.js → chunk-H4Z73DC4.js} +4 -4
- package/dist/{chunk-GWYTROSD.js → chunk-L4DFVMTS.js} +335 -4
- package/dist/chunk-L4DFVMTS.js.map +1 -0
- package/dist/{chunk-7BGDQT5X.js → chunk-PIPB3JMK.js} +1 -7
- package/dist/{chunk-7BGDQT5X.js.map → chunk-PIPB3JMK.js.map} +1 -1
- package/dist/{chunk-MEBT5YHA.js → chunk-SNPZMRBC.js} +2 -2
- package/dist/{chunk-VYFAMTHI.js → chunk-ZPFZ2ZRW.js} +4 -13
- package/dist/{chunk-VYFAMTHI.js.map → chunk-ZPFZ2ZRW.js.map} +1 -1
- package/dist/core/index.d.ts +8 -44
- package/dist/{executor-D15yjeMo.d.ts → executor-Bu1OlqCl.d.ts} +43 -3
- package/dist/hooks/index.d.ts +3 -3
- package/dist/hooks/index.js +2 -2
- package/dist/{index-CFUuTzXO.d.ts → index-vwVJ0BWj.d.ts} +1 -9
- package/dist/index.d.ts +5 -5
- package/dist/index.js +21 -13
- package/dist/index.native.d.ts +77 -76
- package/dist/index.native.js +20 -12
- package/dist/index.web.d.ts +21 -44
- package/dist/index.web.js +215 -156
- package/dist/index.web.js.map +1 -1
- package/dist/powersync-bridge/index.d.ts +1 -1
- package/dist/powersync-bridge/index.js +1 -1
- package/dist/query/index.d.ts +1 -1
- package/dist/query/index.js +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +1 -1
- package/dist/{useDbCount-Ckb-FhZk.d.ts → useDbCount-dCkdaBpP.d.ts} +41 -83
- package/dist/{useResolveFeedback-CuUkdHoR.d.ts → useResolveFeedback-thFi-4h8.d.ts} +429 -5
- package/dist/with-auth/index.js +5 -5
- package/package.json +1 -1
- package/dist/DataLayerContext-BYZtDD0g.d.ts +0 -946
- package/dist/chunk-GWYTROSD.js.map +0 -1
- package/dist/chunk-LG3OHLGB.js.map +0 -1
- package/dist/chunk-OK2C54B6.js.map +0 -1
- package/dist/chunk-YRIPM2AN.js.map +0 -1
- package/dist/chunk-Z456IHCB.js.map +0 -1
- /package/dist/{chunk-6SDH7M7J.js.map → chunk-ARALLEDJ.js.map} +0 -0
- /package/dist/{chunk-4EO55YV2.js.map → chunk-H4Z73DC4.js.map} +0 -0
- /package/dist/{chunk-MEBT5YHA.js.map → chunk-SNPZMRBC.js.map} +0 -0
|
@@ -1,946 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { SupabaseClient } from '@supabase/supabase-js';
|
|
3
|
-
import { QueryClient } from '@tanstack/react-query';
|
|
4
|
-
import { DatabaseSchema, QueryOptions, DataLayerConfig, TableStrategy, SyncStatus, SyncControl } from './core/index.js';
|
|
5
|
-
import { P as PowerSyncDatabase } from './executor-D15yjeMo.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* V3 Data Layer Adapter Types
|
|
9
|
-
*
|
|
10
|
-
* Extended types for the adapter layer that complement the core DataAdapter interface.
|
|
11
|
-
* These types support the Strategy pattern for routing queries to different backends.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Result from adapter query operations.
|
|
16
|
-
* Extends the basic array with optional count for pagination.
|
|
17
|
-
*/
|
|
18
|
-
interface AdapterQueryResult<T> {
|
|
19
|
-
/** The queried data */
|
|
20
|
-
data: T[];
|
|
21
|
-
/** Total count of matching records (for pagination) */
|
|
22
|
-
count?: number;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Extended adapter interface that accepts table name for multi-table routing.
|
|
26
|
-
*
|
|
27
|
-
* This interface is used by the AdapterRegistry to provide table-aware adapters
|
|
28
|
-
* that can handle multiple tables with a single adapter instance.
|
|
29
|
-
*
|
|
30
|
-
* Differences from core DataAdapter:
|
|
31
|
-
* - Includes table name parameter in all methods
|
|
32
|
-
* - Returns AdapterQueryResult with optional count
|
|
33
|
-
* - Supports optional subscribe method for reactivity
|
|
34
|
-
*/
|
|
35
|
-
interface TableDataAdapter {
|
|
36
|
-
/**
|
|
37
|
-
* Unique identifier for the adapter type
|
|
38
|
-
*/
|
|
39
|
-
readonly name: string;
|
|
40
|
-
/**
|
|
41
|
-
* Execute a query and return results
|
|
42
|
-
*
|
|
43
|
-
* @param table - The table name to query
|
|
44
|
-
* @param options - Query options (select, where, orderBy, limit, offset)
|
|
45
|
-
* @returns Promise resolving to query results with optional count
|
|
46
|
-
*/
|
|
47
|
-
query<T>(table: string, options: QueryOptions): Promise<AdapterQueryResult<T>>;
|
|
48
|
-
/**
|
|
49
|
-
* Query a single record by ID
|
|
50
|
-
*
|
|
51
|
-
* @param table - The table name to query
|
|
52
|
-
* @param id - The record ID
|
|
53
|
-
* @param options - Optional query options (mainly for select)
|
|
54
|
-
* @returns Promise resolving to the record or null if not found
|
|
55
|
-
*/
|
|
56
|
-
queryById?<T>(table: string, id: string, options?: Pick<QueryOptions, "select">): Promise<T | null>;
|
|
57
|
-
/**
|
|
58
|
-
* Subscribe to real-time changes on a query.
|
|
59
|
-
* Not all adapters support this - it's optional.
|
|
60
|
-
*
|
|
61
|
-
* @param table - The table name to watch
|
|
62
|
-
* @param options - Query options to filter what to watch
|
|
63
|
-
* @param callback - Function called with updated data
|
|
64
|
-
* @returns Unsubscribe function
|
|
65
|
-
*/
|
|
66
|
-
subscribe?<T>(table: string, options: QueryOptions, callback: (data: T[]) => void): () => void;
|
|
67
|
-
/**
|
|
68
|
-
* Insert a new record
|
|
69
|
-
*
|
|
70
|
-
* @param table - The table name
|
|
71
|
-
* @param data - The data to insert
|
|
72
|
-
* @returns Promise resolving to the inserted record
|
|
73
|
-
*/
|
|
74
|
-
insert<T>(table: string, data: Partial<T>): Promise<T>;
|
|
75
|
-
/**
|
|
76
|
-
* Update an existing record by ID
|
|
77
|
-
*
|
|
78
|
-
* @param table - The table name
|
|
79
|
-
* @param id - The record ID to update
|
|
80
|
-
* @param data - The data to update
|
|
81
|
-
* @returns Promise resolving to the updated record
|
|
82
|
-
*/
|
|
83
|
-
update<T>(table: string, id: string, data: Partial<T>): Promise<T>;
|
|
84
|
-
/**
|
|
85
|
-
* Upsert (insert or update) a record
|
|
86
|
-
* If the record has an ID and exists, it will be updated.
|
|
87
|
-
* Otherwise, a new record will be inserted.
|
|
88
|
-
*
|
|
89
|
-
* @param table - The table name
|
|
90
|
-
* @param data - The data to upsert
|
|
91
|
-
* @returns Promise resolving to the upserted record
|
|
92
|
-
*/
|
|
93
|
-
upsert<T>(table: string, data: Partial<T>): Promise<T>;
|
|
94
|
-
/**
|
|
95
|
-
* Delete a record by ID
|
|
96
|
-
*
|
|
97
|
-
* @param table - The table name
|
|
98
|
-
* @param id - The record ID to delete
|
|
99
|
-
* @returns Promise that resolves when deletion is complete
|
|
100
|
-
*/
|
|
101
|
-
delete(table: string, id: string): Promise<void>;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Configuration for creating an adapter
|
|
105
|
-
*/
|
|
106
|
-
interface AdapterConfig {
|
|
107
|
-
/**
|
|
108
|
-
* The strategy type to create
|
|
109
|
-
*/
|
|
110
|
-
strategy: "powersync" | "supabase" | "cached" | "hybrid";
|
|
111
|
-
/**
|
|
112
|
-
* Additional strategy-specific configuration
|
|
113
|
-
*/
|
|
114
|
-
[key: string]: unknown;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Factory interface for creating adapters
|
|
118
|
-
*/
|
|
119
|
-
interface AdapterFactory {
|
|
120
|
-
/**
|
|
121
|
-
* Create a new adapter instance based on configuration
|
|
122
|
-
*
|
|
123
|
-
* @param config - Adapter configuration
|
|
124
|
-
* @returns The created adapter instance
|
|
125
|
-
*/
|
|
126
|
-
create(config: AdapterConfig): TableDataAdapter;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Describes the capabilities of an adapter
|
|
130
|
-
*/
|
|
131
|
-
interface AdapterCapabilities {
|
|
132
|
-
/**
|
|
133
|
-
* Whether the adapter supports real-time subscriptions
|
|
134
|
-
*/
|
|
135
|
-
supportsSubscribe: boolean;
|
|
136
|
-
/**
|
|
137
|
-
* Whether the adapter works offline
|
|
138
|
-
*/
|
|
139
|
-
supportsOffline: boolean;
|
|
140
|
-
/**
|
|
141
|
-
* Whether the adapter caches data locally
|
|
142
|
-
*/
|
|
143
|
-
supportsCache: boolean;
|
|
144
|
-
/**
|
|
145
|
-
* Whether the adapter syncs data bidirectionally
|
|
146
|
-
*/
|
|
147
|
-
supportsSync: boolean;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Extended adapter interface with capability reporting
|
|
151
|
-
*/
|
|
152
|
-
interface CapableDataAdapter extends TableDataAdapter {
|
|
153
|
-
/**
|
|
154
|
-
* Get the capabilities of this adapter
|
|
155
|
-
*/
|
|
156
|
-
readonly capabilities: AdapterCapabilities;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Dependencies required to initialize adapters.
|
|
160
|
-
* Uses 'unknown' type for external dependencies to allow proper typing
|
|
161
|
-
* when concrete implementations are provided.
|
|
162
|
-
*/
|
|
163
|
-
interface AdapterDependencies {
|
|
164
|
-
/**
|
|
165
|
-
* PowerSync database instance
|
|
166
|
-
* Will be typed as PowerSyncDatabase when PowerSync is integrated
|
|
167
|
-
*/
|
|
168
|
-
powerSync: unknown;
|
|
169
|
-
/**
|
|
170
|
-
* Supabase client instance
|
|
171
|
-
* Will be typed as SupabaseClient when imported
|
|
172
|
-
*/
|
|
173
|
-
supabase: unknown;
|
|
174
|
-
/**
|
|
175
|
-
* TanStack Query client for caching
|
|
176
|
-
* Will be typed as QueryClient when imported
|
|
177
|
-
*/
|
|
178
|
-
queryClient: unknown;
|
|
179
|
-
/**
|
|
180
|
-
* Database schema for relationship resolution
|
|
181
|
-
*/
|
|
182
|
-
schema: DatabaseSchema;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* String literals for adapter strategy types
|
|
186
|
-
*/
|
|
187
|
-
declare const ADAPTER_STRATEGIES: {
|
|
188
|
-
readonly POWERSYNC: "powersync";
|
|
189
|
-
readonly SUPABASE: "supabase";
|
|
190
|
-
readonly CACHED: "cached";
|
|
191
|
-
readonly HYBRID: "hybrid";
|
|
192
|
-
readonly AUTO: "auto";
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Type for adapter strategy values
|
|
197
|
-
*/
|
|
198
|
-
type AdapterStrategyType = (typeof ADAPTER_STRATEGIES)[keyof typeof ADAPTER_STRATEGIES];
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Adapter Auto-Detector
|
|
202
|
-
*
|
|
203
|
-
* Detects available backends (PowerSync, Supabase) at runtime and recommends
|
|
204
|
-
* the best one to use based on availability and configuration preferences.
|
|
205
|
-
*
|
|
206
|
-
* This enables the V3 data layer to automatically select the optimal backend
|
|
207
|
-
* for offline-first or online-first experiences.
|
|
208
|
-
*/
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Status of a backend adapter
|
|
212
|
-
*/
|
|
213
|
-
declare enum BackendStatus {
|
|
214
|
-
/** Backend is available and ready to use */
|
|
215
|
-
AVAILABLE = "available",
|
|
216
|
-
/** Backend is initializing (e.g., PowerSync syncing) */
|
|
217
|
-
INITIALIZING = "initializing",
|
|
218
|
-
/** Backend is not available */
|
|
219
|
-
UNAVAILABLE = "unavailable"
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Result of auto-detection
|
|
223
|
-
*/
|
|
224
|
-
interface AutoDetectionResult {
|
|
225
|
-
/** PowerSync availability status */
|
|
226
|
-
powerSyncStatus: BackendStatus;
|
|
227
|
-
/** Supabase availability status */
|
|
228
|
-
supabaseStatus: BackendStatus;
|
|
229
|
-
/** Recommended backend to use */
|
|
230
|
-
recommendedBackend: "powersync" | "supabase";
|
|
231
|
-
/** Whether device is online */
|
|
232
|
-
isOnline: boolean;
|
|
233
|
-
/** Reason for recommendation */
|
|
234
|
-
reason: string;
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Sync status information from PowerSync
|
|
238
|
-
*/
|
|
239
|
-
interface SyncStatusInfo {
|
|
240
|
-
/** Whether PowerSync has completed at least one full sync */
|
|
241
|
-
hasSynced: boolean;
|
|
242
|
-
/** Whether connected to PowerSync service */
|
|
243
|
-
connected: boolean;
|
|
244
|
-
/** Whether currently connecting */
|
|
245
|
-
connecting: boolean;
|
|
246
|
-
/** Network connectivity status from platform adapter (NetInfo on React Native) */
|
|
247
|
-
isOnline?: boolean;
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Options for auto-detection
|
|
251
|
-
*/
|
|
252
|
-
interface AutoDetectorOptions {
|
|
253
|
-
/** Prefer PowerSync when available (default: true) */
|
|
254
|
-
preferPowerSync?: boolean;
|
|
255
|
-
/** Timeout for status checks in ms (default: 1000) */
|
|
256
|
-
statusCheckTimeout?: number;
|
|
257
|
-
/**
|
|
258
|
-
* Use Supabase for queries until PowerSync completes initial sync.
|
|
259
|
-
* When true, queries return online data while syncing.
|
|
260
|
-
* @default true
|
|
261
|
-
*/
|
|
262
|
-
useOnlineUntilSynced?: boolean;
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Listener for backend change events
|
|
266
|
-
*/
|
|
267
|
-
type BackendChangeListener = (result: AutoDetectionResult) => void;
|
|
268
|
-
/**
|
|
269
|
-
* Detects available backends and recommends the best one to use.
|
|
270
|
-
*
|
|
271
|
-
* The auto-detector checks for PowerSync and Supabase availability and
|
|
272
|
-
* makes intelligent recommendations based on:
|
|
273
|
-
* - Backend availability
|
|
274
|
-
* - Network connectivity
|
|
275
|
-
* - User preferences (preferPowerSync option)
|
|
276
|
-
*
|
|
277
|
-
* @example
|
|
278
|
-
* ```typescript
|
|
279
|
-
* const detector = new AdapterAutoDetector(powerSyncDb, supabaseClient, {
|
|
280
|
-
* preferPowerSync: true,
|
|
281
|
-
* });
|
|
282
|
-
*
|
|
283
|
-
* const result = detector.detect();
|
|
284
|
-
* console.log(`Using ${result.recommendedBackend}: ${result.reason}`);
|
|
285
|
-
* ```
|
|
286
|
-
*/
|
|
287
|
-
declare class AdapterAutoDetector {
|
|
288
|
-
private powerSyncDb;
|
|
289
|
-
private supabase;
|
|
290
|
-
private options;
|
|
291
|
-
private listeners;
|
|
292
|
-
private lastResult;
|
|
293
|
-
private syncStatus;
|
|
294
|
-
constructor(powerSyncDb: PowerSyncDatabase | null, supabase: SupabaseClient | null, options?: AutoDetectorOptions);
|
|
295
|
-
/**
|
|
296
|
-
* Update the PowerSync database reference.
|
|
297
|
-
* Called when PowerSync becomes available after initial construction.
|
|
298
|
-
*
|
|
299
|
-
* @param db - PowerSync database instance or null
|
|
300
|
-
*/
|
|
301
|
-
setPowerSyncDb(db: PowerSyncDatabase | null): void;
|
|
302
|
-
/**
|
|
303
|
-
* Update the sync status from PowerSync.
|
|
304
|
-
* Called when sync status changes to re-evaluate backend recommendation.
|
|
305
|
-
*
|
|
306
|
-
* @param status - Current sync status or null if not available
|
|
307
|
-
*/
|
|
308
|
-
updateSyncStatus(status: SyncStatusInfo | null): void;
|
|
309
|
-
/**
|
|
310
|
-
* Get current sync status.
|
|
311
|
-
* @returns Current sync status or null
|
|
312
|
-
*/
|
|
313
|
-
getSyncStatus(): SyncStatusInfo | null;
|
|
314
|
-
/**
|
|
315
|
-
* Detect backend availability and recommend best option.
|
|
316
|
-
*
|
|
317
|
-
* The detection logic follows this priority:
|
|
318
|
-
* 1. If preferPowerSync is true and PowerSync is available, use PowerSync
|
|
319
|
-
* 2. If PowerSync is initializing and online with Supabase available, use Supabase temporarily
|
|
320
|
-
* 3. If online with Supabase available, use Supabase
|
|
321
|
-
* 4. If offline but PowerSync available, use PowerSync (offline mode)
|
|
322
|
-
* 5. If offline and PowerSync exists (even if initializing), use PowerSync local data
|
|
323
|
-
* 6. Default to Supabase as fallback
|
|
324
|
-
*
|
|
325
|
-
* @returns Detection result with recommendation and reasoning
|
|
326
|
-
*/
|
|
327
|
-
detect(): AutoDetectionResult;
|
|
328
|
-
/**
|
|
329
|
-
* Detect backend availability WITHOUT notifying listeners.
|
|
330
|
-
*
|
|
331
|
-
* This method is safe to call during React's render phase because it does not
|
|
332
|
-
* trigger state updates in other components. Use this method when you need to
|
|
333
|
-
* check backend status synchronously during render (e.g., in getAdapter()).
|
|
334
|
-
*
|
|
335
|
-
* The regular detect() method with listener notifications should only be called
|
|
336
|
-
* from useEffect or event handlers to avoid the React warning:
|
|
337
|
-
* "Cannot update a component while rendering a different component"
|
|
338
|
-
*
|
|
339
|
-
* @returns Detection result with recommendation and reasoning
|
|
340
|
-
*/
|
|
341
|
-
detectSilent(): AutoDetectionResult;
|
|
342
|
-
/**
|
|
343
|
-
* Internal detection logic shared by detect() and detectSilent().
|
|
344
|
-
* @private
|
|
345
|
-
*/
|
|
346
|
-
private performDetection;
|
|
347
|
-
/**
|
|
348
|
-
* Check if PowerSync is available.
|
|
349
|
-
*
|
|
350
|
-
* PowerSync status depends on:
|
|
351
|
-
* 1. Database instance exists
|
|
352
|
-
* 2. If useOnlineUntilSynced is true, also checks if initial sync completed
|
|
353
|
-
*
|
|
354
|
-
* @returns PowerSync backend status
|
|
355
|
-
*/
|
|
356
|
-
detectPowerSyncStatus(): BackendStatus;
|
|
357
|
-
/**
|
|
358
|
-
* Check if Supabase is available.
|
|
359
|
-
*
|
|
360
|
-
* Supabase is considered available if we have a client instance.
|
|
361
|
-
* The actual network connectivity is checked separately via checkOnlineStatus().
|
|
362
|
-
*
|
|
363
|
-
* @returns Supabase backend status
|
|
364
|
-
*/
|
|
365
|
-
detectSupabaseStatus(): BackendStatus;
|
|
366
|
-
/**
|
|
367
|
-
* Check if device is online.
|
|
368
|
-
*
|
|
369
|
-
* Prefers the sync status's isOnline property if available (from React Native NetInfo).
|
|
370
|
-
* Falls back to navigator.onLine in browser environments.
|
|
371
|
-
* Returns false by default for non-browser environments (React Native, Node.js, etc.)
|
|
372
|
-
* to ensure offline-first behavior works correctly.
|
|
373
|
-
*
|
|
374
|
-
* @returns Whether the device has network connectivity
|
|
375
|
-
*/
|
|
376
|
-
checkOnlineStatus(): boolean;
|
|
377
|
-
/**
|
|
378
|
-
* Update PowerSync instance (e.g., when it becomes available).
|
|
379
|
-
*
|
|
380
|
-
* @param db - New PowerSync database instance or null
|
|
381
|
-
*/
|
|
382
|
-
setPowerSync(db: PowerSyncDatabase | null): void;
|
|
383
|
-
/**
|
|
384
|
-
* Update Supabase instance.
|
|
385
|
-
*
|
|
386
|
-
* @param supabase - New Supabase client instance or null
|
|
387
|
-
*/
|
|
388
|
-
setSupabase(supabase: SupabaseClient | null): void;
|
|
389
|
-
/**
|
|
390
|
-
* Get current PowerSync instance.
|
|
391
|
-
*
|
|
392
|
-
* @returns Current PowerSync database instance or null
|
|
393
|
-
*/
|
|
394
|
-
getPowerSync(): PowerSyncDatabase | null;
|
|
395
|
-
/**
|
|
396
|
-
* Get current Supabase instance.
|
|
397
|
-
*
|
|
398
|
-
* @returns Current Supabase client instance or null
|
|
399
|
-
*/
|
|
400
|
-
getSupabase(): SupabaseClient | null;
|
|
401
|
-
/**
|
|
402
|
-
* Update detector options.
|
|
403
|
-
*
|
|
404
|
-
* @param options - New options to merge with existing
|
|
405
|
-
*/
|
|
406
|
-
setOptions(options: Partial<AutoDetectorOptions>): void;
|
|
407
|
-
/**
|
|
408
|
-
* Get current detector options.
|
|
409
|
-
*
|
|
410
|
-
* @returns Current detector options
|
|
411
|
-
*/
|
|
412
|
-
getOptions(): Required<AutoDetectorOptions>;
|
|
413
|
-
/**
|
|
414
|
-
* Add a listener for backend change events.
|
|
415
|
-
*
|
|
416
|
-
* @param listener - Callback to invoke when detection result changes
|
|
417
|
-
* @returns Function to remove the listener
|
|
418
|
-
*/
|
|
419
|
-
addListener(listener: BackendChangeListener): () => void;
|
|
420
|
-
/**
|
|
421
|
-
* Remove a listener for backend change events.
|
|
422
|
-
*
|
|
423
|
-
* @param listener - Listener to remove
|
|
424
|
-
*/
|
|
425
|
-
removeListener(listener: BackendChangeListener): void;
|
|
426
|
-
/**
|
|
427
|
-
* Get the last detection result.
|
|
428
|
-
*
|
|
429
|
-
* @returns Last detection result or null if never detected
|
|
430
|
-
*/
|
|
431
|
-
getLastResult(): AutoDetectionResult | null;
|
|
432
|
-
/**
|
|
433
|
-
* Check if the detection result has changed from the last result.
|
|
434
|
-
*/
|
|
435
|
-
private hasResultChanged;
|
|
436
|
-
/**
|
|
437
|
-
* Notify all listeners of a detection result change.
|
|
438
|
-
*/
|
|
439
|
-
private notifyListeners;
|
|
440
|
-
}
|
|
441
|
-
/**
|
|
442
|
-
* Create an AdapterAutoDetector instance.
|
|
443
|
-
*
|
|
444
|
-
* @param powerSyncDb - PowerSync database instance or null
|
|
445
|
-
* @param supabase - Supabase client instance or null
|
|
446
|
-
* @param options - Detection options
|
|
447
|
-
* @returns New AdapterAutoDetector instance
|
|
448
|
-
*
|
|
449
|
-
* @example
|
|
450
|
-
* ```typescript
|
|
451
|
-
* const detector = createAdapterAutoDetector(powerSyncDb, supabaseClient, {
|
|
452
|
-
* preferPowerSync: true,
|
|
453
|
-
* statusCheckTimeout: 2000,
|
|
454
|
-
* });
|
|
455
|
-
*
|
|
456
|
-
* const { recommendedBackend, reason } = detector.detect();
|
|
457
|
-
* ```
|
|
458
|
-
*/
|
|
459
|
-
declare function createAdapterAutoDetector(powerSyncDb: PowerSyncDatabase | null, supabase: SupabaseClient | null, options?: AutoDetectorOptions): AdapterAutoDetector;
|
|
460
|
-
|
|
461
|
-
/**
|
|
462
|
-
* Minimal interface for sync tracking callbacks.
|
|
463
|
-
* Intentionally decoupled from the full SyncControl to keep
|
|
464
|
-
* the adapter layer independent of React context types.
|
|
465
|
-
*/
|
|
466
|
-
interface SyncTracker {
|
|
467
|
-
addPendingMutation: (entry: {
|
|
468
|
-
id: string;
|
|
469
|
-
table: string;
|
|
470
|
-
op: string;
|
|
471
|
-
opData?: unknown;
|
|
472
|
-
createdAt?: Date;
|
|
473
|
-
}) => void;
|
|
474
|
-
removePendingMutation: (id: string) => void;
|
|
475
|
-
}
|
|
476
|
-
/**
|
|
477
|
-
* Decorator that wraps a TableDataAdapter and automatically
|
|
478
|
-
* tracks pending mutations via SyncTracker callbacks.
|
|
479
|
-
*
|
|
480
|
-
* Read operations (query, queryById, subscribe) are passed
|
|
481
|
-
* through without modification. Mutation operations (insert,
|
|
482
|
-
* update, upsert, delete) are wrapped with addPendingMutation
|
|
483
|
-
* before the write and removePendingMutation on error.
|
|
484
|
-
*
|
|
485
|
-
* NOTE: The syncTracker can be null/undefined during initialization
|
|
486
|
-
* due to React's useEffect timing. The adapter handles this gracefully
|
|
487
|
-
* by using optional chaining - mutations still work, just without tracking.
|
|
488
|
-
*/
|
|
489
|
-
declare class SyncTrackingAdapter implements TableDataAdapter {
|
|
490
|
-
private readonly inner;
|
|
491
|
-
private readonly syncTracker;
|
|
492
|
-
readonly name: string;
|
|
493
|
-
constructor(inner: TableDataAdapter, syncTracker: SyncTracker | null | undefined);
|
|
494
|
-
query<T>(table: string, options: QueryOptions): Promise<AdapterQueryResult<T>>;
|
|
495
|
-
queryById<T>(table: string, id: string, options?: Pick<QueryOptions, "select">): Promise<T | null>;
|
|
496
|
-
subscribe<T>(table: string, options: QueryOptions, callback: (data: T[]) => void): () => void;
|
|
497
|
-
insert<T>(table: string, data: Partial<T>): Promise<T>;
|
|
498
|
-
update<T>(table: string, id: string, data: Partial<T>): Promise<T>;
|
|
499
|
-
upsert<T>(table: string, data: Partial<T>): Promise<T>;
|
|
500
|
-
delete(table: string, id: string): Promise<void>;
|
|
501
|
-
/** Get the underlying unwrapped adapter */
|
|
502
|
-
getInnerAdapter(): TableDataAdapter;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
/**
|
|
506
|
-
* V3 Data Layer Adapter Registry
|
|
507
|
-
*
|
|
508
|
-
* Factory that creates and manages adapter instances based on table configuration.
|
|
509
|
-
* Uses lazy initialization to create adapters on first access.
|
|
510
|
-
*/
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* Registry that manages and provides adapters based on table configuration.
|
|
514
|
-
*
|
|
515
|
-
* The registry:
|
|
516
|
-
* - Stores configuration for table strategies
|
|
517
|
-
* - Lazily creates adapters when first accessed
|
|
518
|
-
* - Caches created adapters for reuse
|
|
519
|
-
* - Provides default fallback for unconfigured tables
|
|
520
|
-
*
|
|
521
|
-
* Usage:
|
|
522
|
-
* ```typescript
|
|
523
|
-
* const registry = createAdapterRegistry(config);
|
|
524
|
-
*
|
|
525
|
-
* // Later, when providers initialize:
|
|
526
|
-
* registry.setPowerSyncAdapter(powerSyncAdapter);
|
|
527
|
-
* registry.setSupabaseAdapter(supabaseAdapter);
|
|
528
|
-
*
|
|
529
|
-
* // Get adapter for a table:
|
|
530
|
-
* const adapter = registry.getAdapter("Project");
|
|
531
|
-
* ```
|
|
532
|
-
*/
|
|
533
|
-
declare class AdapterRegistry {
|
|
534
|
-
private config;
|
|
535
|
-
/**
|
|
536
|
-
* Cache of created adapters by table name
|
|
537
|
-
*/
|
|
538
|
-
private adapters;
|
|
539
|
-
/**
|
|
540
|
-
* PowerSync adapter instance (set during initialization or lazily via getter)
|
|
541
|
-
*/
|
|
542
|
-
private powerSyncAdapter;
|
|
543
|
-
/**
|
|
544
|
-
* Getter function to retrieve PowerSync database instance.
|
|
545
|
-
* Used for lazy initialization when PowerSync becomes available after registry creation.
|
|
546
|
-
*/
|
|
547
|
-
private powerSyncGetter;
|
|
548
|
-
/**
|
|
549
|
-
* Factory function to create PowerSync adapter from database instance.
|
|
550
|
-
* Set via setPowerSyncGetter along with the getter.
|
|
551
|
-
*/
|
|
552
|
-
private powerSyncAdapterFactory;
|
|
553
|
-
/**
|
|
554
|
-
* Supabase adapter instance (set during initialization)
|
|
555
|
-
*/
|
|
556
|
-
private supabaseAdapter;
|
|
557
|
-
/**
|
|
558
|
-
* Cached adapter instance (wraps Supabase with TanStack Query)
|
|
559
|
-
*/
|
|
560
|
-
private cachedAdapter;
|
|
561
|
-
/**
|
|
562
|
-
* Dependencies for creating adapters
|
|
563
|
-
*/
|
|
564
|
-
private deps;
|
|
565
|
-
/**
|
|
566
|
-
* Whether the registry has been initialized with adapters
|
|
567
|
-
*/
|
|
568
|
-
private _isInitialized;
|
|
569
|
-
/**
|
|
570
|
-
* Auto-detector instance for automatic backend selection
|
|
571
|
-
*/
|
|
572
|
-
private autoDetector;
|
|
573
|
-
/**
|
|
574
|
-
* Sync tracker for mutation tracking
|
|
575
|
-
*/
|
|
576
|
-
private syncTracker;
|
|
577
|
-
/**
|
|
578
|
-
* Sync tracking adapter that wraps PowerSync adapter
|
|
579
|
-
*/
|
|
580
|
-
private syncTrackingAdapter;
|
|
581
|
-
/**
|
|
582
|
-
* Listeners for backend change events
|
|
583
|
-
*/
|
|
584
|
-
private backendChangeListeners;
|
|
585
|
-
/**
|
|
586
|
-
* Last auto-detection result for debugging and status
|
|
587
|
-
*/
|
|
588
|
-
private lastDetectionResult;
|
|
589
|
-
/**
|
|
590
|
-
* Create a new adapter registry
|
|
591
|
-
*
|
|
592
|
-
* @param config - Data layer configuration with table strategies
|
|
593
|
-
*/
|
|
594
|
-
constructor(config: DataLayerConfig);
|
|
595
|
-
/**
|
|
596
|
-
* Check if the registry has been initialized
|
|
597
|
-
*/
|
|
598
|
-
get isInitialized(): boolean;
|
|
599
|
-
/**
|
|
600
|
-
* Initialize the registry with dependencies.
|
|
601
|
-
* Called by DataLayerProvider when PowerSync and Supabase are ready.
|
|
602
|
-
*
|
|
603
|
-
* @param deps - Dependencies needed to create adapters
|
|
604
|
-
*/
|
|
605
|
-
initialize(deps: AdapterDependencies): void;
|
|
606
|
-
/**
|
|
607
|
-
* Set the PowerSync adapter instance
|
|
608
|
-
*
|
|
609
|
-
* @param adapter - PowerSync adapter implementation
|
|
610
|
-
*/
|
|
611
|
-
setPowerSyncAdapter(adapter: TableDataAdapter): void;
|
|
612
|
-
/**
|
|
613
|
-
* Set a getter function for lazy PowerSync adapter initialization.
|
|
614
|
-
*
|
|
615
|
-
* This allows the registry to lazily create the PowerSync adapter when
|
|
616
|
-
* PowerSync becomes available, rather than requiring it at initialization time.
|
|
617
|
-
* Solves race conditions where queries/mutations run before PowerSync is ready.
|
|
618
|
-
*
|
|
619
|
-
* @param getter - Function that returns the PowerSync database instance (or null if not ready)
|
|
620
|
-
* @param factory - Function that creates a TableDataAdapter from the database instance
|
|
621
|
-
*/
|
|
622
|
-
setPowerSyncGetter(getter: () => unknown, factory: (db: unknown) => TableDataAdapter): void;
|
|
623
|
-
/**
|
|
624
|
-
* Ensure PowerSync adapter is initialized if available.
|
|
625
|
-
*
|
|
626
|
-
* Checks the getter (if set) and lazily creates the adapter if PowerSync
|
|
627
|
-
* is now available. Also updates the auto-detector with the new reference.
|
|
628
|
-
*
|
|
629
|
-
* @returns true if PowerSync adapter is available, false otherwise
|
|
630
|
-
*/
|
|
631
|
-
private ensurePowerSyncAdapter;
|
|
632
|
-
/**
|
|
633
|
-
* Set the sync tracker for mutation tracking.
|
|
634
|
-
* When set, write operations on PowerSync tables will
|
|
635
|
-
* automatically track pending mutations.
|
|
636
|
-
*
|
|
637
|
-
* NOTE: This also clears the adapter cache to ensure any
|
|
638
|
-
* previously cached adapters (which may have been created
|
|
639
|
-
* before the sync tracker was available) are recreated
|
|
640
|
-
* with the new sync tracker on next access.
|
|
641
|
-
*/
|
|
642
|
-
setSyncTracker(tracker: SyncTracker): void;
|
|
643
|
-
/**
|
|
644
|
-
* Set the Supabase adapter instance
|
|
645
|
-
*
|
|
646
|
-
* @param adapter - Supabase adapter implementation
|
|
647
|
-
*/
|
|
648
|
-
setSupabaseAdapter(adapter: TableDataAdapter): void;
|
|
649
|
-
/**
|
|
650
|
-
* Set the Cached adapter instance
|
|
651
|
-
*
|
|
652
|
-
* @param adapter - Cached adapter implementation
|
|
653
|
-
*/
|
|
654
|
-
setCachedAdapter(adapter: TableDataAdapter): void;
|
|
655
|
-
/**
|
|
656
|
-
* Initialize auto-detection with a detector instance
|
|
657
|
-
*
|
|
658
|
-
* @param detector - The auto-detector to use
|
|
659
|
-
*/
|
|
660
|
-
initializeAutoDetection(detector: AdapterAutoDetector): void;
|
|
661
|
-
/**
|
|
662
|
-
* Get the appropriate adapter for a table based on configuration.
|
|
663
|
-
*
|
|
664
|
-
* The adapter is selected based on the table's strategy in config.tables:
|
|
665
|
-
* - "powersync": Returns PowerSyncAdapter
|
|
666
|
-
* - "supabase": Returns SupabaseAdapter
|
|
667
|
-
* - "cached": Returns CachedAdapter (wrapping Supabase)
|
|
668
|
-
* - "hybrid": Returns HybridAdapter (combining PowerSync + Cached)
|
|
669
|
-
* - "auto": Uses auto-detection to select the best backend
|
|
670
|
-
*
|
|
671
|
-
* For tables not in config, defaults to auto-detection if available,
|
|
672
|
-
* otherwise falls back to SupabaseAdapter.
|
|
673
|
-
*
|
|
674
|
-
* Supports schema-qualified table names:
|
|
675
|
-
* - "core.Profile" looks up config["core.Profile"] first, then config["Profile"]
|
|
676
|
-
* - Auto-generates PowerSync alias as "CoreProfile" if not explicitly set
|
|
677
|
-
*
|
|
678
|
-
* @param table - The table name (may be schema-qualified like "core.Profile")
|
|
679
|
-
* @param operation - The operation type: 'read' uses fallback logic during init, 'write' always uses PowerSync for powersync tables
|
|
680
|
-
* @returns The appropriate adapter for the table
|
|
681
|
-
* @throws Error if adapters are not initialized
|
|
682
|
-
*/
|
|
683
|
-
getAdapter(table: string, _operation?: 'read' | 'write'): TableDataAdapter;
|
|
684
|
-
/**
|
|
685
|
-
* Get the PowerSync adapter directly
|
|
686
|
-
*
|
|
687
|
-
* @returns PowerSync adapter or null if not initialized
|
|
688
|
-
*/
|
|
689
|
-
getPowerSyncAdapter(): TableDataAdapter | null;
|
|
690
|
-
/**
|
|
691
|
-
* Get the Supabase adapter directly
|
|
692
|
-
*
|
|
693
|
-
* @returns Supabase adapter or null if not initialized
|
|
694
|
-
*/
|
|
695
|
-
getSupabaseAdapter(): TableDataAdapter | null;
|
|
696
|
-
/**
|
|
697
|
-
* Get the Cached adapter directly
|
|
698
|
-
*
|
|
699
|
-
* @returns Cached adapter or null if not initialized
|
|
700
|
-
*/
|
|
701
|
-
getCachedAdapter(): TableDataAdapter | null;
|
|
702
|
-
/**
|
|
703
|
-
* Get all configured table names
|
|
704
|
-
*
|
|
705
|
-
* @returns Array of table names with explicit strategy configuration
|
|
706
|
-
*/
|
|
707
|
-
getConfiguredTables(): string[];
|
|
708
|
-
/**
|
|
709
|
-
* Get the strategy for a specific table
|
|
710
|
-
*
|
|
711
|
-
* @param table - The table name (may include schema prefix like "core.Profile")
|
|
712
|
-
* @returns The table strategy or undefined if not configured
|
|
713
|
-
*/
|
|
714
|
-
getTableStrategy(table: string): TableStrategy | undefined;
|
|
715
|
-
/**
|
|
716
|
-
* Check if a table uses PowerSync strategy
|
|
717
|
-
*
|
|
718
|
-
* @param table - The table name (may include schema prefix like "core.Profile")
|
|
719
|
-
* @returns True if table uses PowerSync, Hybrid, or Auto strategy
|
|
720
|
-
*/
|
|
721
|
-
usesPowerSync(table: string): boolean;
|
|
722
|
-
/**
|
|
723
|
-
* Get all table config keys that use PowerSync (may be schema-qualified)
|
|
724
|
-
*
|
|
725
|
-
* @returns Array of config keys using PowerSync, Hybrid, or Auto strategy
|
|
726
|
-
*/
|
|
727
|
-
getPowerSyncTableKeys(): string[];
|
|
728
|
-
/**
|
|
729
|
-
* Get all tables that use PowerSync (returns aliases for PowerSync schema)
|
|
730
|
-
*
|
|
731
|
-
* @returns Array of PowerSync table aliases
|
|
732
|
-
*/
|
|
733
|
-
getPowerSyncTables(): string[];
|
|
734
|
-
/**
|
|
735
|
-
* Get the PowerSync alias for a table.
|
|
736
|
-
* Uses explicit alias from config if set, otherwise auto-generates.
|
|
737
|
-
*
|
|
738
|
-
* @param table - Table name (may be schema-qualified)
|
|
739
|
-
* @returns The alias to use in PowerSync schema
|
|
740
|
-
*/
|
|
741
|
-
getTableAlias(table: string): string;
|
|
742
|
-
/**
|
|
743
|
-
* Get adapter using auto-detection.
|
|
744
|
-
*
|
|
745
|
-
* Simple logic: PowerSync first, Supabase fallback.
|
|
746
|
-
* Once PowerSync is initialized, always use it for offline-first behavior.
|
|
747
|
-
*/
|
|
748
|
-
private getAutoAdapter;
|
|
749
|
-
/**
|
|
750
|
-
* Subscribe to backend changes
|
|
751
|
-
*
|
|
752
|
-
* @param callback - Function called when recommended backend changes
|
|
753
|
-
* @returns Unsubscribe function
|
|
754
|
-
*/
|
|
755
|
-
onBackendChange(callback: (backend: "powersync" | "supabase") => void): () => void;
|
|
756
|
-
/**
|
|
757
|
-
* Notify listeners of backend change
|
|
758
|
-
*
|
|
759
|
-
* @param backend - The new recommended backend
|
|
760
|
-
*/
|
|
761
|
-
private notifyBackendChange;
|
|
762
|
-
/**
|
|
763
|
-
* Get the last auto-detection result
|
|
764
|
-
*
|
|
765
|
-
* @returns Last detection result or null if never detected
|
|
766
|
-
*/
|
|
767
|
-
getLastDetectionResult(): AutoDetectionResult | null;
|
|
768
|
-
/**
|
|
769
|
-
* Get the auto-detector instance
|
|
770
|
-
*
|
|
771
|
-
* @returns Auto-detector instance or null if not initialized
|
|
772
|
-
*/
|
|
773
|
-
getAutoDetector(): AdapterAutoDetector | null;
|
|
774
|
-
/**
|
|
775
|
-
* Create an adapter based on the strategy type
|
|
776
|
-
*
|
|
777
|
-
* @param strategy - The table strategy configuration
|
|
778
|
-
* @returns The created adapter
|
|
779
|
-
* @throws Error if the required base adapter is not initialized
|
|
780
|
-
*/
|
|
781
|
-
private createAdapter;
|
|
782
|
-
/**
|
|
783
|
-
* Clear all cached adapters.
|
|
784
|
-
* Useful when configuration changes and adapters need to be recreated.
|
|
785
|
-
*/
|
|
786
|
-
clearCache(): void;
|
|
787
|
-
/**
|
|
788
|
-
* Reset the registry to uninitialized state.
|
|
789
|
-
* Used during cleanup or testing.
|
|
790
|
-
*/
|
|
791
|
-
reset(): void;
|
|
792
|
-
/**
|
|
793
|
-
* Dispose all adapters and clean up resources.
|
|
794
|
-
* Called when the DataLayerProvider unmounts.
|
|
795
|
-
*/
|
|
796
|
-
dispose(): void;
|
|
797
|
-
/**
|
|
798
|
-
* Get debug information about the registry state
|
|
799
|
-
*/
|
|
800
|
-
getDebugInfo(): {
|
|
801
|
-
isInitialized: boolean;
|
|
802
|
-
hasPowerSync: boolean;
|
|
803
|
-
hasSupabase: boolean;
|
|
804
|
-
hasCached: boolean;
|
|
805
|
-
cachedAdapterCount: number;
|
|
806
|
-
configuredTableCount: number;
|
|
807
|
-
powerSyncTables: string[];
|
|
808
|
-
hasAutoDetector: boolean;
|
|
809
|
-
lastDetectionResult: AutoDetectionResult | null;
|
|
810
|
-
};
|
|
811
|
-
}
|
|
812
|
-
/**
|
|
813
|
-
* Create a new adapter registry
|
|
814
|
-
*
|
|
815
|
-
* @param config - Data layer configuration
|
|
816
|
-
* @returns A new AdapterRegistry instance
|
|
817
|
-
*
|
|
818
|
-
* @example
|
|
819
|
-
* ```typescript
|
|
820
|
-
* const config: DataLayerConfig = {
|
|
821
|
-
* schema: databaseSchema,
|
|
822
|
-
* connections: { ... },
|
|
823
|
-
* tables: {
|
|
824
|
-
* Project: { strategy: "powersync", syncScope: "activeProject" },
|
|
825
|
-
* AuditLog: { strategy: "supabase" },
|
|
826
|
-
* Report: { strategy: "cached", cacheTime: 60000 },
|
|
827
|
-
* },
|
|
828
|
-
* scopes: { ... },
|
|
829
|
-
* defaults: { syncMode: "live" },
|
|
830
|
-
* };
|
|
831
|
-
*
|
|
832
|
-
* const registry = createAdapterRegistry(config);
|
|
833
|
-
*
|
|
834
|
-
* // In provider:
|
|
835
|
-
* registry.setPowerSyncAdapter(new PowerSyncAdapter(db, schema));
|
|
836
|
-
* registry.setSupabaseAdapter(new SupabaseAdapter(supabase));
|
|
837
|
-
*
|
|
838
|
-
* // In hooks:
|
|
839
|
-
* const adapter = registry.getAdapter("Project"); // Returns PowerSyncAdapter
|
|
840
|
-
* ```
|
|
841
|
-
*/
|
|
842
|
-
declare function createAdapterRegistry(config: DataLayerConfig): AdapterRegistry;
|
|
843
|
-
|
|
844
|
-
/**
|
|
845
|
-
* Status of the data layer initialization
|
|
846
|
-
*/
|
|
847
|
-
interface DataLayerStatus {
|
|
848
|
-
/** Whether the data layer is fully initialized */
|
|
849
|
-
isInitialized: boolean;
|
|
850
|
-
/** Current active backend */
|
|
851
|
-
currentBackend: "powersync" | "supabase" | null;
|
|
852
|
-
/** PowerSync connection status */
|
|
853
|
-
powerSyncStatus: BackendStatus;
|
|
854
|
-
/** Whether device is online */
|
|
855
|
-
isOnline: boolean;
|
|
856
|
-
/** Last auto-detection result */
|
|
857
|
-
lastDetection: AutoDetectionResult | null;
|
|
858
|
-
/** Initialization error if any */
|
|
859
|
-
error: Error | null;
|
|
860
|
-
/** Whether initial sync has completed (from PowerSync) */
|
|
861
|
-
hasSynced: boolean;
|
|
862
|
-
}
|
|
863
|
-
/**
|
|
864
|
-
* STABLE core context - values that don't change after initialization
|
|
865
|
-
*
|
|
866
|
-
* Use useDataLayerCore() to access these values in query/mutation hooks
|
|
867
|
-
* to avoid re-renders when sync status changes.
|
|
868
|
-
*/
|
|
869
|
-
interface DataLayerCoreContextValue {
|
|
870
|
-
/** Adapter registry for getting table adapters */
|
|
871
|
-
registry: AdapterRegistry;
|
|
872
|
-
/** Get adapter for a specific table (defaults to 'read' operation) */
|
|
873
|
-
getAdapter: (table: string, operation?: 'read' | 'write') => TableDataAdapter;
|
|
874
|
-
/** PowerSync database instance (null when not available) */
|
|
875
|
-
powerSync: PowerSyncDatabase | null;
|
|
876
|
-
/** Supabase client (always available) */
|
|
877
|
-
supabase: SupabaseClient;
|
|
878
|
-
/** React Query client */
|
|
879
|
-
queryClient: QueryClient;
|
|
880
|
-
/** Database schema */
|
|
881
|
-
schema: DatabaseSchema;
|
|
882
|
-
/** Sync controls (for PowerSync, no-op for Supabase-only) - stable reference */
|
|
883
|
-
syncControl: SyncControl;
|
|
884
|
-
}
|
|
885
|
-
/**
|
|
886
|
-
* DYNAMIC status context - values that change during runtime
|
|
887
|
-
*
|
|
888
|
-
* Use useDataLayerStatus() for UI components that display sync status,
|
|
889
|
-
* online indicator, etc. Components using this WILL re-render when status changes.
|
|
890
|
-
*/
|
|
891
|
-
interface DataLayerStatusContextValue {
|
|
892
|
-
/** Current status */
|
|
893
|
-
status: DataLayerStatus;
|
|
894
|
-
/** Sync status (for PowerSync, no-op for Supabase-only) */
|
|
895
|
-
syncStatus: SyncStatus;
|
|
896
|
-
}
|
|
897
|
-
/**
|
|
898
|
-
* Context value for the data layer (combines core and status)
|
|
899
|
-
*
|
|
900
|
-
* @deprecated Prefer using useDataLayerCore() or useDataLayerStatus() for better performance.
|
|
901
|
-
* This combined interface is kept for backward compatibility.
|
|
902
|
-
*/
|
|
903
|
-
interface DataLayerContextValue {
|
|
904
|
-
/** Adapter registry for getting table adapters */
|
|
905
|
-
registry: AdapterRegistry;
|
|
906
|
-
/** Get adapter for a specific table (defaults to 'read' operation) */
|
|
907
|
-
getAdapter: (table: string, operation?: 'read' | 'write') => TableDataAdapter;
|
|
908
|
-
/** PowerSync database instance (null when not available) */
|
|
909
|
-
powerSync: PowerSyncDatabase | null;
|
|
910
|
-
/** Supabase client (always available) */
|
|
911
|
-
supabase: SupabaseClient;
|
|
912
|
-
/** React Query client */
|
|
913
|
-
queryClient: QueryClient;
|
|
914
|
-
/** Database schema */
|
|
915
|
-
schema: DatabaseSchema;
|
|
916
|
-
/** Current status */
|
|
917
|
-
status: DataLayerStatus;
|
|
918
|
-
/** Sync status (for PowerSync, no-op for Supabase-only) */
|
|
919
|
-
syncStatus: SyncStatus;
|
|
920
|
-
/** Sync controls (for PowerSync, no-op for Supabase-only) */
|
|
921
|
-
syncControl: SyncControl;
|
|
922
|
-
}
|
|
923
|
-
/**
|
|
924
|
-
* STABLE Core context - values that don't change after initialization
|
|
925
|
-
*
|
|
926
|
-
* Use useDataLayerCore() hook to access. Components consuming this context
|
|
927
|
-
* will NOT re-render when sync status or network status changes.
|
|
928
|
-
*/
|
|
929
|
-
declare const DataLayerCoreContext: react.Context<DataLayerCoreContextValue>;
|
|
930
|
-
/**
|
|
931
|
-
* DYNAMIC Status context - values that change during runtime
|
|
932
|
-
*
|
|
933
|
-
* Use useDataLayerStatus() hook to access. Components consuming this context
|
|
934
|
-
* WILL re-render when sync status or network status changes.
|
|
935
|
-
*/
|
|
936
|
-
declare const DataLayerStatusContext: react.Context<DataLayerStatusContextValue>;
|
|
937
|
-
/**
|
|
938
|
-
* Combined data layer context (backward compatibility)
|
|
939
|
-
*
|
|
940
|
-
* @deprecated Prefer using DataLayerCoreContext or DataLayerStatusContext for better performance.
|
|
941
|
-
* Provides access to the V3 data layer throughout the React component tree.
|
|
942
|
-
* Must be accessed via the useDataLayer hook or similar consumer.
|
|
943
|
-
*/
|
|
944
|
-
declare const DataLayerContext: react.Context<DataLayerContextValue>;
|
|
945
|
-
|
|
946
|
-
export { type AdapterQueryResult as A, BackendStatus as B, type CapableDataAdapter as C, DataLayerContext as D, type SyncStatusInfo as S, type TableDataAdapter as T, type AdapterConfig as a, type AdapterFactory as b, type AdapterCapabilities as c, type AdapterDependencies as d, type AdapterStrategyType as e, ADAPTER_STRATEGIES as f, AdapterRegistry as g, createAdapterRegistry as h, AdapterAutoDetector as i, createAdapterAutoDetector as j, type AutoDetectionResult as k, type AutoDetectorOptions as l, type BackendChangeListener as m, SyncTrackingAdapter as n, type SyncTracker as o, DataLayerCoreContext as p, DataLayerStatusContext as q, type DataLayerContextValue as r, type DataLayerCoreContextValue as s, type DataLayerStatusContextValue as t, type DataLayerStatus as u };
|