// 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 DeploymentCommandDefinition_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 { DeploymentCommand } from '../deployment.js';
import * as constants from '../../core/constants.js';
import { NodeCommand } from '../node/index.js';
import * as NodeFlags from '../node/flags.js';
let DeploymentCommandDefinition = class DeploymentCommandDefinition extends BaseCommandDefinition {
    static { DeploymentCommandDefinition_1 = this; }
    logger;
    deploymentCommand;
    nodeCommand;
    constructor(logger, deploymentCommand, nodeCommand) {
        super();
        this.logger = logger;
        this.deploymentCommand = deploymentCommand;
        this.nodeCommand = nodeCommand;
        this.deploymentCommand = patchInject(deploymentCommand, InjectTokens.DeploymentCommand, this.constructor.name);
        this.nodeCommand = patchInject(nodeCommand, InjectTokens.NodeCommand, this.constructor.name);
        this.logger = patchInject(logger, InjectTokens.SoloLogger, this.constructor.name);
    }
    static COMMAND_NAME = 'deployment';
    static DESCRIPTION = 'Create, modify, and delete deployment configurations. ' +
        'Deployments are required for most of the other commands.';
    static CLUSTER_SUBCOMMAND_NAME = 'cluster';
    static CLUSTER_SUBCOMMAND_DESCRIPTION = 'View and manage Solo cluster references used by a deployment.';
    static CONFIG_SUBCOMMAND_NAME = 'config';
    static CONFIG_SUBCOMMAND_DESCRIPTION = 'List, view, create, delete, and import deployments. These commands affect the local configuration only.';
    static STATE_SUBCOMMAND_NAME = 'state';
    static STATE_SUBCOMMAND_DESCRIPTION = 'View the actual state of the deployment on the Kubernetes clusters or ' +
        'teardown/destroy all remote and local configuration for a given deployment.';
    static DIAGNOSTIC_SUBCOMMAND_NAME = 'diagnostics';
    static DIAGNOSTIC_SUBCOMMAND_DESCRIPTION = 'Capture diagnostic information such as logs, signed states, and ledger/network/node configurations.';
    static CLUSTER_ATTACH = 'attach';
    static CONFIG_LIST = 'list';
    static CONFIG_CREATE = 'create';
    static CONFIG_DELETE = 'delete';
    static DIAGNOSTIC_ALL = 'all';
    static DIAGNOSTIC_LOGS = 'logs';
    static DIAGNOSTIC_CONNECTIONS = 'connections';
    static CREATE_COMMAND = `${DeploymentCommandDefinition_1.COMMAND_NAME} ${DeploymentCommandDefinition_1.CONFIG_SUBCOMMAND_NAME} ${DeploymentCommandDefinition_1.CONFIG_CREATE}`;
    static ATTACH_COMMAND = `${DeploymentCommandDefinition_1.COMMAND_NAME} ${DeploymentCommandDefinition_1.CLUSTER_SUBCOMMAND_NAME} ${DeploymentCommandDefinition_1.CLUSTER_ATTACH}`;
    static DELETE_COMMAND = `${DeploymentCommandDefinition_1.COMMAND_NAME} ${DeploymentCommandDefinition_1.CONFIG_SUBCOMMAND_NAME} ${DeploymentCommandDefinition_1.CONFIG_DELETE}`;
    static CONNECTIONS_COMMAND = `${DeploymentCommandDefinition_1.COMMAND_NAME} ${DeploymentCommandDefinition_1.DIAGNOSTIC_SUBCOMMAND_NAME} ${DeploymentCommandDefinition_1.DIAGNOSTIC_CONNECTIONS}`;
    getCommandDefinition() {
        return new CommandBuilder(DeploymentCommandDefinition_1.COMMAND_NAME, DeploymentCommandDefinition_1.DESCRIPTION, this.logger)
            .addCommandGroup(new CommandGroup(DeploymentCommandDefinition_1.CLUSTER_SUBCOMMAND_NAME, DeploymentCommandDefinition_1.CLUSTER_SUBCOMMAND_DESCRIPTION).addSubcommand(new Subcommand(DeploymentCommandDefinition_1.CLUSTER_ATTACH, 'Attaches a cluster reference to a deployment.', this.deploymentCommand, this.deploymentCommand.addCluster, DeploymentCommand.ADD_CLUSTER_FLAGS_LIST, [constants.KUBECTL])))
            .addCommandGroup(new CommandGroup(DeploymentCommandDefinition_1.CONFIG_SUBCOMMAND_NAME, DeploymentCommandDefinition_1.CONFIG_SUBCOMMAND_DESCRIPTION)
            .addSubcommand(new Subcommand(DeploymentCommandDefinition_1.CONFIG_LIST, 'Lists all local deployment configurations.', this.deploymentCommand, this.deploymentCommand.list, DeploymentCommand.LIST_DEPLOYMENTS_FLAGS_LIST, []))
            .addSubcommand(new Subcommand(DeploymentCommandDefinition_1.CONFIG_CREATE, 'Creates a new local deployment configuration.', this.deploymentCommand, this.deploymentCommand.create, DeploymentCommand.CREATE_FLAGS_LIST, []))
            .addSubcommand(new Subcommand(DeploymentCommandDefinition_1.CONFIG_DELETE, 'Removes a local deployment configuration.', this.deploymentCommand, this.deploymentCommand.delete, DeploymentCommand.DESTROY_FLAGS_LIST, [])))
            .addCommandGroup(new CommandGroup(DeploymentCommandDefinition_1.DIAGNOSTIC_SUBCOMMAND_NAME, DeploymentCommandDefinition_1.DIAGNOSTIC_SUBCOMMAND_DESCRIPTION)
            .addSubcommand(new Subcommand(DeploymentCommandDefinition_1.DIAGNOSTIC_ALL, 'Captures logs, configs, and diagnostic artifacts from all consensus nodes and test connections.', this.nodeCommand.handlers, this.nodeCommand.handlers.all, NodeFlags.DIAGNOSTICS_CONNECTIONS))
            .addSubcommand(new Subcommand(DeploymentCommandDefinition_1.DIAGNOSTIC_CONNECTIONS, 'Tests connections to Consensus, Relay, Explorer, Mirror and Block nodes.', this.nodeCommand.handlers, this.nodeCommand.handlers.connections, NodeFlags.DIAGNOSTICS_CONNECTIONS))
            .addSubcommand(new Subcommand(DeploymentCommandDefinition_1.DIAGNOSTIC_LOGS, 'Get logs and configuration files from consensus node/nodes.', this.nodeCommand.handlers, this.nodeCommand.handlers.logs, NodeFlags.LOGS_FLAGS)))
            .build();
    }
};
DeploymentCommandDefinition = DeploymentCommandDefinition_1 = __decorate([
    injectable(),
    __param(0, inject(InjectTokens.SoloLogger)),
    __param(1, inject(InjectTokens.DeploymentCommand)),
    __param(2, inject(InjectTokens.NodeCommand)),
    __metadata("design:paramtypes", [Object, DeploymentCommand,
        NodeCommand])
], DeploymentCommandDefinition);
export { DeploymentCommandDefinition };
//# sourceMappingURL=deployment-command-definition.js.map