@fluxbase/sdk 0.0.1-rc.48 → 0.0.1-rc.50

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.d.cts CHANGED
@@ -201,7 +201,7 @@ interface SelectOptions {
201
201
  */
202
202
  head?: boolean;
203
203
  }
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' | 'between' | 'not.between';
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' | 'between' | 'not.between' | 'vec_l2' | 'vec_cos' | 'vec_ip';
205
205
  interface QueryFilter {
206
206
  column: string;
207
207
  operator: FilterOperator;
@@ -212,6 +212,10 @@ interface OrderBy {
212
212
  column: string;
213
213
  direction: OrderDirection;
214
214
  nulls?: 'first' | 'last';
215
+ /** Vector operator for similarity ordering (vec_l2, vec_cos, vec_ip) */
216
+ vectorOp?: 'vec_l2' | 'vec_cos' | 'vec_ip';
217
+ /** Vector value for similarity ordering */
218
+ vectorValue?: number[];
215
219
  }
216
220
  /**
217
221
  * Options for upsert operations (Supabase-compatible)
@@ -476,6 +480,81 @@ interface ResumableDownloadData {
476
480
  /** File size in bytes from HEAD request, or null if unknown */
477
481
  size: number | null;
478
482
  }
483
+ /** Options for resumable chunked uploads */
484
+ interface ResumableUploadOptions {
485
+ /**
486
+ * Chunk size in bytes for each upload request.
487
+ * @default 5242880 (5MB)
488
+ */
489
+ chunkSize?: number;
490
+ /**
491
+ * Number of retry attempts per chunk on failure.
492
+ * @default 3
493
+ */
494
+ maxRetries?: number;
495
+ /**
496
+ * Base delay in milliseconds for exponential backoff.
497
+ * @default 1000
498
+ */
499
+ retryDelayMs?: number;
500
+ /**
501
+ * Timeout in milliseconds per chunk request.
502
+ * @default 60000 (1 minute)
503
+ */
504
+ chunkTimeout?: number;
505
+ /** AbortSignal to cancel the upload */
506
+ signal?: AbortSignal;
507
+ /** Callback for upload progress */
508
+ onProgress?: (progress: ResumableUploadProgress) => void;
509
+ /** MIME type of the file */
510
+ contentType?: string;
511
+ /** Custom metadata to attach to the file */
512
+ metadata?: Record<string, string>;
513
+ /** Cache-Control header value */
514
+ cacheControl?: string;
515
+ /** Existing upload session ID to resume (optional) */
516
+ resumeSessionId?: string;
517
+ }
518
+ /** Upload progress information for resumable uploads */
519
+ interface ResumableUploadProgress {
520
+ /** Number of bytes uploaded so far */
521
+ loaded: number;
522
+ /** Total file size in bytes */
523
+ total: number;
524
+ /** Upload percentage (0-100) */
525
+ percentage: number;
526
+ /** Current chunk being uploaded (1-indexed) */
527
+ currentChunk: number;
528
+ /** Total number of chunks */
529
+ totalChunks: number;
530
+ /** Transfer rate in bytes per second */
531
+ bytesPerSecond: number;
532
+ /** Upload session ID (for resume capability) */
533
+ sessionId: string;
534
+ }
535
+ /** Chunked upload session information */
536
+ interface ChunkedUploadSession {
537
+ /** Unique session identifier for resume */
538
+ sessionId: string;
539
+ /** Target bucket */
540
+ bucket: string;
541
+ /** Target file path */
542
+ path: string;
543
+ /** Total file size */
544
+ totalSize: number;
545
+ /** Chunk size used */
546
+ chunkSize: number;
547
+ /** Total number of chunks */
548
+ totalChunks: number;
549
+ /** Array of completed chunk indices (0-indexed) */
550
+ completedChunks: number[];
551
+ /** Session status */
552
+ status: 'active' | 'completing' | 'completed' | 'aborted' | 'expired';
553
+ /** Session expiration time */
554
+ expiresAt: string;
555
+ /** Session creation time */
556
+ createdAt: string;
557
+ }
479
558
  interface ShareFileOptions {
480
559
  userId: string;
481
560
  permission: 'read' | 'write';
@@ -831,6 +910,13 @@ interface ListInvitationsResponse {
831
910
  interface RevokeInvitationResponse {
832
911
  message: string;
833
912
  }
913
+ /**
914
+ * Override information for a setting controlled by environment variable
915
+ */
916
+ interface SettingOverride {
917
+ is_overridden: boolean;
918
+ env_var: string;
919
+ }
834
920
  /**
835
921
  * System setting with key-value storage
836
922
  */
@@ -839,6 +925,10 @@ interface SystemSetting {
839
925
  key: string;
840
926
  value: Record<string, unknown>;
841
927
  description?: string;
928
+ /** True if this setting is overridden by an environment variable */
929
+ is_overridden?: boolean;
930
+ /** The environment variable name if overridden */
931
+ override_source?: string;
842
932
  created_at: string;
843
933
  updated_at: string;
844
934
  }
@@ -949,6 +1039,15 @@ interface EmailSettings {
949
1039
  interface SecuritySettings {
950
1040
  enable_global_rate_limit: boolean;
951
1041
  }
1042
+ /**
1043
+ * Indicates which settings are overridden by environment variables (read-only)
1044
+ */
1045
+ interface SettingOverrides {
1046
+ authentication?: Record<string, boolean>;
1047
+ features?: Record<string, boolean>;
1048
+ email?: Record<string, boolean>;
1049
+ security?: Record<string, boolean>;
1050
+ }
952
1051
  /**
953
1052
  * Complete application settings structure
954
1053
  */
@@ -957,6 +1056,8 @@ interface AppSettings {
957
1056
  features: FeatureSettings;
958
1057
  email: EmailSettings;
959
1058
  security: SecuritySettings;
1059
+ /** Settings overridden by environment variables (read-only, cannot be modified via API) */
1060
+ overrides?: SettingOverrides;
960
1061
  }
961
1062
  /**
962
1063
  * Request to update application settings
@@ -1105,6 +1206,8 @@ interface AuthSettings {
1105
1206
  password_require_special: boolean;
1106
1207
  session_timeout_minutes: number;
1107
1208
  max_sessions_per_user: number;
1209
+ /** Settings overridden by environment variables (read-only, cannot be modified via API) */
1210
+ _overrides?: Record<string, SettingOverride>;
1108
1211
  }
1109
1212
  /**
1110
1213
  * Request to update authentication settings
@@ -1818,7 +1921,11 @@ interface AIProvider {
1818
1921
  provider_type: AIProviderType;
1819
1922
  is_default: boolean;
1820
1923
  enabled: boolean;
1821
- config?: Record<string, string>;
1924
+ config: Record<string, string>;
1925
+ /** True if provider was configured via environment variables or fluxbase.yaml */
1926
+ from_config?: boolean;
1927
+ /** @deprecated Use from_config instead */
1928
+ read_only?: boolean;
1822
1929
  created_at: string;
1823
1930
  updated_at: string;
1824
1931
  }
@@ -2094,6 +2201,229 @@ interface UpdateConversationOptions {
2094
2201
  /** New title for the conversation */
2095
2202
  title: string;
2096
2203
  }
2204
+ /**
2205
+ * Knowledge base summary
2206
+ */
2207
+ interface KnowledgeBaseSummary {
2208
+ id: string;
2209
+ name: string;
2210
+ namespace: string;
2211
+ description: string;
2212
+ enabled: boolean;
2213
+ document_count: number;
2214
+ total_chunks: number;
2215
+ embedding_model: string;
2216
+ created_at: string;
2217
+ updated_at: string;
2218
+ }
2219
+ /**
2220
+ * Knowledge base full details
2221
+ */
2222
+ interface KnowledgeBase extends KnowledgeBaseSummary {
2223
+ embedding_dimensions: number;
2224
+ chunk_size: number;
2225
+ chunk_overlap: number;
2226
+ chunk_strategy: string;
2227
+ source: string;
2228
+ created_by?: string;
2229
+ }
2230
+ /**
2231
+ * Request to create a knowledge base
2232
+ */
2233
+ interface CreateKnowledgeBaseRequest {
2234
+ name: string;
2235
+ namespace?: string;
2236
+ description?: string;
2237
+ embedding_model?: string;
2238
+ embedding_dimensions?: number;
2239
+ chunk_size?: number;
2240
+ chunk_overlap?: number;
2241
+ chunk_strategy?: string;
2242
+ }
2243
+ /**
2244
+ * Request to update a knowledge base
2245
+ */
2246
+ interface UpdateKnowledgeBaseRequest {
2247
+ name?: string;
2248
+ description?: string;
2249
+ embedding_model?: string;
2250
+ embedding_dimensions?: number;
2251
+ chunk_size?: number;
2252
+ chunk_overlap?: number;
2253
+ chunk_strategy?: string;
2254
+ enabled?: boolean;
2255
+ }
2256
+ /**
2257
+ * Document status
2258
+ */
2259
+ type DocumentStatus = 'pending' | 'processing' | 'indexed' | 'failed';
2260
+ /**
2261
+ * Document in a knowledge base
2262
+ */
2263
+ interface KnowledgeBaseDocument {
2264
+ id: string;
2265
+ knowledge_base_id: string;
2266
+ title: string;
2267
+ source_url?: string;
2268
+ source_type?: string;
2269
+ mime_type: string;
2270
+ content_hash: string;
2271
+ chunk_count: number;
2272
+ status: DocumentStatus;
2273
+ error_message?: string;
2274
+ metadata?: Record<string, string>;
2275
+ tags?: string[];
2276
+ created_at: string;
2277
+ updated_at: string;
2278
+ }
2279
+ /**
2280
+ * Request to add a document
2281
+ */
2282
+ interface AddDocumentRequest {
2283
+ title?: string;
2284
+ content: string;
2285
+ source?: string;
2286
+ mime_type?: string;
2287
+ metadata?: Record<string, string>;
2288
+ }
2289
+ /**
2290
+ * Response after adding a document
2291
+ */
2292
+ interface AddDocumentResponse {
2293
+ document_id: string;
2294
+ status: string;
2295
+ message: string;
2296
+ }
2297
+ /**
2298
+ * Response after uploading a document file
2299
+ */
2300
+ interface UploadDocumentResponse {
2301
+ document_id: string;
2302
+ status: string;
2303
+ message: string;
2304
+ filename: string;
2305
+ extracted_length: number;
2306
+ mime_type: string;
2307
+ }
2308
+ /**
2309
+ * Chatbot-knowledge base link
2310
+ */
2311
+ interface ChatbotKnowledgeBaseLink {
2312
+ id: string;
2313
+ chatbot_id: string;
2314
+ knowledge_base_id: string;
2315
+ enabled: boolean;
2316
+ max_chunks: number;
2317
+ similarity_threshold: number;
2318
+ priority: number;
2319
+ created_at: string;
2320
+ }
2321
+ /**
2322
+ * Request to link a knowledge base to a chatbot
2323
+ */
2324
+ interface LinkKnowledgeBaseRequest {
2325
+ knowledge_base_id: string;
2326
+ priority?: number;
2327
+ max_chunks?: number;
2328
+ similarity_threshold?: number;
2329
+ }
2330
+ /**
2331
+ * Request to update a chatbot-knowledge base link
2332
+ */
2333
+ interface UpdateChatbotKnowledgeBaseRequest {
2334
+ priority?: number;
2335
+ max_chunks?: number;
2336
+ similarity_threshold?: number;
2337
+ enabled?: boolean;
2338
+ }
2339
+ /**
2340
+ * Search result from knowledge base
2341
+ */
2342
+ interface KnowledgeBaseSearchResult {
2343
+ chunk_id: string;
2344
+ document_id: string;
2345
+ document_title: string;
2346
+ knowledge_base_name?: string;
2347
+ content: string;
2348
+ similarity: number;
2349
+ metadata?: Record<string, unknown>;
2350
+ }
2351
+ /**
2352
+ * Response from knowledge base search
2353
+ */
2354
+ interface SearchKnowledgeBaseResponse {
2355
+ results: KnowledgeBaseSearchResult[];
2356
+ count: number;
2357
+ query: string;
2358
+ }
2359
+ /**
2360
+ * System health status response
2361
+ */
2362
+ interface HealthResponse {
2363
+ status: string;
2364
+ services: {
2365
+ database: boolean;
2366
+ realtime: boolean;
2367
+ };
2368
+ timestamp: string;
2369
+ }
2370
+ /**
2371
+ * Storage bucket information (admin API)
2372
+ */
2373
+ interface AdminBucket {
2374
+ id: string;
2375
+ name: string;
2376
+ public: boolean;
2377
+ allowed_mime_types: string[] | null;
2378
+ max_file_size: number | null;
2379
+ created_at: string;
2380
+ updated_at: string;
2381
+ }
2382
+ /**
2383
+ * Response from listing buckets (admin API)
2384
+ */
2385
+ interface AdminListBucketsResponse {
2386
+ buckets: AdminBucket[];
2387
+ }
2388
+ /**
2389
+ * Storage object information (admin API)
2390
+ */
2391
+ interface AdminStorageObject {
2392
+ id: string;
2393
+ bucket: string;
2394
+ path: string;
2395
+ mime_type: string;
2396
+ size: number;
2397
+ metadata: Record<string, unknown> | null;
2398
+ owner_id: string | null;
2399
+ created_at: string;
2400
+ updated_at: string;
2401
+ }
2402
+ /**
2403
+ * Response from listing objects (admin API)
2404
+ */
2405
+ interface AdminListObjectsResponse {
2406
+ bucket: string;
2407
+ objects: AdminStorageObject[] | null;
2408
+ prefixes: string[];
2409
+ truncated: boolean;
2410
+ }
2411
+ /**
2412
+ * Response from generating a signed URL
2413
+ */
2414
+ interface SignedUrlResponse {
2415
+ url: string;
2416
+ expires_in: number;
2417
+ }
2418
+ /**
2419
+ * Request to send an email
2420
+ */
2421
+ interface SendEmailRequest {
2422
+ to: string | string[];
2423
+ subject: string;
2424
+ html?: string;
2425
+ text?: string;
2426
+ }
2097
2427
  /**
2098
2428
  * Base Fluxbase response type (Supabase-compatible)
2099
2429
  * Returns either `{ data, error: null }` on success or `{ data: null, error }` on failure
@@ -2212,16 +2542,29 @@ interface RPCInvokeResponse<T = unknown> {
2212
2542
  error?: string;
2213
2543
  }
2214
2544
  /**
2215
- * RPC execution log entry
2545
+ * Execution log entry (shared by jobs, RPC, and functions)
2216
2546
  */
2217
- interface RPCExecutionLog {
2547
+ interface ExecutionLog {
2548
+ /** Unique log entry ID */
2218
2549
  id: number;
2550
+ /** ID of the execution (job ID, RPC execution ID, or function execution ID) */
2219
2551
  execution_id: string;
2552
+ /** Line number within the execution log */
2220
2553
  line_number: number;
2554
+ /** Log level (debug, info, warn, error) */
2221
2555
  level: string;
2556
+ /** Log message content */
2222
2557
  message: string;
2223
- created_at: string;
2558
+ /** Timestamp of the log entry */
2559
+ timestamp: string;
2560
+ /** Additional structured fields */
2561
+ fields?: Record<string, unknown>;
2224
2562
  }
2563
+ /**
2564
+ * RPC execution log entry
2565
+ * @deprecated Use ExecutionLog instead
2566
+ */
2567
+ type RPCExecutionLog = ExecutionLog;
2225
2568
  /**
2226
2569
  * RPC procedure specification for sync operations
2227
2570
  */
@@ -2290,6 +2633,123 @@ interface RPCExecutionFilters {
2290
2633
  limit?: number;
2291
2634
  offset?: number;
2292
2635
  }
2636
+ /**
2637
+ * Vector distance metric for similarity search
2638
+ * - l2: Euclidean distance (L2 norm) - lower is more similar
2639
+ * - cosine: Cosine distance - lower is more similar (1 - cosine similarity)
2640
+ * - inner_product: Negative inner product - lower is more similar
2641
+ */
2642
+ type VectorMetric = 'l2' | 'cosine' | 'inner_product';
2643
+ /**
2644
+ * Options for vector similarity ordering
2645
+ */
2646
+ interface VectorOrderOptions {
2647
+ /** The vector to compare against */
2648
+ vector: number[];
2649
+ /** Distance metric to use */
2650
+ metric?: VectorMetric;
2651
+ }
2652
+ /**
2653
+ * Request for vector embedding generation
2654
+ */
2655
+ interface EmbedRequest {
2656
+ /** Text to embed (single) */
2657
+ text?: string;
2658
+ /** Multiple texts to embed */
2659
+ texts?: string[];
2660
+ /** Embedding model to use (defaults to configured model) */
2661
+ model?: string;
2662
+ }
2663
+ /**
2664
+ * Response from vector embedding generation
2665
+ */
2666
+ interface EmbedResponse {
2667
+ /** Generated embeddings (one per input text) */
2668
+ embeddings: number[][];
2669
+ /** Model used for embedding */
2670
+ model: string;
2671
+ /** Dimensions of the embeddings */
2672
+ dimensions: number;
2673
+ /** Token usage information */
2674
+ usage?: {
2675
+ prompt_tokens: number;
2676
+ total_tokens: number;
2677
+ };
2678
+ }
2679
+ /**
2680
+ * Options for vector search via the convenience endpoint
2681
+ */
2682
+ interface VectorSearchOptions {
2683
+ /** Table to search in */
2684
+ table: string;
2685
+ /** Vector column to search */
2686
+ column: string;
2687
+ /** Text query to search for (will be auto-embedded) */
2688
+ query?: string;
2689
+ /** Direct vector input (alternative to text query) */
2690
+ vector?: number[];
2691
+ /** Distance metric to use */
2692
+ metric?: VectorMetric;
2693
+ /** Minimum similarity threshold (0-1 for cosine, varies for others) */
2694
+ match_threshold?: number;
2695
+ /** Maximum number of results */
2696
+ match_count?: number;
2697
+ /** Columns to select (default: all) */
2698
+ select?: string;
2699
+ /** Additional filters to apply */
2700
+ filters?: QueryFilter[];
2701
+ }
2702
+ /**
2703
+ * Result from vector search
2704
+ */
2705
+ interface VectorSearchResult<T = Record<string, unknown>> {
2706
+ /** Matched records */
2707
+ data: T[];
2708
+ /** Distance scores for each result */
2709
+ distances: number[];
2710
+ /** Embedding model used (if query text was embedded) */
2711
+ model?: string;
2712
+ }
2713
+ /**
2714
+ * Log level for execution logs
2715
+ */
2716
+ type ExecutionLogLevel = 'debug' | 'info' | 'warn' | 'error';
2717
+ /**
2718
+ * Execution type for log subscriptions
2719
+ */
2720
+ type ExecutionType = 'function' | 'job' | 'rpc';
2721
+ /**
2722
+ * Execution log event received from realtime subscription
2723
+ */
2724
+ interface ExecutionLogEvent {
2725
+ /** Unique execution ID */
2726
+ execution_id: string;
2727
+ /** Type of execution */
2728
+ execution_type: ExecutionType;
2729
+ /** Line number in the execution log */
2730
+ line_number: number;
2731
+ /** Log level */
2732
+ level: ExecutionLogLevel;
2733
+ /** Log message content */
2734
+ message: string;
2735
+ /** Timestamp of the log entry */
2736
+ timestamp: string;
2737
+ /** Additional fields */
2738
+ fields?: Record<string, unknown>;
2739
+ }
2740
+ /**
2741
+ * Callback for execution log events
2742
+ */
2743
+ type ExecutionLogCallback = (log: ExecutionLogEvent) => void;
2744
+ /**
2745
+ * Configuration for execution log subscription
2746
+ */
2747
+ interface ExecutionLogConfig {
2748
+ /** Execution ID to subscribe to */
2749
+ execution_id: string;
2750
+ /** Type of execution (function, job, rpc) */
2751
+ type?: ExecutionType;
2752
+ }
2293
2753
  /**
2294
2754
  * @deprecated Use FluxbaseResponse instead
2295
2755
  */
@@ -2311,8 +2771,10 @@ declare class RealtimeChannel {
2311
2771
  private callbacks;
2312
2772
  private presenceCallbacks;
2313
2773
  private broadcastCallbacks;
2774
+ private executionLogCallbacks;
2314
2775
  private subscriptionConfig;
2315
2776
  private subscriptionId;
2777
+ private executionLogConfig;
2316
2778
  private _presenceState;
2317
2779
  private myPresenceKey;
2318
2780
  private config;
@@ -2403,6 +2865,25 @@ declare class RealtimeChannel {
2403
2865
  on(event: "presence", config: {
2404
2866
  event: "sync" | "join" | "leave";
2405
2867
  }, callback: PresenceCallback): this;
2868
+ /**
2869
+ * Listen to execution log events
2870
+ *
2871
+ * @param event - 'execution_log'
2872
+ * @param config - Configuration with execution_id and optional type
2873
+ * @param callback - Function to call when log entries are received
2874
+ * @returns This channel for chaining
2875
+ *
2876
+ * @example
2877
+ * ```typescript
2878
+ * channel.on('execution_log', { execution_id: 'abc123', type: 'function' }, (log) => {
2879
+ * console.log(`[${log.level}] ${log.message}`)
2880
+ * })
2881
+ * ```
2882
+ */
2883
+ on(event: "execution_log", config: {
2884
+ execution_id: string;
2885
+ type?: ExecutionType;
2886
+ }, callback: ExecutionLogCallback): this;
2406
2887
  /**
2407
2888
  * Remove a callback
2408
2889
  */
@@ -2497,6 +2978,10 @@ declare class RealtimeChannel {
2497
2978
  * Internal: Handle incoming message
2498
2979
  */
2499
2980
  private handleMessage;
2981
+ /**
2982
+ * Internal: Handle execution log message
2983
+ */
2984
+ private handleExecutionLog;
2500
2985
  /**
2501
2986
  * Internal: Handle broadcast message
2502
2987
  */
@@ -2584,6 +3069,74 @@ declare class FluxbaseRealtime {
2584
3069
  * @param token - The new auth token
2585
3070
  */
2586
3071
  setAuth(token: string | null): void;
3072
+ /**
3073
+ * Create an execution log subscription channel
3074
+ *
3075
+ * This provides a cleaner API for subscribing to execution logs
3076
+ * (functions, jobs, or RPC procedures).
3077
+ *
3078
+ * @param executionId - The execution ID to subscribe to
3079
+ * @param type - The type of execution ('function', 'job', 'rpc')
3080
+ * @returns ExecutionLogsChannel instance with fluent API
3081
+ *
3082
+ * @example
3083
+ * ```typescript
3084
+ * const channel = client.realtime.executionLogs('exec-123', 'function')
3085
+ * .onLog((log) => {
3086
+ * console.log(`[${log.level}] ${log.message}`)
3087
+ * })
3088
+ * .subscribe()
3089
+ * ```
3090
+ */
3091
+ executionLogs(executionId: string, type?: ExecutionType): ExecutionLogsChannel;
3092
+ }
3093
+ /**
3094
+ * Specialized channel for execution log subscriptions
3095
+ * Provides a cleaner API than the generic RealtimeChannel
3096
+ */
3097
+ declare class ExecutionLogsChannel {
3098
+ private channel;
3099
+ private executionId;
3100
+ private executionType;
3101
+ private logCallbacks;
3102
+ constructor(url: string, executionId: string, type: ExecutionType, token: string | null, tokenRefreshCallback: (() => Promise<string | null>) | null);
3103
+ /**
3104
+ * Register a callback for log events
3105
+ *
3106
+ * @param callback - Function to call when log entries are received
3107
+ * @returns This channel for chaining
3108
+ *
3109
+ * @example
3110
+ * ```typescript
3111
+ * channel.onLog((log) => {
3112
+ * console.log(`[${log.level}] Line ${log.line_number}: ${log.message}`)
3113
+ * })
3114
+ * ```
3115
+ */
3116
+ onLog(callback: ExecutionLogCallback): this;
3117
+ /**
3118
+ * Subscribe to execution logs
3119
+ *
3120
+ * @param callback - Optional status callback
3121
+ * @returns Promise that resolves when subscribed
3122
+ *
3123
+ * @example
3124
+ * ```typescript
3125
+ * await channel.subscribe()
3126
+ * ```
3127
+ */
3128
+ subscribe(callback?: (status: "SUBSCRIBED" | "CHANNEL_ERROR" | "TIMED_OUT" | "CLOSED", err?: Error) => void): this;
3129
+ /**
3130
+ * Unsubscribe from execution logs
3131
+ *
3132
+ * @returns Promise resolving to status
3133
+ *
3134
+ * @example
3135
+ * ```typescript
3136
+ * await channel.unsubscribe()
3137
+ * ```
3138
+ */
3139
+ unsubscribe(): Promise<"ok" | "timed out" | "error">;
2587
3140
  }
2588
3141
 
2589
3142
  /**
@@ -2663,6 +3216,10 @@ declare class FluxbaseFetch {
2663
3216
  * GET request that returns response with headers (for count queries)
2664
3217
  */
2665
3218
  getWithHeaders<T = unknown>(path: string, options?: Omit<FetchOptions, 'method'>): Promise<FetchResponseWithHeaders<T>>;
3219
+ /**
3220
+ * POST request that returns response with headers (for POST-based queries with count)
3221
+ */
3222
+ postWithHeaders<T = unknown>(path: string, body?: unknown, options?: Omit<FetchOptions, 'method' | 'body'>): Promise<FetchResponseWithHeaders<T>>;
2666
3223
  /**
2667
3224
  * Make an HTTP request and return response with headers
2668
3225
  */
@@ -2691,6 +3248,10 @@ declare class FluxbaseFetch {
2691
3248
  * HEAD request
2692
3249
  */
2693
3250
  head(path: string, options?: Omit<FetchOptions, 'method'>): Promise<Headers>;
3251
+ /**
3252
+ * GET request that returns response as Blob (for file downloads)
3253
+ */
3254
+ getBlob(path: string, options?: Omit<FetchOptions, 'method'>): Promise<Blob>;
2694
3255
  }
2695
3256
 
2696
3257
  /**
@@ -3161,13 +3722,66 @@ declare class StorageBucket {
3161
3722
  error: Error | null;
3162
3723
  }>;
3163
3724
  /**
3164
- * List files in the bucket
3165
- * Supports both Supabase-style list(path, options) and Fluxbase-style list(options)
3166
- * @param pathOrOptions - The folder path or list options
3167
- * @param maybeOptions - List options when first param is a path
3168
- */
3169
- list(pathOrOptions?: string | ListOptions, maybeOptions?: ListOptions): Promise<{
3170
- data: FileObject[] | null;
3725
+ * Upload a large file with resumable chunked uploads.
3726
+ *
3727
+ * Features:
3728
+ * - Uploads file in chunks for reliability
3729
+ * - Automatically retries failed chunks with exponential backoff
3730
+ * - Reports progress via callback with chunk-level granularity
3731
+ * - Can resume interrupted uploads using session ID
3732
+ *
3733
+ * @param path - The file path within the bucket
3734
+ * @param file - The File or Blob to upload
3735
+ * @param options - Upload options including chunk size, retries, and progress callback
3736
+ * @returns Upload result with file info
3737
+ *
3738
+ * @example
3739
+ * const { data, error } = await storage.from('uploads').uploadResumable('large.zip', file, {
3740
+ * chunkSize: 5 * 1024 * 1024, // 5MB chunks
3741
+ * maxRetries: 3,
3742
+ * onProgress: (p) => {
3743
+ * console.log(`${p.percentage}% (chunk ${p.currentChunk}/${p.totalChunks})`);
3744
+ * console.log(`Speed: ${(p.bytesPerSecond / 1024 / 1024).toFixed(2)} MB/s`);
3745
+ * console.log(`Session ID (for resume): ${p.sessionId}`);
3746
+ * }
3747
+ * });
3748
+ *
3749
+ * // To resume an interrupted upload:
3750
+ * const { data, error } = await storage.from('uploads').uploadResumable('large.zip', file, {
3751
+ * resumeSessionId: 'previous-session-id',
3752
+ * });
3753
+ */
3754
+ uploadResumable(path: string, file: File | Blob, options?: ResumableUploadOptions): Promise<{
3755
+ data: {
3756
+ id: string;
3757
+ path: string;
3758
+ fullPath: string;
3759
+ } | null;
3760
+ error: Error | null;
3761
+ }>;
3762
+ /**
3763
+ * Abort an in-progress resumable upload
3764
+ * @param sessionId - The upload session ID to abort
3765
+ */
3766
+ abortResumableUpload(sessionId: string): Promise<{
3767
+ error: Error | null;
3768
+ }>;
3769
+ /**
3770
+ * Get the status of a resumable upload session
3771
+ * @param sessionId - The upload session ID to check
3772
+ */
3773
+ getResumableUploadStatus(sessionId: string): Promise<{
3774
+ data: ChunkedUploadSession | null;
3775
+ error: Error | null;
3776
+ }>;
3777
+ /**
3778
+ * List files in the bucket
3779
+ * Supports both Supabase-style list(path, options) and Fluxbase-style list(options)
3780
+ * @param pathOrOptions - The folder path or list options
3781
+ * @param maybeOptions - List options when first param is a path
3782
+ */
3783
+ list(pathOrOptions?: string | ListOptions, maybeOptions?: ListOptions): Promise<{
3784
+ data: FileObject[] | null;
3171
3785
  error: Error | null;
3172
3786
  }>;
3173
3787
  /**
@@ -3602,6 +4216,198 @@ declare class FluxbaseJobs {
3602
4216
  data: Job | null;
3603
4217
  error: Error | null;
3604
4218
  }>;
4219
+ /**
4220
+ * Get execution logs for a job
4221
+ *
4222
+ * Returns logs for the specified job. Only returns logs for jobs
4223
+ * owned by the authenticated user (unless using service_role).
4224
+ *
4225
+ * @param jobId - Job ID
4226
+ * @param afterLine - Optional line number to get logs after (for polling/streaming)
4227
+ * @returns Promise resolving to { data, error } tuple with execution logs
4228
+ *
4229
+ * @example
4230
+ * ```typescript
4231
+ * // Get all logs for a job
4232
+ * const { data: logs, error } = await client.jobs.getLogs('550e8400-e29b-41d4-a716-446655440000')
4233
+ *
4234
+ * if (logs) {
4235
+ * for (const log of logs) {
4236
+ * console.log(`[${log.level}] ${log.message}`)
4237
+ * }
4238
+ * }
4239
+ *
4240
+ * // Backfill + stream pattern
4241
+ * const { data: logs } = await client.jobs.getLogs(jobId)
4242
+ * let lastLine = Math.max(...(logs?.map(l => l.line_number) ?? []), 0)
4243
+ *
4244
+ * const channel = client.realtime
4245
+ * .executionLogs(jobId, 'job')
4246
+ * .onLog((log) => {
4247
+ * if (log.line_number > lastLine) {
4248
+ * displayLog(log)
4249
+ * lastLine = log.line_number
4250
+ * }
4251
+ * })
4252
+ * .subscribe()
4253
+ * ```
4254
+ */
4255
+ getLogs(jobId: string, afterLine?: number): Promise<{
4256
+ data: ExecutionLog[] | null;
4257
+ error: Error | null;
4258
+ }>;
4259
+ }
4260
+
4261
+ /**
4262
+ * RPC (Remote Procedure Call) module for invoking SQL-based procedures
4263
+ */
4264
+
4265
+ /**
4266
+ * Options for invoking an RPC procedure
4267
+ */
4268
+ interface RPCInvokeOptions {
4269
+ /** Namespace of the procedure (defaults to 'default') */
4270
+ namespace?: string;
4271
+ /** Execute asynchronously (returns execution ID immediately) */
4272
+ async?: boolean;
4273
+ }
4274
+ /**
4275
+ * Fetch interface for RPC operations
4276
+ */
4277
+ interface RPCFetch {
4278
+ get: <T>(path: string) => Promise<T>;
4279
+ post: <T>(path: string, body?: unknown) => Promise<T>;
4280
+ }
4281
+ /**
4282
+ * FluxbaseRPC provides methods for invoking RPC procedures
4283
+ *
4284
+ * @example
4285
+ * ```typescript
4286
+ * // Invoke a procedure synchronously
4287
+ * const { data, error } = await fluxbase.rpc.invoke('get-user-orders', {
4288
+ * user_id: '123',
4289
+ * limit: 10
4290
+ * });
4291
+ *
4292
+ * // Invoke asynchronously
4293
+ * const { data: asyncResult } = await fluxbase.rpc.invoke('long-running-report', {
4294
+ * start_date: '2024-01-01'
4295
+ * }, { async: true });
4296
+ *
4297
+ * // Poll for status
4298
+ * const { data: status } = await fluxbase.rpc.getStatus(asyncResult.execution_id);
4299
+ * ```
4300
+ */
4301
+ declare class FluxbaseRPC {
4302
+ private fetch;
4303
+ constructor(fetch: RPCFetch);
4304
+ /**
4305
+ * List available RPC procedures (public, enabled)
4306
+ *
4307
+ * @param namespace - Optional namespace filter
4308
+ * @returns Promise resolving to { data, error } tuple with array of procedure summaries
4309
+ */
4310
+ list(namespace?: string): Promise<{
4311
+ data: RPCProcedureSummary[] | null;
4312
+ error: Error | null;
4313
+ }>;
4314
+ /**
4315
+ * Invoke an RPC procedure
4316
+ *
4317
+ * @param name - Procedure name
4318
+ * @param params - Optional parameters to pass to the procedure
4319
+ * @param options - Optional invocation options
4320
+ * @returns Promise resolving to { data, error } tuple with invocation response
4321
+ *
4322
+ * @example
4323
+ * ```typescript
4324
+ * // Synchronous invocation
4325
+ * const { data, error } = await fluxbase.rpc.invoke('get-user-orders', {
4326
+ * user_id: '123',
4327
+ * limit: 10
4328
+ * });
4329
+ * console.log(data.result); // Query results
4330
+ *
4331
+ * // Asynchronous invocation
4332
+ * const { data: asyncData } = await fluxbase.rpc.invoke('generate-report', {
4333
+ * year: 2024
4334
+ * }, { async: true });
4335
+ * console.log(asyncData.execution_id); // Use to poll status
4336
+ * ```
4337
+ */
4338
+ invoke<T = unknown>(name: string, params?: Record<string, unknown>, options?: RPCInvokeOptions): Promise<{
4339
+ data: RPCInvokeResponse<T> | null;
4340
+ error: Error | null;
4341
+ }>;
4342
+ /**
4343
+ * Get execution status (for async invocations or checking history)
4344
+ *
4345
+ * @param executionId - The execution ID returned from async invoke
4346
+ * @returns Promise resolving to { data, error } tuple with execution details
4347
+ *
4348
+ * @example
4349
+ * ```typescript
4350
+ * const { data, error } = await fluxbase.rpc.getStatus('execution-uuid');
4351
+ * if (data.status === 'completed') {
4352
+ * console.log('Result:', data.result);
4353
+ * } else if (data.status === 'running') {
4354
+ * console.log('Still running...');
4355
+ * }
4356
+ * ```
4357
+ */
4358
+ getStatus(executionId: string): Promise<{
4359
+ data: RPCExecution | null;
4360
+ error: Error | null;
4361
+ }>;
4362
+ /**
4363
+ * Get execution logs (for debugging and monitoring)
4364
+ *
4365
+ * @param executionId - The execution ID
4366
+ * @param afterLine - Optional line number to get logs after (for polling)
4367
+ * @returns Promise resolving to { data, error } tuple with execution logs
4368
+ *
4369
+ * @example
4370
+ * ```typescript
4371
+ * const { data: logs } = await fluxbase.rpc.getLogs('execution-uuid');
4372
+ * for (const log of logs) {
4373
+ * console.log(`[${log.level}] ${log.message}`);
4374
+ * }
4375
+ * ```
4376
+ */
4377
+ getLogs(executionId: string, afterLine?: number): Promise<{
4378
+ data: RPCExecutionLog[] | null;
4379
+ error: Error | null;
4380
+ }>;
4381
+ /**
4382
+ * Poll for execution completion with exponential backoff
4383
+ *
4384
+ * @param executionId - The execution ID to poll
4385
+ * @param options - Polling options
4386
+ * @returns Promise resolving to final execution state
4387
+ *
4388
+ * @example
4389
+ * ```typescript
4390
+ * const { data: result } = await fluxbase.rpc.invoke('long-task', {}, { async: true });
4391
+ * const { data: final } = await fluxbase.rpc.waitForCompletion(result.execution_id, {
4392
+ * maxWaitMs: 60000, // Wait up to 1 minute
4393
+ * onProgress: (exec) => console.log(`Status: ${exec.status}`)
4394
+ * });
4395
+ * console.log('Final result:', final.result);
4396
+ * ```
4397
+ */
4398
+ waitForCompletion(executionId: string, options?: {
4399
+ /** Maximum time to wait in milliseconds (default: 30000) */
4400
+ maxWaitMs?: number;
4401
+ /** Initial polling interval in milliseconds (default: 500) */
4402
+ initialIntervalMs?: number;
4403
+ /** Maximum polling interval in milliseconds (default: 5000) */
4404
+ maxIntervalMs?: number;
4405
+ /** Callback for progress updates */
4406
+ onProgress?: (execution: RPCExecution) => void;
4407
+ }): Promise<{
4408
+ data: RPCExecution | null;
4409
+ error: Error | null;
4410
+ }>;
3605
4411
  }
3606
4412
 
3607
4413
  /**
@@ -5854,17 +6660,12 @@ declare class FluxbaseAdminMigrations {
5854
6660
  error: Error | null;
5855
6661
  };
5856
6662
  /**
5857
- * Trigger schema refresh which will restart the server
5858
- * Handles the restart gracefully by waiting for the server to come back online
6663
+ * Trigger schema refresh to update the REST API cache
6664
+ * Note: Server no longer restarts - cache is invalidated instantly
5859
6665
  *
5860
6666
  * @private
5861
6667
  */
5862
- private triggerSchemaRefreshWithRestart;
5863
- /**
5864
- * Helper function to sleep for a given duration
5865
- * @private
5866
- */
5867
- private sleep;
6668
+ private triggerSchemaRefresh;
5868
6669
  /**
5869
6670
  * Smart sync all registered migrations
5870
6671
  *
@@ -5939,7 +6740,7 @@ declare class FluxbaseAdminMigrations {
5939
6740
  * const { data, error } = await client.admin.migrations.list('myapp', 'pending')
5940
6741
  * ```
5941
6742
  */
5942
- list(namespace?: string, status?: 'pending' | 'applied' | 'failed' | 'rolled_back'): Promise<{
6743
+ list(namespace?: string, status?: "pending" | "applied" | "failed" | "rolled_back"): Promise<{
5943
6744
  data: Migration[] | null;
5944
6745
  error: Error | null;
5945
6746
  }>;
@@ -6446,8 +7247,8 @@ declare class FluxbaseAdminJobs {
6446
7247
  }
6447
7248
 
6448
7249
  /**
6449
- * Admin AI module for managing AI chatbots and providers
6450
- * Provides administrative operations for chatbot lifecycle management
7250
+ * Admin AI module for managing AI chatbots, providers, and knowledge bases
7251
+ * Provides administrative operations for chatbot lifecycle management and RAG
6451
7252
  */
6452
7253
 
6453
7254
  /**
@@ -6677,54 +7478,355 @@ declare class FluxbaseAdminAI {
6677
7478
  data: null;
6678
7479
  error: Error | null;
6679
7480
  }>;
6680
- }
6681
-
6682
- /**
6683
- * Admin RPC module for managing RPC procedures
6684
- * Provides administrative operations for RPC procedure lifecycle management
6685
- */
6686
-
6687
- /**
6688
- * Admin RPC manager for managing RPC procedures
6689
- * Provides sync, CRUD, and execution monitoring operations
6690
- *
6691
- * @category Admin
6692
- */
6693
- declare class FluxbaseAdminRPC {
6694
- private fetch;
6695
- constructor(fetch: FluxbaseFetch);
6696
7481
  /**
6697
- * Sync RPC procedures from filesystem or API payload
6698
- *
6699
- * Can sync from:
6700
- * 1. Filesystem (if no procedures provided) - loads from configured procedures directory
6701
- * 2. API payload (if procedures array provided) - syncs provided procedure specifications
6702
- *
6703
- * Requires service_role or admin authentication.
7482
+ * List all knowledge bases
6704
7483
  *
6705
- * @param options - Sync options including namespace and optional procedures array
6706
- * @returns Promise resolving to { data, error } tuple with sync results
7484
+ * @returns Promise resolving to { data, error } tuple with array of knowledge base summaries
6707
7485
  *
6708
7486
  * @example
6709
7487
  * ```typescript
6710
- * // Sync from filesystem
6711
- * const { data, error } = await client.admin.rpc.sync()
6712
- *
6713
- * // Sync with provided procedure code
6714
- * const { data, error } = await client.admin.rpc.sync({
6715
- * namespace: 'default',
6716
- * procedures: [{
6717
- * name: 'get-user-orders',
6718
- * code: myProcedureSQL,
6719
- * }],
6720
- * options: {
6721
- * delete_missing: false, // Don't remove procedures not in this sync
6722
- * dry_run: false, // Preview changes without applying
6723
- * }
6724
- * })
6725
- *
7488
+ * const { data, error } = await client.admin.ai.listKnowledgeBases()
6726
7489
  * if (data) {
6727
- * console.log(`Synced: ${data.summary.created} created, ${data.summary.updated} updated`)
7490
+ * console.log('Knowledge bases:', data.map(kb => kb.name))
7491
+ * }
7492
+ * ```
7493
+ */
7494
+ listKnowledgeBases(): Promise<{
7495
+ data: KnowledgeBaseSummary[] | null;
7496
+ error: Error | null;
7497
+ }>;
7498
+ /**
7499
+ * Get a specific knowledge base
7500
+ *
7501
+ * @param id - Knowledge base ID
7502
+ * @returns Promise resolving to { data, error } tuple with knowledge base details
7503
+ *
7504
+ * @example
7505
+ * ```typescript
7506
+ * const { data, error } = await client.admin.ai.getKnowledgeBase('uuid')
7507
+ * if (data) {
7508
+ * console.log('Knowledge base:', data.name)
7509
+ * }
7510
+ * ```
7511
+ */
7512
+ getKnowledgeBase(id: string): Promise<{
7513
+ data: KnowledgeBase | null;
7514
+ error: Error | null;
7515
+ }>;
7516
+ /**
7517
+ * Create a new knowledge base
7518
+ *
7519
+ * @param request - Knowledge base configuration
7520
+ * @returns Promise resolving to { data, error } tuple with created knowledge base
7521
+ *
7522
+ * @example
7523
+ * ```typescript
7524
+ * const { data, error } = await client.admin.ai.createKnowledgeBase({
7525
+ * name: 'product-docs',
7526
+ * description: 'Product documentation',
7527
+ * chunk_size: 512,
7528
+ * chunk_overlap: 50,
7529
+ * })
7530
+ * ```
7531
+ */
7532
+ createKnowledgeBase(request: CreateKnowledgeBaseRequest): Promise<{
7533
+ data: KnowledgeBase | null;
7534
+ error: Error | null;
7535
+ }>;
7536
+ /**
7537
+ * Update an existing knowledge base
7538
+ *
7539
+ * @param id - Knowledge base ID
7540
+ * @param updates - Fields to update
7541
+ * @returns Promise resolving to { data, error } tuple with updated knowledge base
7542
+ *
7543
+ * @example
7544
+ * ```typescript
7545
+ * const { data, error } = await client.admin.ai.updateKnowledgeBase('uuid', {
7546
+ * description: 'Updated description',
7547
+ * enabled: true,
7548
+ * })
7549
+ * ```
7550
+ */
7551
+ updateKnowledgeBase(id: string, updates: UpdateKnowledgeBaseRequest): Promise<{
7552
+ data: KnowledgeBase | null;
7553
+ error: Error | null;
7554
+ }>;
7555
+ /**
7556
+ * Delete a knowledge base
7557
+ *
7558
+ * @param id - Knowledge base ID
7559
+ * @returns Promise resolving to { data, error } tuple
7560
+ *
7561
+ * @example
7562
+ * ```typescript
7563
+ * const { data, error } = await client.admin.ai.deleteKnowledgeBase('uuid')
7564
+ * ```
7565
+ */
7566
+ deleteKnowledgeBase(id: string): Promise<{
7567
+ data: null;
7568
+ error: Error | null;
7569
+ }>;
7570
+ /**
7571
+ * List documents in a knowledge base
7572
+ *
7573
+ * @param knowledgeBaseId - Knowledge base ID
7574
+ * @returns Promise resolving to { data, error } tuple with array of documents
7575
+ *
7576
+ * @example
7577
+ * ```typescript
7578
+ * const { data, error } = await client.admin.ai.listDocuments('kb-uuid')
7579
+ * if (data) {
7580
+ * console.log('Documents:', data.map(d => d.title))
7581
+ * }
7582
+ * ```
7583
+ */
7584
+ listDocuments(knowledgeBaseId: string): Promise<{
7585
+ data: KnowledgeBaseDocument[] | null;
7586
+ error: Error | null;
7587
+ }>;
7588
+ /**
7589
+ * Get a specific document
7590
+ *
7591
+ * @param knowledgeBaseId - Knowledge base ID
7592
+ * @param documentId - Document ID
7593
+ * @returns Promise resolving to { data, error } tuple with document details
7594
+ *
7595
+ * @example
7596
+ * ```typescript
7597
+ * const { data, error } = await client.admin.ai.getDocument('kb-uuid', 'doc-uuid')
7598
+ * ```
7599
+ */
7600
+ getDocument(knowledgeBaseId: string, documentId: string): Promise<{
7601
+ data: KnowledgeBaseDocument | null;
7602
+ error: Error | null;
7603
+ }>;
7604
+ /**
7605
+ * Add a document to a knowledge base
7606
+ *
7607
+ * Document will be chunked and embedded asynchronously.
7608
+ *
7609
+ * @param knowledgeBaseId - Knowledge base ID
7610
+ * @param request - Document content and metadata
7611
+ * @returns Promise resolving to { data, error } tuple with document ID
7612
+ *
7613
+ * @example
7614
+ * ```typescript
7615
+ * const { data, error } = await client.admin.ai.addDocument('kb-uuid', {
7616
+ * title: 'Getting Started Guide',
7617
+ * content: 'This is the content of the document...',
7618
+ * metadata: { category: 'guides' },
7619
+ * })
7620
+ * if (data) {
7621
+ * console.log('Document ID:', data.document_id)
7622
+ * }
7623
+ * ```
7624
+ */
7625
+ addDocument(knowledgeBaseId: string, request: AddDocumentRequest): Promise<{
7626
+ data: AddDocumentResponse | null;
7627
+ error: Error | null;
7628
+ }>;
7629
+ /**
7630
+ * Upload a document file to a knowledge base
7631
+ *
7632
+ * Supported file types: PDF, TXT, MD, HTML, CSV, DOCX, XLSX, RTF, EPUB, JSON
7633
+ * Maximum file size: 50MB
7634
+ *
7635
+ * @param knowledgeBaseId - Knowledge base ID
7636
+ * @param file - File to upload (File or Blob)
7637
+ * @param title - Optional document title (defaults to filename without extension)
7638
+ * @returns Promise resolving to { data, error } tuple with upload result
7639
+ *
7640
+ * @example
7641
+ * ```typescript
7642
+ * // Browser
7643
+ * const fileInput = document.getElementById('file') as HTMLInputElement
7644
+ * const file = fileInput.files?.[0]
7645
+ * if (file) {
7646
+ * const { data, error } = await client.admin.ai.uploadDocument('kb-uuid', file)
7647
+ * if (data) {
7648
+ * console.log('Document ID:', data.document_id)
7649
+ * console.log('Extracted length:', data.extracted_length)
7650
+ * }
7651
+ * }
7652
+ *
7653
+ * // Node.js (with node-fetch or similar)
7654
+ * import { Blob } from 'buffer'
7655
+ * const content = await fs.readFile('document.pdf')
7656
+ * const blob = new Blob([content], { type: 'application/pdf' })
7657
+ * const { data, error } = await client.admin.ai.uploadDocument('kb-uuid', blob, 'My Document')
7658
+ * ```
7659
+ */
7660
+ uploadDocument(knowledgeBaseId: string, file: File | Blob, title?: string): Promise<{
7661
+ data: UploadDocumentResponse | null;
7662
+ error: Error | null;
7663
+ }>;
7664
+ /**
7665
+ * Delete a document from a knowledge base
7666
+ *
7667
+ * @param knowledgeBaseId - Knowledge base ID
7668
+ * @param documentId - Document ID
7669
+ * @returns Promise resolving to { data, error } tuple
7670
+ *
7671
+ * @example
7672
+ * ```typescript
7673
+ * const { data, error } = await client.admin.ai.deleteDocument('kb-uuid', 'doc-uuid')
7674
+ * ```
7675
+ */
7676
+ deleteDocument(knowledgeBaseId: string, documentId: string): Promise<{
7677
+ data: null;
7678
+ error: Error | null;
7679
+ }>;
7680
+ /**
7681
+ * Search a knowledge base
7682
+ *
7683
+ * @param knowledgeBaseId - Knowledge base ID
7684
+ * @param query - Search query
7685
+ * @param options - Search options
7686
+ * @returns Promise resolving to { data, error } tuple with search results
7687
+ *
7688
+ * @example
7689
+ * ```typescript
7690
+ * const { data, error } = await client.admin.ai.searchKnowledgeBase('kb-uuid', 'how to reset password', {
7691
+ * max_chunks: 5,
7692
+ * threshold: 0.7,
7693
+ * })
7694
+ * if (data) {
7695
+ * console.log('Results:', data.results.map(r => r.content))
7696
+ * }
7697
+ * ```
7698
+ */
7699
+ searchKnowledgeBase(knowledgeBaseId: string, query: string, options?: {
7700
+ max_chunks?: number;
7701
+ threshold?: number;
7702
+ }): Promise<{
7703
+ data: SearchKnowledgeBaseResponse | null;
7704
+ error: Error | null;
7705
+ }>;
7706
+ /**
7707
+ * List knowledge bases linked to a chatbot
7708
+ *
7709
+ * @param chatbotId - Chatbot ID
7710
+ * @returns Promise resolving to { data, error } tuple with linked knowledge bases
7711
+ *
7712
+ * @example
7713
+ * ```typescript
7714
+ * const { data, error } = await client.admin.ai.listChatbotKnowledgeBases('chatbot-uuid')
7715
+ * if (data) {
7716
+ * console.log('Linked KBs:', data.map(l => l.knowledge_base_id))
7717
+ * }
7718
+ * ```
7719
+ */
7720
+ listChatbotKnowledgeBases(chatbotId: string): Promise<{
7721
+ data: ChatbotKnowledgeBaseLink[] | null;
7722
+ error: Error | null;
7723
+ }>;
7724
+ /**
7725
+ * Link a knowledge base to a chatbot
7726
+ *
7727
+ * @param chatbotId - Chatbot ID
7728
+ * @param request - Link configuration
7729
+ * @returns Promise resolving to { data, error } tuple with link details
7730
+ *
7731
+ * @example
7732
+ * ```typescript
7733
+ * const { data, error } = await client.admin.ai.linkKnowledgeBase('chatbot-uuid', {
7734
+ * knowledge_base_id: 'kb-uuid',
7735
+ * priority: 1,
7736
+ * max_chunks: 5,
7737
+ * similarity_threshold: 0.7,
7738
+ * })
7739
+ * ```
7740
+ */
7741
+ linkKnowledgeBase(chatbotId: string, request: LinkKnowledgeBaseRequest): Promise<{
7742
+ data: ChatbotKnowledgeBaseLink | null;
7743
+ error: Error | null;
7744
+ }>;
7745
+ /**
7746
+ * Update a chatbot-knowledge base link
7747
+ *
7748
+ * @param chatbotId - Chatbot ID
7749
+ * @param knowledgeBaseId - Knowledge base ID
7750
+ * @param updates - Fields to update
7751
+ * @returns Promise resolving to { data, error } tuple with updated link
7752
+ *
7753
+ * @example
7754
+ * ```typescript
7755
+ * const { data, error } = await client.admin.ai.updateChatbotKnowledgeBase(
7756
+ * 'chatbot-uuid',
7757
+ * 'kb-uuid',
7758
+ * { max_chunks: 10, enabled: true }
7759
+ * )
7760
+ * ```
7761
+ */
7762
+ updateChatbotKnowledgeBase(chatbotId: string, knowledgeBaseId: string, updates: UpdateChatbotKnowledgeBaseRequest): Promise<{
7763
+ data: ChatbotKnowledgeBaseLink | null;
7764
+ error: Error | null;
7765
+ }>;
7766
+ /**
7767
+ * Unlink a knowledge base from a chatbot
7768
+ *
7769
+ * @param chatbotId - Chatbot ID
7770
+ * @param knowledgeBaseId - Knowledge base ID
7771
+ * @returns Promise resolving to { data, error } tuple
7772
+ *
7773
+ * @example
7774
+ * ```typescript
7775
+ * const { data, error } = await client.admin.ai.unlinkKnowledgeBase('chatbot-uuid', 'kb-uuid')
7776
+ * ```
7777
+ */
7778
+ unlinkKnowledgeBase(chatbotId: string, knowledgeBaseId: string): Promise<{
7779
+ data: null;
7780
+ error: Error | null;
7781
+ }>;
7782
+ }
7783
+
7784
+ /**
7785
+ * Admin RPC module for managing RPC procedures
7786
+ * Provides administrative operations for RPC procedure lifecycle management
7787
+ */
7788
+
7789
+ /**
7790
+ * Admin RPC manager for managing RPC procedures
7791
+ * Provides sync, CRUD, and execution monitoring operations
7792
+ *
7793
+ * @category Admin
7794
+ */
7795
+ declare class FluxbaseAdminRPC {
7796
+ private fetch;
7797
+ constructor(fetch: FluxbaseFetch);
7798
+ /**
7799
+ * Sync RPC procedures from filesystem or API payload
7800
+ *
7801
+ * Can sync from:
7802
+ * 1. Filesystem (if no procedures provided) - loads from configured procedures directory
7803
+ * 2. API payload (if procedures array provided) - syncs provided procedure specifications
7804
+ *
7805
+ * Requires service_role or admin authentication.
7806
+ *
7807
+ * @param options - Sync options including namespace and optional procedures array
7808
+ * @returns Promise resolving to { data, error } tuple with sync results
7809
+ *
7810
+ * @example
7811
+ * ```typescript
7812
+ * // Sync from filesystem
7813
+ * const { data, error } = await client.admin.rpc.sync()
7814
+ *
7815
+ * // Sync with provided procedure code
7816
+ * const { data, error } = await client.admin.rpc.sync({
7817
+ * namespace: 'default',
7818
+ * procedures: [{
7819
+ * name: 'get-user-orders',
7820
+ * code: myProcedureSQL,
7821
+ * }],
7822
+ * options: {
7823
+ * delete_missing: false, // Don't remove procedures not in this sync
7824
+ * dry_run: false, // Preview changes without applying
7825
+ * }
7826
+ * })
7827
+ *
7828
+ * if (data) {
7829
+ * console.log(`Synced: ${data.summary.created} created, ${data.summary.updated} updated`)
6728
7830
  * }
6729
7831
  * ```
6730
7832
  */
@@ -6920,6 +8022,158 @@ declare class FluxbaseAdminRPC {
6920
8022
  }>;
6921
8023
  }
6922
8024
 
8025
+ /**
8026
+ * Admin storage manager for bucket and object management
8027
+ */
8028
+ declare class FluxbaseAdminStorage {
8029
+ private fetch;
8030
+ constructor(fetch: FluxbaseFetch);
8031
+ /**
8032
+ * List all storage buckets
8033
+ *
8034
+ * @returns List of buckets
8035
+ *
8036
+ * @example
8037
+ * ```typescript
8038
+ * const { data, error } = await admin.storage.listBuckets();
8039
+ * if (data) {
8040
+ * console.log(`Found ${data.buckets.length} buckets`);
8041
+ * }
8042
+ * ```
8043
+ */
8044
+ listBuckets(): Promise<DataResponse<AdminListBucketsResponse>>;
8045
+ /**
8046
+ * Create a new storage bucket
8047
+ *
8048
+ * @param name - Bucket name
8049
+ * @returns Success message
8050
+ *
8051
+ * @example
8052
+ * ```typescript
8053
+ * const { error } = await admin.storage.createBucket('my-bucket');
8054
+ * if (!error) {
8055
+ * console.log('Bucket created');
8056
+ * }
8057
+ * ```
8058
+ */
8059
+ createBucket(name: string): Promise<DataResponse<{
8060
+ message: string;
8061
+ }>>;
8062
+ /**
8063
+ * Delete a storage bucket
8064
+ *
8065
+ * @param name - Bucket name
8066
+ * @returns Success message
8067
+ *
8068
+ * @example
8069
+ * ```typescript
8070
+ * const { error } = await admin.storage.deleteBucket('my-bucket');
8071
+ * if (!error) {
8072
+ * console.log('Bucket deleted');
8073
+ * }
8074
+ * ```
8075
+ */
8076
+ deleteBucket(name: string): Promise<DataResponse<{
8077
+ message: string;
8078
+ }>>;
8079
+ /**
8080
+ * List objects in a bucket
8081
+ *
8082
+ * @param bucket - Bucket name
8083
+ * @param prefix - Optional path prefix to filter results
8084
+ * @param delimiter - Optional delimiter for hierarchical listing (usually '/')
8085
+ * @returns List of objects and prefixes (folders)
8086
+ *
8087
+ * @example
8088
+ * ```typescript
8089
+ * // List all objects in bucket
8090
+ * const { data } = await admin.storage.listObjects('my-bucket');
8091
+ *
8092
+ * // List objects in a folder
8093
+ * const { data } = await admin.storage.listObjects('my-bucket', 'folder/', '/');
8094
+ * ```
8095
+ */
8096
+ listObjects(bucket: string, prefix?: string, delimiter?: string): Promise<DataResponse<AdminListObjectsResponse>>;
8097
+ /**
8098
+ * Get object metadata
8099
+ *
8100
+ * @param bucket - Bucket name
8101
+ * @param key - Object key (path)
8102
+ * @returns Object metadata
8103
+ *
8104
+ * @example
8105
+ * ```typescript
8106
+ * const { data } = await admin.storage.getObjectMetadata('my-bucket', 'path/to/file.txt');
8107
+ * if (data) {
8108
+ * console.log(`File size: ${data.size} bytes`);
8109
+ * }
8110
+ * ```
8111
+ */
8112
+ getObjectMetadata(bucket: string, key: string): Promise<DataResponse<AdminStorageObject>>;
8113
+ /**
8114
+ * Download an object as a Blob
8115
+ *
8116
+ * @param bucket - Bucket name
8117
+ * @param key - Object key (path)
8118
+ * @returns Object data as Blob
8119
+ *
8120
+ * @example
8121
+ * ```typescript
8122
+ * const { data: blob } = await admin.storage.downloadObject('my-bucket', 'file.pdf');
8123
+ * if (blob) {
8124
+ * // Use the blob
8125
+ * const url = URL.createObjectURL(blob);
8126
+ * }
8127
+ * ```
8128
+ */
8129
+ downloadObject(bucket: string, key: string): Promise<DataResponse<Blob>>;
8130
+ /**
8131
+ * Delete an object
8132
+ *
8133
+ * @param bucket - Bucket name
8134
+ * @param key - Object key (path)
8135
+ *
8136
+ * @example
8137
+ * ```typescript
8138
+ * const { error } = await admin.storage.deleteObject('my-bucket', 'path/to/file.txt');
8139
+ * if (!error) {
8140
+ * console.log('Object deleted');
8141
+ * }
8142
+ * ```
8143
+ */
8144
+ deleteObject(bucket: string, key: string): Promise<VoidResponse>;
8145
+ /**
8146
+ * Create a folder (empty object with directory content type)
8147
+ *
8148
+ * @param bucket - Bucket name
8149
+ * @param folderPath - Folder path (should end with /)
8150
+ *
8151
+ * @example
8152
+ * ```typescript
8153
+ * const { error } = await admin.storage.createFolder('my-bucket', 'new-folder/');
8154
+ * ```
8155
+ */
8156
+ createFolder(bucket: string, folderPath: string): Promise<VoidResponse>;
8157
+ /**
8158
+ * Generate a signed URL for temporary access
8159
+ *
8160
+ * @param bucket - Bucket name
8161
+ * @param key - Object key (path)
8162
+ * @param expiresIn - Expiration time in seconds
8163
+ * @returns Signed URL and expiration info
8164
+ *
8165
+ * @example
8166
+ * ```typescript
8167
+ * const { data } = await admin.storage.generateSignedUrl('my-bucket', 'file.pdf', 3600);
8168
+ * if (data) {
8169
+ * console.log(`Download at: ${data.url}`);
8170
+ * console.log(`Expires in: ${data.expires_in} seconds`);
8171
+ * }
8172
+ * ```
8173
+ */
8174
+ generateSignedUrl(bucket: string, key: string, expiresIn: number): Promise<DataResponse<SignedUrlResponse>>;
8175
+ }
8176
+
6923
8177
  /**
6924
8178
  * Admin client for managing Fluxbase instance
6925
8179
  */
@@ -6970,6 +8224,10 @@ declare class FluxbaseAdmin {
6970
8224
  * RPC manager for procedure management (create, update, delete, sync, execution monitoring)
6971
8225
  */
6972
8226
  rpc: FluxbaseAdminRPC;
8227
+ /**
8228
+ * Storage manager for bucket and object management (list, create, delete, signed URLs)
8229
+ */
8230
+ storage: FluxbaseAdminStorage;
6973
8231
  constructor(fetch: FluxbaseFetch);
6974
8232
  /**
6975
8233
  * Set admin authentication token
@@ -6982,7 +8240,41 @@ declare class FluxbaseAdmin {
6982
8240
  /**
6983
8241
  * Clear admin token
6984
8242
  */
6985
- clearToken(): void;
8243
+ clearToken(): void;
8244
+ /**
8245
+ * Get system health status
8246
+ *
8247
+ * @returns Health status including database and realtime service status
8248
+ *
8249
+ * @example
8250
+ * ```typescript
8251
+ * const { data, error } = await admin.getHealth();
8252
+ * if (data) {
8253
+ * console.log('Status:', data.status);
8254
+ * console.log('Database:', data.services.database);
8255
+ * console.log('Realtime:', data.services.realtime);
8256
+ * }
8257
+ * ```
8258
+ */
8259
+ getHealth(): Promise<DataResponse<HealthResponse>>;
8260
+ /**
8261
+ * Send an email
8262
+ *
8263
+ * @param request - Email details (to, subject, html/text)
8264
+ *
8265
+ * @example
8266
+ * ```typescript
8267
+ * const { error } = await admin.sendEmail({
8268
+ * to: 'user@example.com',
8269
+ * subject: 'Hello',
8270
+ * html: '<p>Your message here</p>'
8271
+ * });
8272
+ * if (!error) {
8273
+ * console.log('Email sent');
8274
+ * }
8275
+ * ```
8276
+ */
8277
+ sendEmail(request: SendEmailRequest): Promise<VoidResponse>;
6986
8278
  /**
6987
8279
  * Check if initial admin setup is needed
6988
8280
  *
@@ -7470,6 +8762,93 @@ declare class FluxbaseAI {
7470
8762
  }>;
7471
8763
  }
7472
8764
 
8765
+ /**
8766
+ * Vector search module for Fluxbase SDK
8767
+ * Provides convenience methods for vector similarity search using pgvector
8768
+ */
8769
+
8770
+ /**
8771
+ * FluxbaseVector provides vector search functionality using pgvector
8772
+ *
8773
+ * @example
8774
+ * ```typescript
8775
+ * // Embed text and search
8776
+ * const { data: results } = await client.vector.search({
8777
+ * table: 'documents',
8778
+ * column: 'embedding',
8779
+ * query: 'How to use TypeScript?',
8780
+ * match_count: 10
8781
+ * })
8782
+ *
8783
+ * // Embed text directly
8784
+ * const { data: embedding } = await client.vector.embed({ text: 'Hello world' })
8785
+ * ```
8786
+ */
8787
+ declare class FluxbaseVector {
8788
+ private fetch;
8789
+ constructor(fetch: FluxbaseFetch);
8790
+ /**
8791
+ * Generate embeddings for text
8792
+ *
8793
+ * @example
8794
+ * ```typescript
8795
+ * // Single text
8796
+ * const { data } = await client.vector.embed({
8797
+ * text: 'Hello world'
8798
+ * })
8799
+ * console.log(data.embeddings[0]) // [0.1, 0.2, ...]
8800
+ *
8801
+ * // Multiple texts
8802
+ * const { data } = await client.vector.embed({
8803
+ * texts: ['Hello', 'World'],
8804
+ * model: 'text-embedding-3-small'
8805
+ * })
8806
+ * ```
8807
+ */
8808
+ embed(request: EmbedRequest): Promise<FluxbaseResponse<EmbedResponse>>;
8809
+ /**
8810
+ * Search for similar vectors with automatic text embedding
8811
+ *
8812
+ * This is a convenience method that:
8813
+ * 1. Embeds the query text automatically (if `query` is provided)
8814
+ * 2. Performs vector similarity search
8815
+ * 3. Returns results with distance scores
8816
+ *
8817
+ * @example
8818
+ * ```typescript
8819
+ * // Search with text query (auto-embedded)
8820
+ * const { data } = await client.vector.search({
8821
+ * table: 'documents',
8822
+ * column: 'embedding',
8823
+ * query: 'How to use TypeScript?',
8824
+ * match_count: 10,
8825
+ * match_threshold: 0.8
8826
+ * })
8827
+ *
8828
+ * // Search with pre-computed vector
8829
+ * const { data } = await client.vector.search({
8830
+ * table: 'documents',
8831
+ * column: 'embedding',
8832
+ * vector: [0.1, 0.2, ...],
8833
+ * metric: 'cosine',
8834
+ * match_count: 10
8835
+ * })
8836
+ *
8837
+ * // With additional filters
8838
+ * const { data } = await client.vector.search({
8839
+ * table: 'documents',
8840
+ * column: 'embedding',
8841
+ * query: 'TypeScript tutorial',
8842
+ * filters: [
8843
+ * { column: 'status', operator: 'eq', value: 'published' }
8844
+ * ],
8845
+ * match_count: 10
8846
+ * })
8847
+ * ```
8848
+ */
8849
+ search<T = Record<string, unknown>>(options: VectorSearchOptions): Promise<FluxbaseResponse<VectorSearchResult<T>>>;
8850
+ }
8851
+
7473
8852
  /**
7474
8853
  * PostgreSQL query builder for Fluxbase SDK
7475
8854
  * Inspired by Supabase's PostgREST client
@@ -7493,6 +8872,7 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
7493
8872
  private operationType;
7494
8873
  private countType?;
7495
8874
  private headOnly;
8875
+ private isCountAggregation;
7496
8876
  private insertData?;
7497
8877
  private updateData?;
7498
8878
  constructor(fetch: FluxbaseFetch, table: string, schema?: string);
@@ -7691,6 +9071,56 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
7691
9071
  ascending?: boolean;
7692
9072
  nullsFirst?: boolean;
7693
9073
  }): this;
9074
+ /**
9075
+ * Order results by vector similarity (pgvector)
9076
+ * Results are ordered by distance (ascending = closest first)
9077
+ *
9078
+ * @example
9079
+ * ```typescript
9080
+ * // Order by cosine similarity (closest matches first)
9081
+ * const { data } = await client
9082
+ * .from('documents')
9083
+ * .select('id, title, content')
9084
+ * .orderByVector('embedding', queryVector, 'cosine')
9085
+ * .limit(10)
9086
+ * ```
9087
+ *
9088
+ * @param column - The vector column to order by
9089
+ * @param vector - The query vector to compare against
9090
+ * @param metric - Distance metric: 'l2' (euclidean), 'cosine', or 'inner_product'
9091
+ * @param options - Optional: { ascending?: boolean } - defaults to true (closest first)
9092
+ */
9093
+ orderByVector(column: string, vector: number[], metric?: VectorMetric, options?: {
9094
+ ascending?: boolean;
9095
+ }): this;
9096
+ /**
9097
+ * Filter by vector similarity (pgvector)
9098
+ * This is a convenience method that adds a vector filter using the specified distance metric.
9099
+ * Typically used with orderByVector() for similarity search.
9100
+ *
9101
+ * @example
9102
+ * ```typescript
9103
+ * // Find the 10 most similar documents
9104
+ * const { data } = await client
9105
+ * .from('documents')
9106
+ * .select('id, title, content')
9107
+ * .vectorSearch('embedding', queryVector, 'cosine')
9108
+ * .limit(10)
9109
+ *
9110
+ * // Combine with other filters
9111
+ * const { data } = await client
9112
+ * .from('documents')
9113
+ * .select('id, title, content')
9114
+ * .eq('status', 'published')
9115
+ * .vectorSearch('embedding', queryVector)
9116
+ * .limit(10)
9117
+ * ```
9118
+ *
9119
+ * @param column - The vector column to search
9120
+ * @param vector - The query vector
9121
+ * @param metric - Distance metric: 'l2' (euclidean), 'cosine', or 'inner_product'
9122
+ */
9123
+ vectorSearch(column: string, vector: number[], metric?: VectorMetric): this;
7694
9124
  /**
7695
9125
  * Limit number of rows returned
7696
9126
  */
@@ -7984,6 +9414,21 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
7984
9414
  * Header format: "0-999/50000" or "* /50000" (when no rows returned)
7985
9415
  */
7986
9416
  private parseContentRangeCount;
9417
+ /**
9418
+ * Check if the query should use POST-based query endpoint
9419
+ * Returns true if the query string would exceed the URL length threshold
9420
+ */
9421
+ private shouldUsePostQuery;
9422
+ /**
9423
+ * Execute a SELECT query using the POST /query endpoint
9424
+ * Used when query parameters would exceed URL length limits
9425
+ */
9426
+ private executePostQuery;
9427
+ /**
9428
+ * Build the request body for POST-based queries
9429
+ * Used when query parameters would exceed URL length limits
9430
+ */
9431
+ private buildQueryBody;
7987
9432
  }
7988
9433
 
7989
9434
  /**
@@ -7991,10 +9436,10 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
7991
9436
  *
7992
9437
  * @example
7993
9438
  * ```typescript
7994
- * // Query the jobs.execution_logs table
9439
+ * // Query the logging.entries table
7995
9440
  * const { data } = await client
7996
- * .schema('jobs')
7997
- * .from('execution_logs')
9441
+ * .schema('logging')
9442
+ * .from('entries')
7998
9443
  * .select('*')
7999
9444
  * .execute();
8000
9445
  * ```
@@ -8013,6 +9458,29 @@ declare class SchemaQueryBuilder {
8013
9458
  from<T = any>(table: string): QueryBuilder<T>;
8014
9459
  }
8015
9460
 
9461
+ /**
9462
+ * Callable RPC type - can be called directly (Supabase-compatible) or access methods
9463
+ * @category RPC
9464
+ */
9465
+ type CallableRPC = {
9466
+ /**
9467
+ * Call a PostgreSQL function (RPC) - Supabase compatible
9468
+ * Uses 'default' namespace
9469
+ *
9470
+ * @param fn - Function name
9471
+ * @param params - Function parameters
9472
+ * @returns Promise with data or error
9473
+ *
9474
+ * @example
9475
+ * ```typescript
9476
+ * const { data, error } = await client.rpc('get_user_orders', { user_id: '123' })
9477
+ * ```
9478
+ */
9479
+ <T = any>(fn: string, params?: Record<string, unknown>): Promise<{
9480
+ data: T | null;
9481
+ error: Error | null;
9482
+ }>;
9483
+ } & FluxbaseRPC;
8016
9484
  /**
8017
9485
  * Main Fluxbase client class
8018
9486
  * @category Client
@@ -8040,6 +9508,57 @@ declare class FluxbaseClient<Database = any, _SchemaName extends string & keyof
8040
9508
  settings: SettingsClient;
8041
9509
  /** AI module for chatbots and conversation history */
8042
9510
  ai: FluxbaseAI;
9511
+ /**
9512
+ * Vector search module for pgvector similarity search
9513
+ *
9514
+ * Provides convenience methods for vector similarity search:
9515
+ * - `embed()` - Generate embeddings from text
9516
+ * - `search()` - Search for similar vectors with auto-embedding
9517
+ *
9518
+ * @example
9519
+ * ```typescript
9520
+ * // Search with automatic embedding
9521
+ * const { data } = await client.vector.search({
9522
+ * table: 'documents',
9523
+ * column: 'embedding',
9524
+ * query: 'How to use TypeScript?',
9525
+ * match_count: 10
9526
+ * })
9527
+ *
9528
+ * // Generate embeddings
9529
+ * const { data } = await client.vector.embed({ text: 'Hello world' })
9530
+ * ```
9531
+ *
9532
+ * Note: For more control, use the QueryBuilder methods:
9533
+ * - `vectorSearch()` - Filter and order by vector similarity
9534
+ * - `orderByVector()` - Order results by vector distance
9535
+ *
9536
+ * @category Vector Search
9537
+ */
9538
+ vector: FluxbaseVector;
9539
+ /**
9540
+ * RPC module for calling PostgreSQL functions - Supabase compatible
9541
+ *
9542
+ * Can be called directly (Supabase-style) or access methods like invoke(), list(), getStatus()
9543
+ *
9544
+ * @example
9545
+ * ```typescript
9546
+ * // Supabase-style direct call (uses 'default' namespace)
9547
+ * const { data, error } = await client.rpc('get_user_orders', { user_id: '123' })
9548
+ *
9549
+ * // With full options
9550
+ * const { data, error } = await client.rpc.invoke('get_user_orders', { user_id: '123' }, {
9551
+ * namespace: 'custom',
9552
+ * async: true
9553
+ * })
9554
+ *
9555
+ * // List available procedures
9556
+ * const { data: procedures } = await client.rpc.list()
9557
+ * ```
9558
+ *
9559
+ * @category RPC
9560
+ */
9561
+ rpc: CallableRPC;
8043
9562
  /**
8044
9563
  * Create a new Fluxbase client instance
8045
9564
  *
@@ -8092,12 +9611,12 @@ declare class FluxbaseClient<Database = any, _SchemaName extends string & keyof
8092
9611
  *
8093
9612
  * @example
8094
9613
  * ```typescript
8095
- * // Query the jobs.execution_logs table
9614
+ * // Query the logging.entries table
8096
9615
  * const { data } = await client
8097
- * .schema('jobs')
8098
- * .from('execution_logs')
9616
+ * .schema('logging')
9617
+ * .from('entries')
8099
9618
  * .select('*')
8100
- * .eq('job_id', jobId)
9619
+ * .eq('execution_id', executionId)
8101
9620
  * .execute()
8102
9621
  *
8103
9622
  * // Insert into a custom schema table
@@ -8239,156 +9758,4 @@ declare class FluxbaseClient<Database = any, _SchemaName extends string & keyof
8239
9758
  */
8240
9759
  declare function createClient<Database = any, SchemaName extends string & keyof Database = any>(fluxbaseUrl?: string, fluxbaseKey?: string, options?: FluxbaseClientOptions): FluxbaseClient<Database, SchemaName>;
8241
9760
 
8242
- /**
8243
- * RPC (Remote Procedure Call) module for invoking SQL-based procedures
8244
- */
8245
-
8246
- /**
8247
- * Options for invoking an RPC procedure
8248
- */
8249
- interface RPCInvokeOptions {
8250
- /** Namespace of the procedure (defaults to 'default') */
8251
- namespace?: string;
8252
- /** Execute asynchronously (returns execution ID immediately) */
8253
- async?: boolean;
8254
- }
8255
- /**
8256
- * Fetch interface for RPC operations
8257
- */
8258
- interface RPCFetch {
8259
- get: <T>(path: string) => Promise<T>;
8260
- post: <T>(path: string, body?: unknown) => Promise<T>;
8261
- }
8262
- /**
8263
- * FluxbaseRPC provides methods for invoking RPC procedures
8264
- *
8265
- * @example
8266
- * ```typescript
8267
- * // Invoke a procedure synchronously
8268
- * const { data, error } = await fluxbase.rpc.invoke('get-user-orders', {
8269
- * user_id: '123',
8270
- * limit: 10
8271
- * });
8272
- *
8273
- * // Invoke asynchronously
8274
- * const { data: asyncResult } = await fluxbase.rpc.invoke('long-running-report', {
8275
- * start_date: '2024-01-01'
8276
- * }, { async: true });
8277
- *
8278
- * // Poll for status
8279
- * const { data: status } = await fluxbase.rpc.getStatus(asyncResult.execution_id);
8280
- * ```
8281
- */
8282
- declare class FluxbaseRPC {
8283
- private fetch;
8284
- constructor(fetch: RPCFetch);
8285
- /**
8286
- * List available RPC procedures (public, enabled)
8287
- *
8288
- * @param namespace - Optional namespace filter
8289
- * @returns Promise resolving to { data, error } tuple with array of procedure summaries
8290
- */
8291
- list(namespace?: string): Promise<{
8292
- data: RPCProcedureSummary[] | null;
8293
- error: Error | null;
8294
- }>;
8295
- /**
8296
- * Invoke an RPC procedure
8297
- *
8298
- * @param name - Procedure name
8299
- * @param params - Optional parameters to pass to the procedure
8300
- * @param options - Optional invocation options
8301
- * @returns Promise resolving to { data, error } tuple with invocation response
8302
- *
8303
- * @example
8304
- * ```typescript
8305
- * // Synchronous invocation
8306
- * const { data, error } = await fluxbase.rpc.invoke('get-user-orders', {
8307
- * user_id: '123',
8308
- * limit: 10
8309
- * });
8310
- * console.log(data.result); // Query results
8311
- *
8312
- * // Asynchronous invocation
8313
- * const { data: asyncData } = await fluxbase.rpc.invoke('generate-report', {
8314
- * year: 2024
8315
- * }, { async: true });
8316
- * console.log(asyncData.execution_id); // Use to poll status
8317
- * ```
8318
- */
8319
- invoke<T = unknown>(name: string, params?: Record<string, unknown>, options?: RPCInvokeOptions): Promise<{
8320
- data: RPCInvokeResponse<T> | null;
8321
- error: Error | null;
8322
- }>;
8323
- /**
8324
- * Get execution status (for async invocations or checking history)
8325
- *
8326
- * @param executionId - The execution ID returned from async invoke
8327
- * @returns Promise resolving to { data, error } tuple with execution details
8328
- *
8329
- * @example
8330
- * ```typescript
8331
- * const { data, error } = await fluxbase.rpc.getStatus('execution-uuid');
8332
- * if (data.status === 'completed') {
8333
- * console.log('Result:', data.result);
8334
- * } else if (data.status === 'running') {
8335
- * console.log('Still running...');
8336
- * }
8337
- * ```
8338
- */
8339
- getStatus(executionId: string): Promise<{
8340
- data: RPCExecution | null;
8341
- error: Error | null;
8342
- }>;
8343
- /**
8344
- * Get execution logs (for debugging and monitoring)
8345
- *
8346
- * @param executionId - The execution ID
8347
- * @param afterLine - Optional line number to get logs after (for polling)
8348
- * @returns Promise resolving to { data, error } tuple with execution logs
8349
- *
8350
- * @example
8351
- * ```typescript
8352
- * const { data: logs } = await fluxbase.rpc.getLogs('execution-uuid');
8353
- * for (const log of logs) {
8354
- * console.log(`[${log.level}] ${log.message}`);
8355
- * }
8356
- * ```
8357
- */
8358
- getLogs(executionId: string, afterLine?: number): Promise<{
8359
- data: RPCExecutionLog[] | null;
8360
- error: Error | null;
8361
- }>;
8362
- /**
8363
- * Poll for execution completion with exponential backoff
8364
- *
8365
- * @param executionId - The execution ID to poll
8366
- * @param options - Polling options
8367
- * @returns Promise resolving to final execution state
8368
- *
8369
- * @example
8370
- * ```typescript
8371
- * const { data: result } = await fluxbase.rpc.invoke('long-task', {}, { async: true });
8372
- * const { data: final } = await fluxbase.rpc.waitForCompletion(result.execution_id, {
8373
- * maxWaitMs: 60000, // Wait up to 1 minute
8374
- * onProgress: (exec) => console.log(`Status: ${exec.status}`)
8375
- * });
8376
- * console.log('Final result:', final.result);
8377
- * ```
8378
- */
8379
- waitForCompletion(executionId: string, options?: {
8380
- /** Maximum time to wait in milliseconds (default: 30000) */
8381
- maxWaitMs?: number;
8382
- /** Initial polling interval in milliseconds (default: 500) */
8383
- initialIntervalMs?: number;
8384
- /** Maximum polling interval in milliseconds (default: 5000) */
8385
- maxIntervalMs?: number;
8386
- /** Callback for progress updates */
8387
- onProgress?: (execution: RPCExecution) => void;
8388
- }): Promise<{
8389
- data: RPCExecution | null;
8390
- error: Error | null;
8391
- }>;
8392
- }
8393
-
8394
- export { type AIChatClientMessage, type AIChatEvent, type AIChatEventType, type AIChatMessageRole, type AIChatOptions, type AIChatServerMessage, type AIChatbot, type AIChatbotSummary, type AIConversation, type AIConversationMessage, type AIProvider, type AIProviderType, type AIUsageStats, type AIUserConversationDetail, type AIUserConversationSummary, type AIUserMessage, type AIUserQueryResult, type AIUserUsageStats, 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 ChatbotSpec, type Column, type CreateAIProviderRequest, 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, FluxbaseAI, FluxbaseAIChat, FluxbaseAdmin, FluxbaseAdminAI, FluxbaseAdminFunctions, FluxbaseAdminJobs, FluxbaseAdminMigrations, FluxbaseAdminRPC, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseJobs, FluxbaseManagement, FluxbaseOAuth, FluxbaseRPC, 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 ListConversationsOptions, type ListConversationsResult, 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 RPCExecution, type RPCExecutionFilters, type RPCExecutionLog, type RPCExecutionStatus, type RPCInvokeResponse, type RPCProcedure, type RPCProcedureSpec, type RPCProcedureSummary, 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 StreamUploadOptions, type SupabaseAuthResponse, type SupabaseResponse, type SyncChatbotsOptions, type SyncChatbotsResult, type SyncError, type SyncFunctionsOptions, type SyncFunctionsResult, type SyncMigrationsOptions, type SyncMigrationsResult, type SyncRPCOptions, type SyncRPCResult, type SystemSetting, SystemSettingsManager, type Table, type TestEmailTemplateRequest, type TestWebhookResponse, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAIProviderRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateConversationOptions, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateMigrationRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateRPCProcedureRequest, 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, bundleCode, createClient, denoExternalPlugin, loadImportMap };
9761
+ export { type AIChatClientMessage, type AIChatEvent, type AIChatEventType, type AIChatMessageRole, type AIChatOptions, type AIChatServerMessage, type AIChatbot, type AIChatbotSummary, type AIConversation, type AIConversationMessage, type AIProvider, type AIProviderType, type AIUsageStats, type AIUserConversationDetail, type AIUserConversationSummary, type AIUserMessage, type AIUserQueryResult, type AIUserUsageStats, type APIKey, APIKeysManager, type AcceptInvitationRequest, type AcceptInvitationResponse, type AdminAuthResponse, type AdminBucket, type AdminListBucketsResponse, type AdminListObjectsResponse, type AdminLoginRequest, type AdminMeResponse, type AdminRefreshRequest, type AdminRefreshResponse, type AdminSetupRequest, type AdminSetupStatusResponse, type AdminStorageObject, 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 ChatbotSpec, type ChunkedUploadSession, type Column, type CreateAIProviderRequest, 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 EmbedRequest, type EmbedResponse, type EnrichedUser, type ExecutionLog, type ExecutionLogCallback, type ExecutionLogConfig, type ExecutionLogEvent, type ExecutionLogLevel, ExecutionLogsChannel, type ExecutionType, type FeatureSettings, type FileObject, type FilterOperator, FluxbaseAI, FluxbaseAIChat, FluxbaseAdmin, FluxbaseAdminAI, FluxbaseAdminFunctions, FluxbaseAdminJobs, FluxbaseAdminMigrations, FluxbaseAdminRPC, FluxbaseAdminStorage, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseJobs, FluxbaseManagement, FluxbaseOAuth, FluxbaseRPC, FluxbaseRealtime, type FluxbaseResponse, FluxbaseSettings, FluxbaseStorage, FluxbaseVector, type FunctionInvokeOptions, type FunctionSpec, type GetImpersonationResponse, type HealthResponse, 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 ListConversationsOptions, type ListConversationsResult, 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 RPCExecution, type RPCExecutionFilters, type RPCExecutionLog, type RPCExecutionStatus, type RPCInvokeResponse, type RPCProcedure, type RPCProcedureSpec, type RPCProcedureSummary, type RealtimeBroadcastPayload, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeChannelConfig, type RealtimeMessage, type RealtimePostgresChangesPayload, type RealtimePresencePayload, type RequestOptions, type ResetUserPasswordResponse, type ResumableDownloadData, type ResumableDownloadOptions, type ResumableUploadOptions, type ResumableUploadProgress, type RevokeAPIKeyResponse, type RevokeInvitationResponse, type RollbackMigrationRequest, type SESSettings, type SMTPSettings, type Schema, SchemaQueryBuilder, type SecuritySettings, type SendEmailRequest, type SendGridSettings, type SessionResponse, SettingsClient, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type SignedUrlResponse, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type StreamDownloadData, type StreamUploadOptions, type SupabaseAuthResponse, type SupabaseResponse, type SyncChatbotsOptions, type SyncChatbotsResult, type SyncError, type SyncFunctionsOptions, type SyncFunctionsResult, type SyncMigrationsOptions, type SyncMigrationsResult, type SyncRPCOptions, type SyncRPCResult, type SystemSetting, SystemSettingsManager, type Table, type TestEmailTemplateRequest, type TestWebhookResponse, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAIProviderRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateConversationOptions, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateMigrationRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateRPCProcedureRequest, type UpdateSystemSettingRequest, type UpdateUserAttributes, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type UploadProgress, type UpsertOptions, type User, type UserResponse, type ValidateInvitationResponse, type VectorMetric, type VectorOrderOptions, type VectorSearchOptions, type VectorSearchResult, type VoidResponse, type WeakPassword, type Webhook, type WebhookDelivery, WebhooksManager, bundleCode, createClient, denoExternalPlugin, loadImportMap };