@zayne-labs/callapi-plugins 4.0.39 → 4.0.41

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.
@@ -1,15 +1,9 @@
1
1
  import { AnyFunction } from "@zayne-labs/toolkit-type-helpers";
2
2
 
3
- //#region ../callapi/dist/validation-Do6HBp6Z.d.ts
3
+ //#region ../callapi/dist/index-CCyp1Rmr.d.ts
4
4
  //#region src/constants/common.d.ts
5
5
  declare const fetchSpecificKeys: readonly (keyof RequestInit | "duplex")[];
6
6
  //#endregion
7
- //#region src/constants/validation.d.ts
8
- declare const fallBackRouteSchemaKey = "@default";
9
- type FallBackRouteSchemaKey = typeof fallBackRouteSchemaKey;
10
- //#endregion
11
- //#endregion
12
- //#region ../callapi/dist/index-DLD315Wj.d.ts
13
7
  //#region src/types/type-helpers.d.ts
14
8
  type AnyString = string & NonNullable<unknown>;
15
9
  type AnyNumber = number & NonNullable<unknown>;
@@ -558,6 +552,10 @@ interface Middlewares<TCallApiContext extends NoInfer<CallApiContext> = DefaultC
558
552
  fetchMiddleware?: (context: FetchMiddlewareContext<TCallApiContext>) => FetchImpl;
559
553
  }
560
554
  //#endregion
555
+ //#region src/constants/validation.d.ts
556
+ declare const fallBackRouteSchemaKey = "@default";
557
+ type FallBackRouteSchemaKey = typeof fallBackRouteSchemaKey;
558
+ //#endregion
561
559
  //#region src/types/standard-schema.d.ts
562
560
  /**
563
561
  * The Standard Schema interface.
@@ -681,40 +679,41 @@ interface CallApiSchemaConfig {
681
679
  */
682
680
  strict?: boolean;
683
681
  }
682
+ type CallApiSchemaType<TInput> = StandardSchemaV1<TInput | undefined> | ((value: TInput) => Awaitable<TInput | undefined>);
684
683
  interface CallApiSchema {
685
- auth?: StandardSchemaV1<AuthOption | undefined> | ((auth: AuthOption) => Awaitable<AuthOption | undefined>);
684
+ auth?: CallApiSchemaType<AuthOption>;
686
685
  /**
687
686
  * The schema to use for validating the request body.
688
687
  */
689
- body?: StandardSchemaV1<Body | undefined> | ((body: Body) => Awaitable<Body | undefined>);
688
+ body?: CallApiSchemaType<Body>;
690
689
  /**
691
690
  * The schema to use for validating the response data.
692
691
  */
693
- data?: StandardSchemaV1 | ((data: unknown) => unknown);
692
+ data?: CallApiSchemaType<unknown>;
694
693
  /**
695
694
  * The schema to use for validating the response error data.
696
695
  */
697
- errorData?: StandardSchemaV1 | ((errorData: unknown) => unknown);
696
+ errorData?: CallApiSchemaType<unknown>;
698
697
  /**
699
698
  * The schema to use for validating the request headers.
700
699
  */
701
- headers?: StandardSchemaV1<HeadersOption | undefined> | ((headers: HeadersOption) => Awaitable<HeadersOption | undefined>);
700
+ headers?: CallApiSchemaType<HeadersOption>;
702
701
  /**
703
702
  * The schema to use for validating the meta option.
704
703
  */
705
- meta?: StandardSchemaV1<GlobalMeta | undefined> | ((meta: GlobalMeta) => Awaitable<GlobalMeta | undefined>);
704
+ meta?: CallApiSchemaType<GlobalMeta>;
706
705
  /**
707
706
  * The schema to use for validating the request method.
708
707
  */
709
- method?: StandardSchemaV1<MethodUnion | undefined> | ((method: MethodUnion) => Awaitable<MethodUnion | undefined>);
708
+ method?: CallApiSchemaType<MethodUnion>;
710
709
  /**
711
710
  * The schema to use for validating the request url parameters.
712
711
  */
713
- params?: StandardSchemaV1<Params | undefined> | ((params: Params) => Awaitable<Params | undefined>);
712
+ params?: CallApiSchemaType<Params>;
714
713
  /**
715
714
  * The schema to use for validating the request url queries.
716
715
  */
717
- query?: StandardSchemaV1<Query | undefined> | ((query: Query) => Awaitable<Query | undefined>);
716
+ query?: CallApiSchemaType<Query>;
718
717
  }
719
718
  declare const routeKeyMethods: readonly ["delete", "get", "patch", "post", "put"];
720
719
  type RouteKeyMethods = (typeof routeKeyMethods)[number];
@@ -733,7 +732,7 @@ type AllowedQueryParamValues = UnmaskType<boolean | number | string>;
733
732
  type RecordStyleParams = UnmaskType<Record<string, AllowedQueryParamValues>>;
734
733
  type TupleStyleParams = UnmaskType<AllowedQueryParamValues[]>;
735
734
  type Params = UnmaskType<RecordStyleParams | TupleStyleParams>;
736
- type Query = UnmaskType<Record<string, AllowedQueryParamValues>>;
735
+ type Query = UnmaskType<Record<string, AllowedQueryParamValues> | URLSearchParams>;
737
736
  type InitURLOrURLObject = AnyString | RouteKeyMethodsURLUnion | URL;
738
737
  interface URLOptions {
739
738
  /**
@@ -859,8 +858,8 @@ type ApplyStrictConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKe
859
858
  // eslint-disable-next-line perfectionist/sort-union-types -- Don't sort union types
860
859
  TSchemaRouteKeys | Exclude<InitURLOrURLObject, RouteKeyMethodsURLUnion>;
861
860
  type ApplySchemaConfiguration<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = ApplyStrictConfig<TSchemaConfig, ApplyURLBasedConfig<TSchemaConfig, TSchemaRouteKeys>>;
862
- type InferAllRouteKeys<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = ApplySchemaConfiguration<TSchemaConfig, Exclude<Extract<keyof TBaseSchemaRoutes, string>, FallBackRouteSchemaKey>>;
863
- type InferInitURL<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = keyof TBaseSchemaRoutes extends never ? InitURLOrURLObject : InferAllRouteKeys<TBaseSchemaRoutes, TSchemaConfig>;
861
+ type InferAllMainRouteKeys<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = ApplySchemaConfiguration<TSchemaConfig, Exclude<Extract<keyof TBaseSchemaRoutes, string>, FallBackRouteSchemaKey>>;
862
+ type InferInitURL<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = keyof TBaseSchemaRoutes extends never ? InitURLOrURLObject : InferAllMainRouteKeys<TBaseSchemaRoutes, TSchemaConfig>;
864
863
  type GetCurrentRouteSchema<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TComputedFallBackRouteSchema = TBaseSchemaRoutes[FallBackRouteSchemaKey], TComputedCurrentRouteSchema = TBaseSchemaRoutes[TCurrentRouteSchemaKey], TComputedRouteSchema extends CallApiSchema = NonNullable<Omit<TComputedFallBackRouteSchema, keyof TComputedCurrentRouteSchema> & TComputedCurrentRouteSchema>> = TComputedRouteSchema extends CallApiSchema ? Writeable<TComputedRouteSchema, "deep"> : CallApiSchema;
865
864
  type JsonPrimitive = boolean | number | string | null | undefined;
866
865
  type SerializableObject = Record<PropertyKey, unknown>;
@@ -1088,7 +1087,7 @@ type ValidationErrorDetails = {
1088
1087
  *
1089
1088
  * 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.
1090
1089
  */
1091
- issueCause: "unknown" | `schemaConfig-(${SafeExtract<keyof CallApiSchemaConfig, "strict">})` | keyof CallApiSchema;
1090
+ issueCause: "toFormData" | "toQueryString" | "unknown" | `schemaConfig-(${SafeExtract<keyof CallApiSchemaConfig, "strict">})` | keyof CallApiSchema;
1092
1091
  /**
1093
1092
  * The issues that caused the validation error.
1094
1093
  */
@@ -1130,7 +1129,7 @@ type FetchSpecificKeysUnion = Exclude<(typeof fetchSpecificKeys)[number], "body"
1130
1129
  type ModifiedRequestInit = RequestInit & {
1131
1130
  duplex?: "half";
1132
1131
  };
1133
- type CallApiRequestOptions = Prettify<{
1132
+ type CallApiRequestOptions = {
1134
1133
  /**
1135
1134
  * Body of the request, can be a object or any other supported body type.
1136
1135
  */
@@ -1144,7 +1143,7 @@ type CallApiRequestOptions = Prettify<{
1144
1143
  * @default "GET"
1145
1144
  */
1146
1145
  method?: MethodUnion;
1147
- } & Pick<ModifiedRequestInit, FetchSpecificKeysUnion>>;
1146
+ } & Pick<ModifiedRequestInit, FetchSpecificKeysUnion>;
1148
1147
  type CallApiRequestOptionsForHooks = Omit<CallApiRequestOptions, "headers"> & {
1149
1148
  headers: Record<string, string | undefined>;
1150
1149
  };
@@ -1174,7 +1173,7 @@ type SharedExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiC
1174
1173
  * ```ts
1175
1174
  * // Custom form data serialization
1176
1175
  * bodySerializer: (data) => {
1177
- * const formData = new URLSearchParams();
1176
+ * const formData = new FormData();
1178
1177
  * Object.entries(data).forEach(([key, value]) => {
1179
1178
  * formData.append(key, String(value));
1180
1179
  * });
@@ -1277,18 +1276,15 @@ type SharedExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiC
1277
1276
  */
1278
1277
  defaultHTTPErrorMessage?: string | ((context: Pick<HTTPError<TErrorData>, "errorData" | "response">) => string);
1279
1278
  /**
1280
- * Forces calculation of total byte size from request/response body streams.
1279
+ * Forces calculation of total byte size from request body streams.
1281
1280
  *
1282
1281
  * Useful when the Content-Length header is missing or incorrect, and you need
1283
- * accurate size information for progress tracking or bandwidth monitoring.
1282
+ * accurate size information for progress tracking.
1284
1283
  *
1285
1284
  * @default false
1286
1285
  *
1287
1286
  */
1288
- forcefullyCalculateStreamSize?: boolean | {
1289
- request?: boolean;
1290
- response?: boolean;
1291
- };
1287
+ forcefullyCalculateRequestStreamSize?: boolean;
1292
1288
  /**
1293
1289
  * Optional metadata field for associating additional information with requests.
1294
1290
  *
@@ -1339,20 +1335,20 @@ type SharedExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiC
1339
1335
  *
1340
1336
  * @example
1341
1337
  * ```ts
1342
- * responseParser: (responseString) => {
1343
- * return JSON.parse(responseString);
1338
+ * responseParser: (text) => {
1339
+ * return JSON.parse(text);
1344
1340
  * }
1345
1341
  *
1346
1342
  * // Parse XML responses
1347
- * responseParser: (responseString) => {
1343
+ * responseParser: (text) => {
1348
1344
  * const parser = new DOMParser();
1349
- * const doc = parser.parseFromString(responseString, "text/xml");
1345
+ * const doc = parser.parseFromString(text, "text/xml");
1350
1346
  * return xmlToObject(doc);
1351
1347
  * }
1352
1348
  *
1353
1349
  * // Parse CSV responses
1354
- * responseParser: (responseString) => {
1355
- * const lines = responseString.split('\n');
1350
+ * responseParser: (text) => {
1351
+ * const lines = text.split('\n');
1356
1352
  * const headers = lines[0].split(',');
1357
1353
  * const data = lines.slice(1).map(line => {
1358
1354
  * const values = line.split(',');
@@ -1366,7 +1362,7 @@ type SharedExtraOptions<TCallApiContext extends CallApiContext = DefaultCallApiC
1366
1362
  *
1367
1363
  * ```
1368
1364
  */
1369
- responseParser?: (responseString: string) => Awaitable<TData>;
1365
+ responseParser?: ResponseParser<TData>;
1370
1366
  /**
1371
1367
  * Expected response type, determines how the response body is parsed.
1372
1368
  *
@@ -1676,16 +1672,16 @@ type BaseCallApiConfig<TBaseCallApiContext extends CallApiContext = DefaultCallA
1676
1672
  type CallApiConfig<TCallApiContext extends CallApiContext = DefaultCallApiContext, TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeType = ResultModeType, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TResponseType extends ResponseTypeType = ResponseTypeType, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes = BaseCallApiSchemaRoutes, TSchema extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TInitURL extends InitURLOrURLObject = InitURLOrURLObject, TCurrentRouteSchemaKey extends string = string, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray> = InferExtraOptions<TSchema, TBaseSchemaRoutes, TCurrentRouteSchemaKey, TCallApiContext> & InferRequestOptions<TSchema, TInitURL> & Omit<CallApiExtraOptions<TCallApiContext, TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TBasePluginArray, TPluginArray, TBaseSchemaRoutes, TSchema, TBaseSchemaConfig, TSchemaConfig, TCurrentRouteSchemaKey>, keyof InferExtraOptions<CallApiSchema, BaseCallApiSchemaRoutes, string, CallApiContext>> & Omit<CallApiRequestOptions, keyof InferRequestOptions<CallApiSchema, string>>;
1677
1673
  //#endregion
1678
1674
  //#region src/result.d.ts
1679
- type Parser<TData> = (responseString: string) => Awaitable<TData>;
1680
- declare const getResponseType: <TResponse>(response: Response, parser: Parser<TResponse>) => {
1675
+ type ResponseParser<TData> = (text: string) => Awaitable<TData>;
1676
+ declare const getResponseType: <TData>(response: Response, responseParser: ResponseParser<TData>) => {
1681
1677
  arrayBuffer: () => Promise<ArrayBuffer>;
1682
1678
  blob: () => Promise<Blob>;
1683
1679
  formData: () => Promise<FormData>;
1684
- json: () => Promise<TResponse>;
1680
+ json: () => Promise<TData>;
1685
1681
  stream: () => ReadableStream<Uint8Array<ArrayBuffer>> | null;
1686
1682
  text: () => Promise<string>;
1687
1683
  };
1688
- type InitResponseTypeMap<TResponse = unknown> = ReturnType<typeof getResponseType<TResponse>>;
1684
+ type InitResponseTypeMap<TData = unknown> = ReturnType<typeof getResponseType<TData>>;
1689
1685
  type ResponseTypeUnion = keyof InitResponseTypeMap;
1690
1686
  type ResponseTypePlaceholder = null;
1691
1687
  type ResponseTypeType = ResponseTypePlaceholder | ResponseTypeUnion;
@@ -1766,7 +1762,7 @@ interface CallApiPlugin<TCallApiContext extends CallApiContext = DefaultCallApiC
1766
1762
  /**
1767
1763
  * Hooks for the plugin
1768
1764
  */
1769
- hooks?: PluginHooks<TCallApiContext> | ((context: PluginSetupContext<TCallApiContext>) => Awaitable<PluginHooks<TCallApiContext>>);
1765
+ hooks?: PluginHooks<TCallApiContext> | ((context: PluginSetupContext<TCallApiContext>) => Awaitable<PluginHooks<TCallApiContext>> | Awaitable<void>);
1770
1766
  /**
1771
1767
  * A unique id for the plugin
1772
1768
  */
@@ -1774,7 +1770,7 @@ interface CallApiPlugin<TCallApiContext extends CallApiContext = DefaultCallApiC
1774
1770
  /**
1775
1771
  * Middlewares that for the plugin
1776
1772
  */
1777
- middlewares?: PluginMiddlewares<TCallApiContext> | ((context: PluginSetupContext<TCallApiContext>) => Awaitable<PluginMiddlewares<TCallApiContext>>);
1773
+ middlewares?: PluginMiddlewares<TCallApiContext> | ((context: PluginSetupContext<TCallApiContext>) => Awaitable<PluginMiddlewares<TCallApiContext>> | Awaitable<void>);
1778
1774
  /**
1779
1775
  * A name for the plugin
1780
1776
  */
@@ -1929,4 +1925,4 @@ declare const loggerPlugin: (options?: LoggerOptions) => {
1929
1925
  };
1930
1926
  //#endregion
1931
1927
  export { defaultConsoleObject as n, loggerPlugin as r, LoggerOptions as t };
1932
- //# sourceMappingURL=index-doc1rAsf.d.ts.map
1928
+ //# sourceMappingURL=index-LJprBgx9.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { n as defaultConsoleObject, r as loggerPlugin, t as LoggerOptions } from "./index-doc1rAsf.js";
1
+ import { n as defaultConsoleObject, r as loggerPlugin, t as LoggerOptions } from "./index-LJprBgx9.js";
2
2
  export { LoggerOptions, defaultConsoleObject, loggerPlugin };
@@ -1,2 +1,2 @@
1
- import { n as defaultConsoleObject, r as loggerPlugin, t as LoggerOptions } from "../../index-doc1rAsf.js";
1
+ import { n as defaultConsoleObject, r as loggerPlugin, t as LoggerOptions } from "../../index-LJprBgx9.js";
2
2
  export { LoggerOptions, defaultConsoleObject, loggerPlugin };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zayne-labs/callapi-plugins",
3
3
  "type": "module",
4
- "version": "4.0.39",
4
+ "version": "4.0.41",
5
5
  "description": "A collection of plugins for callapi",
6
6
  "author": "Ryan Zayne",
7
7
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  "peerDependencies": {
25
25
  "@zayne-labs/toolkit-type-helpers": ">=0.11.17",
26
26
  "consola": "3.x.x",
27
- "@zayne-labs/callapi": "1.11.39"
27
+ "@zayne-labs/callapi": "1.11.41"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@arethetypeswrong/cli": "0.18.2",
@@ -41,7 +41,7 @@
41
41
  "tsdown": "0.19.0-beta.3",
42
42
  "typescript": "5.9.3",
43
43
  "vitest": "^4.0.16",
44
- "@zayne-labs/callapi": "1.11.39"
44
+ "@zayne-labs/callapi": "1.11.41"
45
45
  },
46
46
  "publishConfig": {
47
47
  "access": "public",