@pol-studios/db 1.0.18 → 1.0.19

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 (45) hide show
  1. package/dist/{chunk-ZFM6AGWV.js → chunk-2T6WTCP4.js} +56 -27
  2. package/dist/chunk-2T6WTCP4.js.map +1 -0
  3. package/dist/{chunk-XOPORVJG.js → chunk-R5B2XMN5.js} +6 -8
  4. package/dist/chunk-R5B2XMN5.js.map +1 -0
  5. package/dist/index.js +2 -2
  6. package/dist/index.native.js +2 -2
  7. package/dist/index.web.js +1 -1
  8. package/package.json +1 -1
  9. package/dist/DataLayerContext-ZmLPYR_s.d.ts +0 -825
  10. package/dist/EntityPermissions-DwFt4tUd.d.ts +0 -35
  11. package/dist/FilterConfig-Bt2Ek74z.d.ts +0 -99
  12. package/dist/UserMetadataContext-B8gVWGMl.d.ts +0 -35
  13. package/dist/UserMetadataContext-DntmpK41.d.ts +0 -33
  14. package/dist/auth/context.d.ts +0 -48
  15. package/dist/auth/guards.d.ts +0 -180
  16. package/dist/auth/hooks.d.ts +0 -312
  17. package/dist/auth/index.d.ts +0 -11
  18. package/dist/chunk-XOPORVJG.js.map +0 -1
  19. package/dist/chunk-ZFM6AGWV.js.map +0 -1
  20. package/dist/client/index.d.ts +0 -16
  21. package/dist/core/index.d.ts +0 -539
  22. package/dist/database.types-ChFCG-4M.d.ts +0 -8604
  23. package/dist/executor-CB4KHyYG.d.ts +0 -507
  24. package/dist/gen/index.d.ts +0 -1099
  25. package/dist/hooks/index.d.ts +0 -100
  26. package/dist/index-BNKhgDdC.d.ts +0 -433
  27. package/dist/index.d.ts +0 -33
  28. package/dist/index.native.d.ts +0 -773
  29. package/dist/index.web.d.ts +0 -321
  30. package/dist/mutation/index.d.ts +0 -58
  31. package/dist/parser/index.d.ts +0 -366
  32. package/dist/powersync-bridge/index.d.ts +0 -284
  33. package/dist/query/index.d.ts +0 -723
  34. package/dist/realtime/index.d.ts +0 -44
  35. package/dist/select-query-parser-BwyHum1L.d.ts +0 -352
  36. package/dist/setupAuthContext-Kv-THH-h.d.ts +0 -61
  37. package/dist/types/index.d.ts +0 -10
  38. package/dist/types-CYr9JiUE.d.ts +0 -62
  39. package/dist/useBatchUpsert-9OYjibLh.d.ts +0 -24
  40. package/dist/useDbCount-Id14x_1P.d.ts +0 -1082
  41. package/dist/useDbQuery-C-TL8jY1.d.ts +0 -19
  42. package/dist/useReceiptAI-6HkRpRml.d.ts +0 -58
  43. package/dist/useResolveFeedback-Ca2rh_Bs.d.ts +0 -997
  44. package/dist/useSupabase-DvWVuHHE.d.ts +0 -28
  45. package/dist/with-auth/index.d.ts +0 -704
@@ -1,773 +0,0 @@
1
- export { C as CompositeTypes, c as Constants, D as Database, E as Enums, J as Json, T as Tables, a as TablesInsert, b as TablesUpdate } from './database.types-ChFCG-4M.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 { r as BackendSelectionResult, B as BooleanOperator, l as ClarificationQuestion, k as ClarificationSuggestion, C as CombinedProviderStatus, j as ComputedSortConfig, n as DataLayerWithPowerSyncProps, D as DbChangeLog, a as EnhancedSyncControl, E as EnhancedSyncStatus, e as Filter, d as FilterConditionType, m as FilterContextType, f as FilterGroup, g as FilterInput, F as FilterOperator, h as FilterState, H as HasPowerSyncConfig, O as OrderColumn, i as Pagination, P as PowerSyncEnabledConfig, b as PowerSyncEnabledContextValue, q as PowerSyncTables, Q as QueryState, S as Sort, U as UseDataLayerWithPowerSync, p as UseSyncControlWithPowerSync, o as UseSyncStatusWithPowerSync, V as ValueOrArrayForPropertyType, c as createCombinedStatus, s as normalizeFilter, u as useDbAdvanceFilterQuery, u as useDbAdvanceQuery } from './index-BNKhgDdC.js';
4
- export { A as AIOptions, B as AIResponse, P as AlertProps, K as BUCKETS, L as BucketName, I as CustomPageQueryResult, N as DEFAULT_QUERY_TIMEOUT, a9 as FeedbackListItem, aa as FeedbackListParams, Q as LiveChangeContext, R as LiveChangeContextProvider, D as ServerAvailabilityState, J as StorageObjectMetadata, ac as SubmitFeedbackParams, S as SupabaseAdapter, T as TIMEOUT_ERROR_MESSAGE, G as UpdateOptions, U as UseDbPartialAdvanceQueryResult, p as UseDbPartialQueryResult, r as UseDbRealtimeQueryResult, v as UseMutationSuccessOptions, t as convertFilterToRealtimeQuery, M as createInCondition, y as createSupabaseAdapter, H as executeAdvanceQuery, z as getErrorBody, k as getSupabaseUrl, O as isTimeoutError, n as newTimeActivity, s as setSupabaseUrl, C as useAI, ad as useApplyFeedback, g as useAutosaveState, a4 as useChangelogById, a5 as useChangelogBySlug, a6 as useChangelogEntries, a7 as useChangelogMedia, a2 as useChangelogs, c as useDbDelete, a as useDbInsert, l as useDbMultiDelete, m as useDbMultiUpsert, o as useDbPartialAdvanceQuery, q as useDbPartialQuery, u as useDbRealtime, d as useDbRealtimeQuery, b as useDbUpdate, c as useDelete, W as useDeleteChangelog, Z as useDeleteChangelogEntry, a0 as useDeleteChangelogMedia, a8 as useFeedbackList, a as useInsert, f as useLatestOperationLog, e as useLiveChangeTracking, _ as useMultiDeleteChangelogEntries, Y as useMultiUpsertChangelogEntries, w as useMutationSuccess, x as useMutationSuccessRN, a3 as usePublishedChangelogs, u as useRealtime, d as useRealtimeQuery, ae as useResolveFeedback, F as useSearchQuery, E as useServerAvailability, j as useStoragePath, i as useStorageUrl, ab as useSubmitFeedback, h as useToastError, b as useUpdate, a1 as useUploadChangelogMedia, V as useUpsertChangelog, X as useUpsertChangelogEntry, $ as useUpsertChangelogMedia } from './useResolveFeedback-Ca2rh_Bs.js';
5
- export { F as Fetch, i as GenericFunction, g as GenericNonUpdatableView, j as GenericSchema, G as GenericTable, f as GenericUpdatableView, h as GenericView, P as PostgrestError, d as PostgrestMaybeSingleResponse, e as PostgrestResponse, b as PostgrestResponseFailure, a as PostgrestResponseSuccess, c as PostgrestSingleResponse, k as Prettify } from './types-CYr9JiUE.js';
6
- export { U as UseDbQuerySingleReturn, u as useDbQuery } from './useDbQuery-C-TL8jY1.js';
7
- import * as _tanstack_react_query from '@tanstack/react-query';
8
- import { QueryClient } from '@tanstack/react-query';
9
- import { FileOptions } from '@supabase/storage-js';
10
- export { D as DatabaseTypes, P as PublicTableNames, R as ResolveRowType, S as SchemaNames, l as SchemaTableNames, T as TableIdentifier, r as UseAdvanceQueryOptions, s as UseAdvanceQueryResult, n as UseDbCountOptions, o as UseDbCountResult, U as UseDbInfiniteQueryOptions, m as UseDbInfiniteQueryResult, q as UseDbQueryOptions, p as UseDbQueryResult, k as useAdvanceQuery, a as useDataLayer, j as useDbCount, j as useDbCountV3, d as useDbDeleteV3, i as useDbInfiniteQuery, i as useDbInfiniteQueryV3, e as useDbInsertV3, g as useDbQueryById, f as useDbQueryV3, h as useDbUpdateV3, u as useDbUpsert, u as useDbUpsertV3, u as useUpsert } from './useDbCount-Id14x_1P.js';
11
- export { useOnlineStatus, useSyncControl, useSyncStatus } from './hooks/index.js';
12
- export { u as useBatchDelete, a as useBatchUpsert } from './useBatchUpsert-9OYjibLh.js';
13
- import { DatabaseSchema, QueryOptions, DataLayerConfig } from './core/index.js';
14
- 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';
15
- export { UsePartialAdvancedQueryResult, UsePartialQueryResult, UseQuerySingleReturn, extractColumnNames, extractRelationNames, getRelationSelect, hasRelation, parseSelect, stringifySelect, tokenizeTopLevel, useAdvancedFilterQuery, useAdvancedQuery, useInfiniteQuery, usePartialAdvancedQuery, usePartialQuery, useQuery } from './query/index.js';
16
- import { Q as QueryExecutor, P as PowerSyncDatabase$1 } from './executor-CB4KHyYG.js';
17
- 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';
18
- import { T as TableDataAdapter, C as CapableDataAdapter, c as AdapterCapabilities, A as AdapterQueryResult, p as DataLayerContextValue, S as SyncStatusInfo } from './DataLayerContext-ZmLPYR_s.js';
19
- 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, D as DataLayerContext, n as DataLayerCoreContext, q as DataLayerCoreContextValue, s as DataLayerStatus, o as DataLayerStatusContext, r as DataLayerStatusContextValue, j as createAdapterAutoDetector, h as createAdapterRegistry } from './DataLayerContext-ZmLPYR_s.js';
20
- import * as react from 'react';
21
- import react__default, { ReactNode, JSX } from 'react';
22
- import { SupabaseClient } from '@supabase/supabase-js';
23
- export { C as ClientInstanceId, 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-DvWVuHHE.js';
24
- export { e as UserMetadataContextProvider, c as UserMetadataContextType, a as UserMetadataInsert, U as UserMetadataRow, b as UserMetadataUpdate, u as useLiveChangesIndicator, h as useSetUserMetadata, f as useUserMetadata, i as useUserMetadataState, g as useUserMetadataValue, d as userMetadataContext } from './UserMetadataContext-B8gVWGMl.js';
25
- import * as react_dropzone from 'react-dropzone';
26
- import { FileRejection, FileError } from 'react-dropzone';
27
- 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';
28
- export { G as GetResult, S as SelectQueryError } from './select-query-parser-BwyHum1L.js';
29
- 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';
30
- import * as react_jsx_runtime from 'react/jsx-runtime';
31
- import 'moment';
32
- import '@supabase-cache-helpers/postgrest-react-query';
33
- import '@pol-studios/utils';
34
- import '@supabase/functions-js';
35
- import '@supabase/postgrest-js';
36
- import '@supabase/supabase-js/dist/module/lib/types.js';
37
-
38
- type RequestOptions = {
39
- onUploadProgress?: (bytesUploaded: number, bytesTotal: number) => any;
40
- };
41
- declare function sanitizeStorageKey(path: string): string;
42
- declare function useDbAttachmentUpload(bucketId: string, options?: RequestOptions): _tanstack_react_query.UseMutationResult<{
43
- bucketId: string;
44
- path: string;
45
- contentType: string;
46
- }, Error, {
47
- directory?: string;
48
- fileName?: string;
49
- file: File | Blob | Pick<ReadableStreamDefaultReader, "read">;
50
- onUploadProgress?: (bytesUploaded: number, bytesTotal: number) => any;
51
- } & FileOptions, unknown>;
52
-
53
- /**
54
- * PowerSync Adapter
55
- *
56
- * Wraps the QueryExecutor to execute queries against PowerSync's local SQLite database.
57
- * Implements the TableDataAdapter interface for use with the V3 data layer.
58
- *
59
- * This adapter provides offline-first data access by querying the local SQLite
60
- * database that PowerSync keeps synchronized with Supabase.
61
- */
62
-
63
- /**
64
- * Handler interface for PowerSync watch callbacks.
65
- */
66
- interface WatchHandler {
67
- onResult: (results: {
68
- rows?: {
69
- _array: Record<string, unknown>[];
70
- };
71
- }) => void;
72
- onError?: (error: Error) => void;
73
- }
74
- /**
75
- * Options for PowerSync watch operations.
76
- */
77
- interface SQLWatchOptions {
78
- signal?: AbortSignal;
79
- tables?: string[];
80
- throttleMs?: number;
81
- }
82
- /**
83
- * Extended PowerSync database interface that includes watch functionality.
84
- * This extends the base interface from the executor to add reactive query support.
85
- *
86
- * The watch method is optional to maintain backward compatibility with databases
87
- * that don't support reactive queries. When not available, subscribe will fall
88
- * back to polling.
89
- */
90
- interface PowerSyncDatabase {
91
- getAll<T>(sql: string, params?: unknown[]): Promise<T[]>;
92
- get<T>(sql: string, params?: unknown[]): Promise<T | null>;
93
- execute(sql: string, params?: unknown[]): Promise<{
94
- rowsAffected: number;
95
- }>;
96
- /**
97
- * Watch a SQL query for changes.
98
- * Executes the query and invokes the handler whenever the underlying data changes.
99
- * Optional - if not available, subscribe will fall back to polling.
100
- */
101
- watch?(sql: string, parameters?: unknown[], handler?: WatchHandler, options?: SQLWatchOptions): void;
102
- }
103
- /**
104
- * PowerSyncAdapter implements the TableDataAdapter interface by delegating
105
- * all operations to the QueryExecutor.
106
- *
107
- * @example
108
- * const adapter = createPowerSyncAdapter(powerSyncDb, schema);
109
- *
110
- * // Query with filtering and pagination
111
- * const { data, count } = await adapter.query<EquipmentUnit>("EquipmentUnit", {
112
- * where: { status: "active" },
113
- * orderBy: [{ field: "name", direction: "asc" }],
114
- * limit: 10
115
- * });
116
- *
117
- * // Query with relations
118
- * const { data } = await adapter.query<EquipmentUnitWithRelations>("EquipmentUnit", {
119
- * select: "*, EquipmentFixture(*), ProjectDatabase(name)"
120
- * });
121
- */
122
- declare class PowerSyncAdapter implements TableDataAdapter, CapableDataAdapter {
123
- private db;
124
- private schema;
125
- /**
126
- * Unique identifier for this adapter type
127
- */
128
- readonly name = "powersync";
129
- /**
130
- * Capabilities supported by this adapter
131
- */
132
- readonly capabilities: AdapterCapabilities;
133
- /**
134
- * The underlying query executor
135
- */
136
- private executor;
137
- /**
138
- * Create a new PowerSyncAdapter
139
- *
140
- * @param db - PowerSync database instance
141
- * @param schema - Database schema for relationship resolution
142
- */
143
- constructor(db: PowerSyncDatabase, schema: DatabaseSchema);
144
- /**
145
- * Execute a query and return results with optional count for pagination.
146
- *
147
- * @param table - The table name to query
148
- * @param options - Query options (select, where, orderBy, limit, offset)
149
- * @returns Promise resolving to query results with optional count
150
- */
151
- query<T>(table: string, options?: QueryOptions): Promise<AdapterQueryResult<T>>;
152
- /**
153
- * Query a single record by ID.
154
- *
155
- * @param table - The table name to query
156
- * @param id - The record ID
157
- * @param options - Optional query options (mainly for select)
158
- * @returns Promise resolving to the record or null if not found
159
- */
160
- queryById<T>(table: string, id: string, options?: Pick<QueryOptions, "select">): Promise<T | null>;
161
- /**
162
- * Subscribe to changes on a query using PowerSync's native watch() API.
163
- *
164
- * This uses PowerSync's reactive query watching which efficiently detects
165
- * changes to the underlying data and re-executes the query only when needed.
166
- *
167
- * If the database doesn't support watch(), falls back to polling every 5 seconds.
168
- *
169
- * @param table - The table name to watch
170
- * @param options - Query options to filter what to watch
171
- * @param callback - Function called with updated data
172
- * @returns Unsubscribe function
173
- */
174
- subscribe<T>(table: string, options: QueryOptions, callback: (data: T[]) => void): () => void;
175
- /**
176
- * Fallback polling-based subscription for databases that don't support watch().
177
- *
178
- * @internal
179
- */
180
- private subscribeWithPolling;
181
- /**
182
- * Insert a new record.
183
- *
184
- * @param table - The table name
185
- * @param data - The data to insert
186
- * @returns Promise resolving to the inserted record
187
- */
188
- insert<T>(table: string, data: Partial<T>): Promise<T>;
189
- /**
190
- * Update an existing record by ID.
191
- *
192
- * @param table - The table name
193
- * @param id - The record ID to update
194
- * @param data - The data to update
195
- * @returns Promise resolving to the updated record
196
- */
197
- update<T>(table: string, id: string, data: Partial<T>): Promise<T>;
198
- /**
199
- * Upsert (insert or update) a record.
200
- * If the record has an ID and exists, it will be updated.
201
- * Otherwise, a new record will be inserted.
202
- *
203
- * @param table - The table name
204
- * @param data - The data to upsert
205
- * @returns Promise resolving to the upserted record
206
- */
207
- upsert<T>(table: string, data: Partial<T>): Promise<T>;
208
- /**
209
- * Delete a record by ID.
210
- *
211
- * @param table - The table name
212
- * @param id - The record ID to delete
213
- * @returns Promise that resolves when deletion is complete
214
- */
215
- delete(table: string, id: string): Promise<void>;
216
- /**
217
- * Get the underlying QueryExecutor for advanced use cases.
218
- *
219
- * This allows direct access to the executor for operations that
220
- * may not be covered by the TableDataAdapter interface.
221
- *
222
- * @returns The QueryExecutor instance
223
- */
224
- getExecutor(): QueryExecutor;
225
- /**
226
- * Get the raw PowerSync database for advanced use cases.
227
- *
228
- * This allows direct SQL execution when the adapter methods
229
- * are not sufficient.
230
- *
231
- * @returns The PowerSyncDatabase instance
232
- */
233
- getDatabase(): PowerSyncDatabase;
234
- /**
235
- * Get the database schema.
236
- *
237
- * @returns The DatabaseSchema used for relationship resolution
238
- */
239
- getSchema(): DatabaseSchema;
240
- }
241
- /**
242
- * Create a new PowerSyncAdapter instance.
243
- *
244
- * This is the recommended way to create a PowerSyncAdapter as it provides
245
- * a cleaner API and allows for future enhancements without breaking changes.
246
- *
247
- * @param db - PowerSync database instance
248
- * @param schema - Database schema for relationship resolution
249
- * @returns A new PowerSyncAdapter instance
250
- *
251
- * @example
252
- * import { createPowerSyncAdapter } from "./adapters/powersync-adapter";
253
- *
254
- * const adapter = createPowerSyncAdapter(powerSyncDb, databaseSchema);
255
- *
256
- * // Use the adapter
257
- * const { data } = await adapter.query("EquipmentUnit", {
258
- * where: { status: "active" }
259
- * });
260
- */
261
- declare function createPowerSyncAdapter(db: PowerSyncDatabase, schema: DatabaseSchema): PowerSyncAdapter;
262
-
263
- /**
264
- * V3 Data Layer Provider
265
- *
266
- * React context provider that initializes adapters, manages the PowerSync lifecycle,
267
- * and provides context for all V3 hooks. This is the main entry point for the V3
268
- * data layer in a React application.
269
- */
270
-
271
- /**
272
- * Props for DataLayerProvider
273
- */
274
- interface DataLayerProviderProps {
275
- /** Data layer configuration */
276
- config: DataLayerConfig;
277
- /** Children to render */
278
- children: ReactNode;
279
- /**
280
- * Optional PowerSync database instance.
281
- *
282
- * This accepts any object that implements the PowerSyncDatabase interface,
283
- * including the AbstractPowerSyncDatabase from @pol-studios/powersync.
284
- *
285
- * When using with @pol-studios/powersync, pass the `db` value from usePowerSync():
286
- * @example
287
- * ```tsx
288
- * // With @pol-studios/powersync
289
- * const { db, isReady } = usePowerSync();
290
- *
291
- * if (!isReady) return <Loading />;
292
- *
293
- * return (
294
- * <DataLayerProvider
295
- * config={config}
296
- * powerSyncInstance={db}
297
- * supabaseClient={supabase}
298
- * queryClient={queryClient}
299
- * >
300
- * {children}
301
- * </DataLayerProvider>
302
- * );
303
- * ```
304
- */
305
- powerSyncInstance?: PowerSyncDatabase$1 | null;
306
- /** Supabase client (required) */
307
- supabaseClient: SupabaseClient;
308
- /** React Query client (required) */
309
- queryClient: QueryClient;
310
- /** Callback when initialization completes */
311
- onInitialized?: (context: DataLayerContextValue) => void;
312
- /** Callback when error occurs */
313
- onError?: (error: Error) => void;
314
- /**
315
- * Current sync status from @pol-studios/powersync.
316
- * Pass the status object from useSyncStatus() hook.
317
- * When hasSynced is false and useOnlineUntilSynced is true (default),
318
- * queries will use Supabase until initial sync completes.
319
- */
320
- powerSyncSyncStatus?: SyncStatusInfo;
321
- }
322
- /**
323
- * Provider component for the V3 data layer.
324
- *
325
- * This provider:
326
- * - Creates and manages the AdapterRegistry
327
- * - Initializes the AdapterAutoDetector for backend selection
328
- * - Sets up Supabase and PowerSync adapters
329
- * - Tracks online/offline status
330
- * - Provides context for all V3 hooks
331
- *
332
- * @example
333
- * ```tsx
334
- * import { DataLayerProvider } from "@pol-studios/db";
335
- *
336
- * function App() {
337
- * return (
338
- * <DataLayerProvider
339
- * config={dataLayerConfig}
340
- * supabaseClient={supabase}
341
- * queryClient={queryClient}
342
- * powerSyncInstance={powerSyncDb}
343
- * >
344
- * <YourApp />
345
- * </DataLayerProvider>
346
- * );
347
- * }
348
- * ```
349
- */
350
- declare function DataLayerProvider({ config, children, powerSyncInstance, supabaseClient, queryClient, onInitialized, onError, powerSyncSyncStatus, }: DataLayerProviderProps): JSX.Element;
351
-
352
- interface FileWithPreview extends File {
353
- preview?: string;
354
- errors: readonly FileError[];
355
- }
356
- type UseSupabaseUploadOptions = {
357
- /**
358
- * Name of bucket to upload files to in your Supabase project
359
- */
360
- bucketName: string;
361
- /**
362
- * Folder to upload files to in the specified bucket within your Supabase project.
363
- *
364
- * Defaults to uploading files to the root of the bucket
365
- *
366
- * e.g If specified path is `test`, your file will be uploaded as `test/file_name`
367
- */
368
- path?: string;
369
- /**
370
- * Allowed MIME types for each file upload (e.g `image/png`, `text/html`, etc). Wildcards are also supported (e.g `image/*`).
371
- *
372
- * Defaults to allowing uploading of all MIME types.
373
- */
374
- allowedMimeTypes?: string[];
375
- /**
376
- * Maximum upload size of each file allowed in bytes. (e.g 1000 bytes = 1 KB)
377
- */
378
- maxFileSize?: number;
379
- /**
380
- * Maximum number of files allowed per upload.
381
- */
382
- maxFiles?: number;
383
- /**
384
- * The number of seconds the asset is cached in the browser and in the Supabase CDN.
385
- *
386
- * This is set in the Cache-Control: max-age=<seconds> header. Defaults to 3600 seconds.
387
- */
388
- cacheControl?: number;
389
- /**
390
- * When set to true, the file is overwritten if it exists.
391
- *
392
- * When set to false, an error is thrown if the object already exists. Defaults to `false`
393
- */
394
- upsert?: boolean;
395
- };
396
- type UseSupabaseUploadReturn = ReturnType<typeof useSupabaseUpload>;
397
- declare const useSupabaseUpload: (options: UseSupabaseUploadOptions) => {
398
- open: () => void;
399
- isFocused: boolean;
400
- isDragActive: boolean;
401
- isDragAccept: boolean;
402
- isDragReject: boolean;
403
- isFileDialogActive: boolean;
404
- acceptedFiles: readonly react_dropzone.FileWithPath[];
405
- fileRejections: readonly FileRejection[];
406
- rootRef: React.RefObject<HTMLElement>;
407
- inputRef: React.RefObject<HTMLInputElement>;
408
- getRootProps: <T extends react_dropzone.DropzoneRootProps>(props?: T) => T;
409
- getInputProps: <T extends react_dropzone.DropzoneInputProps>(props?: T) => T;
410
- files: FileWithPreview[];
411
- setFiles: react.Dispatch<react.SetStateAction<FileWithPreview[]>>;
412
- successes: string[];
413
- isSuccess: boolean;
414
- loading: boolean;
415
- errors: {
416
- name: string;
417
- message: string;
418
- }[];
419
- setErrors: react.Dispatch<react.SetStateAction<{
420
- name: string;
421
- message: string;
422
- }[]>>;
423
- onUpload: () => Promise<void>;
424
- maxFileSize: number;
425
- maxFiles: number;
426
- allowedMimeTypes: string[];
427
- };
428
-
429
- /**
430
- * Conflict Types for @pol-studios/db
431
- *
432
- * Canonical type definitions for conflict detection and resolution.
433
- * These types are shared between @pol-studios/db and @pol-studios/powersync.
434
- */
435
- /**
436
- * Represents a field-level conflict where both local and server changed the same field.
437
- */
438
- interface FieldConflict {
439
- /** The field name that has conflicting changes */
440
- field: string;
441
- /** The local (pending) value */
442
- localValue: unknown;
443
- /** The current server value */
444
- serverValue: unknown;
445
- /** User who made the server change (from AuditLog.changeBy) */
446
- changedBy: string | null;
447
- /** When the server change occurred (from AuditLog.changeAt) */
448
- changedAt: Date;
449
- }
450
- /**
451
- * Result of checking for conflicts between local changes and server state.
452
- */
453
- interface ConflictCheckResult {
454
- /** Whether any field conflicts were detected */
455
- hasConflict: boolean;
456
- /** List of field-level conflicts */
457
- conflicts: FieldConflict[];
458
- /** Fields that can safely sync (no server changes) */
459
- nonConflictingChanges: string[];
460
- /** The table name */
461
- table: string;
462
- /** The record ID */
463
- recordId: string;
464
- }
465
- /**
466
- * User's resolution choice for a conflict.
467
- */
468
- type ConflictResolution = {
469
- action: 'overwrite';
470
- } | {
471
- action: 'keep-server';
472
- } | {
473
- action: 'partial';
474
- fields: string[];
475
- };
476
-
477
- /**
478
- * Interface for ConflictBus from @pol-studios/powersync.
479
- * Defined here to avoid circular dependency between packages.
480
- */
481
- interface ConflictBusInterface {
482
- onConflict: (listener: (conflict: ConflictCheckResult) => void) => () => void;
483
- onResolution: (listener: (table: string, recordId: string, resolution: ConflictResolution) => void) => () => void;
484
- emitConflict: (conflict: ConflictCheckResult) => void;
485
- emitResolution: (table: string, recordId: string, resolution: ConflictResolution) => void;
486
- }
487
- /**
488
- * Context value provided to consumers.
489
- */
490
- interface ConflictContextValue {
491
- /** Current conflict state */
492
- pendingConflicts: ConflictCheckResult[];
493
- /** Add a conflict (called by connector) */
494
- addConflict: (conflict: ConflictCheckResult) => void;
495
- /** Resolve a single conflict by table and record ID */
496
- resolveConflict: (table: string, recordId: string, resolution: ConflictResolution) => void;
497
- /** Resolve all pending conflicts with the same resolution */
498
- resolveAll: (resolution: ConflictResolution) => void;
499
- /** Remove a conflict by table and record ID (after sync completes) */
500
- removeConflict: (table: string, recordId: string) => void;
501
- /** Get resolution for a specific table and record */
502
- getResolution: (table: string, recordId: string) => ConflictResolution | undefined;
503
- /** Clear all resolved conflicts from the resolutions map */
504
- clearResolved: () => void;
505
- /** Clear all conflicts (resolved and pending) */
506
- clearAll: () => void;
507
- /** Whether there are any pending conflicts */
508
- hasConflicts: boolean;
509
- }
510
- declare const ConflictContext: react__default.Context<ConflictContextValue>;
511
- interface ConflictProviderProps {
512
- children: react__default.ReactNode;
513
- /**
514
- * Optional: Event bus for receiving conflicts from the connector.
515
- * When provided, the provider will:
516
- * - Subscribe to conflict events and add them to state
517
- * - Emit resolution events when conflicts are resolved
518
- */
519
- conflictBus?: ConflictBusInterface;
520
- }
521
- /**
522
- * Provider component for conflict state management.
523
- *
524
- * Wrap your app with this provider to enable conflict detection and resolution.
525
- *
526
- * @example
527
- * ```tsx
528
- * <PowerSyncProvider connector={connector}>
529
- * <ConflictProvider>
530
- * <App />
531
- * </ConflictProvider>
532
- * </PowerSyncProvider>
533
- * ```
534
- */
535
- declare function ConflictProvider({ children, conflictBus }: ConflictProviderProps): react_jsx_runtime.JSX.Element;
536
-
537
- /**
538
- * Conflict State Hooks for @pol-studios/db
539
- *
540
- * Provides hooks for accessing and filtering conflict state.
541
- */
542
-
543
- /**
544
- * Hook to access the full conflict state and actions.
545
- *
546
- * @throws Error if used outside of ConflictProvider
547
- * @returns Full conflict context value
548
- *
549
- * @example
550
- * ```tsx
551
- * function ConflictManager() {
552
- * const { pendingConflicts, resolveAll, clearResolved } = useConflictState();
553
- *
554
- * return (
555
- * <View>
556
- * <Text>{pendingConflicts.length} conflicts pending</Text>
557
- * <Button onPress={() => resolveAll({ action: 'keep-server' })}>
558
- * Accept All Server Changes
559
- * </Button>
560
- * </View>
561
- * );
562
- * }
563
- * ```
564
- */
565
- declare function useConflictState(): ConflictContextValue;
566
- /**
567
- * Hook to get only pending conflicts (read-only).
568
- *
569
- * Use this when you only need to display conflicts without resolution actions.
570
- *
571
- * @returns Array of pending conflicts
572
- *
573
- * @example
574
- * ```tsx
575
- * function ConflictBadge() {
576
- * const conflicts = usePendingConflicts();
577
- * if (conflicts.length === 0) return null;
578
- * return <Badge count={conflicts.length} />;
579
- * }
580
- * ```
581
- */
582
- declare function usePendingConflicts(): ConflictCheckResult[];
583
- /**
584
- * Hook to check if there are any pending conflicts.
585
- *
586
- * Optimized for conditional rendering - only triggers re-render on boolean change.
587
- *
588
- * @returns True if there are pending conflicts
589
- *
590
- * @example
591
- * ```tsx
592
- * function App() {
593
- * const hasConflicts = useHasConflicts();
594
- * return (
595
- * <>
596
- * {hasConflicts && <ConflictBanner />}
597
- * <MainContent />
598
- * </>
599
- * );
600
- * }
601
- * ```
602
- */
603
- declare function useHasConflicts(): boolean;
604
- /**
605
- * Hook to get a specific conflict by table and record ID.
606
- *
607
- * Returns null if no conflict exists for the record.
608
- *
609
- * @param table - The table name
610
- * @param recordId - The record ID to look up
611
- * @returns The conflict for this record, or null
612
- *
613
- * @example
614
- * ```tsx
615
- * function RecordEditor({ table, recordId }: { table: string; recordId: string }) {
616
- * const conflict = useConflictForRecord(table, recordId);
617
- *
618
- * if (conflict) {
619
- * return <ConflictWarning conflict={conflict} />;
620
- * }
621
- *
622
- * return <EditForm recordId={recordId} />;
623
- * }
624
- * ```
625
- */
626
- declare function useConflictForRecord(table: string, recordId: string): ConflictCheckResult | null;
627
- /**
628
- * Hook to get conflicts filtered by table name.
629
- *
630
- * Useful for showing conflicts scoped to a specific entity type.
631
- *
632
- * @param table - The table name to filter by
633
- * @returns Conflicts for the specified table
634
- *
635
- * @example
636
- * ```tsx
637
- * function EquipmentConflicts() {
638
- * const conflicts = useConflictsForTable('EquipmentFixtureUnit');
639
- * return (
640
- * <FlatList
641
- * data={conflicts}
642
- * renderItem={({ item }) => <ConflictCard conflict={item} />}
643
- * />
644
- * );
645
- * }
646
- * ```
647
- */
648
- declare function useConflictsForTable(table: string): ConflictCheckResult[];
649
- /**
650
- * Hook to get conflict count by table.
651
- *
652
- * Returns a map of table names to conflict counts for summary display.
653
- *
654
- * @returns Map of table name to conflict count
655
- *
656
- * @example
657
- * ```tsx
658
- * function ConflictSummary() {
659
- * const countByTable = useConflictCountByTable();
660
- * return (
661
- * <View>
662
- * {Array.from(countByTable.entries()).map(([table, count]) => (
663
- * <Text key={table}>{table}: {count} conflicts</Text>
664
- * ))}
665
- * </View>
666
- * );
667
- * }
668
- * ```
669
- */
670
- declare function useConflictCountByTable(): Map<string, number>;
671
-
672
- /**
673
- * Conflict Resolution Hook for @pol-studios/db
674
- *
675
- * Provides methods for resolving individual conflicts.
676
- */
677
-
678
- /**
679
- * Return type for useConflictResolution hook.
680
- */
681
- interface UseConflictResolutionReturn {
682
- /** The conflict being resolved */
683
- conflict: ConflictCheckResult;
684
- /** Resolve with a specific resolution */
685
- resolve: (resolution: ConflictResolution) => void;
686
- /** Accept server changes, discard local */
687
- keepServer: () => void;
688
- /** Overwrite server with local changes */
689
- overwrite: () => void;
690
- /** Only sync fields that don't conflict */
691
- syncNonConflicting: () => void;
692
- /** Sync specific fields only */
693
- syncFields: (fields: string[]) => void;
694
- /** Check if a specific field has a conflict */
695
- hasFieldConflict: (field: string) => boolean;
696
- /** Get conflict info for a specific field */
697
- getFieldConflict: (field: string) => {
698
- localValue: unknown;
699
- serverValue: unknown;
700
- changedBy: string | null;
701
- changedAt: Date;
702
- } | null;
703
- }
704
- /**
705
- * Hook for resolving a specific conflict.
706
- *
707
- * Provides convenience methods for common resolution patterns.
708
- *
709
- * @param conflict - The conflict to resolve
710
- * @returns Resolution methods and utilities
711
- *
712
- * @example
713
- * ```tsx
714
- * function ConflictCard({ conflict }: { conflict: ConflictCheckResult }) {
715
- * const {
716
- * keepServer,
717
- * overwrite,
718
- * syncNonConflicting,
719
- * hasFieldConflict,
720
- * getFieldConflict,
721
- * } = useConflictResolution(conflict);
722
- *
723
- * return (
724
- * <Card>
725
- * <Text>Conflict on {conflict.table}</Text>
726
- * {conflict.conflicts.map(fc => (
727
- * <View key={fc.field}>
728
- * <Text>{fc.field}</Text>
729
- * <Text>Yours: {String(fc.localValue)}</Text>
730
- * <Text>Theirs: {String(fc.serverValue)} by {fc.changedBy}</Text>
731
- * </View>
732
- * ))}
733
- * <Button onPress={keepServer}>Keep Theirs</Button>
734
- * <Button onPress={overwrite}>Use Mine</Button>
735
- * <Button onPress={syncNonConflicting}>Sync Safe Fields Only</Button>
736
- * </Card>
737
- * );
738
- * }
739
- * ```
740
- */
741
- declare function useConflictResolution(conflict: ConflictCheckResult): UseConflictResolutionReturn;
742
- /**
743
- * Hook for bulk conflict resolution.
744
- *
745
- * Provides methods for resolving multiple conflicts at once.
746
- *
747
- * @returns Bulk resolution methods
748
- *
749
- * @example
750
- * ```tsx
751
- * function ConflictSummary() {
752
- * const conflicts = usePendingConflicts();
753
- * const { resolveAllKeepServer, resolveAllOverwrite } = useBulkConflictResolution();
754
- *
755
- * return (
756
- * <View>
757
- * <Text>{conflicts.length} conflicts</Text>
758
- * <Button onPress={resolveAllKeepServer}>Accept All Server Changes</Button>
759
- * <Button onPress={resolveAllOverwrite}>Overwrite All with Mine</Button>
760
- * </View>
761
- * );
762
- * }
763
- * ```
764
- */
765
- declare function useBulkConflictResolution(): {
766
- resolveAllKeepServer: () => void;
767
- resolveAllOverwrite: () => void;
768
- resolveAllSyncNonConflicting: () => void;
769
- clearResolved: () => void;
770
- conflictCount: number;
771
- };
772
-
773
- export { AdapterCapabilities, AdapterQueryResult, CapableDataAdapter, type ConflictCheckResult, ConflictContext, type ConflictContextValue, ConflictProvider, type ConflictProviderProps, type ConflictResolution, DataLayerConfig, DataLayerContextValue, DataLayerProvider, type DataLayerProviderProps, DatabaseSchema, type FieldConflict, PowerSyncAdapter, PowerSyncDatabase$1 as PowerSyncDatabase, QueryExecutor, QueryOptions, SyncStatusInfo, TableDataAdapter, type UseConflictResolutionReturn, type UseSupabaseUploadOptions, type UseSupabaseUploadReturn, createPowerSyncAdapter, sanitizeStorageKey, useBulkConflictResolution, useConflictCountByTable, useConflictForRecord, useConflictResolution, useConflictState, useConflictsForTable, useDbAttachmentUpload as useDbUpload, useHasConflicts, usePendingConflicts, useSupabaseUpload };