UNPKG

diffusion

Version:

Diffusion JavaScript client

90 lines (89 loc) 3.97 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.RemoteServerBuilderImpl = void 0; var errors_1 = require("./../../../errors/errors"); var remote_servers_1 = require("./../../../features/remote-servers"); var remote_server_definition_1 = require("./../../services/remote-servers/remote-server-definition"); var require_non_null_1 = require("./../../util/require-non-null"); /** * Implementation of {@link RemoteServersBuilder}. * * @since 6.7 */ // eslint-disable-next-line deprecation/deprecation var RemoteServerBuilderImpl = /** @class */ (function () { /** * Constructor. */ function RemoteServerBuilderImpl(topicSelectors) { this.thePrincipal = ''; this.theCredentials = undefined; this.theConnectionOptions = {}; this.theMissingTopicNotificationFilter = undefined; this.theTopicSelectors = topicSelectors; } RemoteServerBuilderImpl.prototype.principal = function (principal) { this.thePrincipal = require_non_null_1.requireNonNull(principal, 'principal'); return this; }; RemoteServerBuilderImpl.prototype.credentials = function (credentials) { this.theCredentials = credentials; return this; }; RemoteServerBuilderImpl.prototype.connectionOptions = function (connectionOptions) { require_non_null_1.requireNonNull(connectionOptions, 'connectionOptions'); this.theConnectionOptions = __assign({}, connectionOptions); return this; }; RemoteServerBuilderImpl.prototype.connectionOption = function (connectionOption, value) { if (value === null || value === undefined) { delete this.theConnectionOptions[require_non_null_1.requireNonNull(connectionOption, 'connectionOption')]; } else { this.theConnectionOptions[require_non_null_1.requireNonNull(connectionOption, 'connectionOption')] = value; } return this; }; RemoteServerBuilderImpl.prototype.missingTopicNotificationFilter = function (filter) { if (filter !== null) { try { this.theTopicSelectors.parse(filter); } catch (err) { throw new errors_1.IllegalArgumentError("filter is invalid: " + err); } } this.theMissingTopicNotificationFilter = filter === null ? undefined : filter; return this; }; RemoteServerBuilderImpl.prototype.reset = function () { this.thePrincipal = ''; this.theCredentials = undefined; this.theConnectionOptions = {}; this.theMissingTopicNotificationFilter = undefined; return this; }; RemoteServerBuilderImpl.prototype.create = function (name, url) { var trimmedName = require_non_null_1.requireNonNull(name, 'name').trim(); if (trimmedName.length === 0) { throw new errors_1.IllegalArgumentError('Non whitespace name must be supplied'); } var trimmedUrl = require_non_null_1.requireNonNull(url, 'url').trim(); if (trimmedUrl.length === 0) { throw new errors_1.IllegalArgumentError('Non whitespace url must be supplied'); } return new remote_server_definition_1.RemoteServerDefinitionImpl(remote_servers_1.RemoteServerType.SECONDARY_INITIATOR, trimmedName, [trimmedUrl], this.thePrincipal, this.theConnectionOptions, this.theCredentials, undefined, this.theMissingTopicNotificationFilter); }; return RemoteServerBuilderImpl; }()); exports.RemoteServerBuilderImpl = RemoteServerBuilderImpl;