@fluxbase/sdk 0.0.1-rc.14 → 0.0.1-rc.16
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 +355 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +486 -171
- package/dist/index.d.ts +486 -171
- package/dist/index.js +355 -34
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -149,24 +149,60 @@ interface PostgresChangesConfig {
|
|
|
149
149
|
table: string;
|
|
150
150
|
filter?: string;
|
|
151
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Realtime postgres_changes payload structure
|
|
154
|
+
* Compatible with Supabase realtime payloads
|
|
155
|
+
*/
|
|
156
|
+
interface RealtimePostgresChangesPayload<T = any> {
|
|
157
|
+
/** Event type (Supabase-compatible field name) */
|
|
158
|
+
eventType: 'INSERT' | 'UPDATE' | 'DELETE' | '*';
|
|
159
|
+
/** Database schema */
|
|
160
|
+
schema: string;
|
|
161
|
+
/** Table name */
|
|
162
|
+
table: string;
|
|
163
|
+
/** Commit timestamp (Supabase-compatible field name) */
|
|
164
|
+
commit_timestamp: string;
|
|
165
|
+
/** New record data (Supabase-compatible field name) */
|
|
166
|
+
new: T;
|
|
167
|
+
/** Old record data (Supabase-compatible field name) */
|
|
168
|
+
old: T;
|
|
169
|
+
/** Error message if any */
|
|
170
|
+
errors: string | null;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* @deprecated Use RealtimePostgresChangesPayload instead
|
|
174
|
+
*/
|
|
152
175
|
interface RealtimeChangePayload {
|
|
176
|
+
/** @deprecated Use eventType instead */
|
|
153
177
|
type: 'INSERT' | 'UPDATE' | 'DELETE';
|
|
154
178
|
schema: string;
|
|
155
179
|
table: string;
|
|
180
|
+
/** @deprecated Use 'new' instead */
|
|
156
181
|
new_record?: Record<string, unknown>;
|
|
182
|
+
/** @deprecated Use 'old' instead */
|
|
157
183
|
old_record?: Record<string, unknown>;
|
|
184
|
+
/** @deprecated Use commit_timestamp instead */
|
|
158
185
|
timestamp: string;
|
|
159
186
|
}
|
|
160
|
-
type RealtimeCallback = (payload:
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
187
|
+
type RealtimeCallback = (payload: RealtimePostgresChangesPayload) => void;
|
|
188
|
+
/**
|
|
189
|
+
* File object returned by storage operations
|
|
190
|
+
* Compatible with Supabase FileObject structure
|
|
191
|
+
*/
|
|
192
|
+
interface FileObject {
|
|
193
|
+
name: string;
|
|
194
|
+
id?: string;
|
|
195
|
+
bucket_id?: string;
|
|
196
|
+
owner?: string;
|
|
197
|
+
created_at?: string;
|
|
198
|
+
updated_at?: string;
|
|
199
|
+
last_accessed_at?: string;
|
|
200
|
+
metadata?: Record<string, any>;
|
|
169
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* @deprecated Use FileObject instead. This alias is provided for backwards compatibility.
|
|
204
|
+
*/
|
|
205
|
+
type StorageObject = FileObject;
|
|
170
206
|
interface UploadOptions {
|
|
171
207
|
contentType?: string;
|
|
172
208
|
metadata?: Record<string, string>;
|
|
@@ -239,6 +275,7 @@ interface AdminSetupRequest {
|
|
|
239
275
|
email: string;
|
|
240
276
|
password: string;
|
|
241
277
|
name: string;
|
|
278
|
+
setup_token: string;
|
|
242
279
|
}
|
|
243
280
|
interface AdminUser {
|
|
244
281
|
id: string;
|
|
@@ -963,6 +1000,216 @@ interface AuthSubscription {
|
|
|
963
1000
|
*/
|
|
964
1001
|
unsubscribe: () => void;
|
|
965
1002
|
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Options for invoking an edge function
|
|
1005
|
+
*/
|
|
1006
|
+
interface FunctionInvokeOptions {
|
|
1007
|
+
/**
|
|
1008
|
+
* Request body to send to the function
|
|
1009
|
+
*/
|
|
1010
|
+
body?: any;
|
|
1011
|
+
/**
|
|
1012
|
+
* Custom headers to include in the request
|
|
1013
|
+
*/
|
|
1014
|
+
headers?: Record<string, string>;
|
|
1015
|
+
/**
|
|
1016
|
+
* HTTP method to use
|
|
1017
|
+
* @default 'POST'
|
|
1018
|
+
*/
|
|
1019
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Edge function metadata
|
|
1023
|
+
*/
|
|
1024
|
+
interface EdgeFunction {
|
|
1025
|
+
id: string;
|
|
1026
|
+
name: string;
|
|
1027
|
+
description?: string;
|
|
1028
|
+
code: string;
|
|
1029
|
+
version: number;
|
|
1030
|
+
enabled: boolean;
|
|
1031
|
+
timeout_seconds: number;
|
|
1032
|
+
memory_limit_mb: number;
|
|
1033
|
+
allow_net: boolean;
|
|
1034
|
+
allow_env: boolean;
|
|
1035
|
+
allow_read: boolean;
|
|
1036
|
+
allow_write: boolean;
|
|
1037
|
+
allow_unauthenticated: boolean;
|
|
1038
|
+
cron_schedule?: string;
|
|
1039
|
+
created_at: string;
|
|
1040
|
+
updated_at: string;
|
|
1041
|
+
created_by?: string;
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Request to create a new edge function
|
|
1045
|
+
*/
|
|
1046
|
+
interface CreateFunctionRequest {
|
|
1047
|
+
name: string;
|
|
1048
|
+
description?: string;
|
|
1049
|
+
code: string;
|
|
1050
|
+
enabled?: boolean;
|
|
1051
|
+
timeout_seconds?: number;
|
|
1052
|
+
memory_limit_mb?: number;
|
|
1053
|
+
allow_net?: boolean;
|
|
1054
|
+
allow_env?: boolean;
|
|
1055
|
+
allow_read?: boolean;
|
|
1056
|
+
allow_write?: boolean;
|
|
1057
|
+
allow_unauthenticated?: boolean;
|
|
1058
|
+
cron_schedule?: string;
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* Request to update an existing edge function
|
|
1062
|
+
*/
|
|
1063
|
+
interface UpdateFunctionRequest {
|
|
1064
|
+
description?: string;
|
|
1065
|
+
code?: string;
|
|
1066
|
+
enabled?: boolean;
|
|
1067
|
+
timeout_seconds?: number;
|
|
1068
|
+
memory_limit_mb?: number;
|
|
1069
|
+
allow_net?: boolean;
|
|
1070
|
+
allow_env?: boolean;
|
|
1071
|
+
allow_read?: boolean;
|
|
1072
|
+
allow_write?: boolean;
|
|
1073
|
+
allow_unauthenticated?: boolean;
|
|
1074
|
+
cron_schedule?: string;
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* Edge function execution record
|
|
1078
|
+
*/
|
|
1079
|
+
interface EdgeFunctionExecution {
|
|
1080
|
+
id: string;
|
|
1081
|
+
function_id: string;
|
|
1082
|
+
trigger_type: string;
|
|
1083
|
+
status: 'success' | 'error';
|
|
1084
|
+
status_code?: number;
|
|
1085
|
+
duration_ms?: number;
|
|
1086
|
+
result?: string;
|
|
1087
|
+
logs?: string;
|
|
1088
|
+
error_message?: string;
|
|
1089
|
+
executed_at: string;
|
|
1090
|
+
completed_at?: string;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
/**
|
|
1094
|
+
* Realtime subscriptions using WebSockets
|
|
1095
|
+
*/
|
|
1096
|
+
|
|
1097
|
+
declare class RealtimeChannel {
|
|
1098
|
+
private ws;
|
|
1099
|
+
private url;
|
|
1100
|
+
private token;
|
|
1101
|
+
private channelName;
|
|
1102
|
+
private callbacks;
|
|
1103
|
+
private subscriptionConfig;
|
|
1104
|
+
private reconnectAttempts;
|
|
1105
|
+
private maxReconnectAttempts;
|
|
1106
|
+
private reconnectDelay;
|
|
1107
|
+
private heartbeatInterval;
|
|
1108
|
+
constructor(url: string, channelName: string, token?: string | null);
|
|
1109
|
+
/**
|
|
1110
|
+
* Listen to postgres_changes with optional row-level filtering
|
|
1111
|
+
*
|
|
1112
|
+
* @param event - 'postgres_changes'
|
|
1113
|
+
* @param config - Configuration including optional filter
|
|
1114
|
+
* @param callback - Function to call when changes occur
|
|
1115
|
+
* @returns This channel for chaining
|
|
1116
|
+
*
|
|
1117
|
+
* @example
|
|
1118
|
+
* ```typescript
|
|
1119
|
+
* channel.on('postgres_changes', {
|
|
1120
|
+
* event: '*',
|
|
1121
|
+
* schema: 'public',
|
|
1122
|
+
* table: 'jobs',
|
|
1123
|
+
* filter: 'created_by=eq.user123'
|
|
1124
|
+
* }, (payload) => {
|
|
1125
|
+
* console.log('Job updated:', payload)
|
|
1126
|
+
* })
|
|
1127
|
+
* ```
|
|
1128
|
+
*/
|
|
1129
|
+
on(event: "postgres_changes", config: PostgresChangesConfig, callback: RealtimeCallback): this;
|
|
1130
|
+
/**
|
|
1131
|
+
* Listen to a specific event type (backwards compatibility)
|
|
1132
|
+
*
|
|
1133
|
+
* @param event - The event type (INSERT, UPDATE, DELETE, or '*' for all)
|
|
1134
|
+
* @param callback - The callback function
|
|
1135
|
+
* @returns This channel for chaining
|
|
1136
|
+
*
|
|
1137
|
+
* @example
|
|
1138
|
+
* ```typescript
|
|
1139
|
+
* channel.on('INSERT', (payload) => {
|
|
1140
|
+
* console.log('New record inserted:', payload.new_record)
|
|
1141
|
+
* })
|
|
1142
|
+
* ```
|
|
1143
|
+
*/
|
|
1144
|
+
on(event: "INSERT" | "UPDATE" | "DELETE" | "*", callback: RealtimeCallback): this;
|
|
1145
|
+
/**
|
|
1146
|
+
* Remove a callback
|
|
1147
|
+
*/
|
|
1148
|
+
off(event: "INSERT" | "UPDATE" | "DELETE" | "*", callback: RealtimeCallback): this;
|
|
1149
|
+
/**
|
|
1150
|
+
* Subscribe to the channel
|
|
1151
|
+
* @param callback - Optional status callback (Supabase-compatible)
|
|
1152
|
+
* @param _timeout - Optional timeout in milliseconds (currently unused)
|
|
1153
|
+
*/
|
|
1154
|
+
subscribe(callback?: (status: "SUBSCRIBED" | "CHANNEL_ERROR" | "TIMED_OUT" | "CLOSED", err?: Error) => void, _timeout?: number): this;
|
|
1155
|
+
/**
|
|
1156
|
+
* Unsubscribe from the channel
|
|
1157
|
+
* @param timeout - Optional timeout in milliseconds
|
|
1158
|
+
* @returns Promise resolving to status string (Supabase-compatible)
|
|
1159
|
+
*/
|
|
1160
|
+
unsubscribe(timeout?: number): Promise<"ok" | "timed out" | "error">;
|
|
1161
|
+
/**
|
|
1162
|
+
* Internal: Connect to WebSocket
|
|
1163
|
+
*/
|
|
1164
|
+
private connect;
|
|
1165
|
+
/**
|
|
1166
|
+
* Internal: Disconnect WebSocket
|
|
1167
|
+
*/
|
|
1168
|
+
private disconnect;
|
|
1169
|
+
/**
|
|
1170
|
+
* Internal: Send a message
|
|
1171
|
+
*/
|
|
1172
|
+
private send;
|
|
1173
|
+
/**
|
|
1174
|
+
* Internal: Handle incoming message
|
|
1175
|
+
*/
|
|
1176
|
+
private handleMessage;
|
|
1177
|
+
/**
|
|
1178
|
+
* Internal: Handle broadcast message
|
|
1179
|
+
*/
|
|
1180
|
+
private handleBroadcast;
|
|
1181
|
+
/**
|
|
1182
|
+
* Internal: Start heartbeat interval
|
|
1183
|
+
*/
|
|
1184
|
+
private startHeartbeat;
|
|
1185
|
+
/**
|
|
1186
|
+
* Internal: Stop heartbeat interval
|
|
1187
|
+
*/
|
|
1188
|
+
private stopHeartbeat;
|
|
1189
|
+
/**
|
|
1190
|
+
* Internal: Attempt to reconnect
|
|
1191
|
+
*/
|
|
1192
|
+
private attemptReconnect;
|
|
1193
|
+
}
|
|
1194
|
+
declare class FluxbaseRealtime {
|
|
1195
|
+
private url;
|
|
1196
|
+
private token;
|
|
1197
|
+
private channels;
|
|
1198
|
+
constructor(url: string, token?: string | null);
|
|
1199
|
+
/**
|
|
1200
|
+
* Create or get a channel
|
|
1201
|
+
* @param channelName - Channel name (e.g., 'table:public.products')
|
|
1202
|
+
*/
|
|
1203
|
+
channel(channelName: string): RealtimeChannel;
|
|
1204
|
+
/**
|
|
1205
|
+
* Remove all channels
|
|
1206
|
+
*/
|
|
1207
|
+
removeAllChannels(): void;
|
|
1208
|
+
/**
|
|
1209
|
+
* Update auth token for all channels
|
|
1210
|
+
*/
|
|
1211
|
+
setToken(token: string | null): void;
|
|
1212
|
+
}
|
|
966
1213
|
|
|
967
1214
|
/**
|
|
968
1215
|
* HTTP client for making requests to the Fluxbase API
|
|
@@ -1200,123 +1447,6 @@ declare class FluxbaseAuth {
|
|
|
1200
1447
|
private emitAuthChange;
|
|
1201
1448
|
}
|
|
1202
1449
|
|
|
1203
|
-
/**
|
|
1204
|
-
* Realtime subscriptions using WebSockets
|
|
1205
|
-
*/
|
|
1206
|
-
|
|
1207
|
-
declare class RealtimeChannel {
|
|
1208
|
-
private ws;
|
|
1209
|
-
private url;
|
|
1210
|
-
private token;
|
|
1211
|
-
private channelName;
|
|
1212
|
-
private callbacks;
|
|
1213
|
-
private subscriptionConfig;
|
|
1214
|
-
private reconnectAttempts;
|
|
1215
|
-
private maxReconnectAttempts;
|
|
1216
|
-
private reconnectDelay;
|
|
1217
|
-
private heartbeatInterval;
|
|
1218
|
-
constructor(url: string, channelName: string, token?: string | null);
|
|
1219
|
-
/**
|
|
1220
|
-
* Listen to postgres_changes with optional row-level filtering
|
|
1221
|
-
*
|
|
1222
|
-
* @param event - 'postgres_changes'
|
|
1223
|
-
* @param config - Configuration including optional filter
|
|
1224
|
-
* @param callback - Function to call when changes occur
|
|
1225
|
-
* @returns This channel for chaining
|
|
1226
|
-
*
|
|
1227
|
-
* @example
|
|
1228
|
-
* ```typescript
|
|
1229
|
-
* channel.on('postgres_changes', {
|
|
1230
|
-
* event: '*',
|
|
1231
|
-
* schema: 'public',
|
|
1232
|
-
* table: 'jobs',
|
|
1233
|
-
* filter: 'created_by=eq.user123'
|
|
1234
|
-
* }, (payload) => {
|
|
1235
|
-
* console.log('Job updated:', payload)
|
|
1236
|
-
* })
|
|
1237
|
-
* ```
|
|
1238
|
-
*/
|
|
1239
|
-
on(event: 'postgres_changes', config: PostgresChangesConfig, callback: RealtimeCallback): this;
|
|
1240
|
-
/**
|
|
1241
|
-
* Listen to a specific event type (backwards compatibility)
|
|
1242
|
-
*
|
|
1243
|
-
* @param event - The event type (INSERT, UPDATE, DELETE, or '*' for all)
|
|
1244
|
-
* @param callback - The callback function
|
|
1245
|
-
* @returns This channel for chaining
|
|
1246
|
-
*
|
|
1247
|
-
* @example
|
|
1248
|
-
* ```typescript
|
|
1249
|
-
* channel.on('INSERT', (payload) => {
|
|
1250
|
-
* console.log('New record inserted:', payload.new_record)
|
|
1251
|
-
* })
|
|
1252
|
-
* ```
|
|
1253
|
-
*/
|
|
1254
|
-
on(event: 'INSERT' | 'UPDATE' | 'DELETE' | '*', callback: RealtimeCallback): this;
|
|
1255
|
-
/**
|
|
1256
|
-
* Remove a callback
|
|
1257
|
-
*/
|
|
1258
|
-
off(event: 'INSERT' | 'UPDATE' | 'DELETE' | '*', callback: RealtimeCallback): this;
|
|
1259
|
-
/**
|
|
1260
|
-
* Subscribe to the channel
|
|
1261
|
-
*/
|
|
1262
|
-
subscribe(): this;
|
|
1263
|
-
/**
|
|
1264
|
-
* Unsubscribe from the channel
|
|
1265
|
-
*/
|
|
1266
|
-
unsubscribe(): void;
|
|
1267
|
-
/**
|
|
1268
|
-
* Internal: Connect to WebSocket
|
|
1269
|
-
*/
|
|
1270
|
-
private connect;
|
|
1271
|
-
/**
|
|
1272
|
-
* Internal: Disconnect WebSocket
|
|
1273
|
-
*/
|
|
1274
|
-
private disconnect;
|
|
1275
|
-
/**
|
|
1276
|
-
* Internal: Send a message
|
|
1277
|
-
*/
|
|
1278
|
-
private send;
|
|
1279
|
-
/**
|
|
1280
|
-
* Internal: Handle incoming message
|
|
1281
|
-
*/
|
|
1282
|
-
private handleMessage;
|
|
1283
|
-
/**
|
|
1284
|
-
* Internal: Handle broadcast message
|
|
1285
|
-
*/
|
|
1286
|
-
private handleBroadcast;
|
|
1287
|
-
/**
|
|
1288
|
-
* Internal: Start heartbeat interval
|
|
1289
|
-
*/
|
|
1290
|
-
private startHeartbeat;
|
|
1291
|
-
/**
|
|
1292
|
-
* Internal: Stop heartbeat interval
|
|
1293
|
-
*/
|
|
1294
|
-
private stopHeartbeat;
|
|
1295
|
-
/**
|
|
1296
|
-
* Internal: Attempt to reconnect
|
|
1297
|
-
*/
|
|
1298
|
-
private attemptReconnect;
|
|
1299
|
-
}
|
|
1300
|
-
declare class FluxbaseRealtime {
|
|
1301
|
-
private url;
|
|
1302
|
-
private token;
|
|
1303
|
-
private channels;
|
|
1304
|
-
constructor(url: string, token?: string | null);
|
|
1305
|
-
/**
|
|
1306
|
-
* Create or get a channel
|
|
1307
|
-
* @param channelName - Channel name (e.g., 'table:public.products')
|
|
1308
|
-
*/
|
|
1309
|
-
channel(channelName: string): RealtimeChannel;
|
|
1310
|
-
/**
|
|
1311
|
-
* Remove all channels
|
|
1312
|
-
*/
|
|
1313
|
-
removeAllChannels(): void;
|
|
1314
|
-
/**
|
|
1315
|
-
* Update auth token for all channels
|
|
1316
|
-
*/
|
|
1317
|
-
setToken(token: string | null): void;
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
1450
|
/**
|
|
1321
1451
|
* Storage client for file operations
|
|
1322
1452
|
*/
|
|
@@ -1332,7 +1462,11 @@ declare class StorageBucket {
|
|
|
1332
1462
|
* @param options - Upload options
|
|
1333
1463
|
*/
|
|
1334
1464
|
upload(path: string, file: File | Blob | ArrayBuffer, options?: UploadOptions): Promise<{
|
|
1335
|
-
data:
|
|
1465
|
+
data: {
|
|
1466
|
+
id: string;
|
|
1467
|
+
path: string;
|
|
1468
|
+
fullPath: string;
|
|
1469
|
+
} | null;
|
|
1336
1470
|
error: Error | null;
|
|
1337
1471
|
}>;
|
|
1338
1472
|
/**
|
|
@@ -1345,10 +1479,12 @@ declare class StorageBucket {
|
|
|
1345
1479
|
}>;
|
|
1346
1480
|
/**
|
|
1347
1481
|
* List files in the bucket
|
|
1348
|
-
*
|
|
1482
|
+
* Supports both Supabase-style list(path, options) and Fluxbase-style list(options)
|
|
1483
|
+
* @param pathOrOptions - The folder path or list options
|
|
1484
|
+
* @param maybeOptions - List options when first param is a path
|
|
1349
1485
|
*/
|
|
1350
|
-
list(
|
|
1351
|
-
data:
|
|
1486
|
+
list(pathOrOptions?: string | ListOptions, maybeOptions?: ListOptions): Promise<{
|
|
1487
|
+
data: FileObject[] | null;
|
|
1352
1488
|
error: Error | null;
|
|
1353
1489
|
}>;
|
|
1354
1490
|
/**
|
|
@@ -1356,7 +1492,7 @@ declare class StorageBucket {
|
|
|
1356
1492
|
* @param paths - Array of file paths to remove
|
|
1357
1493
|
*/
|
|
1358
1494
|
remove(paths: string[]): Promise<{
|
|
1359
|
-
data: null;
|
|
1495
|
+
data: FileObject[] | null;
|
|
1360
1496
|
error: Error | null;
|
|
1361
1497
|
}>;
|
|
1362
1498
|
/**
|
|
@@ -1385,7 +1521,9 @@ declare class StorageBucket {
|
|
|
1385
1521
|
* @param toPath - New file path
|
|
1386
1522
|
*/
|
|
1387
1523
|
move(fromPath: string, toPath: string): Promise<{
|
|
1388
|
-
data:
|
|
1524
|
+
data: {
|
|
1525
|
+
message: string;
|
|
1526
|
+
} | null;
|
|
1389
1527
|
error: Error | null;
|
|
1390
1528
|
}>;
|
|
1391
1529
|
/**
|
|
@@ -1394,7 +1532,9 @@ declare class StorageBucket {
|
|
|
1394
1532
|
* @param toPath - Destination file path
|
|
1395
1533
|
*/
|
|
1396
1534
|
copy(fromPath: string, toPath: string): Promise<{
|
|
1397
|
-
data:
|
|
1535
|
+
data: {
|
|
1536
|
+
path: string;
|
|
1537
|
+
} | null;
|
|
1398
1538
|
error: Error | null;
|
|
1399
1539
|
}>;
|
|
1400
1540
|
/**
|
|
@@ -1447,7 +1587,9 @@ declare class FluxbaseStorage {
|
|
|
1447
1587
|
* @param bucketName - The name of the bucket to create
|
|
1448
1588
|
*/
|
|
1449
1589
|
createBucket(bucketName: string): Promise<{
|
|
1450
|
-
data:
|
|
1590
|
+
data: {
|
|
1591
|
+
name: string;
|
|
1592
|
+
} | null;
|
|
1451
1593
|
error: Error | null;
|
|
1452
1594
|
}>;
|
|
1453
1595
|
/**
|
|
@@ -1455,7 +1597,9 @@ declare class FluxbaseStorage {
|
|
|
1455
1597
|
* @param bucketName - The name of the bucket to delete
|
|
1456
1598
|
*/
|
|
1457
1599
|
deleteBucket(bucketName: string): Promise<{
|
|
1458
|
-
data:
|
|
1600
|
+
data: {
|
|
1601
|
+
message: string;
|
|
1602
|
+
} | null;
|
|
1459
1603
|
error: Error | null;
|
|
1460
1604
|
}>;
|
|
1461
1605
|
/**
|
|
@@ -1463,7 +1607,9 @@ declare class FluxbaseStorage {
|
|
|
1463
1607
|
* @param bucketName - The name of the bucket to empty
|
|
1464
1608
|
*/
|
|
1465
1609
|
emptyBucket(bucketName: string): Promise<{
|
|
1466
|
-
data:
|
|
1610
|
+
data: {
|
|
1611
|
+
message: string;
|
|
1612
|
+
} | null;
|
|
1467
1613
|
error: Error | null;
|
|
1468
1614
|
}>;
|
|
1469
1615
|
/**
|
|
@@ -1485,6 +1631,179 @@ declare class FluxbaseStorage {
|
|
|
1485
1631
|
}>;
|
|
1486
1632
|
}
|
|
1487
1633
|
|
|
1634
|
+
/**
|
|
1635
|
+
* Edge Functions module for Fluxbase SDK
|
|
1636
|
+
* Compatible with Supabase Functions API
|
|
1637
|
+
*
|
|
1638
|
+
* @example
|
|
1639
|
+
* ```typescript
|
|
1640
|
+
* // Invoke a function
|
|
1641
|
+
* const { data, error } = await client.functions.invoke('hello-world', {
|
|
1642
|
+
* body: { name: 'Alice' }
|
|
1643
|
+
* })
|
|
1644
|
+
*
|
|
1645
|
+
* // With custom headers
|
|
1646
|
+
* const { data, error } = await client.functions.invoke('api-call', {
|
|
1647
|
+
* body: { query: 'data' },
|
|
1648
|
+
* headers: { 'X-Custom-Header': 'value' },
|
|
1649
|
+
* method: 'POST'
|
|
1650
|
+
* })
|
|
1651
|
+
* ```
|
|
1652
|
+
*/
|
|
1653
|
+
|
|
1654
|
+
/**
|
|
1655
|
+
* Edge Functions client for invoking and managing serverless functions
|
|
1656
|
+
* API-compatible with Supabase Functions
|
|
1657
|
+
*
|
|
1658
|
+
* @category Functions
|
|
1659
|
+
*/
|
|
1660
|
+
declare class FluxbaseFunctions {
|
|
1661
|
+
private fetch;
|
|
1662
|
+
constructor(fetch: FluxbaseFetch);
|
|
1663
|
+
/**
|
|
1664
|
+
* Invoke an edge function
|
|
1665
|
+
*
|
|
1666
|
+
* This method is fully compatible with Supabase's functions.invoke() API.
|
|
1667
|
+
*
|
|
1668
|
+
* @param functionName - The name of the function to invoke
|
|
1669
|
+
* @param options - Invocation options including body, headers, and HTTP method
|
|
1670
|
+
* @returns Promise resolving to { data, error } tuple
|
|
1671
|
+
*
|
|
1672
|
+
* @example
|
|
1673
|
+
* ```typescript
|
|
1674
|
+
* // Simple invocation
|
|
1675
|
+
* const { data, error } = await client.functions.invoke('hello', {
|
|
1676
|
+
* body: { name: 'World' }
|
|
1677
|
+
* })
|
|
1678
|
+
*
|
|
1679
|
+
* // With GET method
|
|
1680
|
+
* const { data, error } = await client.functions.invoke('get-data', {
|
|
1681
|
+
* method: 'GET'
|
|
1682
|
+
* })
|
|
1683
|
+
*
|
|
1684
|
+
* // With custom headers
|
|
1685
|
+
* const { data, error } = await client.functions.invoke('api-proxy', {
|
|
1686
|
+
* body: { query: 'search' },
|
|
1687
|
+
* headers: { 'Authorization': 'Bearer token' },
|
|
1688
|
+
* method: 'POST'
|
|
1689
|
+
* })
|
|
1690
|
+
* ```
|
|
1691
|
+
*/
|
|
1692
|
+
invoke<T = any>(functionName: string, options?: FunctionInvokeOptions): Promise<{
|
|
1693
|
+
data: T | null;
|
|
1694
|
+
error: Error | null;
|
|
1695
|
+
}>;
|
|
1696
|
+
/**
|
|
1697
|
+
* Create a new edge function
|
|
1698
|
+
*
|
|
1699
|
+
* @param request - Function configuration and code
|
|
1700
|
+
* @returns Promise resolving to { data, error } tuple with created function metadata
|
|
1701
|
+
*
|
|
1702
|
+
* @example
|
|
1703
|
+
* ```typescript
|
|
1704
|
+
* const { data, error } = await client.functions.create({
|
|
1705
|
+
* name: 'my-function',
|
|
1706
|
+
* code: 'export default async function handler(req) { return { hello: "world" } }',
|
|
1707
|
+
* enabled: true
|
|
1708
|
+
* })
|
|
1709
|
+
* ```
|
|
1710
|
+
*/
|
|
1711
|
+
create(request: CreateFunctionRequest): Promise<{
|
|
1712
|
+
data: EdgeFunction | null;
|
|
1713
|
+
error: Error | null;
|
|
1714
|
+
}>;
|
|
1715
|
+
/**
|
|
1716
|
+
* List all edge functions
|
|
1717
|
+
*
|
|
1718
|
+
* @returns Promise resolving to { data, error } tuple with array of functions
|
|
1719
|
+
*
|
|
1720
|
+
* @example
|
|
1721
|
+
* ```typescript
|
|
1722
|
+
* const { data, error } = await client.functions.list()
|
|
1723
|
+
* if (data) {
|
|
1724
|
+
* console.log('Functions:', data.map(f => f.name))
|
|
1725
|
+
* }
|
|
1726
|
+
* ```
|
|
1727
|
+
*/
|
|
1728
|
+
list(): Promise<{
|
|
1729
|
+
data: EdgeFunction[] | null;
|
|
1730
|
+
error: Error | null;
|
|
1731
|
+
}>;
|
|
1732
|
+
/**
|
|
1733
|
+
* Get details of a specific edge function
|
|
1734
|
+
*
|
|
1735
|
+
* @param name - Function name
|
|
1736
|
+
* @returns Promise resolving to { data, error } tuple with function metadata
|
|
1737
|
+
*
|
|
1738
|
+
* @example
|
|
1739
|
+
* ```typescript
|
|
1740
|
+
* const { data, error } = await client.functions.get('my-function')
|
|
1741
|
+
* if (data) {
|
|
1742
|
+
* console.log('Function version:', data.version)
|
|
1743
|
+
* }
|
|
1744
|
+
* ```
|
|
1745
|
+
*/
|
|
1746
|
+
get(name: string): Promise<{
|
|
1747
|
+
data: EdgeFunction | null;
|
|
1748
|
+
error: Error | null;
|
|
1749
|
+
}>;
|
|
1750
|
+
/**
|
|
1751
|
+
* Update an existing edge function
|
|
1752
|
+
*
|
|
1753
|
+
* @param name - Function name
|
|
1754
|
+
* @param updates - Fields to update
|
|
1755
|
+
* @returns Promise resolving to { data, error } tuple with updated function metadata
|
|
1756
|
+
*
|
|
1757
|
+
* @example
|
|
1758
|
+
* ```typescript
|
|
1759
|
+
* const { data, error } = await client.functions.update('my-function', {
|
|
1760
|
+
* enabled: false,
|
|
1761
|
+
* description: 'Updated description'
|
|
1762
|
+
* })
|
|
1763
|
+
* ```
|
|
1764
|
+
*/
|
|
1765
|
+
update(name: string, updates: UpdateFunctionRequest): Promise<{
|
|
1766
|
+
data: EdgeFunction | null;
|
|
1767
|
+
error: Error | null;
|
|
1768
|
+
}>;
|
|
1769
|
+
/**
|
|
1770
|
+
* Delete an edge function
|
|
1771
|
+
*
|
|
1772
|
+
* @param name - Function name
|
|
1773
|
+
* @returns Promise resolving to { data, error } tuple
|
|
1774
|
+
*
|
|
1775
|
+
* @example
|
|
1776
|
+
* ```typescript
|
|
1777
|
+
* const { data, error } = await client.functions.delete('my-function')
|
|
1778
|
+
* ```
|
|
1779
|
+
*/
|
|
1780
|
+
delete(name: string): Promise<{
|
|
1781
|
+
data: null;
|
|
1782
|
+
error: Error | null;
|
|
1783
|
+
}>;
|
|
1784
|
+
/**
|
|
1785
|
+
* Get execution history for an edge function
|
|
1786
|
+
*
|
|
1787
|
+
* @param name - Function name
|
|
1788
|
+
* @param limit - Maximum number of executions to return (optional)
|
|
1789
|
+
* @returns Promise resolving to { data, error } tuple with execution records
|
|
1790
|
+
*
|
|
1791
|
+
* @example
|
|
1792
|
+
* ```typescript
|
|
1793
|
+
* const { data, error } = await client.functions.getExecutions('my-function', 10)
|
|
1794
|
+
* if (data) {
|
|
1795
|
+
* data.forEach(exec => {
|
|
1796
|
+
* console.log(`${exec.executed_at}: ${exec.status} (${exec.duration_ms}ms)`)
|
|
1797
|
+
* })
|
|
1798
|
+
* }
|
|
1799
|
+
* ```
|
|
1800
|
+
*/
|
|
1801
|
+
getExecutions(name: string, limit?: number): Promise<{
|
|
1802
|
+
data: EdgeFunctionExecution[] | null;
|
|
1803
|
+
error: Error | null;
|
|
1804
|
+
}>;
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1488
1807
|
/**
|
|
1489
1808
|
* System Settings Manager
|
|
1490
1809
|
*
|
|
@@ -3850,40 +4169,6 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
|
|
|
3850
4169
|
private formatValue;
|
|
3851
4170
|
}
|
|
3852
4171
|
|
|
3853
|
-
/**
|
|
3854
|
-
* Main Fluxbase client for interacting with the Fluxbase backend.
|
|
3855
|
-
*
|
|
3856
|
-
* This client provides access to all Fluxbase features including:
|
|
3857
|
-
* - Database operations via PostgREST-compatible API
|
|
3858
|
-
* - Authentication and user management
|
|
3859
|
-
* - Real-time subscriptions via WebSockets
|
|
3860
|
-
* - File storage and management
|
|
3861
|
-
* - PostgreSQL function calls (RPC)
|
|
3862
|
-
*
|
|
3863
|
-
* @example
|
|
3864
|
-
* ```typescript
|
|
3865
|
-
* import { createClient } from '@fluxbase/sdk'
|
|
3866
|
-
*
|
|
3867
|
-
* const client = createClient({
|
|
3868
|
-
* url: 'http://localhost:8080',
|
|
3869
|
-
* auth: {
|
|
3870
|
-
* token: 'your-jwt-token',
|
|
3871
|
-
* autoRefresh: true
|
|
3872
|
-
* }
|
|
3873
|
-
* })
|
|
3874
|
-
*
|
|
3875
|
-
* // Query database
|
|
3876
|
-
* const { data } = await client.from('users').select('*').execute()
|
|
3877
|
-
*
|
|
3878
|
-
* // Subscribe to realtime changes
|
|
3879
|
-
* client.realtime.subscribe('users', (payload) => {
|
|
3880
|
-
* console.log('Change:', payload)
|
|
3881
|
-
* })
|
|
3882
|
-
* ```
|
|
3883
|
-
*
|
|
3884
|
-
* @category Client
|
|
3885
|
-
*/
|
|
3886
|
-
|
|
3887
4172
|
/**
|
|
3888
4173
|
* Main Fluxbase client class
|
|
3889
4174
|
* @category Client
|
|
@@ -3897,6 +4182,8 @@ declare class FluxbaseClient {
|
|
|
3897
4182
|
realtime: FluxbaseRealtime;
|
|
3898
4183
|
/** Storage module for file operations */
|
|
3899
4184
|
storage: FluxbaseStorage;
|
|
4185
|
+
/** Functions module for invoking and managing edge functions */
|
|
4186
|
+
functions: FluxbaseFunctions;
|
|
3900
4187
|
/** Admin module for instance management (requires admin authentication) */
|
|
3901
4188
|
admin: FluxbaseAdmin;
|
|
3902
4189
|
/** Management module for API keys, webhooks, and invitations */
|
|
@@ -3979,6 +4266,34 @@ declare class FluxbaseClient {
|
|
|
3979
4266
|
* @category Authentication
|
|
3980
4267
|
*/
|
|
3981
4268
|
setAuthToken(token: string | null): void;
|
|
4269
|
+
/**
|
|
4270
|
+
* Create or get a realtime channel (Supabase-compatible alias)
|
|
4271
|
+
*
|
|
4272
|
+
* This is a convenience method that delegates to client.realtime.channel().
|
|
4273
|
+
* Both patterns work identically:
|
|
4274
|
+
* - client.channel('room-1') - Supabase-style
|
|
4275
|
+
* - client.realtime.channel('room-1') - Fluxbase-style
|
|
4276
|
+
*
|
|
4277
|
+
* @param name - Channel name
|
|
4278
|
+
* @returns RealtimeChannel instance
|
|
4279
|
+
*
|
|
4280
|
+
* @example
|
|
4281
|
+
* ```typescript
|
|
4282
|
+
* // Supabase-compatible usage
|
|
4283
|
+
* const channel = client.channel('room-1')
|
|
4284
|
+
* .on('postgres_changes', {
|
|
4285
|
+
* event: '*',
|
|
4286
|
+
* schema: 'public',
|
|
4287
|
+
* table: 'messages'
|
|
4288
|
+
* }, (payload) => {
|
|
4289
|
+
* console.log('Change:', payload)
|
|
4290
|
+
* })
|
|
4291
|
+
* .subscribe()
|
|
4292
|
+
* ```
|
|
4293
|
+
*
|
|
4294
|
+
* @category Realtime
|
|
4295
|
+
*/
|
|
4296
|
+
channel(name: string): RealtimeChannel;
|
|
3982
4297
|
/**
|
|
3983
4298
|
* Get the internal HTTP client
|
|
3984
4299
|
*
|
|
@@ -4024,4 +4339,4 @@ declare class FluxbaseClient {
|
|
|
4024
4339
|
*/
|
|
4025
4340
|
declare function createClient(options: FluxbaseClientOptions): FluxbaseClient;
|
|
4026
4341
|
|
|
4027
|
-
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 AuthResponse, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type Column, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateColumnRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateWebhookRequest, DDLManager, type DeleteAPIKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type EmailSettings, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EnrichedUser, type FeatureSettings, type FilterOperator, FluxbaseAdmin, FluxbaseAuth, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, FluxbaseSettings, FluxbaseStorage, 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 OAuthProvider, OAuthProviderManager, type OrderBy, type OrderDirection, type PostgrestError, type PostgrestResponse, QueryBuilder, type QueryFilter, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeMessage, type RequestOptions, type ResetUserPasswordResponse, type RevokeAPIKeyResponse, type RevokeInvitationResponse, type SESSettings, type SMTPSettings, type Schema, type SecuritySettings, type SendGridSettings, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, 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 UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateSystemSettingRequest, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type User, type ValidateInvitationResponse, type Webhook, type WebhookDelivery, WebhooksManager, createClient };
|
|
4342
|
+
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 AuthResponse, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type Column, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateColumnRequest, type CreateFunctionRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateWebhookRequest, DDLManager, 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, FluxbaseAuth, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseManagement, FluxbaseOAuth, FluxbaseRealtime, FluxbaseSettings, FluxbaseStorage, type FunctionInvokeOptions, 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 OAuthProvider, OAuthProviderManager, type OrderBy, type OrderDirection, type PostgresChangesConfig, type PostgrestError, type PostgrestResponse, QueryBuilder, type QueryFilter, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeMessage, type RealtimePostgresChangesPayload, type RequestOptions, type ResetUserPasswordResponse, type RevokeAPIKeyResponse, type RevokeInvitationResponse, type SESSettings, type SMTPSettings, type Schema, type SecuritySettings, type SendGridSettings, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, 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 UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateSystemSettingRequest, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type User, type ValidateInvitationResponse, type Webhook, type WebhookDelivery, WebhooksManager, createClient };
|