'use strict';

var chunk5HJQACVQ_cjs = require('./chunk-5HJQACVQ.cjs');
var chunkZKMVCV4G_cjs = require('./chunk-ZKMVCV4G.cjs');
var chunkZYXDUS6Q_cjs = require('./chunk-ZYXDUS6Q.cjs');
var chunkY2BKW5ND_cjs = require('./chunk-Y2BKW5ND.cjs');
var chunk6P7P7Y5U_cjs = require('./chunk-6P7P7Y5U.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 = chunk6P7P7Y5U_cjs.createRoute({
  method: "GET",
  path: "/logs/transports",
  responseType: "json",
  responseSchema: chunk5HJQACVQ_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 chunkY2BKW5ND_cjs.handleError(error, "Error getting log Transports");
    }
  }
});
var LIST_LOGS_ROUTE = chunk6P7P7Y5U_cjs.createRoute({
  method: "GET",
  path: "/logs",
  responseType: "json",
  queryParamSchema: chunk5HJQACVQ_cjs.listLogsQuerySchema,
  responseSchema: chunk5HJQACVQ_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;
      chunkZKMVCV4G_cjs.validateBody({ transportId });
      const filters = chunkZKMVCV4G_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 chunkY2BKW5ND_cjs.handleError(error, "Error getting logs");
    }
  }
});
var LIST_LOGS_BY_RUN_ID_ROUTE = chunk6P7P7Y5U_cjs.createRoute({
  method: "GET",
  path: "/logs/:runId",
  responseType: "json",
  pathParamSchema: chunkZYXDUS6Q_cjs.runIdSchema,
  queryParamSchema: chunk5HJQACVQ_cjs.listLogsQuerySchema,
  responseSchema: chunk5HJQACVQ_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;
      chunkZKMVCV4G_cjs.validateBody({ runId, transportId });
      const filters = chunkZKMVCV4G_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 chunkY2BKW5ND_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-GU5KJAMA.cjs.map
//# sourceMappingURL=chunk-GU5KJAMA.cjs.map