UNPKG

apisearch-ui

Version:

Javascript User Interface of Apisearch.

1,569 lines (1,471 loc) 622 kB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["apisearchUI"] = factory(); else root["apisearchUI"] = factory(); })(self, function() { return /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ "./node_modules/apisearch/lib/Apisearch.js": /*!*************************************************!*\ !*** ./node_modules/apisearch/lib/Apisearch.js ***! \*************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; exports.__esModule = true; var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); var AxiosClient_1 = __webpack_require__(/*! ./Http/AxiosClient */ "./node_modules/apisearch/lib/Http/AxiosClient.js"); var Query_1 = __webpack_require__(/*! ./Query/Query */ "./node_modules/apisearch/lib/Query/Query.js"); var Query_2 = __webpack_require__(/*! ./Query/Query */ "./node_modules/apisearch/lib/Query/Query.js"); var Query_3 = __webpack_require__(/*! ./Query/Query */ "./node_modules/apisearch/lib/Query/Query.js"); var SortBy_1 = __webpack_require__(/*! ./Query/SortBy */ "./node_modules/apisearch/lib/Query/SortBy.js"); var HttpRepository_1 = __webpack_require__(/*! ./Repository/HttpRepository */ "./node_modules/apisearch/lib/Repository/HttpRepository.js"); var Result_1 = __webpack_require__(/*! ./Result/Result */ "./node_modules/apisearch/lib/Result/Result.js"); var ResultAggregations_1 = __webpack_require__(/*! ./Result/ResultAggregations */ "./node_modules/apisearch/lib/Result/ResultAggregations.js"); var Transformer_1 = __webpack_require__(/*! ./Transformer/Transformer */ "./node_modules/apisearch/lib/Transformer/Transformer.js"); var CacheClient_1 = __webpack_require__(/*! ./Http/CacheClient */ "./node_modules/apisearch/lib/Http/CacheClient.js"); /** * Apisearch class */ var Apisearch = /** @class */ (function () { function Apisearch() { } /** * Constructor * * @param config * * @return {HttpRepository} */ Apisearch.createRepository = function (config) { Apisearch.ensureRepositoryConfigIsValid(config); config.options = tslib_1.__assign({ api_version: "v1", override_queries: true, timeout: 3000 }, config.options); /** * Client */ var httpClient = typeof config.options.http_client !== "undefined" ? config.options.http_client : new AxiosClient_1.AxiosClient(config.options.endpoint, config.options.api_version, config.options.timeout, config.options.override_queries); if (config.options.use_cache) { httpClient = new CacheClient_1.CacheClient(httpClient); } return new HttpRepository_1.HttpRepository(httpClient, config.app_id, config.index_id, config.token, new Transformer_1.Transformer()); }; /** * Ensure the Repository configuration is valid * * @param config */ Apisearch.ensureRepositoryConfigIsValid = function (config) { Apisearch.ensureIsDefined(config.app_id, "app_id"); Apisearch.ensureIsDefined(config.index_id, "index_id"); Apisearch.ensureIsDefined(config.token, "token"); Apisearch.ensureIsDefined(config.options.endpoint, "options.endpoint"); }; /** * Ensure the value is not undefined * * @param param * @param name */ Apisearch.ensureIsDefined = function (param, name) { if (typeof param === "undefined") { throw new TypeError(name + " parameter must be defined."); } }; /** * Created located * * @param coordinate * @param queryText * @param page * @param size * * @returns {Query} */ Apisearch.createQueryLocated = function (coordinate, queryText, page, size) { if (page === void 0) { page = Query_1.QUERY_DEFAULT_PAGE; } if (size === void 0) { size = Query_2.QUERY_DEFAULT_SIZE; } return Query_3.Query.createLocated(coordinate, queryText, page, size); }; /** * Create * * @param queryText * @param page * @param size * * @returns {Query} */ Apisearch.createQuery = function (queryText, page, size) { if (page === void 0) { page = Query_1.QUERY_DEFAULT_PAGE; } if (size === void 0) { size = Query_2.QUERY_DEFAULT_SIZE; } return Query_3.Query.create(queryText, page, size); }; /** * Create match all * * @return {Query} */ Apisearch.createQueryMatchAll = function () { return Query_3.Query.createMatchAll(); }; /** * Create by UUID * * @param uuid * * @return {Query} */ Apisearch.createQueryByUUID = function (uuid) { return Query_3.Query.createByUUID(uuid); }; /** * Create by UUIDs * * @param uuids * * @return {Query} */ Apisearch.createQueryByUUIDs = function () { var uuids = []; for (var _i = 0; _i < arguments.length; _i++) { uuids[_i] = arguments[_i]; } return Query_3.Query.createByUUIDs.apply(Query_3.Query, uuids); }; /** * Create empty result * * @return {Result} */ Apisearch.createEmptyResult = function () { return Result_1.Result.create("", 0, 0, new ResultAggregations_1.ResultAggregations(0), [], []); }; /** * Create empty sortby * * @return {SortBy} */ Apisearch.createEmptySortBy = function () { return SortBy_1.SortBy.create(); }; /** * Create empty sortby * * @return {SortBy} */ Apisearch.createEmptyScoreStrategy = function () { return SortBy_1.SortBy.create(); }; return Apisearch; }()); exports["default"] = Apisearch; /***/ }), /***/ "./node_modules/apisearch/lib/Config/Config.js": /*!*****************************************************!*\ !*** ./node_modules/apisearch/lib/Config/Config.js ***! \*****************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; exports.__esModule = true; exports.Config = exports.DEFAULT_REPLICAS = exports.DEFAULT_SHARDS = void 0; var Synonym_1 = __webpack_require__(/*! ./Synonym */ "./node_modules/apisearch/lib/Config/Synonym.js"); exports.DEFAULT_SHARDS = 1; exports.DEFAULT_REPLICAS = 0; /** * Result class */ var Config = /** @class */ (function () { /** * Constructor * * @param language * @param storeSearchableMetadata * @param shards * @param replicas */ function Config(language, storeSearchableMetadata, shards, replicas) { if (language === void 0) { language = null; } if (storeSearchableMetadata === void 0) { storeSearchableMetadata = true; } if (shards === void 0) { shards = exports.DEFAULT_SHARDS; } if (replicas === void 0) { replicas = exports.DEFAULT_REPLICAS; } this.synonyms = []; this.language = language; this.storeSearchableMetadata = storeSearchableMetadata; this.shards = shards; this.replicas = replicas; } /** * Get language * * @return {string} */ Config.prototype.getLanguage = function () { return this.language; }; /** * Should searchable metadata be stored * * @return {boolean} */ Config.prototype.shouldSearchableMetadataBeStored = function () { return this.storeSearchableMetadata; }; /** * Add synonym * * @param synonym */ Config.prototype.addSynonym = function (synonym) { this.synonyms.push(synonym); }; /** * Get synonyms * * @return {Synonym[]} */ Config.prototype.getSynonyms = function () { return this.synonyms; }; /** * Get shards * * @return {number} */ Config.prototype.getShards = function () { return this.shards; }; /** * Get replicas * * @return {number} */ Config.prototype.getReplicas = function () { return this.replicas; }; /** * to array */ Config.prototype.toArray = function () { return { language: this.language, store_searchable_metadata: this.storeSearchableMetadata, synonyms: this.synonyms.map(function (synonym) { return synonym.toArray(); }), shards: this.shards, replicas: this.replicas }; }; /** * Create from array */ Config.createFromArray = function (array) { var config = new Config(array.language ? array.language : null, typeof array.store_searchable_metadata == "boolean" ? array.store_searchable_metadata : true); if (array.synonyms instanceof Array && array.synonyms.length > 0) { config.synonyms = array.synonyms.map(function (synonym) { return Synonym_1.Synonym.createFromArray(synonym); }); } config.shards = typeof array.shards == "number" ? array.shards : exports.DEFAULT_SHARDS; config.replicas = typeof array.replicas == "number" ? array.replicas : exports.DEFAULT_REPLICAS; return config; }; return Config; }()); exports.Config = Config; /***/ }), /***/ "./node_modules/apisearch/lib/Config/Synonym.js": /*!******************************************************!*\ !*** ./node_modules/apisearch/lib/Config/Synonym.js ***! \******************************************************/ /***/ ((__unused_webpack_module, exports) => { "use strict"; exports.__esModule = true; exports.Synonym = void 0; /** * Result class */ var Synonym = /** @class */ (function () { /** * Constructor * * @param words */ function Synonym(words) { this.words = words; } /** * get words * * @return {string[]} */ Synonym.prototype.getWords = function () { return this.words; }; /** * Create by words * * @param words * * @return {Synonym} */ Synonym.createbyWords = function (words) { return new Synonym(words); }; /** * To array * * @return {{words: string[]}} */ Synonym.prototype.toArray = function () { return { words: this.words }; }; /** * create from array * * @param array * * @returns {Synonym} */ Synonym.createFromArray = function (array) { return new Synonym(array.words instanceof Object ? array.words : []); }; /** * Expand * * @returns {string} */ Synonym.prototype.expand = function () { return this.words.join(","); }; return Synonym; }()); exports.Synonym = Synonym; /***/ }), /***/ "./node_modules/apisearch/lib/Error/ConnectionError.js": /*!*************************************************************!*\ !*** ./node_modules/apisearch/lib/Error/ConnectionError.js ***! \*************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; exports.__esModule = true; exports.ConnectionError = void 0; var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); var ErrorWithMessage_1 = __webpack_require__(/*! ./ErrorWithMessage */ "./node_modules/apisearch/lib/Error/ErrorWithMessage.js"); /** * Connection error */ var ConnectionError = /** @class */ (function (_super) { tslib_1.__extends(ConnectionError, _super); function ConnectionError() { return _super !== null && _super.apply(this, arguments) || this; } /** * Get transportable http error * * @return {number} */ ConnectionError.getTransportableHTTPError = function () { return 500; }; return ConnectionError; }(ErrorWithMessage_1.ErrorWithMessage)); exports.ConnectionError = ConnectionError; /***/ }), /***/ "./node_modules/apisearch/lib/Error/ErrorWithMessage.js": /*!**************************************************************!*\ !*** ./node_modules/apisearch/lib/Error/ErrorWithMessage.js ***! \**************************************************************/ /***/ ((__unused_webpack_module, exports) => { "use strict"; exports.__esModule = true; exports.ErrorWithMessage = void 0; /** * ConnectError */ var ErrorWithMessage = /** @class */ (function () { /** * Constructor * * @param message */ function ErrorWithMessage(message) { this.message = message; } return ErrorWithMessage; }()); exports.ErrorWithMessage = ErrorWithMessage; /***/ }), /***/ "./node_modules/apisearch/lib/Error/EventError.js": /*!********************************************************!*\ !*** ./node_modules/apisearch/lib/Error/EventError.js ***! \********************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; exports.__esModule = true; exports.EventError = void 0; var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); var ErrorWithMessage_1 = __webpack_require__(/*! ./ErrorWithMessage */ "./node_modules/apisearch/lib/Error/ErrorWithMessage.js"); /** * EventError */ var EventError = /** @class */ (function (_super) { tslib_1.__extends(EventError, _super); function EventError() { return _super !== null && _super.apply(this, arguments) || this; } /** * Get transportable http error * * @return {number} */ EventError.throwEndpointNotAvailable = function () { return new EventError("Endpoint not available"); }; return EventError; }(ErrorWithMessage_1.ErrorWithMessage)); exports.EventError = EventError; /***/ }), /***/ "./node_modules/apisearch/lib/Error/ForbiddenError.js": /*!************************************************************!*\ !*** ./node_modules/apisearch/lib/Error/ForbiddenError.js ***! \************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; exports.__esModule = true; exports.ForbiddenError = void 0; var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); var ErrorWithMessage_1 = __webpack_require__(/*! ./ErrorWithMessage */ "./node_modules/apisearch/lib/Error/ErrorWithMessage.js"); /** * Forbidden Error */ var ForbiddenError = /** @class */ (function (_super) { tslib_1.__extends(ForbiddenError, _super); function ForbiddenError() { return _super !== null && _super.apply(this, arguments) || this; } /** * Get transportable http error * * @return {number} */ ForbiddenError.getTransportableHTTPError = function () { return 403; }; /** * App id is required * * @return {ForbiddenError} */ ForbiddenError.createAppIdIsRequiredException = function () { return new ForbiddenError("AppId query parameter MUST be defined with a valid value"); }; /** * Index id is required * * @return {ForbiddenError} */ ForbiddenError.createIndexIsRequiredException = function () { return new ForbiddenError("Index query parameter MUST be defined with a valid value"); }; /** * Token is required * * @return {ForbiddenError} */ ForbiddenError.createTokenIsRequiredException = function () { return new ForbiddenError("Token query parameter MUST be defined with a valid value"); }; return ForbiddenError; }(ErrorWithMessage_1.ErrorWithMessage)); exports.ForbiddenError = ForbiddenError; /***/ }), /***/ "./node_modules/apisearch/lib/Error/InvalidFormatError.js": /*!****************************************************************!*\ !*** ./node_modules/apisearch/lib/Error/InvalidFormatError.js ***! \****************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; exports.__esModule = true; exports.InvalidFormatError = void 0; var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); var ErrorWithMessage_1 = __webpack_require__(/*! ./ErrorWithMessage */ "./node_modules/apisearch/lib/Error/ErrorWithMessage.js"); /** * Class InvalidFormatError */ var InvalidFormatError = /** @class */ (function (_super) { tslib_1.__extends(InvalidFormatError, _super); function InvalidFormatError() { return _super !== null && _super.apply(this, arguments) || this; } /** * Get transportable http error * * @return {number} */ InvalidFormatError.getTransportableHTTPError = function () { return 400; }; /** * Item representation not valid * * @return {InvalidFormatError} */ InvalidFormatError.itemRepresentationNotValid = function () { return new InvalidFormatError("Item representation not valid. Expecting Item array serialized but found malformed data"); }; /** * Item UUID representation not valid * * @return {InvalidFormatError} */ InvalidFormatError.itemUUIDRepresentationNotValid = function () { return new InvalidFormatError("Item UUID representation not valid. Expecting UUID array serialized but found malformed data"); }; /** * Create Composed UUID bad format. * * @return {InvalidFormatError} */ InvalidFormatError.composedItemUUIDNotValid = function () { return new InvalidFormatError("A composed UUID should always follow this format: {id}~{type}."); }; /** * Create Query sorted by distance without coordinate. * * @return {InvalidFormatError} */ InvalidFormatError.querySortedByDistanceWithoutCoordinate = function () { return new InvalidFormatError("In order to be able to sort by coordinates, you need to create a Query by using Query::createLocated() instead of Query::create()"); }; /** * Query representation not valid * * @return {InvalidFormatError} */ InvalidFormatError.queryFormatNotValid = function () { return new InvalidFormatError("Query Format not valid. Expecting a Query serialized but found malformed data"); }; /** * Coordinate representation not valid * * @return {InvalidFormatError} */ InvalidFormatError.coordinateFormatNotValid = function () { return new InvalidFormatError("A Coordinate should always contain a lat (Latitude) and a lon (Longitude)"); }; /** * Config representation not valid * * @return {InvalidFormatError} */ InvalidFormatError.configFormatNotValid = function () { return new InvalidFormatError("Config Format not valid. Expecting a Config serialized but found malformed data"); }; /** * Token representation not valid * * @return {InvalidFormatError} */ InvalidFormatError.tokenFormatNotValid = function () { return new InvalidFormatError("Token Format not valid. Expecting a Token serialized but found malformed data"); }; /** * Index format not valid. * * @return {InvalidFormatError} */ InvalidFormatError.indexFormatNotValid = function () { return new InvalidFormatError('Index Format not valid. Expecting an Index serialized but found malformed data'); }; /** * IndexUUI format not valid. * * @return {InvalidFormatError} */ InvalidFormatError.indexUUIDFormatNotValid = function () { return new InvalidFormatError('IndexUUID Format not valid. Expecting an IndexUUID serialized but found malformed data'); }; /** * App format not valid. * * @return {InvalidFormatError} */ InvalidFormatError.appUUIDFormatNotValid = function () { return new InvalidFormatError('AppUUID Format not valid. Expecting an AppUUID serialized but found malformed data'); }; /** * Campaign representation not valid * * @return {InvalidFormatError} */ InvalidFormatError.campaignFormatNotValid = function () { return new InvalidFormatError("Campaign Format not valid. Expecting a Campaign serialized but found malformed data"); }; /** * Changes representation not valid * * @return {InvalidFormatError} */ InvalidFormatError.changesFormatNotValid = function () { return new InvalidFormatError("Changes Format not valid. Expecting a Changes serialized but found malformed data"); }; /** * Boost clause representation not valid * * @return {InvalidFormatError} */ InvalidFormatError.boostClauseFormatNotValid = function () { return new InvalidFormatError("Boost clause Format not valid. Expecting a Boost clause serialized but found malformed data"); }; /** * token uuid representation not valid * * @return {InvalidFormatError} */ InvalidFormatError.tokenUUIDFormatNotValid = function () { return new InvalidFormatError("Token UUID Format not valid. Expecting a TokenUUID serialized but found malformed data"); }; /** * User representation not valid * * @return {InvalidFormatError} */ InvalidFormatError.userFormatNotValid = function () { return new InvalidFormatError("User Format not valid. Expecting a User serialized but found malformed data"); }; return InvalidFormatError; }(ErrorWithMessage_1.ErrorWithMessage)); exports.InvalidFormatError = InvalidFormatError; /***/ }), /***/ "./node_modules/apisearch/lib/Error/InvalidTokenError.js": /*!***************************************************************!*\ !*** ./node_modules/apisearch/lib/Error/InvalidTokenError.js ***! \***************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; exports.__esModule = true; exports.InvalidTokenError = void 0; var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); var ErrorWithMessage_1 = __webpack_require__(/*! ./ErrorWithMessage */ "./node_modules/apisearch/lib/Error/ErrorWithMessage.js"); /** * Invalid token error */ var InvalidTokenError = /** @class */ (function (_super) { tslib_1.__extends(InvalidTokenError, _super); function InvalidTokenError() { return _super !== null && _super.apply(this, arguments) || this; } /** * Get transportable http error * * @return {number} */ InvalidTokenError.getTransportableHTTPError = function () { return 401; }; /** * Invalid token permissions * * @param tokenReference * * @return {InvalidTokenError} */ InvalidTokenError.createInvalidTokenPermissions = function (tokenReference) { return new InvalidTokenError("Token " + tokenReference + "not valid"); }; /** * Invalid token permissions * * @param tokenReference * @param maxHitsPerQuery * * @return {InvalidTokenError} */ InvalidTokenError.createInvalidTokenMaxHitsPerQuery = function (tokenReference, maxHitsPerQuery) { return new InvalidTokenError("Token " + tokenReference + "not valid. Max " + maxHitsPerQuery + " hits allowed"); }; return InvalidTokenError; }(ErrorWithMessage_1.ErrorWithMessage)); exports.InvalidTokenError = InvalidTokenError; /***/ }), /***/ "./node_modules/apisearch/lib/Error/ResourceExistsError.js": /*!*****************************************************************!*\ !*** ./node_modules/apisearch/lib/Error/ResourceExistsError.js ***! \*****************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; exports.__esModule = true; exports.ResourceExistsError = void 0; var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); var ErrorWithMessage_1 = __webpack_require__(/*! ./ErrorWithMessage */ "./node_modules/apisearch/lib/Error/ErrorWithMessage.js"); /** * Resource exists error */ var ResourceExistsError = /** @class */ (function (_super) { tslib_1.__extends(ResourceExistsError, _super); function ResourceExistsError() { return _super !== null && _super.apply(this, arguments) || this; } /** * Get transportable http error * * @return {number} */ ResourceExistsError.getTransportableHTTPError = function () { return 409; }; /** * Index not available * * @return {InvalidFormatError} */ ResourceExistsError.indexAvailable = function () { return new ResourceExistsError("Index exists and cannot be created again"); }; /** * Events not available * * @return {InvalidFormatError} */ ResourceExistsError.eventsIndexAvailable = function () { return new ResourceExistsError("Events index exists and cannot be created again"); }; /** * Logs not available * * @return {InvalidFormatError} */ ResourceExistsError.logsIndexAvailable = function () { return new ResourceExistsError("Logs index exists and cannot be created again"); }; return ResourceExistsError; }(ErrorWithMessage_1.ErrorWithMessage)); exports.ResourceExistsError = ResourceExistsError; /***/ }), /***/ "./node_modules/apisearch/lib/Error/ResourceNotAvailableError.js": /*!***********************************************************************!*\ !*** ./node_modules/apisearch/lib/Error/ResourceNotAvailableError.js ***! \***********************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; exports.__esModule = true; exports.ResourceNotAvailableError = void 0; var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); var ErrorWithMessage_1 = __webpack_require__(/*! ./ErrorWithMessage */ "./node_modules/apisearch/lib/Error/ErrorWithMessage.js"); /** * Resource not available error */ var ResourceNotAvailableError = /** @class */ (function (_super) { tslib_1.__extends(ResourceNotAvailableError, _super); function ResourceNotAvailableError() { return _super !== null && _super.apply(this, arguments) || this; } /** * Get transportable http error * * @return {number} */ ResourceNotAvailableError.getTransportableHTTPError = function () { return 404; }; /** * Index not available * * @param resourceId * * @return {InvalidFormatError} */ ResourceNotAvailableError.indexNotAvailable = function (resourceId) { return new ResourceNotAvailableError("Index not available - " + resourceId); }; /** * Events not available * * @param resourceId * * @return {InvalidFormatError} */ ResourceNotAvailableError.eventsIndexNotAvailable = function (resourceId) { return new ResourceNotAvailableError("Events not available - " + resourceId); }; /** * Logs not available * * @param resourceId * * @return {InvalidFormatError} */ ResourceNotAvailableError.logsIndexNotAvailable = function (resourceId) { return new ResourceNotAvailableError("Logs not available - " + resourceId); }; /** * Engine not available * * @param resourceId * * @return {InvalidFormatError} */ ResourceNotAvailableError.engineNotAvailable = function (resourceId) { return new ResourceNotAvailableError("Engine not available - " + resourceId); }; return ResourceNotAvailableError; }(ErrorWithMessage_1.ErrorWithMessage)); exports.ResourceNotAvailableError = ResourceNotAvailableError; /***/ }), /***/ "./node_modules/apisearch/lib/Error/UnknownError.js": /*!**********************************************************!*\ !*** ./node_modules/apisearch/lib/Error/UnknownError.js ***! \**********************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; exports.__esModule = true; exports.UnknownError = void 0; var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); var ErrorWithMessage_1 = __webpack_require__(/*! ./ErrorWithMessage */ "./node_modules/apisearch/lib/Error/ErrorWithMessage.js"); /** * Connection error */ var UnknownError = /** @class */ (function (_super) { tslib_1.__extends(UnknownError, _super); function UnknownError() { return _super !== null && _super.apply(this, arguments) || this; } /** * Unknown error * * @return this */ UnknownError.createUnknownError = function () { return new this("Unknown error."); }; return UnknownError; }(ErrorWithMessage_1.ErrorWithMessage)); exports.UnknownError = UnknownError; /***/ }), /***/ "./node_modules/apisearch/lib/Error/UnsupportedContentTypeError.js": /*!*************************************************************************!*\ !*** ./node_modules/apisearch/lib/Error/UnsupportedContentTypeError.js ***! \*************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; exports.__esModule = true; exports.UnsupportedContentTypeError = void 0; var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); var ErrorWithMessage_1 = __webpack_require__(/*! ./ErrorWithMessage */ "./node_modules/apisearch/lib/Error/ErrorWithMessage.js"); /** * Unsupported content type error */ var UnsupportedContentTypeError = /** @class */ (function (_super) { tslib_1.__extends(UnsupportedContentTypeError, _super); function UnsupportedContentTypeError() { return _super !== null && _super.apply(this, arguments) || this; } /** * Get transportable http error * * @return {number} */ UnsupportedContentTypeError.getTransportableHTTPError = function () { return 415; }; /** * Unsupported content type * * @return {InvalidFormatError} */ UnsupportedContentTypeError.createUnsupportedContentTypeException = function () { return new UnsupportedContentTypeError("This content type is not accepted. Please use application/json"); }; return UnsupportedContentTypeError; }(ErrorWithMessage_1.ErrorWithMessage)); exports.UnsupportedContentTypeError = UnsupportedContentTypeError; /***/ }), /***/ "./node_modules/apisearch/lib/Geo/LocationRange.js": /*!*********************************************************!*\ !*** ./node_modules/apisearch/lib/Geo/LocationRange.js ***! \*********************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; exports.__esModule = true; exports.Square = exports.Polygon = exports.CoordinateAndDistance = exports.LocationRange = void 0; var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); var Coordinate_1 = __webpack_require__(/*! ../Model/Coordinate */ "./node_modules/apisearch/lib/Model/Coordinate.js"); /** * Abstract Location Range class */ var LocationRange = /** @class */ (function () { function LocationRange() { } /** * From filter object * * @param object * * @return {LocationRange} */ LocationRange.fromFilterObject = function (object) { throw TypeError("Method not valid"); }; /** * to array */ LocationRange.prototype.toArray = function () { return { type: this.getName(), data: this.toFilterObject() }; }; /** * Create from array * * @param array */ LocationRange.createFromArray = function (array) { if (array.type == "CoordinateAndDistance") { return CoordinateAndDistance.fromFilterObject(array.data); } if (array.type == "Polygon") { return Polygon.fromFilterObject(array.data); } if (array.type == "Square") { return Square.fromFilterObject(array.data); } }; return LocationRange; }()); exports.LocationRange = LocationRange; /** * CoordinateAndDistance */ var CoordinateAndDistance = /** @class */ (function (_super) { tslib_1.__extends(CoordinateAndDistance, _super); /** * Constructor * * @param coordinate * @param distance */ function CoordinateAndDistance(coordinate, distance) { var _this = _super.call(this) || this; _this.coordinate = coordinate; _this.distance = distance; return _this; } /** * To filter object * * @return {{}}} */ CoordinateAndDistance.prototype.toFilterObject = function () { return { coordinate: this.coordinate.toArray(), distance: this.distance }; }; /** * Get name * * @return {string} */ CoordinateAndDistance.prototype.getName = function () { return "CoordinateAndDistance"; }; /** * From filter object * * @param object * * @return {LocationRange} */ CoordinateAndDistance.fromFilterObject = function (object) { return new CoordinateAndDistance(Coordinate_1.Coordinate.createFromArray(object.coordinate), object.distance); }; return CoordinateAndDistance; }(LocationRange)); exports.CoordinateAndDistance = CoordinateAndDistance; /** * Polygon */ var Polygon = /** @class */ (function (_super) { tslib_1.__extends(Polygon, _super); /** * Constructor * * @param coordinates */ function Polygon(coordinates) { var _this = _super.call(this) || this; if (coordinates.length < 3) { throw new Error("A polygon needs more than two coordinates."); } _this.coordinates = coordinates; return _this; } /** * To filter object * * @return {{coordinates: {lat:number, lon:number}[]}} */ Polygon.prototype.toFilterObject = function () { var coordinates = []; for (var i in this.coordinates) { coordinates.push(this.coordinates[i].toArray()); } return { coordinates: coordinates }; }; /** * Get name * * @return {string} */ Polygon.prototype.getName = function () { return "Polygon"; }; /** * From filter object * * @param object * * @return {Polygon} */ Polygon.fromFilterObject = function (object) { var coordinates = []; for (var i in object.coordinates) { coordinates.push(Coordinate_1.Coordinate.createFromArray(object.coordinates[i])); } return new Polygon(coordinates); }; return Polygon; }(LocationRange)); exports.Polygon = Polygon; /** * Square */ var Square = /** @class */ (function (_super) { tslib_1.__extends(Square, _super); /** * Constructor * * @param topLeftCoordinate * @param bottomRightCoordinate */ function Square(topLeftCoordinate, bottomRightCoordinate) { var _this = _super.call(this) || this; _this.topLeftCoordinate = topLeftCoordinate; _this.bottomRightCoordinate = bottomRightCoordinate; return _this; } /** * To filter object * * @return {{}}} */ Square.prototype.toFilterObject = function () { return { top_left: this.topLeftCoordinate.toArray(), bottom_right: this.bottomRightCoordinate.toArray() }; }; /** * Get name * * @return {string} */ Square.prototype.getName = function () { return "Square"; }; /** * From filter object * * @param object * * @return {LocationRange} */ Square.fromFilterObject = function (object) { return new Square(Coordinate_1.Coordinate.createFromArray(object.top_left), Coordinate_1.Coordinate.createFromArray(object.bottom_right)); }; return Square; }(LocationRange)); exports.Square = Square; /***/ }), /***/ "./node_modules/apisearch/lib/Http/AxiosClient.js": /*!********************************************************!*\ !*** ./node_modules/apisearch/lib/Http/AxiosClient.js ***! \********************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; exports.__esModule = true; exports.AxiosClient = void 0; var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); var axios_1 = __webpack_require__(/*! axios */ "./node_modules/axios/index.js"); var __1 = __webpack_require__(/*! .. */ "./node_modules/apisearch/lib/index.js"); var Client_1 = __webpack_require__(/*! ./Client */ "./node_modules/apisearch/lib/Http/Client.js"); var Response_1 = __webpack_require__(/*! ./Response */ "./node_modules/apisearch/lib/Http/Response.js"); /** * AxiosClient */ var AxiosClient = /** @class */ (function (_super) { tslib_1.__extends(AxiosClient, _super); /** * Constructor * * @param host * @param version * @param timeout * @param overrideQueries */ function AxiosClient(host, version, timeout, overrideQueries) { var _this = _super.call(this, version) || this; _this.host = host; _this.timeout = timeout; _this.overrideQueries = overrideQueries; _this.abortControllers = {}; return _this; } /** * @param url * @param method * @param credentials * @param parameters * @param data */ AxiosClient.prototype.get = function (url, method, credentials, parameters, data) { if (parameters === void 0) { parameters = {}; } if (data === void 0) { data = {}; } return tslib_1.__awaiter(this, void 0, void 0, function () { var headers, axiosRequestConfig, axiosResponse, error_1, response; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: url = url.replace(/^\/*|\/*$/g, ""); url = "/" + (this.version + "/" + url).replace(/^\/*|\/*$/g, ""); method = method.toLowerCase(); if ("get" === method && this.overrideQueries) { this.abort(url, true); } headers = "get" === method ? {} : { "Content-Encoding": "gzip", "Content-Type": "application/json" }; axiosRequestConfig = { baseURL: this.host.replace(/\/*$/g, ""), data: data, headers: headers, method: method, timeout: this.timeout, transformRequest: [function (rawData) { return JSON.stringify(rawData); }], url: url + "?" + Client_1.Client.objectToUrlParameters(tslib_1.__assign(tslib_1.__assign({}, parameters), { token: credentials.token })).replace(/#/g, "%23") }; if (typeof this.abortControllers[url] !== "undefined") { axiosRequestConfig.signal = this.abortControllers[url].signal; } _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); return [4 /*yield*/, this.fetch(url, axiosRequestConfig, 3)]; case 2: axiosResponse = _a.sent(); return [2 /*return*/, new Response_1.Response(axiosResponse.status, axiosResponse.data)]; case 3: error_1 = _a.sent(); response = void 0; if (error_1.response) { response = new Response_1.Response(error_1.response.status, error_1.response.data); } else { response = new Response_1.Response(__1.ConnectionError.getTransportableHTTPError(), { message: error_1.message }); } throw response; case 4: return [2 /*return*/]; } }); }); }; /** * Abort current request * And regenerate the cancellation token * * @param url * @param urlIsFormatted */ AxiosClient.prototype.abort = function (url, urlIsFormatted) { if (!urlIsFormatted) { url = url.replace(/^\/*|\/*$/g, ""); url = "/" + (this.version + "/" + url).replace(/^\/*|\/*$/g, ""); } if (typeof this.abortControllers[url] !== "undefined") { this.abortControllers[url].abort(); } this.generateAbortController(url); }; /** * Generate a new cancellation token for a query * * @param url */ AxiosClient.prototype.generateAbortController = function (url) { this.abortControllers[url] = new AbortController(); }; /** * @param url * @param options * @param retries */ AxiosClient.prototype.fetch = function (url, options, retries) { return tslib_1.__awaiter(this, void 0, void 0, function () { var _this = this; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, axios_1["default"] .request(options) .then(function (response) { return { data: response.data, status: response.status }; })["catch"](function (error) { var response = error.response; if (error.code !== undefined && error.code !== "ECONNREFUSED" && error.code !== "ECONNABORTED" && error.code !== "ERR_BAD_REQUEST" && error.message !== "Network Error") { return { data: response.data, status: response.status }; } if (retries <= 0) { throw error; } retries = retries - 1; return _this.fetch(url, options, retries); })]; case 1: return [2 /*return*/, _a.sent()]; } }); }); }; return AxiosClient; }(Client_1.Client)); exports.AxiosClient = AxiosClient; /***/ }), /***/ "./node_modules/apisearch/lib/Http/CacheClient.js": /*!********************************************************!*\ !*** ./node_modules/apisearch/lib/Http/CacheClient.js ***! \********************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; exports.__esModule = true; exports.CacheClient = void 0; var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); var ts_md5_1 = __webpack_require__(/*! ts-md5 */ "./node_modules/ts-md5/dist/md5.js"); /** * AxiosClient */ var CacheClient = /** @class */ (function () { function CacheClient(httpClient) { this.cache = {}; this.hits = 0; this.httpClient = httpClient; } CacheClient.prototype.flushCache = function () { this.cache = {}; }; CacheClient.prototype.size = function () { return Object.keys(this.cache).length; }; CacheClient.prototype.getNumberOfHits = function () { return this.hits; }; /** * Get * * @param url * @param method * @param credentials * @param parameters * @param data * * @return {Promise<Response>} */ CacheClient.prototype.get = function (url, method, credentials, parameters, data) { if (parameters === void 0) { parameters = {}; } if (data === void 0) { data = {}; } return tslib_1.__awaiter(this, void 0, void 0, function () { var cacheUID, _a, _b; return tslib_1.__generator(this, function (_c) { switch (_c.label) { case 0: if (method !== 'get') { return [2 /*return*/, this.httpClient.get(url, method, credentials, parameters, data)]; } cacheUID = ts_md5_1.Md5.hashStr(JSON.stringify({ 'u': url, 'c': credentials, 'p': parameters, 'd': data })).toString(); if (!!this.cache[cacheUID]) return [3 /*break*/, 2]; _a = this.cache; _b = cacheUID; return [4 /*yield*/, this.httpClient.get(url, method, credentials, parameters, data)]; case 1: _a[_b] = _c.sent(); return [3 /*break*/, 3]; case 2: this.httpClient.abort(url, false); this.hits++; _c.label = 3; case 3: return [2 /*return*/, this.cache[cacheUID]]; } }); }); }; /** * Abort current request * And regenerate the cancellation token * * @param url * @param urlIsFormatted */ CacheClient.prototype.abort = function (url, urlIsFormatted) { }; return CacheClient; }()); exports.CacheClient = CacheClient; /***/ }), /***/ "./node_modules/apisearch/lib/Http/Client.js": /*!***************************************************!*\ !*** ./node_modules/apisearch/lib/Http/Client.js ***! \***************************************************/ /***/ ((__unused_webpack_module, exports) => { "use strict"; exports.__esModule = true; exports.Client = void 0; /** * Client */ var Client = /** @class */ (function () { /** * Constructor * * @param version */ function Client(version) { this.version = version.replace(/^\/*|\/*$/g, ""); } /** * Build an url parameters array by an object * * @param params * * @returns {string} */ Client.objectToUrlParameters = function (params) { var builtParams = []; for (var i in params) { builtParams.push(i + "=" + params[i]); } return builtParams.join("&"); }; return Client; }()); exports.Client = Client; /***/ }), /***/ "./node_modules/apisearch/lib/Http/HttpClient.js": /*!*******************************************************!*\ !*** ./node_modules/apisearch/lib/Http/HttpClient.js ***! \*******************************************************/ /***/ ((__unused_webpack_module, exports) => { "use strict"; exports.__esModule = true; exports.HttpClient = void 0; /** * Http class */ var HttpClient = /** @class */ (function () { function HttpClient() { } return HttpClient; }()); exports.HttpClient = HttpClient; /***/ }), /***/ "./node_modules/apisearch/lib/Http/Response.js": /*!*****************************************************!*\ !*** ./node_modules/apisearch/lib/Http/Response.js ***! \*****************************************************/ /***/ ((__unused_webpack_module, exports) => { "use strict"; exports.__esModule = true; exports.Response = void 0; /** * Response */ var Response = /** @class */ (function () { /** * Constructor * * @param code * @param body */ function Response(code, body) { this.code = code; this.body = body; } /** * Get code * * @return {number} */ Response.prototype.getCode = function () { return this.code; }; /** * Get body * * @return {any} */ Response.prototype.getBody = function () { return this.body; }; return Response; }()); exports.Response = Response; /***/ }), /***/ "./node_modules/apisearch/lib/Model/AppUUID.js": /*!*****************************************************!*\ !*** ./node_modules/apisearch/lib/Model/AppUUID.js ***! \*****************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; exports.__esModule = true; exports.AppUUID = void 0; var InvalidFormatError_1 = __webpack_require__(/*! ../Error/InvalidFormatError */ "./node_modules/apisearch/lib/Error/InvalidFormatError.js"); /** * AppUUID class */ var AppUUID = /** @class */ (function ()