"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAWSFunctionHandler = exports.getOpenAPIPathsObject = exports.getCombinePaths = void 0;
var common_1 = require("./common");
/**
 * Combine paths array in single open api paths object.
 *
 * This will be help fun when paths are defined each endpoint for modularity,
 * this can be used to combine all these separate paths in one.
 */
var getCombinePaths = function (paths) {
    return paths.reduce(function (parsedPaths, path) { return (__assign(__assign({}, parsedPaths), Object.fromEntries(Object.entries(path).map(function (_a) {
        var path = _a[0], methods = _a[1];
        return [
            path,
            __assign(__assign({}, parsedPaths[path]), methods),
        ];
    })))); }, {});
};
exports.getCombinePaths = getCombinePaths;
/**
 * Will help in creating paths object form path, method and operation schema.
 */
var getOpenAPIPathsObject = function (path, method, operationSpec) {
    var _a, _b;
    var schema = (_a = {},
        _a[path] = (_b = {},
            _b[method] = operationSpec,
            _b),
        _a);
    return schema;
};
exports.getOpenAPIPathsObject = getOpenAPIPathsObject;
/**
 * Will help reducing boilerplate for defining Lambda handler.
 */
var getAWSFunctionHandler = function (path, method, handler) {
    var functionDefinition = {
        handler: handler,
        events: [
            {
                http: {
                    cors: true,
                    method: method.toLocaleUpperCase(),
                    path: path,
                },
            },
        ],
    };
    return (0, common_1.getDeepMutable)(functionDefinition);
};
exports.getAWSFunctionHandler = getAWSFunctionHandler;
//# sourceMappingURL=config-helper.js.map