{"version":3,"file":"nitro-BYA2IdQR.mjs","names":[],"sources":["../src/nitro.ts"],"sourcesContent":["import type { EnvironmentContext, RouteConfig, SamplingConfig } from './types'\nimport { extractErrorStatus } from './shared/errors'\n\nexport { shouldLog, getServiceForPath } from './shared/routes'\n\nexport interface NitroModuleOptions {\n  /**\n   * Enable or disable all logging globally.\n   * @default true\n   */\n  enabled?: boolean\n\n  /**\n   * Environment context overrides.\n   */\n  env?: Partial<EnvironmentContext>\n\n  /**\n   * Enable pretty printing.\n   * @default true in development, false in production\n   */\n  pretty?: boolean\n\n  /**\n   * Route patterns to include in logging.\n   * Supports glob patterns like '/api/**'.\n   * If not set, all routes are logged.\n   */\n  include?: string[]\n\n  /**\n   * Route patterns to exclude from logging.\n   * Supports glob patterns like '/_nitro/**'.\n   * Exclusions take precedence over inclusions.\n   */\n  exclude?: string[]\n\n  /**\n   * Route-specific service configuration.\n   */\n  routes?: Record<string, RouteConfig>\n\n  /**\n   * Sampling configuration for filtering logs.\n   */\n  sampling?: SamplingConfig\n}\n\nexport interface MxllogConfig {\n  enabled?: boolean\n  env?: Record<string, unknown>\n  pretty?: boolean\n  include?: string[]\n  exclude?: string[]\n  routes?: Record<string, RouteConfig>\n  sampling?: SamplingConfig\n}\n\n/**\n * Resolve an MxllogError from an error or its cause chain.\n * Both Nitro v2 (h3) and v3 wrap thrown errors — this unwraps them.\n */\nexport function resolveMxllogError(error: Error): Error | null {\n  if (error.name === 'MxllogError') return error\n  if ((error.cause as Error)?.name === 'MxllogError') return error.cause as Error\n  return null\n}\n\nexport { extractErrorStatus } from './shared/errors'\n\n/**\n * Build a standard mxllog error JSON response body.\n * Used by both v2 and v3 error handlers to ensure consistent shape.\n */\nexport function serializeMxllogErrorResponse(error: Error, url: string): Record<string, unknown> {\n  const status = extractErrorStatus(error)\n  const { data } = error as { data?: unknown }\n  const statusMessage = (error as { statusMessage?: string }).statusMessage || error.message\n  return {\n    url,\n    status,\n    statusCode: status,\n    statusText: statusMessage,\n    statusMessage,\n    message: error.message,\n    error: true,\n    ...(data !== undefined && { data }),\n  }\n}\n\n"],"mappings":";;;;;;AA8DA,SAAgB,mBAAmB,OAA4B;AAC7D,KAAI,MAAM,SAAS,cAAe,QAAO;AACzC,KAAK,MAAM,OAAiB,SAAS,cAAe,QAAO,MAAM;AACjE,QAAO;;;;;;AAST,SAAgB,6BAA6B,OAAc,KAAsC;CAC/F,MAAM,SAAS,mBAAmB,MAAM;CACxC,MAAM,EAAE,SAAS;CACjB,MAAM,gBAAiB,MAAqC,iBAAiB,MAAM;AACnF,QAAO;EACL;EACA;EACA,YAAY;EACZ,YAAY;EACZ;EACA,SAAS,MAAM;EACf,OAAO;EACP,GAAI,SAAS,KAAA,KAAa,EAAE,MAAM;EACnC"}