@reifydb/react 0.0.1-alpha.8 → 0.1.0
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.mts +2 -0
- package/dist/index.d.ts +6 -11
- package/dist/index.js +31 -65
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -0
- package/package.json +3 -3
package/dist/index.d.mts
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -35,21 +35,16 @@ declare class Connection {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
* Get
|
|
39
|
-
* If a
|
|
38
|
+
* Get the singleton connection instance.
|
|
39
|
+
* If a config is provided, the connection's config will be updated via setConfig().
|
|
40
40
|
* @param config - Optional connection configuration
|
|
41
|
-
* @returns Connection instance
|
|
41
|
+
* @returns The singleton Connection instance
|
|
42
42
|
*/
|
|
43
43
|
declare function getConnection(config?: ConnectionConfig): Connection;
|
|
44
44
|
/**
|
|
45
|
-
* Clear
|
|
46
|
-
* @param config - Configuration of the connection to clear
|
|
45
|
+
* Clear the singleton connection
|
|
47
46
|
*/
|
|
48
|
-
declare function clearConnection(
|
|
49
|
-
/**
|
|
50
|
-
* Clear all cached connections
|
|
51
|
-
*/
|
|
52
|
-
declare function clearAllConnections(): Promise<void>;
|
|
47
|
+
declare function clearConnection(): Promise<void>;
|
|
53
48
|
|
|
54
49
|
declare const ConnectionContext: React.Context<Connection | null>;
|
|
55
50
|
interface ConnectionProviderProps {
|
|
@@ -144,4 +139,4 @@ declare function useCommandMany<S extends readonly SchemaNode[] = readonly Schem
|
|
|
144
139
|
error: string | undefined;
|
|
145
140
|
};
|
|
146
141
|
|
|
147
|
-
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,
|
|
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
CHANGED
|
@@ -29,19 +29,16 @@ var Connection = class {
|
|
|
29
29
|
}
|
|
30
30
|
async connect(url, options) {
|
|
31
31
|
if (this.state.isConnected || this.state.isConnecting) {
|
|
32
|
-
console.debug("[Connection] Already connected or connecting, skipping wsConnection attempt");
|
|
33
32
|
return;
|
|
34
33
|
}
|
|
35
34
|
const connectUrl = url || this.config.url || DEFAULT_CONFIG.url;
|
|
36
35
|
const connectOptions = { ...this.config.options, ...options };
|
|
37
|
-
console.debug("[Connection] Attempting to connect to:", connectUrl);
|
|
38
36
|
this.updateState({
|
|
39
37
|
isConnecting: true,
|
|
40
38
|
connectionError: null
|
|
41
39
|
});
|
|
42
40
|
try {
|
|
43
41
|
const client = await Client.connect_ws(connectUrl, connectOptions);
|
|
44
|
-
console.debug("[Connection] Successfully connected to WebSocket");
|
|
45
42
|
this.updateState({
|
|
46
43
|
client,
|
|
47
44
|
isConnected: true,
|
|
@@ -115,51 +112,43 @@ var Connection = class {
|
|
|
115
112
|
};
|
|
116
113
|
|
|
117
114
|
// src/connection/connection-pool.ts
|
|
118
|
-
var
|
|
115
|
+
var defaultConnection = null;
|
|
119
116
|
function getConnection(config) {
|
|
120
117
|
const effectiveConfig = config ? { ...DEFAULT_CONFIG, ...config } : DEFAULT_CONFIG;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
if (!defaultConnection) {
|
|
119
|
+
defaultConnection = new Connection(effectiveConfig);
|
|
120
|
+
} else {
|
|
121
|
+
defaultConnection.setConfig(effectiveConfig);
|
|
124
122
|
}
|
|
125
|
-
return
|
|
123
|
+
return defaultConnection;
|
|
126
124
|
}
|
|
127
|
-
async function clearConnection(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (connection) {
|
|
132
|
-
await connection.disconnect();
|
|
133
|
-
connectionCache.delete(key);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
async function clearAllConnections() {
|
|
137
|
-
const disconnectPromises = [];
|
|
138
|
-
for (const connection of connectionCache.values()) {
|
|
139
|
-
disconnectPromises.push(connection.disconnect());
|
|
125
|
+
async function clearConnection() {
|
|
126
|
+
if (defaultConnection) {
|
|
127
|
+
await defaultConnection.disconnect();
|
|
128
|
+
defaultConnection = null;
|
|
140
129
|
}
|
|
141
|
-
await Promise.all(disconnectPromises);
|
|
142
|
-
connectionCache.clear();
|
|
143
130
|
}
|
|
144
131
|
|
|
145
132
|
// src/connection/connection-context.tsx
|
|
146
|
-
import React, { createContext, useEffect,
|
|
133
|
+
import React, { createContext, useEffect, useRef } from "react";
|
|
147
134
|
var ConnectionContext = createContext(null);
|
|
148
135
|
function ConnectionProvider({ config, children }) {
|
|
149
|
-
const connection =
|
|
136
|
+
const connection = getConnection(config);
|
|
137
|
+
const prevConfigRef = useRef(void 0);
|
|
138
|
+
const currentConfigStr = JSON.stringify(config);
|
|
150
139
|
useEffect(() => {
|
|
151
|
-
|
|
152
|
-
|
|
140
|
+
const configChanged = prevConfigRef.current !== void 0 && prevConfigRef.current !== currentConfigStr;
|
|
141
|
+
if (configChanged && connection.isConnected()) {
|
|
142
|
+
connection.reconnect().catch((err) => {
|
|
143
|
+
console.error("[ConnectionProvider] Failed to reconnect:", err);
|
|
144
|
+
});
|
|
145
|
+
} else if (!connection.isConnected() && !connection.isConnecting()) {
|
|
153
146
|
connection.connect().catch((err) => {
|
|
154
147
|
console.error("[ConnectionProvider] Failed to connect:", err);
|
|
155
148
|
});
|
|
156
|
-
} else {
|
|
157
|
-
console.log("[ConnectionProvider] Skipping auto-connect, current state:", {
|
|
158
|
-
isConnected: connection.isConnected(),
|
|
159
|
-
isConnecting: connection.isConnecting()
|
|
160
|
-
});
|
|
161
149
|
}
|
|
162
|
-
|
|
150
|
+
prevConfigRef.current = currentConfigStr;
|
|
151
|
+
}, [currentConfigStr, connection]);
|
|
163
152
|
return /* @__PURE__ */ React.createElement(ConnectionContext.Provider, { value: connection }, children);
|
|
164
153
|
}
|
|
165
154
|
|
|
@@ -178,11 +167,6 @@ function useConnection(overrideConfig) {
|
|
|
178
167
|
const currentState = connection.getState();
|
|
179
168
|
setState(currentState);
|
|
180
169
|
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
170
|
setState({
|
|
187
171
|
client: newState.client,
|
|
188
172
|
isConnected: newState.isConnected,
|
|
@@ -190,19 +174,8 @@ function useConnection(overrideConfig) {
|
|
|
190
174
|
connectionError: newState.connectionError
|
|
191
175
|
});
|
|
192
176
|
});
|
|
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
177
|
return unsubscribe;
|
|
205
|
-
}, [connection
|
|
178
|
+
}, [connection]);
|
|
206
179
|
return {
|
|
207
180
|
...state,
|
|
208
181
|
connect: () => connection.connect(),
|
|
@@ -212,7 +185,7 @@ function useConnection(overrideConfig) {
|
|
|
212
185
|
}
|
|
213
186
|
|
|
214
187
|
// src/hooks/use-query-executor.ts
|
|
215
|
-
import { useState as useState2, useCallback, useRef } from "react";
|
|
188
|
+
import { useState as useState2, useCallback, useRef as useRef2 } from "react";
|
|
216
189
|
function useQueryExecutor(options) {
|
|
217
190
|
const { client } = useConnection(options?.connectionConfig);
|
|
218
191
|
const [state, setState] = useState2({
|
|
@@ -221,11 +194,9 @@ function useQueryExecutor(options) {
|
|
|
221
194
|
error: void 0,
|
|
222
195
|
executionTime: void 0
|
|
223
196
|
});
|
|
224
|
-
const abortControllerRef =
|
|
197
|
+
const abortControllerRef = useRef2(null);
|
|
225
198
|
const query = useCallback(
|
|
226
199
|
(statements, params, schemas) => {
|
|
227
|
-
console.log("[useQuery] Executing query:", statements);
|
|
228
|
-
console.log("[useQuery] Client available:", !!client);
|
|
229
200
|
if (abortControllerRef.current) {
|
|
230
201
|
abortControllerRef.current.abort();
|
|
231
202
|
}
|
|
@@ -240,7 +211,6 @@ function useQueryExecutor(options) {
|
|
|
240
211
|
(async () => {
|
|
241
212
|
try {
|
|
242
213
|
const frameResults = await client?.query(statements, params || null, schemas || []) || [];
|
|
243
|
-
console.debug("frameResults", frameResults);
|
|
244
214
|
const executionTime = Date.now() - startTime;
|
|
245
215
|
const results = frameResults.map((frame) => {
|
|
246
216
|
if (Array.isArray(frame) && frame.length > 0) {
|
|
@@ -330,7 +300,7 @@ function useQueryExecutor(options) {
|
|
|
330
300
|
}
|
|
331
301
|
|
|
332
302
|
// src/hooks/use-query.ts
|
|
333
|
-
import { useEffect as useEffect3, useMemo
|
|
303
|
+
import { useEffect as useEffect3, useMemo } from "react";
|
|
334
304
|
function useQueryOne(rql, params, schema, options) {
|
|
335
305
|
const {
|
|
336
306
|
isExecuting,
|
|
@@ -342,7 +312,7 @@ function useQueryOne(rql, params, schema, options) {
|
|
|
342
312
|
const schemas = schema ? [schema] : void 0;
|
|
343
313
|
query(rql, params, schemas);
|
|
344
314
|
}, [rql, params, query]);
|
|
345
|
-
const result =
|
|
315
|
+
const result = useMemo(() => {
|
|
346
316
|
return results && results.length > 0 ? results[0] : void 0;
|
|
347
317
|
}, [results]);
|
|
348
318
|
return { isExecuting, result, error };
|
|
@@ -361,7 +331,7 @@ function useQueryMany(statements, params, schemas, options) {
|
|
|
361
331
|
}
|
|
362
332
|
|
|
363
333
|
// src/hooks/use-command-executor.ts
|
|
364
|
-
import { useState as useState3, useCallback as useCallback2, useRef as
|
|
334
|
+
import { useState as useState3, useCallback as useCallback2, useRef as useRef3 } from "react";
|
|
365
335
|
function useCommandExecutor(options) {
|
|
366
336
|
const { client } = useConnection(options?.connectionConfig);
|
|
367
337
|
const [state, setState] = useState3({
|
|
@@ -370,11 +340,9 @@ function useCommandExecutor(options) {
|
|
|
370
340
|
error: void 0,
|
|
371
341
|
executionTime: void 0
|
|
372
342
|
});
|
|
373
|
-
const abortControllerRef =
|
|
343
|
+
const abortControllerRef = useRef3(null);
|
|
374
344
|
const command = useCallback2(
|
|
375
345
|
(statements, params, schemas) => {
|
|
376
|
-
console.log("[useCommand] Executing command:", statements);
|
|
377
|
-
console.log("[useCommand] Client available:", !!client);
|
|
378
346
|
if (abortControllerRef.current) {
|
|
379
347
|
abortControllerRef.current.abort();
|
|
380
348
|
}
|
|
@@ -389,7 +357,6 @@ function useCommandExecutor(options) {
|
|
|
389
357
|
(async () => {
|
|
390
358
|
try {
|
|
391
359
|
const frameResults = await client?.command(statements, params || null, schemas || []) || [];
|
|
392
|
-
console.debug("frameResults", frameResults);
|
|
393
360
|
const executionTime = Date.now() - startTime;
|
|
394
361
|
const results = frameResults.map((frame) => {
|
|
395
362
|
if (Array.isArray(frame) && frame.length > 0) {
|
|
@@ -480,7 +447,7 @@ function useCommandExecutor(options) {
|
|
|
480
447
|
}
|
|
481
448
|
|
|
482
449
|
// src/hooks/use-command.ts
|
|
483
|
-
import { useEffect as useEffect4, useMemo as
|
|
450
|
+
import { useEffect as useEffect4, useMemo as useMemo2 } from "react";
|
|
484
451
|
function useCommandOne(statement, params, schema, options) {
|
|
485
452
|
const {
|
|
486
453
|
isExecuting,
|
|
@@ -492,7 +459,7 @@ function useCommandOne(statement, params, schema, options) {
|
|
|
492
459
|
const schemas = schema ? [schema] : void 0;
|
|
493
460
|
command(statement, params, schemas);
|
|
494
461
|
}, [statement, params, command]);
|
|
495
|
-
const result =
|
|
462
|
+
const result = useMemo2(() => {
|
|
496
463
|
return results && results.length > 0 ? results[0] : void 0;
|
|
497
464
|
}, [results]);
|
|
498
465
|
return { isExecuting, result, error };
|
|
@@ -514,7 +481,6 @@ export {
|
|
|
514
481
|
ConnectionContext,
|
|
515
482
|
ConnectionProvider,
|
|
516
483
|
DEFAULT_CONFIG,
|
|
517
|
-
clearAllConnections,
|
|
518
484
|
clearConnection,
|
|
519
485
|
getConnection,
|
|
520
486
|
useCommandExecutor,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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, clearAllConnections} 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 * Connection cache that stores connections by their configuration.\n * This ensures that connections with the same configuration share the same instance.\n */\nconst connectionCache = new Map<string, Connection>();\n\n/**\n * Get or create a connection for the given configuration.\n * If a connection with the same config already exists, it will be reused.\n * @param config - Optional connection configuration\n * @returns Connection instance for the given configuration\n */\nexport function getConnection(config?: ConnectionConfig): Connection {\n const effectiveConfig = config ? { ...DEFAULT_CONFIG, ...config } : DEFAULT_CONFIG;\n const key = JSON.stringify(effectiveConfig);\n \n if (!connectionCache.has(key)) {\n connectionCache.set(key, new Connection(effectiveConfig));\n }\n \n return connectionCache.get(key)!;\n}\n\n/**\n * Clear a specific connection from the cache\n * @param config - Configuration of the connection to clear\n */\nexport async function clearConnection(config?: ConnectionConfig): Promise<void> {\n const effectiveConfig = config ? { ...DEFAULT_CONFIG, ...config } : DEFAULT_CONFIG;\n const key = JSON.stringify(effectiveConfig);\n \n const connection = connectionCache.get(key);\n if (connection) {\n await connection.disconnect();\n connectionCache.delete(key);\n }\n}\n\n/**\n * Clear all cached connections\n */\nexport async function clearAllConnections(): Promise<void> {\n const disconnectPromises = [];\n for (const connection of connectionCache.values()) {\n disconnectPromises.push(connection.disconnect());\n }\n await Promise.all(disconnectPromises);\n connectionCache.clear();\n}","import React, { createContext, useEffect, useMemo, 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 const connection = useMemo(() => getConnection(config), [JSON.stringify(config)]);\n \n useEffect(() => {\n // Auto-connect if not connected\n if (!connection.isConnected() && !connection.isConnecting()) {\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 });\n }\n }, [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, params, schemas);\n }, [statements, params, command]);\n\n return {isExecuting, results, error};\n}"],"mappings":";AAAA,cAAc;AACd,cAAc;;;ACDd,SAAQ,cAA6C;AAe9C,IAAM,iBAAmC;AAAA,EAC5C,KAAK;AAAA,EACL,SAAS;AAAA,IACL,WAAW;AAAA,EACf;AACJ;AAEO,IAAM,aAAN,MAAiB;AAAA,EAUpB,YAAY,QAA2B;AATvC,SAAQ,QAAyB;AAAA,MAC7B,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,cAAc;AAAA,MACd,iBAAiB;AAAA,MACjB,WAAW,oBAAI,IAAI;AAAA,IACvB;AAII,SAAK,SAAS,EAAE,GAAG,gBAAgB,GAAG,OAAO;AAAA,EACjD;AAAA,EAEA,UAAU,QAAgC;AACtC,SAAK,SAAS,EAAC,GAAG,gBAAgB,GAAG,OAAM;AAAA,EAC/C;AAAA,EAEA,YAA8B;AAC1B,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,MAAM,QAAQ,KAAc,SAAuD;AAE/E,QAAI,KAAK,MAAM,eAAe,KAAK,MAAM,cAAc;AACnD,cAAQ,MAAM,6EAA6E;AAC3F;AAAA,IACJ;AAEA,UAAM,aAAa,OAAO,KAAK,OAAO,OAAO,eAAe;AAC5D,UAAM,iBAAiB,EAAC,GAAG,KAAK,OAAO,SAAS,GAAG,QAAO;AAE1D,YAAQ,MAAM,0CAA0C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C;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","useState","useEffect","useMemo","useEffect","useMemo","useState","useCallback","useRef","useState","useRef","useCallback","useEffect","useMemo","useEffect","useMemo"]}
|
|
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 return;\n }\n\n const connectUrl = url || this.config.url || DEFAULT_CONFIG.url!;\n const connectOptions = {...this.config.options, ...options};\n\n this.updateState({\n isConnecting: true,\n connectionError: null,\n });\n\n try {\n const client = await Client.connect_ws(connectUrl, connectOptions);\n\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 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 connection.connect().catch(err => {\n console.error('[ConnectionProvider] Failed to connect:', err);\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 setState({\n client: newState.client,\n isConnected: newState.isConnected,\n isConnecting: newState.isConnecting,\n connectionError: newState.connectionError,\n });\n });\n\n // No auto-connect - ConnectionProvider handles all auto-connection\n // Users must either wrap with ConnectionProvider or manually call connect()\n\n return unsubscribe;\n }, [connection]);\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 // 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 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 // 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 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, params, schemas);\n }, [statements, params, command]);\n\n return {isExecuting, results, error};\n}"],"mappings":";AAAA,cAAc;AACd,cAAc;;;ACDd,SAAQ,cAA6C;AAe9C,IAAM,iBAAmC;AAAA,EAC5C,KAAK;AAAA,EACL,SAAS;AAAA,IACL,WAAW;AAAA,EACf;AACJ;AAEO,IAAM,aAAN,MAAiB;AAAA,EAUpB,YAAY,QAA2B;AATvC,SAAQ,QAAyB;AAAA,MAC7B,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,cAAc;AAAA,MACd,iBAAiB;AAAA,MACjB,WAAW,oBAAI,IAAI;AAAA,IACvB;AAII,SAAK,SAAS,EAAE,GAAG,gBAAgB,GAAG,OAAO;AAA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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/dist/index.mjs
ADDED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reifydb/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@reifydb/core": "0.
|
|
9
|
-
"@reifydb/client": "0.
|
|
8
|
+
"@reifydb/core": "0.1.0",
|
|
9
|
+
"@reifydb/client": "0.1.0"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
12
|
"react": ">=16.8.0"
|