@pol-studios/db 1.0.0 → 1.0.1

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/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-CeUdM6kV.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 +6 -0
  22. package/dist/index-CMhJjgef.d.ts +1815 -0
  23. package/dist/index-DNv49L9u.d.ts +8780 -0
  24. package/dist/index.d.ts +1486 -0
  25. package/dist/index.js +10320 -7124
  26. package/dist/index.js.map +1 -1
  27. package/dist/mutation/index.d.ts +58 -0
  28. package/dist/mutation/index.js +4581 -76
  29. package/dist/mutation/index.js.map +1 -1
  30. package/dist/parser/index.d.ts +366 -0
  31. package/dist/parser/index.js +26 -26
  32. package/dist/parser/index.js.map +1 -1
  33. package/dist/query/index.d.ts +723 -0
  34. package/dist/query/index.js +13124 -10324
  35. package/dist/query/index.js.map +1 -1
  36. package/dist/realtime/index.d.ts +44 -0
  37. package/dist/realtime/index.js +13217 -9297
  38. package/dist/realtime/index.js.map +1 -1
  39. package/dist/select-query-parser-CGI40aOg.d.ts +352 -0
  40. package/dist/types/index.d.ts +6 -0
  41. package/dist/types-DjuX1XHy.d.ts +62 -0
  42. package/dist/useBatchUpsert-BHaIk9ID.d.ts +24 -0
  43. package/dist/useDbQuery-C-TL8jY1.d.ts +19 -0
  44. package/dist/useSupabase-DO9kQv2O.d.ts +27 -0
  45. package/package.json +28 -15
@@ -0,0 +1,1486 @@
1
+ import { u as useDbAdvanceFilterQuery, Q as QueryState, T as Tables, D as DbChangeLog } from './index-DNv49L9u.js';
2
+ export { B as BooleanOperator, l as ClarificationQuestion, k as ClarificationSuggestion, C as CompositeTypes, j as ComputedSortConfig, d as Constants, a as Database, E as Enums, f as Filter, e as FilterConditionType, m as FilterContextType, g as FilterGroup, h as FilterInput, F as FilterOperator, i as FilterState, J as Json, O as OrderColumn, P as Pagination, S as Sort, b as TablesInsert, c as TablesUpdate, V as ValueOrArrayForPropertyType, n as normalizeFilter } from './index-DNv49L9u.js';
3
+ 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';
4
+ import * as _tanstack_react_query from '@tanstack/react-query';
5
+ import { UseQueryOptions, UseMutationResult, QueryClient, UseMutationOptions } from '@tanstack/react-query';
6
+ import { D as Database } from './useSupabase-DO9kQv2O.js';
7
+ export { a as SupabaseDatabaseTypes, S 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-DO9kQv2O.js';
8
+ import { G as GetResult } from './select-query-parser-CGI40aOg.js';
9
+ export { S as SelectQueryError } from './select-query-parser-CGI40aOg.js';
10
+ import { G as GenericSchema, a as GenericTable } from './types-DjuX1XHy.js';
11
+ export { F as Fetch, k as GenericFunction, i as GenericNonUpdatableView, h as GenericUpdatableView, j as GenericView, b as PostgrestError, f as PostgrestMaybeSingleResponse, g as PostgrestResponse, d as PostgrestResponseFailure, c as PostgrestResponseSuccess, e as PostgrestSingleResponse, P as Prettify } from './types-DjuX1XHy.js';
12
+ import { useInsertMutation, useUpdateMutation } from '@supabase-cache-helpers/postgrest-react-query';
13
+ import { PostgrestSingleResponse, PostgrestError, RealtimePostgresChangesPayload, SupabaseClient } from '@supabase/supabase-js';
14
+ import * as react from 'react';
15
+ import { ReactNode, JSX } from 'react';
16
+ import { U as UseDbQuerySingleReturn } from './useDbQuery-C-TL8jY1.js';
17
+ export { u as useDbQuery } from './useDbQuery-C-TL8jY1.js';
18
+ import { ItemType as ItemType$6 } from '@pol-studios/utils';
19
+ import { FileOptions, TransformOptions } from '@supabase/storage-js';
20
+ export { u as useBatchDelete, a as useBatchUpsert } from './useBatchUpsert-BHaIk9ID.js';
21
+ import { DatabaseSchema, QueryOptions, DataLayerConfig } from './core/index.js';
22
+ 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';
23
+ export { UsePartialAdvancedQueryResult, UsePartialQueryResult, UseQuerySingleReturn, extractColumnNames, extractRelationNames, getRelationSelect, hasRelation, parseSelect, stringifySelect, tokenizeTopLevel, useAdvancedFilterQuery, useAdvancedQuery, useInfiniteQuery, usePartialAdvancedQuery, usePartialQuery, useQuery } from './query/index.js';
24
+ import { Q as QueryExecutor, P as PowerSyncDatabase$1 } from './executor-CB4KHyYG.js';
25
+ 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';
26
+ import { T as TableDataAdapter, C as CapableDataAdapter, A as AdapterCapabilities, a as AdapterQueryResult, D as DataLayerContextValue } from './index-CMhJjgef.js';
27
+ export { F as ADAPTER_STRATEGIES, I as AdapterAutoDetector, y as AdapterConfig, B as AdapterDependencies, z as AdapterFactory, G as AdapterRegistry, E as AdapterStrategyType, L as AutoDetectionResult, M as AutoDetectorOptions, N as BackendChangeListener, K as BackendStatus, O as DataLayerContext, Q as DataLayerStatus, n as DatabaseTypes, P as PublicTableNames, R as ResolveRowType, S as SchemaNames, o as SchemaTableNames, p as TableIdentifier, w as UseAdvanceQueryOptions, x as UseAdvanceQueryResult, r as UseDbCountOptions, s as UseDbCountResult, U as UseDbInfiniteQueryOptions, q as UseDbInfiniteQueryResult, v as UseDbQueryOptions, t as UseDbQueryResult, J as createAdapterAutoDetector, H as createAdapterRegistry, m as useAdvanceQuery, u as useDataLayer, l as useDbCount, l as useDbCountV3, b as useDbDeleteV3, k as useDbInfiniteQuery, k as useDbInfiniteQueryV3, c as useDbInsertV3, e as useDbQueryById, d as useDbQueryV3, f as useDbUpdateV3, g as useDbUpsertV3, h as useOnlineStatus, i as useSyncControl, j as useSyncStatus } from './index-CMhJjgef.js';
28
+ import { FunctionsResponse } from '@supabase/functions-js';
29
+ import * as _supabase_postgrest_js from '@supabase/postgrest-js';
30
+ import { PostgrestSingleResponse as PostgrestSingleResponse$1 } from '@supabase/postgrest-js';
31
+ import { Moment } from 'moment';
32
+ import * as react_dropzone from 'react-dropzone';
33
+ import { FileRejection, FileError } from 'react-dropzone';
34
+ 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';
35
+ 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';
36
+ import * as react_jsx_runtime from 'react/jsx-runtime';
37
+ import '@supabase/supabase-js/dist/module/lib/types.js';
38
+
39
+ declare function setSupabaseUrl(url: string): void;
40
+ declare function getSupabaseUrl(): string;
41
+
42
+ type ItemType$5<T> = T extends Array<infer U> ? U : T;
43
+ declare function useDbDelete<TableName extends string & keyof PublicSchema["Tables"], Table extends PublicSchema["Tables"][TableName], Schema extends keyof Database = "public", PublicSchema extends GenericSchema = Database[Extract<keyof Database, Schema>], Query extends string = "*", RelationName = unknown, Relationships = Table extends {
44
+ Relationships: infer R;
45
+ } ? R : unknown, RowResult extends object = GetResult<PublicSchema, Table["Row"], RelationName, Relationships, Query>>(relation: TableName | {
46
+ table: TableName;
47
+ schema: Schema;
48
+ }, primaryKeys?: (keyof ItemType$5<RowResult> & string)[]): _tanstack_react_query.UseMutationResult<RowResult, Error, Partial<RowResult>, unknown>;
49
+
50
+ type ItemType$4<T> = T extends Array<infer U> ? U : T;
51
+ type MutationOption$2 = Parameters<typeof useInsertMutation>[3];
52
+ declare function useDbInsert<TableName extends string & keyof PublicSchema["Tables"], Table extends PublicSchema["Tables"][TableName], Schema extends keyof Database = "public", ReturnQuery extends string | undefined = undefined, PublicSchema extends GenericSchema = Database[Extract<keyof Database, Schema>], RelationName = unknown, Relationships = Table extends {
53
+ Relationships: infer R;
54
+ } ? R : unknown, RowResult = ReturnQuery extends undefined ? null : GetResult<PublicSchema, Table["Row"], RelationName, Relationships, Extract<ReturnQuery, string>>, ResultInsert extends object = GetResult<PublicSchema, Table["Insert"], RelationName, Relationships, "*">>(relation: TableName | {
55
+ table: TableName;
56
+ schema: Schema;
57
+ }, primaryKeys?: (keyof (ItemType$4<RowResult> | any) & string)[], query?: ReturnQuery, mutationOption?: MutationOption$2 & {
58
+ crossOrganization?: boolean;
59
+ }): _tanstack_react_query.UseMutationResult<RowResult, Error, ResultInsert, unknown>;
60
+
61
+ type ItemType$3<T> = T extends Array<infer U> ? U : T;
62
+ declare function useDbMultiDelete<TableName extends string & keyof PublicSchema["Tables"], Table extends PublicSchema["Tables"][TableName], Schema extends keyof Database = "public", PublicSchema extends GenericSchema = Database[Extract<keyof Database, Schema>], Query extends string = "*", RelationName = unknown, Relationships = Table extends {
63
+ Relationships: infer R;
64
+ } ? R : unknown, RowResult extends object = Omit<GetResult<PublicSchema, Table["Update"], RelationName, Relationships, Query>, "id">>(relation: TableName | {
65
+ table: TableName;
66
+ schema: Schema;
67
+ }, primaryKeys?: (keyof ItemType$3<RowResult> & string)[]): _tanstack_react_query.UseMutationResult<RowResult, Error, RowResult | RowResult[], unknown>;
68
+
69
+ type ItemType$2<T> = T extends Array<infer U> ? U : T;
70
+ declare function useDbMultiUpsert<TableName extends string & keyof PublicSchema["Tables"], Table extends PublicSchema["Tables"][TableName], Schema extends keyof Database = "public", PublicSchema extends GenericSchema = Database[Extract<keyof Database, Schema>], Query extends string = "*", RelationName = unknown, Relationships = Table extends {
71
+ Relationships: infer R;
72
+ } ? R : unknown, RowResult extends object = GetResult<PublicSchema, Table["Row"], RelationName, Relationships, Query>, ResultInsert extends object = GetResult<PublicSchema, Table["Insert"], RelationName, Relationships, Query>, ResultUpdate extends object = Omit<GetResult<PublicSchema, Table["Update"], RelationName, Relationships, Query>, "id"> & {
73
+ id: any;
74
+ }>(relation: TableName | {
75
+ table: TableName;
76
+ schema: Schema;
77
+ }, primaryKeys?: (keyof (ItemType$2<RowResult> | any) & string)[], query?: string): _tanstack_react_query.UseMutationResult<RowResult[], Error, (ResultInsert | ResultUpdate)[], unknown>;
78
+
79
+ type UseDbPartialAdvanceQueryResult<T extends Record<string, any>> = ReturnType<typeof useDbPartialAdvanceQuery<T[]>>;
80
+ declare function useDbPartialAdvanceQuery<Result extends Record<string, any>[]>(query: PromiseLike<PostgrestSingleResponse<Result>>, itemCountPerPage: number, config?: Omit<UseQueryOptions<PostgrestSingleResponse<Result>>, "queryKey" | "queryFn"> & {
81
+ filterKey?: string;
82
+ timeout?: number;
83
+ }): [
84
+ ReturnType<typeof useDbAdvanceFilterQuery<Result>>[0] & {
85
+ currentPage: number;
86
+ setCurrentPage: (value: React.SetStateAction<number>) => void;
87
+ fetchNextPage: () => any;
88
+ fetchPreviousPage: () => any;
89
+ data: {
90
+ Items: Result;
91
+ CurrentPage: number;
92
+ ItemCount: number;
93
+ MaxCountPerPage: number;
94
+ PageCount: number;
95
+ };
96
+ pageCount: number;
97
+ hasNextPage: boolean;
98
+ hasPreviousPage: boolean;
99
+ count: number;
100
+ },
101
+ QueryState,
102
+ React.Dispatch<React.SetStateAction<QueryState>>
103
+ ];
104
+
105
+ type UseDbPartialQueryResult<T extends Record<string, any>> = ReturnType<typeof useDbPartialQuery<T[]>>;
106
+ declare function useDbPartialQuery<Result extends Record<string, any>[]>(query: PromiseLike<PostgrestSingleResponse<Result>>, itemCountPerPage: number, config?: Omit<UseQueryOptions<Result, PostgrestError>, "queryKey" | "queryFn">): {
107
+ fetchPreviousPage: () => void;
108
+ fetchNextPage: () => void;
109
+ currentPage: number;
110
+ setCurrentPage: react.Dispatch<react.SetStateAction<number>>;
111
+ data: {
112
+ Items: Result;
113
+ CurrentPage: number;
114
+ ItemCount: number;
115
+ MaxCountPerPage: number;
116
+ PageCount: number;
117
+ };
118
+ pageCount: number;
119
+ hasNextPage: boolean;
120
+ hasPreviousPage: boolean;
121
+ error: PostgrestError;
122
+ status: "error";
123
+ isError: true;
124
+ isPending: false;
125
+ isSuccess: false;
126
+ failureCount: number;
127
+ failureReason: PostgrestError;
128
+ isPaused: boolean;
129
+ isLoading: false;
130
+ isLoadingError: false;
131
+ isRefetchError: true;
132
+ isPlaceholderData: false;
133
+ dataUpdatedAt: number;
134
+ errorUpdatedAt: number;
135
+ errorUpdateCount: number;
136
+ isFetched: boolean;
137
+ isFetchedAfterMount: boolean;
138
+ isFetching: boolean;
139
+ isInitialLoading: boolean;
140
+ isRefetching: boolean;
141
+ isStale: boolean;
142
+ isEnabled: boolean;
143
+ fetchStatus: _tanstack_react_query.FetchStatus;
144
+ promise: Promise<Result>;
145
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PostgrestSingleResponse<Result>, PostgrestError>>;
146
+ count: number | null;
147
+ } | {
148
+ fetchPreviousPage: () => void;
149
+ fetchNextPage: () => void;
150
+ currentPage: number;
151
+ setCurrentPage: react.Dispatch<react.SetStateAction<number>>;
152
+ data: {
153
+ Items: Result;
154
+ CurrentPage: number;
155
+ ItemCount: number;
156
+ MaxCountPerPage: number;
157
+ PageCount: number;
158
+ };
159
+ pageCount: number;
160
+ hasNextPage: boolean;
161
+ hasPreviousPage: boolean;
162
+ error: null;
163
+ status: "success";
164
+ isError: false;
165
+ isPending: false;
166
+ isSuccess: true;
167
+ failureCount: number;
168
+ failureReason: PostgrestError;
169
+ isPaused: boolean;
170
+ isLoading: false;
171
+ isLoadingError: false;
172
+ isRefetchError: false;
173
+ isPlaceholderData: false;
174
+ dataUpdatedAt: number;
175
+ errorUpdatedAt: number;
176
+ errorUpdateCount: number;
177
+ isFetched: boolean;
178
+ isFetchedAfterMount: boolean;
179
+ isFetching: boolean;
180
+ isInitialLoading: boolean;
181
+ isRefetching: boolean;
182
+ isStale: boolean;
183
+ isEnabled: boolean;
184
+ fetchStatus: _tanstack_react_query.FetchStatus;
185
+ promise: Promise<Result>;
186
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PostgrestSingleResponse<Result>, PostgrestError>>;
187
+ count: number | null;
188
+ } | {
189
+ fetchPreviousPage: () => void;
190
+ fetchNextPage: () => void;
191
+ currentPage: number;
192
+ setCurrentPage: react.Dispatch<react.SetStateAction<number>>;
193
+ data: {
194
+ Items: Result;
195
+ CurrentPage: number;
196
+ ItemCount: number;
197
+ MaxCountPerPage: number;
198
+ PageCount: number;
199
+ };
200
+ pageCount: number;
201
+ hasNextPage: boolean;
202
+ hasPreviousPage: boolean;
203
+ error: PostgrestError;
204
+ status: "error";
205
+ isError: true;
206
+ isPending: false;
207
+ isSuccess: false;
208
+ failureCount: number;
209
+ failureReason: PostgrestError;
210
+ isPaused: boolean;
211
+ isLoading: false;
212
+ isLoadingError: true;
213
+ isRefetchError: false;
214
+ isPlaceholderData: false;
215
+ dataUpdatedAt: number;
216
+ errorUpdatedAt: number;
217
+ errorUpdateCount: number;
218
+ isFetched: boolean;
219
+ isFetchedAfterMount: boolean;
220
+ isFetching: boolean;
221
+ isInitialLoading: boolean;
222
+ isRefetching: boolean;
223
+ isStale: boolean;
224
+ isEnabled: boolean;
225
+ fetchStatus: _tanstack_react_query.FetchStatus;
226
+ promise: Promise<Result>;
227
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PostgrestSingleResponse<Result>, PostgrestError>>;
228
+ count: number | null;
229
+ } | {
230
+ fetchPreviousPage: () => void;
231
+ fetchNextPage: () => void;
232
+ currentPage: number;
233
+ setCurrentPage: react.Dispatch<react.SetStateAction<number>>;
234
+ data: {
235
+ Items: Result;
236
+ CurrentPage: number;
237
+ ItemCount: number;
238
+ MaxCountPerPage: number;
239
+ PageCount: number;
240
+ };
241
+ pageCount: number;
242
+ hasNextPage: boolean;
243
+ hasPreviousPage: boolean;
244
+ error: null;
245
+ status: "pending";
246
+ isError: false;
247
+ isPending: true;
248
+ isSuccess: false;
249
+ failureCount: number;
250
+ failureReason: PostgrestError;
251
+ isPaused: boolean;
252
+ isLoading: true;
253
+ isLoadingError: false;
254
+ isRefetchError: false;
255
+ isPlaceholderData: false;
256
+ dataUpdatedAt: number;
257
+ errorUpdatedAt: number;
258
+ errorUpdateCount: number;
259
+ isFetched: boolean;
260
+ isFetchedAfterMount: boolean;
261
+ isFetching: boolean;
262
+ isInitialLoading: boolean;
263
+ isRefetching: boolean;
264
+ isStale: boolean;
265
+ isEnabled: boolean;
266
+ fetchStatus: _tanstack_react_query.FetchStatus;
267
+ promise: Promise<Result>;
268
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PostgrestSingleResponse<Result>, PostgrestError>>;
269
+ count: number | null;
270
+ } | {
271
+ fetchPreviousPage: () => void;
272
+ fetchNextPage: () => void;
273
+ currentPage: number;
274
+ setCurrentPage: react.Dispatch<react.SetStateAction<number>>;
275
+ data: {
276
+ Items: Result;
277
+ CurrentPage: number;
278
+ ItemCount: number;
279
+ MaxCountPerPage: number;
280
+ PageCount: number;
281
+ };
282
+ pageCount: number;
283
+ hasNextPage: boolean;
284
+ hasPreviousPage: boolean;
285
+ error: null;
286
+ status: "pending";
287
+ isError: false;
288
+ isPending: true;
289
+ isSuccess: false;
290
+ failureCount: number;
291
+ failureReason: PostgrestError;
292
+ isPaused: boolean;
293
+ isLoading: boolean;
294
+ isLoadingError: false;
295
+ isRefetchError: false;
296
+ isPlaceholderData: false;
297
+ dataUpdatedAt: number;
298
+ errorUpdatedAt: number;
299
+ errorUpdateCount: number;
300
+ isFetched: boolean;
301
+ isFetchedAfterMount: boolean;
302
+ isFetching: boolean;
303
+ isInitialLoading: boolean;
304
+ isRefetching: boolean;
305
+ isStale: boolean;
306
+ isEnabled: boolean;
307
+ fetchStatus: _tanstack_react_query.FetchStatus;
308
+ promise: Promise<Result>;
309
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PostgrestSingleResponse<Result>, PostgrestError>>;
310
+ count: number | null;
311
+ } | {
312
+ fetchPreviousPage: () => void;
313
+ fetchNextPage: () => void;
314
+ currentPage: number;
315
+ setCurrentPage: react.Dispatch<react.SetStateAction<number>>;
316
+ data: {
317
+ Items: Result;
318
+ CurrentPage: number;
319
+ ItemCount: number;
320
+ MaxCountPerPage: number;
321
+ PageCount: number;
322
+ };
323
+ pageCount: number;
324
+ hasNextPage: boolean;
325
+ hasPreviousPage: boolean;
326
+ error: null;
327
+ status: "success";
328
+ isError: false;
329
+ isPending: false;
330
+ isSuccess: true;
331
+ failureCount: number;
332
+ failureReason: PostgrestError;
333
+ isPaused: boolean;
334
+ isLoading: false;
335
+ isLoadingError: false;
336
+ isRefetchError: false;
337
+ isPlaceholderData: true;
338
+ dataUpdatedAt: number;
339
+ errorUpdatedAt: number;
340
+ errorUpdateCount: number;
341
+ isFetched: boolean;
342
+ isFetchedAfterMount: boolean;
343
+ isFetching: boolean;
344
+ isInitialLoading: boolean;
345
+ isRefetching: boolean;
346
+ isStale: boolean;
347
+ isEnabled: boolean;
348
+ fetchStatus: _tanstack_react_query.FetchStatus;
349
+ promise: Promise<Result>;
350
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PostgrestSingleResponse<Result>, PostgrestError>>;
351
+ count: number | null;
352
+ };
353
+
354
+ declare function useDbRealtime(key: string, query: string, table: string | {
355
+ table: string;
356
+ schema: string;
357
+ }, primaryKeys: string[], options?: {
358
+ filter?: string;
359
+ enabled?: boolean;
360
+ onChange?: (payload: RealtimePostgresChangesPayload<{
361
+ [key: string]: any;
362
+ }>) => any;
363
+ }): "SUBSCRIBED" | "TIMED_OUT" | "CLOSED" | "CHANNEL_ERROR";
364
+
365
+ type ConfigurationOptions<T> = {
366
+ crossOrganization?: boolean;
367
+ };
368
+ type FilterOperator = "or" | "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "like" | "ilike" | "is" | "in" | "cs" | "cd" | "fts" | "plfts";
369
+ type ValueType = number | string | boolean | null | Date | object;
370
+ type FilterDefinition = {
371
+ path: string;
372
+ alias?: string;
373
+ operator: FilterOperator;
374
+ negate: boolean;
375
+ value: ValueType;
376
+ };
377
+ type FilterDefinitions = (FilterComposite | FilterDefinition)[];
378
+ type FilterComposite = {
379
+ or?: FilterDefinitions;
380
+ and?: FilterDefinitions;
381
+ };
382
+ type UseDbRealtimeQueryResult<T> = UseDbQuerySingleReturn<T> & {
383
+ realtimeStatus: "SUBSCRIBED" | "TIMED_OUT" | "CLOSED" | "CHANNEL_ERROR" | "Loading...";
384
+ isRealtimeConnected: boolean;
385
+ isRealtimeLoading: boolean;
386
+ };
387
+ type DataType = Record<string, any>;
388
+ declare function convertFilterToRealtimeQuery(filters: FilterDefinitions): string;
389
+ declare function useDbRealtimeQuery<Result extends DataType>(query: PromiseLike<PostgrestSingleResponse<Result>>, config?: Omit<UseQueryOptions<PostgrestSingleResponse<Result>>, "queryKey" | "queryFn"> & ConfigurationOptions<Result>, primaryKeys?: (keyof ItemType$6<Result> & string)[]): UseDbRealtimeQueryResult<Result>;
390
+
391
+ type ItemType$1<T> = T extends Array<infer U> ? U : T;
392
+ type MutationOption$1 = Parameters<typeof useUpdateMutation>[3];
393
+ declare function useDbUpdate<TableName extends string & keyof PublicSchema["Tables"], Table extends PublicSchema["Tables"][TableName], Schema extends keyof Database = "public", ReturnQuery extends string | undefined = undefined, PublicSchema extends GenericSchema = Database[Extract<keyof Database, Schema>], RelationName = unknown, Relationships = Table extends {
394
+ Relationships: infer R;
395
+ } ? R : unknown, RowResult = ReturnQuery extends undefined ? null : GetResult<PublicSchema, Table["Row"], RelationName, Relationships, Extract<ReturnQuery, string>>, ResultUpdate extends object = (Omit<GetResult<PublicSchema, Table["Update"], RelationName, Relationships, "*">, "id"> & {
396
+ id: number;
397
+ }) | Omit<GetResult<PublicSchema, Table["Update"], RelationName, Relationships, "*">, "id">>(relation: TableName | {
398
+ table: TableName;
399
+ schema: Schema;
400
+ }, primaryKeys?: (keyof (ItemType$1<RowResult> | any) & string)[], query?: ReturnQuery, mutationOption?: MutationOption$1 & {
401
+ crossOrganization?: boolean;
402
+ }): _tanstack_react_query.UseMutationResult<RowResult, Error, ResultUpdate, unknown>;
403
+
404
+ type RequestOptions = {
405
+ onUploadProgress?: (bytesUploaded: number, bytesTotal: number) => any;
406
+ };
407
+ declare function sanitizeStorageKey(path: string): string;
408
+ declare function useDbAttachmentUpload(bucketId: string, options?: RequestOptions): _tanstack_react_query.UseMutationResult<{
409
+ bucketId: string;
410
+ path: string;
411
+ contentType: string;
412
+ }, Error, {
413
+ directory?: string;
414
+ fileName?: string;
415
+ file: File | Blob | Pick<ReadableStreamDefaultReader, "read">;
416
+ onUploadProgress?: (bytesUploaded: number, bytesTotal: number) => any;
417
+ } & FileOptions, unknown>;
418
+
419
+ type ItemType<T> = T extends Array<infer U> ? U : T;
420
+ type MutationOption = Parameters<typeof useUpdateMutation>[3];
421
+ type useDbUpsertResponse = ReturnType<typeof useDbUpsert>;
422
+ declare function useDbUpsert<TableName extends string & keyof PublicSchema["Tables"], Table extends PublicSchema["Tables"][TableName], Schema extends keyof Database = "public", ReturnQuery extends string | undefined = undefined, PublicSchema extends GenericSchema = Database[Extract<keyof Database, Schema>], RelationName = unknown, Relationships = Table extends {
423
+ Relationships: infer R;
424
+ } ? R : unknown, RowResult = ReturnQuery extends undefined ? null : GetResult<PublicSchema, Table["Row"], RelationName, Relationships, Extract<ReturnQuery, string>>, ResultInsert extends object = Omit<GetResult<PublicSchema, Table["Insert"], RelationName, Relationships, "*">, "id">, ResultUpdate extends object = Omit<GetResult<PublicSchema, Table["Update"], RelationName, Relationships, "*">, "id"> & {
425
+ id?: any;
426
+ }>(relation: TableName | {
427
+ table: TableName;
428
+ schema: Schema;
429
+ }, primaryKeys?: (keyof (ItemType<RowResult> | any) & string)[], query?: ReturnQuery, mutationOption?: MutationOption & {
430
+ crossOrganization?: boolean;
431
+ }): _tanstack_react_query.UseMutationResult<RowResult, Error, ResultInsert | ResultUpdate, unknown>;
432
+
433
+ interface UseMutationSuccessOptions {
434
+ successMessage?: string;
435
+ entityName?: string;
436
+ enabled?: boolean;
437
+ onSuccess?: () => void;
438
+ }
439
+ /**
440
+ * Hook to automatically show success feedback after successful mutations
441
+ * Works with both React Native and Web platforms
442
+ */
443
+ declare function useMutationSuccess<TData, TError, TVariables>(mutation: UseMutationResult<TData, TError, TVariables>, options?: UseMutationSuccessOptions): UseMutationResult<TData, TError, TVariables>;
444
+ /**
445
+ * Hook for React Native that uses native toast/alert system
446
+ * @deprecated Use useMutationSuccess instead - it auto-detects platform
447
+ */
448
+ declare function useMutationSuccessRN<TData, TError, TVariables>(mutation: UseMutationResult<TData, TError, TVariables>, options?: UseMutationSuccessOptions): UseMutationResult<TData, TError, TVariables>;
449
+
450
+ /**
451
+ * V3 Data Layer - Supabase Adapter
452
+ *
453
+ * Implements the TableDataAdapter interface for direct Supabase/PostgREST queries.
454
+ * This adapter is used for online-only data access without local caching.
455
+ */
456
+
457
+ /**
458
+ * Adapter for querying Supabase directly via PostgREST API.
459
+ *
460
+ * This adapter:
461
+ * - Queries Supabase directly (no local caching)
462
+ * - Supports real-time subscriptions via Supabase Realtime
463
+ * - Works only when online
464
+ * - Uses Supabase's native select embedding for relations
465
+ *
466
+ * @example
467
+ * ```typescript
468
+ * const adapter = createSupabaseAdapter(supabaseClient, schema);
469
+ *
470
+ * // Query with relations
471
+ * const result = await adapter.query<Project>("projects", {
472
+ * select: "*, client:clients(*), tasks(*)",
473
+ * where: { status: "active" },
474
+ * orderBy: [{ field: "created_at", direction: "desc" }],
475
+ * limit: 10
476
+ * });
477
+ * ```
478
+ */
479
+ declare class SupabaseAdapter implements TableDataAdapter, CapableDataAdapter {
480
+ private supabase;
481
+ private schema;
482
+ readonly name = "supabase";
483
+ readonly capabilities: AdapterCapabilities;
484
+ constructor(supabase: SupabaseClient, schema: DatabaseSchema);
485
+ /**
486
+ * Parse a table identifier to extract schema and table name.
487
+ * Handles schema-qualified names like "core.Profile" -> { schema: "core", tableName: "Profile" }
488
+ *
489
+ * @param table - The table name, optionally schema-qualified (e.g., "users" or "core.Profile")
490
+ * @returns Object with schema (defaults to "public") and tableName
491
+ */
492
+ private parseTableIdentifier;
493
+ /**
494
+ * Execute a query and return results with optional count
495
+ *
496
+ * @param table - The table name to query
497
+ * @param options - Query options (select, where, orderBy, limit, offset)
498
+ * @returns Promise resolving to query results with optional count
499
+ */
500
+ query<T>(table: string, options: QueryOptions): Promise<AdapterQueryResult<T>>;
501
+ /**
502
+ * Query a single record by ID
503
+ *
504
+ * @param table - The table name to query
505
+ * @param id - The record ID
506
+ * @param options - Optional query options (mainly for select)
507
+ * @returns Promise resolving to the record or null if not found
508
+ */
509
+ queryById<T>(table: string, id: string, options?: Pick<QueryOptions, "select">): Promise<T | null>;
510
+ /**
511
+ * Insert a new record
512
+ *
513
+ * @param table - The table name
514
+ * @param data - The data to insert
515
+ * @returns Promise resolving to the inserted record
516
+ */
517
+ insert<T>(table: string, data: Partial<T>): Promise<T>;
518
+ /**
519
+ * Update an existing record by ID
520
+ *
521
+ * @param table - The table name
522
+ * @param id - The record ID to update
523
+ * @param data - The data to update
524
+ * @returns Promise resolving to the updated record
525
+ */
526
+ update<T>(table: string, id: string, data: Partial<T>): Promise<T>;
527
+ /**
528
+ * Upsert (insert or update) a record
529
+ *
530
+ * @param table - The table name
531
+ * @param data - The data to upsert
532
+ * @returns Promise resolving to the upserted record
533
+ */
534
+ upsert<T>(table: string, data: Partial<T>): Promise<T>;
535
+ /**
536
+ * Delete a record by ID
537
+ *
538
+ * @param table - The table name
539
+ * @param id - The record ID to delete
540
+ * @returns Promise that resolves when deletion is complete
541
+ */
542
+ delete(table: string, id: string): Promise<void>;
543
+ /**
544
+ * Subscribe to real-time changes on a query
545
+ *
546
+ * @param table - The table name to watch
547
+ * @param options - Query options to filter what to watch
548
+ * @param callback - Function called with updated data
549
+ * @returns Unsubscribe function
550
+ */
551
+ subscribe<T>(table: string, options: QueryOptions, callback: (data: T[]) => void): () => void;
552
+ /**
553
+ * Apply where clause filters to a Supabase query
554
+ *
555
+ * Converts WhereClause to Supabase filter methods:
556
+ * - Direct value: .eq(field, value)
557
+ * - { in: [...] }: .in(field, values)
558
+ * - { gt: n }: .gt(field, n)
559
+ * - { gte: n }: .gte(field, n)
560
+ * - { lt: n }: .lt(field, n)
561
+ * - { lte: n }: .lte(field, n)
562
+ * - { like: s }: .ilike(field, s)
563
+ * - { is: null }: .is(field, null)
564
+ * - { neq: v }: .neq(field, v) or .not(field, "is", null)
565
+ * - { notIn: [...] }: .not().in(field, values)
566
+ *
567
+ * @param query - The Supabase query builder
568
+ * @param where - The where clause to apply
569
+ * @returns The query with filters applied
570
+ */
571
+ private applyWhereClause;
572
+ }
573
+ /**
574
+ * Create a new SupabaseAdapter instance
575
+ *
576
+ * @param supabase - The Supabase client instance
577
+ * @param schema - The database schema definition
578
+ * @returns A new SupabaseAdapter instance
579
+ *
580
+ * @example
581
+ * ```typescript
582
+ * const adapter = createSupabaseAdapter(supabaseClient, databaseSchema);
583
+ * const projects = await adapter.query<Project>("projects", {
584
+ * where: { status: "active" }
585
+ * });
586
+ * ```
587
+ */
588
+ declare function createSupabaseAdapter(supabase: SupabaseClient, schema: DatabaseSchema): SupabaseAdapter;
589
+
590
+ /**
591
+ * PowerSync Adapter
592
+ *
593
+ * Wraps the QueryExecutor to execute queries against PowerSync's local SQLite database.
594
+ * Implements the TableDataAdapter interface for use with the V3 data layer.
595
+ *
596
+ * This adapter provides offline-first data access by querying the local SQLite
597
+ * database that PowerSync keeps synchronized with Supabase.
598
+ */
599
+
600
+ /**
601
+ * Handler interface for PowerSync watch callbacks.
602
+ */
603
+ interface WatchHandler {
604
+ onResult: (results: {
605
+ rows?: {
606
+ _array: Record<string, unknown>[];
607
+ };
608
+ }) => void;
609
+ onError?: (error: Error) => void;
610
+ }
611
+ /**
612
+ * Options for PowerSync watch operations.
613
+ */
614
+ interface SQLWatchOptions {
615
+ signal?: AbortSignal;
616
+ tables?: string[];
617
+ throttleMs?: number;
618
+ }
619
+ /**
620
+ * Extended PowerSync database interface that includes watch functionality.
621
+ * This extends the base interface from the executor to add reactive query support.
622
+ *
623
+ * The watch method is optional to maintain backward compatibility with databases
624
+ * that don't support reactive queries. When not available, subscribe will fall
625
+ * back to polling.
626
+ */
627
+ interface PowerSyncDatabase {
628
+ getAll<T>(sql: string, params?: unknown[]): Promise<T[]>;
629
+ get<T>(sql: string, params?: unknown[]): Promise<T | null>;
630
+ execute(sql: string, params?: unknown[]): Promise<{
631
+ rowsAffected: number;
632
+ }>;
633
+ /**
634
+ * Watch a SQL query for changes.
635
+ * Executes the query and invokes the handler whenever the underlying data changes.
636
+ * Optional - if not available, subscribe will fall back to polling.
637
+ */
638
+ watch?(sql: string, parameters?: unknown[], handler?: WatchHandler, options?: SQLWatchOptions): void;
639
+ }
640
+ /**
641
+ * PowerSyncAdapter implements the TableDataAdapter interface by delegating
642
+ * all operations to the QueryExecutor.
643
+ *
644
+ * @example
645
+ * const adapter = createPowerSyncAdapter(powerSyncDb, schema);
646
+ *
647
+ * // Query with filtering and pagination
648
+ * const { data, count } = await adapter.query<EquipmentUnit>("EquipmentUnit", {
649
+ * where: { status: "active" },
650
+ * orderBy: [{ field: "name", direction: "asc" }],
651
+ * limit: 10
652
+ * });
653
+ *
654
+ * // Query with relations
655
+ * const { data } = await adapter.query<EquipmentUnitWithRelations>("EquipmentUnit", {
656
+ * select: "*, EquipmentFixture(*), ProjectDatabase(name)"
657
+ * });
658
+ */
659
+ declare class PowerSyncAdapter implements TableDataAdapter, CapableDataAdapter {
660
+ private db;
661
+ private schema;
662
+ /**
663
+ * Unique identifier for this adapter type
664
+ */
665
+ readonly name = "powersync";
666
+ /**
667
+ * Capabilities supported by this adapter
668
+ */
669
+ readonly capabilities: AdapterCapabilities;
670
+ /**
671
+ * The underlying query executor
672
+ */
673
+ private executor;
674
+ /**
675
+ * Create a new PowerSyncAdapter
676
+ *
677
+ * @param db - PowerSync database instance
678
+ * @param schema - Database schema for relationship resolution
679
+ */
680
+ constructor(db: PowerSyncDatabase, schema: DatabaseSchema);
681
+ /**
682
+ * Execute a query and return results with optional count for pagination.
683
+ *
684
+ * @param table - The table name to query
685
+ * @param options - Query options (select, where, orderBy, limit, offset)
686
+ * @returns Promise resolving to query results with optional count
687
+ */
688
+ query<T>(table: string, options?: QueryOptions): Promise<AdapterQueryResult<T>>;
689
+ /**
690
+ * Query a single record by ID.
691
+ *
692
+ * @param table - The table name to query
693
+ * @param id - The record ID
694
+ * @param options - Optional query options (mainly for select)
695
+ * @returns Promise resolving to the record or null if not found
696
+ */
697
+ queryById<T>(table: string, id: string, options?: Pick<QueryOptions, "select">): Promise<T | null>;
698
+ /**
699
+ * Subscribe to changes on a query using PowerSync's native watch() API.
700
+ *
701
+ * This uses PowerSync's reactive query watching which efficiently detects
702
+ * changes to the underlying data and re-executes the query only when needed.
703
+ *
704
+ * If the database doesn't support watch(), falls back to polling every 5 seconds.
705
+ *
706
+ * @param table - The table name to watch
707
+ * @param options - Query options to filter what to watch
708
+ * @param callback - Function called with updated data
709
+ * @returns Unsubscribe function
710
+ */
711
+ subscribe<T>(table: string, options: QueryOptions, callback: (data: T[]) => void): () => void;
712
+ /**
713
+ * Fallback polling-based subscription for databases that don't support watch().
714
+ *
715
+ * @internal
716
+ */
717
+ private subscribeWithPolling;
718
+ /**
719
+ * Insert a new record.
720
+ *
721
+ * @param table - The table name
722
+ * @param data - The data to insert
723
+ * @returns Promise resolving to the inserted record
724
+ */
725
+ insert<T>(table: string, data: Partial<T>): Promise<T>;
726
+ /**
727
+ * Update an existing record by ID.
728
+ *
729
+ * @param table - The table name
730
+ * @param id - The record ID to update
731
+ * @param data - The data to update
732
+ * @returns Promise resolving to the updated record
733
+ */
734
+ update<T>(table: string, id: string, data: Partial<T>): Promise<T>;
735
+ /**
736
+ * Upsert (insert or update) a record.
737
+ * If the record has an ID and exists, it will be updated.
738
+ * Otherwise, a new record will be inserted.
739
+ *
740
+ * @param table - The table name
741
+ * @param data - The data to upsert
742
+ * @returns Promise resolving to the upserted record
743
+ */
744
+ upsert<T>(table: string, data: Partial<T>): Promise<T>;
745
+ /**
746
+ * Delete a record by ID.
747
+ *
748
+ * @param table - The table name
749
+ * @param id - The record ID to delete
750
+ * @returns Promise that resolves when deletion is complete
751
+ */
752
+ delete(table: string, id: string): Promise<void>;
753
+ /**
754
+ * Get the underlying QueryExecutor for advanced use cases.
755
+ *
756
+ * This allows direct access to the executor for operations that
757
+ * may not be covered by the TableDataAdapter interface.
758
+ *
759
+ * @returns The QueryExecutor instance
760
+ */
761
+ getExecutor(): QueryExecutor;
762
+ /**
763
+ * Get the raw PowerSync database for advanced use cases.
764
+ *
765
+ * This allows direct SQL execution when the adapter methods
766
+ * are not sufficient.
767
+ *
768
+ * @returns The PowerSyncDatabase instance
769
+ */
770
+ getDatabase(): PowerSyncDatabase;
771
+ /**
772
+ * Get the database schema.
773
+ *
774
+ * @returns The DatabaseSchema used for relationship resolution
775
+ */
776
+ getSchema(): DatabaseSchema;
777
+ }
778
+ /**
779
+ * Create a new PowerSyncAdapter instance.
780
+ *
781
+ * This is the recommended way to create a PowerSyncAdapter as it provides
782
+ * a cleaner API and allows for future enhancements without breaking changes.
783
+ *
784
+ * @param db - PowerSync database instance
785
+ * @param schema - Database schema for relationship resolution
786
+ * @returns A new PowerSyncAdapter instance
787
+ *
788
+ * @example
789
+ * import { createPowerSyncAdapter } from "./adapters/powersync-adapter";
790
+ *
791
+ * const adapter = createPowerSyncAdapter(powerSyncDb, databaseSchema);
792
+ *
793
+ * // Use the adapter
794
+ * const { data } = await adapter.query("EquipmentUnit", {
795
+ * where: { status: "active" }
796
+ * });
797
+ */
798
+ declare function createPowerSyncAdapter(db: PowerSyncDatabase, schema: DatabaseSchema): PowerSyncAdapter;
799
+
800
+ /**
801
+ * V3 Data Layer Provider
802
+ *
803
+ * React context provider that initializes adapters, manages the PowerSync lifecycle,
804
+ * and provides context for all V3 hooks. This is the main entry point for the V3
805
+ * data layer in a React application.
806
+ */
807
+
808
+ /**
809
+ * Props for DataLayerProvider
810
+ */
811
+ interface DataLayerProviderProps {
812
+ /** Data layer configuration */
813
+ config: DataLayerConfig;
814
+ /** Children to render */
815
+ children: ReactNode;
816
+ /** Optional PowerSync database instance */
817
+ powerSyncInstance?: PowerSyncDatabase$1 | null;
818
+ /** Supabase client (required) */
819
+ supabaseClient: SupabaseClient;
820
+ /** React Query client (required) */
821
+ queryClient: QueryClient;
822
+ /** Callback when initialization completes */
823
+ onInitialized?: (context: DataLayerContextValue) => void;
824
+ /** Callback when error occurs */
825
+ onError?: (error: Error) => void;
826
+ }
827
+ /**
828
+ * Provider component for the V3 data layer.
829
+ *
830
+ * This provider:
831
+ * - Creates and manages the AdapterRegistry
832
+ * - Initializes the AdapterAutoDetector for backend selection
833
+ * - Sets up Supabase and PowerSync adapters
834
+ * - Tracks online/offline status
835
+ * - Provides context for all V3 hooks
836
+ *
837
+ * @example
838
+ * ```tsx
839
+ * import { DataLayerProvider } from "@pol-studios/db";
840
+ *
841
+ * function App() {
842
+ * return (
843
+ * <DataLayerProvider
844
+ * config={dataLayerConfig}
845
+ * supabaseClient={supabase}
846
+ * queryClient={queryClient}
847
+ * powerSyncInstance={powerSyncDb}
848
+ * >
849
+ * <YourApp />
850
+ * </DataLayerProvider>
851
+ * );
852
+ * }
853
+ * ```
854
+ */
855
+ declare function DataLayerProvider({ config, children, powerSyncInstance, supabaseClient, queryClient, onInitialized, onError, }: DataLayerProviderProps): JSX.Element;
856
+
857
+ declare function useSupabaseFunction(): {
858
+ downloadFunctionResponse: (functionName: string, body?: any, name?: string) => Promise<void>;
859
+ };
860
+
861
+ declare function getErrorBody(response: FunctionsResponse<any>): Promise<any>;
862
+
863
+ interface AIOptions {
864
+ maxTokens?: number;
865
+ temperature?: number;
866
+ }
867
+ interface AIResponse {
868
+ success: boolean;
869
+ data?: {
870
+ response: string;
871
+ };
872
+ error?: string;
873
+ }
874
+ declare function useAI(): {
875
+ generate: (prompt: string, context: Record<string, any>, options?: AIOptions) => Promise<string>;
876
+ };
877
+
878
+ interface ExtractedReceipt {
879
+ merchantName: string;
880
+ transactionDate: string | null;
881
+ currency: string;
882
+ subtotal: number | null;
883
+ tax: number | null;
884
+ total: number;
885
+ lineItems: Array<{
886
+ description: string;
887
+ amount: number;
888
+ quantity: number | null;
889
+ suggestedCategory: string | null;
890
+ }>;
891
+ confidence: number;
892
+ notes: string | null;
893
+ }
894
+ interface PendingExpense {
895
+ id: string;
896
+ file: File;
897
+ status: "processing" | "ready" | "error" | "confirming";
898
+ extractedData: ExtractedReceipt | null;
899
+ error: string | null;
900
+ duplicateWarning?: {
901
+ existingExpenseId: number;
902
+ reason: string;
903
+ };
904
+ }
905
+ interface BatchAnalysisProgress {
906
+ total: number;
907
+ completed: number;
908
+ processing: string[];
909
+ }
910
+ interface RecentExpenseContext {
911
+ merchantName: string;
912
+ category: string | null;
913
+ amount: number;
914
+ }
915
+ interface UseReceiptAIOptions {
916
+ recentExpenses?: RecentExpenseContext[];
917
+ taxCategories?: Tables<"TaxCategory">[];
918
+ }
919
+ declare function useReceiptAI(options?: UseReceiptAIOptions): {
920
+ analyzeReceipt: (file: File) => Promise<ExtractedReceipt | null>;
921
+ analyzeMultipleReceipts: (files: File[], onProgress?: (progress: BatchAnalysisProgress) => void, onItemComplete?: (item: PendingExpense) => void) => Promise<PendingExpense[]>;
922
+ isAnalyzing: boolean;
923
+ batchProgress: BatchAnalysisProgress;
924
+ error: string;
925
+ extractedData: ExtractedReceipt;
926
+ reset: () => void;
927
+ };
928
+
929
+ interface ServerAvailabilityState {
930
+ isAvailable: boolean | null;
931
+ isChecking: boolean;
932
+ lastChecked: Date | null;
933
+ error: Error | null;
934
+ }
935
+ /**
936
+ * Hook to check if the Supabase server is available.
937
+ * Performs periodic health checks and provides availability state.
938
+ * Works without requiring Supabase context, making it safe to use at app initialization.
939
+ */
940
+ declare function useServerAvailability(options?: {
941
+ enabled?: boolean;
942
+ checkInterval?: number;
943
+ timeout?: number;
944
+ }): ServerAvailabilityState & {
945
+ checkAvailability: () => Promise<void>;
946
+ };
947
+
948
+ declare function useSearchQuery<Result>(baseQuery: PromiseLike<PostgrestSingleResponse$1<Result>>, searchText: string, columns: ((string & keyof Result) | string)[], options?: {
949
+ isOptional: boolean;
950
+ additionCondition: (string | undefined)[];
951
+ }): PromiseLike<PostgrestSingleResponse$1<Result>>;
952
+
953
+ type PublicSchema$2 = Database[Extract<keyof Database, "public">];
954
+ type TableRow<T> = T extends {
955
+ Row: infer R extends Record<string, unknown>;
956
+ } ? R : Record<string, unknown>;
957
+ declare function useLiveChangeTracking<Relation extends GenericTable, TableName extends string & keyof PublicSchema$2["Tables"], Table extends PublicSchema$2["Tables"][TableName] = PublicSchema$2["Tables"][TableName], Query extends string = "*", RelationName = unknown, Relationships = Table extends {
958
+ Relationships: infer R;
959
+ } ? R : unknown, TItem = GetResult<PublicSchema$2, TableRow<Table>, RelationName, Relationships, Query>>(tableName: TableName, item: TItem, action?: (updates: Partial<TItem>, changeLog: DbChangeLog) => any): DbChangeLog;
960
+
961
+ declare function useLatestOperationLog(tableName: string, recordId: number): UseDbQuerySingleReturn<unknown>;
962
+
963
+ type PublicSchema$1 = Database[Extract<keyof Database, "public">];
964
+ type TimeActivity = any;
965
+ declare function newTimeActivity(date: Moment): TimeActivity;
966
+ type AutosaveOptions<T> = UpdateOptions<T> & {
967
+ delay: number;
968
+ primaryKeys?: string[];
969
+ transformBeforeMutation?: (item: T) => Partial<T>;
970
+ };
971
+ type UpdateOptions<T> = Partial<UseMutationOptions<T, Error, T, unknown>> & {
972
+ updateCache?: boolean;
973
+ };
974
+ /**
975
+ * Hook for managing autosave state with proper entity switching support.
976
+ *
977
+ * This hook provides three main functions:
978
+ * 1. `updateValue` - For making changes to the current entity (with autosave)
979
+ * 2. `setNewEntity` - For switching to a completely different entity (saves previous entity first)
980
+ * 3. `setValue` - For setting a value without triggering autosave or change tracking
981
+ *
982
+ * @example
983
+ * ```tsx
984
+ * const [value, updateValue, mutation, setValue, setNewEntity] = useAutosaveState(
985
+ * 'time_activities',
986
+ * defaultTimeActivity,
987
+ * {
988
+ * delay: 500,
989
+ * transformBeforeMutation: (item) => omitFields(item, ['computedField', 'uiOnlyField'])
990
+ * }
991
+ * );
992
+ *
993
+ * // For making changes to current entity (autosaves after delay)
994
+ * updateValue(prev => ({ ...prev, description: 'New description' }));
995
+ *
996
+ * // For switching to a different entity (saves current entity first)
997
+ * setNewEntity(differentTimeActivity);
998
+ * ```
999
+ */
1000
+ declare function useAutosaveState<T extends TItem & {
1001
+ id: number;
1002
+ }, TableName extends string & keyof PublicSchema$1["Tables"] = any, Table extends PublicSchema$1["Tables"][TableName] = any, Query extends string = "*", RelationName = unknown, Relationships = Table extends {
1003
+ Relationships: infer R;
1004
+ } ? R : unknown, TItem = Omit<GetResult<PublicSchema$1, Table extends {
1005
+ Row: infer R;
1006
+ } ? R extends Record<string, unknown> ? R : any : any, RelationName, Relationships, Query>, "id"> & {
1007
+ id: number;
1008
+ }>(relation: TableName, defaultValue: T, options?: AutosaveOptions<T>): [
1009
+ T,
1010
+ React.Dispatch<React.SetStateAction<T>>,
1011
+ UseMutationResult<PostgrestSingleResponse<T>, Error, T, unknown>,
1012
+ React.Dispatch<React.SetStateAction<T>>,
1013
+ (newEntity: T) => void,
1014
+ () => Promise<void>
1015
+ ];
1016
+
1017
+ declare function useToastError<T>(mutation: useDbUpsertResponse): UseMutationResult<unknown, Error, object, unknown>;
1018
+
1019
+ declare function executeAdvanceQuery<Result>(supabase: any, query: PromiseLike<PostgrestSingleResponse<Result>>, filterLayer: QueryState): Promise<{
1020
+ data: any;
1021
+ count: number | null;
1022
+ error: any;
1023
+ }>;
1024
+
1025
+ type CustomPageQueryResult<T extends Record<string, any>[]> = ReturnType<typeof useDbPartialQuery<T>>;
1026
+
1027
+ type Attachment = {
1028
+ bucketId: string;
1029
+ path: string;
1030
+ };
1031
+ declare function useStorageUrl(): {
1032
+ fetchUrl: (entity: {
1033
+ bucketId: string;
1034
+ path: string;
1035
+ }, options?: {
1036
+ download?: string | boolean;
1037
+ transform?: TransformOptions;
1038
+ }) => Promise<string>;
1039
+ fetchUrls: (entities: Attachment[], options?: {
1040
+ download?: string | boolean;
1041
+ transform?: TransformOptions;
1042
+ }) => Promise<Map<string, string | undefined>>;
1043
+ prefetchImage: (entity: Attachment, options?: {
1044
+ download?: string | boolean;
1045
+ transform?: TransformOptions;
1046
+ }) => Promise<void>;
1047
+ fetchPublicUrl: (entity: {
1048
+ bucketId: string;
1049
+ path: string;
1050
+ }, options?: {
1051
+ download?: string | boolean;
1052
+ transform?: TransformOptions;
1053
+ }) => Promise<string>;
1054
+ expireCache: (entity: {
1055
+ bucketId: string;
1056
+ path: string;
1057
+ }) => Promise<void>;
1058
+ getCacheVersion: (entity: {
1059
+ bucketId: string;
1060
+ path: string;
1061
+ }) => number;
1062
+ subscribeToCacheVersion: (entity: {
1063
+ bucketId: string;
1064
+ path: string;
1065
+ }, callback: () => void) => () => void;
1066
+ };
1067
+
1068
+ interface FileWithPreview extends File {
1069
+ preview?: string;
1070
+ errors: readonly FileError[];
1071
+ }
1072
+ type UseSupabaseUploadOptions = {
1073
+ /**
1074
+ * Name of bucket to upload files to in your Supabase project
1075
+ */
1076
+ bucketName: string;
1077
+ /**
1078
+ * Folder to upload files to in the specified bucket within your Supabase project.
1079
+ *
1080
+ * Defaults to uploading files to the root of the bucket
1081
+ *
1082
+ * e.g If specified path is `test`, your file will be uploaded as `test/file_name`
1083
+ */
1084
+ path?: string;
1085
+ /**
1086
+ * Allowed MIME types for each file upload (e.g `image/png`, `text/html`, etc). Wildcards are also supported (e.g `image/*`).
1087
+ *
1088
+ * Defaults to allowing uploading of all MIME types.
1089
+ */
1090
+ allowedMimeTypes?: string[];
1091
+ /**
1092
+ * Maximum upload size of each file allowed in bytes. (e.g 1000 bytes = 1 KB)
1093
+ */
1094
+ maxFileSize?: number;
1095
+ /**
1096
+ * Maximum number of files allowed per upload.
1097
+ */
1098
+ maxFiles?: number;
1099
+ /**
1100
+ * The number of seconds the asset is cached in the browser and in the Supabase CDN.
1101
+ *
1102
+ * This is set in the Cache-Control: max-age=<seconds> header. Defaults to 3600 seconds.
1103
+ */
1104
+ cacheControl?: number;
1105
+ /**
1106
+ * When set to true, the file is overwritten if it exists.
1107
+ *
1108
+ * When set to false, an error is thrown if the object already exists. Defaults to `false`
1109
+ */
1110
+ upsert?: boolean;
1111
+ };
1112
+ type UseSupabaseUploadReturn = ReturnType<typeof useSupabaseUpload>;
1113
+ declare const useSupabaseUpload: (options: UseSupabaseUploadOptions) => {
1114
+ open: () => void;
1115
+ isFocused: boolean;
1116
+ isDragActive: boolean;
1117
+ isDragAccept: boolean;
1118
+ isDragReject: boolean;
1119
+ isFileDialogActive: boolean;
1120
+ acceptedFiles: readonly react_dropzone.FileWithPath[];
1121
+ fileRejections: readonly FileRejection[];
1122
+ rootRef: React.RefObject<HTMLElement>;
1123
+ inputRef: React.RefObject<HTMLInputElement>;
1124
+ getRootProps: <T extends react_dropzone.DropzoneRootProps>(props?: T) => T;
1125
+ getInputProps: <T extends react_dropzone.DropzoneInputProps>(props?: T) => T;
1126
+ files: FileWithPreview[];
1127
+ setFiles: react.Dispatch<react.SetStateAction<FileWithPreview[]>>;
1128
+ successes: string[];
1129
+ isSuccess: boolean;
1130
+ loading: boolean;
1131
+ errors: {
1132
+ name: string;
1133
+ message: string;
1134
+ }[];
1135
+ setErrors: react.Dispatch<react.SetStateAction<{
1136
+ name: string;
1137
+ message: string;
1138
+ }[]>>;
1139
+ onUpload: () => Promise<void>;
1140
+ maxFileSize: number;
1141
+ maxFiles: number;
1142
+ allowedMimeTypes: string[];
1143
+ };
1144
+
1145
+ /**
1146
+ * Metadata stored in storage.objects.metadata JSONB column
1147
+ */
1148
+ interface StorageObjectMetadata {
1149
+ processingStatus: "None" | "Processing" | "Error";
1150
+ contentType: string;
1151
+ contentHeight?: number;
1152
+ contentWidth?: number;
1153
+ originalFileName?: string;
1154
+ legacyAttachmentId?: number;
1155
+ }
1156
+ type UseStoragePathOptions = {
1157
+ /** Whether to fetch metadata from storage.objects (default: true) */
1158
+ fetchMetadata?: boolean;
1159
+ /** Transform options for the URL */
1160
+ transform?: {
1161
+ width?: number;
1162
+ height?: number;
1163
+ quality?: number;
1164
+ format?: "origin";
1165
+ };
1166
+ /** Whether to get a download URL */
1167
+ download?: string | boolean;
1168
+ };
1169
+ type UseStoragePathResult = {
1170
+ /** Signed URL for the storage object */
1171
+ url: string | null;
1172
+ /** Metadata from storage.objects.metadata JSONB */
1173
+ metadata: StorageObjectMetadata | null;
1174
+ /** Content type (from metadata or inferred from path) */
1175
+ contentType: string;
1176
+ /** Whether the URL or metadata is still loading */
1177
+ isLoading: boolean;
1178
+ /** Error if URL fetch failed */
1179
+ error: Error | null;
1180
+ };
1181
+ /**
1182
+ * Hook to get a signed URL and metadata for a storage path.
1183
+ * Replaces useAttachment for the path-based storage approach.
1184
+ *
1185
+ * @param storagePath - The path within the bucket (e.g., "14/abc-123.jpg")
1186
+ * @param bucketId - The storage bucket ID
1187
+ * @param options - Optional configuration
1188
+ *
1189
+ * @example
1190
+ * ```tsx
1191
+ * const { url, contentType, isLoading } = useStoragePath(
1192
+ * profile.profilePath,
1193
+ * 'attachments'
1194
+ * );
1195
+ *
1196
+ * if (isLoading) return <Spinner />;
1197
+ * return <img src={url} />;
1198
+ * ```
1199
+ */
1200
+ declare function useStoragePath(storagePath: string | undefined | null, bucketId: string, options?: UseStoragePathOptions): UseStoragePathResult;
1201
+
1202
+ /**
1203
+ * Storage bucket names for Supabase storage.
1204
+ * Use these constants when calling storage APIs.
1205
+ */
1206
+ declare const BUCKETS: {
1207
+ readonly AVATARS: "avatars";
1208
+ readonly FIXTURE_CATALOG_COVER: "fixture-catalog-cover";
1209
+ readonly FIXTURE_ATTACHMENTS: "fixture-attachments";
1210
+ readonly UNIT_DOCUMENTATION: "unit-documentation-attachments";
1211
+ readonly DATASHEETS: "datasheets";
1212
+ readonly PATTERNS: "patterns";
1213
+ readonly LOGOS: "logos";
1214
+ readonly RECEIPTS: "receipts";
1215
+ readonly TICKET_ATTACHMENTS: "ticket-attachment";
1216
+ readonly PROCESS_RESULTS: "process-results";
1217
+ readonly DATA_EXCHANGE_IMPORTS: "data-exchange-imports";
1218
+ readonly EMAIL_TEMPLATES: "email-templates";
1219
+ readonly EMAIL_TEMPLATES_ASSETS: "email-templates-assets";
1220
+ };
1221
+ type BucketName = (typeof BUCKETS)[keyof typeof BUCKETS];
1222
+
1223
+ declare function createInCondition(column: string, values: (string | number)[]): string;
1224
+
1225
+ /**
1226
+ * Platform-aware network status utility
1227
+ *
1228
+ * Provides unified network connectivity detection for both web (browser)
1229
+ * and React Native environments.
1230
+ *
1231
+ * - On React Native: Uses @react-native-community/netinfo
1232
+ * - On Web: Uses navigator.onLine and window online/offline events
1233
+ */
1234
+ /**
1235
+ * Check if we're running in React Native environment
1236
+ */
1237
+ declare function isReactNative(): boolean;
1238
+ /**
1239
+ * Get current online status
1240
+ *
1241
+ * @returns Promise resolving to true if online, false if offline
1242
+ */
1243
+ declare function getOnlineStatus(): Promise<boolean>;
1244
+ /**
1245
+ * Get current online status synchronously (browser only, RN returns cached/default)
1246
+ * Use getOnlineStatus() for accurate cross-platform results
1247
+ *
1248
+ * @returns true if online (or unknown), false if offline
1249
+ */
1250
+ declare function getOnlineStatusSync(): boolean;
1251
+ /**
1252
+ * Subscribe to network status changes
1253
+ *
1254
+ * @param callback - Function called when online status changes
1255
+ * @returns Unsubscribe function
1256
+ */
1257
+ declare function subscribeToNetworkChanges(callback: (isOnline: boolean) => void): () => void;
1258
+ /**
1259
+ * Initialize network monitoring (call early in app lifecycle)
1260
+ * This pre-loads NetInfo on React Native for faster subsequent calls
1261
+ */
1262
+ declare function initializeNetworkMonitoring(): Promise<void>;
1263
+
1264
+ declare const TIMEOUT_ERROR_MESSAGE = "Request timed out";
1265
+ declare const DEFAULT_QUERY_TIMEOUT = 15000;
1266
+ declare function isTimeoutError(error: Error | null | undefined): boolean;
1267
+
1268
+ interface AlertProps {
1269
+ title: string;
1270
+ description: string;
1271
+ }
1272
+ interface Context {
1273
+ lastModifiedUserName: string;
1274
+ changeLog: DbChangeLog;
1275
+ }
1276
+ declare const LiveChangeContext: react.Context<Context>;
1277
+ declare const LiveChangeContextProvider: ({ children, changeLog, }: {
1278
+ children: ReactNode;
1279
+ changeLog: DbChangeLog;
1280
+ }) => react_jsx_runtime.JSX.Element;
1281
+
1282
+ /**
1283
+ * Upsert a changelog (create or update)
1284
+ */
1285
+ declare const useUpsertChangelog: () => _tanstack_react_query.UseMutationResult<any, Error, Omit<any, "id"> | (Omit<any, "id"> & {
1286
+ id?: any;
1287
+ }), unknown>;
1288
+ /**
1289
+ * Delete a changelog
1290
+ * Note: Cascade delete will remove all associated entries and media
1291
+ */
1292
+ declare const useDeleteChangelog: () => _tanstack_react_query.UseMutationResult<any, Error, Partial<any>, unknown>;
1293
+ /**
1294
+ * Upsert a changelog entry (create or update)
1295
+ */
1296
+ declare const useUpsertChangelogEntry: () => _tanstack_react_query.UseMutationResult<any, Error, Omit<any, "id"> | (Omit<any, "id"> & {
1297
+ id?: any;
1298
+ }), unknown>;
1299
+ /**
1300
+ * Upsert multiple changelog entries at once
1301
+ */
1302
+ declare const useMultiUpsertChangelogEntries: () => _tanstack_react_query.UseMutationResult<any[], Error, any[], unknown>;
1303
+ /**
1304
+ * Delete a changelog entry
1305
+ * Note: Cascade delete will remove all associated media
1306
+ */
1307
+ declare const useDeleteChangelogEntry: () => _tanstack_react_query.UseMutationResult<any, Error, Partial<any>, unknown>;
1308
+ /**
1309
+ * Delete multiple changelog entries at once
1310
+ */
1311
+ declare const useMultiDeleteChangelogEntries: () => _tanstack_react_query.UseMutationResult<Omit<any, "id">, Error, Omit<any, "id"> | Omit<any, "id">[], unknown>;
1312
+ /**
1313
+ * Upsert changelog media (create or update)
1314
+ */
1315
+ declare const useUpsertChangelogMedia: () => _tanstack_react_query.UseMutationResult<any, Error, Omit<any, "id"> | (Omit<any, "id"> & {
1316
+ id?: any;
1317
+ }), unknown>;
1318
+ /**
1319
+ * Delete changelog media
1320
+ */
1321
+ declare const useDeleteChangelogMedia: () => _tanstack_react_query.UseMutationResult<any, Error, Partial<any>, unknown>;
1322
+ /**
1323
+ * Upload media file for changelog entry
1324
+ * Just returns a simple upload function - caller handles creating ChangelogMedia records
1325
+ */
1326
+ declare const useUploadChangelogMedia: () => {
1327
+ mutateAsync: () => Promise<{
1328
+ path: string;
1329
+ publicUrl: string;
1330
+ }>;
1331
+ };
1332
+
1333
+ /**
1334
+ * Fetch all changelogs with their entries and media
1335
+ * Ordered by release date (newest first)
1336
+ */
1337
+ declare const useChangelogs: (options?: {
1338
+ realtime?: boolean;
1339
+ }) => (Omit<_tanstack_react_query.QueryObserverRefetchErrorResult<any[], _supabase_postgrest_js.PostgrestError>, "refetch"> & Pick<_tanstack_react_query.UseQueryResult<_supabase_postgrest_js.PostgrestSingleResponse<any[]>, _supabase_postgrest_js.PostgrestError>, "refetch"> & Pick<_supabase_postgrest_js.PostgrestSingleResponse<any[]>, "count"> & {
1340
+ data: any[];
1341
+ count?: number | null;
1342
+ }) | (Omit<_tanstack_react_query.QueryObserverSuccessResult<any[], _supabase_postgrest_js.PostgrestError>, "refetch"> & Pick<_tanstack_react_query.UseQueryResult<_supabase_postgrest_js.PostgrestSingleResponse<any[]>, _supabase_postgrest_js.PostgrestError>, "refetch"> & Pick<_supabase_postgrest_js.PostgrestSingleResponse<any[]>, "count"> & {
1343
+ data: any[];
1344
+ count?: number | null;
1345
+ }) | (Omit<_tanstack_react_query.QueryObserverLoadingErrorResult<any[], _supabase_postgrest_js.PostgrestError>, "refetch"> & Pick<_tanstack_react_query.UseQueryResult<_supabase_postgrest_js.PostgrestSingleResponse<any[]>, _supabase_postgrest_js.PostgrestError>, "refetch"> & Pick<_supabase_postgrest_js.PostgrestSingleResponse<any[]>, "count"> & {
1346
+ data: any[];
1347
+ count?: number | null;
1348
+ }) | (Omit<_tanstack_react_query.QueryObserverPendingResult<any[], _supabase_postgrest_js.PostgrestError>, "refetch"> & Pick<_tanstack_react_query.UseQueryResult<_supabase_postgrest_js.PostgrestSingleResponse<any[]>, _supabase_postgrest_js.PostgrestError>, "refetch"> & Pick<_supabase_postgrest_js.PostgrestSingleResponse<any[]>, "count"> & {
1349
+ data: any[];
1350
+ count?: number | null;
1351
+ }) | (Omit<_tanstack_react_query.QueryObserverPlaceholderResult<any[], _supabase_postgrest_js.PostgrestError>, "refetch"> & Pick<_tanstack_react_query.UseQueryResult<_supabase_postgrest_js.PostgrestSingleResponse<any[]>, _supabase_postgrest_js.PostgrestError>, "refetch"> & Pick<_supabase_postgrest_js.PostgrestSingleResponse<any[]>, "count"> & {
1352
+ data: any[];
1353
+ count?: number | null;
1354
+ });
1355
+ /**
1356
+ * Fetch published changelogs only
1357
+ */
1358
+ declare const usePublishedChangelogs: (options?: {
1359
+ realtime?: boolean;
1360
+ }) => (Omit<_tanstack_react_query.QueryObserverRefetchErrorResult<any[], _supabase_postgrest_js.PostgrestError>, "refetch"> & Pick<_tanstack_react_query.UseQueryResult<_supabase_postgrest_js.PostgrestSingleResponse<any[]>, _supabase_postgrest_js.PostgrestError>, "refetch"> & Pick<_supabase_postgrest_js.PostgrestSingleResponse<any[]>, "count"> & {
1361
+ data: any[];
1362
+ count?: number | null;
1363
+ }) | (Omit<_tanstack_react_query.QueryObserverSuccessResult<any[], _supabase_postgrest_js.PostgrestError>, "refetch"> & Pick<_tanstack_react_query.UseQueryResult<_supabase_postgrest_js.PostgrestSingleResponse<any[]>, _supabase_postgrest_js.PostgrestError>, "refetch"> & Pick<_supabase_postgrest_js.PostgrestSingleResponse<any[]>, "count"> & {
1364
+ data: any[];
1365
+ count?: number | null;
1366
+ }) | (Omit<_tanstack_react_query.QueryObserverLoadingErrorResult<any[], _supabase_postgrest_js.PostgrestError>, "refetch"> & Pick<_tanstack_react_query.UseQueryResult<_supabase_postgrest_js.PostgrestSingleResponse<any[]>, _supabase_postgrest_js.PostgrestError>, "refetch"> & Pick<_supabase_postgrest_js.PostgrestSingleResponse<any[]>, "count"> & {
1367
+ data: any[];
1368
+ count?: number | null;
1369
+ }) | (Omit<_tanstack_react_query.QueryObserverPendingResult<any[], _supabase_postgrest_js.PostgrestError>, "refetch"> & Pick<_tanstack_react_query.UseQueryResult<_supabase_postgrest_js.PostgrestSingleResponse<any[]>, _supabase_postgrest_js.PostgrestError>, "refetch"> & Pick<_supabase_postgrest_js.PostgrestSingleResponse<any[]>, "count"> & {
1370
+ data: any[];
1371
+ count?: number | null;
1372
+ }) | (Omit<_tanstack_react_query.QueryObserverPlaceholderResult<any[], _supabase_postgrest_js.PostgrestError>, "refetch"> & Pick<_tanstack_react_query.UseQueryResult<_supabase_postgrest_js.PostgrestSingleResponse<any[]>, _supabase_postgrest_js.PostgrestError>, "refetch"> & Pick<_supabase_postgrest_js.PostgrestSingleResponse<any[]>, "count"> & {
1373
+ data: any[];
1374
+ count?: number | null;
1375
+ });
1376
+ /**
1377
+ * Fetch a single changelog by ID
1378
+ */
1379
+ declare const useChangelogById: (id: string | undefined) => UseDbQuerySingleReturn<any>;
1380
+ /**
1381
+ * Fetch a single changelog by slug
1382
+ */
1383
+ declare const useChangelogBySlug: (slug: string | undefined) => UseDbQuerySingleReturn<any>;
1384
+ /**
1385
+ * Fetch changelog entries for a specific changelog
1386
+ */
1387
+ declare const useChangelogEntries: (changelogId: string | undefined) => UseDbQuerySingleReturn<any[]>;
1388
+ /**
1389
+ * Fetch media for a specific changelog entry
1390
+ */
1391
+ declare const useChangelogMedia: (entryId: string | undefined) => UseDbQuerySingleReturn<any[]>;
1392
+
1393
+ interface FeedbackListItem {
1394
+ id: number;
1395
+ userId: string | null;
1396
+ table: string | null;
1397
+ schema: string;
1398
+ memoryType: string;
1399
+ resolved: boolean;
1400
+ resolvedAt: string | null;
1401
+ resolvedBy: string | null;
1402
+ createdAt: string;
1403
+ updatedAt: string;
1404
+ data: {
1405
+ query: string;
1406
+ queryHash?: string;
1407
+ status?: "success" | "failure" | "needs_review" | "cache_hit";
1408
+ statusMessage?: string;
1409
+ confidence?: number;
1410
+ filters?: any;
1411
+ sql?: string;
1412
+ sqlError?: string;
1413
+ agentDecisions?: any;
1414
+ context?: any;
1415
+ trace?: any;
1416
+ corrections?: {
1417
+ domainTerm?: string;
1418
+ domainFieldPath?: string;
1419
+ fieldPath?: string;
1420
+ filters?: any;
1421
+ };
1422
+ feedback?: string;
1423
+ modelUsed?: string;
1424
+ reasoningEffort?: "minimal" | "medium" | "high";
1425
+ performance?: any;
1426
+ resultCount?: number;
1427
+ };
1428
+ }
1429
+ interface FeedbackListParams {
1430
+ resolved?: boolean;
1431
+ status?: string;
1432
+ limit?: number;
1433
+ offset?: number;
1434
+ userId?: string;
1435
+ startDate?: string;
1436
+ endDate?: string;
1437
+ }
1438
+ declare function useFeedbackList(params?: FeedbackListParams): _tanstack_react_query.UseQueryResult<{
1439
+ success: boolean;
1440
+ data: FeedbackListItem[];
1441
+ pagination: {
1442
+ limit: number;
1443
+ offset: number;
1444
+ total: number;
1445
+ };
1446
+ }, Error>;
1447
+
1448
+ interface SubmitFeedbackParams {
1449
+ memoryId?: number;
1450
+ query: string;
1451
+ table: string;
1452
+ schema?: string;
1453
+ status?: "success" | "failure" | "needs_review";
1454
+ corrections?: {
1455
+ domainTerm?: string;
1456
+ domainFieldPath?: string;
1457
+ fieldPath?: string;
1458
+ filters?: any;
1459
+ };
1460
+ feedback?: string;
1461
+ }
1462
+ declare function useSubmitFeedback(): _tanstack_react_query.UseMutationResult<{
1463
+ success: boolean;
1464
+ data: any;
1465
+ }, Error, SubmitFeedbackParams, unknown>;
1466
+
1467
+ declare function useApplyFeedback(): _tanstack_react_query.UseMutationResult<{
1468
+ success: boolean;
1469
+ data: any;
1470
+ learningResults: Array<{
1471
+ type: string;
1472
+ id: number;
1473
+ action: string;
1474
+ }>;
1475
+ }, Error, number, unknown>;
1476
+
1477
+ declare function useResolveFeedback(): _tanstack_react_query.UseMutationResult<{
1478
+ success: boolean;
1479
+ data: any;
1480
+ learningResults: Array<{
1481
+ type: string;
1482
+ id: number;
1483
+ }>;
1484
+ }, Error, number, unknown>;
1485
+
1486
+ export { type AIOptions, type AIResponse, AdapterCapabilities, AdapterQueryResult, type AlertProps, BUCKETS, type BatchAnalysisProgress, type BucketName, CapableDataAdapter, type CustomPageQueryResult, DEFAULT_QUERY_TIMEOUT, DataLayerConfig, DataLayerContextValue, DataLayerProvider, type DataLayerProviderProps, DatabaseSchema, DbChangeLog, type ExtractedReceipt, type FeedbackListItem, type FeedbackListParams, GenericSchema, GenericTable, GetResult, LiveChangeContext, LiveChangeContextProvider, type MutationOption, type PendingExpense, PowerSyncAdapter, PowerSyncDatabase$1 as PowerSyncDatabase, QueryExecutor, QueryOptions, QueryState, type ServerAvailabilityState, type StorageObjectMetadata, type SubmitFeedbackParams, SupabaseAdapter, TIMEOUT_ERROR_MESSAGE, TableDataAdapter, Tables, type UpdateOptions, type UseDbPartialAdvanceQueryResult, type UseDbPartialQueryResult, UseDbQuerySingleReturn, type UseDbRealtimeQueryResult, type UseMutationSuccessOptions, type UseSupabaseUploadOptions, type UseSupabaseUploadReturn, convertFilterToRealtimeQuery, createInCondition, createPowerSyncAdapter, createSupabaseAdapter, executeAdvanceQuery, getErrorBody, getOnlineStatus, getOnlineStatusSync, getSupabaseUrl, initializeNetworkMonitoring, isReactNative, isTimeoutError, newTimeActivity, sanitizeStorageKey, setSupabaseUrl, subscribeToNetworkChanges, useAI, useApplyFeedback, useAutosaveState, useChangelogById, useChangelogBySlug, useChangelogEntries, useChangelogMedia, useChangelogs, useDbAdvanceFilterQuery, useDbAdvanceFilterQuery as useDbAdvanceQuery, useDbDelete, useDbInsert, useDbMultiDelete, useDbMultiUpsert, useDbPartialAdvanceQuery, useDbPartialQuery, useDbRealtime, useDbRealtimeQuery, useDbUpdate, useDbAttachmentUpload as useDbUpload, useDbUpsert, type useDbUpsertResponse, useDbDelete as useDelete, useDeleteChangelog, useDeleteChangelogEntry, useDeleteChangelogMedia, useFeedbackList, useDbInsert as useInsert, useLatestOperationLog, useLiveChangeTracking, useMultiDeleteChangelogEntries, useMultiUpsertChangelogEntries, useMutationSuccess, useMutationSuccessRN, usePublishedChangelogs, useDbRealtime as useRealtime, useDbRealtimeQuery as useRealtimeQuery, useReceiptAI, useResolveFeedback, useSearchQuery, useServerAvailability, useStoragePath, useStorageUrl, useSubmitFeedback, useSupabaseFunction, useSupabaseUpload, useToastError, useDbUpdate as useUpdate, useUploadChangelogMedia, useDbUpsert as useUpsert, useUpsertChangelog, useUpsertChangelogEntry, useUpsertChangelogMedia };