"use strict";
// File: src/modules/infrastructure/servers/entities/infrastructure-operations.entity.ts
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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.InfrastructureOperationEntity = exports.OperationStep = exports.OperationStatus = exports.OperationType = void 0;
const cloud_provider_enum_1 = require("../../../../modules/providers/enums/cloud-provider.enum");
const typeorm_1 = require("typeorm");
var OperationType;
(function (OperationType) {
    OperationType["CREATE_SERVER"] = "create_server";
    OperationType["DELETE_SERVER"] = "delete_server";
    OperationType["UPDATE_SERVER"] = "update_server";
    OperationType["START_SERVER"] = "start_server";
    OperationType["STOP_SERVER"] = "stop_server";
    OperationType["RESTART_SERVER"] = "restart_server";
    // Cluster operations
    OperationType["CREATE_CLUSTER"] = "create_cluster";
    OperationType["DELETE_CLUSTER"] = "delete_cluster";
    OperationType["ADD_WORKER"] = "add_worker";
    OperationType["REMOVE_WORKER"] = "remove_worker";
    OperationType["SCALE_NODE"] = "scale_node";
    OperationType["EXPAND_SHARED_VOLUME"] = "expand_shared_volume";
    OperationType["START_CLUSTER"] = "start_cluster";
    OperationType["STOP_CLUSTER"] = "stop_cluster";
    OperationType["ATTACH_CLUSTER_TO_VNET"] = "attach_cluster_to_vnet";
    // Application build operations
    OperationType["BUILD_APPLICATION"] = "build_application";
    // Build cache operations
    OperationType["CLEAR_BUILD_CACHE"] = "clear_build_cache";
    // Application operations
    OperationType["DEPLOY_APPLICATION"] = "deploy_application";
    OperationType["UPDATE_APPLICATION"] = "update_application";
    OperationType["DELETE_APPLICATION"] = "delete_application";
    OperationType["ROLLBACK_APPLICATION"] = "rollback_application";
    // Catalog operations
    OperationType["INSTALL_CATALOG_APP"] = "install_catalog_app";
    OperationType["UNINSTALL_CATALOG_APP"] = "uninstall_catalog_app";
    // Authz operations
    OperationType["INSTALL_AUTHZ"] = "install_authz";
    OperationType["UNINSTALL_AUTHZ"] = "uninstall_authz";
    // Backup operations
    OperationType["CREATE_BACKUP_DESTINATION"] = "create_backup_destination";
    OperationType["HEALTH_CHECK_DESTINATION"] = "health_check_destination";
    OperationType["INSTALL_VELERO"] = "install_velero";
    OperationType["UNINSTALL_VELERO"] = "uninstall_velero";
    OperationType["RUN_BACKUP_JOB"] = "run_backup_job";
    OperationType["REPLICATE_BACKUP"] = "replicate_backup";
    OperationType["RUN_RESTORE_JOB"] = "run_restore_job";
    OperationType["RESTORE_PREVIEW"] = "restore_preview";
    OperationType["PRE_DEPLOY_SNAPSHOT"] = "pre_deploy_snapshot";
    OperationType["ENABLE_ETCD_SNAPSHOTS"] = "enable_etcd_snapshots";
    OperationType["CREATE_PROVIDER_SNAPSHOT"] = "create_provider_snapshot";
    OperationType["RESTORE_FROM_PROVIDER_SNAPSHOT"] = "restore_from_provider_snapshot";
    OperationType["BACKUP_QUICK_SETUP"] = "backup_quick_setup";
    // Provider VM-level backups (whole-VM imaging by the cloud provider)
    OperationType["ENABLE_VM_BACKUPS"] = "enable_vm_backups";
    OperationType["DISABLE_VM_BACKUPS"] = "disable_vm_backups";
    // Application-level volume operations
    OperationType["APP_SNAPSHOT_CREATE"] = "app_snapshot_create";
    OperationType["APP_SNAPSHOT_DELETE"] = "app_snapshot_delete";
    OperationType["APP_SNAPSHOT_RESTORE"] = "app_snapshot_restore";
    OperationType["APP_VOLUME_SWAP"] = "app_volume_swap";
    OperationType["APP_BACKUP_CREATE"] = "app_backup_create";
})(OperationType || (exports.OperationType = OperationType = {}));
var OperationStatus;
(function (OperationStatus) {
    OperationStatus["PENDING"] = "PENDING";
    OperationStatus["IN_PROGRESS"] = "IN_PROGRESS";
    OperationStatus["COMPLETED"] = "COMPLETED";
    OperationStatus["FAILED"] = "FAILED";
    OperationStatus["CANCELLED"] = "CANCELLED";
})(OperationStatus || (exports.OperationStatus = OperationStatus = {}));
// Operation Steps - Granular steps for tracking operation progress
var OperationStep;
(function (OperationStep) {
    // Server creation steps
    OperationStep["SERVER_CREATE_INIT"] = "server_create_init";
    OperationStep["SERVER_CREATE_PROVISIONING"] = "server_create_provisioning";
    OperationStep["SERVER_CREATE_WAITING"] = "server_create_waiting";
    OperationStep["SERVER_CREATE_FINALIZING"] = "server_create_finalizing";
    // Server deletion steps
    OperationStep["SERVER_DELETE_INIT"] = "server_delete_init";
    OperationStep["SERVER_DELETE_EXECUTING"] = "server_delete_executing";
    OperationStep["SERVER_DELETE_WAITING"] = "server_delete_waiting";
    OperationStep["SERVER_DELETE_CLEANUP"] = "server_delete_cleanup";
    // Cluster creation steps
    OperationStep["CLUSTER_CREATE_INIT"] = "cluster_create_init";
    OperationStep["CLUSTER_CREATE_MASTER"] = "cluster_create_master";
    OperationStep["CLUSTER_CREATE_MASTER_WAIT_K3S"] = "cluster_create_master_wait_k3s";
    OperationStep["CLUSTER_CREATE_KUBECONFIG"] = "cluster_create_kubeconfig";
    OperationStep["CLUSTER_CREATE_WORKERS"] = "cluster_create_workers";
    OperationStep["CLUSTER_CREATE_FINALIZING"] = "cluster_create_finalizing";
    // Cluster deletion steps
    OperationStep["CLUSTER_DELETE_INIT"] = "cluster_delete_init";
    OperationStep["CLUSTER_DELETE_NODES"] = "cluster_delete_nodes";
    OperationStep["CLUSTER_DELETE_WAITING"] = "cluster_delete_waiting";
    OperationStep["CLUSTER_DELETE_CLEANUP"] = "cluster_delete_cleanup";
    // Cluster power management steps
    OperationStep["CLUSTER_STOP_INIT"] = "cluster_stop_init";
    OperationStep["CLUSTER_STOP_SERVERS"] = "cluster_stop_servers";
    OperationStep["CLUSTER_STOP_UPDATE_STATUS"] = "cluster_stop_update_status";
    OperationStep["CLUSTER_START_INIT"] = "cluster_start_init";
    OperationStep["CLUSTER_START_SERVERS"] = "cluster_start_servers";
    OperationStep["CLUSTER_START_WAIT_READY"] = "cluster_start_wait_ready";
    OperationStep["CLUSTER_START_UPDATE_STATUS"] = "cluster_start_update_status";
    OperationStep["CLUSTER_ATTACH_VNET_INIT"] = "cluster_attach_vnet_init";
    OperationStep["CLUSTER_ATTACH_VNET_NODES"] = "cluster_attach_vnet_nodes";
    OperationStep["CLUSTER_ATTACH_VNET_PERSIST"] = "cluster_attach_vnet_persist";
    // Cluster scaling steps (manual add/remove worker)
    OperationStep["CLUSTER_ADD_WORKER_VALIDATE"] = "cluster_add_worker_validate";
    OperationStep["CLUSTER_ADD_WORKER_PROVISION"] = "cluster_add_worker_provision";
    OperationStep["CLUSTER_ADD_WORKER_JOIN"] = "cluster_add_worker_join";
    OperationStep["CLUSTER_ADD_WORKER_FINALIZE"] = "cluster_add_worker_finalize";
    OperationStep["CLUSTER_REMOVE_WORKER_CORDON"] = "cluster_remove_worker_cordon";
    OperationStep["CLUSTER_REMOVE_WORKER_DRAIN"] = "cluster_remove_worker_drain";
    OperationStep["CLUSTER_REMOVE_WORKER_DELETE"] = "cluster_remove_worker_delete";
    OperationStep["CLUSTER_REMOVE_WORKER_DELETE_NODE"] = "cluster_remove_worker_delete_node";
    OperationStep["CLUSTER_REMOVE_WORKER_FINALIZE"] = "cluster_remove_worker_finalize";
    OperationStep["SCALE_NODE_PRECHECK"] = "scale_node_precheck";
    OperationStep["SCALE_NODE_POWER_OFF"] = "scale_node_power_off";
    OperationStep["SCALE_NODE_CHANGE_TYPE"] = "scale_node_change_type";
    OperationStep["SCALE_NODE_POWER_ON"] = "scale_node_power_on";
    OperationStep["SCALE_NODE_WAIT_READY"] = "scale_node_wait_ready";
    OperationStep["SCALE_NODE_FINALIZE"] = "scale_node_finalize";
    OperationStep["EXPAND_VOLUME_PRECHECK"] = "expand_volume_precheck";
    OperationStep["EXPAND_VOLUME_PROVIDER"] = "expand_volume_provider";
    OperationStep["EXPAND_VOLUME_RESIZE_FS"] = "expand_volume_resize_fs";
    OperationStep["EXPAND_VOLUME_FINALIZE"] = "expand_volume_finalize";
    // Application build steps (Path B)
    OperationStep["APP_BUILD_INIT"] = "app_build_init";
    OperationStep["APP_BUILD_CREATE_JOB"] = "app_build_create_job";
    OperationStep["APP_BUILD_CLONING"] = "app_build_cloning";
    OperationStep["APP_BUILD_ANALYZING"] = "app_build_analyzing";
    OperationStep["APP_BUILD_BUILDING"] = "app_build_building";
    OperationStep["APP_BUILD_PUSHING"] = "app_build_pushing";
    OperationStep["APP_BUILD_FINALIZE"] = "app_build_finalize";
    // Application deploy steps
    OperationStep["APP_DEPLOY_INIT"] = "app_deploy_init";
    OperationStep["APP_DEPLOY_BUILD"] = "app_deploy_build";
    OperationStep["APP_DEPLOY_PUSH_IMAGE"] = "app_deploy_push_image";
    OperationStep["APP_DEPLOY_GENERATE_MANIFESTS"] = "app_deploy_generate_manifests";
    OperationStep["APP_DEPLOY_APPLY_MANIFESTS"] = "app_deploy_apply_manifests";
    OperationStep["APP_DEPLOY_WAIT_READY"] = "app_deploy_wait_ready";
    OperationStep["APP_DEPLOY_FINALIZE"] = "app_deploy_finalize";
    OperationStep["APP_DELETE_INIT"] = "app_delete_init";
    OperationStep["APP_DELETE_K8S_RESOURCES"] = "app_delete_k8s_resources";
    OperationStep["APP_DELETE_FINALIZE"] = "app_delete_finalize";
    // Build cache steps
    OperationStep["BUILD_CACHE_CLEAR_INIT"] = "build_cache_clear_init";
    OperationStep["BUILD_CACHE_CLEAR_DELETING"] = "build_cache_clear_deleting";
    OperationStep["BUILD_CACHE_CLEAR_RECREATING"] = "build_cache_clear_recreating";
    // Catalog install steps
    OperationStep["CATALOG_INSTALL_INIT"] = "catalog_install_init";
    OperationStep["CATALOG_INSTALL_RESOLVE_DEPS"] = "catalog_install_resolve_deps";
    OperationStep["CATALOG_INSTALL_GENERATE_SECRETS"] = "catalog_install_generate_secrets";
    OperationStep["CATALOG_INSTALL_RESOLVE_TEMPLATES"] = "catalog_install_resolve_templates";
    OperationStep["CATALOG_INSTALL_CREATE_APPLICATIONS"] = "catalog_install_create_applications";
    OperationStep["CATALOG_INSTALL_DEPLOY_COMPONENTS"] = "catalog_install_deploy_components";
    OperationStep["CATALOG_INSTALL_CREATE_ENDPOINTS"] = "catalog_install_create_endpoints";
    OperationStep["CATALOG_INSTALL_FINALIZE"] = "catalog_install_finalize";
    // Catalog uninstall steps
    OperationStep["CATALOG_UNINSTALL_INIT"] = "catalog_uninstall_init";
    OperationStep["CATALOG_UNINSTALL_DELETE_APPS"] = "catalog_uninstall_delete_apps";
    OperationStep["CATALOG_UNINSTALL_FINALIZE"] = "catalog_uninstall_finalize";
    // Authz install steps
    OperationStep["AUTHZ_INSTALL_INIT"] = "authz_install_init";
    OperationStep["AUTHZ_ENSURE_NAMESPACE"] = "authz_ensure_namespace";
    OperationStep["AUTHZ_DEPLOY_SERVICE"] = "authz_deploy_service";
    OperationStep["AUTHZ_DEPLOY_WORKLOAD"] = "authz_deploy_workload";
    OperationStep["AUTHZ_WAIT_READY"] = "authz_wait_ready";
    OperationStep["AUTHZ_INSTALL_FINALIZE"] = "authz_install_finalize";
    // Authz uninstall steps
    OperationStep["AUTHZ_UNINSTALL_INIT"] = "authz_uninstall_init";
    OperationStep["AUTHZ_UNINSTALL_DELETE_WORKLOAD"] = "authz_uninstall_delete_workload";
    OperationStep["AUTHZ_UNINSTALL_FINALIZE"] = "authz_uninstall_finalize";
    // Velero install
    OperationStep["VELERO_INSTALL_RENDER_MANIFESTS"] = "velero_install_render_manifests";
    OperationStep["VELERO_INSTALL_APPLY_NAMESPACE"] = "velero_install_apply_namespace";
    OperationStep["VELERO_INSTALL_APPLY_CRDS"] = "velero_install_apply_crds";
    OperationStep["VELERO_INSTALL_APPLY_RBAC"] = "velero_install_apply_rbac";
    OperationStep["VELERO_INSTALL_APPLY_CREDENTIALS_SECRET"] = "velero_install_apply_credentials_secret";
    OperationStep["VELERO_INSTALL_APPLY_DEPLOYMENT"] = "velero_install_apply_deployment";
    OperationStep["VELERO_INSTALL_APPLY_BSL"] = "velero_install_apply_bsl";
    OperationStep["VELERO_INSTALL_APPLY_VSL"] = "velero_install_apply_vsl";
    OperationStep["VELERO_INSTALL_WAIT_READY"] = "velero_install_wait_ready";
    OperationStep["VELERO_INSTALL_FINALIZE"] = "velero_install_finalize";
    // Run backup job
    OperationStep["BACKUP_RUN_RESOLVE_SCOPE"] = "backup_run_resolve_scope";
    OperationStep["BACKUP_RUN_CREATE_VELERO_CR"] = "backup_run_create_velero_cr";
    OperationStep["BACKUP_RUN_WATCH_PROGRESS"] = "backup_run_watch_progress";
    OperationStep["BACKUP_RUN_RECORD_ARTIFACT"] = "backup_run_record_artifact";
    OperationStep["BACKUP_RUN_ENQUEUE_REPLICATION"] = "backup_run_enqueue_replication";
    OperationStep["BACKUP_RUN_FINALIZE"] = "backup_run_finalize";
    // Replicate backup
    OperationStep["REPLICATE_PRESIGN_SOURCE"] = "replicate_presign_source";
    OperationStep["REPLICATE_LAUNCH_RCLONE"] = "replicate_launch_rclone";
    OperationStep["REPLICATE_WAIT_COMPLETION"] = "replicate_wait_completion";
    OperationStep["REPLICATE_VERIFY_OBJECTS"] = "replicate_verify_objects";
    OperationStep["REPLICATE_MARK_AVAILABLE"] = "replicate_mark_available";
    // Restore
    OperationStep["RESTORE_SELECT_SOURCE"] = "restore_select_source";
    OperationStep["RESTORE_ENSURE_BSL"] = "restore_ensure_bsl";
    OperationStep["RESTORE_CREATE_VELERO_CR"] = "restore_create_velero_cr";
    OperationStep["RESTORE_WATCH_PROGRESS"] = "restore_watch_progress";
    OperationStep["RESTORE_POSTPROCESS"] = "restore_postprocess";
    // Health-check destination
    OperationStep["DEST_HEALTH_CONNECT"] = "dest_health_connect";
    OperationStep["DEST_HEALTH_LIST_BUCKET"] = "dest_health_list_bucket";
    OperationStep["DEST_HEALTH_WRITE_PROBE"] = "dest_health_write_probe";
    OperationStep["DEST_HEALTH_DELETE_PROBE"] = "dest_health_delete_probe";
    OperationStep["DEST_HEALTH_UPDATE_USAGE"] = "dest_health_update_usage";
    // Etcd L1
    OperationStep["ETCD_RENDER_DROPIN"] = "etcd_render_dropin";
    OperationStep["ETCD_SSH_APPLY"] = "etcd_ssh_apply";
    OperationStep["ETCD_RELOAD_K3S"] = "etcd_reload_k3s";
    OperationStep["ETCD_VERIFY_FIRST_SNAPSHOT"] = "etcd_verify_first_snapshot";
    // Provider OS snapshot
    OperationStep["PROVIDER_SNAPSHOT_INIT"] = "provider_snapshot_init";
    OperationStep["PROVIDER_SNAPSHOT_CREATE"] = "provider_snapshot_create";
    OperationStep["PROVIDER_SNAPSHOT_WAIT"] = "provider_snapshot_wait";
    OperationStep["PROVIDER_SNAPSHOT_FINALIZE"] = "provider_snapshot_finalize";
    // Pre-deploy snapshot
    OperationStep["PREDEPLOY_SNAPSHOT_INIT"] = "predeploy_snapshot_init";
    OperationStep["PREDEPLOY_SNAPSHOT_RUN"] = "predeploy_snapshot_run";
    OperationStep["PREDEPLOY_SNAPSHOT_FINALIZE"] = "predeploy_snapshot_finalize";
    // VM backups (provider-side)
    OperationStep["VM_BACKUPS_RESOLVE_PROVIDER"] = "vm_backups_resolve_provider";
    OperationStep["VM_BACKUPS_TOGGLE_NODE"] = "vm_backups_toggle_node";
    OperationStep["VM_BACKUPS_FINALIZE"] = "vm_backups_finalize";
    // Quick setup orchestrator
    OperationStep["QUICK_SETUP_RESOLVE_PROVISIONERS"] = "quick_setup_resolve_provisioners";
    OperationStep["QUICK_SETUP_PROVISION_PRIMARY"] = "quick_setup_provision_primary";
    OperationStep["QUICK_SETUP_PROVISION_REPLICA"] = "quick_setup_provision_replica";
    OperationStep["QUICK_SETUP_CREATE_POLICY"] = "quick_setup_create_policy";
    OperationStep["QUICK_SETUP_INSTALL_VELERO"] = "quick_setup_install_velero";
    OperationStep["QUICK_SETUP_RUN_FIRST_BACKUP"] = "quick_setup_run_first_backup";
    OperationStep["QUICK_SETUP_FINALIZE"] = "quick_setup_finalize";
})(OperationStep || (exports.OperationStep = OperationStep = {}));
let InfrastructureOperationEntity = class InfrastructureOperationEntity {
};
exports.InfrastructureOperationEntity = InfrastructureOperationEntity;
__decorate([
    (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
    __metadata("design:type", String)
], InfrastructureOperationEntity.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.Column)({
        type: 'enum',
        enum: OperationType,
        nullable: true,
    }),
    __metadata("design:type", String)
], InfrastructureOperationEntity.prototype, "operationType", void 0);
__decorate([
    (0, typeorm_1.Column)({
        type: 'enum',
        enum: OperationStatus,
        default: OperationStatus.PENDING,
    }),
    __metadata("design:type", String)
], InfrastructureOperationEntity.prototype, "status", void 0);
__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    __metadata("design:type", String)
], InfrastructureOperationEntity.prototype, "resourceType", void 0);
__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    __metadata("design:type", String)
], InfrastructureOperationEntity.prototype, "resourceName", void 0);
__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    __metadata("design:type", String)
], InfrastructureOperationEntity.prototype, "resourceId", void 0);
__decorate([
    (0, typeorm_1.Column)({
        type: 'enum',
        enum: cloud_provider_enum_1.CloudProvider,
        nullable: true,
    }),
    __metadata("design:type", String)
], InfrastructureOperationEntity.prototype, "provider", void 0);
__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    __metadata("design:type", String)
], InfrastructureOperationEntity.prototype, "userId", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'json', default: '{}' }),
    __metadata("design:type", Object)
], InfrastructureOperationEntity.prototype, "metadata", void 0);
__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    __metadata("design:type", String)
], InfrastructureOperationEntity.prototype, "errorMessage", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'int', default: 0 }),
    __metadata("design:type", Number)
], InfrastructureOperationEntity.prototype, "progress", void 0);
__decorate([
    (0, typeorm_1.Column)({
        type: 'enum',
        enum: OperationStep,
        nullable: true,
    }),
    __metadata("design:type", String)
], InfrastructureOperationEntity.prototype, "currentStep", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'int', default: 0 }),
    __metadata("design:type", Number)
], InfrastructureOperationEntity.prototype, "currentStepIndex", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'int', default: 0 }),
    __metadata("design:type", Number)
], InfrastructureOperationEntity.prototype, "totalSteps", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'int', default: 0 }),
    __metadata("design:type", Number)
], InfrastructureOperationEntity.prototype, "currentStepProgress", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'int', nullable: true }),
    __metadata("design:type", Number)
], InfrastructureOperationEntity.prototype, "estimatedDurationInSeconds", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'timestamptz', nullable: true }),
    __metadata("design:type", Date)
], InfrastructureOperationEntity.prototype, "startedAt", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'timestamptz', nullable: true }),
    __metadata("design:type", Date)
], InfrastructureOperationEntity.prototype, "completedAt", void 0);
__decorate([
    (0, typeorm_1.CreateDateColumn)({ type: 'timestamptz' }),
    __metadata("design:type", Date)
], InfrastructureOperationEntity.prototype, "createdAt", void 0);
__decorate([
    (0, typeorm_1.UpdateDateColumn)({ type: 'timestamptz' }),
    __metadata("design:type", Date)
], InfrastructureOperationEntity.prototype, "updatedAt", void 0);
exports.InfrastructureOperationEntity = InfrastructureOperationEntity = __decorate([
    (0, typeorm_1.Entity)('infrastructure_operations')
], InfrastructureOperationEntity);
