@igniter-js/caller 0.1.4 → 0.1.5
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/AGENTS.md +112 -5
- package/README.md +123 -5
- package/dist/adapters/index.d.mts +70 -1
- package/dist/adapters/index.d.ts +70 -1
- package/dist/client/index.d.mts +212 -0
- package/dist/client/index.d.ts +212 -0
- package/dist/client/index.js +688 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/index.mjs +679 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/index.d.mts +66 -995
- package/dist/index.d.ts +66 -995
- package/dist/index.js +406 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +403 -7
- package/dist/index.mjs.map +1 -1
- package/dist/manager-CVi9utzy.d.ts +1121 -0
- package/dist/manager-DWvX2zsz.d.mts +1121 -0
- package/dist/store-D2p2dqGN.d.mts +54 -0
- package/dist/store-D2p2dqGN.d.ts +54 -0
- package/package.json +14 -5
- package/dist/index-COZVROi_.d.mts +0 -121
- package/dist/index-COZVROi_.d.ts +0 -121
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { I as IgniterCallerManager, a as IgniterCallerApiResponse, b as IgniterCallerSchemaMap, c as IgniterCallerSchemaMethod, E as EndpointInfo, G as GetPaths, d as InferResponse, T as TypedRequestBuilder, e as IgniterCallerTypedRequestBuilder, P as PostPaths, f as PutPaths, g as PatchPaths, D as DeletePaths, H as HeadPaths } from '../manager-DWvX2zsz.mjs';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { PropsWithChildren } from 'react';
|
|
4
|
+
import { IgniterError } from '@igniter-js/common';
|
|
5
|
+
import '@igniter-js/telemetry';
|
|
6
|
+
import 'zod';
|
|
7
|
+
import '../store-D2p2dqGN.mjs';
|
|
8
|
+
|
|
9
|
+
type IgniterCallerClientHeaders = Record<string, string>;
|
|
10
|
+
type IgniterCallerClientCookies = Record<string, string>;
|
|
11
|
+
type IgniterCallerClientQuery = Record<string, string | number | boolean>;
|
|
12
|
+
interface IgniterCallerClientConfig {
|
|
13
|
+
headers?: IgniterCallerClientHeaders;
|
|
14
|
+
cookies?: IgniterCallerClientCookies;
|
|
15
|
+
query?: IgniterCallerClientQuery;
|
|
16
|
+
onQueryLoading?: (isLoading: boolean) => void;
|
|
17
|
+
onQuerySuccess?: (data: unknown) => void;
|
|
18
|
+
onQueryError?: (error: IgniterError) => void;
|
|
19
|
+
onQuerySettled?: (data: unknown | null, error?: IgniterError | null) => void;
|
|
20
|
+
onMutationLoading?: (isLoading: boolean) => void;
|
|
21
|
+
onMutationSuccess?: (data: unknown) => void;
|
|
22
|
+
onMutationError?: (error: IgniterError) => void;
|
|
23
|
+
onMutationSettled?: (data: unknown | null, error?: IgniterError | null) => void;
|
|
24
|
+
}
|
|
25
|
+
type IgniterCallerClientConfigKey = keyof IgniterCallerClientConfig;
|
|
26
|
+
type IgniterCallerClientConfigValue<TKey extends IgniterCallerClientConfigKey> = IgniterCallerClientConfig[TKey];
|
|
27
|
+
|
|
28
|
+
type IgniterCallerClientMap = Record<string, IgniterCallerManager<any>>;
|
|
29
|
+
type IgniterCallerClientConfigs<TCallers extends IgniterCallerClientMap> = Partial<Record<keyof TCallers, IgniterCallerClientConfig>>;
|
|
30
|
+
type IgniterCallerClientRefetchFn = (invalidate?: boolean) => void;
|
|
31
|
+
type IgniterCallerClientListeners = Map<string, Set<IgniterCallerClientRefetchFn>>;
|
|
32
|
+
interface IgniterCallerClientContextValue<TCallers extends IgniterCallerClientMap> {
|
|
33
|
+
callers: TCallers;
|
|
34
|
+
configs: IgniterCallerClientConfigs<TCallers>;
|
|
35
|
+
globalConfig: IgniterCallerClientConfig;
|
|
36
|
+
onError?: (error: IgniterError) => void;
|
|
37
|
+
setConfig: <TKey extends IgniterCallerClientConfigKey>(callerKey: keyof TCallers, key: TKey, value: IgniterCallerClientConfigValue<TKey>) => void;
|
|
38
|
+
setConfigBatch: (callerKey: keyof TCallers, config: Partial<IgniterCallerClientConfig>) => void;
|
|
39
|
+
getConfig: <TKey extends IgniterCallerClientConfigKey>(callerKey: keyof TCallers, key: TKey) => IgniterCallerClientConfigValue<TKey> | undefined;
|
|
40
|
+
getMergedConfig: (callerKey: keyof TCallers) => IgniterCallerClientConfig;
|
|
41
|
+
register: (key: string, refetch: IgniterCallerClientRefetchFn) => void;
|
|
42
|
+
unregister: (key: string, refetch: IgniterCallerClientRefetchFn) => void;
|
|
43
|
+
invalidate: (keys: string | string[], data?: unknown) => void;
|
|
44
|
+
listeners: IgniterCallerClientListeners;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface IgniterCallerProviderProps<TCallers extends IgniterCallerClientMap> extends PropsWithChildren {
|
|
48
|
+
callers: TCallers;
|
|
49
|
+
configs?: IgniterCallerClientConfigs<TCallers>;
|
|
50
|
+
hooks?: IgniterCallerClientConfig;
|
|
51
|
+
onError?: (error: IgniterError) => void;
|
|
52
|
+
}
|
|
53
|
+
declare function IgniterCallerProvider<TCallers extends IgniterCallerClientMap>(props: IgniterCallerProviderProps<TCallers>): react_jsx_runtime.JSX.Element;
|
|
54
|
+
declare function useIgniterCallerContext<TCallers extends IgniterCallerClientMap>(): IgniterCallerClientContextValue<TCallers>;
|
|
55
|
+
declare function useIgniterCaller<TCallers extends IgniterCallerClientMap>(): <TKey extends keyof TCallers>(callerKey: TKey) => IgniterCallerClient<IgniterCallerManager<any>>;
|
|
56
|
+
|
|
57
|
+
type IgniterCallerClientRequestParams<TSchemas extends IgniterCallerSchemaMap, TPath extends string, TMethod extends IgniterCallerSchemaMethod> = EndpointInfo<TSchemas, TPath, TMethod>['params'] & Record<string, string | number | boolean>;
|
|
58
|
+
type IgniterCallerClientRequestBody<TSchemas extends IgniterCallerSchemaMap, TPath extends string, TMethod extends IgniterCallerSchemaMethod> = EndpointInfo<TSchemas, TPath, TMethod>['request'];
|
|
59
|
+
interface IgniterCallerUseQueryOptions<TResponse, TVariables extends {
|
|
60
|
+
params?: Record<string, string | number | boolean>;
|
|
61
|
+
query?: IgniterCallerClientQuery;
|
|
62
|
+
} = {
|
|
63
|
+
params?: Record<string, string | number | boolean>;
|
|
64
|
+
query?: IgniterCallerClientQuery;
|
|
65
|
+
}> {
|
|
66
|
+
enabled?: boolean;
|
|
67
|
+
initialData?: TResponse;
|
|
68
|
+
params?: TVariables['params'];
|
|
69
|
+
query?: TVariables['query'];
|
|
70
|
+
headers?: IgniterCallerClientHeaders;
|
|
71
|
+
cookies?: IgniterCallerClientCookies;
|
|
72
|
+
staleTime?: number;
|
|
73
|
+
refetchInterval?: number;
|
|
74
|
+
refetchIntervalInBackground?: boolean;
|
|
75
|
+
refetchOnWindowFocus?: boolean;
|
|
76
|
+
refetchOnMount?: boolean;
|
|
77
|
+
onLoading?: (isLoading: boolean) => void;
|
|
78
|
+
onRequest?: (response: IgniterCallerApiResponse<TResponse>) => void;
|
|
79
|
+
onSuccess?: (data: TResponse) => void;
|
|
80
|
+
onError?: (error: IgniterError) => void;
|
|
81
|
+
onSettled?: (data: TResponse | null, error?: IgniterError | null) => void;
|
|
82
|
+
}
|
|
83
|
+
interface IgniterCallerUseQueryResult<TResponse, TVariables = unknown> {
|
|
84
|
+
data: TResponse | null;
|
|
85
|
+
error: IgniterError | null;
|
|
86
|
+
variables?: TVariables;
|
|
87
|
+
isLoading: boolean;
|
|
88
|
+
isFetching: boolean;
|
|
89
|
+
isSuccess: boolean;
|
|
90
|
+
isError: boolean;
|
|
91
|
+
status: 'loading' | 'error' | 'success';
|
|
92
|
+
refetch: () => void;
|
|
93
|
+
invalidate: (data?: TResponse) => void;
|
|
94
|
+
execute: (variables?: TVariables) => Promise<IgniterCallerApiResponse<TResponse> | undefined>;
|
|
95
|
+
}
|
|
96
|
+
interface IgniterCallerUseMutateOptions<TResponse, TVariables extends {
|
|
97
|
+
params?: Record<string, string | number | boolean>;
|
|
98
|
+
query?: IgniterCallerClientQuery;
|
|
99
|
+
body?: unknown;
|
|
100
|
+
} = {
|
|
101
|
+
params?: Record<string, string | number | boolean>;
|
|
102
|
+
query?: IgniterCallerClientQuery;
|
|
103
|
+
body?: unknown;
|
|
104
|
+
}> {
|
|
105
|
+
params?: TVariables['params'];
|
|
106
|
+
query?: TVariables['query'];
|
|
107
|
+
body?: TVariables['body'];
|
|
108
|
+
headers?: IgniterCallerClientHeaders;
|
|
109
|
+
cookies?: IgniterCallerClientCookies;
|
|
110
|
+
onLoading?: (isLoading: boolean) => void;
|
|
111
|
+
onRequest?: (response: IgniterCallerApiResponse<TResponse>) => void;
|
|
112
|
+
onSuccess?: (data: TResponse) => void;
|
|
113
|
+
onError?: (error: IgniterError) => void;
|
|
114
|
+
onSettled?: (data: TResponse | null, error?: IgniterError | null) => void;
|
|
115
|
+
}
|
|
116
|
+
interface IgniterCallerUseMutateResult<TResponse, TVariables = unknown> {
|
|
117
|
+
data: TResponse | null;
|
|
118
|
+
error: IgniterError | null;
|
|
119
|
+
variables?: TVariables;
|
|
120
|
+
isLoading: boolean;
|
|
121
|
+
isSuccess: boolean;
|
|
122
|
+
isError: boolean;
|
|
123
|
+
status: 'loading' | 'error' | 'success';
|
|
124
|
+
mutate: (variables?: TVariables) => Promise<IgniterCallerApiResponse<TResponse> | undefined>;
|
|
125
|
+
retry: () => void;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
type InferCallerSchemas<TCaller> = TCaller extends IgniterCallerManager<infer TSchemas> ? TSchemas : IgniterCallerSchemaMap;
|
|
129
|
+
type IgniterCallerClientInvalidate<TSchemas extends IgniterCallerSchemaMap> = {
|
|
130
|
+
<TPath extends GetPaths<TSchemas>>(path: TPath, data?: InferResponse<TSchemas, TPath, 'GET'>): void;
|
|
131
|
+
(paths: string | string[]): void;
|
|
132
|
+
};
|
|
133
|
+
interface IgniterCallerClientConfigApi {
|
|
134
|
+
set<TKey extends IgniterCallerClientConfigKey>(key: TKey, value: IgniterCallerClientConfigValue<TKey>): void;
|
|
135
|
+
get<TKey extends IgniterCallerClientConfigKey>(key: TKey): IgniterCallerClientConfigValue<TKey> | undefined;
|
|
136
|
+
reset: () => void;
|
|
137
|
+
}
|
|
138
|
+
type IgniterCallerClientQueryBuilder<TSchemas extends IgniterCallerSchemaMap, TPath extends string> = TypedRequestBuilder<TSchemas, TPath, 'GET'> & {
|
|
139
|
+
useQuery: (options?: IgniterCallerUseQueryOptions<InferResponse<TSchemas, TPath, 'GET'>, {
|
|
140
|
+
params?: IgniterCallerClientRequestParams<TSchemas, TPath, 'GET'>;
|
|
141
|
+
query?: IgniterCallerClientQuery;
|
|
142
|
+
}>) => IgniterCallerUseQueryResult<InferResponse<TSchemas, TPath, 'GET'>>;
|
|
143
|
+
};
|
|
144
|
+
type IgniterCallerClientMutateBuilder<TSchemas extends IgniterCallerSchemaMap, TPath extends string, TMethod extends 'POST' | 'PUT' | 'PATCH' | 'DELETE'> = TypedRequestBuilder<TSchemas, TPath, TMethod> & {
|
|
145
|
+
useMutate: (options?: IgniterCallerUseMutateOptions<InferResponse<TSchemas, TPath, TMethod>, {
|
|
146
|
+
params?: IgniterCallerClientRequestParams<TSchemas, TPath, TMethod>;
|
|
147
|
+
query?: IgniterCallerClientQuery;
|
|
148
|
+
body?: IgniterCallerClientRequestBody<TSchemas, TPath, TMethod>;
|
|
149
|
+
}>) => IgniterCallerUseMutateResult<InferResponse<TSchemas, TPath, TMethod>>;
|
|
150
|
+
};
|
|
151
|
+
type IgniterCallerClientUntypedQueryBuilder = IgniterCallerTypedRequestBuilder<unknown> & {
|
|
152
|
+
useQuery: (options?: IgniterCallerUseQueryOptions<unknown>) => IgniterCallerUseQueryResult<unknown>;
|
|
153
|
+
};
|
|
154
|
+
type IgniterCallerClientUntypedMutateBuilder = IgniterCallerTypedRequestBuilder<unknown> & {
|
|
155
|
+
useMutate: (options?: IgniterCallerUseMutateOptions<unknown>) => IgniterCallerUseMutateResult<unknown>;
|
|
156
|
+
};
|
|
157
|
+
interface IgniterCallerClient<TCaller extends IgniterCallerManager<any>> {
|
|
158
|
+
raw: TCaller;
|
|
159
|
+
config: IgniterCallerClientConfigApi;
|
|
160
|
+
invalidate: IgniterCallerClientInvalidate<InferCallerSchemas<TCaller>>;
|
|
161
|
+
get: {
|
|
162
|
+
<TPath extends GetPaths<InferCallerSchemas<TCaller>>>(path: TPath): IgniterCallerClientQueryBuilder<InferCallerSchemas<TCaller>, TPath>;
|
|
163
|
+
<TPath extends string>(path?: TPath): IgniterCallerClientUntypedQueryBuilder;
|
|
164
|
+
};
|
|
165
|
+
post: {
|
|
166
|
+
<TPath extends PostPaths<InferCallerSchemas<TCaller>>>(path: TPath): IgniterCallerClientMutateBuilder<InferCallerSchemas<TCaller>, TPath, 'POST'>;
|
|
167
|
+
<TPath extends string>(path?: TPath): IgniterCallerClientUntypedMutateBuilder;
|
|
168
|
+
};
|
|
169
|
+
put: {
|
|
170
|
+
<TPath extends PutPaths<InferCallerSchemas<TCaller>>>(path: TPath): IgniterCallerClientMutateBuilder<InferCallerSchemas<TCaller>, TPath, 'PUT'>;
|
|
171
|
+
<TPath extends string>(path?: TPath): IgniterCallerClientUntypedMutateBuilder;
|
|
172
|
+
};
|
|
173
|
+
patch: {
|
|
174
|
+
<TPath extends PatchPaths<InferCallerSchemas<TCaller>>>(path: TPath): IgniterCallerClientMutateBuilder<InferCallerSchemas<TCaller>, TPath, 'PATCH'>;
|
|
175
|
+
<TPath extends string>(path?: TPath): IgniterCallerClientUntypedMutateBuilder;
|
|
176
|
+
};
|
|
177
|
+
delete: {
|
|
178
|
+
<TPath extends DeletePaths<InferCallerSchemas<TCaller>>>(path: TPath): IgniterCallerClientMutateBuilder<InferCallerSchemas<TCaller>, TPath, 'DELETE'>;
|
|
179
|
+
<TPath extends string>(path?: TPath): IgniterCallerClientUntypedMutateBuilder;
|
|
180
|
+
};
|
|
181
|
+
head: {
|
|
182
|
+
<TPath extends HeadPaths<InferCallerSchemas<TCaller>>>(path: TPath): IgniterCallerClientQueryBuilder<InferCallerSchemas<TCaller>, TPath>;
|
|
183
|
+
<TPath extends string>(path?: TPath): IgniterCallerClientUntypedQueryBuilder;
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
declare function createIgniterCallerClient<TCaller extends IgniterCallerManager<any>, TCallers extends Record<string, IgniterCallerManager<any>>>(context: IgniterCallerClientContextValue<TCallers>, callerKey: keyof TCallers): IgniterCallerClient<TCaller>;
|
|
188
|
+
|
|
189
|
+
declare class IgniterCallerClientCache {
|
|
190
|
+
private static cache;
|
|
191
|
+
static get<T>(key: string, staleTime?: number): T | undefined;
|
|
192
|
+
static set(key: string, data: unknown): void;
|
|
193
|
+
static replacePrefix(prefix: string, data: unknown): void;
|
|
194
|
+
static clearPrefix(prefix: string): void;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
declare function buildQueryKey(params: {
|
|
198
|
+
callerKey: string;
|
|
199
|
+
method: string;
|
|
200
|
+
path: string;
|
|
201
|
+
query?: IgniterCallerClientQuery;
|
|
202
|
+
params?: Record<string, string | number | boolean>;
|
|
203
|
+
}): string;
|
|
204
|
+
declare function buildQueryPrefix(params: {
|
|
205
|
+
callerKey: string;
|
|
206
|
+
method: string;
|
|
207
|
+
path: string;
|
|
208
|
+
}): string;
|
|
209
|
+
|
|
210
|
+
declare function buildCookieHeader(cookies?: IgniterCallerClientCookies): string | undefined;
|
|
211
|
+
|
|
212
|
+
export { type IgniterCallerClient, IgniterCallerClientCache, type IgniterCallerClientConfig, type IgniterCallerClientConfigApi, type IgniterCallerClientConfigKey, type IgniterCallerClientConfigValue, type IgniterCallerClientConfigs, type IgniterCallerClientContextValue, type IgniterCallerClientCookies, type IgniterCallerClientHeaders, type IgniterCallerClientInvalidate, type IgniterCallerClientListeners, type IgniterCallerClientMap, type IgniterCallerClientMutateBuilder, type IgniterCallerClientQuery, type IgniterCallerClientQueryBuilder, type IgniterCallerClientRefetchFn, type IgniterCallerClientRequestBody, type IgniterCallerClientRequestParams, type IgniterCallerClientUntypedMutateBuilder, type IgniterCallerClientUntypedQueryBuilder, IgniterCallerProvider, type IgniterCallerProviderProps, type IgniterCallerUseMutateOptions, type IgniterCallerUseMutateResult, type IgniterCallerUseQueryOptions, type IgniterCallerUseQueryResult, type InferCallerSchemas, buildCookieHeader, buildQueryKey, buildQueryPrefix, createIgniterCallerClient, useIgniterCaller, useIgniterCallerContext };
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { I as IgniterCallerManager, a as IgniterCallerApiResponse, b as IgniterCallerSchemaMap, c as IgniterCallerSchemaMethod, E as EndpointInfo, G as GetPaths, d as InferResponse, T as TypedRequestBuilder, e as IgniterCallerTypedRequestBuilder, P as PostPaths, f as PutPaths, g as PatchPaths, D as DeletePaths, H as HeadPaths } from '../manager-CVi9utzy.js';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { PropsWithChildren } from 'react';
|
|
4
|
+
import { IgniterError } from '@igniter-js/common';
|
|
5
|
+
import '@igniter-js/telemetry';
|
|
6
|
+
import 'zod';
|
|
7
|
+
import '../store-D2p2dqGN.js';
|
|
8
|
+
|
|
9
|
+
type IgniterCallerClientHeaders = Record<string, string>;
|
|
10
|
+
type IgniterCallerClientCookies = Record<string, string>;
|
|
11
|
+
type IgniterCallerClientQuery = Record<string, string | number | boolean>;
|
|
12
|
+
interface IgniterCallerClientConfig {
|
|
13
|
+
headers?: IgniterCallerClientHeaders;
|
|
14
|
+
cookies?: IgniterCallerClientCookies;
|
|
15
|
+
query?: IgniterCallerClientQuery;
|
|
16
|
+
onQueryLoading?: (isLoading: boolean) => void;
|
|
17
|
+
onQuerySuccess?: (data: unknown) => void;
|
|
18
|
+
onQueryError?: (error: IgniterError) => void;
|
|
19
|
+
onQuerySettled?: (data: unknown | null, error?: IgniterError | null) => void;
|
|
20
|
+
onMutationLoading?: (isLoading: boolean) => void;
|
|
21
|
+
onMutationSuccess?: (data: unknown) => void;
|
|
22
|
+
onMutationError?: (error: IgniterError) => void;
|
|
23
|
+
onMutationSettled?: (data: unknown | null, error?: IgniterError | null) => void;
|
|
24
|
+
}
|
|
25
|
+
type IgniterCallerClientConfigKey = keyof IgniterCallerClientConfig;
|
|
26
|
+
type IgniterCallerClientConfigValue<TKey extends IgniterCallerClientConfigKey> = IgniterCallerClientConfig[TKey];
|
|
27
|
+
|
|
28
|
+
type IgniterCallerClientMap = Record<string, IgniterCallerManager<any>>;
|
|
29
|
+
type IgniterCallerClientConfigs<TCallers extends IgniterCallerClientMap> = Partial<Record<keyof TCallers, IgniterCallerClientConfig>>;
|
|
30
|
+
type IgniterCallerClientRefetchFn = (invalidate?: boolean) => void;
|
|
31
|
+
type IgniterCallerClientListeners = Map<string, Set<IgniterCallerClientRefetchFn>>;
|
|
32
|
+
interface IgniterCallerClientContextValue<TCallers extends IgniterCallerClientMap> {
|
|
33
|
+
callers: TCallers;
|
|
34
|
+
configs: IgniterCallerClientConfigs<TCallers>;
|
|
35
|
+
globalConfig: IgniterCallerClientConfig;
|
|
36
|
+
onError?: (error: IgniterError) => void;
|
|
37
|
+
setConfig: <TKey extends IgniterCallerClientConfigKey>(callerKey: keyof TCallers, key: TKey, value: IgniterCallerClientConfigValue<TKey>) => void;
|
|
38
|
+
setConfigBatch: (callerKey: keyof TCallers, config: Partial<IgniterCallerClientConfig>) => void;
|
|
39
|
+
getConfig: <TKey extends IgniterCallerClientConfigKey>(callerKey: keyof TCallers, key: TKey) => IgniterCallerClientConfigValue<TKey> | undefined;
|
|
40
|
+
getMergedConfig: (callerKey: keyof TCallers) => IgniterCallerClientConfig;
|
|
41
|
+
register: (key: string, refetch: IgniterCallerClientRefetchFn) => void;
|
|
42
|
+
unregister: (key: string, refetch: IgniterCallerClientRefetchFn) => void;
|
|
43
|
+
invalidate: (keys: string | string[], data?: unknown) => void;
|
|
44
|
+
listeners: IgniterCallerClientListeners;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface IgniterCallerProviderProps<TCallers extends IgniterCallerClientMap> extends PropsWithChildren {
|
|
48
|
+
callers: TCallers;
|
|
49
|
+
configs?: IgniterCallerClientConfigs<TCallers>;
|
|
50
|
+
hooks?: IgniterCallerClientConfig;
|
|
51
|
+
onError?: (error: IgniterError) => void;
|
|
52
|
+
}
|
|
53
|
+
declare function IgniterCallerProvider<TCallers extends IgniterCallerClientMap>(props: IgniterCallerProviderProps<TCallers>): react_jsx_runtime.JSX.Element;
|
|
54
|
+
declare function useIgniterCallerContext<TCallers extends IgniterCallerClientMap>(): IgniterCallerClientContextValue<TCallers>;
|
|
55
|
+
declare function useIgniterCaller<TCallers extends IgniterCallerClientMap>(): <TKey extends keyof TCallers>(callerKey: TKey) => IgniterCallerClient<IgniterCallerManager<any>>;
|
|
56
|
+
|
|
57
|
+
type IgniterCallerClientRequestParams<TSchemas extends IgniterCallerSchemaMap, TPath extends string, TMethod extends IgniterCallerSchemaMethod> = EndpointInfo<TSchemas, TPath, TMethod>['params'] & Record<string, string | number | boolean>;
|
|
58
|
+
type IgniterCallerClientRequestBody<TSchemas extends IgniterCallerSchemaMap, TPath extends string, TMethod extends IgniterCallerSchemaMethod> = EndpointInfo<TSchemas, TPath, TMethod>['request'];
|
|
59
|
+
interface IgniterCallerUseQueryOptions<TResponse, TVariables extends {
|
|
60
|
+
params?: Record<string, string | number | boolean>;
|
|
61
|
+
query?: IgniterCallerClientQuery;
|
|
62
|
+
} = {
|
|
63
|
+
params?: Record<string, string | number | boolean>;
|
|
64
|
+
query?: IgniterCallerClientQuery;
|
|
65
|
+
}> {
|
|
66
|
+
enabled?: boolean;
|
|
67
|
+
initialData?: TResponse;
|
|
68
|
+
params?: TVariables['params'];
|
|
69
|
+
query?: TVariables['query'];
|
|
70
|
+
headers?: IgniterCallerClientHeaders;
|
|
71
|
+
cookies?: IgniterCallerClientCookies;
|
|
72
|
+
staleTime?: number;
|
|
73
|
+
refetchInterval?: number;
|
|
74
|
+
refetchIntervalInBackground?: boolean;
|
|
75
|
+
refetchOnWindowFocus?: boolean;
|
|
76
|
+
refetchOnMount?: boolean;
|
|
77
|
+
onLoading?: (isLoading: boolean) => void;
|
|
78
|
+
onRequest?: (response: IgniterCallerApiResponse<TResponse>) => void;
|
|
79
|
+
onSuccess?: (data: TResponse) => void;
|
|
80
|
+
onError?: (error: IgniterError) => void;
|
|
81
|
+
onSettled?: (data: TResponse | null, error?: IgniterError | null) => void;
|
|
82
|
+
}
|
|
83
|
+
interface IgniterCallerUseQueryResult<TResponse, TVariables = unknown> {
|
|
84
|
+
data: TResponse | null;
|
|
85
|
+
error: IgniterError | null;
|
|
86
|
+
variables?: TVariables;
|
|
87
|
+
isLoading: boolean;
|
|
88
|
+
isFetching: boolean;
|
|
89
|
+
isSuccess: boolean;
|
|
90
|
+
isError: boolean;
|
|
91
|
+
status: 'loading' | 'error' | 'success';
|
|
92
|
+
refetch: () => void;
|
|
93
|
+
invalidate: (data?: TResponse) => void;
|
|
94
|
+
execute: (variables?: TVariables) => Promise<IgniterCallerApiResponse<TResponse> | undefined>;
|
|
95
|
+
}
|
|
96
|
+
interface IgniterCallerUseMutateOptions<TResponse, TVariables extends {
|
|
97
|
+
params?: Record<string, string | number | boolean>;
|
|
98
|
+
query?: IgniterCallerClientQuery;
|
|
99
|
+
body?: unknown;
|
|
100
|
+
} = {
|
|
101
|
+
params?: Record<string, string | number | boolean>;
|
|
102
|
+
query?: IgniterCallerClientQuery;
|
|
103
|
+
body?: unknown;
|
|
104
|
+
}> {
|
|
105
|
+
params?: TVariables['params'];
|
|
106
|
+
query?: TVariables['query'];
|
|
107
|
+
body?: TVariables['body'];
|
|
108
|
+
headers?: IgniterCallerClientHeaders;
|
|
109
|
+
cookies?: IgniterCallerClientCookies;
|
|
110
|
+
onLoading?: (isLoading: boolean) => void;
|
|
111
|
+
onRequest?: (response: IgniterCallerApiResponse<TResponse>) => void;
|
|
112
|
+
onSuccess?: (data: TResponse) => void;
|
|
113
|
+
onError?: (error: IgniterError) => void;
|
|
114
|
+
onSettled?: (data: TResponse | null, error?: IgniterError | null) => void;
|
|
115
|
+
}
|
|
116
|
+
interface IgniterCallerUseMutateResult<TResponse, TVariables = unknown> {
|
|
117
|
+
data: TResponse | null;
|
|
118
|
+
error: IgniterError | null;
|
|
119
|
+
variables?: TVariables;
|
|
120
|
+
isLoading: boolean;
|
|
121
|
+
isSuccess: boolean;
|
|
122
|
+
isError: boolean;
|
|
123
|
+
status: 'loading' | 'error' | 'success';
|
|
124
|
+
mutate: (variables?: TVariables) => Promise<IgniterCallerApiResponse<TResponse> | undefined>;
|
|
125
|
+
retry: () => void;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
type InferCallerSchemas<TCaller> = TCaller extends IgniterCallerManager<infer TSchemas> ? TSchemas : IgniterCallerSchemaMap;
|
|
129
|
+
type IgniterCallerClientInvalidate<TSchemas extends IgniterCallerSchemaMap> = {
|
|
130
|
+
<TPath extends GetPaths<TSchemas>>(path: TPath, data?: InferResponse<TSchemas, TPath, 'GET'>): void;
|
|
131
|
+
(paths: string | string[]): void;
|
|
132
|
+
};
|
|
133
|
+
interface IgniterCallerClientConfigApi {
|
|
134
|
+
set<TKey extends IgniterCallerClientConfigKey>(key: TKey, value: IgniterCallerClientConfigValue<TKey>): void;
|
|
135
|
+
get<TKey extends IgniterCallerClientConfigKey>(key: TKey): IgniterCallerClientConfigValue<TKey> | undefined;
|
|
136
|
+
reset: () => void;
|
|
137
|
+
}
|
|
138
|
+
type IgniterCallerClientQueryBuilder<TSchemas extends IgniterCallerSchemaMap, TPath extends string> = TypedRequestBuilder<TSchemas, TPath, 'GET'> & {
|
|
139
|
+
useQuery: (options?: IgniterCallerUseQueryOptions<InferResponse<TSchemas, TPath, 'GET'>, {
|
|
140
|
+
params?: IgniterCallerClientRequestParams<TSchemas, TPath, 'GET'>;
|
|
141
|
+
query?: IgniterCallerClientQuery;
|
|
142
|
+
}>) => IgniterCallerUseQueryResult<InferResponse<TSchemas, TPath, 'GET'>>;
|
|
143
|
+
};
|
|
144
|
+
type IgniterCallerClientMutateBuilder<TSchemas extends IgniterCallerSchemaMap, TPath extends string, TMethod extends 'POST' | 'PUT' | 'PATCH' | 'DELETE'> = TypedRequestBuilder<TSchemas, TPath, TMethod> & {
|
|
145
|
+
useMutate: (options?: IgniterCallerUseMutateOptions<InferResponse<TSchemas, TPath, TMethod>, {
|
|
146
|
+
params?: IgniterCallerClientRequestParams<TSchemas, TPath, TMethod>;
|
|
147
|
+
query?: IgniterCallerClientQuery;
|
|
148
|
+
body?: IgniterCallerClientRequestBody<TSchemas, TPath, TMethod>;
|
|
149
|
+
}>) => IgniterCallerUseMutateResult<InferResponse<TSchemas, TPath, TMethod>>;
|
|
150
|
+
};
|
|
151
|
+
type IgniterCallerClientUntypedQueryBuilder = IgniterCallerTypedRequestBuilder<unknown> & {
|
|
152
|
+
useQuery: (options?: IgniterCallerUseQueryOptions<unknown>) => IgniterCallerUseQueryResult<unknown>;
|
|
153
|
+
};
|
|
154
|
+
type IgniterCallerClientUntypedMutateBuilder = IgniterCallerTypedRequestBuilder<unknown> & {
|
|
155
|
+
useMutate: (options?: IgniterCallerUseMutateOptions<unknown>) => IgniterCallerUseMutateResult<unknown>;
|
|
156
|
+
};
|
|
157
|
+
interface IgniterCallerClient<TCaller extends IgniterCallerManager<any>> {
|
|
158
|
+
raw: TCaller;
|
|
159
|
+
config: IgniterCallerClientConfigApi;
|
|
160
|
+
invalidate: IgniterCallerClientInvalidate<InferCallerSchemas<TCaller>>;
|
|
161
|
+
get: {
|
|
162
|
+
<TPath extends GetPaths<InferCallerSchemas<TCaller>>>(path: TPath): IgniterCallerClientQueryBuilder<InferCallerSchemas<TCaller>, TPath>;
|
|
163
|
+
<TPath extends string>(path?: TPath): IgniterCallerClientUntypedQueryBuilder;
|
|
164
|
+
};
|
|
165
|
+
post: {
|
|
166
|
+
<TPath extends PostPaths<InferCallerSchemas<TCaller>>>(path: TPath): IgniterCallerClientMutateBuilder<InferCallerSchemas<TCaller>, TPath, 'POST'>;
|
|
167
|
+
<TPath extends string>(path?: TPath): IgniterCallerClientUntypedMutateBuilder;
|
|
168
|
+
};
|
|
169
|
+
put: {
|
|
170
|
+
<TPath extends PutPaths<InferCallerSchemas<TCaller>>>(path: TPath): IgniterCallerClientMutateBuilder<InferCallerSchemas<TCaller>, TPath, 'PUT'>;
|
|
171
|
+
<TPath extends string>(path?: TPath): IgniterCallerClientUntypedMutateBuilder;
|
|
172
|
+
};
|
|
173
|
+
patch: {
|
|
174
|
+
<TPath extends PatchPaths<InferCallerSchemas<TCaller>>>(path: TPath): IgniterCallerClientMutateBuilder<InferCallerSchemas<TCaller>, TPath, 'PATCH'>;
|
|
175
|
+
<TPath extends string>(path?: TPath): IgniterCallerClientUntypedMutateBuilder;
|
|
176
|
+
};
|
|
177
|
+
delete: {
|
|
178
|
+
<TPath extends DeletePaths<InferCallerSchemas<TCaller>>>(path: TPath): IgniterCallerClientMutateBuilder<InferCallerSchemas<TCaller>, TPath, 'DELETE'>;
|
|
179
|
+
<TPath extends string>(path?: TPath): IgniterCallerClientUntypedMutateBuilder;
|
|
180
|
+
};
|
|
181
|
+
head: {
|
|
182
|
+
<TPath extends HeadPaths<InferCallerSchemas<TCaller>>>(path: TPath): IgniterCallerClientQueryBuilder<InferCallerSchemas<TCaller>, TPath>;
|
|
183
|
+
<TPath extends string>(path?: TPath): IgniterCallerClientUntypedQueryBuilder;
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
declare function createIgniterCallerClient<TCaller extends IgniterCallerManager<any>, TCallers extends Record<string, IgniterCallerManager<any>>>(context: IgniterCallerClientContextValue<TCallers>, callerKey: keyof TCallers): IgniterCallerClient<TCaller>;
|
|
188
|
+
|
|
189
|
+
declare class IgniterCallerClientCache {
|
|
190
|
+
private static cache;
|
|
191
|
+
static get<T>(key: string, staleTime?: number): T | undefined;
|
|
192
|
+
static set(key: string, data: unknown): void;
|
|
193
|
+
static replacePrefix(prefix: string, data: unknown): void;
|
|
194
|
+
static clearPrefix(prefix: string): void;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
declare function buildQueryKey(params: {
|
|
198
|
+
callerKey: string;
|
|
199
|
+
method: string;
|
|
200
|
+
path: string;
|
|
201
|
+
query?: IgniterCallerClientQuery;
|
|
202
|
+
params?: Record<string, string | number | boolean>;
|
|
203
|
+
}): string;
|
|
204
|
+
declare function buildQueryPrefix(params: {
|
|
205
|
+
callerKey: string;
|
|
206
|
+
method: string;
|
|
207
|
+
path: string;
|
|
208
|
+
}): string;
|
|
209
|
+
|
|
210
|
+
declare function buildCookieHeader(cookies?: IgniterCallerClientCookies): string | undefined;
|
|
211
|
+
|
|
212
|
+
export { type IgniterCallerClient, IgniterCallerClientCache, type IgniterCallerClientConfig, type IgniterCallerClientConfigApi, type IgniterCallerClientConfigKey, type IgniterCallerClientConfigValue, type IgniterCallerClientConfigs, type IgniterCallerClientContextValue, type IgniterCallerClientCookies, type IgniterCallerClientHeaders, type IgniterCallerClientInvalidate, type IgniterCallerClientListeners, type IgniterCallerClientMap, type IgniterCallerClientMutateBuilder, type IgniterCallerClientQuery, type IgniterCallerClientQueryBuilder, type IgniterCallerClientRefetchFn, type IgniterCallerClientRequestBody, type IgniterCallerClientRequestParams, type IgniterCallerClientUntypedMutateBuilder, type IgniterCallerClientUntypedQueryBuilder, IgniterCallerProvider, type IgniterCallerProviderProps, type IgniterCallerUseMutateOptions, type IgniterCallerUseMutateResult, type IgniterCallerUseQueryOptions, type IgniterCallerUseQueryResult, type InferCallerSchemas, buildCookieHeader, buildQueryKey, buildQueryPrefix, createIgniterCallerClient, useIgniterCaller, useIgniterCallerContext };
|