@ahoo-wang/fetcher-react 3.3.8 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -40,11 +40,16 @@ robust data fetching capabilities.
40
40
  - [useEventSubscription Hook](#useeventsubscription-hook)
41
41
  - [useKeyStorage Hook](#usekeystorage-hook)
42
42
  - [useImmerKeyStorage Hook](#useimmerkeystorage-hook)
43
- - [Wow Query Hooks](#wow-query-hooks)
43
+ - [Wow Query Hooks](#wow-query-hooks)
44
44
  - [useListQuery Hook](#uselistquery-hook)
45
45
  - [usePagedQuery Hook](#usepagedquery-hook)
46
46
  - [useSingleQuery Hook](#usesinglequery-hook)
47
47
  - [useCountQuery Hook](#usecountquery-hook)
48
+ - [useFetcherCountQuery Hook](#usefetchercountquery-hook)
49
+ - [useFetcherPagedQuery Hook](#usefetcherpagedquery-hook)
50
+ - [useFetcherListQuery Hook](#usefetcherlistquery-hook)
51
+ - [useFetcherListStreamQuery Hook](#usefetcherliststreamquery-hook)
52
+ - [useFetcherSingleQuery Hook](#usefetchersinglequery-hook)
48
53
  - [useListStreamQuery Hook](#useliststreamquery-hook)
49
54
  - [Best Practices](#best-practices)
50
55
  - [API Reference](#api-reference)
@@ -1129,6 +1134,447 @@ const MyComponent = () => {
1129
1134
  };
1130
1135
  ```
1131
1136
 
1137
+ ### useFetcherCountQuery Hook
1138
+
1139
+ The `useFetcherCountQuery` hook is a specialized React hook for performing count queries using the Fetcher library. It is designed for scenarios where you need to retrieve the count of records that match a specific condition, returning a number representing the count.
1140
+
1141
+ ```typescript jsx
1142
+ import { useFetcherCountQuery } from '@ahoo-wang/fetcher-react';
1143
+ import { all } from '@ahoo-wang/fetcher-wow';
1144
+ function UserCountComponent() {
1145
+ const { data: count, loading, error, execute } = useFetcherCountQuery({
1146
+ url: '/api/users/count',
1147
+ initialQuery: all(),
1148
+ autoExecute: true,
1149
+ });
1150
+ if (loading) return <div>Loading...</div>;
1151
+ if (error) return <div>Error: {error.message}</div>;
1152
+ return (
1153
+ <div>
1154
+ <div>Total active users: {count}</div>
1155
+ <button onClick={execute}>Refresh Count</button>
1156
+ </div>
1157
+ );
1158
+ }
1159
+ ```
1160
+
1161
+ #### Auto Execute Example
1162
+
1163
+ ```typescript jsx
1164
+ import { useFetcherCountQuery } from '@ahoo-wang/fetcher-react';
1165
+ const MyComponent = () => {
1166
+ const { data: count, loading, error, execute } = useFetcherCountQuery({
1167
+ url: '/api/users/count',
1168
+ initialQuery: { status: 'active' },
1169
+ autoExecute: true, // Automatically execute on component mount
1170
+ });
1171
+ // The query will execute automatically when the component mounts
1172
+ if (loading) return <div>Loading...</div>;
1173
+ if (error) return <div>Error: {error.message}</div>;
1174
+ return (
1175
+ <div>
1176
+ <p>Total active users: {count}</p>
1177
+ </div>
1178
+ );
1179
+ };
1180
+ ```
1181
+
1182
+ ### useFetcherPagedQuery Hook
1183
+
1184
+ The `useFetcherPagedQuery` hook is a specialized React hook for performing paged queries using the Fetcher library. It is designed for scenarios where you need to retrieve paginated data that matches a query condition, returning a PagedList containing the items for the current page along with pagination metadata.
1185
+
1186
+ ```typescript jsx
1187
+ import { useFetcherPagedQuery } from '@ahoo-wang/fetcher-react';
1188
+ import { pagedQuery, contains, pagination, desc } from '@ahoo-wang/fetcher-wow';
1189
+
1190
+ interface User {
1191
+ id: number;
1192
+ name: string;
1193
+ email: string;
1194
+ }
1195
+
1196
+ function UserListComponent() {
1197
+ const {
1198
+ data: pagedList,
1199
+ loading,
1200
+ error,
1201
+ execute,
1202
+ setQuery,
1203
+ getQuery
1204
+ } = useFetcherPagedQuery<User, keyof User>({
1205
+ url: '/api/users/paged',
1206
+ initialQuery: pagedQuery({
1207
+ condition: contains('name', 'John'),
1208
+ sort: [desc('createdAt')],
1209
+ pagination: pagination({ index: 1, size: 10 })
1210
+ }),
1211
+ autoExecute: true,
1212
+ });
1213
+
1214
+ const goToPage = (page: number) => {
1215
+ const currentQuery = getQuery();
1216
+ setQuery({
1217
+ ...currentQuery,
1218
+ pagination: { ...currentQuery.pagination, index: page }
1219
+ });
1220
+ };
1221
+
1222
+ if (loading) return <div>Loading...</div>;
1223
+ if (error) return <div>Error: {error.message}</div>;
1224
+
1225
+ return (
1226
+ <div>
1227
+ <h2>Users</h2>
1228
+ <ul>
1229
+ {pagedList.list.map(user => (
1230
+ <li key={user.id}>{user.name} - {user.email}</li>
1231
+ ))}
1232
+ </ul>
1233
+ <div>
1234
+ <span>Total: {pagedList.total} users</span>
1235
+ <button onClick={() => goToPage(1)} disabled={pagedList.pagination.index === 1}>
1236
+ First
1237
+ </button>
1238
+ <button onClick={() => goToPage(pagedList.pagination.index - 1)} disabled={pagedList.pagination.index === 1}>
1239
+ Previous
1240
+ </button>
1241
+ <span>Page {pagedList.pagination.index}</span>
1242
+ <button onClick={() => goToPage(pagedList.pagination.index + 1)}>
1243
+ Next
1244
+ </button>
1245
+ </div>
1246
+ </div>
1247
+ );
1248
+ }
1249
+ ```
1250
+
1251
+ #### Auto Execute Example
1252
+
1253
+ ```typescript jsx
1254
+ import { useFetcherPagedQuery } from '@ahoo-wang/fetcher-react';
1255
+
1256
+ const MyComponent = () => {
1257
+ const { data: pagedList, loading, error, execute } = useFetcherPagedQuery({
1258
+ url: '/api/products/paged',
1259
+ initialQuery: {
1260
+ condition: { category: 'electronics' },
1261
+ pagination: { index: 1, size: 20 },
1262
+ projection: {},
1263
+ sort: []
1264
+ },
1265
+ autoExecute: true, // Automatically execute on component mount
1266
+ });
1267
+
1268
+ // The query will execute automatically when the component mounts
1269
+
1270
+ if (loading) return <div>Loading...</div>;
1271
+ if (error) return <div>Error: {error.message}</div>;
1272
+
1273
+ return (
1274
+ <div>
1275
+ <h2>Products</h2>
1276
+ <div>Total: {pagedList.total}</div>
1277
+ <ul>
1278
+ {pagedList.list.map(product => (
1279
+ <li key={product.id}>{product.name}</li>
1280
+ ))}
1281
+ </ul>
1282
+ </div>
1283
+ );
1284
+ };
1285
+ ```
1286
+
1287
+ ### useFetcherListQuery Hook
1288
+
1289
+ The `useFetcherListQuery` hook is a specialized React hook for performing list queries using the Fetcher library. It is designed for fetching lists of items with support for filtering, sorting, and pagination through the ListQuery type, returning an array of results.
1290
+
1291
+ ```typescript jsx
1292
+ import { useFetcherListQuery } from '@ahoo-wang/fetcher-react';
1293
+ import { listQuery, contains, desc } from '@ahoo-wang/fetcher-wow';
1294
+
1295
+ interface User {
1296
+ id: string;
1297
+ name: string;
1298
+ email: string;
1299
+ createdAt: string;
1300
+ }
1301
+
1302
+ function UserListComponent() {
1303
+ const {
1304
+ loading,
1305
+ result: users,
1306
+ error,
1307
+ execute,
1308
+ setQuery,
1309
+ getQuery,
1310
+ } = useFetcherListQuery<User, keyof User>({
1311
+ url: '/api/users/list',
1312
+ initialQuery: listQuery({
1313
+ condition: contains('name', 'John'),
1314
+ sort: [desc('createdAt')],
1315
+ limit: 10,
1316
+ }),
1317
+ autoExecute: true,
1318
+ });
1319
+
1320
+ const loadMore = () => {
1321
+ const currentQuery = getQuery();
1322
+ setQuery({
1323
+ ...currentQuery,
1324
+ limit: (currentQuery.limit || 10) + 10,
1325
+ });
1326
+ };
1327
+
1328
+ if (loading) return <div>Loading users...</div>;
1329
+ if (error) return <div>Error: {error.message}</div>;
1330
+
1331
+ return (
1332
+ <div>
1333
+ <h2>Users ({users?.length || 0})</h2>
1334
+ <ul>
1335
+ {users?.map(user => (
1336
+ <li key={user.id}>
1337
+ {user.name} - {user.email}
1338
+ </li>
1339
+ ))}
1340
+ </ul>
1341
+ <button onClick={loadMore}>Load More</button>
1342
+ <button onClick={execute}>Refresh list</button>
1343
+ </div>
1344
+ );
1345
+ }
1346
+ ```
1347
+
1348
+ #### Auto Execute Example
1349
+
1350
+ ```typescript jsx
1351
+ import { useFetcherListQuery } from '@ahoo-wang/fetcher-react';
1352
+
1353
+ const MyComponent = () => {
1354
+ const { result: products, loading, error, execute } = useFetcherListQuery({
1355
+ url: '/api/products/list',
1356
+ initialQuery: {
1357
+ condition: { category: 'electronics' },
1358
+ projection: {},
1359
+ sort: [],
1360
+ limit: 20
1361
+ },
1362
+ autoExecute: true, // Automatically execute on component mount
1363
+ });
1364
+
1365
+ // The query will execute automatically when the component mounts
1366
+
1367
+ if (loading) return <div>Loading...</div>;
1368
+ if (error) return <div>Error: {error.message}</div>;
1369
+
1370
+ return (
1371
+ <div>
1372
+ <h2>Products</h2>
1373
+ <ul>
1374
+ {products?.map(product => (
1375
+ <li key={product.id}>{product.name}</li>
1376
+ ))}
1377
+ </ul>
1378
+ </div>
1379
+ );
1380
+ };
1381
+ ```
1382
+
1383
+ ### useFetcherListStreamQuery Hook
1384
+
1385
+ The `useFetcherListStreamQuery` hook is a specialized React hook for performing list stream queries using the Fetcher library with server-sent events. It is designed for scenarios where you need to retrieve a stream of data that matches a list query condition, returning a ReadableStream of JSON server-sent events for real-time data streaming.
1386
+
1387
+ ```typescript jsx
1388
+ import { useFetcherListStreamQuery } from '@ahoo-wang/fetcher-react';
1389
+ import { listQuery, contains } from '@ahoo-wang/fetcher-wow';
1390
+ import { JsonServerSentEvent } from '@ahoo-wang/fetcher-eventstream';
1391
+ import { useEffect, useRef } from 'react';
1392
+
1393
+ interface User {
1394
+ id: number;
1395
+ name: string;
1396
+ }
1397
+
1398
+ function UserStreamComponent() {
1399
+ const { data: stream, loading, error, execute } = useFetcherListStreamQuery<User, 'id' | 'name'>({
1400
+ url: '/api/users/stream',
1401
+ initialQuery: listQuery({
1402
+ condition: contains('name', 'John'),
1403
+ limit: 10,
1404
+ }),
1405
+ autoExecute: true,
1406
+ });
1407
+
1408
+ const messagesRef = useRef<HTMLDivElement>(null);
1409
+
1410
+ useEffect(() => {
1411
+ if (stream) {
1412
+ const reader = stream.getReader();
1413
+ const readStream = async () => {
1414
+ try {
1415
+ while (true) {
1416
+ const { done, value } = await reader.read();
1417
+ if (done) break;
1418
+ // Process the JsonServerSentEvent<User>
1419
+ const newUser = value.data;
1420
+ if (messagesRef.current) {
1421
+ const div = document.createElement('div');
1422
+ div.textContent = `New user: ${newUser.name}`;
1423
+ messagesRef.current.appendChild(div);
1424
+ }
1425
+ }
1426
+ } catch (err) {
1427
+ console.error('Stream error:', err);
1428
+ }
1429
+ };
1430
+ readStream();
1431
+ }
1432
+ }, [stream]);
1433
+
1434
+ if (loading) return <div>Loading stream...</div>;
1435
+ if (error) return <div>Error: {error.message}</div>;
1436
+
1437
+ return (
1438
+ <div>
1439
+ <div ref={messagesRef}></div>
1440
+ <button onClick={execute}>Restart Stream</button>
1441
+ </div>
1442
+ );
1443
+ }
1444
+ ```
1445
+
1446
+ #### Auto Execute Example
1447
+
1448
+ ```typescript jsx
1449
+ import { useFetcherListStreamQuery } from '@ahoo-wang/fetcher-react';
1450
+ import { useEffect, useRef } from 'react';
1451
+
1452
+ const MyComponent = () => {
1453
+ const { data: stream, loading, error, execute } = useFetcherListStreamQuery({
1454
+ url: '/api/notifications/stream',
1455
+ initialQuery: {
1456
+ condition: { type: 'important' },
1457
+ limit: 50
1458
+ },
1459
+ autoExecute: true, // Automatically execute on component mount
1460
+ });
1461
+
1462
+ const notificationsRef = useRef<HTMLDivElement>(null);
1463
+
1464
+ useEffect(() => {
1465
+ if (stream) {
1466
+ const reader = stream.getReader();
1467
+ const processStream = async () => {
1468
+ try {
1469
+ while (true) {
1470
+ const { done, value } = await reader.read();
1471
+ if (done) break;
1472
+
1473
+ const notification = value.data;
1474
+ if (notificationsRef.current) {
1475
+ const notificationDiv = document.createElement('div');
1476
+ notificationDiv.textContent = `Notification: ${notification.message}`;
1477
+ notificationsRef.current.appendChild(notificationDiv);
1478
+ }
1479
+ }
1480
+ } catch (err) {
1481
+ console.error('Stream processing error:', err);
1482
+ }
1483
+ };
1484
+ processStream();
1485
+ }
1486
+ }, [stream]);
1487
+
1488
+ // The stream will start automatically when the component mounts
1489
+
1490
+ if (loading) return <div>Loading...</div>;
1491
+ if (error) return <div>Error: {error.message}</div>;
1492
+
1493
+ return (
1494
+ <div>
1495
+ <h2>Live Notifications</h2>
1496
+ <div ref={notificationsRef}></div>
1497
+ </div>
1498
+ );
1499
+ };
1500
+ ```
1501
+
1502
+ ### useFetcherSingleQuery Hook
1503
+
1504
+ The `useFetcherSingleQuery` hook is a specialized React hook for performing single item queries using the Fetcher library. It is designed for fetching a single item with support for filtering and sorting through the SingleQuery type, returning a single result item.
1505
+
1506
+ ```typescript jsx
1507
+ import { useFetcherSingleQuery } from '@ahoo-wang/fetcher-react';
1508
+ import { singleQuery, eq } from '@ahoo-wang/fetcher-wow';
1509
+
1510
+ interface User {
1511
+ id: string;
1512
+ name: string;
1513
+ email: string;
1514
+ createdAt: string;
1515
+ }
1516
+
1517
+ function UserProfileComponent({ userId }: { userId: string }) {
1518
+ const {
1519
+ loading,
1520
+ result: user,
1521
+ error,
1522
+ execute,
1523
+ } = useFetcherSingleQuery<User, keyof User>({
1524
+ url: `/api/users/${userId}`,
1525
+ initialQuery: singleQuery({
1526
+ condition: eq('id', userId),
1527
+ }),
1528
+ autoExecute: true,
1529
+ });
1530
+
1531
+ if (loading) return <div>Loading user...</div>;
1532
+ if (error) return <div>Error: {error.message}</div>;
1533
+ if (!user) return <div>User not found</div>;
1534
+
1535
+ return (
1536
+ <div>
1537
+ <h2>{user.name}</h2>
1538
+ <p>Email: {user.email}</p>
1539
+ <p>Created: {user.createdAt}</p>
1540
+ <button onClick={execute}>Refresh</button>
1541
+ </div>
1542
+ );
1543
+ }
1544
+ ```
1545
+
1546
+ #### Auto Execute Example
1547
+
1548
+ ```typescript jsx
1549
+ import { useFetcherSingleQuery } from '@ahoo-wang/fetcher-react';
1550
+
1551
+ const MyComponent = () => {
1552
+ const { result: product, loading, error, execute } = useFetcherSingleQuery({
1553
+ url: '/api/products/featured',
1554
+ initialQuery: {
1555
+ condition: { featured: true },
1556
+ projection: {},
1557
+ sort: []
1558
+ },
1559
+ autoExecute: true, // Automatically execute on component mount
1560
+ });
1561
+
1562
+ // The query will execute automatically when the component mounts
1563
+
1564
+ if (loading) return <div>Loading...</div>;
1565
+ if (error) return <div>Error: {error.message}</div>;
1566
+ if (!product) return <div>Product not found</div>;
1567
+
1568
+ return (
1569
+ <div>
1570
+ <h2>Featured Product</h2>
1571
+ <div>{product.name}</div>
1572
+ <div>{product.description}</div>
1573
+ </div>
1574
+ );
1575
+ };
1576
+ ```
1577
+
1132
1578
  ### useListStreamQuery Hook
1133
1579
 
1134
1580
  The `useListStreamQuery` hook manages list stream queries that return a readable stream of server-sent events.
@@ -2242,6 +2688,156 @@ A React hook for managing count queries with state management for conditions.
2242
2688
 
2243
2689
  An object containing promise state, execute function, and setter for condition.
2244
2690
 
2691
+ ### useFetcherCountQuery
2692
+
2693
+ ```typescript
2694
+ function useFetcherCountQuery<FIELDS extends string = string, E = FetcherError>(
2695
+ options: UseFetcherCountQueryOptions<FIELDS, E>,
2696
+ ): UseFetcherCountQueryReturn<FIELDS, E>;
2697
+ ```
2698
+
2699
+ A React hook for performing count queries using the Fetcher library. It wraps the useFetcherQuery hook and specializes it for count operations, returning a number representing the count.
2700
+
2701
+ **Type Parameters:**
2702
+
2703
+ - `FIELDS`: A string union type representing the fields that can be used in the condition
2704
+ - `E`: The type of error that may be thrown (defaults to `FetcherError`)
2705
+
2706
+ **Parameters:**
2707
+
2708
+ - `options`: Configuration options for the count query, including the condition, fetcher instance, and other query settings
2709
+ - `url`: The URL to fetch the count from
2710
+ - `initialQuery`: The initial condition for the count query
2711
+ - `autoExecute`: Whether to automatically execute the query on component mount (defaults to false)
2712
+
2713
+ **Returns:**
2714
+
2715
+ An object containing the query result (count as a number), loading state, error state, and utility functions.
2716
+
2717
+ ### useFetcherPagedQuery
2718
+
2719
+ ```typescript
2720
+ function useFetcherPagedQuery<
2721
+ R,
2722
+ FIELDS extends string = string,
2723
+ E = FetcherError,
2724
+ >(
2725
+ options: UseFetcherPagedQueryOptions<R, FIELDS, E>,
2726
+ ): UseFetcherPagedQueryReturn<R, FIELDS, E>;
2727
+ ```
2728
+
2729
+ A React hook for performing paged queries using the Fetcher library. It wraps the useFetcherQuery hook and specializes it for paged operations, returning a PagedList containing items and pagination metadata.
2730
+
2731
+ **Type Parameters:**
2732
+
2733
+ - `R`: The type of the resource or entity contained in each item of the paged list
2734
+ - `FIELDS`: A string union type representing the fields that can be used in the paged query
2735
+ - `E`: The type of error that may be thrown (defaults to `FetcherError`)
2736
+
2737
+ **Parameters:**
2738
+
2739
+ - `options`: Configuration options for the paged query, including the paged query parameters, fetcher instance, and other query settings
2740
+ - `url`: The URL to fetch the paged data from
2741
+ - `initialQuery`: The initial paged query configuration
2742
+ - `autoExecute`: Whether to automatically execute the query on component mount (defaults to false)
2743
+
2744
+ **Returns:**
2745
+
2746
+ An object containing the query result (PagedList with items and pagination info), loading state, error state, and utility functions.
2747
+
2748
+ ### useFetcherListQuery
2749
+
2750
+ ```typescript
2751
+ function useFetcherListQuery<
2752
+ R,
2753
+ FIELDS extends string = string,
2754
+ E = FetcherError,
2755
+ >(
2756
+ options: UseFetcherListQueryOptions<R, FIELDS, E>,
2757
+ ): UseFetcherListQueryReturn<R, FIELDS, E>;
2758
+ ```
2759
+
2760
+ A React hook for executing list queries using the fetcher library within the wow framework. It wraps the useFetcherQuery hook and specializes it for list operations, returning an array of results with support for filtering, sorting, and pagination.
2761
+
2762
+ **Type Parameters:**
2763
+
2764
+ - `R`: The type of individual items in the result array (e.g., User, Product)
2765
+ - `FIELDS`: The fields available for filtering, sorting, and pagination in the list query
2766
+ - `E`: The type of error that may be thrown (defaults to `FetcherError`)
2767
+
2768
+ **Parameters:**
2769
+
2770
+ - `options`: Configuration options for the list query, including the list query parameters, fetcher instance, and other query settings
2771
+ - `url`: The URL to fetch the list data from
2772
+ - `initialQuery`: The initial list query configuration
2773
+ - `autoExecute`: Whether to automatically execute the query on component mount (defaults to false)
2774
+
2775
+ **Returns:**
2776
+
2777
+ An object containing the query result (array of items), loading state, error state, and utility functions.
2778
+
2779
+ ### useFetcherListStreamQuery
2780
+
2781
+ ```typescript
2782
+ function useFetcherListStreamQuery<
2783
+ R,
2784
+ FIELDS extends string = string,
2785
+ E = FetcherError,
2786
+ >(
2787
+ options: UseFetcherListStreamQueryOptions<R, FIELDS, E>,
2788
+ ): UseFetcherListStreamQueryReturn<R, FIELDS, E>;
2789
+ ```
2790
+
2791
+ A React hook for performing list stream queries using the Fetcher library with server-sent events. It wraps the useFetcherQuery hook and specializes it for streaming operations, returning a ReadableStream of JSON server-sent events for real-time data streaming.
2792
+
2793
+ **Type Parameters:**
2794
+
2795
+ - `R`: The type of the resource or entity contained in each event in the stream
2796
+ - `FIELDS`: The fields available for filtering, sorting, and pagination in the list query
2797
+ - `E`: The type of error that may be thrown (defaults to `FetcherError`)
2798
+
2799
+ **Parameters:**
2800
+
2801
+ - `options`: Configuration options for the list stream query, including the list query parameters, fetcher instance, and other query settings
2802
+ - `url`: The URL to fetch the stream data from
2803
+ - `initialQuery`: The initial list query configuration
2804
+ - `autoExecute`: Whether to automatically execute the query on component mount (defaults to false)
2805
+
2806
+ **Returns:**
2807
+
2808
+ An object containing the query result (ReadableStream of JSON server-sent events), loading state, error state, and utility functions.
2809
+
2810
+ ### useFetcherSingleQuery
2811
+
2812
+ ```typescript
2813
+ function useFetcherSingleQuery<
2814
+ R,
2815
+ FIELDS extends string = string,
2816
+ E = FetcherError,
2817
+ >(
2818
+ options: UseFetcherSingleQueryOptions<R, FIELDS, E>,
2819
+ ): UseFetcherSingleQueryReturn<R, FIELDS, E>;
2820
+ ```
2821
+
2822
+ A React hook for executing single item queries using the fetcher library within the wow framework. It wraps the useFetcherQuery hook and specializes it for single item operations, returning a single result item with support for filtering and sorting.
2823
+
2824
+ **Type Parameters:**
2825
+
2826
+ - `R`: The type of the result item (e.g., User, Product)
2827
+ - `FIELDS`: The fields available for filtering and sorting in the single query
2828
+ - `E`: The type of error that may be thrown (defaults to `FetcherError`)
2829
+
2830
+ **Parameters:**
2831
+
2832
+ - `options`: Configuration options for the single query, including the single query parameters, fetcher instance, and other query settings
2833
+ - `url`: The URL to fetch the single item from
2834
+ - `initialQuery`: The initial single query configuration
2835
+ - `autoExecute`: Whether to automatically execute the query on component mount (defaults to false)
2836
+
2837
+ **Returns:**
2838
+
2839
+ An object containing the query result (single item), loading state, error state, and utility functions.
2840
+
2245
2841
  ### useListStreamQuery
2246
2842
 
2247
2843
  ```typescript