@ragbits/api-client-react 1.4.0-dev.202512021005 → 1.4.0-dev.202512090236

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 CHANGED
@@ -7,13 +7,13 @@ import type { RagbitsCallResult, RagbitsStreamResult } from './types';
7
7
  * @param defaultOptions - Default options for the API call
8
8
  */
9
9
  export declare function useRagbitsCall<Endpoints extends {
10
- [K in keyof Endpoints]: EndpointDefinition;
11
- } = BaseApiEndpoints, URL extends keyof Endpoints = keyof Endpoints>(endpoint: URL, defaultOptions?: RequestOptions<URL, Endpoints>): RagbitsCallResult<URL, Endpoints, Error>;
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>;
12
12
  /**
13
13
  * Hook for handling streaming responses from Ragbits endpoints
14
14
  * - Supports any streaming endpoints by providing `Endpoints` generic argument
15
15
  * @param endpoint - The predefined streaming endpoint
16
16
  */
17
17
  export declare function useRagbitsStream<Endpoints extends {
18
- [K in keyof Endpoints]: EndpointDefinition;
18
+ [K in keyof Endpoints]: EndpointDefinition<any, any, any, any>;
19
19
  } = BaseStreamingEndpoints, URL extends keyof Endpoints = keyof Endpoints>(endpoint: URL, customHeaders?: Record<string, string>): RagbitsStreamResult<URL, Endpoints, Error>;
package/dist/index.cjs CHANGED
@@ -78,7 +78,8 @@ function useRagbitsCall(endpoint, defaultOptions) {
78
78
  setIsLoading(false);
79
79
  }, []);
80
80
  const call = (0, import_react2.useCallback)(
81
- async (options = {}) => {
81
+ async (...args) => {
82
+ const options = args[0];
82
83
  if (abortControllerRef.current && isLoading) {
83
84
  abortControllerRef.current.abort();
84
85
  }
@@ -89,10 +90,10 @@ function useRagbitsCall(endpoint, defaultOptions) {
89
90
  try {
90
91
  const mergedOptions = {
91
92
  ...defaultOptions,
92
- ...options,
93
+ ...options || {},
93
94
  headers: {
94
95
  ...defaultOptions?.headers,
95
- ...options.headers
96
+ ...options?.headers || {}
96
97
  }
97
98
  };
98
99
  const requestOptions = {
package/dist/index.js CHANGED
@@ -50,7 +50,8 @@ function useRagbitsCall(endpoint, defaultOptions) {
50
50
  setIsLoading(false);
51
51
  }, []);
52
52
  const call = useCallback(
53
- async (options = {}) => {
53
+ async (...args) => {
54
+ const options = args[0];
54
55
  if (abortControllerRef.current && isLoading) {
55
56
  abortControllerRef.current.abort();
56
57
  }
@@ -61,10 +62,10 @@ function useRagbitsCall(endpoint, defaultOptions) {
61
62
  try {
62
63
  const mergedOptions = {
63
64
  ...defaultOptions,
64
- ...options,
65
+ ...options || {},
65
66
  headers: {
66
67
  ...defaultOptions?.headers,
67
- ...options.headers
68
+ ...options?.headers || {}
68
69
  }
69
70
  };
70
71
  const requestOptions = {
package/dist/types.d.ts CHANGED
@@ -1,16 +1,23 @@
1
- import type { StreamCallbacks, RagbitsClient, RequestOptions, EndpointDefinition, BaseApiEndpoints, EndpointRequest, EndpointResponse, BaseStreamingEndpoints } from '@ragbits/api-client';
1
+ import type { StreamCallbacks, RagbitsClient, RequestOptions, EndpointDefinition, BaseApiEndpoints, EndpointRequest, EndpointResponse, BaseStreamingEndpoints, HasRequiredParams } from '@ragbits/api-client';
2
+ export type { BaseApiEndpoints, BaseStreamingEndpoints, EndpointDefinition, } from '@ragbits/api-client';
3
+ /**
4
+ * Call function type - mirrors makeRequest signature
5
+ */
6
+ export type CallFunction<URL extends keyof Endpoints, Endpoints extends {
7
+ [K in keyof Endpoints]: EndpointDefinition<any, any, any, any>;
8
+ }> = HasRequiredParams<URL, Endpoints> extends true ? (options: RequestOptions<URL, Endpoints>) => Promise<EndpointResponse<URL, Endpoints>> : (options?: RequestOptions<URL, Endpoints>) => Promise<EndpointResponse<URL, Endpoints>>;
2
9
  export interface RagbitsCallResult<URL extends keyof Endpoints, Endpoints extends {
3
- [K in keyof Endpoints]: EndpointDefinition;
10
+ [K in keyof Endpoints]: EndpointDefinition<any, any, any, any>;
4
11
  } = BaseApiEndpoints, Err = Error> {
5
12
  data: EndpointResponse<URL, Endpoints> | null;
6
13
  error: Err | null;
7
14
  isLoading: boolean;
8
- call: (options?: RequestOptions<URL, Endpoints>) => Promise<EndpointResponse<URL, Endpoints>>;
15
+ call: CallFunction<URL, Endpoints>;
9
16
  reset: () => void;
10
17
  abort: () => void;
11
18
  }
12
19
  export interface RagbitsStreamResult<URL extends keyof Endpoints, Endpoints extends {
13
- [K in keyof Endpoints]: EndpointDefinition;
20
+ [K in keyof Endpoints]: EndpointDefinition<any, any, any, any>;
14
21
  } = BaseStreamingEndpoints, Err = Error> {
15
22
  isStreaming: boolean;
16
23
  error: Err | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ragbits/api-client-react",
3
- "version": "1.4.0-dev.202512021005",
3
+ "version": "1.4.0-dev.202512090236",
4
4
  "description": "React hooks for the Ragbits API client",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,7 +33,7 @@
33
33
  "react-dom": ">=16.8.0"
34
34
  },
35
35
  "dependencies": {
36
- "@ragbits/api-client": "1.4.0-dev.202512021005"
36
+ "@ragbits/api-client": "*"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@eslint/js": "^9.17.0",