"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const plugin_1 = require("../libs/plugin");
const identity_component_1 = require("../identity/identity-component");
const deepmerge = __importStar(require("deepmerge"));
/**
 * We require an IdentityPlugin to forward the configuration from lower level webapps
 * TODO: refactor so that we don't need such dummy plugins!
 */
exports.IdentityPlugin = (props) => {
    const path = require('path');
    const result = {
        applies: (component) => {
            return identity_component_1.isIdentity(component);
        },
        // convert the component into configuration parts
        // while the component is of Type `any`, its props must be of type `IDataLayerArgs` | `IDataLayerProps`
        process: (component, childConfigs, infrastructureMode) => {
            return {
                slsConfigs: deepmerge.all(childConfigs.map(config => config.slsConfigs)),
                // add the server config
                webpackConfigs: childConfigs.reduce((result, config) => result.concat(config.webpackConfigs), []),
                postBuilds: childConfigs.reduce((result, config) => result.concat(config.postBuilds), []),
                iamRoleStatements: plugin_1.forwardChildIamRoleStatements(childConfigs)
                /* THESE VALUES MUST NOT BE PROVIDED BY A CHILD, THEY ARE NOT FORWARED UPWARDS

                 environments: environments,

                 //stackName: component.stackName,

                 assetsPath: component.assetsPath,

                 buildPath: component.buildPath,

                 region: component.region,

                 domain: domain,

                 certArn: certArn,

                 supportOfflineStart: true,

                 supportCreateDomain: true
                 */
            };
        }
    };
    return result;
};
//# sourceMappingURL=template-plugin.js.map