@zayne-labs/callapi-plugins 1.0.9 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/package.json +8 -8
package/dist/esm/index.d.ts
CHANGED
@@ -2,7 +2,7 @@ import * as _zayne_labs_callapi0 from "@zayne-labs/callapi";
|
|
2
2
|
import { AnyFunction } from "@zayne-labs/toolkit-type-helpers";
|
3
3
|
|
4
4
|
//#region src/logger/logger.d.ts
|
5
|
-
type
|
5
|
+
type ConsoleLikeObject = {
|
6
6
|
error: AnyFunction<void>;
|
7
7
|
fail?: AnyFunction<void>;
|
8
8
|
log: AnyFunction<void>;
|
@@ -13,7 +13,7 @@ type LoggerOptions = {
|
|
13
13
|
/**
|
14
14
|
* Custom console object
|
15
15
|
*/
|
16
|
-
consoleObject?:
|
16
|
+
consoleObject?: ConsoleLikeObject;
|
17
17
|
/**
|
18
18
|
* Enable or disable the logger
|
19
19
|
* @default true
|
@@ -24,7 +24,7 @@ type LoggerOptions = {
|
|
24
24
|
*/
|
25
25
|
verbose?: boolean;
|
26
26
|
};
|
27
|
-
declare const
|
27
|
+
declare const defaultConsoleObject: ConsoleLikeObject;
|
28
28
|
declare const loggerPlugin: (options?: LoggerOptions) => {
|
29
29
|
id: string;
|
30
30
|
name: string;
|
@@ -65,5 +65,5 @@ declare const loggerPlugin: (options?: LoggerOptions) => {
|
|
65
65
|
};
|
66
66
|
};
|
67
67
|
//#endregion
|
68
|
-
export { LoggerOptions,
|
68
|
+
export { LoggerOptions, defaultConsoleObject, loggerPlugin };
|
69
69
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.js
CHANGED
@@ -79,7 +79,7 @@ const consola = createConsola({ formatOptions: {
|
|
79
79
|
date: false,
|
80
80
|
fancy: true
|
81
81
|
} });
|
82
|
-
const
|
82
|
+
const defaultConsoleObject = {
|
83
83
|
error: (...args) => consola.error("", ...args),
|
84
84
|
fail: (...args) => consola.fail("", ...args),
|
85
85
|
log: (...args) => consola.info("", ...args),
|
@@ -87,7 +87,7 @@ const defaultConsole = {
|
|
87
87
|
warn: (...args) => consola.warn("", ...args)
|
88
88
|
};
|
89
89
|
const loggerPlugin = definePlugin((options) => {
|
90
|
-
const { consoleObject =
|
90
|
+
const { consoleObject = defaultConsoleObject, enabled = true, verbose } = options ?? {};
|
91
91
|
return {
|
92
92
|
id: "logger",
|
93
93
|
name: "Logger",
|
@@ -124,5 +124,5 @@ const loggerPlugin = definePlugin((options) => {
|
|
124
124
|
});
|
125
125
|
|
126
126
|
//#endregion
|
127
|
-
export {
|
127
|
+
export { defaultConsoleObject, loggerPlugin };
|
128
128
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","names":["status: number","
|
1
|
+
{"version":3,"file":"index.js","names":["status: number","defaultConsoleObject: ConsoleLikeObject","options?: LoggerOptions"],"sources":["../../src/logger/constants.ts","../../src/logger/utils.ts","../../src/logger/logger.ts"],"sourcesContent":["export const statusTextMap = new Map<number, string>([\n\t[100, \"Continue\"],\n\t[101, \"Switching Protocols\"],\n\t[102, \"Processing\"],\n\t[200, \"OK\"],\n\t[201, \"Created\"],\n\t[202, \"Accepted\"],\n\t[203, \"Non-Authoritative Information\"],\n\t[204, \"No Content\"],\n\t[205, \"Reset Content\"],\n\t[206, \"Partial Content\"],\n\t[207, \"Multi-Status\"],\n\t[208, \"Already Reported\"],\n\t[226, \"IM Used\"],\n\t[300, \"Multiple Choices\"],\n\t[301, \"Moved Permanently\"],\n\t[302, \"Found\"],\n\t[303, \"See Other\"],\n\t[304, \"Not Modified\"],\n\t[305, \"Use Proxy\"],\n\t[307, \"Temporary Redirect\"],\n\t[308, \"Permanent Redirect\"],\n\t[400, \"Bad Request\"],\n\t[401, \"Unauthorized\"],\n\t[402, \"Payment Required\"],\n\t[403, \"Forbidden\"],\n\t[404, \"Not Found\"],\n\t[405, \"Method Not Allowed\"],\n\t[406, \"Not Acceptable\"],\n\t[407, \"Proxy Authentication Required\"],\n\t[408, \"Request Timeout\"],\n\t[409, \"Conflict\"],\n\t[410, \"Gone\"],\n\t[411, \"Length Required\"],\n\t[412, \"Precondition Failed\"],\n\t[413, \"Payload Too Large\"],\n\t[414, \"URI Too Long\"],\n\t[415, \"Unsupported Media Type\"],\n\t[416, \"Range Not Satisfiable\"],\n\t[417, \"Expectation Failed\"],\n\t[418, \"I'm a teapot\"],\n\t[421, \"Misdirected Request\"],\n\t[422, \"Unprocessable Entity\"],\n\t[423, \"Locked\"],\n\t[424, \"Failed Dependency\"],\n\t[425, \"Too Early\"],\n\t[426, \"Upgrade Required\"],\n\t[428, \"Precondition Required\"],\n\t[429, \"Too Many Requests\"],\n\t[431, \"Request Header Fields Too Large\"],\n\t[451, \"Unavailable For Legal Reasons\"],\n\t[500, \"Internal Server Error\"],\n\t[501, \"Not Implemented\"],\n\t[502, \"Bad Gateway\"],\n\t[503, \"Service Unavailable\"],\n\t[504, \"Gateway Timeout\"],\n\t[505, \"HTTP Version Not Supported\"],\n\t[506, \"Variant Also Negotiates\"],\n\t[507, \"Insufficient Storage\"],\n\t[508, \"Loop Detected\"],\n\t[510, \"Not Extended\"],\n\t[511, \"Network Authentication Required\"],\n]);\n","import { statusTextMap } from \"./constants\";\n\nexport const getStatusText = (status: number) => statusTextMap.get(status) ?? \"Unknown\";\n","import { definePlugin } from \"@zayne-labs/callapi\";\nimport 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?: boolean;\n\t/**\n\t * Enable or disable verbose mode\n\t */\n\tverbose?: boolean;\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 = definePlugin((options?: LoggerOptions) => {\n\tconst { consoleObject = defaultConsoleObject, enabled = true, verbose } = options ?? {};\n\n\treturn {\n\t\t/* eslint-disable perfectionist/sort-objects -- Ignore for now */\n\t\tid: \"logger\",\n\t\tname: \"Logger\",\n\t\tversion: \"1.0.0\",\n\n\t\thooks: {\n\t\t\t/* eslint-enable perfectionist/sort-objects -- Ignore */\n\t\t\tonRequest: (ctx) => {\n\t\t\t\tif (!enabled) 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\tif (!enabled) return;\n\n\t\t\t\tconst log = consoleObject.fail ?? consoleObject.error;\n\n\t\t\t\tlog(`Request to failed with error: ${ctx.error.name}`);\n\n\t\t\t\tverbose && consoleObject.error(ctx.error.errorData);\n\t\t\t},\n\n\t\t\tonResponseError: (ctx) => {\n\t\t\t\tif (!enabled) return;\n\n\t\t\t\tconst log = consoleObject.fail ?? consoleObject.error;\n\n\t\t\t\tlog(\n\t\t\t\t\t\"Request failed with status: \",\n\t\t\t\t\tctx.response.status,\n\t\t\t\t\t`(${ctx.response.statusText || getStatusText(ctx.response.status)})`\n\t\t\t\t);\n\n\t\t\t\tverbose && consoleObject.error(ctx.error.errorData);\n\t\t\t},\n\n\t\t\tonRetry: (ctx) => {\n\t\t\t\tif (!enabled) 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\tif (!enabled) return;\n\n\t\t\t\tconst log = consoleObject.success ?? consoleObject.log;\n\n\t\t\t\tlog(\"Request succeeded\", ctx.data);\n\t\t\t},\n\t\t},\n\t};\n});\n"],"mappings":";;;;AAAA,MAAa,gBAAgB,IAAI,IAAoB;CACpD,CAAC,KAAK,UAAW;CACjB,CAAC,KAAK,qBAAsB;CAC5B,CAAC,KAAK,YAAa;CACnB,CAAC,KAAK,IAAK;CACX,CAAC,KAAK,SAAU;CAChB,CAAC,KAAK,UAAW;CACjB,CAAC,KAAK,+BAAgC;CACtC,CAAC,KAAK,YAAa;CACnB,CAAC,KAAK,eAAgB;CACtB,CAAC,KAAK,iBAAkB;CACxB,CAAC,KAAK,cAAe;CACrB,CAAC,KAAK,kBAAmB;CACzB,CAAC,KAAK,SAAU;CAChB,CAAC,KAAK,kBAAmB;CACzB,CAAC,KAAK,mBAAoB;CAC1B,CAAC,KAAK,OAAQ;CACd,CAAC,KAAK,WAAY;CAClB,CAAC,KAAK,cAAe;CACrB,CAAC,KAAK,WAAY;CAClB,CAAC,KAAK,oBAAqB;CAC3B,CAAC,KAAK,oBAAqB;CAC3B,CAAC,KAAK,aAAc;CACpB,CAAC,KAAK,cAAe;CACrB,CAAC,KAAK,kBAAmB;CACzB,CAAC,KAAK,WAAY;CAClB,CAAC,KAAK,WAAY;CAClB,CAAC,KAAK,oBAAqB;CAC3B,CAAC,KAAK,gBAAiB;CACvB,CAAC,KAAK,+BAAgC;CACtC,CAAC,KAAK,iBAAkB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": "module",
|
4
|
-
"version": "
|
4
|
+
"version": "2.0.0",
|
5
5
|
"description": "A collection of plugins for callapi",
|
6
6
|
"author": "Ryan Zayne",
|
7
7
|
"license": "MIT",
|
@@ -21,7 +21,7 @@
|
|
21
21
|
"peerDependencies": {
|
22
22
|
"@zayne-labs/toolkit-type-helpers": ">=0.9.35",
|
23
23
|
"consola": "^3.4.2",
|
24
|
-
"@zayne-labs/callapi": "1.
|
24
|
+
"@zayne-labs/callapi": "1.9.0"
|
25
25
|
},
|
26
26
|
"devDependencies": {
|
27
27
|
"@arethetypeswrong/cli": "0.18.2",
|
@@ -29,16 +29,16 @@
|
|
29
29
|
"@size-limit/preset-small-lib": "11.2.0",
|
30
30
|
"@total-typescript/ts-reset": "0.6.1",
|
31
31
|
"@zayne-labs/toolkit-type-helpers": "^0.10.6",
|
32
|
-
"@zayne-labs/tsconfig": "0.9.
|
32
|
+
"@zayne-labs/tsconfig": "0.9.9",
|
33
33
|
"concurrently": "^9.2.0",
|
34
34
|
"consola": "3.4.2",
|
35
35
|
"cross-env": "^10.0.0",
|
36
36
|
"publint": "^0.3.12",
|
37
37
|
"size-limit": "11.2.0",
|
38
|
-
"tsdown": "^0.
|
39
|
-
"typescript": "5.
|
38
|
+
"tsdown": "^0.13.1",
|
39
|
+
"typescript": "5.9.2",
|
40
40
|
"vitest": "^3.2.4",
|
41
|
-
"@zayne-labs/callapi": "1.
|
41
|
+
"@zayne-labs/callapi": "1.9.0"
|
42
42
|
},
|
43
43
|
"publishConfig": {
|
44
44
|
"access": "public",
|
@@ -53,8 +53,8 @@
|
|
53
53
|
],
|
54
54
|
"scripts": {
|
55
55
|
"build": "tsdown",
|
56
|
-
"build:dev": "cross-env NODE_ENV=development
|
57
|
-
"build:test": "concurrently --prefix-colors \"yellow.bold,#7da4f8.bold,magenta\" --names PUBLINT,
|
56
|
+
"build:dev": "cross-env NODE_ENV=development tsdown",
|
57
|
+
"build:test": "concurrently --prefix-colors \"yellow.bold,#7da4f8.bold,magenta\" --names PUBLINT,TSDOWN 'pnpm:lint:publint' 'pnpm:build:dev'",
|
58
58
|
"dev": "pnpm build:dev --watch",
|
59
59
|
"lint:attw": "attw --pack . --profile esm-only --format table-flipped --ignore-rules=cjs-resolves-to-esm --ignore-rules=named-exports",
|
60
60
|
"lint:eslint": "pnpm build && pnpm lint:eslint:dev",
|