@zayne-labs/callapi 1.8.21 → 1.9.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/README.md +3 -1
- package/dist/esm/{common-C-kIzPcz.d.ts → common-Byku1Sji.d.ts} +83 -129
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +59 -93
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/index.d.ts +1 -1
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/{utils-DZe23qYR.js → utils-DUbIqsYh.js} +28 -44
- package/dist/esm/utils-DUbIqsYh.js.map +1 -0
- package/package.json +5 -5
- package/dist/esm/utils-DZe23qYR.js.map +0 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import { CallApiExtraOptions, CallApiResultErrorVariant, HTTPError, PossibleHTTPError, PossibleJavaScriptError, PossibleValidationError, ValidationError } from "../common-
|
1
|
+
import { CallApiExtraOptions, CallApiResultErrorVariant, HTTPError, PossibleHTTPError, PossibleJavaScriptError, PossibleValidationError, ValidationError } from "../common-Byku1Sji.js";
|
2
2
|
|
3
3
|
//#region src/utils/common.d.ts
|
4
4
|
|
package/dist/esm/utils/index.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
import { isHTTPError, isHTTPErrorInstance, isJavascriptError, isValidationError, isValidationErrorInstance, toQueryString } from "../utils-
|
1
|
+
import { isHTTPError, isHTTPErrorInstance, isJavascriptError, isValidationError, isValidationErrorInstance, toQueryString } from "../utils-DUbIqsYh.js";
|
2
2
|
|
3
3
|
export { isHTTPError, isHTTPErrorInstance, isJavascriptError, isValidationError, isValidationErrorInstance, toQueryString };
|
@@ -3,44 +3,30 @@ const defineEnum = (value) => value;
|
|
3
3
|
|
4
4
|
//#endregion
|
5
5
|
//#region src/constants/default-options.ts
|
6
|
-
const
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
});
|
29
|
-
|
30
|
-
responseParser: JSON.parse,
|
31
|
-
responseType: "json",
|
32
|
-
resultMode: "all"
|
33
|
-
});
|
34
|
-
const hookDefaults = defineEnum({
|
35
|
-
hooksExecutionMode: "parallel",
|
36
|
-
hooksRegistrationOrder: "pluginsFirst"
|
37
|
-
});
|
38
|
-
const dedupeDefaults = defineEnum({
|
39
|
-
dedupeCacheScope: "local",
|
40
|
-
dedupeCacheScopeKey: "default",
|
41
|
-
dedupeStrategy: "cancel"
|
42
|
-
});
|
43
|
-
const requestOptionDefaults = defineEnum({ method: "GET" });
|
6
|
+
const extraOptionDefaults = () => {
|
7
|
+
return defineEnum({
|
8
|
+
bodySerializer: JSON.stringify,
|
9
|
+
defaultHTTPErrorMessage: "An unexpected error occurred during the HTTP request.",
|
10
|
+
dedupeCacheScope: "local",
|
11
|
+
dedupeCacheScopeKey: "default",
|
12
|
+
dedupeStrategy: "cancel",
|
13
|
+
hooksExecutionMode: "parallel",
|
14
|
+
hooksRegistrationOrder: "pluginsFirst",
|
15
|
+
responseParser: JSON.parse,
|
16
|
+
responseType: "json",
|
17
|
+
resultMode: "all",
|
18
|
+
retryAttempts: 0,
|
19
|
+
retryCondition: () => true,
|
20
|
+
retryDelay: 1e3,
|
21
|
+
retryMaxDelay: 1e4,
|
22
|
+
retryMethods: ["GET", "POST"],
|
23
|
+
retryStatusCodes: [],
|
24
|
+
retryStrategy: "linear"
|
25
|
+
});
|
26
|
+
};
|
27
|
+
const requestOptionDefaults = () => {
|
28
|
+
return defineEnum({ method: "GET" });
|
29
|
+
};
|
44
30
|
|
45
31
|
//#endregion
|
46
32
|
//#region src/error.ts
|
@@ -57,12 +43,11 @@ var HTTPError = class HTTPError extends Error {
|
|
57
43
|
errorData,
|
58
44
|
response
|
59
45
|
});
|
60
|
-
const selectedDefaultErrorMessage = resolvedDefaultHTTPErrorMessage ?? (response.statusText ||
|
46
|
+
const selectedDefaultErrorMessage = resolvedDefaultHTTPErrorMessage ?? (response.statusText || extraOptionDefaults().defaultHTTPErrorMessage);
|
61
47
|
const message = errorData?.message ?? selectedDefaultErrorMessage;
|
62
48
|
super(message, errorOptions);
|
63
49
|
this.errorData = errorData;
|
64
50
|
this.response = response;
|
65
|
-
Error.captureStackTrace(this, this.constructor);
|
66
51
|
}
|
67
52
|
/**
|
68
53
|
* @description Checks if the given error is an instance of HTTPError
|
@@ -96,7 +81,6 @@ var ValidationError = class ValidationError extends Error {
|
|
96
81
|
super(message, errorOptions);
|
97
82
|
this.errorData = issues;
|
98
83
|
this.response = response;
|
99
|
-
Error.captureStackTrace(this, this.constructor);
|
100
84
|
}
|
101
85
|
/**
|
102
86
|
* @description Checks if the given error is an instance of HTTPError
|
@@ -266,7 +250,7 @@ const getHeaders = async (options) => {
|
|
266
250
|
const getBody = (options) => {
|
267
251
|
const { body, bodySerializer } = options;
|
268
252
|
if (isSerializable(body)) {
|
269
|
-
const selectedBodySerializer = bodySerializer ??
|
253
|
+
const selectedBodySerializer = bodySerializer ?? extraOptionDefaults().bodySerializer;
|
270
254
|
return selectedBodySerializer(body);
|
271
255
|
}
|
272
256
|
return body;
|
@@ -312,5 +296,5 @@ const deterministicHashFn = (value) => {
|
|
312
296
|
};
|
313
297
|
|
314
298
|
//#endregion
|
315
|
-
export { HTTPError, ValidationError, createCombinedSignal, createTimeoutSignal,
|
316
|
-
//# sourceMappingURL=utils-
|
299
|
+
export { HTTPError, ValidationError, createCombinedSignal, createTimeoutSignal, defineEnum, deterministicHashFn, extraOptionDefaults, getBody, getFetchImpl, getHeaders, isArray, isFunction, isHTTPError, isHTTPErrorInstance, isJavascriptError, isObject, isPlainObject, isReadableStream, isString, isValidationError, isValidationErrorInstance, requestOptionDefaults, splitBaseConfig, splitConfig, toQueryString, waitFor };
|
300
|
+
//# sourceMappingURL=utils-DUbIqsYh.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utils-DUbIqsYh.js","names":["value: TValue","errorDetails: HTTPErrorDetails<TErrorData>","errorOptions?: ErrorOptions","error: unknown","path: ValidationError[\"errorData\"][number][\"path\"]","issues: ValidationError[\"errorData\"]","details: ValidationErrorDetails","error: CallApiResultErrorVariant<TErrorData>[\"error\"] | null","error: unknown","error: CallApiResultErrorVariant<unknown>[\"error\"] | null","value: unknown","value: ValidAuthValue","auth: CallApiExtraOptions[\"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","value: unknown","val: unknown","result: Record<string, unknown>"],"sources":["../../src/types/type-helpers.ts","../../src/constants/default-options.ts","../../src/error.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\"> =\n\tTObject extends readonly [...infer TTupleItems] ?\n\t\t[\n\t\t\t...{\n\t\t\t\t[Index in keyof TTupleItems]: TLevel extends \"deep\" ? Writeable<TTupleItems[Index], \"deep\">\n\t\t\t\t:\tTTupleItems[Index];\n\t\t\t},\n\t\t]\n\t: TObject extends ArrayOrObject ?\n\t\t{\n\t\t\t-readonly [Key in keyof TObject]: TLevel extends \"deep\" ? Writeable<TObject[Key], \"deep\">\n\t\t\t:\tTObject[Key];\n\t\t}\n\t:\tTObject;\n\nexport const defineEnum = <const TValue extends object>(value: TValue) => value as Writeable<TValue>;\n\nexport type UnionToIntersection<TUnion> =\n\t(TUnion extends unknown ? (param: TUnion) => void : never) extends (param: infer TParam) => void ?\n\t\tTParam\n\t:\tnever;\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 { CallApiConfig, CallApiExtraOptions } from \"../types/common\";\nimport { defineEnum } from \"../types/type-helpers\";\n\nexport const extraOptionDefaults = () => {\n\treturn defineEnum({\n\t\t// Common defaults\n\t\tbodySerializer: JSON.stringify,\n\t\tdefaultHTTPErrorMessage: \"An unexpected error occurred during the HTTP request.\",\n\n\t\t// Dedupe defaults\n\t\t/* eslint-disable perfectionist/sort-objects -- Allow */\n\t\tdedupeCacheScope: \"local\",\n\t\tdedupeCacheScopeKey: \"default\",\n\t\tdedupeStrategy: \"cancel\",\n\t\t/* eslint-enable perfectionist/sort-objects -- Allow */\n\n\t\t// Hook defaults\n\t\thooksExecutionMode: \"parallel\",\n\t\thooksRegistrationOrder: \"pluginsFirst\",\n\n\t\t// Response defaults\n\t\tresponseParser: JSON.parse,\n\t\tresponseType: \"json\",\n\t\tresultMode: \"all\",\n\n\t\t// Retry Defaults\n\t\tretryAttempts: 0,\n\t\tretryCondition: () => true,\n\t\tretryDelay: 1000,\n\t\tretryMaxDelay: 10000,\n\t\tretryMethods: [\"GET\", \"POST\"],\n\t\tretryStatusCodes: [],\n\t\tretryStrategy: \"linear\",\n\t} satisfies CallApiExtraOptions);\n};\n\nexport const requestOptionDefaults = () => {\n\treturn defineEnum({ method: \"GET\" } satisfies CallApiConfig);\n};\n","import { extraOptionDefaults } from \"./constants/default-options\";\nimport type { CallApiExtraOptions } from \"./types\";\nimport type { StandardSchemaV1 } from \"./types/standard-schema\";\nimport { isObject, isString } from \"./utils/guards\";\n\ntype HTTPErrorDetails<TErrorData> = Pick<CallApiExtraOptions, \"defaultHTTPErrorMessage\"> & {\n\terrorData: TErrorData;\n\tresponse: Response;\n};\n\nconst httpErrorSymbol = Symbol(\"HTTPError\");\n\nexport class HTTPError<TErrorData = Record<string, unknown>> extends Error {\n\terrorData: HTTPErrorDetails<TErrorData>[\"errorData\"];\n\n\thttpErrorSymbol = httpErrorSymbol;\n\n\tisHTTPError = true;\n\n\toverride name = \"HTTPError\" as const;\n\n\tresponse: HTTPErrorDetails<TErrorData>[\"response\"];\n\n\tconstructor(errorDetails: HTTPErrorDetails<TErrorData>, errorOptions?: ErrorOptions) {\n\t\tconst { defaultHTTPErrorMessage, errorData, response } = errorDetails;\n\n\t\tconst resolvedDefaultHTTPErrorMessage =\n\t\t\tisString(defaultHTTPErrorMessage) ? defaultHTTPErrorMessage : (\n\t\t\t\tdefaultHTTPErrorMessage?.({ errorData, response })\n\t\t\t);\n\n\t\tconst selectedDefaultErrorMessage =\n\t\t\tresolvedDefaultHTTPErrorMessage\n\t\t\t?? (response.statusText || extraOptionDefaults().defaultHTTPErrorMessage);\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}\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 override 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\nconst prettifyPath = (path: ValidationError[\"errorData\"][number][\"path\"]) => {\n\tif (!path || path.length === 0) {\n\t\treturn \"\";\n\t}\n\n\tconst pathString = path.map((segment) => (isObject(segment) ? segment.key : segment)).join(\".\");\n\n\treturn ` → at ${pathString}`;\n};\n\nconst prettifyValidationIssues = (issues: ValidationError[\"errorData\"]) => {\n\tconst issuesString = issues\n\t\t.map((issue) => `✖ ${issue.message}${prettifyPath(issue.path)}`)\n\t\t.join(\" | \");\n\n\treturn issuesString;\n};\n\ntype ValidationErrorDetails = {\n\tissues: readonly StandardSchemaV1.Issue[];\n\tresponse: Response | null;\n};\n\nconst validationErrorSymbol = Symbol(\"validationErrorSymbol\");\n\nexport class ValidationError extends Error {\n\terrorData: ValidationErrorDetails[\"issues\"];\n\n\toverride name = \"ValidationError\";\n\n\tresponse: ValidationErrorDetails[\"response\"];\n\n\tvalidationErrorSymbol = validationErrorSymbol;\n\n\tconstructor(details: ValidationErrorDetails, errorOptions?: ErrorOptions) {\n\t\tconst { issues, response } = details;\n\n\t\tconst message = prettifyValidationIssues(issues);\n\n\t\tsuper(message, errorOptions);\n\n\t\tthis.errorData = issues;\n\t\tthis.response = response;\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 override 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","import { HTTPError, ValidationError } from \"../error\";\nimport type {\n\tCallApiResultErrorVariant,\n\tPossibleHTTPError,\n\tPossibleJavaScriptError,\n\tPossibleValidationError,\n} from \"../result\";\nimport type { AnyFunction } from \"../types/type-helpers\";\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\"] | null\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 isJavascriptError = (\n\terror: CallApiResultErrorVariant<unknown>[\"error\"] | null\n): error is PossibleJavaScriptError => {\n\treturn isObject(error) && !isHTTPError(error) && !isValidationError(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 isValidJsonString = (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 { CallApiExtraOptions } 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: CallApiExtraOptions[\"auth\"]\n): Promise<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\tif (bearer === undefined) return;\n\n\t\t\treturn { 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 { extraOptionDefaults } from \"../constants/default-options\";\nimport type { BaseCallApiExtraOptions, CallApiExtraOptions, CallApiRequestOptions } from \"../types/common\";\nimport { isFunction, isPlainObject, isQueryString, isSerializable, isValidJsonString } 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\tbody: CallApiRequestOptions[\"body\"];\n\theaders: CallApiRequestOptions[\"headers\"];\n};\n\nexport const getHeaders = async (options: GetHeadersOptions) => {\n\tconst { auth, body, headers } = options;\n\n\t// == Return early if any of the following conditions are not met (so that native fetch would auto set the correct headers):\n\tconst shouldResolveHeaders = Boolean(headers) || 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(headers),\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) || isValidJsonString(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 ?? extraOptionDefaults().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\nexport const deterministicHashFn = (value: unknown): string => {\n\treturn JSON.stringify(value, (_, val: unknown) => {\n\t\tif (!isPlainObject(val)) {\n\t\t\treturn val;\n\t\t}\n\n\t\tconst sortedKeys = Object.keys(val).sort();\n\n\t\tconst result: Record<string, unknown> = {};\n\n\t\tfor (const key of sortedKeys) {\n\t\t\tresult[key] = val[key];\n\t\t}\n\n\t\treturn result;\n\t});\n};\n"],"mappings":";AAyCA,MAAa,aAAa,CAA8BA,UAAkB;;;;ACtC1E,MAAa,sBAAsB,MAAM;AACxC,QAAO,WAAW;EAEjB,gBAAgB,KAAK;EACrB,yBAAyB;EAIzB,kBAAkB;EAClB,qBAAqB;EACrB,gBAAgB;EAIhB,oBAAoB;EACpB,wBAAwB;EAGxB,gBAAgB,KAAK;EACrB,cAAc;EACd,YAAY;EAGZ,eAAe;EACf,gBAAgB,MAAM;EACtB,YAAY;EACZ,eAAe;EACf,cAAc,CAAC,OAAO,MAAO;EAC7B,kBAAkB,CAAE;EACpB,eAAe;CACf,EAA+B;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BAAuB,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;AAE9F,MAAa,sBAAsB,CAACC,UAA2B;AAC9D,QAAO,KAAK,UAAU,OAAO,CAAC,GAAGC,QAAiB;AACjD,MAAI,CAAC,cAAc,IAAI,CACtB,QAAO;EAGR,MAAM,aAAa,OAAO,KAAK,IAAI,CAAC,MAAM;EAE1C,MAAMC,SAAkC,CAAE;AAE1C,OAAK,MAAM,OAAO,YACjB,OAAO,OAAO,IAAI;AAGnB,SAAO;CACP,EAAC;AACF"}
|
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.9.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",
|
@@ -38,15 +38,15 @@
|
|
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/prettier-config": "^0.9.
|
41
|
+
"@zayne-labs/prettier-config": "^0.9.9",
|
42
42
|
"@zayne-labs/toolkit-type-helpers": "^0.10.6",
|
43
|
-
"@zayne-labs/tsconfig": "0.9.
|
43
|
+
"@zayne-labs/tsconfig": "0.9.9",
|
44
44
|
"concurrently": "^9.2.0",
|
45
45
|
"cross-env": "^10.0.0",
|
46
46
|
"publint": "^0.3.12",
|
47
47
|
"size-limit": "11.2.0",
|
48
|
-
"tsdown": "^0.
|
49
|
-
"typescript": "5.
|
48
|
+
"tsdown": "^0.13.1",
|
49
|
+
"typescript": "5.9.2",
|
50
50
|
"vitest": "^3.2.4"
|
51
51
|
},
|
52
52
|
"publishConfig": {
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"utils-DZe23qYR.js","names":["value: TValue","errorDetails: HTTPErrorDetails<TErrorData>","errorOptions?: ErrorOptions","error: unknown","path: ValidationError[\"errorData\"][number][\"path\"]","issues: ValidationError[\"errorData\"]","details: ValidationErrorDetails","error: CallApiResultErrorVariant<TErrorData>[\"error\"] | null","error: unknown","error: CallApiResultErrorVariant<unknown>[\"error\"] | null","value: unknown","value: ValidAuthValue","auth: CallApiExtraOptions[\"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","value: unknown","val: unknown","result: Record<string, unknown>"],"sources":["../../src/types/type-helpers.ts","../../src/constants/default-options.ts","../../src/error.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\"> =\n\tTObject extends readonly [...infer TTupleItems] ?\n\t\t[\n\t\t\t...{\n\t\t\t\t[Index in keyof TTupleItems]: TLevel extends \"deep\" ? Writeable<TTupleItems[Index], \"deep\">\n\t\t\t\t:\tTTupleItems[Index];\n\t\t\t},\n\t\t]\n\t: TObject extends ArrayOrObject ?\n\t\t{\n\t\t\t-readonly [Key in keyof TObject]: TLevel extends \"deep\" ? Writeable<TObject[Key], \"deep\">\n\t\t\t:\tTObject[Key];\n\t\t}\n\t:\tTObject;\n\nexport const defineEnum = <const TValue extends object>(value: TValue) => value as Writeable<TValue>;\n\nexport type UnionToIntersection<TUnion> =\n\t(TUnion extends unknown ? (param: TUnion) => void : never) extends (param: infer TParam) => void ?\n\t\tTParam\n\t:\tnever;\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 { CallApiConfig, CallApiExtraOptions } from \"../types/common\";\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 CallApiExtraOptions[\"retryMethods\"],\n\tstatusCodes: [] satisfies CallApiExtraOptions[\"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\tdefaultHTTPErrorMessage: \"An unexpected error occurred during the HTTP request.\",\n} satisfies CallApiConfig);\n\nexport const responseDefaults = defineEnum({\n\tresponseParser: JSON.parse,\n\tresponseType: \"json\",\n\tresultMode: \"all\",\n} satisfies CallApiConfig);\n\nexport const hookDefaults = defineEnum({\n\thooksExecutionMode: \"parallel\",\n\thooksRegistrationOrder: \"pluginsFirst\",\n} satisfies CallApiConfig);\n\nexport const dedupeDefaults = defineEnum({\n\tdedupeCacheScope: \"local\",\n\tdedupeCacheScopeKey: \"default\",\n\tdedupeStrategy: \"cancel\",\n} satisfies CallApiConfig);\n\nexport const requestOptionDefaults = defineEnum({\n\tmethod: \"GET\",\n} satisfies CallApiConfig);\n","import { commonDefaults } from \"./constants/default-options\";\nimport type { CallApiExtraOptions } from \"./types\";\nimport type { StandardSchemaV1 } from \"./types/standard-schema\";\nimport { isObject, isString } from \"./utils/guards\";\n\ntype HTTPErrorDetails<TErrorData> = Pick<CallApiExtraOptions, \"defaultHTTPErrorMessage\"> & {\n\terrorData: TErrorData;\n\tresponse: Response;\n};\n\nconst httpErrorSymbol = Symbol(\"HTTPError\");\n\nexport class HTTPError<TErrorData = Record<string, unknown>> extends Error {\n\terrorData: HTTPErrorDetails<TErrorData>[\"errorData\"];\n\n\thttpErrorSymbol = httpErrorSymbol;\n\n\tisHTTPError = true;\n\n\toverride name = \"HTTPError\" as const;\n\n\tresponse: HTTPErrorDetails<TErrorData>[\"response\"];\n\n\tconstructor(errorDetails: HTTPErrorDetails<TErrorData>, errorOptions?: ErrorOptions) {\n\t\tconst { defaultHTTPErrorMessage, errorData, response } = errorDetails;\n\n\t\tconst resolvedDefaultHTTPErrorMessage =\n\t\t\tisString(defaultHTTPErrorMessage) ? defaultHTTPErrorMessage : (\n\t\t\t\tdefaultHTTPErrorMessage?.({ errorData, response })\n\t\t\t);\n\n\t\tconst selectedDefaultErrorMessage =\n\t\t\tresolvedDefaultHTTPErrorMessage\n\t\t\t?? (response.statusText || commonDefaults.defaultHTTPErrorMessage);\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\nconst prettifyPath = (path: ValidationError[\"errorData\"][number][\"path\"]) => {\n\tif (!path || path.length === 0) {\n\t\treturn \"\";\n\t}\n\n\tconst pathString = path.map((segment) => (isObject(segment) ? segment.key : segment)).join(\".\");\n\n\treturn ` → at ${pathString}`;\n};\n\nconst prettifyValidationIssues = (issues: ValidationError[\"errorData\"]) => {\n\tconst issuesString = issues\n\t\t.map((issue) => `✖ ${issue.message}${prettifyPath(issue.path)}`)\n\t\t.join(\" | \");\n\n\treturn issuesString;\n};\n\ntype ValidationErrorDetails = {\n\tissues: readonly StandardSchemaV1.Issue[];\n\tresponse: Response | null;\n};\n\nconst validationErrorSymbol = Symbol(\"validationErrorSymbol\");\n\nexport class ValidationError extends Error {\n\terrorData: ValidationErrorDetails[\"issues\"];\n\n\toverride name = \"ValidationError\";\n\n\tresponse: ValidationErrorDetails[\"response\"];\n\n\tvalidationErrorSymbol = validationErrorSymbol;\n\n\tconstructor(details: ValidationErrorDetails, errorOptions?: ErrorOptions) {\n\t\tconst { issues, response } = details;\n\n\t\tconst message = prettifyValidationIssues(issues);\n\n\t\tsuper(message, errorOptions);\n\n\t\tthis.errorData = 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","import { HTTPError, ValidationError } from \"../error\";\nimport type {\n\tCallApiResultErrorVariant,\n\tPossibleHTTPError,\n\tPossibleJavaScriptError,\n\tPossibleValidationError,\n} from \"../result\";\nimport type { AnyFunction } from \"../types/type-helpers\";\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\"] | null\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 isJavascriptError = (\n\terror: CallApiResultErrorVariant<unknown>[\"error\"] | null\n): error is PossibleJavaScriptError => {\n\treturn isObject(error) && !isHTTPError(error) && !isValidationError(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 isValidJsonString = (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 { CallApiExtraOptions } 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: CallApiExtraOptions[\"auth\"]\n): Promise<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\tif (bearer === undefined) return;\n\n\t\t\treturn { 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 { BaseCallApiExtraOptions, CallApiExtraOptions, CallApiRequestOptions } from \"../types/common\";\nimport { isFunction, isPlainObject, isQueryString, isSerializable, isValidJsonString } 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\tbody: CallApiRequestOptions[\"body\"];\n\theaders: CallApiRequestOptions[\"headers\"];\n};\n\nexport const getHeaders = async (options: GetHeadersOptions) => {\n\tconst { auth, body, headers } = options;\n\n\t// == Return early if any of the following conditions are not met (so that native fetch would auto set the correct headers):\n\tconst shouldResolveHeaders = Boolean(headers) || 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(headers),\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) || isValidJsonString(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\nexport const deterministicHashFn = (value: unknown): string => {\n\treturn JSON.stringify(value, (_, val: unknown) => {\n\t\tif (!isPlainObject(val)) {\n\t\t\treturn val;\n\t\t}\n\n\t\tconst sortedKeys = Object.keys(val).sort();\n\n\t\tconst result: Record<string, unknown> = {};\n\n\t\tfor (const key of sortedKeys) {\n\t\t\tresult[key] = val[key];\n\t\t}\n\n\t\treturn result;\n\t});\n};\n"],"mappings":";AAyCA,MAAa,aAAa,CAA8BA,UAAkB;;;;ACtC1E,MAAa,gBAAgB,WAAW;CACvC,UAAU;CACV,WAAW,MAAM;CACjB,OAAO;CACP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