search-client
Version:
Javascript library for executing searches in the Haive search-index via the SearchManager REST interface.
59 lines • 2.17 kB
JavaScript
import 'url-polyfill';
/**
* A common settings base-class for the descending Autocomplete, Categorize and Find settings classes.
*
* @param TDataType Defines the data-type that the descendant settings-class needs to return on lookups.
*/
var BaseSettings = /** @class */ (function () {
function BaseSettings() {
}
Object.defineProperty(BaseSettings.prototype, "url", {
/**
* Returns the actual url for the service.
*/
get: function () {
var parts = [];
parts.push(this.baseUrl);
if (this.basePath) {
parts.push(this.basePath);
}
if (this.servicePath) {
parts.push(this.servicePath);
}
var url = new URL(parts.join('/'));
return url.toString();
},
set: function (value) {
// Do nothing
},
enumerable: false,
configurable: true
});
/**
* Handles the construction of the base-settings class with its properties.
*
* @param settings The settings that are to be set up for the base settings class.
*/
BaseSettings.prototype.init = function (settings) {
if (typeof settings.baseUrl === 'undefined' ||
typeof settings.servicePath === 'undefined') {
throw Error('Must have settings, with baseUrl, basePath and servicePath.');
}
this.enabled =
typeof settings.enabled !== 'undefined' ? settings.enabled : true;
this.baseUrl = settings.baseUrl.replace(/\/+$/, '');
this.basePath =
typeof settings.basePath !== 'undefined'
? settings.basePath.replace(/(^\/+)|(\/+$)/g, '')
: 'RestService/v4';
this.servicePath = settings.servicePath.replace(/(^\/+)|(\/+$)/g, '');
this.cbWarning = settings.cbWarning;
this.cbError = settings.cbError;
this.cbRequest = settings.cbRequest;
this.cbSuccess = settings.cbSuccess;
this.cbResultState = settings.cbResultState;
};
return BaseSettings;
}());
export { BaseSettings };
//# sourceMappingURL=BaseSettings.js.map