@fluxbase/sdk 0.0.1-rc.42 → 0.0.1-rc.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +854 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +358 -7
- package/dist/index.d.ts +358 -7
- package/dist/index.js +854 -56
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/dist/index.d.cts
CHANGED
|
@@ -179,6 +179,28 @@ interface PostgrestResponse<T> {
|
|
|
179
179
|
status: number;
|
|
180
180
|
statusText: string;
|
|
181
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Count type for select queries (Supabase-compatible)
|
|
184
|
+
* - 'exact': Returns the exact count of rows (SELECT COUNT(*))
|
|
185
|
+
* - 'planned': Uses PostgreSQL's query planner estimate (faster, less accurate)
|
|
186
|
+
* - 'estimated': Uses statistics-based estimate (fastest, least accurate)
|
|
187
|
+
*/
|
|
188
|
+
type CountType = 'exact' | 'planned' | 'estimated';
|
|
189
|
+
/**
|
|
190
|
+
* Options for select queries (Supabase-compatible)
|
|
191
|
+
*/
|
|
192
|
+
interface SelectOptions {
|
|
193
|
+
/**
|
|
194
|
+
* Count type to use for the query
|
|
195
|
+
* When specified, the count will be returned in the response
|
|
196
|
+
*/
|
|
197
|
+
count?: CountType;
|
|
198
|
+
/**
|
|
199
|
+
* If true, only returns count without fetching data (HEAD request)
|
|
200
|
+
* Useful for getting total count without transferring row data
|
|
201
|
+
*/
|
|
202
|
+
head?: boolean;
|
|
203
|
+
}
|
|
182
204
|
type FilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in' | 'cs' | 'cd' | 'ov' | 'sl' | 'sr' | 'nxr' | 'nxl' | 'adj' | 'not' | 'fts' | 'plfts' | 'wfts' | 'st_intersects' | 'st_contains' | 'st_within' | 'st_dwithin' | 'st_distance' | 'st_touches' | 'st_crosses' | 'st_overlaps';
|
|
183
205
|
interface QueryFilter {
|
|
184
206
|
column: string;
|
|
@@ -213,7 +235,7 @@ interface UpsertOptions {
|
|
|
213
235
|
defaultToNull?: boolean;
|
|
214
236
|
}
|
|
215
237
|
interface RealtimeMessage {
|
|
216
|
-
type: 'subscribe' | 'unsubscribe' | 'heartbeat' | 'broadcast' | 'presence' | 'ack' | 'error';
|
|
238
|
+
type: 'subscribe' | 'unsubscribe' | 'heartbeat' | 'broadcast' | 'presence' | 'ack' | 'error' | 'postgres_changes' | 'access_token';
|
|
217
239
|
channel?: string;
|
|
218
240
|
event?: string;
|
|
219
241
|
schema?: string;
|
|
@@ -227,6 +249,7 @@ interface RealtimeMessage {
|
|
|
227
249
|
messageId?: string;
|
|
228
250
|
status?: string;
|
|
229
251
|
subscription_id?: string;
|
|
252
|
+
token?: string;
|
|
230
253
|
}
|
|
231
254
|
interface PostgresChangesConfig {
|
|
232
255
|
event: 'INSERT' | 'UPDATE' | 'DELETE' | '*';
|
|
@@ -367,6 +390,75 @@ interface ListOptions {
|
|
|
367
390
|
interface SignedUrlOptions {
|
|
368
391
|
expiresIn?: number;
|
|
369
392
|
}
|
|
393
|
+
interface DownloadOptions {
|
|
394
|
+
/** If true, returns a ReadableStream instead of Blob */
|
|
395
|
+
stream?: boolean;
|
|
396
|
+
/**
|
|
397
|
+
* Timeout in milliseconds for the download request.
|
|
398
|
+
* For streaming downloads, this applies to the initial response.
|
|
399
|
+
* Set to 0 or undefined for no timeout (recommended for large files).
|
|
400
|
+
* @default undefined (no timeout for streaming, 30000 for non-streaming)
|
|
401
|
+
*/
|
|
402
|
+
timeout?: number;
|
|
403
|
+
/** AbortSignal to cancel the download */
|
|
404
|
+
signal?: AbortSignal;
|
|
405
|
+
}
|
|
406
|
+
/** Response type for stream downloads, includes file size from Content-Length header */
|
|
407
|
+
interface StreamDownloadData {
|
|
408
|
+
/** The readable stream for the file content */
|
|
409
|
+
stream: ReadableStream<Uint8Array>;
|
|
410
|
+
/** File size in bytes from Content-Length header, or null if unknown */
|
|
411
|
+
size: number | null;
|
|
412
|
+
}
|
|
413
|
+
/** Options for resumable chunked downloads */
|
|
414
|
+
interface ResumableDownloadOptions {
|
|
415
|
+
/**
|
|
416
|
+
* Chunk size in bytes for each download request.
|
|
417
|
+
* @default 5242880 (5MB)
|
|
418
|
+
*/
|
|
419
|
+
chunkSize?: number;
|
|
420
|
+
/**
|
|
421
|
+
* Number of retry attempts per chunk on failure.
|
|
422
|
+
* @default 3
|
|
423
|
+
*/
|
|
424
|
+
maxRetries?: number;
|
|
425
|
+
/**
|
|
426
|
+
* Base delay in milliseconds for exponential backoff.
|
|
427
|
+
* @default 1000
|
|
428
|
+
*/
|
|
429
|
+
retryDelayMs?: number;
|
|
430
|
+
/**
|
|
431
|
+
* Timeout in milliseconds per chunk request.
|
|
432
|
+
* @default 30000
|
|
433
|
+
*/
|
|
434
|
+
chunkTimeout?: number;
|
|
435
|
+
/** AbortSignal to cancel the download */
|
|
436
|
+
signal?: AbortSignal;
|
|
437
|
+
/** Callback for download progress */
|
|
438
|
+
onProgress?: (progress: DownloadProgress) => void;
|
|
439
|
+
}
|
|
440
|
+
/** Download progress information */
|
|
441
|
+
interface DownloadProgress {
|
|
442
|
+
/** Number of bytes downloaded so far */
|
|
443
|
+
loaded: number;
|
|
444
|
+
/** Total file size in bytes, or null if unknown */
|
|
445
|
+
total: number | null;
|
|
446
|
+
/** Download percentage (0-100), or null if total is unknown */
|
|
447
|
+
percentage: number | null;
|
|
448
|
+
/** Current chunk being downloaded (1-indexed) */
|
|
449
|
+
currentChunk: number;
|
|
450
|
+
/** Total number of chunks, or null if total size unknown */
|
|
451
|
+
totalChunks: number | null;
|
|
452
|
+
/** Transfer rate in bytes per second */
|
|
453
|
+
bytesPerSecond: number;
|
|
454
|
+
}
|
|
455
|
+
/** Response type for resumable downloads - stream abstracts chunking */
|
|
456
|
+
interface ResumableDownloadData {
|
|
457
|
+
/** The readable stream for the file content (abstracts chunking internally) */
|
|
458
|
+
stream: ReadableStream<Uint8Array>;
|
|
459
|
+
/** File size in bytes from HEAD request, or null if unknown */
|
|
460
|
+
size: number | null;
|
|
461
|
+
}
|
|
370
462
|
interface ShareFileOptions {
|
|
371
463
|
userId: string;
|
|
372
464
|
permission: 'read' | 'write';
|
|
@@ -1512,6 +1604,10 @@ interface JobFunctionSpec {
|
|
|
1512
1604
|
is_pre_bundled?: boolean;
|
|
1513
1605
|
/** Original source code (for debugging when pre-bundled) */
|
|
1514
1606
|
original_code?: string;
|
|
1607
|
+
/** Source directory for resolving relative imports during bundling (used by syncWithBundling) */
|
|
1608
|
+
sourceDir?: string;
|
|
1609
|
+
/** Additional paths to search for node_modules during bundling (used by syncWithBundling) */
|
|
1610
|
+
nodePaths?: string[];
|
|
1515
1611
|
enabled?: boolean;
|
|
1516
1612
|
schedule?: string;
|
|
1517
1613
|
timeout_seconds?: number;
|
|
@@ -1748,10 +1844,18 @@ declare class RealtimeChannel {
|
|
|
1748
1844
|
private reconnectAttempts;
|
|
1749
1845
|
private maxReconnectAttempts;
|
|
1750
1846
|
private reconnectDelay;
|
|
1847
|
+
private shouldReconnect;
|
|
1751
1848
|
private heartbeatInterval;
|
|
1752
1849
|
private pendingAcks;
|
|
1753
1850
|
private messageIdCounter;
|
|
1851
|
+
private onTokenRefreshNeeded;
|
|
1852
|
+
private isRefreshingToken;
|
|
1754
1853
|
constructor(url: string, channelName: string, token?: string | null, config?: RealtimeChannelConfig);
|
|
1854
|
+
/**
|
|
1855
|
+
* Set callback to request a token refresh when connection fails due to auth
|
|
1856
|
+
* @internal
|
|
1857
|
+
*/
|
|
1858
|
+
setTokenRefreshCallback(callback: () => Promise<string | null>): void;
|
|
1755
1859
|
/**
|
|
1756
1860
|
* Listen to postgres_changes with optional row-level filtering
|
|
1757
1861
|
*
|
|
@@ -1894,10 +1998,18 @@ declare class RealtimeChannel {
|
|
|
1894
1998
|
* ```
|
|
1895
1999
|
*/
|
|
1896
2000
|
presenceState(): Record<string, PresenceState[]>;
|
|
2001
|
+
/**
|
|
2002
|
+
* Check if the current token is expired or about to expire
|
|
2003
|
+
*/
|
|
2004
|
+
private isTokenExpired;
|
|
1897
2005
|
/**
|
|
1898
2006
|
* Internal: Connect to WebSocket
|
|
1899
2007
|
*/
|
|
1900
2008
|
private connect;
|
|
2009
|
+
/**
|
|
2010
|
+
* Internal: Actually establish the WebSocket connection
|
|
2011
|
+
*/
|
|
2012
|
+
private connectWithToken;
|
|
1901
2013
|
/**
|
|
1902
2014
|
* Internal: Disconnect WebSocket
|
|
1903
2015
|
*/
|
|
@@ -1930,6 +2042,15 @@ declare class RealtimeChannel {
|
|
|
1930
2042
|
* Internal: Stop heartbeat interval
|
|
1931
2043
|
*/
|
|
1932
2044
|
private stopHeartbeat;
|
|
2045
|
+
/**
|
|
2046
|
+
* Update the authentication token on an existing connection
|
|
2047
|
+
* Sends an access_token message to the server to update auth context
|
|
2048
|
+
* On failure, silently triggers a reconnect
|
|
2049
|
+
*
|
|
2050
|
+
* @param token - The new JWT access token
|
|
2051
|
+
* @internal
|
|
2052
|
+
*/
|
|
2053
|
+
updateToken(token: string | null): void;
|
|
1933
2054
|
/**
|
|
1934
2055
|
* Internal: Attempt to reconnect
|
|
1935
2056
|
*/
|
|
@@ -1939,7 +2060,14 @@ declare class FluxbaseRealtime {
|
|
|
1939
2060
|
private url;
|
|
1940
2061
|
private token;
|
|
1941
2062
|
private channels;
|
|
2063
|
+
private tokenRefreshCallback;
|
|
1942
2064
|
constructor(url: string, token?: string | null);
|
|
2065
|
+
/**
|
|
2066
|
+
* Set callback to request a token refresh when connections fail due to auth
|
|
2067
|
+
* This callback should refresh the auth token and return the new access token
|
|
2068
|
+
* @internal
|
|
2069
|
+
*/
|
|
2070
|
+
setTokenRefreshCallback(callback: () => Promise<string | null>): void;
|
|
1943
2071
|
/**
|
|
1944
2072
|
* Create or get a channel with optional configuration
|
|
1945
2073
|
*
|
|
@@ -1975,6 +2103,9 @@ declare class FluxbaseRealtime {
|
|
|
1975
2103
|
removeAllChannels(): void;
|
|
1976
2104
|
/**
|
|
1977
2105
|
* Update auth token for all channels
|
|
2106
|
+
* Updates both the stored token for new channels and propagates
|
|
2107
|
+
* the token to all existing connected channels.
|
|
2108
|
+
*
|
|
1978
2109
|
* @param token - The new auth token
|
|
1979
2110
|
*/
|
|
1980
2111
|
setAuth(token: string | null): void;
|
|
@@ -1989,29 +2120,82 @@ interface FetchOptions {
|
|
|
1989
2120
|
headers?: Record<string, string>;
|
|
1990
2121
|
body?: unknown;
|
|
1991
2122
|
timeout?: number;
|
|
2123
|
+
/** Skip automatic token refresh on 401 (used for auth endpoints) */
|
|
2124
|
+
skipAutoRefresh?: boolean;
|
|
1992
2125
|
}
|
|
2126
|
+
/**
|
|
2127
|
+
* Response with headers included (for count queries)
|
|
2128
|
+
*/
|
|
2129
|
+
interface FetchResponseWithHeaders<T> {
|
|
2130
|
+
data: T;
|
|
2131
|
+
headers: Headers;
|
|
2132
|
+
status: number;
|
|
2133
|
+
}
|
|
2134
|
+
/** Callback type for automatic token refresh on 401 errors */
|
|
2135
|
+
type RefreshTokenCallback = () => Promise<boolean>;
|
|
1993
2136
|
declare class FluxbaseFetch {
|
|
1994
2137
|
private baseUrl;
|
|
1995
2138
|
private defaultHeaders;
|
|
1996
2139
|
private timeout;
|
|
1997
2140
|
private debug;
|
|
2141
|
+
private refreshTokenCallback;
|
|
2142
|
+
private isRefreshing;
|
|
2143
|
+
private refreshPromise;
|
|
2144
|
+
private anonKey;
|
|
1998
2145
|
constructor(baseUrl: string, options?: {
|
|
1999
2146
|
headers?: Record<string, string>;
|
|
2000
2147
|
timeout?: number;
|
|
2001
2148
|
debug?: boolean;
|
|
2002
2149
|
});
|
|
2150
|
+
/**
|
|
2151
|
+
* Register a callback to refresh the token when a 401 error occurs
|
|
2152
|
+
* The callback should return true if refresh was successful, false otherwise
|
|
2153
|
+
*/
|
|
2154
|
+
setRefreshTokenCallback(callback: RefreshTokenCallback | null): void;
|
|
2155
|
+
/**
|
|
2156
|
+
* Set the anon key for fallback authentication
|
|
2157
|
+
* When setAuthToken(null) is called, the Authorization header will be
|
|
2158
|
+
* restored to use this anon key instead of being deleted
|
|
2159
|
+
*/
|
|
2160
|
+
setAnonKey(key: string): void;
|
|
2003
2161
|
/**
|
|
2004
2162
|
* Update the authorization header
|
|
2163
|
+
* When token is null, restores to anon key if available
|
|
2005
2164
|
*/
|
|
2006
2165
|
setAuthToken(token: string | null): void;
|
|
2007
2166
|
/**
|
|
2008
2167
|
* Make an HTTP request
|
|
2009
2168
|
*/
|
|
2010
2169
|
request<T = unknown>(path: string, options: FetchOptions): Promise<T>;
|
|
2170
|
+
/**
|
|
2171
|
+
* Internal request implementation with retry capability
|
|
2172
|
+
*/
|
|
2173
|
+
private requestInternal;
|
|
2174
|
+
/**
|
|
2175
|
+
* Handle token refresh with deduplication
|
|
2176
|
+
* Multiple concurrent requests that fail with 401 will share the same refresh operation
|
|
2177
|
+
*/
|
|
2178
|
+
private handleTokenRefresh;
|
|
2179
|
+
/**
|
|
2180
|
+
* Execute the actual token refresh
|
|
2181
|
+
*/
|
|
2182
|
+
private executeRefresh;
|
|
2011
2183
|
/**
|
|
2012
2184
|
* GET request
|
|
2013
2185
|
*/
|
|
2014
2186
|
get<T = unknown>(path: string, options?: Omit<FetchOptions, 'method'>): Promise<T>;
|
|
2187
|
+
/**
|
|
2188
|
+
* GET request that returns response with headers (for count queries)
|
|
2189
|
+
*/
|
|
2190
|
+
getWithHeaders<T = unknown>(path: string, options?: Omit<FetchOptions, 'method'>): Promise<FetchResponseWithHeaders<T>>;
|
|
2191
|
+
/**
|
|
2192
|
+
* Make an HTTP request and return response with headers
|
|
2193
|
+
*/
|
|
2194
|
+
requestWithHeaders<T = unknown>(path: string, options: FetchOptions): Promise<FetchResponseWithHeaders<T>>;
|
|
2195
|
+
/**
|
|
2196
|
+
* Internal request implementation that returns response with headers
|
|
2197
|
+
*/
|
|
2198
|
+
private requestWithHeadersInternal;
|
|
2015
2199
|
/**
|
|
2016
2200
|
* POST request
|
|
2017
2201
|
*/
|
|
@@ -2086,6 +2270,17 @@ declare class FluxbaseAuth {
|
|
|
2086
2270
|
subscription: AuthSubscription;
|
|
2087
2271
|
};
|
|
2088
2272
|
};
|
|
2273
|
+
/**
|
|
2274
|
+
* Start the automatic token refresh timer
|
|
2275
|
+
* This is called automatically when autoRefresh is enabled and a session exists
|
|
2276
|
+
* Only works in browser environments
|
|
2277
|
+
*/
|
|
2278
|
+
startAutoRefresh(): void;
|
|
2279
|
+
/**
|
|
2280
|
+
* Stop the automatic token refresh timer
|
|
2281
|
+
* Call this when you want to disable auto-refresh without signing out
|
|
2282
|
+
*/
|
|
2283
|
+
stopAutoRefresh(): void;
|
|
2089
2284
|
/**
|
|
2090
2285
|
* Sign in with email and password (Supabase-compatible)
|
|
2091
2286
|
* Returns { user, session } if successful, or SignInWith2FAResponse if 2FA is required
|
|
@@ -2318,8 +2513,14 @@ declare class FluxbaseAuth {
|
|
|
2318
2513
|
private saveSession;
|
|
2319
2514
|
/**
|
|
2320
2515
|
* Internal: Schedule automatic token refresh
|
|
2516
|
+
* Only runs in browser environments when autoRefresh is enabled
|
|
2321
2517
|
*/
|
|
2322
2518
|
private scheduleTokenRefresh;
|
|
2519
|
+
/**
|
|
2520
|
+
* Internal: Attempt to refresh the token with retry logic
|
|
2521
|
+
* Uses exponential backoff: 1s, 2s, 4s delays between retries
|
|
2522
|
+
*/
|
|
2523
|
+
private attemptRefresh;
|
|
2323
2524
|
/**
|
|
2324
2525
|
* Internal: Emit auth state change event to all listeners
|
|
2325
2526
|
*/
|
|
@@ -2356,11 +2557,70 @@ declare class StorageBucket {
|
|
|
2356
2557
|
/**
|
|
2357
2558
|
* Download a file from the bucket
|
|
2358
2559
|
* @param path - The path/key of the file
|
|
2560
|
+
* @param options - Download options (use { stream: true } for streaming)
|
|
2561
|
+
*
|
|
2562
|
+
* @example
|
|
2563
|
+
* ```typescript
|
|
2564
|
+
* // Default: returns Blob
|
|
2565
|
+
* const { data: blob } = await storage.from('bucket').download('file.pdf');
|
|
2566
|
+
*
|
|
2567
|
+
* // Streaming: returns { stream, size } for progress tracking
|
|
2568
|
+
* const { data } = await storage.from('bucket').download('large.json', { stream: true });
|
|
2569
|
+
* console.log(`File size: ${data.size} bytes`);
|
|
2570
|
+
* // Process data.stream...
|
|
2571
|
+
* ```
|
|
2359
2572
|
*/
|
|
2360
2573
|
download(path: string): Promise<{
|
|
2361
2574
|
data: Blob | null;
|
|
2362
2575
|
error: Error | null;
|
|
2363
2576
|
}>;
|
|
2577
|
+
download(path: string, options: {
|
|
2578
|
+
stream: true;
|
|
2579
|
+
timeout?: number;
|
|
2580
|
+
signal?: AbortSignal;
|
|
2581
|
+
}): Promise<{
|
|
2582
|
+
data: StreamDownloadData | null;
|
|
2583
|
+
error: Error | null;
|
|
2584
|
+
}>;
|
|
2585
|
+
download(path: string, options: {
|
|
2586
|
+
stream?: false;
|
|
2587
|
+
timeout?: number;
|
|
2588
|
+
signal?: AbortSignal;
|
|
2589
|
+
}): Promise<{
|
|
2590
|
+
data: Blob | null;
|
|
2591
|
+
error: Error | null;
|
|
2592
|
+
}>;
|
|
2593
|
+
/**
|
|
2594
|
+
* Download a file with resumable chunked downloads for large files.
|
|
2595
|
+
* Returns a ReadableStream that abstracts the chunking internally.
|
|
2596
|
+
*
|
|
2597
|
+
* Features:
|
|
2598
|
+
* - Downloads file in chunks using HTTP Range headers
|
|
2599
|
+
* - Automatically retries failed chunks with exponential backoff
|
|
2600
|
+
* - Reports progress via callback
|
|
2601
|
+
* - Falls back to regular streaming if Range not supported
|
|
2602
|
+
*
|
|
2603
|
+
* @param path - The file path within the bucket
|
|
2604
|
+
* @param options - Download options including chunk size, retries, and progress callback
|
|
2605
|
+
* @returns A ReadableStream and file size (consumer doesn't need to know about chunking)
|
|
2606
|
+
*
|
|
2607
|
+
* @example
|
|
2608
|
+
* ```typescript
|
|
2609
|
+
* const { data, error } = await storage.from('bucket').downloadResumable('large.json', {
|
|
2610
|
+
* chunkSize: 5 * 1024 * 1024, // 5MB chunks
|
|
2611
|
+
* maxRetries: 3,
|
|
2612
|
+
* onProgress: (progress) => console.log(`${progress.percentage}% complete`)
|
|
2613
|
+
* });
|
|
2614
|
+
* if (data) {
|
|
2615
|
+
* console.log(`File size: ${data.size} bytes`);
|
|
2616
|
+
* // Process data.stream...
|
|
2617
|
+
* }
|
|
2618
|
+
* ```
|
|
2619
|
+
*/
|
|
2620
|
+
downloadResumable(path: string, options?: ResumableDownloadOptions): Promise<{
|
|
2621
|
+
data: ResumableDownloadData | null;
|
|
2622
|
+
error: Error | null;
|
|
2623
|
+
}>;
|
|
2364
2624
|
/**
|
|
2365
2625
|
* List files in the bucket
|
|
2366
2626
|
* Supports both Supabase-style list(path, options) and Fluxbase-style list(options)
|
|
@@ -5111,6 +5371,14 @@ interface BundleOptions {
|
|
|
5111
5371
|
sourcemap?: boolean;
|
|
5112
5372
|
/** Minify output */
|
|
5113
5373
|
minify?: boolean;
|
|
5374
|
+
/** Import map from deno.json (maps aliases to npm: or file paths) */
|
|
5375
|
+
importMap?: Record<string, string>;
|
|
5376
|
+
/** Base directory for resolving relative imports (resolveDir in esbuild) */
|
|
5377
|
+
baseDir?: string;
|
|
5378
|
+
/** Additional paths to search for node_modules (useful when importing from parent directories) */
|
|
5379
|
+
nodePaths?: string[];
|
|
5380
|
+
/** Custom define values for esbuild (e.g., { 'process.env.NODE_ENV': '"production"' }) */
|
|
5381
|
+
define?: Record<string, string>;
|
|
5114
5382
|
}
|
|
5115
5383
|
/**
|
|
5116
5384
|
* Result of bundling job code
|
|
@@ -5754,6 +6022,7 @@ declare class FluxbaseAdmin {
|
|
|
5754
6022
|
declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse<T>> {
|
|
5755
6023
|
private fetch;
|
|
5756
6024
|
private table;
|
|
6025
|
+
private schema?;
|
|
5757
6026
|
private selectQuery;
|
|
5758
6027
|
private filters;
|
|
5759
6028
|
private orFilters;
|
|
@@ -5765,16 +6034,24 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
|
|
|
5765
6034
|
private maybeSingleRow;
|
|
5766
6035
|
private groupByColumns?;
|
|
5767
6036
|
private operationType;
|
|
6037
|
+
private countType?;
|
|
6038
|
+
private headOnly;
|
|
5768
6039
|
private insertData?;
|
|
5769
6040
|
private updateData?;
|
|
5770
|
-
constructor(fetch: FluxbaseFetch, table: string);
|
|
6041
|
+
constructor(fetch: FluxbaseFetch, table: string, schema?: string);
|
|
6042
|
+
/**
|
|
6043
|
+
* Build the API path for this table, including schema if specified
|
|
6044
|
+
*/
|
|
6045
|
+
private buildTablePath;
|
|
5771
6046
|
/**
|
|
5772
6047
|
* Select columns to return
|
|
5773
6048
|
* @example select('*')
|
|
5774
6049
|
* @example select('id, name, email')
|
|
5775
6050
|
* @example select('id, name, posts(title, content)')
|
|
6051
|
+
* @example select('*', { count: 'exact' }) // Get exact count
|
|
6052
|
+
* @example select('*', { count: 'exact', head: true }) // Get count only (no data)
|
|
5776
6053
|
*/
|
|
5777
|
-
select(columns?: string): this;
|
|
6054
|
+
select(columns?: string, options?: SelectOptions): this;
|
|
5778
6055
|
/**
|
|
5779
6056
|
* Insert a single row or multiple rows
|
|
5780
6057
|
*/
|
|
@@ -6215,6 +6492,38 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
|
|
|
6215
6492
|
* Format a value for the query string
|
|
6216
6493
|
*/
|
|
6217
6494
|
private formatValue;
|
|
6495
|
+
/**
|
|
6496
|
+
* Parse the Content-Range header to extract the total count
|
|
6497
|
+
* Header format: "0-999/50000" or "* /50000" (when no rows returned)
|
|
6498
|
+
*/
|
|
6499
|
+
private parseContentRangeCount;
|
|
6500
|
+
}
|
|
6501
|
+
|
|
6502
|
+
/**
|
|
6503
|
+
* Schema-scoped query builder for accessing tables in non-public schemas.
|
|
6504
|
+
*
|
|
6505
|
+
* @example
|
|
6506
|
+
* ```typescript
|
|
6507
|
+
* // Query the jobs.execution_logs table
|
|
6508
|
+
* const { data } = await client
|
|
6509
|
+
* .schema('jobs')
|
|
6510
|
+
* .from('execution_logs')
|
|
6511
|
+
* .select('*')
|
|
6512
|
+
* .execute();
|
|
6513
|
+
* ```
|
|
6514
|
+
*/
|
|
6515
|
+
|
|
6516
|
+
declare class SchemaQueryBuilder {
|
|
6517
|
+
private fetch;
|
|
6518
|
+
private schemaName;
|
|
6519
|
+
constructor(fetch: FluxbaseFetch, schemaName: string);
|
|
6520
|
+
/**
|
|
6521
|
+
* Create a query builder for a table in this schema
|
|
6522
|
+
*
|
|
6523
|
+
* @param table - The table name (without schema prefix)
|
|
6524
|
+
* @returns A query builder instance for constructing and executing queries
|
|
6525
|
+
*/
|
|
6526
|
+
from<T = any>(table: string): QueryBuilder<T>;
|
|
6218
6527
|
}
|
|
6219
6528
|
|
|
6220
6529
|
/**
|
|
@@ -6284,6 +6593,35 @@ declare class FluxbaseClient<Database = any, _SchemaName extends string & keyof
|
|
|
6284
6593
|
* @category Database
|
|
6285
6594
|
*/
|
|
6286
6595
|
from<T = any>(table: string): QueryBuilder<T>;
|
|
6596
|
+
/**
|
|
6597
|
+
* Access a specific database schema
|
|
6598
|
+
*
|
|
6599
|
+
* Use this to query tables in non-public schemas.
|
|
6600
|
+
*
|
|
6601
|
+
* @param schemaName - The schema name (e.g., 'jobs', 'analytics')
|
|
6602
|
+
* @returns A schema query builder for constructing queries on that schema
|
|
6603
|
+
*
|
|
6604
|
+
* @example
|
|
6605
|
+
* ```typescript
|
|
6606
|
+
* // Query the jobs.execution_logs table
|
|
6607
|
+
* const { data } = await client
|
|
6608
|
+
* .schema('jobs')
|
|
6609
|
+
* .from('execution_logs')
|
|
6610
|
+
* .select('*')
|
|
6611
|
+
* .eq('job_id', jobId)
|
|
6612
|
+
* .execute()
|
|
6613
|
+
*
|
|
6614
|
+
* // Insert into a custom schema table
|
|
6615
|
+
* await client
|
|
6616
|
+
* .schema('analytics')
|
|
6617
|
+
* .from('events')
|
|
6618
|
+
* .insert({ event_type: 'click', data: {} })
|
|
6619
|
+
* .execute()
|
|
6620
|
+
* ```
|
|
6621
|
+
*
|
|
6622
|
+
* @category Database
|
|
6623
|
+
*/
|
|
6624
|
+
schema(schemaName: string): SchemaQueryBuilder;
|
|
6287
6625
|
/**
|
|
6288
6626
|
* Call a PostgreSQL function (Remote Procedure Call)
|
|
6289
6627
|
*
|
|
@@ -6391,8 +6729,18 @@ declare class FluxbaseClient<Database = any, _SchemaName extends string & keyof
|
|
|
6391
6729
|
*
|
|
6392
6730
|
* This function signature is identical to Supabase's createClient, making migration seamless.
|
|
6393
6731
|
*
|
|
6394
|
-
*
|
|
6395
|
-
*
|
|
6732
|
+
* When called without arguments (or with undefined values), the function will attempt to
|
|
6733
|
+
* read from environment variables:
|
|
6734
|
+
* - `FLUXBASE_URL` - The URL of your Fluxbase instance
|
|
6735
|
+
* - `FLUXBASE_ANON_KEY` or `FLUXBASE_JOB_TOKEN` or `FLUXBASE_SERVICE_TOKEN` - The API key/token
|
|
6736
|
+
*
|
|
6737
|
+
* This is useful in:
|
|
6738
|
+
* - Server-side environments where env vars are set
|
|
6739
|
+
* - Fluxbase job functions where tokens are automatically provided
|
|
6740
|
+
* - Edge functions with configured environment
|
|
6741
|
+
*
|
|
6742
|
+
* @param fluxbaseUrl - The URL of your Fluxbase instance (optional if FLUXBASE_URL env var is set)
|
|
6743
|
+
* @param fluxbaseKey - The anon key or JWT token (optional if env var is set)
|
|
6396
6744
|
* @param options - Optional client configuration
|
|
6397
6745
|
* @returns A configured Fluxbase client instance with full TypeScript support
|
|
6398
6746
|
*
|
|
@@ -6413,6 +6761,9 @@ declare class FluxbaseClient<Database = any, _SchemaName extends string & keyof
|
|
|
6413
6761
|
* { timeout: 30000, debug: true }
|
|
6414
6762
|
* )
|
|
6415
6763
|
*
|
|
6764
|
+
* // In a Fluxbase job function (reads from env vars automatically)
|
|
6765
|
+
* const client = createClient()
|
|
6766
|
+
*
|
|
6416
6767
|
* // With TypeScript database types
|
|
6417
6768
|
* const client = createClient<Database>(
|
|
6418
6769
|
* 'http://localhost:8080',
|
|
@@ -6422,6 +6773,6 @@ declare class FluxbaseClient<Database = any, _SchemaName extends string & keyof
|
|
|
6422
6773
|
*
|
|
6423
6774
|
* @category Client
|
|
6424
6775
|
*/
|
|
6425
|
-
declare function createClient<Database = any, SchemaName extends string & keyof Database = any>(fluxbaseUrl
|
|
6776
|
+
declare function createClient<Database = any, SchemaName extends string & keyof Database = any>(fluxbaseUrl?: string, fluxbaseKey?: string, options?: FluxbaseClientOptions): FluxbaseClient<Database, SchemaName>;
|
|
6426
6777
|
|
|
6427
|
-
export { type APIKey, APIKeysManager, type AcceptInvitationRequest, type AcceptInvitationResponse, type AdminAuthResponse, type AdminLoginRequest, type AdminMeResponse, type AdminRefreshRequest, type AdminRefreshResponse, type AdminSetupRequest, type AdminSetupStatusResponse, type AdminUser, type AppSettings, AppSettingsManager, type ApplyMigrationRequest, type ApplyPendingRequest, type AuthResponse, type AuthResponseData, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type BroadcastCallback, type BroadcastMessage, type BundleOptions, type BundleResult, type Column, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateColumnRequest, type CreateFunctionRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateMigrationRequest, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateWebhookRequest, DDLManager, type DataResponse, type DeleteAPIKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type EdgeFunction, type EdgeFunctionExecution, type EmailSettings, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EnrichedUser, type FeatureSettings, type FileObject, type FilterOperator, FluxbaseAdmin, FluxbaseAdminFunctions, FluxbaseAdminJobs, FluxbaseAdminMigrations, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseJobs, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, type FluxbaseResponse, FluxbaseSettings, FluxbaseStorage, type FunctionInvokeOptions, type FunctionSpec, type GetImpersonationResponse, type HttpMethod, type ImpersonateAnonRequest, type ImpersonateServiceRequest, type ImpersonateUserRequest, ImpersonationManager, type ImpersonationSession, type ImpersonationTargetUser, type ImpersonationType, type Invitation, InvitationsManager, type InviteUserRequest, type InviteUserResponse, type ListAPIKeysResponse, type ListEmailTemplatesResponse, type ListImpersonationSessionsOptions, type ListImpersonationSessionsResponse, type ListInvitationsOptions, type ListInvitationsResponse, type ListOAuthProvidersResponse, type ListOptions, type ListSchemasResponse, type ListSystemSettingsResponse, type ListTablesResponse, type ListUsersOptions, type ListUsersResponse, type ListWebhookDeliveriesResponse, type ListWebhooksResponse, type MailgunSettings, type Migration, type MigrationExecution, type OAuthProvider, OAuthProviderManager, type OrderBy, type OrderDirection, type PostgresChangesConfig, type PostgrestError, type PostgrestResponse, type PresenceCallback, type PresenceState, QueryBuilder, type QueryFilter, type RealtimeBroadcastPayload, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeChannelConfig, type RealtimeMessage, type RealtimePostgresChangesPayload, type RealtimePresencePayload, type RequestOptions, type ResetUserPasswordResponse, type RevokeAPIKeyResponse, type RevokeInvitationResponse, type RollbackMigrationRequest, type SESSettings, type SMTPSettings, type Schema, type SecuritySettings, type SendGridSettings, type SessionResponse, SettingsClient, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type SupabaseAuthResponse, type SupabaseResponse, type SyncError, type SyncFunctionsOptions, type SyncFunctionsResult, type SyncMigrationsOptions, type SyncMigrationsResult, type SystemSetting, SystemSettingsManager, type Table, type TestEmailTemplateRequest, type TestWebhookResponse, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateMigrationRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateSystemSettingRequest, type UpdateUserAttributes, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type UploadProgress, type UpsertOptions, type User, type UserResponse, type ValidateInvitationResponse, type VoidResponse, type WeakPassword, type Webhook, type WebhookDelivery, WebhooksManager, createClient };
|
|
6778
|
+
export { type APIKey, APIKeysManager, type AcceptInvitationRequest, type AcceptInvitationResponse, type AdminAuthResponse, type AdminLoginRequest, type AdminMeResponse, type AdminRefreshRequest, type AdminRefreshResponse, type AdminSetupRequest, type AdminSetupStatusResponse, type AdminUser, type AppSettings, AppSettingsManager, type ApplyMigrationRequest, type ApplyPendingRequest, type AuthResponse, type AuthResponseData, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type BroadcastCallback, type BroadcastMessage, type BundleOptions, type BundleResult, type Column, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateColumnRequest, type CreateFunctionRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateMigrationRequest, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateWebhookRequest, DDLManager, type DataResponse, type DeleteAPIKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type DownloadOptions, type DownloadProgress, type EdgeFunction, type EdgeFunctionExecution, type EmailSettings, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EnrichedUser, type FeatureSettings, type FileObject, type FilterOperator, FluxbaseAdmin, FluxbaseAdminFunctions, FluxbaseAdminJobs, FluxbaseAdminMigrations, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseJobs, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, type FluxbaseResponse, FluxbaseSettings, FluxbaseStorage, type FunctionInvokeOptions, type FunctionSpec, type GetImpersonationResponse, type HttpMethod, type ImpersonateAnonRequest, type ImpersonateServiceRequest, type ImpersonateUserRequest, ImpersonationManager, type ImpersonationSession, type ImpersonationTargetUser, type ImpersonationType, type Invitation, InvitationsManager, type InviteUserRequest, type InviteUserResponse, type ListAPIKeysResponse, type ListEmailTemplatesResponse, type ListImpersonationSessionsOptions, type ListImpersonationSessionsResponse, type ListInvitationsOptions, type ListInvitationsResponse, type ListOAuthProvidersResponse, type ListOptions, type ListSchemasResponse, type ListSystemSettingsResponse, type ListTablesResponse, type ListUsersOptions, type ListUsersResponse, type ListWebhookDeliveriesResponse, type ListWebhooksResponse, type MailgunSettings, type Migration, type MigrationExecution, type OAuthProvider, OAuthProviderManager, type OrderBy, type OrderDirection, type PostgresChangesConfig, type PostgrestError, type PostgrestResponse, type PresenceCallback, type PresenceState, QueryBuilder, type QueryFilter, type RealtimeBroadcastPayload, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeChannelConfig, type RealtimeMessage, type RealtimePostgresChangesPayload, type RealtimePresencePayload, type RequestOptions, type ResetUserPasswordResponse, type ResumableDownloadData, type ResumableDownloadOptions, type RevokeAPIKeyResponse, type RevokeInvitationResponse, type RollbackMigrationRequest, type SESSettings, type SMTPSettings, type Schema, SchemaQueryBuilder, type SecuritySettings, type SendGridSettings, type SessionResponse, SettingsClient, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type StreamDownloadData, type SupabaseAuthResponse, type SupabaseResponse, type SyncError, type SyncFunctionsOptions, type SyncFunctionsResult, type SyncMigrationsOptions, type SyncMigrationsResult, type SystemSetting, SystemSettingsManager, type Table, type TestEmailTemplateRequest, type TestWebhookResponse, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateMigrationRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateSystemSettingRequest, type UpdateUserAttributes, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type UploadProgress, type UpsertOptions, type User, type UserResponse, type ValidateInvitationResponse, type VoidResponse, type WeakPassword, type Webhook, type WebhookDelivery, WebhooksManager, createClient };
|