"use strict";
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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.HetznerObjectStorageModule = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const storage_module_1 = require("../../../../storage/storage.module");
const storage_backend_provider_enum_1 = require("../../../../storage/enums/storage-backend-provider.enum");
const object_storage_provisioner_registry_token_1 = require("../../../../storage/tokens/object-storage-provisioner-registry.token");
const api_token_entity_1 = require("../../../../access/entities/api-token.entity");
const api_token_repository_1 = require("../../../../access/repositories/api-token.repository");
const key_storage_service_1 = require("../../../../access/services/key-storage.service");
const hetzner_provider_module_1 = require("../hetzner-provider.module");
const hetzner_object_storage_connection_service_1 = require("./hetzner-object-storage-connection.service");
const hetzner_object_storage_connection_controller_1 = require("./hetzner-object-storage-connection.controller");
const hetzner_object_storage_provisioner_1 = require("./hetzner-object-storage.provisioner");
/**
 * API-only module che aggiunge il provisioning automatico di Hetzner Object
 * Storage (require ApiTokenRepository → DataSource TypeORM, NON safe per CLI).
 *
 * Importa questo modulo in ProvidersModule (API), NON in CliProvidersModule.
 */
let HetznerObjectStorageModule = class HetznerObjectStorageModule {
};
exports.HetznerObjectStorageModule = HetznerObjectStorageModule;
exports.HetznerObjectStorageModule = HetznerObjectStorageModule = __decorate([
    (0, common_1.Module)({
        imports: [
            storage_module_1.StorageModule,
            hetzner_provider_module_1.HetznerProviderModule,
            typeorm_1.TypeOrmModule.forFeature([api_token_entity_1.ApiTokenEntity]),
        ],
        controllers: [hetzner_object_storage_connection_controller_1.HetznerObjectStorageConnectionController],
        providers: [
            api_token_repository_1.ApiTokenRepository,
            key_storage_service_1.KeyStorageService,
            hetzner_object_storage_connection_service_1.HetznerObjectStorageConnectionService,
            hetzner_object_storage_provisioner_1.HetznerObjectStorageProvisioner,
            (0, object_storage_provisioner_registry_token_1.multiProvisionerProvider)({
                provide: object_storage_provisioner_registry_token_1.OBJECT_STORAGE_PROVISIONER_REGISTRY,
                useFactory: (p) => ({
                    provider: storage_backend_provider_enum_1.StorageBackendProvider.HETZNER_OBJECT_STORAGE,
                    provisioner: p,
                }),
                inject: [hetzner_object_storage_provisioner_1.HetznerObjectStorageProvisioner],
                multi: true,
            }),
        ],
        exports: [
            hetzner_object_storage_connection_service_1.HetznerObjectStorageConnectionService,
            hetzner_object_storage_provisioner_1.HetznerObjectStorageProvisioner,
            object_storage_provisioner_registry_token_1.OBJECT_STORAGE_PROVISIONER_REGISTRY,
        ],
    })
], HetznerObjectStorageModule);
