@zayne-labs/callapi 1.7.18 → 1.8.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/esm/common-nPLfv6fl.d.ts +910 -0
- package/dist/esm/index.d.ts +10 -7
- package/dist/esm/index.js +699 -690
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/index.d.ts +12 -6
- package/dist/esm/utils/index.js +3 -3
- package/dist/esm/utils-C_6UX70F.js +393 -0
- package/dist/esm/utils-C_6UX70F.js.map +1 -0
- package/package.json +10 -9
- package/dist/esm/chunk-F56CKRKR.js +0 -278
- package/dist/esm/chunk-F56CKRKR.js.map +0 -1
- package/dist/esm/common-C3q7szew.d.ts +0 -774
- package/dist/esm/utils/index.js.map +0 -1
@@ -0,0 +1,393 @@
|
|
1
|
+
//#region src/types/type-helpers.ts
|
2
|
+
const defineEnum = (value) => value;
|
3
|
+
|
4
|
+
//#endregion
|
5
|
+
//#region src/constants/default-options.ts
|
6
|
+
const retryDefaults = defineEnum({
|
7
|
+
attempts: 0,
|
8
|
+
condition: () => true,
|
9
|
+
delay: 1e3,
|
10
|
+
maxDelay: 1e4,
|
11
|
+
methods: ["GET", "POST"],
|
12
|
+
statusCodes: [],
|
13
|
+
strategy: "linear"
|
14
|
+
});
|
15
|
+
const defaultRetryStatusCodesLookup = defineEnum({
|
16
|
+
408: "Request Timeout",
|
17
|
+
409: "Conflict",
|
18
|
+
425: "Too Early",
|
19
|
+
429: "Too Many Requests",
|
20
|
+
500: "Internal Server Error",
|
21
|
+
502: "Bad Gateway",
|
22
|
+
503: "Service Unavailable",
|
23
|
+
504: "Gateway Timeout"
|
24
|
+
});
|
25
|
+
const commonDefaults = defineEnum({
|
26
|
+
bodySerializer: JSON.stringify,
|
27
|
+
defaultErrorMessage: "An unexpected error occurred during the HTTP request."
|
28
|
+
});
|
29
|
+
const responseDefaults = defineEnum({
|
30
|
+
responseParser: JSON.parse,
|
31
|
+
responseType: "json",
|
32
|
+
resultMode: "all"
|
33
|
+
});
|
34
|
+
const hookDefaults = defineEnum({
|
35
|
+
mergedHooksExecutionMode: "parallel",
|
36
|
+
mergedHooksExecutionOrder: "mainHooksAfterPlugins"
|
37
|
+
});
|
38
|
+
const dedupeDefaults = defineEnum({ dedupeStrategy: "cancel" });
|
39
|
+
const requestOptionDefaults = defineEnum({ method: "GET" });
|
40
|
+
|
41
|
+
//#endregion
|
42
|
+
//#region src/error.ts
|
43
|
+
const httpErrorSymbol = Symbol("HTTPError");
|
44
|
+
var HTTPError = class HTTPError extends Error {
|
45
|
+
errorData;
|
46
|
+
httpErrorSymbol = httpErrorSymbol;
|
47
|
+
isHTTPError = true;
|
48
|
+
name = "HTTPError";
|
49
|
+
response;
|
50
|
+
constructor(errorDetails, errorOptions) {
|
51
|
+
const { defaultErrorMessage, errorData, response } = errorDetails;
|
52
|
+
const selectedDefaultErrorMessage = defaultErrorMessage ?? (response.statusText || commonDefaults.defaultErrorMessage);
|
53
|
+
const message = errorData?.message ?? selectedDefaultErrorMessage;
|
54
|
+
super(message, errorOptions);
|
55
|
+
this.errorData = errorData;
|
56
|
+
this.response = response;
|
57
|
+
Error.captureStackTrace(this, this.constructor);
|
58
|
+
}
|
59
|
+
/**
|
60
|
+
* @description Checks if the given error is an instance of HTTPError
|
61
|
+
* @param error - The error to check
|
62
|
+
* @returns true if the error is an instance of HTTPError, false otherwise
|
63
|
+
*/
|
64
|
+
static isError(error) {
|
65
|
+
if (!isObject(error)) return false;
|
66
|
+
if (error instanceof HTTPError) return true;
|
67
|
+
return error.httpErrorSymbol === httpErrorSymbol && error.isHTTPError === true;
|
68
|
+
}
|
69
|
+
};
|
70
|
+
|
71
|
+
//#endregion
|
72
|
+
//#region src/validation.ts
|
73
|
+
const validationErrorSymbol = Symbol("validationErrorSymbol");
|
74
|
+
const formatPath = (path) => {
|
75
|
+
if (!path?.length) return "";
|
76
|
+
return ` → at ${path.map((segment) => typeof segment === "object" && "key" in segment ? segment.key : String(segment)).join(".")}`;
|
77
|
+
};
|
78
|
+
const formatValidationIssues = (issues) => {
|
79
|
+
return issues.map((issue) => `✖ ${issue.message}${formatPath(issue.path)}`).join(" | ");
|
80
|
+
};
|
81
|
+
var ValidationError = class ValidationError extends Error {
|
82
|
+
issues;
|
83
|
+
name = "ValidationError";
|
84
|
+
response;
|
85
|
+
validationErrorSymbol = validationErrorSymbol;
|
86
|
+
constructor(details, errorOptions) {
|
87
|
+
const { issues, response } = details;
|
88
|
+
const message = formatValidationIssues(issues);
|
89
|
+
super(message, errorOptions);
|
90
|
+
this.issues = issues;
|
91
|
+
this.response = response;
|
92
|
+
Error.captureStackTrace(this, this.constructor);
|
93
|
+
}
|
94
|
+
/**
|
95
|
+
* @description Checks if the given error is an instance of HTTPError
|
96
|
+
* @param error - The error to check
|
97
|
+
* @returns true if the error is an instance of HTTPError, false otherwise
|
98
|
+
*/
|
99
|
+
static isError(error) {
|
100
|
+
if (!isObject(error)) return false;
|
101
|
+
if (error instanceof ValidationError) return true;
|
102
|
+
return error.validationErrorSymbol === validationErrorSymbol && error.name === "ValidationError";
|
103
|
+
}
|
104
|
+
};
|
105
|
+
const handleValidatorFunction = async (validator, inputData) => {
|
106
|
+
try {
|
107
|
+
const result = await validator(inputData);
|
108
|
+
return {
|
109
|
+
issues: void 0,
|
110
|
+
value: result
|
111
|
+
};
|
112
|
+
} catch (error) {
|
113
|
+
return {
|
114
|
+
issues: error,
|
115
|
+
value: void 0
|
116
|
+
};
|
117
|
+
}
|
118
|
+
};
|
119
|
+
const standardSchemaParser = async (schema, inputData, response) => {
|
120
|
+
const result = isFunction(schema) ? await handleValidatorFunction(schema, inputData) : await schema["~standard"].validate(inputData);
|
121
|
+
if (result.issues) throw new ValidationError({
|
122
|
+
issues: result.issues,
|
123
|
+
response: response ?? null
|
124
|
+
}, { cause: result.issues });
|
125
|
+
return result.value;
|
126
|
+
};
|
127
|
+
const routeKeyMethods = defineEnum([
|
128
|
+
"delete",
|
129
|
+
"get",
|
130
|
+
"patch",
|
131
|
+
"post",
|
132
|
+
"put"
|
133
|
+
]);
|
134
|
+
const defineSchema = (baseSchema) => {
|
135
|
+
return baseSchema;
|
136
|
+
};
|
137
|
+
const handleValidation = async (schema, validationOptions) => {
|
138
|
+
const { inputValue, response, schemaConfig } = validationOptions;
|
139
|
+
if (!schema || schemaConfig?.disableRuntimeValidation) return inputValue;
|
140
|
+
const validResult = await standardSchemaParser(schema, inputValue, response);
|
141
|
+
return validResult;
|
142
|
+
};
|
143
|
+
const extraOptionsToBeValidated = [
|
144
|
+
"meta",
|
145
|
+
"params",
|
146
|
+
"query"
|
147
|
+
];
|
148
|
+
const handleExtraOptionsValidation = async (validationOptions) => {
|
149
|
+
const { extraOptions, schema, schemaConfig } = validationOptions;
|
150
|
+
const validationResultArray = await Promise.all(extraOptionsToBeValidated.map((propertyKey) => handleValidation(schema?.[propertyKey], {
|
151
|
+
inputValue: extraOptions[propertyKey],
|
152
|
+
schemaConfig
|
153
|
+
})));
|
154
|
+
const validatedResultObject = {};
|
155
|
+
for (const [index, propertyKey] of extraOptionsToBeValidated.entries()) {
|
156
|
+
const validationResult = validationResultArray[index];
|
157
|
+
if (validationResult === void 0) continue;
|
158
|
+
validatedResultObject[propertyKey] = validationResult;
|
159
|
+
}
|
160
|
+
return validatedResultObject;
|
161
|
+
};
|
162
|
+
const requestOptionsToBeValidated = [
|
163
|
+
"body",
|
164
|
+
"headers",
|
165
|
+
"method"
|
166
|
+
];
|
167
|
+
const handleRequestOptionsValidation = async (validationOptions) => {
|
168
|
+
const { requestOptions, schema, schemaConfig } = validationOptions;
|
169
|
+
const validationResultArray = await Promise.all(requestOptionsToBeValidated.map((propertyKey) => handleValidation(schema?.[propertyKey], {
|
170
|
+
inputValue: requestOptions[propertyKey],
|
171
|
+
schemaConfig
|
172
|
+
})));
|
173
|
+
const validatedResultObject = {};
|
174
|
+
for (const [index, propertyKey] of requestOptionsToBeValidated.entries()) {
|
175
|
+
const validationResult = validationResultArray[index];
|
176
|
+
if (validationResult === void 0) continue;
|
177
|
+
validatedResultObject[propertyKey] = validationResult;
|
178
|
+
}
|
179
|
+
return validatedResultObject;
|
180
|
+
};
|
181
|
+
const handleOptionsValidation = async (validationOptions) => {
|
182
|
+
const { extraOptions, requestOptions, schema, schemaConfig } = validationOptions;
|
183
|
+
if (schemaConfig?.disableRuntimeValidation) return {
|
184
|
+
extraOptionsValidationResult: null,
|
185
|
+
requestOptionsValidationResult: null
|
186
|
+
};
|
187
|
+
const [extraOptionsValidationResult, requestOptionsValidationResult] = await Promise.all([handleExtraOptionsValidation({
|
188
|
+
extraOptions,
|
189
|
+
schema,
|
190
|
+
schemaConfig
|
191
|
+
}), handleRequestOptionsValidation({
|
192
|
+
requestOptions,
|
193
|
+
schema,
|
194
|
+
schemaConfig
|
195
|
+
})]);
|
196
|
+
return {
|
197
|
+
extraOptionsValidationResult,
|
198
|
+
requestOptionsValidationResult
|
199
|
+
};
|
200
|
+
};
|
201
|
+
|
202
|
+
//#endregion
|
203
|
+
//#region src/utils/guards.ts
|
204
|
+
const isHTTPError = (error) => {
|
205
|
+
return isObject(error) && error.name === "HTTPError";
|
206
|
+
};
|
207
|
+
const isHTTPErrorInstance = (error) => {
|
208
|
+
return HTTPError.isError(error);
|
209
|
+
};
|
210
|
+
const isValidationError = (error) => {
|
211
|
+
return isObject(error) && error.name === "ValidationError";
|
212
|
+
};
|
213
|
+
const isValidationErrorInstance = (error) => {
|
214
|
+
return ValidationError.isError(error);
|
215
|
+
};
|
216
|
+
const isArray = (value) => Array.isArray(value);
|
217
|
+
const isObject = (value) => {
|
218
|
+
return typeof value === "object" && value !== null;
|
219
|
+
};
|
220
|
+
const hasObjectPrototype = (value) => {
|
221
|
+
return Object.prototype.toString.call(value) === "[object Object]";
|
222
|
+
};
|
223
|
+
/**
|
224
|
+
* @description Copied from TanStack Query's isPlainObject
|
225
|
+
* @see https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L321
|
226
|
+
*/
|
227
|
+
const isPlainObject = (value) => {
|
228
|
+
if (!hasObjectPrototype(value)) return false;
|
229
|
+
const constructor = value?.constructor;
|
230
|
+
if (constructor === void 0) return true;
|
231
|
+
const prototype = constructor.prototype;
|
232
|
+
if (!hasObjectPrototype(prototype)) return false;
|
233
|
+
if (!Object.hasOwn(prototype, "isPrototypeOf")) return false;
|
234
|
+
if (Object.getPrototypeOf(value) !== Object.prototype) return false;
|
235
|
+
return true;
|
236
|
+
};
|
237
|
+
const isJsonString = (value) => {
|
238
|
+
if (!isString(value)) return false;
|
239
|
+
try {
|
240
|
+
JSON.parse(value);
|
241
|
+
return true;
|
242
|
+
} catch {
|
243
|
+
return false;
|
244
|
+
}
|
245
|
+
};
|
246
|
+
const isSerializable = (value) => {
|
247
|
+
return isPlainObject(value) || isArray(value) || typeof value?.toJSON === "function";
|
248
|
+
};
|
249
|
+
const isFunction = (value) => typeof value === "function";
|
250
|
+
const isQueryString = (value) => isString(value) && value.includes("=");
|
251
|
+
const isString = (value) => typeof value === "string";
|
252
|
+
const isReadableStream = (value) => {
|
253
|
+
return value instanceof ReadableStream;
|
254
|
+
};
|
255
|
+
|
256
|
+
//#endregion
|
257
|
+
//#region src/auth.ts
|
258
|
+
const getValue = (value) => {
|
259
|
+
return isFunction(value) ? value() : value;
|
260
|
+
};
|
261
|
+
const getAuthHeader = async (auth) => {
|
262
|
+
if (auth === void 0) return;
|
263
|
+
if (isString(auth) || auth === null) return { Authorization: `Bearer ${auth}` };
|
264
|
+
switch (auth.type) {
|
265
|
+
case "Basic": {
|
266
|
+
const username = await getValue(auth.username);
|
267
|
+
const password = await getValue(auth.password);
|
268
|
+
if (username === void 0 || password === void 0) return;
|
269
|
+
return { Authorization: `Basic ${globalThis.btoa(`${username}:${password}`)}` };
|
270
|
+
}
|
271
|
+
case "Custom": {
|
272
|
+
const value = await getValue(auth.value);
|
273
|
+
if (value === void 0) return;
|
274
|
+
const prefix = await getValue(auth.prefix);
|
275
|
+
return { Authorization: `${prefix} ${value}` };
|
276
|
+
}
|
277
|
+
default: {
|
278
|
+
const bearer = await getValue(auth.bearer);
|
279
|
+
const token = await getValue(auth.token);
|
280
|
+
if ("token" in auth && token !== void 0) return { Authorization: `Token ${token}` };
|
281
|
+
return bearer !== void 0 && { Authorization: `Bearer ${bearer}` };
|
282
|
+
}
|
283
|
+
}
|
284
|
+
};
|
285
|
+
|
286
|
+
//#endregion
|
287
|
+
//#region src/constants/common.ts
|
288
|
+
const fetchSpecificKeys = defineEnum([
|
289
|
+
"body",
|
290
|
+
"integrity",
|
291
|
+
"duplex",
|
292
|
+
"method",
|
293
|
+
"headers",
|
294
|
+
"signal",
|
295
|
+
"cache",
|
296
|
+
"redirect",
|
297
|
+
"window",
|
298
|
+
"credentials",
|
299
|
+
"keepalive",
|
300
|
+
"referrer",
|
301
|
+
"priority",
|
302
|
+
"mode",
|
303
|
+
"referrerPolicy"
|
304
|
+
]);
|
305
|
+
|
306
|
+
//#endregion
|
307
|
+
//#region src/utils/common.ts
|
308
|
+
const omitKeys = (initialObject, keysToOmit) => {
|
309
|
+
const updatedObject = {};
|
310
|
+
const keysToOmitSet = new Set(keysToOmit);
|
311
|
+
for (const [key, value] of Object.entries(initialObject)) if (!keysToOmitSet.has(key)) updatedObject[key] = value;
|
312
|
+
return updatedObject;
|
313
|
+
};
|
314
|
+
const pickKeys = (initialObject, keysToPick) => {
|
315
|
+
const updatedObject = {};
|
316
|
+
const keysToPickSet = new Set(keysToPick);
|
317
|
+
for (const [key, value] of Object.entries(initialObject)) if (keysToPickSet.has(key)) updatedObject[key] = value;
|
318
|
+
return updatedObject;
|
319
|
+
};
|
320
|
+
const splitBaseConfig = (baseConfig) => [pickKeys(baseConfig, fetchSpecificKeys), omitKeys(baseConfig, fetchSpecificKeys)];
|
321
|
+
const splitConfig = (config) => [pickKeys(config, fetchSpecificKeys), omitKeys(config, fetchSpecificKeys)];
|
322
|
+
const toQueryString = (params) => {
|
323
|
+
if (!params) {
|
324
|
+
console.error("toQueryString:", "No query params provided!");
|
325
|
+
return null;
|
326
|
+
}
|
327
|
+
return new URLSearchParams(params).toString();
|
328
|
+
};
|
329
|
+
const objectifyHeaders = (headers) => {
|
330
|
+
if (!headers || isPlainObject(headers)) return headers;
|
331
|
+
return Object.fromEntries(headers);
|
332
|
+
};
|
333
|
+
const getHeaders = async (options) => {
|
334
|
+
const { auth, baseHeaders, body, headers } = options;
|
335
|
+
const resolvedHeaders = isFunction(headers) ? headers({ baseHeaders: baseHeaders ?? {} }) : headers ?? baseHeaders;
|
336
|
+
const shouldResolveHeaders = Boolean(resolvedHeaders) || Boolean(body) || Boolean(auth);
|
337
|
+
if (!shouldResolveHeaders) return;
|
338
|
+
const headersObject = {
|
339
|
+
...await getAuthHeader(auth),
|
340
|
+
...objectifyHeaders(resolvedHeaders)
|
341
|
+
};
|
342
|
+
if (isQueryString(body)) {
|
343
|
+
headersObject["Content-Type"] = "application/x-www-form-urlencoded";
|
344
|
+
return headersObject;
|
345
|
+
}
|
346
|
+
if (isSerializable(body) || isJsonString(body)) {
|
347
|
+
headersObject["Content-Type"] = "application/json";
|
348
|
+
headersObject.Accept = "application/json";
|
349
|
+
}
|
350
|
+
return headersObject;
|
351
|
+
};
|
352
|
+
const getBody = (options) => {
|
353
|
+
const { body, bodySerializer } = options;
|
354
|
+
if (isSerializable(body)) {
|
355
|
+
const selectedBodySerializer = bodySerializer ?? commonDefaults.bodySerializer;
|
356
|
+
return selectedBodySerializer(body);
|
357
|
+
}
|
358
|
+
return body;
|
359
|
+
};
|
360
|
+
const getFetchImpl = (customFetchImpl) => {
|
361
|
+
if (customFetchImpl) return customFetchImpl;
|
362
|
+
if (typeof globalThis !== "undefined" && isFunction(globalThis.fetch)) return globalThis.fetch;
|
363
|
+
throw new Error("No fetch implementation found");
|
364
|
+
};
|
365
|
+
const PromiseWithResolvers = () => {
|
366
|
+
let reject;
|
367
|
+
let resolve;
|
368
|
+
const promise = new Promise((res, rej) => {
|
369
|
+
resolve = res;
|
370
|
+
reject = rej;
|
371
|
+
});
|
372
|
+
return {
|
373
|
+
promise,
|
374
|
+
reject,
|
375
|
+
resolve
|
376
|
+
};
|
377
|
+
};
|
378
|
+
const waitFor = (delay) => {
|
379
|
+
if (delay === 0) return;
|
380
|
+
const { promise, resolve } = PromiseWithResolvers();
|
381
|
+
setTimeout(resolve, delay);
|
382
|
+
return promise;
|
383
|
+
};
|
384
|
+
const createCombinedSignal = (...signals) => {
|
385
|
+
const cleanedSignals = signals.filter(Boolean);
|
386
|
+
const combinedSignal = AbortSignal.any(cleanedSignals);
|
387
|
+
return combinedSignal;
|
388
|
+
};
|
389
|
+
const createTimeoutSignal = (milliseconds) => AbortSignal.timeout(milliseconds);
|
390
|
+
|
391
|
+
//#endregion
|
392
|
+
export { HTTPError, ValidationError, commonDefaults, createCombinedSignal, createTimeoutSignal, dedupeDefaults, defineSchema, getBody, getFetchImpl, getHeaders, handleOptionsValidation, handleValidation, hookDefaults, isArray, isFunction, isHTTPError, isHTTPErrorInstance, isObject, isPlainObject, isReadableStream, isString, isValidationError, isValidationErrorInstance, requestOptionDefaults, responseDefaults, retryDefaults, routeKeyMethods, splitBaseConfig, splitConfig, toQueryString, waitFor };
|
393
|
+
//# sourceMappingURL=utils-C_6UX70F.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utils-C_6UX70F.js","names":["value: TValue","errorDetails: ErrorDetails<TErrorData>","errorOptions?: ErrorOptions","error: unknown","path: StandardSchemaV1.Issue[\"path\"]","issues: ValidationError[\"issues\"]","details: ValidationErrorDetails","errorOptions?: ErrorOptions","error: unknown","validator: Extract<CallApiSchema[keyof CallApiSchema], AnyFunction>","inputData: TInput","schema: TSchema","inputData: InferSchemaInput<TSchema>","response?: Response | null","baseSchema: TBaseSchema","schema: TSchema | undefined","validationOptions: ValidationOptions<TSchema>","validationOptions: ExtraOptionsValidationOptions","validatedResultObject: Prettify<\n\t\tPick<CallApiExtraOptions, (typeof extraOptionsToBeValidated)[number]>\n\t>","validationOptions: RequestOptionsValidationOptions","validatedResultObject: Prettify<\n\t\tPick<CallApiRequestOptions, (typeof requestOptionsToBeValidated)[number]>\n\t>","validationOptions: ExtraOptionsValidationOptions & RequestOptionsValidationOptions","error: CallApiResultErrorVariant<TErrorData>[\"error\"] | null","error: unknown","error: CallApiResultErrorVariant<unknown>[\"error\"]","value: unknown","value: ValidAuthValue","auth: SharedExtraOptions[\"auth\"]","initialObject: TObject","keysToOmit: TOmitArray","keysToPick: TPickArray","baseConfig: Record<string, any>","config: Record<string, any>","toQueryString: ToQueryStringFn","headers: CallApiRequestOptions[\"headers\"]","options: GetHeadersOptions","headersObject: Record<string, string | undefined>","options: GetBodyOptions","customFetchImpl: CallApiExtraOptions[\"customFetchImpl\"]","reject!: (reason?: unknown) => void","resolve!: (value: unknown) => void","delay: number","milliseconds: number"],"sources":["../../src/types/type-helpers.ts","../../src/constants/default-options.ts","../../src/error.ts","../../src/validation.ts","../../src/utils/guards.ts","../../src/auth.ts","../../src/constants/common.ts","../../src/utils/common.ts"],"sourcesContent":["// == These two types allows for adding arbitrary literal types, while still provided autocomplete for defaults.\n// == Usually intersection with \"{}\" or \"NonNullable<unknown>\" would make it work fine, but the placeholder with never type is added to make the AnyWhatever type appear last in a given union.\nexport type AnyString = string & NonNullable<unknown>;\nexport type AnyNumber = number & NonNullable<unknown>;\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Any is fine here\nexport type AnyObject = Record<keyof any, any>;\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Any is required here so that one can pass custom function type without type errors\nexport type AnyFunction<TResult = unknown> = (...args: any[]) => TResult;\n\nexport type CallbackFn<in TParams, out TResult = void> = (...params: TParams[]) => TResult;\n\nexport type Prettify<TObject> = NonNullable<unknown> & { [Key in keyof TObject]: TObject[Key] };\n\nexport type WriteableLevel = \"deep\" | \"shallow\";\n\n/**\n * Makes all properties in an object type writeable (removes readonly modifiers).\n * Supports both shallow and deep modes, and handles special cases like arrays, tuples, and unions.\n * @template TObject - The object type to make writeable\n * @template TVariant - The level of writeable transformation (\"shallow\" | \"deep\")\n */\n\ntype ArrayOrObject = Record<number | string | symbol, unknown> | unknown[];\n\nexport type Writeable<TObject, TLevel extends WriteableLevel = \"shallow\"> = TObject extends readonly [\n\t...infer TTupleItems,\n]\n\t? [\n\t\t\t...{\n\t\t\t\t[Index in keyof TTupleItems]: TLevel extends \"deep\"\n\t\t\t\t\t? Writeable<TTupleItems[Index], \"deep\">\n\t\t\t\t\t: TTupleItems[Index];\n\t\t\t},\n\t\t]\n\t: TObject extends ArrayOrObject\n\t\t? {\n\t\t\t\t-readonly [Key in keyof TObject]: TLevel extends \"deep\"\n\t\t\t\t\t? Writeable<TObject[Key], \"deep\">\n\t\t\t\t\t: TObject[Key];\n\t\t\t}\n\t\t: TObject;\n\nexport const defineEnum = <const TValue extends object>(value: TValue) => value as Writeable<TValue>;\n\nexport type UnionToIntersection<TUnion> = (\n\tTUnion extends unknown ? (param: TUnion) => void : never\n) extends (param: infer TParam) => void\n\t? TParam\n\t: never;\n\n// == Using this Immediately Indexed Mapped type helper to help show computed type of anything passed to it instead of just the type name\nexport type UnmaskType<TValue> = { _: TValue }[\"_\"];\n\nexport type Awaitable<TValue> = Promise<TValue> | TValue;\n\nexport type CommonRequestHeaders =\n\t| \"Access-Control-Allow-Credentials\"\n\t| \"Access-Control-Allow-Headers\"\n\t| \"Access-Control-Allow-Methods\"\n\t| \"Access-Control-Allow-Origin\"\n\t| \"Access-Control-Expose-Headers\"\n\t| \"Access-Control-Max-Age\"\n\t| \"Age\"\n\t| \"Allow\"\n\t| \"Cache-Control\"\n\t| \"Clear-Site-Data\"\n\t| \"Content-Disposition\"\n\t| \"Content-Encoding\"\n\t| \"Content-Language\"\n\t| \"Content-Length\"\n\t| \"Content-Location\"\n\t| \"Content-Range\"\n\t| \"Content-Security-Policy-Report-Only\"\n\t| \"Content-Security-Policy\"\n\t| \"Cookie\"\n\t| \"Cross-Origin-Embedder-Policy\"\n\t| \"Cross-Origin-Opener-Policy\"\n\t| \"Cross-Origin-Resource-Policy\"\n\t| \"Date\"\n\t| \"ETag\"\n\t| \"Expires\"\n\t| \"Last-Modified\"\n\t| \"Location\"\n\t| \"Permissions-Policy\"\n\t| \"Pragma\"\n\t| \"Retry-After\"\n\t| \"Save-Data\"\n\t| \"Sec-CH-Prefers-Color-Scheme\"\n\t| \"Sec-CH-Prefers-Reduced-Motion\"\n\t| \"Sec-CH-UA-Arch\"\n\t| \"Sec-CH-UA-Bitness\"\n\t| \"Sec-CH-UA-Form-Factor\"\n\t| \"Sec-CH-UA-Full-Version-List\"\n\t| \"Sec-CH-UA-Full-Version\"\n\t| \"Sec-CH-UA-Mobile\"\n\t| \"Sec-CH-UA-Model\"\n\t| \"Sec-CH-UA-Platform-Version\"\n\t| \"Sec-CH-UA-Platform\"\n\t| \"Sec-CH-UA-WoW64\"\n\t| \"Sec-CH-UA\"\n\t| \"Sec-Fetch-Dest\"\n\t| \"Sec-Fetch-Mode\"\n\t| \"Sec-Fetch-Site\"\n\t| \"Sec-Fetch-User\"\n\t| \"Sec-GPC\"\n\t| \"Server-Timing\"\n\t| \"Server\"\n\t| \"Service-Worker-Navigation-Preload\"\n\t| \"Set-Cookie\"\n\t| \"Strict-Transport-Security\"\n\t| \"Timing-Allow-Origin\"\n\t| \"Trailer\"\n\t| \"Transfer-Encoding\"\n\t| \"Upgrade\"\n\t| \"Vary\"\n\t| \"Warning\"\n\t| \"WWW-Authenticate\"\n\t| \"X-Content-Type-Options\"\n\t| \"X-DNS-Prefetch-Control\"\n\t| \"X-Frame-Options\"\n\t| \"X-Permitted-Cross-Domain-Policies\"\n\t| \"X-Powered-By\"\n\t| \"X-Robots-Tag\"\n\t| \"X-XSS-Protection\"\n\t| AnyString;\n\nexport type CommonAuthorizationHeaders = `${\"Basic\" | \"Bearer\" | \"Token\"} ${string}`;\n\nexport type CommonContentTypes =\n\t| \"application/epub+zip\"\n\t| \"application/gzip\"\n\t| \"application/json\"\n\t| \"application/ld+json\"\n\t| \"application/octet-stream\"\n\t| \"application/ogg\"\n\t| \"application/pdf\"\n\t| \"application/rtf\"\n\t| \"application/vnd.ms-fontobject\"\n\t| \"application/wasm\"\n\t| \"application/xhtml+xml\"\n\t| \"application/xml\"\n\t| \"application/zip\"\n\t| \"audio/aac\"\n\t| \"audio/mpeg\"\n\t| \"audio/ogg\"\n\t| \"audio/opus\"\n\t| \"audio/webm\"\n\t| \"audio/x-midi\"\n\t| \"font/otf\"\n\t| \"font/ttf\"\n\t| \"font/woff\"\n\t| \"font/woff2\"\n\t| \"image/avif\"\n\t| \"image/bmp\"\n\t| \"image/gif\"\n\t| \"image/jpeg\"\n\t| \"image/png\"\n\t| \"image/svg+xml\"\n\t| \"image/tiff\"\n\t| \"image/webp\"\n\t| \"image/x-icon\"\n\t| \"model/gltf-binary\"\n\t| \"model/gltf+json\"\n\t| \"text/calendar\"\n\t| \"text/css\"\n\t| \"text/csv\"\n\t| \"text/html\"\n\t| \"text/javascript\"\n\t| \"text/plain\"\n\t| \"video/3gpp\"\n\t| \"video/3gpp2\"\n\t| \"video/av1\"\n\t| \"video/mp2t\"\n\t| \"video/mp4\"\n\t| \"video/mpeg\"\n\t| \"video/ogg\"\n\t| \"video/webm\"\n\t| \"video/x-msvideo\"\n\t| AnyString;\n","import type { SharedExtraOptions } from \"../types\";\nimport { defineEnum } from \"../types/type-helpers\";\n\nexport const retryDefaults = defineEnum({\n\tattempts: 0,\n\tcondition: () => true,\n\tdelay: 1000,\n\tmaxDelay: 10000,\n\tmethods: [\"GET\", \"POST\"] satisfies SharedExtraOptions[\"retryMethods\"],\n\tstatusCodes: [] satisfies SharedExtraOptions[\"retryStatusCodes\"],\n\tstrategy: \"linear\",\n});\n\nexport const defaultRetryStatusCodesLookup = defineEnum({\n\t408: \"Request Timeout\",\n\t409: \"Conflict\",\n\t425: \"Too Early\",\n\t429: \"Too Many Requests\",\n\t500: \"Internal Server Error\",\n\t502: \"Bad Gateway\",\n\t503: \"Service Unavailable\",\n\t504: \"Gateway Timeout\",\n});\n\nexport const commonDefaults = defineEnum({\n\tbodySerializer: JSON.stringify,\n\tdefaultErrorMessage: \"An unexpected error occurred during the HTTP request.\",\n});\n\nexport const responseDefaults = defineEnum({\n\tresponseParser: JSON.parse,\n\tresponseType: \"json\",\n\tresultMode: \"all\",\n});\n\nexport const hookDefaults = defineEnum({\n\tmergedHooksExecutionMode: \"parallel\",\n\tmergedHooksExecutionOrder: \"mainHooksAfterPlugins\",\n});\n\nexport const dedupeDefaults = defineEnum({\n\tdedupeStrategy: \"cancel\",\n});\n\nexport const requestOptionDefaults = defineEnum({\n\tmethod: \"GET\",\n});\n","import { commonDefaults } from \"./constants/default-options\";\nimport type { CallApiExtraOptions } from \"./types\";\nimport { isObject } from \"./utils/guards\";\n\ntype ErrorDetails<TErrorData> = {\n\tdefaultErrorMessage: CallApiExtraOptions[\"defaultErrorMessage\"];\n\terrorData: TErrorData;\n\tresponse: Response;\n};\n\nconst httpErrorSymbol = Symbol(\"HTTPError\");\n\nexport class HTTPError<TErrorData = Record<string, unknown>> extends Error {\n\terrorData: ErrorDetails<TErrorData>[\"errorData\"];\n\n\thttpErrorSymbol = httpErrorSymbol;\n\n\tisHTTPError = true;\n\n\toverride name = \"HTTPError\" as const;\n\n\tresponse: ErrorDetails<TErrorData>[\"response\"];\n\n\tconstructor(errorDetails: ErrorDetails<TErrorData>, errorOptions?: ErrorOptions) {\n\t\tconst { defaultErrorMessage, errorData, response } = errorDetails;\n\n\t\tconst selectedDefaultErrorMessage =\n\t\t\tdefaultErrorMessage ?? (response.statusText || commonDefaults.defaultErrorMessage);\n\n\t\tconst message =\n\t\t\t(errorData as { message?: string } | undefined)?.message ?? selectedDefaultErrorMessage;\n\n\t\tsuper(message, errorOptions);\n\n\t\tthis.errorData = errorData;\n\t\tthis.response = response;\n\t\tError.captureStackTrace(this, this.constructor);\n\t}\n\n\t/**\n\t * @description Checks if the given error is an instance of HTTPError\n\t * @param error - The error to check\n\t * @returns true if the error is an instance of HTTPError, false otherwise\n\t */\n\tstatic isError<TErrorData>(error: unknown): error is HTTPError<TErrorData> {\n\t\tif (!isObject<Record<string, unknown>>(error)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (error instanceof HTTPError) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn error.httpErrorSymbol === httpErrorSymbol && error.isHTTPError === true;\n\t}\n}\n","/* eslint-disable ts-eslint/consistent-type-definitions -- I need to use interfaces for the sake of user overrides */\nimport type {\n\tBody,\n\tCallApiExtraOptions,\n\tCallApiRequestOptions,\n\tGlobalMeta,\n\tHeadersOption,\n\tMethodUnion,\n} from \"./types\";\nimport type { StandardSchemaV1 } from \"./types/standard-schema\";\nimport {\n\ttype AnyFunction,\n\ttype AnyString,\n\ttype Awaitable,\n\ttype Prettify,\n\ttype UnionToIntersection,\n\ttype Writeable,\n\tdefineEnum,\n} from \"./types/type-helpers\";\nimport type { Params, Query } from \"./url\";\nimport { isFunction, isObject } from \"./utils/guards\";\n\ntype InferSchemaInput<TSchema extends CallApiSchema[keyof CallApiSchema]> =\n\tTSchema extends StandardSchemaV1\n\t\t? StandardSchemaV1.InferInput<TSchema>\n\t\t: TSchema extends (value: infer TInput) => unknown\n\t\t\t? TInput\n\t\t\t: never;\n\nexport type InferSchemaResult<TSchema, TFallbackResult = NonNullable<unknown>> = undefined extends TSchema\n\t? TFallbackResult\n\t: TSchema extends StandardSchemaV1\n\t\t? StandardSchemaV1.InferOutput<TSchema>\n\t\t: TSchema extends AnyFunction<infer TResult>\n\t\t\t? TResult\n\t\t\t: TFallbackResult;\n\nconst validationErrorSymbol = Symbol(\"validationErrorSymbol\");\n\ntype ValidationErrorDetails = {\n\tissues: readonly StandardSchemaV1.Issue[];\n\tresponse: Response | null;\n};\n\nconst formatPath = (path: StandardSchemaV1.Issue[\"path\"]) => {\n\tif (!path?.length) {\n\t\treturn \"\";\n\t}\n\n\treturn ` → at ${path\n\t\t.map((segment) => (typeof segment === \"object\" && \"key\" in segment ? segment.key : String(segment)))\n\t\t.join(\".\")}`;\n};\n\nconst formatValidationIssues = (issues: ValidationError[\"issues\"]): string => {\n\treturn issues.map((issue) => `✖ ${issue.message}${formatPath(issue.path)}`).join(\" | \");\n};\n\nexport class ValidationError extends Error {\n\tissues: readonly StandardSchemaV1.Issue[];\n\n\toverride name = \"ValidationError\";\n\n\tresponse: Response | null;\n\n\tvalidationErrorSymbol = validationErrorSymbol;\n\n\tconstructor(details: ValidationErrorDetails, errorOptions?: ErrorOptions) {\n\t\tconst { issues, response } = details;\n\n\t\tconst message = formatValidationIssues(issues);\n\n\t\tsuper(message, errorOptions);\n\n\t\tthis.issues = issues;\n\t\tthis.response = response;\n\n\t\tError.captureStackTrace(this, this.constructor);\n\t}\n\n\t/**\n\t * @description Checks if the given error is an instance of HTTPError\n\t * @param error - The error to check\n\t * @returns true if the error is an instance of HTTPError, false otherwise\n\t */\n\tstatic isError(error: unknown): error is ValidationError {\n\t\tif (!isObject<Record<string, unknown>>(error)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (error instanceof ValidationError) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn error.validationErrorSymbol === validationErrorSymbol && error.name === \"ValidationError\";\n\t}\n}\n\nconst handleValidatorFunction = async <TInput>(\n\tvalidator: Extract<CallApiSchema[keyof CallApiSchema], AnyFunction>,\n\tinputData: TInput\n): Promise<StandardSchemaV1.Result<TInput>> => {\n\ttry {\n\t\tconst result = await validator(inputData as never);\n\n\t\treturn { issues: undefined, value: result as never };\n\t} catch (error) {\n\t\treturn { issues: error as never, value: undefined };\n\t}\n};\n\nexport const standardSchemaParser = async <\n\tTSchema extends NonNullable<CallApiSchema[keyof CallApiSchema]>,\n>(\n\tschema: TSchema,\n\tinputData: InferSchemaInput<TSchema>,\n\tresponse?: Response | null\n): Promise<InferSchemaResult<TSchema>> => {\n\tconst result = isFunction(schema)\n\t\t? await handleValidatorFunction(schema, inputData)\n\t\t: await schema[\"~standard\"].validate(inputData);\n\n\t// == If the `issues` field exists, it means the validation failed\n\tif (result.issues) {\n\t\tthrow new ValidationError(\n\t\t\t{ issues: result.issues, response: response ?? null },\n\t\t\t{ cause: result.issues }\n\t\t);\n\t}\n\n\treturn result.value as never;\n};\n\nexport interface CallApiSchemaConfig {\n\t/**\n\t * The base url of the schema. By default it's the baseURL of the fetch instance.\n\t */\n\tbaseURL?: string;\n\n\t/**\n\t * Disables runtime validation for the schema.\n\t */\n\tdisableRuntimeValidation?: boolean;\n\n\t/**\n\t * If `true`, the original input value will be used instead of the transformed/validated output.\n\t *\n\t * This is useful when you want to validate the input but don't want any transformations\n\t * applied by the validation schema (e.g., type coercion, default values, etc).\n\t */\n\tdisableValidationOutputApplication?: boolean;\n\n\t/**\n\t * Controls the inference of the method option based on the route modifiers (`@get/`, `@post/`, `@put/`, `@patch/`, `@delete/`).\n\t *\n\t * - When `true`, the method option is made required on the type level and is not automatically added to the request options.\n\t * - When `false` or `undefined` (default), the method option is not required on the type level, and is automatically added to the request options.\n\t *\n\t */\n\trequireHttpMethodProvision?: boolean;\n\n\t/**\n\t * Controls the strictness of API route validation.\n\t *\n\t * When true:\n\t * - Only routes explicitly defined in the schema will be considered valid to typescript\n\t * - Attempting to call undefined routes will result in type errors\n\t * - Useful for ensuring API calls conform exactly to your schema definition\n\t *\n\t * When false or undefined (default):\n\t * - All routes will be allowed, whether they are defined in the schema or not\n\t * - Provides more flexibility but less type safety\n\t *\n\t * @default false\n\t */\n\tstrict?: boolean;\n}\n\nexport const routeKeyMethods = defineEnum([\"delete\", \"get\", \"patch\", \"post\", \"put\"]);\n\nexport type RouteKeyMethods = (typeof routeKeyMethods)[number];\n\ntype RouteKey = `@${RouteKeyMethods}/${AnyString}` | AnyString;\n\nexport interface CallApiSchema {\n\t/**\n\t * The schema to use for validating the request body.\n\t */\n\tbody?: StandardSchemaV1<Body> | ((body: Body) => Awaitable<Body>);\n\n\t/**\n\t * The schema to use for validating the response data.\n\t */\n\tdata?: StandardSchemaV1 | ((data: unknown) => unknown);\n\n\t/**\n\t * The schema to use for validating the response error data.\n\t */\n\terrorData?: StandardSchemaV1 | ((errorData: unknown) => unknown);\n\n\t/**\n\t * The schema to use for validating the request headers.\n\t */\n\theaders?:\n\t\t| StandardSchemaV1<HeadersOption | undefined>\n\t\t| ((headers: HeadersOption) => Awaitable<HeadersOption>);\n\n\t/**\n\t * The schema to use for validating the meta option.\n\t */\n\tmeta?: StandardSchemaV1<GlobalMeta | undefined> | ((meta: GlobalMeta) => Awaitable<GlobalMeta>);\n\n\t/**\n\t * The schema to use for validating the request method.\n\t */\n\tmethod?: StandardSchemaV1<MethodUnion | undefined> | ((method: MethodUnion) => Awaitable<MethodUnion>);\n\n\t/**\n\t * The schema to use for validating the request url parameters.\n\t */\n\tparams?: StandardSchemaV1<Params | undefined> | ((params: Params) => Awaitable<Params>);\n\n\t/**\n\t * The schema to use for validating the request url queries.\n\t */\n\tquery?: StandardSchemaV1<Query | undefined> | ((query: Query) => Awaitable<Query>);\n}\n\nexport type BaseCallApiSchema = {\n\t[key in RouteKey]?: CallApiSchema;\n};\n\nexport const defineSchema = <const TBaseSchema extends BaseCallApiSchema>(baseSchema: TBaseSchema) => {\n\treturn baseSchema as Writeable<typeof baseSchema, \"deep\">;\n};\n\ntype ValidationOptions<\n\tTSchema extends CallApiSchema[keyof CallApiSchema] = CallApiSchema[keyof CallApiSchema],\n> = {\n\tinputValue: InferSchemaInput<TSchema>;\n\tresponse?: Response | null;\n\tschemaConfig: CallApiSchemaConfig | undefined;\n};\n\nexport const handleValidation = async <TSchema extends CallApiSchema[keyof CallApiSchema]>(\n\tschema: TSchema | undefined,\n\tvalidationOptions: ValidationOptions<TSchema>\n): Promise<InferSchemaResult<TSchema>> => {\n\tconst { inputValue, response, schemaConfig } = validationOptions;\n\n\tif (!schema || schemaConfig?.disableRuntimeValidation) {\n\t\treturn inputValue as never;\n\t}\n\n\tconst validResult = await standardSchemaParser(schema, inputValue, response);\n\n\treturn validResult as never;\n};\n\ntype LastOf<TValue> =\n\tUnionToIntersection<TValue extends unknown ? () => TValue : never> extends () => infer R ? R : never;\n\ntype Push<TArray extends unknown[], TArrayItem> = [...TArray, TArrayItem];\n\ntype UnionToTuple<\n\tTUnion,\n\tTComputedLastUnion = LastOf<TUnion>,\n\tTComputedIsUnionEqualToNever = [TUnion] extends [never] ? true : false,\n> = true extends TComputedIsUnionEqualToNever\n\t? []\n\t: Push<UnionToTuple<Exclude<TUnion, TComputedLastUnion>>, TComputedLastUnion>;\n\nexport type Tuple<\n\tTTuple,\n\tTArray extends TTuple[] = [],\n> = UnionToTuple<TTuple>[\"length\"] extends TArray[\"length\"]\n\t? [...TArray]\n\t: Tuple<TTuple, [TTuple, ...TArray]>;\n\nconst extraOptionsToBeValidated = [\"meta\", \"params\", \"query\"] satisfies Tuple<\n\tExtract<keyof CallApiSchema, keyof CallApiExtraOptions>\n>;\n\ntype ExtraOptionsValidationOptions = {\n\textraOptions: CallApiExtraOptions;\n\tschema: CallApiSchema | undefined;\n\tschemaConfig: CallApiSchemaConfig | undefined;\n};\n\nconst handleExtraOptionsValidation = async (validationOptions: ExtraOptionsValidationOptions) => {\n\tconst { extraOptions, schema, schemaConfig } = validationOptions;\n\n\tconst validationResultArray = await Promise.all(\n\t\textraOptionsToBeValidated.map((propertyKey) =>\n\t\t\thandleValidation(schema?.[propertyKey], {\n\t\t\t\tinputValue: extraOptions[propertyKey],\n\t\t\t\tschemaConfig,\n\t\t\t})\n\t\t)\n\t);\n\n\tconst validatedResultObject: Prettify<\n\t\tPick<CallApiExtraOptions, (typeof extraOptionsToBeValidated)[number]>\n\t> = {};\n\n\tfor (const [index, propertyKey] of extraOptionsToBeValidated.entries()) {\n\t\tconst validationResult = validationResultArray[index];\n\n\t\tif (validationResult === undefined) continue;\n\n\t\tvalidatedResultObject[propertyKey] = validationResult as never;\n\t}\n\n\treturn validatedResultObject;\n};\n\nconst requestOptionsToBeValidated = [\"body\", \"headers\", \"method\"] satisfies Tuple<\n\tExtract<keyof CallApiSchema, keyof CallApiRequestOptions>\n>;\n\ntype RequestOptionsValidationOptions = {\n\trequestOptions: CallApiRequestOptions;\n\tschema: CallApiSchema | undefined;\n\tschemaConfig: CallApiSchemaConfig | undefined;\n};\n\nconst handleRequestOptionsValidation = async (validationOptions: RequestOptionsValidationOptions) => {\n\tconst { requestOptions, schema, schemaConfig } = validationOptions;\n\n\tconst validationResultArray = await Promise.all(\n\t\trequestOptionsToBeValidated.map((propertyKey) =>\n\t\t\thandleValidation(schema?.[propertyKey], {\n\t\t\t\tinputValue: requestOptions[propertyKey],\n\t\t\t\tschemaConfig,\n\t\t\t})\n\t\t)\n\t);\n\n\tconst validatedResultObject: Prettify<\n\t\tPick<CallApiRequestOptions, (typeof requestOptionsToBeValidated)[number]>\n\t> = {};\n\n\tfor (const [index, propertyKey] of requestOptionsToBeValidated.entries()) {\n\t\tconst validationResult = validationResultArray[index];\n\n\t\tif (validationResult === undefined) continue;\n\n\t\tvalidatedResultObject[propertyKey] = validationResult as never;\n\t}\n\n\treturn validatedResultObject;\n};\n\nexport const handleOptionsValidation = async (\n\tvalidationOptions: ExtraOptionsValidationOptions & RequestOptionsValidationOptions\n) => {\n\tconst { extraOptions, requestOptions, schema, schemaConfig } = validationOptions;\n\n\tif (schemaConfig?.disableRuntimeValidation) {\n\t\treturn {\n\t\t\textraOptionsValidationResult: null,\n\t\t\trequestOptionsValidationResult: null,\n\t\t};\n\t}\n\n\tconst [extraOptionsValidationResult, requestOptionsValidationResult] = await Promise.all([\n\t\thandleExtraOptionsValidation({ extraOptions, schema, schemaConfig }),\n\t\thandleRequestOptionsValidation({ requestOptions, schema, schemaConfig }),\n\t]);\n\n\treturn { extraOptionsValidationResult, requestOptionsValidationResult };\n};\n","import { HTTPError } from \"../error\";\nimport type { CallApiResultErrorVariant, PossibleHTTPError, PossibleValidationError } from \"../result\";\nimport type { AnyFunction } from \"../types/type-helpers\";\nimport { ValidationError } from \"../validation\";\n\nexport const isHTTPError = <TErrorData>(\n\terror: CallApiResultErrorVariant<TErrorData>[\"error\"] | null\n): error is PossibleHTTPError<TErrorData> => {\n\treturn isObject(error) && error.name === \"HTTPError\";\n};\n\nexport const isHTTPErrorInstance = <TErrorData>(error: unknown) => {\n\treturn HTTPError.isError<TErrorData>(error);\n};\n\nexport const isValidationError = (\n\terror: CallApiResultErrorVariant<unknown>[\"error\"]\n): error is PossibleValidationError => {\n\treturn isObject(error) && error.name === \"ValidationError\";\n};\n\nexport const isValidationErrorInstance = (error: unknown): error is ValidationError => {\n\treturn ValidationError.isError(error);\n};\n\nexport const isArray = <TArrayItem>(value: unknown): value is TArrayItem[] => Array.isArray(value);\n\nexport const isObject = <TObject extends object>(value: unknown): value is TObject => {\n\treturn typeof value === \"object\" && value !== null;\n};\n\nconst hasObjectPrototype = (value: unknown) => {\n\treturn Object.prototype.toString.call(value) === \"[object Object]\";\n};\n\n/**\n * @description Copied from TanStack Query's isPlainObject\n * @see https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L321\n */\nexport const isPlainObject = <TPlainObject extends Record<string, unknown>>(\n\tvalue: unknown\n): value is TPlainObject => {\n\tif (!hasObjectPrototype(value)) {\n\t\treturn false;\n\t}\n\n\t// If has no constructor\n\tconst constructor = (value as object | undefined)?.constructor;\n\tif (constructor === undefined) {\n\t\treturn true;\n\t}\n\n\t// If has modified prototype\n\tconst prototype = constructor.prototype as object;\n\tif (!hasObjectPrototype(prototype)) {\n\t\treturn false;\n\t}\n\n\t// If constructor does not have an Object-specific method\n\tif (!Object.hasOwn(prototype, \"isPrototypeOf\")) {\n\t\treturn false;\n\t}\n\n\t// Handles Objects created by Object.create(<arbitrary prototype>)\n\tif (Object.getPrototypeOf(value) !== Object.prototype) {\n\t\treturn false;\n\t}\n\n\t// It's probably a plain object at this point\n\treturn true;\n};\n\nexport const isJsonString = (value: unknown): value is string => {\n\tif (!isString(value)) {\n\t\treturn false;\n\t}\n\n\ttry {\n\t\tJSON.parse(value);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nexport const isSerializable = (value: unknown) => {\n\treturn (\n\t\tisPlainObject(value)\n\t\t|| isArray(value)\n\t\t|| typeof (value as { toJSON: unknown } | undefined)?.toJSON === \"function\"\n\t);\n};\n\nexport const isFunction = <TFunction extends AnyFunction>(value: unknown): value is TFunction =>\n\ttypeof value === \"function\";\n\nexport const isQueryString = (value: unknown): value is string => isString(value) && value.includes(\"=\");\n\nexport const isString = (value: unknown) => typeof value === \"string\";\n\nexport const isReadableStream = (value: unknown): value is ReadableStream<unknown> => {\n\treturn value instanceof ReadableStream;\n};\n\n// https://github.com/unjs/ofetch/blob/main/src/utils.ts\nexport const isJSONSerializable = (value: unknown) => {\n\tif (value === undefined) {\n\t\treturn false;\n\t}\n\tconst t = typeof value;\n\t// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- No time to make this more type-safe\n\tif (t === \"string\" || t === \"number\" || t === \"boolean\" || t === null) {\n\t\treturn true;\n\t}\n\tif (t !== \"object\") {\n\t\treturn false;\n\t}\n\tif (isArray(value)) {\n\t\treturn true;\n\t}\n\tif ((value as Buffer | null)?.buffer) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\t(value?.constructor && value.constructor.name === \"Object\")\n\t\t// eslint-disable-next-line ts-eslint/prefer-nullish-coalescing -- Nullish coalescing makes no sense in this boolean context\n\t\t|| typeof (value as { toJSON: () => unknown } | null)?.toJSON === \"function\"\n\t);\n};\n","/* eslint-disable perfectionist/sort-object-types -- Avoid Sorting for now */\n\nimport type { SharedExtraOptions } from \"./types/common\";\nimport type { Awaitable } from \"./types/type-helpers\";\nimport { isFunction, isString } from \"./utils/guards\";\n\ntype ValueOrFunctionResult<TValue> = TValue | (() => TValue);\n\ntype ValidAuthValue = ValueOrFunctionResult<Awaitable<string | null | undefined>>;\n\n/**\n * Bearer Or Token authentication\n *\n * The value of `bearer` will be added to a header as\n * `auth: Bearer some-auth-token`,\n *\n * The value of `token` will be added to a header as\n * `auth: Token some-auth-token`,\n */\nexport type BearerOrTokenAuth =\n\t| {\n\t\t\ttype?: \"Bearer\";\n\t\t\tbearer?: ValidAuthValue;\n\t\t\ttoken?: never;\n\t }\n\t| {\n\t\t\ttype?: \"Token\";\n\t\t\tbearer?: never;\n\t\t\ttoken?: ValidAuthValue;\n\t };\n\n/**\n * Basic auth\n */\nexport type BasicAuth = {\n\ttype: \"Basic\";\n\tusername: ValidAuthValue;\n\tpassword: ValidAuthValue;\n};\n\n/**\n * Custom auth\n *\n * @param prefix - prefix of the header\n * @param authValue - value of the header\n *\n * @example\n * ```ts\n * {\n * type: \"Custom\",\n * prefix: \"Token\",\n * authValue: \"token\"\n * }\n * ```\n */\nexport type CustomAuth = {\n\ttype: \"Custom\";\n\tprefix: ValidAuthValue;\n\tvalue: ValidAuthValue;\n};\n\n// eslint-disable-next-line perfectionist/sort-union-types -- Let the first one be first\nexport type Auth = BearerOrTokenAuth | BasicAuth | CustomAuth;\n\nconst getValue = (value: ValidAuthValue) => {\n\treturn isFunction(value) ? value() : value;\n};\n\ntype AuthorizationHeader = {\n\tAuthorization: string;\n};\n\nexport const getAuthHeader = async (\n\tauth: SharedExtraOptions[\"auth\"]\n): Promise<false | AuthorizationHeader | undefined> => {\n\tif (auth === undefined) return;\n\n\tif (isString(auth) || auth === null) {\n\t\treturn { Authorization: `Bearer ${auth}` };\n\t}\n\n\tswitch (auth.type) {\n\t\tcase \"Basic\": {\n\t\t\tconst username = await getValue(auth.username);\n\t\t\tconst password = await getValue(auth.password);\n\n\t\t\tif (username === undefined || password === undefined) return;\n\n\t\t\treturn {\n\t\t\t\tAuthorization: `Basic ${globalThis.btoa(`${username}:${password}`)}`,\n\t\t\t};\n\t\t}\n\n\t\tcase \"Custom\": {\n\t\t\tconst value = await getValue(auth.value);\n\n\t\t\tif (value === undefined) return;\n\n\t\t\tconst prefix = await getValue(auth.prefix);\n\n\t\t\treturn {\n\t\t\t\tAuthorization: `${prefix} ${value}`,\n\t\t\t};\n\t\t}\n\n\t\tdefault: {\n\t\t\tconst bearer = await getValue(auth.bearer);\n\t\t\tconst token = await getValue(auth.token);\n\n\t\t\tif (\"token\" in auth && token !== undefined) {\n\t\t\t\treturn { Authorization: `Token ${token}` };\n\t\t\t}\n\n\t\t\treturn bearer !== undefined && { Authorization: `Bearer ${bearer}` };\n\t\t}\n\t}\n};\n","import type { ModifiedRequestInit } from \"../types\";\nimport { defineEnum } from \"../types/type-helpers\";\n\nexport const fetchSpecificKeys = defineEnum([\n\t\"body\",\n\t\"integrity\",\n\t\"duplex\",\n\t\"method\",\n\t\"headers\",\n\t\"signal\",\n\t\"cache\",\n\t\"redirect\",\n\t\"window\",\n\t\"credentials\",\n\t\"keepalive\",\n\t\"referrer\",\n\t\"priority\",\n\t\"mode\",\n\t\"referrerPolicy\",\n] satisfies Array<keyof ModifiedRequestInit> as Array<keyof ModifiedRequestInit>);\n","import { getAuthHeader } from \"../auth\";\nimport { fetchSpecificKeys } from \"../constants/common\";\nimport { commonDefaults } from \"../constants/default-options\";\nimport type { InferHeadersOption } from \"../types\";\nimport type { BaseCallApiExtraOptions, CallApiExtraOptions, CallApiRequestOptions } from \"../types/common\";\nimport type { AnyFunction } from \"../types/type-helpers\";\nimport type { CallApiSchema } from \"../validation\";\nimport { isFunction, isJsonString, isPlainObject, isQueryString, isSerializable } from \"./guards\";\n\nexport const omitKeys = <\n\tTObject extends Record<string, unknown>,\n\tconst TOmitArray extends Array<keyof TObject>,\n>(\n\tinitialObject: TObject,\n\tkeysToOmit: TOmitArray\n) => {\n\tconst updatedObject = {} as Record<string, unknown>;\n\n\tconst keysToOmitSet = new Set(keysToOmit);\n\n\tfor (const [key, value] of Object.entries(initialObject)) {\n\t\tif (!keysToOmitSet.has(key)) {\n\t\t\tupdatedObject[key] = value;\n\t\t}\n\t}\n\n\treturn updatedObject as Omit<TObject, TOmitArray[number]>;\n};\n\nexport const pickKeys = <\n\tTObject extends Record<string, unknown>,\n\tconst TPickArray extends Array<keyof TObject>,\n>(\n\tinitialObject: TObject,\n\tkeysToPick: TPickArray\n) => {\n\tconst updatedObject = {} as Record<string, unknown>;\n\n\tconst keysToPickSet = new Set(keysToPick);\n\n\tfor (const [key, value] of Object.entries(initialObject)) {\n\t\tif (keysToPickSet.has(key)) {\n\t\t\tupdatedObject[key] = value;\n\t\t}\n\t}\n\n\treturn updatedObject as Pick<TObject, TPickArray[number]>;\n};\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Any is required here so that one can pass custom function type without type errors\nexport const splitBaseConfig = (baseConfig: Record<string, any>) =>\n\t[\n\t\tpickKeys(baseConfig, fetchSpecificKeys) as CallApiRequestOptions,\n\t\tomitKeys(baseConfig, fetchSpecificKeys) as BaseCallApiExtraOptions,\n\t] as const;\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Any is required here so that one can pass custom function type without type errors\nexport const splitConfig = (config: Record<string, any>) =>\n\t[\n\t\tpickKeys(config, fetchSpecificKeys) as CallApiRequestOptions,\n\t\tomitKeys(config, fetchSpecificKeys) as CallApiExtraOptions,\n\t] as const;\n\ntype ToQueryStringFn = {\n\t(params: CallApiExtraOptions[\"query\"]): string | null;\n\t(params: Required<CallApiExtraOptions>[\"query\"]): string;\n};\n\nexport const toQueryString: ToQueryStringFn = (params) => {\n\tif (!params) {\n\t\tconsole.error(\"toQueryString:\", \"No query params provided!\");\n\n\t\treturn null as never;\n\t}\n\n\treturn new URLSearchParams(params as Record<string, string>).toString();\n};\n\nexport const objectifyHeaders = (headers: CallApiRequestOptions[\"headers\"]) => {\n\tif (!headers || isPlainObject(headers)) {\n\t\treturn headers;\n\t}\n\n\treturn Object.fromEntries(headers);\n};\n\nexport type GetHeadersOptions = {\n\tauth: CallApiExtraOptions[\"auth\"];\n\tbaseHeaders: CallApiRequestOptions[\"headers\"];\n\tbody: CallApiRequestOptions[\"body\"];\n\theaders: CallApiRequestOptions[\"headers\"];\n};\n\nexport const getHeaders = async (options: GetHeadersOptions) => {\n\tconst { auth, baseHeaders, body, headers } = options;\n\n\ttype HeaderFn = Extract<InferHeadersOption<CallApiSchema>[\"headers\"], AnyFunction>;\n\n\tconst resolvedHeaders = isFunction<HeaderFn>(headers)\n\t\t? headers({ baseHeaders: baseHeaders ?? {} })\n\t\t: (headers ?? baseHeaders);\n\n\t// == Return early if any of the following conditions are met (so that native fetch would auto set the correct headers):\n\t// == - The headers are not provided\n\t// == - The body is not provided\n\t// == - The auth option is not provided\n\tconst shouldResolveHeaders = Boolean(resolvedHeaders) || Boolean(body) || Boolean(auth);\n\n\tif (!shouldResolveHeaders) return;\n\n\tconst headersObject: Record<string, string | undefined> = {\n\t\t...(await getAuthHeader(auth)),\n\t\t...objectifyHeaders(resolvedHeaders),\n\t};\n\n\tif (isQueryString(body)) {\n\t\theadersObject[\"Content-Type\"] = \"application/x-www-form-urlencoded\";\n\n\t\treturn headersObject;\n\t}\n\n\tif (isSerializable(body) || isJsonString(body)) {\n\t\theadersObject[\"Content-Type\"] = \"application/json\";\n\t\theadersObject.Accept = \"application/json\";\n\t}\n\n\treturn headersObject;\n};\n\nexport type GetBodyOptions = {\n\tbody: CallApiRequestOptions[\"body\"];\n\tbodySerializer: CallApiExtraOptions[\"bodySerializer\"];\n};\n\nexport const getBody = (options: GetBodyOptions) => {\n\tconst { body, bodySerializer } = options;\n\n\tif (isSerializable(body)) {\n\t\tconst selectedBodySerializer = bodySerializer ?? commonDefaults.bodySerializer;\n\n\t\treturn selectedBodySerializer(body);\n\t}\n\n\treturn body;\n};\n\nexport const getFetchImpl = (customFetchImpl: CallApiExtraOptions[\"customFetchImpl\"]) => {\n\tif (customFetchImpl) {\n\t\treturn customFetchImpl;\n\t}\n\n\tif (typeof globalThis !== \"undefined\" && isFunction(globalThis.fetch)) {\n\t\treturn globalThis.fetch;\n\t}\n\n\tthrow new Error(\"No fetch implementation found\");\n};\n\nconst PromiseWithResolvers = () => {\n\tlet reject!: (reason?: unknown) => void;\n\tlet resolve!: (value: unknown) => void;\n\n\tconst promise = new Promise((res, rej) => {\n\t\tresolve = res;\n\t\treject = rej;\n\t});\n\n\treturn { promise, reject, resolve };\n};\n\nexport const waitFor = (delay: number) => {\n\tif (delay === 0) return;\n\n\tconst { promise, resolve } = PromiseWithResolvers();\n\n\tsetTimeout(resolve, delay);\n\n\treturn promise;\n};\n\nexport const createCombinedSignal = (...signals: Array<AbortSignal | null | undefined>) => {\n\tconst cleanedSignals = signals.filter(Boolean);\n\n\tconst combinedSignal = AbortSignal.any(cleanedSignals);\n\n\treturn combinedSignal;\n};\n\nexport const createTimeoutSignal = (milliseconds: number) => AbortSignal.timeout(milliseconds);\n"],"mappings":";AA4CA,MAAa,aAAa,CAA8BA,UAAkB;;;;ACzC1E,MAAa,gBAAgB,WAAW;CACvC,UAAU;CACV,WAAW,MAAM;CACjB,OAAO;CACP,UAAU;CACV,SAAS,CAAC,OAAO,MAAO;CACxB,aAAa,CAAE;CACf,UAAU;AACV,EAAC;AAEF,MAAa,gCAAgC,WAAW;CACvD,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;AACL,EAAC;AAEF,MAAa,iBAAiB,WAAW;CACxC,gBAAgB,KAAK;CACrB,qBAAqB;AACrB,EAAC;AAEF,MAAa,mBAAmB,WAAW;CAC1C,gBAAgB,KAAK;CACrB,cAAc;CACd,YAAY;AACZ,EAAC;AAEF,MAAa,eAAe,WAAW;CACtC,0BAA0B;CAC1B,2BAA2B;AAC3B,EAAC;AAEF,MAAa,iBAAiB,WAAW,EACxC,gBAAgB,SAChB,EAAC;AAEF,MAAa,wBAAwB,WAAW,EAC/C,QAAQ,MACR,EAAC;;;;ACpCF,MAAM,kBAAkB,OAAO,YAAY;AAE3C,IAAa,YAAb,MAAa,kBAAwD,MAAM;CAC1E;CAEA,kBAAkB;CAElB,cAAc;CAEd,AAAS,OAAO;CAEhB;CAEA,YAAYC,cAAwCC,cAA6B;EAChF,MAAM,EAAE,qBAAqB,WAAW,UAAU,GAAG;EAErD,MAAM,8BACL,wBAAwB,SAAS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QAAQ;AACzC,YAAU;AACV,WAAS;CACT;AAED,QAAO;EAAE;EAAS;EAAQ;CAAS;AACnC;AAED,MAAa,UAAU,CAACC,UAAkB;AACzC,KAAI,UAAU,EAAG;CAEjB,MAAM,EAAE,SAAS,SAAS,GAAG,sBAAsB;AAEnD,YAAW,SAAS,MAAM;AAE1B,QAAO;AACP;AAED,MAAa,uBAAuB,CAAC,GAAG,YAAmD;CAC1F,MAAM,iBAAiB,QAAQ,OAAO,QAAQ;CAE9C,MAAM,iBAAiB,YAAY,IAAI,eAAe;AAEtD,QAAO;AACP;AAED,MAAa,sBAAsB,CAACC,iBAAyB,YAAY,QAAQ,aAAa"}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@zayne-labs/callapi",
|
3
3
|
"type": "module",
|
4
|
-
"version": "1.
|
4
|
+
"version": "1.8.0",
|
5
5
|
"description": "A lightweight wrapper over fetch with quality of life improvements like built-in request cancellation, retries, interceptors and more",
|
6
6
|
"author": "Ryan Zayne",
|
7
7
|
"license": "MIT",
|
@@ -34,19 +34,20 @@
|
|
34
34
|
"node": ">=v18.17.0"
|
35
35
|
},
|
36
36
|
"devDependencies": {
|
37
|
-
"@arethetypeswrong/cli": "0.
|
37
|
+
"@arethetypeswrong/cli": "0.18.1",
|
38
38
|
"@size-limit/esbuild-why": "11.2.0",
|
39
39
|
"@size-limit/preset-small-lib": "11.2.0",
|
40
40
|
"@total-typescript/ts-reset": "0.6.1",
|
41
|
-
"@zayne-labs/toolkit-type-helpers": "^0.9.
|
42
|
-
"@zayne-labs/tsconfig": "0.
|
41
|
+
"@zayne-labs/toolkit-type-helpers": "^0.9.46",
|
42
|
+
"@zayne-labs/tsconfig": "0.9.1",
|
43
43
|
"concurrently": "^9.1.2",
|
44
44
|
"cross-env": "^7.0.3",
|
45
45
|
"publint": "^0.3.12",
|
46
46
|
"size-limit": "11.2.0",
|
47
|
-
"
|
47
|
+
"tsdown": "^0.12.6",
|
48
|
+
"tsup": "^8.5.0",
|
48
49
|
"typescript": "5.8.3",
|
49
|
-
"vitest": "^3.1.
|
50
|
+
"vitest": "^3.1.4"
|
50
51
|
},
|
51
52
|
"publishConfig": {
|
52
53
|
"access": "public",
|
@@ -56,15 +57,15 @@
|
|
56
57
|
"size-limit": [
|
57
58
|
{
|
58
59
|
"path": "./src/index.ts",
|
59
|
-
"limit": "
|
60
|
+
"limit": "5.5 kb"
|
60
61
|
},
|
61
62
|
{
|
62
63
|
"path": "./src/utils/index.ts",
|
63
|
-
"limit": "
|
64
|
+
"limit": "900 b"
|
64
65
|
}
|
65
66
|
],
|
66
67
|
"scripts": {
|
67
|
-
"build": "
|
68
|
+
"build": "tsdown",
|
68
69
|
"build:dev": "cross-env NODE_ENV=development tsup",
|
69
70
|
"build:test": "concurrently --prefix-colors \"yellow.bold,#7da4f8.bold,magenta\" --names PUBLINT,TSUP 'pnpm:lint:publint' 'pnpm:build:dev'",
|
70
71
|
"dev": "pnpm build:dev --watch",
|