/**
 * CoreTraffic Platform Service Provider
 *
 * CoreTraffic is a core infrastructure service that provides reverse proxy functionality.
 * Unlike other platform services:
 * - It doesn't provision resources for user services
 * - It's started automatically by Onebox and cannot be stopped by users
 * - It delegates to the existing reverse proxy manager for actual operations
 */
import { BasePlatformServiceProvider } from './base.js';
import { logger } from '../../../logging.js';
export class CoreTrafficProvider extends BasePlatformServiceProvider {
    type = 'coretraffic';
    displayName = 'CoreTraffic Reverse Proxy';
    resourceTypes = [];
    isCore = true;
    constructor(oneboxRef) {
        super(oneboxRef);
    }
    async getDefaultConfig() {
        return {
            image: 'code.foss.global/serve.zone/coretraffic:latest',
            port: 80,
            volumes: [],
            environment: {},
        };
    }
    getEnvVarMappings() {
        return [];
    }
    async deployContainer() {
        logger.info('Starting CoreTraffic via reverse proxy manager...');
        const reverseProxy = this.oneboxRef.reverseProxy;
        await reverseProxy.startHttp();
        const platformService = await this.oneboxRef.database.getPlatformServiceByType(this.type);
        if (platformService) {
            await this.oneboxRef.database.updatePlatformService(platformService.id, {
                status: 'running',
                containerId: 'onebox-coretraffic',
            });
        }
        logger.success('CoreTraffic platform service started');
        return 'onebox-coretraffic';
    }
    async stopContainer(_containerId) {
        throw new Error('CoreTraffic is a core infrastructure service and cannot be stopped');
    }
    async healthCheck() {
        try {
            const reverseProxy = this.oneboxRef.reverseProxy;
            const status = reverseProxy.getStatus();
            return status.http.running;
        }
        catch (error) {
            logger.debug(`CoreTraffic health check failed: ${error}`);
            return false;
        }
    }
    async provisionResource(_userService) {
        throw new Error('CoreTraffic does not provision resources for user services');
    }
    async deprovisionResource(_resource, _credentials) {
        throw new Error('CoreTraffic does not manage resources for user services');
    }
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29yZXRyYWZmaWMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi90cy9jbGFzc2VzL3BsYXRmb3JtLXNlcnZpY2VzL3Byb3Z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