"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.ScalewayProviderModule = void 0;
const common_1 = require("@nestjs/common");
const cloud_provider_enum_1 = require("../../enums/cloud-provider.enum");
const dns_provider_enum_1 = require("../../enums/dns-provider.enum");
const scaleway_instances_adapter_1 = require("./scaleway-instances.adapter");
const scaleway_baremetal_adapter_1 = require("./scaleway-baremetal.adapter");
const scaleway_provider_service_1 = require("./scaleway-provider.service");
const scaleway_firewall_service_1 = require("./scaleway-firewall.service");
const scaleway_dns_service_1 = require("./scaleway-dns.service");
const scaleway_vpc_adapter_1 = require("./scaleway-vpc.adapter");
const scaleway_iam_adapter_1 = require("./scaleway-iam.adapter");
const scaleway_capabilities_service_1 = require("./scaleway-capabilities.service");
const scaleway_object_storage_backend_1 = require("./object-storage/scaleway-object-storage.backend");
const scaleway_bootstrap_seeder_service_1 = require("./scaleway-bootstrap-seeder.service");
const shared_infrastructure_module_1 = require("../../../infrastructure/shared/shared-infrastructure.module");
const storage_module_1 = require("../../../storage/storage.module");
const storage_backend_provider_enum_1 = require("../../../storage/enums/storage-backend-provider.enum");
const storage_backend_registry_token_1 = require("../../../storage/tokens/storage-backend-registry.token");
const tokens_1 = require("../../core/tokens");
/**
 * Scaleway provider module — auto-registers Scaleway into the global provider registry.
 *
 * Covers both Scaleway Instances (VMs) and Elastic Metal (bare metal) through
 * a unified ScalewayProviderService backed by two internal adapters.
 *
 * Services depend on 'ICredentialProvider' which must be provided globally
 * by the parent module (ProvidersModule / CliProvidersModule marked @Global()).
 *
 * NOTE: questo modulo NON ha dipendenze TypeORM. Per il provisioning automatico
 * di Scaleway Object Storage (DB-dipendente, API only) vedere
 * [ScalewayObjectStorageModule](object-storage/scaleway-object-storage.module.ts).
 *
 * To add Scaleway to the system: import ScalewayProviderModule in ProvidersModule.
 */
let ScalewayProviderModule = class ScalewayProviderModule {
};
exports.ScalewayProviderModule = ScalewayProviderModule;
exports.ScalewayProviderModule = ScalewayProviderModule = __decorate([
    (0, common_1.Module)({
        imports: [storage_module_1.StorageModule, shared_infrastructure_module_1.SharedInfrastructureModule],
        providers: [
            scaleway_instances_adapter_1.ScalewayInstancesAdapter,
            scaleway_baremetal_adapter_1.ScalewayBareMetalAdapter,
            scaleway_provider_service_1.ScalewayProviderService,
            scaleway_firewall_service_1.ScalewayFirewallService,
            scaleway_dns_service_1.ScalewayDnsService,
            scaleway_vpc_adapter_1.ScalewayVpcAdapter,
            scaleway_iam_adapter_1.ScalewayIamAdapter,
            scaleway_capabilities_service_1.ScalewayCapabilitiesService,
            scaleway_object_storage_backend_1.ScalewayObjectStorageBackend,
            scaleway_bootstrap_seeder_service_1.ScalewayBootstrapSeeder,
            (0, storage_backend_registry_token_1.multiBackupStorageProvider)({
                provide: storage_backend_registry_token_1.BACKUP_STORAGE_BACKEND_REGISTRY,
                useFactory: (s) => ({
                    provider: storage_backend_provider_enum_1.StorageBackendProvider.SCALEWAY_OBJECT_STORAGE,
                    backend: s,
                }),
                inject: [scaleway_object_storage_backend_1.ScalewayObjectStorageBackend],
                multi: true,
            }),
            (0, tokens_1.multiProvider)({
                provide: tokens_1.CAPABILITIES_PROVIDER_REGISTRY,
                useFactory: (s) => ({
                    provider: cloud_provider_enum_1.CloudProvider.SCALEWAY,
                    service: s,
                }),
                inject: [scaleway_capabilities_service_1.ScalewayCapabilitiesService],
                multi: true,
            }),
            (0, tokens_1.multiProvider)({
                provide: tokens_1.CLOUD_PROVIDER_REGISTRY,
                useFactory: (s) => ({
                    provider: cloud_provider_enum_1.CloudProvider.SCALEWAY,
                    service: s,
                }),
                inject: [scaleway_provider_service_1.ScalewayProviderService],
                multi: true,
            }),
            (0, tokens_1.multiProvider)({
                provide: tokens_1.FIREWALL_PROVIDER_REGISTRY,
                useFactory: (s) => ({
                    provider: cloud_provider_enum_1.CloudProvider.SCALEWAY,
                    service: s,
                }),
                inject: [scaleway_firewall_service_1.ScalewayFirewallService],
                multi: true,
            }),
            (0, tokens_1.multiProvider)({
                provide: tokens_1.DNS_PROVIDER_REGISTRY,
                useFactory: (s) => ({
                    provider: dns_provider_enum_1.DnsProvider.SCALEWAY,
                    service: s,
                }),
                inject: [scaleway_dns_service_1.ScalewayDnsService],
                multi: true,
            }),
        ],
        exports: [
            scaleway_provider_service_1.ScalewayProviderService,
            scaleway_firewall_service_1.ScalewayFirewallService,
            scaleway_dns_service_1.ScalewayDnsService,
            scaleway_vpc_adapter_1.ScalewayVpcAdapter,
            scaleway_iam_adapter_1.ScalewayIamAdapter,
            scaleway_capabilities_service_1.ScalewayCapabilitiesService,
            scaleway_object_storage_backend_1.ScalewayObjectStorageBackend,
            scaleway_bootstrap_seeder_service_1.ScalewayBootstrapSeeder,
            tokens_1.CLOUD_PROVIDER_REGISTRY,
            tokens_1.FIREWALL_PROVIDER_REGISTRY,
            tokens_1.DNS_PROVIDER_REGISTRY,
            tokens_1.CAPABILITIES_PROVIDER_REGISTRY,
            storage_backend_registry_token_1.BACKUP_STORAGE_BACKEND_REGISTRY,
        ],
    })
], ScalewayProviderModule);
