import { getDeepMutable } from "./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.
 */
export const getCombinePaths = (paths) => paths.reduce((parsedPaths, path) => ({
    ...parsedPaths,
    ...Object.fromEntries(Object.entries(path).map(([path, methods]) => [
        path,
        { ...parsedPaths[path], ...methods },
    ])),
}), {});
/**
 * Will help in creating paths object form path, method and operation schema.
 */
export const getOpenAPIPathsObject = (path, method, operationSpec) => {
    const schema = {
        [path]: {
            [method]: operationSpec,
        },
    };
    return schema;
};
/**
 * Will help reducing boilerplate for defining Lambda handler.
 */
export const getAWSFunctionHandler = (path, method, handler) => {
    const functionDefinition = {
        handler,
        events: [
            {
                http: {
                    cors: true,
                    method: method.toLocaleUpperCase(),
                    path,
                },
            },
        ],
    };
    return getDeepMutable(functionDefinition);
};
//# sourceMappingURL=config-helper.js.map