{"version":3,"file":"log-file-rotation.mjs","names":["z.boolean","z.literal","z.object","z.union","z.string","z.number"],"sources":["../../../src/node/log/log-file-rotation.ts"],"sourcesContent":["import type { Type } from '../../common/schema'\nimport type { RotationOptions } from './log-rotation'\nimport { valueToBoolean } from '../../common/data/convert'\nimport { z } from '../../common/schema'\n\nexport type LogRotationOptions = boolean | RotationOptions | 'daily' | 'weekly' | 'monthly' | 'size'\n\nexport function parseLogRotationConfigEnv(v?: string | null): LogRotationOptions {\n  if (['daily', 'weekly', 'monthly', 'size'].includes(String(v).trim().toLowerCase())) {\n    return v as 'daily' | 'weekly' | 'monthly' | 'size'\n  }\n\n  return valueToBoolean(v, false)\n}\n\nexport function getLogRotationConfig(rotation: LogRotationOptions | undefined): RotationOptions | undefined {\n  if (!rotation)\n    return undefined\n\n  // default for true and explicit 'size' is size-based rotation\n  if (rotation === true || rotation === 'size') {\n    return { size: '10M', maxFiles: 5, compress: 'gzip' }\n  }\n\n  // time-based shortcuts -> map to interval + maxFiles\n  if (rotation === 'daily')\n    return { interval: '1d', maxFiles: 30, compress: 'gzip' }\n  if (rotation === 'weekly')\n    return { interval: '7d', maxFiles: 30, compress: 'gzip' }\n  if (rotation === 'monthly')\n    return { interval: '1M', maxFiles: 90, compress: 'gzip' }\n\n  // assume it's a full RotationOptions object\n  return rotation as RotationOptions\n}\n\nexport function getLogFileRotationConfigSchemaOptions(simple = false): Type[] {\n  const options: Type[] = [\n    z.boolean(),\n    z.literal('daily'),\n    z.literal('weekly'),\n    z.literal('monthly'),\n    z.literal('size'),\n  ]\n\n  if (!simple) {\n    options.push(z.object({\n      compress: z.union([z.boolean(), z.literal('gzip')]).optional(),\n      encoding: z.string().optional(),\n      history: z.string().optional(),\n      immutable: z.boolean().optional(),\n      initialRotation: z.boolean().optional(),\n      interval: z.string().optional(),\n      intervalBoundary: z.boolean().optional(),\n      intervalUTC: z.boolean().optional(),\n      maxFiles: z.number().optional(),\n      maxSize: z.string().optional(),\n      mode: z.number().optional(),\n      omitExtension: z.boolean().optional(),\n      path: z.string().optional(),\n      rotate: z.number().optional(),\n      size: z.string().optional(),\n      teeToStdout: z.boolean().optional(),\n    }))\n  }\n\n  return options\n}\n"],"mappings":";;;;AAOA,SAAgB,0BAA0B,GAAuC;AAC/E,KAAI;EAAC;EAAS;EAAU;EAAW;EAAO,CAAC,SAAS,OAAO,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CACjF,QAAO;AAGT,QAAO,eAAe,GAAG,MAAM;;AAGjC,SAAgB,qBAAqB,UAAuE;AAC1G,KAAI,CAAC,SACH,QAAO;AAGT,KAAI,aAAa,QAAQ,aAAa,OACpC,QAAO;EAAE,MAAM;EAAO,UAAU;EAAG,UAAU;EAAQ;AAIvD,KAAI,aAAa,QACf,QAAO;EAAE,UAAU;EAAM,UAAU;EAAI,UAAU;EAAQ;AAC3D,KAAI,aAAa,SACf,QAAO;EAAE,UAAU;EAAM,UAAU;EAAI,UAAU;EAAQ;AAC3D,KAAI,aAAa,UACf,QAAO;EAAE,UAAU;EAAM,UAAU;EAAI,UAAU;EAAQ;AAG3D,QAAO;;AAGT,SAAgB,sCAAsC,SAAS,OAAe;CAC5E,MAAM,UAAkB;EACtBA,SAAW;EACXC,QAAU,QAAQ;EAClBA,QAAU,SAAS;EACnBA,QAAU,UAAU;EACpBA,QAAU,OAAO;EAClB;AAED,KAAI,CAAC,OACH,SAAQ,KAAKC,OAAS;EACpB,UAAUC,MAAQ,CAACH,SAAW,EAAEC,QAAU,OAAO,CAAC,CAAC,CAAC,UAAU;EAC9D,UAAUG,QAAU,CAAC,UAAU;EAC/B,SAASA,QAAU,CAAC,UAAU;EAC9B,WAAWJ,SAAW,CAAC,UAAU;EACjC,iBAAiBA,SAAW,CAAC,UAAU;EACvC,UAAUI,QAAU,CAAC,UAAU;EAC/B,kBAAkBJ,SAAW,CAAC,UAAU;EACxC,aAAaA,SAAW,CAAC,UAAU;EACnC,UAAUK,QAAU,CAAC,UAAU;EAC/B,SAASD,QAAU,CAAC,UAAU;EAC9B,MAAMC,QAAU,CAAC,UAAU;EAC3B,eAAeL,SAAW,CAAC,UAAU;EACrC,MAAMI,QAAU,CAAC,UAAU;EAC3B,QAAQC,QAAU,CAAC,UAAU;EAC7B,MAAMD,QAAU,CAAC,UAAU;EAC3B,aAAaJ,SAAW,CAAC,UAAU;EACpC,CAAC,CAAC;AAGL,QAAO"}