@zayne-labs/callapi-plugins 4.0.43 → 4.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index-C01h-7d8.d.ts → index-BBzD4BfV.d.ts} +22 -39
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{logger-7UxwBYul.js → logger-AycKC1q9.js} +1 -1
- package/dist/{logger-7UxwBYul.js.map → logger-AycKC1q9.js.map} +1 -1
- package/dist/plugins/logger/index.d.ts +1 -1
- package/dist/plugins/logger/index.js +1 -1
- package/package.json +11 -10
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { AnyFunction } from "@zayne-labs/toolkit-type-helpers";
|
|
2
2
|
|
|
3
|
-
//#region ../callapi/dist/index-
|
|
3
|
+
//#region ../callapi/dist/index-N6YsZaGN.d.ts
|
|
4
4
|
//#region src/constants/common.d.ts
|
|
5
|
-
declare const fetchSpecificKeys: readonly (keyof RequestInit | "duplex")[];
|
|
6
|
-
//#endregion
|
|
5
|
+
declare const fetchSpecificKeys: readonly (keyof RequestInit | "duplex")[]; //#endregion
|
|
7
6
|
//#region src/types/type-helpers.d.ts
|
|
8
7
|
type AnyString = string & NonNullable<unknown>;
|
|
9
8
|
type AnyNumber = number & NonNullable<unknown>;
|
|
10
|
-
type AnyFunction$1<TResult
|
|
9
|
+
type AnyFunction$1<TResult = unknown> = (...args: any[]) => TResult;
|
|
11
10
|
type Prettify<TObject> = NonNullable<unknown> & { [Key in keyof TObject]: TObject[Key] };
|
|
12
11
|
type WriteableLevel = "deep" | "shallow";
|
|
13
12
|
/**
|
|
@@ -37,8 +36,7 @@ type Awaitable<TValue> = Promise<TValue> | TValue;
|
|
|
37
36
|
type DistributiveOmit<TObject, TKeysToOmit extends keyof TObject> = TObject extends unknown ? Omit<TObject, TKeysToOmit> : never;
|
|
38
37
|
type CommonRequestHeaders = "Access-Control-Allow-Credentials" | "Access-Control-Allow-Headers" | "Access-Control-Allow-Methods" | "Access-Control-Allow-Origin" | "Access-Control-Expose-Headers" | "Access-Control-Max-Age" | "Age" | "Allow" | "Cache-Control" | "Clear-Site-Data" | "Content-Disposition" | "Content-Encoding" | "Content-Language" | "Content-Length" | "Content-Location" | "Content-Range" | "Content-Security-Policy-Report-Only" | "Content-Security-Policy" | "Cookie" | "Cross-Origin-Embedder-Policy" | "Cross-Origin-Opener-Policy" | "Cross-Origin-Resource-Policy" | "Date" | "ETag" | "Expires" | "Last-Modified" | "Location" | "Permissions-Policy" | "Pragma" | "Retry-After" | "Save-Data" | "Sec-CH-Prefers-Color-Scheme" | "Sec-CH-Prefers-Reduced-Motion" | "Sec-CH-UA-Arch" | "Sec-CH-UA-Bitness" | "Sec-CH-UA-Form-Factor" | "Sec-CH-UA-Full-Version-List" | "Sec-CH-UA-Full-Version" | "Sec-CH-UA-Mobile" | "Sec-CH-UA-Model" | "Sec-CH-UA-Platform-Version" | "Sec-CH-UA-Platform" | "Sec-CH-UA-WoW64" | "Sec-CH-UA" | "Sec-Fetch-Dest" | "Sec-Fetch-Mode" | "Sec-Fetch-Site" | "Sec-Fetch-User" | "Sec-GPC" | "Server-Timing" | "Server" | "Service-Worker-Navigation-Preload" | "Set-Cookie" | "Strict-Transport-Security" | "Timing-Allow-Origin" | "Trailer" | "Transfer-Encoding" | "Upgrade" | "Vary" | "Warning" | "WWW-Authenticate" | "X-Content-Type-Options" | "X-DNS-Prefetch-Control" | "X-Frame-Options" | "X-Permitted-Cross-Domain-Policies" | "X-Powered-By" | "X-Robots-Tag" | "X-XSS-Protection" | AnyString;
|
|
39
38
|
type CommonAuthorizationHeaders = `${"Basic" | "Bearer" | "Token"} ${string}`;
|
|
40
|
-
type CommonContentTypes = "application/epub+zip" | "application/gzip" | "application/json" | "application/ld+json" | "application/octet-stream" | "application/ogg" | "application/pdf" | "application/rtf" | "application/vnd.ms-fontobject" | "application/wasm" | "application/xhtml+xml" | "application/xml" | "application/zip" | "audio/aac" | "audio/mpeg" | "audio/ogg" | "audio/opus" | "audio/webm" | "audio/x-midi" | "font/otf" | "font/ttf" | "font/woff" | "font/woff2" | "image/avif" | "image/bmp" | "image/gif" | "image/jpeg" | "image/png" | "image/svg+xml" | "image/tiff" | "image/webp" | "image/x-icon" | "model/gltf-binary" | "model/gltf+json" | "text/calendar" | "text/css" | "text/csv" | "text/html" | "text/javascript" | "text/plain" | "video/3gpp" | "video/3gpp2" | "video/av1" | "video/mp2t" | "video/mp4" | "video/mpeg" | "video/ogg" | "video/webm" | "video/x-msvideo" | AnyString;
|
|
41
|
-
//#endregion
|
|
39
|
+
type CommonContentTypes = "application/epub+zip" | "application/gzip" | "application/json" | "application/ld+json" | "application/octet-stream" | "application/ogg" | "application/pdf" | "application/rtf" | "application/vnd.ms-fontobject" | "application/wasm" | "application/xhtml+xml" | "application/xml" | "application/zip" | "audio/aac" | "audio/mpeg" | "audio/ogg" | "audio/opus" | "audio/webm" | "audio/x-midi" | "font/otf" | "font/ttf" | "font/woff" | "font/woff2" | "image/avif" | "image/bmp" | "image/gif" | "image/jpeg" | "image/png" | "image/svg+xml" | "image/tiff" | "image/webp" | "image/x-icon" | "model/gltf-binary" | "model/gltf+json" | "text/calendar" | "text/css" | "text/csv" | "text/html" | "text/javascript" | "text/plain" | "video/3gpp" | "video/3gpp2" | "video/av1" | "video/mp2t" | "video/mp4" | "video/mpeg" | "video/ogg" | "video/webm" | "video/x-msvideo" | AnyString; //#endregion
|
|
42
40
|
//#region src/auth.d.ts
|
|
43
41
|
type PossibleAuthValue = Awaitable<string | null | undefined>;
|
|
44
42
|
type PossibleAuthValueOrGetter = PossibleAuthValue | (() => PossibleAuthValue);
|
|
@@ -75,8 +73,7 @@ type CustomAuth = {
|
|
|
75
73
|
prefix: PossibleAuthValueOrGetter;
|
|
76
74
|
value: PossibleAuthValueOrGetter;
|
|
77
75
|
};
|
|
78
|
-
type AuthOption = PossibleAuthValueOrGetter | BearerAuth | TokenAuth | BasicAuth | CustomAuth;
|
|
79
|
-
//#endregion
|
|
76
|
+
type AuthOption = PossibleAuthValueOrGetter | BearerAuth | TokenAuth | BasicAuth | CustomAuth; //#endregion
|
|
80
77
|
//#region src/stream.d.ts
|
|
81
78
|
type StreamProgressEvent = {
|
|
82
79
|
/**
|
|
@@ -95,8 +92,7 @@ type StreamProgressEvent = {
|
|
|
95
92
|
* Amount of data transferred so far
|
|
96
93
|
*/
|
|
97
94
|
transferredBytes: number;
|
|
98
|
-
};
|
|
99
|
-
//#endregion
|
|
95
|
+
}; //#endregion
|
|
100
96
|
//#region src/hooks.d.ts
|
|
101
97
|
interface Hooks<TCallApiContext extends CallApiContext = DefaultCallApiContext> {
|
|
102
98
|
/**
|
|
@@ -292,8 +288,7 @@ type RequestStreamContext<TCallApiContext extends Pick<CallApiContext, "Inferred
|
|
|
292
288
|
type ResponseStreamContext<TCallApiContext extends Pick<CallApiContext, "InferredExtraOptions" | "Meta"> = DefaultCallApiContext> = RequestContext<TCallApiContext> & {
|
|
293
289
|
event: StreamProgressEvent;
|
|
294
290
|
response: Response;
|
|
295
|
-
};
|
|
296
|
-
//#endregion
|
|
291
|
+
}; //#endregion
|
|
297
292
|
//#region src/dedupe.d.ts
|
|
298
293
|
type DedupeStrategyUnion = UnmaskType<"cancel" | "defer" | "none">;
|
|
299
294
|
type DedupeOptions = {
|
|
@@ -502,8 +497,7 @@ type DedupeOptions = {
|
|
|
502
497
|
* @default "cancel"
|
|
503
498
|
*/
|
|
504
499
|
dedupeStrategy?: DedupeStrategyUnion | ((context: RequestContext) => DedupeStrategyUnion);
|
|
505
|
-
};
|
|
506
|
-
//#endregion
|
|
500
|
+
}; //#endregion
|
|
507
501
|
//#region src/middlewares.d.ts
|
|
508
502
|
type FetchImpl = UnmaskType<(input: string | Request | URL, init?: RequestInit) => Promise<Response>>;
|
|
509
503
|
type FetchMiddlewareContext<TCallApiContext extends CallApiContext> = RequestContext<TCallApiContext> & {
|
|
@@ -550,12 +544,10 @@ interface Middlewares<TCallApiContext extends NoInfer<CallApiContext> = DefaultC
|
|
|
550
544
|
* ```
|
|
551
545
|
*/
|
|
552
546
|
fetchMiddleware?: (context: FetchMiddlewareContext<TCallApiContext>) => FetchImpl;
|
|
553
|
-
}
|
|
554
|
-
//#endregion
|
|
547
|
+
} //#endregion
|
|
555
548
|
//#region src/constants/validation.d.ts
|
|
556
549
|
declare const fallBackRouteSchemaKey = "@default";
|
|
557
|
-
type FallBackRouteSchemaKey = typeof fallBackRouteSchemaKey;
|
|
558
|
-
//#endregion
|
|
550
|
+
type FallBackRouteSchemaKey = typeof fallBackRouteSchemaKey; //#endregion
|
|
559
551
|
//#region src/types/standard-schema.d.ts
|
|
560
552
|
/**
|
|
561
553
|
* The Standard Schema interface.
|
|
@@ -635,8 +627,7 @@ declare namespace StandardSchemaV1 {
|
|
|
635
627
|
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
636
628
|
/** Infers the output type of a Standard. */
|
|
637
629
|
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
638
|
-
}
|
|
639
|
-
//#endregion
|
|
630
|
+
} //#endregion
|
|
640
631
|
//#region src/validation.d.ts
|
|
641
632
|
type ResultVariant = "infer-input" | "infer-output";
|
|
642
633
|
type InferSchemaResult<TSchema, TFallbackResult, TResultVariant extends ResultVariant> = undefined extends TSchema ? TFallbackResult : TSchema extends StandardSchemaV1 ? TResultVariant extends "infer-input" ? StandardSchemaV1.InferInput<TSchema> : StandardSchemaV1.InferOutput<TSchema> : TSchema extends AnyFunction$1<infer TResult> ? Awaited<TResult> : TFallbackResult;
|
|
@@ -723,8 +714,7 @@ type BaseCallApiSchemaRoutes = Partial<Record<AnyString | BaseSchemaRouteKeyPref
|
|
|
723
714
|
type BaseCallApiSchemaAndConfig = {
|
|
724
715
|
config?: CallApiSchemaConfig;
|
|
725
716
|
routes: BaseCallApiSchemaRoutes;
|
|
726
|
-
};
|
|
727
|
-
//#endregion
|
|
717
|
+
}; //#endregion
|
|
728
718
|
//#region src/url.d.ts
|
|
729
719
|
declare const atSymbol = "@";
|
|
730
720
|
type AtSymbol = typeof atSymbol;
|
|
@@ -845,8 +835,7 @@ interface URLOptions {
|
|
|
845
835
|
* ```
|
|
846
836
|
*/
|
|
847
837
|
query?: Query;
|
|
848
|
-
}
|
|
849
|
-
//#endregion
|
|
838
|
+
} //#endregion
|
|
850
839
|
//#region src/types/conditional-types.d.ts
|
|
851
840
|
/**
|
|
852
841
|
* @description Makes a type partial if the output type of TSchema is not provided or has undefined in the union, otherwise makes it required
|
|
@@ -854,8 +843,7 @@ interface URLOptions {
|
|
|
854
843
|
type MakeSchemaOptionRequiredIfDefined<TSchemaOption extends CallApiSchema[keyof CallApiSchema], TObject> = undefined extends InferSchemaOutput<TSchemaOption, undefined> ? TObject : Required<TObject>;
|
|
855
844
|
type MergeBaseWithRouteKey<TBaseURLOrPrefix extends string | undefined, TRouteKey extends string> = TBaseURLOrPrefix extends string ? TRouteKey extends `${AtSymbol}${infer TMethod extends RouteKeyMethods}/${infer TRestOfRoutKey}` ? `${AtSymbol}${TMethod}/${RemoveLeadingSlash<RemoveTrailingSlash<TBaseURLOrPrefix>>}/${RemoveLeadingSlash<TRestOfRoutKey>}` : `${TBaseURLOrPrefix}${TRouteKey}` : TRouteKey;
|
|
856
845
|
type ApplyURLBasedConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig["prefix"] extends string ? MergeBaseWithRouteKey<TSchemaConfig["prefix"], TSchemaRouteKeys> : TSchemaConfig["baseURL"] extends string ? MergeBaseWithRouteKey<TSchemaConfig["baseURL"], TSchemaRouteKeys> : TSchemaRouteKeys;
|
|
857
|
-
type ApplyStrictConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig["strict"] extends true ? TSchemaRouteKeys :
|
|
858
|
-
// eslint-disable-next-line perfectionist/sort-union-types -- Don't sort union types
|
|
846
|
+
type ApplyStrictConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig["strict"] extends true ? TSchemaRouteKeys : // eslint-disable-next-line perfectionist/sort-union-types -- Don't sort union types
|
|
859
847
|
TSchemaRouteKeys | Exclude<InitURLOrURLObject, RouteKeyMethodsURLUnion>;
|
|
860
848
|
type ApplySchemaConfiguration<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = ApplyStrictConfig<TSchemaConfig, ApplyURLBasedConfig<TSchemaConfig, TSchemaRouteKeys>>;
|
|
861
849
|
type InferAllMainRouteKeys<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = ApplySchemaConfiguration<TSchemaConfig, Exclude<Extract<keyof TBaseSchemaRoutes, string>, FallBackRouteSchemaKey>>;
|
|
@@ -974,10 +962,10 @@ type EmptyString = "";
|
|
|
974
962
|
type EmptyTuple = readonly [];
|
|
975
963
|
type StringTuple = readonly string[];
|
|
976
964
|
type PossibleParamNamePatterns = `${string}:${string}` | `${string}{${string}}${"" | AnyString}`;
|
|
977
|
-
type ExtractRouteParamNames<TCurrentRoute
|
|
965
|
+
type ExtractRouteParamNames<TCurrentRoute, TParamNamesAccumulator extends StringTuple = EmptyTuple> = TCurrentRoute extends PossibleParamNamePatterns ? TCurrentRoute extends `${infer TRoutePrefix}:${infer TParamAndRemainingRoute}` ? TParamAndRemainingRoute extends `${infer TCurrentParam}/${infer TRemainingRoute}` ? TCurrentParam extends EmptyString ? ExtractRouteParamNames<`${TRoutePrefix}/${TRemainingRoute}`, TParamNamesAccumulator> : ExtractRouteParamNames<`${TRoutePrefix}/${TRemainingRoute}`, [...TParamNamesAccumulator, TCurrentParam]> : TParamAndRemainingRoute extends `${infer TCurrentParam}` ? TCurrentParam extends EmptyString ? ExtractRouteParamNames<TRoutePrefix, TParamNamesAccumulator> : ExtractRouteParamNames<TRoutePrefix, [...TParamNamesAccumulator, TCurrentParam]> : ExtractRouteParamNames<TRoutePrefix, TParamNamesAccumulator> : TCurrentRoute extends `${infer TRoutePrefix}{${infer TCurrentParam}}${infer TRemainingRoute}` ? TCurrentParam extends EmptyString ? ExtractRouteParamNames<`${TRoutePrefix}${TRemainingRoute}`, TParamNamesAccumulator> : ExtractRouteParamNames<`${TRoutePrefix}${TRemainingRoute}`, [...TParamNamesAccumulator, TCurrentParam]> : TParamNamesAccumulator : TParamNamesAccumulator;
|
|
978
966
|
type ConvertParamNamesToRecord<TParamNames extends StringTuple> = Prettify<TParamNames extends (readonly [infer TFirstParamName extends string, ...infer TRemainingParamNames extends StringTuple]) ? Record<TFirstParamName, AllowedQueryParamValues> & ConvertParamNamesToRecord<TRemainingParamNames> : NonNullable<unknown>>;
|
|
979
967
|
type ConvertParamNamesToTuple<TParamNames extends StringTuple> = TParamNames extends readonly [string, ...infer TRemainingParamNames extends StringTuple] ? [AllowedQueryParamValues, ...ConvertParamNamesToTuple<TRemainingParamNames>] : [];
|
|
980
|
-
type InferParamsFromRoute<TCurrentRoute
|
|
968
|
+
type InferParamsFromRoute<TCurrentRoute> = ExtractRouteParamNames<TCurrentRoute> extends StringTuple ? ExtractRouteParamNames<TCurrentRoute> extends EmptyTuple ? Params : ConvertParamNamesToRecord<ExtractRouteParamNames<TCurrentRoute>> | ConvertParamNamesToTuple<ExtractRouteParamNames<TCurrentRoute>> : Params;
|
|
981
969
|
type MakeParamsOptionRequired<TParamsSchemaOption extends CallApiSchema["params"], TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TObject> = MakeSchemaOptionRequiredIfDefined<TParamsSchemaOption, Params extends InferParamsFromRoute<TCurrentRouteSchemaKey> ? TObject : TCurrentRouteSchemaKey extends Extract<keyof TBaseSchemaRoutes, TCurrentRouteSchemaKey> ? undefined extends InferSchemaOutput<TParamsSchemaOption, null> ? TObject : Required<TObject> : TObject>;
|
|
982
970
|
type InferParamsOption<TSchema extends CallApiSchema, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = MakeParamsOptionRequired<TSchema["params"], TBaseSchemaRoutes, TCurrentRouteSchemaKey, {
|
|
983
971
|
/**
|
|
@@ -1003,8 +991,7 @@ type ThrowOnErrorOption<TErrorData, TThrowOnError extends ThrowOnErrorBoolean> =
|
|
|
1003
991
|
throwOnError?: true;
|
|
1004
992
|
} : {
|
|
1005
993
|
throwOnError?: ThrowOnErrorType<TErrorData, TThrowOnError>;
|
|
1006
|
-
};
|
|
1007
|
-
//#endregion
|
|
994
|
+
}; //#endregion
|
|
1008
995
|
//#region src/retry.d.ts
|
|
1009
996
|
declare const defaultRetryStatusCodesLookup: () => Readonly<{
|
|
1010
997
|
408: "Request Timeout";
|
|
@@ -1060,8 +1047,7 @@ interface RetryOptions<TErrorData> {
|
|
|
1060
1047
|
* @default "linear"
|
|
1061
1048
|
*/
|
|
1062
1049
|
retryStrategy?: "exponential" | "linear";
|
|
1063
|
-
}
|
|
1064
|
-
//#endregion
|
|
1050
|
+
} //#endregion
|
|
1065
1051
|
//#region src/utils/external/error.d.ts
|
|
1066
1052
|
type HTTPErrorDetails<TErrorData> = Pick<CallApiExtraOptions, "defaultHTTPErrorMessage"> & {
|
|
1067
1053
|
errorData: TErrorData;
|
|
@@ -1110,8 +1096,7 @@ declare class ValidationError extends Error {
|
|
|
1110
1096
|
* @returns true if the error is an instance of ValidationError, false otherwise
|
|
1111
1097
|
*/
|
|
1112
1098
|
static isError(error: unknown): error is ValidationError;
|
|
1113
|
-
}
|
|
1114
|
-
//#endregion
|
|
1099
|
+
} //#endregion
|
|
1115
1100
|
//#region src/types/common.d.ts
|
|
1116
1101
|
interface Register {}
|
|
1117
1102
|
type GlobalMeta = Register extends {
|
|
@@ -1755,8 +1740,7 @@ interface CallApiPlugin<TCallApiContext extends CallApiContext = DefaultCallApiC
|
|
|
1755
1740
|
*/
|
|
1756
1741
|
version?: string;
|
|
1757
1742
|
}
|
|
1758
|
-
type InferPluginExtraOptions<TPluginArray extends CallApiPlugin[]> = UnionToIntersection<TPluginArray extends Array<infer TPlugin> ? TPlugin extends CallApiPlugin ? TPlugin["defineExtraOptions"] extends AnyFunction$1<infer TResult> ? InferSchemaOutput<TResult, TResult> : never : never : never>;
|
|
1759
|
-
//#endregion
|
|
1743
|
+
type InferPluginExtraOptions<TPluginArray extends CallApiPlugin[]> = UnionToIntersection<TPluginArray extends Array<infer TPlugin> ? TPlugin extends CallApiPlugin ? TPlugin["defineExtraOptions"] extends AnyFunction$1<infer TResult> ? InferSchemaOutput<TResult, TResult> : never : never : never>; //#endregion
|
|
1760
1744
|
//#region src/types/default-types.d.ts
|
|
1761
1745
|
type DefaultDataType = unknown;
|
|
1762
1746
|
type DefaultPluginArray = CallApiPlugin[];
|
|
@@ -1764,8 +1748,7 @@ type DefaultThrowOnError = boolean;
|
|
|
1764
1748
|
type DefaultMetaObject = Record<string, unknown>;
|
|
1765
1749
|
type DefaultCallApiContext = Prettify<OverrideCallApiContext<Required<CallApiContext>, {
|
|
1766
1750
|
Meta: GlobalMeta;
|
|
1767
|
-
}>>;
|
|
1768
|
-
//#endregion
|
|
1751
|
+
}>>; //#endregion
|
|
1769
1752
|
//#region src/createFetchClient.d.ts
|
|
1770
1753
|
//#endregion
|
|
1771
1754
|
//#region src/plugins/logger/logger.d.ts
|
|
@@ -1892,4 +1875,4 @@ declare const loggerPlugin: (options?: LoggerOptions) => {
|
|
|
1892
1875
|
};
|
|
1893
1876
|
//#endregion
|
|
1894
1877
|
export { defaultConsoleObject as n, loggerPlugin as r, LoggerOptions as t };
|
|
1895
|
-
//# sourceMappingURL=index-
|
|
1878
|
+
//# sourceMappingURL=index-BBzD4BfV.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-
|
|
1
|
+
import { n as defaultConsoleObject, r as loggerPlugin, t as LoggerOptions } from "./index-BBzD4BfV.js";
|
|
2
2
|
export { LoggerOptions, defaultConsoleObject, loggerPlugin };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger-7UxwBYul.js","names":[],"sources":["../src/plugins/logger/constants.ts","../src/plugins/logger/utils.ts","../src/plugins/logger/logger.ts"],"sourcesContent":["export const getStatusTextMap = () => {\n\treturn new Map<number, string>([\n\t\t[100, \"Continue\"],\n\t\t[101, \"Switching Protocols\"],\n\t\t[102, \"Processing\"],\n\t\t[200, \"OK\"],\n\t\t[201, \"Created\"],\n\t\t[202, \"Accepted\"],\n\t\t[203, \"Non-Authoritative Information\"],\n\t\t[204, \"No Content\"],\n\t\t[205, \"Reset Content\"],\n\t\t[206, \"Partial Content\"],\n\t\t[207, \"Multi-Status\"],\n\t\t[208, \"Already Reported\"],\n\t\t[226, \"IM Used\"],\n\t\t[300, \"Multiple Choices\"],\n\t\t[301, \"Moved Permanently\"],\n\t\t[302, \"Found\"],\n\t\t[303, \"See Other\"],\n\t\t[304, \"Not Modified\"],\n\t\t[305, \"Use Proxy\"],\n\t\t[307, \"Temporary Redirect\"],\n\t\t[308, \"Permanent Redirect\"],\n\t\t[400, \"Bad Request\"],\n\t\t[401, \"Unauthorized\"],\n\t\t[402, \"Payment Required\"],\n\t\t[403, \"Forbidden\"],\n\t\t[404, \"Not Found\"],\n\t\t[405, \"Method Not Allowed\"],\n\t\t[406, \"Not Acceptable\"],\n\t\t[407, \"Proxy Authentication Required\"],\n\t\t[408, \"Request Timeout\"],\n\t\t[409, \"Conflict\"],\n\t\t[410, \"Gone\"],\n\t\t[411, \"Length Required\"],\n\t\t[412, \"Precondition Failed\"],\n\t\t[413, \"Payload Too Large\"],\n\t\t[414, \"URI Too Long\"],\n\t\t[415, \"Unsupported Media Type\"],\n\t\t[416, \"Range Not Satisfiable\"],\n\t\t[417, \"Expectation Failed\"],\n\t\t[418, \"I'm a teapot\"],\n\t\t[421, \"Misdirected Request\"],\n\t\t[422, \"Unprocessable Entity\"],\n\t\t[423, \"Locked\"],\n\t\t[424, \"Failed Dependency\"],\n\t\t[425, \"Too Early\"],\n\t\t[426, \"Upgrade Required\"],\n\t\t[428, \"Precondition Required\"],\n\t\t[429, \"Too Many Requests\"],\n\t\t[431, \"Request Header Fields Too Large\"],\n\t\t[451, \"Unavailable For Legal Reasons\"],\n\t\t[500, \"Internal Server Error\"],\n\t\t[501, \"Not Implemented\"],\n\t\t[502, \"Bad Gateway\"],\n\t\t[503, \"Service Unavailable\"],\n\t\t[504, \"Gateway Timeout\"],\n\t\t[505, \"HTTP Version Not Supported\"],\n\t\t[506, \"Variant Also Negotiates\"],\n\t\t[507, \"Insufficient Storage\"],\n\t\t[508, \"Loop Detected\"],\n\t\t[510, \"Not Extended\"],\n\t\t[511, \"Network Authentication Required\"],\n\t]);\n};\n","import { getStatusTextMap } from \"./constants\";\n\nexport const getStatusText = (status: number) => {\n\tconst statusTextMap = getStatusTextMap();\n\n\tconst statusText = statusTextMap.get(status) ?? \"Unknown\";\n\n\treturn statusText;\n};\n","import { definePlugin } from \"@zayne-labs/callapi/utils\";\nimport { isBoolean, type AnyFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport { createConsola } from \"consola\";\nimport { getStatusText } from \"./utils\";\n\ntype ConsoleLikeObject = {\n\terror: AnyFunction<void>;\n\tfail?: AnyFunction<void>;\n\tlog: AnyFunction<void>;\n\tsuccess?: AnyFunction<void>;\n\twarn?: AnyFunction<void>;\n};\n\nconst consola = createConsola({\n\tformatOptions: {\n\t\tcolors: true,\n\t\tcolumns: 80,\n\t\tcompact: 10,\n\t\tdate: false,\n\t\tfancy: true,\n\t},\n});\n\nexport type LoggerOptions = {\n\t/**\n\t * Custom console object\n\t */\n\tconsoleObject?: ConsoleLikeObject;\n\t/**\n\t * Enable or disable the logger\n\t * @default true\n\t */\n\tenabled?:\n\t\t| boolean\n\t\t| {\n\t\t\t\tonError?: boolean;\n\t\t\t\tonRequest?: boolean;\n\t\t\t\tonRequestError?: boolean;\n\t\t\t\tonResponse?: boolean;\n\t\t\t\tonResponseError?: boolean;\n\t\t\t\tonRetry?: boolean;\n\t\t\t\tonSuccess?: boolean;\n\t\t\t\tonValidationError?: boolean;\n\t\t };\n\t/**\n\t * Enable or disable verbose mode\n\t */\n\tmode?: \"basic\" | \"verbose\";\n};\n\n/* eslint-disable ts-eslint/no-unsafe-argument -- Ignore for now */\nexport const defaultConsoleObject: ConsoleLikeObject = {\n\terror: (...args) => consola.error(\"\", ...args),\n\tfail: (...args) => consola.fail(\"\", ...args),\n\tlog: (...args) => consola.info(\"\", ...args),\n\tsuccess: (...args) => consola.success(\"\", ...args),\n\twarn: (...args) => consola.warn(\"\", ...args),\n};\n/* eslint-enable ts-eslint/no-unsafe-argument -- Ignore for now */\n\nexport const loggerPlugin = (options?: LoggerOptions) => {\n\tconst { consoleObject = defaultConsoleObject, enabled = true, mode = \"basic\" } = options ?? {};\n\n\tconst isBasicMode = mode === \"basic\";\n\tconst isVerboseMode = mode === \"verbose\";\n\n\tconst lineBreak = \"\\n\";\n\n\tconst successLog = consoleObject.success ?? consoleObject.log;\n\n\t// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- Ignore\n\tconst errorLog = consoleObject.error ?? consoleObject.fail ?? consoleObject.log;\n\n\treturn definePlugin({\n\t\t/* eslint-disable perfectionist/sort-objects -- Ignore for now */\n\t\tid: \"logger\",\n\t\tname: \"Logger\",\n\t\tversion: \"1.1.0\",\n\n\t\thooks: {\n\t\t\t/* eslint-enable perfectionist/sort-objects -- Ignore */\n\t\t\tonRequest: (ctx) => {\n\t\t\t\tconst isEnabled = isBoolean(enabled) ? enabled : enabled.onRequest === true;\n\n\t\t\t\tif (!isEnabled) return;\n\n\t\t\t\tconsoleObject.log(`Request being sent to: ${ctx.options.fullURL}`);\n\t\t\t},\n\n\t\t\tonRequestError: (ctx) => {\n\t\t\t\tconst isEnabled =\n\t\t\t\t\tisBoolean(enabled) ? enabled : enabled.onRequestError === true || enabled.onError;\n\n\t\t\t\tif (!isEnabled) return;\n\n\t\t\t\tconst message = [\n\t\t\t\t\t`${ctx.request.method} to '${ctx.options.fullURL}' failed!`,\n\t\t\t\t\t`Reason = ${ctx.error.name}: ${ctx.error.message}`,\n\t\t\t\t].join(lineBreak);\n\n\t\t\t\terrorLog(message);\n\t\t\t},\n\n\t\t\tonResponseError: (ctx) => {\n\t\t\t\tconst isEnabled =\n\t\t\t\t\tisBoolean(enabled) ? enabled : enabled.onResponseError === true || enabled.onError;\n\n\t\t\t\tif (!isEnabled) return;\n\n\t\t\t\tconst message = [\n\t\t\t\t\t`${ctx.request.method} request to '${ctx.options.fullURL}' failed with status: ${ctx.response.status} (${ctx.response.statusText || getStatusText(ctx.response.status)})`,\n\t\t\t\t\t`Reason = \"${ctx.error.name}: ${ctx.error.message}\"`,\n\t\t\t\t].join(lineBreak);\n\n\t\t\t\tisBasicMode && errorLog(message);\n\n\t\t\t\tconst verboseMessage = [message, \"ErrorData: \"].join(lineBreak);\n\n\t\t\t\tisVerboseMode && consoleObject.error(verboseMessage, ctx.error.errorData);\n\t\t\t},\n\n\t\t\tonRetry: (ctx) => {\n\t\t\t\tconst isEnabled = isBoolean(enabled) ? enabled : enabled.onRetry === true;\n\n\t\t\t\tif (!isEnabled) return;\n\n\t\t\t\tconst log = consoleObject.warn ?? consoleObject.log;\n\n\t\t\t\tlog(`Retrying request... Attempt: `, ctx.retryAttemptCount);\n\t\t\t},\n\n\t\t\tonSuccess: (ctx) => {\n\t\t\t\tconst isEnabled = isBoolean(enabled) ? enabled : enabled.onSuccess === true;\n\n\t\t\t\tif (!isEnabled) return;\n\n\t\t\t\tsuccessLog(\"Request succeeded!\", ctx.data);\n\t\t\t},\n\n\t\t\tonValidationError: (ctx) => {\n\t\t\t\tconst isEnabled =\n\t\t\t\t\tisBoolean(enabled) ? enabled : enabled.onValidationError === true || enabled.onError;\n\n\t\t\t\tif (!isEnabled) return;\n\n\t\t\t\tconst getMessage = (limit: number | null = null) => {\n\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\tlimit === null ?\n\t\t\t\t\t\t\tctx.error.message\n\t\t\t\t\t\t:\t`${ctx.error.message.slice(0, limit).trimEnd()}${ctx.error.message.length > limit ? \"...\" : \"\"}`;\n\n\t\t\t\t\treturn [\n\t\t\t\t\t\t`(${ctx.error.issueCause.toUpperCase()}) Validation for request to '${ctx.options.fullURL}' failed!`,\n\t\t\t\t\t\t`${ctx.error.name}: ${errorMessage}`,\n\t\t\t\t\t].join(lineBreak);\n\t\t\t\t};\n\n\t\t\t\tisBasicMode && errorLog(getMessage(150));\n\n\t\t\t\tconst verboseMessage = [getMessage(), \"Issues: \"].join(lineBreak);\n\n\t\t\t\tisVerboseMode && consoleObject.error(verboseMessage, ctx.error.errorData);\n\t\t\t},\n\t\t},\n\t});\n};\n"],"mappings":";;;;;AAAA,MAAa,yBAAyB;AACrC,QAAO,IAAI,IAAoB;EAC9B,CAAC,KAAK,WAAW;EACjB,CAAC,KAAK,sBAAsB;EAC5B,CAAC,KAAK,aAAa;EACnB,CAAC,KAAK,KAAK;EACX,CAAC,KAAK,UAAU;EAChB,CAAC,KAAK,WAAW;EACjB,CAAC,KAAK,gCAAgC;EACtC,CAAC,KAAK,aAAa;EACnB,CAAC,KAAK,gBAAgB;EACtB,CAAC,KAAK,kBAAkB;EACxB,CAAC,KAAK,eAAe;EACrB,CAAC,KAAK,mBAAmB;EACzB,CAAC,KAAK,UAAU;EAChB,CAAC,KAAK,mBAAmB;EACzB,CAAC,KAAK,oBAAoB;EAC1B,CAAC,KAAK,QAAQ;EACd,CAAC,KAAK,YAAY;EAClB,CAAC,KAAK,eAAe;EACrB,CAAC,KAAK,YAAY;EAClB,CAAC,KAAK,qBAAqB;EAC3B,CAAC,KAAK,qBAAqB;EAC3B,CAAC,KAAK,cAAc;EACpB,CAAC,KAAK,eAAe;EACrB,CAAC,KAAK,mBAAmB;EACzB,CAAC,KAAK,YAAY;EAClB,CAAC,KAAK,YAAY;EAClB,CAAC,KAAK,qBAAqB;EAC3B,CAAC,K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,SAAS,QAAQ;IAEhC,MAAM,iBAAiB,CAAC,SAAS,cAAc,CAAC,KAAK,UAAU;AAE/D,qBAAiB,cAAc,MAAM,gBAAgB,IAAI,MAAM,UAAU;;GAG1E,UAAU,QAAQ;AAGjB,QAAI,EAFc,UAAU,QAAQ,GAAG,UAAU,QAAQ,YAAY,MAErD;AAIhB,KAFY,cAAc,QAAQ,cAAc,KAE5C,iCAAiC,IAAI,kBAAkB;;GAG5D,YAAY,QAAQ;AAGnB,QAAI,EAFc,UAAU,QAAQ,GAAG,UAAU,QAAQ,cAAc,MAEvD;AAEhB,eAAW,sBAAsB,IAAI,KAAK;;GAG3C,oBAAoB,QAAQ;AAI3B,QAAI,EAFH,UAAU,QAAQ,GAAG,UAAU,QAAQ,sBAAsB,QAAQ,QAAQ,SAE9D;IAEhB,MAAM,cAAc,QAAuB,SAAS;KACnD,MAAM,eACL,UAAU,OACT,IAAI,MAAM,UACT,GAAG,IAAI,MAAM,QAAQ,MAAM,GAAG,MAAM,CAAC,SAAS,GAAG,IAAI,MAAM,QAAQ,SAAS,QAAQ,QAAQ;AAE/F,YAAO,CACN,IAAI,IAAI,MAAM,WAAW,aAAa,CAAC,+BAA+B,IAAI,QAAQ,QAAQ,YAC1F,GAAG,IAAI,MAAM,KAAK,IAAI,eACtB,CAAC,KAAK,UAAU;;AAGlB,mBAAe,SAAS,WAAW,IAAI,CAAC;IAExC,MAAM,iBAAiB,CAAC,YAAY,EAAE,WAAW,CAAC,KAAK,UAAU;AAEjE,qBAAiB,cAAc,MAAM,gBAAgB,IAAI,MAAM,UAAU;;GAE1E;EACD,CAAC"}
|
|
1
|
+
{"version":3,"file":"logger-AycKC1q9.js","names":[],"sources":["../src/plugins/logger/constants.ts","../src/plugins/logger/utils.ts","../src/plugins/logger/logger.ts"],"sourcesContent":["export const getStatusTextMap = () => {\n\treturn new Map<number, string>([\n\t\t[100, \"Continue\"],\n\t\t[101, \"Switching Protocols\"],\n\t\t[102, \"Processing\"],\n\t\t[200, \"OK\"],\n\t\t[201, \"Created\"],\n\t\t[202, \"Accepted\"],\n\t\t[203, \"Non-Authoritative Information\"],\n\t\t[204, \"No Content\"],\n\t\t[205, \"Reset Content\"],\n\t\t[206, \"Partial Content\"],\n\t\t[207, \"Multi-Status\"],\n\t\t[208, \"Already Reported\"],\n\t\t[226, \"IM Used\"],\n\t\t[300, \"Multiple Choices\"],\n\t\t[301, \"Moved Permanently\"],\n\t\t[302, \"Found\"],\n\t\t[303, \"See Other\"],\n\t\t[304, \"Not Modified\"],\n\t\t[305, \"Use Proxy\"],\n\t\t[307, \"Temporary Redirect\"],\n\t\t[308, \"Permanent Redirect\"],\n\t\t[400, \"Bad Request\"],\n\t\t[401, \"Unauthorized\"],\n\t\t[402, \"Payment Required\"],\n\t\t[403, \"Forbidden\"],\n\t\t[404, \"Not Found\"],\n\t\t[405, \"Method Not Allowed\"],\n\t\t[406, \"Not Acceptable\"],\n\t\t[407, \"Proxy Authentication Required\"],\n\t\t[408, \"Request Timeout\"],\n\t\t[409, \"Conflict\"],\n\t\t[410, \"Gone\"],\n\t\t[411, \"Length Required\"],\n\t\t[412, \"Precondition Failed\"],\n\t\t[413, \"Payload Too Large\"],\n\t\t[414, \"URI Too Long\"],\n\t\t[415, \"Unsupported Media Type\"],\n\t\t[416, \"Range Not Satisfiable\"],\n\t\t[417, \"Expectation Failed\"],\n\t\t[418, \"I'm a teapot\"],\n\t\t[421, \"Misdirected Request\"],\n\t\t[422, \"Unprocessable Entity\"],\n\t\t[423, \"Locked\"],\n\t\t[424, \"Failed Dependency\"],\n\t\t[425, \"Too Early\"],\n\t\t[426, \"Upgrade Required\"],\n\t\t[428, \"Precondition Required\"],\n\t\t[429, \"Too Many Requests\"],\n\t\t[431, \"Request Header Fields Too Large\"],\n\t\t[451, \"Unavailable For Legal Reasons\"],\n\t\t[500, \"Internal Server Error\"],\n\t\t[501, \"Not Implemented\"],\n\t\t[502, \"Bad Gateway\"],\n\t\t[503, \"Service Unavailable\"],\n\t\t[504, \"Gateway Timeout\"],\n\t\t[505, \"HTTP Version Not Supported\"],\n\t\t[506, \"Variant Also Negotiates\"],\n\t\t[507, \"Insufficient Storage\"],\n\t\t[508, \"Loop Detected\"],\n\t\t[510, \"Not Extended\"],\n\t\t[511, \"Network Authentication Required\"],\n\t]);\n};\n","import { getStatusTextMap } from \"./constants\";\n\nexport const getStatusText = (status: number) => {\n\tconst statusTextMap = getStatusTextMap();\n\n\tconst statusText = statusTextMap.get(status) ?? \"Unknown\";\n\n\treturn statusText;\n};\n","import { definePlugin } from \"@zayne-labs/callapi/utils\";\nimport { isBoolean, type AnyFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport { createConsola } from \"consola\";\nimport { getStatusText } from \"./utils\";\n\ntype ConsoleLikeObject = {\n\terror: AnyFunction<void>;\n\tfail?: AnyFunction<void>;\n\tlog: AnyFunction<void>;\n\tsuccess?: AnyFunction<void>;\n\twarn?: AnyFunction<void>;\n};\n\nconst consola = createConsola({\n\tformatOptions: {\n\t\tcolors: true,\n\t\tcolumns: 80,\n\t\tcompact: 10,\n\t\tdate: false,\n\t\tfancy: true,\n\t},\n});\n\nexport type LoggerOptions = {\n\t/**\n\t * Custom console object\n\t */\n\tconsoleObject?: ConsoleLikeObject;\n\t/**\n\t * Enable or disable the logger\n\t * @default true\n\t */\n\tenabled?:\n\t\t| boolean\n\t\t| {\n\t\t\t\tonError?: boolean;\n\t\t\t\tonRequest?: boolean;\n\t\t\t\tonRequestError?: boolean;\n\t\t\t\tonResponse?: boolean;\n\t\t\t\tonResponseError?: boolean;\n\t\t\t\tonRetry?: boolean;\n\t\t\t\tonSuccess?: boolean;\n\t\t\t\tonValidationError?: boolean;\n\t\t };\n\t/**\n\t * Enable or disable verbose mode\n\t */\n\tmode?: \"basic\" | \"verbose\";\n};\n\n/* eslint-disable ts-eslint/no-unsafe-argument -- Ignore for now */\nexport const defaultConsoleObject: ConsoleLikeObject = {\n\terror: (...args) => consola.error(\"\", ...args),\n\tfail: (...args) => consola.fail(\"\", ...args),\n\tlog: (...args) => consola.info(\"\", ...args),\n\tsuccess: (...args) => consola.success(\"\", ...args),\n\twarn: (...args) => consola.warn(\"\", ...args),\n};\n/* eslint-enable ts-eslint/no-unsafe-argument -- Ignore for now */\n\nexport const loggerPlugin = (options?: LoggerOptions) => {\n\tconst { consoleObject = defaultConsoleObject, enabled = true, mode = \"basic\" } = options ?? {};\n\n\tconst isBasicMode = mode === \"basic\";\n\tconst isVerboseMode = mode === \"verbose\";\n\n\tconst lineBreak = \"\\n\";\n\n\tconst successLog = consoleObject.success ?? consoleObject.log;\n\n\t// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- Ignore\n\tconst errorLog = consoleObject.error ?? consoleObject.fail ?? consoleObject.log;\n\n\treturn definePlugin({\n\t\t/* eslint-disable perfectionist/sort-objects -- Ignore for now */\n\t\tid: \"logger\",\n\t\tname: \"Logger\",\n\t\tversion: \"1.1.0\",\n\n\t\thooks: {\n\t\t\t/* eslint-enable perfectionist/sort-objects -- Ignore */\n\t\t\tonRequest: (ctx) => {\n\t\t\t\tconst isEnabled = isBoolean(enabled) ? enabled : enabled.onRequest === true;\n\n\t\t\t\tif (!isEnabled) return;\n\n\t\t\t\tconsoleObject.log(`Request being sent to: ${ctx.options.fullURL}`);\n\t\t\t},\n\n\t\t\tonRequestError: (ctx) => {\n\t\t\t\tconst isEnabled =\n\t\t\t\t\tisBoolean(enabled) ? enabled : enabled.onRequestError === true || enabled.onError;\n\n\t\t\t\tif (!isEnabled) return;\n\n\t\t\t\tconst message = [\n\t\t\t\t\t`${ctx.request.method} to '${ctx.options.fullURL}' failed!`,\n\t\t\t\t\t`Reason = ${ctx.error.name}: ${ctx.error.message}`,\n\t\t\t\t].join(lineBreak);\n\n\t\t\t\terrorLog(message);\n\t\t\t},\n\n\t\t\tonResponseError: (ctx) => {\n\t\t\t\tconst isEnabled =\n\t\t\t\t\tisBoolean(enabled) ? enabled : enabled.onResponseError === true || enabled.onError;\n\n\t\t\t\tif (!isEnabled) return;\n\n\t\t\t\tconst message = [\n\t\t\t\t\t`${ctx.request.method} request to '${ctx.options.fullURL}' failed with status: ${ctx.response.status} (${ctx.response.statusText || getStatusText(ctx.response.status)})`,\n\t\t\t\t\t`Reason = \"${ctx.error.name}: ${ctx.error.message}\"`,\n\t\t\t\t].join(lineBreak);\n\n\t\t\t\tisBasicMode && errorLog(message);\n\n\t\t\t\tconst verboseMessage = [message, \"ErrorData: \"].join(lineBreak);\n\n\t\t\t\tisVerboseMode && consoleObject.error(verboseMessage, ctx.error.errorData);\n\t\t\t},\n\n\t\t\tonRetry: (ctx) => {\n\t\t\t\tconst isEnabled = isBoolean(enabled) ? enabled : enabled.onRetry === true;\n\n\t\t\t\tif (!isEnabled) return;\n\n\t\t\t\tconst log = consoleObject.warn ?? consoleObject.log;\n\n\t\t\t\tlog(`Retrying request... Attempt: `, ctx.retryAttemptCount);\n\t\t\t},\n\n\t\t\tonSuccess: (ctx) => {\n\t\t\t\tconst isEnabled = isBoolean(enabled) ? enabled : enabled.onSuccess === true;\n\n\t\t\t\tif (!isEnabled) return;\n\n\t\t\t\tsuccessLog(\"Request succeeded!\", ctx.data);\n\t\t\t},\n\n\t\t\tonValidationError: (ctx) => {\n\t\t\t\tconst isEnabled =\n\t\t\t\t\tisBoolean(enabled) ? enabled : enabled.onValidationError === true || enabled.onError;\n\n\t\t\t\tif (!isEnabled) return;\n\n\t\t\t\tconst getMessage = (limit: number | null = null) => {\n\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\tlimit === null ?\n\t\t\t\t\t\t\tctx.error.message\n\t\t\t\t\t\t:\t`${ctx.error.message.slice(0, limit).trimEnd()}${ctx.error.message.length > limit ? \"...\" : \"\"}`;\n\n\t\t\t\t\treturn [\n\t\t\t\t\t\t`(${ctx.error.issueCause.toUpperCase()}) Validation for request to '${ctx.options.fullURL}' failed!`,\n\t\t\t\t\t\t`${ctx.error.name}: ${errorMessage}`,\n\t\t\t\t\t].join(lineBreak);\n\t\t\t\t};\n\n\t\t\t\tisBasicMode && errorLog(getMessage(150));\n\n\t\t\t\tconst verboseMessage = [getMessage(), \"Issues: \"].join(lineBreak);\n\n\t\t\t\tisVerboseMode && consoleObject.error(verboseMessage, ctx.error.errorData);\n\t\t\t},\n\t\t},\n\t});\n};\n"],"mappings":";;;;;AAAA,MAAa,yBAAyB;AACrC,QAAO,IAAI,IAAoB;EAC9B,CAAC,KAAK,WAAW;EACjB,CAAC,KAAK,sBAAsB;EAC5B,CAAC,KAAK,aAAa;EACnB,CAAC,KAAK,KAAK;EACX,CAAC,KAAK,UAAU;EAChB,CAAC,KAAK,WAAW;EACjB,CAAC,KAAK,gCAAgC;EACtC,CAAC,KAAK,aAAa;EACnB,CAAC,KAAK,gBAAgB;EACtB,CAAC,KAAK,kBAAkB;EACxB,CAAC,KAAK,eAAe;EACrB,CAAC,KAAK,mBAAmB;EACzB,CAAC,KAAK,UAAU;EAChB,CAAC,KAAK,mBAAmB;EACzB,CAAC,KAAK,oBAAoB;EAC1B,CAAC,KAAK,QAAQ;EACd,CAAC,KAAK,YAAY;EAClB,CAAC,KAAK,eAAe;EACrB,CAAC,KAAK,YAAY;EAClB,CAAC,KAAK,qBAAqB;EAC3B,CAAC,KAAK,qBAAqB;EAC3B,CAAC,KAAK,cAAc;EACpB,CAAC,KAAK,eAAe;EACrB,CAAC,KAAK,mBAAmB;EACzB,CAAC,KAAK,YAAY;EAClB,CAAC,KAAK,YAAY;EAClB,CAAC,KAAK,qBAAqB;EAC3B,CAAC,KAAK,iBAAiB;EACvB,CAAC,KAAK,gCAAgC;EACtC,CAAC,KAAK,kBAAkB;EACxB,CAAC,KAAK,WAAW;EACjB,CAAC,KAAK,OAAO;EACb,CAAC,KAAK,kBAAkB;EACxB,CAAC,KAAK,sBAAsB;EAC5B,CAAC,KAAK,oBAAoB;EAC1B,CAAC,KAAK,eAAe;EACrB,CAAC,KAAK,yBAAyB;EAC/B,CAAC,KAAK,wBAAwB;EAC9B,CAAC,KAAK,q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;AAGnB,QAAI,EAFc,UAAU,QAAQ,GAAG,UAAU,QAAQ,cAAc,MAEvD;AAEhB,eAAW,sBAAsB,IAAI,KAAK;;GAG3C,oBAAoB,QAAQ;AAI3B,QAAI,EAFH,UAAU,QAAQ,GAAG,UAAU,QAAQ,sBAAsB,QAAQ,QAAQ,SAE9D;IAEhB,MAAM,cAAc,QAAuB,SAAS;KACnD,MAAM,eACL,UAAU,OACT,IAAI,MAAM,UACT,GAAG,IAAI,MAAM,QAAQ,MAAM,GAAG,MAAM,CAAC,SAAS,GAAG,IAAI,MAAM,QAAQ,SAAS,QAAQ,QAAQ;AAE/F,YAAO,CACN,IAAI,IAAI,MAAM,WAAW,aAAa,CAAC,+BAA+B,IAAI,QAAQ,QAAQ,YAC1F,GAAG,IAAI,MAAM,KAAK,IAAI,eACtB,CAAC,KAAK,UAAU;;AAGlB,mBAAe,SAAS,WAAW,IAAI,CAAC;IAExC,MAAM,iBAAiB,CAAC,YAAY,EAAE,WAAW,CAAC,KAAK,UAAU;AAEjE,qBAAiB,cAAc,MAAM,gBAAgB,IAAI,MAAM,UAAU;;GAE1E;EACD,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as defaultConsoleObject, r as loggerPlugin, t as LoggerOptions } from "../../index-
|
|
1
|
+
import { n as defaultConsoleObject, r as loggerPlugin, t as LoggerOptions } from "../../index-BBzD4BfV.js";
|
|
2
2
|
export { LoggerOptions, defaultConsoleObject, loggerPlugin };
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zayne-labs/callapi-plugins",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.45",
|
|
5
5
|
"description": "A collection of plugins for callapi",
|
|
6
6
|
"author": "Ryan Zayne",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"homepage": "https://github.com/zayne-labs/callapi#readme",
|
|
8
|
+
"homepage": "https://github.com/zayne-labs/callapi/tree/main/packages/callapi-plugins#readme",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/zayne-labs/callapi.git"
|
|
11
|
+
"url": "git+https://github.com/zayne-labs/callapi.git",
|
|
12
|
+
"directory": "packages/callapi-plugins"
|
|
12
13
|
},
|
|
13
14
|
"sideEffects": false,
|
|
14
15
|
"exports": {
|
|
@@ -24,24 +25,24 @@
|
|
|
24
25
|
"peerDependencies": {
|
|
25
26
|
"@zayne-labs/toolkit-type-helpers": ">=0.11.17",
|
|
26
27
|
"consola": "3.x.x",
|
|
27
|
-
"@zayne-labs/callapi": "1.11.
|
|
28
|
+
"@zayne-labs/callapi": "1.11.45"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@arethetypeswrong/cli": "0.18.2",
|
|
31
32
|
"@size-limit/esbuild-why": "12.0.0",
|
|
32
33
|
"@size-limit/preset-small-lib": "12.0.0",
|
|
33
34
|
"@total-typescript/ts-reset": "0.6.1",
|
|
34
|
-
"@zayne-labs/toolkit-type-helpers": "^0.12.
|
|
35
|
-
"@zayne-labs/tsconfig": "0.11.
|
|
35
|
+
"@zayne-labs/toolkit-type-helpers": "^0.12.30",
|
|
36
|
+
"@zayne-labs/tsconfig": "0.11.21",
|
|
36
37
|
"concurrently": "^9.2.1",
|
|
37
38
|
"consola": "3.4.2",
|
|
38
39
|
"cross-env": "^10.1.0",
|
|
39
|
-
"publint": "^0.3.
|
|
40
|
+
"publint": "^0.3.17",
|
|
40
41
|
"size-limit": "12.0.0",
|
|
41
|
-
"tsdown": "0.
|
|
42
|
+
"tsdown": "0.20.1",
|
|
42
43
|
"typescript": "5.9.3",
|
|
43
|
-
"vitest": "^4.0.
|
|
44
|
-
"@zayne-labs/callapi": "1.11.
|
|
44
|
+
"vitest": "^4.0.18",
|
|
45
|
+
"@zayne-labs/callapi": "1.11.45"
|
|
45
46
|
},
|
|
46
47
|
"publishConfig": {
|
|
47
48
|
"access": "public",
|