@fluxbase/sdk 0.0.1-rc.46 → 0.0.1-rc.48
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 +1749 -253
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1746 -128
- package/dist/index.d.ts +1746 -128
- package/dist/index.js +1742 -254
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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';
|
|
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';
|
|
205
205
|
interface QueryFilter {
|
|
206
206
|
column: string;
|
|
207
207
|
operator: FilterOperator;
|
|
@@ -382,6 +382,23 @@ interface UploadOptions {
|
|
|
382
382
|
/** Optional callback to track upload progress */
|
|
383
383
|
onUploadProgress?: (progress: UploadProgress) => void;
|
|
384
384
|
}
|
|
385
|
+
/**
|
|
386
|
+
* Options for streaming uploads (memory-efficient for large files)
|
|
387
|
+
*/
|
|
388
|
+
interface StreamUploadOptions {
|
|
389
|
+
/** MIME type of the file */
|
|
390
|
+
contentType?: string;
|
|
391
|
+
/** Custom metadata to attach to the file */
|
|
392
|
+
metadata?: Record<string, string>;
|
|
393
|
+
/** Cache-Control header value */
|
|
394
|
+
cacheControl?: string;
|
|
395
|
+
/** If true, overwrite existing file at this path */
|
|
396
|
+
upsert?: boolean;
|
|
397
|
+
/** AbortSignal to cancel the upload */
|
|
398
|
+
signal?: AbortSignal;
|
|
399
|
+
/** Optional callback to track upload progress */
|
|
400
|
+
onUploadProgress?: (progress: UploadProgress) => void;
|
|
401
|
+
}
|
|
385
402
|
interface ListOptions {
|
|
386
403
|
prefix?: string;
|
|
387
404
|
limit?: number;
|
|
@@ -876,6 +893,9 @@ interface FeatureSettings {
|
|
|
876
893
|
enable_realtime: boolean;
|
|
877
894
|
enable_storage: boolean;
|
|
878
895
|
enable_functions: boolean;
|
|
896
|
+
enable_ai: boolean;
|
|
897
|
+
enable_jobs: boolean;
|
|
898
|
+
enable_rpc: boolean;
|
|
879
899
|
}
|
|
880
900
|
/**
|
|
881
901
|
* SMTP email provider configuration
|
|
@@ -1398,6 +1418,14 @@ interface FunctionSpec {
|
|
|
1398
1418
|
name: string;
|
|
1399
1419
|
description?: string;
|
|
1400
1420
|
code: string;
|
|
1421
|
+
/** If true, code is already bundled and server will skip bundling */
|
|
1422
|
+
is_pre_bundled?: boolean;
|
|
1423
|
+
/** Original source code (for debugging when pre-bundled) */
|
|
1424
|
+
original_code?: string;
|
|
1425
|
+
/** Source directory for resolving relative imports during bundling (used by syncWithBundling) */
|
|
1426
|
+
sourceDir?: string;
|
|
1427
|
+
/** Additional paths to search for node_modules during bundling (used by syncWithBundling) */
|
|
1428
|
+
nodePaths?: string[];
|
|
1401
1429
|
enabled?: boolean;
|
|
1402
1430
|
timeout_seconds?: number;
|
|
1403
1431
|
memory_limit_mb?: number;
|
|
@@ -1569,6 +1597,18 @@ interface Job {
|
|
|
1569
1597
|
/** Estimated seconds remaining (computed, only for running jobs with progress > 0) */
|
|
1570
1598
|
estimated_seconds_left?: number;
|
|
1571
1599
|
}
|
|
1600
|
+
/**
|
|
1601
|
+
* User context for submitting jobs on behalf of another user.
|
|
1602
|
+
* Only available when using service_role authentication.
|
|
1603
|
+
*/
|
|
1604
|
+
interface OnBehalfOf {
|
|
1605
|
+
/** User ID (UUID) to submit the job as */
|
|
1606
|
+
user_id: string;
|
|
1607
|
+
/** Optional email address of the user */
|
|
1608
|
+
user_email?: string;
|
|
1609
|
+
/** Optional role of the user (defaults to "authenticated") */
|
|
1610
|
+
user_role?: string;
|
|
1611
|
+
}
|
|
1572
1612
|
/**
|
|
1573
1613
|
* Job statistics
|
|
1574
1614
|
*/
|
|
@@ -1764,6 +1804,296 @@ interface SyncMigrationsResult {
|
|
|
1764
1804
|
/** Warning messages */
|
|
1765
1805
|
warnings?: string[];
|
|
1766
1806
|
}
|
|
1807
|
+
/**
|
|
1808
|
+
* AI provider type
|
|
1809
|
+
*/
|
|
1810
|
+
type AIProviderType = 'openai' | 'azure' | 'ollama';
|
|
1811
|
+
/**
|
|
1812
|
+
* AI provider configuration
|
|
1813
|
+
*/
|
|
1814
|
+
interface AIProvider {
|
|
1815
|
+
id: string;
|
|
1816
|
+
name: string;
|
|
1817
|
+
display_name: string;
|
|
1818
|
+
provider_type: AIProviderType;
|
|
1819
|
+
is_default: boolean;
|
|
1820
|
+
enabled: boolean;
|
|
1821
|
+
config?: Record<string, string>;
|
|
1822
|
+
created_at: string;
|
|
1823
|
+
updated_at: string;
|
|
1824
|
+
}
|
|
1825
|
+
/**
|
|
1826
|
+
* Request to create an AI provider
|
|
1827
|
+
*/
|
|
1828
|
+
interface CreateAIProviderRequest {
|
|
1829
|
+
name: string;
|
|
1830
|
+
display_name: string;
|
|
1831
|
+
provider_type: AIProviderType;
|
|
1832
|
+
is_default?: boolean;
|
|
1833
|
+
enabled?: boolean;
|
|
1834
|
+
config: Record<string, string>;
|
|
1835
|
+
}
|
|
1836
|
+
/**
|
|
1837
|
+
* Request to update an AI provider
|
|
1838
|
+
*/
|
|
1839
|
+
interface UpdateAIProviderRequest {
|
|
1840
|
+
display_name?: string;
|
|
1841
|
+
config?: Record<string, string>;
|
|
1842
|
+
enabled?: boolean;
|
|
1843
|
+
}
|
|
1844
|
+
/**
|
|
1845
|
+
* AI chatbot summary (list view)
|
|
1846
|
+
*/
|
|
1847
|
+
interface AIChatbotSummary {
|
|
1848
|
+
id: string;
|
|
1849
|
+
name: string;
|
|
1850
|
+
namespace: string;
|
|
1851
|
+
description?: string;
|
|
1852
|
+
enabled: boolean;
|
|
1853
|
+
is_public: boolean;
|
|
1854
|
+
allowed_tables: string[];
|
|
1855
|
+
allowed_operations: string[];
|
|
1856
|
+
allowed_schemas: string[];
|
|
1857
|
+
version: number;
|
|
1858
|
+
source: string;
|
|
1859
|
+
created_at: string;
|
|
1860
|
+
updated_at: string;
|
|
1861
|
+
}
|
|
1862
|
+
/**
|
|
1863
|
+
* AI chatbot full details
|
|
1864
|
+
*/
|
|
1865
|
+
interface AIChatbot extends AIChatbotSummary {
|
|
1866
|
+
code: string;
|
|
1867
|
+
original_code?: string;
|
|
1868
|
+
max_tokens: number;
|
|
1869
|
+
temperature: number;
|
|
1870
|
+
provider_id?: string;
|
|
1871
|
+
persist_conversations: boolean;
|
|
1872
|
+
conversation_ttl_hours: number;
|
|
1873
|
+
max_conversation_turns: number;
|
|
1874
|
+
rate_limit_per_minute: number;
|
|
1875
|
+
daily_request_limit: number;
|
|
1876
|
+
daily_token_budget: number;
|
|
1877
|
+
allow_unauthenticated: boolean;
|
|
1878
|
+
}
|
|
1879
|
+
/**
|
|
1880
|
+
* Chatbot specification for sync operations
|
|
1881
|
+
*/
|
|
1882
|
+
interface ChatbotSpec {
|
|
1883
|
+
name: string;
|
|
1884
|
+
description?: string;
|
|
1885
|
+
code: string;
|
|
1886
|
+
original_code?: string;
|
|
1887
|
+
is_pre_bundled?: boolean;
|
|
1888
|
+
enabled?: boolean;
|
|
1889
|
+
allowed_tables?: string[];
|
|
1890
|
+
allowed_operations?: string[];
|
|
1891
|
+
allowed_schemas?: string[];
|
|
1892
|
+
max_tokens?: number;
|
|
1893
|
+
temperature?: number;
|
|
1894
|
+
persist_conversations?: boolean;
|
|
1895
|
+
conversation_ttl_hours?: number;
|
|
1896
|
+
max_conversation_turns?: number;
|
|
1897
|
+
rate_limit_per_minute?: number;
|
|
1898
|
+
daily_request_limit?: number;
|
|
1899
|
+
daily_token_budget?: number;
|
|
1900
|
+
allow_unauthenticated?: boolean;
|
|
1901
|
+
is_public?: boolean;
|
|
1902
|
+
}
|
|
1903
|
+
/**
|
|
1904
|
+
* Options for syncing chatbots
|
|
1905
|
+
*/
|
|
1906
|
+
interface SyncChatbotsOptions {
|
|
1907
|
+
namespace?: string;
|
|
1908
|
+
chatbots?: ChatbotSpec[];
|
|
1909
|
+
options?: {
|
|
1910
|
+
delete_missing?: boolean;
|
|
1911
|
+
dry_run?: boolean;
|
|
1912
|
+
};
|
|
1913
|
+
}
|
|
1914
|
+
/**
|
|
1915
|
+
* Result of a chatbot sync operation
|
|
1916
|
+
*/
|
|
1917
|
+
interface SyncChatbotsResult {
|
|
1918
|
+
message: string;
|
|
1919
|
+
namespace: string;
|
|
1920
|
+
summary: {
|
|
1921
|
+
created: number;
|
|
1922
|
+
updated: number;
|
|
1923
|
+
deleted: number;
|
|
1924
|
+
unchanged: number;
|
|
1925
|
+
errors: number;
|
|
1926
|
+
};
|
|
1927
|
+
details: {
|
|
1928
|
+
created: string[];
|
|
1929
|
+
updated: string[];
|
|
1930
|
+
deleted: string[];
|
|
1931
|
+
unchanged: string[];
|
|
1932
|
+
};
|
|
1933
|
+
errors: SyncError[];
|
|
1934
|
+
dry_run: boolean;
|
|
1935
|
+
}
|
|
1936
|
+
/**
|
|
1937
|
+
* AI chat message role
|
|
1938
|
+
*/
|
|
1939
|
+
type AIChatMessageRole = 'user' | 'assistant' | 'system' | 'tool';
|
|
1940
|
+
/**
|
|
1941
|
+
* AI chat message for WebSocket
|
|
1942
|
+
*/
|
|
1943
|
+
interface AIChatClientMessage {
|
|
1944
|
+
type: 'start_chat' | 'message' | 'cancel';
|
|
1945
|
+
chatbot?: string;
|
|
1946
|
+
namespace?: string;
|
|
1947
|
+
conversation_id?: string;
|
|
1948
|
+
content?: string;
|
|
1949
|
+
impersonate_user_id?: string;
|
|
1950
|
+
}
|
|
1951
|
+
/**
|
|
1952
|
+
* AI chat server message
|
|
1953
|
+
*/
|
|
1954
|
+
interface AIChatServerMessage {
|
|
1955
|
+
type: 'chat_started' | 'progress' | 'content' | 'query_result' | 'done' | 'error' | 'cancelled';
|
|
1956
|
+
conversation_id?: string;
|
|
1957
|
+
message_id?: string;
|
|
1958
|
+
chatbot?: string;
|
|
1959
|
+
step?: string;
|
|
1960
|
+
message?: string;
|
|
1961
|
+
delta?: string;
|
|
1962
|
+
query?: string;
|
|
1963
|
+
summary?: string;
|
|
1964
|
+
row_count?: number;
|
|
1965
|
+
data?: Record<string, any>[];
|
|
1966
|
+
usage?: AIUsageStats;
|
|
1967
|
+
error?: string;
|
|
1968
|
+
code?: string;
|
|
1969
|
+
}
|
|
1970
|
+
/**
|
|
1971
|
+
* AI token usage statistics
|
|
1972
|
+
*/
|
|
1973
|
+
interface AIUsageStats {
|
|
1974
|
+
prompt_tokens: number;
|
|
1975
|
+
completion_tokens: number;
|
|
1976
|
+
total_tokens?: number;
|
|
1977
|
+
}
|
|
1978
|
+
/**
|
|
1979
|
+
* AI conversation summary
|
|
1980
|
+
*/
|
|
1981
|
+
interface AIConversation {
|
|
1982
|
+
id: string;
|
|
1983
|
+
chatbot_id: string;
|
|
1984
|
+
user_id?: string;
|
|
1985
|
+
session_id?: string;
|
|
1986
|
+
title?: string;
|
|
1987
|
+
status: 'active' | 'archived';
|
|
1988
|
+
turn_count: number;
|
|
1989
|
+
total_prompt_tokens: number;
|
|
1990
|
+
total_completion_tokens: number;
|
|
1991
|
+
created_at: string;
|
|
1992
|
+
updated_at: string;
|
|
1993
|
+
last_message_at: string;
|
|
1994
|
+
expires_at?: string;
|
|
1995
|
+
}
|
|
1996
|
+
/**
|
|
1997
|
+
* AI conversation message
|
|
1998
|
+
*/
|
|
1999
|
+
interface AIConversationMessage {
|
|
2000
|
+
id: string;
|
|
2001
|
+
conversation_id: string;
|
|
2002
|
+
role: AIChatMessageRole;
|
|
2003
|
+
content: string;
|
|
2004
|
+
tool_call_id?: string;
|
|
2005
|
+
tool_name?: string;
|
|
2006
|
+
executed_sql?: string;
|
|
2007
|
+
sql_result_summary?: string;
|
|
2008
|
+
sql_row_count?: number;
|
|
2009
|
+
sql_error?: string;
|
|
2010
|
+
sql_duration_ms?: number;
|
|
2011
|
+
prompt_tokens?: number;
|
|
2012
|
+
completion_tokens?: number;
|
|
2013
|
+
created_at: string;
|
|
2014
|
+
sequence_number: number;
|
|
2015
|
+
}
|
|
2016
|
+
/**
|
|
2017
|
+
* User's conversation summary (list view)
|
|
2018
|
+
*/
|
|
2019
|
+
interface AIUserConversationSummary {
|
|
2020
|
+
id: string;
|
|
2021
|
+
chatbot: string;
|
|
2022
|
+
namespace: string;
|
|
2023
|
+
title?: string;
|
|
2024
|
+
preview: string;
|
|
2025
|
+
message_count: number;
|
|
2026
|
+
created_at: string;
|
|
2027
|
+
updated_at: string;
|
|
2028
|
+
}
|
|
2029
|
+
/**
|
|
2030
|
+
* Query result data in a user message
|
|
2031
|
+
*/
|
|
2032
|
+
interface AIUserQueryResult {
|
|
2033
|
+
query?: string;
|
|
2034
|
+
summary: string;
|
|
2035
|
+
row_count: number;
|
|
2036
|
+
data?: Record<string, unknown>[];
|
|
2037
|
+
}
|
|
2038
|
+
/**
|
|
2039
|
+
* Token usage stats in a user message
|
|
2040
|
+
*/
|
|
2041
|
+
interface AIUserUsageStats {
|
|
2042
|
+
prompt_tokens: number;
|
|
2043
|
+
completion_tokens: number;
|
|
2044
|
+
total_tokens?: number;
|
|
2045
|
+
}
|
|
2046
|
+
/**
|
|
2047
|
+
* User's message in conversation detail view
|
|
2048
|
+
*/
|
|
2049
|
+
interface AIUserMessage {
|
|
2050
|
+
id: string;
|
|
2051
|
+
role: 'user' | 'assistant';
|
|
2052
|
+
content: string;
|
|
2053
|
+
timestamp: string;
|
|
2054
|
+
query_results?: AIUserQueryResult[];
|
|
2055
|
+
usage?: AIUserUsageStats;
|
|
2056
|
+
}
|
|
2057
|
+
/**
|
|
2058
|
+
* User's conversation detail with messages
|
|
2059
|
+
*/
|
|
2060
|
+
interface AIUserConversationDetail {
|
|
2061
|
+
id: string;
|
|
2062
|
+
chatbot: string;
|
|
2063
|
+
namespace: string;
|
|
2064
|
+
title?: string;
|
|
2065
|
+
created_at: string;
|
|
2066
|
+
updated_at: string;
|
|
2067
|
+
messages: AIUserMessage[];
|
|
2068
|
+
}
|
|
2069
|
+
/**
|
|
2070
|
+
* Options for listing user conversations
|
|
2071
|
+
*/
|
|
2072
|
+
interface ListConversationsOptions {
|
|
2073
|
+
/** Filter by chatbot name */
|
|
2074
|
+
chatbot?: string;
|
|
2075
|
+
/** Filter by namespace */
|
|
2076
|
+
namespace?: string;
|
|
2077
|
+
/** Number of conversations to return (default: 50, max: 100) */
|
|
2078
|
+
limit?: number;
|
|
2079
|
+
/** Offset for pagination */
|
|
2080
|
+
offset?: number;
|
|
2081
|
+
}
|
|
2082
|
+
/**
|
|
2083
|
+
* Result of listing user conversations
|
|
2084
|
+
*/
|
|
2085
|
+
interface ListConversationsResult {
|
|
2086
|
+
conversations: AIUserConversationSummary[];
|
|
2087
|
+
total: number;
|
|
2088
|
+
has_more: boolean;
|
|
2089
|
+
}
|
|
2090
|
+
/**
|
|
2091
|
+
* Options for updating a conversation
|
|
2092
|
+
*/
|
|
2093
|
+
interface UpdateConversationOptions {
|
|
2094
|
+
/** New title for the conversation */
|
|
2095
|
+
title: string;
|
|
2096
|
+
}
|
|
1767
2097
|
/**
|
|
1768
2098
|
* Base Fluxbase response type (Supabase-compatible)
|
|
1769
2099
|
* Returns either `{ data, error: null }` on success or `{ data: null, error }` on failure
|
|
@@ -1815,6 +2145,151 @@ type SessionResponse = FluxbaseResponse<{
|
|
|
1815
2145
|
* Generic data response
|
|
1816
2146
|
*/
|
|
1817
2147
|
type DataResponse<T> = FluxbaseResponse<T>;
|
|
2148
|
+
/**
|
|
2149
|
+
* RPC procedure summary for listings
|
|
2150
|
+
*/
|
|
2151
|
+
interface RPCProcedureSummary {
|
|
2152
|
+
id: string;
|
|
2153
|
+
name: string;
|
|
2154
|
+
namespace: string;
|
|
2155
|
+
description?: string;
|
|
2156
|
+
allowed_tables: string[];
|
|
2157
|
+
allowed_schemas: string[];
|
|
2158
|
+
max_execution_time_seconds: number;
|
|
2159
|
+
require_role?: string;
|
|
2160
|
+
is_public: boolean;
|
|
2161
|
+
enabled: boolean;
|
|
2162
|
+
version: number;
|
|
2163
|
+
source: string;
|
|
2164
|
+
created_at: string;
|
|
2165
|
+
updated_at: string;
|
|
2166
|
+
}
|
|
2167
|
+
/**
|
|
2168
|
+
* Full RPC procedure details
|
|
2169
|
+
*/
|
|
2170
|
+
interface RPCProcedure extends RPCProcedureSummary {
|
|
2171
|
+
sql_query: string;
|
|
2172
|
+
original_code?: string;
|
|
2173
|
+
input_schema?: Record<string, string>;
|
|
2174
|
+
output_schema?: Record<string, string>;
|
|
2175
|
+
created_by?: string;
|
|
2176
|
+
}
|
|
2177
|
+
/**
|
|
2178
|
+
* RPC execution status
|
|
2179
|
+
*/
|
|
2180
|
+
type RPCExecutionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timeout';
|
|
2181
|
+
/**
|
|
2182
|
+
* RPC execution record
|
|
2183
|
+
*/
|
|
2184
|
+
interface RPCExecution {
|
|
2185
|
+
id: string;
|
|
2186
|
+
procedure_id?: string;
|
|
2187
|
+
procedure_name: string;
|
|
2188
|
+
namespace: string;
|
|
2189
|
+
status: RPCExecutionStatus;
|
|
2190
|
+
input_params?: Record<string, unknown>;
|
|
2191
|
+
result?: unknown;
|
|
2192
|
+
error_message?: string;
|
|
2193
|
+
rows_returned?: number;
|
|
2194
|
+
duration_ms?: number;
|
|
2195
|
+
user_id?: string;
|
|
2196
|
+
user_role?: string;
|
|
2197
|
+
user_email?: string;
|
|
2198
|
+
is_async: boolean;
|
|
2199
|
+
created_at: string;
|
|
2200
|
+
started_at?: string;
|
|
2201
|
+
completed_at?: string;
|
|
2202
|
+
}
|
|
2203
|
+
/**
|
|
2204
|
+
* RPC invocation response
|
|
2205
|
+
*/
|
|
2206
|
+
interface RPCInvokeResponse<T = unknown> {
|
|
2207
|
+
execution_id: string;
|
|
2208
|
+
status: RPCExecutionStatus;
|
|
2209
|
+
result?: T;
|
|
2210
|
+
rows_returned?: number;
|
|
2211
|
+
duration_ms?: number;
|
|
2212
|
+
error?: string;
|
|
2213
|
+
}
|
|
2214
|
+
/**
|
|
2215
|
+
* RPC execution log entry
|
|
2216
|
+
*/
|
|
2217
|
+
interface RPCExecutionLog {
|
|
2218
|
+
id: number;
|
|
2219
|
+
execution_id: string;
|
|
2220
|
+
line_number: number;
|
|
2221
|
+
level: string;
|
|
2222
|
+
message: string;
|
|
2223
|
+
created_at: string;
|
|
2224
|
+
}
|
|
2225
|
+
/**
|
|
2226
|
+
* RPC procedure specification for sync operations
|
|
2227
|
+
*/
|
|
2228
|
+
interface RPCProcedureSpec {
|
|
2229
|
+
name: string;
|
|
2230
|
+
code: string;
|
|
2231
|
+
description?: string;
|
|
2232
|
+
enabled?: boolean;
|
|
2233
|
+
}
|
|
2234
|
+
/**
|
|
2235
|
+
* Options for syncing RPC procedures
|
|
2236
|
+
*/
|
|
2237
|
+
interface SyncRPCOptions {
|
|
2238
|
+
namespace?: string;
|
|
2239
|
+
procedures?: RPCProcedureSpec[];
|
|
2240
|
+
options?: {
|
|
2241
|
+
delete_missing?: boolean;
|
|
2242
|
+
dry_run?: boolean;
|
|
2243
|
+
};
|
|
2244
|
+
}
|
|
2245
|
+
/**
|
|
2246
|
+
* Result of RPC sync operation
|
|
2247
|
+
*/
|
|
2248
|
+
interface SyncRPCResult {
|
|
2249
|
+
message: string;
|
|
2250
|
+
namespace: string;
|
|
2251
|
+
summary: {
|
|
2252
|
+
created: number;
|
|
2253
|
+
updated: number;
|
|
2254
|
+
deleted: number;
|
|
2255
|
+
unchanged: number;
|
|
2256
|
+
errors: number;
|
|
2257
|
+
};
|
|
2258
|
+
details: {
|
|
2259
|
+
created: string[];
|
|
2260
|
+
updated: string[];
|
|
2261
|
+
deleted: string[];
|
|
2262
|
+
unchanged: string[];
|
|
2263
|
+
};
|
|
2264
|
+
errors: Array<{
|
|
2265
|
+
procedure: string;
|
|
2266
|
+
error: string;
|
|
2267
|
+
}>;
|
|
2268
|
+
dry_run: boolean;
|
|
2269
|
+
}
|
|
2270
|
+
/**
|
|
2271
|
+
* Options for updating an RPC procedure
|
|
2272
|
+
*/
|
|
2273
|
+
interface UpdateRPCProcedureRequest {
|
|
2274
|
+
description?: string;
|
|
2275
|
+
enabled?: boolean;
|
|
2276
|
+
is_public?: boolean;
|
|
2277
|
+
require_role?: string;
|
|
2278
|
+
max_execution_time_seconds?: number;
|
|
2279
|
+
allowed_tables?: string[];
|
|
2280
|
+
allowed_schemas?: string[];
|
|
2281
|
+
}
|
|
2282
|
+
/**
|
|
2283
|
+
* Filters for listing RPC executions
|
|
2284
|
+
*/
|
|
2285
|
+
interface RPCExecutionFilters {
|
|
2286
|
+
namespace?: string;
|
|
2287
|
+
procedure?: string;
|
|
2288
|
+
status?: RPCExecutionStatus;
|
|
2289
|
+
user_id?: string;
|
|
2290
|
+
limit?: number;
|
|
2291
|
+
offset?: number;
|
|
2292
|
+
}
|
|
1818
2293
|
/**
|
|
1819
2294
|
* @deprecated Use FluxbaseResponse instead
|
|
1820
2295
|
*/
|
|
@@ -2555,8 +3030,73 @@ declare class StorageBucket {
|
|
|
2555
3030
|
*/
|
|
2556
3031
|
private uploadWithProgress;
|
|
2557
3032
|
/**
|
|
2558
|
-
*
|
|
2559
|
-
*
|
|
3033
|
+
* Upload a file using streaming for reduced memory usage.
|
|
3034
|
+
* This method bypasses FormData buffering and streams data directly to the server.
|
|
3035
|
+
* Ideal for large files where memory efficiency is important.
|
|
3036
|
+
*
|
|
3037
|
+
* @param path - The path/key for the file
|
|
3038
|
+
* @param stream - ReadableStream of the file data
|
|
3039
|
+
* @param size - The size of the file in bytes (required for Content-Length header)
|
|
3040
|
+
* @param options - Upload options
|
|
3041
|
+
*
|
|
3042
|
+
* @example
|
|
3043
|
+
* ```typescript
|
|
3044
|
+
* // Upload from a File's stream
|
|
3045
|
+
* const file = new File([...], 'large-video.mp4');
|
|
3046
|
+
* const { data, error } = await storage
|
|
3047
|
+
* .from('videos')
|
|
3048
|
+
* .uploadStream('video.mp4', file.stream(), file.size, {
|
|
3049
|
+
* contentType: 'video/mp4',
|
|
3050
|
+
* });
|
|
3051
|
+
*
|
|
3052
|
+
* // Upload from a fetch response stream
|
|
3053
|
+
* const response = await fetch('https://example.com/data.zip');
|
|
3054
|
+
* const size = parseInt(response.headers.get('content-length') || '0');
|
|
3055
|
+
* const { data, error } = await storage
|
|
3056
|
+
* .from('files')
|
|
3057
|
+
* .uploadStream('data.zip', response.body!, size, {
|
|
3058
|
+
* contentType: 'application/zip',
|
|
3059
|
+
* });
|
|
3060
|
+
* ```
|
|
3061
|
+
*/
|
|
3062
|
+
uploadStream(path: string, stream: ReadableStream<Uint8Array>, size: number, options?: StreamUploadOptions): Promise<{
|
|
3063
|
+
data: {
|
|
3064
|
+
id: string;
|
|
3065
|
+
path: string;
|
|
3066
|
+
fullPath: string;
|
|
3067
|
+
} | null;
|
|
3068
|
+
error: Error | null;
|
|
3069
|
+
}>;
|
|
3070
|
+
/**
|
|
3071
|
+
* Upload a large file using streaming for reduced memory usage.
|
|
3072
|
+
* This is a convenience method that converts a File or Blob to a stream.
|
|
3073
|
+
*
|
|
3074
|
+
* @param path - The path/key for the file
|
|
3075
|
+
* @param file - The File or Blob to upload
|
|
3076
|
+
* @param options - Upload options
|
|
3077
|
+
*
|
|
3078
|
+
* @example
|
|
3079
|
+
* ```typescript
|
|
3080
|
+
* const file = new File([...], 'large-video.mp4');
|
|
3081
|
+
* const { data, error } = await storage
|
|
3082
|
+
* .from('videos')
|
|
3083
|
+
* .uploadLargeFile('video.mp4', file, {
|
|
3084
|
+
* contentType: 'video/mp4',
|
|
3085
|
+
* onUploadProgress: (p) => console.log(`${p.percentage}% complete`),
|
|
3086
|
+
* });
|
|
3087
|
+
* ```
|
|
3088
|
+
*/
|
|
3089
|
+
uploadLargeFile(path: string, file: File | Blob, options?: StreamUploadOptions): Promise<{
|
|
3090
|
+
data: {
|
|
3091
|
+
id: string;
|
|
3092
|
+
path: string;
|
|
3093
|
+
fullPath: string;
|
|
3094
|
+
} | null;
|
|
3095
|
+
error: Error | null;
|
|
3096
|
+
}>;
|
|
3097
|
+
/**
|
|
3098
|
+
* Download a file from the bucket
|
|
3099
|
+
* @param path - The path/key of the file
|
|
2560
3100
|
*
|
|
2561
3101
|
* @example
|
|
2562
3102
|
* ```typescript
|
|
@@ -2917,7 +3457,7 @@ declare class FluxbaseJobs {
|
|
|
2917
3457
|
*
|
|
2918
3458
|
* @param jobName - Name of the job function to execute
|
|
2919
3459
|
* @param payload - Job input data
|
|
2920
|
-
* @param options - Additional options (priority, namespace, scheduled time)
|
|
3460
|
+
* @param options - Additional options (priority, namespace, scheduled time, onBehalfOf)
|
|
2921
3461
|
* @returns Promise resolving to { data, error } tuple with submitted job details
|
|
2922
3462
|
*
|
|
2923
3463
|
* @example
|
|
@@ -2943,12 +3483,26 @@ declare class FluxbaseJobs {
|
|
|
2943
3483
|
* const { data } = await client.jobs.submit('scheduled-task', payload, {
|
|
2944
3484
|
* scheduled: '2025-01-01T00:00:00Z'
|
|
2945
3485
|
* })
|
|
3486
|
+
*
|
|
3487
|
+
* // Submit on behalf of a user (service_role only)
|
|
3488
|
+
* const { data } = await serviceClient.jobs.submit('user-task', payload, {
|
|
3489
|
+
* onBehalfOf: {
|
|
3490
|
+
* user_id: 'user-uuid',
|
|
3491
|
+
* user_email: 'user@example.com'
|
|
3492
|
+
* }
|
|
3493
|
+
* })
|
|
2946
3494
|
* ```
|
|
2947
3495
|
*/
|
|
2948
3496
|
submit(jobName: string, payload?: any, options?: {
|
|
2949
3497
|
priority?: number;
|
|
2950
3498
|
namespace?: string;
|
|
2951
3499
|
scheduled?: string;
|
|
3500
|
+
/**
|
|
3501
|
+
* Submit job on behalf of another user (service_role only).
|
|
3502
|
+
* The job will be created with the specified user's identity,
|
|
3503
|
+
* allowing them to see the job and its logs via RLS.
|
|
3504
|
+
*/
|
|
3505
|
+
onBehalfOf?: OnBehalfOf;
|
|
2952
3506
|
}): Promise<{
|
|
2953
3507
|
data: Job | null;
|
|
2954
3508
|
error: Error | null;
|
|
@@ -4875,6 +5429,121 @@ declare class FluxbaseManagement {
|
|
|
4875
5429
|
constructor(fetch: FluxbaseFetch);
|
|
4876
5430
|
}
|
|
4877
5431
|
|
|
5432
|
+
/**
|
|
5433
|
+
* esbuild plugin that marks Deno-specific imports as external
|
|
5434
|
+
* Use this when bundling functions/jobs with esbuild to handle npm:, https://, and jsr: imports
|
|
5435
|
+
*
|
|
5436
|
+
* @example
|
|
5437
|
+
* ```typescript
|
|
5438
|
+
* import { denoExternalPlugin } from '@fluxbase/sdk'
|
|
5439
|
+
* import * as esbuild from 'esbuild'
|
|
5440
|
+
*
|
|
5441
|
+
* const result = await esbuild.build({
|
|
5442
|
+
* entryPoints: ['./my-function.ts'],
|
|
5443
|
+
* bundle: true,
|
|
5444
|
+
* plugins: [denoExternalPlugin],
|
|
5445
|
+
* // ... other options
|
|
5446
|
+
* })
|
|
5447
|
+
* ```
|
|
5448
|
+
*/
|
|
5449
|
+
declare const denoExternalPlugin: {
|
|
5450
|
+
name: string;
|
|
5451
|
+
setup(build: {
|
|
5452
|
+
onResolve: (opts: {
|
|
5453
|
+
filter: RegExp;
|
|
5454
|
+
}, cb: (args: {
|
|
5455
|
+
path: string;
|
|
5456
|
+
}) => {
|
|
5457
|
+
path: string;
|
|
5458
|
+
external: boolean;
|
|
5459
|
+
}) => void;
|
|
5460
|
+
}): void;
|
|
5461
|
+
};
|
|
5462
|
+
/**
|
|
5463
|
+
* Load import map from a deno.json file
|
|
5464
|
+
*
|
|
5465
|
+
* @param denoJsonPath - Path to deno.json file
|
|
5466
|
+
* @returns Import map object or null if not found
|
|
5467
|
+
*
|
|
5468
|
+
* @example
|
|
5469
|
+
* ```typescript
|
|
5470
|
+
* const importMap = await loadImportMap('./deno.json')
|
|
5471
|
+
* const bundled = await bundleCode({
|
|
5472
|
+
* code: myCode,
|
|
5473
|
+
* importMap,
|
|
5474
|
+
* })
|
|
5475
|
+
* ```
|
|
5476
|
+
*/
|
|
5477
|
+
declare function loadImportMap(denoJsonPath: string): Promise<Record<string, string> | null>;
|
|
5478
|
+
/**
|
|
5479
|
+
* Options for bundling code
|
|
5480
|
+
*/
|
|
5481
|
+
interface BundleOptions {
|
|
5482
|
+
/** Entry point code */
|
|
5483
|
+
code: string;
|
|
5484
|
+
/** External modules to exclude from bundle */
|
|
5485
|
+
external?: string[];
|
|
5486
|
+
/** Source map generation */
|
|
5487
|
+
sourcemap?: boolean;
|
|
5488
|
+
/** Minify output */
|
|
5489
|
+
minify?: boolean;
|
|
5490
|
+
/** Import map from deno.json (maps aliases to npm: or file paths) */
|
|
5491
|
+
importMap?: Record<string, string>;
|
|
5492
|
+
/** Base directory for resolving relative imports (resolveDir in esbuild) */
|
|
5493
|
+
baseDir?: string;
|
|
5494
|
+
/** Additional paths to search for node_modules (useful when importing from parent directories) */
|
|
5495
|
+
nodePaths?: string[];
|
|
5496
|
+
/** Custom define values for esbuild (e.g., { 'process.env.NODE_ENV': '"production"' }) */
|
|
5497
|
+
define?: Record<string, string>;
|
|
5498
|
+
}
|
|
5499
|
+
/**
|
|
5500
|
+
* Result of bundling code
|
|
5501
|
+
*/
|
|
5502
|
+
interface BundleResult {
|
|
5503
|
+
/** Bundled code */
|
|
5504
|
+
code: string;
|
|
5505
|
+
/** Source map (if enabled) */
|
|
5506
|
+
sourceMap?: string;
|
|
5507
|
+
}
|
|
5508
|
+
/**
|
|
5509
|
+
* Bundle code using esbuild (client-side)
|
|
5510
|
+
*
|
|
5511
|
+
* Transforms and bundles TypeScript/JavaScript code into a single file
|
|
5512
|
+
* that can be executed by the Fluxbase Deno runtime.
|
|
5513
|
+
*
|
|
5514
|
+
* Requires esbuild as a peer dependency.
|
|
5515
|
+
*
|
|
5516
|
+
* @param options - Bundle options including source code
|
|
5517
|
+
* @returns Promise resolving to bundled code
|
|
5518
|
+
* @throws Error if esbuild is not available
|
|
5519
|
+
*
|
|
5520
|
+
* @example
|
|
5521
|
+
* ```typescript
|
|
5522
|
+
* import { bundleCode } from '@fluxbase/sdk'
|
|
5523
|
+
*
|
|
5524
|
+
* const bundled = await bundleCode({
|
|
5525
|
+
* code: `
|
|
5526
|
+
* import { helper } from './utils'
|
|
5527
|
+
* export default async function handler(req) {
|
|
5528
|
+
* return helper(req.payload)
|
|
5529
|
+
* }
|
|
5530
|
+
* `,
|
|
5531
|
+
* minify: true,
|
|
5532
|
+
* })
|
|
5533
|
+
*
|
|
5534
|
+
* // Use bundled code in sync
|
|
5535
|
+
* await client.admin.functions.sync({
|
|
5536
|
+
* namespace: 'default',
|
|
5537
|
+
* functions: [{
|
|
5538
|
+
* name: 'my-function',
|
|
5539
|
+
* code: bundled.code,
|
|
5540
|
+
* is_pre_bundled: true,
|
|
5541
|
+
* }]
|
|
5542
|
+
* })
|
|
5543
|
+
* ```
|
|
5544
|
+
*/
|
|
5545
|
+
declare function bundleCode(options: BundleOptions): Promise<BundleResult>;
|
|
5546
|
+
|
|
4878
5547
|
/**
|
|
4879
5548
|
* Admin Functions module for managing edge functions
|
|
4880
5549
|
* Provides administrative operations for function lifecycle management
|
|
@@ -5071,6 +5740,68 @@ declare class FluxbaseAdminFunctions {
|
|
|
5071
5740
|
data: SyncFunctionsResult | null;
|
|
5072
5741
|
error: Error | null;
|
|
5073
5742
|
}>;
|
|
5743
|
+
/**
|
|
5744
|
+
* Sync edge functions with automatic client-side bundling
|
|
5745
|
+
*
|
|
5746
|
+
* This is a convenience method that bundles all function code using esbuild
|
|
5747
|
+
* before sending to the server. Requires esbuild as a peer dependency.
|
|
5748
|
+
*
|
|
5749
|
+
* @param options - Sync options including namespace and functions array
|
|
5750
|
+
* @param bundleOptions - Optional bundling configuration
|
|
5751
|
+
* @returns Promise resolving to { data, error } tuple with sync results
|
|
5752
|
+
*
|
|
5753
|
+
* @example
|
|
5754
|
+
* ```typescript
|
|
5755
|
+
* const { data, error } = await client.admin.functions.syncWithBundling({
|
|
5756
|
+
* namespace: 'default',
|
|
5757
|
+
* functions: [
|
|
5758
|
+
* { name: 'hello', code: helloCode },
|
|
5759
|
+
* { name: 'goodbye', code: goodbyeCode },
|
|
5760
|
+
* ],
|
|
5761
|
+
* options: { delete_missing: true }
|
|
5762
|
+
* })
|
|
5763
|
+
* ```
|
|
5764
|
+
*/
|
|
5765
|
+
syncWithBundling(options: SyncFunctionsOptions, bundleOptions?: Partial<BundleOptions>): Promise<{
|
|
5766
|
+
data: SyncFunctionsResult | null;
|
|
5767
|
+
error: Error | null;
|
|
5768
|
+
}>;
|
|
5769
|
+
/**
|
|
5770
|
+
* Bundle function code using esbuild (client-side)
|
|
5771
|
+
*
|
|
5772
|
+
* Transforms and bundles TypeScript/JavaScript code into a single file
|
|
5773
|
+
* that can be executed by the Fluxbase edge functions runtime.
|
|
5774
|
+
*
|
|
5775
|
+
* Requires esbuild as a peer dependency.
|
|
5776
|
+
*
|
|
5777
|
+
* @param options - Bundle options including source code
|
|
5778
|
+
* @returns Promise resolving to bundled code
|
|
5779
|
+
* @throws Error if esbuild is not available
|
|
5780
|
+
*
|
|
5781
|
+
* @example
|
|
5782
|
+
* ```typescript
|
|
5783
|
+
* const bundled = await FluxbaseAdminFunctions.bundleCode({
|
|
5784
|
+
* code: `
|
|
5785
|
+
* import { helper } from './utils'
|
|
5786
|
+
* export default async function handler(req) {
|
|
5787
|
+
* return helper(req.body)
|
|
5788
|
+
* }
|
|
5789
|
+
* `,
|
|
5790
|
+
* minify: true,
|
|
5791
|
+
* })
|
|
5792
|
+
*
|
|
5793
|
+
* // Use bundled code in sync
|
|
5794
|
+
* await client.admin.functions.sync({
|
|
5795
|
+
* namespace: 'default',
|
|
5796
|
+
* functions: [{
|
|
5797
|
+
* name: 'my-function',
|
|
5798
|
+
* code: bundled.code,
|
|
5799
|
+
* is_pre_bundled: true,
|
|
5800
|
+
* }]
|
|
5801
|
+
* })
|
|
5802
|
+
* ```
|
|
5803
|
+
*/
|
|
5804
|
+
static bundleCode(options: BundleOptions): Promise<BundleResult>;
|
|
5074
5805
|
}
|
|
5075
5806
|
|
|
5076
5807
|
/**
|
|
@@ -5359,36 +6090,6 @@ declare class FluxbaseAdminMigrations {
|
|
|
5359
6090
|
* Provides administrative operations for job lifecycle management
|
|
5360
6091
|
*/
|
|
5361
6092
|
|
|
5362
|
-
/**
|
|
5363
|
-
* Options for bundling job code
|
|
5364
|
-
*/
|
|
5365
|
-
interface BundleOptions {
|
|
5366
|
-
/** Entry point code */
|
|
5367
|
-
code: string;
|
|
5368
|
-
/** External modules to exclude from bundle */
|
|
5369
|
-
external?: string[];
|
|
5370
|
-
/** Source map generation */
|
|
5371
|
-
sourcemap?: boolean;
|
|
5372
|
-
/** Minify output */
|
|
5373
|
-
minify?: boolean;
|
|
5374
|
-
/** Import map from deno.json (maps aliases to npm: or file paths) */
|
|
5375
|
-
importMap?: Record<string, string>;
|
|
5376
|
-
/** Base directory for resolving relative imports (resolveDir in esbuild) */
|
|
5377
|
-
baseDir?: string;
|
|
5378
|
-
/** Additional paths to search for node_modules (useful when importing from parent directories) */
|
|
5379
|
-
nodePaths?: string[];
|
|
5380
|
-
/** Custom define values for esbuild (e.g., { 'process.env.NODE_ENV': '"production"' }) */
|
|
5381
|
-
define?: Record<string, string>;
|
|
5382
|
-
}
|
|
5383
|
-
/**
|
|
5384
|
-
* Result of bundling job code
|
|
5385
|
-
*/
|
|
5386
|
-
interface BundleResult {
|
|
5387
|
-
/** Bundled code */
|
|
5388
|
-
code: string;
|
|
5389
|
-
/** Source map (if enabled) */
|
|
5390
|
-
sourceMap?: string;
|
|
5391
|
-
}
|
|
5392
6093
|
/**
|
|
5393
6094
|
* Admin Jobs manager for managing background job functions
|
|
5394
6095
|
* Provides create, update, delete, sync, and monitoring operations
|
|
@@ -5745,90 +6446,573 @@ declare class FluxbaseAdminJobs {
|
|
|
5745
6446
|
}
|
|
5746
6447
|
|
|
5747
6448
|
/**
|
|
5748
|
-
* Admin
|
|
6449
|
+
* Admin AI module for managing AI chatbots and providers
|
|
6450
|
+
* Provides administrative operations for chatbot lifecycle management
|
|
5749
6451
|
*/
|
|
5750
|
-
|
|
6452
|
+
|
|
6453
|
+
/**
|
|
6454
|
+
* Admin AI manager for managing AI chatbots and providers
|
|
6455
|
+
* Provides create, update, delete, sync, and monitoring operations
|
|
6456
|
+
*
|
|
6457
|
+
* @category Admin
|
|
6458
|
+
*/
|
|
6459
|
+
declare class FluxbaseAdminAI {
|
|
5751
6460
|
private fetch;
|
|
5752
|
-
private adminToken;
|
|
5753
|
-
/**
|
|
5754
|
-
* Settings manager for system and application settings
|
|
5755
|
-
*/
|
|
5756
|
-
settings: FluxbaseSettings;
|
|
5757
|
-
/**
|
|
5758
|
-
* DDL manager for database schema and table operations
|
|
5759
|
-
*/
|
|
5760
|
-
ddl: DDLManager;
|
|
5761
|
-
/**
|
|
5762
|
-
* OAuth configuration manager for provider and auth settings
|
|
5763
|
-
*/
|
|
5764
|
-
oauth: FluxbaseOAuth;
|
|
5765
|
-
/**
|
|
5766
|
-
* Impersonation manager for user impersonation and audit trail
|
|
5767
|
-
*/
|
|
5768
|
-
impersonation: ImpersonationManager;
|
|
5769
|
-
/**
|
|
5770
|
-
* Management namespace for API keys, webhooks, and invitations
|
|
5771
|
-
*/
|
|
5772
|
-
management: FluxbaseManagement;
|
|
5773
|
-
/**
|
|
5774
|
-
* Email template manager for customizing authentication and notification emails
|
|
5775
|
-
*/
|
|
5776
|
-
emailTemplates: EmailTemplateManager;
|
|
5777
|
-
/**
|
|
5778
|
-
* Functions manager for edge function management (create, update, delete, sync)
|
|
5779
|
-
*/
|
|
5780
|
-
functions: FluxbaseAdminFunctions;
|
|
5781
|
-
/**
|
|
5782
|
-
* Jobs manager for background job management (create, update, delete, sync, monitoring)
|
|
5783
|
-
*/
|
|
5784
|
-
jobs: FluxbaseAdminJobs;
|
|
5785
|
-
/**
|
|
5786
|
-
* Migrations manager for database migration operations (create, apply, rollback, sync)
|
|
5787
|
-
*/
|
|
5788
|
-
migrations: FluxbaseAdminMigrations;
|
|
5789
6461
|
constructor(fetch: FluxbaseFetch);
|
|
5790
6462
|
/**
|
|
5791
|
-
*
|
|
5792
|
-
*/
|
|
5793
|
-
setToken(token: string): void;
|
|
5794
|
-
/**
|
|
5795
|
-
* Get current admin token
|
|
5796
|
-
*/
|
|
5797
|
-
getToken(): string | null;
|
|
5798
|
-
/**
|
|
5799
|
-
* Clear admin token
|
|
5800
|
-
*/
|
|
5801
|
-
clearToken(): void;
|
|
5802
|
-
/**
|
|
5803
|
-
* Check if initial admin setup is needed
|
|
6463
|
+
* List all chatbots (admin view)
|
|
5804
6464
|
*
|
|
5805
|
-
* @
|
|
6465
|
+
* @param namespace - Optional namespace filter
|
|
6466
|
+
* @returns Promise resolving to { data, error } tuple with array of chatbot summaries
|
|
5806
6467
|
*
|
|
5807
6468
|
* @example
|
|
5808
6469
|
* ```typescript
|
|
5809
|
-
* const
|
|
5810
|
-
* if (
|
|
5811
|
-
* console.log('
|
|
6470
|
+
* const { data, error } = await client.admin.ai.listChatbots()
|
|
6471
|
+
* if (data) {
|
|
6472
|
+
* console.log('Chatbots:', data.map(c => c.name))
|
|
5812
6473
|
* }
|
|
5813
6474
|
* ```
|
|
5814
6475
|
*/
|
|
5815
|
-
|
|
6476
|
+
listChatbots(namespace?: string): Promise<{
|
|
6477
|
+
data: AIChatbotSummary[] | null;
|
|
6478
|
+
error: Error | null;
|
|
6479
|
+
}>;
|
|
5816
6480
|
/**
|
|
5817
|
-
*
|
|
5818
|
-
*
|
|
5819
|
-
* Creates the first admin user and completes initial setup.
|
|
5820
|
-
* This endpoint can only be called once.
|
|
6481
|
+
* Get details of a specific chatbot
|
|
5821
6482
|
*
|
|
5822
|
-
* @param
|
|
5823
|
-
* @returns
|
|
6483
|
+
* @param id - Chatbot ID
|
|
6484
|
+
* @returns Promise resolving to { data, error } tuple with chatbot details
|
|
5824
6485
|
*
|
|
5825
6486
|
* @example
|
|
5826
6487
|
* ```typescript
|
|
5827
|
-
* const
|
|
5828
|
-
*
|
|
5829
|
-
*
|
|
5830
|
-
*
|
|
5831
|
-
*
|
|
6488
|
+
* const { data, error } = await client.admin.ai.getChatbot('uuid')
|
|
6489
|
+
* if (data) {
|
|
6490
|
+
* console.log('Chatbot:', data.name)
|
|
6491
|
+
* }
|
|
6492
|
+
* ```
|
|
6493
|
+
*/
|
|
6494
|
+
getChatbot(id: string): Promise<{
|
|
6495
|
+
data: AIChatbot | null;
|
|
6496
|
+
error: Error | null;
|
|
6497
|
+
}>;
|
|
6498
|
+
/**
|
|
6499
|
+
* Enable or disable a chatbot
|
|
6500
|
+
*
|
|
6501
|
+
* @param id - Chatbot ID
|
|
6502
|
+
* @param enabled - Whether to enable or disable
|
|
6503
|
+
* @returns Promise resolving to { data, error } tuple with updated chatbot
|
|
6504
|
+
*
|
|
6505
|
+
* @example
|
|
6506
|
+
* ```typescript
|
|
6507
|
+
* const { data, error } = await client.admin.ai.toggleChatbot('uuid', true)
|
|
6508
|
+
* ```
|
|
6509
|
+
*/
|
|
6510
|
+
toggleChatbot(id: string, enabled: boolean): Promise<{
|
|
6511
|
+
data: AIChatbot | null;
|
|
6512
|
+
error: Error | null;
|
|
6513
|
+
}>;
|
|
6514
|
+
/**
|
|
6515
|
+
* Delete a chatbot
|
|
6516
|
+
*
|
|
6517
|
+
* @param id - Chatbot ID
|
|
6518
|
+
* @returns Promise resolving to { data, error } tuple
|
|
6519
|
+
*
|
|
6520
|
+
* @example
|
|
6521
|
+
* ```typescript
|
|
6522
|
+
* const { data, error } = await client.admin.ai.deleteChatbot('uuid')
|
|
6523
|
+
* ```
|
|
6524
|
+
*/
|
|
6525
|
+
deleteChatbot(id: string): Promise<{
|
|
6526
|
+
data: null;
|
|
6527
|
+
error: Error | null;
|
|
6528
|
+
}>;
|
|
6529
|
+
/**
|
|
6530
|
+
* Sync chatbots from filesystem or API payload
|
|
6531
|
+
*
|
|
6532
|
+
* Can sync from:
|
|
6533
|
+
* 1. Filesystem (if no chatbots provided) - loads from configured chatbots directory
|
|
6534
|
+
* 2. API payload (if chatbots array provided) - syncs provided chatbot specifications
|
|
6535
|
+
*
|
|
6536
|
+
* Requires service_role or admin authentication.
|
|
6537
|
+
*
|
|
6538
|
+
* @param options - Sync options including namespace and optional chatbots array
|
|
6539
|
+
* @returns Promise resolving to { data, error } tuple with sync results
|
|
6540
|
+
*
|
|
6541
|
+
* @example
|
|
6542
|
+
* ```typescript
|
|
6543
|
+
* // Sync from filesystem
|
|
6544
|
+
* const { data, error } = await client.admin.ai.sync()
|
|
6545
|
+
*
|
|
6546
|
+
* // Sync with provided chatbot code
|
|
6547
|
+
* const { data, error } = await client.admin.ai.sync({
|
|
6548
|
+
* namespace: 'default',
|
|
6549
|
+
* chatbots: [{
|
|
6550
|
+
* name: 'sql-assistant',
|
|
6551
|
+
* code: myChatbotCode,
|
|
6552
|
+
* }],
|
|
6553
|
+
* options: {
|
|
6554
|
+
* delete_missing: false, // Don't remove chatbots not in this sync
|
|
6555
|
+
* dry_run: false, // Preview changes without applying
|
|
6556
|
+
* }
|
|
6557
|
+
* })
|
|
6558
|
+
*
|
|
6559
|
+
* if (data) {
|
|
6560
|
+
* console.log(`Synced: ${data.summary.created} created, ${data.summary.updated} updated`)
|
|
6561
|
+
* }
|
|
6562
|
+
* ```
|
|
6563
|
+
*/
|
|
6564
|
+
sync(options?: SyncChatbotsOptions): Promise<{
|
|
6565
|
+
data: SyncChatbotsResult | null;
|
|
6566
|
+
error: Error | null;
|
|
6567
|
+
}>;
|
|
6568
|
+
/**
|
|
6569
|
+
* List all AI providers
|
|
6570
|
+
*
|
|
6571
|
+
* @returns Promise resolving to { data, error } tuple with array of providers
|
|
6572
|
+
*
|
|
6573
|
+
* @example
|
|
6574
|
+
* ```typescript
|
|
6575
|
+
* const { data, error } = await client.admin.ai.listProviders()
|
|
6576
|
+
* if (data) {
|
|
6577
|
+
* console.log('Providers:', data.map(p => p.name))
|
|
6578
|
+
* }
|
|
6579
|
+
* ```
|
|
6580
|
+
*/
|
|
6581
|
+
listProviders(): Promise<{
|
|
6582
|
+
data: AIProvider[] | null;
|
|
6583
|
+
error: Error | null;
|
|
6584
|
+
}>;
|
|
6585
|
+
/**
|
|
6586
|
+
* Get details of a specific provider
|
|
6587
|
+
*
|
|
6588
|
+
* @param id - Provider ID
|
|
6589
|
+
* @returns Promise resolving to { data, error } tuple with provider details
|
|
6590
|
+
*
|
|
6591
|
+
* @example
|
|
6592
|
+
* ```typescript
|
|
6593
|
+
* const { data, error } = await client.admin.ai.getProvider('uuid')
|
|
6594
|
+
* if (data) {
|
|
6595
|
+
* console.log('Provider:', data.display_name)
|
|
6596
|
+
* }
|
|
6597
|
+
* ```
|
|
6598
|
+
*/
|
|
6599
|
+
getProvider(id: string): Promise<{
|
|
6600
|
+
data: AIProvider | null;
|
|
6601
|
+
error: Error | null;
|
|
6602
|
+
}>;
|
|
6603
|
+
/**
|
|
6604
|
+
* Create a new AI provider
|
|
6605
|
+
*
|
|
6606
|
+
* @param request - Provider configuration
|
|
6607
|
+
* @returns Promise resolving to { data, error } tuple with created provider
|
|
6608
|
+
*
|
|
6609
|
+
* @example
|
|
6610
|
+
* ```typescript
|
|
6611
|
+
* const { data, error } = await client.admin.ai.createProvider({
|
|
6612
|
+
* name: 'openai-main',
|
|
6613
|
+
* display_name: 'OpenAI (Main)',
|
|
6614
|
+
* provider_type: 'openai',
|
|
6615
|
+
* is_default: true,
|
|
6616
|
+
* config: {
|
|
6617
|
+
* api_key: 'sk-...',
|
|
6618
|
+
* model: 'gpt-4-turbo',
|
|
6619
|
+
* }
|
|
6620
|
+
* })
|
|
6621
|
+
* ```
|
|
6622
|
+
*/
|
|
6623
|
+
createProvider(request: CreateAIProviderRequest): Promise<{
|
|
6624
|
+
data: AIProvider | null;
|
|
6625
|
+
error: Error | null;
|
|
6626
|
+
}>;
|
|
6627
|
+
/**
|
|
6628
|
+
* Update an existing AI provider
|
|
6629
|
+
*
|
|
6630
|
+
* @param id - Provider ID
|
|
6631
|
+
* @param updates - Fields to update
|
|
6632
|
+
* @returns Promise resolving to { data, error } tuple with updated provider
|
|
6633
|
+
*
|
|
6634
|
+
* @example
|
|
6635
|
+
* ```typescript
|
|
6636
|
+
* const { data, error } = await client.admin.ai.updateProvider('uuid', {
|
|
6637
|
+
* display_name: 'Updated Name',
|
|
6638
|
+
* config: {
|
|
6639
|
+
* api_key: 'new-key',
|
|
6640
|
+
* model: 'gpt-4-turbo',
|
|
6641
|
+
* },
|
|
6642
|
+
* enabled: true,
|
|
6643
|
+
* })
|
|
6644
|
+
* ```
|
|
6645
|
+
*/
|
|
6646
|
+
updateProvider(id: string, updates: UpdateAIProviderRequest): Promise<{
|
|
6647
|
+
data: AIProvider | null;
|
|
6648
|
+
error: Error | null;
|
|
6649
|
+
}>;
|
|
6650
|
+
/**
|
|
6651
|
+
* Set a provider as the default
|
|
6652
|
+
*
|
|
6653
|
+
* @param id - Provider ID
|
|
6654
|
+
* @returns Promise resolving to { data, error } tuple with updated provider
|
|
6655
|
+
*
|
|
6656
|
+
* @example
|
|
6657
|
+
* ```typescript
|
|
6658
|
+
* const { data, error } = await client.admin.ai.setDefaultProvider('uuid')
|
|
6659
|
+
* ```
|
|
6660
|
+
*/
|
|
6661
|
+
setDefaultProvider(id: string): Promise<{
|
|
6662
|
+
data: AIProvider | null;
|
|
6663
|
+
error: Error | null;
|
|
6664
|
+
}>;
|
|
6665
|
+
/**
|
|
6666
|
+
* Delete a provider
|
|
6667
|
+
*
|
|
6668
|
+
* @param id - Provider ID
|
|
6669
|
+
* @returns Promise resolving to { data, error } tuple
|
|
6670
|
+
*
|
|
6671
|
+
* @example
|
|
6672
|
+
* ```typescript
|
|
6673
|
+
* const { data, error } = await client.admin.ai.deleteProvider('uuid')
|
|
6674
|
+
* ```
|
|
6675
|
+
*/
|
|
6676
|
+
deleteProvider(id: string): Promise<{
|
|
6677
|
+
data: null;
|
|
6678
|
+
error: Error | null;
|
|
6679
|
+
}>;
|
|
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
|
+
/**
|
|
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.
|
|
6704
|
+
*
|
|
6705
|
+
* @param options - Sync options including namespace and optional procedures array
|
|
6706
|
+
* @returns Promise resolving to { data, error } tuple with sync results
|
|
6707
|
+
*
|
|
6708
|
+
* @example
|
|
6709
|
+
* ```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
|
+
*
|
|
6726
|
+
* if (data) {
|
|
6727
|
+
* console.log(`Synced: ${data.summary.created} created, ${data.summary.updated} updated`)
|
|
6728
|
+
* }
|
|
6729
|
+
* ```
|
|
6730
|
+
*/
|
|
6731
|
+
sync(options?: SyncRPCOptions): Promise<{
|
|
6732
|
+
data: SyncRPCResult | null;
|
|
6733
|
+
error: Error | null;
|
|
6734
|
+
}>;
|
|
6735
|
+
/**
|
|
6736
|
+
* List all RPC procedures (admin view)
|
|
6737
|
+
*
|
|
6738
|
+
* @param namespace - Optional namespace filter
|
|
6739
|
+
* @returns Promise resolving to { data, error } tuple with array of procedure summaries
|
|
6740
|
+
*
|
|
6741
|
+
* @example
|
|
6742
|
+
* ```typescript
|
|
6743
|
+
* const { data, error } = await client.admin.rpc.list()
|
|
6744
|
+
* if (data) {
|
|
6745
|
+
* console.log('Procedures:', data.map(p => p.name))
|
|
6746
|
+
* }
|
|
6747
|
+
* ```
|
|
6748
|
+
*/
|
|
6749
|
+
list(namespace?: string): Promise<{
|
|
6750
|
+
data: RPCProcedureSummary[] | null;
|
|
6751
|
+
error: Error | null;
|
|
6752
|
+
}>;
|
|
6753
|
+
/**
|
|
6754
|
+
* List all namespaces
|
|
6755
|
+
*
|
|
6756
|
+
* @returns Promise resolving to { data, error } tuple with array of namespace names
|
|
6757
|
+
*
|
|
6758
|
+
* @example
|
|
6759
|
+
* ```typescript
|
|
6760
|
+
* const { data, error } = await client.admin.rpc.listNamespaces()
|
|
6761
|
+
* if (data) {
|
|
6762
|
+
* console.log('Namespaces:', data)
|
|
6763
|
+
* }
|
|
6764
|
+
* ```
|
|
6765
|
+
*/
|
|
6766
|
+
listNamespaces(): Promise<{
|
|
6767
|
+
data: string[] | null;
|
|
6768
|
+
error: Error | null;
|
|
6769
|
+
}>;
|
|
6770
|
+
/**
|
|
6771
|
+
* Get details of a specific RPC procedure
|
|
6772
|
+
*
|
|
6773
|
+
* @param namespace - Procedure namespace
|
|
6774
|
+
* @param name - Procedure name
|
|
6775
|
+
* @returns Promise resolving to { data, error } tuple with procedure details
|
|
6776
|
+
*
|
|
6777
|
+
* @example
|
|
6778
|
+
* ```typescript
|
|
6779
|
+
* const { data, error } = await client.admin.rpc.get('default', 'get-user-orders')
|
|
6780
|
+
* if (data) {
|
|
6781
|
+
* console.log('Procedure:', data.name)
|
|
6782
|
+
* console.log('SQL:', data.sql_query)
|
|
6783
|
+
* }
|
|
6784
|
+
* ```
|
|
6785
|
+
*/
|
|
6786
|
+
get(namespace: string, name: string): Promise<{
|
|
6787
|
+
data: RPCProcedure | null;
|
|
6788
|
+
error: Error | null;
|
|
6789
|
+
}>;
|
|
6790
|
+
/**
|
|
6791
|
+
* Update an RPC procedure
|
|
6792
|
+
*
|
|
6793
|
+
* @param namespace - Procedure namespace
|
|
6794
|
+
* @param name - Procedure name
|
|
6795
|
+
* @param updates - Fields to update
|
|
6796
|
+
* @returns Promise resolving to { data, error } tuple with updated procedure
|
|
6797
|
+
*
|
|
6798
|
+
* @example
|
|
6799
|
+
* ```typescript
|
|
6800
|
+
* const { data, error } = await client.admin.rpc.update('default', 'get-user-orders', {
|
|
6801
|
+
* enabled: false,
|
|
6802
|
+
* max_execution_time_seconds: 60,
|
|
6803
|
+
* })
|
|
6804
|
+
* ```
|
|
6805
|
+
*/
|
|
6806
|
+
update(namespace: string, name: string, updates: UpdateRPCProcedureRequest): Promise<{
|
|
6807
|
+
data: RPCProcedure | null;
|
|
6808
|
+
error: Error | null;
|
|
6809
|
+
}>;
|
|
6810
|
+
/**
|
|
6811
|
+
* Enable or disable an RPC procedure
|
|
6812
|
+
*
|
|
6813
|
+
* @param namespace - Procedure namespace
|
|
6814
|
+
* @param name - Procedure name
|
|
6815
|
+
* @param enabled - Whether to enable or disable
|
|
6816
|
+
* @returns Promise resolving to { data, error } tuple with updated procedure
|
|
6817
|
+
*
|
|
6818
|
+
* @example
|
|
6819
|
+
* ```typescript
|
|
6820
|
+
* const { data, error } = await client.admin.rpc.toggle('default', 'get-user-orders', true)
|
|
6821
|
+
* ```
|
|
6822
|
+
*/
|
|
6823
|
+
toggle(namespace: string, name: string, enabled: boolean): Promise<{
|
|
6824
|
+
data: RPCProcedure | null;
|
|
6825
|
+
error: Error | null;
|
|
6826
|
+
}>;
|
|
6827
|
+
/**
|
|
6828
|
+
* Delete an RPC procedure
|
|
6829
|
+
*
|
|
6830
|
+
* @param namespace - Procedure namespace
|
|
6831
|
+
* @param name - Procedure name
|
|
6832
|
+
* @returns Promise resolving to { data, error } tuple
|
|
6833
|
+
*
|
|
6834
|
+
* @example
|
|
6835
|
+
* ```typescript
|
|
6836
|
+
* const { data, error } = await client.admin.rpc.delete('default', 'get-user-orders')
|
|
6837
|
+
* ```
|
|
6838
|
+
*/
|
|
6839
|
+
delete(namespace: string, name: string): Promise<{
|
|
6840
|
+
data: null;
|
|
6841
|
+
error: Error | null;
|
|
6842
|
+
}>;
|
|
6843
|
+
/**
|
|
6844
|
+
* List RPC executions with optional filters
|
|
6845
|
+
*
|
|
6846
|
+
* @param filters - Optional filters for namespace, procedure, status, user
|
|
6847
|
+
* @returns Promise resolving to { data, error } tuple with array of executions
|
|
6848
|
+
*
|
|
6849
|
+
* @example
|
|
6850
|
+
* ```typescript
|
|
6851
|
+
* // List all executions
|
|
6852
|
+
* const { data, error } = await client.admin.rpc.listExecutions()
|
|
6853
|
+
*
|
|
6854
|
+
* // List failed executions for a specific procedure
|
|
6855
|
+
* const { data, error } = await client.admin.rpc.listExecutions({
|
|
6856
|
+
* namespace: 'default',
|
|
6857
|
+
* procedure: 'get-user-orders',
|
|
6858
|
+
* status: 'failed',
|
|
6859
|
+
* })
|
|
6860
|
+
* ```
|
|
6861
|
+
*/
|
|
6862
|
+
listExecutions(filters?: RPCExecutionFilters): Promise<{
|
|
6863
|
+
data: RPCExecution[] | null;
|
|
6864
|
+
error: Error | null;
|
|
6865
|
+
}>;
|
|
6866
|
+
/**
|
|
6867
|
+
* Get details of a specific execution
|
|
6868
|
+
*
|
|
6869
|
+
* @param executionId - Execution ID
|
|
6870
|
+
* @returns Promise resolving to { data, error } tuple with execution details
|
|
6871
|
+
*
|
|
6872
|
+
* @example
|
|
6873
|
+
* ```typescript
|
|
6874
|
+
* const { data, error } = await client.admin.rpc.getExecution('execution-uuid')
|
|
6875
|
+
* if (data) {
|
|
6876
|
+
* console.log('Status:', data.status)
|
|
6877
|
+
* console.log('Duration:', data.duration_ms, 'ms')
|
|
6878
|
+
* }
|
|
6879
|
+
* ```
|
|
6880
|
+
*/
|
|
6881
|
+
getExecution(executionId: string): Promise<{
|
|
6882
|
+
data: RPCExecution | null;
|
|
6883
|
+
error: Error | null;
|
|
6884
|
+
}>;
|
|
6885
|
+
/**
|
|
6886
|
+
* Get execution logs for a specific execution
|
|
6887
|
+
*
|
|
6888
|
+
* @param executionId - Execution ID
|
|
6889
|
+
* @param afterLine - Optional line number to get logs after (for polling)
|
|
6890
|
+
* @returns Promise resolving to { data, error } tuple with execution logs
|
|
6891
|
+
*
|
|
6892
|
+
* @example
|
|
6893
|
+
* ```typescript
|
|
6894
|
+
* const { data, error } = await client.admin.rpc.getExecutionLogs('execution-uuid')
|
|
6895
|
+
* if (data) {
|
|
6896
|
+
* for (const log of data) {
|
|
6897
|
+
* console.log(`[${log.level}] ${log.message}`)
|
|
6898
|
+
* }
|
|
6899
|
+
* }
|
|
6900
|
+
* ```
|
|
6901
|
+
*/
|
|
6902
|
+
getExecutionLogs(executionId: string, afterLine?: number): Promise<{
|
|
6903
|
+
data: RPCExecutionLog[] | null;
|
|
6904
|
+
error: Error | null;
|
|
6905
|
+
}>;
|
|
6906
|
+
/**
|
|
6907
|
+
* Cancel a running execution
|
|
6908
|
+
*
|
|
6909
|
+
* @param executionId - Execution ID
|
|
6910
|
+
* @returns Promise resolving to { data, error } tuple with updated execution
|
|
6911
|
+
*
|
|
6912
|
+
* @example
|
|
6913
|
+
* ```typescript
|
|
6914
|
+
* const { data, error } = await client.admin.rpc.cancelExecution('execution-uuid')
|
|
6915
|
+
* ```
|
|
6916
|
+
*/
|
|
6917
|
+
cancelExecution(executionId: string): Promise<{
|
|
6918
|
+
data: RPCExecution | null;
|
|
6919
|
+
error: Error | null;
|
|
6920
|
+
}>;
|
|
6921
|
+
}
|
|
6922
|
+
|
|
6923
|
+
/**
|
|
6924
|
+
* Admin client for managing Fluxbase instance
|
|
6925
|
+
*/
|
|
6926
|
+
declare class FluxbaseAdmin {
|
|
6927
|
+
private fetch;
|
|
6928
|
+
private adminToken;
|
|
6929
|
+
/**
|
|
6930
|
+
* Settings manager for system and application settings
|
|
6931
|
+
*/
|
|
6932
|
+
settings: FluxbaseSettings;
|
|
6933
|
+
/**
|
|
6934
|
+
* DDL manager for database schema and table operations
|
|
6935
|
+
*/
|
|
6936
|
+
ddl: DDLManager;
|
|
6937
|
+
/**
|
|
6938
|
+
* OAuth configuration manager for provider and auth settings
|
|
6939
|
+
*/
|
|
6940
|
+
oauth: FluxbaseOAuth;
|
|
6941
|
+
/**
|
|
6942
|
+
* Impersonation manager for user impersonation and audit trail
|
|
6943
|
+
*/
|
|
6944
|
+
impersonation: ImpersonationManager;
|
|
6945
|
+
/**
|
|
6946
|
+
* Management namespace for API keys, webhooks, and invitations
|
|
6947
|
+
*/
|
|
6948
|
+
management: FluxbaseManagement;
|
|
6949
|
+
/**
|
|
6950
|
+
* Email template manager for customizing authentication and notification emails
|
|
6951
|
+
*/
|
|
6952
|
+
emailTemplates: EmailTemplateManager;
|
|
6953
|
+
/**
|
|
6954
|
+
* Functions manager for edge function management (create, update, delete, sync)
|
|
6955
|
+
*/
|
|
6956
|
+
functions: FluxbaseAdminFunctions;
|
|
6957
|
+
/**
|
|
6958
|
+
* Jobs manager for background job management (create, update, delete, sync, monitoring)
|
|
6959
|
+
*/
|
|
6960
|
+
jobs: FluxbaseAdminJobs;
|
|
6961
|
+
/**
|
|
6962
|
+
* Migrations manager for database migration operations (create, apply, rollback, sync)
|
|
6963
|
+
*/
|
|
6964
|
+
migrations: FluxbaseAdminMigrations;
|
|
6965
|
+
/**
|
|
6966
|
+
* AI manager for chatbot and provider management (create, update, delete, sync)
|
|
6967
|
+
*/
|
|
6968
|
+
ai: FluxbaseAdminAI;
|
|
6969
|
+
/**
|
|
6970
|
+
* RPC manager for procedure management (create, update, delete, sync, execution monitoring)
|
|
6971
|
+
*/
|
|
6972
|
+
rpc: FluxbaseAdminRPC;
|
|
6973
|
+
constructor(fetch: FluxbaseFetch);
|
|
6974
|
+
/**
|
|
6975
|
+
* Set admin authentication token
|
|
6976
|
+
*/
|
|
6977
|
+
setToken(token: string): void;
|
|
6978
|
+
/**
|
|
6979
|
+
* Get current admin token
|
|
6980
|
+
*/
|
|
6981
|
+
getToken(): string | null;
|
|
6982
|
+
/**
|
|
6983
|
+
* Clear admin token
|
|
6984
|
+
*/
|
|
6985
|
+
clearToken(): void;
|
|
6986
|
+
/**
|
|
6987
|
+
* Check if initial admin setup is needed
|
|
6988
|
+
*
|
|
6989
|
+
* @returns Setup status indicating if initial setup is required
|
|
6990
|
+
*
|
|
6991
|
+
* @example
|
|
6992
|
+
* ```typescript
|
|
6993
|
+
* const status = await admin.getSetupStatus();
|
|
6994
|
+
* if (status.needs_setup) {
|
|
6995
|
+
* console.log('Initial setup required');
|
|
6996
|
+
* }
|
|
6997
|
+
* ```
|
|
6998
|
+
*/
|
|
6999
|
+
getSetupStatus(): Promise<DataResponse<AdminSetupStatusResponse>>;
|
|
7000
|
+
/**
|
|
7001
|
+
* Perform initial admin setup
|
|
7002
|
+
*
|
|
7003
|
+
* Creates the first admin user and completes initial setup.
|
|
7004
|
+
* This endpoint can only be called once.
|
|
7005
|
+
*
|
|
7006
|
+
* @param request - Setup request containing email, password, and name
|
|
7007
|
+
* @returns Authentication response with tokens
|
|
7008
|
+
*
|
|
7009
|
+
* @example
|
|
7010
|
+
* ```typescript
|
|
7011
|
+
* const response = await admin.setup({
|
|
7012
|
+
* email: 'admin@example.com',
|
|
7013
|
+
* password: 'SecurePassword123!',
|
|
7014
|
+
* name: 'Admin User'
|
|
7015
|
+
* });
|
|
5832
7016
|
*
|
|
5833
7017
|
* // Store tokens
|
|
5834
7018
|
* localStorage.setItem('admin_token', response.access_token);
|
|
@@ -6012,6 +7196,280 @@ declare class FluxbaseAdmin {
|
|
|
6012
7196
|
resetUserPassword(userId: string, type?: "app" | "dashboard"): Promise<DataResponse<ResetUserPasswordResponse>>;
|
|
6013
7197
|
}
|
|
6014
7198
|
|
|
7199
|
+
/**
|
|
7200
|
+
* AI Chat module for interacting with AI chatbots
|
|
7201
|
+
* Provides WebSocket-based chat functionality with streaming support
|
|
7202
|
+
*/
|
|
7203
|
+
|
|
7204
|
+
/**
|
|
7205
|
+
* Event types for chat callbacks
|
|
7206
|
+
*/
|
|
7207
|
+
type AIChatEventType = "connected" | "chat_started" | "progress" | "content" | "query_result" | "done" | "error" | "cancelled" | "disconnected";
|
|
7208
|
+
/**
|
|
7209
|
+
* Chat event data
|
|
7210
|
+
*/
|
|
7211
|
+
interface AIChatEvent {
|
|
7212
|
+
type: AIChatEventType;
|
|
7213
|
+
conversationId?: string;
|
|
7214
|
+
chatbot?: string;
|
|
7215
|
+
step?: string;
|
|
7216
|
+
message?: string;
|
|
7217
|
+
delta?: string;
|
|
7218
|
+
query?: string;
|
|
7219
|
+
summary?: string;
|
|
7220
|
+
rowCount?: number;
|
|
7221
|
+
data?: Record<string, any>[];
|
|
7222
|
+
usage?: AIUsageStats;
|
|
7223
|
+
error?: string;
|
|
7224
|
+
code?: string;
|
|
7225
|
+
}
|
|
7226
|
+
/**
|
|
7227
|
+
* Chat connection options
|
|
7228
|
+
*/
|
|
7229
|
+
interface AIChatOptions {
|
|
7230
|
+
/** WebSocket URL (defaults to ws://host/ai/ws) */
|
|
7231
|
+
wsUrl?: string;
|
|
7232
|
+
/** JWT token for authentication */
|
|
7233
|
+
token?: string;
|
|
7234
|
+
/** Callback for all events */
|
|
7235
|
+
onEvent?: (event: AIChatEvent) => void;
|
|
7236
|
+
/** Callback for content chunks (streaming) */
|
|
7237
|
+
onContent?: (delta: string, conversationId: string) => void;
|
|
7238
|
+
/** Callback for progress updates */
|
|
7239
|
+
onProgress?: (step: string, message: string, conversationId: string) => void;
|
|
7240
|
+
/** Callback for query results */
|
|
7241
|
+
onQueryResult?: (query: string, summary: string, rowCount: number, data: Record<string, any>[], conversationId: string) => void;
|
|
7242
|
+
/** Callback when message is complete */
|
|
7243
|
+
onDone?: (usage: AIUsageStats | undefined, conversationId: string) => void;
|
|
7244
|
+
/** Callback for errors */
|
|
7245
|
+
onError?: (error: string, code: string | undefined, conversationId: string | undefined) => void;
|
|
7246
|
+
/** Reconnect attempts (0 = no reconnect) */
|
|
7247
|
+
reconnectAttempts?: number;
|
|
7248
|
+
/** Reconnect delay in ms */
|
|
7249
|
+
reconnectDelay?: number;
|
|
7250
|
+
}
|
|
7251
|
+
/**
|
|
7252
|
+
* AI Chat client for WebSocket-based chat with AI chatbots
|
|
7253
|
+
*
|
|
7254
|
+
* @example
|
|
7255
|
+
* ```typescript
|
|
7256
|
+
* const chat = new FluxbaseAIChat({
|
|
7257
|
+
* wsUrl: 'ws://localhost:8080/ai/ws',
|
|
7258
|
+
* token: 'my-jwt-token',
|
|
7259
|
+
* onContent: (delta, convId) => {
|
|
7260
|
+
* process.stdout.write(delta)
|
|
7261
|
+
* },
|
|
7262
|
+
* onProgress: (step, message) => {
|
|
7263
|
+
* console.log(`[${step}] ${message}`)
|
|
7264
|
+
* },
|
|
7265
|
+
* onQueryResult: (query, summary, rowCount, data) => {
|
|
7266
|
+
* console.log(`Query: ${query}`)
|
|
7267
|
+
* console.log(`Result: ${summary} (${rowCount} rows)`)
|
|
7268
|
+
* },
|
|
7269
|
+
* onDone: (usage) => {
|
|
7270
|
+
* console.log(`\nTokens: ${usage?.total_tokens}`)
|
|
7271
|
+
* },
|
|
7272
|
+
* onError: (error, code) => {
|
|
7273
|
+
* console.error(`Error: ${error} (${code})`)
|
|
7274
|
+
* },
|
|
7275
|
+
* })
|
|
7276
|
+
*
|
|
7277
|
+
* await chat.connect()
|
|
7278
|
+
* const convId = await chat.startChat('sql-assistant')
|
|
7279
|
+
* await chat.sendMessage(convId, 'Show me the top 10 users by order count')
|
|
7280
|
+
* ```
|
|
7281
|
+
*/
|
|
7282
|
+
declare class FluxbaseAIChat {
|
|
7283
|
+
private ws;
|
|
7284
|
+
private options;
|
|
7285
|
+
private reconnectCount;
|
|
7286
|
+
private pendingStartResolve;
|
|
7287
|
+
private pendingStartReject;
|
|
7288
|
+
private accumulatedContent;
|
|
7289
|
+
constructor(options: AIChatOptions);
|
|
7290
|
+
/**
|
|
7291
|
+
* Connect to the AI chat WebSocket
|
|
7292
|
+
*
|
|
7293
|
+
* @returns Promise that resolves when connected
|
|
7294
|
+
*/
|
|
7295
|
+
connect(): Promise<void>;
|
|
7296
|
+
/**
|
|
7297
|
+
* Disconnect from the AI chat WebSocket
|
|
7298
|
+
*/
|
|
7299
|
+
disconnect(): void;
|
|
7300
|
+
/**
|
|
7301
|
+
* Check if connected
|
|
7302
|
+
*/
|
|
7303
|
+
isConnected(): boolean;
|
|
7304
|
+
/**
|
|
7305
|
+
* Start a new chat session with a chatbot
|
|
7306
|
+
*
|
|
7307
|
+
* @param chatbot - Chatbot name
|
|
7308
|
+
* @param namespace - Optional namespace (defaults to 'default')
|
|
7309
|
+
* @param conversationId - Optional conversation ID to resume
|
|
7310
|
+
* @param impersonateUserId - Optional user ID to impersonate (admin only)
|
|
7311
|
+
* @returns Promise resolving to conversation ID
|
|
7312
|
+
*/
|
|
7313
|
+
startChat(chatbot: string, namespace?: string, conversationId?: string, impersonateUserId?: string): Promise<string>;
|
|
7314
|
+
/**
|
|
7315
|
+
* Send a message in a conversation
|
|
7316
|
+
*
|
|
7317
|
+
* @param conversationId - Conversation ID
|
|
7318
|
+
* @param content - Message content
|
|
7319
|
+
*/
|
|
7320
|
+
sendMessage(conversationId: string, content: string): void;
|
|
7321
|
+
/**
|
|
7322
|
+
* Cancel an ongoing message generation
|
|
7323
|
+
*
|
|
7324
|
+
* @param conversationId - Conversation ID
|
|
7325
|
+
*/
|
|
7326
|
+
cancel(conversationId: string): void;
|
|
7327
|
+
/**
|
|
7328
|
+
* Get the full accumulated response content for a conversation
|
|
7329
|
+
*
|
|
7330
|
+
* @param conversationId - Conversation ID
|
|
7331
|
+
* @returns Accumulated content string
|
|
7332
|
+
*/
|
|
7333
|
+
getAccumulatedContent(conversationId: string): string;
|
|
7334
|
+
private buildWsUrl;
|
|
7335
|
+
private handleMessage;
|
|
7336
|
+
private serverMessageToEvent;
|
|
7337
|
+
private emitEvent;
|
|
7338
|
+
private handleClose;
|
|
7339
|
+
}
|
|
7340
|
+
/**
|
|
7341
|
+
* Fluxbase AI client for listing chatbots and managing conversations
|
|
7342
|
+
*
|
|
7343
|
+
* @example
|
|
7344
|
+
* ```typescript
|
|
7345
|
+
* const ai = new FluxbaseAI(fetchClient, 'ws://localhost:8080')
|
|
7346
|
+
*
|
|
7347
|
+
* // List available chatbots
|
|
7348
|
+
* const { data, error } = await ai.listChatbots()
|
|
7349
|
+
*
|
|
7350
|
+
* // Create a chat connection
|
|
7351
|
+
* const chat = ai.createChat({
|
|
7352
|
+
* token: 'my-jwt-token',
|
|
7353
|
+
* onContent: (delta) => process.stdout.write(delta),
|
|
7354
|
+
* })
|
|
7355
|
+
*
|
|
7356
|
+
* await chat.connect()
|
|
7357
|
+
* const convId = await chat.startChat('sql-assistant')
|
|
7358
|
+
* chat.sendMessage(convId, 'Show me recent orders')
|
|
7359
|
+
* ```
|
|
7360
|
+
*/
|
|
7361
|
+
declare class FluxbaseAI {
|
|
7362
|
+
private fetch;
|
|
7363
|
+
private wsBaseUrl;
|
|
7364
|
+
constructor(fetch: {
|
|
7365
|
+
get: <T>(path: string) => Promise<T>;
|
|
7366
|
+
patch: <T>(path: string, body?: unknown) => Promise<T>;
|
|
7367
|
+
delete: (path: string) => Promise<void>;
|
|
7368
|
+
}, wsBaseUrl: string);
|
|
7369
|
+
/**
|
|
7370
|
+
* List available chatbots (public, enabled)
|
|
7371
|
+
*
|
|
7372
|
+
* @returns Promise resolving to { data, error } tuple with array of chatbot summaries
|
|
7373
|
+
*/
|
|
7374
|
+
listChatbots(): Promise<{
|
|
7375
|
+
data: AIChatbotSummary[] | null;
|
|
7376
|
+
error: Error | null;
|
|
7377
|
+
}>;
|
|
7378
|
+
/**
|
|
7379
|
+
* Get details of a specific chatbot
|
|
7380
|
+
*
|
|
7381
|
+
* @param id - Chatbot ID
|
|
7382
|
+
* @returns Promise resolving to { data, error } tuple with chatbot details
|
|
7383
|
+
*/
|
|
7384
|
+
getChatbot(id: string): Promise<{
|
|
7385
|
+
data: AIChatbotSummary | null;
|
|
7386
|
+
error: Error | null;
|
|
7387
|
+
}>;
|
|
7388
|
+
/**
|
|
7389
|
+
* Create a new AI chat connection
|
|
7390
|
+
*
|
|
7391
|
+
* @param options - Chat connection options
|
|
7392
|
+
* @returns FluxbaseAIChat instance
|
|
7393
|
+
*/
|
|
7394
|
+
createChat(options: Omit<AIChatOptions, "wsUrl">): FluxbaseAIChat;
|
|
7395
|
+
/**
|
|
7396
|
+
* List the authenticated user's conversations
|
|
7397
|
+
*
|
|
7398
|
+
* @param options - Optional filters and pagination
|
|
7399
|
+
* @returns Promise resolving to { data, error } tuple with conversations
|
|
7400
|
+
*
|
|
7401
|
+
* @example
|
|
7402
|
+
* ```typescript
|
|
7403
|
+
* // List all conversations
|
|
7404
|
+
* const { data, error } = await ai.listConversations()
|
|
7405
|
+
*
|
|
7406
|
+
* // Filter by chatbot
|
|
7407
|
+
* const { data, error } = await ai.listConversations({ chatbot: 'sql-assistant' })
|
|
7408
|
+
*
|
|
7409
|
+
* // With pagination
|
|
7410
|
+
* const { data, error } = await ai.listConversations({ limit: 20, offset: 0 })
|
|
7411
|
+
* ```
|
|
7412
|
+
*/
|
|
7413
|
+
listConversations(options?: ListConversationsOptions): Promise<{
|
|
7414
|
+
data: ListConversationsResult | null;
|
|
7415
|
+
error: Error | null;
|
|
7416
|
+
}>;
|
|
7417
|
+
/**
|
|
7418
|
+
* Get a single conversation with all messages
|
|
7419
|
+
*
|
|
7420
|
+
* @param id - Conversation ID
|
|
7421
|
+
* @returns Promise resolving to { data, error } tuple with conversation detail
|
|
7422
|
+
*
|
|
7423
|
+
* @example
|
|
7424
|
+
* ```typescript
|
|
7425
|
+
* const { data, error } = await ai.getConversation('conv-uuid-123')
|
|
7426
|
+
* if (data) {
|
|
7427
|
+
* console.log(`Title: ${data.title}`)
|
|
7428
|
+
* console.log(`Messages: ${data.messages.length}`)
|
|
7429
|
+
* }
|
|
7430
|
+
* ```
|
|
7431
|
+
*/
|
|
7432
|
+
getConversation(id: string): Promise<{
|
|
7433
|
+
data: AIUserConversationDetail | null;
|
|
7434
|
+
error: Error | null;
|
|
7435
|
+
}>;
|
|
7436
|
+
/**
|
|
7437
|
+
* Delete a conversation
|
|
7438
|
+
*
|
|
7439
|
+
* @param id - Conversation ID
|
|
7440
|
+
* @returns Promise resolving to { error } (null on success)
|
|
7441
|
+
*
|
|
7442
|
+
* @example
|
|
7443
|
+
* ```typescript
|
|
7444
|
+
* const { error } = await ai.deleteConversation('conv-uuid-123')
|
|
7445
|
+
* if (!error) {
|
|
7446
|
+
* console.log('Conversation deleted')
|
|
7447
|
+
* }
|
|
7448
|
+
* ```
|
|
7449
|
+
*/
|
|
7450
|
+
deleteConversation(id: string): Promise<{
|
|
7451
|
+
error: Error | null;
|
|
7452
|
+
}>;
|
|
7453
|
+
/**
|
|
7454
|
+
* Update a conversation (currently supports title update only)
|
|
7455
|
+
*
|
|
7456
|
+
* @param id - Conversation ID
|
|
7457
|
+
* @param updates - Fields to update
|
|
7458
|
+
* @returns Promise resolving to { data, error } tuple with updated conversation
|
|
7459
|
+
*
|
|
7460
|
+
* @example
|
|
7461
|
+
* ```typescript
|
|
7462
|
+
* const { data, error } = await ai.updateConversation('conv-uuid-123', {
|
|
7463
|
+
* title: 'My custom conversation title'
|
|
7464
|
+
* })
|
|
7465
|
+
* ```
|
|
7466
|
+
*/
|
|
7467
|
+
updateConversation(id: string, updates: UpdateConversationOptions): Promise<{
|
|
7468
|
+
data: AIUserConversationDetail | null;
|
|
7469
|
+
error: Error | null;
|
|
7470
|
+
}>;
|
|
7471
|
+
}
|
|
7472
|
+
|
|
6015
7473
|
/**
|
|
6016
7474
|
* PostgreSQL query builder for Fluxbase SDK
|
|
6017
7475
|
* Inspired by Supabase's PostgREST client
|
|
@@ -6025,6 +7483,7 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
|
|
|
6025
7483
|
private filters;
|
|
6026
7484
|
private orFilters;
|
|
6027
7485
|
private andFilters;
|
|
7486
|
+
private betweenFilters;
|
|
6028
7487
|
private orderBys;
|
|
6029
7488
|
private limitValue?;
|
|
6030
7489
|
private offsetValue?;
|
|
@@ -6145,6 +7604,8 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
|
|
|
6145
7604
|
* Generic filter method using PostgREST syntax (Supabase-compatible)
|
|
6146
7605
|
* @example filter('name', 'in', '("Han","Yoda")')
|
|
6147
7606
|
* @example filter('age', 'gte', '18')
|
|
7607
|
+
* @example filter('recorded_at', 'between', ['2024-01-01', '2024-01-10'])
|
|
7608
|
+
* @example filter('recorded_at', 'not.between', ['2024-01-01', '2024-01-10'])
|
|
6148
7609
|
*/
|
|
6149
7610
|
filter(column: string, operator: FilterOperator, value: unknown): this;
|
|
6150
7611
|
/**
|
|
@@ -6158,6 +7619,29 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
|
|
|
6158
7619
|
* @example overlaps('tags', '["news","sports"]')
|
|
6159
7620
|
*/
|
|
6160
7621
|
overlaps(column: string, value: unknown): this;
|
|
7622
|
+
/**
|
|
7623
|
+
* Filter column value within an inclusive range (BETWEEN)
|
|
7624
|
+
* Generates: AND (column >= min AND column <= max)
|
|
7625
|
+
*
|
|
7626
|
+
* @param column - Column name to filter
|
|
7627
|
+
* @param min - Minimum value (inclusive)
|
|
7628
|
+
* @param max - Maximum value (inclusive)
|
|
7629
|
+
* @example between('recorded_at', '2024-01-01', '2024-01-10')
|
|
7630
|
+
* @example between('price', 10, 100)
|
|
7631
|
+
*/
|
|
7632
|
+
between(column: string, min: unknown, max: unknown): this;
|
|
7633
|
+
/**
|
|
7634
|
+
* Filter column value outside an inclusive range (NOT BETWEEN)
|
|
7635
|
+
* Generates: OR (column < min OR column > max)
|
|
7636
|
+
* Multiple notBetween calls on the same column AND together
|
|
7637
|
+
*
|
|
7638
|
+
* @param column - Column name to filter
|
|
7639
|
+
* @param min - Minimum value of excluded range
|
|
7640
|
+
* @param max - Maximum value of excluded range
|
|
7641
|
+
* @example notBetween('recorded_at', '2024-01-01', '2024-01-10')
|
|
7642
|
+
* @example notBetween('price', 0, 10) // Excludes items priced 0-10
|
|
7643
|
+
*/
|
|
7644
|
+
notBetween(column: string, min: unknown, max: unknown): this;
|
|
6161
7645
|
/**
|
|
6162
7646
|
* Check if geometries intersect (PostGIS ST_Intersects)
|
|
6163
7647
|
* @param column - Column containing geometry/geography data
|
|
@@ -6490,6 +7974,11 @@ declare class QueryBuilder<T = unknown> implements PromiseLike<PostgrestResponse
|
|
|
6490
7974
|
* Format a value for the query string
|
|
6491
7975
|
*/
|
|
6492
7976
|
private formatValue;
|
|
7977
|
+
/**
|
|
7978
|
+
* Validate between filter value - must be array of exactly 2 elements
|
|
7979
|
+
* @throws Error if value is invalid
|
|
7980
|
+
*/
|
|
7981
|
+
private validateBetweenValue;
|
|
6493
7982
|
/**
|
|
6494
7983
|
* Parse the Content-Range header to extract the total count
|
|
6495
7984
|
* Header format: "0-999/50000" or "* /50000" (when no rows returned)
|
|
@@ -6549,6 +8038,8 @@ declare class FluxbaseClient<Database = any, _SchemaName extends string & keyof
|
|
|
6549
8038
|
management: FluxbaseManagement;
|
|
6550
8039
|
/** Settings module for reading public application settings (respects RLS policies) */
|
|
6551
8040
|
settings: SettingsClient;
|
|
8041
|
+
/** AI module for chatbots and conversation history */
|
|
8042
|
+
ai: FluxbaseAI;
|
|
6552
8043
|
/**
|
|
6553
8044
|
* Create a new Fluxbase client instance
|
|
6554
8045
|
*
|
|
@@ -6620,31 +8111,6 @@ declare class FluxbaseClient<Database = any, _SchemaName extends string & keyof
|
|
|
6620
8111
|
* @category Database
|
|
6621
8112
|
*/
|
|
6622
8113
|
schema(schemaName: string): SchemaQueryBuilder;
|
|
6623
|
-
/**
|
|
6624
|
-
* Call a PostgreSQL function (Remote Procedure Call)
|
|
6625
|
-
*
|
|
6626
|
-
* @param functionName - The name of the PostgreSQL function to call
|
|
6627
|
-
* @param params - Optional parameters to pass to the function
|
|
6628
|
-
* @returns Promise containing the function result or error
|
|
6629
|
-
*
|
|
6630
|
-
* @example
|
|
6631
|
-
* ```typescript
|
|
6632
|
-
* // Call a function without parameters
|
|
6633
|
-
* const { data, error } = await client.rpc('get_total_users')
|
|
6634
|
-
*
|
|
6635
|
-
* // Call a function with parameters
|
|
6636
|
-
* const { data, error } = await client.rpc('calculate_discount', {
|
|
6637
|
-
* product_id: 123,
|
|
6638
|
-
* coupon_code: 'SAVE20'
|
|
6639
|
-
* })
|
|
6640
|
-
* ```
|
|
6641
|
-
*
|
|
6642
|
-
* @category Database
|
|
6643
|
-
*/
|
|
6644
|
-
rpc<T = any>(functionName: string, params?: Record<string, unknown>): Promise<{
|
|
6645
|
-
data: T | null;
|
|
6646
|
-
error: Error | null;
|
|
6647
|
-
}>;
|
|
6648
8114
|
/**
|
|
6649
8115
|
* Sync auth state with realtime connections
|
|
6650
8116
|
* @internal
|
|
@@ -6773,4 +8239,156 @@ declare class FluxbaseClient<Database = any, _SchemaName extends string & keyof
|
|
|
6773
8239
|
*/
|
|
6774
8240
|
declare function createClient<Database = any, SchemaName extends string & keyof Database = any>(fluxbaseUrl?: string, fluxbaseKey?: string, options?: FluxbaseClientOptions): FluxbaseClient<Database, SchemaName>;
|
|
6775
8241
|
|
|
6776
|
-
|
|
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 };
|