{"version":3,"file":"log-file-rotation.cjs","names":["valueToBoolean"],"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,QAAOA,2CAAe,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;wCACX;uCACD,QAAQ;uCACR,SAAS;uCACT,UAAU;uCACV,OAAO;EAClB;AAED,KAAI,CAAC,OACH,SAAQ,yCAAc;EACpB,6CAAkB,uCAAY,uCAAY,OAAO,CAAC,CAAC,CAAC,UAAU;EAC9D,+CAAoB,CAAC,UAAU;EAC/B,8CAAmB,CAAC,UAAU;EAC9B,iDAAsB,CAAC,UAAU;EACjC,uDAA4B,CAAC,UAAU;EACvC,+CAAoB,CAAC,UAAU;EAC/B,wDAA6B,CAAC,UAAU;EACxC,mDAAwB,CAAC,UAAU;EACnC,+CAAoB,CAAC,UAAU;EAC/B,8CAAmB,CAAC,UAAU;EAC9B,2CAAgB,CAAC,UAAU;EAC3B,qDAA0B,CAAC,UAAU;EACrC,2CAAgB,CAAC,UAAU;EAC3B,6CAAkB,CAAC,UAAU;EAC7B,2CAAgB,CAAC,UAAU;EAC3B,mDAAwB,CAAC,UAAU;EACpC,CAAC,CAAC;AAGL,QAAO"}