@faasjs/react 8.0.0-beta.20 → 8.0.0-beta.22
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 +158 -216
- package/dist/index.mjs +295 -297
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -7,13 +7,15 @@ import { FaasAction, FaasAction as FaasAction$1, FaasActionUnionType, FaasAction
|
|
|
7
7
|
/**
|
|
8
8
|
* Generate a random identifier with an optional prefix.
|
|
9
9
|
*
|
|
10
|
-
* @param prefix - Prefix prepended to the generated identifier.
|
|
11
|
-
* @param length - Length of the generated identifier excluding `prefix`. Must be between `8` and `18`.
|
|
12
|
-
* @returns Generated identifier string.
|
|
10
|
+
* @param {string} [prefix] - Prefix prepended to the generated identifier.
|
|
11
|
+
* @param {number} [length] - Length of the generated identifier excluding `prefix`. Must be between `8` and `18`.
|
|
12
|
+
* @returns {string} Generated identifier string.
|
|
13
13
|
* @throws {Error} When `length` is outside the supported `8` to `18` range.
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```ts
|
|
17
|
+
* import { generateId } from '@faasjs/react'
|
|
18
|
+
*
|
|
17
19
|
* const id = generateId('prefix-')
|
|
18
20
|
*
|
|
19
21
|
* id.startsWith('prefix-') // true
|
|
@@ -35,8 +37,8 @@ declare function generateId(prefix?: string, length?: number): string;
|
|
|
35
37
|
* - Ensures consistent URL formatting across the codebase
|
|
36
38
|
* - Throws Error at runtime if baseUrl doesn't end with '/'
|
|
37
39
|
*
|
|
38
|
-
* @see FaasBrowserClient for usage in client creation
|
|
39
|
-
* @see Options for usage in request options
|
|
40
|
+
* @see {@link FaasBrowserClient} for usage in client creation.
|
|
41
|
+
* @see {@link Options} for usage in request options.
|
|
40
42
|
*/
|
|
41
43
|
type BaseUrl = `${string}/`;
|
|
42
44
|
/**
|
|
@@ -78,8 +80,8 @@ type BaseUrl = `${string}/`;
|
|
|
78
80
|
* When false or undefined, returns a wrapped Response with automatic JSON parsing.
|
|
79
81
|
*
|
|
80
82
|
* @augments RequestInit
|
|
81
|
-
* @see FaasBrowserClient for client creation
|
|
82
|
-
* @see Response for response object structure
|
|
83
|
+
* @see {@link FaasBrowserClient} for client creation.
|
|
84
|
+
* @see {@link Response} for response object structure.
|
|
83
85
|
*/
|
|
84
86
|
type Options = RequestInit & {
|
|
85
87
|
headers?: Record<string, string>; /** Async hook called after request options are merged but before the request is sent. */
|
|
@@ -114,9 +116,9 @@ type Options = RequestInit & {
|
|
|
114
116
|
* - Used in Response, ResponseError, and Options types
|
|
115
117
|
* - Simplified model compared to browser's Headers interface (no .get(), .set() methods)
|
|
116
118
|
*
|
|
117
|
-
* @see Response for usage in response objects
|
|
118
|
-
* @see ResponseError for usage in error objects
|
|
119
|
-
* @see Options for usage in request options
|
|
119
|
+
* @see {@link Response} for usage in response objects.
|
|
120
|
+
* @see {@link ResponseError} for usage in error objects.
|
|
121
|
+
* @see {@link Options} for usage in request options.
|
|
120
122
|
*/
|
|
121
123
|
type ResponseHeaders = {
|
|
122
124
|
[key: string]: string;
|
|
@@ -129,12 +131,12 @@ type ResponseHeaders = {
|
|
|
129
131
|
*
|
|
130
132
|
* @template PathOrData - The function path or data type for type safety
|
|
131
133
|
*
|
|
132
|
-
* @param action - The function path to call.
|
|
133
|
-
* @param params - Optional parameters for the function.
|
|
134
|
-
* @param options - Optional request overrides.
|
|
134
|
+
* @param {FaasAction<PathOrData>} action - The function path to call.
|
|
135
|
+
* @param {FaasParams<PathOrData>} [params] - Optional parameters for the function.
|
|
136
|
+
* @param {Options} [options] - Optional request overrides.
|
|
135
137
|
* See {@link Options} for supported request fields such as `headers`, `beforeRequest`,
|
|
136
138
|
* `request`, `baseUrl`, and `stream`.
|
|
137
|
-
* @returns Promise resolving to the request response. In streaming mode the runtime returns the native fetch response.
|
|
139
|
+
* @returns {Promise<Response<FaasData<PathOrData>> | Response>} Promise resolving to the request response. In streaming mode the runtime returns the native fetch response.
|
|
138
140
|
*
|
|
139
141
|
* Notes:
|
|
140
142
|
* - Used internally by FaasBrowserClient.action method
|
|
@@ -143,9 +145,9 @@ type ResponseHeaders = {
|
|
|
143
145
|
* - Params are optional and can be undefined
|
|
144
146
|
* - Options override client defaults when provided
|
|
145
147
|
*
|
|
146
|
-
* @see FaasBrowserClient for the class that uses this type
|
|
147
|
-
* @see Response for the return type
|
|
148
|
-
* @see Options for the options parameter type
|
|
148
|
+
* @see {@link FaasBrowserClient} for the class that uses this type.
|
|
149
|
+
* @see {@link Response} for the return type.
|
|
150
|
+
* @see {@link Options} for the options parameter type.
|
|
149
151
|
*/
|
|
150
152
|
type FaasBrowserClientAction = <PathOrData extends FaasActionUnionType$1>(action: FaasAction$1<PathOrData>, params?: FaasParams$1<PathOrData>, options?: Options) => Promise<Response<FaasData$1<PathOrData>> | Response>;
|
|
151
153
|
/**
|
|
@@ -175,8 +177,8 @@ type FaasBrowserClientAction = <PathOrData extends FaasActionUnionType$1>(action
|
|
|
175
177
|
* - If data is provided without body, body is automatically JSON.stringify(data)
|
|
176
178
|
* - Used by Response constructor and mock handlers
|
|
177
179
|
*
|
|
178
|
-
* @see Response for the class that uses these properties
|
|
179
|
-
* @see ResponseErrorProps for error response properties
|
|
180
|
+
* @see {@link Response} for the class that uses these properties.
|
|
181
|
+
* @see {@link ResponseErrorProps} for error response properties.
|
|
180
182
|
*/
|
|
181
183
|
type ResponseProps<T = any> = {
|
|
182
184
|
status?: number;
|
|
@@ -295,9 +297,9 @@ type ResponseProps<T = any> = {
|
|
|
295
297
|
* })
|
|
296
298
|
* ```
|
|
297
299
|
*
|
|
298
|
-
* @see ResponseProps for response property type
|
|
299
|
-
* @see ResponseError for error response handling
|
|
300
|
-
* @see FaasBrowserClient.action for method returning Response
|
|
300
|
+
* @see {@link ResponseProps} for response property type.
|
|
301
|
+
* @see {@link ResponseError} for error response handling.
|
|
302
|
+
* @see {@link FaasBrowserClient.action} for method returning Response.
|
|
301
303
|
*/
|
|
302
304
|
declare class Response<T = any> {
|
|
303
305
|
/**
|
|
@@ -319,12 +321,12 @@ declare class Response<T = any> {
|
|
|
319
321
|
/**
|
|
320
322
|
* Create a wrapped response object.
|
|
321
323
|
*
|
|
322
|
-
* @param props - Response properties including status, headers, body, and data.
|
|
323
|
-
* @param props.status - HTTP status code. Defaults to `200` when `data` or `body` exists, otherwise `204`.
|
|
324
|
-
* @param props.headers - Response headers keyed by header name.
|
|
325
|
-
* @param props.body - Raw response body to expose without additional parsing.
|
|
326
|
-
* @param props.data - Parsed response payload to expose on `response.data`.
|
|
327
|
-
* @returns Wrapped response instance.
|
|
324
|
+
* @param {ResponseProps<T>} [props] - Response properties including status, headers, body, and data.
|
|
325
|
+
* @param {number} [props.status] - HTTP status code. Defaults to `200` when `data` or `body` exists, otherwise `204`.
|
|
326
|
+
* @param {ResponseHeaders} [props.headers] - Response headers keyed by header name.
|
|
327
|
+
* @param {any} [props.body] - Raw response body to expose without additional parsing.
|
|
328
|
+
* @param {T} [props.data] - Parsed response payload to expose on `response.data`.
|
|
329
|
+
* @returns {Response<T>} Wrapped response instance.
|
|
328
330
|
*/
|
|
329
331
|
constructor(props?: ResponseProps<T>);
|
|
330
332
|
}
|
|
@@ -430,9 +432,9 @@ type ResponseErrorProps = {
|
|
|
430
432
|
* - Use instanceof ResponseError to distinguish FaasJS errors from other JavaScript errors
|
|
431
433
|
* - The body property can contain structured error information from the server response
|
|
432
434
|
*
|
|
433
|
-
* @see FaasBrowserClient.action for how ResponseError is thrown in requests
|
|
434
|
-
* @see ResponseProps for the structure of response data
|
|
435
|
-
* @see setMock for mocking errors in tests
|
|
435
|
+
* @see {@link FaasBrowserClient.action} for how ResponseError is thrown in requests.
|
|
436
|
+
* @see {@link ResponseProps} for the structure of response data.
|
|
437
|
+
* @see {@link setMock} for mocking errors in tests.
|
|
436
438
|
*/
|
|
437
439
|
declare class ResponseError extends Error {
|
|
438
440
|
/**
|
|
@@ -454,17 +456,17 @@ declare class ResponseError extends Error {
|
|
|
454
456
|
/**
|
|
455
457
|
* Create a ResponseError from a message, Error, or structured response error payload.
|
|
456
458
|
*
|
|
457
|
-
* @param data - Error message, Error object, or structured response error props.
|
|
458
|
-
* @param data.message - User-facing error message when `data` is a structured object.
|
|
459
|
-
* @param data.status - HTTP status code when `data` is a structured object.
|
|
460
|
-
* @param data.headers - Response headers returned with the error when `data` is a structured object.
|
|
461
|
-
* @param data.body - Raw error body or structured error payload when `data` is a structured object.
|
|
462
|
-
* @param data.originalError - Original error preserved on the instance when `data` is a structured object.
|
|
463
|
-
* @param options - Additional options such as status, headers, and body.
|
|
464
|
-
* @param options.status - HTTP status override used when `data` is a string or `Error`.
|
|
465
|
-
* @param options.headers - Response headers override used when `data` is a string or `Error`.
|
|
466
|
-
* @param options.body - Raw error body override used when `data` is a string or `Error`.
|
|
467
|
-
* @returns ResponseError instance.
|
|
459
|
+
* @param {string | Error | ResponseErrorProps} data - Error message, Error object, or structured response error props.
|
|
460
|
+
* @param {string} data.message - User-facing error message when `data` is a structured object.
|
|
461
|
+
* @param {number} [data.status] - HTTP status code when `data` is a structured object.
|
|
462
|
+
* @param {ResponseHeaders} [data.headers] - Response headers returned with the error when `data` is a structured object.
|
|
463
|
+
* @param {any} [data.body] - Raw error body or structured error payload when `data` is a structured object.
|
|
464
|
+
* @param {Error} [data.originalError] - Original error preserved on the instance when `data` is a structured object.
|
|
465
|
+
* @param {Omit<ResponseErrorProps, 'message' | 'originalError'>} [options] - Additional options such as status, headers, and body.
|
|
466
|
+
* @param {number} [options.status] - HTTP status override used when `data` is a string or `Error`.
|
|
467
|
+
* @param {ResponseHeaders} [options.headers] - Response headers override used when `data` is a string or `Error`.
|
|
468
|
+
* @param {any} [options.body] - Raw error body override used when `data` is a string or `Error`.
|
|
469
|
+
* @returns {ResponseError} ResponseError instance.
|
|
468
470
|
*/
|
|
469
471
|
constructor(data: string | Error, options?: Omit<ResponseErrorProps, 'message' | 'originalError'>);
|
|
470
472
|
constructor(data: ResponseErrorProps);
|
|
@@ -475,20 +477,20 @@ declare class ResponseError extends Error {
|
|
|
475
477
|
* Defines the signature for functions that can mock API requests during testing.
|
|
476
478
|
* Mock handlers receive request parameters and return simulated responses or errors.
|
|
477
479
|
*
|
|
478
|
-
* @param action - The function path/action being requested (for example, `user` or `data/list`).
|
|
480
|
+
* @param {string} action - The function path/action being requested (for example, `user` or `data/list`).
|
|
479
481
|
* Converted to lowercase by the client before being passed to the handler.
|
|
480
482
|
*
|
|
481
|
-
* @param params - The parameters passed to the action.
|
|
483
|
+
* @param {Record<string, any> | undefined} params - The parameters passed to the action.
|
|
482
484
|
* May be undefined if the action was called without parameters.
|
|
483
485
|
* Parameters are passed as a plain object (already JSON-serialized if needed).
|
|
484
486
|
*
|
|
485
|
-
* @param options - The full request options including headers, beforeRequest hook, and other config.
|
|
487
|
+
* @param {Options} options - The full request options including headers, beforeRequest hook, and other config.
|
|
486
488
|
* Includes X-FaasJS-Request-Id header in the headers object.
|
|
487
489
|
* Contains merged client defaults and per-request options.
|
|
488
490
|
* See {@link Options} for supported request fields such as `headers`, `beforeRequest`,
|
|
489
491
|
* `request`, `baseUrl`, and `stream`.
|
|
490
492
|
*
|
|
491
|
-
* @returns A promise resolving to:
|
|
493
|
+
* @returns {Promise<ResponseProps> | Promise<void> | Promise<Error>} A promise resolving to:
|
|
492
494
|
* - ResponseProps: Mock response data (status, headers, body, data)
|
|
493
495
|
* - void: Returns an empty response (204 No Content)
|
|
494
496
|
* - Error: Throws ResponseError when returning an Error object
|
|
@@ -500,62 +502,15 @@ declare class ResponseError extends Error {
|
|
|
500
502
|
* - Returning an Error object causes the action() method to reject with ResponseError
|
|
501
503
|
* - Async function - must return a Promise
|
|
502
504
|
* - Receives the fully merged options including default headers
|
|
503
|
-
*
|
|
504
|
-
* @
|
|
505
|
-
*
|
|
506
|
-
* setMock(async (action, params, options) => {
|
|
507
|
-
* if (action === 'user') {
|
|
508
|
-
* return {
|
|
509
|
-
* status: 200,
|
|
510
|
-
* data: { id: params.id, name: 'Mock User' }
|
|
511
|
-
* }
|
|
512
|
-
* }
|
|
513
|
-
* return { status: 404, data: { error: 'Not found' } }
|
|
514
|
-
* })
|
|
515
|
-
* ```
|
|
516
|
-
*
|
|
517
|
-
* @example Conditional mock based on parameters
|
|
518
|
-
* ```ts
|
|
519
|
-
* setMock(async (action, params) => {
|
|
520
|
-
* if (action === 'login') {
|
|
521
|
-
* if (params.email === 'admin@example.com' && params.password === 'admin') {
|
|
522
|
-
* return { data: { token: 'admin-token', role: 'admin' } }
|
|
523
|
-
* }
|
|
524
|
-
* return { status: 401, data: { error: 'Invalid credentials' } }
|
|
525
|
-
* }
|
|
526
|
-
* })
|
|
527
|
-
* ```
|
|
528
|
-
*
|
|
529
|
-
* @example Throwing error from mock
|
|
530
|
-
* ```ts
|
|
531
|
-
* setMock(async (action) => {
|
|
532
|
-
* if (action === 'protected') {
|
|
533
|
-
* return new Error('Unauthorized access')
|
|
534
|
-
* // This will be wrapped in ResponseError and thrown
|
|
535
|
-
* }
|
|
536
|
-
* })
|
|
537
|
-
* ```
|
|
538
|
-
*
|
|
539
|
-
* @example Returning void for empty response
|
|
540
|
-
* ```ts
|
|
541
|
-
* setMock(async (action) => {
|
|
542
|
-
* if (action === 'delete') {
|
|
543
|
-
* // Return void for 204 No Content
|
|
544
|
-
* return
|
|
545
|
-
* }
|
|
546
|
-
* return { data: { success: true } }
|
|
547
|
-
* })
|
|
548
|
-
* ```
|
|
549
|
-
*
|
|
550
|
-
* @see setMock for setting up mock handlers
|
|
551
|
-
* @see ResponseProps for response structure
|
|
552
|
-
* @see ResponseError for error handling
|
|
505
|
+
* @see {@link setMock} for setting up mock handlers.
|
|
506
|
+
* @see {@link ResponseProps} for response structure.
|
|
507
|
+
* @see {@link ResponseError} for error handling.
|
|
553
508
|
*/
|
|
554
509
|
type MockHandler = (action: string, params: Record<string, any> | undefined, options: Options) => Promise<ResponseProps> | Promise<void> | Promise<Error>;
|
|
555
510
|
/**
|
|
556
511
|
* Set the global mock handler used by all {@link FaasBrowserClient} instances.
|
|
557
512
|
*
|
|
558
|
-
* @param handler - Mock handler, can be:
|
|
513
|
+
* @param {MockHandler | ResponseProps | Response | null | undefined} handler - Mock handler, can be:
|
|
559
514
|
* - MockHandler function: receives (action, params, options) and returns response data
|
|
560
515
|
* - ResponseProps object: static response data
|
|
561
516
|
* - Response instance: pre-configured Response object
|
|
@@ -711,8 +666,8 @@ declare function setMock(handler: MockHandler | ResponseProps | Response | null
|
|
|
711
666
|
*
|
|
712
667
|
* @throws {Error} When baseUrl does not end with '/'
|
|
713
668
|
*
|
|
714
|
-
* @see setMock for testing support
|
|
715
|
-
* @see ResponseError for error handling
|
|
669
|
+
* @see {@link setMock} for testing support.
|
|
670
|
+
* @see {@link ResponseError} for error handling.
|
|
716
671
|
*/
|
|
717
672
|
declare class FaasBrowserClient {
|
|
718
673
|
/**
|
|
@@ -730,8 +685,8 @@ declare class FaasBrowserClient {
|
|
|
730
685
|
/**
|
|
731
686
|
* Creates a new FaasBrowserClient instance.
|
|
732
687
|
*
|
|
733
|
-
* @param baseUrl - Base URL for all API requests. Must end with `/`. Defaults to `/` for relative requests.
|
|
734
|
-
* @param options - Default request options such as headers, hooks, request override, or stream mode.
|
|
688
|
+
* @param {BaseUrl} [baseUrl] - Base URL for all API requests. Must end with `/`. Defaults to `/` for relative requests.
|
|
689
|
+
* @param {Options} [options] - Default request options such as headers, hooks, request override, or stream mode.
|
|
735
690
|
* See {@link Options} for supported request fields such as `headers`, `beforeRequest`,
|
|
736
691
|
* `request`, `baseUrl`, and `stream`.
|
|
737
692
|
*
|
|
@@ -791,16 +746,16 @@ declare class FaasBrowserClient {
|
|
|
791
746
|
* Makes a request to a FaasJS function.
|
|
792
747
|
*
|
|
793
748
|
* @template PathOrData - The function path or data type for type safety
|
|
794
|
-
* @param action - The function path to call. Converted to lowercase when constructing the URL.
|
|
749
|
+
* @param {FaasAction<PathOrData>} action - The function path to call. Converted to lowercase when constructing the URL.
|
|
795
750
|
* Must be a non-empty string.
|
|
796
|
-
* @param params - The parameters to send to the function. Will be serialized as JSON.
|
|
751
|
+
* @param {FaasParams<PathOrData>} [params] - The parameters to send to the function. Will be serialized as JSON.
|
|
797
752
|
* Optional if the function accepts no parameters.
|
|
798
|
-
* @param options - Optional request options that override client defaults.
|
|
753
|
+
* @param {Options} [options] - Optional request options that override client defaults.
|
|
799
754
|
* Supports headers, beforeRequest hook, custom request function, baseUrl override, and streaming mode.
|
|
800
755
|
* See {@link Options} for supported request fields such as `headers`, `beforeRequest`,
|
|
801
756
|
* `request`, `baseUrl`, and `stream`.
|
|
802
757
|
*
|
|
803
|
-
* @returns A promise resolving to the wrapped FaasJS response. When `options.stream`
|
|
758
|
+
* @returns {Promise<Response<FaasData<PathOrData>>>} A promise resolving to the wrapped FaasJS response. When `options.stream`
|
|
804
759
|
* is `true`, the runtime returns the native fetch response so callers can read the stream.
|
|
805
760
|
*
|
|
806
761
|
* @throws {Error} When action is not provided or is empty
|
|
@@ -902,12 +857,12 @@ declare class FaasBrowserClient {
|
|
|
902
857
|
*
|
|
903
858
|
* @template PathOrData - Action path or response data type used for inference.
|
|
904
859
|
*
|
|
905
|
-
* @param action - Action path to invoke.
|
|
906
|
-
* @param params - Parameters sent to the action.
|
|
907
|
-
* @param options - Optional per-request overrides such as headers or base URL.
|
|
908
|
-
* See the
|
|
860
|
+
* @param {FaasAction<PathOrData>} action - Action path to invoke.
|
|
861
|
+
* @param {FaasParams<PathOrData>} params - Parameters sent to the action.
|
|
862
|
+
* @param {Options} [options] - Optional per-request overrides such as headers or base URL.
|
|
863
|
+
* See the browser-client `Options` type for supported fields such as `headers`, `beforeRequest`,
|
|
909
864
|
* `request`, `baseUrl`, and `stream`.
|
|
910
|
-
* @returns Response returned by the active browser client.
|
|
865
|
+
* @returns {Promise<Response<FaasData<PathOrData>>>} Response returned by the active browser client.
|
|
911
866
|
* @throws {ResponseError} When the request fails and the active client does not recover inside `onError`.
|
|
912
867
|
*
|
|
913
868
|
* @example
|
|
@@ -976,16 +931,16 @@ type FaasDataWrapperRef<PathOrData extends FaasActionUnionType$1 = any> = FaasDa
|
|
|
976
931
|
* The wrapper defers rendering `children` or `render` until the first request
|
|
977
932
|
* completes, then keeps passing the latest request state to the rendered output.
|
|
978
933
|
*
|
|
979
|
-
* @param props - Wrapper props controlling the request and rendered fallback.
|
|
980
|
-
* @param props.render - Render prop that receives the resolved Faas request state.
|
|
981
|
-
* @param props.children - Child element cloned with injected Faas request state.
|
|
982
|
-
* @param props.fallback - Element rendered before the first successful load.
|
|
983
|
-
* @param props.action - Action path to request.
|
|
984
|
-
* @param props.params - Params sent to the action.
|
|
985
|
-
* @param props.onDataChange - Callback invoked when the resolved data value changes.
|
|
986
|
-
* @param props.data - Controlled data value used instead of internal state.
|
|
987
|
-
* @param props.setData - Controlled setter used instead of internal state.
|
|
988
|
-
* @param props.baseUrl - Base URL override used for this wrapper instance.
|
|
934
|
+
* @param {FaasDataWrapperProps<PathOrData>} props - Wrapper props controlling the request and rendered fallback.
|
|
935
|
+
* @param {(args: FaasDataInjection<PathOrData>) => JSX.Element | JSX.Element[]} [props.render] - Render prop that receives the resolved Faas request state.
|
|
936
|
+
* @param {React.ReactElement<Partial<FaasDataInjection<PathOrData>>>} [props.children] - Child element cloned with injected Faas request state.
|
|
937
|
+
* @param {JSX.Element | false} [props.fallback] - Element rendered before the first successful load.
|
|
938
|
+
* @param {FaasAction<PathOrData>} props.action - Action path to request.
|
|
939
|
+
* @param {FaasParams<PathOrData>} [props.params] - Params sent to the action.
|
|
940
|
+
* @param {(args: FaasDataInjection<PathOrData>) => void} [props.onDataChange] - Callback invoked when the resolved data value changes.
|
|
941
|
+
* @param {FaasData<PathOrData>} [props.data] - Controlled data value used instead of internal state.
|
|
942
|
+
* @param {React.Dispatch<React.SetStateAction<FaasData<PathOrData>>>} [props.setData] - Controlled setter used instead of internal state.
|
|
943
|
+
* @param {BaseUrl} [props.baseUrl] - Base URL override used for this wrapper instance.
|
|
989
944
|
*
|
|
990
945
|
* @example
|
|
991
946
|
* ```tsx
|
|
@@ -1065,9 +1020,9 @@ declare const FaasDataWrapper: <PathOrData extends FaasActionUnionType$1 = any>(
|
|
|
1065
1020
|
*
|
|
1066
1021
|
* @template PathOrData - Action path or response data type used for inference.
|
|
1067
1022
|
* @template TComponentProps - Component props including injected Faas data fields.
|
|
1068
|
-
* @param Component - Component that consumes injected Faas data props.
|
|
1069
|
-
* @param faasProps - Request configuration forwarded to `FaasDataWrapper`.
|
|
1070
|
-
* @returns Component that accepts the original props minus the injected Faas data fields.
|
|
1023
|
+
* @param {React.FC<TComponentProps>} Component - Component that consumes injected Faas data props.
|
|
1024
|
+
* @param {FaasDataWrapperProps<PathOrData>} faasProps - Request configuration forwarded to `FaasDataWrapper`.
|
|
1025
|
+
* @returns {React.FC<Omit<TComponentProps, keyof FaasDataInjection<PathOrData>> & Record<string, any>>} Component that accepts the original props minus the injected Faas data fields.
|
|
1071
1026
|
*
|
|
1072
1027
|
* @example
|
|
1073
1028
|
* ```tsx
|
|
@@ -1091,25 +1046,33 @@ declare const FaasDataWrapper: <PathOrData extends FaasActionUnionType$1 = any>(
|
|
|
1091
1046
|
*/
|
|
1092
1047
|
declare function withFaasData<PathOrData extends FaasActionUnionType$1, TComponentProps extends Required<FaasDataInjection<PathOrData>> = Required<FaasDataInjection<PathOrData>>>(Component: React.FC<TComponentProps>, faasProps: FaasDataWrapperProps<PathOrData>): React.FC<Omit<TComponentProps, keyof FaasDataInjection<PathOrData>> & Record<string, any>>;
|
|
1093
1048
|
//#endregion
|
|
1049
|
+
//#region src/useFaasRequest.d.ts
|
|
1050
|
+
/**
|
|
1051
|
+
* Shared request options consumed by `useFaas` and `useFaasStream`.
|
|
1052
|
+
*
|
|
1053
|
+
* @property {Params} [params] - Controlled params override sent with the request without mutating local params state.
|
|
1054
|
+
* @property {Data} [data] - Controlled data value used by higher-level hooks.
|
|
1055
|
+
* @property {React.Dispatch<React.SetStateAction<Data>>} [setData] - Controlled setter paired with `data`.
|
|
1056
|
+
* @property {boolean | ((params: Params) => boolean)} [skip] - Boolean or predicate that suppresses the automatic request.
|
|
1057
|
+
* @property {number} [debounce] - Milliseconds to wait before sending the latest request.
|
|
1058
|
+
* @property {BaseUrl} [baseUrl] - Base URL override used for this request lifecycle.
|
|
1059
|
+
*/
|
|
1060
|
+
type SharedUseFaasOptions<Params, Data> = {
|
|
1061
|
+
params?: Params;
|
|
1062
|
+
data?: Data;
|
|
1063
|
+
setData?: React.Dispatch<React.SetStateAction<Data>>;
|
|
1064
|
+
skip?: boolean | ((params: Params) => boolean);
|
|
1065
|
+
debounce?: number;
|
|
1066
|
+
baseUrl?: BaseUrl;
|
|
1067
|
+
};
|
|
1068
|
+
//#endregion
|
|
1094
1069
|
//#region src/useFaas.d.ts
|
|
1095
1070
|
/**
|
|
1096
1071
|
* Options that customize the {@link useFaas} request lifecycle.
|
|
1097
1072
|
*
|
|
1098
1073
|
* @template PathOrData - Action path or response data type used for inference.
|
|
1099
1074
|
*/
|
|
1100
|
-
type useFaasOptions<PathOrData extends FaasActionUnionType$1> =
|
|
1101
|
-
/** Override the current request params without changing the hook's stored params state. */params?: FaasParams$1<PathOrData>; /** Controlled data value used instead of the hook's internal state. */
|
|
1102
|
-
data?: FaasData$1<PathOrData>; /** Controlled setter that is called instead of the hook's internal `setData`. */
|
|
1103
|
-
setData?: React.Dispatch<React.SetStateAction<FaasData$1<PathOrData>>>;
|
|
1104
|
-
/**
|
|
1105
|
-
* If skip is true, the request will not be sent.
|
|
1106
|
-
*
|
|
1107
|
-
* However, you can still use reload to send the request.
|
|
1108
|
-
*/
|
|
1109
|
-
skip?: boolean | ((params: FaasParams$1<PathOrData>) => boolean); /** Delay the latest automatic request by the given number of milliseconds. */
|
|
1110
|
-
debounce?: number; /** Override the default base URL for this hook instance. */
|
|
1111
|
-
baseUrl?: BaseUrl;
|
|
1112
|
-
};
|
|
1075
|
+
type useFaasOptions<PathOrData extends FaasActionUnionType$1> = SharedUseFaasOptions<FaasParams$1<PathOrData>, FaasData$1<PathOrData>>;
|
|
1113
1076
|
/**
|
|
1114
1077
|
* Request FaasJS data and keep request state in React state.
|
|
1115
1078
|
*
|
|
@@ -1119,16 +1082,11 @@ type useFaasOptions<PathOrData extends FaasActionUnionType$1> = {
|
|
|
1119
1082
|
*
|
|
1120
1083
|
* @template PathOrData - Action path or response data type used for inference.
|
|
1121
1084
|
*
|
|
1122
|
-
* @param action - Action path to invoke.
|
|
1123
|
-
* @param defaultParams - Params used for the initial request and future reloads.
|
|
1124
|
-
* @param options - Optional hook configuration such as controlled data, debounce, and
|
|
1125
|
-
*
|
|
1126
|
-
* @
|
|
1127
|
-
* @param options.setData - Controlled setter used instead of the hook's internal `setData`.
|
|
1128
|
-
* @param options.skip - Boolean or predicate that suppresses the automatic request until `reload()` runs.
|
|
1129
|
-
* @param options.debounce - Milliseconds to wait before sending the latest request.
|
|
1130
|
-
* @param options.baseUrl - Base URL override used for this hook instance.
|
|
1131
|
-
* @returns Request state and helper methods described by {@link FaasDataInjection}.
|
|
1085
|
+
* @param {FaasAction<PathOrData>} action - Action path to invoke.
|
|
1086
|
+
* @param {FaasParams<PathOrData>} defaultParams - Params used for the initial request and future reloads.
|
|
1087
|
+
* @param {useFaasOptions<PathOrData>} [options] - Optional hook configuration such as controlled data, skip logic, debounce timing, and base URL overrides.
|
|
1088
|
+
* See the `useFaasOptions` type for `params`, `data`, `setData`, `skip`, `debounce`, and `baseUrl`.
|
|
1089
|
+
* @returns {FaasDataInjection<PathOrData>} Request state and helper methods described by {@link FaasDataInjection}.
|
|
1132
1090
|
*
|
|
1133
1091
|
* @example
|
|
1134
1092
|
* ```tsx
|
|
@@ -1167,9 +1125,9 @@ declare function useFaas<PathOrData extends FaasActionUnionType$1>(action: FaasA
|
|
|
1167
1125
|
/**
|
|
1168
1126
|
* Factory for per-request error handlers used by {@link FaasReactClient}.
|
|
1169
1127
|
*
|
|
1170
|
-
* @param action - Action name that failed.
|
|
1171
|
-
* @param params - Params sent with the failed request.
|
|
1172
|
-
* @returns Async callback invoked with the resulting {@link ResponseError}.
|
|
1128
|
+
* @param {string} action - Action name that failed.
|
|
1129
|
+
* @param {Record<string, any>} params - Params sent with the failed request.
|
|
1130
|
+
* @returns {(res: ResponseError) => Promise<void>} Async callback invoked with the resulting {@link ResponseError}.
|
|
1173
1131
|
*/
|
|
1174
1132
|
type OnError = (action: string, params: Record<string, any>) => (res: ResponseError) => Promise<void>;
|
|
1175
1133
|
/**
|
|
@@ -1214,13 +1172,13 @@ type FaasReactClientInstance = {
|
|
|
1214
1172
|
* The returned client is stored by `baseUrl` and becomes the default client
|
|
1215
1173
|
* used by helpers such as {@link faas} and {@link useFaas}.
|
|
1216
1174
|
*
|
|
1217
|
-
* @param options - Client configuration including base URL, default request options, and error hooks.
|
|
1218
|
-
* @param options.baseUrl - Base URL used to register and route the client instance.
|
|
1219
|
-
* @param options.options - Default browser-client request options forwarded to `FaasBrowserClient`.
|
|
1220
|
-
* @param options.onError - Hook factory used to handle failed `faas` and `useFaas` requests.
|
|
1175
|
+
* @param {FaasReactClientOptions} [options] - Client configuration including base URL, default request options, and error hooks.
|
|
1176
|
+
* @param {BaseUrl} [options.baseUrl] - Base URL used to register and route the client instance.
|
|
1177
|
+
* @param {Options} [options.options] - Default browser-client request options forwarded to `FaasBrowserClient`.
|
|
1178
|
+
* @param {OnError} [options.onError] - Hook factory used to handle failed `faas` and `useFaas` requests.
|
|
1221
1179
|
* See {@link Options} for supported browser-client request fields such as `headers`,
|
|
1222
1180
|
* `beforeRequest`, `request`, `baseUrl`, and `stream`.
|
|
1223
|
-
* @returns Registered FaasReactClient instance.
|
|
1181
|
+
* @returns {FaasReactClientInstance} Registered FaasReactClient instance.
|
|
1224
1182
|
*
|
|
1225
1183
|
* @example
|
|
1226
1184
|
* ```ts
|
|
@@ -1249,8 +1207,8 @@ declare function FaasReactClient(options?: FaasReactClientOptions): FaasReactCli
|
|
|
1249
1207
|
* different base URLs. In normal single-client app code, prefer the default
|
|
1250
1208
|
* `faas`, `useFaas`, or `FaasReactClient` setup directly.
|
|
1251
1209
|
*
|
|
1252
|
-
* @param host - Registered base URL to look up. Omit it to use the default client.
|
|
1253
|
-
* @returns Registered or newly created FaasReactClient instance.
|
|
1210
|
+
* @param {string} [host] - Registered base URL to look up. Omit it to use the default client.
|
|
1211
|
+
* @returns {FaasReactClientInstance} Registered or newly created FaasReactClient instance.
|
|
1254
1212
|
*
|
|
1255
1213
|
* @example
|
|
1256
1214
|
* ```ts
|
|
@@ -1276,7 +1234,8 @@ declare function getClient(host?: string): FaasReactClientInstance;
|
|
|
1276
1234
|
* Returns a constant value that is created by the given function.
|
|
1277
1235
|
*
|
|
1278
1236
|
* @template T - Constant value type returned by the initializer.
|
|
1279
|
-
* @param fn - Initializer that runs only once for the current component instance.
|
|
1237
|
+
* @param {() => T} fn - Initializer that runs only once for the current component instance.
|
|
1238
|
+
* @returns {T} Stable value returned by the initializer.
|
|
1280
1239
|
*
|
|
1281
1240
|
* @example
|
|
1282
1241
|
* ```tsx
|
|
@@ -1343,17 +1302,17 @@ declare class ErrorBoundary extends Component<ErrorBoundaryProps, {
|
|
|
1343
1302
|
/**
|
|
1344
1303
|
* Create an error boundary with empty error state.
|
|
1345
1304
|
*
|
|
1346
|
-
* @param props - Boundary props.
|
|
1347
|
-
* @param props.children - Descendant elements protected by the boundary.
|
|
1348
|
-
* @param props.onError - Callback invoked after a render error is captured.
|
|
1349
|
-
* @param props.errorChildren - Custom fallback element that receives error details.
|
|
1305
|
+
* @param {ErrorBoundaryProps} props - Boundary props.
|
|
1306
|
+
* @param {ReactNode} [props.children] - Descendant elements protected by the boundary.
|
|
1307
|
+
* @param {(error: Error | null, info: any) => void} [props.onError] - Callback invoked after a render error is captured.
|
|
1308
|
+
* @param {ReactElement<ErrorChildrenProps>} [props.errorChildren] - Custom fallback element that receives error details.
|
|
1350
1309
|
*/
|
|
1351
1310
|
constructor(props: ErrorBoundaryProps);
|
|
1352
1311
|
/**
|
|
1353
1312
|
* Capture rendering errors from descendant components.
|
|
1354
1313
|
*
|
|
1355
|
-
* @param error - Caught render error.
|
|
1356
|
-
* @param info - React component stack metadata.
|
|
1314
|
+
* @param {Error} error - Caught render error.
|
|
1315
|
+
* @param {ErrorInfo} info - React component stack metadata.
|
|
1357
1316
|
*/
|
|
1358
1317
|
componentDidCatch(error: Error, info: ErrorInfo): void;
|
|
1359
1318
|
/**
|
|
@@ -1370,9 +1329,9 @@ declare class ErrorBoundary extends Component<ErrorBoundaryProps, {
|
|
|
1370
1329
|
* It handles various data types including primitives, arrays, dates, regular expressions, functions,
|
|
1371
1330
|
* maps, sets, and promises.
|
|
1372
1331
|
*
|
|
1373
|
-
* @param a - The first value to compare.
|
|
1374
|
-
* @param b - The second value to compare.
|
|
1375
|
-
* @returns `true` if the values are deeply equal, `false` otherwise.
|
|
1332
|
+
* @param {any} a - The first value to compare.
|
|
1333
|
+
* @param {any} b - The second value to compare.
|
|
1334
|
+
* @returns {boolean} `true` if the values are deeply equal, `false` otherwise.
|
|
1376
1335
|
*
|
|
1377
1336
|
* @example
|
|
1378
1337
|
* ```ts
|
|
@@ -1386,8 +1345,8 @@ declare function equal(a: any, b: any): boolean;
|
|
|
1386
1345
|
/**
|
|
1387
1346
|
* Custom hook that memoizes a value using deep equality comparison.
|
|
1388
1347
|
*
|
|
1389
|
-
* @param value - The value to be memoized.
|
|
1390
|
-
* @returns The memoized value.
|
|
1348
|
+
* @param {any} value - The value to be memoized.
|
|
1349
|
+
* @returns {any} The memoized value.
|
|
1391
1350
|
*
|
|
1392
1351
|
* @example
|
|
1393
1352
|
* ```tsx
|
|
@@ -1404,9 +1363,9 @@ declare function useEqualMemoize(value: any): any;
|
|
|
1404
1363
|
/**
|
|
1405
1364
|
* Custom hook that works like `useEffect` but uses deep comparison on dependencies.
|
|
1406
1365
|
*
|
|
1407
|
-
* @param callback - The effect callback function to run.
|
|
1408
|
-
* @param dependencies - The list of dependencies for the effect.
|
|
1409
|
-
* @returns The result of the `useEffect` hook with memoized dependencies.
|
|
1366
|
+
* @param {React.EffectCallback} callback - The effect callback function to run.
|
|
1367
|
+
* @param {any[]} dependencies - The list of dependencies for the effect.
|
|
1368
|
+
* @returns {void} The result of the `useEffect` hook with memoized dependencies.
|
|
1410
1369
|
*
|
|
1411
1370
|
* @example
|
|
1412
1371
|
* ```tsx
|
|
@@ -1427,9 +1386,9 @@ declare function useEqualEffect(callback: React.EffectCallback, dependencies: an
|
|
|
1427
1386
|
*
|
|
1428
1387
|
* @template T - Memoized value type returned by the callback.
|
|
1429
1388
|
*
|
|
1430
|
-
* @param callback - The callback function to run.
|
|
1431
|
-
* @param dependencies - The list of dependencies.
|
|
1432
|
-
* @returns The result of the `useMemo` hook with memoized dependencies.
|
|
1389
|
+
* @param {() => T} callback - The callback function to run.
|
|
1390
|
+
* @param {any[]} dependencies - The list of dependencies.
|
|
1391
|
+
* @returns {T} The result of the `useMemo` hook with memoized dependencies.
|
|
1433
1392
|
*
|
|
1434
1393
|
* @example
|
|
1435
1394
|
* ```tsx
|
|
@@ -1448,9 +1407,9 @@ declare function useEqualMemo<T>(callback: () => T, dependencies: any[]): T;
|
|
|
1448
1407
|
*
|
|
1449
1408
|
* @template T - Callback signature to memoize.
|
|
1450
1409
|
*
|
|
1451
|
-
* @param callback - The callback function to run.
|
|
1452
|
-
* @param dependencies - The list of dependencies.
|
|
1453
|
-
* @returns The result of the `useCallback` hook with memoized dependencies.
|
|
1410
|
+
* @param {T} callback - The callback function to run.
|
|
1411
|
+
* @param {any[]} dependencies - The list of dependencies.
|
|
1412
|
+
* @returns {T} The result of the `useCallback` hook with memoized dependencies.
|
|
1454
1413
|
*
|
|
1455
1414
|
* @example
|
|
1456
1415
|
* ```tsx
|
|
@@ -1484,12 +1443,12 @@ type OptionalWrapperProps<TWrapper extends ComponentType<{
|
|
|
1484
1443
|
/**
|
|
1485
1444
|
* Conditionally wrap children with another component.
|
|
1486
1445
|
*
|
|
1487
|
-
* @param props - Wrapper condition, wrapper component, and child content.
|
|
1488
|
-
* @param props.condition - When `true`, wrap children with `Wrapper`.
|
|
1489
|
-
* @param props.Wrapper - Component used as the wrapper when the condition passes.
|
|
1490
|
-
* @param props.wrapperProps - Props forwarded to the wrapper component.
|
|
1491
|
-
* @param props.children - Content rendered directly or inside the wrapper.
|
|
1492
|
-
* @returns Wrapped children or the original children when `condition` is false.
|
|
1446
|
+
* @param {OptionalWrapperProps} props - Wrapper condition, wrapper component, and child content.
|
|
1447
|
+
* @param {boolean} props.condition - When `true`, wrap children with `Wrapper`.
|
|
1448
|
+
* @param {OptionalWrapperProps['Wrapper']} props.Wrapper - Component used as the wrapper when the condition passes.
|
|
1449
|
+
* @param {OptionalWrapperProps['wrapperProps']} [props.wrapperProps] - Props forwarded to the wrapper component.
|
|
1450
|
+
* @param {ReactNode} props.children - Content rendered directly or inside the wrapper.
|
|
1451
|
+
* @returns {ReactNode} Wrapped children or the original children when `condition` is false.
|
|
1493
1452
|
*
|
|
1494
1453
|
* @example
|
|
1495
1454
|
* ```tsx
|
|
@@ -1520,8 +1479,8 @@ declare namespace OptionalWrapper {
|
|
|
1520
1479
|
* subscribe to the values they access.
|
|
1521
1480
|
*
|
|
1522
1481
|
* @template T - Context value shape exposed by the provider and hook.
|
|
1523
|
-
* @param defaultValue - Default value map or key list used to create split contexts.
|
|
1524
|
-
* @returns Provider and hook helpers for the split context.
|
|
1482
|
+
* @param {Record<string, any> | (keyof T)[]} defaultValue - Default value map or key list used to create split contexts.
|
|
1483
|
+
* @returns {{ Provider<NewT extends T = T>(this: void, props: { value?: Partial<NewT>; children: ReactNode; memo?: true | any[]; initializeStates?: Partial<NewT> }): ReactNode; use<NewT extends T = T>(this: void): Readonly<NewT> }} Provider and hook helpers for the split context.
|
|
1525
1484
|
*
|
|
1526
1485
|
* @example
|
|
1527
1486
|
* ```tsx
|
|
@@ -1565,7 +1524,7 @@ declare function createSplittingContext<T extends Record<string, any>>(defaultVa
|
|
|
1565
1524
|
/**
|
|
1566
1525
|
* The provider component of the splitting context.
|
|
1567
1526
|
*
|
|
1568
|
-
* @see https://faasjs.com/doc/react/functions/createSplittingContext.html#provider
|
|
1527
|
+
* @see [Provider docs](https://faasjs.com/doc/react/functions/createSplittingContext.html#provider)
|
|
1569
1528
|
*
|
|
1570
1529
|
* @example
|
|
1571
1530
|
* ```tsx
|
|
@@ -1613,7 +1572,7 @@ declare function createSplittingContext<T extends Record<string, any>>(defaultVa
|
|
|
1613
1572
|
/**
|
|
1614
1573
|
* Hook used to read values from the splitting context.
|
|
1615
1574
|
*
|
|
1616
|
-
* @see https://faasjs.com/doc/react/functions/createSplittingContext.html#use
|
|
1575
|
+
* @see [Hook docs](https://faasjs.com/doc/react/functions/createSplittingContext.html#use)
|
|
1617
1576
|
*
|
|
1618
1577
|
* @example
|
|
1619
1578
|
* ```tsx
|
|
@@ -1644,8 +1603,8 @@ type StatesWithSetters<T> = T & StateSetters<T>;
|
|
|
1644
1603
|
* Create local state entries and matching setters for each key in an object.
|
|
1645
1604
|
*
|
|
1646
1605
|
* @template T - A generic type that extends a record with string keys and any values.
|
|
1647
|
-
* @param initialStates - Object whose keys become state values and `setXxx` setters.
|
|
1648
|
-
* @returns Object containing the original keys plus generated setter functions.
|
|
1606
|
+
* @param {T} initialStates - Object whose keys become state values and `setXxx` setters.
|
|
1607
|
+
* @returns {StatesWithSetters<T>} Object containing the original keys plus generated setter functions.
|
|
1649
1608
|
*
|
|
1650
1609
|
* @example
|
|
1651
1610
|
* ```tsx
|
|
@@ -1662,19 +1621,7 @@ declare function useSplittingState<T extends Record<string, unknown>>(initialSta
|
|
|
1662
1621
|
/**
|
|
1663
1622
|
* Options that customize the {@link useFaasStream} request lifecycle.
|
|
1664
1623
|
*/
|
|
1665
|
-
type UseFaasStreamOptions =
|
|
1666
|
-
/** Override the current request params without changing the hook's stored params state. */params?: Record<string, any>; /** Controlled stream text used instead of the hook's internal state. */
|
|
1667
|
-
data?: string; /** Controlled setter that is called instead of the hook's internal `setData`. */
|
|
1668
|
-
setData?: React.Dispatch<React.SetStateAction<string>>;
|
|
1669
|
-
/**
|
|
1670
|
-
* If skip is true, the request will not be sent.
|
|
1671
|
-
*
|
|
1672
|
-
* However, you can still use reload to send the request.
|
|
1673
|
-
*/
|
|
1674
|
-
skip?: boolean | ((params: Record<string, any>) => boolean); /** Delay the latest automatic request by the given number of milliseconds. */
|
|
1675
|
-
debounce?: number; /** Override the default base URL for this hook instance. */
|
|
1676
|
-
baseUrl?: BaseUrl;
|
|
1677
|
-
};
|
|
1624
|
+
type UseFaasStreamOptions = SharedUseFaasOptions<Record<string, any>, string>;
|
|
1678
1625
|
/**
|
|
1679
1626
|
* Result returned by {@link useFaasStream}.
|
|
1680
1627
|
*/
|
|
@@ -1697,16 +1644,11 @@ type UseFaasStreamResult = {
|
|
|
1697
1644
|
* It sends a streaming request, appends decoded text chunks to `data`, and
|
|
1698
1645
|
* exposes reload helpers for retrying the same action.
|
|
1699
1646
|
*
|
|
1700
|
-
* @param action - Action path to invoke.
|
|
1701
|
-
* @param defaultParams - Params used for the initial request and future reloads.
|
|
1702
|
-
* @param options - Optional hook configuration such as controlled
|
|
1703
|
-
*
|
|
1704
|
-
* @
|
|
1705
|
-
* @param options.setData - Controlled setter used instead of the hook's internal `setData`.
|
|
1706
|
-
* @param options.skip - Boolean or predicate that suppresses the automatic request until `reload()` runs.
|
|
1707
|
-
* @param options.debounce - Milliseconds to wait before sending the latest request.
|
|
1708
|
-
* @param options.baseUrl - Base URL override used for this hook instance.
|
|
1709
|
-
* @returns Streaming request state and helper methods described by {@link UseFaasStreamResult}.
|
|
1647
|
+
* @param {string} action - Action path to invoke.
|
|
1648
|
+
* @param {Record<string, any>} defaultParams - Params used for the initial request and future reloads.
|
|
1649
|
+
* @param {UseFaasStreamOptions} [options] - Optional hook configuration such as controlled stream text, skip logic, debounce timing, and base URL overrides.
|
|
1650
|
+
* See the `UseFaasStreamOptions` type for `params`, `data`, `setData`, `skip`, `debounce`, and `baseUrl`.
|
|
1651
|
+
* @returns {UseFaasStreamResult} Streaming request state and helper methods described by {@link UseFaasStreamResult}.
|
|
1710
1652
|
*
|
|
1711
1653
|
* @example
|
|
1712
1654
|
* ```tsx
|
|
@@ -1739,8 +1681,8 @@ declare function useFaasStream(action: string, defaultParams: Record<string, any
|
|
|
1739
1681
|
* Hook to store the previous value of a state or prop.
|
|
1740
1682
|
*
|
|
1741
1683
|
* @template T - The type of the value.
|
|
1742
|
-
* @param value - The current value to track.
|
|
1743
|
-
* @returns Previous value from the prior render, or `undefined` on the first render.
|
|
1684
|
+
* @param {T} value - The current value to track.
|
|
1685
|
+
* @returns {T | undefined} Previous value from the prior render, or `undefined` on the first render.
|
|
1744
1686
|
*
|
|
1745
1687
|
* @example
|
|
1746
1688
|
* ```tsx
|
|
@@ -1760,8 +1702,8 @@ declare function usePrevious<T = any>(value: T): T | undefined;
|
|
|
1760
1702
|
* Custom hook that returns a stateful value and a ref to that value.
|
|
1761
1703
|
*
|
|
1762
1704
|
* @template T - The type of the value.
|
|
1763
|
-
* @param initialValue - Initial state value. When omitted, state starts as `null`.
|
|
1764
|
-
* @returns Tuple containing the current state, the state setter, and a ref that always points at the latest state.
|
|
1705
|
+
* @param {T} [initialValue] - Initial state value. When omitted, state starts as `null`.
|
|
1706
|
+
* @returns {[T | null, Dispatch<SetStateAction<T | null>>, RefObject<T | null>]} Tuple containing the current state, the state setter, and a ref that always points at the latest state.
|
|
1765
1707
|
*
|
|
1766
1708
|
* @example
|
|
1767
1709
|
* ```tsx
|