@reifydb/react 0.1.3 → 0.1.5
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 +11 -1
- package/dist/index.js +163 -1
- package/dist/index.js.map +1 -1
- package/package.json +18 -17
package/dist/index.d.ts
CHANGED
|
@@ -139,4 +139,14 @@ declare function useCommandMany<S extends readonly SchemaNode[] = readonly Schem
|
|
|
139
139
|
error: string | undefined;
|
|
140
140
|
};
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
interface ColumnInfo {
|
|
143
|
+
name: string;
|
|
144
|
+
dataType: string;
|
|
145
|
+
}
|
|
146
|
+
interface TableInfo {
|
|
147
|
+
name: string;
|
|
148
|
+
columns: ColumnInfo[];
|
|
149
|
+
}
|
|
150
|
+
declare function useSchema(): [boolean, TableInfo[], string | undefined];
|
|
151
|
+
|
|
152
|
+
export { type ColumnInfo, 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, type TableInfo, clearConnection, getConnection, useCommandExecutor, useCommandMany, useCommandOne, useConnection, useQueryExecutor, useQueryMany, useQueryOne, useSchema };
|
package/dist/index.js
CHANGED
|
@@ -476,6 +476,167 @@ function useCommandMany(statements, params, schemas, options) {
|
|
|
476
476
|
}, [statements, params, command]);
|
|
477
477
|
return { isExecuting, results, error };
|
|
478
478
|
}
|
|
479
|
+
|
|
480
|
+
// src/hooks/use-schema.ts
|
|
481
|
+
import { useEffect as useEffect5, useState as useState4 } from "react";
|
|
482
|
+
import { Schema } from "@reifydb/core";
|
|
483
|
+
var namespaceSchema = Schema.object({
|
|
484
|
+
id: Schema.number(),
|
|
485
|
+
name: Schema.string()
|
|
486
|
+
});
|
|
487
|
+
var tableSchema = Schema.object({
|
|
488
|
+
id: Schema.number(),
|
|
489
|
+
namespace_id: Schema.number(),
|
|
490
|
+
name: Schema.string(),
|
|
491
|
+
primary_key_id: Schema.number()
|
|
492
|
+
});
|
|
493
|
+
var viewSchema = Schema.object({
|
|
494
|
+
id: Schema.number(),
|
|
495
|
+
namespace_id: Schema.number(),
|
|
496
|
+
name: Schema.string()
|
|
497
|
+
});
|
|
498
|
+
var columnSchema = Schema.object({
|
|
499
|
+
id: Schema.number(),
|
|
500
|
+
source_id: Schema.number(),
|
|
501
|
+
source_type: Schema.number(),
|
|
502
|
+
name: Schema.string(),
|
|
503
|
+
type: Schema.number(),
|
|
504
|
+
position: Schema.number(),
|
|
505
|
+
auto_increment: Schema.boolean()
|
|
506
|
+
});
|
|
507
|
+
function useSchema() {
|
|
508
|
+
const { isExecuting, results, error, query } = useQueryExecutor();
|
|
509
|
+
const [schema, setSchema] = useState4([]);
|
|
510
|
+
const [isLoading, setIsLoading] = useState4(true);
|
|
511
|
+
useEffect5(() => {
|
|
512
|
+
if (!query) return;
|
|
513
|
+
const fetchSchema = async () => {
|
|
514
|
+
setIsLoading(true);
|
|
515
|
+
try {
|
|
516
|
+
await query(
|
|
517
|
+
`FROM system.namespaces; FROM system.tables; FROM system.views; FROM system.columns;`,
|
|
518
|
+
void 0,
|
|
519
|
+
[namespaceSchema, tableSchema, viewSchema, columnSchema]
|
|
520
|
+
);
|
|
521
|
+
} catch (err) {
|
|
522
|
+
console.error("Failed to fetch schema:", err);
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
fetchSchema();
|
|
526
|
+
}, [query]);
|
|
527
|
+
useEffect5(() => {
|
|
528
|
+
if (!results || results.length < 4) {
|
|
529
|
+
setIsLoading(isExecuting);
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
const tablesResult = results[1];
|
|
533
|
+
const viewsResult = results[2];
|
|
534
|
+
const columnsResult = results[3];
|
|
535
|
+
if (!tablesResult?.rows || !viewsResult?.rows || !columnsResult?.rows) {
|
|
536
|
+
setIsLoading(false);
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
const namespacesResult = results[0];
|
|
540
|
+
const namespaces = namespacesResult.rows;
|
|
541
|
+
const tables = tablesResult.rows;
|
|
542
|
+
const views = viewsResult.rows;
|
|
543
|
+
const columns = columnsResult.rows;
|
|
544
|
+
const namespaceMap = /* @__PURE__ */ new Map();
|
|
545
|
+
namespaces.forEach((ns) => {
|
|
546
|
+
const id = ns.id?.valueOf();
|
|
547
|
+
const name = ns.name?.valueOf();
|
|
548
|
+
if (id !== void 0 && name) {
|
|
549
|
+
namespaceMap.set(id, name);
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
const tableInfoMap = /* @__PURE__ */ new Map();
|
|
553
|
+
tables.forEach((table) => {
|
|
554
|
+
const tableId = table.id?.valueOf();
|
|
555
|
+
const namespaceId = table.namespace_id?.valueOf();
|
|
556
|
+
const tableName = table.name?.valueOf();
|
|
557
|
+
if (tableId === void 0 || !tableName || namespaceId === void 0) return;
|
|
558
|
+
const namespace = namespaceMap.get(namespaceId);
|
|
559
|
+
if (!namespace) return;
|
|
560
|
+
const fullTableName = `${namespace}.${tableName}`;
|
|
561
|
+
tableInfoMap.set(tableId, {
|
|
562
|
+
name: fullTableName,
|
|
563
|
+
columns: []
|
|
564
|
+
});
|
|
565
|
+
});
|
|
566
|
+
views.forEach((view) => {
|
|
567
|
+
const viewId = view.id?.valueOf();
|
|
568
|
+
const namespaceId = view.namespace_id?.valueOf();
|
|
569
|
+
const viewName = view.name?.valueOf();
|
|
570
|
+
if (viewId === void 0 || !viewName || namespaceId === void 0) return;
|
|
571
|
+
const namespace = namespaceMap.get(namespaceId);
|
|
572
|
+
if (!namespace) return;
|
|
573
|
+
const fullViewName = `${namespace}.${viewName}`;
|
|
574
|
+
tableInfoMap.set(viewId, {
|
|
575
|
+
name: fullViewName,
|
|
576
|
+
columns: []
|
|
577
|
+
});
|
|
578
|
+
});
|
|
579
|
+
const typeMap = {
|
|
580
|
+
0: "Undefined",
|
|
581
|
+
1: "Float4",
|
|
582
|
+
2: "Float8",
|
|
583
|
+
3: "Int1",
|
|
584
|
+
4: "Int2",
|
|
585
|
+
5: "Int4",
|
|
586
|
+
6: "Int8",
|
|
587
|
+
7: "Int16",
|
|
588
|
+
8: "Utf8",
|
|
589
|
+
9: "Uint1",
|
|
590
|
+
10: "Uint2",
|
|
591
|
+
11: "Uint4",
|
|
592
|
+
12: "Uint8",
|
|
593
|
+
13: "Uint16",
|
|
594
|
+
14: "Boolean",
|
|
595
|
+
15: "Date",
|
|
596
|
+
16: "DateTime",
|
|
597
|
+
17: "Time",
|
|
598
|
+
18: "Duration",
|
|
599
|
+
19: "RowNumber",
|
|
600
|
+
20: "Uuid4",
|
|
601
|
+
21: "Uuid7",
|
|
602
|
+
22: "Blob",
|
|
603
|
+
23: "IdentityId",
|
|
604
|
+
24: "Int",
|
|
605
|
+
25: "Decimal",
|
|
606
|
+
26: "Uint",
|
|
607
|
+
27: "Any"
|
|
608
|
+
};
|
|
609
|
+
const tableColumnsMap = /* @__PURE__ */ new Map();
|
|
610
|
+
columns.forEach((column) => {
|
|
611
|
+
const sourceId = column.source_id?.valueOf();
|
|
612
|
+
const sourceType = column.source_type?.valueOf();
|
|
613
|
+
const columnName = column.name?.valueOf();
|
|
614
|
+
const typeId = column.type?.valueOf();
|
|
615
|
+
const position = column.position?.valueOf();
|
|
616
|
+
if (sourceId === void 0 || !columnName || typeId === void 0) return;
|
|
617
|
+
if (sourceType !== 0 && sourceType !== 1) return;
|
|
618
|
+
if (!tableColumnsMap.has(sourceId)) {
|
|
619
|
+
tableColumnsMap.set(sourceId, []);
|
|
620
|
+
}
|
|
621
|
+
tableColumnsMap.get(sourceId).push({
|
|
622
|
+
name: columnName,
|
|
623
|
+
dataType: typeMap[typeId] || `Unknown(${typeId})`,
|
|
624
|
+
position: position ?? 0
|
|
625
|
+
});
|
|
626
|
+
});
|
|
627
|
+
tableColumnsMap.forEach((cols, sourceId) => {
|
|
628
|
+
const tableInfo = tableInfoMap.get(sourceId);
|
|
629
|
+
if (tableInfo) {
|
|
630
|
+
cols.sort((a, b) => a.position - b.position);
|
|
631
|
+
tableInfo.columns = cols.map((c) => ({ name: c.name, dataType: c.dataType }));
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
const schemaArray = Array.from(tableInfoMap.values()).filter((table) => table.name !== "reifydb.flows").sort((a, b) => a.name.localeCompare(b.name));
|
|
635
|
+
setSchema(schemaArray);
|
|
636
|
+
setIsLoading(false);
|
|
637
|
+
}, [results, isExecuting]);
|
|
638
|
+
return [isLoading, schema, error];
|
|
639
|
+
}
|
|
479
640
|
export {
|
|
480
641
|
Connection,
|
|
481
642
|
ConnectionContext,
|
|
@@ -489,6 +650,7 @@ export {
|
|
|
489
650
|
useConnection,
|
|
490
651
|
useQueryExecutor,
|
|
491
652
|
useQueryMany,
|
|
492
|
-
useQueryOne
|
|
653
|
+
useQueryOne,
|
|
654
|
+
useSchema
|
|
493
655
|
};
|
|
494
656
|
//# sourceMappingURL=index.js.map
|
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} 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,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ACb,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;;;AChKA,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"]}
|
|
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","../src/hooks/use-schema.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';\nexport {useSchema, type TableInfo, type ColumnInfo} from './hooks/use-schema';","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}","import {useEffect, useState} from 'react';\nimport {Schema, InferSchema} from '@reifydb/core';\nimport {useQueryExecutor} from './use-query-executor';\n\nexport interface ColumnInfo {\n name: string;\n dataType: string;\n}\n\nexport interface TableInfo {\n name: string;\n columns: ColumnInfo[];\n}\n\nconst namespaceSchema = Schema.object({\n id: Schema.number(),\n name: Schema.string(),\n});\n\nconst tableSchema = Schema.object({\n id: Schema.number(),\n namespace_id: Schema.number(),\n name: Schema.string(),\n primary_key_id: Schema.number(),\n});\n\nconst viewSchema = Schema.object({\n id: Schema.number(),\n namespace_id: Schema.number(),\n name: Schema.string(),\n});\n\nconst columnSchema = Schema.object({\n id: Schema.number(),\n source_id: Schema.number(),\n source_type: Schema.number(),\n name: Schema.string(),\n type: Schema.number(),\n position: Schema.number(),\n auto_increment: Schema.boolean(),\n});\n\ntype NamespaceRow = InferSchema<typeof namespaceSchema>;\ntype TableRow = InferSchema<typeof tableSchema>;\ntype ViewRow = InferSchema<typeof viewSchema>;\ntype ColumnRow = InferSchema<typeof columnSchema>;\n\nexport function useSchema(): [boolean, TableInfo[], string | undefined] {\n const {isExecuting, results, error, query} = useQueryExecutor();\n const [schema, setSchema] = useState<TableInfo[]>([]);\n const [isLoading, setIsLoading] = useState(true);\n\n useEffect(() => {\n if (!query) return;\n\n const fetchSchema = async () => {\n setIsLoading(true);\n\n try {\n await query(\n `FROM system.namespaces; FROM system.tables; FROM system.views; FROM system.columns;`,\n undefined,\n [namespaceSchema, tableSchema, viewSchema, columnSchema]\n );\n } catch (err) {\n console.error('Failed to fetch schema:', err);\n }\n };\n\n fetchSchema();\n }, [query]);\n\n useEffect(() => {\n if (!results || results.length < 4) {\n setIsLoading(isExecuting);\n return;\n }\n\n const tablesResult = results[1];\n const viewsResult = results[2];\n const columnsResult = results[3];\n\n if (!tablesResult?.rows || !viewsResult?.rows || !columnsResult?.rows) {\n setIsLoading(false);\n return;\n }\n\n const namespacesResult = results[0];\n const namespaces = namespacesResult.rows as unknown as NamespaceRow[];\n const tables = tablesResult.rows as unknown as TableRow[];\n const views = viewsResult.rows as unknown as ViewRow[];\n const columns = columnsResult.rows as unknown as ColumnRow[];\n\n const namespaceMap = new Map<number, string>();\n namespaces.forEach((ns) => {\n const id = ns.id?.valueOf() as number;\n const name = ns.name?.valueOf() as string;\n if (id !== undefined && name) {\n namespaceMap.set(id, name);\n }\n });\n\n const tableInfoMap = new Map<number, TableInfo>();\n\n tables.forEach((table) => {\n const tableId = table.id?.valueOf() as number;\n const namespaceId = table.namespace_id?.valueOf() as number;\n const tableName = table.name?.valueOf() as string;\n\n if (tableId === undefined || !tableName || namespaceId === undefined) return;\n\n const namespace = namespaceMap.get(namespaceId);\n if (!namespace) return;\n\n const fullTableName = `${namespace}.${tableName}`;\n\n tableInfoMap.set(tableId, {\n name: fullTableName,\n columns: [],\n });\n });\n\n views.forEach((view) => {\n const viewId = view.id?.valueOf() as number;\n const namespaceId = view.namespace_id?.valueOf() as number;\n const viewName = view.name?.valueOf() as string;\n\n if (viewId === undefined || !viewName || namespaceId === undefined) return;\n\n const namespace = namespaceMap.get(namespaceId);\n if (!namespace) return;\n\n const fullViewName = `${namespace}.${viewName}`;\n\n tableInfoMap.set(viewId, {\n name: fullViewName,\n columns: [],\n });\n });\n\n const typeMap: Record<number, string> = {\n 0: 'Undefined',\n 1: 'Float4',\n 2: 'Float8',\n 3: 'Int1',\n 4: 'Int2',\n 5: 'Int4',\n 6: 'Int8',\n 7: 'Int16',\n 8: 'Utf8',\n 9: 'Uint1',\n 10: 'Uint2',\n 11: 'Uint4',\n 12: 'Uint8',\n 13: 'Uint16',\n 14: 'Boolean',\n 15: 'Date',\n 16: 'DateTime',\n 17: 'Time',\n 18: 'Duration',\n 19: 'RowNumber',\n 20: 'Uuid4',\n 21: 'Uuid7',\n 22: 'Blob',\n 23: 'IdentityId',\n 24: 'Int',\n 25: 'Decimal',\n 26: 'Uint',\n 27: 'Any',\n };\n\n // Create a map to collect columns with their positions\n const tableColumnsMap = new Map<number, Array<{name: string; dataType: string; position: number}>>();\n\n columns.forEach((column) => {\n const sourceId = column.source_id?.valueOf() as number;\n const sourceType = column.source_type?.valueOf() as number;\n const columnName = column.name?.valueOf() as string;\n const typeId = column.type?.valueOf() as number;\n const position = column.position?.valueOf() as number;\n\n if (sourceId === undefined || !columnName || typeId === undefined) return;\n if (sourceType !== 0 && sourceType !== 1) return;\n\n if (!tableColumnsMap.has(sourceId)) {\n tableColumnsMap.set(sourceId, []);\n }\n\n tableColumnsMap.get(sourceId)!.push({\n name: columnName,\n dataType: typeMap[typeId] || `Unknown(${typeId})`,\n position: position ?? 0,\n });\n });\n\n // Sort columns by position and add to table info\n tableColumnsMap.forEach((cols, sourceId) => {\n const tableInfo = tableInfoMap.get(sourceId);\n if (tableInfo) {\n cols.sort((a, b) => a.position - b.position);\n tableInfo.columns = cols.map((c) => ({name: c.name, dataType: c.dataType}));\n }\n });\n\n const schemaArray = Array.from(tableInfoMap.values())\n .filter((table) => table.name !== 'reifydb.flows')\n .sort((a, b) => a.name.localeCompare(b.name));\n\n setSchema(schemaArray);\n setIsLoading(false);\n }, [results, isExecuting]);\n\n return [isLoading, schema, error];\n}\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,E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AAI,QAAQ;AAC3C,UAAI,WAAW;AACX,aAAK,KAAK,CAAC,GAAG,MAAM,EAAE,WAAW,EAAE,QAAQ;AAC3C,kBAAU,UAAU,KAAK,IAAI,CAAC,OAAO,EAAC,MAAM,EAAE,MAAM,UAAU,EAAE,SAAQ,EAAE;AAAA,MAC9E;AAAA,IACJ,CAAC;AAED,UAAM,cAAc,MAAM,KAAK,aAAa,OAAO,CAAC,EAC/C,OAAO,CAAC,UAAU,MAAM,SAAS,eAAe,EAChD,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;AAEhD,cAAU,WAAW;AACrB,iBAAa,KAAK;AAAA,EACtB,GAAG,CAAC,SAAS,WAAW,CAAC;AAEzB,SAAO,CAAC,WAAW,QAAQ,KAAK;AACpC;","names":["useEffect","useEffect","useState","useRef","useState","useRef","useEffect","useEffect","useState","useCallback","useRef","useState","useRef","useCallback","useEffect","useMemo","useEffect","useMemo","useEffect","useState","useState","useEffect"]}
|
package/package.json
CHANGED
|
@@ -1,23 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reifydb/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"build": "tsup src/index.ts --dts --format esm --sourcemap",
|
|
9
|
-
"dev": "tsc --watch",
|
|
10
|
-
"test": "pnpm test:integration",
|
|
11
|
-
"test:integration": "vitest run --config vitest.config.ts",
|
|
12
|
-
"test:integration:watch": "vitest --config vitest.config.ts",
|
|
13
|
-
"test:integration:coverage": "vitest run --coverage --config vitest.config.ts",
|
|
14
|
-
"test:coverage": "pnpm test:integration:coverage",
|
|
15
|
-
"pretest:integration": "pnpm build",
|
|
16
|
-
"publish:npm": "pnpm publish --access public"
|
|
17
|
-
},
|
|
18
7
|
"dependencies": {
|
|
19
|
-
"@reifydb/core": "
|
|
20
|
-
"@reifydb/client": "
|
|
8
|
+
"@reifydb/core": "0.1.5",
|
|
9
|
+
"@reifydb/client": "0.1.5"
|
|
21
10
|
},
|
|
22
11
|
"peerDependencies": {
|
|
23
12
|
"react": ">=16.8.0"
|
|
@@ -45,7 +34,19 @@
|
|
|
45
34
|
"license.md"
|
|
46
35
|
],
|
|
47
36
|
"publishConfig": {
|
|
48
|
-
"access": "public"
|
|
37
|
+
"access": "public",
|
|
38
|
+
"linkWorkspacePackages": false
|
|
49
39
|
},
|
|
50
|
-
"license": "MIT"
|
|
51
|
-
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsup src/index.ts --dts --format esm --sourcemap",
|
|
43
|
+
"dev": "tsc --watch",
|
|
44
|
+
"test": "pnpm test:integration",
|
|
45
|
+
"test:integration": "vitest run --config vitest.config.ts",
|
|
46
|
+
"test:integration:watch": "vitest --config vitest.config.ts",
|
|
47
|
+
"test:integration:coverage": "vitest run --coverage --config vitest.config.ts",
|
|
48
|
+
"test:coverage": "pnpm test:integration:coverage",
|
|
49
|
+
"pretest:integration": "pnpm build",
|
|
50
|
+
"publish:npm": "pnpm publish --access public"
|
|
51
|
+
}
|
|
52
|
+
}
|