@zayne-labs/callapi 1.11.30 → 1.11.32

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
@@ -65,8 +65,8 @@ Structured errors make robust error handling trivial.
65
65
  const { data, error } = await callApi("/api/users");
66
66
 
67
67
  if (error) {
68
- console.log(error.name); // "HTTPError", "ValidationError"
69
- console.log(error.errorData); // Actual API response
68
+ console.log(error.name); // "HTTPError", "ValidationError"
69
+ console.log(error.errorData); // Actual API response
70
70
  }
71
71
  ```
72
72
 
@@ -76,9 +76,9 @@ Supports exponential backoff and custom retry conditions.
76
76
 
77
77
  ```js
78
78
  await callApi("/api/data", {
79
- retryAttempts: 3,
80
- retryStrategy: "exponential",
81
- retryStatusCodes: [429, 500, 502, 503],
79
+ retryAttempts: 3,
80
+ retryStrategy: "exponential",
81
+ retryStatusCodes: [429, 500, 502, 503],
82
82
  });
83
83
  ```
84
84
 
@@ -92,19 +92,19 @@ import { createFetchClient } from "@zayne-labs/callapi";
92
92
  import { defineSchema } from "@zayne-labs/callapi/utils";
93
93
 
94
94
  const callMainApi = createFetchClient({
95
- schema: defineSchema({
96
- "/users/:id": {
97
- data: z.object({
98
- id: z.number(),
99
- name: z.string(),
100
- }),
101
- },
102
- }),
95
+ schema: defineSchema({
96
+ "/users/:id": {
97
+ data: z.object({
98
+ id: z.number(),
99
+ name: z.string(),
100
+ }),
101
+ },
102
+ }),
103
103
  });
104
104
 
105
105
  // Fully typed + validated
106
106
  const user = await callMainApi("/users/:id", {
107
- params: { id: 123 },
107
+ params: { id: 123 },
108
108
  });
109
109
  ```
110
110
 
@@ -114,15 +114,15 @@ Hook into CallApi's lifecycle at any point.
114
114
 
115
115
  ```js
116
116
  const api = createFetchClient({
117
- onRequest: ({ request }) => {
118
- request.headers.set("Authorization", `Bearer ${token}`);
119
- },
120
- onError: ({ error }) => {
121
- Sentry.captureException(error);
122
- },
123
- onResponseStream: ({ event }) => {
124
- console.log(`Downloaded ${event.progress}%`);
125
- },
117
+ onRequest: ({ request }) => {
118
+ request.headers.set("Authorization", `Bearer ${token}`);
119
+ },
120
+ onError: ({ error }) => {
121
+ Sentry.captureException(error);
122
+ },
123
+ onResponseStream: ({ event }) => {
124
+ console.log(`Downloaded ${event.progress}%`);
125
+ },
126
126
  });
127
127
  ```
128
128
 
@@ -132,38 +132,38 @@ Extend functionality with setup, hooks, and middleware.
132
132
 
133
133
  ```js
134
134
  const metricsPlugin = definePlugin({
135
- id: "metrics",
136
- name: "Metrics Plugin",
137
-
138
- setup: ({ options }) => ({
139
- options: {
140
- ...options,
141
- meta: { startTime: Date.now() },
142
- },
143
- }),
144
-
145
- hooks: {
146
- onSuccess: ({ options }) => {
147
- const duration = Date.now() - options.meta.startTime;
148
-
149
- console.info(`Request took ${duration}ms`);
150
- },
151
- },
152
-
153
- middlewares: {
154
- fetchMiddleware: (ctx) => async (input, init) => {
155
- console.info("→", input);
156
-
157
- const response = await ctx.fetchImpl(input, init);
158
-
159
- console.info("←", response.status);
160
- return response;
161
- },
162
- },
135
+ id: "metrics",
136
+ name: "Metrics Plugin",
137
+
138
+ setup: ({ options }) => ({
139
+ options: {
140
+ ...options,
141
+ meta: { startTime: Date.now() },
142
+ },
143
+ }),
144
+
145
+ hooks: {
146
+ onSuccess: ({ options }) => {
147
+ const duration = Date.now() - options.meta.startTime;
148
+
149
+ console.info(`Request took ${duration}ms`);
150
+ },
151
+ },
152
+
153
+ middlewares: {
154
+ fetchMiddleware: (ctx) => async (input, init) => {
155
+ console.info("→", input);
156
+
157
+ const response = await ctx.fetchImpl(input, init);
158
+
159
+ console.info("←", response.status);
160
+ return response;
161
+ },
162
+ },
163
163
  });
164
164
 
165
165
  const api = createFetchClient({
166
- plugins: [metricsPlugin],
166
+ plugins: [metricsPlugin],
167
167
  });
168
168
  ```
169
169
 
@@ -195,10 +195,10 @@ const { data } = await callApi("/api/users");
195
195
 
196
196
  // Configured
197
197
  const api = createFetchClient({
198
- baseURL: "https://api.example.com",
199
- retryAttempts: 2,
200
- timeout: 10000,
201
- onError: ({ error }) => trackError(error),
198
+ baseURL: "https://api.example.com",
199
+ retryAttempts: 2,
200
+ timeout: 10000,
201
+ onError: ({ error }) => trackError(error),
202
202
  });
203
203
  ```
204
204
 
@@ -206,7 +206,7 @@ const api = createFetchClient({
206
206
 
207
207
  ```html
208
208
  <script type="module">
209
- import { callApi } from "https://esm.run/@zayne-labs/callapi";
209
+ import { callApi } from "https://esm.run/@zayne-labs/callapi";
210
210
  </script>
211
211
  ```
212
212
 
@@ -93,157 +93,6 @@ type StreamProgressEvent = {
93
93
  transferredBytes: number;
94
94
  };
95
95
  //#endregion
96
- //#region src/middlewares.d.ts
97
- type FetchImpl = UnmaskType<(input: string | Request | URL, init?: RequestInit) => Promise<Response>>;
98
- interface Middlewares<TCallApiContext extends NoInfer<CallApiContext> = DefaultCallApiContext> {
99
- /**
100
- * Wraps the fetch implementation to intercept requests at the network layer.
101
- *
102
- * Takes a context object containing the current fetch function and returns a new fetch function.
103
- * Use it to cache responses, add logging, handle offline mode, or short-circuit requests etc.
104
- * Multiple middleware compose in order: plugins → base config → per-request.
105
- *
106
- * Unlike `customFetchImpl`, middleware can call through to the original fetch.
107
- *
108
- * @example
109
- * ```ts
110
- * // Cache responses
111
- * const cache = new Map();
112
- *
113
- * fetchMiddleware: (ctx) => async (input, init) => {
114
- * const key = input.toString();
115
- * if (cache.has(key)) return cache.get(key).clone();
116
- *
117
- * const response = await ctx.fetchImpl(input, init);
118
- * cache.set(key, response.clone());
119
- * return response;
120
- * }
121
- *
122
- * // Handle offline
123
- * fetchMiddleware: (ctx) => async (input, init) => {
124
- * if (!navigator.onLine) {
125
- * return new Response('{"error": "offline"}', { status: 503 });
126
- * }
127
- * return ctx.fetchImpl(input, init);
128
- * }
129
- * ```
130
- */
131
- fetchMiddleware?: (context: RequestContext<TCallApiContext> & {
132
- fetchImpl: FetchImpl;
133
- }) => FetchImpl;
134
- }
135
- //#endregion
136
- //#region src/types/conditional-types.d.ts
137
- /**
138
- * @description Makes a type partial if the output type of TSchema is not provided or has undefined in the union, otherwise makes it required
139
- */
140
- type MakeSchemaOptionRequiredIfDefined<TSchemaOption extends CallApiSchema[keyof CallApiSchema], TObject> = undefined extends InferSchemaOutput<TSchemaOption, undefined> ? TObject : Required<TObject>;
141
- type ApplyURLBasedConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig["prefix"] extends string ? `${TSchemaConfig["prefix"]}${TSchemaRouteKeys}` : TSchemaConfig["baseURL"] extends string ? `${TSchemaConfig["baseURL"]}${TSchemaRouteKeys}` : TSchemaRouteKeys;
142
- type ApplyStrictConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig["strict"] extends true ? TSchemaRouteKeys :
143
- // eslint-disable-next-line perfectionist/sort-union-types -- Don't sort union types
144
- TSchemaRouteKeys | Exclude<InitURLOrURLObject, RouteKeyMethodsURLUnion>;
145
- type ApplySchemaConfiguration<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = ApplyStrictConfig<TSchemaConfig, ApplyURLBasedConfig<TSchemaConfig, TSchemaRouteKeys>>;
146
- type InferAllRouteKeys<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = ApplySchemaConfiguration<TSchemaConfig, Exclude<Extract<keyof TBaseSchemaRoutes, string>, FallBackRouteSchemaKey>>;
147
- type InferInitURL<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = keyof TBaseSchemaRoutes extends never ? InitURLOrURLObject : InferAllRouteKeys<TBaseSchemaRoutes, TSchemaConfig>;
148
- type GetCurrentRouteSchemaKey<TSchemaConfig extends CallApiSchemaConfig, TPath> = TPath extends URL ? string : TSchemaConfig["baseURL"] extends string ? TPath extends `${TSchemaConfig["baseURL"]}${infer TCurrentRoute}` ? TCurrentRoute extends string ? TCurrentRoute : string : TPath extends `${TSchemaConfig["prefix"]}${infer TCurrentRoute}` ? TCurrentRoute extends string ? TCurrentRoute : string : string : TPath;
149
- type GetCurrentRouteSchema<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TComputedFallBackRouteSchema = TBaseSchemaRoutes[FallBackRouteSchemaKey], TComputedCurrentRouteSchema = TBaseSchemaRoutes[TCurrentRouteSchemaKey], TComputedRouteSchema extends CallApiSchema = NonNullable<Omit<TComputedFallBackRouteSchema, keyof TComputedCurrentRouteSchema> & TComputedCurrentRouteSchema>> = TComputedRouteSchema extends CallApiSchema ? Writeable<TComputedRouteSchema, "deep"> : CallApiSchema;
150
- type JsonPrimitive = boolean | number | string | null | undefined;
151
- type SerializableObject = Record<PropertyKey, unknown>;
152
- type SerializableArray = Array<JsonPrimitive | SerializableObject> | ReadonlyArray<JsonPrimitive | SerializableObject>;
153
- type Body = UnmaskType<Exclude<RequestInit["body"], undefined> | SerializableArray | SerializableObject>;
154
- type InferBodyOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema["body"], {
155
- /**
156
- * Body of the request, can be a object or any other supported body type.
157
- */
158
- body?: InferSchemaOutput<TSchema["body"], Body>;
159
- }>;
160
- type MethodUnion = UnmaskType<"CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE" | AnyString>;
161
- type InferMethodFromURL<TInitURL> = string extends TInitURL ? MethodUnion : TInitURL extends `@${infer TMethod extends RouteKeyMethods}/${string}` ? Uppercase<TMethod> : MethodUnion;
162
- type InferMethodOption<TSchema extends CallApiSchema, TInitURL> = MakeSchemaOptionRequiredIfDefined<TSchema["method"], {
163
- /**
164
- * HTTP method for the request.
165
- * @default "GET"
166
- */
167
- method?: InferSchemaOutput<TSchema["method"], InferMethodFromURL<TInitURL>>;
168
- }>;
169
- type HeadersOption = UnmaskType<Record<"Authorization", CommonAuthorizationHeaders | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | Array<[string, string]>>;
170
- type InferHeadersOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema["headers"], {
171
- /**
172
- * Headers to be used in the request.
173
- */
174
- headers?: InferSchemaOutput<TSchema["headers"], HeadersOption> | ((context: {
175
- baseHeaders: NonNullable<HeadersOption>;
176
- }) => InferSchemaOutput<TSchema["headers"], HeadersOption>);
177
- }>;
178
- type InferRequestOptions<TSchema extends CallApiSchema, TInitURL extends InferInitURL<BaseCallApiSchemaRoutes, CallApiSchemaConfig>> = InferBodyOption<TSchema> & InferHeadersOption<TSchema> & InferMethodOption<TSchema, TInitURL>;
179
- type InferMetaOption<TSchema extends CallApiSchema, TCallApiContext extends CallApiContext> = MakeSchemaOptionRequiredIfDefined<TSchema["meta"], {
180
- /**
181
- * - An optional field you can fill with additional information,
182
- * to associate with the request, typically used for logging or tracing.
183
- *
184
- * - A good use case for this, would be to use the info to handle specific cases in any of the shared interceptors.
185
- *
186
- * @example
187
- * ```ts
188
- * const callMainApi = callApi.create({
189
- * baseURL: "https://main-api.com",
190
- * onResponseError: ({ response, options }) => {
191
- * if (options.meta?.userId) {
192
- * console.error(`User ${options.meta.userId} made an error`);
193
- * }
194
- * },
195
- * });
196
- *
197
- * const response = await callMainApi({
198
- * url: "https://example.com/api/data",
199
- * meta: { userId: "123" },
200
- * });
201
- * ```
202
- */
203
- meta?: InferSchemaOutput<TSchema["meta"], TCallApiContext["Meta"]>;
204
- }>;
205
- type InferQueryOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema["query"], {
206
- /**
207
- * Parameters to be appended to the URL (i.e: /:id)
208
- */
209
- query?: InferSchemaOutput<TSchema["query"], Query>;
210
- }>;
211
- type EmptyString = "";
212
- type EmptyTuple = readonly [];
213
- type StringTuple = readonly string[];
214
- type PossibleParamNamePatterns = `${string}:${string}` | `${string}{${string}}${"" | AnyString}`;
215
- type ExtractRouteParamNames<TCurrentRoute$1, TParamNamesAccumulator extends StringTuple = EmptyTuple> = TCurrentRoute$1 extends PossibleParamNamePatterns ? TCurrentRoute$1 extends `${infer TRoutePrefix}:${infer TParamAndRemainingRoute}` ? TParamAndRemainingRoute extends `${infer TCurrentParam}/${infer TRemainingRoute}` ? TCurrentParam extends EmptyString ? ExtractRouteParamNames<`${TRoutePrefix}/${TRemainingRoute}`, TParamNamesAccumulator> : ExtractRouteParamNames<`${TRoutePrefix}/${TRemainingRoute}`, [...TParamNamesAccumulator, TCurrentParam]> : TParamAndRemainingRoute extends `${infer TCurrentParam}` ? TCurrentParam extends EmptyString ? ExtractRouteParamNames<TRoutePrefix, TParamNamesAccumulator> : ExtractRouteParamNames<TRoutePrefix, [...TParamNamesAccumulator, TCurrentParam]> : ExtractRouteParamNames<TRoutePrefix, TParamNamesAccumulator> : TCurrentRoute$1 extends `${infer TRoutePrefix}{${infer TCurrentParam}}${infer TRemainingRoute}` ? TCurrentParam extends EmptyString ? ExtractRouteParamNames<`${TRoutePrefix}${TRemainingRoute}`, TParamNamesAccumulator> : ExtractRouteParamNames<`${TRoutePrefix}${TRemainingRoute}`, [...TParamNamesAccumulator, TCurrentParam]> : TParamNamesAccumulator : TParamNamesAccumulator;
216
- type ConvertParamNamesToRecord<TParamNames extends StringTuple> = Prettify<TParamNames extends (readonly [infer TFirstParamName extends string, ...infer TRemainingParamNames extends StringTuple]) ? Record<TFirstParamName, AllowedQueryParamValues> & ConvertParamNamesToRecord<TRemainingParamNames> : NonNullable<unknown>>;
217
- type ConvertParamNamesToTuple<TParamNames extends StringTuple> = TParamNames extends readonly [string, ...infer TRemainingParamNames extends StringTuple] ? [AllowedQueryParamValues, ...ConvertParamNamesToTuple<TRemainingParamNames>] : [];
218
- type InferParamsFromRoute<TCurrentRoute$1> = ExtractRouteParamNames<TCurrentRoute$1> extends StringTuple ? ExtractRouteParamNames<TCurrentRoute$1> extends EmptyTuple ? Params : ConvertParamNamesToRecord<ExtractRouteParamNames<TCurrentRoute$1>> | ConvertParamNamesToTuple<ExtractRouteParamNames<TCurrentRoute$1>> : Params;
219
- type MakeParamsOptionRequired<TParamsSchemaOption extends CallApiSchema["params"], TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TObject> = MakeSchemaOptionRequiredIfDefined<TParamsSchemaOption, Params extends InferParamsFromRoute<TCurrentRouteSchemaKey> ? TObject : TCurrentRouteSchemaKey extends Extract<keyof TBaseSchemaRoutes, TCurrentRouteSchemaKey> ? undefined extends InferSchemaOutput<TParamsSchemaOption, null> ? TObject : Required<TObject> : TObject>;
220
- type InferParamsOption<TSchema extends CallApiSchema, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = MakeParamsOptionRequired<TSchema["params"], TBaseSchemaRoutes, TCurrentRouteSchemaKey, {
221
- /**
222
- * Parameters to be appended to the URL (i.e: /:id)
223
- */
224
- params?: InferSchemaOutput<TSchema["params"], InferParamsFromRoute<TCurrentRouteSchemaKey>>;
225
- }>;
226
- type InferExtraOptions<TSchema extends CallApiSchema, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TCallApiContext extends CallApiContext> = InferMetaOption<TSchema, TCallApiContext> & InferParamsOption<TSchema, TBaseSchemaRoutes, TCurrentRouteSchemaKey> & InferQueryOption<TSchema>;
227
- type InferPluginExtraOptions<TPluginArray extends CallApiPlugin[]> = UnionToIntersection<TPluginArray extends Array<infer TPlugin> ? TPlugin extends CallApiPlugin ? TPlugin["defineExtraOptions"] extends AnyFunction<infer TReturnedSchema> ? InferSchemaOutput<TReturnedSchema> : never : never : never>;
228
- type ResultModeOption<TErrorData, TResultMode extends ResultModeType> = TErrorData extends false ? {
229
- resultMode: "onlyData";
230
- } : TErrorData extends false | undefined ? {
231
- resultMode?: "onlyData";
232
- } : {
233
- resultMode?: TResultMode;
234
- };
235
- type ThrowOnErrorUnion = boolean;
236
- type ThrowOnErrorType<TErrorData, TThrowOnError extends ThrowOnErrorUnion> = TThrowOnError | ((context: ErrorContext<{
237
- ErrorData: TErrorData;
238
- }>) => TThrowOnError);
239
- type ThrowOnErrorOption<TErrorData, TThrowOnError extends ThrowOnErrorUnion> = TErrorData extends false ? {
240
- throwOnError: true;
241
- } : TErrorData extends false | undefined ? {
242
- throwOnError?: true;
243
- } : {
244
- throwOnError?: ThrowOnErrorType<TErrorData, TThrowOnError>;
245
- };
246
- //#endregion
247
96
  //#region src/types/standard-schema.d.ts
248
97
  /**
249
98
  * The Standard Schema interface.
@@ -349,6 +198,7 @@ type ResultVariant = "infer-input" | "infer-output";
349
198
  type InferSchemaResult<TSchema, TFallbackResult, TResultVariant extends ResultVariant> = undefined extends TSchema ? TFallbackResult : TSchema extends StandardSchemaV1 ? TResultVariant extends "infer-input" ? StandardSchemaV1.InferInput<TSchema> : StandardSchemaV1.InferOutput<TSchema> : TSchema extends AnyFunction<infer TResult> ? Awaited<TResult> : TFallbackResult;
350
199
  type InferSchemaOutput<TSchema, TFallbackResult = unknown> = InferSchemaResult<TSchema, TFallbackResult, "infer-output">;
351
200
  type InferSchemaInput<TSchema, TFallbackResult = unknown> = InferSchemaResult<TSchema, TFallbackResult, "infer-input">;
201
+ type BooleanObject = { [Key in keyof CallApiSchema]: boolean };
352
202
  interface CallApiSchemaConfig {
353
203
  /**
354
204
  * The base url of the schema. By default it's the baseURL of the callApi instance.
@@ -357,14 +207,14 @@ interface CallApiSchemaConfig {
357
207
  /**
358
208
  * Disables runtime validation for the schema.
359
209
  */
360
- disableRuntimeValidation?: boolean;
210
+ disableRuntimeValidation?: boolean | BooleanObject;
361
211
  /**
362
212
  * If `true`, the original input value will be used instead of the transformed/validated output.
363
213
  *
364
214
  * This is useful when you want to validate the input but don't want any transformations
365
215
  * applied by the validation schema (e.g., type coercion, default values, etc).
366
216
  */
367
- disableValidationOutputApplication?: boolean;
217
+ disableValidationOutputApplication?: boolean | BooleanObject;
368
218
  /**
369
219
  * Optional url prefix that will be substituted for the `baseURL` of the schemaConfig at runtime.
370
220
  *
@@ -549,6 +399,157 @@ interface URLOptions {
549
399
  query?: Query;
550
400
  }
551
401
  //#endregion
402
+ //#region src/types/conditional-types.d.ts
403
+ /**
404
+ * @description Makes a type partial if the output type of TSchema is not provided or has undefined in the union, otherwise makes it required
405
+ */
406
+ type MakeSchemaOptionRequiredIfDefined<TSchemaOption extends CallApiSchema[keyof CallApiSchema], TObject> = undefined extends InferSchemaOutput<TSchemaOption, undefined> ? TObject : Required<TObject>;
407
+ type ApplyURLBasedConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig["prefix"] extends string ? `${TSchemaConfig["prefix"]}${TSchemaRouteKeys}` : TSchemaConfig["baseURL"] extends string ? `${TSchemaConfig["baseURL"]}${TSchemaRouteKeys}` : TSchemaRouteKeys;
408
+ type ApplyStrictConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig["strict"] extends true ? TSchemaRouteKeys :
409
+ // eslint-disable-next-line perfectionist/sort-union-types -- Don't sort union types
410
+ TSchemaRouteKeys | Exclude<InitURLOrURLObject, RouteKeyMethodsURLUnion>;
411
+ type ApplySchemaConfiguration<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = ApplyStrictConfig<TSchemaConfig, ApplyURLBasedConfig<TSchemaConfig, TSchemaRouteKeys>>;
412
+ type InferAllRouteKeys<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = ApplySchemaConfiguration<TSchemaConfig, Exclude<Extract<keyof TBaseSchemaRoutes, string>, FallBackRouteSchemaKey>>;
413
+ type InferInitURL<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = keyof TBaseSchemaRoutes extends never ? InitURLOrURLObject : InferAllRouteKeys<TBaseSchemaRoutes, TSchemaConfig>;
414
+ type GetCurrentRouteSchemaKey<TSchemaConfig extends CallApiSchemaConfig, TPath> = TPath extends URL ? string : TSchemaConfig["baseURL"] extends string ? TPath extends `${TSchemaConfig["baseURL"]}${infer TCurrentRoute}` ? TCurrentRoute extends string ? TCurrentRoute : string : TPath extends `${TSchemaConfig["prefix"]}${infer TCurrentRoute}` ? TCurrentRoute extends string ? TCurrentRoute : string : string : TPath;
415
+ type GetCurrentRouteSchema<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TComputedFallBackRouteSchema = TBaseSchemaRoutes[FallBackRouteSchemaKey], TComputedCurrentRouteSchema = TBaseSchemaRoutes[TCurrentRouteSchemaKey], TComputedRouteSchema extends CallApiSchema = NonNullable<Omit<TComputedFallBackRouteSchema, keyof TComputedCurrentRouteSchema> & TComputedCurrentRouteSchema>> = TComputedRouteSchema extends CallApiSchema ? Writeable<TComputedRouteSchema, "deep"> : CallApiSchema;
416
+ type JsonPrimitive = boolean | number | string | null | undefined;
417
+ type SerializableObject = Record<PropertyKey, unknown>;
418
+ type SerializableArray = Array<JsonPrimitive | SerializableObject> | ReadonlyArray<JsonPrimitive | SerializableObject>;
419
+ type Body = UnmaskType<Exclude<RequestInit["body"], undefined> | SerializableArray | SerializableObject>;
420
+ type InferBodyOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema["body"], {
421
+ /**
422
+ * Body of the request, can be a object or any other supported body type.
423
+ */
424
+ body?: InferSchemaOutput<TSchema["body"], Body>;
425
+ }>;
426
+ type MethodUnion = UnmaskType<"CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE" | AnyString>;
427
+ type InferMethodFromURL<TInitURL> = string extends TInitURL ? MethodUnion : TInitURL extends `@${infer TMethod extends RouteKeyMethods}/${string}` ? Uppercase<TMethod> : MethodUnion;
428
+ type InferMethodOption<TSchema extends CallApiSchema, TInitURL> = MakeSchemaOptionRequiredIfDefined<TSchema["method"], {
429
+ /**
430
+ * HTTP method for the request.
431
+ * @default "GET"
432
+ */
433
+ method?: InferSchemaOutput<TSchema["method"], InferMethodFromURL<TInitURL>>;
434
+ }>;
435
+ type HeadersOption = UnmaskType<Headers | Record<"Authorization", CommonAuthorizationHeaders | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | Array<[string, string]>>;
436
+ type InferHeadersOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema["headers"], {
437
+ /**
438
+ * Headers to be used in the request.
439
+ */
440
+ headers?: InferSchemaOutput<TSchema["headers"], HeadersOption> | ((context: {
441
+ baseHeaders: Extract<HeadersOption, Record<string, unknown>>;
442
+ }) => InferSchemaOutput<TSchema["headers"], HeadersOption>);
443
+ }>;
444
+ type InferRequestOptions<TSchema extends CallApiSchema, TInitURL extends InferInitURL<BaseCallApiSchemaRoutes, CallApiSchemaConfig>> = InferBodyOption<TSchema> & InferHeadersOption<TSchema> & InferMethodOption<TSchema, TInitURL>;
445
+ type InferMetaOption<TSchema extends CallApiSchema, TCallApiContext extends CallApiContext> = MakeSchemaOptionRequiredIfDefined<TSchema["meta"], {
446
+ /**
447
+ * - An optional field you can fill with additional information,
448
+ * to associate with the request, typically used for logging or tracing.
449
+ *
450
+ * - A good use case for this, would be to use the info to handle specific cases in any of the shared interceptors.
451
+ *
452
+ * @example
453
+ * ```ts
454
+ * const callMainApi = callApi.create({
455
+ * baseURL: "https://main-api.com",
456
+ * onResponseError: ({ response, options }) => {
457
+ * if (options.meta?.userId) {
458
+ * console.error(`User ${options.meta.userId} made an error`);
459
+ * }
460
+ * },
461
+ * });
462
+ *
463
+ * const response = await callMainApi({
464
+ * url: "https://example.com/api/data",
465
+ * meta: { userId: "123" },
466
+ * });
467
+ * ```
468
+ */
469
+ meta?: InferSchemaOutput<TSchema["meta"], TCallApiContext["Meta"]>;
470
+ }>;
471
+ type InferQueryOption<TSchema extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema["query"], {
472
+ /**
473
+ * Parameters to be appended to the URL (i.e: /:id)
474
+ */
475
+ query?: InferSchemaOutput<TSchema["query"], Query>;
476
+ }>;
477
+ type EmptyString = "";
478
+ type EmptyTuple = readonly [];
479
+ type StringTuple = readonly string[];
480
+ type PossibleParamNamePatterns = `${string}:${string}` | `${string}{${string}}${"" | AnyString}`;
481
+ type ExtractRouteParamNames<TCurrentRoute, TParamNamesAccumulator extends StringTuple = EmptyTuple> = TCurrentRoute extends PossibleParamNamePatterns ? TCurrentRoute extends `${infer TRoutePrefix}:${infer TParamAndRemainingRoute}` ? TParamAndRemainingRoute extends `${infer TCurrentParam}/${infer TRemainingRoute}` ? TCurrentParam extends EmptyString ? ExtractRouteParamNames<`${TRoutePrefix}/${TRemainingRoute}`, TParamNamesAccumulator> : ExtractRouteParamNames<`${TRoutePrefix}/${TRemainingRoute}`, [...TParamNamesAccumulator, TCurrentParam]> : TParamAndRemainingRoute extends `${infer TCurrentParam}` ? TCurrentParam extends EmptyString ? ExtractRouteParamNames<TRoutePrefix, TParamNamesAccumulator> : ExtractRouteParamNames<TRoutePrefix, [...TParamNamesAccumulator, TCurrentParam]> : ExtractRouteParamNames<TRoutePrefix, TParamNamesAccumulator> : TCurrentRoute extends `${infer TRoutePrefix}{${infer TCurrentParam}}${infer TRemainingRoute}` ? TCurrentParam extends EmptyString ? ExtractRouteParamNames<`${TRoutePrefix}${TRemainingRoute}`, TParamNamesAccumulator> : ExtractRouteParamNames<`${TRoutePrefix}${TRemainingRoute}`, [...TParamNamesAccumulator, TCurrentParam]> : TParamNamesAccumulator : TParamNamesAccumulator;
482
+ type ConvertParamNamesToRecord<TParamNames extends StringTuple> = Prettify<TParamNames extends (readonly [infer TFirstParamName extends string, ...infer TRemainingParamNames extends StringTuple]) ? Record<TFirstParamName, AllowedQueryParamValues> & ConvertParamNamesToRecord<TRemainingParamNames> : NonNullable<unknown>>;
483
+ type ConvertParamNamesToTuple<TParamNames extends StringTuple> = TParamNames extends readonly [string, ...infer TRemainingParamNames extends StringTuple] ? [AllowedQueryParamValues, ...ConvertParamNamesToTuple<TRemainingParamNames>] : [];
484
+ type InferParamsFromRoute<TCurrentRoute> = ExtractRouteParamNames<TCurrentRoute> extends StringTuple ? ExtractRouteParamNames<TCurrentRoute> extends EmptyTuple ? Params : ConvertParamNamesToRecord<ExtractRouteParamNames<TCurrentRoute>> | ConvertParamNamesToTuple<ExtractRouteParamNames<TCurrentRoute>> : Params;
485
+ type MakeParamsOptionRequired<TParamsSchemaOption extends CallApiSchema["params"], TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TObject> = MakeSchemaOptionRequiredIfDefined<TParamsSchemaOption, Params extends InferParamsFromRoute<TCurrentRouteSchemaKey> ? TObject : TCurrentRouteSchemaKey extends Extract<keyof TBaseSchemaRoutes, TCurrentRouteSchemaKey> ? undefined extends InferSchemaOutput<TParamsSchemaOption, null> ? TObject : Required<TObject> : TObject>;
486
+ type InferParamsOption<TSchema extends CallApiSchema, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = MakeParamsOptionRequired<TSchema["params"], TBaseSchemaRoutes, TCurrentRouteSchemaKey, {
487
+ /**
488
+ * Parameters to be appended to the URL (i.e: /:id)
489
+ */
490
+ params?: InferSchemaOutput<TSchema["params"], InferParamsFromRoute<TCurrentRouteSchemaKey>>;
491
+ }>;
492
+ type InferExtraOptions<TSchema extends CallApiSchema, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TCallApiContext extends CallApiContext> = InferMetaOption<TSchema, TCallApiContext> & InferParamsOption<TSchema, TBaseSchemaRoutes, TCurrentRouteSchemaKey> & InferQueryOption<TSchema>;
493
+ type InferPluginExtraOptions<TPluginArray extends CallApiPlugin[]> = UnionToIntersection<TPluginArray extends Array<infer TPlugin> ? TPlugin extends CallApiPlugin ? TPlugin["defineExtraOptions"] extends AnyFunction<infer TReturnedSchema> ? InferSchemaOutput<TReturnedSchema> : never : never : never>;
494
+ type ResultModeOption<TErrorData, TResultMode extends ResultModeType> = TErrorData extends false ? {
495
+ resultMode: "onlyData";
496
+ } : TErrorData extends false | undefined ? {
497
+ resultMode?: "onlyData";
498
+ } : {
499
+ resultMode?: TResultMode;
500
+ };
501
+ type ThrowOnErrorUnion = boolean;
502
+ type ThrowOnErrorType<TErrorData, TThrowOnError extends ThrowOnErrorUnion> = TThrowOnError | ((context: ErrorContext<{
503
+ ErrorData: TErrorData;
504
+ }>) => TThrowOnError);
505
+ type ThrowOnErrorOption<TErrorData, TThrowOnError extends ThrowOnErrorUnion> = TErrorData extends false ? {
506
+ throwOnError: true;
507
+ } : TErrorData extends false | undefined ? {
508
+ throwOnError?: true;
509
+ } : {
510
+ throwOnError?: ThrowOnErrorType<TErrorData, TThrowOnError>;
511
+ };
512
+ //#endregion
513
+ //#region src/middlewares.d.ts
514
+ type FetchImpl = UnmaskType<(input: string | Request | URL, init?: RequestInit) => Promise<Response>>;
515
+ interface Middlewares<TCallApiContext extends NoInfer<CallApiContext> = DefaultCallApiContext> {
516
+ /**
517
+ * Wraps the fetch implementation to intercept requests at the network layer.
518
+ *
519
+ * Takes a context object containing the current fetch function and returns a new fetch function.
520
+ * Use it to cache responses, add logging, handle offline mode, or short-circuit requests etc.
521
+ * Multiple middleware compose in order: plugins → base config → per-request.
522
+ *
523
+ * Unlike `customFetchImpl`, middleware can call through to the original fetch.
524
+ *
525
+ * @example
526
+ * ```ts
527
+ * // Cache responses
528
+ * const cache = new Map();
529
+ *
530
+ * fetchMiddleware: (ctx) => async (input, init) => {
531
+ * const key = input.toString();
532
+ * if (cache.has(key)) return cache.get(key).clone();
533
+ *
534
+ * const response = await ctx.fetchImpl(input, init);
535
+ * cache.set(key, response.clone());
536
+ * return response;
537
+ * }
538
+ *
539
+ * // Handle offline
540
+ * fetchMiddleware: (ctx) => async (input, init) => {
541
+ * if (!navigator.onLine) {
542
+ * return new Response('{"error": "offline"}', { status: 503 });
543
+ * }
544
+ * return ctx.fetchImpl(input, init);
545
+ * }
546
+ * ```
547
+ */
548
+ fetchMiddleware?: (context: RequestContext<TCallApiContext> & {
549
+ fetchImpl: FetchImpl;
550
+ }) => FetchImpl;
551
+ }
552
+ //#endregion
552
553
  //#region src/plugins.d.ts
553
554
  type PluginSetupContext<TCallApiContext extends CallApiContext = DefaultCallApiContext> = RequestContext<TCallApiContext> & {
554
555
  initURL: string;
@@ -1762,24 +1763,17 @@ type CallApiResultErrorVariant<TErrorData> = {
1762
1763
  error: PossibleJavaScriptOrValidationError;
1763
1764
  response: Response | null;
1764
1765
  };
1765
- type CallApiSuccessOrErrorVariant<TData, TError> = CallApiResultErrorVariant<TError> | CallApiResultSuccessVariant<TData>;
1766
- type ResultModeMapWithoutException<TData, TErrorData, TComputedResult extends CallApiSuccessOrErrorVariant<TData, TErrorData> = CallApiSuccessOrErrorVariant<TData, TErrorData>> = UnmaskType<{
1766
+ type CallApiResultSuccessOrErrorVariant<TData, TError> = CallApiResultErrorVariant<TError> | CallApiResultSuccessVariant<TData>;
1767
+ type ResultModeMap<TData = DefaultDataType, TErrorData = DefaultDataType, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TComputedResultWithoutException extends CallApiResultSuccessOrErrorVariant<TData, TErrorData> = CallApiResultSuccessOrErrorVariant<TData, TErrorData>, TComputedResultWithException extends CallApiResultSuccessVariant<TData> = CallApiResultSuccessVariant<TData>, TComputedResult extends (TThrowOnError extends true ? TComputedResultWithException : TComputedResultWithoutException) = (TThrowOnError extends true ? TComputedResultWithException : TComputedResultWithoutException)> = UnmaskType<{
1767
1768
  all: TComputedResult;
1768
1769
  onlyData: TComputedResult["data"];
1769
1770
  onlyResponse: TComputedResult["response"];
1770
- withoutResponse: DistributiveOmit<TComputedResult, "response">;
1771
+ withoutResponse: Prettify<DistributiveOmit<TComputedResult, "response">>;
1771
1772
  }>;
1772
- type ResultModeMapWithException<TData, TComputedResult extends CallApiResultSuccessVariant<TData> = CallApiResultSuccessVariant<TData>> = {
1773
- all: TComputedResult;
1774
- onlyData: TComputedResult["data"];
1775
- onlyResponse: TComputedResult["response"];
1776
- withoutResponse: DistributiveOmit<TComputedResult, "response">;
1777
- };
1778
- type ResultModeMap<TData = DefaultDataType, TErrorData = DefaultDataType, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError> = TThrowOnError extends true ? ResultModeMapWithException<TData> : ResultModeMapWithoutException<TData, TErrorData>;
1779
1773
  type ResultModePlaceholder = null;
1780
1774
  type ResultModeUnion = keyof ResultModeMap;
1781
1775
  type ResultModeType = ResultModePlaceholder | ResultModeUnion;
1782
- type InferCallApiResult<TData, TErrorData, TResultMode extends ResultModeType, TThrowOnError extends ThrowOnErrorUnion, TComputedResultModeMapWithException extends ResultModeMapWithException<TData> = ResultModeMapWithException<TData>, TComputedResultModeMap extends ResultModeMap<TData, TErrorData, TThrowOnError> = ResultModeMap<TData, TErrorData, TThrowOnError>> = TErrorData extends false ? TComputedResultModeMapWithException["onlyData"] : TErrorData extends false | undefined ? TComputedResultModeMapWithException["onlyData"] : ResultModePlaceholder extends TResultMode ? TComputedResultModeMap["all"] : TResultMode extends ResultModeUnion ? TComputedResultModeMap[TResultMode] : never;
1776
+ type InferCallApiResult<TData, TErrorData, TResultMode extends ResultModeType, TThrowOnError extends ThrowOnErrorUnion, TComputedResultModeMapWithException extends ResultModeMap<TData, TErrorData, true> = ResultModeMap<TData, TErrorData, true>, TComputedResultModeMapWithoutException extends ResultModeMap<TData, TErrorData, TThrowOnError> = ResultModeMap<TData, TErrorData, TThrowOnError>> = TErrorData extends false ? TComputedResultModeMapWithException["onlyData"] : TErrorData extends false | undefined ? TComputedResultModeMapWithException["onlyData"] : ResultModePlaceholder extends TResultMode ? TComputedResultModeMapWithoutException["all"] : TResultMode extends ResultModeUnion ? TComputedResultModeMapWithoutException[TResultMode] : never;
1783
1777
  //#endregion
1784
1778
  //#region src/createFetchClient.d.ts
1785
1779
  declare const createFetchClientWithContext: <TOuterCallApiContext extends CallApiContext = DefaultCallApiContext>() => <TBaseCallApiContext extends CallApiContext = TOuterCallApiContext, TBaseData = TBaseCallApiContext["Data"], TBaseErrorData = TBaseCallApiContext["ErrorData"], TBaseResultMode extends ResultModeType = (TBaseCallApiContext["ResultMode"] extends ResultModeType ? TBaseCallApiContext["ResultMode"] : ResultModeType), TBaseThrowOnError extends ThrowOnErrorUnion = boolean, TBaseResponseType extends ResponseTypeType = ResponseTypeType, const TBaseSchemaAndConfig extends BaseCallApiSchemaAndConfig = BaseCallApiSchemaAndConfig, const TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TComputedBaseSchemaConfig extends CallApiSchemaConfig = GetBaseSchemaConfig<TBaseSchemaAndConfig>, TComputedBaseSchemaRoutes extends BaseCallApiSchemaRoutes = GetBaseSchemaRoutes<TBaseSchemaAndConfig>>(initBaseConfig?: BaseCallApiConfig<TBaseCallApiContext, TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBaseSchemaAndConfig, TBasePluginArray>) => <TData = TBaseData, TErrorData = TBaseErrorData, TResultMode extends ResultModeType = TBaseResultMode, TCallApiContext extends CallApiContext = TBaseCallApiContext, TThrowOnError extends ThrowOnErrorUnion = TBaseThrowOnError, TResponseType extends ResponseTypeType = TBaseResponseType, const TSchemaConfig extends CallApiSchemaConfig = TComputedBaseSchemaConfig, TInitURL extends InferInitURL<TComputedBaseSchemaRoutes, TSchemaConfig> = InferInitURL<TComputedBaseSchemaRoutes, TSchemaConfig>, TCurrentRouteSchemaKey extends GetCurrentRouteSchemaKey<TSchemaConfig, TInitURL> = GetCurrentRouteSchemaKey<TSchemaConfig, TInitURL>, const TSchema extends CallApiSchema = GetCurrentRouteSchema<TComputedBaseSchemaRoutes, TCurrentRouteSchemaKey>, const TPluginArray extends CallApiPlugin[] = TBasePluginArray, TComputedData = InferSchemaOutput<TSchema["data"], GetResponseType<TData, TResponseType>>, TComputedErrorData = InferSchemaOutput<TSchema["errorData"], GetResponseType<TErrorData, TResponseType>>, TComputedResult = CallApiResult<TComputedData, TComputedErrorData, TResultMode, TThrowOnError>>(initURL: TInitURL, initConfig?: CallApiConfig<TCallApiContext, TComputedData, TComputedErrorData, TResultMode, TThrowOnError, TResponseType, TComputedBaseSchemaRoutes, TSchema, TComputedBaseSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, TBasePluginArray, TPluginArray>) => Promise<TComputedResult>;
@@ -1787,8 +1781,16 @@ declare const createFetchClient: <TBaseCallApiContext extends CallApiContext = D
1787
1781
  all: CallApiResultSuccessVariant<TComputedData>;
1788
1782
  onlyData: NoInferUnMasked<TComputedData>;
1789
1783
  onlyResponse: Response;
1790
- withoutResponse: Omit<CallApiResultSuccessVariant<TComputedData>, "response">;
1791
- }, ResultModeMap<TComputedData, TComputedErrorData, TThrowOnError>>>(initURL: TInitURL, initConfig?: CallApiConfig<TCallApiContext, TComputedData, TComputedErrorData, TResultMode, TThrowOnError, TResponseType, TComputedBaseSchemaRoutes, TSchema, TComputedBaseSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, TBasePluginArray, TPluginArray>) => Promise<TComputedResult>;
1784
+ withoutResponse: {
1785
+ error: null;
1786
+ data: NoInferUnMasked<TComputedData>;
1787
+ };
1788
+ }, {
1789
+ all: TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>;
1790
+ onlyData: (TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>)["data"];
1791
+ onlyResponse: (TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>)["response"];
1792
+ withoutResponse: DistributiveOmit<TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>, "response"> extends infer T ? { [Key in keyof T]: T[Key] } : never;
1793
+ }>>(initURL: TInitURL, initConfig?: CallApiConfig<TCallApiContext, TComputedData, TComputedErrorData, TResultMode, TThrowOnError, TResponseType, TComputedBaseSchemaRoutes, TSchema, TComputedBaseSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, TBasePluginArray, TPluginArray>) => Promise<TComputedResult>;
1792
1794
  declare const callApi: <TData = unknown, TErrorData = unknown, TResultMode extends ResultModeType = ResultModeType, TCallApiContext extends CallApiContext = DefaultCallApiContext, TThrowOnError extends ThrowOnErrorUnion = boolean, TResponseType extends ResponseTypeType = ResponseTypeType, const TSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TInitURL extends ApplyStrictConfig<TSchemaConfig, ApplyURLBasedConfig<TSchemaConfig, AnyString | "@delete/" | "@get/" | "@patch/" | "@post/" | "@put/">> = ApplyStrictConfig<TSchemaConfig, ApplyURLBasedConfig<TSchemaConfig, AnyString | "@delete/" | "@get/" | "@patch/" | "@post/" | "@put/">>, TCurrentRouteSchemaKey extends GetCurrentRouteSchemaKey<TSchemaConfig, TInitURL> = GetCurrentRouteSchemaKey<TSchemaConfig, TInitURL>, const TSchema extends CallApiSchema = GetCurrentRouteSchema<{
1793
1795
  [x: AnyString]: CallApiSchema | undefined;
1794
1796
  "@default"?: CallApiSchema | undefined;
@@ -1825,8 +1827,16 @@ declare const callApi: <TData = unknown, TErrorData = unknown, TResultMode exten
1825
1827
  all: CallApiResultSuccessVariant<TComputedData>;
1826
1828
  onlyData: NoInferUnMasked<TComputedData>;
1827
1829
  onlyResponse: Response;
1828
- withoutResponse: Omit<CallApiResultSuccessVariant<TComputedData>, "response">;
1829
- }, ResultModeMap<TComputedData, TComputedErrorData, TThrowOnError>>>(initURL: TInitURL, initConfig?: CallApiConfig<TCallApiContext, TComputedData, TComputedErrorData, TResultMode, TThrowOnError, TResponseType, {
1830
+ withoutResponse: {
1831
+ error: null;
1832
+ data: NoInferUnMasked<TComputedData>;
1833
+ };
1834
+ }, {
1835
+ all: TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>;
1836
+ onlyData: (TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>)["data"];
1837
+ onlyResponse: (TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>)["response"];
1838
+ withoutResponse: DistributiveOmit<TThrowOnError extends true ? CallApiResultSuccessVariant<TComputedData> : CallApiResultSuccessOrErrorVariant<TComputedData, TComputedErrorData>, "response"> extends infer T ? { [Key in keyof T]: T[Key] } : never;
1839
+ }>>(initURL: TInitURL, initConfig?: CallApiConfig<TCallApiContext, TComputedData, TComputedErrorData, TResultMode, TThrowOnError, TResponseType, {
1830
1840
  [x: AnyString]: CallApiSchema | undefined;
1831
1841
  "@default"?: CallApiSchema | undefined;
1832
1842
  "@delete/"?: CallApiSchema | undefined;
@@ -1836,5 +1846,5 @@ declare const callApi: <TData = unknown, TErrorData = unknown, TResultMode exten
1836
1846
  "@put/"?: CallApiSchema | undefined;
1837
1847
  }, TSchema, CallApiSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, DefaultPluginArray, TPluginArray>) => Promise<TComputedResult>;
1838
1848
  //#endregion
1839
- export { Writeable as $, ErrorContext as A, CallApiPlugin as B, InferExtendSchemaContext as C, ValidationError as D, HTTPError as E, ResponseContext as F, BaseSchemaRouteKeyPrefixes as G, PluginSetupContext as H, ResponseErrorContext as I, InferSchemaInput as J, CallApiSchema as K, ResponseStreamContext as L, HooksOrHooksArray as M, RequestContext as N, RetryOptions as O, RequestStreamContext as P, Satisfies as Q, SuccessContext as R, GetExtendSchemaConfigContext as S, Register as T, URLOptions as U, PluginHooks as V, BaseCallApiSchemaRoutes as W, InferParamsFromRoute as X, InferSchemaOutput as Y, AnyFunction as Z, CallApiExtraOptionsForHooks as _, CallApiResultSuccessVariant as a, CallApiRequestOptionsForHooks as b, PossibleJavaScriptError as c, ResponseTypeType as d, ResultModeType as f, CallApiExtraOptions as g, CallApiConfig as h, CallApiResultErrorVariant as i, Hooks as j, DedupeOptions as k, PossibleJavaScriptOrValidationError as l, BaseCallApiExtraOptions as m, createFetchClient as n, CallApiSuccessOrErrorVariant as o, BaseCallApiConfig as p, CallApiSchemaConfig as q, createFetchClientWithContext as r, PossibleHTTPError as s, callApi as t, PossibleValidationError as u, CallApiParameters as v, InstanceContext as w, CallApiResultLoose as x, CallApiRequestOptions as y, DefaultCallApiContext as z };
1840
- //# sourceMappingURL=index-DvEQIgL-.d.ts.map
1849
+ export { Writeable as $, ErrorContext as A, CallApiPlugin as B, InferExtendSchemaContext as C, ValidationError as D, HTTPError as E, ResponseContext as F, BaseCallApiSchemaRoutes as G, PluginSetupContext as H, ResponseErrorContext as I, CallApiSchemaConfig as J, BaseSchemaRouteKeyPrefixes as K, ResponseStreamContext as L, HooksOrHooksArray as M, RequestContext as N, RetryOptions as O, RequestStreamContext as P, Satisfies as Q, SuccessContext as R, GetExtendSchemaConfigContext as S, Register as T, InferParamsFromRoute as U, PluginHooks as V, URLOptions as W, InferSchemaOutput as X, InferSchemaInput as Y, AnyFunction as Z, CallApiExtraOptionsForHooks as _, CallApiResultSuccessOrErrorVariant as a, CallApiRequestOptionsForHooks as b, PossibleJavaScriptError as c, ResponseTypeType as d, ResultModeType as f, CallApiExtraOptions as g, CallApiConfig as h, CallApiResultErrorVariant as i, Hooks as j, DedupeOptions as k, PossibleJavaScriptOrValidationError as l, BaseCallApiExtraOptions as m, createFetchClient as n, CallApiResultSuccessVariant as o, BaseCallApiConfig as p, CallApiSchema as q, createFetchClientWithContext as r, PossibleHTTPError as s, callApi as t, PossibleValidationError as u, CallApiParameters as v, InstanceContext as w, CallApiResultLoose as x, CallApiRequestOptions as y, DefaultCallApiContext as z };
1850
+ //# sourceMappingURL=index-BDKB03qO.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- import "./validation-Do6HBp6Z.js";
2
- import { A as ErrorContext, B as CallApiPlugin, C as InferExtendSchemaContext, F as ResponseContext, G as BaseSchemaRouteKeyPrefixes, H as PluginSetupContext, I as ResponseErrorContext, J as InferSchemaInput, K as CallApiSchema, L as ResponseStreamContext, M as HooksOrHooksArray, N as RequestContext, O as RetryOptions, P as RequestStreamContext, R as SuccessContext, S as GetExtendSchemaConfigContext, T as Register, U as URLOptions, V as PluginHooks, W as BaseCallApiSchemaRoutes, X as InferParamsFromRoute, Y as InferSchemaOutput, _ as CallApiExtraOptionsForHooks, a as CallApiResultSuccessVariant, b as CallApiRequestOptionsForHooks, c as PossibleJavaScriptError, d as ResponseTypeType, f as ResultModeType, g as CallApiExtraOptions, h as CallApiConfig, i as CallApiResultErrorVariant, j as Hooks, k as DedupeOptions, l as PossibleJavaScriptOrValidationError, m as BaseCallApiExtraOptions, n as createFetchClient, o as CallApiSuccessOrErrorVariant, p as BaseCallApiConfig, q as CallApiSchemaConfig, r as createFetchClientWithContext, s as PossibleHTTPError, t as callApi, u as PossibleValidationError, v as CallApiParameters, w as InstanceContext, x as CallApiResultLoose, y as CallApiRequestOptions, z as DefaultCallApiContext } from "./index-DvEQIgL-.js";
3
- export { BaseCallApiConfig, BaseCallApiExtraOptions, BaseCallApiSchemaRoutes, BaseSchemaRouteKeyPrefixes, CallApiConfig, CallApiExtraOptions, CallApiExtraOptionsForHooks, CallApiParameters, CallApiPlugin, CallApiRequestOptions, CallApiRequestOptionsForHooks, CallApiResultLoose as CallApiResult, CallApiResultErrorVariant, CallApiResultSuccessVariant, CallApiSchema, CallApiSchemaConfig, CallApiSuccessOrErrorVariant, DedupeOptions, DefaultCallApiContext, ErrorContext, GetExtendSchemaConfigContext, Hooks, HooksOrHooksArray, InferExtendSchemaContext, InferParamsFromRoute, InferSchemaInput, InferSchemaOutput, InstanceContext, PluginHooks, PluginSetupContext, PossibleHTTPError, PossibleJavaScriptError, PossibleJavaScriptOrValidationError, PossibleValidationError, Register, RequestContext, RequestStreamContext, ResponseContext, ResponseErrorContext, ResponseStreamContext, ResponseTypeType, ResultModeType, RetryOptions, SuccessContext, URLOptions, callApi, createFetchClient, createFetchClientWithContext };
1
+ import { A as ErrorContext, B as CallApiPlugin, C as InferExtendSchemaContext, F as ResponseContext, G as BaseCallApiSchemaRoutes, H as PluginSetupContext, I as ResponseErrorContext, J as CallApiSchemaConfig, K as BaseSchemaRouteKeyPrefixes, L as ResponseStreamContext, M as HooksOrHooksArray, N as RequestContext, O as RetryOptions, P as RequestStreamContext, R as SuccessContext, S as GetExtendSchemaConfigContext, T as Register, U as InferParamsFromRoute, V as PluginHooks, W as URLOptions, X as InferSchemaOutput, Y as InferSchemaInput, _ as CallApiExtraOptionsForHooks, a as CallApiResultSuccessOrErrorVariant, b as CallApiRequestOptionsForHooks, c as PossibleJavaScriptError, d as ResponseTypeType, f as ResultModeType, g as CallApiExtraOptions, h as CallApiConfig, i as CallApiResultErrorVariant, j as Hooks, k as DedupeOptions, l as PossibleJavaScriptOrValidationError, m as BaseCallApiExtraOptions, n as createFetchClient, o as CallApiResultSuccessVariant, p as BaseCallApiConfig, q as CallApiSchema, r as createFetchClientWithContext, s as PossibleHTTPError, t as callApi, u as PossibleValidationError, v as CallApiParameters, w as InstanceContext, x as CallApiResultLoose, y as CallApiRequestOptions, z as DefaultCallApiContext } from "./index-BDKB03qO.js";
2
+ export { BaseCallApiConfig, BaseCallApiExtraOptions, BaseCallApiSchemaRoutes, BaseSchemaRouteKeyPrefixes, CallApiConfig, CallApiExtraOptions, CallApiExtraOptionsForHooks, CallApiParameters, CallApiPlugin, CallApiRequestOptions, CallApiRequestOptionsForHooks, CallApiResultLoose as CallApiResult, CallApiResultErrorVariant, CallApiResultSuccessOrErrorVariant, CallApiResultSuccessVariant, CallApiSchema, CallApiSchemaConfig, DedupeOptions, DefaultCallApiContext, ErrorContext, GetExtendSchemaConfigContext, Hooks, HooksOrHooksArray, InferExtendSchemaContext, InferParamsFromRoute, InferSchemaInput, InferSchemaOutput, InstanceContext, PluginHooks, PluginSetupContext, PossibleHTTPError, PossibleJavaScriptError, PossibleJavaScriptOrValidationError, PossibleValidationError, Register, RequestContext, RequestStreamContext, ResponseContext, ResponseErrorContext, ResponseStreamContext, ResponseTypeType, ResultModeType, RetryOptions, SuccessContext, URLOptions, callApi, createFetchClient, createFetchClientWithContext };