"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createCommandBus = void 0;
const __1 = require("..");
const constants_1 = require("../constants");
function uncapitalize(str) {
    return str.charAt(0).toLowerCase() + str.slice(1);
}
function createCommandBus(name, options) {
    const ret = {
        [name]: class extends __1.CommandBusBase {
        },
    };
    Reflect.defineMetadata(constants_1.COMMAND_BUS_OPTIONS, options, ret[name]);
    const bus = new ret[name]();
    const decorator = (command, resolver) => (0, __1.CommandHandler)(bus, command, resolver);
    return {
        [uncapitalize(name)]: bus,
        [`${name}Handler`]: decorator,
        bind: bus.registerFunctionHandler.bind(bus),
    };
}
exports.createCommandBus = createCommandBus;
//# sourceMappingURL=createCommandBus.factory.js.map