UNPKG

@zowe/imperative

Version:
70 lines 3.22 kB
"use strict"; /* * This program and the accompanying materials are made available under the terms of the * Eclipse Public License v2.0 which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-v20.html * * SPDX-License-Identifier: EPL-2.0 * * Copyright Contributors to the Zowe Project. * */ Object.defineProperty(exports, "__esModule", { value: true }); exports.CompleteAuthGroupBuilder = void 0; const messages_1 = require("../../../../messages"); const constants_1 = require("../../../../constants"); const AuthLoginCommandBuilder_1 = require("./AuthLoginCommandBuilder"); const AuthLogoutCommandBuilder_1 = require("./AuthLogoutCommandBuilder"); /** * Generate a complete group of commands for logging in and out of services * based on provided auth definitions. */ class CompleteAuthGroupBuilder { /** * Get the complete auth group of commands * @param {[key: string]: ICommandProfileAuthConfig} authConfigs - mapping of profile types to auth configs * @param {Logger} logger - logger to use in the builder classes * @param {IImperativeAuthGroupConfig} authGroupConfig - config that allows command definitions to be overridden * @returns {ICommandDefinition} - the complete profile group of commands */ static getAuthGroup(authConfigs, logger, authGroupConfig = {}) { const authGroup = Object.assign(Object.assign({}, this.defaultAuthGroup), authGroupConfig.authGroup); const loginGroup = Object.assign(Object.assign({}, this.defaultLoginGroup), authGroupConfig.loginGroup); const logoutGroup = Object.assign(Object.assign({}, this.defaultLogoutGroup), authGroupConfig.logoutGroup); for (const profileType of Object.keys(authConfigs)) { for (const authConfig of authConfigs[profileType]) { const loginCommandAction = new AuthLoginCommandBuilder_1.AuthLoginCommandBuilder(profileType, logger, authConfig); const logoutCommandAction = new AuthLogoutCommandBuilder_1.AuthLogoutCommandBuilder(profileType, logger, authConfig); loginGroup.children.push(loginCommandAction.build()); logoutGroup.children.push(logoutCommandAction.build()); } } authGroup.children.push(loginGroup, logoutGroup); return authGroup; } } exports.CompleteAuthGroupBuilder = CompleteAuthGroupBuilder; CompleteAuthGroupBuilder.defaultAuthGroup = { name: constants_1.Constants.AUTH_GROUP, summary: messages_1.authCategorySummary.message, description: messages_1.authCategoryDesc.message, type: "group", children: [] }; CompleteAuthGroupBuilder.defaultLoginGroup = { name: constants_1.Constants.LOGIN_ACTION, description: messages_1.authLoginGroupDesc.message, summary: messages_1.authLoginGroupSummary.message, aliases: ["li"], type: "group", children: [], }; CompleteAuthGroupBuilder.defaultLogoutGroup = { name: constants_1.Constants.LOGOUT_ACTION, description: messages_1.authLogoutGroupDesc.message, summary: messages_1.authLogoutGroupSummary.message, aliases: ["lo"], type: "group", children: [], }; //# sourceMappingURL=CompleteAuthGroupBuilder.js.map