Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

opensearch-browser

Package Overview
Dependencies
Maintainers
3
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opensearch-browser - npm Package Compare versions

Comparing version 2.0.0-alpha.6 to 2.0.0-alpha.7

.github/workflows/ci.yml

12

.eslintrc.js
module.exports = {
"extends": "airbnb",
"parser": "babel-eslint",
"extends": "airbnb-base",
"parser": "@babel/eslint-parser",
"parserOptions": {
"sourceType": "module",
"allowImportExportEverywhere": false
"allowImportExportEverywhere": false,
"babelOptions": {
"presets": ["@babel/preset-env"],
}
},
"plugins": [
"import"
],
"rules": {

@@ -9,0 +15,0 @@ "comma-dangle": ["error", {

@@ -27,3 +27,2 @@ "use strict";

var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
if (!values) {

@@ -30,0 +29,0 @@ return globalConfig;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,16 +6,15 @@ Object.defineProperty(exports, "__esModule", {

});
exports.OpenSearchDescription = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _url = require('./url');
var _utils = require('./utils');
exports.OpenSearchDescription = void 0;
var _url = require("./url");
var _utils = require("./utils");
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
/**
* Class to parse the OpenSearchDescription XML document and get the saerch URLs
*/
var OpenSearchDescription = exports.OpenSearchDescription = function () {
var OpenSearchDescription = /*#__PURE__*/function () {
/**

@@ -42,3 +41,2 @@ * Create an OpenSearchDescription object

_classCallCheck(this, OpenSearchDescription);
this.shortName = values.shortName;

@@ -69,6 +67,4 @@ this.description = values.description;

*/
_createClass(OpenSearchDescription, [{
key: 'getUrl',
key: "getUrl",
value: function getUrl() {

@@ -90,5 +86,4 @@ var urls = this.getUrls.apply(this, arguments);

*/
}, {
key: 'getUrls',
key: "getUrls",
value: function getUrls() {

@@ -98,3 +93,2 @@ var parameters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;

var method = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var urls = this.urls.filter(function (url) {

@@ -105,3 +99,2 @@ return (0, _utils.find)(url.relations, function (rel) {

});
if (type) {

@@ -117,3 +110,2 @@ urls = urls.filter(function (url) {

}
if (parameters) {

@@ -132,7 +124,5 @@ return urls.filter(function (url) {

*/
}, {
key: 'serialize',
key: "serialize",
value:
/**

@@ -142,3 +132,3 @@ * Serialize the OpenSearch description to a simple object.

*/
value: function serialize() {
function serialize() {
return {

@@ -170,8 +160,6 @@ shortName: this.shortName,

*/
}], [{
key: 'fromXml',
key: "fromXml",
value: function fromXml(xml) {
var xmlDoc = (0, _utils.parseXml)(xml).documentElement;
var values = {

@@ -195,3 +183,5 @@ shortName: (0, _utils.getText)(xmlDoc, 'os', 'ShortName'),

queries: (0, _utils.getElements)(xmlDoc, 'os', 'Query').map(function (node) {
var query = { role: node.getAttribute('role') };
var query = {
role: node.getAttribute('role')
};
for (var i = 0; i < node.attributes.length; ++i) {

@@ -214,3 +204,3 @@ var attribute = node.attributes[i];

}, {
key: 'deserialize',
key: "deserialize",
value: function deserialize(values) {

@@ -224,4 +214,4 @@ return new OpenSearchDescription((0, _utils.assign)({}, values, {

}]);
return OpenSearchDescription;
}();
}();
exports.OpenSearchDescription = OpenSearchDescription;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -7,5 +7,3 @@ Object.defineProperty(exports, "__esModule", {

exports.getErrorFromXml = getErrorFromXml;
var _utils = require('./utils');
var _utils = require("./utils");
/**

@@ -25,7 +23,5 @@ * @module opensearch/error

var exceptionElement = (0, _utils.getFirstElement)(root, root.namespaceURI, 'Exception');
if (!exceptionElement) {
return null;
}
var message = ((0, _utils.getText)(exceptionElement, exceptionElement.namespaceURI, 'ExceptionText') || '').trim();

@@ -32,0 +28,0 @@ var code = exceptionElement.getAttribute('exceptionCode');

@@ -1,24 +0,25 @@

'use strict';
"use strict";
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.AtomFormat = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _utils = require('../utils');
var _base = require('./base');
exports.AtomFormat = void 0;
var _utils = require("../utils");
var _base = require("./base");
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
/**
* @module opensearch/formats/atom
*/
/**

@@ -29,14 +30,12 @@ * Class to parse Atom feeds

*/
var AtomFormat = exports.AtomFormat = function (_BaseFeedFormat) {
var AtomFormat = /*#__PURE__*/function (_BaseFeedFormat) {
_inherits(AtomFormat, _BaseFeedFormat);
var _super = _createSuper(AtomFormat);
function AtomFormat() {
_classCallCheck(this, AtomFormat);
return _possibleConstructorReturn(this, (AtomFormat.__proto__ || Object.getPrototypeOf(AtomFormat)).apply(this, arguments));
return _super.apply(this, arguments);
}
_createClass(AtomFormat, [{
key: 'parse',
key: "parse",
value:
/**

@@ -47,11 +46,9 @@ * Parse the given XML.

*/
value: function parse(text) {
var _this2 = this;
function parse(text) {
var _this = this;
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$extraFields = _ref.extraFields,
extraFields = _ref$extraFields === undefined ? undefined : _ref$extraFields,
_ref$namespaces = _ref.namespaces,
namespaces = _ref$namespaces === undefined ? undefined : _ref$namespaces;
_ref$extraFields = _ref.extraFields,
extraFields = _ref$extraFields === void 0 ? undefined : _ref$extraFields,
_ref$namespaces = _ref.namespaces,
namespaces = _ref$namespaces === void 0 ? undefined : _ref$namespaces;
var xmlDoc = (0, _utils.parseXml)(text).documentElement;

@@ -66,43 +63,34 @@ var records = (0, _utils.getElements)(xmlDoc, 'atom', 'entry').map(function (node) {

summary: (0, _utils.getText)(node, 'atom', 'summary'),
links: _this2.parseLinks(node),
media: _this2.parseMedia(node)
links: _this.parseLinks(node),
media: _this.parseMedia(node)
}
};
var box = _this2.parseBox(node);
var box = _this.parseBox(node);
if (box) {
entry.bbox = box;
}
var geometry = _this2.parseGeometry(node);
var geometry = _this.parseGeometry(node);
if (geometry) {
entry.geometry = geometry;
if (!entry.bbox) {
entry.bbox = _this2.getBoxFromGeometry(geometry);
entry.bbox = _this.getBoxFromGeometry(geometry);
}
}
var date = _this2.parseDate(node);
var date = _this.parseDate(node);
if (date) {
entry.properties.time = date;
}
var eop = _this2.parseEOP(node);
var eop = _this.parseEOP(node);
if (eop) {
entry.properties.eop = eop;
}
var s3Path = _this2.parseS3Path(node);
var s3Path = _this.parseS3Path(node);
if (s3Path) {
entry.properties.s3Path = s3Path;
}
if (extraFields) {
_this2.parseExtraFields(node, extraFields, namespaces, entry);
_this.parseExtraFields(node, extraFields, namespaces, entry);
}
return entry;
});
return {

@@ -112,3 +100,4 @@ totalResults: parseInt((0, _utils.getText)(xmlDoc, 'os', 'totalResults'), 10),

itemsPerPage: parseInt((0, _utils.getText)(xmlDoc, 'os', 'itemsPerPage'), 10),
query: {}, // TODO:
query: {},
// TODO:
links: this.parseLinks(xmlDoc),

@@ -119,4 +108,4 @@ records: records

}]);
return AtomFormat;
}(_base.BaseFeedFormat);
}(_base.BaseFeedFormat);
exports.AtomFormat = AtomFormat;

@@ -1,21 +0,26 @@

'use strict';
"use strict";
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.BaseFeedFormat = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var _utils = require('../utils');
exports.BaseFeedFormat = void 0;
var _utils = require("../utils");
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function swapAndPair(values) {
var out = [];
for (var i = 0; i < values.length; i += 2) {

@@ -28,3 +33,2 @@ var lat = values[i];

}
function parseGeometryValues(value) {

@@ -34,13 +38,9 @@ var values = value.trim().split(/\s+/).map(parseFloat);

}
function parseGmlLine(node) {
return swapAndPair((0, _utils.getText)(node, node.namespaceURI, 'posList').trim().split(/\s+/).map(parseFloat));
}
function parseGmlPolygon(node, namespaceURI) {
var exteriorElement = (0, _utils.getFirstElement)(node, namespaceURI, 'exterior');
var interiorElements = (0, _utils.getElements)(node, namespaceURI, 'interior');
var exterior = parseGmlLine((0, _utils.getFirstElement)(exteriorElement, namespaceURI, 'LinearRing'), namespaceURI);
var interiors = interiorElements.map(function (interiorElement) {

@@ -51,11 +51,8 @@ return parseGmlLine((0, _utils.getFirstElement)(interiorElement, namespaceURI, 'LinearRing'), namespaceURI);

}
function parseGmlEnvelope(node, namespaceURI) {
var lowerLeftCorner = (0, _utils.getText)(node, namespaceURI, 'lowerCorner').trim().split(/\s+/).map(parseFloat);
var upperRightCorner = (0, _utils.getText)(node, namespaceURI, 'upperCorner').trim().split(/\s+/).map(parseFloat);
var bbox = [[[lowerLeftCorner[1], lowerLeftCorner[0]], [upperRightCorner[1], lowerLeftCorner[0]], [upperRightCorner[1], upperRightCorner[0]], [lowerLeftCorner[1], upperRightCorner[0]], [lowerLeftCorner[1], lowerLeftCorner[0]]]];
return bbox;
}
function parseGml(node) {

@@ -136,3 +133,2 @@ switch (node.localName) {

}
function boxFromLineString(lineString) {

@@ -143,8 +139,6 @@ var minX = null;

var maxY = null;
for (var i = 0; i < lineString.length; ++i) {
var _lineString$i = _slicedToArray(lineString[i], 2),
x = _lineString$i[0],
y = _lineString$i[1];
x = _lineString$i[0],
y = _lineString$i[1];
minX = minX === null || x < minX ? x : minX;

@@ -157,10 +151,8 @@ minY = minY === null || y < minY ? y : minY;

}
var BaseFeedFormat = exports.BaseFeedFormat = function () {
var BaseFeedFormat = /*#__PURE__*/function () {
function BaseFeedFormat() {
_classCallCheck(this, BaseFeedFormat);
}
_createClass(BaseFeedFormat, [{
key: 'parseGeometry',
key: "parseGeometry",
value: function parseGeometry(node) {

@@ -171,3 +163,2 @@ var where = (0, _utils.getFirstElement)(node, 'georss', 'where');

var polygon = (0, _utils.getText)(node, 'georss', 'polygon');
if (where) {

@@ -197,3 +188,3 @@ var geomNode = (0, _utils.getFirstElement)(where);

}, {
key: 'parseBox',
key: "parseBox",
value: function parseBox(node) {

@@ -208,3 +199,3 @@ var box = (0, _utils.getText)(node, 'georss', 'box');

}, {
key: 'getBoxFromGeometry',
key: "getBoxFromGeometry",
value: function getBoxFromGeometry(geometry) {

@@ -239,3 +230,3 @@ var coords = geometry.coordinates;

}, {
key: 'parseDate',
key: "parseDate",
value: function parseDate(node) {

@@ -247,3 +238,4 @@ var date = (0, _utils.getText)(node, 'dc', 'date');

return new Date(date);
} else if (values.length >= 1) {
}
if (values.length >= 1) {
return [new Date(values[0]), new Date(values[1])];

@@ -255,3 +247,3 @@ }

}, {
key: 'parseLinks',
key: "parseLinks",
value: function parseLinks(node) {

@@ -274,3 +266,2 @@ return (0, _utils.getElements)(node, 'atom', 'link').map(function (linkNode) {

}
return link;

@@ -280,3 +271,3 @@ });

}, {
key: 'parseMedia',
key: "parseMedia",
value: function parseMedia(node) {

@@ -291,3 +282,2 @@ var directMedias = (0, _utils.getElements)(node, 'media', 'content');

var allMedias = directMedias.concat(groupedMedias);
return allMedias.map(function (mediaNode) {

@@ -303,3 +293,3 @@ var category = (0, _utils.getFirstElement)(mediaNode, 'media', 'category');

}, {
key: 'parseEOP',
key: "parseEOP",
value: function parseEOP(node) {

@@ -324,3 +314,3 @@ var eoNode = (0, _utils.getFirstElement)(node, null, 'EarthObservation');

}, {
key: 'parseS3Path',
key: "parseS3Path",
value: function parseS3Path(node) {

@@ -330,3 +320,3 @@ return (0, _utils.getText)(node, null, 's3Path');

}, {
key: 'parseExtraFields',
key: "parseExtraFields",
value: function parseExtraFields(node, extraFields, namespaces, item) {

@@ -340,3 +330,2 @@ for (var outPath in extraFields) {

var _maybePath = _slicedToArray(maybePath, 2);
xmlPath = _maybePath[0];

@@ -347,3 +336,2 @@ single = _maybePath[1];

}
var parts = outPath.split('.');

@@ -363,4 +351,4 @@ var ref = item;

}]);
return BaseFeedFormat;
}();
}();
exports.BaseFeedFormat = BaseFeedFormat;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,14 +6,13 @@ Object.defineProperty(exports, "__esModule", {

});
exports.GeoJSONFormat = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _utils = require('../utils');
exports.GeoJSONFormat = void 0;
var _utils = require("../utils");
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
/**
* @module opensearch/formats/geojson
*/
/**

@@ -24,10 +23,9 @@ * Class to parse GeoJSON results

*/
var GeoJSONFormat = exports.GeoJSONFormat = function () {
var GeoJSONFormat = /*#__PURE__*/function () {
function GeoJSONFormat() {
_classCallCheck(this, GeoJSONFormat);
}
_createClass(GeoJSONFormat, [{
key: 'parse',
key: "parse",
value:
/**

@@ -38,3 +36,3 @@ * Parse the given JSON.

*/
value: function parse(text) {
function parse(text) {
var result = JSON.parse(text);

@@ -49,3 +47,2 @@ var records = result.features.map(function (item) {

});
return {

@@ -57,4 +54,4 @@ // TODO: parse properties of featurecollection

}]);
return GeoJSONFormat;
}();
}();
exports.GeoJSONFormat = GeoJSONFormat;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,14 +6,9 @@ Object.defineProperty(exports, "__esModule", {

});
exports.getFormat = getFormat;
exports.getSupportedTypes = getSupportedTypes;
exports.getFormat = getFormat;
exports.registerFormat = registerFormat;
var _atom = require('./atom');
var _rss = require('./rss');
var _geojson = require('./geojson');
var _suggestionsJson = require('./suggestions-json');
var _atom = require("./atom");
var _rss = require("./rss");
var _geojson = require("./geojson");
var _suggestionsJson = require("./suggestions-json");
/**

@@ -24,42 +19,40 @@ * @module opensearch/formats

/**
* The interface built-in and custom format parsers must conform to.
* @interface module:opensearch/formats.FormatInterface
*/
* The interface built-in and custom format parsers must conform to.
* @interface module:opensearch/formats.FormatInterface
*/
/**
* Main parsing function for the format.
* @function
* @name module:opensearch/formats.FormatInterface#parse
* @param {string} text The text (or binary string) response to parse.
* @returns {module:opensearch/formats.SearchResult} The parsed search result
*/
* Main parsing function for the format.
* @function
* @name module:opensearch/formats.FormatInterface#parse
* @param {string} text The text (or binary string) response to parse.
* @returns {module:opensearch/formats.SearchResult} The parsed search result
*/
/**
* @typedef module:opensearch/formats.Record
* @type Object
* @property {string} id The id of the record
* @property {object} properties The parsed properties of the record
* @property {object} [geometry] The parsed record geometry
* @property {float[]} [bbox] The parsed record geometry
*/
* @typedef module:opensearch/formats.Record
* @type Object
* @property {string} id The id of the record
* @property {object} properties The parsed properties of the record
* @property {object} [geometry] The parsed record geometry
* @property {float[]} [bbox] The parsed record geometry
*/
/**
* @typedef module:opensearch/formats.SearchResult
* @type Object
* @property {int} [totalResults] The total amount of matched records
* @property {int} [startIndex] The start index of this response
* @property {int} [itemsPerPage] The number of items per page of results
* @property {object} [query] The query of this result
* @property {object[]} [links] Relevant links of this result
* @property {module:opensearch/formats.Record[]} records The parsed records
*/
* @typedef module:opensearch/formats.SearchResult
* @type Object
* @property {int} [totalResults] The total amount of matched records
* @property {int} [startIndex] The start index of this response
* @property {int} [itemsPerPage] The number of items per page of results
* @property {object} [query] The query of this result
* @property {object[]} [links] Relevant links of this result
* @property {module:opensearch/formats.Record[]} records The parsed records
*/
/**
* @typedef module:opensearch/formats.Suggestion
* @type Object
* @property {string} completion The completion value
* @property {string} [description] A description of the completion
* @property {string} [url] The search URL for that completion
*/
* @typedef module:opensearch/formats.Suggestion
* @type Object
* @property {string} completion The completion value
* @property {string} [description] A description of the completion
* @property {string} [url] The search URL for that completion
*/
var formatRegistry = {};

@@ -94,3 +87,2 @@

}
registerFormat('application/atom+xml', new _atom.AtomFormat());

@@ -97,0 +89,0 @@ registerFormat('application/rss+xml', new _rss.RSSFormat());

@@ -1,24 +0,25 @@

'use strict';
"use strict";
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.RSSFormat = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _utils = require('../utils');
var _base = require('./base');
exports.RSSFormat = void 0;
var _utils = require("../utils");
var _base = require("./base");
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
/**
* @module opensearch/formats/rss
*/
/**

@@ -29,14 +30,12 @@ * Class to parse RSS feeds

*/
var RSSFormat = exports.RSSFormat = function (_BaseFeedFormat) {
var RSSFormat = /*#__PURE__*/function (_BaseFeedFormat) {
_inherits(RSSFormat, _BaseFeedFormat);
var _super = _createSuper(RSSFormat);
function RSSFormat() {
_classCallCheck(this, RSSFormat);
return _possibleConstructorReturn(this, (RSSFormat.__proto__ || Object.getPrototypeOf(RSSFormat)).apply(this, arguments));
return _super.apply(this, arguments);
}
_createClass(RSSFormat, [{
key: 'parse',
key: "parse",
value:
/**

@@ -47,11 +46,9 @@ * Parse the given XML.

*/
value: function parse(text) {
var _this2 = this;
function parse(text) {
var _this = this;
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$extraFields = _ref.extraFields,
extraFields = _ref$extraFields === undefined ? undefined : _ref$extraFields,
_ref$namespaces = _ref.namespaces,
namespaces = _ref$namespaces === undefined ? undefined : _ref$namespaces;
_ref$extraFields = _ref.extraFields,
extraFields = _ref$extraFields === void 0 ? undefined : _ref$extraFields,
_ref$namespaces = _ref.namespaces,
namespaces = _ref$namespaces === void 0 ? undefined : _ref$namespaces;
var xmlDoc = (0, _utils.parseXml)(text).documentElement;

@@ -66,43 +63,34 @@ var channel = (0, _utils.getFirstElement)(xmlDoc, null, 'channel');

summary: (0, _utils.getText)(node, null, 'description'),
links: _this2.parseLinks(node),
media: _this2.parseMedia(node)
links: _this.parseLinks(node),
media: _this.parseMedia(node)
}
};
var box = _this2.parseBox(node);
var box = _this.parseBox(node);
if (box) {
item.bbox = box;
}
var geometry = _this2.parseGeometry(node);
var geometry = _this.parseGeometry(node);
if (geometry) {
item.geometry = geometry;
if (!item.bbox) {
item.bbox = _this2.getBoxFromGeometry(geometry);
item.bbox = _this.getBoxFromGeometry(geometry);
}
}
var date = _this2.parseDate(node);
var date = _this.parseDate(node);
if (date) {
item.properties.time = date;
}
var eop = _this2.parseEOP(node);
var eop = _this.parseEOP(node);
if (eop) {
item.properties.eop = eop;
}
var s3Path = _this2.parseS3Path(node);
var s3Path = _this.parseS3Path(node);
if (s3Path) {
item.properties.s3Path = s3Path;
}
if (extraFields) {
_this2.parseExtraFields(node, extraFields, namespaces, item);
_this.parseExtraFields(node, extraFields, namespaces, item);
}
return item;
});
return {

@@ -112,3 +100,4 @@ totalResults: parseInt((0, _utils.getText)(channel, 'os', 'totalResults'), 10),

itemsPerPage: parseInt((0, _utils.getText)(channel, 'os', 'itemsPerPage'), 10),
query: {}, // TODO:
query: {},
// TODO:
links: this.parseLinks(xmlDoc),

@@ -119,4 +108,4 @@ records: records

}]);
return RSSFormat;
}(_base.BaseFeedFormat);
}(_base.BaseFeedFormat);
exports.RSSFormat = RSSFormat;

@@ -6,13 +6,18 @@ "use strict";

});
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
exports.SuggestionsJSONFormat = void 0;
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
/**
* @module opensearch/formats/suggestions-json
*/
/**

@@ -22,11 +27,9 @@ * Class to parse SuggestionsJSONFormat results

*/
var SuggestionsJSONFormat = exports.SuggestionsJSONFormat = function () {
var SuggestionsJSONFormat = /*#__PURE__*/function () {
function SuggestionsJSONFormat() {
_classCallCheck(this, SuggestionsJSONFormat);
}
_createClass(SuggestionsJSONFormat, [{
key: "parse",
value:
/**

@@ -37,10 +40,8 @@ * Parse the given JSON.

*/
value: function parse(text) {
function parse(text) {
var result = JSON.parse(text);
var _result = _slicedToArray(result, 4),
completions = _result[1],
descriptions = _result[2],
urls = _result[3];
completions = _result[1],
descriptions = _result[2],
urls = _result[3];
return completions.map(function (completion, index) {

@@ -55,4 +56,4 @@ return {

}]);
return SuggestionsJSONFormat;
}();
}();
exports.SuggestionsJSONFormat = SuggestionsJSONFormat;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,13 +6,20 @@ Object.defineProperty(exports, "__esModule", {

});
exports.registerFormat = exports.config = undefined;
Object.defineProperty(exports, "config", {
enumerable: true,
get: function get() {
return _config.config;
}
});
exports.deserialize = deserialize;
exports.discover = discover;
exports.fromXml = fromXml;
exports.deserialize = deserialize;
var _service = require('./service');
var _config = require('./config');
var _formats = require('./formats');
Object.defineProperty(exports, "registerFormat", {
enumerable: true,
get: function get() {
return _formats.registerFormat;
}
});
var _service = require("./service");
var _config = require("./config");
var _formats = require("./formats");
/**

@@ -48,5 +55,2 @@ * @module opensearch

return _service.OpenSearchService.deserialize(values);
}
exports.config = _config.config;
exports.registerFormat = _formats.registerFormat;
}

@@ -1,34 +0,31 @@

'use strict';
"use strict";
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.OpenSearchPaginator = exports.PagedSearchProgressEmitter = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _eventEmitter = require('event-emitter');
var _eventEmitter2 = _interopRequireDefault(_eventEmitter);
var _search = require('./search');
var _utils = require('./utils');
var _config2 = require('./config');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
exports.PagedSearchProgressEmitter = exports.OpenSearchPaginator = void 0;
var _eventEmitter = _interopRequireDefault(require("event-emitter"));
var _search = require("./search");
var _utils = require("./utils");
var _config2 = require("./config");
var _excluded = ["useCache", "preferredItemsPerPage", "preferStartIndex", "baseOffset", "totalResults"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } // eslint-disable-next-line max-classes-per-file
/**
* @module opensearch/paginator
*/
/**

@@ -41,14 +38,11 @@ * Event emitter to track the progress of paged searches.

*/
var PagedSearchProgressEmitter = function (_EventEmitter) {
var PagedSearchProgressEmitter = /*#__PURE__*/function (_EventEmitter) {
_inherits(PagedSearchProgressEmitter, _EventEmitter);
var _super = _createSuper(PagedSearchProgressEmitter);
function PagedSearchProgressEmitter() {
_classCallCheck(this, PagedSearchProgressEmitter);
return _possibleConstructorReturn(this, (PagedSearchProgressEmitter.__proto__ || Object.getPrototypeOf(PagedSearchProgressEmitter)).apply(this, arguments));
return _super.apply(this, arguments);
}
return PagedSearchProgressEmitter;
}(_eventEmitter2.default);
return _createClass(PagedSearchProgressEmitter);
}(_eventEmitter["default"]);
/**

@@ -60,3 +54,2 @@ * Search Progress Event

*/
/**

@@ -68,3 +61,2 @@ * Search Success Event

*/
/**

@@ -76,10 +68,6 @@ * Search Error Event

*/
exports.PagedSearchProgressEmitter = PagedSearchProgressEmitter;
function isCancellable(promise) {
return promise && typeof promise.cancel === 'function' && !promise.isCancelled();
}
function combinePages(pages) {

@@ -101,4 +89,3 @@ var firstPage = pages[0];

*/
var OpenSearchPaginator = exports.OpenSearchPaginator = function () {
var OpenSearchPaginator = /*#__PURE__*/function () {
/**

@@ -126,17 +113,14 @@ * @param {OpenSearchUrl} url The URL to perform all subsequent requests on.

var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
_classCallCheck(this, OpenSearchPaginator);
var _options$useCache = options.useCache,
useCache = _options$useCache === undefined ? true : _options$useCache,
_options$preferredIte = options.preferredItemsPerPage,
preferredItemsPerPage = _options$preferredIte === undefined ? undefined : _options$preferredIte,
_options$preferStartI = options.preferStartIndex,
preferStartIndex = _options$preferStartI === undefined ? true : _options$preferStartI,
_options$baseOffset = options.baseOffset,
baseOffset = _options$baseOffset === undefined ? 0 : _options$baseOffset,
_options$totalResults = options.totalResults,
totalResults = _options$totalResults === undefined ? undefined : _options$totalResults,
searchOptions = _objectWithoutProperties(options, ['useCache', 'preferredItemsPerPage', 'preferStartIndex', 'baseOffset', 'totalResults']);
useCache = _options$useCache === void 0 ? true : _options$useCache,
_options$preferredIte = options.preferredItemsPerPage,
preferredItemsPerPage = _options$preferredIte === void 0 ? undefined : _options$preferredIte,
_options$preferStartI = options.preferStartIndex,
preferStartIndex = _options$preferStartI === void 0 ? true : _options$preferStartI,
_options$baseOffset = options.baseOffset,
baseOffset = _options$baseOffset === void 0 ? 0 : _options$baseOffset,
_options$totalResults = options.totalResults,
totalResults = _options$totalResults === void 0 ? undefined : _options$totalResults,
searchOptions = _objectWithoutProperties(options, _excluded);
this._url = url;

@@ -160,12 +144,8 @@ this._parameters = parameters;

*/
_createClass(OpenSearchPaginator, [{
key: 'fetchPage',
key: "fetchPage",
value: function fetchPage() {
var _this2 = this;
var _this = this;
var pageIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var maxCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
// TODO: implement caching of whole pages

@@ -176,3 +156,2 @@ // if (this._cache && this._cache[pageIndex]) {

var parameters = (0, _utils.assign)({}, this._parameters);
var pageSize = this.getActualPageSize();

@@ -186,3 +165,2 @@ if (pageSize && maxCount) {

}
if (this._preferStartIndex) {

@@ -198,5 +176,5 @@ if (typeof pageSize === 'undefined') {

return (0, _search.search)(this._url, parameters, this._searchOptions).then(function (result) {
_this2._totalResults = result.totalResults;
if (!_this2._serverItemsPerPage && result.itemsPerPage) {
_this2._serverItemsPerPage = result.itemsPerPage;
_this._totalResults = result.totalResults;
if (!_this._serverItemsPerPage && result.itemsPerPage) {
_this._serverItemsPerPage = result.itemsPerPage;
}

@@ -214,18 +192,14 @@ return result;

*/
}, {
key: 'fetchAllPages',
key: "fetchAllPages",
value: function fetchAllPages() {
var _this3 = this;
var _this2 = this;
return this.fetchPage().then(function (firstPage) {
var pageCount = _this3.getPageCount();
var pageCount = _this2.getPageCount();
var requests = [firstPage];
for (var i = 1; i < pageCount; ++i) {
requests.push(_this3.fetchPage(i));
requests.push(_this2.fetchPage(i));
}
var _config = (0, _config2.config)(),
Promise = _config.Promise;
Promise = _config.Promise;
return Promise.all(requests);

@@ -240,5 +214,4 @@ });

*/
}, {
key: 'fetchAllRecords',
key: "fetchAllRecords",
value: function fetchAllRecords() {

@@ -265,8 +238,6 @@ return this.fetchAllPages().then(function (pages) {

*/
}, {
key: 'fetchFirstRecords',
key: "fetchFirstRecords",
value: function fetchFirstRecords(maxCount) {
var _this4 = this;
var _this3 = this;
// Get the first page

@@ -281,3 +252,3 @@ return this.fetchPage(0, maxCount).then(function (firstPage) {

var requests = [firstPage];
var usedMaxCount = Math.min(maxCount, firstPage.totalResults - firstPage.startIndex + _this4._url.indexOffset);
var usedMaxCount = Math.min(maxCount, firstPage.totalResults - firstPage.startIndex + _this3._url.indexOffset);

@@ -291,5 +262,4 @@ // determine the number of pages and issue a request for each

}
requests.push(_this4.fetchPage(i, count));
requests.push(_this3.fetchPage(i, count));
}
return Promise.all(requests).then(function (pages) {

@@ -312,11 +282,8 @@ return combinePages(pages);

*/
}, {
key: 'searchFirstRecords',
key: "searchFirstRecords",
value: function searchFirstRecords() {
var _this5 = this;
var _this4 = this;
var maxCount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
var preserveOrder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
// Get the first page

@@ -351,3 +318,2 @@ var emitter = new PagedSearchProgressEmitter();

});
var hasError = false;

@@ -359,4 +325,3 @@ var onError = function onError(error) {

};
request.catch(onError).then(function (firstPage) {
request["catch"](onError).then(function (firstPage) {
if (hasError) {

@@ -371,3 +336,3 @@ throw firstPage;

}
var usedMaxCount = maxCount ? Math.min(maxCount, firstPage.totalResults - firstPage.startIndex + _this5._url.indexOffset) : firstPage.totalResults;
var usedMaxCount = maxCount ? Math.min(maxCount, firstPage.totalResults - firstPage.startIndex + _this4._url.indexOffset) : firstPage.totalResults;

@@ -381,3 +346,3 @@ // determine the number of pages and issue a request for each

}
newRequests.push(_this5.fetchPage(i, count));
newRequests.push(_this4.fetchPage(i, count));
}

@@ -387,43 +352,38 @@

requests = newRequests;
var pages = Array(requests.length);
if (preserveOrder) {
// when the order of the the responses is important, the algorithm is
// more complex
var index = 0;
var allRequests = Array.from(requests);
var onPage = function onPage(page) {
if (hasError) {
return;
}
pages[index] = page;
index += 1;
emitter.emit('page', page);
var promise = allRequests.shift();
if (promise) {
promise.then(onPage, onError);
} else {
emitter.emit('success', combinePages(pages)); // TODO:
}
};
if (preserveOrder) {
(function () {
// when the order of the the responses is important, the algorithm is
// more complex
var index = 0;
var allRequests = Array.from(requests);
var onPage = function onPage(page) {
allRequests.shift().then(onPage, onError);
} else {
var successCount = 0;
requests.forEach(function (req, index) {
req.then(function (page) {
if (hasError) {
return;
}
successCount += 1;
pages[index] = page;
index += 1;
emitter.emit('page', page);
var promise = allRequests.shift();
if (promise) {
promise.then(onPage, onError);
} else {
emitter.emit('success', combinePages(pages)); // TODO:
if (successCount === requests.length) {
emitter.emit('success', combinePages(pages)); // TODO
}
};
allRequests.shift().then(onPage, onError);
})();
} else {
(function () {
var successCount = 0;
requests.forEach(function (req, index) {
req.then(function (page) {
if (hasError) {
return;
}
successCount += 1;
pages[index] = page;
if (successCount === requests.length) {
emitter.emit('success', combinePages(pages)); // TODO
}
}, onError);
});
})();
}, onError);
});
}

@@ -438,11 +398,12 @@ });

*/
}, {
key: 'getActualPageSize',
key: "getActualPageSize",
value: function getActualPageSize() {
if (this._preferredItemsPerPage && this._serverItemsPerPage) {
return Math.min(this._preferredItemsPerPage, this._serverItemsPerPage);
} else if (this._serverItemsPerPage) {
}
if (this._serverItemsPerPage) {
return this._serverItemsPerPage;
} else if (this._preferredItemsPerPage) {
}
if (this._preferredItemsPerPage) {
return this._preferredItemsPerPage;

@@ -454,3 +415,4 @@ }

return countParam.maxExclusive - 1;
} else if (countParam.maxInclusive) {
}
if (countParam.maxInclusive) {
return countParam.maxInclusive;

@@ -467,5 +429,4 @@ }

*/
}, {
key: 'getPageCount',
key: "getPageCount",
value: function getPageCount() {

@@ -475,3 +436,4 @@ var pageSize = this.getActualPageSize();

return this._totalResults;
} else if (!pageSize) {
}
if (!pageSize) {
return undefined;

@@ -482,4 +444,4 @@ }

}]);
return OpenSearchPaginator;
}();
}();
exports.OpenSearchPaginator = OpenSearchPaginator;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {

});
exports.OpenSearchParameter = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _utils = require('./utils');
exports.OpenSearchParameter = void 0;
var _utils = require("./utils");
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
/**

@@ -21,3 +21,2 @@ * @module opensearch/parameter

var typeREglobal = /{([a-zA-Z:]+)([?]?)}/g;
function parseType(value) {

@@ -30,10 +29,7 @@ var match = typeRE.exec(value);

}
function isMandatory(value) {
return typeRE.exec(value)[2] !== '?';
}
function formatDate(value) {
var pattern = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
var rePattern = pattern ? new RegExp(pattern) : null;

@@ -48,3 +44,3 @@ if (value instanceof Date) {

// Try without milliseconds
formatted = isoString.split('.')[0] + 'Z';
formatted = "".concat(isoString.split('.')[0], "Z");
if (!rePattern || rePattern.test(formatted)) {

@@ -61,2 +57,3 @@ return formatted;

// Try without Zulu and milliseconds
// eslint-disable-next-line prefer-destructuring
formatted = isoString.split('.')[0];

@@ -72,41 +69,39 @@ if (!rePattern || rePattern.test(formatted)) {

}
function eoValueToString(value) {
var isDate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var pattern = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
var convertDate = function convertDate(dateValue) {
return formatDate(dateValue, pattern);
};
if (typeof value === 'string') {
return value;
} else if (typeof value === 'number') {
}
if (typeof value === 'number') {
return value.toString();
} else if (isDate && value instanceof Date) {
}
if (isDate && value instanceof Date) {
return convertDate(value);
} else if (Array.isArray(value)) {
}
if (Array.isArray(value)) {
if (isDate) {
return '{' + value.map(convertDate).join(',') + '}';
return "{".concat(value.map(convertDate).join(','), "}");
}
return '{' + value.join(',') + '}';
return "{".concat(value.join(','), "}");
}
var left = null;
var right = null;
if (Object.prototype.hasOwnProperty.call(value, 'min')) {
left = '[' + (isDate ? convertDate(value.min) : value.min);
left = "[".concat(isDate ? convertDate(value.min) : value.min);
} else if (Object.prototype.hasOwnProperty.call(value, 'minExclusive')) {
left = ']' + (isDate ? convertDate(value.minExclusive) : value.minExclusive);
left = "]".concat(isDate ? convertDate(value.minExclusive) : value.minExclusive);
}
if (Object.prototype.hasOwnProperty.call(value, 'max')) {
right = (isDate ? convertDate(value.max) : value.max) + ']';
right = "".concat(isDate ? convertDate(value.max) : value.max, "]");
} else if (Object.prototype.hasOwnProperty.call(value, 'maxExclusive')) {
right = (isDate ? convertDate(value.maxExclusive) : value.maxExclusive) + '[';
right = "".concat(isDate ? convertDate(value.maxExclusive) : value.maxExclusive, "[");
}
if (left !== null && right !== null) {
return left + ',' + right;
} else if (left !== null) {
return "".concat(left, ",").concat(right);
}
if (left !== null) {
return left;

@@ -116,3 +111,2 @@ }

}
function _serializeValue(value, type, pattern) {

@@ -161,4 +155,3 @@ switch (type) {

*/
var OpenSearchParameter = exports.OpenSearchParameter = function () {
var OpenSearchParameter = /*#__PURE__*/function () {
/**

@@ -188,5 +181,3 @@ * Class to describe a single OpenSearch URL parameter.

var pattern = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : undefined;
_classCallCheck(this, OpenSearchParameter);
this._type = type;

@@ -207,92 +198,4 @@ this._name = name;

*/
_createClass(OpenSearchParameter, [{
key: 'combined',
/**
* Combines this parameter with the values of another parameter.
* @param {OpenSearchParameter} other the other parameter
* @returns {OpenSearchParameter} the combined parameter
*/
value: function combined(other) {
return new OpenSearchParameter(this.type, this.name, (0, _utils.isNullOrUndefined)(this.mandatory) ? other.mandatory : this.mandatory, (0, _utils.isNullOrUndefined)(this.options) ? other.options : this.options, (0, _utils.isNullOrUndefined)(this.minExclusive) ? other.minExclusive : this.minExclusive, (0, _utils.isNullOrUndefined)(this.maxExclusive) ? other.maxExclusive : this.maxExclusive, (0, _utils.isNullOrUndefined)(this.minInclusive) ? other.minInclusive : this.minInclusive, (0, _utils.isNullOrUndefined)(this.maxInclusive) ? other.maxInclusive : this.maxInclusive, (0, _utils.isNullOrUndefined)(this.pattern) ? other.pattern : this.pattern);
}
/**
* Serialize the given value according to the internal type to be sent in a
* request.
* @param {Number|string|Date|array|object} value The value to serialize. The
* allowed types depend on the
* internal type.
* @param {string} [type] For multi-parameters, this parameter indicates what
* of the multiple values to serialize.
* @returns {string} the serialized value.
*/
}, {
key: 'serializeValue',
value: function serializeValue(value) {
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
var types = this.type;
if (this.isMulti && type) {
if (Array.isArray(value)) {
return _serializeValue(value[this.types.indexOf(type)], type, this.pattern);
} else if (Object.prototype.hasOwnProperty.call(value, type)) {
return _serializeValue(value[type], type, this.pattern);
}
return _serializeValue(value, type, this.pattern);
}
return _serializeValue(value, types, this.pattern);
}
/**
* Constructs a new OpenSearchParameter from a DOM-Node.
* @param {DOMNode} node the node to create the parameter from.
* @returns {OpenSearchParameter} the constructed parameters object.
*/
}, {
key: 'serialize',
/**
* Serialize the parameter to a simple object.
* @returns {object} The serialized parameter
*/
value: function serialize() {
var values = {
type: this._type,
name: this._name,
mandatory: this._mandatory,
options: this._options,
pattern: this._pattern
};
if (typeof this._minExclusive !== 'undefined') {
values.minExclusive = this._minExclusive;
}
if (typeof this._maxExclusive !== 'undefined') {
values.maxExclusive = this._maxExclusive;
}
if (typeof this._minInclusive !== 'undefined') {
values.minInclusive = this._minInclusive;
}
if (typeof this._maxInclusive !== 'undefined') {
values.maxInclusive = this._maxInclusive;
}
return values;
}
/**
* Deserialize a parameter from a simple object.
* @param {object} values The serialized parameter
* @returns {OpenSearchParameter} The deserialized parameter
*/
}, {
key: 'type',
key: "type",
get: function get() {

@@ -306,5 +209,4 @@ return this._type;

*/
}, {
key: 'name',
key: "name",
get: function get() {

@@ -318,5 +220,4 @@ return this._name;

*/
}, {
key: 'mandatory',
key: "mandatory",
get: function get() {

@@ -330,5 +231,4 @@ return this._mandatory;

*/
}, {
key: 'options',
key: "options",
get: function get() {

@@ -342,5 +242,4 @@ return this._options;

*/
}, {
key: 'minExclusive',
key: "minExclusive",
get: function get() {

@@ -354,5 +253,4 @@ return this._minExclusive;

*/
}, {
key: 'maxExclusive',
key: "maxExclusive",
get: function get() {

@@ -366,5 +264,4 @@ return this._maxExclusive;

*/
}, {
key: 'minInclusive',
key: "minInclusive",
get: function get() {

@@ -378,5 +275,4 @@ return this._minInclusive;

*/
}, {
key: 'maxInclusive',
key: "maxInclusive",
get: function get() {

@@ -390,5 +286,4 @@ return this._maxInclusive;

*/
}, {
key: 'pattern',
key: "pattern",
get: function get() {

@@ -403,10 +298,88 @@ return this._pattern;

*/
}, {
key: 'isMulti',
key: "isMulti",
get: function get() {
return Array.isArray(this.type);
}
/**
* Combines this parameter with the values of another parameter.
* @param {OpenSearchParameter} other the other parameter
* @returns {OpenSearchParameter} the combined parameter
*/
}, {
key: "combined",
value: function combined(other) {
return new OpenSearchParameter(this.type, this.name, (0, _utils.isNullOrUndefined)(this.mandatory) ? other.mandatory : this.mandatory, (0, _utils.isNullOrUndefined)(this.options) ? other.options : this.options, (0, _utils.isNullOrUndefined)(this.minExclusive) ? other.minExclusive : this.minExclusive, (0, _utils.isNullOrUndefined)(this.maxExclusive) ? other.maxExclusive : this.maxExclusive, (0, _utils.isNullOrUndefined)(this.minInclusive) ? other.minInclusive : this.minInclusive, (0, _utils.isNullOrUndefined)(this.maxInclusive) ? other.maxInclusive : this.maxInclusive, (0, _utils.isNullOrUndefined)(this.pattern) ? other.pattern : this.pattern);
}
/**
* Serialize the given value according to the internal type to be sent in a
* request.
* @param {Number|string|Date|array|object} value The value to serialize. The
* allowed types depend on the
* internal type.
* @param {string} [type] For multi-parameters, this parameter indicates what
* of the multiple values to serialize.
* @returns {string} the serialized value.
*/
}, {
key: "serializeValue",
value: function serializeValue(value) {
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
var types = this.type;
if (this.isMulti && type) {
if (Array.isArray(value)) {
return _serializeValue(value[this.types.indexOf(type)], type, this.pattern);
}
if (Object.prototype.hasOwnProperty.call(value, type)) {
return _serializeValue(value[type], type, this.pattern);
}
return _serializeValue(value, type, this.pattern);
}
return _serializeValue(value, types, this.pattern);
}
/**
* Constructs a new OpenSearchParameter from a DOM-Node.
* @param {DOMNode} node the node to create the parameter from.
* @returns {OpenSearchParameter} the constructed parameters object.
*/
}, {
key: "serialize",
value:
/**
* Serialize the parameter to a simple object.
* @returns {object} The serialized parameter
*/
function serialize() {
var values = {
type: this._type,
name: this._name,
mandatory: this._mandatory,
options: this._options,
pattern: this._pattern
};
if (typeof this._minExclusive !== 'undefined') {
values.minExclusive = this._minExclusive;
}
if (typeof this._maxExclusive !== 'undefined') {
values.maxExclusive = this._maxExclusive;
}
if (typeof this._minInclusive !== 'undefined') {
values.minInclusive = this._minInclusive;
}
if (typeof this._maxInclusive !== 'undefined') {
values.maxInclusive = this._maxInclusive;
}
return values;
}
/**
* Deserialize a parameter from a simple object.
* @param {object} values The serialized parameter
* @returns {OpenSearchParameter} The deserialized parameter
*/
}], [{
key: 'fromNode',
key: "fromNode",
value: function fromNode(node) {

@@ -422,3 +395,3 @@ var type = parseType(node.getAttribute('value'));

var optionNodes = (0, _utils.getElements)(node, 'parameters', 'Option');
var options = void 0;
var options;
if (optionNodes.length) {

@@ -442,5 +415,4 @@ options = optionNodes.map(function (optionNode) {

*/
}, {
key: 'fromKeyValuePair',
key: "fromKeyValuePair",
value: function fromKeyValuePair(key, value) {

@@ -462,3 +434,3 @@ var type = parseType(value);

}, {
key: 'deserialize',
key: "deserialize",
value: function deserialize(values) {

@@ -468,4 +440,4 @@ return new OpenSearchParameter(values.type, values.name, values.mandatory, values.options, values.minExclusive, values.maxExclusive, values.minInclusive, values.maxInclusive, values.pattern);

}]);
return OpenSearchParameter;
}();
}();
exports.OpenSearchParameter = OpenSearchParameter;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,24 +6,18 @@ Object.defineProperty(exports, "__esModule", {

});
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); /* eslint no-underscore-dangle:
["error", { "allow": ["_parametersByName", "_parametersByType"] }]
*/
exports.createBaseRequest = createBaseRequest;
exports.search = search;
var _urlParse = require('url-parse');
var _urlParse2 = _interopRequireDefault(_urlParse);
var _formats = require('./formats');
var _utils = require('./utils');
var _error = require('./error');
var _config2 = require('./config');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _urlParse = _interopRequireDefault(require("url-parse"));
var _formats = require("./formats");
var _utils = require("./utils");
var _error = require("./error");
var _config2 = require("./config");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /* eslint no-underscore-dangle:
["error", { "allow": ["_parametersByName", "_parametersByType"] }]
*/
/**

@@ -34,10 +28,10 @@ * @module opensearch/search

/**
* @typedef module:opensearch/search.BaseRequest
* @type Object
* @property {string} url The URL of the search service.
* @property {string} method The ussed HTTP method.
* @property {object} [headers] Optional HTTP headers.
* @property {string|FormData} [body] The body to be sent to the search service.
* (For HTTP POST requests)
*/
* @typedef module:opensearch/search.BaseRequest
* @type Object
* @property {string} url The URL of the search service.
* @property {string} method The ussed HTTP method.
* @property {object} [headers] Optional HTTP headers.
* @property {string|FormData} [body] The body to be sent to the search service.
* (For HTTP POST requests)
*/

@@ -58,12 +52,10 @@ /**

if (!Object.prototype.hasOwnProperty.call(url._parametersByType, key) && !Object.prototype.hasOwnProperty.call(url._parametersByName, key)) {
throw new Error('Invalid parameter \'' + key + '\'.');
throw new Error("Invalid parameter '".concat(key, "'."));
}
});
var missingMandatoryParameters = url.getMissingMandatoryParameters(parameterValues).map(function (parameter) {
return parameter.type;
});
if (missingMandatoryParameters.length) {
throw new Error('Missing mandatory parameters: ' + missingMandatoryParameters.join(', '));
throw new Error("Missing mandatory parameters: ".concat(missingMandatoryParameters.join(', ')));
}

@@ -78,13 +70,10 @@

var urlString = url.url;
for (var i = 0; i < serialized.length; ++i) {
var _serialized$i = _slicedToArray(serialized[i], 3),
type = _serialized$i[1],
value = _serialized$i[2];
urlString = urlString.replace(new RegExp('{' + type + '[?]?}'), value);
type = _serialized$i[1],
value = _serialized$i[2];
urlString = urlString.replace(new RegExp("{".concat(type, "[?]?}")), value);
}
if (dropEmptyParameters) {
var parsed = (0, _urlParse2.default)(urlString, false);
var parsed = (0, _urlParse["default"])(urlString, false);
var query = parsed.query.split('&').map(function (param) {

@@ -97,7 +86,5 @@ return param.split('=');

}).join('&');
parsed.set('query', query);
urlString = parsed.toString();
}
return {

@@ -116,6 +103,5 @@ method: url.method,

var _ref2 = _slicedToArray(_ref, 3),
name = _ref2[0],
value = _ref2[2];
return encodeURIComponent(name) + '=' + encodeURIComponent(value);
name = _ref2[0],
value = _ref2[2];
return "".concat(encodeURIComponent(name), "=").concat(encodeURIComponent(value));
}).join('&');

@@ -126,11 +112,9 @@ } else if (enctype === 'multipart/form-data') {

var _ref4 = _slicedToArray(_ref3, 3),
name = _ref4[0],
value = _ref4[2];
name = _ref4[0],
value = _ref4[2];
return body.append(name, value);
});
} else {
throw new Error('Unsupported enctype \'' + enctype + '\'.');
throw new Error("Unsupported enctype '".concat(enctype, "'."));
}
return {

@@ -166,19 +150,14 @@ method: url.method,

var type = options.type,
raw = options.raw,
maxUrlLength = options.maxUrlLength,
dropEmptyParameters = options.dropEmptyParameters,
parseOptions = options.parseOptions,
headers = options.headers;
raw = options.raw,
maxUrlLength = options.maxUrlLength,
dropEmptyParameters = options.dropEmptyParameters,
parseOptions = options.parseOptions,
headers = options.headers;
var baseRequest = createBaseRequest(url, parameters, dropEmptyParameters, headers);
var _config = (0, _config2.config)(),
useXHR = _config.useXHR,
Promise = _config.Promise;
useXHR = _config.useXHR,
Promise = _config.Promise;
if (typeof maxUrlLength !== 'undefined' && baseRequest.url.length > maxUrlLength) {
return Promise.reject(new Error('Search URL too long: ' + baseRequest.url.length + ', maximum: ' + maxUrlLength));
return Promise.reject(new Error("Search URL too long: ".concat(baseRequest.url.length, ", maximum: ").concat(maxUrlLength)));
}
var request = null;

@@ -196,3 +175,2 @@

};
xhr.onerror = function () {

@@ -225,5 +203,4 @@ reject(new TypeError('Failed to fetch'));

var _ref6 = _slicedToArray(_ref5, 2),
text = _ref6[0],
status = _ref6[1];
text = _ref6[0],
status = _ref6[1];
if (status >= 400) {

@@ -235,3 +212,3 @@ var error = (0, _error.getErrorFromXml)(text);

if (!format) {
throw new Error('Could not parse response of type \'' + type + '\'.');
throw new Error("Could not parse response of type '".concat(type, "'."));
}

@@ -238,0 +215,0 @@ return format.parse(text, parseOptions);

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,26 +6,20 @@ Object.defineProperty(exports, "__esModule", {

});
exports.OpenSearchService = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
require('isomorphic-fetch');
var _description = require('./description');
var _paginator = require('./paginator');
var _search2 = require('./search');
var _formats = require('./formats/');
var _utils = require('./utils');
var _config3 = require('./config');
exports.OpenSearchService = void 0;
require("isomorphic-fetch");
var _description = require("./description");
var _paginator = require("./paginator");
var _search2 = require("./search");
var _formats = require("./formats");
var _utils = require("./utils");
var _config3 = require("./config");
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
/**
* Class to perform searches.
*/
var OpenSearchService = exports.OpenSearchService = function () {
var OpenSearchService = /*#__PURE__*/function () {
/**

@@ -37,3 +31,2 @@ * Create an OpenSearchDescription object

_classCallCheck(this, OpenSearchService);
this.descriptionDocument = descriptionDocument;

@@ -46,6 +39,4 @@ }

*/
_createClass(OpenSearchService, [{
key: 'getDescription',
key: "getDescription",
value: function getDescription() {

@@ -62,5 +53,4 @@ return this.descriptionDocument;

*/
}, {
key: 'getUrl',
key: "getUrl",
value: function getUrl(parameters, type, method) {

@@ -73,20 +63,19 @@ var url = this.descriptionDocument.getUrl(parameters, type, method);

var missingParamNames = alternativeUrls[0].getMissingMandatoryParameters(parameters).map(function (p) {
return '"' + p.type + '"';
return "\"".concat(p.type, "\"");
});
var unsupportedParameterKeys = alternativeUrls[0].getUnsupportedParameterKeys(parameters).map(function (k) {
return '"' + k + '"';
return "\"".concat(k, "\"");
});
var terms = [];
if (missingParamNames.length) {
terms.push('missing parameters: ' + missingParamNames.join(', '));
terms.push("missing parameters: ".concat(missingParamNames.join(', ')));
}
if (unsupportedParameterKeys.length) {
terms.push('unsupported parameters keys: ' + unsupportedParameterKeys.join(', '));
terms.push("unsupported parameters keys: ".concat(unsupportedParameterKeys.join(', ')));
}
throw new Error('No matching URL found, ' + terms.join(' and '));
throw new Error("No matching URL found, ".concat(terms.join(' and ')));
}
// standard error, when multiple/no URLs with that type/method are specified
throw new Error('No URL found for type \'' + type + '\' and the given parameters.');
throw new Error("No URL found for type '".concat(type, "' and the given parameters."));
}

@@ -104,9 +93,7 @@ return url;

*/
}, {
key: 'createSearchRequest',
key: "createSearchRequest",
value: function createSearchRequest(parameters) {
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var method = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var url = null;

@@ -128,3 +115,2 @@ if (!type) {

}
return (0, _search2.createBaseRequest)(url, parameters);

@@ -147,12 +133,10 @@ }

*/
}, {
key: 'search',
key: "search",
value: function search(parameters) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$type = options.type,
type = _options$type === undefined ? null : _options$type,
_options$method = options.method,
method = _options$method === undefined ? null : _options$method;
type = _options$type === void 0 ? null : _options$type,
_options$method = options.method,
method = _options$method === void 0 ? null : _options$method;
var url = null;

@@ -174,3 +158,2 @@ if (!type) {

}
return (0, _search2.search)(url, parameters, options);

@@ -187,11 +170,9 @@ }

*/
}, {
key: 'getSuggestions',
key: "getSuggestions",
value: function getSuggestions(parameters) {
var method = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var maxUrlLength = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
var type = 'application/x-suggestions+json';
var url = void 0;
var url;
try {

@@ -201,4 +182,3 @@ url = this.getUrl(parameters, type, method);

var _config = (0, _config3.config)(),
_Promise = _config.Promise;
_Promise = _config.Promise;
return _Promise.reject(new Error('No suggestion URL found.'));

@@ -218,12 +198,10 @@ }

*/
}, {
key: 'getPaginator',
key: "getPaginator",
value: function getPaginator(parameters) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$type2 = options.type,
type = _options$type2 === undefined ? null : _options$type2,
_options$method2 = options.method,
method = _options$method2 === undefined ? null : _options$method2;
type = _options$type2 === void 0 ? null : _options$type2,
_options$method2 = options.method,
method = _options$method2 === void 0 ? null : _options$method2;
return new _paginator.OpenSearchPaginator(this.getUrl(parameters, type, method), parameters, options);

@@ -237,7 +215,5 @@ }

*/
}, {
key: 'serialize',
key: "serialize",
value:
/**

@@ -247,3 +223,3 @@ * Serialize the service to a simple object.

*/
value: function serialize() {
function serialize() {
return {

@@ -259,10 +235,8 @@ description: this.descriptionDocument.serialize()

*/
}], [{
key: 'discover',
key: "discover",
value: function discover(url) {
var _config2 = (0, _config3.config)(),
useXHR = _config2.useXHR,
Promise = _config2.Promise;
useXHR = _config2.useXHR,
Promise = _config2.Promise;
if (useXHR) {

@@ -300,5 +274,4 @@ return new Promise(function (resolve, reject, onCancel) {

*/
}, {
key: 'fromXml',
key: "fromXml",
value: function fromXml(xml) {

@@ -308,3 +281,3 @@ return new OpenSearchService(_description.OpenSearchDescription.fromXml(xml));

}, {
key: 'deserialize',
key: "deserialize",
value: function deserialize(values) {

@@ -314,4 +287,4 @@ return new OpenSearchService(_description.OpenSearchDescription.deserialize(values.description));

}]);
return OpenSearchService;
}();
}();
exports.OpenSearchService = OpenSearchService;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,20 +6,13 @@ Object.defineProperty(exports, "__esModule", {

});
exports.OpenSearchUrl = undefined;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _urlParse = require('url-parse');
var _urlParse2 = _interopRequireDefault(_urlParse);
var _utils = require('./utils');
var _parameter = require('./parameter');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.OpenSearchUrl = void 0;
var _urlParse = _interopRequireDefault(require("url-parse"));
var _utils = require("./utils");
var _parameter = require("./parameter");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
/**

@@ -32,3 +25,4 @@ * @module opensearch/url

return false;
} else if (parameter.isMulti) {
}
if (parameter.isMulti) {
var types = parameter.type;

@@ -57,4 +51,3 @@ for (var i = 0; i < types.length; ++i) {

*/
var OpenSearchUrl = exports.OpenSearchUrl = function () {
var OpenSearchUrl = /*#__PURE__*/function () {
/**

@@ -72,2 +65,3 @@ * Create an OpenSearchUrl object

function OpenSearchUrl(type, url) {
var _this = this;
var parameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];

@@ -77,10 +71,5 @@ var method = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'GET';

var indexOffset = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1;
var _this = this;
var pageOffset = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 1;
var relations = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : ['results'];
_classCallCheck(this, OpenSearchUrl);
this._type = type;

@@ -93,3 +82,2 @@ this._url = url;

this._relations = relations;
this._parameters = parameters;

@@ -116,9 +104,79 @@ this._parametersByName = {};

*/
_createClass(OpenSearchUrl, [{
key: "type",
get: function get() {
return this._type;
}
/**
* The URL template or base URL
* @readonly
*/
}, {
key: "url",
get: function get() {
return this._url;
}
_createClass(OpenSearchUrl, [{
key: 'hasParameter',
/**
* The HTTP method
* @readonly
*/
}, {
key: "method",
get: function get() {
return this._method;
}
/**
* The encoding type
* @readonly
*/
}, {
key: "enctype",
get: function get() {
return this._enctype;
}
/**
* The index offset of this URL
* @readonly
*/
}, {
key: "indexOffset",
get: function get() {
return this._indexOffset;
}
/**
* The page offset of this URL
* @readonly
*/
}, {
key: "pageOffset",
get: function get() {
return this._pageOffset;
}
/**
* The page offset of this URL
* @readonly
*/
}, {
key: "relations",
get: function get() {
return this._relations;
}
/**
* The template/request parameters of the URL
* @readonly
*/
}, {
key: "parameters",
get: function get() {
return this._parameters;
}
/**
* Returns whether the URL has a template parameter of the given type

@@ -128,2 +186,4 @@ * @param {string} type The parameter type to check

*/
}, {
key: "hasParameter",
value: function hasParameter(type) {

@@ -138,5 +198,4 @@ return Object.prototype.hasOwnProperty.call(this._parametersByType, type);

*/
}, {
key: 'getParameter',
key: "getParameter",
value: function getParameter(type) {

@@ -151,8 +210,6 @@ return this._parametersByType[type];

*/
}, {
key: 'isCompatible',
key: "isCompatible",
value: function isCompatible(parameters) {
var _this2 = this;
var compatible = true;

@@ -167,3 +224,2 @@ Object.keys(parameters).forEach(function (key) {

}
if (this.getMissingMandatoryParameters(parameters).length) {

@@ -178,5 +234,4 @@ return false;

*/
}, {
key: 'getMissingMandatoryParameters',
key: "getMissingMandatoryParameters",
value: function getMissingMandatoryParameters(parameterValues) {

@@ -193,5 +248,4 @@ return this.parameters.filter(function (parameter) {

*/
}, {
key: 'getMissingOptionalParameters',
key: "getMissingOptionalParameters",
value: function getMissingOptionalParameters(parameterValues) {

@@ -208,8 +262,6 @@ return this.parameters.filter(function (parameter) {

*/
}, {
key: 'getUnsupportedParameterKeys',
key: "getUnsupportedParameterKeys",
value: function getUnsupportedParameterKeys(parameters) {
var _this3 = this;
return Object.keys(parameters).filter(function (key) {

@@ -226,20 +278,16 @@ return !Object.prototype.hasOwnProperty.call(_this3._parametersByType, key) && !Object.prototype.hasOwnProperty.call(_this3._parametersByName, key);

*/
}, {
key: 'serializeValues',
key: "serializeValues",
value: function serializeValues(values) {
var _this4 = this;
Object.keys(values).forEach(function (key) {
if (!Object.prototype.hasOwnProperty.call(_this4._parametersByType, key) && !Object.prototype.hasOwnProperty.call(_this4._parametersByName, key)) {
throw new Error('Invalid parameter \'' + key + '\'.');
throw new Error("Invalid parameter '".concat(key, "'."));
}
});
var missingMandatoryParameters = this.getMissingMandatoryParameters(values).map(function (parameter) {
return parameter.type;
});
if (missingMandatoryParameters.length) {
throw new Error('Missing mandatory parameters: ' + missingMandatoryParameters.join(', '));
throw new Error("Missing mandatory parameters: ".concat(missingMandatoryParameters.join(', ')));
}

@@ -282,7 +330,5 @@ var serialized = [];

*/
}, {
key: 'serialize',
key: "serialize",
value:
/**

@@ -292,3 +338,3 @@ * Serialize the URL to a simple object.

*/
value: function serialize() {
function serialize() {
return {

@@ -313,87 +359,4 @@ type: this._type,

*/
}, {
key: 'type',
get: function get() {
return this._type;
}
/**
* The URL template or base URL
* @readonly
*/
}, {
key: 'url',
get: function get() {
return this._url;
}
/**
* The HTTP method
* @readonly
*/
}, {
key: 'method',
get: function get() {
return this._method;
}
/**
* The encoding type
* @readonly
*/
}, {
key: 'enctype',
get: function get() {
return this._enctype;
}
/**
* The index offset of this URL
* @readonly
*/
}, {
key: 'indexOffset',
get: function get() {
return this._indexOffset;
}
/**
* The page offset of this URL
* @readonly
*/
}, {
key: 'pageOffset',
get: function get() {
return this._pageOffset;
}
/**
* The page offset of this URL
* @readonly
*/
}, {
key: 'relations',
get: function get() {
return this._relations;
}
/**
* The template/request parameters of the URL
* @readonly
*/
}, {
key: 'parameters',
get: function get() {
return this._parameters;
}
}], [{
key: 'fromNode',
key: "fromNode",
value: function fromNode(node) {

@@ -407,4 +370,3 @@ var parameterNodes = (0, _utils.getElements)(node, 'parameters', 'Parameter');

var relations = !rel || rel === '' ? undefined : rel.split(' ');
var parsed = (0, _urlParse2.default)(node.getAttribute('template'), true);
var parsed = (0, _urlParse["default"])(node.getAttribute('template'), true);
var parametersFromTemplate = Object.keys(parsed.query).map(function (name) {

@@ -416,3 +378,2 @@ return _parameter.OpenSearchParameter.fromKeyValuePair(name, parsed.query[name]);

var parametersFromNode = parameterNodes.map(_parameter.OpenSearchParameter.fromNode);
var parametersNotInTemplate = parametersFromNode.filter(function (p1) {

@@ -438,3 +399,2 @@ return !(0, _utils.find)(parametersFromTemplate, function (p2) {

}).concat(parametersNotInTemplate);
return new OpenSearchUrl(node.getAttribute('type'), node.getAttribute('template'), parameters, method, enctype, indexOffset, pageOffset, relations);

@@ -451,10 +411,8 @@ }

*/
}, {
key: 'fromTemplateUrl',
key: "fromTemplateUrl",
value: function fromTemplateUrl(type, templateUrl) {
var method = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'GET';
var enctype = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'application/x-www-form-urlencoded';
var parsed = (0, _urlParse2.default)(templateUrl, true);
var parsed = (0, _urlParse["default"])(templateUrl, true);
var parameters = Object.keys(parsed.query).map(function (name) {

@@ -468,3 +426,3 @@ return _parameter.OpenSearchParameter.fromKeyValuePair(name, parsed.query[name]);

}, {
key: 'deserialize',
key: "deserialize",
value: function deserialize(values) {

@@ -476,4 +434,4 @@ return new OpenSearchUrl(values.type, values.url, values.parameters.map(function (parameterDesc) {

}]);
return OpenSearchUrl;
}();
}();
exports.OpenSearchUrl = OpenSearchUrl;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,26 +6,25 @@ Object.defineProperty(exports, "__esModule", {

});
exports.namespaces = undefined;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
exports.parseURLQuery = parseURLQuery;
exports.parseXml = parseXml;
exports.assign = assign;
exports.createRequest = createRequest;
exports.createXHR = createXHR;
exports.fetchAndCheck = fetchAndCheck;
exports.find = find;
exports.getAttributeNS = getAttributeNS;
exports.getElements = getElements;
exports.getFirstElement = getFirstElement;
exports.getText = getText;
exports.getAttributeNS = getAttributeNS;
exports.isNullOrUndefined = isNullOrUndefined;
exports.lookupPrefix = lookupPrefix;
exports.namespaces = void 0;
exports.parseURLQuery = parseURLQuery;
exports.parseXml = parseXml;
exports.simplePath = simplePath;
exports.lookupPrefix = lookupPrefix;
exports.fetchAndCheck = fetchAndCheck;
exports.isNullOrUndefined = isNullOrUndefined;
exports.toWKT = toWKT;
exports.createRequest = createRequest;
exports.createXHR = createXHR;
exports.find = find;
exports.assign = assign;
require('isomorphic-fetch');
require("isomorphic-fetch");
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
/**

@@ -45,7 +44,7 @@ * @module opensearch/utils

}
function parseXml(xmlStr) {
if (typeof DOMParser !== 'undefined') {
return new DOMParser().parseFromString(xmlStr, 'text/xml');
} else if (typeof ActiveXObject !== 'undefined') {
}
if (typeof ActiveXObject !== 'undefined') {
var xmlDoc = new ActiveXObject('Microsoft.XMLDOM'); // eslint-disable-line no-undef

@@ -62,3 +61,3 @@ xmlDoc.async = 'false';

*/
var namespaces = exports.namespaces = {
var namespaces = {
os: 'http://a9.com/-/spec/opensearch/1.1/',

@@ -70,3 +69,2 @@ parameters: 'http://a9.com/-/spec/opensearch/extensions/parameters/1.0/',

media: 'http://search.yahoo.com/mrss/',
// EOP and OM related namespaces

@@ -81,2 +79,3 @@ opt: 'http://www.opengis.net/opt/2.1',

*/
exports.namespaces = namespaces;
function getChildren(element) {

@@ -97,3 +96,2 @@ if (element.children) {

var usedNamespaces = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : namespaces;
if (!element) {

@@ -108,3 +106,4 @@ return [];

});
} else if (tagName) {
}
if (tagName) {
return children.filter(function (child) {

@@ -146,3 +145,2 @@ return child.localName === tagName;

var usedNamespaces = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : namespaces;
var namespaceURI = usedNamespaces[namespace] || namespace;

@@ -154,3 +152,2 @@ if (node.hasAttributeNS(namespaceURI, name)) {

}
function splitNamespace(name) {

@@ -182,3 +179,2 @@ return name.indexOf(':') !== -1 ? name.split(':') : [null, name];

var usedNamespaces = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
// split path and discard empty parts

@@ -189,88 +185,87 @@ var parts = path.split('/').filter(function (part) {

var current = single ? element : [element];
var _loop = function _loop() {
var part = parts[i];
for (var i = 0; i < parts.length; ++i) {
var part = parts[i];
// single values are treated differently
if (single) {
if (part === 'text()') {
return current.textContent;
} else if (part.indexOf('@') !== -1) {
var _part$split = part.split('@'),
// single values are treated differently
if (single) {
if (part === 'text()') {
return {
v: current.textContent
};
}
if (part.indexOf('@') !== -1) {
var _part$split = part.split('@'),
_part$split2 = _slicedToArray(_part$split, 2),
nodePart = _part$split2[0],
attrPart = _part$split2[1];
var _splitNamespace = splitNamespace(nodePart),
var _splitNamespace = splitNamespace(nodePart),
_splitNamespace2 = _slicedToArray(_splitNamespace, 2),
_namespace = _splitNamespace2[0],
_tagName = _splitNamespace2[1];
var _splitNamespace3 = splitNamespace(attrPart),
var _splitNamespace3 = splitNamespace(attrPart),
_splitNamespace4 = _slicedToArray(_splitNamespace3, 2),
attrNamespace = _splitNamespace4[0],
attrName = _splitNamespace4[1];
current = getFirstElement(current, _namespace, _tagName, usedNamespaces);
return current ? getAttributeNS(current, attrNamespace, attrName, undefined, usedNamespaces) : null;
}
var _splitNamespace5 = splitNamespace(part),
current = getFirstElement(current, _namespace, _tagName, usedNamespaces);
return {
v: current ? getAttributeNS(current, attrNamespace, attrName, undefined, usedNamespaces) : null
};
}
var _splitNamespace5 = splitNamespace(part),
_splitNamespace6 = _slicedToArray(_splitNamespace5, 2),
namespace = _splitNamespace6[0],
tagName = _splitNamespace6[1];
current = getFirstElement(current, namespace, tagName, usedNamespaces);
if (!current) {
return null;
}
} else if (part === 'text()') {
return current.map(function (currentElement) {
return currentElement.textContent;
});
} else if (part.indexOf('@') !== -1) {
var _ret = function () {
current = getFirstElement(current, namespace, tagName, usedNamespaces);
if (!current) {
return {
v: null
};
}
} else if (part === 'text()') {
return {
v: current.map(function (currentElement) {
return currentElement.textContent;
})
};
} else if (part.indexOf('@') !== -1) {
var _part$split3 = part.split('@'),
_part$split4 = _slicedToArray(_part$split3, 2),
nodePart = _part$split4[0],
attrPart = _part$split4[1];
var _splitNamespace7 = splitNamespace(nodePart),
_splitNamespace8 = _slicedToArray(_splitNamespace7, 2),
namespace = _splitNamespace8[0],
tagName = _splitNamespace8[1];
var _splitNamespace9 = splitNamespace(attrPart),
_splitNamespace10 = _slicedToArray(_splitNamespace9, 2),
attrNamespace = _splitNamespace10[0],
attrName = _splitNamespace10[1];
_part$split4 = _slicedToArray(_part$split3, 2),
_nodePart = _part$split4[0],
_attrPart = _part$split4[1];
var _splitNamespace7 = splitNamespace(_nodePart),
_splitNamespace8 = _slicedToArray(_splitNamespace7, 2),
_namespace2 = _splitNamespace8[0],
_tagName2 = _splitNamespace8[1];
var _splitNamespace9 = splitNamespace(_attrPart),
_splitNamespace10 = _slicedToArray(_splitNamespace9, 2),
_attrNamespace = _splitNamespace10[0],
_attrName = _splitNamespace10[1];
return {
v: current.map(function (currentElement) {
return getElements(currentElement, namespace, tagName, usedNamespaces);
return getElements(currentElement, _namespace2, _tagName2, usedNamespaces);
}).reduce(function (acc, value) {
return acc.concat(value);
}, []).map(function (finalElement) {
return getAttributeNS(finalElement, attrNamespace, attrName, undefined, usedNamespaces);
}, [])
// eslint-disable-next-line max-len
.map(function (finalElement) {
return getAttributeNS(finalElement, _attrNamespace, _attrName, undefined, usedNamespaces);
})
};
}();
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
} else {
(function () {
} else {
var _splitNamespace11 = splitNamespace(part),
_splitNamespace12 = _slicedToArray(_splitNamespace11, 2),
namespace = _splitNamespace12[0],
tagName = _splitNamespace12[1];
_splitNamespace12 = _slicedToArray(_splitNamespace11, 2),
_namespace3 = _splitNamespace12[0],
_tagName3 = _splitNamespace12[1];
current = current.map(function (currentElement) {
return getElements(currentElement, namespace, tagName, usedNamespaces);
return getElements(currentElement, _namespace3, _tagName3, usedNamespaces);
}).reduce(function (acc, value) {
return acc.concat(value);
}, []);
})();
}
}
},
_ret;
for (var i = 0; i < parts.length; ++i) {
_ret = _loop();
if (_ret) return _ret.v;
}
return current;

@@ -338,3 +333,4 @@ }

// Node.DOCUMENT_TYPE_NODE
return null; // type is unknown
return null;
// type is unknown
case 2:

@@ -354,5 +350,4 @@ // Node.ATTRIBUTE_NODE

}
function fetchAndCheck() {
return fetch.apply(undefined, arguments).then(function (response) {
return fetch.apply(void 0, arguments).then(function (response) {
if (response.status >= 400) {

@@ -364,3 +359,2 @@ throw new Error('Bad response from server');

}
function isNullOrUndefined(value) {

@@ -382,23 +376,17 @@ return typeof value === 'undefined' || value === null;

}
function wrapParens(s) {
return '(' + s + ')';
}
function pairWKT(c) {
return c.join(' ');
}
function ringWKT(r) {
return r.map(pairWKT).join(', ');
}
function ringsWKT(r) {
return r.map(ringWKT).map(wrapParens).join(', ');
}
function multiRingsWKT(r) {
return r.map(ringsWKT).map(wrapParens).join(', ');
}
switch (gj.type) {

@@ -445,3 +433,2 @@ case 'Point':

var baseRequest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var xhr = new XMLHttpRequest();

@@ -485,6 +472,5 @@ xhr.open(baseRequest.method || 'GET', url);

function assign(target) {
for (var _len = arguments.length, sources = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
sources[_key - 1] = arguments[_key];
}
if (Object.assign) {

@@ -503,3 +489,4 @@ return Object.assign.apply(Object, [target].concat(sources));

}
return target;
}
{
"name": "opensearch-browser",
"version": "2.0.0-alpha.6",
"version": "2.0.0-alpha.7",
"description": "An OpenSearch client supporting the geo and time extensions.",

@@ -9,4 +9,3 @@ "main": "dist/index.js",

"test:watch": "npm run test -- -w",
"test:coverage": "mochify --transform babelify --transform [ stringify --extensions [.xml] ] --plugin [ mochify-istanbul --exclude '**/+(test|node_modules)/**/*' --report lcovonly ] test/setup.js test/*js test/formats/*js && cat lcov.info | coveralls && rm lcov.info",
"coverage": "mochify --transform babelify --transform [ stringify --extensions [.xml] ] --plugin [ mochify-istanbul --exclude '**/+(test|node_modules)/**/*' --report text ] test/setup.js test/*js test/formats/*js",
"coverage": "nyc --reporter text --reporter lcovonly --instrument false mochify --transform [ stringify --extensions [.xml] ] --transform [ babelify --ignore [ /.*/test/.* ] --plugins [ babel-plugin-istanbul] ]",
"build": "babel src/ -d dist/ && browserify -d -t babelify src/index.js -o dist/opensearch-browserify.js",

@@ -35,30 +34,26 @@ "watch": "babel src/ -d dist/ -w",

"event-emitter": "^0.3.5",
"isomorphic-fetch": "^2.2.1",
"isomorphic-fetch": "^3.0.0",
"url-parse": "^1.4.7"
},
"devDependencies": {
"babel-cli": "^6.22.2",
"babel-eslint": "^7.1.1",
"babel-plugin-transform-es2015-destructuring": "^6.23.0",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.22.0",
"@babel/cli": "^7.22.10",
"@babel/core": "^7.22.11",
"@babel/eslint-parser": "^7.22.11",
"@babel/eslint-plugin": "^7.22.10",
"@babel/preset-env": "^7.22.10",
"@babel/register": "^7.22.5",
"babel-plugin-istanbul": "^6.1.1",
"babel-polyfill": "^6.22.0",
"babel-preset-es2015": "^6.22.0",
"babel-register": "^6.22.0",
"babelify": "^7.3.0",
"bluebird": "3.5.5",
"babelify": "^10.0.0",
"bluebird": "3.7.2",
"browserify": "^14.3.0",
"chai": "^3.5.0",
"coveralls": "^3.0.4",
"eslint": "^3.14.1",
"eslint-config-airbnb": "^14.0.0",
"eslint-config-pedant": "^0.8.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^3.0.2",
"eslint-plugin-react": "^6.9.0",
"fetch-mock": "^5.9.3",
"istanbul": "^0.4.5",
"coveralls": "^3.1.1",
"eslint": "^8.47.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.28.0",
"fetch-mock": "^6.4.2",
"jsdoc": "^3.5.5",
"mochify": "^2.18.1",
"mochify-istanbul": "^2.4.2",
"mochify": "^9.2.0",
"nyc": "^15.1.0",
"sinon": "^1.17.7",

@@ -65,0 +60,0 @@ "sinon-chai": "^2.8.0",

# OpenSearch JavaScript client
[![Build Status](https://travis-ci.org/eoxc/opensearch.svg?branch=master)](https://travis-ci.org/eoxc/opensearch) [![NPM](https://nodei.co/npm/opensearch-browser.png?mini=true)](https://nodei.co/npm/opensearch-browser/)
[![NPM](https://nodei.co/npm/opensearch-browser.png?mini=true)](https://nodei.co/npm/opensearch-browser/)
[![Coverage Status](https://coveralls.io/repos/github/eoxc/opensearch/badge.svg?branch=master)](https://coveralls.io/github/eoxc/opensearch?branch=master)

@@ -92,3 +92,3 @@

then the the following request parameters are possible:
then the following request parameters are possible:

@@ -208,8 +208,8 @@ ```javascript

functionality and exchange formats. It also supports the
[Geo](http://www.opensearch.org/Specifications/OpenSearch/Extensions/Geo/1.0/Draft_1),
[Time](http://www.opensearch.org/Specifications/OpenSearch/Extensions/Time/1.0/Draft_1),
[EO Products](https://portal.opengeospatial.org/files/?artifact_id=61006),
[Parameters](http://www.opensearch.org/Specifications/OpenSearch/Extensions/Parameter/1.0), and
[Suggestions](http://www.opensearch.org/Specifications/OpenSearch/Extensions/Suggestions/1.1)
[Geo](https://web.archive.org/web/20180427065533/http://www.opensearch.org/Specifications/OpenSearch/Extensions/Geo/1.0/Draft_2),
[Time](https://web.archive.org/web/20180406022122/http://www.opensearch.org/Specifications/OpenSearch/Extensions/Time/1.0/Draft_1),
[EO Products](https://www.opengis.net/doc/is/opensearch-eo/1.0),
[Parameters](https://web.archive.org/web/20180408193434/http://www.opensearch.org/Specifications/OpenSearch/Extensions/Parameter/1.0), and
[Suggestions](https://web.archive.org/web/20180406023110/http://www.opensearch.org/Specifications/OpenSearch/Extensions/Suggestions/1.1)
extensions and adheres to various points of the
[CEOS OpenSearch best practice paper](http://ceos.org/document_management/Working_Groups/WGISS/Interest_Groups/OpenSearch/CEOS-OPENSEARCH-BP-V1.1-Final.pdf).
[CEOS OpenSearch best practice paper](https://ceos.org/document_management/Working_Groups/WGISS/Interest_Groups/OpenSearch/CEOS-OPENSEARCH-BP-V1.2.pdf).
import { OpenSearchUrl } from './url';
import { parseXml, getElements, getText, find, assign } from './utils';
import {
parseXml, getElements, getText, find, assign,
} from './utils';

@@ -70,7 +72,7 @@ /**

getUrls(parameters = null, type = null, method = null) {
let urls = this.urls.filter(url => find(url.relations, rel => rel === 'results'));
let urls = this.urls.filter((url) => find(url.relations, (rel) => rel === 'results'));
if (type) {
urls = urls.filter(
url => (Array.isArray(type) ? type.indexOf(url.type) > -1 : url.type === type)
(url) => (Array.isArray(type) ? type.indexOf(url.type) > -1 : url.type === type)
);

@@ -80,3 +82,3 @@ }

urls = urls.filter(
url => (Array.isArray(method) ? method.indexOf(url.method) > -1 : url.method === method)
(url) => (Array.isArray(method) ? method.indexOf(url.method) > -1 : url.method === method)
);

@@ -87,3 +89,3 @@ }

return urls.filter(
url => url.isCompatible(parameters)
(url) => url.isCompatible(parameters)
);

@@ -108,6 +110,6 @@ }

urls: getElements(xmlDoc, 'os', 'Url').map(
node => OpenSearchUrl.fromNode(node)
(node) => OpenSearchUrl.fromNode(node)
),
longName: getText(xmlDoc, 'os', 'LongName'),
images: getElements(xmlDoc, 'os', 'Image').map(node => ({
images: getElements(xmlDoc, 'os', 'Image').map((node) => ({
height: parseInt(node.getAttribute('height'), 10),

@@ -147,3 +149,3 @@ width: parseInt(node.getAttribute('width'), 10),

contact: this.contact,
urls: this.urls.map(url => url.serialize()),
urls: this.urls.map((url) => url.serialize()),
longName: this.longName,

@@ -169,5 +171,5 @@ images: this.images,

return new OpenSearchDescription(assign({}, values, {
urls: values.urls.map(urlDesc => OpenSearchUrl.deserialize(urlDesc)),
urls: values.urls.map((urlDesc) => OpenSearchUrl.deserialize(urlDesc)),
}));
}
}
import { parseXml, getElements, getText } from '../utils';
import { BaseFeedFormat } from './base';
/**

@@ -6,0 +5,0 @@ * @module opensearch/formats/atom

@@ -1,4 +0,5 @@

import { getElements, getFirstElement, getText, simplePath } from '../utils';
import {
getElements, getFirstElement, getText, simplePath,
} from '../utils';
function swapAndPair(values) {

@@ -31,10 +32,6 @@ const out = [];

const exterior = parseGmlLine(
getFirstElement(exteriorElement, namespaceURI, 'LinearRing'), namespaceURI
);
const exterior = parseGmlLine(getFirstElement(exteriorElement, namespaceURI, 'LinearRing'), namespaceURI);
const interiors = interiorElements
.map(interiorElement => parseGmlLine(
getFirstElement(interiorElement, namespaceURI, 'LinearRing'), namespaceURI
));
.map((interiorElement) => parseGmlLine(getFirstElement(interiorElement, namespaceURI, 'LinearRing'), namespaceURI));
return [exterior, ...interiors];

@@ -100,4 +97,4 @@ }

const polygons = getElements(node, node.namespaceURI, 'polygonMember')
.map(surfaceMember => getFirstElement(surfaceMember, surfaceMember.namespaceURI, 'Polygon'));
const coordinates = polygons.map(polygon => parseGmlPolygon(polygon, node.namespaceURI));
.map((surfaceMember) => getFirstElement(surfaceMember, surfaceMember.namespaceURI, 'Polygon'));
const coordinates = polygons.map((polygon) => parseGmlPolygon(polygon, node.namespaceURI));
return {

@@ -111,3 +108,3 @@ type: 'MultiPolygon',

let polygons = getElements(node, node.namespaceURI, 'surfaceMember')
.map(surfaceMember => getFirstElement(surfaceMember, surfaceMember.namespaceURI, 'Polygon'));
.map((surfaceMember) => getFirstElement(surfaceMember, surfaceMember.namespaceURI, 'Polygon'));
const surfaceMembers = getFirstElement(node, node.namespaceURI, 'surfaceMembers');

@@ -117,3 +114,3 @@ if (surfaceMembers) {

}
const coordinates = polygons.map(polygon => parseGmlPolygon(polygon, node.namespaceURI));
const coordinates = polygons.map((polygon) => parseGmlPolygon(polygon, node.namespaceURI));
return {

@@ -200,3 +197,3 @@ type: 'MultiPolygon',

case 'MultiPolygon': {
const bboxes = coords.map(polygon => boxFromLineString(polygon[0]));
const bboxes = coords.map((polygon) => boxFromLineString(polygon[0]));
const outBox = bboxes[0];

@@ -223,3 +220,3 @@ for (let i = 1; i < bboxes.length; ++i) {

return new Date(date);
} else if (values.length >= 1) {
} if (values.length >= 1) {
return [new Date(values[0]), new Date(values[1])];

@@ -257,3 +254,3 @@ }

const groupedMedias = groups
.map(group => getElements(group, 'media', 'content'))
.map((group) => getElements(group, 'media', 'content'))
.reduce((oldElems, newElems) => oldElems.concat(newElems), []);

@@ -284,4 +281,4 @@ const allMedias = directMedias.concat(groupedMedias);

resolution:
simplePath(eoEquipment, 'sensor/Sensor/resolution/text()', true) +
simplePath(eoEquipment, 'sensor/Sensor/resolution@uom', true),
simplePath(eoEquipment, 'sensor/Sensor/resolution/text()', true)
+ simplePath(eoEquipment, 'sensor/Sensor/resolution@uom', true),
orbitNumber: simplePath(eoEquipment, 'acquisitionParameters/Acquisition/orbitNumber/text()', true),

@@ -288,0 +285,0 @@ cloudCoverPercentage: simplePath(eoNode, 'om:result/opt:EarthObservationResult/opt:cloudCoverPercentage/text()', true),

import { assign } from '../utils';
/**

@@ -5,0 +4,0 @@ * @module opensearch/formats/geojson

@@ -6,3 +6,2 @@ import { AtomFormat } from './atom';

/**

@@ -12,3 +11,3 @@ * @module opensearch/formats

/**
/**
* The interface built-in and custom format parsers must conform to.

@@ -18,3 +17,3 @@ * @interface module:opensearch/formats.FormatInterface

/**
/**
* Main parsing function for the format.

@@ -27,3 +26,3 @@ * @function

/**
/**
* @typedef module:opensearch/formats.Record

@@ -37,3 +36,3 @@ * @type Object

/**
/**
* @typedef module:opensearch/formats.SearchResult

@@ -49,3 +48,3 @@ * @type Object

/**
/**
* @typedef module:opensearch/formats.Suggestion

@@ -52,0 +51,0 @@ * @type Object

@@ -1,5 +0,6 @@

import { parseXml, getElements, getFirstElement, getText } from '../utils';
import {
parseXml, getElements, getFirstElement, getText,
} from '../utils';
import { BaseFeedFormat } from './base';
/**

@@ -6,0 +7,0 @@ * @module opensearch/formats/rss

@@ -10,3 +10,2 @@ /**

export class SuggestionsJSONFormat {
/**

@@ -13,0 +12,0 @@ * Parse the given JSON.

@@ -0,1 +1,2 @@

// eslint-disable-next-line max-classes-per-file
import EventEmitter from 'event-emitter';

@@ -6,3 +7,2 @@ import { search } from './search';

/**

@@ -45,3 +45,2 @@ * @module opensearch/paginator

function isCancellable(promise) {

@@ -204,11 +203,10 @@ return promise && typeof promise.cancel === 'function' && !promise.isCancelled();

const requests = [firstPage];
const usedMaxCount =
Math.min(
maxCount,
(firstPage.totalResults - firstPage.startIndex) + this._url.indexOffset
);
const usedMaxCount = Math.min(
maxCount,
(firstPage.totalResults - firstPage.startIndex) + this._url.indexOffset
);
// determine the number of pages and issue a request for each
const numPages = firstPage.itemsPerPage ?
Math.ceil(usedMaxCount / firstPage.itemsPerPage) : 1;
const numPages = firstPage.itemsPerPage
? Math.ceil(usedMaxCount / firstPage.itemsPerPage) : 1;
for (let i = 1; i < numPages; ++i) {

@@ -223,3 +221,3 @@ let count = firstPage.itemsPerPage;

return Promise.all(requests)
.then(pages => combinePages(pages));
.then((pages) => combinePages(pages));
});

@@ -296,4 +294,4 @@ }

// determine the number of pages and issue a request for each
const numPages = firstPage.itemsPerPage ?
Math.ceil(usedMaxCount / firstPage.itemsPerPage) : 1;
const numPages = firstPage.itemsPerPage
? Math.ceil(usedMaxCount / firstPage.itemsPerPage) : 1;
for (let i = startPageIndex; i < numPages; ++i) {

@@ -358,5 +356,5 @@ let count = firstPage.itemsPerPage;

return Math.min(this._preferredItemsPerPage, this._serverItemsPerPage);
} else if (this._serverItemsPerPage) {
} if (this._serverItemsPerPage) {
return this._serverItemsPerPage;
} else if (this._preferredItemsPerPage) {
} if (this._preferredItemsPerPage) {
return this._preferredItemsPerPage;

@@ -368,3 +366,3 @@ }

return countParam.maxExclusive - 1;
} else if (countParam.maxInclusive) {
} if (countParam.maxInclusive) {
return countParam.maxInclusive;

@@ -385,3 +383,3 @@ }

return this._totalResults;
} else if (!pageSize) {
} if (!pageSize) {
return undefined;

@@ -388,0 +386,0 @@ }

import { getElements, isNullOrUndefined, toWKT } from './utils';
/**

@@ -8,3 +7,2 @@ * @module opensearch/parameter

const typeRE = /{([a-zA-Z:]+)([?]?)}/;

@@ -47,2 +45,3 @@ const typeREglobal = /{([a-zA-Z:]+)([?]?)}/g;

// Try without Zulu and milliseconds
// eslint-disable-next-line prefer-destructuring
formatted = isoString.split('.')[0];

@@ -60,11 +59,11 @@ if (!rePattern || rePattern.test(formatted)) {

function eoValueToString(value, isDate = false, pattern = undefined) {
const convertDate = dateValue => formatDate(dateValue, pattern);
const convertDate = (dateValue) => formatDate(dateValue, pattern);
if (typeof value === 'string') {
return value;
} else if (typeof value === 'number') {
} if (typeof value === 'number') {
return value.toString();
} else if (isDate && value instanceof Date) {
} if (isDate && value instanceof Date) {
return convertDate(value);
} else if (Array.isArray(value)) {
} if (Array.isArray(value)) {
if (isDate) {

@@ -92,3 +91,3 @@ return `{${value.map(convertDate).join(',')}}`;

return `${left},${right}`;
} else if (left !== null) {
} if (left !== null) {
return left;

@@ -99,3 +98,2 @@ }

function serializeValue(value, type, pattern) {

@@ -162,6 +160,13 @@ switch (type) {

*/
constructor(type, name, mandatory, options = null,
minExclusive = undefined, maxExclusive = undefined,
minInclusive = undefined, maxInclusive = undefined,
pattern = undefined) {
constructor(
type,
name,
mandatory,
options = null,
minExclusive = undefined,
maxExclusive = undefined,
minInclusive = undefined,
maxInclusive = undefined,
pattern = undefined
) {
this._type = type;

@@ -266,3 +271,4 @@ this._name = name;

return new OpenSearchParameter(
this.type, this.name,
this.type,
this.name,
isNullOrUndefined(this.mandatory) ? other.mandatory : this.mandatory,

@@ -294,3 +300,3 @@ isNullOrUndefined(this.options) ? other.options : this.options,

return serializeValue(value[this.types.indexOf(type)], type, this.pattern);
} else if (Object.prototype.hasOwnProperty.call(value, type)) {
} if (Object.prototype.hasOwnProperty.call(value, type)) {
return serializeValue(value[type], type, this.pattern);

@@ -312,22 +318,22 @@ }

const mandatory = node.hasAttribute('minimum')
? node.getAttribute('minimum') !== '0' : undefined;
? node.getAttribute('minimum') !== '0' : undefined;
const minExclusive = node.hasAttribute('minExclusive')
? parseInt(node.getAttribute('minExclusive'), 10)
: undefined;
? parseInt(node.getAttribute('minExclusive'), 10)
: undefined;
const maxExclusive = node.hasAttribute('maxExclusive')
? parseInt(node.getAttribute('maxExclusive'), 10)
: undefined;
? parseInt(node.getAttribute('maxExclusive'), 10)
: undefined;
const minInclusive = node.hasAttribute('minInclusive')
? parseInt(node.getAttribute('minInclusive'), 10)
: undefined;
? parseInt(node.getAttribute('minInclusive'), 10)
: undefined;
const maxInclusive = node.hasAttribute('maxInclusive')
? parseInt(node.getAttribute('maxInclusive'), 10)
: undefined;
? parseInt(node.getAttribute('maxInclusive'), 10)
: undefined;
const pattern = node.hasAttribute('pattern')
? node.getAttribute('pattern')
: undefined;
? node.getAttribute('pattern')
: undefined;
const optionNodes = getElements(node, 'parameters', 'Option');
let options;
if (optionNodes.length) {
options = optionNodes.map(optionNode => ({
options = optionNodes.map((optionNode) => ({
label: optionNode.getAttribute('label'),

@@ -338,4 +344,11 @@ value: optionNode.getAttribute('value'),

return new OpenSearchParameter(
type, name, mandatory, options,
minExclusive, maxExclusive, minInclusive, maxInclusive, pattern
type,
name,
mandatory,
options,
minExclusive,
maxExclusive,
minInclusive,
maxInclusive,
pattern
);

@@ -360,5 +373,3 @@ }

}
return new OpenSearchParameter(
type, key, isMandatory(value)
);
return new OpenSearchParameter(type, key, isMandatory(value));
}

@@ -403,4 +414,10 @@ return null;

return new OpenSearchParameter(
values.type, values.name, values.mandatory, values.options,
values.minExclusive, values.maxExclusive, values.minInclusive, values.maxInclusive,
values.type,
values.name,
values.mandatory,
values.options,
values.minExclusive,
values.maxExclusive,
values.minInclusive,
values.maxInclusive,
values.pattern,

@@ -407,0 +424,0 @@ );

@@ -16,3 +16,3 @@ /* eslint no-underscore-dangle:

/**
/**
* @typedef module:opensearch/search.BaseRequest

@@ -47,3 +47,3 @@ * @type Object

const missingMandatoryParameters = url.getMissingMandatoryParameters(parameterValues)
.map(parameter => parameter.type);
.map((parameter) => parameter.type);

@@ -70,5 +70,5 @@ if (missingMandatoryParameters.length) {

const query = parsed.query.split('&')
.map(param => param.split('='))
.filter(paramParts => paramParts[1] !== '')
.map(paramParts => paramParts.join('='))
.map((param) => param.split('='))
.filter((paramParts) => paramParts[1] !== '')
.map((paramParts) => paramParts.join('='))
.join('&');

@@ -128,3 +128,5 @@

export function search(url, parameters = {}, options = {}) {
const { type, raw, maxUrlLength, dropEmptyParameters, parseOptions, headers } = options;
const {
type, raw, maxUrlLength, dropEmptyParameters, parseOptions, headers,
} = options;

@@ -168,3 +170,3 @@ const baseRequest = createBaseRequest(url, parameters, dropEmptyParameters, headers);

}
request = request.then(response => response.text().then(text => [text, response.status]));
request = request.then((response) => response.text().then((text) => [text, response.status]));
}

@@ -171,0 +173,0 @@

@@ -6,3 +6,3 @@ import 'isomorphic-fetch';

import { search, createBaseRequest } from './search';
import { getSupportedTypes } from './formats/';
import { getSupportedTypes } from './formats';
import { fetchAndCheck, createXHR } from './utils';

@@ -46,6 +46,6 @@ import { config } from './config';

.getMissingMandatoryParameters(parameters)
.map(p => `"${p.type}"`);
.map((p) => `"${p.type}"`);
const unsupportedParameterKeys = alternativeUrls[0]
.getUnsupportedParameterKeys(parameters)
.map(k => `"${k}"`);
.map((k) => `"${k}"`);

@@ -164,5 +164,3 @@ const terms = [];

const { type = null, method = null } = options;
return new OpenSearchPaginator(
this.getUrl(parameters, type, method), parameters, options
);
return new OpenSearchPaginator(this.getUrl(parameters, type, method), parameters, options);
}

@@ -198,4 +196,4 @@

return fetchAndCheck(url)
.then(response => response.text())
.then(response => OpenSearchService.fromXml(response));
.then((response) => response.text())
.then((response) => OpenSearchService.fromXml(response));
}

@@ -202,0 +200,0 @@

@@ -5,3 +5,2 @@ import parse from 'url-parse';

/**

@@ -11,7 +10,6 @@ * @module opensearch/url

function isParameterMissing(parameterValues, parameter) {
if (Object.prototype.hasOwnProperty.call(parameterValues, parameter.name)) {
return false;
} else if (parameter.isMulti) {
} if (parameter.isMulti) {
const types = parameter.type;

@@ -29,3 +27,2 @@ for (let i = 0; i < types.length; ++i) {

/**

@@ -54,5 +51,12 @@ * Class to parse a single URL of an OpenSearchDescription XML document and

*/
constructor(type, url, parameters = [], method = 'GET',
constructor(
type,
url,
parameters = [],
method = 'GET',
enctype = 'application/x-www-form-urlencoded',
indexOffset = 1, pageOffset = 1, relations = ['results']) {
indexOffset = 1,
pageOffset = 1,
relations = ['results']
) {
this._type = type;

@@ -193,4 +197,4 @@ this._url = url;

return this.parameters
.filter(parameter => parameter.mandatory)
.filter(parameter => isParameterMissing(parameterValues, parameter));
.filter((parameter) => parameter.mandatory)
.filter((parameter) => isParameterMissing(parameterValues, parameter));
}

@@ -203,4 +207,4 @@

return this.parameters
.filter(parameter => !parameter.mandatory)
.filter(parameter => isParameterMissing(parameterValues, parameter));
.filter((parameter) => !parameter.mandatory)
.filter((parameter) => isParameterMissing(parameterValues, parameter));
}

@@ -212,6 +216,6 @@

getUnsupportedParameterKeys(parameters) {
return Object.keys(parameters).filter(key => (
!Object.prototype.hasOwnProperty.call(this._parametersByType, key)
return Object.keys(parameters).filter((key) => (
!Object.prototype.hasOwnProperty.call(this._parametersByType, key)
&& !Object.prototype.hasOwnProperty.call(this._parametersByName, key)
));
));
}

@@ -234,3 +238,3 @@

const missingMandatoryParameters = this.getMissingMandatoryParameters(values)
.map(parameter => parameter.type);
.map((parameter) => parameter.type);

@@ -241,3 +245,3 @@ if (missingMandatoryParameters.length) {

const serialized = [];
const parameters = this.parameters;
const { parameters } = this;
for (let i = 0; i < parameters.length; ++i) {

@@ -281,6 +285,6 @@ const parameter = parameters[i];

const enctype = getAttributeNS(node, 'parameters', 'enctype');
const indexOffset = node.hasAttribute('indexOffset') ?
parseInt(node.getAttribute('indexOffset'), 10) : 1;
const pageOffset = node.hasAttribute('pageOffset') ?
parseInt(node.getAttribute('pageOffset'), 10) : 1;
const indexOffset = node.hasAttribute('indexOffset')
? parseInt(node.getAttribute('indexOffset'), 10) : 1;
const pageOffset = node.hasAttribute('pageOffset')
? parseInt(node.getAttribute('pageOffset'), 10) : 1;
const rel = node.getAttribute('rel');

@@ -291,8 +295,8 @@ const relations = (!rel || rel === '') ? undefined : rel.split(' ');

const parametersFromTemplate = Object.keys(parsed.query)
.map(name => OpenSearchParameter.fromKeyValuePair(name, parsed.query[name]))
.filter(parameter => parameter);
.map((name) => OpenSearchParameter.fromKeyValuePair(name, parsed.query[name]))
.filter((parameter) => parameter);
const parametersFromNode = parameterNodes.map(OpenSearchParameter.fromNode);
const parametersNotInTemplate = parametersFromNode.filter(
p1 => !find(parametersFromTemplate, p2 => p1.name === p2.name)
(p1) => !find(parametersFromTemplate, (p2) => p1.name === p2.name)
).map((param) => {

@@ -306,3 +310,3 @@ // eslint-disable-next-line no-underscore-dangle, no-param-reassign

const parameters = parametersFromTemplate.map((p1) => {
const p2 = find(parametersFromNode, p => p1.name === p.name);
const p2 = find(parametersFromNode, (p) => p1.name === p.name);
if (p2) {

@@ -315,4 +319,10 @@ return p1.combined(p2);

return new OpenSearchUrl(
node.getAttribute('type'), node.getAttribute('template'),
parameters, method, enctype, indexOffset, pageOffset, relations
node.getAttribute('type'),
node.getAttribute('template'),
parameters,
method,
enctype,
indexOffset,
pageOffset,
relations
);

@@ -329,8 +339,12 @@ }

*/
static fromTemplateUrl(type, templateUrl, method = 'GET',
enctype = 'application/x-www-form-urlencoded') {
static fromTemplateUrl(
type,
templateUrl,
method = 'GET',
enctype = 'application/x-www-form-urlencoded'
) {
const parsed = parse(templateUrl, true);
const parameters = Object.keys(parsed.query)
.map(name => OpenSearchParameter.fromKeyValuePair(name, parsed.query[name]))
.filter(parameter => parameter);
.map((name) => OpenSearchParameter.fromKeyValuePair(name, parsed.query[name]))
.filter((parameter) => parameter);
return new OpenSearchUrl(type, templateUrl, parameters, method, enctype);

@@ -352,3 +366,3 @@ }

relations: this._relations,
parameters: this._parameters.map(parameter => parameter.serialize()),
parameters: this._parameters.map((parameter) => parameter.serialize()),
};

@@ -364,7 +378,12 @@ }

return new OpenSearchUrl(
values.type, values.url,
values.parameters.map(parameterDesc => OpenSearchParameter.deserialize(parameterDesc)),
values.method, values.enctype, values.indexOffset, values.pageOffset, values.relations
values.type,
values.url,
values.parameters.map((parameterDesc) => OpenSearchParameter.deserialize(parameterDesc)),
values.method,
values.enctype,
values.indexOffset,
values.pageOffset,
values.relations
);
}
}
import 'isomorphic-fetch';
/**

@@ -22,3 +21,3 @@ * @module opensearch/utils

return (new DOMParser()).parseFromString(xmlStr, 'text/xml');
} else if (typeof ActiveXObject !== 'undefined') {
} if (typeof ActiveXObject !== 'undefined') {
const xmlDoc = new ActiveXObject('Microsoft.XMLDOM'); // eslint-disable-line no-undef

@@ -56,3 +55,3 @@ xmlDoc.async = 'false';

}
return Array.from(element.childNodes).filter(node => node.nodeType === 1); // Node.ELEMENT_NODE
return Array.from(element.childNodes).filter((node) => node.nodeType === 1); // Node.ELEMENT_NODE
}

@@ -72,6 +71,6 @@

return children.filter(
child => child.localName === tagName && child.namespaceURI === namespaceURI
(child) => child.localName === tagName && child.namespaceURI === namespaceURI
);
} else if (tagName) {
return children.filter(child => child.localName === tagName);
} if (tagName) {
return children.filter((child) => child.localName === tagName);
}

@@ -141,3 +140,3 @@ return children;

// split path and discard empty parts
const parts = path.split('/').filter(part => part.length);
const parts = path.split('/').filter((part) => part.length);
let current = single ? element : [element];

@@ -152,3 +151,3 @@

return current.textContent;
} else if (part.indexOf('@') !== -1) {
} if (part.indexOf('@') !== -1) {
const [nodePart, attrPart] = part.split('@');

@@ -158,4 +157,4 @@ const [namespace, tagName] = splitNamespace(nodePart);

current = getFirstElement(current, namespace, tagName, usedNamespaces);
return current ?
getAttributeNS(current, attrNamespace, attrName, undefined, usedNamespaces) : null;
return current
? getAttributeNS(current, attrNamespace, attrName, undefined, usedNamespaces) : null;
}

@@ -168,3 +167,3 @@ const [namespace, tagName] = splitNamespace(part);

} else if (part === 'text()') {
return current.map(currentElement => currentElement.textContent);
return current.map((currentElement) => currentElement.textContent);
} else if (part.indexOf('@') !== -1) {

@@ -175,13 +174,12 @@ const [nodePart, attrPart] = part.split('@');

return current.map(
currentElement => getElements(currentElement, namespace, tagName, usedNamespaces)
)
(currentElement) => getElements(currentElement, namespace, tagName, usedNamespaces)
)
.reduce((acc, value) => acc.concat(value), [])
.map(finalElement =>
getAttributeNS(finalElement, attrNamespace, attrName, undefined, usedNamespaces)
);
// eslint-disable-next-line max-len
.map((finalElement) => getAttributeNS(finalElement, attrNamespace, attrName, undefined, usedNamespaces));
} else {
const [namespace, tagName] = splitNamespace(part);
current = current.map(
currentElement => getElements(currentElement, namespace, tagName, usedNamespaces)
)
(currentElement) => getElements(currentElement, namespace, tagName, usedNamespaces)
)
.reduce((acc, value) => acc.concat(value), []);

@@ -194,3 +192,2 @@ }

// adapted from https://developer.mozilla.org/en-US/Add-ons/Code_snippets/LookupPrefix

@@ -197,0 +194,0 @@ // Private function for lookupPrefix only

@@ -7,3 +7,2 @@ import { expect } from 'chai';

describe('OpenSearchDescription', () => {

@@ -19,4 +18,8 @@ describe('constructor', () => {

expect(description.images).to.deep.equal([
{ width: 64, height: 64, type: 'image/png', url: 'http://example.com/websearch.png' },
{ width: 16, height: 16, type: 'image/vnd.microsoft.icon', url: 'http://example.com/websearch.ico' },
{
width: 64, height: 64, type: 'image/png', url: 'http://example.com/websearch.png',
},
{
width: 16, height: 16, type: 'image/vnd.microsoft.icon', url: 'http://example.com/websearch.ico',
},
]);

@@ -23,0 +26,0 @@ expect(description.queries).to.deep.equal([

@@ -12,11 +12,7 @@ /* eslint-disable no-unused-expressions */

describe('OpenSearchPaginator', () => {
const simpleUrl = OpenSearchUrl.fromTemplateUrl(
'application/atom+xml', 'http://example.com/?start={startIndex?}&count={count?}'
);
const urlWithCountMax = new OpenSearchUrl(
'application/atom+xml', 'http://example.com/', [
new OpenSearchParameter('count', 'count', false, null, undefined, undefined, 1, 25),
new OpenSearchParameter('start', 'startIndex'),
], 'application/x-www-form-urlencoded', 0, 0
);
const simpleUrl = OpenSearchUrl.fromTemplateUrl('application/atom+xml', 'http://example.com/?start={startIndex?}&count={count?}');
const urlWithCountMax = new OpenSearchUrl('application/atom+xml', 'http://example.com/', [
new OpenSearchParameter('count', 'count', false, null, undefined, undefined, 1, 25),
new OpenSearchParameter('start', 'startIndex'),
], 'application/x-www-form-urlencoded', 0, 0);

@@ -23,0 +19,0 @@ let searchStub;

@@ -7,7 +7,7 @@ import { expect } from 'chai';

// import fetchMock after isomorphic-fetch was set up to not confuse global `Request`
// eslint-disable-next-line import/first
// eslint-disable-next-line import/order
import fetchMock from 'fetch-mock';
// eslint-disable-next-line import/first
// eslint-disable-next-line import/order
import BluebirdPromise from 'bluebird';
// eslint-disable-next-line import/first
// eslint-disable-next-line import/order
import xhrMock from 'xhr-mock';

@@ -27,9 +27,8 @@

xhrMock.setup();
xhrMock.get(new RegExp('.*'), (req, res) =>
res
.status(200)
.body(atomExample)
);
// eslint-disable-next-line
xhrMock.get(new RegExp('.*'), (req, res) => res
.status(200)
.body(atomExample));
savedConfig = Object.assign({}, config());
savedConfig = { ...config() };
});

@@ -75,3 +74,2 @@ after(() => {

const errorXml = `<?xml version="1.0" encoding="UTF-8"?><ows:ExceptionReport xmlns:ows="http://www.opengis.net/ows/2.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" xml:lang="en" xsi:schemaLocation="http://www.opengis.net/ows/2.0 http://schemas.opengis.net/ows/2.0/owsExceptionReport.xsd">

@@ -92,9 +90,8 @@ <ows:Exception exceptionCode="InvalidParameterValue" locator="httpAccept">

xhrMock.setup();
xhrMock.get(new RegExp('.*'), (req, res) =>
res
.status(400)
.body(errorXml)
);
// eslint-disable-next-line
xhrMock.get(new RegExp('.*'), (req, res) => res
.status(400)
.body(errorXml));
savedConfig = Object.assign({}, config());
savedConfig = { ...config() };
});

@@ -110,3 +107,3 @@ after(() => {

it('should correctly report errors with XHR based searches', (done) => {
it('should correctly report errors with XHR based searches', () => {
config({ useXHR: true });

@@ -116,7 +113,6 @@ return search(service.getDescription().getUrl(), { searchTerms: 'terms' })

expect(error.message).to.equal('MIME type {xapplication/atom+xml} is not supported for dataset series {EOP:CODE-DE:S1_SAR_L1_GRD}.');
done();
});
}).then();
});
it('should correctly report errors with fetch based searches', (done) => {
it('should correctly report errors with fetch based searches', () => {
config({ useXHR: false });

@@ -126,4 +122,3 @@ return search(service.getDescription().getUrl(), { searchTerms: 'terms' })

expect(error.message).to.equal('MIME type {xapplication/atom+xml} is not supported for dataset series {EOP:CODE-DE:S1_SAR_L1_GRD}.');
done();
});
}).then();
});

@@ -130,0 +125,0 @@

@@ -7,3 +7,3 @@ /* eslint no-unused-expressions: ["off"] */

// import fetchMock after isomorphic-fetch was set up to not confuse global `Request`
// eslint-disable-next-line import/first
// eslint-disable-next-line import/order
import fetchMock from 'fetch-mock';

@@ -64,3 +64,2 @@

describe('OpenSearchService', () => {

@@ -67,0 +66,0 @@ before(() => {

@@ -60,3 +60,2 @@ import { expect } from 'chai';

describe('serializeValues', () => {

@@ -91,2 +90,3 @@ const xml = `<os:Url

/* eslint-disable */
/* TODO: this was moved to a separate file

@@ -202,2 +202,3 @@ describe('#createRequest', () => {

*/
/* eslint-enable */
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc