"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.handler = exports.config = void 0;
const zod_1 = require("zod");
exports.config = {
    type: 'api',
    name: 'Event Emitter',
    description: 'System endpoint for emitting events',
    path: '/emit',
    method: 'POST',
    emits: [], // Dynamic emissions
    flows: ['_system'],
    bodySchema: zod_1.z.object({
        topic: zod_1.z.string(),
        data: zod_1.z.record(zod_1.z.unknown()),
    }),
};
const handler = async (req, { emit, logger }) => {
    const { topic, data } = req.body;
    logger.info('[Event Emitter] Emitting event', { topic, data });
    await emit({ topic, data });
    return {
        status: 200,
        body: { success: true, emitted: { topic, data } },
    };
};
exports.handler = handler;
