@reifydb/react 0.4.9 → 0.4.11
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.ts +76 -76
- package/dist/index.js +403 -403
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Column, ShapeNode, InferShape } from '@reifydb/core';
|
|
2
2
|
export * from '@reifydb/core';
|
|
3
|
-
import { WsClientOptions, WsClient, HttpClient, JsonHttpClient,
|
|
3
|
+
import { WsClientOptions, WsClient, HttpClient, JsonHttpClient, JsonWsClient } from '@reifydb/client';
|
|
4
4
|
export * from '@reifydb/client';
|
|
5
5
|
import React, { ReactNode } from 'react';
|
|
6
6
|
|
|
7
7
|
interface ConnectionState {
|
|
8
|
-
client: WsClient | HttpClient | JsonHttpClient |
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
client: WsClient | HttpClient | JsonHttpClient | JsonWsClient | null;
|
|
9
|
+
is_connected: boolean;
|
|
10
|
+
is_connecting: boolean;
|
|
11
|
+
connection_error: string | null;
|
|
12
12
|
listeners: Set<(state: ConnectionState) => void>;
|
|
13
13
|
}
|
|
14
14
|
interface ConnectionConfig {
|
|
@@ -22,33 +22,33 @@ declare const DEFAULT_URL = "ws://127.0.0.1:8090";
|
|
|
22
22
|
declare class Connection {
|
|
23
23
|
private state;
|
|
24
24
|
private config;
|
|
25
|
-
private
|
|
25
|
+
private connect_promise;
|
|
26
26
|
constructor(config?: ConnectionConfig);
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
set_config(config: ConnectionConfig): void;
|
|
28
|
+
get_config(): ConnectionConfig;
|
|
29
29
|
connect(url?: string, options?: Omit<WsClientOptions, 'url'>): Promise<void>;
|
|
30
30
|
disconnect(): Promise<void>;
|
|
31
31
|
reconnect(url?: string, options?: Omit<WsClientOptions, 'url'>): Promise<void>;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
get_client(): WsClient | HttpClient | JsonHttpClient | JsonWsClient | null;
|
|
33
|
+
is_connected(): boolean;
|
|
34
|
+
is_connecting(): boolean;
|
|
35
|
+
get_connection_error(): string | null;
|
|
36
|
+
get_state(): Omit<ConnectionState, 'listeners'>;
|
|
37
37
|
subscribe(listener: (state: ConnectionState) => void): () => void;
|
|
38
|
-
private
|
|
38
|
+
private update_state;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Get the singleton connection instance.
|
|
43
|
-
* If a config is provided, the connection's config will be updated via
|
|
43
|
+
* If a config is provided, the connection's config will be updated via set_config().
|
|
44
44
|
* @param config - Optional connection configuration
|
|
45
45
|
* @returns The singleton Connection instance
|
|
46
46
|
*/
|
|
47
|
-
declare function
|
|
47
|
+
declare function get_connection(config?: ConnectionConfig): Connection;
|
|
48
48
|
/**
|
|
49
49
|
* Clear the singleton connection
|
|
50
50
|
*/
|
|
51
|
-
declare function
|
|
51
|
+
declare function clear_connection(): Promise<void>;
|
|
52
52
|
|
|
53
53
|
declare const ConnectionContext: React.Context<Connection | null>;
|
|
54
54
|
interface ConnectionProviderProps {
|
|
@@ -57,50 +57,50 @@ interface ConnectionProviderProps {
|
|
|
57
57
|
}
|
|
58
58
|
declare function ConnectionProvider({ config, children }: ConnectionProviderProps): React.JSX.Element;
|
|
59
59
|
|
|
60
|
-
declare function useConnection(
|
|
60
|
+
declare function useConnection(override_config?: ConnectionConfig): {
|
|
61
61
|
connect: () => Promise<void>;
|
|
62
62
|
disconnect: () => Promise<void>;
|
|
63
63
|
reconnect: () => Promise<void>;
|
|
64
|
-
client: WsClient | HttpClient | JsonHttpClient |
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
client: WsClient | HttpClient | JsonHttpClient | JsonWsClient | null;
|
|
65
|
+
is_connected: boolean;
|
|
66
|
+
is_connecting: boolean;
|
|
67
|
+
connection_error: string | null;
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
interface QueryResult<T = any> {
|
|
71
71
|
columns: Column[];
|
|
72
72
|
rows: T[];
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
execution_time_ms: number;
|
|
74
|
+
rows_affected?: number;
|
|
75
75
|
}
|
|
76
76
|
interface QueryState<T = any> {
|
|
77
|
-
|
|
77
|
+
is_executing: boolean;
|
|
78
78
|
results: QueryResult<T>[] | undefined;
|
|
79
79
|
error: string | undefined;
|
|
80
|
-
|
|
80
|
+
execution_time: number | undefined;
|
|
81
81
|
}
|
|
82
82
|
interface QueryExecutorOptions {
|
|
83
|
-
|
|
83
|
+
connection_config?: ConnectionConfig;
|
|
84
84
|
}
|
|
85
85
|
declare function useQueryExecutor<T = any>(options?: QueryExecutorOptions): {
|
|
86
|
-
|
|
86
|
+
is_executing: boolean;
|
|
87
87
|
results: QueryResult<T>[] | undefined;
|
|
88
88
|
error: string | undefined;
|
|
89
|
-
|
|
90
|
-
query: (
|
|
91
|
-
|
|
89
|
+
execution_time: number | undefined;
|
|
90
|
+
query: (rql: string, params?: any, shapes?: readonly ShapeNode[]) => Promise<void>;
|
|
91
|
+
cancel_query: () => void;
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
interface QueryOptions extends QueryExecutorOptions {
|
|
95
|
-
|
|
95
|
+
connection_config?: ConnectionConfig;
|
|
96
96
|
}
|
|
97
97
|
declare function useQueryOne<S extends ShapeNode = any>(rql: string, params?: any, shape?: S, options?: QueryOptions): {
|
|
98
|
-
|
|
98
|
+
is_executing: boolean;
|
|
99
99
|
result: QueryResult<S extends ShapeNode ? InferShape<S> : any> | undefined;
|
|
100
100
|
error: string | undefined;
|
|
101
101
|
};
|
|
102
|
-
declare function useQueryMany<S extends readonly ShapeNode[] = readonly ShapeNode[]>(
|
|
103
|
-
|
|
102
|
+
declare function useQueryMany<S extends readonly ShapeNode[] = readonly ShapeNode[]>(rql: string, params?: any, shapes?: S, options?: QueryOptions): {
|
|
103
|
+
is_executing: boolean;
|
|
104
104
|
results: QueryResult<S extends readonly ShapeNode[] ? InferShape<S[number]> : any>[] | undefined;
|
|
105
105
|
error: string | undefined;
|
|
106
106
|
};
|
|
@@ -108,37 +108,37 @@ declare function useQueryMany<S extends readonly ShapeNode[] = readonly ShapeNod
|
|
|
108
108
|
interface CommandResult<T = any> {
|
|
109
109
|
columns: Column[];
|
|
110
110
|
rows: T[];
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
execution_time_ms: number;
|
|
112
|
+
rows_affected?: number;
|
|
113
113
|
}
|
|
114
114
|
interface CommandState<T = any> {
|
|
115
|
-
|
|
115
|
+
is_executing: boolean;
|
|
116
116
|
results: CommandResult<T>[] | undefined;
|
|
117
117
|
error: string | undefined;
|
|
118
|
-
|
|
118
|
+
execution_time: number | undefined;
|
|
119
119
|
}
|
|
120
120
|
interface CommandExecutorOptions {
|
|
121
|
-
|
|
121
|
+
connection_config?: ConnectionConfig;
|
|
122
122
|
}
|
|
123
123
|
declare function useCommandExecutor<T = any>(options?: CommandExecutorOptions): {
|
|
124
|
-
|
|
124
|
+
is_executing: boolean;
|
|
125
125
|
results: CommandResult<T>[] | undefined;
|
|
126
126
|
error: string | undefined;
|
|
127
|
-
|
|
128
|
-
command: (
|
|
129
|
-
|
|
127
|
+
execution_time: number | undefined;
|
|
128
|
+
command: (rql: string, params?: any, shapes?: readonly ShapeNode[]) => Promise<void>;
|
|
129
|
+
cancel_command: () => void;
|
|
130
130
|
};
|
|
131
131
|
|
|
132
132
|
interface CommandOptions extends CommandExecutorOptions {
|
|
133
|
-
|
|
133
|
+
connection_config?: ConnectionConfig;
|
|
134
134
|
}
|
|
135
|
-
declare function useCommandOne<S extends ShapeNode = any>(
|
|
136
|
-
|
|
135
|
+
declare function useCommandOne<S extends ShapeNode = any>(rql: string, params?: any, shape?: S, options?: CommandOptions): {
|
|
136
|
+
is_executing: boolean;
|
|
137
137
|
result: CommandResult<S extends ShapeNode ? InferShape<S> : any> | undefined;
|
|
138
138
|
error: string | undefined;
|
|
139
139
|
};
|
|
140
|
-
declare function useCommandMany<S extends readonly ShapeNode[] = readonly ShapeNode[]>(
|
|
141
|
-
|
|
140
|
+
declare function useCommandMany<S extends readonly ShapeNode[] = readonly ShapeNode[]>(rql: string, params?: any, shapes?: S, options?: CommandOptions): {
|
|
141
|
+
is_executing: boolean;
|
|
142
142
|
results: CommandResult<S extends readonly ShapeNode[] ? InferShape<S[number]> : any>[] | undefined;
|
|
143
143
|
error: string | undefined;
|
|
144
144
|
};
|
|
@@ -146,43 +146,43 @@ declare function useCommandMany<S extends readonly ShapeNode[] = readonly ShapeN
|
|
|
146
146
|
interface AdminResult<T = any> {
|
|
147
147
|
columns: Column[];
|
|
148
148
|
rows: T[];
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
execution_time_ms: number;
|
|
150
|
+
rows_affected?: number;
|
|
151
151
|
}
|
|
152
152
|
interface AdminState<T = any> {
|
|
153
|
-
|
|
153
|
+
is_executing: boolean;
|
|
154
154
|
results: AdminResult<T>[] | undefined;
|
|
155
155
|
error: string | undefined;
|
|
156
|
-
|
|
156
|
+
execution_time: number | undefined;
|
|
157
157
|
}
|
|
158
158
|
interface AdminExecutorOptions {
|
|
159
|
-
|
|
159
|
+
connection_config?: ConnectionConfig;
|
|
160
160
|
}
|
|
161
161
|
declare function useAdminExecutor<T = any>(options?: AdminExecutorOptions): {
|
|
162
|
-
|
|
162
|
+
is_executing: boolean;
|
|
163
163
|
results: AdminResult<T>[] | undefined;
|
|
164
164
|
error: string | undefined;
|
|
165
|
-
|
|
166
|
-
admin: (
|
|
167
|
-
|
|
165
|
+
execution_time: number | undefined;
|
|
166
|
+
admin: (rql: string, params?: any, shapes?: readonly ShapeNode[]) => Promise<void>;
|
|
167
|
+
cancel_admin: () => void;
|
|
168
168
|
};
|
|
169
169
|
|
|
170
170
|
interface AdminOptions extends AdminExecutorOptions {
|
|
171
|
-
|
|
171
|
+
connection_config?: ConnectionConfig;
|
|
172
172
|
}
|
|
173
|
-
declare function useAdminOne<S extends ShapeNode = any>(
|
|
174
|
-
|
|
173
|
+
declare function useAdminOne<S extends ShapeNode = any>(rql: string, params?: any, shape?: S, options?: AdminOptions): {
|
|
174
|
+
is_executing: boolean;
|
|
175
175
|
result: AdminResult<S extends ShapeNode ? InferShape<S> : any> | undefined;
|
|
176
176
|
error: string | undefined;
|
|
177
177
|
};
|
|
178
|
-
declare function useAdminMany<S extends readonly ShapeNode[] = readonly ShapeNode[]>(
|
|
179
|
-
|
|
178
|
+
declare function useAdminMany<S extends readonly ShapeNode[] = readonly ShapeNode[]>(rql: string, params?: any, shapes?: S, options?: AdminOptions): {
|
|
179
|
+
is_executing: boolean;
|
|
180
180
|
results: AdminResult<S extends readonly ShapeNode[] ? InferShape<S[number]> : any>[] | undefined;
|
|
181
181
|
error: string | undefined;
|
|
182
182
|
};
|
|
183
183
|
|
|
184
184
|
interface SubscriptionExecutorOptions {
|
|
185
|
-
|
|
185
|
+
connection_config?: ConnectionConfig;
|
|
186
186
|
}
|
|
187
187
|
interface ChangeEvent<T> {
|
|
188
188
|
operation: 'INSERT' | 'UPDATE' | 'REMOVE';
|
|
@@ -192,34 +192,34 @@ interface ChangeEvent<T> {
|
|
|
192
192
|
interface SubscriptionState<T> {
|
|
193
193
|
data: T[];
|
|
194
194
|
changes: ChangeEvent<T>[];
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
is_subscribed: boolean;
|
|
196
|
+
is_subscribing: boolean;
|
|
197
197
|
error: string | undefined;
|
|
198
|
-
|
|
198
|
+
subscription_id: string | undefined;
|
|
199
199
|
}
|
|
200
200
|
declare function useSubscriptionExecutor<T = any>(options?: SubscriptionExecutorOptions): {
|
|
201
201
|
state: SubscriptionState<T>;
|
|
202
|
-
subscribe: (
|
|
202
|
+
subscribe: (rql: string, params?: any, shape?: ShapeNode) => Promise<void>;
|
|
203
203
|
unsubscribe: () => Promise<void>;
|
|
204
|
-
|
|
205
|
-
|
|
204
|
+
clear_changes: () => void;
|
|
205
|
+
clear_data: () => void;
|
|
206
206
|
};
|
|
207
207
|
|
|
208
208
|
interface SubscriptionOptions extends SubscriptionExecutorOptions {
|
|
209
209
|
enabled?: boolean;
|
|
210
210
|
}
|
|
211
|
-
declare function useSubscription<S extends ShapeNode = any>(
|
|
211
|
+
declare function useSubscription<S extends ShapeNode = any>(rql: string, params?: any, shape?: S, options?: SubscriptionOptions): {
|
|
212
212
|
data: InferShape<S>[];
|
|
213
213
|
changes: ChangeEvent<InferShape<S>>[];
|
|
214
|
-
|
|
215
|
-
|
|
214
|
+
is_subscribed: boolean;
|
|
215
|
+
is_subscribing: boolean;
|
|
216
216
|
error: string | undefined;
|
|
217
|
-
|
|
217
|
+
subscription_id: string | undefined;
|
|
218
218
|
};
|
|
219
219
|
|
|
220
220
|
interface ColumnInfo {
|
|
221
221
|
name: string;
|
|
222
|
-
|
|
222
|
+
data_type: string;
|
|
223
223
|
}
|
|
224
224
|
interface TableInfo {
|
|
225
225
|
name: string;
|
|
@@ -227,4 +227,4 @@ interface TableInfo {
|
|
|
227
227
|
}
|
|
228
228
|
declare function useShape(): [boolean, TableInfo[], string | undefined];
|
|
229
229
|
|
|
230
|
-
export { type AdminExecutorOptions, type AdminOptions, type AdminResult, type AdminState, type ChangeEvent, type ColumnInfo, type CommandExecutorOptions, type CommandOptions, type CommandResult, type CommandState, Connection, type ConnectionConfig, ConnectionContext, ConnectionProvider, type ConnectionProviderProps, DEFAULT_CONFIG, DEFAULT_URL, type QueryExecutorOptions, type QueryOptions, type QueryResult, type QueryState, type SubscriptionExecutorOptions, type SubscriptionOptions, type SubscriptionState, type TableInfo,
|
|
230
|
+
export { type AdminExecutorOptions, type AdminOptions, type AdminResult, type AdminState, type ChangeEvent, type ColumnInfo, type CommandExecutorOptions, type CommandOptions, type CommandResult, type CommandState, Connection, type ConnectionConfig, ConnectionContext, ConnectionProvider, type ConnectionProviderProps, DEFAULT_CONFIG, DEFAULT_URL, type QueryExecutorOptions, type QueryOptions, type QueryResult, type QueryState, type SubscriptionExecutorOptions, type SubscriptionOptions, type SubscriptionState, type TableInfo, clear_connection, get_connection, useAdminExecutor, useAdminMany, useAdminOne, useCommandExecutor, useCommandMany, useCommandOne, useConnection, useQueryExecutor, useQueryMany, useQueryOne, useShape, useSubscription, useSubscriptionExecutor };
|