@pol-studios/db 1.0.58 → 1.0.59
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-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-OK2C54B6.js → chunk-K46TGKB2.js} +323 -379
- package/dist/chunk-K46TGKB2.js.map +1 -0
- package/dist/{chunk-GWYTROSD.js → chunk-L4DFVMTS.js} +335 -4
- package/dist/chunk-L4DFVMTS.js.map +1 -0
- package/dist/{chunk-MEBT5YHA.js → chunk-SNPZMRBC.js} +2 -2
- package/dist/{chunk-LG3OHLGB.js → chunk-VADZSRHY.js} +16 -337
- package/dist/chunk-VADZSRHY.js.map +1 -0
- package/dist/{chunk-4EO55YV2.js → chunk-VSY6766U.js} +4 -4
- package/dist/{chunk-VYFAMTHI.js → chunk-WY6MNB6K.js} +2 -2
- package/dist/core/index.d.ts +1 -1
- 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 +20 -12
- 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 -149
- package/dist/index.web.js.map +1 -1
- package/dist/powersync-bridge/index.d.ts +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-MEBT5YHA.js.map → chunk-SNPZMRBC.js.map} +0 -0
- /package/dist/{chunk-4EO55YV2.js.map → chunk-VSY6766U.js.map} +0 -0
- /package/dist/{chunk-VYFAMTHI.js.map → chunk-WY6MNB6K.js.map} +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
2
|
import { UseMutationResult, UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';
|
|
3
|
+
import { QueryOptions, DataLayerConfig, TableStrategy, DatabaseSchema } from './core/index.js';
|
|
4
|
+
import { T as TableDataAdapter, A as AdapterQueryResult, d as AdapterDependencies, g as AdapterAutoDetector, i as AutoDetectionResult, C as CapableDataAdapter, c as AdapterCapabilities } from './DataLayerContext-V5FotiSk.js';
|
|
3
5
|
import { SupabaseClient, PostgrestSingleResponse as PostgrestSingleResponse$1, PostgrestError } from '@supabase/supabase-js';
|
|
4
|
-
import { T as TableDataAdapter, C as CapableDataAdapter, c as AdapterCapabilities, A as AdapterQueryResult } from './DataLayerContext-BYZtDD0g.js';
|
|
5
|
-
import { DatabaseSchema, QueryOptions } from './core/index.js';
|
|
6
6
|
import { FunctionsResponse } from '@supabase/functions-js';
|
|
7
7
|
import * as _supabase_postgrest_js from '@supabase/postgrest-js';
|
|
8
8
|
import { PostgrestSingleResponse } from '@supabase/postgrest-js';
|
|
9
9
|
import { G as GetResult } from './select-query-parser-BwyHum1L.js';
|
|
10
10
|
import { G as GenericTable } from './types-CYr9JiUE.js';
|
|
11
11
|
import { D as Database } from './useSupabase-DSZNeXnF.js';
|
|
12
|
-
import { D as DbChangeLog, Q as QueryState } from './index-
|
|
12
|
+
import { D as DbChangeLog, Q as QueryState } from './index-vwVJ0BWj.js';
|
|
13
13
|
import { U as UseDbQuerySingleReturn } from './useDbQuery-C-TL8jY1.js';
|
|
14
|
-
import { J as UseDbUpsertResult } from './useDbCount-
|
|
14
|
+
import { J as UseDbUpsertResult } from './useDbCount-dCkdaBpP.js';
|
|
15
15
|
import { Moment } from 'moment';
|
|
16
16
|
import * as react from 'react';
|
|
17
17
|
import { ReactNode } from 'react';
|
|
@@ -39,6 +39,430 @@ declare function useMutationSuccess<TData, TError, TVariables>(mutation: UseMuta
|
|
|
39
39
|
*/
|
|
40
40
|
declare function useMutationSuccessRN<TData, TError, TVariables>(mutation: UseMutationResult<TData, TError, TVariables>, options?: UseMutationSuccessOptions): UseMutationResult<TData, TError, TVariables>;
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Minimal interface for sync tracking callbacks.
|
|
44
|
+
* Intentionally decoupled from the full SyncControl to keep
|
|
45
|
+
* the adapter layer independent of React context types.
|
|
46
|
+
*/
|
|
47
|
+
interface SyncTracker {
|
|
48
|
+
addPendingMutation: (entry: {
|
|
49
|
+
id: string;
|
|
50
|
+
table: string;
|
|
51
|
+
op: string;
|
|
52
|
+
opData?: unknown;
|
|
53
|
+
createdAt?: Date;
|
|
54
|
+
}) => void;
|
|
55
|
+
removePendingMutation: (id: string) => void;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Decorator that wraps a TableDataAdapter and automatically
|
|
59
|
+
* tracks pending mutations via SyncTracker callbacks.
|
|
60
|
+
*
|
|
61
|
+
* Read operations (query, queryById, subscribe) are passed
|
|
62
|
+
* through without modification. Mutation operations (insert,
|
|
63
|
+
* update, upsert, delete) are wrapped with addPendingMutation
|
|
64
|
+
* before the write and removePendingMutation on error.
|
|
65
|
+
*
|
|
66
|
+
* NOTE: The syncTracker can be null/undefined during initialization
|
|
67
|
+
* due to React's useEffect timing. The adapter handles this gracefully
|
|
68
|
+
* by using optional chaining - mutations still work, just without tracking.
|
|
69
|
+
*/
|
|
70
|
+
declare class SyncTrackingAdapter implements TableDataAdapter {
|
|
71
|
+
private readonly inner;
|
|
72
|
+
private readonly syncTracker;
|
|
73
|
+
readonly name: string;
|
|
74
|
+
constructor(inner: TableDataAdapter, syncTracker: SyncTracker | null | undefined);
|
|
75
|
+
query<T>(table: string, options: QueryOptions): Promise<AdapterQueryResult<T>>;
|
|
76
|
+
queryById<T>(table: string, id: string, options?: Pick<QueryOptions, "select">): Promise<T | null>;
|
|
77
|
+
subscribe<T>(table: string, options: QueryOptions, callback: (data: T[]) => void): () => void;
|
|
78
|
+
insert<T>(table: string, data: Partial<T>): Promise<T>;
|
|
79
|
+
update<T>(table: string, id: string, data: Partial<T>): Promise<T>;
|
|
80
|
+
upsert<T>(table: string, data: Partial<T>): Promise<T>;
|
|
81
|
+
delete(table: string, id: string): Promise<void>;
|
|
82
|
+
/** Get the underlying unwrapped adapter */
|
|
83
|
+
getInnerAdapter(): TableDataAdapter;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* V3 Data Layer Adapter Registry
|
|
88
|
+
*
|
|
89
|
+
* Factory that creates and manages adapter instances based on table configuration.
|
|
90
|
+
* Uses lazy initialization to create adapters on first access.
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Strip schema prefix from a table name.
|
|
95
|
+
*
|
|
96
|
+
* Examples:
|
|
97
|
+
* - "core.Profile" → "Profile"
|
|
98
|
+
* - "billing.Invoice" → "Invoice"
|
|
99
|
+
* - "Profile" → "Profile" (no schema, unchanged)
|
|
100
|
+
*
|
|
101
|
+
* @param tableName - Table name, optionally schema-qualified
|
|
102
|
+
* @returns Table name without schema prefix
|
|
103
|
+
*/
|
|
104
|
+
declare function stripSchemaPrefix(tableName: string): string;
|
|
105
|
+
/**
|
|
106
|
+
* Generate a PowerSync alias from a schema-qualified table name.
|
|
107
|
+
* Use this when there are conflicting table names across schemas.
|
|
108
|
+
*
|
|
109
|
+
* Examples:
|
|
110
|
+
* - "core.Profile" → "CoreProfile"
|
|
111
|
+
* - "billing.Invoice" → "BillingInvoice"
|
|
112
|
+
* - "Profile" → "Profile" (no schema, unchanged)
|
|
113
|
+
*
|
|
114
|
+
* @param tableName - Table name, optionally schema-qualified
|
|
115
|
+
* @returns PascalCase alias suitable for PowerSync schema
|
|
116
|
+
*/
|
|
117
|
+
declare function generatePowerSyncAlias(tableName: string): string;
|
|
118
|
+
/**
|
|
119
|
+
* Get the PowerSync alias for a table from its strategy config.
|
|
120
|
+
*
|
|
121
|
+
* Resolution order:
|
|
122
|
+
* 1. Explicit alias in strategy config → use it
|
|
123
|
+
* 2. Schema-qualified name → strip schema (e.g., "core.Profile" → "Profile")
|
|
124
|
+
* 3. Unqualified name → use as-is
|
|
125
|
+
*
|
|
126
|
+
* Note: If you have conflicting table names (e.g., both "core.Profile" and "public.Profile"),
|
|
127
|
+
* you MUST set an explicit `alias` in the config for at least one of them.
|
|
128
|
+
*
|
|
129
|
+
* @param tableName - Table name (may be schema-qualified)
|
|
130
|
+
* @param strategy - Table strategy config
|
|
131
|
+
* @returns The alias to use in PowerSync schema
|
|
132
|
+
*/
|
|
133
|
+
declare function getPowerSyncAlias(tableName: string, strategy: TableStrategy | undefined): string;
|
|
134
|
+
/**
|
|
135
|
+
* Registry that manages and provides adapters based on table configuration.
|
|
136
|
+
*
|
|
137
|
+
* The registry:
|
|
138
|
+
* - Stores configuration for table strategies
|
|
139
|
+
* - Lazily creates adapters when first accessed
|
|
140
|
+
* - Caches created adapters for reuse
|
|
141
|
+
* - Provides default fallback for unconfigured tables
|
|
142
|
+
*
|
|
143
|
+
* Usage:
|
|
144
|
+
* ```typescript
|
|
145
|
+
* const registry = createAdapterRegistry(config);
|
|
146
|
+
*
|
|
147
|
+
* // Later, when providers initialize:
|
|
148
|
+
* registry.setPowerSyncAdapter(powerSyncAdapter);
|
|
149
|
+
* registry.setSupabaseAdapter(supabaseAdapter);
|
|
150
|
+
*
|
|
151
|
+
* // Get adapter for a table:
|
|
152
|
+
* const adapter = registry.getAdapter("Project");
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
declare class AdapterRegistry {
|
|
156
|
+
private config;
|
|
157
|
+
/**
|
|
158
|
+
* Cache of created adapters by table name
|
|
159
|
+
*/
|
|
160
|
+
private adapters;
|
|
161
|
+
/**
|
|
162
|
+
* PowerSync adapter instance (set during initialization or lazily via getter)
|
|
163
|
+
*/
|
|
164
|
+
private powerSyncAdapter;
|
|
165
|
+
/**
|
|
166
|
+
* Getter function to retrieve PowerSync database instance.
|
|
167
|
+
* Used for lazy initialization when PowerSync becomes available after registry creation.
|
|
168
|
+
*/
|
|
169
|
+
private powerSyncGetter;
|
|
170
|
+
/**
|
|
171
|
+
* Factory function to create PowerSync adapter from database instance.
|
|
172
|
+
* Set via setPowerSyncGetter along with the getter.
|
|
173
|
+
*/
|
|
174
|
+
private powerSyncAdapterFactory;
|
|
175
|
+
/**
|
|
176
|
+
* Supabase adapter instance (set during initialization)
|
|
177
|
+
*/
|
|
178
|
+
private supabaseAdapter;
|
|
179
|
+
/**
|
|
180
|
+
* Cached adapter instance (wraps Supabase with TanStack Query)
|
|
181
|
+
*/
|
|
182
|
+
private cachedAdapter;
|
|
183
|
+
/**
|
|
184
|
+
* Dependencies for creating adapters
|
|
185
|
+
*/
|
|
186
|
+
private deps;
|
|
187
|
+
/**
|
|
188
|
+
* Whether the registry has been initialized with adapters
|
|
189
|
+
*/
|
|
190
|
+
private _isInitialized;
|
|
191
|
+
/**
|
|
192
|
+
* Auto-detector instance for automatic backend selection
|
|
193
|
+
*/
|
|
194
|
+
private autoDetector;
|
|
195
|
+
/**
|
|
196
|
+
* Sync tracker for mutation tracking
|
|
197
|
+
*/
|
|
198
|
+
private syncTracker;
|
|
199
|
+
/**
|
|
200
|
+
* Sync tracking adapter that wraps PowerSync adapter
|
|
201
|
+
*/
|
|
202
|
+
private syncTrackingAdapter;
|
|
203
|
+
/**
|
|
204
|
+
* Listeners for backend change events
|
|
205
|
+
*/
|
|
206
|
+
private backendChangeListeners;
|
|
207
|
+
/**
|
|
208
|
+
* Last auto-detection result for debugging and status
|
|
209
|
+
*/
|
|
210
|
+
private lastDetectionResult;
|
|
211
|
+
/**
|
|
212
|
+
* Create a new adapter registry
|
|
213
|
+
*
|
|
214
|
+
* @param config - Data layer configuration with table strategies
|
|
215
|
+
*/
|
|
216
|
+
constructor(config: DataLayerConfig);
|
|
217
|
+
/**
|
|
218
|
+
* Check if the registry has been initialized
|
|
219
|
+
*/
|
|
220
|
+
get isInitialized(): boolean;
|
|
221
|
+
/**
|
|
222
|
+
* Initialize the registry with dependencies.
|
|
223
|
+
* Called by DataLayerProvider when PowerSync and Supabase are ready.
|
|
224
|
+
*
|
|
225
|
+
* @param deps - Dependencies needed to create adapters
|
|
226
|
+
*/
|
|
227
|
+
initialize(deps: AdapterDependencies): void;
|
|
228
|
+
/**
|
|
229
|
+
* Set the PowerSync adapter instance
|
|
230
|
+
*
|
|
231
|
+
* @param adapter - PowerSync adapter implementation
|
|
232
|
+
*/
|
|
233
|
+
setPowerSyncAdapter(adapter: TableDataAdapter): void;
|
|
234
|
+
/**
|
|
235
|
+
* Set a getter function for lazy PowerSync adapter initialization.
|
|
236
|
+
*
|
|
237
|
+
* This allows the registry to lazily create the PowerSync adapter when
|
|
238
|
+
* PowerSync becomes available, rather than requiring it at initialization time.
|
|
239
|
+
* Solves race conditions where queries/mutations run before PowerSync is ready.
|
|
240
|
+
*
|
|
241
|
+
* @param getter - Function that returns the PowerSync database instance (or null if not ready)
|
|
242
|
+
* @param factory - Function that creates a TableDataAdapter from the database instance
|
|
243
|
+
*/
|
|
244
|
+
setPowerSyncGetter(getter: () => unknown, factory: (db: unknown) => TableDataAdapter): void;
|
|
245
|
+
/**
|
|
246
|
+
* Ensure PowerSync adapter is initialized if available.
|
|
247
|
+
*
|
|
248
|
+
* Checks the getter (if set) and lazily creates the adapter if PowerSync
|
|
249
|
+
* is now available. Also updates the auto-detector with the new reference.
|
|
250
|
+
*
|
|
251
|
+
* @returns true if PowerSync adapter is available, false otherwise
|
|
252
|
+
*/
|
|
253
|
+
private ensurePowerSyncAdapter;
|
|
254
|
+
/**
|
|
255
|
+
* Set the sync tracker for mutation tracking.
|
|
256
|
+
* When set, write operations on PowerSync tables will
|
|
257
|
+
* automatically track pending mutations.
|
|
258
|
+
*
|
|
259
|
+
* NOTE: This also clears the adapter cache to ensure any
|
|
260
|
+
* previously cached adapters (which may have been created
|
|
261
|
+
* before the sync tracker was available) are recreated
|
|
262
|
+
* with the new sync tracker on next access.
|
|
263
|
+
*/
|
|
264
|
+
setSyncTracker(tracker: SyncTracker): void;
|
|
265
|
+
/**
|
|
266
|
+
* Set the Supabase adapter instance
|
|
267
|
+
*
|
|
268
|
+
* @param adapter - Supabase adapter implementation
|
|
269
|
+
*/
|
|
270
|
+
setSupabaseAdapter(adapter: TableDataAdapter): void;
|
|
271
|
+
/**
|
|
272
|
+
* Set the Cached adapter instance
|
|
273
|
+
*
|
|
274
|
+
* @param adapter - Cached adapter implementation
|
|
275
|
+
*/
|
|
276
|
+
setCachedAdapter(adapter: TableDataAdapter): void;
|
|
277
|
+
/**
|
|
278
|
+
* Initialize auto-detection with a detector instance
|
|
279
|
+
*
|
|
280
|
+
* @param detector - The auto-detector to use
|
|
281
|
+
*/
|
|
282
|
+
initializeAutoDetection(detector: AdapterAutoDetector): void;
|
|
283
|
+
/**
|
|
284
|
+
* Get the appropriate adapter for a table based on configuration.
|
|
285
|
+
*
|
|
286
|
+
* The adapter is selected based on the table's strategy in config.tables:
|
|
287
|
+
* - "powersync": Returns PowerSyncAdapter
|
|
288
|
+
* - "supabase": Returns SupabaseAdapter
|
|
289
|
+
* - "cached": Returns CachedAdapter (wrapping Supabase)
|
|
290
|
+
* - "hybrid": Returns HybridAdapter (combining PowerSync + Cached)
|
|
291
|
+
* - "auto": Uses auto-detection to select the best backend
|
|
292
|
+
*
|
|
293
|
+
* For tables not in config, defaults to auto-detection if available,
|
|
294
|
+
* otherwise falls back to SupabaseAdapter.
|
|
295
|
+
*
|
|
296
|
+
* Supports schema-qualified table names:
|
|
297
|
+
* - "core.Profile" looks up config["core.Profile"] first, then config["Profile"]
|
|
298
|
+
* - Auto-generates PowerSync alias as "CoreProfile" if not explicitly set
|
|
299
|
+
*
|
|
300
|
+
* @param table - The table name (may be schema-qualified like "core.Profile")
|
|
301
|
+
* @param operation - The operation type: 'read' uses fallback logic during init, 'write' always uses PowerSync for powersync tables
|
|
302
|
+
* @returns The appropriate adapter for the table
|
|
303
|
+
* @throws Error if adapters are not initialized
|
|
304
|
+
*/
|
|
305
|
+
getAdapter(table: string, _operation?: 'read' | 'write'): TableDataAdapter;
|
|
306
|
+
/**
|
|
307
|
+
* Get the PowerSync adapter directly
|
|
308
|
+
*
|
|
309
|
+
* @returns PowerSync adapter or null if not initialized
|
|
310
|
+
*/
|
|
311
|
+
getPowerSyncAdapter(): TableDataAdapter | null;
|
|
312
|
+
/**
|
|
313
|
+
* Get the Supabase adapter directly
|
|
314
|
+
*
|
|
315
|
+
* @returns Supabase adapter or null if not initialized
|
|
316
|
+
*/
|
|
317
|
+
getSupabaseAdapter(): TableDataAdapter | null;
|
|
318
|
+
/**
|
|
319
|
+
* Get the Cached adapter directly
|
|
320
|
+
*
|
|
321
|
+
* @returns Cached adapter or null if not initialized
|
|
322
|
+
*/
|
|
323
|
+
getCachedAdapter(): TableDataAdapter | null;
|
|
324
|
+
/**
|
|
325
|
+
* Get all configured table names
|
|
326
|
+
*
|
|
327
|
+
* @returns Array of table names with explicit strategy configuration
|
|
328
|
+
*/
|
|
329
|
+
getConfiguredTables(): string[];
|
|
330
|
+
/**
|
|
331
|
+
* Get the strategy for a specific table
|
|
332
|
+
*
|
|
333
|
+
* @param table - The table name (may include schema prefix like "core.Profile")
|
|
334
|
+
* @returns The table strategy or undefined if not configured
|
|
335
|
+
*/
|
|
336
|
+
getTableStrategy(table: string): TableStrategy | undefined;
|
|
337
|
+
/**
|
|
338
|
+
* Check if a table uses PowerSync strategy
|
|
339
|
+
*
|
|
340
|
+
* @param table - The table name (may include schema prefix like "core.Profile")
|
|
341
|
+
* @returns True if table uses PowerSync, Hybrid, or Auto strategy
|
|
342
|
+
*/
|
|
343
|
+
usesPowerSync(table: string): boolean;
|
|
344
|
+
/**
|
|
345
|
+
* Get all table config keys that use PowerSync (may be schema-qualified)
|
|
346
|
+
*
|
|
347
|
+
* @returns Array of config keys using PowerSync, Hybrid, or Auto strategy
|
|
348
|
+
*/
|
|
349
|
+
getPowerSyncTableKeys(): string[];
|
|
350
|
+
/**
|
|
351
|
+
* Get all tables that use PowerSync (returns aliases for PowerSync schema)
|
|
352
|
+
*
|
|
353
|
+
* @returns Array of PowerSync table aliases
|
|
354
|
+
*/
|
|
355
|
+
getPowerSyncTables(): string[];
|
|
356
|
+
/**
|
|
357
|
+
* Get the PowerSync alias for a table.
|
|
358
|
+
* Uses explicit alias from config if set, otherwise auto-generates.
|
|
359
|
+
*
|
|
360
|
+
* @param table - Table name (may be schema-qualified)
|
|
361
|
+
* @returns The alias to use in PowerSync schema
|
|
362
|
+
*/
|
|
363
|
+
getTableAlias(table: string): string;
|
|
364
|
+
/**
|
|
365
|
+
* Get adapter using auto-detection.
|
|
366
|
+
*
|
|
367
|
+
* Simple logic: PowerSync first, Supabase fallback.
|
|
368
|
+
* Once PowerSync is initialized, always use it for offline-first behavior.
|
|
369
|
+
*/
|
|
370
|
+
private getAutoAdapter;
|
|
371
|
+
/**
|
|
372
|
+
* Subscribe to backend changes
|
|
373
|
+
*
|
|
374
|
+
* @param callback - Function called when recommended backend changes
|
|
375
|
+
* @returns Unsubscribe function
|
|
376
|
+
*/
|
|
377
|
+
onBackendChange(callback: (backend: "powersync" | "supabase") => void): () => void;
|
|
378
|
+
/**
|
|
379
|
+
* Notify listeners of backend change
|
|
380
|
+
*
|
|
381
|
+
* @param backend - The new recommended backend
|
|
382
|
+
*/
|
|
383
|
+
private notifyBackendChange;
|
|
384
|
+
/**
|
|
385
|
+
* Get the last auto-detection result
|
|
386
|
+
*
|
|
387
|
+
* @returns Last detection result or null if never detected
|
|
388
|
+
*/
|
|
389
|
+
getLastDetectionResult(): AutoDetectionResult | null;
|
|
390
|
+
/**
|
|
391
|
+
* Get the auto-detector instance
|
|
392
|
+
*
|
|
393
|
+
* @returns Auto-detector instance or null if not initialized
|
|
394
|
+
*/
|
|
395
|
+
getAutoDetector(): AdapterAutoDetector | null;
|
|
396
|
+
/**
|
|
397
|
+
* Create an adapter based on the strategy type
|
|
398
|
+
*
|
|
399
|
+
* @param strategy - The table strategy configuration
|
|
400
|
+
* @returns The created adapter
|
|
401
|
+
* @throws Error if the required base adapter is not initialized
|
|
402
|
+
*/
|
|
403
|
+
private createAdapter;
|
|
404
|
+
/**
|
|
405
|
+
* Clear all cached adapters.
|
|
406
|
+
* Useful when configuration changes and adapters need to be recreated.
|
|
407
|
+
*/
|
|
408
|
+
clearCache(): void;
|
|
409
|
+
/**
|
|
410
|
+
* Reset the registry to uninitialized state.
|
|
411
|
+
* Used during cleanup or testing.
|
|
412
|
+
*/
|
|
413
|
+
reset(): void;
|
|
414
|
+
/**
|
|
415
|
+
* Dispose all adapters and clean up resources.
|
|
416
|
+
* Called when the DataLayerProvider unmounts.
|
|
417
|
+
*/
|
|
418
|
+
dispose(): void;
|
|
419
|
+
/**
|
|
420
|
+
* Get debug information about the registry state
|
|
421
|
+
*/
|
|
422
|
+
getDebugInfo(): {
|
|
423
|
+
isInitialized: boolean;
|
|
424
|
+
hasPowerSync: boolean;
|
|
425
|
+
hasSupabase: boolean;
|
|
426
|
+
hasCached: boolean;
|
|
427
|
+
cachedAdapterCount: number;
|
|
428
|
+
configuredTableCount: number;
|
|
429
|
+
powerSyncTables: string[];
|
|
430
|
+
hasAutoDetector: boolean;
|
|
431
|
+
lastDetectionResult: AutoDetectionResult | null;
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Create a new adapter registry
|
|
436
|
+
*
|
|
437
|
+
* @param config - Data layer configuration
|
|
438
|
+
* @returns A new AdapterRegistry instance
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* ```typescript
|
|
442
|
+
* const config: DataLayerConfig = {
|
|
443
|
+
* schema: databaseSchema,
|
|
444
|
+
* connections: { ... },
|
|
445
|
+
* tables: {
|
|
446
|
+
* Project: { strategy: "powersync", syncScope: "activeProject" },
|
|
447
|
+
* AuditLog: { strategy: "supabase" },
|
|
448
|
+
* Report: { strategy: "cached", cacheTime: 60000 },
|
|
449
|
+
* },
|
|
450
|
+
* scopes: { ... },
|
|
451
|
+
* defaults: { syncMode: "live" },
|
|
452
|
+
* };
|
|
453
|
+
*
|
|
454
|
+
* const registry = createAdapterRegistry(config);
|
|
455
|
+
*
|
|
456
|
+
* // In provider:
|
|
457
|
+
* registry.setPowerSyncAdapter(new PowerSyncAdapter(db, schema));
|
|
458
|
+
* registry.setSupabaseAdapter(new SupabaseAdapter(supabase));
|
|
459
|
+
*
|
|
460
|
+
* // In hooks:
|
|
461
|
+
* const adapter = registry.getAdapter("Project"); // Returns PowerSyncAdapter
|
|
462
|
+
* ```
|
|
463
|
+
*/
|
|
464
|
+
declare function createAdapterRegistry(config: DataLayerConfig): AdapterRegistry;
|
|
465
|
+
|
|
42
466
|
/**
|
|
43
467
|
* V3 Data Layer - Supabase Adapter
|
|
44
468
|
*
|
|
@@ -967,4 +1391,4 @@ declare function useResolveFeedback(): _tanstack_react_query.UseMutationResult<{
|
|
|
967
1391
|
}>;
|
|
968
1392
|
}, Error, number, unknown>;
|
|
969
1393
|
|
|
970
|
-
export {
|
|
1394
|
+
export { LiveChangeContextProvider as $, type AttachmentQueueProvider as A, SupabaseAdapter as B, createSupabaseAdapter as C, SyncTrackingAdapter as D, type SyncTracker as E, getErrorBody as F, type AIOptions as G, type AIResponse as H, useAI as I, type ServerAvailabilityState as J, useServerAvailability as K, useSearchQuery as L, type UpdateOptions as M, executeAdvanceQuery as N, type CustomPageQueryResult as O, BUCKETS as P, type BucketName as Q, createInCondition as R, StorageQueueProvider as S, TIMEOUT_ERROR_MESSAGE as T, type UseAutosaveOptions as U, DEFAULT_QUERY_TIMEOUT as V, isTimeoutError as W, type UseDbRealtimeQueryResult as X, convertFilterToRealtimeQuery as Y, type AlertProps as Z, LiveChangeContext as _, useLatestOperationLog as a, useUpsertChangelog as a0, useDeleteChangelog as a1, useUpsertChangelogEntry as a2, useMultiUpsertChangelogEntries as a3, useDeleteChangelogEntry as a4, useMultiDeleteChangelogEntries as a5, useUpsertChangelogMedia as a6, useDeleteChangelogMedia as a7, useUploadChangelogMedia as a8, useChangelogs as a9, usePublishedChangelogs as aa, useChangelogById as ab, useChangelogBySlug as ac, useChangelogEntries as ad, useChangelogMedia as ae, useFeedbackList as af, type FeedbackListItem as ag, type FeedbackListParams as ah, useSubmitFeedback as ai, type SubmitFeedbackParams as aj, useApplyFeedback as ak, useResolveFeedback as al, type UseDbPartialQueryResult as am, useDbPartialQuery as an, useAutosaveState as b, useAutosave as c, type UseAutosaveResult as d, useToastError as e, useStorageSource as f, getStorageUrl as g, type UseStorageSourceOptions as h, type UseStorageSourceResult as i, type StorageQueueProviderProps as j, StorageQueueContext as k, useStorageQueueContext as l, type StorageQueueContextValue as m, newTimeActivity as n, useDbRealtimeQuery as o, getSupabaseUrl as p, type UseMutationSuccessOptions as q, useMutationSuccess as r, setSupabaseUrl as s, useMutationSuccessRN as t, useLiveChangeTracking as u, AdapterRegistry as v, createAdapterRegistry as w, stripSchemaPrefix as x, generatePowerSyncAlias as y, getPowerSyncAlias as z };
|
package/dist/with-auth/index.js
CHANGED
|
@@ -5,20 +5,20 @@ import {
|
|
|
5
5
|
useUserMetadataState,
|
|
6
6
|
useUserMetadataValue,
|
|
7
7
|
userMetadataContext
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-VSY6766U.js";
|
|
9
9
|
import {
|
|
10
10
|
useDbUpsert
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-WY6MNB6K.js";
|
|
12
12
|
import "../chunk-SM73S2DY.js";
|
|
13
13
|
import "../chunk-NSIAAYW3.js";
|
|
14
14
|
import {
|
|
15
15
|
useAuth,
|
|
16
16
|
useSetupAuth
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-SNPZMRBC.js";
|
|
18
18
|
import {
|
|
19
19
|
useDbQuery
|
|
20
|
-
} from "../chunk-
|
|
21
|
-
import "../chunk-
|
|
20
|
+
} from "../chunk-ARALLEDJ.js";
|
|
21
|
+
import "../chunk-L4DFVMTS.js";
|
|
22
22
|
import "../chunk-RT4O5H2E.js";
|
|
23
23
|
import {
|
|
24
24
|
getSupabaseUrl
|