@zayne-labs/callapi 1.11.11 → 1.11.12

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.
@@ -0,0 +1,204 @@
1
+ import { t as extraOptionDefaults } from "./defaults-BD3B1uIH.js";
2
+
3
+ //#region src/utils/guards.ts
4
+ const isArray = (value) => Array.isArray(value);
5
+ const isBoolean = (value) => typeof value === "boolean";
6
+ const isBlob = (value) => value instanceof Blob;
7
+ const isObject = (value) => {
8
+ return typeof value === "object" && value !== null;
9
+ };
10
+ const hasObjectPrototype = (value) => {
11
+ return Object.prototype.toString.call(value) === "[object Object]";
12
+ };
13
+ /**
14
+ * @description Copied from TanStack Query's isPlainObject
15
+ * @see https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L321
16
+ */
17
+ const isPlainObject = (value) => {
18
+ if (!hasObjectPrototype(value)) return false;
19
+ const constructor = value?.constructor;
20
+ if (constructor === void 0) return true;
21
+ const prototype = constructor.prototype;
22
+ if (!hasObjectPrototype(prototype)) return false;
23
+ if (!Object.hasOwn(prototype, "isPrototypeOf")) return false;
24
+ if (Object.getPrototypeOf(value) !== Object.prototype) return false;
25
+ return true;
26
+ };
27
+ const isValidJsonString = (value) => {
28
+ if (!isString(value)) return false;
29
+ try {
30
+ JSON.parse(value);
31
+ return true;
32
+ } catch {
33
+ return false;
34
+ }
35
+ };
36
+ const isSerializable = (value) => {
37
+ return isPlainObject(value) || isArray(value) || typeof value?.toJSON === "function";
38
+ };
39
+ const isFunction = (value) => typeof value === "function";
40
+ const isQueryString = (value) => isString(value) && value.includes("=");
41
+ const isString = (value) => typeof value === "string";
42
+ const isPromise = (value) => value instanceof Promise;
43
+ const isReadableStream = (value) => {
44
+ return value instanceof ReadableStream;
45
+ };
46
+
47
+ //#endregion
48
+ //#region src/utils/external/error.ts
49
+ const httpErrorSymbol = Symbol("HTTPError");
50
+ var HTTPError = class HTTPError extends Error {
51
+ errorData;
52
+ httpErrorSymbol = httpErrorSymbol;
53
+ name = "HTTPError";
54
+ response;
55
+ constructor(errorDetails, errorOptions) {
56
+ const { defaultHTTPErrorMessage, errorData, response } = errorDetails;
57
+ const selectedDefaultErrorMessage = (isString(defaultHTTPErrorMessage) ? defaultHTTPErrorMessage : defaultHTTPErrorMessage?.({
58
+ errorData,
59
+ response
60
+ })) ?? (response.statusText || extraOptionDefaults.defaultHTTPErrorMessage);
61
+ const message = errorData?.message ?? selectedDefaultErrorMessage;
62
+ super(message, errorOptions);
63
+ this.errorData = errorData;
64
+ this.response = response;
65
+ }
66
+ /**
67
+ * @description Checks if the given error is an instance of HTTPError
68
+ * @param error - The error to check
69
+ * @returns true if the error is an instance of HTTPError, false otherwise
70
+ */
71
+ static isError(error) {
72
+ if (!isObject(error)) return false;
73
+ if (error instanceof HTTPError) return true;
74
+ const actualError = error;
75
+ return actualError.httpErrorSymbol === httpErrorSymbol && actualError.name === "HTTPError";
76
+ }
77
+ };
78
+ const prettifyPath = (path) => {
79
+ if (!path || path.length === 0) return "";
80
+ return ` → at ${path.map((segment) => isObject(segment) ? segment.key : segment).join(".")}`;
81
+ };
82
+ const prettifyValidationIssues = (issues) => {
83
+ return issues.map((issue) => `✖ ${issue.message}${prettifyPath(issue.path)}`).join(" | ");
84
+ };
85
+ const validationErrorSymbol = Symbol("ValidationErrorSymbol");
86
+ var ValidationError = class ValidationError extends Error {
87
+ errorData;
88
+ issueCause;
89
+ name = "ValidationError";
90
+ response;
91
+ validationErrorSymbol = validationErrorSymbol;
92
+ constructor(details, errorOptions) {
93
+ const { issueCause, issues, response } = details;
94
+ const message = prettifyValidationIssues(issues);
95
+ super(message, errorOptions);
96
+ this.errorData = issues;
97
+ this.response = response;
98
+ this.issueCause = issueCause;
99
+ }
100
+ /**
101
+ * @description Checks if the given error is an instance of ValidationError
102
+ * @param error - The error to check
103
+ * @returns true if the error is an instance of ValidationError, false otherwise
104
+ */
105
+ static isError(error) {
106
+ if (!isObject(error)) return false;
107
+ if (error instanceof ValidationError) return true;
108
+ const actualError = error;
109
+ return actualError.validationErrorSymbol === validationErrorSymbol && actualError.name === "ValidationError";
110
+ }
111
+ };
112
+
113
+ //#endregion
114
+ //#region src/utils/external/guards.ts
115
+ const isHTTPError = (error) => {
116
+ return isObject(error) && error.name === "HTTPError";
117
+ };
118
+ const isHTTPErrorInstance = (error) => {
119
+ return HTTPError.isError(error);
120
+ };
121
+ const isValidationError = (error) => {
122
+ return isObject(error) && error.name === "ValidationError";
123
+ };
124
+ const isValidationErrorInstance = (error) => {
125
+ return ValidationError.isError(error);
126
+ };
127
+ const isJavascriptError = (error) => {
128
+ return isObject(error) && !isHTTPError(error) && !isValidationError(error);
129
+ };
130
+
131
+ //#endregion
132
+ //#region src/utils/external/body.ts
133
+ const toQueryString = (query) => {
134
+ if (!query) {
135
+ console.error("toQueryString:", "No query params provided!");
136
+ return null;
137
+ }
138
+ return new URLSearchParams(query).toString();
139
+ };
140
+ const toBlobOrString = (value) => {
141
+ return isBlob(value) ? value : String(value);
142
+ };
143
+ /**
144
+ * @description Converts a plain object to FormData.
145
+ *
146
+ * Handles various data types:
147
+ * - **Primitives** (string, number, boolean): Converted to strings
148
+ * - **Blobs/Files**: Added directly to FormData
149
+ * - **Arrays**: Each item is appended (allows multiple values for same key)
150
+ * - **Objects**: JSON stringified before adding to FormData
151
+ *
152
+ * @example
153
+ * ```ts
154
+ * // Basic usage
155
+ * const formData = toFormData({
156
+ * name: "John",
157
+ * age: 30,
158
+ * active: true
159
+ * });
160
+ *
161
+ * // With arrays
162
+ * const formData = toFormData({
163
+ * tags: ["javascript", "typescript"],
164
+ * name: "John"
165
+ * });
166
+ *
167
+ * // With files
168
+ * const formData = toFormData({
169
+ * avatar: fileBlob,
170
+ * name: "John"
171
+ * });
172
+ *
173
+ * // With nested objects (one level only)
174
+ * const formData = toFormData({
175
+ * user: { name: "John", age: 30 },
176
+ * settings: { theme: "dark" }
177
+ * });
178
+ *
179
+ * // Type-preserving usage with Zod
180
+ * const schema = z.object({ name: z.string(), file: z.instanceof(Blob) });
181
+ * const data = schema.parse({ name: "John", file: blob });
182
+ * const typedFormData = toFormData(data, { returnType: "inputType" });
183
+ * // Type is { name: string; file: Blob }, runtime is FormData
184
+ * ```
185
+ */
186
+ const toFormData = (data) => {
187
+ const formData = new FormData();
188
+ for (const [key, value] of Object.entries(data)) {
189
+ if (isArray(value)) {
190
+ value.forEach((innerValue) => formData.append(key, toBlobOrString(innerValue)));
191
+ continue;
192
+ }
193
+ if (isObject(value) && !isBlob(value)) {
194
+ formData.set(key, JSON.stringify(value));
195
+ continue;
196
+ }
197
+ formData.set(key, toBlobOrString(value));
198
+ }
199
+ return formData;
200
+ };
201
+
202
+ //#endregion
203
+ export { isReadableStream as _, isJavascriptError as a, isValidJsonString as b, HTTPError as c, isBoolean as d, isFunction as f, isQueryString as g, isPromise as h, isHTTPErrorInstance as i, ValidationError as l, isPlainObject as m, toQueryString as n, isValidationError as o, isObject as p, isHTTPError as r, isValidationErrorInstance as s, toFormData as t, isArray as u, isSerializable as v, isString as y };
204
+ //# sourceMappingURL=body-B9WKokQt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"body-B9WKokQt.js","names":["toQueryString: ToQueryStringFn","toFormData: ToFormDataFn"],"sources":["../../src/utils/guards.ts","../../src/utils/external/error.ts","../../src/utils/external/guards.ts","../../src/utils/external/body.ts"],"sourcesContent":["import type { AnyFunction } from \"../types/type-helpers\";\n\nexport const isArray = <TArrayItem>(value: unknown): value is TArrayItem[] => Array.isArray(value);\n\nexport const isBoolean = (value: unknown): value is boolean => typeof value === \"boolean\";\n\nexport const isBlob = (value: unknown): value is Blob => value instanceof Blob;\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 isPromise = (value: unknown) => value instanceof Promise;\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\tvalue?.constructor.name === \"Object\"\n\t\t|| typeof (value as { toJSON: () => unknown } | null)?.toJSON === \"function\"\n\t);\n};\n","import { extraOptionDefaults } from \"../../constants/defaults\";\nimport type { CallApiExtraOptions } from \"../../types\";\nimport type { StandardSchemaV1 } from \"../../types/standard-schema\";\nimport type { CallApiSchema, CallApiSchemaConfig } from \"../../validation\";\nimport { isObject, isString } from \"../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\treadonly httpErrorSymbol = httpErrorSymbol;\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<HTTPError>(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\tconst actualError = error as HTTPError;\n\n\t\treturn (\n\t\t\tactualError.httpErrorSymbol === httpErrorSymbol\n\t\t\t// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- Allow\n\t\t\t&& actualError.name === \"HTTPError\"\n\t\t);\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 SafeExtract<TUnion, TKey extends TUnion> = Extract<TUnion, TKey>;\n\ntype ValidationErrorDetails = {\n\t/**\n\t * The cause of the validation error.\n\t *\n\t * It's either the name the schema for which validation failed, or the name of the schema config option that led to the validation error.\n\t */\n\tissueCause:\n\t\t| \"unknown\"\n\t\t| `schemaConfig-(${SafeExtract<keyof CallApiSchemaConfig, \"strict\">})`\n\t\t| keyof CallApiSchema;\n\n\t/**\n\t * The issues that caused the validation error.\n\t */\n\tissues: readonly StandardSchemaV1.Issue[];\n\n\t/**\n\t * The response from server, if any.\n\t */\n\tresponse: Response | null;\n};\n\nconst validationErrorSymbol = Symbol(\"ValidationErrorSymbol\");\n\nexport class ValidationError extends Error {\n\terrorData: ValidationErrorDetails[\"issues\"];\n\n\tissueCause: ValidationErrorDetails[\"issueCause\"];\n\n\toverride name = \"ValidationError\" as const;\n\n\tresponse: ValidationErrorDetails[\"response\"];\n\n\treadonly validationErrorSymbol = validationErrorSymbol;\n\n\tconstructor(details: ValidationErrorDetails, errorOptions?: ErrorOptions) {\n\t\tconst { issueCause, 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\tthis.issueCause = issueCause;\n\t}\n\n\t/**\n\t * @description Checks if the given error is an instance of ValidationError\n\t * @param error - The error to check\n\t * @returns true if the error is an instance of ValidationError, false otherwise\n\t */\n\tstatic override isError(error: unknown): error is ValidationError {\n\t\tif (!isObject<ValidationError>(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\tconst actualError = error as ValidationError;\n\n\t\treturn (\n\t\t\tactualError.validationErrorSymbol === validationErrorSymbol\n\t\t\t// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- Allow\n\t\t\t&& actualError.name === \"ValidationError\"\n\t\t);\n\t}\n}\n","import type {\n\tCallApiResultErrorVariant,\n\tPossibleHTTPError,\n\tPossibleJavaScriptError,\n\tPossibleValidationError,\n} from \"../../result\";\nimport { isObject } from \"../guards\";\nimport { HTTPError, ValidationError } from \"./error\";\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","import type { CallApiExtraOptions } from \"../../types/common\";\nimport { isArray, isBlob, isObject } from \"../guards\";\n\ntype ToQueryStringFn = {\n\t(query: CallApiExtraOptions[\"query\"]): string | null;\n\t(query: Required<CallApiExtraOptions>[\"query\"]): string;\n};\n\nexport const toQueryString: ToQueryStringFn = (query) => {\n\tif (!query) {\n\t\tconsole.error(\"toQueryString:\", \"No query params provided!\");\n\n\t\treturn null as never;\n\t}\n\n\treturn new URLSearchParams(query as Record<string, string>).toString();\n};\n\ntype AllowedPrimitives = boolean | number | string | Blob;\n\ntype AllowedValues = AllowedPrimitives | AllowedPrimitives[] | Record<string, AllowedPrimitives>;\n\nconst toBlobOrString = (value: AllowedPrimitives): string | Blob => {\n\treturn isBlob(value) ? value : String(value);\n};\n\ntype ToFormDataFn = {\n\t(data: Record<string, AllowedValues>): FormData;\n\n\t<TData extends Record<string, AllowedValues>>(data: TData, options: { returnType: \"inputType\" }): TData;\n};\n\n/**\n * @description Converts a plain object to FormData.\n *\n * Handles various data types:\n * - **Primitives** (string, number, boolean): Converted to strings\n * - **Blobs/Files**: Added directly to FormData\n * - **Arrays**: Each item is appended (allows multiple values for same key)\n * - **Objects**: JSON stringified before adding to FormData\n *\n * @example\n * ```ts\n * // Basic usage\n * const formData = toFormData({\n * name: \"John\",\n * age: 30,\n * active: true\n * });\n *\n * // With arrays\n * const formData = toFormData({\n * tags: [\"javascript\", \"typescript\"],\n * name: \"John\"\n * });\n *\n * // With files\n * const formData = toFormData({\n * avatar: fileBlob,\n * name: \"John\"\n * });\n *\n * // With nested objects (one level only)\n * const formData = toFormData({\n * user: { name: \"John\", age: 30 },\n * settings: { theme: \"dark\" }\n * });\n *\n * // Type-preserving usage with Zod\n * const schema = z.object({ name: z.string(), file: z.instanceof(Blob) });\n * const data = schema.parse({ name: \"John\", file: blob });\n * const typedFormData = toFormData(data, { returnType: \"inputType\" });\n * // Type is { name: string; file: Blob }, runtime is FormData\n * ```\n */\nexport const toFormData: ToFormDataFn = (data: Record<string, AllowedValues>) => {\n\tconst formData = new FormData();\n\n\tfor (const [key, value] of Object.entries(data)) {\n\t\tif (isArray(value)) {\n\t\t\tvalue.forEach((innerValue) => formData.append(key, toBlobOrString(innerValue)));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (isObject(value) && !isBlob(value)) {\n\t\t\tformData.set(key, JSON.stringify(value));\n\t\t\tcontinue;\n\t\t}\n\n\t\tformData.set(key, toBlobOrString(value));\n\t}\n\n\treturn formData;\n};\n"],"mappings":"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"}
@@ -1,3 +1,5 @@
1
+ import { n as fetchSpecificKeys, t as fallBackRouteSchemaKey } from "./validation-uPnlxhfx.js";
2
+
1
3
  //#region src/types/type-helpers.d.ts
2
4
  type AnyString = string & NonNullable<unknown>;
3
5
  type AnyNumber = number & NonNullable<unknown>;
@@ -62,8 +64,69 @@ type CustomAuth = {
62
64
  };
63
65
  type Auth = PossibleAuthValueOrGetter | BearerOrTokenAuth | BasicAuth | CustomAuth;
64
66
  //#endregion
65
- //#region src/constants/common.d.ts
66
- declare const fetchSpecificKeys: readonly (keyof RequestInit | "duplex")[];
67
+ //#region src/utils/external/body.d.ts
68
+ type ToQueryStringFn = {
69
+ (query: CallApiExtraOptions["query"]): string | null;
70
+ (query: Required<CallApiExtraOptions>["query"]): string;
71
+ };
72
+ declare const toQueryString: ToQueryStringFn;
73
+ type AllowedPrimitives = boolean | number | string | Blob;
74
+ type AllowedValues = AllowedPrimitives | AllowedPrimitives[] | Record<string, AllowedPrimitives>;
75
+ type ToFormDataFn = {
76
+ (data: Record<string, AllowedValues>): FormData;
77
+ <TData extends Record<string, AllowedValues>>(data: TData, options: {
78
+ returnType: "inputType";
79
+ }): TData;
80
+ };
81
+ /**
82
+ * @description Converts a plain object to FormData.
83
+ *
84
+ * Handles various data types:
85
+ * - **Primitives** (string, number, boolean): Converted to strings
86
+ * - **Blobs/Files**: Added directly to FormData
87
+ * - **Arrays**: Each item is appended (allows multiple values for same key)
88
+ * - **Objects**: JSON stringified before adding to FormData
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * // Basic usage
93
+ * const formData = toFormData({
94
+ * name: "John",
95
+ * age: 30,
96
+ * active: true
97
+ * });
98
+ *
99
+ * // With arrays
100
+ * const formData = toFormData({
101
+ * tags: ["javascript", "typescript"],
102
+ * name: "John"
103
+ * });
104
+ *
105
+ * // With files
106
+ * const formData = toFormData({
107
+ * avatar: fileBlob,
108
+ * name: "John"
109
+ * });
110
+ *
111
+ * // With nested objects (one level only)
112
+ * const formData = toFormData({
113
+ * user: { name: "John", age: 30 },
114
+ * settings: { theme: "dark" }
115
+ * });
116
+ *
117
+ * // Type-preserving usage with Zod
118
+ * const schema = z.object({ name: z.string(), file: z.instanceof(Blob) });
119
+ * const data = schema.parse({ name: "John", file: blob });
120
+ * const typedFormData = toFormData(data, { returnType: "inputType" });
121
+ * // Type is { name: string; file: Blob }, runtime is FormData
122
+ * ```
123
+ */
124
+ declare const toFormData: ToFormDataFn;
125
+ //#endregion
126
+ //#region src/types/default-types.d.ts
127
+ type DefaultDataType = unknown;
128
+ type DefaultPluginArray = CallApiPlugin[];
129
+ type DefaultThrowOnError = boolean;
67
130
  //#endregion
68
131
  //#region src/types/standard-schema.d.ts
69
132
  /**
@@ -286,8 +349,10 @@ interface URLOptions {
286
349
  }
287
350
  //#endregion
288
351
  //#region src/validation.d.ts
289
- type InferSchemaOutputResult<TSchema$1, TFallbackResult = unknown> = undefined extends TSchema$1 ? TFallbackResult : TSchema$1 extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TSchema$1> : TSchema$1 extends AnyFunction<infer TResult> ? Awaited<TResult> : TFallbackResult;
290
- type InferSchemaInputResult<TSchema$1, TFallbackResult = unknown> = undefined extends TSchema$1 ? TFallbackResult : TSchema$1 extends StandardSchemaV1 ? StandardSchemaV1.InferInput<TSchema$1> : TSchema$1 extends AnyFunction<infer TResult> ? Awaited<TResult> : TFallbackResult;
352
+ type ResultVariant = "infer-input" | "infer-output";
353
+ type InferSchemaResult<TSchema$1, TFallbackResult, TResultVariant extends ResultVariant> = undefined extends TSchema$1 ? TFallbackResult : TSchema$1 extends StandardSchemaV1 ? TResultVariant extends "infer-input" ? StandardSchemaV1.InferInput<TSchema$1> : StandardSchemaV1.InferOutput<TSchema$1> : TSchema$1 extends AnyFunction<infer TResult> ? Awaited<TResult> : TFallbackResult;
354
+ type InferSchemaOutput<TSchema$1, TFallbackResult = unknown> = InferSchemaResult<TSchema$1, TFallbackResult, "infer-output">;
355
+ type InferSchemaInput<TSchema$1, TFallbackResult = unknown> = InferSchemaResult<TSchema$1, TFallbackResult, "infer-input">;
291
356
  interface CallApiSchemaConfig {
292
357
  /**
293
358
  * The base url of the schema. By default it's the baseURL of the callApi instance.
@@ -366,73 +431,8 @@ type BaseCallApiSchemaAndConfig = {
366
431
  config?: CallApiSchemaConfig;
367
432
  routes: BaseCallApiSchemaRoutes;
368
433
  };
369
- declare const fallBackRouteSchemaKey = ".";
370
434
  type FallBackRouteSchemaKey = typeof fallBackRouteSchemaKey;
371
435
  //#endregion
372
- //#region src/utils/external/body.d.ts
373
- type ToQueryStringFn = {
374
- (query: CallApiExtraOptions["query"]): string | null;
375
- (query: Required<CallApiExtraOptions>["query"]): string;
376
- };
377
- declare const toQueryString: ToQueryStringFn;
378
- type AllowedPrimitives = boolean | number | string | Blob;
379
- type AllowedValues = AllowedPrimitives | AllowedPrimitives[] | Record<string, AllowedPrimitives>;
380
- type ToFormDataFn = {
381
- (data: Record<string, AllowedValues>): FormData;
382
- <TData extends Record<string, AllowedValues>>(data: TData, options: {
383
- returnType: "inputType";
384
- }): TData;
385
- };
386
- /**
387
- * @description Converts a plain object to FormData.
388
- *
389
- * Handles various data types:
390
- * - **Primitives** (string, number, boolean): Converted to strings
391
- * - **Blobs/Files**: Added directly to FormData
392
- * - **Arrays**: Each item is appended (allows multiple values for same key)
393
- * - **Objects**: JSON stringified before adding to FormData
394
- *
395
- * @example
396
- * ```ts
397
- * // Basic usage
398
- * const formData = toFormData({
399
- * name: "John",
400
- * age: 30,
401
- * active: true
402
- * });
403
- *
404
- * // With arrays
405
- * const formData = toFormData({
406
- * tags: ["javascript", "typescript"],
407
- * name: "John"
408
- * });
409
- *
410
- * // With files
411
- * const formData = toFormData({
412
- * avatar: fileBlob,
413
- * name: "John"
414
- * });
415
- *
416
- * // With nested objects (one level only)
417
- * const formData = toFormData({
418
- * user: { name: "John", age: 30 },
419
- * settings: { theme: "dark" }
420
- * });
421
- *
422
- * // Type-preserving usage with Zod
423
- * const schema = z.object({ name: z.string(), file: z.instanceof(Blob) });
424
- * const data = schema.parse({ name: "John", file: blob });
425
- * const typedFormData = toFormData(data, { returnType: "inputType" });
426
- * // Type is { name: string; file: Blob }, runtime is FormData
427
- * ```
428
- */
429
- declare const toFormData: ToFormDataFn;
430
- //#endregion
431
- //#region src/types/default-types.d.ts
432
- type DefaultDataType = unknown;
433
- type DefaultPluginArray = CallApiPlugin[];
434
- type DefaultThrowOnError = boolean;
435
- //#endregion
436
436
  //#region src/utils/external/error.d.ts
437
437
  type HTTPErrorDetails<TErrorData$1> = Pick<CallApiExtraOptions, "defaultHTTPErrorMessage"> & {
438
438
  errorData: TErrorData$1;
@@ -867,14 +867,14 @@ type RequestContext = {
867
867
  * made by this client instance, such as baseURL, default headers, and
868
868
  * global options.
869
869
  */
870
- baseConfig: BaseCallApiExtraOptions & CallApiRequestOptions;
870
+ baseConfig: Exclude<BaseCallApiConfig, AnyFunction>;
871
871
  /**
872
872
  * Instance-specific configuration object passed to the callApi instance.
873
873
  *
874
874
  * Contains configuration specific to this particular API call, which
875
875
  * can override or extend the base configuration.
876
876
  */
877
- config: CallApiExtraOptions & CallApiRequestOptions;
877
+ config: CallApiConfig;
878
878
  /**
879
879
  * Merged options combining base config, instance config, and default options.
880
880
  *
@@ -1224,7 +1224,7 @@ interface RetryOptions<TErrorData$1> {
1224
1224
  /**
1225
1225
  * @description Makes a type partial if the output type of TSchema is not provided or has undefined in the union, otherwise makes it required
1226
1226
  */
1227
- type MakeSchemaOptionRequiredIfDefined<TSchemaOption extends CallApiSchema[keyof CallApiSchema], TObject> = undefined extends InferSchemaInputResult<TSchemaOption, undefined> ? TObject : Required<TObject>;
1227
+ type MakeSchemaOptionRequiredIfDefined<TSchemaOption extends CallApiSchema[keyof CallApiSchema], TObject> = undefined extends InferSchemaInput<TSchemaOption, undefined> ? TObject : Required<TObject>;
1228
1228
  type ApplyURLBasedConfig<TSchemaConfig$1 extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig$1["prefix"] extends string ? `${TSchemaConfig$1["prefix"]}${TSchemaRouteKeys}` : TSchemaConfig$1["baseURL"] extends string ? `${TSchemaConfig$1["baseURL"]}${TSchemaRouteKeys}` : TSchemaRouteKeys;
1229
1229
  type ApplyStrictConfig<TSchemaConfig$1 extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig$1["strict"] extends true ? TSchemaRouteKeys :
1230
1230
  // eslint-disable-next-line perfectionist/sort-union-types -- Don't sort union types
@@ -1236,13 +1236,13 @@ type GetCurrentRouteSchemaKey<TSchemaConfig$1 extends CallApiSchemaConfig, TPath
1236
1236
  type GetCurrentRouteSchema<TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TComputedFallBackRouteSchema = TBaseSchemaRoutes$1[FallBackRouteSchemaKey], TComputedCurrentRouteSchema = TBaseSchemaRoutes$1[TCurrentRouteSchemaKey], TComputedRouteSchema extends CallApiSchema = NonNullable<Omit<TComputedFallBackRouteSchema, keyof TComputedCurrentRouteSchema> & TComputedCurrentRouteSchema>> = TComputedRouteSchema extends CallApiSchema ? Writeable<TComputedRouteSchema, "deep"> : CallApiSchema;
1237
1237
  type JsonPrimitive = boolean | number | string | null | undefined;
1238
1238
  type SerializableObject = Record<keyof object, unknown>;
1239
- type SerializableArray = Array<JsonPrimitive | SerializableArray | SerializableObject> | ReadonlyArray<JsonPrimitive | SerializableArray | SerializableObject>;
1239
+ type SerializableArray = Array<JsonPrimitive | SerializableObject> | ReadonlyArray<JsonPrimitive | SerializableObject>;
1240
1240
  type Body = UnmaskType<RequestInit["body"] | SerializableArray | SerializableObject>;
1241
1241
  type InferBodyOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema$1["body"], {
1242
1242
  /**
1243
1243
  * Body of the request, can be a object or any other supported body type.
1244
1244
  */
1245
- body?: InferSchemaInputResult<TSchema$1["body"], Body>;
1245
+ body?: InferSchemaInput<TSchema$1["body"], Body>;
1246
1246
  }>;
1247
1247
  type MethodUnion = UnmaskType<"CONNECT" | "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT" | "TRACE" | AnyString>;
1248
1248
  type InferMethodFromURL<TInitURL> = string extends TInitURL ? MethodUnion : TInitURL extends `@${infer TMethod extends RouteKeyMethods}/${string}` ? Uppercase<TMethod> : MethodUnion;
@@ -1251,16 +1251,16 @@ type InferMethodOption<TSchema$1 extends CallApiSchema, TInitURL> = MakeSchemaOp
1251
1251
  * HTTP method for the request.
1252
1252
  * @default "GET"
1253
1253
  */
1254
- method?: InferSchemaInputResult<TSchema$1["method"], InferMethodFromURL<TInitURL>>;
1254
+ method?: InferSchemaInput<TSchema$1["method"], InferMethodFromURL<TInitURL>>;
1255
1255
  }>;
1256
1256
  type HeadersOption = UnmaskType<Record<"Authorization", CommonAuthorizationHeaders | undefined> | Record<"Content-Type", CommonContentTypes | undefined> | Record<CommonRequestHeaders, string | undefined> | Record<string, string | undefined> | Array<[string, string]>>;
1257
1257
  type InferHeadersOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema$1["headers"], {
1258
1258
  /**
1259
1259
  * Headers to be used in the request.
1260
1260
  */
1261
- headers?: InferSchemaInputResult<TSchema$1["headers"], HeadersOption> | ((context: {
1261
+ headers?: InferSchemaInput<TSchema$1["headers"], HeadersOption> | ((context: {
1262
1262
  baseHeaders: NonNullable<HeadersOption>;
1263
- }) => InferSchemaInputResult<TSchema$1["headers"], HeadersOption>);
1263
+ }) => InferSchemaInput<TSchema$1["headers"], HeadersOption>);
1264
1264
  }>;
1265
1265
  type InferRequestOptions<TSchema$1 extends CallApiSchema, TInitURL extends InferInitURL<BaseCallApiSchemaRoutes, CallApiSchemaConfig>> = InferBodyOption<TSchema$1> & InferHeadersOption<TSchema$1> & InferMethodOption<TSchema$1, TInitURL>;
1266
1266
  interface Register {}
@@ -1291,13 +1291,13 @@ type InferMetaOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequired
1291
1291
  * });
1292
1292
  * ```
1293
1293
  */
1294
- meta?: InferSchemaInputResult<TSchema$1["meta"], GlobalMeta>;
1294
+ meta?: InferSchemaInput<TSchema$1["meta"], GlobalMeta>;
1295
1295
  }>;
1296
1296
  type InferQueryOption<TSchema$1 extends CallApiSchema> = MakeSchemaOptionRequiredIfDefined<TSchema$1["query"], {
1297
1297
  /**
1298
1298
  * Parameters to be appended to the URL (i.e: /:id)
1299
1299
  */
1300
- query?: InferSchemaInputResult<TSchema$1["query"], Query>;
1300
+ query?: InferSchemaInput<TSchema$1["query"], Query>;
1301
1301
  }>;
1302
1302
  type EmptyString = "";
1303
1303
  type EmptyTuple = readonly [];
@@ -1307,15 +1307,15 @@ type ExtractRouteParamNames<TCurrentRoute$1, TParamNamesAccumulator extends Stri
1307
1307
  type ConvertParamNamesToRecord<TParamNames extends StringTuple> = Prettify<TParamNames extends (readonly [infer TFirstParamName extends string, ...infer TRemainingParamNames extends StringTuple]) ? Record<TFirstParamName, AllowedQueryParamValues> & ConvertParamNamesToRecord<TRemainingParamNames> : NonNullable<unknown>>;
1308
1308
  type ConvertParamNamesToTuple<TParamNames extends StringTuple> = TParamNames extends readonly [string, ...infer TRemainingParamNames extends StringTuple] ? [AllowedQueryParamValues, ...ConvertParamNamesToTuple<TRemainingParamNames>] : [];
1309
1309
  type InferParamsFromRoute<TCurrentRoute$1> = ExtractRouteParamNames<TCurrentRoute$1> extends StringTuple ? ExtractRouteParamNames<TCurrentRoute$1> extends EmptyTuple ? Params : ConvertParamNamesToRecord<ExtractRouteParamNames<TCurrentRoute$1>> | ConvertParamNamesToTuple<ExtractRouteParamNames<TCurrentRoute$1>> : Params;
1310
- type MakeParamsOptionRequired<TParamsSchemaOption extends CallApiSchema["params"], TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TObject> = MakeSchemaOptionRequiredIfDefined<TParamsSchemaOption, Params extends InferParamsFromRoute<TCurrentRouteSchemaKey> ? TObject : TCurrentRouteSchemaKey extends Extract<keyof TBaseSchemaRoutes$1, TCurrentRouteSchemaKey> ? undefined extends InferSchemaInputResult<TParamsSchemaOption, null> ? TObject : Required<TObject> : TObject>;
1310
+ type MakeParamsOptionRequired<TParamsSchemaOption extends CallApiSchema["params"], TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TObject> = MakeSchemaOptionRequiredIfDefined<TParamsSchemaOption, Params extends InferParamsFromRoute<TCurrentRouteSchemaKey> ? TObject : TCurrentRouteSchemaKey extends Extract<keyof TBaseSchemaRoutes$1, TCurrentRouteSchemaKey> ? undefined extends InferSchemaInput<TParamsSchemaOption, null> ? TObject : Required<TObject> : TObject>;
1311
1311
  type InferParamsOption<TSchema$1 extends CallApiSchema, TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = MakeParamsOptionRequired<TSchema$1["params"], TBaseSchemaRoutes$1, TCurrentRouteSchemaKey, {
1312
1312
  /**
1313
1313
  * Parameters to be appended to the URL (i.e: /:id)
1314
1314
  */
1315
- params?: InferSchemaInputResult<TSchema$1["params"], InferParamsFromRoute<TCurrentRouteSchemaKey>>;
1315
+ params?: InferSchemaInput<TSchema$1["params"], InferParamsFromRoute<TCurrentRouteSchemaKey>>;
1316
1316
  }>;
1317
1317
  type InferExtraOptions<TSchema$1 extends CallApiSchema, TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = InferMetaOption<TSchema$1> & InferParamsOption<TSchema$1, TBaseSchemaRoutes$1, TCurrentRouteSchemaKey> & InferQueryOption<TSchema$1>;
1318
- type InferPluginOptions<TPluginArray extends CallApiPlugin[]> = UnionToIntersection<TPluginArray extends Array<infer TPlugin> ? TPlugin extends CallApiPlugin ? TPlugin["defineExtraOptions"] extends AnyFunction<infer TReturnedSchema> ? InferSchemaOutputResult<TReturnedSchema> : never : never : never>;
1318
+ type InferPluginOptions<TPluginArray extends CallApiPlugin[]> = UnionToIntersection<TPluginArray extends Array<infer TPlugin> ? TPlugin extends CallApiPlugin ? TPlugin["defineExtraOptions"] extends AnyFunction<infer TReturnedSchema> ? InferSchemaInput<TReturnedSchema> : never : never : never>;
1319
1319
  type ResultModeOption<TErrorData$1, TResultMode extends ResultModeUnion> = TErrorData$1 extends false ? {
1320
1320
  resultMode: "onlyData";
1321
1321
  } : TErrorData$1 extends false | undefined ? {
@@ -1881,5 +1881,5 @@ type CallApiConfig<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataType, TR
1881
1881
  type CallApiParameters<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes = BaseCallApiSchemaRoutes, TSchema$1 extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig$1 extends CallApiSchemaConfig = CallApiSchemaConfig, TInitURL extends InitURLOrURLObject = InitURLOrURLObject, TCurrentRouteSchemaKey extends string = string, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray> = [initURL: TInitURL, config?: CallApiConfig<TData$1, TErrorData$1, TResultMode, TThrowOnError, TResponseType, TBaseSchemaRoutes$1, TSchema$1, TBaseSchemaConfig, TSchemaConfig$1, TInitURL, TCurrentRouteSchemaKey, TBasePluginArray, TPluginArray>];
1882
1882
  type CallApiResult<TData$1, TErrorData$1, TResultMode extends ResultModeUnion, TThrowOnError extends ThrowOnErrorUnion, TResponseType extends ResponseTypeUnion> = GetCallApiResult<TData$1, TErrorData$1, TResultMode, TThrowOnError, TResponseType>;
1883
1883
  //#endregion
1884
- export { GetResponseType as $, RequestStreamContext as A, defineBaseConfig as B, RetryOptions as C, HooksOrHooksArray as D, Hooks as E, isHTTPError as F, CallApiPlugin as G, defineSchema as H, isHTTPErrorInstance as I, PluginSetupContext as J, PluginHooks as K, isJavascriptError as L, ResponseErrorContext as M, ResponseStreamContext as N, PluginExtraOptions as O, SuccessContext as P, GetCallApiResult as Q, isValidationError as R, ThrowOnErrorUnion as S, AnyString as St, ErrorContext as T, defineSchemaConfig as U, definePlugin as V, defineSchemaRoutes as W, CallApiResultSuccessVariant as X, CallApiResultErrorVariant as Y, CallApiSuccessOrErrorVariant as Z, GetCurrentRouteSchema as _, CallApiSchema as _t, CallApiExtraOptions as a, ResponseTypeUnion as at, InferParamsFromRoute as b, fallBackRouteSchemaKey as bt, CallApiRequestOptions as c, HTTPError as ct, GetBaseSchemaConfig as d, DefaultPluginArray as dt, PossibleHTTPError as et, GetBaseSchemaRoutes as f, DefaultThrowOnError as ft, ApplyURLBasedConfig as g, BaseCallApiSchemaRoutes as gt, ApplyStrictConfig as h, BaseCallApiSchemaAndConfig as ht, CallApiConfig as i, ResponseTypeMap as it, ResponseContext as j, RequestContext as k, CallApiRequestOptionsForHooks as l, ValidationError as lt, InferExtendSchemaContext as m, toQueryString as mt, BaseCallApiExtraOptions as n, PossibleJavaScriptOrValidationError as nt, CallApiExtraOptionsForHooks as o, ResultModeMap as ot, InferExtendSchemaConfigContext as p, toFormData as pt, PluginHooksWithMoreOptions as q, BaseInstanceContext as r, PossibleValidationError as rt, CallApiParameters as s, ResultModeUnion as st, BaseCallApiConfig as t, PossibleJavaScriptError as tt, CallApiResult as u, DefaultDataType as ut, GetCurrentRouteSchemaKey as v, CallApiSchemaConfig as vt, DedupeOptions as w, Register as x, URLOptions as xt, InferInitURL as y, InferSchemaOutputResult as yt, isValidationErrorInstance as z };
1885
- //# sourceMappingURL=common-7RMbhCz1.d.ts.map
1884
+ export { GetResponseType as $, RequestStreamContext as A, defineBaseConfig as B, RetryOptions as C, AnyFunction as Ct, HooksOrHooksArray as D, Hooks as E, isHTTPError as F, CallApiPlugin as G, defineSchema as H, isHTTPErrorInstance as I, PluginSetupContext as J, PluginHooks as K, isJavascriptError as L, ResponseErrorContext as M, ResponseStreamContext as N, PluginExtraOptions as O, SuccessContext as P, GetCallApiResult as Q, isValidationError as R, ThrowOnErrorUnion as S, toQueryString as St, ErrorContext as T, defineSchemaConfig as U, definePlugin as V, defineSchemaRoutes as W, CallApiResultSuccessVariant as X, CallApiResultErrorVariant as Y, CallApiSuccessOrErrorVariant as Z, GetCurrentRouteSchema as _, StandardSchemaV1 as _t, CallApiExtraOptions as a, ResponseTypeUnion as at, InferParamsFromRoute as b, DefaultThrowOnError as bt, CallApiRequestOptions as c, HTTPError as ct, GetBaseSchemaConfig as d, BaseCallApiSchemaRoutes as dt, PossibleHTTPError as et, GetBaseSchemaRoutes as f, CallApiSchema as ft, ApplyURLBasedConfig as g, URLOptions as gt, ApplyStrictConfig as h, InferSchemaOutput as ht, CallApiConfig as i, ResponseTypeMap as it, ResponseContext as j, RequestContext as k, CallApiRequestOptionsForHooks as l, ValidationError as lt, InferExtendSchemaContext as m, InferSchemaInput as mt, BaseCallApiExtraOptions as n, PossibleJavaScriptOrValidationError as nt, CallApiExtraOptionsForHooks as o, ResultModeMap as ot, InferExtendSchemaConfigContext as p, CallApiSchemaConfig as pt, PluginHooksWithMoreOptions as q, BaseInstanceContext as r, PossibleValidationError as rt, CallApiParameters as s, ResultModeUnion as st, BaseCallApiConfig as t, PossibleJavaScriptError as tt, CallApiResult as u, BaseCallApiSchemaAndConfig as ut, GetCurrentRouteSchemaKey as v, DefaultDataType as vt, DedupeOptions as w, AnyString as wt, Register as x, toFormData as xt, InferInitURL as y, DefaultPluginArray as yt, isValidationErrorInstance as z };
1885
+ //# sourceMappingURL=common-Clx7i8bR.d.ts.map
@@ -0,0 +1,30 @@
1
+ import { n as fetchSpecificKeys, t as fallBackRouteSchemaKey } from "../validation-uPnlxhfx.js";
2
+
3
+ //#region src/constants/defaults.d.ts
4
+ declare const extraOptionDefaults: Readonly<Readonly<{
5
+ bodySerializer: {
6
+ (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
7
+ (value: any, replacer?: (number | string)[] | null, space?: string | number): string;
8
+ };
9
+ defaultHTTPErrorMessage: string;
10
+ dedupeCacheScope: "local";
11
+ dedupeCacheScopeKey: "default";
12
+ dedupeStrategy: "cancel";
13
+ hooksExecutionMode: "parallel";
14
+ responseParser: (text: string, reviver?: (this: any, key: string, value: any) => any) => any;
15
+ responseType: "json";
16
+ resultMode: "all";
17
+ retryAttempts: number;
18
+ retryCondition: () => true;
19
+ retryDelay: number;
20
+ retryMaxDelay: number;
21
+ retryMethods: ("GET" | "POST")[];
22
+ retryStatusCodes: never[];
23
+ retryStrategy: "linear";
24
+ }>>;
25
+ declare const requestOptionDefaults: Readonly<{
26
+ method: "GET";
27
+ }>;
28
+ //#endregion
29
+ export { extraOptionDefaults, fallBackRouteSchemaKey, fetchSpecificKeys, requestOptionDefaults };
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ import { n as requestOptionDefaults, t as extraOptionDefaults } from "../defaults-BD3B1uIH.js";
2
+ import { n as fetchSpecificKeys, t as fallBackRouteSchemaKey } from "../validation-MjkoG9bG.js";
3
+
4
+ export { extraOptionDefaults, fallBackRouteSchemaKey, fetchSpecificKeys, requestOptionDefaults };
@@ -0,0 +1,28 @@
1
+ //#region src/types/type-helpers.ts
2
+ const defineEnum = (value) => Object.freeze(value);
3
+
4
+ //#endregion
5
+ //#region src/constants/defaults.ts
6
+ const extraOptionDefaults = Object.freeze(defineEnum({
7
+ bodySerializer: JSON.stringify,
8
+ defaultHTTPErrorMessage: "HTTP request failed unexpectedly",
9
+ dedupeCacheScope: "local",
10
+ dedupeCacheScopeKey: "default",
11
+ dedupeStrategy: "cancel",
12
+ hooksExecutionMode: "parallel",
13
+ responseParser: JSON.parse,
14
+ responseType: "json",
15
+ resultMode: "all",
16
+ retryAttempts: 0,
17
+ retryCondition: () => true,
18
+ retryDelay: 1e3,
19
+ retryMaxDelay: 1e4,
20
+ retryMethods: ["GET", "POST"],
21
+ retryStatusCodes: [],
22
+ retryStrategy: "linear"
23
+ }));
24
+ const requestOptionDefaults = defineEnum({ method: "GET" });
25
+
26
+ //#endregion
27
+ export { requestOptionDefaults as n, defineEnum as r, extraOptionDefaults as t };
28
+ //# sourceMappingURL=defaults-BD3B1uIH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults-BD3B1uIH.js","names":[],"sources":["../../src/types/type-helpers.ts","../../src/constants/defaults.ts"],"sourcesContent":["// == These two types allows for adding arbitrary literal types, while still provided autocomplete for defaults.\n\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 Prettify<TObject> = NonNullable<unknown> & { [Key in keyof TObject]: TObject[Key] };\n\ntype 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[] | readonly unknown[];\n\nexport type Writeable<TObject, TLevel extends WriteableLevel = \"shallow\"> =\n\tTObject extends ArrayOrObject ?\n\t\t{\n\t\t\t-readonly [Key in keyof TObject]: TLevel extends \"deep\" ?\n\t\t\t\tNonNullable<TObject[Key]> extends ArrayOrObject ?\n\t\t\t\t\tWriteable<TObject[Key], \"deep\">\n\t\t\t\t:\tTObject[Key]\n\t\t\t:\tTObject[Key];\n\t\t}\n\t:\tTObject;\n\nexport const defineEnum = <const TValue extends object>(value: TValue) =>\n\tObject.freeze(value) as Readonly<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 RemovePrefix<TPrefix extends \"dedupe\" | \"retry\", TKey extends string> =\n\tTKey extends `${TPrefix}${infer TRest}` ? Uncapitalize<TRest> : TKey;\n\nexport type Awaitable<TValue> = Promise<TValue> | TValue;\n\nexport type MatchExactObjectType<TActualObject extends TExpectedObject, TExpectedObject> = {\n\t[Key in keyof TActualObject]: Key extends keyof TExpectedObject ? TActualObject[Key] : never;\n};\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 = Object.freeze(\n\tdefineEnum({\n\t\t// Common defaults\n\t\tbodySerializer: JSON.stringify,\n\t\tdefaultHTTPErrorMessage: \"HTTP request failed unexpectedly\",\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\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 = defineEnum({\n\tmethod: \"GET\",\n} satisfies CallApiConfig);\n"],"mappings":";AAoCA,MAAa,cAA2C,UACvD,OAAO,OAAO,MAAM;;;;AClCrB,MAAa,sBAAsB,OAAO,OACzC,WAAW;CAEV,gBAAgB,KAAK;CACrB,yBAAyB;CAIzB,kBAAkB;CAClB,qBAAqB;CACrB,gBAAgB;CAIhB,oBAAoB;CAGpB,gBAAgB,KAAK;CACrB,cAAc;CACd,YAAY;CAGZ,eAAe;CACf,sBAAsB;CACtB,YAAY;CACZ,eAAe;CACf,cAAc,CAAC,OAAO,OAAO;CAC7B,kBAAkB,EAAE;CACpB,eAAe;CACf,CAA+B,CAChC;AAED,MAAa,wBAAwB,WAAW,EAC/C,QAAQ,OACR,CAAyB"}