// SPDX-License-Identifier: Apache-2.0
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var ConsensusCommandDefinition_1;
import { inject, injectable } from 'tsyringe-neo';
import { InjectTokens } from '../../core/dependency-injection/inject-tokens.js';
import { patchInject } from '../../core/dependency-injection/container-helper.js';
import { BaseCommandDefinition } from './base-command-definition.js';
import { CommandBuilder, CommandGroup, Subcommand } from '../../core/command-path-builders/command-builder.js';
import { NodeCommand } from '../node/index.js';
import { NetworkCommand } from '../network.js';
import * as NodeFlags from '../node/flags.js';
import * as constants from '../../core/constants.js';
let ConsensusCommandDefinition = class ConsensusCommandDefinition extends BaseCommandDefinition {
    static { ConsensusCommandDefinition_1 = this; }
    logger;
    nodeCommand;
    networkCommand;
    constructor(logger, nodeCommand, networkCommand) {
        super();
        this.logger = logger;
        this.nodeCommand = nodeCommand;
        this.networkCommand = networkCommand;
        this.nodeCommand = patchInject(nodeCommand, InjectTokens.NodeCommand, this.constructor.name);
        this.networkCommand = patchInject(networkCommand, InjectTokens.NetworkCommand, this.constructor.name);
        this.logger = patchInject(logger, InjectTokens.SoloLogger, this.constructor.name);
    }
    static COMMAND_NAME = 'consensus';
    static DESCRIPTION = 'Consensus Node operations for creating, modifying, and destroying resources. ' +
        'These commands require the presence of an existing deployment.';
    static NETWORK_SUBCOMMAND_NAME = 'network';
    static NETWORK_SUBCOMMAND_DESCRIPTION = 'Ledger/network wide consensus operations such as freeze, upgrade, ' +
        'and deploy. Operates on the entire ledger and all consensus node instances.';
    static NODE_SUBCOMMAND_NAME = 'node';
    static NODE_SUBCOMMAND_DESCRIPTION = 'List, create, manage, or destroy consensus node instances. Operates on a single consensus node instance at a time.';
    static STATE_SUBCOMMAND_NAME = 'state';
    static STATE_SUBCOMMAND_DESCRIPTION = 'List, download, and upload consensus node state backups to/from individual consensus node instances.';
    static DEV_NODE_ADD_SUBCOMMAND_NAME = 'dev-node-add';
    static DEV_NODE_ADD_SUBCOMMAND_DESCRIPTION = 'Dev operations for adding consensus nodes.';
    static DEV_NODE_UPDATE_SUBCOMMAND_NAME = 'dev-node-update';
    static DEV_NODE_UPDATE_SUBCOMMAND_DESCRIPTION = 'Dev operations for updating consensus nodes';
    static DEV_NODE_UPGRADE_SUBCOMMAND_NAME = 'dev-node-upgrade';
    static DEV_NODE_UPGRADE_SUBCOMMAND_DESCRIPTION = 'Dev operations for upgrading consensus nodes';
    static DEV_NODE_DELETE_SUBCOMMAND_NAME = 'dev-node-delete';
    static DEV_NODE_DELETE_SUBCOMMAND_DESCRIPTION = 'Dev operations for delete consensus nodes';
    static DEV_FREEZE_SUBCOMMAND_NAME = 'dev-freeze';
    static DEV_FREEZE_SUBCOMMAND_DESCRIPTION = 'Dev operations for freezing consensus nodes';
    static DEV_NODE_PREPARE = 'prepare';
    static DEV_NODE_SUBMIT_TRANSACTION = 'submit-transactions';
    static DEV_NODE_EXECUTE = 'execute';
    static DEV_FREEZE_PREPARE_UPGRADE = 'prepare-upgrade';
    static DEV_FREEZE_FREEZE_UPGRADE = 'freeze-upgrade';
    static NODE_SETUP = 'setup';
    static NODE_START = 'start';
    static NODE_STOP = 'stop';
    static NODE_RESTART = 'restart';
    static NODE_REFRESH = 'refresh';
    static NODE_LOGS = 'logs';
    static NODE_STATES = 'states';
    static NODE_ADD = 'add';
    static NODE_UPDATE = 'update';
    static NODE_DESTROY = 'destroy';
    static NETWORK_DEPLOY = 'deploy';
    static NETWORK_DESTROY = 'destroy';
    static NETWORK_UPGRADE = 'upgrade';
    static NETWORK_FREEZE = 'freeze';
    static STATE_DOWNLOAD = 'download';
    static SETUP_COMMAND = `${ConsensusCommandDefinition_1.COMMAND_NAME} ${ConsensusCommandDefinition_1.NODE_SUBCOMMAND_NAME} ${ConsensusCommandDefinition_1.NODE_SETUP}`;
    static START_COMMAND = `${ConsensusCommandDefinition_1.COMMAND_NAME} ${ConsensusCommandDefinition_1.NODE_SUBCOMMAND_NAME} ${ConsensusCommandDefinition_1.NODE_START}`;
    static DEPLOY_COMMAND = `${ConsensusCommandDefinition_1.COMMAND_NAME} ${ConsensusCommandDefinition_1.NETWORK_SUBCOMMAND_NAME} ${ConsensusCommandDefinition_1.NETWORK_DEPLOY}`;
    static DESTROY_COMMAND = `${ConsensusCommandDefinition_1.COMMAND_NAME} ${ConsensusCommandDefinition_1.NETWORK_SUBCOMMAND_NAME} ${ConsensusCommandDefinition_1.NETWORK_DESTROY}`;
    getCommandDefinition() {
        return (new CommandBuilder(ConsensusCommandDefinition_1.COMMAND_NAME, ConsensusCommandDefinition_1.DESCRIPTION, this.logger)
            // NETWORK SUBCOMMANDS
            .addCommandGroup(new CommandGroup(ConsensusCommandDefinition_1.NETWORK_SUBCOMMAND_NAME, ConsensusCommandDefinition_1.NETWORK_SUBCOMMAND_DESCRIPTION)
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.NETWORK_DEPLOY, 'Installs and configures all consensus nodes for the deployment.', this.networkCommand, this.networkCommand.deploy, NetworkCommand.DEPLOY_FLAGS_LIST, [constants.HELM, constants.KUBECTL]))
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.NETWORK_DESTROY, 'Removes all consensus network components from the deployment.', this.networkCommand, this.networkCommand.destroy, NetworkCommand.DESTROY_FLAGS_LIST, [constants.HELM, constants.KUBECTL]))
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.NETWORK_FREEZE, 'Initiates a network freeze for scheduled maintenance or upgrades', this.nodeCommand.handlers, this.nodeCommand.handlers.freeze, NodeFlags.FREEZE_FLAGS, []))
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.NETWORK_UPGRADE, 'Upgrades the software version running on all consensus nodes.', this.nodeCommand.handlers, this.nodeCommand.handlers.upgrade, NodeFlags.UPGRADE_FLAGS, [constants.HELM, constants.KUBECTL])))
            // NODE SUBCOMMANDS
            .addCommandGroup(new CommandGroup(ConsensusCommandDefinition_1.NODE_SUBCOMMAND_NAME, ConsensusCommandDefinition_1.NODE_SUBCOMMAND_DESCRIPTION)
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.NODE_SETUP, 'Setup node with a specific version of Hedera platform', this.nodeCommand.handlers, this.nodeCommand.handlers.setup, NodeFlags.SETUP_FLAGS, []))
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.NODE_START, 'Start a node', this.nodeCommand.handlers, this.nodeCommand.handlers.start, NodeFlags.START_FLAGS, [constants.KUBECTL]))
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.NODE_STOP, 'Stop a node', this.nodeCommand.handlers, this.nodeCommand.handlers.stop, NodeFlags.STOP_FLAGS, [constants.KUBECTL]))
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.NODE_RESTART, 'Restart all nodes of the network', this.nodeCommand.handlers, this.nodeCommand.handlers.restart, NodeFlags.RESTART_FLAGS, [constants.KUBECTL]))
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.NODE_REFRESH, 'Reset and restart a node', this.nodeCommand.handlers, this.nodeCommand.handlers.refresh, NodeFlags.REFRESH_FLAGS, []))
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.NODE_ADD, 'Adds a node with a specific version of Hedera platform', this.nodeCommand.handlers, this.nodeCommand.handlers.add, NodeFlags.ADD_FLAGS, [constants.HELM, constants.KUBECTL]))
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.NODE_UPDATE, 'Update a node with a specific version of Hedera platform', this.nodeCommand.handlers, this.nodeCommand.handlers.update, NodeFlags.UPDATE_FLAGS, [constants.HELM, constants.KUBECTL]))
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.NODE_DESTROY, 'Delete a node with a specific version of Hedera platform', this.nodeCommand.handlers, this.nodeCommand.handlers.destroy, NodeFlags.DESTROY_FLAGS, [constants.HELM])))
            // STATE SUBCOMMANDS
            .addCommandGroup(new CommandGroup(ConsensusCommandDefinition_1.STATE_SUBCOMMAND_NAME, ConsensusCommandDefinition_1.STATE_SUBCOMMAND_DESCRIPTION).addSubcommand(new Subcommand(ConsensusCommandDefinition_1.STATE_DOWNLOAD, 'Downloads a signed state from consensus node/nodes.', this.nodeCommand.handlers, this.nodeCommand.handlers.states, NodeFlags.STATES_FLAGS)))
            // DEV NODE ADD SUBCOMMANDS
            .addCommandGroup(new CommandGroup(ConsensusCommandDefinition_1.DEV_NODE_ADD_SUBCOMMAND_NAME, ConsensusCommandDefinition_1.DEV_NODE_ADD_SUBCOMMAND_DESCRIPTION)
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.DEV_NODE_PREPARE, 'Prepares the addition of a node with a specific version of Hedera platform', this.nodeCommand.handlers, this.nodeCommand.handlers.addPrepare, NodeFlags.ADD_PREPARE_FLAGS))
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.DEV_NODE_SUBMIT_TRANSACTION, 'Submits NodeCreateTransaction and Upgrade transactions to the network nodes', this.nodeCommand.handlers, this.nodeCommand.handlers.addSubmitTransactions, NodeFlags.ADD_SUBMIT_TRANSACTIONS_FLAGS))
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.DEV_NODE_EXECUTE, 'Executes the addition of a previously prepared node', this.nodeCommand.handlers, this.nodeCommand.handlers.addExecute, NodeFlags.ADD_EXECUTE_FLAGS)))
            // DEV NODE UPDATE SUBCOMMANDS
            .addCommandGroup(new CommandGroup(ConsensusCommandDefinition_1.DEV_NODE_UPDATE_SUBCOMMAND_NAME, ConsensusCommandDefinition_1.DEV_NODE_UPDATE_SUBCOMMAND_DESCRIPTION)
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.DEV_NODE_PREPARE, 'Prepare the deployment to update a node with a specific version of Hedera platform', this.nodeCommand.handlers, this.nodeCommand.handlers.updatePrepare, NodeFlags.UPDATE_PREPARE_FLAGS))
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.DEV_NODE_SUBMIT_TRANSACTION, 'Submit transactions for updating a node with a specific version of Hedera platform', this.nodeCommand.handlers, this.nodeCommand.handlers.updateSubmitTransactions, NodeFlags.UPDATE_SUBMIT_TRANSACTIONS_FLAGS))
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.DEV_NODE_EXECUTE, 'Executes the updating of a node with a specific version of Hedera platform', this.nodeCommand.handlers, this.nodeCommand.handlers.updateExecute, NodeFlags.UPDATE_SUBMIT_TRANSACTIONS_FLAGS)))
            // DEV NODE UPGRADE SUBCOMMANDS
            .addCommandGroup(new CommandGroup(ConsensusCommandDefinition_1.DEV_NODE_UPGRADE_SUBCOMMAND_NAME, ConsensusCommandDefinition_1.DEV_NODE_UPGRADE_SUBCOMMAND_DESCRIPTION)
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.DEV_NODE_PREPARE, 'Prepare for upgrading network', this.nodeCommand.handlers, this.nodeCommand.handlers.upgradePrepare, NodeFlags.DEFAULT_FLAGS))
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.DEV_NODE_SUBMIT_TRANSACTION, 'Submit transactions for upgrading network', this.nodeCommand.handlers, this.nodeCommand.handlers.upgradeSubmitTransactions, NodeFlags.UPGRADE_SUBMIT_TRANSACTIONS_FLAGS))
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.DEV_NODE_EXECUTE, 'Executes the upgrading the network', this.nodeCommand.handlers, this.nodeCommand.handlers.upgradeExecute, NodeFlags.UPGRADE_EXECUTE_FLAGS)))
            // DEV NODE DELETE SUBCOMMANDS
            .addCommandGroup(new CommandGroup(ConsensusCommandDefinition_1.DEV_NODE_DELETE_SUBCOMMAND_NAME, ConsensusCommandDefinition_1.DEV_NODE_DELETE_SUBCOMMAND_DESCRIPTION)
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.DEV_NODE_PREPARE, 'Prepares the deletion of a node with a specific version of Hedera platform', this.nodeCommand.handlers, this.nodeCommand.handlers.destroyPrepare, NodeFlags.DESTROY_PREPARE_FLAGS))
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.DEV_NODE_SUBMIT_TRANSACTION, 'Submits transactions to the network nodes for deleting a node', this.nodeCommand.handlers, this.nodeCommand.handlers.destroySubmitTransactions, NodeFlags.DESTROY_SUBMIT_TRANSACTIONS_FLAGS))
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.DEV_NODE_EXECUTE, 'Executes the deletion of a previously prepared node', this.nodeCommand.handlers, this.nodeCommand.handlers.destroyExecute, NodeFlags.DESTROY_EXECUTE_FLAGS)))
            // DEV FREEZE SUBCOMMANDS
            .addCommandGroup(new CommandGroup(ConsensusCommandDefinition_1.DEV_FREEZE_SUBCOMMAND_NAME, ConsensusCommandDefinition_1.DEV_FREEZE_SUBCOMMAND_DESCRIPTION)
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.DEV_FREEZE_PREPARE_UPGRADE, 'Prepare the network for a Freeze Upgrade operation', this.nodeCommand.handlers, this.nodeCommand.handlers.prepareUpgrade, NodeFlags.PREPARE_UPGRADE_FLAGS))
            .addSubcommand(new Subcommand(ConsensusCommandDefinition_1.DEV_FREEZE_FREEZE_UPGRADE, 'Performs a Freeze Upgrade operation with on the network after it has been prepared with prepare-upgrade', this.nodeCommand.handlers, this.nodeCommand.handlers.freezeUpgrade, NodeFlags.PREPARE_UPGRADE_FLAGS)))
            .build());
    }
};
ConsensusCommandDefinition = ConsensusCommandDefinition_1 = __decorate([
    injectable(),
    __param(0, inject(InjectTokens.SoloLogger)),
    __param(1, inject(InjectTokens.NodeCommand)),
    __param(2, inject(InjectTokens.NetworkCommand)),
    __metadata("design:paramtypes", [Object, NodeCommand,
        NetworkCommand])
], ConsensusCommandDefinition);
export { ConsensusCommandDefinition };
//# sourceMappingURL=consensus-command-definition.js.map