'use strict';

var chunk6BHM6ZJR_cjs = require('./chunk-6BHM6ZJR.cjs');
var chunkLWK57QIA_cjs = require('./chunk-LWK57QIA.cjs');
var chunkEES2ZZGL_cjs = require('./chunk-EES2ZZGL.cjs');
var chunkYDO5OPEU_cjs = require('./chunk-YDO5OPEU.cjs');
var chunkB34S64RC_cjs = require('./chunk-B34S64RC.cjs');
var chunkO7I5CWRX_cjs = require('./chunk-O7I5CWRX.cjs');

// src/server/handlers/logs.ts
var logs_exports = {};
chunkO7I5CWRX_cjs.__export(logs_exports, {
  LIST_LOGS_BY_RUN_ID_ROUTE: () => LIST_LOGS_BY_RUN_ID_ROUTE,
  LIST_LOGS_ROUTE: () => LIST_LOGS_ROUTE,
  LIST_LOG_TRANSPORTS_ROUTE: () => LIST_LOG_TRANSPORTS_ROUTE
});
var LIST_LOG_TRANSPORTS_ROUTE = chunkYDO5OPEU_cjs.createRoute({
  method: "GET",
  path: "/logs/transports",
  responseType: "json",
  responseSchema: chunk6BHM6ZJR_cjs.listLogTransportsResponseSchema,
  summary: "List log transports",
  description: "Returns a list of all available log transports",
  tags: ["Logs"],
  requiresAuth: true,
  handler: async ({ mastra }) => {
    try {
      const logger = mastra.getLogger();
      const transports = logger.getTransports();
      return {
        transports: transports ? [...transports.keys()] : []
      };
    } catch (error) {
      return chunkB34S64RC_cjs.handleError(error, "Error getting log Transports");
    }
  }
});
var LIST_LOGS_ROUTE = chunkYDO5OPEU_cjs.createRoute({
  method: "GET",
  path: "/logs",
  responseType: "json",
  queryParamSchema: chunk6BHM6ZJR_cjs.listLogsQuerySchema,
  responseSchema: chunk6BHM6ZJR_cjs.listLogsResponseSchema,
  summary: "List logs",
  description: "Returns logs from a specific transport with optional filtering by date range, log level, and custom filters",
  tags: ["Logs"],
  requiresAuth: true,
  handler: async ({ mastra, ...params }) => {
    try {
      const { transportId, fromDate, toDate, logLevel, filters: _filters, page, perPage } = params;
      chunkLWK57QIA_cjs.validateBody({ transportId });
      const filters = chunkLWK57QIA_cjs.parseFilters(_filters);
      const logs = await mastra.listLogs(transportId, {
        fromDate,
        toDate,
        logLevel,
        filters,
        page: page ? Number(page) : void 0,
        perPage: perPage ? Number(perPage) : void 0
      });
      return logs;
    } catch (error) {
      return chunkB34S64RC_cjs.handleError(error, "Error getting logs");
    }
  }
});
var LIST_LOGS_BY_RUN_ID_ROUTE = chunkYDO5OPEU_cjs.createRoute({
  method: "GET",
  path: "/logs/:runId",
  responseType: "json",
  pathParamSchema: chunkEES2ZZGL_cjs.runIdSchema,
  queryParamSchema: chunk6BHM6ZJR_cjs.listLogsQuerySchema,
  responseSchema: chunk6BHM6ZJR_cjs.listLogsResponseSchema,
  summary: "List logs by run ID",
  description: "Returns all logs for a specific execution run from a transport",
  tags: ["Logs"],
  requiresAuth: true,
  handler: async ({ mastra, runId, ...params }) => {
    try {
      const { transportId, fromDate, toDate, logLevel, filters: _filters, page, perPage } = params;
      chunkLWK57QIA_cjs.validateBody({ runId, transportId });
      const filters = chunkLWK57QIA_cjs.parseFilters(_filters);
      const logs = await mastra.listLogsByRunId({
        runId,
        transportId,
        fromDate,
        toDate,
        logLevel,
        filters,
        page: page ? Number(page) : void 0,
        perPage: perPage ? Number(perPage) : void 0
      });
      return logs;
    } catch (error) {
      return chunkB34S64RC_cjs.handleError(error, "Error getting logs by run ID");
    }
  }
});

exports.LIST_LOGS_BY_RUN_ID_ROUTE = LIST_LOGS_BY_RUN_ID_ROUTE;
exports.LIST_LOGS_ROUTE = LIST_LOGS_ROUTE;
exports.LIST_LOG_TRANSPORTS_ROUTE = LIST_LOG_TRANSPORTS_ROUTE;
exports.logs_exports = logs_exports;
//# sourceMappingURL=chunk-UAINGDV5.cjs.map
//# sourceMappingURL=chunk-UAINGDV5.cjs.map