"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseCliWorkerConfig = void 0;
const semver_1 = require("semver");
const lib_1 = require("tnp-core/lib");
//#region base worker config
class BaseCliWorkerConfig {
    static from(opt) {
        return lib_1._.merge(new BaseCliWorkerConfig(), opt);
    }
    /**
     * path to file where config is stored
     */
    pathToFile;
    /**
     * port taken by service
     */
    port;
    /**
     * unique in whole system id of service
     */
    serviceID;
    /**
     * pid of service process
     */
    pid;
    /**
     * timestamp when service was started
     * (in other cases = null)
     */
    startTimestamp;
    /**
     * version
     */
    version;
    hasBiggerOrEqualWorkerVersionThan(other) {
        //#region @backendFunc
        other = BaseCliWorkerConfig.from(other);
        if (this.serviceID !== other.serviceID) {
            return false;
        }
        if (!this.version || !other.version) {
            false;
        }
        try {
            return (0, semver_1.gte)(this.version, other.version);
        }
        catch (error) {
            return false;
        }
        //#endregion
    }
    isEquals(other) {
        other = BaseCliWorkerConfig.from(other);
        return (!!this.serviceID &&
            !!this.port &&
            !!this.pid &&
            this.serviceID === other.serviceID &&
            this.port === other.port &&
            this.pid === other.pid);
    }
    get isEmpty() {
        return !this.serviceID && !this.port && !this.pid;
    }
}
exports.BaseCliWorkerConfig = BaseCliWorkerConfig;
//#endregion
//# sourceMappingURL=base-cli-worker-config.js.map