@pol-studios/db 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1165 @@
1
+ import * as _tanstack_react_query from '@tanstack/react-query';
2
+ import { UseQueryOptions, UseMutationResult, UseMutationOptions } from '@tanstack/react-query';
3
+ import { D as Database } from './useSupabase-pPhUZHcl.js';
4
+ import { G as GetResult } from './select-query-parser-CLkOKHzc.js';
5
+ import { G as GenericSchema, a as GenericTable } from './types-CKsWM8T3.js';
6
+ import { useInsertMutation, useUpdateMutation } from '@supabase-cache-helpers/postgrest-react-query';
7
+ import { PostgrestSingleResponse, PostgrestError, RealtimePostgresChangesPayload, SupabaseClient } from '@supabase/supabase-js';
8
+ import { u as useDbAdvanceFilterQuery, Q as QueryState, T as Tables, d as DbChangeLog } from './index-DNrSptau.js';
9
+ import { ItemType as ItemType$6 } from '@pol-studios/utils';
10
+ import { U as UseDbQuerySingleReturn } from './useDbQuery-C-TL8jY1.js';
11
+ import { FileOptions, TransformOptions } from '@supabase/storage-js';
12
+ import { T as TableDataAdapter, C as CapableDataAdapter, c as AdapterCapabilities, A as AdapterQueryResult } from './useDbCount-B5-Va9sg.js';
13
+ import { DatabaseSchema, QueryOptions } from './core/index.js';
14
+ import { FunctionsResponse } from '@supabase/functions-js';
15
+ import * as _supabase_postgrest_js from '@supabase/postgrest-js';
16
+ import { PostgrestSingleResponse as PostgrestSingleResponse$1 } from '@supabase/postgrest-js';
17
+ import { Moment } from 'moment';
18
+ import * as react from 'react';
19
+ import { ReactNode } from 'react';
20
+ import * as react_dropzone from 'react-dropzone';
21
+ import { FileRejection, FileError } from 'react-dropzone';
22
+ import * as react_jsx_runtime from 'react/jsx-runtime';
23
+
24
+ declare function setSupabaseUrl(url: string): void;
25
+ declare function getSupabaseUrl(): string;
26
+
27
+ type ItemType$5<T> = T extends Array<infer U> ? U : T;
28
+ 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 {
29
+ Relationships: infer R;
30
+ } ? R : unknown, RowResult extends object = GetResult<PublicSchema, Table["Row"], RelationName, Relationships, Query>>(relation: TableName | {
31
+ table: TableName;
32
+ schema: Schema;
33
+ }, primaryKeys?: (keyof ItemType$5<RowResult> & string)[]): _tanstack_react_query.UseMutationResult<RowResult, Error, Partial<RowResult>, unknown>;
34
+
35
+ type ItemType$4<T> = T extends Array<infer U> ? U : T;
36
+ type MutationOption$2 = Parameters<typeof useInsertMutation>[3];
37
+ 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 {
38
+ Relationships: infer R;
39
+ } ? 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 | {
40
+ table: TableName;
41
+ schema: Schema;
42
+ }, primaryKeys?: (keyof (ItemType$4<RowResult> | any) & string)[], query?: ReturnQuery, mutationOption?: MutationOption$2 & {
43
+ crossOrganization?: boolean;
44
+ }): _tanstack_react_query.UseMutationResult<RowResult, Error, ResultInsert, unknown>;
45
+
46
+ type ItemType$3<T> = T extends Array<infer U> ? U : T;
47
+ 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 {
48
+ Relationships: infer R;
49
+ } ? R : unknown, RowResult extends object = Omit<GetResult<PublicSchema, Table["Update"], RelationName, Relationships, Query>, "id">>(relation: TableName | {
50
+ table: TableName;
51
+ schema: Schema;
52
+ }, primaryKeys?: (keyof ItemType$3<RowResult> & string)[]): _tanstack_react_query.UseMutationResult<RowResult, Error, RowResult | RowResult[], unknown>;
53
+
54
+ type ItemType$2<T> = T extends Array<infer U> ? U : T;
55
+ 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 {
56
+ Relationships: infer R;
57
+ } ? 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"> & {
58
+ id: any;
59
+ }>(relation: TableName | {
60
+ table: TableName;
61
+ schema: Schema;
62
+ }, primaryKeys?: (keyof (ItemType$2<RowResult> | any) & string)[], query?: string): _tanstack_react_query.UseMutationResult<RowResult[], Error, (ResultInsert | ResultUpdate)[], unknown>;
63
+
64
+ type UseDbPartialAdvanceQueryResult<T extends Record<string, any>> = ReturnType<typeof useDbPartialAdvanceQuery<T[]>>;
65
+ declare function useDbPartialAdvanceQuery<Result extends Record<string, any>[]>(query: PromiseLike<PostgrestSingleResponse<Result>>, itemCountPerPage: number, config?: Omit<UseQueryOptions<PostgrestSingleResponse<Result>>, "queryKey" | "queryFn"> & {
66
+ filterKey?: string;
67
+ timeout?: number;
68
+ }): [
69
+ ReturnType<typeof useDbAdvanceFilterQuery<Result>>[0] & {
70
+ currentPage: number;
71
+ setCurrentPage: (value: React.SetStateAction<number>) => void;
72
+ fetchNextPage: () => any;
73
+ fetchPreviousPage: () => any;
74
+ data: {
75
+ Items: Result;
76
+ CurrentPage: number;
77
+ ItemCount: number;
78
+ MaxCountPerPage: number;
79
+ PageCount: number;
80
+ };
81
+ pageCount: number;
82
+ hasNextPage: boolean;
83
+ hasPreviousPage: boolean;
84
+ count: number;
85
+ },
86
+ QueryState,
87
+ React.Dispatch<React.SetStateAction<QueryState>>
88
+ ];
89
+
90
+ type UseDbPartialQueryResult<T extends Record<string, any>> = ReturnType<typeof useDbPartialQuery<T[]>>;
91
+ declare function useDbPartialQuery<Result extends Record<string, any>[]>(query: PromiseLike<PostgrestSingleResponse<Result>>, itemCountPerPage: number, config?: Omit<UseQueryOptions<Result, PostgrestError>, "queryKey" | "queryFn">): {
92
+ fetchPreviousPage: () => void;
93
+ fetchNextPage: () => void;
94
+ currentPage: number;
95
+ setCurrentPage: react.Dispatch<react.SetStateAction<number>>;
96
+ data: {
97
+ Items: Result;
98
+ CurrentPage: number;
99
+ ItemCount: number;
100
+ MaxCountPerPage: number;
101
+ PageCount: number;
102
+ };
103
+ pageCount: number;
104
+ hasNextPage: boolean;
105
+ hasPreviousPage: boolean;
106
+ error: PostgrestError;
107
+ status: "error";
108
+ isError: true;
109
+ isPending: false;
110
+ isSuccess: false;
111
+ failureCount: number;
112
+ failureReason: PostgrestError;
113
+ isPaused: boolean;
114
+ isLoading: false;
115
+ isLoadingError: false;
116
+ isRefetchError: true;
117
+ isPlaceholderData: false;
118
+ dataUpdatedAt: number;
119
+ errorUpdatedAt: number;
120
+ errorUpdateCount: number;
121
+ isFetched: boolean;
122
+ isFetchedAfterMount: boolean;
123
+ isFetching: boolean;
124
+ isInitialLoading: boolean;
125
+ isRefetching: boolean;
126
+ isStale: boolean;
127
+ isEnabled: boolean;
128
+ fetchStatus: _tanstack_react_query.FetchStatus;
129
+ promise: Promise<Result>;
130
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PostgrestSingleResponse<Result>, PostgrestError>>;
131
+ count: number | null;
132
+ } | {
133
+ fetchPreviousPage: () => void;
134
+ fetchNextPage: () => void;
135
+ currentPage: number;
136
+ setCurrentPage: react.Dispatch<react.SetStateAction<number>>;
137
+ data: {
138
+ Items: Result;
139
+ CurrentPage: number;
140
+ ItemCount: number;
141
+ MaxCountPerPage: number;
142
+ PageCount: number;
143
+ };
144
+ pageCount: number;
145
+ hasNextPage: boolean;
146
+ hasPreviousPage: boolean;
147
+ error: null;
148
+ status: "success";
149
+ isError: false;
150
+ isPending: false;
151
+ isSuccess: true;
152
+ failureCount: number;
153
+ failureReason: PostgrestError;
154
+ isPaused: boolean;
155
+ isLoading: false;
156
+ isLoadingError: false;
157
+ isRefetchError: false;
158
+ isPlaceholderData: false;
159
+ dataUpdatedAt: number;
160
+ errorUpdatedAt: number;
161
+ errorUpdateCount: number;
162
+ isFetched: boolean;
163
+ isFetchedAfterMount: boolean;
164
+ isFetching: boolean;
165
+ isInitialLoading: boolean;
166
+ isRefetching: boolean;
167
+ isStale: boolean;
168
+ isEnabled: boolean;
169
+ fetchStatus: _tanstack_react_query.FetchStatus;
170
+ promise: Promise<Result>;
171
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PostgrestSingleResponse<Result>, PostgrestError>>;
172
+ count: number | null;
173
+ } | {
174
+ fetchPreviousPage: () => void;
175
+ fetchNextPage: () => void;
176
+ currentPage: number;
177
+ setCurrentPage: react.Dispatch<react.SetStateAction<number>>;
178
+ data: {
179
+ Items: Result;
180
+ CurrentPage: number;
181
+ ItemCount: number;
182
+ MaxCountPerPage: number;
183
+ PageCount: number;
184
+ };
185
+ pageCount: number;
186
+ hasNextPage: boolean;
187
+ hasPreviousPage: boolean;
188
+ error: PostgrestError;
189
+ status: "error";
190
+ isError: true;
191
+ isPending: false;
192
+ isSuccess: false;
193
+ failureCount: number;
194
+ failureReason: PostgrestError;
195
+ isPaused: boolean;
196
+ isLoading: false;
197
+ isLoadingError: true;
198
+ isRefetchError: false;
199
+ isPlaceholderData: false;
200
+ dataUpdatedAt: number;
201
+ errorUpdatedAt: number;
202
+ errorUpdateCount: number;
203
+ isFetched: boolean;
204
+ isFetchedAfterMount: boolean;
205
+ isFetching: boolean;
206
+ isInitialLoading: boolean;
207
+ isRefetching: boolean;
208
+ isStale: boolean;
209
+ isEnabled: boolean;
210
+ fetchStatus: _tanstack_react_query.FetchStatus;
211
+ promise: Promise<Result>;
212
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PostgrestSingleResponse<Result>, PostgrestError>>;
213
+ count: number | null;
214
+ } | {
215
+ fetchPreviousPage: () => void;
216
+ fetchNextPage: () => void;
217
+ currentPage: number;
218
+ setCurrentPage: react.Dispatch<react.SetStateAction<number>>;
219
+ data: {
220
+ Items: Result;
221
+ CurrentPage: number;
222
+ ItemCount: number;
223
+ MaxCountPerPage: number;
224
+ PageCount: number;
225
+ };
226
+ pageCount: number;
227
+ hasNextPage: boolean;
228
+ hasPreviousPage: boolean;
229
+ error: null;
230
+ status: "pending";
231
+ isError: false;
232
+ isPending: true;
233
+ isSuccess: false;
234
+ failureCount: number;
235
+ failureReason: PostgrestError;
236
+ isPaused: boolean;
237
+ isLoading: true;
238
+ isLoadingError: false;
239
+ isRefetchError: false;
240
+ isPlaceholderData: false;
241
+ dataUpdatedAt: number;
242
+ errorUpdatedAt: number;
243
+ errorUpdateCount: number;
244
+ isFetched: boolean;
245
+ isFetchedAfterMount: boolean;
246
+ isFetching: boolean;
247
+ isInitialLoading: boolean;
248
+ isRefetching: boolean;
249
+ isStale: boolean;
250
+ isEnabled: boolean;
251
+ fetchStatus: _tanstack_react_query.FetchStatus;
252
+ promise: Promise<Result>;
253
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PostgrestSingleResponse<Result>, PostgrestError>>;
254
+ count: number | null;
255
+ } | {
256
+ fetchPreviousPage: () => void;
257
+ fetchNextPage: () => void;
258
+ currentPage: number;
259
+ setCurrentPage: react.Dispatch<react.SetStateAction<number>>;
260
+ data: {
261
+ Items: Result;
262
+ CurrentPage: number;
263
+ ItemCount: number;
264
+ MaxCountPerPage: number;
265
+ PageCount: number;
266
+ };
267
+ pageCount: number;
268
+ hasNextPage: boolean;
269
+ hasPreviousPage: boolean;
270
+ error: null;
271
+ status: "pending";
272
+ isError: false;
273
+ isPending: true;
274
+ isSuccess: false;
275
+ failureCount: number;
276
+ failureReason: PostgrestError;
277
+ isPaused: boolean;
278
+ isLoading: boolean;
279
+ isLoadingError: false;
280
+ isRefetchError: false;
281
+ isPlaceholderData: false;
282
+ dataUpdatedAt: number;
283
+ errorUpdatedAt: number;
284
+ errorUpdateCount: number;
285
+ isFetched: boolean;
286
+ isFetchedAfterMount: boolean;
287
+ isFetching: boolean;
288
+ isInitialLoading: boolean;
289
+ isRefetching: boolean;
290
+ isStale: boolean;
291
+ isEnabled: boolean;
292
+ fetchStatus: _tanstack_react_query.FetchStatus;
293
+ promise: Promise<Result>;
294
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PostgrestSingleResponse<Result>, PostgrestError>>;
295
+ count: number | null;
296
+ } | {
297
+ fetchPreviousPage: () => void;
298
+ fetchNextPage: () => void;
299
+ currentPage: number;
300
+ setCurrentPage: react.Dispatch<react.SetStateAction<number>>;
301
+ data: {
302
+ Items: Result;
303
+ CurrentPage: number;
304
+ ItemCount: number;
305
+ MaxCountPerPage: number;
306
+ PageCount: number;
307
+ };
308
+ pageCount: number;
309
+ hasNextPage: boolean;
310
+ hasPreviousPage: boolean;
311
+ error: null;
312
+ status: "success";
313
+ isError: false;
314
+ isPending: false;
315
+ isSuccess: true;
316
+ failureCount: number;
317
+ failureReason: PostgrestError;
318
+ isPaused: boolean;
319
+ isLoading: false;
320
+ isLoadingError: false;
321
+ isRefetchError: false;
322
+ isPlaceholderData: true;
323
+ dataUpdatedAt: number;
324
+ errorUpdatedAt: number;
325
+ errorUpdateCount: number;
326
+ isFetched: boolean;
327
+ isFetchedAfterMount: boolean;
328
+ isFetching: boolean;
329
+ isInitialLoading: boolean;
330
+ isRefetching: boolean;
331
+ isStale: boolean;
332
+ isEnabled: boolean;
333
+ fetchStatus: _tanstack_react_query.FetchStatus;
334
+ promise: Promise<Result>;
335
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<PostgrestSingleResponse<Result>, PostgrestError>>;
336
+ count: number | null;
337
+ };
338
+
339
+ declare function useDbRealtime(key: string, query: string, table: string | {
340
+ table: string;
341
+ schema: string;
342
+ }, primaryKeys: string[], options?: {
343
+ filter?: string;
344
+ enabled?: boolean;
345
+ onChange?: (payload: RealtimePostgresChangesPayload<{
346
+ [key: string]: any;
347
+ }>) => any;
348
+ }): "SUBSCRIBED" | "TIMED_OUT" | "CLOSED" | "CHANNEL_ERROR";
349
+
350
+ type ConfigurationOptions<T> = {
351
+ crossOrganization?: boolean;
352
+ };
353
+ type FilterOperator = "or" | "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "like" | "ilike" | "is" | "in" | "cs" | "cd" | "fts" | "plfts";
354
+ type ValueType = number | string | boolean | null | Date | object;
355
+ type FilterDefinition = {
356
+ path: string;
357
+ alias?: string;
358
+ operator: FilterOperator;
359
+ negate: boolean;
360
+ value: ValueType;
361
+ };
362
+ type FilterDefinitions = (FilterComposite | FilterDefinition)[];
363
+ type FilterComposite = {
364
+ or?: FilterDefinitions;
365
+ and?: FilterDefinitions;
366
+ };
367
+ type UseDbRealtimeQueryResult<T> = UseDbQuerySingleReturn<T> & {
368
+ realtimeStatus: "SUBSCRIBED" | "TIMED_OUT" | "CLOSED" | "CHANNEL_ERROR" | "Loading...";
369
+ isRealtimeConnected: boolean;
370
+ isRealtimeLoading: boolean;
371
+ };
372
+ type DataType = Record<string, any>;
373
+ declare function convertFilterToRealtimeQuery(filters: FilterDefinitions): string;
374
+ 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>;
375
+
376
+ type ItemType$1<T> = T extends Array<infer U> ? U : T;
377
+ type MutationOption$1 = Parameters<typeof useUpdateMutation>[3];
378
+ 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 {
379
+ Relationships: infer R;
380
+ } ? 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"> & {
381
+ id: number;
382
+ }) | Omit<GetResult<PublicSchema, Table["Update"], RelationName, Relationships, "*">, "id">>(relation: TableName | {
383
+ table: TableName;
384
+ schema: Schema;
385
+ }, primaryKeys?: (keyof (ItemType$1<RowResult> | any) & string)[], query?: ReturnQuery, mutationOption?: MutationOption$1 & {
386
+ crossOrganization?: boolean;
387
+ }): _tanstack_react_query.UseMutationResult<RowResult, Error, ResultUpdate, unknown>;
388
+
389
+ type RequestOptions = {
390
+ onUploadProgress?: (bytesUploaded: number, bytesTotal: number) => any;
391
+ };
392
+ declare function sanitizeStorageKey(path: string): string;
393
+ declare function useDbAttachmentUpload(bucketId: string, options?: RequestOptions): _tanstack_react_query.UseMutationResult<{
394
+ bucketId: string;
395
+ path: string;
396
+ contentType: string;
397
+ }, Error, {
398
+ directory?: string;
399
+ fileName?: string;
400
+ file: File | Blob | Pick<ReadableStreamDefaultReader, "read">;
401
+ onUploadProgress?: (bytesUploaded: number, bytesTotal: number) => any;
402
+ } & FileOptions, unknown>;
403
+
404
+ type ItemType<T> = T extends Array<infer U> ? U : T;
405
+ type MutationOption = Parameters<typeof useUpdateMutation>[3];
406
+ type useDbUpsertResponse = ReturnType<typeof useDbUpsert>;
407
+ 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 {
408
+ Relationships: infer R;
409
+ } ? 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"> & {
410
+ id?: any;
411
+ }>(relation: TableName | {
412
+ table: TableName;
413
+ schema: Schema;
414
+ }, primaryKeys?: (keyof (ItemType<RowResult> | any) & string)[], query?: ReturnQuery, mutationOption?: MutationOption & {
415
+ crossOrganization?: boolean;
416
+ }): _tanstack_react_query.UseMutationResult<RowResult, Error, ResultInsert | ResultUpdate, unknown>;
417
+
418
+ interface UseMutationSuccessOptions {
419
+ successMessage?: string;
420
+ entityName?: string;
421
+ enabled?: boolean;
422
+ onSuccess?: () => void;
423
+ }
424
+ /**
425
+ * Hook to automatically show success feedback after successful mutations
426
+ * Works with both React Native and Web platforms
427
+ */
428
+ declare function useMutationSuccess<TData, TError, TVariables>(mutation: UseMutationResult<TData, TError, TVariables>, options?: UseMutationSuccessOptions): UseMutationResult<TData, TError, TVariables>;
429
+ /**
430
+ * Hook for React Native that uses native toast/alert system
431
+ * @deprecated Use useMutationSuccess instead - it auto-detects platform
432
+ */
433
+ declare function useMutationSuccessRN<TData, TError, TVariables>(mutation: UseMutationResult<TData, TError, TVariables>, options?: UseMutationSuccessOptions): UseMutationResult<TData, TError, TVariables>;
434
+
435
+ /**
436
+ * V3 Data Layer - Supabase Adapter
437
+ *
438
+ * Implements the TableDataAdapter interface for direct Supabase/PostgREST queries.
439
+ * This adapter is used for online-only data access without local caching.
440
+ */
441
+
442
+ /**
443
+ * Adapter for querying Supabase directly via PostgREST API.
444
+ *
445
+ * This adapter:
446
+ * - Queries Supabase directly (no local caching)
447
+ * - Supports real-time subscriptions via Supabase Realtime
448
+ * - Works only when online
449
+ * - Uses Supabase's native select embedding for relations
450
+ *
451
+ * @example
452
+ * ```typescript
453
+ * const adapter = createSupabaseAdapter(supabaseClient, schema);
454
+ *
455
+ * // Query with relations
456
+ * const result = await adapter.query<Project>("projects", {
457
+ * select: "*, client:clients(*), tasks(*)",
458
+ * where: { status: "active" },
459
+ * orderBy: [{ field: "created_at", direction: "desc" }],
460
+ * limit: 10
461
+ * });
462
+ * ```
463
+ */
464
+ declare class SupabaseAdapter implements TableDataAdapter, CapableDataAdapter {
465
+ private supabase;
466
+ private schema;
467
+ readonly name = "supabase";
468
+ readonly capabilities: AdapterCapabilities;
469
+ constructor(supabase: SupabaseClient, schema: DatabaseSchema);
470
+ /**
471
+ * Parse a table identifier to extract schema and table name.
472
+ * Handles schema-qualified names like "core.Profile" -> { schema: "core", tableName: "Profile" }
473
+ *
474
+ * @param table - The table name, optionally schema-qualified (e.g., "users" or "core.Profile")
475
+ * @returns Object with schema (defaults to "public") and tableName
476
+ */
477
+ private parseTableIdentifier;
478
+ /**
479
+ * Execute a query and return results with optional count
480
+ *
481
+ * @param table - The table name to query
482
+ * @param options - Query options (select, where, orderBy, limit, offset)
483
+ * @returns Promise resolving to query results with optional count
484
+ */
485
+ query<T>(table: string, options: QueryOptions): Promise<AdapterQueryResult<T>>;
486
+ /**
487
+ * Query a single record by ID
488
+ *
489
+ * @param table - The table name to query
490
+ * @param id - The record ID
491
+ * @param options - Optional query options (mainly for select)
492
+ * @returns Promise resolving to the record or null if not found
493
+ */
494
+ queryById<T>(table: string, id: string, options?: Pick<QueryOptions, "select">): Promise<T | null>;
495
+ /**
496
+ * Insert a new record
497
+ *
498
+ * @param table - The table name
499
+ * @param data - The data to insert
500
+ * @returns Promise resolving to the inserted record
501
+ */
502
+ insert<T>(table: string, data: Partial<T>): Promise<T>;
503
+ /**
504
+ * Update an existing record by ID
505
+ *
506
+ * @param table - The table name
507
+ * @param id - The record ID to update
508
+ * @param data - The data to update
509
+ * @returns Promise resolving to the updated record
510
+ */
511
+ update<T>(table: string, id: string, data: Partial<T>): Promise<T>;
512
+ /**
513
+ * Upsert (insert or update) a record
514
+ *
515
+ * @param table - The table name
516
+ * @param data - The data to upsert
517
+ * @returns Promise resolving to the upserted record
518
+ */
519
+ upsert<T>(table: string, data: Partial<T>): Promise<T>;
520
+ /**
521
+ * Delete a record by ID
522
+ *
523
+ * @param table - The table name
524
+ * @param id - The record ID to delete
525
+ * @returns Promise that resolves when deletion is complete
526
+ */
527
+ delete(table: string, id: string): Promise<void>;
528
+ /**
529
+ * Subscribe to real-time changes on a query
530
+ *
531
+ * @param table - The table name to watch
532
+ * @param options - Query options to filter what to watch
533
+ * @param callback - Function called with updated data
534
+ * @returns Unsubscribe function
535
+ */
536
+ subscribe<T>(table: string, options: QueryOptions, callback: (data: T[]) => void): () => void;
537
+ /**
538
+ * Apply where clause filters to a Supabase query
539
+ *
540
+ * Converts WhereClause to Supabase filter methods:
541
+ * - Direct value: .eq(field, value)
542
+ * - { in: [...] }: .in(field, values)
543
+ * - { gt: n }: .gt(field, n)
544
+ * - { gte: n }: .gte(field, n)
545
+ * - { lt: n }: .lt(field, n)
546
+ * - { lte: n }: .lte(field, n)
547
+ * - { like: s }: .ilike(field, s)
548
+ * - { is: null }: .is(field, null)
549
+ * - { neq: v }: .neq(field, v) or .not(field, "is", null)
550
+ * - { notIn: [...] }: .not().in(field, values)
551
+ *
552
+ * @param query - The Supabase query builder
553
+ * @param where - The where clause to apply
554
+ * @returns The query with filters applied
555
+ */
556
+ private applyWhereClause;
557
+ }
558
+ /**
559
+ * Create a new SupabaseAdapter instance
560
+ *
561
+ * @param supabase - The Supabase client instance
562
+ * @param schema - The database schema definition
563
+ * @returns A new SupabaseAdapter instance
564
+ *
565
+ * @example
566
+ * ```typescript
567
+ * const adapter = createSupabaseAdapter(supabaseClient, databaseSchema);
568
+ * const projects = await adapter.query<Project>("projects", {
569
+ * where: { status: "active" }
570
+ * });
571
+ * ```
572
+ */
573
+ declare function createSupabaseAdapter(supabase: SupabaseClient, schema: DatabaseSchema): SupabaseAdapter;
574
+
575
+ declare function useSupabaseFunction(): {
576
+ downloadFunctionResponse: (functionName: string, body?: any, name?: string) => Promise<void>;
577
+ };
578
+
579
+ declare function getErrorBody(response: FunctionsResponse<any>): Promise<any>;
580
+
581
+ interface AIOptions {
582
+ maxTokens?: number;
583
+ temperature?: number;
584
+ }
585
+ interface AIResponse {
586
+ success: boolean;
587
+ data?: {
588
+ response: string;
589
+ };
590
+ error?: string;
591
+ }
592
+ declare function useAI(): {
593
+ generate: (prompt: string, context: Record<string, any>, options?: AIOptions) => Promise<string>;
594
+ };
595
+
596
+ interface ExtractedReceipt {
597
+ merchantName: string;
598
+ transactionDate: string | null;
599
+ currency: string;
600
+ subtotal: number | null;
601
+ tax: number | null;
602
+ total: number;
603
+ lineItems: Array<{
604
+ description: string;
605
+ amount: number;
606
+ quantity: number | null;
607
+ suggestedCategory: string | null;
608
+ }>;
609
+ confidence: number;
610
+ notes: string | null;
611
+ }
612
+ interface PendingExpense {
613
+ id: string;
614
+ file: File;
615
+ status: "processing" | "ready" | "error" | "confirming";
616
+ extractedData: ExtractedReceipt | null;
617
+ error: string | null;
618
+ duplicateWarning?: {
619
+ existingExpenseId: number;
620
+ reason: string;
621
+ };
622
+ }
623
+ interface BatchAnalysisProgress {
624
+ total: number;
625
+ completed: number;
626
+ processing: string[];
627
+ }
628
+ interface RecentExpenseContext {
629
+ merchantName: string;
630
+ category: string | null;
631
+ amount: number;
632
+ }
633
+ interface UseReceiptAIOptions {
634
+ recentExpenses?: RecentExpenseContext[];
635
+ taxCategories?: Tables<"TaxCategory">[];
636
+ }
637
+ declare function useReceiptAI(options?: UseReceiptAIOptions): {
638
+ analyzeReceipt: (file: File) => Promise<ExtractedReceipt | null>;
639
+ analyzeMultipleReceipts: (files: File[], onProgress?: (progress: BatchAnalysisProgress) => void, onItemComplete?: (item: PendingExpense) => void) => Promise<PendingExpense[]>;
640
+ isAnalyzing: boolean;
641
+ batchProgress: BatchAnalysisProgress;
642
+ error: string;
643
+ extractedData: ExtractedReceipt;
644
+ reset: () => void;
645
+ };
646
+
647
+ interface ServerAvailabilityState {
648
+ isAvailable: boolean | null;
649
+ isChecking: boolean;
650
+ lastChecked: Date | null;
651
+ error: Error | null;
652
+ }
653
+ /**
654
+ * Hook to check if the Supabase server is available.
655
+ * Performs periodic health checks and provides availability state.
656
+ * Works without requiring Supabase context, making it safe to use at app initialization.
657
+ */
658
+ declare function useServerAvailability(options?: {
659
+ enabled?: boolean;
660
+ checkInterval?: number;
661
+ timeout?: number;
662
+ }): ServerAvailabilityState & {
663
+ checkAvailability: () => Promise<void>;
664
+ };
665
+
666
+ declare function useSearchQuery<Result>(baseQuery: PromiseLike<PostgrestSingleResponse$1<Result>>, searchText: string, columns: ((string & keyof Result) | string)[], options?: {
667
+ isOptional: boolean;
668
+ additionCondition: (string | undefined)[];
669
+ }): PromiseLike<PostgrestSingleResponse$1<Result>>;
670
+
671
+ type PublicSchema$2 = Database[Extract<keyof Database, "public">];
672
+ type TableRow<T> = T extends {
673
+ Row: infer R extends Record<string, unknown>;
674
+ } ? R : Record<string, unknown>;
675
+ 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 {
676
+ Relationships: infer R;
677
+ } ? R : unknown, TItem = GetResult<PublicSchema$2, TableRow<Table>, RelationName, Relationships, Query>>(tableName: TableName, item: TItem, action?: (updates: Partial<TItem>, changeLog: DbChangeLog) => any): DbChangeLog;
678
+
679
+ declare function useLatestOperationLog(tableName: string, recordId: number): UseDbQuerySingleReturn<unknown>;
680
+
681
+ type PublicSchema$1 = Database[Extract<keyof Database, "public">];
682
+ type TimeActivity = any;
683
+ declare function newTimeActivity(date: Moment): TimeActivity;
684
+ type AutosaveOptions<T> = UpdateOptions<T> & {
685
+ delay: number;
686
+ primaryKeys?: string[];
687
+ transformBeforeMutation?: (item: T) => Partial<T>;
688
+ };
689
+ type UpdateOptions<T> = Partial<UseMutationOptions<T, Error, T, unknown>> & {
690
+ updateCache?: boolean;
691
+ };
692
+ /**
693
+ * Hook for managing autosave state with proper entity switching support.
694
+ *
695
+ * This hook provides three main functions:
696
+ * 1. `updateValue` - For making changes to the current entity (with autosave)
697
+ * 2. `setNewEntity` - For switching to a completely different entity (saves previous entity first)
698
+ * 3. `setValue` - For setting a value without triggering autosave or change tracking
699
+ *
700
+ * @example
701
+ * ```tsx
702
+ * const [value, updateValue, mutation, setValue, setNewEntity] = useAutosaveState(
703
+ * 'time_activities',
704
+ * defaultTimeActivity,
705
+ * {
706
+ * delay: 500,
707
+ * transformBeforeMutation: (item) => omitFields(item, ['computedField', 'uiOnlyField'])
708
+ * }
709
+ * );
710
+ *
711
+ * // For making changes to current entity (autosaves after delay)
712
+ * updateValue(prev => ({ ...prev, description: 'New description' }));
713
+ *
714
+ * // For switching to a different entity (saves current entity first)
715
+ * setNewEntity(differentTimeActivity);
716
+ * ```
717
+ */
718
+ declare function useAutosaveState<T extends TItem & {
719
+ id: number;
720
+ }, TableName extends string & keyof PublicSchema$1["Tables"] = any, Table extends PublicSchema$1["Tables"][TableName] = any, Query extends string = "*", RelationName = unknown, Relationships = Table extends {
721
+ Relationships: infer R;
722
+ } ? R : unknown, TItem = Omit<GetResult<PublicSchema$1, Table extends {
723
+ Row: infer R;
724
+ } ? R extends Record<string, unknown> ? R : any : any, RelationName, Relationships, Query>, "id"> & {
725
+ id: number;
726
+ }>(relation: TableName, defaultValue: T, options?: AutosaveOptions<T>): [
727
+ T,
728
+ React.Dispatch<React.SetStateAction<T>>,
729
+ UseMutationResult<PostgrestSingleResponse<T>, Error, T, unknown>,
730
+ React.Dispatch<React.SetStateAction<T>>,
731
+ (newEntity: T) => void,
732
+ () => Promise<void>
733
+ ];
734
+
735
+ declare function useToastError<T>(mutation: useDbUpsertResponse): UseMutationResult<unknown, Error, object, unknown>;
736
+
737
+ declare function executeAdvanceQuery<Result>(supabase: any, query: PromiseLike<PostgrestSingleResponse<Result>>, filterLayer: QueryState): Promise<{
738
+ data: any;
739
+ count: number | null;
740
+ error: any;
741
+ }>;
742
+
743
+ type CustomPageQueryResult<T extends Record<string, any>[]> = ReturnType<typeof useDbPartialQuery<T>>;
744
+
745
+ type Attachment = {
746
+ bucketId: string;
747
+ path: string;
748
+ };
749
+ declare function useStorageUrl(): {
750
+ fetchUrl: (entity: {
751
+ bucketId: string;
752
+ path: string;
753
+ }, options?: {
754
+ download?: string | boolean;
755
+ transform?: TransformOptions;
756
+ }) => Promise<string>;
757
+ fetchUrls: (entities: Attachment[], options?: {
758
+ download?: string | boolean;
759
+ transform?: TransformOptions;
760
+ }) => Promise<Map<string, string | undefined>>;
761
+ prefetchImage: (entity: Attachment, options?: {
762
+ download?: string | boolean;
763
+ transform?: TransformOptions;
764
+ }) => Promise<void>;
765
+ fetchPublicUrl: (entity: {
766
+ bucketId: string;
767
+ path: string;
768
+ }, options?: {
769
+ download?: string | boolean;
770
+ transform?: TransformOptions;
771
+ }) => Promise<string>;
772
+ expireCache: (entity: {
773
+ bucketId: string;
774
+ path: string;
775
+ }) => Promise<void>;
776
+ getCacheVersion: (entity: {
777
+ bucketId: string;
778
+ path: string;
779
+ }) => number;
780
+ subscribeToCacheVersion: (entity: {
781
+ bucketId: string;
782
+ path: string;
783
+ }, callback: () => void) => () => void;
784
+ };
785
+
786
+ interface FileWithPreview extends File {
787
+ preview?: string;
788
+ errors: readonly FileError[];
789
+ }
790
+ type UseSupabaseUploadOptions = {
791
+ /**
792
+ * Name of bucket to upload files to in your Supabase project
793
+ */
794
+ bucketName: string;
795
+ /**
796
+ * Folder to upload files to in the specified bucket within your Supabase project.
797
+ *
798
+ * Defaults to uploading files to the root of the bucket
799
+ *
800
+ * e.g If specified path is `test`, your file will be uploaded as `test/file_name`
801
+ */
802
+ path?: string;
803
+ /**
804
+ * Allowed MIME types for each file upload (e.g `image/png`, `text/html`, etc). Wildcards are also supported (e.g `image/*`).
805
+ *
806
+ * Defaults to allowing uploading of all MIME types.
807
+ */
808
+ allowedMimeTypes?: string[];
809
+ /**
810
+ * Maximum upload size of each file allowed in bytes. (e.g 1000 bytes = 1 KB)
811
+ */
812
+ maxFileSize?: number;
813
+ /**
814
+ * Maximum number of files allowed per upload.
815
+ */
816
+ maxFiles?: number;
817
+ /**
818
+ * The number of seconds the asset is cached in the browser and in the Supabase CDN.
819
+ *
820
+ * This is set in the Cache-Control: max-age=<seconds> header. Defaults to 3600 seconds.
821
+ */
822
+ cacheControl?: number;
823
+ /**
824
+ * When set to true, the file is overwritten if it exists.
825
+ *
826
+ * When set to false, an error is thrown if the object already exists. Defaults to `false`
827
+ */
828
+ upsert?: boolean;
829
+ };
830
+ type UseSupabaseUploadReturn = ReturnType<typeof useSupabaseUpload>;
831
+ declare const useSupabaseUpload: (options: UseSupabaseUploadOptions) => {
832
+ open: () => void;
833
+ isFocused: boolean;
834
+ isDragActive: boolean;
835
+ isDragAccept: boolean;
836
+ isDragReject: boolean;
837
+ isFileDialogActive: boolean;
838
+ acceptedFiles: readonly react_dropzone.FileWithPath[];
839
+ fileRejections: readonly FileRejection[];
840
+ rootRef: React.RefObject<HTMLElement>;
841
+ inputRef: React.RefObject<HTMLInputElement>;
842
+ getRootProps: <T extends react_dropzone.DropzoneRootProps>(props?: T) => T;
843
+ getInputProps: <T extends react_dropzone.DropzoneInputProps>(props?: T) => T;
844
+ files: FileWithPreview[];
845
+ setFiles: react.Dispatch<react.SetStateAction<FileWithPreview[]>>;
846
+ successes: string[];
847
+ isSuccess: boolean;
848
+ loading: boolean;
849
+ errors: {
850
+ name: string;
851
+ message: string;
852
+ }[];
853
+ setErrors: react.Dispatch<react.SetStateAction<{
854
+ name: string;
855
+ message: string;
856
+ }[]>>;
857
+ onUpload: () => Promise<void>;
858
+ maxFileSize: number;
859
+ maxFiles: number;
860
+ allowedMimeTypes: string[];
861
+ };
862
+
863
+ /**
864
+ * Metadata stored in storage.objects.metadata JSONB column
865
+ */
866
+ interface StorageObjectMetadata {
867
+ processingStatus: "None" | "Processing" | "Error";
868
+ contentType: string;
869
+ contentHeight?: number;
870
+ contentWidth?: number;
871
+ originalFileName?: string;
872
+ legacyAttachmentId?: number;
873
+ }
874
+ type UseStoragePathOptions = {
875
+ /** Whether to fetch metadata from storage.objects (default: true) */
876
+ fetchMetadata?: boolean;
877
+ /** Transform options for the URL */
878
+ transform?: {
879
+ width?: number;
880
+ height?: number;
881
+ quality?: number;
882
+ format?: "origin";
883
+ };
884
+ /** Whether to get a download URL */
885
+ download?: string | boolean;
886
+ };
887
+ type UseStoragePathResult = {
888
+ /** Signed URL for the storage object */
889
+ url: string | null;
890
+ /** Metadata from storage.objects.metadata JSONB */
891
+ metadata: StorageObjectMetadata | null;
892
+ /** Content type (from metadata or inferred from path) */
893
+ contentType: string;
894
+ /** Whether the URL or metadata is still loading */
895
+ isLoading: boolean;
896
+ /** Error if URL fetch failed */
897
+ error: Error | null;
898
+ };
899
+ /**
900
+ * Hook to get a signed URL and metadata for a storage path.
901
+ * Replaces useAttachment for the path-based storage approach.
902
+ *
903
+ * @param storagePath - The path within the bucket (e.g., "14/abc-123.jpg")
904
+ * @param bucketId - The storage bucket ID
905
+ * @param options - Optional configuration
906
+ *
907
+ * @example
908
+ * ```tsx
909
+ * const { url, contentType, isLoading } = useStoragePath(
910
+ * profile.profilePath,
911
+ * 'attachments'
912
+ * );
913
+ *
914
+ * if (isLoading) return <Spinner />;
915
+ * return <img src={url} />;
916
+ * ```
917
+ */
918
+ declare function useStoragePath(storagePath: string | undefined | null, bucketId: string, options?: UseStoragePathOptions): UseStoragePathResult;
919
+
920
+ /**
921
+ * Storage bucket names for Supabase storage.
922
+ * Use these constants when calling storage APIs.
923
+ */
924
+ declare const BUCKETS: {
925
+ readonly AVATARS: "avatars";
926
+ readonly FIXTURE_CATALOG_COVER: "fixture-catalog-cover";
927
+ readonly FIXTURE_ATTACHMENTS: "fixture-attachments";
928
+ readonly UNIT_DOCUMENTATION: "unit-documentation-attachments";
929
+ readonly DATASHEETS: "datasheets";
930
+ readonly PATTERNS: "patterns";
931
+ readonly LOGOS: "logos";
932
+ readonly RECEIPTS: "receipts";
933
+ readonly TICKET_ATTACHMENTS: "ticket-attachment";
934
+ readonly PROCESS_RESULTS: "process-results";
935
+ readonly DATA_EXCHANGE_IMPORTS: "data-exchange-imports";
936
+ readonly EMAIL_TEMPLATES: "email-templates";
937
+ readonly EMAIL_TEMPLATES_ASSETS: "email-templates-assets";
938
+ };
939
+ type BucketName = (typeof BUCKETS)[keyof typeof BUCKETS];
940
+
941
+ declare function createInCondition(column: string, values: (string | number)[]): string;
942
+
943
+ declare const TIMEOUT_ERROR_MESSAGE = "Request timed out";
944
+ declare const DEFAULT_QUERY_TIMEOUT = 15000;
945
+ declare function isTimeoutError(error: Error | null | undefined): boolean;
946
+
947
+ interface AlertProps {
948
+ title: string;
949
+ description: string;
950
+ }
951
+ interface Context {
952
+ lastModifiedUserName: string;
953
+ changeLog: DbChangeLog;
954
+ }
955
+ declare const LiveChangeContext: react.Context<Context>;
956
+ declare const LiveChangeContextProvider: ({ children, changeLog, }: {
957
+ children: ReactNode;
958
+ changeLog: DbChangeLog;
959
+ }) => react_jsx_runtime.JSX.Element;
960
+
961
+ /**
962
+ * Upsert a changelog (create or update)
963
+ */
964
+ declare const useUpsertChangelog: () => _tanstack_react_query.UseMutationResult<any, Error, Omit<any, "id"> | (Omit<any, "id"> & {
965
+ id?: any;
966
+ }), unknown>;
967
+ /**
968
+ * Delete a changelog
969
+ * Note: Cascade delete will remove all associated entries and media
970
+ */
971
+ declare const useDeleteChangelog: () => _tanstack_react_query.UseMutationResult<any, Error, Partial<any>, unknown>;
972
+ /**
973
+ * Upsert a changelog entry (create or update)
974
+ */
975
+ declare const useUpsertChangelogEntry: () => _tanstack_react_query.UseMutationResult<any, Error, Omit<any, "id"> | (Omit<any, "id"> & {
976
+ id?: any;
977
+ }), unknown>;
978
+ /**
979
+ * Upsert multiple changelog entries at once
980
+ */
981
+ declare const useMultiUpsertChangelogEntries: () => _tanstack_react_query.UseMutationResult<any[], Error, any[], unknown>;
982
+ /**
983
+ * Delete a changelog entry
984
+ * Note: Cascade delete will remove all associated media
985
+ */
986
+ declare const useDeleteChangelogEntry: () => _tanstack_react_query.UseMutationResult<any, Error, Partial<any>, unknown>;
987
+ /**
988
+ * Delete multiple changelog entries at once
989
+ */
990
+ declare const useMultiDeleteChangelogEntries: () => _tanstack_react_query.UseMutationResult<Omit<any, "id">, Error, Omit<any, "id"> | Omit<any, "id">[], unknown>;
991
+ /**
992
+ * Upsert changelog media (create or update)
993
+ */
994
+ declare const useUpsertChangelogMedia: () => _tanstack_react_query.UseMutationResult<any, Error, Omit<any, "id"> | (Omit<any, "id"> & {
995
+ id?: any;
996
+ }), unknown>;
997
+ /**
998
+ * Delete changelog media
999
+ */
1000
+ declare const useDeleteChangelogMedia: () => _tanstack_react_query.UseMutationResult<any, Error, Partial<any>, unknown>;
1001
+ /**
1002
+ * Upload media file for changelog entry
1003
+ * Just returns a simple upload function - caller handles creating ChangelogMedia records
1004
+ */
1005
+ declare const useUploadChangelogMedia: () => {
1006
+ mutateAsync: () => Promise<{
1007
+ path: string;
1008
+ publicUrl: string;
1009
+ }>;
1010
+ };
1011
+
1012
+ /**
1013
+ * Fetch all changelogs with their entries and media
1014
+ * Ordered by release date (newest first)
1015
+ */
1016
+ declare const useChangelogs: (options?: {
1017
+ realtime?: boolean;
1018
+ }) => (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"> & {
1019
+ data: any[];
1020
+ count?: number | null;
1021
+ }) | (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"> & {
1022
+ data: any[];
1023
+ count?: number | null;
1024
+ }) | (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"> & {
1025
+ data: any[];
1026
+ count?: number | null;
1027
+ }) | (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"> & {
1028
+ data: any[];
1029
+ count?: number | null;
1030
+ }) | (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"> & {
1031
+ data: any[];
1032
+ count?: number | null;
1033
+ });
1034
+ /**
1035
+ * Fetch published changelogs only
1036
+ */
1037
+ declare const usePublishedChangelogs: (options?: {
1038
+ realtime?: boolean;
1039
+ }) => (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"> & {
1040
+ data: any[];
1041
+ count?: number | null;
1042
+ }) | (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"> & {
1043
+ data: any[];
1044
+ count?: number | null;
1045
+ }) | (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"> & {
1046
+ data: any[];
1047
+ count?: number | null;
1048
+ }) | (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"> & {
1049
+ data: any[];
1050
+ count?: number | null;
1051
+ }) | (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"> & {
1052
+ data: any[];
1053
+ count?: number | null;
1054
+ });
1055
+ /**
1056
+ * Fetch a single changelog by ID
1057
+ */
1058
+ declare const useChangelogById: (id: string | undefined) => UseDbQuerySingleReturn<any>;
1059
+ /**
1060
+ * Fetch a single changelog by slug
1061
+ */
1062
+ declare const useChangelogBySlug: (slug: string | undefined) => UseDbQuerySingleReturn<any>;
1063
+ /**
1064
+ * Fetch changelog entries for a specific changelog
1065
+ */
1066
+ declare const useChangelogEntries: (changelogId: string | undefined) => UseDbQuerySingleReturn<any[]>;
1067
+ /**
1068
+ * Fetch media for a specific changelog entry
1069
+ */
1070
+ declare const useChangelogMedia: (entryId: string | undefined) => UseDbQuerySingleReturn<any[]>;
1071
+
1072
+ interface FeedbackListItem {
1073
+ id: number;
1074
+ userId: string | null;
1075
+ table: string | null;
1076
+ schema: string;
1077
+ memoryType: string;
1078
+ resolved: boolean;
1079
+ resolvedAt: string | null;
1080
+ resolvedBy: string | null;
1081
+ createdAt: string;
1082
+ updatedAt: string;
1083
+ data: {
1084
+ query: string;
1085
+ queryHash?: string;
1086
+ status?: "success" | "failure" | "needs_review" | "cache_hit";
1087
+ statusMessage?: string;
1088
+ confidence?: number;
1089
+ filters?: any;
1090
+ sql?: string;
1091
+ sqlError?: string;
1092
+ agentDecisions?: any;
1093
+ context?: any;
1094
+ trace?: any;
1095
+ corrections?: {
1096
+ domainTerm?: string;
1097
+ domainFieldPath?: string;
1098
+ fieldPath?: string;
1099
+ filters?: any;
1100
+ };
1101
+ feedback?: string;
1102
+ modelUsed?: string;
1103
+ reasoningEffort?: "minimal" | "medium" | "high";
1104
+ performance?: any;
1105
+ resultCount?: number;
1106
+ };
1107
+ }
1108
+ interface FeedbackListParams {
1109
+ resolved?: boolean;
1110
+ status?: string;
1111
+ limit?: number;
1112
+ offset?: number;
1113
+ userId?: string;
1114
+ startDate?: string;
1115
+ endDate?: string;
1116
+ }
1117
+ declare function useFeedbackList(params?: FeedbackListParams): _tanstack_react_query.UseQueryResult<{
1118
+ success: boolean;
1119
+ data: FeedbackListItem[];
1120
+ pagination: {
1121
+ limit: number;
1122
+ offset: number;
1123
+ total: number;
1124
+ };
1125
+ }, Error>;
1126
+
1127
+ interface SubmitFeedbackParams {
1128
+ memoryId?: number;
1129
+ query: string;
1130
+ table: string;
1131
+ schema?: string;
1132
+ status?: "success" | "failure" | "needs_review";
1133
+ corrections?: {
1134
+ domainTerm?: string;
1135
+ domainFieldPath?: string;
1136
+ fieldPath?: string;
1137
+ filters?: any;
1138
+ };
1139
+ feedback?: string;
1140
+ }
1141
+ declare function useSubmitFeedback(): _tanstack_react_query.UseMutationResult<{
1142
+ success: boolean;
1143
+ data: any;
1144
+ }, Error, SubmitFeedbackParams, unknown>;
1145
+
1146
+ declare function useApplyFeedback(): _tanstack_react_query.UseMutationResult<{
1147
+ success: boolean;
1148
+ data: any;
1149
+ learningResults: Array<{
1150
+ type: string;
1151
+ id: number;
1152
+ action: string;
1153
+ }>;
1154
+ }, Error, number, unknown>;
1155
+
1156
+ declare function useResolveFeedback(): _tanstack_react_query.UseMutationResult<{
1157
+ success: boolean;
1158
+ data: any;
1159
+ learningResults: Array<{
1160
+ type: string;
1161
+ id: number;
1162
+ }>;
1163
+ }, Error, number, unknown>;
1164
+
1165
+ export { createInCondition as $, sanitizeStorageKey as A, type useDbUpsertResponse as B, type UseMutationSuccessOptions as C, useMutationSuccess as D, useMutationSuccessRN as E, getErrorBody as F, type AIOptions as G, type AIResponse as H, useAI as I, type ExtractedReceipt as J, type BatchAnalysisProgress as K, type ServerAvailabilityState as L, type MutationOption as M, useServerAvailability as N, useSearchQuery as O, type PendingExpense as P, type UpdateOptions as Q, executeAdvanceQuery as R, SupabaseAdapter as S, type CustomPageQueryResult as T, type UseDbPartialAdvanceQueryResult as U, useSupabaseUpload as V, type UseSupabaseUploadOptions as W, type UseSupabaseUploadReturn as X, type StorageObjectMetadata as Y, BUCKETS as Z, type BucketName as _, useDbAttachmentUpload as a, TIMEOUT_ERROR_MESSAGE as a0, DEFAULT_QUERY_TIMEOUT as a1, isTimeoutError as a2, type AlertProps as a3, LiveChangeContext as a4, LiveChangeContextProvider as a5, useUpsertChangelog as a6, useDeleteChangelog as a7, useUpsertChangelogEntry as a8, useMultiUpsertChangelogEntries as a9, useDeleteChangelogEntry as aa, useMultiDeleteChangelogEntries as ab, useUpsertChangelogMedia as ac, useDeleteChangelogMedia as ad, useUploadChangelogMedia as ae, useChangelogs as af, usePublishedChangelogs as ag, useChangelogById as ah, useChangelogBySlug as ai, useChangelogEntries as aj, useChangelogMedia as ak, useFeedbackList as al, type FeedbackListItem as am, type FeedbackListParams as an, useSubmitFeedback as ao, type SubmitFeedbackParams as ap, useApplyFeedback as aq, useResolveFeedback as ar, useDbInsert as b, useDbUpdate as c, useDbDelete as d, useDbUpsert as e, useDbRealtimeQuery as f, createSupabaseAdapter as g, useSupabaseFunction as h, useReceiptAI as i, useLiveChangeTracking as j, useLatestOperationLog as k, useAutosaveState as l, useToastError as m, newTimeActivity as n, useStorageUrl as o, useStoragePath as p, getSupabaseUrl as q, useDbMultiDelete as r, setSupabaseUrl as s, useDbMultiUpsert as t, useDbRealtime as u, useDbPartialAdvanceQuery as v, type UseDbPartialQueryResult as w, useDbPartialQuery as x, type UseDbRealtimeQueryResult as y, convertFilterToRealtimeQuery as z };