@arkstack/common 0.3.9 → 0.3.11

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.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /// <reference path="./app.d.ts" />
2
2
  import { DotPath } from "@h3ravel/support";
3
+ import pino from "pino";
3
4
  import { ChalkInstance } from "chalk";
4
5
 
5
6
  //#region src/lifecycle.d.ts
@@ -77,6 +78,21 @@ interface GlobalConfig {
77
78
  <X extends Record<string, any>, P extends DotPath<X>>(key: P): DotPathValue<X, P>;
78
79
  <X extends Record<string, any>, P extends DotPath<X>, D>(key: P, defaultValue: D): DotPathValue<X, P> | D;
79
80
  }
81
+ type ArkstackErrorShape = Error & {
82
+ cause?: unknown;
83
+ code?: number | string;
84
+ errors?: unknown;
85
+ getModelName?: () => string;
86
+ status?: number;
87
+ statusCode?: number;
88
+ };
89
+ interface ArkstackErrorPayload {
90
+ status: 'error';
91
+ code: number;
92
+ message: string;
93
+ errors?: unknown;
94
+ stack?: string;
95
+ }
80
96
  //#endregion
81
97
  //#region src/system.d.ts
82
98
  declare const env: GlobalEnv;
@@ -84,6 +100,21 @@ declare const appUrl: (link?: string) => string;
84
100
  declare const config: GlobalConfig;
85
101
  declare const nodeEnv: () => "prod" | "dev";
86
102
  declare const outputDir: (cwd?: string) => string;
103
+ declare const importFile: <T = unknown>(filePath: string) => Promise<T>;
104
+ //#endregion
105
+ //#region src/error-handling.d.ts
106
+ declare const toErrorShape: (value: unknown) => ArkstackErrorShape | undefined;
107
+ declare const normalizeStatusCode: (value: unknown, fallback?: number) => number;
108
+ declare const getErrorLogger: () => pino.Logger;
109
+ declare const serializeError: (value: unknown, seen?: WeakSet<object>) => unknown;
110
+ declare const getPrimaryError: (error: ArkstackErrorShape | string) => string | ArkstackErrorShape;
111
+ declare const getValidationErrors: (error: ArkstackErrorShape) => any;
112
+ declare const isValidationError: (error: unknown) => error is ArkstackErrorShape;
113
+ declare const isModelNotFoundError: (error: unknown) => error is ArkstackErrorShape;
114
+ declare const shouldHideStack: () => boolean;
115
+ declare const shouldLogError: (error: unknown) => boolean;
116
+ declare const createErrorPayload: (err: ArkstackErrorShape | string, fallbackMessage?: string) => ArkstackErrorPayload;
117
+ declare const logUnhandledError: (err: unknown, request: Record<string, unknown>, message: string) => void;
87
118
  //#endregion
88
- export { DotPathValue, GlobalConfig, GlobalEnv, Logger, LoggerChalk, LoggerLog, LoggerParseSignature, appUrl, bindGracefulShutdown, bootWithDetectedPort, buildHtmlErrorResponse, config, env, loadPrototypes, nodeEnv, outputDir };
119
+ export { ArkstackErrorPayload, ArkstackErrorShape, DotPathValue, GlobalConfig, GlobalEnv, Logger, LoggerChalk, LoggerLog, LoggerParseSignature, appUrl, bindGracefulShutdown, bootWithDetectedPort, buildHtmlErrorResponse, config, createErrorPayload, env, getErrorLogger, getPrimaryError, getValidationErrors, importFile, isModelNotFoundError, isValidationError, loadPrototypes, logUnhandledError, nodeEnv, normalizeStatusCode, outputDir, serializeError, shouldHideStack, shouldLogError, toErrorShape };
89
120
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,8 +1,11 @@
1
1
  import { Obj } from "@h3ravel/support";
2
+ import { createJiti } from "@rexxars/jiti";
2
3
  import { createRequire } from "module";
3
- import path from "node:path";
4
+ import path, { resolve } from "node:path";
5
+ import { pathToFileURL } from "node:url";
4
6
  import { readdirSync } from "fs";
5
7
  import { detect } from "detect-port";
8
+ import pino from "pino";
6
9
  import chalk from "chalk";
7
10
 
8
11
  //#region src/lifecycle.ts
@@ -112,6 +115,13 @@ const outputDir = (cwd = process.cwd()) => {
112
115
  };
113
116
  return path.isAbsolute(output[NODE_ENV] ?? output.dev) ? output[NODE_ENV] ?? output.dev : path.join(cwd, output[NODE_ENV] ?? output.dev);
114
117
  };
118
+ const importFile = async (filePath) => {
119
+ const resolvedPath = resolve(filePath);
120
+ return await createJiti(pathToFileURL(resolvedPath).href, {
121
+ interopDefault: false,
122
+ tsconfigPaths: true
123
+ }).import(resolvedPath);
124
+ };
115
125
 
116
126
  //#endregion
117
127
  //#region src/network.ts
@@ -199,6 +209,98 @@ const loadPrototypes = () => {
199
209
  };
200
210
  };
201
211
 
212
+ //#endregion
213
+ //#region src/error-handling.ts
214
+ const loggerCache = /* @__PURE__ */ new Map();
215
+ const isRecord = (value) => typeof value === "object" && value !== null;
216
+ const toErrorShape = (value) => isRecord(value) ? value : void 0;
217
+ const normalizeStatusCode = (value, fallback = 500) => {
218
+ const code = typeof value === "number" ? value : Number(value);
219
+ return Number.isInteger(code) && code >= 100 && code < 600 ? code : fallback;
220
+ };
221
+ const getErrorLogger = () => {
222
+ const destination = path.resolve(process.cwd(), "storage/logs/error.log");
223
+ if (!loggerCache.has(destination)) loggerCache.set(destination, pino({ level: "error" }, pino.destination({
224
+ dest: destination,
225
+ mkdir: true,
226
+ sync: false
227
+ })));
228
+ return loggerCache.get(destination);
229
+ };
230
+ const serializeError = (value, seen = /* @__PURE__ */ new WeakSet()) => {
231
+ if (Array.isArray(value)) return value.map((entry) => serializeError(entry, seen));
232
+ if (!isRecord(value)) return value;
233
+ if (seen.has(value)) return "[Circular]";
234
+ seen.add(value);
235
+ const serialized = {};
236
+ if (value instanceof Error) {
237
+ serialized.name = value.name;
238
+ serialized.message = value.message;
239
+ serialized.stack = value.stack;
240
+ }
241
+ for (const key of Reflect.ownKeys(value)) {
242
+ const property = typeof key === "string" ? key : key.toString();
243
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
244
+ if (!descriptor || !("value" in descriptor)) continue;
245
+ serialized[property] = serializeError(descriptor.value, seen);
246
+ }
247
+ return serialized;
248
+ };
249
+ const getPrimaryError = (error) => {
250
+ if (typeof error === "string") return error;
251
+ return toErrorShape(error.cause) ?? error;
252
+ };
253
+ const getValidationErrors = (error) => {
254
+ if (typeof error.errors === "function") return error.errors();
255
+ return error.errors;
256
+ };
257
+ const isValidationError = (error) => {
258
+ return typeof toErrorShape(error)?.errors !== "undefined";
259
+ };
260
+ const isModelNotFoundError = (error) => {
261
+ return typeof toErrorShape(error)?.getModelName === "function";
262
+ };
263
+ const shouldHideStack = () => {
264
+ const value = process.env.HIDE_ERROR_STACK;
265
+ return value === "true" || value === "1" || value === "on";
266
+ };
267
+ const shouldLogError = (error) => !isValidationError(error) && !isModelNotFoundError(error);
268
+ const createErrorPayload = (err, fallbackMessage = "Something went wrong") => {
269
+ const primaryError = getPrimaryError(err);
270
+ const detailedError = typeof primaryError === "string" ? void 0 : primaryError;
271
+ const validationError = detailedError && isValidationError(detailedError) ? detailedError : void 0;
272
+ const modelNotFoundError = detailedError && isModelNotFoundError(detailedError) ? detailedError : void 0;
273
+ const payload = {
274
+ status: "error",
275
+ code: typeof err === "string" ? 500 : normalizeStatusCode(detailedError?.statusCode ?? detailedError?.status),
276
+ message: typeof err === "string" ? `${fallbackMessage}: ${err}` : detailedError?.message || err.message || fallbackMessage
277
+ };
278
+ if (validationError) {
279
+ payload.code = normalizeStatusCode(validationError.statusCode ?? validationError.status, 422);
280
+ payload.message = validationError.message || fallbackMessage;
281
+ payload.errors = getValidationErrors(validationError);
282
+ } else if (modelNotFoundError) {
283
+ payload.code = 404;
284
+ payload.message = `${modelNotFoundError.getModelName?.()} not found!`;
285
+ } else if (detailedError?.stack) {
286
+ const [stackLine, ...rest] = detailedError.stack.split("\n");
287
+ const [key, content = ""] = stackLine.split(":");
288
+ payload.errors = { [key]: [content.trim(), ...rest.map((entry) => entry.trim())] };
289
+ }
290
+ if (detailedError && process.env.NODE_ENV === "development" && !shouldHideStack() && !validationError) payload.stack = detailedError.stack;
291
+ if (!validationError || payload.code === 404) {
292
+ delete payload.errors;
293
+ delete payload.stack;
294
+ }
295
+ return payload;
296
+ };
297
+ const logUnhandledError = (err, request, message) => {
298
+ getErrorLogger().error({
299
+ error: serializeError(err),
300
+ request
301
+ }, message);
302
+ };
303
+
202
304
  //#endregion
203
305
  //#region src/Logger.ts
204
306
  var Console = class {
@@ -404,5 +506,5 @@ var Logger = class Logger {
404
506
  };
405
507
 
406
508
  //#endregion
407
- export { Logger, appUrl, bindGracefulShutdown, bootWithDetectedPort, buildHtmlErrorResponse, config, env, loadPrototypes, nodeEnv, outputDir };
509
+ export { Logger, appUrl, bindGracefulShutdown, bootWithDetectedPort, buildHtmlErrorResponse, config, createErrorPayload, env, getErrorLogger, getPrimaryError, getValidationErrors, importFile, isModelNotFoundError, isValidationError, loadPrototypes, logUnhandledError, nodeEnv, normalizeStatusCode, outputDir, serializeError, shouldHideStack, shouldLogError, toErrorShape };
408
510
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/lifecycle.ts","../src/system.ts","../src/network.ts","../src/prototypes.ts","../src/Logger.ts"],"sourcesContent":["export const bindGracefulShutdown = (shutdown: () => Promise<void> | void) => {\n ['SIGINT', 'SIGTERM', 'SIGQUIT'].forEach((signal) => {\n process.on(signal, async () => {\n await shutdown()\n })\n })\n}\n","import { DotPath, Obj } from '@h3ravel/support'\nimport { GlobalConfig, GlobalEnv } from './types'\n\nimport { createRequire } from 'module'\nimport path from 'node:path'\nimport { readdirSync } from 'fs'\n\n/**\n * Read the .env file\n *\n * @param env\n * @param def\n * @returns\n */\nexport const env: GlobalEnv = <X = string, Y = undefined | X> (\n env: string,\n defaultValue?: Y,\n) => {\n let val: string | number | boolean | undefined | null = process.env[env] ?? ''\n\n if ([true, 'true', 'on', false, 'false', 'off'].includes(val)) {\n val = [true, 'true', 'on'].includes(val)\n }\n\n if (!isNaN(Number(val)) && typeof val !== 'boolean' && typeof val !== 'undefined' && val !== '') {\n val = Number(val)\n }\n\n if (val === '') {\n val = undefined\n }\n\n if (val === 'null') {\n val = null\n }\n\n val ??= defaultValue as typeof val\n\n return val as Y extends undefined ? X : Y\n}\n\n/**\n * Build the app url\n *\n * @param link\n * @returns\n */\nexport const appUrl = (link?: string): string => {\n const port = env('PORT') || '3000'\n const defaultUrl = `http://localhost:${port}`\n const appUrl = env('APP_URL') ?? defaultUrl\n\n try {\n const url = new URL(appUrl)\n // Append port only if APP_URL has a port or is localhost\n if (url.port || url.hostname === 'localhost') {\n url.port = port\n }\n // Remove trailing slash from base URL\n const baseUrl = url.toString().replace(/\\/$/, '')\n // Append link with proper path separator\n if (link) {\n // Ensure link starts with '/' and remove duplicate slashes\n const normalizedLink = `/${link.replace(/^\\/+/, '')}`\n\n return `${baseUrl}${normalizedLink}`\n }\n\n return baseUrl\n } catch {\n // Return default URL with link if provided\n return link ? `${defaultUrl}/${link.replace(/^\\/+/, '')}` : defaultUrl\n }\n}\n\n/**\n * Gets the application configuration.\n * \n * @param key The configuration key to retrieve.\n * @param defaultValue The default value to return if the key is not found.\n * @returns The configuration value.\n */\nexport const config: GlobalConfig = <X extends Record<string, any>, P extends DotPath<X> | undefined = undefined> (\n key?: P,\n defaultValue?: any\n) => {\n const dist = path.relative(process.cwd(), outputDir())\n const require = createRequire(import.meta.url)\n\n const files = readdirSync(path.join(process.cwd(), `${dist}/config`), { withFileTypes: true })\n .filter(file => {\n if (file.name.includes('middleware') && globalThis.arkctx.runtime === 'CLI') return false\n\n return file.isFile() && (file.name.endsWith('.js') || file.name.endsWith('.ts'))\n })\n\n const config = files.reduce((configs, file) => {\n const configName = path.basename(file.name, path.extname(file.name))\n\n configs[configName] = require(path.join(file.parentPath, file.name))\n .default((globalThis as any).app())\n\n return configs\n }, {} as Record<string, any>) as X\n\n\n if (key) {\n return Obj.get(config, key, defaultValue)\n }\n\n return config\n}\n\n/**\n * Gets the current Node environment (development or production).\n * \n * @returns \n */\nexport const nodeEnv = () => {\n let envValue = env<'development' | 'production'>('NODE_ENV', 'development')\n\n if (envValue !== 'development' && envValue !== 'production') {\n envValue = 'development'\n }\n\n return envValue === 'production' ? 'prod' : 'dev'\n}\n\n/**\n * Gets the output directory for the application based on the current environment.\n * \n * @param cwd The current working directory (optional, defaults to process.cwd()).\n * @returns \n */\nexport const outputDir = (cwd = process.cwd()) => {\n const NODE_ENV = nodeEnv()\n\n const output = {\n dev: env('OUTPUT_DIR_DEV', '.arkstack/build'),\n prod: env('OUTPUT_DIR', 'dist'),\n }\n\n return path.isAbsolute(output[NODE_ENV] ?? output.dev)\n ? (output[NODE_ENV] ?? output.dev)\n : path.join(cwd, output[NODE_ENV] ?? output.dev)\n}","import { config, env } from './system'\n\nimport { detect } from 'detect-port'\n\nexport const bootWithDetectedPort = async (\n boot: (port: number) => Promise<void>,\n preferredPort: number = 3000,\n app?: any\n) => {\n if (app && !globalThis.app)\n globalThis.app = () => app\n globalThis.env = env\n globalThis.config = config\n globalThis.arkctx = {\n runtime: 'HTTP',\n }\n const port = await detect(preferredPort)\n await boot(port)\n}\n\n\nexport const buildHtmlErrorResponse = ({\n message = 'An unexpected error occurred.',\n stack,\n title,\n code = 500,\n}: {\n message?: string;\n stack?: string;\n code?: number;\n title?: string;\n}) => {\n const titleMap: Record<number, string> = {\n 400: 'Bad Request',\n 401: 'Unauthorized',\n 403: 'Forbidden',\n 404: 'Not Found',\n 500: 'Internal Server Error',\n 502: 'Bad Gateway',\n 503: 'Service Unavailable',\n 504: 'Gateway Timeout',\n }\n\n title = titleMap[code] || title || 'Error'\n\n return `\n <html>\n <head>\n <title>${code} | ${title}</title>\n <style>\n body {\n font-family: Arial, sans-serif;\n background-color: #f8f8f8;\n color: #333;\n padding: 20px;\n }\n h1 {\n color: #e74c3c;\n }\n h3 {\n color: #3498db;\n }\n p {\n color: #555;\n }\n pre {\n background-color: #eee;\n padding: 10px;\n border-radius: 5px;\n overflow-x: auto;\n }\n </style>\n </head>\n <body>\n <h1>${code}</h1>\n <h3>${title}</h3>\n <p>${message}</p>\n ${stack ? `<h2>Stack Trace:</h2><pre>${stack}</pre>` : ''}\n </body>\n </html>\n `\n}","export const loadPrototypes = () => {\n String.prototype.titleCase = function () {\n return this.toLowerCase()\n .replace(/_/g, ' ')\n .replace(/-/g, ' ')\n .replace(/(?:^|\\s)\\w/g, function (match) {\n return match.toUpperCase()\n })\n }\n\n String.prototype.camelCase = function () {\n return this.replace(/(?:^\\w|[A-Z]|\\b\\w|\\s+)/g, function (match, index) {\n if (+match === 0) return '' // or if (/\\s+/.test(match)) for white spaces\n\n return index === 0 ? match.toLowerCase() : match.toUpperCase()\n })\n }\n\n String.prototype.pascalCase = function () {\n return this.replace(/(?:^\\w|[A-Z]|\\b\\w|\\s+)/g, function (match) {\n return match.toUpperCase()\n })\n }\n\n String.prototype.truncate = function (len: number = 20, suffix: string = '...') {\n if (this.length <= len) {\n return this.toString()\n }\n\n const truncated = this.substring(0, len)\n const lastSpaceIndex = truncated.lastIndexOf(' ')\n if (lastSpaceIndex > 0) {\n return truncated.substring(0, lastSpaceIndex) + suffix\n }\n\n return truncated + suffix\n }\n} \n","import chalk, { type ChalkInstance } from 'chalk'\nimport { LoggerChalk, LoggerLog, LoggerParseSignature } from './types'\n\nclass Console {\n static log = (...args: any[]) => Logger.log(args.map(e => [e, 'white']))\n static debug = (...args: any[]) => Logger.debug(args, false, true)\n static warn = (...args: any[]) => args.map(e => Logger.warn(e, false, true))\n static info = (...args: any[]) => args.map(e => Logger.info(e, false, true))\n static error = (...args: any[]) => args.map(e => Logger.error(e, false), true)\n}\n\nexport class Logger {\n /**\n * Global verbosity configuration\n */\n private static verbosity: number = 0\n private static isQuiet: boolean = false\n private static isSilent: boolean = false\n\n /**\n * Configure global verbosity levels\n */\n static configure (options: { verbosity?: number, quiet?: boolean, silent?: boolean } = {}) {\n this.verbosity = options.verbosity ?? 0\n this.isQuiet = options.quiet ?? false\n this.isSilent = options.silent ?? false\n }\n\n /**\n * Check if output should be suppressed\n */\n private static shouldSuppressOutput (level: 'line' | 'debug' | 'info' | 'warn' | 'error' | 'success'): boolean {\n if (this.isSilent) return true\n if (this.isQuiet && (level === 'info' || level === 'success')) return true\n if (level === 'debug' && this.verbosity < 3) return true\n\n return false\n }\n /**\n * Logs the message in two columns\n * \n * @param name \n * @param value \n * @param log If set to false, array of [name, dots, value] output will be returned and not logged \n * @returns \n */\n static twoColumnDetail (name: string, value: string, log?: true, spacer?: string): void\n static twoColumnDetail (name: string, value: string, log?: false, spacer?: string): [string, string, string]\n static twoColumnDetail (name: string, value: string, log = true, spacer = '.'): [string, string, string] | void {\n // eslint-disable-next-line no-control-regex\n const regex = /\\x1b\\[\\d+m/g\n const width = Math.max(process.stdout.columns, 100)\n const dots = Math.max(width - name.replace(regex, '').length - value.replace(regex, '').length - 10, 0)\n\n if (log) return console.log(name, chalk.gray(spacer.repeat(dots)), value)\n else return [name, chalk.gray(spacer.repeat(dots)), value]\n }\n\n /**\n * Logs the message in two columns\n * \n * @param name \n * @param desc \n * @param width \n * @param log If set to false, array of [name, dots, value] output will be returned and not logged \n * @returns \n */\n static describe (name: string, desc: string, width?: number, log?: true): void\n static describe (name: string, desc: string, width?: number, log?: false): [string, string, string]\n static describe (name: string, desc: string, width = 50, log = true): [string, string, string] | void {\n width = Math.max(width, 30)\n // eslint-disable-next-line no-control-regex\n const regex = /\\x1b\\[\\d+m/g\n const dots = Math.max(width - name.replace(regex, '').length, 0)\n\n if (log) return console.log(name, ' '.repeat(dots), desc)\n else return [name, ' '.repeat(dots), desc]\n }\n\n /**\n * Logs the message in two columns but allways passing status\n * \n * @param name \n * @param value \n * @param status \n * @param exit \n * @param preserveCol \n */\n static split (name: string, value: string, status?: 'success' | 'info' | 'error', exit = false, preserveCol = false, spacer = '.') {\n status ??= 'info'\n const color = { success: chalk.bgGreen, info: chalk.bgBlue, error: chalk.bgRed }\n\n const [_name, dots, val] = this.twoColumnDetail(name, value, false, spacer)\n\n console.log(this.textFormat(_name, color[status], preserveCol), dots, val)\n\n if (exit) process.exit(0)\n }\n\n /**\n * Wraps text with chalk\n * \n * @param txt \n * @param color \n * @param preserveCol \n * @returns \n */\n static textFormat (\n txt: unknown | unknown[],\n color: (...text: unknown[]) => string,\n preserveCol = false\n ): string {\n if (txt instanceof Error) {\n const err: Error & { code?: number, statusCode?: number } = txt\n const code = err.code ?? err.statusCode ? ` (${err.code ?? err.statusCode})` : ''\n const output: string[] = []\n\n if (err.message) {\n output.push(this.textFormat(`${err.constructor.name}${code}: ${err.message}`, chalk.bgRed, preserveCol))\n }\n\n if (err.stack) {\n output.push(' ' + chalk.white(err.stack.replace(`${err.name}: ${err.message}`, '').trim()))\n }\n\n return output.join('\\n')\n }\n\n if (Array.isArray(txt)) {\n return txt.map(e => this.textFormat(e, color, preserveCol)).join('\\n')\n }\n\n if (typeof txt === 'object') {\n return this.textFormat(Object.values(txt!), color, preserveCol)\n }\n\n if (typeof txt !== 'string') {\n return color(txt)\n }\n\n const str = String(txt)\n\n if (preserveCol) return str\n\n const [first, ...rest] = str.split(':')\n if (rest.length === 0) return str\n\n return color(` ${first} `) + rest.join(':')\n }\n\n /**\n * Logs a success message\n * \n * @param msg \n * @param exit \n * @param preserveCol \n */\n static success (msg: any, exit = false, preserveCol = false) {\n if (!this.shouldSuppressOutput('success')) {\n console.log(chalk.green('✓'), this.textFormat(msg, chalk.bgGreen, preserveCol))\n }\n if (exit) process.exit(0)\n }\n\n /**\n * Logs an informational message\n * \n * @param msg \n * @param exit \n * @param preserveCol \n */\n static info (msg: any, exit = false, preserveCol = false) {\n if (!this.shouldSuppressOutput('info')) {\n console.log(chalk.blue('ℹ'), this.textFormat(msg, chalk.bgBlue, preserveCol))\n }\n if (exit) process.exit(0)\n }\n\n /**\n * Logs an error message\n * \n * @param msg \n * @param exit \n * @param preserveCol \n */\n static error (msg: any, exit = true, preserveCol = false) {\n if (!this.shouldSuppressOutput('error')) {\n if (msg instanceof Error) {\n if (msg.message) {\n console.error(chalk.red('✖'), this.textFormat('ERROR:' + msg.message, chalk.bgRed, preserveCol))\n }\n console.error(chalk.red(`${(msg as any).detail ? `${(msg as any).detail}\\n` : ''}${msg.stack}`))\n } else {\n console.error(chalk.red('✖'), this.textFormat(msg, chalk.bgRed, preserveCol))\n }\n }\n if (exit) process.exit(1)\n }\n\n /**\n * Logs a warning message\n * \n * @param msg \n * @param exit \n * @param preserveCol \n */\n static warn (msg: any, exit = false, preserveCol = false) {\n if (!this.shouldSuppressOutput('warn')) {\n console.warn(chalk.yellow('⚠'), this.textFormat(msg, chalk.bgYellow, preserveCol))\n }\n if (exit) process.exit(0)\n }\n\n /**\n * Logs a debug message (only shown with verbosity >= 3)\n * \n * @param msg \n * @param exit \n * @param preserveCol \n */\n static debug<M = any> (msg: M | M[], exit = false, preserveCol = false) {\n if (!this.shouldSuppressOutput('debug')) {\n if (Array.isArray(msg)) {\n for (let i = 0; i < msg.length; i++) {\n console.log(chalk.gray('🐛'), chalk.bgGray(i + 1), this.textFormat(msg[i], chalk.bgGray, preserveCol))\n }\n } else {\n console.log(chalk.gray('🐛'), this.textFormat(msg, chalk.bgGray, preserveCol))\n }\n }\n if (exit) process.exit(0)\n }\n\n /**\n * Terminates the process\n */\n static quiet () {\n process.exit(0)\n }\n\n static chalker (styles: LoggerChalk[]) {\n return (input: any): string =>\n styles.reduce((acc, style) => {\n if ((style as any) in chalk) {\n const fn = typeof style === 'function'\n ? style\n : chalk[style as never]\n\n return fn(acc)\n }\n\n return acc\n }, input)\n }\n\n /**\n * Parse an array formated message and logs it\n * \n * @param config \n * @param joiner \n * @param log If set to false, string output will be returned and not logged \n * @param sc color to use ue on split text if : is found \n */\n static parse (config: LoggerParseSignature, joiner?: string, log?: true, sc?: LoggerChalk): void\n static parse (config: LoggerParseSignature, joiner?: string, log?: false, sc?: LoggerChalk): string\n static parse (config: LoggerParseSignature, joiner = ' ', log = true, sc?: LoggerChalk): string | void {\n const string = config.map(([str, opt]) => {\n if (Array.isArray(opt)) {\n opt = Logger.chalker(opt) as ChalkInstance\n }\n\n const output = typeof opt === 'string' && typeof chalk[opt] === 'function'\n ? (chalk as any)[opt](str)\n : typeof opt === 'function' ? opt(str) : str\n\n if (!sc) {\n return output\n }\n\n return this.textFormat(output, Logger.chalker(Array.isArray(sc) ? sc : [sc]))\n }).join(joiner)\n\n if (log && !this.shouldSuppressOutput('line')) console.log(string)\n else return string\n }\n\n /**\n * Ouput formater object or format the output\n * \n * @returns \n */\n static log: LoggerLog = ((config, joiner, log: boolean = true, sc) => {\n if (typeof config === 'string') {\n const conf = [[config, joiner]] as [string, keyof ChalkInstance][]\n\n return this.parse(conf, '', log as false, sc)\n } else if (Array.isArray(config)) {\n return this.parse(config, String(joiner), log as false, sc)\n } else if (log && !this.shouldSuppressOutput('line')) {\n return console.log(this.textFormat(config, Logger.chalker(['blue'])))\n }\n\n return this\n }) as LoggerLog\n\n /**\n * A simple console like output logger\n * \n * @returns \n */\n static console () {\n return Console\n }\n}"],"mappings":";;;;;;;;AAAA,MAAa,wBAAwB,aAAyC;AAC5E;EAAC;EAAU;EAAW;EAAU,CAAC,SAAS,WAAW;AACnD,UAAQ,GAAG,QAAQ,YAAY;AAC7B,SAAM,UAAU;IAChB;GACF;;;;;;;;;;;;ACSJ,MAAa,OACT,KACA,iBACC;CACD,IAAI,MAAoD,QAAQ,IAAI,QAAQ;AAE5E,KAAI;EAAC;EAAM;EAAQ;EAAM;EAAO;EAAS;EAAM,CAAC,SAAS,IAAI,CACzD,OAAM;EAAC;EAAM;EAAQ;EAAK,CAAC,SAAS,IAAI;AAG5C,KAAI,CAAC,MAAM,OAAO,IAAI,CAAC,IAAI,OAAO,QAAQ,aAAa,OAAO,QAAQ,eAAe,QAAQ,GACzF,OAAM,OAAO,IAAI;AAGrB,KAAI,QAAQ,GACR,OAAM;AAGV,KAAI,QAAQ,OACR,OAAM;AAGV,SAAQ;AAER,QAAO;;;;;;;;AASX,MAAa,UAAU,SAA0B;CAC7C,MAAM,OAAO,IAAI,OAAO,IAAI;CAC5B,MAAM,aAAa,oBAAoB;CACvC,MAAM,SAAS,IAAI,UAAU,IAAI;AAEjC,KAAI;EACA,MAAM,MAAM,IAAI,IAAI,OAAO;AAE3B,MAAI,IAAI,QAAQ,IAAI,aAAa,YAC7B,KAAI,OAAO;EAGf,MAAM,UAAU,IAAI,UAAU,CAAC,QAAQ,OAAO,GAA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M,SAAS,OAAO,KAAK,CAAC,KAAK,SAAS;AACtC,OAAI,MAAM,QAAQ,IAAI,CAClB,OAAM,OAAO,QAAQ,IAAI;GAG7B,MAAM,SAAS,OAAO,QAAQ,YAAY,OAAO,MAAM,SAAS,aACzD,MAAc,KAAK,IAAI,GACxB,OAAO,QAAQ,aAAa,IAAI,IAAI,GAAG;AAE7C,OAAI,CAAC,GACD,QAAO;AAGX,UAAO,KAAK,WAAW,QAAQ,OAAO,QAAQ,MAAM,QAAQ,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/E,CAAC,KAAK,OAAO;AAEf,MAAI,OAAO,CAAC,KAAK,qBAAqB,OAAO,CAAE,SAAQ,IAAI,OAAO;MAC7D,QAAO;;;;;;;CAQhB,OAAO,QAAmB,QAAQ,QAAQ,MAAe,MAAM,OAAO;AAClE,MAAI,OAAO,WAAW,UAAU;GAC5B,MAAM,OAAO,CAAC,CAAC,QAAQ,OAAO,CAAC;AAE/B,UAAO,KAAK,MAAM,MAAM,IAAI,KAAc,GAAG;aACtC,MAAM,QAAQ,OAAO,CAC5B,QAAO,KAAK,MAAM,QAAQ,OAAO,OAAO,EAAE,KAAc,GAAG;WACpD,OAAO,CAAC,KAAK,qBAAqB,OAAO,CAChD,QAAO,QAAQ,IAAI,KAAK,WAAW,QAAQ,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AAGzE,SAAO;;;;;;;CAQX,OAAO,UAAW;AACd,SAAO"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/lifecycle.ts","../src/system.ts","../src/network.ts","../src/prototypes.ts","../src/error-handling.ts","../src/Logger.ts"],"sourcesContent":["export const bindGracefulShutdown = (shutdown: () => Promise<void> | void) => {\n ['SIGINT', 'SIGTERM', 'SIGQUIT'].forEach((signal) => {\n process.on(signal, async () => {\n await shutdown()\n })\n })\n}\n","import { DotPath, Obj } from '@h3ravel/support'\nimport { GlobalConfig, GlobalEnv } from './types'\n\n// TODO: @rexxars/jiti has to be replaced with jiti once a new release is available. See https://github.com/unjs/jiti/pull/427\nimport { createJiti } from '@rexxars/jiti'\nimport { createRequire } from 'module'\nimport path from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport { readdirSync } from 'fs'\nimport { resolve } from 'node:path'\n\n/**\n * Read the .env file\n *\n * @param env\n * @param def\n * @returns\n */\nexport const env: GlobalEnv = <X = string, Y = undefined | X> (\n env: string,\n defaultValue?: Y,\n) => {\n let val: string | number | boolean | undefined | null = process.env[env] ?? ''\n\n if ([true, 'true', 'on', false, 'false', 'off'].includes(val)) {\n val = [true, 'true', 'on'].includes(val)\n }\n\n if (!isNaN(Number(val)) && typeof val !== 'boolean' && typeof val !== 'undefined' && val !== '') {\n val = Number(val)\n }\n\n if (val === '') {\n val = undefined\n }\n\n if (val === 'null') {\n val = null\n }\n\n val ??= defaultValue as typeof val\n\n return val as Y extends undefined ? X : Y\n}\n\n/**\n * Build the app url\n *\n * @param link\n * @returns\n */\nexport const appUrl = (link?: string): string => {\n const port = env('PORT') || '3000'\n const defaultUrl = `http://localhost:${port}`\n const appUrl = env('APP_URL') ?? defaultUrl\n\n try {\n const url = new URL(appUrl)\n // Append port only if APP_URL has a port or is localhost\n if (url.port || url.hostname === 'localhost') {\n url.port = port\n }\n // Remove trailing slash from base URL\n const baseUrl = url.toString().replace(/\\/$/, '')\n // Append link with proper path separator\n if (link) {\n // Ensure link starts with '/' and remove duplicate slashes\n const normalizedLink = `/${link.replace(/^\\/+/, '')}`\n\n return `${baseUrl}${normalizedLink}`\n }\n\n return baseUrl\n } catch {\n // Return default URL with link if provided\n return link ? `${defaultUrl}/${link.replace(/^\\/+/, '')}` : defaultUrl\n }\n}\n\n/**\n * Gets the application configuration.\n * \n * @param key The configuration key to retrieve.\n * @param defaultValue The default value to return if the key is not found.\n * @returns The configuration value.\n */\nexport const config: GlobalConfig = <X extends Record<string, any>, P extends DotPath<X> | undefined = undefined> (\n key?: P,\n defaultValue?: any\n) => {\n const dist = path.relative(process.cwd(), outputDir())\n const require = createRequire(import.meta.url)\n\n const files = readdirSync(path.join(process.cwd(), `${dist}/config`), { withFileTypes: true })\n .filter(file => {\n if (file.name.includes('middleware') && globalThis.arkctx.runtime === 'CLI') return false\n\n return file.isFile() && (file.name.endsWith('.js') || file.name.endsWith('.ts'))\n })\n\n const config = files.reduce((configs, file) => {\n const configName = path.basename(file.name, path.extname(file.name))\n\n configs[configName] = require(path.join(file.parentPath, file.name))\n .default((globalThis as any).app())\n\n return configs\n }, {} as Record<string, any>) as X\n\n\n if (key) {\n return Obj.get(config, key, defaultValue)\n }\n\n return config\n}\n\n/**\n * Gets the current Node environment (development or production).\n * \n * @returns \n */\nexport const nodeEnv = () => {\n let envValue = env<'development' | 'production'>('NODE_ENV', 'development')\n\n if (envValue !== 'development' && envValue !== 'production') {\n envValue = 'development'\n }\n\n return envValue === 'production' ? 'prod' : 'dev'\n}\n\n/**\n * Gets the output directory for the application based on the current environment.\n * \n * @param cwd The current working directory (optional, defaults to process.cwd()).\n * @returns \n */\nexport const outputDir = (cwd = process.cwd()) => {\n const NODE_ENV = nodeEnv()\n\n const output = {\n dev: env('OUTPUT_DIR_DEV', '.arkstack/build'),\n prod: env('OUTPUT_DIR', 'dist'),\n }\n\n return path.isAbsolute(output[NODE_ENV] ?? output.dev)\n ? (output[NODE_ENV] ?? output.dev)\n : path.join(cwd, output[NODE_ENV] ?? output.dev)\n}\n\n\nexport const importFile = async <T = unknown> (filePath: string): Promise<T> => {\n const resolvedPath = resolve(filePath)\n const jiti = createJiti(pathToFileURL(resolvedPath).href, {\n interopDefault: false,\n tsconfigPaths: true,\n })\n\n return await jiti.import<T>(resolvedPath)\n}","import { config, env } from './system'\n\nimport { detect } from 'detect-port'\n\nexport const bootWithDetectedPort = async (\n boot: (port: number) => Promise<void>,\n preferredPort: number = 3000,\n app?: any\n) => {\n if (app && !globalThis.app)\n globalThis.app = () => app\n globalThis.env = env\n globalThis.config = config\n globalThis.arkctx = {\n runtime: 'HTTP',\n }\n const port = await detect(preferredPort)\n await boot(port)\n}\n\n\nexport const buildHtmlErrorResponse = ({\n message = 'An unexpected error occurred.',\n stack,\n title,\n code = 500,\n}: {\n message?: string;\n stack?: string;\n code?: number;\n title?: string;\n}) => {\n const titleMap: Record<number, string> = {\n 400: 'Bad Request',\n 401: 'Unauthorized',\n 403: 'Forbidden',\n 404: 'Not Found',\n 500: 'Internal Server Error',\n 502: 'Bad Gateway',\n 503: 'Service Unavailable',\n 504: 'Gateway Timeout',\n }\n\n title = titleMap[code] || title || 'Error'\n\n return `\n <html>\n <head>\n <title>${code} | ${title}</title>\n <style>\n body {\n font-family: Arial, sans-serif;\n background-color: #f8f8f8;\n color: #333;\n padding: 20px;\n }\n h1 {\n color: #e74c3c;\n }\n h3 {\n color: #3498db;\n }\n p {\n color: #555;\n }\n pre {\n background-color: #eee;\n padding: 10px;\n border-radius: 5px;\n overflow-x: auto;\n }\n </style>\n </head>\n <body>\n <h1>${code}</h1>\n <h3>${title}</h3>\n <p>${message}</p>\n ${stack ? `<h2>Stack Trace:</h2><pre>${stack}</pre>` : ''}\n </body>\n </html>\n `\n}","export const loadPrototypes = () => {\n String.prototype.titleCase = function () {\n return this.toLowerCase()\n .replace(/_/g, ' ')\n .replace(/-/g, ' ')\n .replace(/(?:^|\\s)\\w/g, function (match) {\n return match.toUpperCase()\n })\n }\n\n String.prototype.camelCase = function () {\n return this.replace(/(?:^\\w|[A-Z]|\\b\\w|\\s+)/g, function (match, index) {\n if (+match === 0) return '' // or if (/\\s+/.test(match)) for white spaces\n\n return index === 0 ? match.toLowerCase() : match.toUpperCase()\n })\n }\n\n String.prototype.pascalCase = function () {\n return this.replace(/(?:^\\w|[A-Z]|\\b\\w|\\s+)/g, function (match) {\n return match.toUpperCase()\n })\n }\n\n String.prototype.truncate = function (len: number = 20, suffix: string = '...') {\n if (this.length <= len) {\n return this.toString()\n }\n\n const truncated = this.substring(0, len)\n const lastSpaceIndex = truncated.lastIndexOf(' ')\n if (lastSpaceIndex > 0) {\n return truncated.substring(0, lastSpaceIndex) + suffix\n }\n\n return truncated + suffix\n }\n} \n","import pino, { type Logger as PinoLogger } from 'pino'\nimport path from 'node:path'\nimport { ArkstackErrorPayload, ArkstackErrorShape } from './types'\n\nconst loggerCache = new Map<string, PinoLogger>()\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => (\n typeof value === 'object' && value !== null\n)\n\nexport const toErrorShape = (value: unknown): ArkstackErrorShape | undefined => (\n isRecord(value) ? value as unknown as ArkstackErrorShape : undefined\n)\n\nexport const normalizeStatusCode = (value: unknown, fallback: number = 500) => {\n const code = typeof value === 'number' ? value : Number(value)\n\n return Number.isInteger(code) && code >= 100 && code < 600 ? code : fallback\n}\n\nexport const getErrorLogger = () => {\n const destination = path.resolve(process.cwd(), 'storage/logs/error.log')\n\n if (!loggerCache.has(destination)) {\n loggerCache.set(destination, pino({\n level: 'error',\n }, pino.destination({\n dest: destination,\n mkdir: true,\n sync: false,\n })))\n }\n\n return loggerCache.get(destination)!\n}\n\nexport const serializeError = (value: unknown, seen: WeakSet<object> = new WeakSet()): unknown => {\n if (Array.isArray(value)) {\n return value.map((entry) => serializeError(entry, seen))\n }\n\n if (!isRecord(value)) {\n return value\n }\n\n if (seen.has(value)) {\n return '[Circular]'\n }\n\n seen.add(value)\n\n const serialized: Record<string, unknown> = {}\n\n if (value instanceof Error) {\n serialized.name = value.name\n serialized.message = value.message\n serialized.stack = value.stack\n }\n\n for (const key of Reflect.ownKeys(value)) {\n const property = typeof key === 'string' ? key : key.toString()\n const descriptor = Object.getOwnPropertyDescriptor(value, key)\n\n if (!descriptor || !('value' in descriptor)) {\n continue\n }\n\n serialized[property] = serializeError(descriptor.value, seen)\n }\n\n return serialized\n}\n\nexport const getPrimaryError = (error: ArkstackErrorShape | string) => {\n if (typeof error === 'string') {\n return error\n }\n\n return toErrorShape(error.cause) ?? error\n}\n\nexport const getValidationErrors = (error: ArkstackErrorShape) => {\n if (typeof error.errors === 'function') {\n return error.errors()\n }\n\n return error.errors\n}\n\nexport const isValidationError = (error: unknown): error is ArkstackErrorShape => {\n const candidate = toErrorShape(error)\n\n return typeof candidate?.errors !== 'undefined'\n}\n\nexport const isModelNotFoundError = (error: unknown): error is ArkstackErrorShape => {\n const candidate = toErrorShape(error)\n\n return typeof candidate?.getModelName === 'function'\n}\n\nexport const shouldHideStack = () => {\n const value = process.env.HIDE_ERROR_STACK\n\n return value === 'true' || value === '1' || value === 'on'\n}\n\nexport const shouldLogError = (error: unknown) =>\n !isValidationError(error) &&\n !isModelNotFoundError(error)\n\nexport const createErrorPayload = (\n err: ArkstackErrorShape | string,\n fallbackMessage: string = 'Something went wrong',\n): ArkstackErrorPayload => {\n const primaryError = getPrimaryError(err)\n const detailedError = typeof primaryError === 'string'\n ? undefined\n : primaryError\n const validationError = detailedError && isValidationError(detailedError)\n ? detailedError\n : undefined\n const modelNotFoundError = detailedError && isModelNotFoundError(detailedError)\n ? detailedError\n : undefined\n const payload: ArkstackErrorPayload = {\n status: 'error',\n code: typeof err === 'string'\n ? 500\n : normalizeStatusCode(detailedError?.statusCode ?? detailedError?.status),\n message: typeof err === 'string'\n ? `${fallbackMessage}: ${err}`\n : detailedError?.message || err.message || fallbackMessage,\n }\n\n if (validationError) {\n payload.code = normalizeStatusCode(validationError.statusCode ?? validationError.status, 422)\n payload.message = validationError.message || fallbackMessage\n payload.errors = getValidationErrors(validationError)\n } else if (modelNotFoundError) {\n payload.code = 404\n payload.message = `${modelNotFoundError.getModelName?.()} not found!`\n } else if (detailedError?.stack) {\n const [stackLine, ...rest] = detailedError.stack.split('\\n')\n const [key, content = ''] = stackLine.split(':')\n\n payload.errors = {\n [key]: [content.trim(), ...rest.map((entry: string) => entry.trim())]\n }\n }\n\n if (\n detailedError &&\n process.env.NODE_ENV === 'development' &&\n !shouldHideStack() &&\n !validationError\n ) {\n payload.stack = detailedError.stack\n }\n\n if (!validationError || payload.code === 404) {\n delete payload.errors\n delete payload.stack\n }\n\n return payload\n}\n\nexport const logUnhandledError = (\n err: unknown,\n request: Record<string, unknown>,\n message: string,\n) => {\n getErrorLogger().error({\n error: serializeError(err),\n request,\n }, message)\n}","import chalk, { type ChalkInstance } from 'chalk'\nimport { LoggerChalk, LoggerLog, LoggerParseSignature } from './types'\n\nclass Console {\n static log = (...args: any[]) => Logger.log(args.map(e => [e, 'white']))\n static debug = (...args: any[]) => Logger.debug(args, false, true)\n static warn = (...args: any[]) => args.map(e => Logger.warn(e, false, true))\n static info = (...args: any[]) => args.map(e => Logger.info(e, false, true))\n static error = (...args: any[]) => args.map(e => Logger.error(e, false), true)\n}\n\nexport class Logger {\n /**\n * Global verbosity configuration\n */\n private static verbosity: number = 0\n private static isQuiet: boolean = false\n private static isSilent: boolean = false\n\n /**\n * Configure global verbosity levels\n */\n static configure (options: { verbosity?: number, quiet?: boolean, silent?: boolean } = {}) {\n this.verbosity = options.verbosity ?? 0\n this.isQuiet = options.quiet ?? false\n this.isSilent = options.silent ?? false\n }\n\n /**\n * Check if output should be suppressed\n */\n private static shouldSuppressOutput (level: 'line' | 'debug' | 'info' | 'warn' | 'error' | 'success'): boolean {\n if (this.isSilent) return true\n if (this.isQuiet && (level === 'info' || level === 'success')) return true\n if (level === 'debug' && this.verbosity < 3) return true\n\n return false\n }\n /**\n * Logs the message in two columns\n * \n * @param name \n * @param value \n * @param log If set to false, array of [name, dots, value] output will be returned and not logged \n * @returns \n */\n static twoColumnDetail (name: string, value: string, log?: true, spacer?: string): void\n static twoColumnDetail (name: string, value: string, log?: false, spacer?: string): [string, string, string]\n static twoColumnDetail (name: string, value: string, log = true, spacer = '.'): [string, string, string] | void {\n // eslint-disable-next-line no-control-regex\n const regex = /\\x1b\\[\\d+m/g\n const width = Math.max(process.stdout.columns, 100)\n const dots = Math.max(width - name.replace(regex, '').length - value.replace(regex, '').length - 10, 0)\n\n if (log) return console.log(name, chalk.gray(spacer.repeat(dots)), value)\n else return [name, chalk.gray(spacer.repeat(dots)), value]\n }\n\n /**\n * Logs the message in two columns\n * \n * @param name \n * @param desc \n * @param width \n * @param log If set to false, array of [name, dots, value] output will be returned and not logged \n * @returns \n */\n static describe (name: string, desc: string, width?: number, log?: true): void\n static describe (name: string, desc: string, width?: number, log?: false): [string, string, string]\n static describe (name: string, desc: string, width = 50, log = true): [string, string, string] | void {\n width = Math.max(width, 30)\n // eslint-disable-next-line no-control-regex\n const regex = /\\x1b\\[\\d+m/g\n const dots = Math.max(width - name.replace(regex, '').length, 0)\n\n if (log) return console.log(name, ' '.repeat(dots), desc)\n else return [name, ' '.repeat(dots), desc]\n }\n\n /**\n * Logs the message in two columns but allways passing status\n * \n * @param name \n * @param value \n * @param status \n * @param exit \n * @param preserveCol \n */\n static split (name: string, value: string, status?: 'success' | 'info' | 'error', exit = false, preserveCol = false, spacer = '.') {\n status ??= 'info'\n const color = { success: chalk.bgGreen, info: chalk.bgBlue, error: chalk.bgRed }\n\n const [_name, dots, val] = this.twoColumnDetail(name, value, false, spacer)\n\n console.log(this.textFormat(_name, color[status], preserveCol), dots, val)\n\n if (exit) process.exit(0)\n }\n\n /**\n * Wraps text with chalk\n * \n * @param txt \n * @param color \n * @param preserveCol \n * @returns \n */\n static textFormat (\n txt: unknown | unknown[],\n color: (...text: unknown[]) => string,\n preserveCol = false\n ): string {\n if (txt instanceof Error) {\n const err: Error & { code?: number, statusCode?: number } = txt\n const code = err.code ?? err.statusCode ? ` (${err.code ?? err.statusCode})` : ''\n const output: string[] = []\n\n if (err.message) {\n output.push(this.textFormat(`${err.constructor.name}${code}: ${err.message}`, chalk.bgRed, preserveCol))\n }\n\n if (err.stack) {\n output.push(' ' + chalk.white(err.stack.replace(`${err.name}: ${err.message}`, '').trim()))\n }\n\n return output.join('\\n')\n }\n\n if (Array.isArray(txt)) {\n return txt.map(e => this.textFormat(e, color, preserveCol)).join('\\n')\n }\n\n if (typeof txt === 'object') {\n return this.textFormat(Object.values(txt!), color, preserveCol)\n }\n\n if (typeof txt !== 'string') {\n return color(txt)\n }\n\n const str = String(txt)\n\n if (preserveCol) return str\n\n const [first, ...rest] = str.split(':')\n if (rest.length === 0) return str\n\n return color(` ${first} `) + rest.join(':')\n }\n\n /**\n * Logs a success message\n * \n * @param msg \n * @param exit \n * @param preserveCol \n */\n static success (msg: any, exit = false, preserveCol = false) {\n if (!this.shouldSuppressOutput('success')) {\n console.log(chalk.green('✓'), this.textFormat(msg, chalk.bgGreen, preserveCol))\n }\n if (exit) process.exit(0)\n }\n\n /**\n * Logs an informational message\n * \n * @param msg \n * @param exit \n * @param preserveCol \n */\n static info (msg: any, exit = false, preserveCol = false) {\n if (!this.shouldSuppressOutput('info')) {\n console.log(chalk.blue('ℹ'), this.textFormat(msg, chalk.bgBlue, preserveCol))\n }\n if (exit) process.exit(0)\n }\n\n /**\n * Logs an error message\n * \n * @param msg \n * @param exit \n * @param preserveCol \n */\n static error (msg: any, exit = true, preserveCol = false) {\n if (!this.shouldSuppressOutput('error')) {\n if (msg instanceof Error) {\n if (msg.message) {\n console.error(chalk.red('✖'), this.textFormat('ERROR:' + msg.message, chalk.bgRed, preserveCol))\n }\n console.error(chalk.red(`${(msg as any).detail ? `${(msg as any).detail}\\n` : ''}${msg.stack}`))\n } else {\n console.error(chalk.red('✖'), this.textFormat(msg, chalk.bgRed, preserveCol))\n }\n }\n if (exit) process.exit(1)\n }\n\n /**\n * Logs a warning message\n * \n * @param msg \n * @param exit \n * @param preserveCol \n */\n static warn (msg: any, exit = false, preserveCol = false) {\n if (!this.shouldSuppressOutput('warn')) {\n console.warn(chalk.yellow('⚠'), this.textFormat(msg, chalk.bgYellow, preserveCol))\n }\n if (exit) process.exit(0)\n }\n\n /**\n * Logs a debug message (only shown with verbosity >= 3)\n * \n * @param msg \n * @param exit \n * @param preserveCol \n */\n static debug<M = any> (msg: M | M[], exit = false, preserveCol = false) {\n if (!this.shouldSuppressOutput('debug')) {\n if (Array.isArray(msg)) {\n for (let i = 0; i < msg.length; i++) {\n console.log(chalk.gray('🐛'), chalk.bgGray(i + 1), this.textFormat(msg[i], chalk.bgGray, preserveCol))\n }\n } else {\n console.log(chalk.gray('🐛'), this.textFormat(msg, chalk.bgGray, preserveCol))\n }\n }\n if (exit) process.exit(0)\n }\n\n /**\n * Terminates the process\n */\n static quiet () {\n process.exit(0)\n }\n\n static chalker (styles: LoggerChalk[]) {\n return (input: any): string =>\n styles.reduce((acc, style) => {\n if ((style as any) in chalk) {\n const fn = typeof style === 'function'\n ? style\n : chalk[style as never]\n\n return fn(acc)\n }\n\n return acc\n }, input)\n }\n\n /**\n * Parse an array formated message and logs it\n * \n * @param config \n * @param joiner \n * @param log If set to false, string output will be returned and not logged \n * @param sc color to use ue on split text if : is found \n */\n static parse (config: LoggerParseSignature, joiner?: string, log?: true, sc?: LoggerChalk): void\n static parse (config: LoggerParseSignature, joiner?: string, log?: false, sc?: LoggerChalk): string\n static parse (config: LoggerParseSignature, joiner = ' ', log = true, sc?: LoggerChalk): string | void {\n const string = config.map(([str, opt]) => {\n if (Array.isArray(opt)) {\n opt = Logger.chalker(opt) as ChalkInstance\n }\n\n const output = typeof opt === 'string' && typeof chalk[opt] === 'function'\n ? (chalk as any)[opt](str)\n : typeof opt === 'function' ? opt(str) : str\n\n if (!sc) {\n return output\n }\n\n return this.textFormat(output, Logger.chalker(Array.isArray(sc) ? sc : [sc]))\n }).join(joiner)\n\n if (log && !this.shouldSuppressOutput('line')) console.log(string)\n else return string\n }\n\n /**\n * Ouput formater object or format the output\n * \n * @returns \n */\n static log: LoggerLog = ((config, joiner, log: boolean = true, sc) => {\n if (typeof config === 'string') {\n const conf = [[config, joiner]] as [string, keyof ChalkInstance][]\n\n return this.parse(conf, '', log as false, sc)\n } else if (Array.isArray(config)) {\n return this.parse(config, String(joiner), log as false, sc)\n } else if (log && !this.shouldSuppressOutput('line')) {\n return console.log(this.textFormat(config, Logger.chalker(['blue'])))\n }\n\n return this\n }) as LoggerLog\n\n /**\n * A simple console like output logger\n * \n * @returns \n */\n static console () {\n return Console\n }\n}"],"mappings":";;;;;;;;;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@@
1
1
  {
2
2
  "name": "@arkstack/common",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "type": "module",
5
5
  "description": "Common package for Arkstack providing common implementations of core Arkstack features such as routing, middleware, and database integration.",
6
6
  "homepage": "https://arkstack.toneflix.net",
@@ -30,8 +30,10 @@
30
30
  "./package.json": "./package.json"
31
31
  },
32
32
  "dependencies": {
33
+ "@rexxars/jiti": "^2.6.2",
33
34
  "chalk": "^5.6.2",
34
- "detect-port": "^2.1.0"
35
+ "detect-port": "^2.1.0",
36
+ "pino": "^10.3.1"
35
37
  },
36
38
  "peerDependencies": {
37
39
  "@h3ravel/support": "^0.15.11"