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

opensearch-browser

Package Overview
Dependencies
Maintainers
2
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 1.0.7 to 1.0.8

4

dist/paginator.js

@@ -258,3 +258,3 @@ 'use strict';

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

@@ -327,3 +327,3 @@ var count = firstPage.itemsPerPage;

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

@@ -330,0 +330,0 @@ var count = firstPage.itemsPerPage;

@@ -32,10 +32,43 @@ 'use strict';

function formatDate(value) {
var pattern = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
var rePattern = pattern ? new RegExp(pattern) : null;
if (value instanceof Date) {
var isoString = value.toISOString();
var formatted = isoString;
if (!rePattern || rePattern.test(formatted)) {
return formatted;
}
// Try without milliseconds
formatted = isoString.split('.')[0] + 'Z';
if (!rePattern || rePattern.test(formatted)) {
return formatted;
}
// Try without Zulu
formatted = isoString.slice(0, -1);
if (!rePattern || rePattern.test(formatted)) {
return formatted;
}
// Try without Zulu and milliseconds
formatted = isoString.split('.')[0];
if (!rePattern || rePattern.test(formatted)) {
return formatted;
}
// as fallback return the default ISO format
return isoString;
}
return value;
}
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) {
if (dateValue instanceof Date) {
return dateValue.toISOString();
}
return value;
return formatDate(dateValue, pattern);
};

@@ -106,2 +139,3 @@

var maxInclusive = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : undefined;
var pattern = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : undefined;

@@ -118,2 +152,3 @@ _classCallCheck(this, OpenSearchParameter);

this._maxInclusive = maxInclusive;
this._pattern = pattern;
}

@@ -137,3 +172,3 @@

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);
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);
}

@@ -156,6 +191,3 @@

case 'time:end':
if (value instanceof Date) {
return value.toISOString();
}
break;
return formatDate(value, this.pattern);
case 'geo:box':

@@ -182,3 +214,3 @@ if (Array.isArray(value)) {

case 'eo:incidenceAngleVariation':
return eoValueToString(value);
return eoValueToString(value, false, this.pattern);
case 'eo:availabilityTime':

@@ -188,3 +220,3 @@ case 'eo:creationDate':

case 'eo:processingDate':
return eoValueToString(value, true);
return eoValueToString(value, true, this.pattern);
default:

@@ -215,3 +247,4 @@ break;

mandatory: this._mandatory,
options: this._options
options: this._options,
pattern: this._pattern
};

@@ -322,2 +355,13 @@

}
/**
* The pattern, serialized values have to conform to.
* @readonly
*/
}, {
key: 'pattern',
get: function get() {
return this._pattern;
}
}], [{

@@ -333,2 +377,3 @@ key: 'fromNode',

var maxInclusive = node.hasAttribute('maxInclusive') ? parseInt(node.getAttribute('maxInclusive'), 10) : undefined;
var pattern = node.hasAttribute('pattern') ? node.getAttribute('pattern') : undefined;
var optionNodes = (0, _utils.getElements)(node, 'parameters', 'Option');

@@ -344,3 +389,3 @@ var options = void 0;

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

@@ -368,3 +413,3 @@

value: function deserialize(values) {
return new OpenSearchParameter(values.type, values.name, values.mandatory, values.options, values.minExclusive, values.maxExclusive, values.minInclusive, values.maxInclusive);
return new OpenSearchParameter(values.type, values.name, values.mandatory, values.options, values.minExclusive, values.maxExclusive, values.minInclusive, values.maxInclusive, values.pattern);
}

@@ -371,0 +416,0 @@ }]);

{
"name": "opensearch-browser",
"version": "1.0.7",
"version": "1.0.8",
"description": "An OpenSearch client supporting the geo and time extensions.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -200,3 +200,3 @@ import EventEmitter from 'event-emitter';

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

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

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

@@ -269,0 +269,0 @@ let count = firstPage.itemsPerPage;

@@ -22,10 +22,38 @@ import { getElements, isNullOrUndefined, toWKT } from './utils';

function eoValueToString(value, isDate = false) {
const convertDate = (dateValue) => {
if (dateValue instanceof Date) {
return dateValue.toISOString();
function formatDate(value, pattern = undefined) {
const rePattern = pattern ? new RegExp(pattern) : null;
if (value instanceof Date) {
const isoString = value.toISOString();
let formatted = isoString;
if (!rePattern || rePattern.test(formatted)) {
return formatted;
}
return value;
};
// Try without milliseconds
formatted = `${isoString.split('.')[0]}Z`;
if (!rePattern || rePattern.test(formatted)) {
return formatted;
}
// Try without Zulu
formatted = isoString.slice(0, -1);
if (!rePattern || rePattern.test(formatted)) {
return formatted;
}
// Try without Zulu and milliseconds
formatted = isoString.split('.')[0];
if (!rePattern || rePattern.test(formatted)) {
return formatted;
}
// as fallback return the default ISO format
return isoString;
}
return value;
}
function eoValueToString(value, isDate = false, pattern = undefined) {
const convertDate = dateValue => formatDate(dateValue, pattern);
if (typeof value === 'string') {

@@ -89,3 +117,4 @@ return value;

minExclusive = undefined, maxExclusive = undefined,
minInclusive = undefined, maxInclusive = undefined) {
minInclusive = undefined, maxInclusive = undefined,
pattern = undefined) {
this._type = type;

@@ -99,2 +128,3 @@ this._name = name;

this._maxInclusive = maxInclusive;
this._pattern = pattern;
}

@@ -167,2 +197,10 @@

/**
* The pattern, serialized values have to conform to.
* @readonly
*/
get pattern() {
return this._pattern;
}
/**
* Combines this parameter with the values of another parameter.

@@ -180,3 +218,4 @@ * @param {OpenSearchParameter} other the other parameter

isNullOrUndefined(this.minInclusive) ? other.minInclusive : this.minInclusive,
isNullOrUndefined(this.maxInclusive) ? other.maxInclusive : this.maxInclusive
isNullOrUndefined(this.maxInclusive) ? other.maxInclusive : this.maxInclusive,
isNullOrUndefined(this.pattern) ? other.pattern : this.pattern
);

@@ -197,6 +236,3 @@ }

case 'time:end':
if (value instanceof Date) {
return value.toISOString();
}
break;
return formatDate(value, this.pattern);
case 'geo:box':

@@ -223,3 +259,3 @@ if (Array.isArray(value)) {

case 'eo:incidenceAngleVariation':
return eoValueToString(value);
return eoValueToString(value, false, this.pattern);
case 'eo:availabilityTime':

@@ -229,3 +265,3 @@ case 'eo:creationDate':

case 'eo:processingDate':
return eoValueToString(value, true);
return eoValueToString(value, true, this.pattern);
default:

@@ -259,2 +295,5 @@ break;

: undefined;
const pattern = node.hasAttribute('pattern')
? node.getAttribute('pattern')
: undefined;
const optionNodes = getElements(node, 'parameters', 'Option');

@@ -269,3 +308,4 @@ let options;

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

@@ -301,2 +341,3 @@ }

options: this._options,
pattern: this._pattern,
};

@@ -327,5 +368,6 @@

values.type, values.name, values.mandatory, values.options,
values.minExclusive, values.maxExclusive, values.minInclusive, values.maxInclusive
values.minExclusive, values.maxExclusive, values.minInclusive, values.maxInclusive,
values.pattern,
);
}
}

@@ -7,2 +7,4 @@ /* eslint-disable no-unused-expressions */

const namespace = 'xmlns:parameters="http://a9.com/-/spec/opensearch/extensions/parameters/1.0/"';
describe('OpenSearchParameter', () => {

@@ -20,2 +22,26 @@ describe('combined', () => {

const paramDateWithPatternNoMS = OpenSearchParameter.fromNode(
parseXml(
`<parameters:Parameter name="start" value="{time:start}" ${namespace} pattern="^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(Z|[\+\-][0-9]{2}:([0-9]{2})?)$" />`
).documentElement
);
const paramDateWithPatternNoTZ = OpenSearchParameter.fromNode(
parseXml(
`<parameters:Parameter name="start" value="{time:start}" ${namespace} pattern="^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}$" />`
).documentElement
);
const paramDateWithPatternNoMSandTZ = OpenSearchParameter.fromNode(
parseXml(
`<parameters:Parameter name="start" value="{time:start}" ${namespace} pattern="^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$" />`
).documentElement
);
const paramDateWithUnknownPattern = OpenSearchParameter.fromNode(
parseXml(
`<parameters:Parameter name="start" value="{time:start}" ${namespace} pattern="^unknown$" />`
).documentElement
);
it('shall correctly encode Dates', () => {

@@ -82,2 +108,15 @@ expect(paramTime.serializeValue(new Date('2000-01-01T01:01:01Z'))).to.equal('2000-01-01T01:01:01.000Z');

});
it('shall correctly serialize dates when a pattern is specified', () => {
expect(paramDateWithPatternNoMS.serializeValue(new Date('2000-01-02T01:01:01Z'))).to.equal('2000-01-02T01:01:01Z');
});
it('shall correctly serialize dates when a pattern is specified', () => {
expect(paramDateWithPatternNoTZ.serializeValue(new Date('2000-01-02T01:01:01Z'))).to.equal('2000-01-02T01:01:01.000');
});
it('shall correctly serialize dates when a pattern is specified', () => {
expect(paramDateWithPatternNoMSandTZ.serializeValue(new Date('2000-01-02T01:01:01Z'))).to.equal('2000-01-02T01:01:01');
});
it('shall throw when no pattern could be decoded', () => {
expect(paramDateWithUnknownPattern.serializeValue(new Date('2000-01-02T01:01:01Z'))).to.equal('2000-01-02T01:01:01.000Z');
});
});

@@ -108,3 +147,2 @@

describe('fromNode', () => {
const namespace = 'xmlns:parameters="http://a9.com/-/spec/opensearch/extensions/parameters/1.0/"';
const paramMandatory = OpenSearchParameter.fromNode(

@@ -111,0 +149,0 @@ parseXml(`<parameters:Parameter name="q" value="{searchTerms}" ${namespace}/>`).documentElement

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