@reifydb/react 0.0.1-alpha.10 → 0.0.1-alpha.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 +142 -0
- package/dist/index.js +527 -0
- package/dist/index.js.map +1 -0
- package/package.json +3 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Column, SchemaNode, InferSchema } from '@reifydb/core';
|
|
2
|
+
export * from '@reifydb/core';
|
|
3
|
+
import { WsClientOptions, WsClient } from '@reifydb/client';
|
|
4
|
+
export * from '@reifydb/client';
|
|
5
|
+
import React, { ReactNode } from 'react';
|
|
6
|
+
|
|
7
|
+
interface ConnectionState {
|
|
8
|
+
client: WsClient | null;
|
|
9
|
+
isConnected: boolean;
|
|
10
|
+
isConnecting: boolean;
|
|
11
|
+
connectionError: string | null;
|
|
12
|
+
listeners: Set<(state: ConnectionState) => void>;
|
|
13
|
+
}
|
|
14
|
+
interface ConnectionConfig {
|
|
15
|
+
url?: string;
|
|
16
|
+
options?: Omit<WsClientOptions, 'url'>;
|
|
17
|
+
}
|
|
18
|
+
declare const DEFAULT_CONFIG: ConnectionConfig;
|
|
19
|
+
declare class Connection {
|
|
20
|
+
private state;
|
|
21
|
+
private config;
|
|
22
|
+
constructor(config?: ConnectionConfig);
|
|
23
|
+
setConfig(config: ConnectionConfig): void;
|
|
24
|
+
getConfig(): ConnectionConfig;
|
|
25
|
+
connect(url?: string, options?: Omit<WsClientOptions, 'url'>): Promise<void>;
|
|
26
|
+
disconnect(): Promise<void>;
|
|
27
|
+
reconnect(url?: string, options?: Omit<WsClientOptions, 'url'>): Promise<void>;
|
|
28
|
+
getClient(): WsClient | null;
|
|
29
|
+
isConnected(): boolean;
|
|
30
|
+
isConnecting(): boolean;
|
|
31
|
+
getConnectionError(): string | null;
|
|
32
|
+
getState(): Omit<ConnectionState, 'listeners'>;
|
|
33
|
+
subscribe(listener: (state: ConnectionState) => void): () => void;
|
|
34
|
+
private updateState;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Get the singleton connection instance.
|
|
39
|
+
* If a config is provided, the connection's config will be updated via setConfig().
|
|
40
|
+
* @param config - Optional connection configuration
|
|
41
|
+
* @returns The singleton Connection instance
|
|
42
|
+
*/
|
|
43
|
+
declare function getConnection(config?: ConnectionConfig): Connection;
|
|
44
|
+
/**
|
|
45
|
+
* Clear the singleton connection
|
|
46
|
+
*/
|
|
47
|
+
declare function clearConnection(): Promise<void>;
|
|
48
|
+
|
|
49
|
+
declare const ConnectionContext: React.Context<Connection | null>;
|
|
50
|
+
interface ConnectionProviderProps {
|
|
51
|
+
config?: ConnectionConfig;
|
|
52
|
+
children: ReactNode;
|
|
53
|
+
}
|
|
54
|
+
declare function ConnectionProvider({ config, children }: ConnectionProviderProps): React.JSX.Element;
|
|
55
|
+
|
|
56
|
+
declare function useConnection(overrideConfig?: ConnectionConfig): {
|
|
57
|
+
connect: () => Promise<void>;
|
|
58
|
+
disconnect: () => Promise<void>;
|
|
59
|
+
reconnect: () => Promise<void>;
|
|
60
|
+
client: WsClient | null;
|
|
61
|
+
isConnected: boolean;
|
|
62
|
+
isConnecting: boolean;
|
|
63
|
+
connectionError: string | null;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
interface QueryResult<T = any> {
|
|
67
|
+
columns: Column[];
|
|
68
|
+
rows: T[];
|
|
69
|
+
executionTimeMs: number;
|
|
70
|
+
rowsAffected?: number;
|
|
71
|
+
}
|
|
72
|
+
interface QueryState<T = any> {
|
|
73
|
+
isExecuting: boolean;
|
|
74
|
+
results: QueryResult<T>[] | undefined;
|
|
75
|
+
error: string | undefined;
|
|
76
|
+
executionTime: number | undefined;
|
|
77
|
+
}
|
|
78
|
+
interface QueryExecutorOptions {
|
|
79
|
+
connectionConfig?: ConnectionConfig;
|
|
80
|
+
}
|
|
81
|
+
declare function useQueryExecutor<T = any>(options?: QueryExecutorOptions): {
|
|
82
|
+
isExecuting: boolean;
|
|
83
|
+
results: QueryResult<T>[] | undefined;
|
|
84
|
+
error: string | undefined;
|
|
85
|
+
executionTime: number | undefined;
|
|
86
|
+
query: (statements: string | string[], params?: any, schemas?: readonly SchemaNode[]) => void;
|
|
87
|
+
cancelQuery: () => void;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
interface QueryOptions extends QueryExecutorOptions {
|
|
91
|
+
connectionConfig?: ConnectionConfig;
|
|
92
|
+
}
|
|
93
|
+
declare function useQueryOne<S extends SchemaNode = any>(rql: string, params?: any, schema?: S, options?: QueryOptions): {
|
|
94
|
+
isExecuting: boolean;
|
|
95
|
+
result: QueryResult<S extends SchemaNode ? InferSchema<S> : any> | undefined;
|
|
96
|
+
error: string | undefined;
|
|
97
|
+
};
|
|
98
|
+
declare function useQueryMany<S extends readonly SchemaNode[] = readonly SchemaNode[]>(statements: string | string[], params?: any, schemas?: S, options?: QueryOptions): {
|
|
99
|
+
isExecuting: boolean;
|
|
100
|
+
results: QueryResult<S extends readonly SchemaNode[] ? InferSchema<S[number]> : any>[] | undefined;
|
|
101
|
+
error: string | undefined;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
interface CommandResult<T = any> {
|
|
105
|
+
columns: Column[];
|
|
106
|
+
rows: T[];
|
|
107
|
+
executionTimeMs: number;
|
|
108
|
+
rowsAffected?: number;
|
|
109
|
+
}
|
|
110
|
+
interface CommandState<T = any> {
|
|
111
|
+
isExecuting: boolean;
|
|
112
|
+
results: CommandResult<T>[] | undefined;
|
|
113
|
+
error: string | undefined;
|
|
114
|
+
executionTime: number | undefined;
|
|
115
|
+
}
|
|
116
|
+
interface CommandExecutorOptions {
|
|
117
|
+
connectionConfig?: ConnectionConfig;
|
|
118
|
+
}
|
|
119
|
+
declare function useCommandExecutor<T = any>(options?: CommandExecutorOptions): {
|
|
120
|
+
isExecuting: boolean;
|
|
121
|
+
results: CommandResult<T>[] | undefined;
|
|
122
|
+
error: string | undefined;
|
|
123
|
+
executionTime: number | undefined;
|
|
124
|
+
command: (statements: string | string[], params?: any, schemas?: readonly SchemaNode[]) => void;
|
|
125
|
+
cancelCommand: () => void;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
interface CommandOptions extends CommandExecutorOptions {
|
|
129
|
+
connectionConfig?: ConnectionConfig;
|
|
130
|
+
}
|
|
131
|
+
declare function useCommandOne<S extends SchemaNode = any>(statement: string, params?: any, schema?: S, options?: CommandOptions): {
|
|
132
|
+
isExecuting: boolean;
|
|
133
|
+
result: CommandResult<S extends SchemaNode ? InferSchema<S> : any> | undefined;
|
|
134
|
+
error: string | undefined;
|
|
135
|
+
};
|
|
136
|
+
declare function useCommandMany<S extends readonly SchemaNode[] = readonly SchemaNode[]>(statements: string | string[], params?: any, schemas?: S, options?: CommandOptions): {
|
|
137
|
+
isExecuting: boolean;
|
|
138
|
+
results: CommandResult<S extends readonly SchemaNode[] ? InferSchema<S[number]> : any>[] | undefined;
|
|
139
|
+
error: string | undefined;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export { type CommandExecutorOptions, type CommandOptions, type CommandResult, type CommandState, Connection, type ConnectionConfig, ConnectionContext, ConnectionProvider, type ConnectionProviderProps, DEFAULT_CONFIG, type QueryExecutorOptions, type QueryOptions, type QueryResult, type QueryState, clearConnection, getConnection, useCommandExecutor, useCommandMany, useCommandOne, useConnection, useQueryExecutor, useQueryMany, useQueryOne };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
export * from "@reifydb/core";
|
|
3
|
+
export * from "@reifydb/client";
|
|
4
|
+
|
|
5
|
+
// src/connection/connection.ts
|
|
6
|
+
import { Client } from "@reifydb/client";
|
|
7
|
+
var DEFAULT_CONFIG = {
|
|
8
|
+
url: "ws://127.0.0.1:8090",
|
|
9
|
+
options: {
|
|
10
|
+
timeoutMs: 1e3
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
var Connection = class {
|
|
14
|
+
constructor(config) {
|
|
15
|
+
this.state = {
|
|
16
|
+
client: null,
|
|
17
|
+
isConnected: false,
|
|
18
|
+
isConnecting: false,
|
|
19
|
+
connectionError: null,
|
|
20
|
+
listeners: /* @__PURE__ */ new Set()
|
|
21
|
+
};
|
|
22
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
23
|
+
}
|
|
24
|
+
setConfig(config) {
|
|
25
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
26
|
+
}
|
|
27
|
+
getConfig() {
|
|
28
|
+
return this.config;
|
|
29
|
+
}
|
|
30
|
+
async connect(url, options) {
|
|
31
|
+
if (this.state.isConnected || this.state.isConnecting) {
|
|
32
|
+
console.debug("[Connection] Already connected or connecting, skipping wsConnection attempt");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const connectUrl = url || this.config.url || DEFAULT_CONFIG.url;
|
|
36
|
+
const connectOptions = { ...this.config.options, ...options };
|
|
37
|
+
console.debug("[Connection] Attempting to connect to:", connectUrl);
|
|
38
|
+
this.updateState({
|
|
39
|
+
isConnecting: true,
|
|
40
|
+
connectionError: null
|
|
41
|
+
});
|
|
42
|
+
try {
|
|
43
|
+
const client = await Client.connect_ws(connectUrl, connectOptions);
|
|
44
|
+
console.debug("[Connection] Successfully connected to WebSocket");
|
|
45
|
+
this.updateState({
|
|
46
|
+
client,
|
|
47
|
+
isConnected: true,
|
|
48
|
+
isConnecting: false,
|
|
49
|
+
connectionError: null
|
|
50
|
+
});
|
|
51
|
+
} catch (err) {
|
|
52
|
+
const errorMessage = err instanceof Error ? err.message : "Failed to connect to ReifyDB";
|
|
53
|
+
console.error("[Connection] Connection failed:", errorMessage, err);
|
|
54
|
+
this.updateState({
|
|
55
|
+
client: null,
|
|
56
|
+
isConnected: false,
|
|
57
|
+
isConnecting: false,
|
|
58
|
+
connectionError: errorMessage
|
|
59
|
+
});
|
|
60
|
+
throw err;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async disconnect() {
|
|
64
|
+
if (this.state.client) {
|
|
65
|
+
try {
|
|
66
|
+
this.state.client.disconnect();
|
|
67
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
68
|
+
} catch (err) {
|
|
69
|
+
console.error("Error disconnecting:", err);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
this.updateState({
|
|
73
|
+
client: null,
|
|
74
|
+
isConnected: false,
|
|
75
|
+
isConnecting: false,
|
|
76
|
+
connectionError: null
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async reconnect(url, options) {
|
|
80
|
+
await this.disconnect();
|
|
81
|
+
await this.connect(url, options);
|
|
82
|
+
}
|
|
83
|
+
getClient() {
|
|
84
|
+
return this.state.client;
|
|
85
|
+
}
|
|
86
|
+
isConnected() {
|
|
87
|
+
return this.state.isConnected;
|
|
88
|
+
}
|
|
89
|
+
isConnecting() {
|
|
90
|
+
return this.state.isConnecting;
|
|
91
|
+
}
|
|
92
|
+
getConnectionError() {
|
|
93
|
+
return this.state.connectionError;
|
|
94
|
+
}
|
|
95
|
+
getState() {
|
|
96
|
+
const { listeners, ...state } = this.state;
|
|
97
|
+
return state;
|
|
98
|
+
}
|
|
99
|
+
// Subscribe to state changes
|
|
100
|
+
subscribe(listener) {
|
|
101
|
+
this.state.listeners.add(listener);
|
|
102
|
+
return () => {
|
|
103
|
+
this.state.listeners.delete(listener);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
updateState(updates) {
|
|
107
|
+
this.state = {
|
|
108
|
+
...this.state,
|
|
109
|
+
...updates
|
|
110
|
+
};
|
|
111
|
+
this.state.listeners.forEach((listener) => {
|
|
112
|
+
listener(this.state);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// src/connection/connection-pool.ts
|
|
118
|
+
var defaultConnection = null;
|
|
119
|
+
function getConnection(config) {
|
|
120
|
+
const effectiveConfig = config ? { ...DEFAULT_CONFIG, ...config } : DEFAULT_CONFIG;
|
|
121
|
+
if (!defaultConnection) {
|
|
122
|
+
defaultConnection = new Connection(effectiveConfig);
|
|
123
|
+
} else {
|
|
124
|
+
defaultConnection.setConfig(effectiveConfig);
|
|
125
|
+
}
|
|
126
|
+
return defaultConnection;
|
|
127
|
+
}
|
|
128
|
+
async function clearConnection() {
|
|
129
|
+
if (defaultConnection) {
|
|
130
|
+
await defaultConnection.disconnect();
|
|
131
|
+
defaultConnection = null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// src/connection/connection-context.tsx
|
|
136
|
+
import React, { createContext, useEffect, useRef } from "react";
|
|
137
|
+
var ConnectionContext = createContext(null);
|
|
138
|
+
function ConnectionProvider({ config, children }) {
|
|
139
|
+
const connection = getConnection(config);
|
|
140
|
+
const prevConfigRef = useRef(void 0);
|
|
141
|
+
const currentConfigStr = JSON.stringify(config);
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
const configChanged = prevConfigRef.current !== void 0 && prevConfigRef.current !== currentConfigStr;
|
|
144
|
+
if (configChanged && connection.isConnected()) {
|
|
145
|
+
console.log("[ConnectionProvider] Config changed, reconnecting...");
|
|
146
|
+
connection.reconnect().catch((err) => {
|
|
147
|
+
console.error("[ConnectionProvider] Failed to reconnect:", err);
|
|
148
|
+
});
|
|
149
|
+
} else if (!connection.isConnected() && !connection.isConnecting()) {
|
|
150
|
+
console.log("[ConnectionProvider] Initiating auto-connect...");
|
|
151
|
+
connection.connect().catch((err) => {
|
|
152
|
+
console.error("[ConnectionProvider] Failed to connect:", err);
|
|
153
|
+
});
|
|
154
|
+
} else {
|
|
155
|
+
console.log("[ConnectionProvider] Skipping auto-connect, current state:", {
|
|
156
|
+
isConnected: connection.isConnected(),
|
|
157
|
+
isConnecting: connection.isConnecting(),
|
|
158
|
+
configChanged
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
prevConfigRef.current = currentConfigStr;
|
|
162
|
+
}, [currentConfigStr, connection]);
|
|
163
|
+
return /* @__PURE__ */ React.createElement(ConnectionContext.Provider, { value: connection }, children);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// src/hooks/use-connection.ts
|
|
167
|
+
import { useContext, useEffect as useEffect2, useState } from "react";
|
|
168
|
+
function useConnection(overrideConfig) {
|
|
169
|
+
const contextConnection = useContext(ConnectionContext);
|
|
170
|
+
const [connection] = useState(() => {
|
|
171
|
+
if (overrideConfig) {
|
|
172
|
+
return getConnection(overrideConfig);
|
|
173
|
+
}
|
|
174
|
+
return contextConnection || getConnection();
|
|
175
|
+
});
|
|
176
|
+
const [state, setState] = useState(() => connection.getState());
|
|
177
|
+
useEffect2(() => {
|
|
178
|
+
const currentState = connection.getState();
|
|
179
|
+
setState(currentState);
|
|
180
|
+
const unsubscribe = connection.subscribe((newState) => {
|
|
181
|
+
console.log("[useConnection] State update:", {
|
|
182
|
+
isConnected: newState.isConnected,
|
|
183
|
+
isConnecting: newState.isConnecting,
|
|
184
|
+
connectionError: newState.connectionError
|
|
185
|
+
});
|
|
186
|
+
setState({
|
|
187
|
+
client: newState.client,
|
|
188
|
+
isConnected: newState.isConnected,
|
|
189
|
+
isConnecting: newState.isConnecting,
|
|
190
|
+
connectionError: newState.connectionError
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
if (overrideConfig && !connection.isConnected() && !connection.isConnecting()) {
|
|
194
|
+
console.log("[useConnection] Initiating auto-connect for override config...");
|
|
195
|
+
connection.connect().catch((err) => {
|
|
196
|
+
console.error("[useConnection] Failed to connect:", err);
|
|
197
|
+
});
|
|
198
|
+
} else if (!contextConnection && !overrideConfig && !connection.isConnected() && !connection.isConnecting()) {
|
|
199
|
+
console.log("[useConnection] Initiating auto-connect for default connection...");
|
|
200
|
+
connection.connect().catch((err) => {
|
|
201
|
+
console.error("[useConnection] Failed to connect:", err);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
return unsubscribe;
|
|
205
|
+
}, [connection, overrideConfig, contextConnection]);
|
|
206
|
+
return {
|
|
207
|
+
...state,
|
|
208
|
+
connect: () => connection.connect(),
|
|
209
|
+
disconnect: () => connection.disconnect(),
|
|
210
|
+
reconnect: () => connection.reconnect()
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// src/hooks/use-query-executor.ts
|
|
215
|
+
import { useState as useState2, useCallback, useRef as useRef2 } from "react";
|
|
216
|
+
function useQueryExecutor(options) {
|
|
217
|
+
const { client } = useConnection(options?.connectionConfig);
|
|
218
|
+
const [state, setState] = useState2({
|
|
219
|
+
isExecuting: false,
|
|
220
|
+
results: void 0,
|
|
221
|
+
error: void 0,
|
|
222
|
+
executionTime: void 0
|
|
223
|
+
});
|
|
224
|
+
const abortControllerRef = useRef2(null);
|
|
225
|
+
const query = useCallback(
|
|
226
|
+
(statements, params, schemas) => {
|
|
227
|
+
console.log("[useQuery] Executing query:", statements);
|
|
228
|
+
console.log("[useQuery] Client available:", !!client);
|
|
229
|
+
if (abortControllerRef.current) {
|
|
230
|
+
abortControllerRef.current.abort();
|
|
231
|
+
}
|
|
232
|
+
abortControllerRef.current = new AbortController();
|
|
233
|
+
setState({
|
|
234
|
+
isExecuting: true,
|
|
235
|
+
results: void 0,
|
|
236
|
+
error: void 0,
|
|
237
|
+
executionTime: void 0
|
|
238
|
+
});
|
|
239
|
+
const startTime = Date.now();
|
|
240
|
+
(async () => {
|
|
241
|
+
try {
|
|
242
|
+
const frameResults = await client?.query(statements, params || null, schemas || []) || [];
|
|
243
|
+
console.debug("frameResults", frameResults);
|
|
244
|
+
const executionTime = Date.now() - startTime;
|
|
245
|
+
const results = frameResults.map((frame) => {
|
|
246
|
+
if (Array.isArray(frame) && frame.length > 0) {
|
|
247
|
+
const firstRow = frame[0];
|
|
248
|
+
let columns = [];
|
|
249
|
+
const hasValueObjects = firstRow && typeof firstRow === "object" && Object.values(firstRow).some((v) => v && typeof v === "object" && "type" in v);
|
|
250
|
+
if (hasValueObjects) {
|
|
251
|
+
columns = Object.keys(firstRow).map((key) => {
|
|
252
|
+
const value = firstRow[key];
|
|
253
|
+
const dataType = value?.type || "Utf8";
|
|
254
|
+
return {
|
|
255
|
+
name: key,
|
|
256
|
+
type: dataType,
|
|
257
|
+
data: []
|
|
258
|
+
};
|
|
259
|
+
});
|
|
260
|
+
} else {
|
|
261
|
+
columns = Object.keys(firstRow).map((key) => ({
|
|
262
|
+
name: key,
|
|
263
|
+
type: "Utf8",
|
|
264
|
+
// Default type for plain objects
|
|
265
|
+
data: []
|
|
266
|
+
}));
|
|
267
|
+
}
|
|
268
|
+
return {
|
|
269
|
+
columns,
|
|
270
|
+
rows: frame,
|
|
271
|
+
executionTimeMs: executionTime
|
|
272
|
+
};
|
|
273
|
+
} else {
|
|
274
|
+
return {
|
|
275
|
+
columns: [],
|
|
276
|
+
rows: [],
|
|
277
|
+
executionTimeMs: executionTime
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
setState({
|
|
282
|
+
isExecuting: false,
|
|
283
|
+
results,
|
|
284
|
+
error: void 0,
|
|
285
|
+
executionTime
|
|
286
|
+
});
|
|
287
|
+
} catch (err) {
|
|
288
|
+
const executionTime = Date.now() - startTime;
|
|
289
|
+
let errorMessage = "Query execution failed";
|
|
290
|
+
if (err instanceof Error) {
|
|
291
|
+
errorMessage = err.message;
|
|
292
|
+
} else if (typeof err === "string") {
|
|
293
|
+
errorMessage = err;
|
|
294
|
+
} else if (err && typeof err === "object" && "message" in err) {
|
|
295
|
+
errorMessage = err.message;
|
|
296
|
+
}
|
|
297
|
+
setState({
|
|
298
|
+
isExecuting: false,
|
|
299
|
+
results: void 0,
|
|
300
|
+
error: errorMessage,
|
|
301
|
+
executionTime
|
|
302
|
+
});
|
|
303
|
+
} finally {
|
|
304
|
+
abortControllerRef.current = null;
|
|
305
|
+
}
|
|
306
|
+
})();
|
|
307
|
+
},
|
|
308
|
+
[client]
|
|
309
|
+
);
|
|
310
|
+
const cancelQuery = useCallback(() => {
|
|
311
|
+
if (abortControllerRef.current) {
|
|
312
|
+
abortControllerRef.current.abort();
|
|
313
|
+
setState((prev) => ({
|
|
314
|
+
...prev,
|
|
315
|
+
isExecuting: false,
|
|
316
|
+
error: "Query cancelled"
|
|
317
|
+
}));
|
|
318
|
+
}
|
|
319
|
+
}, []);
|
|
320
|
+
return {
|
|
321
|
+
// State
|
|
322
|
+
isExecuting: state.isExecuting,
|
|
323
|
+
results: state.results,
|
|
324
|
+
error: state.error,
|
|
325
|
+
executionTime: state.executionTime,
|
|
326
|
+
// Actions
|
|
327
|
+
query,
|
|
328
|
+
cancelQuery
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// src/hooks/use-query.ts
|
|
333
|
+
import { useEffect as useEffect3, useMemo } from "react";
|
|
334
|
+
function useQueryOne(rql, params, schema, options) {
|
|
335
|
+
const {
|
|
336
|
+
isExecuting,
|
|
337
|
+
results,
|
|
338
|
+
error,
|
|
339
|
+
query
|
|
340
|
+
} = useQueryExecutor(options);
|
|
341
|
+
useEffect3(() => {
|
|
342
|
+
const schemas = schema ? [schema] : void 0;
|
|
343
|
+
query(rql, params, schemas);
|
|
344
|
+
}, [rql, params, query]);
|
|
345
|
+
const result = useMemo(() => {
|
|
346
|
+
return results && results.length > 0 ? results[0] : void 0;
|
|
347
|
+
}, [results]);
|
|
348
|
+
return { isExecuting, result, error };
|
|
349
|
+
}
|
|
350
|
+
function useQueryMany(statements, params, schemas, options) {
|
|
351
|
+
const {
|
|
352
|
+
isExecuting,
|
|
353
|
+
results,
|
|
354
|
+
error,
|
|
355
|
+
query
|
|
356
|
+
} = useQueryExecutor(options);
|
|
357
|
+
useEffect3(() => {
|
|
358
|
+
query(statements, params, schemas);
|
|
359
|
+
}, [statements, params, query]);
|
|
360
|
+
return { isExecuting, results, error };
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// src/hooks/use-command-executor.ts
|
|
364
|
+
import { useState as useState3, useCallback as useCallback2, useRef as useRef3 } from "react";
|
|
365
|
+
function useCommandExecutor(options) {
|
|
366
|
+
const { client } = useConnection(options?.connectionConfig);
|
|
367
|
+
const [state, setState] = useState3({
|
|
368
|
+
isExecuting: false,
|
|
369
|
+
results: void 0,
|
|
370
|
+
error: void 0,
|
|
371
|
+
executionTime: void 0
|
|
372
|
+
});
|
|
373
|
+
const abortControllerRef = useRef3(null);
|
|
374
|
+
const command = useCallback2(
|
|
375
|
+
(statements, params, schemas) => {
|
|
376
|
+
console.log("[useCommand] Executing command:", statements);
|
|
377
|
+
console.log("[useCommand] Client available:", !!client);
|
|
378
|
+
if (abortControllerRef.current) {
|
|
379
|
+
abortControllerRef.current.abort();
|
|
380
|
+
}
|
|
381
|
+
abortControllerRef.current = new AbortController();
|
|
382
|
+
setState({
|
|
383
|
+
isExecuting: true,
|
|
384
|
+
results: void 0,
|
|
385
|
+
error: void 0,
|
|
386
|
+
executionTime: void 0
|
|
387
|
+
});
|
|
388
|
+
const startTime = Date.now();
|
|
389
|
+
(async () => {
|
|
390
|
+
try {
|
|
391
|
+
const frameResults = await client?.command(statements, params || null, schemas || []) || [];
|
|
392
|
+
console.debug("frameResults", frameResults);
|
|
393
|
+
const executionTime = Date.now() - startTime;
|
|
394
|
+
const results = frameResults.map((frame) => {
|
|
395
|
+
if (Array.isArray(frame) && frame.length > 0) {
|
|
396
|
+
const firstRow = frame[0];
|
|
397
|
+
let columns = [];
|
|
398
|
+
const hasValueObjects = firstRow && typeof firstRow === "object" && Object.values(firstRow).some((v) => v && typeof v === "object" && "type" in v);
|
|
399
|
+
if (hasValueObjects) {
|
|
400
|
+
columns = Object.keys(firstRow).map((key) => {
|
|
401
|
+
const value = firstRow[key];
|
|
402
|
+
const dataType = value?.type || "Utf8";
|
|
403
|
+
return {
|
|
404
|
+
name: key,
|
|
405
|
+
type: dataType,
|
|
406
|
+
data: []
|
|
407
|
+
};
|
|
408
|
+
});
|
|
409
|
+
} else {
|
|
410
|
+
columns = Object.keys(firstRow).map((key) => ({
|
|
411
|
+
name: key,
|
|
412
|
+
type: "Utf8",
|
|
413
|
+
// Default type for plain objects
|
|
414
|
+
data: []
|
|
415
|
+
}));
|
|
416
|
+
}
|
|
417
|
+
return {
|
|
418
|
+
columns,
|
|
419
|
+
rows: frame,
|
|
420
|
+
executionTimeMs: executionTime
|
|
421
|
+
};
|
|
422
|
+
} else {
|
|
423
|
+
return {
|
|
424
|
+
columns: [],
|
|
425
|
+
rows: [],
|
|
426
|
+
executionTimeMs: executionTime,
|
|
427
|
+
rowsAffected: typeof frame === "number" ? frame : void 0
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
setState({
|
|
432
|
+
isExecuting: false,
|
|
433
|
+
results,
|
|
434
|
+
error: void 0,
|
|
435
|
+
executionTime
|
|
436
|
+
});
|
|
437
|
+
} catch (err) {
|
|
438
|
+
const executionTime = Date.now() - startTime;
|
|
439
|
+
let errorMessage = "Command execution failed";
|
|
440
|
+
if (err instanceof Error) {
|
|
441
|
+
errorMessage = err.message;
|
|
442
|
+
} else if (typeof err === "string") {
|
|
443
|
+
errorMessage = err;
|
|
444
|
+
} else if (err && typeof err === "object" && "message" in err) {
|
|
445
|
+
errorMessage = err.message;
|
|
446
|
+
}
|
|
447
|
+
setState({
|
|
448
|
+
isExecuting: false,
|
|
449
|
+
results: void 0,
|
|
450
|
+
error: errorMessage,
|
|
451
|
+
executionTime
|
|
452
|
+
});
|
|
453
|
+
} finally {
|
|
454
|
+
abortControllerRef.current = null;
|
|
455
|
+
}
|
|
456
|
+
})();
|
|
457
|
+
},
|
|
458
|
+
[client]
|
|
459
|
+
);
|
|
460
|
+
const cancelCommand = useCallback2(() => {
|
|
461
|
+
if (abortControllerRef.current) {
|
|
462
|
+
abortControllerRef.current.abort();
|
|
463
|
+
setState((prev) => ({
|
|
464
|
+
...prev,
|
|
465
|
+
isExecuting: false,
|
|
466
|
+
error: "Command cancelled"
|
|
467
|
+
}));
|
|
468
|
+
}
|
|
469
|
+
}, []);
|
|
470
|
+
return {
|
|
471
|
+
// State
|
|
472
|
+
isExecuting: state.isExecuting,
|
|
473
|
+
results: state.results,
|
|
474
|
+
error: state.error,
|
|
475
|
+
executionTime: state.executionTime,
|
|
476
|
+
// Actions
|
|
477
|
+
command,
|
|
478
|
+
cancelCommand
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// src/hooks/use-command.ts
|
|
483
|
+
import { useEffect as useEffect4, useMemo as useMemo2 } from "react";
|
|
484
|
+
function useCommandOne(statement, params, schema, options) {
|
|
485
|
+
const {
|
|
486
|
+
isExecuting,
|
|
487
|
+
results,
|
|
488
|
+
error,
|
|
489
|
+
command
|
|
490
|
+
} = useCommandExecutor(options);
|
|
491
|
+
useEffect4(() => {
|
|
492
|
+
const schemas = schema ? [schema] : void 0;
|
|
493
|
+
command(statement, params, schemas);
|
|
494
|
+
}, [statement, params, command]);
|
|
495
|
+
const result = useMemo2(() => {
|
|
496
|
+
return results && results.length > 0 ? results[0] : void 0;
|
|
497
|
+
}, [results]);
|
|
498
|
+
return { isExecuting, result, error };
|
|
499
|
+
}
|
|
500
|
+
function useCommandMany(statements, params, schemas, options) {
|
|
501
|
+
const {
|
|
502
|
+
isExecuting,
|
|
503
|
+
results,
|
|
504
|
+
error,
|
|
505
|
+
command
|
|
506
|
+
} = useCommandExecutor(options);
|
|
507
|
+
useEffect4(() => {
|
|
508
|
+
command(statements, params, schemas);
|
|
509
|
+
}, [statements, params, command]);
|
|
510
|
+
return { isExecuting, results, error };
|
|
511
|
+
}
|
|
512
|
+
export {
|
|
513
|
+
Connection,
|
|
514
|
+
ConnectionContext,
|
|
515
|
+
ConnectionProvider,
|
|
516
|
+
DEFAULT_CONFIG,
|
|
517
|
+
clearConnection,
|
|
518
|
+
getConnection,
|
|
519
|
+
useCommandExecutor,
|
|
520
|
+
useCommandMany,
|
|
521
|
+
useCommandOne,
|
|
522
|
+
useConnection,
|
|
523
|
+
useQueryExecutor,
|
|
524
|
+
useQueryMany,
|
|
525
|
+
useQueryOne
|
|
526
|
+
};
|
|
527
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/connection/connection.ts","../src/connection/connection-pool.ts","../src/connection/connection-context.tsx","../src/hooks/use-connection.ts","../src/hooks/use-query-executor.ts","../src/hooks/use-query.ts","../src/hooks/use-command-executor.ts","../src/hooks/use-command.ts"],"sourcesContent":["export * from '@reifydb/core';\nexport * from '@reifydb/client';\n\n// Export connection utilities\nexport {Connection, type ConnectionConfig, DEFAULT_CONFIG} from './connection/connection';\nexport {getConnection, clearConnection} from './connection/connection-pool';\nexport {ConnectionProvider, ConnectionContext, type ConnectionProviderProps} from './connection/connection-context';\n\n// Export React hooks\nexport {useConnection} from './hooks/use-connection';\nexport {useQueryExecutor, type QueryResult, type QueryState, type QueryExecutorOptions} from './hooks/use-query-executor';\nexport {useQueryOne, useQueryMany, type QueryOptions} from './hooks/use-query';\nexport {useCommandExecutor, type CommandResult, type CommandState, type CommandExecutorOptions} from './hooks/use-command-executor';\nexport {useCommandOne, useCommandMany, type CommandOptions} from './hooks/use-command';","import {Client, WsClient, type WsClientOptions} from '@reifydb/client';\n\ninterface ConnectionState {\n client: WsClient | null;\n isConnected: boolean;\n isConnecting: boolean;\n connectionError: string | null;\n listeners: Set<(state: ConnectionState) => void>;\n}\n\nexport interface ConnectionConfig {\n url?: string;\n options?: Omit<WsClientOptions, 'url'>;\n}\n\nexport const DEFAULT_CONFIG: ConnectionConfig = {\n url: 'ws://127.0.0.1:8090',\n options: {\n timeoutMs: 1000,\n }\n};\n\nexport class Connection {\n private state: ConnectionState = {\n client: null,\n isConnected: false,\n isConnecting: false,\n connectionError: null,\n listeners: new Set(),\n };\n private config: ConnectionConfig;\n\n constructor(config?: ConnectionConfig) {\n this.config = { ...DEFAULT_CONFIG, ...config };\n }\n\n setConfig(config: ConnectionConfig): void {\n this.config = {...DEFAULT_CONFIG, ...config};\n }\n\n getConfig(): ConnectionConfig {\n return this.config;\n }\n\n async connect(url?: string, options?: Omit<WsClientOptions, 'url'>): Promise<void> {\n // Don't connect if already connected or connecting\n if (this.state.isConnected || this.state.isConnecting) {\n console.debug('[Connection] Already connected or connecting, skipping wsConnection attempt');\n return;\n }\n\n const connectUrl = url || this.config.url || DEFAULT_CONFIG.url!;\n const connectOptions = {...this.config.options, ...options};\n\n console.debug('[Connection] Attempting to connect to:', connectUrl);\n this.updateState({\n isConnecting: true,\n connectionError: null,\n });\n\n try {\n const client = await Client.connect_ws(connectUrl, connectOptions);\n\n console.debug('[Connection] Successfully connected to WebSocket');\n this.updateState({\n client,\n isConnected: true,\n isConnecting: false,\n connectionError: null,\n });\n } catch (err) {\n const errorMessage = err instanceof Error ? err.message : 'Failed to connect to ReifyDB';\n console.error('[Connection] Connection failed:', errorMessage, err);\n this.updateState({\n client: null,\n isConnected: false,\n isConnecting: false,\n connectionError: errorMessage,\n });\n throw err;\n }\n }\n\n async disconnect(): Promise<void> {\n if (this.state.client) {\n try {\n this.state.client.disconnect();\n // Small delay to ensure WebSocket closes cleanly\n await new Promise(resolve => setTimeout(resolve, 10));\n } catch (err) {\n console.error('Error disconnecting:', err);\n }\n }\n\n this.updateState({\n client: null,\n isConnected: false,\n isConnecting: false,\n connectionError: null,\n });\n }\n\n async reconnect(url?: string, options?: Omit<WsClientOptions, 'url'>): Promise<void> {\n await this.disconnect();\n await this.connect(url, options);\n }\n\n getClient(): WsClient | null {\n return this.state.client;\n }\n\n isConnected(): boolean {\n return this.state.isConnected;\n }\n\n isConnecting(): boolean {\n return this.state.isConnecting;\n }\n\n getConnectionError(): string | null {\n return this.state.connectionError;\n }\n\n getState(): Omit<ConnectionState, 'listeners'> {\n const {listeners, ...state} = this.state;\n return state;\n }\n\n // Subscribe to state changes\n subscribe(listener: (state: ConnectionState) => void): () => void {\n this.state.listeners.add(listener);\n // Return unsubscribe function\n return () => {\n this.state.listeners.delete(listener);\n };\n }\n\n private updateState(updates: Partial<ConnectionState>): void {\n this.state = {\n ...this.state,\n ...updates,\n };\n\n // Notify all listeners\n this.state.listeners.forEach(listener => {\n listener(this.state);\n });\n }\n}\n\n","import { Connection, ConnectionConfig, DEFAULT_CONFIG } from './connection';\n\n/**\n * Singleton default connection instance.\n * This ensures a single global connection that gets reused and updated.\n */\nlet defaultConnection: Connection | null = null;\n\n/**\n * Get the singleton connection instance.\n * If a config is provided, the connection's config will be updated via setConfig().\n * @param config - Optional connection configuration\n * @returns The singleton Connection instance\n */\nexport function getConnection(config?: ConnectionConfig): Connection {\n const effectiveConfig = config ? { ...DEFAULT_CONFIG, ...config } : DEFAULT_CONFIG;\n\n // Create singleton on first call\n if (!defaultConnection) {\n defaultConnection = new Connection(effectiveConfig);\n } else {\n // Update config on existing connection if provided\n defaultConnection.setConfig(effectiveConfig);\n }\n\n return defaultConnection;\n}\n\n/**\n * Clear the singleton connection\n */\nexport async function clearConnection(): Promise<void> {\n if (defaultConnection) {\n await defaultConnection.disconnect();\n defaultConnection = null;\n }\n}","import React, { createContext, useEffect, useRef, ReactNode } from 'react';\nimport { Connection, ConnectionConfig } from './connection';\nimport { getConnection } from './connection-pool';\n\nexport const ConnectionContext = createContext<Connection | null>(null);\n\nexport interface ConnectionProviderProps {\n config?: ConnectionConfig;\n children: ReactNode;\n}\n\nexport function ConnectionProvider({ config, children }: ConnectionProviderProps) {\n // Get the singleton connection - this always returns the same instance\n // but updates its config via setConfig()\n const connection = getConnection(config);\n\n // Track previous config to detect changes\n const prevConfigRef = useRef<string | undefined>(undefined);\n const currentConfigStr = JSON.stringify(config);\n\n useEffect(() => {\n const configChanged = prevConfigRef.current !== undefined &&\n prevConfigRef.current !== currentConfigStr;\n\n if (configChanged && connection.isConnected()) {\n // Config changed while connected - reconnect with new config\n console.log('[ConnectionProvider] Config changed, reconnecting...');\n connection.reconnect().catch(err => {\n console.error('[ConnectionProvider] Failed to reconnect:', err);\n });\n } else if (!connection.isConnected() && !connection.isConnecting()) {\n // Auto-connect if not connected\n console.log('[ConnectionProvider] Initiating auto-connect...');\n connection.connect().catch(err => {\n console.error('[ConnectionProvider] Failed to connect:', err);\n });\n } else {\n console.log('[ConnectionProvider] Skipping auto-connect, current state:', {\n isConnected: connection.isConnected(),\n isConnecting: connection.isConnecting(),\n configChanged\n });\n }\n\n // Update previous config reference\n prevConfigRef.current = currentConfigStr;\n }, [currentConfigStr, connection]);\n\n return (\n <ConnectionContext.Provider value={connection}>\n {children}\n </ConnectionContext.Provider>\n );\n}","import {useContext, useEffect, useState} from 'react';\nimport {ConnectionConfig} from '../connection/connection';\nimport {getConnection} from '../connection/connection-pool';\nimport {ConnectionContext} from '../connection/connection-context';\nimport {WsClient} from '@reifydb/client';\n\ninterface ConnectionState {\n client: WsClient | null;\n isConnected: boolean;\n isConnecting: boolean;\n connectionError: string | null;\n}\n\nexport function useConnection(overrideConfig?: ConnectionConfig) {\n const contextConnection = useContext(ConnectionContext);\n\n // Use override config if provided, otherwise use context, otherwise get default\n const [connection] = useState(() => {\n if (overrideConfig) {\n return getConnection(overrideConfig);\n }\n return contextConnection || getConnection();\n });\n\n const [state, setState] = useState<ConnectionState>(() => connection.getState());\n\n useEffect(() => {\n // Get initial state immediately\n const currentState = connection.getState();\n setState(currentState);\n \n // Subscribe to connection state changes\n const unsubscribe = connection.subscribe((newState) => {\n console.log('[useConnection] State update:', {\n isConnected: newState.isConnected,\n isConnecting: newState.isConnecting,\n connectionError: newState.connectionError,\n });\n setState({\n client: newState.client,\n isConnected: newState.isConnected,\n isConnecting: newState.isConnecting,\n connectionError: newState.connectionError,\n });\n });\n\n // Auto-connect if not connected (only for override configs, context handles its own)\n if (overrideConfig && !connection.isConnected() && !connection.isConnecting()) {\n console.log('[useConnection] Initiating auto-connect for override config...');\n connection.connect().catch(err => {\n console.error('[useConnection] Failed to connect:', err);\n });\n } else if (!contextConnection && !overrideConfig && !connection.isConnected() && !connection.isConnecting()) {\n // Auto-connect for default connection when no context provider\n console.log('[useConnection] Initiating auto-connect for default connection...');\n connection.connect().catch(err => {\n console.error('[useConnection] Failed to connect:', err);\n });\n }\n\n return unsubscribe;\n }, [connection, overrideConfig, contextConnection]);\n\n return {\n ...state,\n connect: () => connection.connect(),\n disconnect: () => connection.disconnect(),\n reconnect: () => connection.reconnect(),\n };\n}","import {useState, useCallback, useRef} from 'react';\nimport {Column, SchemaNode} from '@reifydb/core';\nimport {ConnectionConfig} from '../connection/connection';\nimport {useConnection} from './use-connection';\n\nexport interface QueryResult<T = any> {\n columns: Column[];\n rows: T[];\n executionTimeMs: number;\n rowsAffected?: number;\n}\n\nexport interface QueryState<T = any> {\n isExecuting: boolean;\n results: QueryResult<T>[] | undefined;\n error: string | undefined;\n executionTime: number | undefined;\n}\n\nexport interface QueryExecutorOptions {\n connectionConfig?: ConnectionConfig;\n}\n\nexport function useQueryExecutor<T = any>(options?: QueryExecutorOptions) {\n const {client} = useConnection(options?.connectionConfig);\n\n const [state, setState] = useState<QueryState<T>>({\n isExecuting: false,\n results: undefined,\n error: undefined,\n executionTime: undefined,\n });\n\n const abortControllerRef = useRef<AbortController | null>(null);\n\n const query = useCallback(\n (statements: string | string[], params?: any, schemas?: readonly SchemaNode[]): void => {\n console.log('[useQuery] Executing query:', statements);\n console.log('[useQuery] Client available:', !!client);\n\n // Cancel any ongoing query for THIS instance only\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n abortControllerRef.current = new AbortController();\n\n setState({\n isExecuting: true,\n results: undefined,\n error: undefined,\n executionTime: undefined,\n });\n\n const startTime = Date.now();\n\n (async () => {\n try {\n // Call client.query which returns FrameResults (array of frames)\n const frameResults = await client?.query(statements, params || null, schemas || []) || [];\n\n console.debug(\"frameResults\", frameResults);\n\n const executionTime = Date.now() - startTime;\n \n // Process each frame into a QueryResult\n const results: QueryResult<T>[] = frameResults.map((frame: any) => {\n if (Array.isArray(frame) && frame.length > 0) {\n const firstRow = frame[0];\n let columns: Column[] = [];\n \n // Check if we have Value objects or plain objects\n const hasValueObjects = firstRow && typeof firstRow === 'object' && \n Object.values(firstRow).some(v => v && typeof v === 'object' && 'type' in v);\n \n if (hasValueObjects) {\n // We have Value objects - extract type info\n columns = Object.keys(firstRow).map((key) => {\n const value = firstRow[key];\n const dataType = value?.type || 'Utf8';\n return {\n name: key,\n type: dataType,\n data: [],\n };\n });\n } else {\n // Plain objects from schema conversion\n columns = Object.keys(firstRow).map((key) => ({\n name: key,\n type: 'Utf8', // Default type for plain objects\n data: [],\n }));\n }\n \n return {\n columns,\n rows: frame as T[],\n executionTimeMs: executionTime,\n };\n } else {\n // Empty result\n return {\n columns: [],\n rows: [],\n executionTimeMs: executionTime,\n };\n }\n });\n\n setState({\n isExecuting: false,\n results,\n error: undefined,\n executionTime,\n });\n } catch (err) {\n const executionTime = Date.now() - startTime;\n let errorMessage = 'Query execution failed';\n\n if (err instanceof Error) {\n errorMessage = err.message;\n } else if (typeof err === 'string') {\n errorMessage = err;\n } else if (err && typeof err === 'object' && 'message' in err) {\n errorMessage = (err as { message: string }).message;\n }\n\n setState({\n isExecuting: false,\n results: undefined,\n error: errorMessage,\n executionTime,\n });\n } finally {\n abortControllerRef.current = null;\n }\n })();\n },\n [client]\n );\n\n const cancelQuery = useCallback(() => {\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n setState((prev) => ({\n ...prev,\n isExecuting: false,\n error: 'Query cancelled',\n }));\n }\n }, []);\n\n return {\n // State\n isExecuting: state.isExecuting,\n results: state.results,\n error: state.error,\n executionTime: state.executionTime,\n\n // Actions\n query,\n cancelQuery,\n };\n}","import {useEffect, useMemo} from 'react';\nimport {SchemaNode, InferSchema} from '@reifydb/core';\nimport {ConnectionConfig} from '../connection/connection';\nimport {useQueryExecutor, type QueryResult, type QueryExecutorOptions} from './use-query-executor';\n\nexport interface QueryOptions extends QueryExecutorOptions {\n connectionConfig?: ConnectionConfig;\n}\n\n// Single query hook - returns a single result\nexport function useQueryOne<S extends SchemaNode = any>(\n rql: string,\n params?: any,\n schema?: S,\n options?: QueryOptions\n): {\n isExecuting: boolean;\n result: QueryResult<S extends SchemaNode ? InferSchema<S> : any> | undefined;\n error: string | undefined;\n} {\n const {\n isExecuting,\n results,\n error,\n query\n } = useQueryExecutor<S extends SchemaNode ? InferSchema<S> : any>(options);\n\n useEffect(() => {\n // Pass schema as array for the executor\n const schemas = schema ? [schema] : undefined;\n query(rql, params, schemas);\n }, [rql, params, query]);\n\n // Extract first result for single query convenience\n const result = useMemo(() => {\n return results && results.length > 0 ? results[0] : undefined;\n }, [results]);\n\n return {isExecuting, result, error};\n}\n\n// Multiple query hook - returns multiple results\nexport function useQueryMany<S extends readonly SchemaNode[] = readonly SchemaNode[]>(\n statements: string | string[],\n params?: any,\n schemas?: S,\n options?: QueryOptions\n): {\n isExecuting: boolean;\n results: QueryResult<S extends readonly SchemaNode[] ? InferSchema<S[number]> : any>[] | undefined;\n error: string | undefined;\n} {\n const {\n isExecuting,\n results,\n error,\n query\n } = useQueryExecutor<S extends readonly SchemaNode[] ? InferSchema<S[number]> : any>(options);\n\n useEffect(() => {\n query(statements, params, schemas);\n }, [statements, params, query]);\n\n return {isExecuting, results, error};\n}","import {useState, useCallback, useRef} from 'react';\nimport {Column, SchemaNode} from '@reifydb/core';\nimport {ConnectionConfig} from '../connection/connection';\nimport {useConnection} from './use-connection';\n\nexport interface CommandResult<T = any> {\n columns: Column[];\n rows: T[];\n executionTimeMs: number;\n rowsAffected?: number;\n}\n\nexport interface CommandState<T = any> {\n isExecuting: boolean;\n results: CommandResult<T>[] | undefined;\n error: string | undefined;\n executionTime: number | undefined;\n}\n\nexport interface CommandExecutorOptions {\n connectionConfig?: ConnectionConfig;\n}\n\nexport function useCommandExecutor<T = any>(options?: CommandExecutorOptions) {\n const {client} = useConnection(options?.connectionConfig);\n\n const [state, setState] = useState<CommandState<T>>({\n isExecuting: false,\n results: undefined,\n error: undefined,\n executionTime: undefined,\n });\n\n const abortControllerRef = useRef<AbortController | null>(null);\n\n const command = useCallback(\n (statements: string | string[], params?: any, schemas?: readonly SchemaNode[]): void => {\n console.log('[useCommand] Executing command:', statements);\n console.log('[useCommand] Client available:', !!client);\n\n // Cancel any ongoing command for THIS instance only\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n abortControllerRef.current = new AbortController();\n\n setState({\n isExecuting: true,\n results: undefined,\n error: undefined,\n executionTime: undefined,\n });\n\n const startTime = Date.now();\n\n (async () => {\n try {\n // Call client.command which returns FrameResults (array of frames)\n // Commands and queries both use the same command method\n const frameResults = await client?.command(statements, params || null, schemas || []) || [];\n\n console.debug(\"frameResults\", frameResults);\n\n const executionTime = Date.now() - startTime;\n \n // Process each frame into a CommandResult\n const results: CommandResult<T>[] = frameResults.map((frame: any) => {\n if (Array.isArray(frame) && frame.length > 0) {\n const firstRow = frame[0];\n let columns: Column[] = [];\n \n // Check if we have Value objects or plain objects\n const hasValueObjects = firstRow && typeof firstRow === 'object' && \n Object.values(firstRow).some(v => v && typeof v === 'object' && 'type' in v);\n \n if (hasValueObjects) {\n // We have Value objects - extract type info\n columns = Object.keys(firstRow).map((key) => {\n const value = firstRow[key];\n const dataType = value?.type || 'Utf8';\n return {\n name: key,\n type: dataType,\n data: [],\n };\n });\n } else {\n // Plain objects from schema conversion\n columns = Object.keys(firstRow).map((key) => ({\n name: key,\n type: 'Utf8', // Default type for plain objects\n data: [],\n }));\n }\n \n return {\n columns,\n rows: frame as T[],\n executionTimeMs: executionTime,\n };\n } else {\n // Empty result or rows affected\n return {\n columns: [],\n rows: [],\n executionTimeMs: executionTime,\n rowsAffected: typeof frame === 'number' ? frame : undefined,\n };\n }\n });\n\n setState({\n isExecuting: false,\n results,\n error: undefined,\n executionTime,\n });\n } catch (err) {\n const executionTime = Date.now() - startTime;\n let errorMessage = 'Command execution failed';\n\n if (err instanceof Error) {\n errorMessage = err.message;\n } else if (typeof err === 'string') {\n errorMessage = err;\n } else if (err && typeof err === 'object' && 'message' in err) {\n errorMessage = (err as { message: string }).message;\n }\n\n setState({\n isExecuting: false,\n results: undefined,\n error: errorMessage,\n executionTime,\n });\n } finally {\n abortControllerRef.current = null;\n }\n })();\n },\n [client]\n );\n\n const cancelCommand = useCallback(() => {\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n setState((prev) => ({\n ...prev,\n isExecuting: false,\n error: 'Command cancelled',\n }));\n }\n }, []);\n\n return {\n // State\n isExecuting: state.isExecuting,\n results: state.results,\n error: state.error,\n executionTime: state.executionTime,\n\n // Actions\n command,\n cancelCommand,\n };\n}","import {useEffect, useMemo} from 'react';\nimport {SchemaNode, InferSchema} from '@reifydb/core';\nimport {ConnectionConfig} from '../connection/connection';\nimport {useCommandExecutor, type CommandResult, type CommandExecutorOptions} from './use-command-executor';\n\nexport interface CommandOptions extends CommandExecutorOptions {\n connectionConfig?: ConnectionConfig;\n}\n\n// Single command hook - returns a single result\nexport function useCommandOne<S extends SchemaNode = any>(\n statement: string,\n params?: any,\n schema?: S,\n options?: CommandOptions\n): {\n isExecuting: boolean;\n result: CommandResult<S extends SchemaNode ? InferSchema<S> : any> | undefined;\n error: string | undefined;\n} {\n const {\n isExecuting,\n results,\n error,\n command\n } = useCommandExecutor<S extends SchemaNode ? InferSchema<S> : any>(options);\n\n useEffect(() => {\n // Pass schema as array for the executor\n const schemas = schema ? [schema] : undefined;\n command(statement, params, schemas);\n }, [statement, params, command]);\n\n // Extract first result for single command convenience\n const result = useMemo(() => {\n return results && results.length > 0 ? results[0] : undefined;\n }, [results]);\n\n return {isExecuting, result, error};\n}\n\n// Multiple command hook - returns multiple results\nexport function useCommandMany<S extends readonly SchemaNode[] = readonly SchemaNode[]>(\n statements: string | string[],\n params?: any,\n schemas?: S,\n options?: CommandOptions\n): {\n isExecuting: boolean;\n results: CommandResult<S extends readonly SchemaNode[] ? InferSchema<S[number]> : any>[] | undefined;\n error: string | undefined;\n} {\n const {\n isExecuting,\n results,\n error,\n command\n } = useCommandExecutor<S extends readonly SchemaNode[] ? InferSchema<S[number]> : any>(options);\n\n useEffect(() => {\n command(statements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,QAChB,GAAG;AAAA,QACH,aAAa;AAAA,QACb,OAAO;AAAA,MACX,EAAE;AAAA,IACN;AAAA,EACJ,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA;AAAA,IAEH,aAAa,MAAM;AAAA,IACnB,SAAS,MAAM;AAAA,IACf,OAAO,MAAM;AAAA,IACb,eAAe,MAAM;AAAA;AAAA,IAGrB;AAAA,IACA;AAAA,EACJ;AACJ;;;ACrKA,SAAQ,aAAAC,YAAW,WAAAC,gBAAc;AAU1B,SAAS,cACZ,WACA,QACA,QACA,SAKF;AACE,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ,IAAI,mBAAgE,OAAO;AAE3E,EAAAC,WAAU,MAAM;AAEZ,UAAM,UAAU,SAAS,CAAC,MAAM,IAAI;AACpC,YAAQ,WAAW,QAAQ,OAAO;AAAA,EACtC,GAAG,CAAC,WAAW,QAAQ,OAAO,CAAC;AAG/B,QAAM,SAASC,SAAQ,MAAM;AACzB,WAAO,WAAW,QAAQ,SAAS,IAAI,QAAQ,CAAC,IAAI;AAAA,EACxD,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAC,aAAa,QAAQ,MAAK;AACtC;AAGO,SAAS,eACZ,YACA,QACA,SACA,SAKF;AACE,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ,IAAI,mBAAmF,OAAO;AAE9F,EAAAD,WAAU,MAAM;AACZ,YAAQ,YAAY,QAAQ,OAAO;AAAA,EACvC,GAAG,CAAC,YAAY,QAAQ,OAAO,CAAC;AAEhC,SAAO,EAAC,aAAa,SAAS,MAAK;AACvC;","names":["useEffect","useEffect","useState","useRef","useState","useRef","useEffect","useEffect","useState","useCallback","useRef","useState","useRef","useCallback","useEffect","useMemo","useEffect","useMemo"]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reifydb/react",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@reifydb/core": "0.0.1-alpha.
|
|
9
|
-
"@reifydb/client": "0.0.1-alpha.
|
|
8
|
+
"@reifydb/core": "0.0.1-alpha.11",
|
|
9
|
+
"@reifydb/client": "0.0.1-alpha.11"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
12
|
"react": ">=16.8.0"
|