@pol-studios/db 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +434 -0
  2. package/dist/EntityPermissions-DwFt4tUd.d.ts +35 -0
  3. package/dist/FilterConfig-Bt2Ek74z.d.ts +99 -0
  4. package/dist/UserMetadataContext-BYYqA6LI.d.ts +89 -0
  5. package/dist/auth/context.d.ts +47 -0
  6. package/dist/auth/context.js +12791 -0
  7. package/dist/auth/context.js.map +1 -0
  8. package/dist/auth/guards.d.ts +180 -0
  9. package/dist/auth/guards.js +7651 -0
  10. package/dist/auth/guards.js.map +1 -0
  11. package/dist/auth/hooks.d.ts +312 -0
  12. package/dist/auth/hooks.js +10600 -0
  13. package/dist/auth/hooks.js.map +1 -0
  14. package/dist/auth/index.d.ts +10 -0
  15. package/dist/auth/index.js +13035 -0
  16. package/dist/auth/index.js.map +1 -0
  17. package/dist/client/index.d.ts +16 -0
  18. package/dist/core/index.d.ts +508 -0
  19. package/dist/executor-CB4KHyYG.d.ts +507 -0
  20. package/dist/gen/index.d.ts +1099 -0
  21. package/dist/hooks/index.d.ts +83 -0
  22. package/dist/index-DNrSptau.d.ts +8780 -0
  23. package/dist/index.d.ts +338 -0
  24. package/dist/index.js +10320 -7124
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.web.d.ts +318 -0
  27. package/dist/index.web.js +56795 -0
  28. package/dist/index.web.js.map +1 -0
  29. package/dist/mutation/index.d.ts +58 -0
  30. package/dist/mutation/index.js +4581 -76
  31. package/dist/mutation/index.js.map +1 -1
  32. package/dist/parser/index.d.ts +366 -0
  33. package/dist/parser/index.js +26 -26
  34. package/dist/parser/index.js.map +1 -1
  35. package/dist/query/index.d.ts +723 -0
  36. package/dist/query/index.js +13124 -10324
  37. package/dist/query/index.js.map +1 -1
  38. package/dist/realtime/index.d.ts +44 -0
  39. package/dist/realtime/index.js +13217 -9297
  40. package/dist/realtime/index.js.map +1 -1
  41. package/dist/select-query-parser-CLkOKHzc.d.ts +352 -0
  42. package/dist/types/index.d.ts +6 -0
  43. package/dist/types-CKsWM8T3.d.ts +62 -0
  44. package/dist/useBatchUpsert-ooLlpJMg.d.ts +24 -0
  45. package/dist/useDbCount-B5-Va9sg.d.ts +1740 -0
  46. package/dist/useDbQuery-C-TL8jY1.d.ts +19 -0
  47. package/dist/useResolveFeedback-DuGP4Tgb.d.ts +1165 -0
  48. package/dist/useSupabase-pPhUZHcl.d.ts +27 -0
  49. package/package.json +31 -7
@@ -0,0 +1,338 @@
1
+ export { B as BooleanOperator, m as ClarificationQuestion, h as ClarificationSuggestion, C as CompositeTypes, g as ComputedSortConfig, c as Constants, D as Database, d as DbChangeLog, E as Enums, k as Filter, F as FilterConditionType, i as FilterContextType, l as FilterGroup, e as FilterInput, j as FilterOperator, f as FilterState, J as Json, O as OrderColumn, P as Pagination, Q as QueryState, S as Sort, T as Tables, a as TablesInsert, b as TablesUpdate, V as ValueOrArrayForPropertyType, n as normalizeFilter, u as useDbAdvanceFilterQuery, u as useDbAdvanceQuery } from './index-DNrSptau.js';
2
+ export { a as FilterConfig, F as FilterConfigOption, G as Group, P as PropertyType, S as SortConfig, T as TableInfo, V as ValueForPropertyType, W as WhereFilter } from './FilterConfig-Bt2Ek74z.js';
3
+ export { G as AIOptions, H as AIResponse, a3 as AlertProps, Z as BUCKETS, K as BatchAnalysisProgress, _ as BucketName, T as CustomPageQueryResult, a1 as DEFAULT_QUERY_TIMEOUT, J as ExtractedReceipt, am as FeedbackListItem, an as FeedbackListParams, a4 as LiveChangeContext, a5 as LiveChangeContextProvider, M as MutationOption, P as PendingExpense, L as ServerAvailabilityState, Y as StorageObjectMetadata, ap as SubmitFeedbackParams, S as SupabaseAdapter, a0 as TIMEOUT_ERROR_MESSAGE, Q as UpdateOptions, U as UseDbPartialAdvanceQueryResult, w as UseDbPartialQueryResult, y as UseDbRealtimeQueryResult, C as UseMutationSuccessOptions, W as UseSupabaseUploadOptions, X as UseSupabaseUploadReturn, z as convertFilterToRealtimeQuery, $ as createInCondition, g as createSupabaseAdapter, R as executeAdvanceQuery, F as getErrorBody, q as getSupabaseUrl, a2 as isTimeoutError, n as newTimeActivity, A as sanitizeStorageKey, s as setSupabaseUrl, I as useAI, aq as useApplyFeedback, l as useAutosaveState, ah as useChangelogById, ai as useChangelogBySlug, aj as useChangelogEntries, ak as useChangelogMedia, af as useChangelogs, d as useDbDelete, b as useDbInsert, r as useDbMultiDelete, t as useDbMultiUpsert, v as useDbPartialAdvanceQuery, x as useDbPartialQuery, u as useDbRealtime, f as useDbRealtimeQuery, c as useDbUpdate, a as useDbUpload, e as useDbUpsert, B as useDbUpsertResponse, d as useDelete, a7 as useDeleteChangelog, aa as useDeleteChangelogEntry, ad as useDeleteChangelogMedia, al as useFeedbackList, b as useInsert, k as useLatestOperationLog, j as useLiveChangeTracking, ab as useMultiDeleteChangelogEntries, a9 as useMultiUpsertChangelogEntries, D as useMutationSuccess, E as useMutationSuccessRN, ag as usePublishedChangelogs, u as useRealtime, f as useRealtimeQuery, i as useReceiptAI, ar as useResolveFeedback, O as useSearchQuery, N as useServerAvailability, p as useStoragePath, o as useStorageUrl, ao as useSubmitFeedback, h as useSupabaseFunction, V as useSupabaseUpload, m as useToastError, c as useUpdate, ae as useUploadChangelogMedia, e as useUpsert, a6 as useUpsertChangelog, a8 as useUpsertChangelogEntry, ac as useUpsertChangelogMedia } from './useResolveFeedback-DuGP4Tgb.js';
4
+ export { F as Fetch, k as GenericFunction, j as GenericNonUpdatableView, G as GenericSchema, a as GenericTable, i as GenericUpdatableView, b as GenericView, c as PostgrestError, g as PostgrestMaybeSingleResponse, h as PostgrestResponse, e as PostgrestResponseFailure, d as PostgrestResponseSuccess, f as PostgrestSingleResponse, P as Prettify } from './types-CKsWM8T3.js';
5
+ export { U as UseDbQuerySingleReturn, u as useDbQuery } from './useDbQuery-C-TL8jY1.js';
6
+ export { u as useBatchDelete, a as useBatchUpsert } from './useBatchUpsert-ooLlpJMg.js';
7
+ import { DatabaseSchema, QueryOptions, DataLayerConfig } from './core/index.js';
8
+ export { AdapterRegistry as AdapterRegistryInterface, AutoStrategy, BuiltQuery, CachedStrategy, ColumnInfo, ColumnType, ConnectionConfig, DataAdapter, DataLayerHooks, DeleteMutationResult, ExtractInsert, ExtractRow, ExtractUpdate, HybridStrategy, MutationHookResult, MutationResult, OrderBy, ParsedSelect, PowerSyncStrategy, QueryResult, QuerySingleResult, RelationshipInfo, RelationshipType, ResolvedRelationship, ScopeDefinition, SelectColumn, SelectRelation, SupabaseStrategy, SyncControl, SyncMode, SyncScope, SyncStatus, TableNames, TableSchema, TableStrategy, UseDbMutationHook, UseDbQueryByIdHook, UseDbQueryHook, WhereClause, WhereOperators } from './core/index.js';
9
+ export { UsePartialAdvancedQueryResult, UsePartialQueryResult, UseQuerySingleReturn, extractColumnNames, extractRelationNames, getRelationSelect, hasRelation, parseSelect, stringifySelect, tokenizeTopLevel, useAdvancedFilterQuery, useAdvancedQuery, useInfiniteQuery, usePartialAdvancedQuery, usePartialQuery, useQuery } from './query/index.js';
10
+ import { Q as QueryExecutor, P as PowerSyncDatabase$1 } from './executor-CB4KHyYG.js';
11
+ export { e as RelationJoinData, R as RelationshipResolver, b as ResultJoiner, S as SQLBuilder, f as createQueryExecutor, c as createRelationshipResolver, d as createResultJoiner, a as createSQLBuilder } from './executor-CB4KHyYG.js';
12
+ import { T as TableDataAdapter, C as CapableDataAdapter, c as AdapterCapabilities, A as AdapterQueryResult, D as DataLayerContextValue } from './useDbCount-B5-Va9sg.js';
13
+ export { f as ADAPTER_STRATEGIES, i as AdapterAutoDetector, a as AdapterConfig, d as AdapterDependencies, b as AdapterFactory, g as AdapterRegistry, e as AdapterStrategyType, k as AutoDetectionResult, l as AutoDetectorOptions, m as BackendChangeListener, B as BackendStatus, a6 as DataLayerContext, a7 as DataLayerStatus, p as DatabaseTypes, P as PublicTableNames, R as ResolveRowType, S as SchemaNames, q as SchemaTableNames, r as TableIdentifier, I as UseAdvanceQueryOptions, J as UseAdvanceQueryResult, a4 as UseDbCountOptions, a5 as UseDbCountResult, a1 as UseDbInfiniteQueryOptions, a2 as UseDbInfiniteQueryResult, U as UseDbQueryOptions, s as UseDbQueryResult, j as createAdapterAutoDetector, h as createAdapterRegistry, x as useAdvanceQuery, u as useDataLayer, a3 as useDbCount, a3 as useDbCountV3, Z as useDbDeleteV3, a0 as useDbInfiniteQuery, a0 as useDbInfiniteQueryV3, K as useDbInsertV3, t as useDbQueryById, o as useDbQueryV3, N as useDbUpdateV3, W as useDbUpsertV3 } from './useDbCount-B5-Va9sg.js';
14
+ import { ReactNode, JSX } from 'react';
15
+ import { SupabaseClient } from '@supabase/supabase-js';
16
+ import { QueryClient } from '@tanstack/react-query';
17
+ export { useOnlineStatus, useSyncControl, useSyncStatus } from './hooks/index.js';
18
+ export { S as SupabaseDatabaseTypes, a as SupabaseProvider, T as TypedSupabaseClient, U as UserSessionId, c as createNewSupabaseClient, u as default, o as onSupabaseInitialized, s as setDefaultOptions, t as typedSupabase, u as useSupabase } from './useSupabase-pPhUZHcl.js';
19
+ export { AnyPostgrestResponse, FilterDefinition, FilterDefinitions, FilterFn, NestedPath, OPERATOR_MAP, OperatorFn, OrderDefinition, Path, PostgrestFilter, PostgrestFilterOperator, PostgrestHasMorePaginationCacheData, PostgrestHasMorePaginationResponse, PostgrestPaginationCacheData, PostgrestPaginationResponse, PostgrestParser, PostgrestQueryParser, PostgrestQueryParserOptions, SUPPORTED_OPERATORS, ValueType, binarySearch, buildSortedComparator, denormalize, encodeObject, extractPathsFromFilters, filterFilterDefinitionsByPaths, findFilters, findIndexOrdered, findLastIndex, get, getTable, groupPathsRecursive, ifDateGetTime, isAndFilter, isAnyPostgrestResponse, isFilterDefinition, isISODateString, isNestedPath, isNotNull, isObject, isOrFilter, isPostgrestBuilder, isPostgrestHasMorePaginationCacheData, isPostgrestHasMorePaginationResponse, isPostgrestPaginationCacheData, isPostgrestPaginationResponse, parseOrderByKey, parseSelectParam, parseValue, removeAliasFromDeclaration, removeFirstPathElement, setFilterValue, sortSearchParams } from './parser/index.js';
20
+ export { G as GetResult, S as SelectQueryError } from './select-query-parser-CLkOKHzc.js';
21
+ export { Accessory, Address, AdvanceQuery, AdvanceQueryNotificationSetting, AdvancedQueryView, BillableService, BillingDetails, CachedEmbedding, Changelog, ChangelogEntry, ChangelogMedia, ChargeTable, Circuit, Client, Comment, CommentReaction, CommentRead, CommentSection, CommentTag, CommonNote, CommonNoteCategory, CommonNoteSubCategory, ControlComponent, ControlComponentDatasheet, Controller, CoreSavedQuery, CoreSavedQueryAccess, Currency, CurrencyUsdConversion, DataExchangeImport, Datasheet, Dimension, DimmerModule, DimmerRack, Embedding, EquipmentConfigurationGroup, EquipmentFixture, EquipmentFixtureConfiguration, EquipmentFixtureConfigurationAccessoryEntry, EquipmentFixtureConfigurationControlComponentEntry, EquipmentFixtureCost, EquipmentFixtureDatasheet, EquipmentFixtureDimension, EquipmentFixtureDocument, EquipmentFixtureLampConfiguration, EquipmentFixtureListing, EquipmentFixtureMode, EquipmentFixtureModeChannel, EquipmentFixturePreset, EquipmentFixtureUnit, EquipmentFixtureUnitControl, EquipmentFixtureUnitLocation, EquipmentFixtureUnitLocationTag, EquipmentFixtureUnitLocationTagValue, EquipmentFixtureUnitPatternEntry, EquipmentFixtureWeight, EquipmentType, EquipmentUnitMediaContent, Expense, ExpenseLineItem, ExpenseReport, Fixture, FixtureCatalog, FixtureCatalogItem, FixtureCategory, FixtureTag, GlobalExpenseReport, HighlightServer, HighlightServerInstance, HighlightServerInstanceLog, HighlightServerInstanceOptions, HighlightServerInstanceStatus, HighlightServerRequest, Invoice, InvoiceSummaryTable, InvoiceTerm, InvoiceTermCondition, Lamp, LampCategory, LampCurrentListing, LampType, LicenseAssignment, Logo, Manufacturer, ManufacturerTag, ManufacturerToTag, OperationLog, OrderHinted, Organization, OrganizationUser, OrganizationUserAccess, ParameterMappingProfile, ParameterMappingProfileAssignment, Pattern, PaymentCustomer, PaymentInvoice, PaymentPaymentIntents, PaymentPlan, PaymentProduct, PaymentProductFeature, PaymentSubscription, PaymentSubscriptionPlan, PhaseActivityBucket, ProfileConfig as Profile, ProfileConfig, ProfileTimeBank, Project, ProjectDatabase, ProjectDatabaseEquipmentConfigurationGroup, ProjectDatabaseExcelParameterAssignment, ProjectDatabaseGroup, ProjectDatabaseParameterMappingProfile, ProjectDefaultRateByTitle, ProjectDocument, ProjectDocumentLineItem, PunchList, PunchListAccess, PunchListItem, PunchListItemAssignment, PunchListItemAttachedEntity, PunchListItemAttachment, PunchListItemCheckListItem, PunchListPage, PunchListPageAccess, PunchListUserOrderHint, QrCode, RetainageItem, RevitEquipmentUnitChange, RevitImport, RevitValueChangedEvent, Role, Service, ServiceCosts, ServiceStorageHourly, SmartCode, SmartCodeTag, Subtask, SystemBroadcastChannel, SystemBroadcastChannelThrottle, SystemConfiguration, SystemEmailNotification, SystemEvent, SystemEventListener, SystemEventWorker, SystemGlobalVariables, SystemHealthCheck, SystemInAppNotification, SystemLog, SystemMutedTopic, SystemNotification, SystemPushNotification, SystemSubscriber, SystemSupportAccess, SystemSupportTeam, SystemTask, SystemTaskAttempt, SystemTaskAttemptAccess, SystemTemp, SystemTicket, SystemTicketAttachment, SystemTicketComment, SystemTicketCommentAttachment, SystemUserPushTokens, Tag, Task, TaxCategory, Ticket, TicketAttachment, TicketComment, TicketCommentAttachment, TimeActivity, TimeBankTransaction, UserMetadata, UserTimesheet, WeeklyTimesheet, WorkEstimation, WorkEstimationLineItem, WorkingPhase, WorkingPhaseBillingItemDailySummary, WorkingPhaseBillingItemLatestSummary, WorkingPhaseCategory, WorkingPhaseDailySummary, WorkingPhaseRoleRate, WorkingPhaseSummary } from './gen/index.js';
22
+ import 'moment';
23
+ import '@supabase-cache-helpers/postgrest-react-query';
24
+ import '@pol-studios/utils';
25
+ import '@supabase/storage-js';
26
+ import '@supabase/functions-js';
27
+ import '@supabase/postgrest-js';
28
+ import 'react-dropzone';
29
+ import 'react/jsx-runtime';
30
+ import '@supabase/supabase-js/dist/module/lib/types.js';
31
+
32
+ /**
33
+ * PowerSync Adapter
34
+ *
35
+ * Wraps the QueryExecutor to execute queries against PowerSync's local SQLite database.
36
+ * Implements the TableDataAdapter interface for use with the V3 data layer.
37
+ *
38
+ * This adapter provides offline-first data access by querying the local SQLite
39
+ * database that PowerSync keeps synchronized with Supabase.
40
+ */
41
+
42
+ /**
43
+ * Handler interface for PowerSync watch callbacks.
44
+ */
45
+ interface WatchHandler {
46
+ onResult: (results: {
47
+ rows?: {
48
+ _array: Record<string, unknown>[];
49
+ };
50
+ }) => void;
51
+ onError?: (error: Error) => void;
52
+ }
53
+ /**
54
+ * Options for PowerSync watch operations.
55
+ */
56
+ interface SQLWatchOptions {
57
+ signal?: AbortSignal;
58
+ tables?: string[];
59
+ throttleMs?: number;
60
+ }
61
+ /**
62
+ * Extended PowerSync database interface that includes watch functionality.
63
+ * This extends the base interface from the executor to add reactive query support.
64
+ *
65
+ * The watch method is optional to maintain backward compatibility with databases
66
+ * that don't support reactive queries. When not available, subscribe will fall
67
+ * back to polling.
68
+ */
69
+ interface PowerSyncDatabase {
70
+ getAll<T>(sql: string, params?: unknown[]): Promise<T[]>;
71
+ get<T>(sql: string, params?: unknown[]): Promise<T | null>;
72
+ execute(sql: string, params?: unknown[]): Promise<{
73
+ rowsAffected: number;
74
+ }>;
75
+ /**
76
+ * Watch a SQL query for changes.
77
+ * Executes the query and invokes the handler whenever the underlying data changes.
78
+ * Optional - if not available, subscribe will fall back to polling.
79
+ */
80
+ watch?(sql: string, parameters?: unknown[], handler?: WatchHandler, options?: SQLWatchOptions): void;
81
+ }
82
+ /**
83
+ * PowerSyncAdapter implements the TableDataAdapter interface by delegating
84
+ * all operations to the QueryExecutor.
85
+ *
86
+ * @example
87
+ * const adapter = createPowerSyncAdapter(powerSyncDb, schema);
88
+ *
89
+ * // Query with filtering and pagination
90
+ * const { data, count } = await adapter.query<EquipmentUnit>("EquipmentUnit", {
91
+ * where: { status: "active" },
92
+ * orderBy: [{ field: "name", direction: "asc" }],
93
+ * limit: 10
94
+ * });
95
+ *
96
+ * // Query with relations
97
+ * const { data } = await adapter.query<EquipmentUnitWithRelations>("EquipmentUnit", {
98
+ * select: "*, EquipmentFixture(*), ProjectDatabase(name)"
99
+ * });
100
+ */
101
+ declare class PowerSyncAdapter implements TableDataAdapter, CapableDataAdapter {
102
+ private db;
103
+ private schema;
104
+ /**
105
+ * Unique identifier for this adapter type
106
+ */
107
+ readonly name = "powersync";
108
+ /**
109
+ * Capabilities supported by this adapter
110
+ */
111
+ readonly capabilities: AdapterCapabilities;
112
+ /**
113
+ * The underlying query executor
114
+ */
115
+ private executor;
116
+ /**
117
+ * Create a new PowerSyncAdapter
118
+ *
119
+ * @param db - PowerSync database instance
120
+ * @param schema - Database schema for relationship resolution
121
+ */
122
+ constructor(db: PowerSyncDatabase, schema: DatabaseSchema);
123
+ /**
124
+ * Execute a query and return results with optional count for pagination.
125
+ *
126
+ * @param table - The table name to query
127
+ * @param options - Query options (select, where, orderBy, limit, offset)
128
+ * @returns Promise resolving to query results with optional count
129
+ */
130
+ query<T>(table: string, options?: QueryOptions): Promise<AdapterQueryResult<T>>;
131
+ /**
132
+ * Query a single record by ID.
133
+ *
134
+ * @param table - The table name to query
135
+ * @param id - The record ID
136
+ * @param options - Optional query options (mainly for select)
137
+ * @returns Promise resolving to the record or null if not found
138
+ */
139
+ queryById<T>(table: string, id: string, options?: Pick<QueryOptions, "select">): Promise<T | null>;
140
+ /**
141
+ * Subscribe to changes on a query using PowerSync's native watch() API.
142
+ *
143
+ * This uses PowerSync's reactive query watching which efficiently detects
144
+ * changes to the underlying data and re-executes the query only when needed.
145
+ *
146
+ * If the database doesn't support watch(), falls back to polling every 5 seconds.
147
+ *
148
+ * @param table - The table name to watch
149
+ * @param options - Query options to filter what to watch
150
+ * @param callback - Function called with updated data
151
+ * @returns Unsubscribe function
152
+ */
153
+ subscribe<T>(table: string, options: QueryOptions, callback: (data: T[]) => void): () => void;
154
+ /**
155
+ * Fallback polling-based subscription for databases that don't support watch().
156
+ *
157
+ * @internal
158
+ */
159
+ private subscribeWithPolling;
160
+ /**
161
+ * Insert a new record.
162
+ *
163
+ * @param table - The table name
164
+ * @param data - The data to insert
165
+ * @returns Promise resolving to the inserted record
166
+ */
167
+ insert<T>(table: string, data: Partial<T>): Promise<T>;
168
+ /**
169
+ * Update an existing record by ID.
170
+ *
171
+ * @param table - The table name
172
+ * @param id - The record ID to update
173
+ * @param data - The data to update
174
+ * @returns Promise resolving to the updated record
175
+ */
176
+ update<T>(table: string, id: string, data: Partial<T>): Promise<T>;
177
+ /**
178
+ * Upsert (insert or update) a record.
179
+ * If the record has an ID and exists, it will be updated.
180
+ * Otherwise, a new record will be inserted.
181
+ *
182
+ * @param table - The table name
183
+ * @param data - The data to upsert
184
+ * @returns Promise resolving to the upserted record
185
+ */
186
+ upsert<T>(table: string, data: Partial<T>): Promise<T>;
187
+ /**
188
+ * Delete a record by ID.
189
+ *
190
+ * @param table - The table name
191
+ * @param id - The record ID to delete
192
+ * @returns Promise that resolves when deletion is complete
193
+ */
194
+ delete(table: string, id: string): Promise<void>;
195
+ /**
196
+ * Get the underlying QueryExecutor for advanced use cases.
197
+ *
198
+ * This allows direct access to the executor for operations that
199
+ * may not be covered by the TableDataAdapter interface.
200
+ *
201
+ * @returns The QueryExecutor instance
202
+ */
203
+ getExecutor(): QueryExecutor;
204
+ /**
205
+ * Get the raw PowerSync database for advanced use cases.
206
+ *
207
+ * This allows direct SQL execution when the adapter methods
208
+ * are not sufficient.
209
+ *
210
+ * @returns The PowerSyncDatabase instance
211
+ */
212
+ getDatabase(): PowerSyncDatabase;
213
+ /**
214
+ * Get the database schema.
215
+ *
216
+ * @returns The DatabaseSchema used for relationship resolution
217
+ */
218
+ getSchema(): DatabaseSchema;
219
+ }
220
+ /**
221
+ * Create a new PowerSyncAdapter instance.
222
+ *
223
+ * This is the recommended way to create a PowerSyncAdapter as it provides
224
+ * a cleaner API and allows for future enhancements without breaking changes.
225
+ *
226
+ * @param db - PowerSync database instance
227
+ * @param schema - Database schema for relationship resolution
228
+ * @returns A new PowerSyncAdapter instance
229
+ *
230
+ * @example
231
+ * import { createPowerSyncAdapter } from "./adapters/powersync-adapter";
232
+ *
233
+ * const adapter = createPowerSyncAdapter(powerSyncDb, databaseSchema);
234
+ *
235
+ * // Use the adapter
236
+ * const { data } = await adapter.query("EquipmentUnit", {
237
+ * where: { status: "active" }
238
+ * });
239
+ */
240
+ declare function createPowerSyncAdapter(db: PowerSyncDatabase, schema: DatabaseSchema): PowerSyncAdapter;
241
+
242
+ /**
243
+ * V3 Data Layer Provider
244
+ *
245
+ * React context provider that initializes adapters, manages the PowerSync lifecycle,
246
+ * and provides context for all V3 hooks. This is the main entry point for the V3
247
+ * data layer in a React application.
248
+ */
249
+
250
+ /**
251
+ * Props for DataLayerProvider
252
+ */
253
+ interface DataLayerProviderProps {
254
+ /** Data layer configuration */
255
+ config: DataLayerConfig;
256
+ /** Children to render */
257
+ children: ReactNode;
258
+ /** Optional PowerSync database instance */
259
+ powerSyncInstance?: PowerSyncDatabase$1 | null;
260
+ /** Supabase client (required) */
261
+ supabaseClient: SupabaseClient;
262
+ /** React Query client (required) */
263
+ queryClient: QueryClient;
264
+ /** Callback when initialization completes */
265
+ onInitialized?: (context: DataLayerContextValue) => void;
266
+ /** Callback when error occurs */
267
+ onError?: (error: Error) => void;
268
+ }
269
+ /**
270
+ * Provider component for the V3 data layer.
271
+ *
272
+ * This provider:
273
+ * - Creates and manages the AdapterRegistry
274
+ * - Initializes the AdapterAutoDetector for backend selection
275
+ * - Sets up Supabase and PowerSync adapters
276
+ * - Tracks online/offline status
277
+ * - Provides context for all V3 hooks
278
+ *
279
+ * @example
280
+ * ```tsx
281
+ * import { DataLayerProvider } from "@pol-studios/db";
282
+ *
283
+ * function App() {
284
+ * return (
285
+ * <DataLayerProvider
286
+ * config={dataLayerConfig}
287
+ * supabaseClient={supabase}
288
+ * queryClient={queryClient}
289
+ * powerSyncInstance={powerSyncDb}
290
+ * >
291
+ * <YourApp />
292
+ * </DataLayerProvider>
293
+ * );
294
+ * }
295
+ * ```
296
+ */
297
+ declare function DataLayerProvider({ config, children, powerSyncInstance, supabaseClient, queryClient, onInitialized, onError, }: DataLayerProviderProps): JSX.Element;
298
+
299
+ /**
300
+ * Platform-aware network status utility
301
+ *
302
+ * Provides unified network connectivity detection for both web (browser)
303
+ * and React Native environments.
304
+ *
305
+ * - On React Native: Uses @react-native-community/netinfo
306
+ * - On Web: Uses navigator.onLine and window online/offline events
307
+ */
308
+ /**
309
+ * Check if we're running in React Native environment
310
+ */
311
+ declare function isReactNative(): boolean;
312
+ /**
313
+ * Get current online status
314
+ *
315
+ * @returns Promise resolving to true if online, false if offline
316
+ */
317
+ declare function getOnlineStatus(): Promise<boolean>;
318
+ /**
319
+ * Get current online status synchronously (browser only, RN returns cached/default)
320
+ * Use getOnlineStatus() for accurate cross-platform results
321
+ *
322
+ * @returns true if online (or unknown), false if offline
323
+ */
324
+ declare function getOnlineStatusSync(): boolean;
325
+ /**
326
+ * Subscribe to network status changes
327
+ *
328
+ * @param callback - Function called when online status changes
329
+ * @returns Unsubscribe function
330
+ */
331
+ declare function subscribeToNetworkChanges(callback: (isOnline: boolean) => void): () => void;
332
+ /**
333
+ * Initialize network monitoring (call early in app lifecycle)
334
+ * This pre-loads NetInfo on React Native for faster subsequent calls
335
+ */
336
+ declare function initializeNetworkMonitoring(): Promise<void>;
337
+
338
+ export { AdapterCapabilities, AdapterQueryResult, CapableDataAdapter, DataLayerConfig, DataLayerContextValue, DataLayerProvider, type DataLayerProviderProps, DatabaseSchema, PowerSyncAdapter, PowerSyncDatabase$1 as PowerSyncDatabase, QueryExecutor, QueryOptions, TableDataAdapter, createPowerSyncAdapter, getOnlineStatus, getOnlineStatusSync, initializeNetworkMonitoring, isReactNative, subscribeToNetworkChanges };