"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.TaonPortsContext_1736199486472_addingNotAssignablePorts = void 0;
// @ts-nocheck
const lib_1 = require("taon/lib");
const tcp_udp_ports_1 = require("../base/tcp-udp-ports");
const portsWithDescription = {
    3000: 'Commonly used for development servers',
    3001: 'Alternate development server port',
    3306: 'MySQL',
    3389: 'Remote Desktop Protocol (RDP)',
    3478: 'STUN (Session Traversal Utilities for NAT)',
    4000: 'Alternative development server port',
    4200: 'Angular CLI Development Server',
    4500: 'IPSec NAT traversal',
    4567: 'Sinatra Default Port',
    5000: 'Flask, Python development server, or Node.js apps',
    5432: 'PostgreSQL',
    5500: 'Live Server (VS Code Extension)',
    5672: 'RabbitMQ',
    5800: 'VNC Remote Desktop (HTTP)',
    5900: 'VNC Remote Desktop',
    5984: 'CouchDB',
    6000: 'in use by something in macos',
};
let TaonPortsContext_1736199486472_addingNotAssignablePorts = class TaonPortsContext_1736199486472_addingNotAssignablePorts extends lib_1.TaonBaseMigration {
    portsController = this.injectController(tcp_udp_ports_1.TaonPortsController);
    commonPortsFrom3000to6000 = Object.keys(portsWithDescription).map(Number);
    async up(queryRunner) {
        const db = await queryRunner.manager.getRepository(tcp_udp_ports_1.Port);
        const allPorts = this.commonPortsFrom3000to6000.map(port => tcp_udp_ports_1.Port.from({
            port,
            serviceId: `not assignable (${portsWithDescription[port]})`,
            status: 'assigned-taken-by-os',
        }));
        await db.save(allPorts);
        for (const commonPortObj of allPorts) {
            this.portsController.portsCache.set(commonPortObj.serviceId, commonPortObj);
        }
    }
    async down(queryRunner) {
        const db = await queryRunner.manager.getRepository(tcp_udp_ports_1.Port);
        await db.remove(await db.find({
            where: {
                status: 'assigned-taken-by-os',
            },
        }));
        const allPorts = Array.from(this.portsController.portsCache.values()).filter(f => f.status === 'assigned-taken-by-os');
        for (const port of allPorts) {
            this.portsController.portsCache.delete(port.serviceId);
        }
    }
};
exports.TaonPortsContext_1736199486472_addingNotAssignablePorts = TaonPortsContext_1736199486472_addingNotAssignablePorts;
exports.TaonPortsContext_1736199486472_addingNotAssignablePorts = TaonPortsContext_1736199486472_addingNotAssignablePorts = __decorate([
    (0, lib_1.TaonMigration)({
        className: 'TaonPortsContext_1736199486472_addingNotAssignablePorts',
    })
], TaonPortsContext_1736199486472_addingNotAssignablePorts);
//# sourceMappingURL=1736199486472_addingNotAssignablePorts.js.map