@reifydb/react 0.4.10 → 0.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { Column, ShapeNode, InferShape } from '@reifydb/core';
2
2
  export * from '@reifydb/core';
3
- import { WsClientOptions, WsClient, HttpClient, JsonHttpClient, JsonWebsocketClient } from '@reifydb/client';
3
+ import { WsClientOptions, WsClient, HttpClient, JsonHttpClient, JsonWsClient } from '@reifydb/client';
4
4
  export * from '@reifydb/client';
5
5
  import React, { ReactNode } from 'react';
6
6
 
7
7
  interface ConnectionState {
8
- client: WsClient | HttpClient | JsonHttpClient | JsonWebsocketClient | null;
8
+ client: WsClient | HttpClient | JsonHttpClient | JsonWsClient | null;
9
9
  is_connected: boolean;
10
10
  is_connecting: boolean;
11
11
  connection_error: string | null;
@@ -29,7 +29,7 @@ declare class Connection {
29
29
  connect(url?: string, options?: Omit<WsClientOptions, 'url'>): Promise<void>;
30
30
  disconnect(): Promise<void>;
31
31
  reconnect(url?: string, options?: Omit<WsClientOptions, 'url'>): Promise<void>;
32
- get_client(): WsClient | HttpClient | JsonHttpClient | JsonWebsocketClient | null;
32
+ get_client(): WsClient | HttpClient | JsonHttpClient | JsonWsClient | null;
33
33
  is_connected(): boolean;
34
34
  is_connecting(): boolean;
35
35
  get_connection_error(): string | null;
@@ -61,7 +61,7 @@ declare function useConnection(override_config?: ConnectionConfig): {
61
61
  connect: () => Promise<void>;
62
62
  disconnect: () => Promise<void>;
63
63
  reconnect: () => Promise<void>;
64
- client: WsClient | HttpClient | JsonHttpClient | JsonWebsocketClient | null;
64
+ client: WsClient | HttpClient | JsonHttpClient | JsonWsClient | null;
65
65
  is_connected: boolean;
66
66
  is_connecting: boolean;
67
67
  connection_error: string | null;
@@ -87,7 +87,7 @@ declare function useQueryExecutor<T = any>(options?: QueryExecutorOptions): {
87
87
  results: QueryResult<T>[] | undefined;
88
88
  error: string | undefined;
89
89
  execution_time: number | undefined;
90
- query: (statements: string | string[], params?: any, shapes?: readonly ShapeNode[]) => Promise<void>;
90
+ query: (rql: string, params?: any, shapes?: readonly ShapeNode[]) => Promise<void>;
91
91
  cancel_query: () => void;
92
92
  };
93
93
 
@@ -99,7 +99,7 @@ declare function useQueryOne<S extends ShapeNode = any>(rql: string, params?: an
99
99
  result: QueryResult<S extends ShapeNode ? InferShape<S> : any> | undefined;
100
100
  error: string | undefined;
101
101
  };
102
- declare function useQueryMany<S extends readonly ShapeNode[] = readonly ShapeNode[]>(statements: string | string[], params?: any, shapes?: S, options?: QueryOptions): {
102
+ declare function useQueryMany<S extends readonly ShapeNode[] = readonly ShapeNode[]>(rql: string, params?: any, shapes?: S, options?: QueryOptions): {
103
103
  is_executing: boolean;
104
104
  results: QueryResult<S extends readonly ShapeNode[] ? InferShape<S[number]> : any>[] | undefined;
105
105
  error: string | undefined;
@@ -125,19 +125,19 @@ declare function useCommandExecutor<T = any>(options?: CommandExecutorOptions):
125
125
  results: CommandResult<T>[] | undefined;
126
126
  error: string | undefined;
127
127
  execution_time: number | undefined;
128
- command: (statements: string | string[], params?: any, shapes?: readonly ShapeNode[]) => Promise<void>;
128
+ command: (rql: string, params?: any, shapes?: readonly ShapeNode[]) => Promise<void>;
129
129
  cancel_command: () => void;
130
130
  };
131
131
 
132
132
  interface CommandOptions extends CommandExecutorOptions {
133
133
  connection_config?: ConnectionConfig;
134
134
  }
135
- declare function useCommandOne<S extends ShapeNode = any>(statement: string, params?: any, shape?: S, options?: CommandOptions): {
135
+ declare function useCommandOne<S extends ShapeNode = any>(rql: string, params?: any, shape?: S, options?: CommandOptions): {
136
136
  is_executing: boolean;
137
137
  result: CommandResult<S extends ShapeNode ? InferShape<S> : any> | undefined;
138
138
  error: string | undefined;
139
139
  };
140
- declare function useCommandMany<S extends readonly ShapeNode[] = readonly ShapeNode[]>(statements: string | string[], params?: any, shapes?: S, options?: CommandOptions): {
140
+ declare function useCommandMany<S extends readonly ShapeNode[] = readonly ShapeNode[]>(rql: string, params?: any, shapes?: S, options?: CommandOptions): {
141
141
  is_executing: boolean;
142
142
  results: CommandResult<S extends readonly ShapeNode[] ? InferShape<S[number]> : any>[] | undefined;
143
143
  error: string | undefined;
@@ -163,19 +163,19 @@ declare function useAdminExecutor<T = any>(options?: AdminExecutorOptions): {
163
163
  results: AdminResult<T>[] | undefined;
164
164
  error: string | undefined;
165
165
  execution_time: number | undefined;
166
- admin: (statements: string | string[], params?: any, shapes?: readonly ShapeNode[]) => Promise<void>;
166
+ admin: (rql: string, params?: any, shapes?: readonly ShapeNode[]) => Promise<void>;
167
167
  cancel_admin: () => void;
168
168
  };
169
169
 
170
170
  interface AdminOptions extends AdminExecutorOptions {
171
171
  connection_config?: ConnectionConfig;
172
172
  }
173
- declare function useAdminOne<S extends ShapeNode = any>(statement: string, params?: any, shape?: S, options?: AdminOptions): {
173
+ declare function useAdminOne<S extends ShapeNode = any>(rql: string, params?: any, shape?: S, options?: AdminOptions): {
174
174
  is_executing: boolean;
175
175
  result: AdminResult<S extends ShapeNode ? InferShape<S> : any> | undefined;
176
176
  error: string | undefined;
177
177
  };
178
- declare function useAdminMany<S extends readonly ShapeNode[] = readonly ShapeNode[]>(statements: string | string[], params?: any, shapes?: S, options?: AdminOptions): {
178
+ declare function useAdminMany<S extends readonly ShapeNode[] = readonly ShapeNode[]>(rql: string, params?: any, shapes?: S, options?: AdminOptions): {
179
179
  is_executing: boolean;
180
180
  results: AdminResult<S extends readonly ShapeNode[] ? InferShape<S[number]> : any>[] | undefined;
181
181
  error: string | undefined;
@@ -199,7 +199,7 @@ interface SubscriptionState<T> {
199
199
  }
200
200
  declare function useSubscriptionExecutor<T = any>(options?: SubscriptionExecutorOptions): {
201
201
  state: SubscriptionState<T>;
202
- subscribe: (query: string, params?: any, shape?: ShapeNode) => Promise<void>;
202
+ subscribe: (rql: string, params?: any, shape?: ShapeNode) => Promise<void>;
203
203
  unsubscribe: () => Promise<void>;
204
204
  clear_changes: () => void;
205
205
  clear_data: () => void;
@@ -208,7 +208,7 @@ declare function useSubscriptionExecutor<T = any>(options?: SubscriptionExecutor
208
208
  interface SubscriptionOptions extends SubscriptionExecutorOptions {
209
209
  enabled?: boolean;
210
210
  }
211
- declare function useSubscription<S extends ShapeNode = any>(query: string, params?: any, shape?: S, options?: SubscriptionOptions): {
211
+ declare function useSubscription<S extends ShapeNode = any>(rql: string, params?: any, shape?: S, options?: SubscriptionOptions): {
212
212
  data: InferShape<S>[];
213
213
  changes: ChangeEvent<InferShape<S>>[];
214
214
  is_subscribed: boolean;
package/dist/index.js CHANGED
@@ -229,10 +229,10 @@ function useQueryExecutor(options) {
229
229
  const execution_id_ref = useRef2(0);
230
230
  const pending_ref = useRef2(null);
231
231
  const query = useCallback(
232
- (statements, params, shapes) => {
232
+ (rql, params, shapes) => {
233
233
  const current_client = client_ref.current;
234
234
  if (!current_client) {
235
- pending_ref.current = { statements, params, shapes };
235
+ pending_ref.current = { rql, params, shapes };
236
236
  setState((prev) => ({ ...prev, is_executing: true, error: void 0 }));
237
237
  return Promise.resolve();
238
238
  }
@@ -242,7 +242,7 @@ function useQueryExecutor(options) {
242
242
  const start_time = Date.now();
243
243
  return (async () => {
244
244
  try {
245
- const frame_results = await current_client.query(statements, params || null, shapes || []) || [];
245
+ const frame_results = await current_client.query(rql, params || null, shapes || []) || [];
246
246
  if (execution_id_ref.current !== this_execution) return;
247
247
  const execution_time = Date.now() - start_time;
248
248
  const results = frame_results.map((frame) => {
@@ -313,8 +313,8 @@ function useQueryExecutor(options) {
313
313
  );
314
314
  useEffect3(() => {
315
315
  if (client && pending_ref.current) {
316
- const { statements, params, shapes } = pending_ref.current;
317
- query(statements, params, shapes);
316
+ const { rql, params, shapes } = pending_ref.current;
317
+ query(rql, params, shapes);
318
318
  }
319
319
  }, [client, query]);
320
320
  const cancel_query = useCallback(() => {
@@ -353,7 +353,7 @@ function useQueryOne(rql, params, shape, options) {
353
353
  }, [results]);
354
354
  return { is_executing, result, error };
355
355
  }
356
- function useQueryMany(statements, params, shapes, options) {
356
+ function useQueryMany(rql, params, shapes, options) {
357
357
  const {
358
358
  is_executing,
359
359
  results,
@@ -361,8 +361,8 @@ function useQueryMany(statements, params, shapes, options) {
361
361
  query
362
362
  } = useQueryExecutor(options);
363
363
  useEffect4(() => {
364
- query(statements, params, shapes);
365
- }, [statements, params, query]);
364
+ query(rql, params, shapes);
365
+ }, [rql, params, query]);
366
366
  return { is_executing, results, error };
367
367
  }
368
368
 
@@ -388,10 +388,10 @@ function useCommandExecutor(options) {
388
388
  const execution_id_ref = useRef3(0);
389
389
  const pending_ref = useRef3(null);
390
390
  const command = useCallback2(
391
- (statements, params, shapes) => {
391
+ (rql, params, shapes) => {
392
392
  const current_client = client_ref.current;
393
393
  if (!current_client) {
394
- pending_ref.current = { statements, params, shapes };
394
+ pending_ref.current = { rql, params, shapes };
395
395
  setState((prev) => ({ ...prev, is_executing: true, error: void 0 }));
396
396
  return Promise.resolve();
397
397
  }
@@ -401,7 +401,7 @@ function useCommandExecutor(options) {
401
401
  const start_time = Date.now();
402
402
  return (async () => {
403
403
  try {
404
- const frame_results = await current_client.command(statements, params || null, shapes || []) || [];
404
+ const frame_results = await current_client.command(rql, params || null, shapes || []) || [];
405
405
  if (execution_id_ref.current !== this_execution) return;
406
406
  const execution_time = Date.now() - start_time;
407
407
  const results = frame_results.map((frame) => {
@@ -473,8 +473,8 @@ function useCommandExecutor(options) {
473
473
  );
474
474
  useEffect5(() => {
475
475
  if (client && pending_ref.current) {
476
- const { statements, params, shapes } = pending_ref.current;
477
- command(statements, params, shapes);
476
+ const { rql, params, shapes } = pending_ref.current;
477
+ command(rql, params, shapes);
478
478
  }
479
479
  }, [client, command]);
480
480
  const cancel_command = useCallback2(() => {
@@ -497,7 +497,7 @@ function useCommandExecutor(options) {
497
497
 
498
498
  // src/hooks/use-command.ts
499
499
  import { useEffect as useEffect6, useMemo as useMemo2 } from "react";
500
- function useCommandOne(statement, params, shape, options) {
500
+ function useCommandOne(rql, params, shape, options) {
501
501
  const {
502
502
  is_executing,
503
503
  results,
@@ -506,14 +506,14 @@ function useCommandOne(statement, params, shape, options) {
506
506
  } = useCommandExecutor(options);
507
507
  useEffect6(() => {
508
508
  const shapes = shape ? [shape] : void 0;
509
- command(statement, params, shapes);
510
- }, [statement, params, command]);
509
+ command(rql, params, shapes);
510
+ }, [rql, params, command]);
511
511
  const result = useMemo2(() => {
512
512
  return results && results.length > 0 ? results[0] : void 0;
513
513
  }, [results]);
514
514
  return { is_executing, result, error };
515
515
  }
516
- function useCommandMany(statements, params, shapes, options) {
516
+ function useCommandMany(rql, params, shapes, options) {
517
517
  const {
518
518
  is_executing,
519
519
  results,
@@ -521,8 +521,8 @@ function useCommandMany(statements, params, shapes, options) {
521
521
  command
522
522
  } = useCommandExecutor(options);
523
523
  useEffect6(() => {
524
- command(statements, params, shapes);
525
- }, [statements, params, command]);
524
+ command(rql, params, shapes);
525
+ }, [rql, params, command]);
526
526
  return { is_executing, results, error };
527
527
  }
528
528
 
@@ -548,10 +548,10 @@ function useAdminExecutor(options) {
548
548
  const execution_id_ref = useRef4(0);
549
549
  const pending_ref = useRef4(null);
550
550
  const admin = useCallback3(
551
- (statements, params, shapes) => {
551
+ (rql, params, shapes) => {
552
552
  const current_client = client_ref.current;
553
553
  if (!current_client) {
554
- pending_ref.current = { statements, params, shapes };
554
+ pending_ref.current = { rql, params, shapes };
555
555
  setState((prev) => ({ ...prev, is_executing: true, error: void 0 }));
556
556
  return Promise.resolve();
557
557
  }
@@ -561,7 +561,7 @@ function useAdminExecutor(options) {
561
561
  const start_time = Date.now();
562
562
  return (async () => {
563
563
  try {
564
- const frame_results = await current_client.admin(statements, params || null, shapes || []) || [];
564
+ const frame_results = await current_client.admin(rql, params || null, shapes || []) || [];
565
565
  if (execution_id_ref.current !== this_execution) return;
566
566
  const execution_time = Date.now() - start_time;
567
567
  const results = frame_results.map((frame) => {
@@ -634,8 +634,8 @@ function useAdminExecutor(options) {
634
634
  );
635
635
  useEffect7(() => {
636
636
  if (client && pending_ref.current) {
637
- const { statements, params, shapes } = pending_ref.current;
638
- admin(statements, params, shapes);
637
+ const { rql, params, shapes } = pending_ref.current;
638
+ admin(rql, params, shapes);
639
639
  }
640
640
  }, [client, admin]);
641
641
  const cancel_admin = useCallback3(() => {
@@ -658,7 +658,7 @@ function useAdminExecutor(options) {
658
658
 
659
659
  // src/hooks/use-admin.ts
660
660
  import { useEffect as useEffect8, useMemo as useMemo3 } from "react";
661
- function useAdminOne(statement, params, shape, options) {
661
+ function useAdminOne(rql, params, shape, options) {
662
662
  const {
663
663
  is_executing,
664
664
  results,
@@ -667,14 +667,14 @@ function useAdminOne(statement, params, shape, options) {
667
667
  } = useAdminExecutor(options);
668
668
  useEffect8(() => {
669
669
  const shapes = shape ? [shape] : void 0;
670
- admin(statement, params, shapes);
671
- }, [statement, params, admin]);
670
+ admin(rql, params, shapes);
671
+ }, [rql, params, admin]);
672
672
  const result = useMemo3(() => {
673
673
  return results && results.length > 0 ? results[0] : void 0;
674
674
  }, [results]);
675
675
  return { is_executing, result, error };
676
676
  }
677
- function useAdminMany(statements, params, shapes, options) {
677
+ function useAdminMany(rql, params, shapes, options) {
678
678
  const {
679
679
  is_executing,
680
680
  results,
@@ -682,8 +682,8 @@ function useAdminMany(statements, params, shapes, options) {
682
682
  admin
683
683
  } = useAdminExecutor(options);
684
684
  useEffect8(() => {
685
- admin(statements, params, shapes);
686
- }, [statements, params, admin]);
685
+ admin(rql, params, shapes);
686
+ }, [rql, params, admin]);
687
687
  return { is_executing, results, error };
688
688
  }
689
689
 
@@ -701,7 +701,7 @@ function useSubscriptionExecutor(options) {
701
701
  });
702
702
  const client_ref = useRef5(client);
703
703
  const subscriptionIdRef = useRef5(void 0);
704
- const query_ref = useRef5(void 0);
704
+ const rql_ref = useRef5(void 0);
705
705
  const params_ref = useRef5(void 0);
706
706
  const shape_ref = useRef5(void 0);
707
707
  useEffect9(() => {
@@ -731,7 +731,7 @@ function useSubscriptionExecutor(options) {
731
731
  const handle_remove = useCallback4((rows) => {
732
732
  add_change_event("REMOVE", rows);
733
733
  }, [add_change_event]);
734
- const subscribe = useCallback4(async (query, params, shape) => {
734
+ const subscribe = useCallback4(async (rql, params, shape) => {
735
735
  const current_client = client_ref.current;
736
736
  if (!current_client) {
737
737
  setState((prev) => ({ ...prev, error: "Client not connected" }));
@@ -741,7 +741,7 @@ function useSubscriptionExecutor(options) {
741
741
  setState((prev) => ({ ...prev, error: "Subscriptions require a WebSocket connection" }));
742
742
  return;
743
743
  }
744
- query_ref.current = query;
744
+ rql_ref.current = rql;
745
745
  params_ref.current = params;
746
746
  shape_ref.current = shape;
747
747
  setState((prev) => ({
@@ -750,7 +750,7 @@ function useSubscriptionExecutor(options) {
750
750
  error: void 0
751
751
  }));
752
752
  try {
753
- const sub_id = await current_client.subscribe(query, params, shape, {
753
+ const sub_id = await current_client.subscribe(rql, params, shape, {
754
754
  on_insert: handle_insert,
755
755
  on_update: handle_update,
756
756
  on_remove: handle_remove
@@ -777,7 +777,7 @@ function useSubscriptionExecutor(options) {
777
777
  try {
778
778
  await current_client.unsubscribe(subscriptionIdRef.current);
779
779
  subscriptionIdRef.current = void 0;
780
- query_ref.current = void 0;
780
+ rql_ref.current = void 0;
781
781
  params_ref.current = void 0;
782
782
  shape_ref.current = void 0;
783
783
  setState((prev) => ({
@@ -816,7 +816,7 @@ function useSubscriptionExecutor(options) {
816
816
 
817
817
  // src/hooks/use-subscription.ts
818
818
  import { useEffect as useEffect10, useMemo as useMemo4 } from "react";
819
- function useSubscription(query, params, shape, options) {
819
+ function useSubscription(rql, params, shape, options) {
820
820
  const {
821
821
  state,
822
822
  subscribe,
@@ -825,11 +825,11 @@ function useSubscription(query, params, shape, options) {
825
825
  const params_key = useMemo4(() => JSON.stringify(params), [params]);
826
826
  useEffect10(() => {
827
827
  if (options?.enabled === false) return;
828
- subscribe(query, params, shape);
828
+ subscribe(rql, params, shape);
829
829
  return () => {
830
830
  unsubscribe();
831
831
  };
832
- }, [query, params_key, shape, options?.enabled, subscribe, unsubscribe]);
832
+ }, [rql, params_key, shape, options?.enabled, subscribe, unsubscribe]);
833
833
  return {
834
834
  data: state.data,
835
835
  changes: state.changes,
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","../src/hooks/use-admin-executor.ts","../src/hooks/use-admin.ts","../src/hooks/use-subscription-executor.ts","../src/hooks/use-subscription.ts","../src/hooks/use-shape.ts"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nexport * from '@reifydb/core';\nexport * from '@reifydb/client';\n\n// Export connection utilities\nexport {Connection, type ConnectionConfig, DEFAULT_CONFIG, DEFAULT_URL} from './connection/connection';\nexport {get_connection, clear_connection} 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 {useAdminExecutor, type AdminResult, type AdminState, type AdminExecutorOptions} from './hooks/use-admin-executor';\nexport {useAdminOne, useAdminMany, type AdminOptions} from './hooks/use-admin';\nexport {\n useSubscriptionExecutor,\n type SubscriptionExecutorOptions,\n type SubscriptionState,\n type ChangeEvent\n} from './hooks/use-subscription-executor';\nexport {\n useSubscription,\n type SubscriptionOptions\n} from './hooks/use-subscription';\nexport {useShape, type TableInfo, type ColumnInfo} from './hooks/use-shape';","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport {Client, WsClient, HttpClient, JsonHttpClient, JsonWebsocketClient, type WsClientOptions} from '@reifydb/client';\n\ninterface ConnectionState {\n client: WsClient | HttpClient | JsonHttpClient | JsonWebsocketClient | null;\n is_connected: boolean;\n is_connecting: boolean;\n connection_error: string | null;\n listeners: Set<(state: ConnectionState) => void>;\n}\n\nexport interface ConnectionConfig {\n url?: string;\n token?: string;\n format?: 'json';\n options?: Omit<WsClientOptions, 'url' | 'token'>;\n}\n\nexport const DEFAULT_CONFIG: ConnectionConfig = {\n url: 'ws://127.0.0.1:8090',\n options: {timeout_ms: 30_000},\n};\n\nexport const DEFAULT_URL = 'ws://127.0.0.1:8090';\n\nexport class Connection {\n private state: ConnectionState = {\n client: null,\n is_connected: false,\n is_connecting: false,\n connection_error: null,\n listeners: new Set(),\n };\n private config: ConnectionConfig;\n private connect_promise: Promise<void> | null = null;\n\n constructor(config: ConnectionConfig = DEFAULT_CONFIG) {\n this.config = {...DEFAULT_CONFIG, ...config};\n }\n\n set_config(config: ConnectionConfig): void {\n this.config = config;\n }\n\n get_config(): ConnectionConfig {\n return this.config;\n }\n\n async connect(url?: string, options?: Omit<WsClientOptions, 'url'>): Promise<void> {\n if (this.state.is_connected) {\n return;\n }\n\n // If already connecting, wait for the in-flight connection\n if (this.connect_promise) {\n return this.connect_promise;\n }\n\n const connect_url = url || this.config.url || DEFAULT_CONFIG.url!;\n const connect_options = {token: this.config.token, ...this.config.options, ...options};\n\n this.update_state({\n is_connecting: true,\n connection_error: null,\n });\n\n this.connect_promise = (async () => {\n try {\n const isHttp = connect_url.startsWith('http://') || connect_url.startsWith('https://');\n const isJson = this.config.format === 'json';\n let client: WsClient | HttpClient | JsonHttpClient | JsonWebsocketClient;\n if (isHttp) {\n client = isJson\n ? Client.connect_json_http(connect_url, connect_options)\n : Client.connect_http(connect_url, connect_options);\n } else {\n client = isJson\n ? await Client.connect_json_ws(connect_url, connect_options)\n : await Client.connect_ws(connect_url, connect_options);\n }\n this.update_state({\n client,\n is_connected: true,\n is_connecting: false,\n connection_error: null,\n });\n } catch (err) {\n const error_message = err instanceof Error ? err.message : 'Failed to connect to ReifyDB';\n console.error('[Connection] Connection failed:', error_message, err);\n this.update_state({\n client: null,\n is_connected: false,\n is_connecting: false,\n connection_error: error_message,\n });\n throw err;\n } finally {\n this.connect_promise = null;\n }\n })();\n\n return this.connect_promise;\n }\n\n async disconnect(): Promise<void> {\n this.connect_promise = null;\n if (this.state.client) {\n try {\n if ('disconnect' in this.state.client) {\n (this.state.client as WsClient).disconnect();\n // Small delay to ensure WebSocket closes cleanly\n await new Promise(resolve => setTimeout(resolve, 10));\n }\n } catch (err) {\n console.error('Error disconnecting:', err);\n }\n }\n\n this.update_state({\n client: null,\n is_connected: false,\n is_connecting: false,\n connection_error: 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 get_client(): WsClient | HttpClient | JsonHttpClient | JsonWebsocketClient | null {\n return this.state.client;\n }\n\n is_connected(): boolean {\n return this.state.is_connected;\n }\n\n is_connecting(): boolean {\n return this.state.is_connecting;\n }\n\n get_connection_error(): string | null {\n return this.state.connection_error;\n }\n\n get_state(): 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 update_state(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","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport { 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 default_connection: 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 set_config().\n * @param config - Optional connection configuration\n * @returns The singleton Connection instance\n */\nexport function get_connection(config?: ConnectionConfig): Connection {\n // Create singleton on first call\n if (!default_connection) {\n const merged_config = {...DEFAULT_CONFIG, ...config};\n default_connection = new Connection(merged_config);\n // Start connection immediately - don't wait for React's useEffect\n default_connection.connect().catch(err => {\n console.error('[ConnectionPool] Eager connect failed:', err);\n });\n } else if (config) {\n // Only update config when explicitly provided, to avoid\n // stripping fields (e.g. token) that were set on creation.\n default_connection.set_config({...DEFAULT_CONFIG, ...config});\n }\n\n return default_connection;\n}\n\n/**\n * Clear the singleton connection\n */\nexport async function clear_connection(): Promise<void> {\n if (default_connection) {\n await default_connection.disconnect();\n default_connection = null;\n }\n}","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport React, { createContext, useEffect, useRef, ReactNode } from 'react';\nimport { Connection, ConnectionConfig } from './connection';\nimport { get_connection } 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 set_config()\n const connection = get_connection(config);\n\n // Track previous config to detect changes\n const prev_config_ref = useRef<string | undefined>(undefined);\n const current_config_str = JSON.stringify(config);\n\n useEffect(() => {\n const config_changed = prev_config_ref.current !== undefined &&\n prev_config_ref.current !== current_config_str;\n\n if (config_changed && connection.is_connected()) {\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.is_connected() && !connection.is_connecting()) {\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 prev_config_ref.current = current_config_str;\n }, [current_config_str, connection]);\n\n return (\n <ConnectionContext.Provider value={connection}>\n {children}\n </ConnectionContext.Provider>\n );\n}","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport {useContext, useEffect, useState} from 'react';\nimport {ConnectionConfig} from '../connection/connection';\nimport {get_connection} from '../connection/connection-pool';\nimport {ConnectionContext} from '../connection/connection-context';\nimport {WsClient, HttpClient, JsonHttpClient, JsonWebsocketClient} from '@reifydb/client';\n\ninterface ConnectionState {\n client: WsClient | HttpClient | JsonHttpClient | JsonWebsocketClient | null;\n is_connected: boolean;\n is_connecting: boolean;\n connection_error: string | null;\n}\n\nexport function useConnection(override_config?: ConnectionConfig) {\n const context_connection = useContext(ConnectionContext);\n\n // Use override config if provided, otherwise use context, otherwise get default\n const [connection] = useState(() => {\n if (override_config) {\n return get_connection(override_config);\n }\n if (context_connection) {\n return context_connection;\n }\n return get_connection();\n });\n\n const [state, setState] = useState<ConnectionState>(() => connection.get_state());\n\n useEffect(() => {\n // Get initial state immediately\n const current_state = connection.get_state();\n setState(current_state);\n\n // Subscribe to connection state changes\n const unsubscribe = connection.subscribe((new_state) => {\n setState({\n client: new_state.client,\n is_connected: new_state.is_connected,\n is_connecting: new_state.is_connecting,\n connection_error: new_state.connection_error,\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}","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport {useState, useCallback, useRef, useEffect} from 'react';\nimport {Column, ShapeNode} 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 execution_time_ms: number;\n rows_affected?: number;\n}\n\nexport interface QueryState<T = any> {\n is_executing: boolean;\n results: QueryResult<T>[] | undefined;\n error: string | undefined;\n execution_time: number | undefined;\n}\n\nexport interface QueryExecutorOptions {\n connection_config?: ConnectionConfig;\n}\n\nexport function useQueryExecutor<T = any>(options?: QueryExecutorOptions) {\n const {client} = useConnection(options?.connection_config);\n\n const [state, setState] = useState<QueryState<T>>({\n is_executing: false,\n results: undefined,\n error: undefined,\n execution_time: undefined,\n });\n\n const client_ref = useRef(client);\n client_ref.current = client;\n\n const is_mounted_ref = useRef(true);\n useEffect(() => {\n return () => { is_mounted_ref.current = false; };\n }, []);\n\n const execution_id_ref = useRef(0);\n const pending_ref = useRef<{statements: string | string[], params?: any, shapes?: readonly ShapeNode[]} | null>(null);\n\n const query = useCallback(\n (statements: string | string[], params?: any, shapes?: readonly ShapeNode[]): Promise<void> => {\n const current_client = client_ref.current;\n\n if (!current_client) {\n pending_ref.current = {statements, params, shapes};\n setState(prev => ({...prev, is_executing: true, error: undefined}));\n return Promise.resolve();\n }\n\n pending_ref.current = null;\n const this_execution = ++execution_id_ref.current;\n\n setState(prev => ({...prev, is_executing: true, error: undefined}));\n\n const start_time = Date.now();\n\n return (async () => {\n try {\n const frame_results = await current_client.query(statements, params || null, shapes || []) || [];\n\n if (execution_id_ref.current !== this_execution) return;\n\n const execution_time = Date.now() - start_time;\n\n const results: QueryResult<T>[] = frame_results.map((frame: any) => {\n if (Array.isArray(frame) && frame.length > 0) {\n const first_row = frame[0];\n let columns: Column[] = [];\n\n const has_value_objects = first_row && typeof first_row === 'object' &&\n Object.values(first_row).some(v => v && typeof v === 'object' && 'type' in v);\n\n if (has_value_objects) {\n columns = Object.keys(first_row).map((key) => {\n const value = first_row[key];\n const data_type = value?.type || 'Utf8';\n return {\n name: key,\n type: data_type,\n payload: [],\n };\n });\n } else {\n columns = Object.keys(first_row).map((key) => ({\n name: key,\n type: 'Utf8',\n payload: [],\n }));\n }\n\n return {\n columns,\n rows: frame as T[],\n execution_time_ms: execution_time,\n };\n } else {\n return {\n columns: [],\n rows: [],\n execution_time_ms: execution_time,\n };\n }\n });\n\n if (!is_mounted_ref.current) return;\n setState({\n is_executing: false,\n results,\n error: undefined,\n execution_time,\n });\n } catch (err) {\n if (execution_id_ref.current !== this_execution) return;\n\n const execution_time = Date.now() - start_time;\n let error_message = 'Query execution failed';\n\n if (err instanceof Error) {\n error_message = err.message;\n } else if (typeof err === 'string') {\n error_message = err;\n } else if (err && typeof err === 'object' && 'message' in err) {\n error_message = (err as { message: string }).message;\n }\n\n console.error('Query execution failed:', error_message);\n\n if (!is_mounted_ref.current) return;\n setState(prev => ({\n ...prev,\n is_executing: false,\n error: error_message,\n execution_time,\n }));\n\n }\n })();\n },\n []\n );\n\n useEffect(() => {\n if (client && pending_ref.current) {\n const {statements, params, shapes} = pending_ref.current;\n query(statements, params, shapes);\n }\n }, [client, query]);\n\n const cancel_query = useCallback(() => {\n execution_id_ref.current++;\n setState((prev) => ({\n ...prev,\n is_executing: false,\n error: 'Query cancelled',\n }));\n }, []);\n\n return {\n is_executing: state.is_executing,\n results: state.results,\n error: state.error,\n execution_time: state.execution_time,\n query,\n cancel_query,\n };\n}\n","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport {useEffect, useMemo} from 'react';\nimport {ShapeNode, InferShape} 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 connection_config?: ConnectionConfig;\n}\n\n// Single query hook - returns a single result\nexport function useQueryOne<S extends ShapeNode = any>(\n rql: string,\n params?: any,\n shape?: S,\n options?: QueryOptions\n): {\n is_executing: boolean;\n result: QueryResult<S extends ShapeNode ? InferShape<S> : any> | undefined;\n error: string | undefined;\n} {\n const {\n is_executing,\n results,\n error,\n query\n } = useQueryExecutor<S extends ShapeNode ? InferShape<S> : any>(options);\n\n useEffect(() => {\n // Pass shape as array for the executor\n const shapes = shape ? [shape] : undefined;\n query(rql, params, shapes);\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 {is_executing, result, error};\n}\n\n// Multiple query hook - returns multiple results\nexport function useQueryMany<S extends readonly ShapeNode[] = readonly ShapeNode[]>(\n statements: string | string[],\n params?: any,\n shapes?: S,\n options?: QueryOptions\n): {\n is_executing: boolean;\n results: QueryResult<S extends readonly ShapeNode[] ? InferShape<S[number]> : any>[] | undefined;\n error: string | undefined;\n} {\n const {\n is_executing,\n results,\n error,\n query\n } = useQueryExecutor<S extends readonly ShapeNode[] ? InferShape<S[number]> : any>(options);\n\n useEffect(() => {\n query(statements, params, shapes);\n }, [statements, params, query]);\n\n return {is_executing, results, error};\n}","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport {useState, useCallback, useRef, useEffect} from 'react';\nimport {Column, ShapeNode} 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 execution_time_ms: number;\n rows_affected?: number;\n}\n\nexport interface CommandState<T = any> {\n is_executing: boolean;\n results: CommandResult<T>[] | undefined;\n error: string | undefined;\n execution_time: number | undefined;\n}\n\nexport interface CommandExecutorOptions {\n connection_config?: ConnectionConfig;\n}\n\nexport function useCommandExecutor<T = any>(options?: CommandExecutorOptions) {\n const {client} = useConnection(options?.connection_config);\n\n const [state, setState] = useState<CommandState<T>>({\n is_executing: false,\n results: undefined,\n error: undefined,\n execution_time: undefined,\n });\n\n const client_ref = useRef(client);\n client_ref.current = client;\n\n const is_mounted_ref = useRef(false);\n useEffect(() => {\n is_mounted_ref.current = true;\n return () => { is_mounted_ref.current = false; };\n }, []);\n\n const execution_id_ref = useRef(0);\n const pending_ref = useRef<{statements: string | string[], params?: any, shapes?: readonly ShapeNode[]} | null>(null);\n\n const command = useCallback(\n (statements: string | string[], params?: any, shapes?: readonly ShapeNode[]): Promise<void> => {\n const current_client = client_ref.current;\n\n if (!current_client) {\n pending_ref.current = {statements, params, shapes};\n setState(prev => ({...prev, is_executing: true, error: undefined}));\n return Promise.resolve();\n }\n\n pending_ref.current = null;\n const this_execution = ++execution_id_ref.current;\n\n setState(prev => ({...prev, is_executing: true, error: undefined}));\n\n const start_time = Date.now();\n\n return (async () => {\n try {\n const frame_results = await current_client.command(statements, params || null, shapes || []) || [];\n\n if (execution_id_ref.current !== this_execution) return;\n\n const execution_time = Date.now() - start_time;\n\n const results: CommandResult<T>[] = frame_results.map((frame: any) => {\n if (Array.isArray(frame) && frame.length > 0) {\n const first_row = frame[0];\n let columns: Column[] = [];\n\n const has_value_objects = first_row && typeof first_row === 'object' &&\n Object.values(first_row).some(v => v && typeof v === 'object' && 'type' in v);\n\n if (has_value_objects) {\n columns = Object.keys(first_row).map((key) => {\n const value = first_row[key];\n const data_type = value?.type || 'Utf8';\n return {\n name: key,\n type: data_type,\n payload: [],\n };\n });\n } else {\n columns = Object.keys(first_row).map((key) => ({\n name: key,\n type: 'Utf8',\n payload: [],\n }));\n }\n\n return {\n columns,\n rows: frame as T[],\n execution_time_ms: execution_time,\n };\n } else {\n return {\n columns: [],\n rows: [],\n execution_time_ms: execution_time,\n rows_affected: typeof frame === 'number' ? frame : undefined,\n };\n }\n });\n\n if (!is_mounted_ref.current) return;\n setState({\n is_executing: false,\n results,\n error: undefined,\n execution_time,\n });\n } catch (err) {\n if (execution_id_ref.current !== this_execution) return;\n\n const execution_time = Date.now() - start_time;\n let error_message = 'Command execution failed';\n\n if (err instanceof Error) {\n error_message = err.message;\n } else if (typeof err === 'string') {\n error_message = err;\n } else if (err && typeof err === 'object' && 'message' in err) {\n error_message = (err as { message: string }).message;\n }\n\n console.error('Command execution failed:', error_message);\n\n if (!is_mounted_ref.current) return;\n setState(prev => ({\n ...prev,\n is_executing: false,\n error: error_message,\n execution_time,\n }));\n\n }\n })();\n },\n []\n );\n\n useEffect(() => {\n if (client && pending_ref.current) {\n const {statements, params, shapes} = pending_ref.current;\n command(statements, params, shapes);\n }\n }, [client, command]);\n\n const cancel_command = useCallback(() => {\n execution_id_ref.current++;\n setState((prev) => ({\n ...prev,\n is_executing: false,\n error: 'Command cancelled',\n }));\n }, []);\n\n return {\n is_executing: state.is_executing,\n results: state.results,\n error: state.error,\n execution_time: state.execution_time,\n command,\n cancel_command,\n };\n}\n","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport {useEffect, useMemo} from 'react';\nimport {ShapeNode, InferShape} 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 connection_config?: ConnectionConfig;\n}\n\n// Single command hook - returns a single result\nexport function useCommandOne<S extends ShapeNode = any>(\n statement: string,\n params?: any,\n shape?: S,\n options?: CommandOptions\n): {\n is_executing: boolean;\n result: CommandResult<S extends ShapeNode ? InferShape<S> : any> | undefined;\n error: string | undefined;\n} {\n const {\n is_executing,\n results,\n error,\n command\n } = useCommandExecutor<S extends ShapeNode ? InferShape<S> : any>(options);\n\n useEffect(() => {\n // Pass shape as array for the executor\n const shapes = shape ? [shape] : undefined;\n command(statement, params, shapes);\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 {is_executing, result, error};\n}\n\n// Multiple command hook - returns multiple results\nexport function useCommandMany<S extends readonly ShapeNode[] = readonly ShapeNode[]>(\n statements: string | string[],\n params?: any,\n shapes?: S,\n options?: CommandOptions\n): {\n is_executing: boolean;\n results: CommandResult<S extends readonly ShapeNode[] ? InferShape<S[number]> : any>[] | undefined;\n error: string | undefined;\n} {\n const {\n is_executing,\n results,\n error,\n command\n } = useCommandExecutor<S extends readonly ShapeNode[] ? InferShape<S[number]> : any>(options);\n\n useEffect(() => {\n command(statements, params, shapes);\n }, [statements, params, command]);\n\n return {is_executing, results, error};\n}","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport {useState, useCallback, useRef, useEffect} from 'react';\nimport {Column, ShapeNode} from '@reifydb/core';\nimport {ConnectionConfig} from '../connection/connection';\nimport {useConnection} from './use-connection';\n\nexport interface AdminResult<T = any> {\n columns: Column[];\n rows: T[];\n execution_time_ms: number;\n rows_affected?: number;\n}\n\nexport interface AdminState<T = any> {\n is_executing: boolean;\n results: AdminResult<T>[] | undefined;\n error: string | undefined;\n execution_time: number | undefined;\n}\n\nexport interface AdminExecutorOptions {\n connection_config?: ConnectionConfig;\n}\n\nexport function useAdminExecutor<T = any>(options?: AdminExecutorOptions) {\n const {client} = useConnection(options?.connection_config);\n\n const [state, setState] = useState<AdminState<T>>({\n is_executing: false,\n results: undefined,\n error: undefined,\n execution_time: undefined,\n });\n\n // Stable refs so the callback never recreates\n const client_ref = useRef(client);\n client_ref.current = client;\n\n const is_mounted_ref = useRef(false);\n useEffect(() => {\n is_mounted_ref.current = true;\n return () => { is_mounted_ref.current = false; };\n }, []);\n\n // Counter to detect superseded executions\n const execution_id_ref = useRef(0);\n\n // Stash pending call if client isn't ready yet\n const pending_ref = useRef<{statements: string | string[], params?: any, shapes?: readonly ShapeNode[]} | null>(null);\n\n const admin = useCallback(\n (statements: string | string[], params?: any, shapes?: readonly ShapeNode[]): Promise<void> => {\n const current_client = client_ref.current;\n // If no client yet, stash the request for replay when client connects\n if (!current_client) {\n pending_ref.current = {statements, params, shapes};\n setState(prev => ({...prev, is_executing: true, error: undefined}));\n return Promise.resolve();\n }\n\n pending_ref.current = null;\n const this_execution = ++execution_id_ref.current;\n\n setState(prev => ({...prev, is_executing: true, error: undefined}));\n\n const start_time = Date.now();\n\n return (async () => {\n try {\n const frame_results = await current_client.admin(statements, params || null, shapes || []) || [];\n\n // If this execution was superseded by a newer one, discard results\n if (execution_id_ref.current !== this_execution) return;\n\n const execution_time = Date.now() - start_time;\n\n // Process each frame into a AdminResult\n const results: AdminResult<T>[] = frame_results.map((frame: any) => {\n if (Array.isArray(frame) && frame.length > 0) {\n const first_row = frame[0];\n let columns: Column[] = [];\n\n // Check if we have Value objects or plain objects\n const has_value_objects = first_row && typeof first_row === 'object' &&\n Object.values(first_row).some(v => v && typeof v === 'object' && 'type' in v);\n\n if (has_value_objects) {\n columns = Object.keys(first_row).map((key) => {\n const value = first_row[key];\n const data_type = value?.type || 'Utf8';\n return {\n name: key,\n type: data_type,\n payload: [],\n };\n });\n } else {\n columns = Object.keys(first_row).map((key) => ({\n name: key,\n type: 'Utf8',\n payload: [],\n }));\n }\n\n return {\n columns,\n rows: frame as T[],\n execution_time_ms: execution_time,\n };\n } else {\n return {\n columns: [],\n rows: [],\n execution_time_ms: execution_time,\n rows_affected: typeof frame === 'number' ? frame : undefined,\n };\n }\n });\n\n if (!is_mounted_ref.current) return;\n setState({\n is_executing: false,\n results,\n error: undefined,\n execution_time,\n });\n } catch (err) {\n if (execution_id_ref.current !== this_execution) return;\n\n const execution_time = Date.now() - start_time;\n let error_message = 'Admin execution failed';\n\n if (err instanceof Error) {\n error_message = err.message;\n } else if (typeof err === 'string') {\n error_message = err;\n } else if (err && typeof err === 'object' && 'message' in err) {\n error_message = (err as { message: string }).message;\n }\n\n console.error('Admin execution failed:', error_message);\n\n if (!is_mounted_ref.current) return;\n setState(prev => ({\n ...prev,\n is_executing: false,\n error: error_message,\n execution_time,\n }));\n\n }\n })();\n },\n [] // stable — never recreates\n );\n\n // Replay pending request when client becomes available\n useEffect(() => {\n if (client && pending_ref.current) {\n const {statements, params, shapes} = pending_ref.current;\n admin(statements, params, shapes);\n }\n }, [client, admin]);\n\n const cancel_admin = useCallback(() => {\n // Bump execution ID so any in-flight request is ignored on completion\n execution_id_ref.current++;\n setState((prev) => ({\n ...prev,\n is_executing: false,\n error: 'Admin cancelled',\n }));\n }, []);\n\n return {\n is_executing: state.is_executing,\n results: state.results,\n error: state.error,\n execution_time: state.execution_time,\n admin,\n cancel_admin,\n };\n}\n","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport {useEffect, useMemo} from 'react';\nimport {ShapeNode, InferShape} from '@reifydb/core';\nimport {ConnectionConfig} from '../connection/connection';\nimport {useAdminExecutor, type AdminResult, type AdminExecutorOptions} from './use-admin-executor';\n\nexport interface AdminOptions extends AdminExecutorOptions {\n connection_config?: ConnectionConfig;\n}\n\n// Single admin hook - returns a single result\nexport function useAdminOne<S extends ShapeNode = any>(\n statement: string,\n params?: any,\n shape?: S,\n options?: AdminOptions\n): {\n is_executing: boolean;\n result: AdminResult<S extends ShapeNode ? InferShape<S> : any> | undefined;\n error: string | undefined;\n} {\n const {\n is_executing,\n results,\n error,\n admin\n } = useAdminExecutor<S extends ShapeNode ? InferShape<S> : any>(options);\n\n useEffect(() => {\n // Pass shape as array for the executor\n const shapes = shape ? [shape] : undefined;\n admin(statement, params, shapes);\n }, [statement, params, admin]);\n\n // Extract first result for single admin convenience\n const result = useMemo(() => {\n return results && results.length > 0 ? results[0] : undefined;\n }, [results]);\n\n return {is_executing, result, error};\n}\n\n// Multiple admin hook - returns multiple results\nexport function useAdminMany<S extends readonly ShapeNode[] = readonly ShapeNode[]>(\n statements: string | string[],\n params?: any,\n shapes?: S,\n options?: AdminOptions\n): {\n is_executing: boolean;\n results: AdminResult<S extends readonly ShapeNode[] ? InferShape<S[number]> : any>[] | undefined;\n error: string | undefined;\n} {\n const {\n is_executing,\n results,\n error,\n admin\n } = useAdminExecutor<S extends readonly ShapeNode[] ? InferShape<S[number]> : any>(options);\n\n useEffect(() => {\n admin(statements, params, shapes);\n }, [statements, params, admin]);\n\n return {is_executing, results, error};\n}\n","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport { useState, useCallback, useRef, useEffect } from 'react';\nimport { ShapeNode } from '@reifydb/core';\nimport { useConnection } from './use-connection';\nimport type { ConnectionConfig } from '../connection/connection';\n\nexport interface SubscriptionExecutorOptions {\n connection_config?: ConnectionConfig;\n}\n\nexport interface ChangeEvent<T> {\n operation: 'INSERT' | 'UPDATE' | 'REMOVE';\n rows: T[];\n timestamp: number;\n}\n\nexport interface SubscriptionState<T> {\n data: T[];\n changes: ChangeEvent<T>[];\n is_subscribed: boolean;\n is_subscribing: boolean;\n error: string | undefined;\n subscription_id: string | undefined;\n}\n\nexport function useSubscriptionExecutor<T = any>(\n options?: SubscriptionExecutorOptions\n) {\n const { client } = useConnection(options?.connection_config);\n\n const [state, setState] = useState<SubscriptionState<T>>({\n data: [],\n changes: [],\n is_subscribed: false,\n is_subscribing: false,\n error: undefined,\n subscription_id: undefined\n });\n\n // Use a ref for client to avoid recreating callbacks when client changes\n const client_ref = useRef(client);\n\n const subscriptionIdRef = useRef<string | undefined>(undefined);\n const query_ref = useRef<string | undefined>(undefined);\n const params_ref = useRef<any>(undefined);\n const shape_ref = useRef<ShapeNode | undefined>(undefined);\n\n // Keep client_ref in sync with client\n useEffect(() => {\n client_ref.current = client;\n }, [client]);\n\n // Helper to add change event\n const add_change_event = useCallback((\n operation: 'INSERT' | 'UPDATE' | 'REMOVE',\n rows: T[]\n ) => {\n setState(prev => {\n const new_change: ChangeEvent<T> = {\n operation,\n rows,\n timestamp: Date.now()\n };\n\n const new_changes = [...prev.changes, new_change];\n\n return {\n ...prev,\n data: prev.data,\n changes: new_changes\n };\n });\n }, []);\n\n // Separate callbacks for each operation type\n const handle_insert = useCallback((rows: T[]) => {\n add_change_event('INSERT', rows);\n }, [add_change_event]);\n\n const handle_update = useCallback((rows: T[]) => {\n add_change_event('UPDATE', rows);\n }, [add_change_event]);\n\n const handle_remove = useCallback((rows: T[]) => {\n add_change_event('REMOVE', rows);\n }, [add_change_event]);\n\n const subscribe = useCallback(async (\n query: string,\n params?: any,\n shape?: ShapeNode\n ) => {\n const current_client = client_ref.current;\n if (!current_client) {\n setState(prev => ({ ...prev, error: 'Client not connected' }));\n return;\n }\n\n if (!('subscribe' in current_client)) {\n setState(prev => ({ ...prev, error: 'Subscriptions require a WebSocket connection' }));\n return;\n }\n\n // Store refs for reconnection\n query_ref.current = query;\n params_ref.current = params;\n shape_ref.current = shape;\n\n setState(prev => ({\n ...prev,\n is_subscribing: true,\n error: undefined\n }));\n\n try {\n const sub_id = await current_client.subscribe(query, params, shape, {\n on_insert: handle_insert,\n on_update: handle_update,\n on_remove: handle_remove\n });\n\n subscriptionIdRef.current = sub_id;\n setState(prev => ({\n ...prev,\n is_subscribing: false,\n is_subscribed: true,\n subscription_id: sub_id\n }));\n } catch (err: any) {\n setState(prev => ({\n ...prev,\n is_subscribing: false,\n error: err.message || 'Subscription failed'\n }));\n }\n }, [handle_insert, handle_update, handle_remove]);\n\n const unsubscribe = useCallback(async () => {\n const current_client = client_ref.current;\n if (!current_client || !subscriptionIdRef.current) return;\n if (!('unsubscribe' in current_client)) return;\n\n try {\n await current_client.unsubscribe(subscriptionIdRef.current);\n subscriptionIdRef.current = undefined;\n query_ref.current = undefined;\n params_ref.current = undefined;\n shape_ref.current = undefined;\n\n setState(prev => ({\n ...prev,\n is_subscribed: false,\n subscription_id: undefined\n }));\n } catch (err: any) {\n setState(prev => ({\n ...prev,\n error: err.message || 'Unsubscribe failed'\n }));\n }\n }, []);\n\n const clear_changes = useCallback(() => {\n setState(prev => ({ ...prev, changes: [] }));\n }, []);\n\n const clear_data = useCallback(() => {\n setState(prev => ({ ...prev, data: [] }));\n }, []);\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n if (subscriptionIdRef.current && client_ref.current && 'unsubscribe' in client_ref.current) {\n client_ref.current.unsubscribe(subscriptionIdRef.current).catch(console.error);\n }\n };\n }, []);\n\n return {\n state,\n subscribe,\n unsubscribe,\n clear_changes,\n clear_data\n };\n}\n","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport { useEffect, useMemo } from 'react';\nimport { ShapeNode, InferShape } from '@reifydb/core';\nimport {\n useSubscriptionExecutor,\n type SubscriptionExecutorOptions,\n type ChangeEvent\n} from './use-subscription-executor';\n\nexport interface SubscriptionOptions extends SubscriptionExecutorOptions {\n enabled?: boolean; // Auto-subscribe (default: true)\n}\n\nexport function useSubscription<S extends ShapeNode = any>(\n query: string,\n params?: any,\n shape?: S,\n options?: SubscriptionOptions\n): {\n data: InferShape<S>[];\n changes: ChangeEvent<InferShape<S>>[];\n is_subscribed: boolean;\n is_subscribing: boolean;\n error: string | undefined;\n subscription_id: string | undefined;\n} {\n const {\n state,\n subscribe,\n unsubscribe\n } = useSubscriptionExecutor<InferShape<S>>(options);\n\n // Serialize params for stable comparison (objects create new refs each render)\n const params_key = useMemo(() => JSON.stringify(params), [params]);\n\n useEffect(() => {\n if (options?.enabled === false) return;\n\n subscribe(query, params, shape);\n\n return () => {\n unsubscribe();\n };\n }, [query, params_key, shape, options?.enabled, subscribe, unsubscribe]);\n\n return {\n data: state.data,\n changes: state.changes,\n is_subscribed: state.is_subscribed,\n is_subscribing: state.is_subscribing,\n error: state.error,\n subscription_id: state.subscription_id\n };\n}\n","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport {useEffect, useState} from 'react';\nimport {Shape, InferShape} from '@reifydb/core';\nimport {useQueryExecutor} from './use-query-executor';\n\nexport interface ColumnInfo {\n name: string;\n data_type: string;\n}\n\nexport interface TableInfo {\n name: string;\n columns: ColumnInfo[];\n}\n\nconst namespace_shape = Shape.object({\n id: Shape.number(),\n name: Shape.string(),\n});\n\nconst table_shape = Shape.object({\n id: Shape.number(),\n namespace_id: Shape.number(),\n name: Shape.string(),\n primary_key_id: Shape.number(),\n});\n\nconst view_shape = Shape.object({\n id: Shape.number(),\n namespace_id: Shape.number(),\n name: Shape.string(),\n});\n\nconst column_shape = Shape.object({\n id: Shape.number(),\n shape_id: Shape.number(),\n shape_type: Shape.number(),\n name: Shape.string(),\n type: Shape.number(),\n position: Shape.number(),\n auto_increment: Shape.boolean(),\n});\n\ntype NamespaceRow = InferShape<typeof namespace_shape>;\ntype TableRow = InferShape<typeof table_shape>;\ntype ViewRow = InferShape<typeof view_shape>;\ntype ColumnRow = InferShape<typeof column_shape>;\n\nexport function useShape(): [boolean, TableInfo[], string | undefined] {\n const {is_executing, results, error, query} = useQueryExecutor();\n const [shape, set_shape] = useState<TableInfo[]>([]);\n const [is_loading, set_is_loading] = useState(true);\n\n useEffect(() => {\n if (!query) return;\n\n const fetch_shape = async () => {\n set_is_loading(true);\n\n try {\n await query(\n `OUTPUT FROM system::namespaces; OUTPUT FROM system::tables; OUTPUT FROM system::views; OUTPUT FROM system::columns;`,\n undefined,\n [namespace_shape, table_shape, view_shape, column_shape]\n );\n } catch (err) {\n console.error('Failed to fetch shape:', err);\n }\n };\n\n fetch_shape();\n }, [query]);\n\n useEffect(() => {\n if (!results || results.length < 4) {\n set_is_loading(is_executing);\n return;\n }\n\n const tables_result = results[1];\n const views_result = results[2];\n const columns_result = results[3];\n\n if (!tables_result?.rows || !views_result?.rows || !columns_result?.rows) {\n set_is_loading(false);\n return;\n }\n\n const namespaces_result = results[0];\n const namespaces = namespaces_result.rows as unknown as NamespaceRow[];\n const tables = tables_result.rows as unknown as TableRow[];\n const views = views_result.rows as unknown as ViewRow[];\n const columns = columns_result.rows as unknown as ColumnRow[];\n\n const namespace_map = 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 namespace_map.set(id, name);\n }\n });\n\n const table_info_map = new Map<number, TableInfo>();\n\n tables.forEach((table) => {\n const table_id = table.id?.valueOf() as number;\n const namespace_id = table.namespace_id?.valueOf() as number;\n const table_name = table.name?.valueOf() as string;\n\n if (table_id === undefined || !table_name || namespace_id === undefined) return;\n\n const namespace = namespace_map.get(namespace_id);\n if (!namespace) return;\n\n const full_table_name = `${namespace}::${table_name}`;\n\n table_info_map.set(table_id, {\n name: full_table_name,\n columns: [],\n });\n });\n\n views.forEach((view) => {\n const view_id = view.id?.valueOf() as number;\n const namespace_id = view.namespace_id?.valueOf() as number;\n const view_name = view.name?.valueOf() as string;\n\n if (view_id === undefined || !view_name || namespace_id === undefined) return;\n\n const namespace = namespace_map.get(namespace_id);\n if (!namespace) return;\n\n const full_view_name = `${namespace}::${view_name}`;\n\n table_info_map.set(view_id, {\n name: full_view_name,\n columns: [],\n });\n });\n\n const type_map: Record<number, string> = {\n 0: 'None',\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: 'IdentityId',\n 20: 'Uuid4',\n 21: 'Uuid7',\n 22: 'Blob',\n 23: 'Int',\n 24: 'Decimal',\n 25: 'Uint',\n 26: 'Any',\n };\n\n // Create a map to collect columns with their positions\n const table_columns_map = new Map<number, Array<{name: string; data_type: string; position: number}>>();\n\n columns.forEach((column) => {\n const shape_id = column.shape_id?.valueOf() as number;\n const shape_type = column.shape_type?.valueOf() as number;\n const column_name = column.name?.valueOf() as string;\n const type_id = column.type?.valueOf() as number;\n const position = column.position?.valueOf() as number;\n\n if (shape_id === undefined || !column_name || type_id === undefined) return;\n if (shape_type !== 0 && shape_type !== 1) return;\n\n if (!table_columns_map.has(shape_id)) {\n table_columns_map.set(shape_id, []);\n }\n\n table_columns_map.get(shape_id)!.push({\n name: column_name,\n data_type: type_map[type_id] || `Unknown(${type_id})`,\n position: position ?? 0,\n });\n });\n\n // Sort columns by position and add to table info\n table_columns_map.forEach((cols, shape_id) => {\n const table_info = table_info_map.get(shape_id);\n if (table_info) {\n cols.sort((a, b) => a.position - b.position);\n table_info.columns = cols.map((c) => ({name: c.name, data_type: c.data_type}));\n }\n });\n\n const shape_array = Array.from(table_info_map.values())\n .filter((table) => table.name !== 'reifydb::flows')\n .sort((a, b) => a.name.localeCompare(b.name));\n\n set_shape(shape_array);\n set_is_loading(false);\n }, [results, is_executing]);\n\n return [is_loading, shape, error];\n}\n"],"mappings":";AAGA,cAAc;AACd,cAAc;;;ACDd,SAAQ,cAA8F;AAiB/F,IAAM,iBAAmC;AAAA,EAC5C,KAAK;AAAA,EACL,SAAS,EAAC,YAAY,IAAM;AAChC;AAEO,IAAM,cAAc;AAEpB,IAAM,aAAN,MAAiB;AAAA,EAWpB,YAAY,SAA2B,gBAAgB;AAVvD,SAAQ,QAAyB;AAAA,MAC7B,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,eAAe;AAAA,MACf,kBAAkB;AAAA,MAClB,WAAW,oBAAI,IAAI;AAAA,IACvB;AAEA,SAAQ,kBAAwC;AAG5C,SAAK,SAAS,EAAC,GAAG,gBAAgB,GAAG,OAAM;AAAA,EAC/C;AAAA,EAEA,WAAW,QAAgC;AACvC,SAAK,SAAS;AAAA,EAClB;AAAA,EAEA,aAA+B;AAC3B,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,MAAM,QAAQ,KAAc,SAAuD;AAC/E,QAAI,KAAK,MAAM,cAAc;AACzB;AAAA,IACJ;AAGA,QAAI,KAAK,iBAAiB;AACtB,aAAO,KAAK;AAAA,IAChB;AAEA,UAAM,cAAc,OAAO,KAAK,OAAO,OAAO,eAAe;AAC7D,UAAM,kBAAkB,EAAC,OAAO,KAAK,OAAO,OAAO,GAAG,KAAK,OAAO,SAAS,GAAG,QAAO;AAErF,SAAK,aAAa;AAAA,MACd,eAAe;AAAA,MACf,kBAAkB;AAAA,IACtB,CAAC;AAED,SAAK,mBAAmB,YAAY;AAChC,UAAI;AACA,cAAM,SAAS,YAAY,WAAW,SAAS,KAAK,YAAY,WAAW,UAAU;AACrF,cAAM,SAAS,KAAK,OAAO,WAAW;AACtC,YAAI;AACJ,YAAI,QAAQ;AACR,mBAAS,SACH,OA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CAAC;AAAA,MACtC;AAEA,wBAAkB,IAAI,QAAQ,EAAG,KAAK;AAAA,QAClC,MAAM;AAAA,QACN,WAAW,SAAS,OAAO,KAAK,WAAW,OAAO;AAAA,QAClD,UAAU,YAAY;AAAA,MAC1B,CAAC;AAAA,IACL,CAAC;AAGD,sBAAkB,QAAQ,CAAC,MAAM,aAAa;AAC1C,YAAM,aAAa,eAAe,IAAI,QAAQ;AAC9C,UAAI,YAAY;AACZ,aAAK,KAAK,CAAC,GAAG,MAAM,EAAE,WAAW,EAAE,QAAQ;AAC3C,mBAAW,UAAU,KAAK,IAAI,CAAC,OAAO,EAAC,MAAM,EAAE,MAAM,WAAW,EAAE,UAAS,EAAE;AAAA,MACjF;AAAA,IACJ,CAAC;AAED,UAAM,cAAc,MAAM,KAAK,eAAe,OAAO,CAAC,EACjD,OAAO,CAAC,UAAU,MAAM,SAAS,gBAAgB,EACjD,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;AAEhD,cAAU,WAAW;AACrB,mBAAe,KAAK;AAAA,EACxB,GAAG,CAAC,SAAS,YAAY,CAAC;AAE1B,SAAO,CAAC,YAAY,OAAO,KAAK;AACpC;","names":["useEffect","useEffect","useState","useRef","useEffect","useState","useRef","useEffect","useEffect","useEffect","useState","useCallback","useRef","useEffect","useState","useRef","useEffect","useCallback","useEffect","useMemo","useEffect","useMemo","useState","useCallback","useRef","useEffect","useState","useRef","useEffect","useCallback","useEffect","useMemo","useEffect","useMemo","useState","useCallback","useRef","useEffect","useState","useRef","useEffect","useCallback","useEffect","useMemo","useMemo","useEffect","useEffect","useState","useState","useEffect"]}
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-admin-executor.ts","../src/hooks/use-admin.ts","../src/hooks/use-subscription-executor.ts","../src/hooks/use-subscription.ts","../src/hooks/use-shape.ts"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nexport * from '@reifydb/core';\nexport * from '@reifydb/client';\n\n// Export connection utilities\nexport {Connection, type ConnectionConfig, DEFAULT_CONFIG, DEFAULT_URL} from './connection/connection';\nexport {get_connection, clear_connection} 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 {useAdminExecutor, type AdminResult, type AdminState, type AdminExecutorOptions} from './hooks/use-admin-executor';\nexport {useAdminOne, useAdminMany, type AdminOptions} from './hooks/use-admin';\nexport {\n useSubscriptionExecutor,\n type SubscriptionExecutorOptions,\n type SubscriptionState,\n type ChangeEvent\n} from './hooks/use-subscription-executor';\nexport {\n useSubscription,\n type SubscriptionOptions\n} from './hooks/use-subscription';\nexport {useShape, type TableInfo, type ColumnInfo} from './hooks/use-shape';","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport {Client, WsClient, HttpClient, JsonHttpClient, JsonWsClient, type WsClientOptions} from '@reifydb/client';\n\ninterface ConnectionState {\n client: WsClient | HttpClient | JsonHttpClient | JsonWsClient | null;\n is_connected: boolean;\n is_connecting: boolean;\n connection_error: string | null;\n listeners: Set<(state: ConnectionState) => void>;\n}\n\nexport interface ConnectionConfig {\n url?: string;\n token?: string;\n format?: 'json';\n options?: Omit<WsClientOptions, 'url' | 'token'>;\n}\n\nexport const DEFAULT_CONFIG: ConnectionConfig = {\n url: 'ws://127.0.0.1:8090',\n options: {timeout_ms: 30_000},\n};\n\nexport const DEFAULT_URL = 'ws://127.0.0.1:8090';\n\nexport class Connection {\n private state: ConnectionState = {\n client: null,\n is_connected: false,\n is_connecting: false,\n connection_error: null,\n listeners: new Set(),\n };\n private config: ConnectionConfig;\n private connect_promise: Promise<void> | null = null;\n\n constructor(config: ConnectionConfig = DEFAULT_CONFIG) {\n this.config = {...DEFAULT_CONFIG, ...config};\n }\n\n set_config(config: ConnectionConfig): void {\n this.config = config;\n }\n\n get_config(): ConnectionConfig {\n return this.config;\n }\n\n async connect(url?: string, options?: Omit<WsClientOptions, 'url'>): Promise<void> {\n if (this.state.is_connected) {\n return;\n }\n\n // If already connecting, wait for the in-flight connection\n if (this.connect_promise) {\n return this.connect_promise;\n }\n\n const connect_url = url || this.config.url || DEFAULT_CONFIG.url!;\n const connect_options = {token: this.config.token, ...this.config.options, ...options};\n\n this.update_state({\n is_connecting: true,\n connection_error: null,\n });\n\n this.connect_promise = (async () => {\n try {\n const isHttp = connect_url.startsWith('http://') || connect_url.startsWith('https://');\n const isJson = this.config.format === 'json';\n let client: WsClient | HttpClient | JsonHttpClient | JsonWsClient;\n if (isHttp) {\n client = isJson\n ? Client.connect_json_http(connect_url, connect_options)\n : Client.connect_http(connect_url, connect_options);\n } else {\n client = isJson\n ? await Client.connect_json_ws(connect_url, connect_options)\n : await Client.connect_ws(connect_url, connect_options);\n }\n this.update_state({\n client,\n is_connected: true,\n is_connecting: false,\n connection_error: null,\n });\n } catch (err) {\n const error_message = err instanceof Error ? err.message : 'Failed to connect to ReifyDB';\n console.error('[Connection] Connection failed:', error_message, err);\n this.update_state({\n client: null,\n is_connected: false,\n is_connecting: false,\n connection_error: error_message,\n });\n throw err;\n } finally {\n this.connect_promise = null;\n }\n })();\n\n return this.connect_promise;\n }\n\n async disconnect(): Promise<void> {\n this.connect_promise = null;\n if (this.state.client) {\n try {\n if ('disconnect' in this.state.client) {\n (this.state.client as WsClient).disconnect();\n // Small delay to ensure WebSocket closes cleanly\n await new Promise(resolve => setTimeout(resolve, 10));\n }\n } catch (err) {\n console.error('Error disconnecting:', err);\n }\n }\n\n this.update_state({\n client: null,\n is_connected: false,\n is_connecting: false,\n connection_error: 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 get_client(): WsClient | HttpClient | JsonHttpClient | JsonWsClient | null {\n return this.state.client;\n }\n\n is_connected(): boolean {\n return this.state.is_connected;\n }\n\n is_connecting(): boolean {\n return this.state.is_connecting;\n }\n\n get_connection_error(): string | null {\n return this.state.connection_error;\n }\n\n get_state(): 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 update_state(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","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport { 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 default_connection: 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 set_config().\n * @param config - Optional connection configuration\n * @returns The singleton Connection instance\n */\nexport function get_connection(config?: ConnectionConfig): Connection {\n // Create singleton on first call\n if (!default_connection) {\n const merged_config = {...DEFAULT_CONFIG, ...config};\n default_connection = new Connection(merged_config);\n // Start connection immediately - don't wait for React's useEffect\n default_connection.connect().catch(err => {\n console.error('[ConnectionPool] Eager connect failed:', err);\n });\n } else if (config) {\n // Only update config when explicitly provided, to avoid\n // stripping fields (e.g. token) that were set on creation.\n default_connection.set_config({...DEFAULT_CONFIG, ...config});\n }\n\n return default_connection;\n}\n\n/**\n * Clear the singleton connection\n */\nexport async function clear_connection(): Promise<void> {\n if (default_connection) {\n await default_connection.disconnect();\n default_connection = null;\n }\n}","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport React, { createContext, useEffect, useRef, ReactNode } from 'react';\nimport { Connection, ConnectionConfig } from './connection';\nimport { get_connection } 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 set_config()\n const connection = get_connection(config);\n\n // Track previous config to detect changes\n const prev_config_ref = useRef<string | undefined>(undefined);\n const current_config_str = JSON.stringify(config);\n\n useEffect(() => {\n const config_changed = prev_config_ref.current !== undefined &&\n prev_config_ref.current !== current_config_str;\n\n if (config_changed && connection.is_connected()) {\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.is_connected() && !connection.is_connecting()) {\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 prev_config_ref.current = current_config_str;\n }, [current_config_str, connection]);\n\n return (\n <ConnectionContext.Provider value={connection}>\n {children}\n </ConnectionContext.Provider>\n );\n}","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport {useContext, useEffect, useState} from 'react';\nimport {ConnectionConfig} from '../connection/connection';\nimport {get_connection} from '../connection/connection-pool';\nimport {ConnectionContext} from '../connection/connection-context';\nimport {WsClient, HttpClient, JsonHttpClient, JsonWsClient} from '@reifydb/client';\n\ninterface ConnectionState {\n client: WsClient | HttpClient | JsonHttpClient | JsonWsClient | null;\n is_connected: boolean;\n is_connecting: boolean;\n connection_error: string | null;\n}\n\nexport function useConnection(override_config?: ConnectionConfig) {\n const context_connection = useContext(ConnectionContext);\n\n // Use override config if provided, otherwise use context, otherwise get default\n const [connection] = useState(() => {\n if (override_config) {\n return get_connection(override_config);\n }\n if (context_connection) {\n return context_connection;\n }\n return get_connection();\n });\n\n const [state, setState] = useState<ConnectionState>(() => connection.get_state());\n\n useEffect(() => {\n // Get initial state immediately\n const current_state = connection.get_state();\n setState(current_state);\n\n // Subscribe to connection state changes\n const unsubscribe = connection.subscribe((new_state) => {\n setState({\n client: new_state.client,\n is_connected: new_state.is_connected,\n is_connecting: new_state.is_connecting,\n connection_error: new_state.connection_error,\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}","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport {useState, useCallback, useRef, useEffect} from 'react';\nimport {Column, ShapeNode} 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 execution_time_ms: number;\n rows_affected?: number;\n}\n\nexport interface QueryState<T = any> {\n is_executing: boolean;\n results: QueryResult<T>[] | undefined;\n error: string | undefined;\n execution_time: number | undefined;\n}\n\nexport interface QueryExecutorOptions {\n connection_config?: ConnectionConfig;\n}\n\nexport function useQueryExecutor<T = any>(options?: QueryExecutorOptions) {\n const {client} = useConnection(options?.connection_config);\n\n const [state, setState] = useState<QueryState<T>>({\n is_executing: false,\n results: undefined,\n error: undefined,\n execution_time: undefined,\n });\n\n const client_ref = useRef(client);\n client_ref.current = client;\n\n const is_mounted_ref = useRef(true);\n useEffect(() => {\n return () => { is_mounted_ref.current = false; };\n }, []);\n\n const execution_id_ref = useRef(0);\n const pending_ref = useRef<{rql: string, params?: any, shapes?: readonly ShapeNode[]} | null>(null);\n\n const query = useCallback(\n (rql: string, params?: any, shapes?: readonly ShapeNode[]): Promise<void> => {\n const current_client = client_ref.current;\n\n if (!current_client) {\n pending_ref.current = {rql, params, shapes};\n setState(prev => ({...prev, is_executing: true, error: undefined}));\n return Promise.resolve();\n }\n\n pending_ref.current = null;\n const this_execution = ++execution_id_ref.current;\n\n setState(prev => ({...prev, is_executing: true, error: undefined}));\n\n const start_time = Date.now();\n\n return (async () => {\n try {\n const frame_results = await current_client.query(rql, params || null, shapes || []) || [];\n\n if (execution_id_ref.current !== this_execution) return;\n\n const execution_time = Date.now() - start_time;\n\n const results: QueryResult<T>[] = frame_results.map((frame: any) => {\n if (Array.isArray(frame) && frame.length > 0) {\n const first_row = frame[0];\n let columns: Column[] = [];\n\n const has_value_objects = first_row && typeof first_row === 'object' &&\n Object.values(first_row).some(v => v && typeof v === 'object' && 'type' in v);\n\n if (has_value_objects) {\n columns = Object.keys(first_row).map((key) => {\n const value = first_row[key];\n const data_type = value?.type || 'Utf8';\n return {\n name: key,\n type: data_type,\n payload: [],\n };\n });\n } else {\n columns = Object.keys(first_row).map((key) => ({\n name: key,\n type: 'Utf8',\n payload: [],\n }));\n }\n\n return {\n columns,\n rows: frame as T[],\n execution_time_ms: execution_time,\n };\n } else {\n return {\n columns: [],\n rows: [],\n execution_time_ms: execution_time,\n };\n }\n });\n\n if (!is_mounted_ref.current) return;\n setState({\n is_executing: false,\n results,\n error: undefined,\n execution_time,\n });\n } catch (err) {\n if (execution_id_ref.current !== this_execution) return;\n\n const execution_time = Date.now() - start_time;\n let error_message = 'Query execution failed';\n\n if (err instanceof Error) {\n error_message = err.message;\n } else if (typeof err === 'string') {\n error_message = err;\n } else if (err && typeof err === 'object' && 'message' in err) {\n error_message = (err as { message: string }).message;\n }\n\n console.error('Query execution failed:', error_message);\n\n if (!is_mounted_ref.current) return;\n setState(prev => ({\n ...prev,\n is_executing: false,\n error: error_message,\n execution_time,\n }));\n\n }\n })();\n },\n []\n );\n\n useEffect(() => {\n if (client && pending_ref.current) {\n const {rql, params, shapes} = pending_ref.current;\n query(rql, params, shapes);\n }\n }, [client, query]);\n\n const cancel_query = useCallback(() => {\n execution_id_ref.current++;\n setState((prev) => ({\n ...prev,\n is_executing: false,\n error: 'Query cancelled',\n }));\n }, []);\n\n return {\n is_executing: state.is_executing,\n results: state.results,\n error: state.error,\n execution_time: state.execution_time,\n query,\n cancel_query,\n };\n}\n","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport {useEffect, useMemo} from 'react';\nimport {ShapeNode, InferShape} 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 connection_config?: ConnectionConfig;\n}\n\n// Single query hook - returns a single result\nexport function useQueryOne<S extends ShapeNode = any>(\n rql: string,\n params?: any,\n shape?: S,\n options?: QueryOptions\n): {\n is_executing: boolean;\n result: QueryResult<S extends ShapeNode ? InferShape<S> : any> | undefined;\n error: string | undefined;\n} {\n const {\n is_executing,\n results,\n error,\n query\n } = useQueryExecutor<S extends ShapeNode ? InferShape<S> : any>(options);\n\n useEffect(() => {\n // Pass shape as array for the executor\n const shapes = shape ? [shape] : undefined;\n query(rql, params, shapes);\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 {is_executing, result, error};\n}\n\n// Multiple query hook - returns multiple results\nexport function useQueryMany<S extends readonly ShapeNode[] = readonly ShapeNode[]>(\n rql: string,\n params?: any,\n shapes?: S,\n options?: QueryOptions\n): {\n is_executing: boolean;\n results: QueryResult<S extends readonly ShapeNode[] ? InferShape<S[number]> : any>[] | undefined;\n error: string | undefined;\n} {\n const {\n is_executing,\n results,\n error,\n query\n } = useQueryExecutor<S extends readonly ShapeNode[] ? InferShape<S[number]> : any>(options);\n\n useEffect(() => {\n query(rql, params, shapes);\n }, [rql, params, query]);\n\n return {is_executing, results, error};\n}","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport {useState, useCallback, useRef, useEffect} from 'react';\nimport {Column, ShapeNode} 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 execution_time_ms: number;\n rows_affected?: number;\n}\n\nexport interface CommandState<T = any> {\n is_executing: boolean;\n results: CommandResult<T>[] | undefined;\n error: string | undefined;\n execution_time: number | undefined;\n}\n\nexport interface CommandExecutorOptions {\n connection_config?: ConnectionConfig;\n}\n\nexport function useCommandExecutor<T = any>(options?: CommandExecutorOptions) {\n const {client} = useConnection(options?.connection_config);\n\n const [state, setState] = useState<CommandState<T>>({\n is_executing: false,\n results: undefined,\n error: undefined,\n execution_time: undefined,\n });\n\n const client_ref = useRef(client);\n client_ref.current = client;\n\n const is_mounted_ref = useRef(false);\n useEffect(() => {\n is_mounted_ref.current = true;\n return () => { is_mounted_ref.current = false; };\n }, []);\n\n const execution_id_ref = useRef(0);\n const pending_ref = useRef<{rql: string, params?: any, shapes?: readonly ShapeNode[]} | null>(null);\n\n const command = useCallback(\n (rql: string, params?: any, shapes?: readonly ShapeNode[]): Promise<void> => {\n const current_client = client_ref.current;\n\n if (!current_client) {\n pending_ref.current = {rql, params, shapes};\n setState(prev => ({...prev, is_executing: true, error: undefined}));\n return Promise.resolve();\n }\n\n pending_ref.current = null;\n const this_execution = ++execution_id_ref.current;\n\n setState(prev => ({...prev, is_executing: true, error: undefined}));\n\n const start_time = Date.now();\n\n return (async () => {\n try {\n const frame_results = await current_client.command(rql, params || null, shapes || []) || [];\n\n if (execution_id_ref.current !== this_execution) return;\n\n const execution_time = Date.now() - start_time;\n\n const results: CommandResult<T>[] = frame_results.map((frame: any) => {\n if (Array.isArray(frame) && frame.length > 0) {\n const first_row = frame[0];\n let columns: Column[] = [];\n\n const has_value_objects = first_row && typeof first_row === 'object' &&\n Object.values(first_row).some(v => v && typeof v === 'object' && 'type' in v);\n\n if (has_value_objects) {\n columns = Object.keys(first_row).map((key) => {\n const value = first_row[key];\n const data_type = value?.type || 'Utf8';\n return {\n name: key,\n type: data_type,\n payload: [],\n };\n });\n } else {\n columns = Object.keys(first_row).map((key) => ({\n name: key,\n type: 'Utf8',\n payload: [],\n }));\n }\n\n return {\n columns,\n rows: frame as T[],\n execution_time_ms: execution_time,\n };\n } else {\n return {\n columns: [],\n rows: [],\n execution_time_ms: execution_time,\n rows_affected: typeof frame === 'number' ? frame : undefined,\n };\n }\n });\n\n if (!is_mounted_ref.current) return;\n setState({\n is_executing: false,\n results,\n error: undefined,\n execution_time,\n });\n } catch (err) {\n if (execution_id_ref.current !== this_execution) return;\n\n const execution_time = Date.now() - start_time;\n let error_message = 'Command execution failed';\n\n if (err instanceof Error) {\n error_message = err.message;\n } else if (typeof err === 'string') {\n error_message = err;\n } else if (err && typeof err === 'object' && 'message' in err) {\n error_message = (err as { message: string }).message;\n }\n\n console.error('Command execution failed:', error_message);\n\n if (!is_mounted_ref.current) return;\n setState(prev => ({\n ...prev,\n is_executing: false,\n error: error_message,\n execution_time,\n }));\n\n }\n })();\n },\n []\n );\n\n useEffect(() => {\n if (client && pending_ref.current) {\n const {rql, params, shapes} = pending_ref.current;\n command(rql, params, shapes);\n }\n }, [client, command]);\n\n const cancel_command = useCallback(() => {\n execution_id_ref.current++;\n setState((prev) => ({\n ...prev,\n is_executing: false,\n error: 'Command cancelled',\n }));\n }, []);\n\n return {\n is_executing: state.is_executing,\n results: state.results,\n error: state.error,\n execution_time: state.execution_time,\n command,\n cancel_command,\n };\n}\n","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport {useEffect, useMemo} from 'react';\nimport {ShapeNode, InferShape} 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 connection_config?: ConnectionConfig;\n}\n\n// Single command hook - returns a single result\nexport function useCommandOne<S extends ShapeNode = any>(\n rql: string,\n params?: any,\n shape?: S,\n options?: CommandOptions\n): {\n is_executing: boolean;\n result: CommandResult<S extends ShapeNode ? InferShape<S> : any> | undefined;\n error: string | undefined;\n} {\n const {\n is_executing,\n results,\n error,\n command\n } = useCommandExecutor<S extends ShapeNode ? InferShape<S> : any>(options);\n\n useEffect(() => {\n // Pass shape as array for the executor\n const shapes = shape ? [shape] : undefined;\n command(rql, params, shapes);\n }, [rql, 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 {is_executing, result, error};\n}\n\n// Multiple command hook - returns multiple results\nexport function useCommandMany<S extends readonly ShapeNode[] = readonly ShapeNode[]>(\n rql: string,\n params?: any,\n shapes?: S,\n options?: CommandOptions\n): {\n is_executing: boolean;\n results: CommandResult<S extends readonly ShapeNode[] ? InferShape<S[number]> : any>[] | undefined;\n error: string | undefined;\n} {\n const {\n is_executing,\n results,\n error,\n command\n } = useCommandExecutor<S extends readonly ShapeNode[] ? InferShape<S[number]> : any>(options);\n\n useEffect(() => {\n command(rql, params, shapes);\n }, [rql, params, command]);\n\n return {is_executing, results, error};\n}","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport {useState, useCallback, useRef, useEffect} from 'react';\nimport {Column, ShapeNode} from '@reifydb/core';\nimport {ConnectionConfig} from '../connection/connection';\nimport {useConnection} from './use-connection';\n\nexport interface AdminResult<T = any> {\n columns: Column[];\n rows: T[];\n execution_time_ms: number;\n rows_affected?: number;\n}\n\nexport interface AdminState<T = any> {\n is_executing: boolean;\n results: AdminResult<T>[] | undefined;\n error: string | undefined;\n execution_time: number | undefined;\n}\n\nexport interface AdminExecutorOptions {\n connection_config?: ConnectionConfig;\n}\n\nexport function useAdminExecutor<T = any>(options?: AdminExecutorOptions) {\n const {client} = useConnection(options?.connection_config);\n\n const [state, setState] = useState<AdminState<T>>({\n is_executing: false,\n results: undefined,\n error: undefined,\n execution_time: undefined,\n });\n\n // Stable refs so the callback never recreates\n const client_ref = useRef(client);\n client_ref.current = client;\n\n const is_mounted_ref = useRef(false);\n useEffect(() => {\n is_mounted_ref.current = true;\n return () => { is_mounted_ref.current = false; };\n }, []);\n\n // Counter to detect superseded executions\n const execution_id_ref = useRef(0);\n\n // Stash pending call if client isn't ready yet\n const pending_ref = useRef<{rql: string, params?: any, shapes?: readonly ShapeNode[]} | null>(null);\n\n const admin = useCallback(\n (rql: string, params?: any, shapes?: readonly ShapeNode[]): Promise<void> => {\n const current_client = client_ref.current;\n // If no client yet, stash the request for replay when client connects\n if (!current_client) {\n pending_ref.current = {rql, params, shapes};\n setState(prev => ({...prev, is_executing: true, error: undefined}));\n return Promise.resolve();\n }\n\n pending_ref.current = null;\n const this_execution = ++execution_id_ref.current;\n\n setState(prev => ({...prev, is_executing: true, error: undefined}));\n\n const start_time = Date.now();\n\n return (async () => {\n try {\n const frame_results = await current_client.admin(rql, params || null, shapes || []) || [];\n\n // If this execution was superseded by a newer one, discard results\n if (execution_id_ref.current !== this_execution) return;\n\n const execution_time = Date.now() - start_time;\n\n // Process each frame into a AdminResult\n const results: AdminResult<T>[] = frame_results.map((frame: any) => {\n if (Array.isArray(frame) && frame.length > 0) {\n const first_row = frame[0];\n let columns: Column[] = [];\n\n // Check if we have Value objects or plain objects\n const has_value_objects = first_row && typeof first_row === 'object' &&\n Object.values(first_row).some(v => v && typeof v === 'object' && 'type' in v);\n\n if (has_value_objects) {\n columns = Object.keys(first_row).map((key) => {\n const value = first_row[key];\n const data_type = value?.type || 'Utf8';\n return {\n name: key,\n type: data_type,\n payload: [],\n };\n });\n } else {\n columns = Object.keys(first_row).map((key) => ({\n name: key,\n type: 'Utf8',\n payload: [],\n }));\n }\n\n return {\n columns,\n rows: frame as T[],\n execution_time_ms: execution_time,\n };\n } else {\n return {\n columns: [],\n rows: [],\n execution_time_ms: execution_time,\n rows_affected: typeof frame === 'number' ? frame : undefined,\n };\n }\n });\n\n if (!is_mounted_ref.current) return;\n setState({\n is_executing: false,\n results,\n error: undefined,\n execution_time,\n });\n } catch (err) {\n if (execution_id_ref.current !== this_execution) return;\n\n const execution_time = Date.now() - start_time;\n let error_message = 'Admin execution failed';\n\n if (err instanceof Error) {\n error_message = err.message;\n } else if (typeof err === 'string') {\n error_message = err;\n } else if (err && typeof err === 'object' && 'message' in err) {\n error_message = (err as { message: string }).message;\n }\n\n console.error('Admin execution failed:', error_message);\n\n if (!is_mounted_ref.current) return;\n setState(prev => ({\n ...prev,\n is_executing: false,\n error: error_message,\n execution_time,\n }));\n\n }\n })();\n },\n [] // stable — never recreates\n );\n\n // Replay pending request when client becomes available\n useEffect(() => {\n if (client && pending_ref.current) {\n const {rql, params, shapes} = pending_ref.current;\n admin(rql, params, shapes);\n }\n }, [client, admin]);\n\n const cancel_admin = useCallback(() => {\n // Bump execution ID so any in-flight request is ignored on completion\n execution_id_ref.current++;\n setState((prev) => ({\n ...prev,\n is_executing: false,\n error: 'Admin cancelled',\n }));\n }, []);\n\n return {\n is_executing: state.is_executing,\n results: state.results,\n error: state.error,\n execution_time: state.execution_time,\n admin,\n cancel_admin,\n };\n}\n","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport {useEffect, useMemo} from 'react';\nimport {ShapeNode, InferShape} from '@reifydb/core';\nimport {ConnectionConfig} from '../connection/connection';\nimport {useAdminExecutor, type AdminResult, type AdminExecutorOptions} from './use-admin-executor';\n\nexport interface AdminOptions extends AdminExecutorOptions {\n connection_config?: ConnectionConfig;\n}\n\n// Single admin hook - returns a single result\nexport function useAdminOne<S extends ShapeNode = any>(\n rql: string,\n params?: any,\n shape?: S,\n options?: AdminOptions\n): {\n is_executing: boolean;\n result: AdminResult<S extends ShapeNode ? InferShape<S> : any> | undefined;\n error: string | undefined;\n} {\n const {\n is_executing,\n results,\n error,\n admin\n } = useAdminExecutor<S extends ShapeNode ? InferShape<S> : any>(options);\n\n useEffect(() => {\n // Pass shape as array for the executor\n const shapes = shape ? [shape] : undefined;\n admin(rql, params, shapes);\n }, [rql, params, admin]);\n\n // Extract first result for single admin convenience\n const result = useMemo(() => {\n return results && results.length > 0 ? results[0] : undefined;\n }, [results]);\n\n return {is_executing, result, error};\n}\n\n// Multiple admin hook - returns multiple results\nexport function useAdminMany<S extends readonly ShapeNode[] = readonly ShapeNode[]>(\n rql: string,\n params?: any,\n shapes?: S,\n options?: AdminOptions\n): {\n is_executing: boolean;\n results: AdminResult<S extends readonly ShapeNode[] ? InferShape<S[number]> : any>[] | undefined;\n error: string | undefined;\n} {\n const {\n is_executing,\n results,\n error,\n admin\n } = useAdminExecutor<S extends readonly ShapeNode[] ? InferShape<S[number]> : any>(options);\n\n useEffect(() => {\n admin(rql, params, shapes);\n }, [rql, params, admin]);\n\n return {is_executing, results, error};\n}\n","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport { useState, useCallback, useRef, useEffect } from 'react';\nimport { ShapeNode } from '@reifydb/core';\nimport { useConnection } from './use-connection';\nimport type { ConnectionConfig } from '../connection/connection';\n\nexport interface SubscriptionExecutorOptions {\n connection_config?: ConnectionConfig;\n}\n\nexport interface ChangeEvent<T> {\n operation: 'INSERT' | 'UPDATE' | 'REMOVE';\n rows: T[];\n timestamp: number;\n}\n\nexport interface SubscriptionState<T> {\n data: T[];\n changes: ChangeEvent<T>[];\n is_subscribed: boolean;\n is_subscribing: boolean;\n error: string | undefined;\n subscription_id: string | undefined;\n}\n\nexport function useSubscriptionExecutor<T = any>(\n options?: SubscriptionExecutorOptions\n) {\n const { client } = useConnection(options?.connection_config);\n\n const [state, setState] = useState<SubscriptionState<T>>({\n data: [],\n changes: [],\n is_subscribed: false,\n is_subscribing: false,\n error: undefined,\n subscription_id: undefined\n });\n\n // Use a ref for client to avoid recreating callbacks when client changes\n const client_ref = useRef(client);\n\n const subscriptionIdRef = useRef<string | undefined>(undefined);\n const rql_ref = useRef<string | undefined>(undefined);\n const params_ref = useRef<any>(undefined);\n const shape_ref = useRef<ShapeNode | undefined>(undefined);\n\n // Keep client_ref in sync with client\n useEffect(() => {\n client_ref.current = client;\n }, [client]);\n\n // Helper to add change event\n const add_change_event = useCallback((\n operation: 'INSERT' | 'UPDATE' | 'REMOVE',\n rows: T[]\n ) => {\n setState(prev => {\n const new_change: ChangeEvent<T> = {\n operation,\n rows,\n timestamp: Date.now()\n };\n\n const new_changes = [...prev.changes, new_change];\n\n return {\n ...prev,\n data: prev.data,\n changes: new_changes\n };\n });\n }, []);\n\n // Separate callbacks for each operation type\n const handle_insert = useCallback((rows: T[]) => {\n add_change_event('INSERT', rows);\n }, [add_change_event]);\n\n const handle_update = useCallback((rows: T[]) => {\n add_change_event('UPDATE', rows);\n }, [add_change_event]);\n\n const handle_remove = useCallback((rows: T[]) => {\n add_change_event('REMOVE', rows);\n }, [add_change_event]);\n\n const subscribe = useCallback(async (\n rql: string,\n params?: any,\n shape?: ShapeNode\n ) => {\n const current_client = client_ref.current;\n if (!current_client) {\n setState(prev => ({ ...prev, error: 'Client not connected' }));\n return;\n }\n\n if (!('subscribe' in current_client)) {\n setState(prev => ({ ...prev, error: 'Subscriptions require a WebSocket connection' }));\n return;\n }\n\n // Store refs for reconnection\n rql_ref.current = rql;\n params_ref.current = params;\n shape_ref.current = shape;\n\n setState(prev => ({\n ...prev,\n is_subscribing: true,\n error: undefined\n }));\n\n try {\n const sub_id = await current_client.subscribe(rql, params, shape, {\n on_insert: handle_insert,\n on_update: handle_update,\n on_remove: handle_remove\n });\n\n subscriptionIdRef.current = sub_id;\n setState(prev => ({\n ...prev,\n is_subscribing: false,\n is_subscribed: true,\n subscription_id: sub_id\n }));\n } catch (err: any) {\n setState(prev => ({\n ...prev,\n is_subscribing: false,\n error: err.message || 'Subscription failed'\n }));\n }\n }, [handle_insert, handle_update, handle_remove]);\n\n const unsubscribe = useCallback(async () => {\n const current_client = client_ref.current;\n if (!current_client || !subscriptionIdRef.current) return;\n if (!('unsubscribe' in current_client)) return;\n\n try {\n await current_client.unsubscribe(subscriptionIdRef.current);\n subscriptionIdRef.current = undefined;\n rql_ref.current = undefined;\n params_ref.current = undefined;\n shape_ref.current = undefined;\n\n setState(prev => ({\n ...prev,\n is_subscribed: false,\n subscription_id: undefined\n }));\n } catch (err: any) {\n setState(prev => ({\n ...prev,\n error: err.message || 'Unsubscribe failed'\n }));\n }\n }, []);\n\n const clear_changes = useCallback(() => {\n setState(prev => ({ ...prev, changes: [] }));\n }, []);\n\n const clear_data = useCallback(() => {\n setState(prev => ({ ...prev, data: [] }));\n }, []);\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n if (subscriptionIdRef.current && client_ref.current && 'unsubscribe' in client_ref.current) {\n client_ref.current.unsubscribe(subscriptionIdRef.current).catch(console.error);\n }\n };\n }, []);\n\n return {\n state,\n subscribe,\n unsubscribe,\n clear_changes,\n clear_data\n };\n}\n","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport { useEffect, useMemo } from 'react';\nimport { ShapeNode, InferShape } from '@reifydb/core';\nimport {\n useSubscriptionExecutor,\n type SubscriptionExecutorOptions,\n type ChangeEvent\n} from './use-subscription-executor';\n\nexport interface SubscriptionOptions extends SubscriptionExecutorOptions {\n enabled?: boolean; // Auto-subscribe (default: true)\n}\n\nexport function useSubscription<S extends ShapeNode = any>(\n rql: string,\n params?: any,\n shape?: S,\n options?: SubscriptionOptions\n): {\n data: InferShape<S>[];\n changes: ChangeEvent<InferShape<S>>[];\n is_subscribed: boolean;\n is_subscribing: boolean;\n error: string | undefined;\n subscription_id: string | undefined;\n} {\n const {\n state,\n subscribe,\n unsubscribe\n } = useSubscriptionExecutor<InferShape<S>>(options);\n\n // Serialize params for stable comparison (objects create new refs each render)\n const params_key = useMemo(() => JSON.stringify(params), [params]);\n\n useEffect(() => {\n if (options?.enabled === false) return;\n\n subscribe(rql, params, shape);\n\n return () => {\n unsubscribe();\n };\n }, [rql, params_key, shape, options?.enabled, subscribe, unsubscribe]);\n\n return {\n data: state.data,\n changes: state.changes,\n is_subscribed: state.is_subscribed,\n is_subscribing: state.is_subscribing,\n error: state.error,\n subscription_id: state.subscription_id\n };\n}\n","// SPDX-License-Identifier: Apache-2.0\n// Copyright (c) 2025 ReifyDB\n\nimport {useEffect, useState} from 'react';\nimport {Shape, InferShape} from '@reifydb/core';\nimport {useQueryExecutor} from './use-query-executor';\n\nexport interface ColumnInfo {\n name: string;\n data_type: string;\n}\n\nexport interface TableInfo {\n name: string;\n columns: ColumnInfo[];\n}\n\nconst namespace_shape = Shape.object({\n id: Shape.number(),\n name: Shape.string(),\n});\n\nconst table_shape = Shape.object({\n id: Shape.number(),\n namespace_id: Shape.number(),\n name: Shape.string(),\n primary_key_id: Shape.number(),\n});\n\nconst view_shape = Shape.object({\n id: Shape.number(),\n namespace_id: Shape.number(),\n name: Shape.string(),\n});\n\nconst column_shape = Shape.object({\n id: Shape.number(),\n shape_id: Shape.number(),\n shape_type: Shape.number(),\n name: Shape.string(),\n type: Shape.number(),\n position: Shape.number(),\n auto_increment: Shape.boolean(),\n});\n\ntype NamespaceRow = InferShape<typeof namespace_shape>;\ntype TableRow = InferShape<typeof table_shape>;\ntype ViewRow = InferShape<typeof view_shape>;\ntype ColumnRow = InferShape<typeof column_shape>;\n\nexport function useShape(): [boolean, TableInfo[], string | undefined] {\n const {is_executing, results, error, query} = useQueryExecutor();\n const [shape, set_shape] = useState<TableInfo[]>([]);\n const [is_loading, set_is_loading] = useState(true);\n\n useEffect(() => {\n if (!query) return;\n\n const fetch_shape = async () => {\n set_is_loading(true);\n\n try {\n await query(\n `OUTPUT FROM system::namespaces; OUTPUT FROM system::tables; OUTPUT FROM system::views; OUTPUT FROM system::columns;`,\n undefined,\n [namespace_shape, table_shape, view_shape, column_shape]\n );\n } catch (err) {\n console.error('Failed to fetch shape:', err);\n }\n };\n\n fetch_shape();\n }, [query]);\n\n useEffect(() => {\n if (!results || results.length < 4) {\n set_is_loading(is_executing);\n return;\n }\n\n const tables_result = results[1];\n const views_result = results[2];\n const columns_result = results[3];\n\n if (!tables_result?.rows || !views_result?.rows || !columns_result?.rows) {\n set_is_loading(false);\n return;\n }\n\n const namespaces_result = results[0];\n const namespaces = namespaces_result.rows as unknown as NamespaceRow[];\n const tables = tables_result.rows as unknown as TableRow[];\n const views = views_result.rows as unknown as ViewRow[];\n const columns = columns_result.rows as unknown as ColumnRow[];\n\n const namespace_map = 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 namespace_map.set(id, name);\n }\n });\n\n const table_info_map = new Map<number, TableInfo>();\n\n tables.forEach((table) => {\n const table_id = table.id?.valueOf() as number;\n const namespace_id = table.namespace_id?.valueOf() as number;\n const table_name = table.name?.valueOf() as string;\n\n if (table_id === undefined || !table_name || namespace_id === undefined) return;\n\n const namespace = namespace_map.get(namespace_id);\n if (!namespace) return;\n\n const full_table_name = `${namespace}::${table_name}`;\n\n table_info_map.set(table_id, {\n name: full_table_name,\n columns: [],\n });\n });\n\n views.forEach((view) => {\n const view_id = view.id?.valueOf() as number;\n const namespace_id = view.namespace_id?.valueOf() as number;\n const view_name = view.name?.valueOf() as string;\n\n if (view_id === undefined || !view_name || namespace_id === undefined) return;\n\n const namespace = namespace_map.get(namespace_id);\n if (!namespace) return;\n\n const full_view_name = `${namespace}::${view_name}`;\n\n table_info_map.set(view_id, {\n name: full_view_name,\n columns: [],\n });\n });\n\n const type_map: Record<number, string> = {\n 0: 'None',\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: 'IdentityId',\n 20: 'Uuid4',\n 21: 'Uuid7',\n 22: 'Blob',\n 23: 'Int',\n 24: 'Decimal',\n 25: 'Uint',\n 26: 'Any',\n };\n\n // Create a map to collect columns with their positions\n const table_columns_map = new Map<number, Array<{name: string; data_type: string; position: number}>>();\n\n columns.forEach((column) => {\n const shape_id = column.shape_id?.valueOf() as number;\n const shape_type = column.shape_type?.valueOf() as number;\n const column_name = column.name?.valueOf() as string;\n const type_id = column.type?.valueOf() as number;\n const position = column.position?.valueOf() as number;\n\n if (shape_id === undefined || !column_name || type_id === undefined) return;\n if (shape_type !== 0 && shape_type !== 1) return;\n\n if (!table_columns_map.has(shape_id)) {\n table_columns_map.set(shape_id, []);\n }\n\n table_columns_map.get(shape_id)!.push({\n name: column_name,\n data_type: type_map[type_id] || `Unknown(${type_id})`,\n position: position ?? 0,\n });\n });\n\n // Sort columns by position and add to table info\n table_columns_map.forEach((cols, shape_id) => {\n const table_info = table_info_map.get(shape_id);\n if (table_info) {\n cols.sort((a, b) => a.position - b.position);\n table_info.columns = cols.map((c) => ({name: c.name, data_type: c.data_type}));\n }\n });\n\n const shape_array = Array.from(table_info_map.values())\n .filter((table) => table.name !== 'reifydb::flows')\n .sort((a, b) => a.name.localeCompare(b.name));\n\n set_shape(shape_array);\n set_is_loading(false);\n }, [results, is_executing]);\n\n return [is_loading, shape, error];\n}\n"],"mappings":";AAGA,cAAc;AACd,cAAc;;;ACDd,SAAQ,cAAuF;AAiBxF,IAAM,iBAAmC;AAAA,EAC5C,KAAK;AAAA,EACL,SAAS,EAAC,YAAY,IAAM;AAChC;AAEO,IAAM,cAAc;AAEpB,IAAM,aAAN,MAAiB;AAAA,EAWpB,YAAY,SAA2B,gBAAgB;AAVvD,SAAQ,QAAyB;AAAA,MAC7B,QAAQ;AAAA,MACR,cAAc;AAAA,MAC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EAAE;AAAA,MACjF;AAAA,IACJ,CAAC;AAED,UAAM,cAAc,MAAM,KAAK,eAAe,OAAO,CAAC,EACjD,OAAO,CAAC,UAAU,MAAM,SAAS,gBAAgB,EACjD,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;AAEhD,cAAU,WAAW;AACrB,mBAAe,KAAK;AAAA,EACxB,GAAG,CAAC,SAAS,YAAY,CAAC;AAE1B,SAAO,CAAC,YAAY,OAAO,KAAK;AACpC;","names":["useEffect","useEffect","useState","useRef","useEffect","useState","useRef","useEffect","useEffect","useEffect","useState","useCallback","useRef","useEffect","useState","useRef","useEffect","useCallback","useEffect","useMemo","useEffect","useMemo","useState","useCallback","useRef","useEffect","useState","useRef","useEffect","useCallback","useEffect","useMemo","useEffect","useMemo","useState","useCallback","useRef","useEffect","useState","useRef","useEffect","useCallback","useEffect","useMemo","useMemo","useEffect","useEffect","useState","useState","useEffect"]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@reifydb/react",
3
- "version": "0.4.10",
3
+ "version": "0.4.11",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "dependencies": {
8
- "@reifydb/core": "0.4.10",
9
- "@reifydb/client": "0.4.10"
8
+ "@reifydb/client": "0.4.11",
9
+ "@reifydb/core": "0.4.11"
10
10
  },
11
11
  "peerDependencies": {
12
12
  "react": ">=16.8.0"