UNPKG

raas-client

Version:
39 lines 2.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const raas_core_1 = require("raas-core"); const common_1 = require("./common"); class Installable { constructor(connection, emitter) { this.connection = connection; this.emitter = emitter; this.listenToInstallableChanges(); } listenToInstallableChanges() { this.connection.onNotification(raas_core_1.Messages.Client.InstallableServerAddedNotification.type, installableServer => { this.emitter.emit('installableServerAdded', installableServer); }); this.connection.onNotification(raas_core_1.Messages.Client.InstallableServerUpdatedNotification.type, installableServer => { this.emitter.emit('installableServerUpdated', installableServer); }); this.connection.onNotification(raas_core_1.Messages.Client.InstallableServerDeletedNotification.type, installableServer => { this.emitter.emit('installableServerDeleted', installableServer); }); } addInstallable(installable, timeout = 2000) { return this.send(raas_core_1.Messages.Server.AddInstallableServerRequest.type, installable, 'installableServerAdded', (param) => param.id === installable.id, timeout, common_1.ErrorMessages.ADDINSTALLABLE_TIMEOUT); } updateInstallableServer(installable, timeout = 2000) { return this.send(raas_core_1.Messages.Server.UpdateInstallableServerRequest.type, installable, 'installableServerUpdated', (param) => param.id === installable.id, timeout, common_1.ErrorMessages.UPDATEINSTALLABLE_TIMEOUT); } deleteInstallableServer(installable, timeout = 2000) { return this.send(raas_core_1.Messages.Server.DeleteInstallableServerRequest.type, installable, 'installableServerDeleted', (param) => param.id === installable.id, timeout, common_1.ErrorMessages.DELETEINSTALLABLE_TIMEOUT); } getAllInstallableServers(timeout = 2000) { return common_1.Common.sendSimpleRequest(this.connection, raas_core_1.Messages.Server.GetInstallableServersRequest.type, null, timeout, common_1.ErrorMessages.GETALLINSTALLABLESERVERS_TIMEOUT); } send(messageType, payload, id, listener, timeout, timeoutMessage) { return common_1.Common.sendRequestSync(this.connection, messageType, payload, this.emitter, id, listener, timeout, timeoutMessage); } } exports.Installable = Installable; //# sourceMappingURL=installable.js.map