@ragbits/api-client-react 1.4.0-dev.202512090236 → 1.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/dist/hooks.d.ts +3 -7
- package/dist/types.d.ts +4 -10
- package/package.json +1 -1
package/dist/hooks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RequestOptions,
|
|
1
|
+
import type { RequestOptions, BaseApiEndpoints, BaseStreamingEndpoints, AnyEndpoints } from '@ragbits/api-client';
|
|
2
2
|
import type { RagbitsCallResult, RagbitsStreamResult } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Hook for making API calls to Ragbits endpoints
|
|
@@ -6,14 +6,10 @@ import type { RagbitsCallResult, RagbitsStreamResult } from './types';
|
|
|
6
6
|
* @param endpoint - The predefined API endpoint
|
|
7
7
|
* @param defaultOptions - Default options for the API call
|
|
8
8
|
*/
|
|
9
|
-
export declare function useRagbitsCall<Endpoints extends
|
|
10
|
-
[K in keyof Endpoints]: EndpointDefinition<any, any, any, any>;
|
|
11
|
-
} = BaseApiEndpoints, URL extends keyof Endpoints = keyof Endpoints>(endpoint: URL, defaultOptions?: Partial<RequestOptions<URL, Endpoints>>): RagbitsCallResult<URL, Endpoints, Error>;
|
|
9
|
+
export declare function useRagbitsCall<Endpoints extends AnyEndpoints<Endpoints> = BaseApiEndpoints, URL extends keyof Endpoints = keyof Endpoints>(endpoint: URL, defaultOptions?: Partial<RequestOptions<URL, Endpoints>>): RagbitsCallResult<URL, Endpoints, Error>;
|
|
12
10
|
/**
|
|
13
11
|
* Hook for handling streaming responses from Ragbits endpoints
|
|
14
12
|
* - Supports any streaming endpoints by providing `Endpoints` generic argument
|
|
15
13
|
* @param endpoint - The predefined streaming endpoint
|
|
16
14
|
*/
|
|
17
|
-
export declare function useRagbitsStream<Endpoints extends
|
|
18
|
-
[K in keyof Endpoints]: EndpointDefinition<any, any, any, any>;
|
|
19
|
-
} = BaseStreamingEndpoints, URL extends keyof Endpoints = keyof Endpoints>(endpoint: URL, customHeaders?: Record<string, string>): RagbitsStreamResult<URL, Endpoints, Error>;
|
|
15
|
+
export declare function useRagbitsStream<Endpoints extends AnyEndpoints<Endpoints> = BaseStreamingEndpoints, URL extends keyof Endpoints = keyof Endpoints>(endpoint: URL, customHeaders?: Record<string, string>): RagbitsStreamResult<URL, Endpoints, Error>;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import type { StreamCallbacks, RagbitsClient, RequestOptions,
|
|
1
|
+
import type { StreamCallbacks, RagbitsClient, RequestOptions, BaseApiEndpoints, EndpointRequest, EndpointResponse, BaseStreamingEndpoints, HasRequiredParams, AnyEndpoints } from '@ragbits/api-client';
|
|
2
2
|
export type { BaseApiEndpoints, BaseStreamingEndpoints, EndpointDefinition, } from '@ragbits/api-client';
|
|
3
3
|
/**
|
|
4
4
|
* Call function type - mirrors makeRequest signature
|
|
5
5
|
*/
|
|
6
|
-
export type CallFunction<URL extends keyof Endpoints, Endpoints extends
|
|
7
|
-
|
|
8
|
-
}> = HasRequiredParams<URL, Endpoints> extends true ? (options: RequestOptions<URL, Endpoints>) => Promise<EndpointResponse<URL, Endpoints>> : (options?: RequestOptions<URL, Endpoints>) => Promise<EndpointResponse<URL, Endpoints>>;
|
|
9
|
-
export interface RagbitsCallResult<URL extends keyof Endpoints, Endpoints extends {
|
|
10
|
-
[K in keyof Endpoints]: EndpointDefinition<any, any, any, any>;
|
|
11
|
-
} = BaseApiEndpoints, Err = Error> {
|
|
6
|
+
export type CallFunction<URL extends keyof Endpoints, Endpoints extends AnyEndpoints<Endpoints>> = HasRequiredParams<URL, Endpoints> extends true ? (options: RequestOptions<URL, Endpoints>) => Promise<EndpointResponse<URL, Endpoints>> : (options?: RequestOptions<URL, Endpoints>) => Promise<EndpointResponse<URL, Endpoints>>;
|
|
7
|
+
export interface RagbitsCallResult<URL extends keyof Endpoints, Endpoints extends AnyEndpoints<Endpoints> = BaseApiEndpoints, Err = Error> {
|
|
12
8
|
data: EndpointResponse<URL, Endpoints> | null;
|
|
13
9
|
error: Err | null;
|
|
14
10
|
isLoading: boolean;
|
|
@@ -16,9 +12,7 @@ export interface RagbitsCallResult<URL extends keyof Endpoints, Endpoints extend
|
|
|
16
12
|
reset: () => void;
|
|
17
13
|
abort: () => void;
|
|
18
14
|
}
|
|
19
|
-
export interface RagbitsStreamResult<URL extends keyof Endpoints, Endpoints extends {
|
|
20
|
-
[K in keyof Endpoints]: EndpointDefinition<any, any, any, any>;
|
|
21
|
-
} = BaseStreamingEndpoints, Err = Error> {
|
|
15
|
+
export interface RagbitsStreamResult<URL extends keyof Endpoints, Endpoints extends AnyEndpoints<Endpoints> = BaseStreamingEndpoints, Err = Error> {
|
|
22
16
|
isStreaming: boolean;
|
|
23
17
|
error: Err | null;
|
|
24
18
|
stream: (data: EndpointRequest<URL, Endpoints>, callbacks: StreamCallbacks<EndpointResponse<URL, Endpoints>, string>) => () => void;
|