eventregistry
Advanced tools
Comparing version 8.8.0 to 8.9.0
@@ -5,2 +5,9 @@ # NodeJS SDK: Change Log | ||
## [v8.9]() (2020-11-24) | ||
**Added** | ||
- added `required` and `excluded` optional parameters to the TopicPage class to methods `addConcept`, `addKeyword`, `addCategory`, `addSource`, `addSourceLocation` and `addSourceGroup`. | ||
- exceptions are now raised by the SDK library in case of status codes 204, 400, 401, 403 and 530. The meaning of the above status codes is described on the [documentation page](https://eventregistry.org/documentation?tab=introduction). | ||
- | ||
## [v8.8.0]() (2020-10-07) | ||
@@ -7,0 +14,0 @@ |
@@ -23,2 +23,3 @@ import { AxiosResponse } from "axios"; | ||
private readonly lock; | ||
private readonly stopStatusCodes; | ||
constructor(config?: EventRegistryStatic.Config); | ||
@@ -25,0 +26,0 @@ /** |
@@ -73,2 +73,3 @@ "use strict"; | ||
if (config === void 0) { config = {}; } | ||
var _this = this; | ||
this.config = { | ||
@@ -88,2 +89,9 @@ host: "http://eventregistry.org", | ||
this._logRequests = false; | ||
this.stopStatusCodes = [ | ||
204, | ||
400, | ||
401, | ||
403, | ||
530, | ||
]; | ||
this.lock = new semaphore_async_await_1.default(1); | ||
@@ -134,3 +142,3 @@ if (!!config.apiKey && !!config.printHostInfo) { | ||
} | ||
if (err.response.status === 530 || err.response.status === 400 || err.response.status === 204) { | ||
if (_.includes(_this.stopStatusCodes, err.response.status)) { | ||
return Promise.reject(err); | ||
@@ -137,0 +145,0 @@ } |
@@ -86,6 +86,6 @@ import { QueryParamsBase } from "./base"; | ||
* Add a relevant concept to the topic page | ||
* @param conceptUri uri of the concept to be added | ||
* @param uri uri of the concept to be added | ||
* @param weight importance of the provided concept (typically in range 1 - 50) | ||
*/ | ||
addConcept(uri: string, wgt: number, label?: string, conceptType?: string): void; | ||
addConcept(uri: string, wgt: number, args?: EventRegistryStatic.TopicPageAddConceptArguments): void; | ||
/** | ||
@@ -96,21 +96,21 @@ * Add a relevant keyword to the topic page | ||
*/ | ||
addKeyword(keyword: string, weight: number): void; | ||
addKeyword(keyword: string, wgt: number, args?: EventRegistryStatic.TopicPageAddKeywordArguments): void; | ||
/** | ||
* Add a relevant category to the topic page | ||
* @param categoryUri uri of the category to be added | ||
* @param uri uri of the category to be added | ||
* @param weight importance of the provided category (typically in range 1 - 50) | ||
*/ | ||
addCategory(categoryUri: string, weight: number): void; | ||
addCategory(uri: string, wgt: number, args?: EventRegistryStatic.TopicPageAddCategoryArguments): void; | ||
/** | ||
* Add a news source to the topic page | ||
* @param sourceUri uri of the news source to add to the topic page | ||
* @param uri uri of the news source to add to the topic page | ||
* @param weight importance of the news source (typically in range 1 - 50) | ||
*/ | ||
addSource(sourceUri: string, weight: number): void; | ||
addSource(uri: string, wgt: number, args?: EventRegistryStatic.TopicPageAddSourceArguments): void; | ||
/** | ||
* Add a list of relevant sources by identifying them by their geographic location | ||
* @param sourceLocationUri uri of the location where the sources should be geographically located | ||
* @param uri uri of the location where the sources should be geographically located | ||
* @param weight importance of the provided list of sources (typically in range 1 - 50) | ||
*/ | ||
addSourceLocation(sourceLocationUri: string, weight: number): void; | ||
addSourceLocation(uri: string, wgt: number, args?: EventRegistryStatic.TopicPageAddSourceLocationArguments): void; | ||
/** | ||
@@ -121,3 +121,3 @@ * Add a list of relevant sources by specifying a whole source group to the topic page | ||
*/ | ||
addSourceGroup(sourceGroupUri: string, weight: number): void; | ||
addSourceGroup(uri: string, wgt: number, args?: EventRegistryStatic.TopicPageAddSourceGroupArguments): void; | ||
/** | ||
@@ -124,0 +124,0 @@ * Add relevant location to the topic page |
@@ -356,10 +356,15 @@ "use strict"; | ||
* Add a relevant concept to the topic page | ||
* @param conceptUri uri of the concept to be added | ||
* @param uri uri of the concept to be added | ||
* @param weight importance of the provided concept (typically in range 1 - 50) | ||
*/ | ||
TopicPage.prototype.addConcept = function (uri, wgt, label, conceptType) { | ||
TopicPage.prototype.addConcept = function (uri, wgt, args) { | ||
if (args === void 0) { args = {}; } | ||
if (!_.isNumber(wgt)) { | ||
throw new Error("Weight value has to be a positive or negative number"); | ||
} | ||
var concept = { uri: uri, wgt: wgt }; | ||
var label = args.label, conceptType = args.conceptType, _a = args.required, required = _a === void 0 ? false : _a, _b = args.excluded, excluded = _b === void 0 ? false : _b; | ||
if (required && excluded) { | ||
throw new Error("Parameters required and excluded can not be true at the same time"); | ||
} | ||
var concept = { uri: uri, wgt: wgt, required: required, excluded: excluded }; | ||
if (!_.isUndefined(label)) { | ||
@@ -378,40 +383,48 @@ _.set(concept, "label", label); | ||
*/ | ||
TopicPage.prototype.addKeyword = function (keyword, weight) { | ||
if (!_.isNumber(weight)) { | ||
TopicPage.prototype.addKeyword = function (keyword, wgt, args) { | ||
if (args === void 0) { args = {}; } | ||
if (!_.isNumber(wgt)) { | ||
throw new Error("Weight value has to be a positive or negative number"); | ||
} | ||
this.topicPage.keywords = __spread(this.topicPage.keywords, [{ keyword: keyword, wgt: weight }]); | ||
var _a = args.required, required = _a === void 0 ? false : _a, _b = args.excluded, excluded = _b === void 0 ? false : _b; | ||
this.topicPage.keywords = __spread(this.topicPage.keywords, [{ keyword: keyword, wgt: wgt, required: required, excluded: excluded }]); | ||
}; | ||
/** | ||
* Add a relevant category to the topic page | ||
* @param categoryUri uri of the category to be added | ||
* @param uri uri of the category to be added | ||
* @param weight importance of the provided category (typically in range 1 - 50) | ||
*/ | ||
TopicPage.prototype.addCategory = function (categoryUri, weight) { | ||
if (!_.isNumber(weight)) { | ||
TopicPage.prototype.addCategory = function (uri, wgt, args) { | ||
if (args === void 0) { args = {}; } | ||
if (!_.isNumber(wgt)) { | ||
throw new Error("Weight value has to be a positive or negative number"); | ||
} | ||
this.topicPage.categories = __spread(this.topicPage.categories, [{ uri: categoryUri, wgt: weight }]); | ||
var _a = args.required, required = _a === void 0 ? false : _a, _b = args.excluded, excluded = _b === void 0 ? false : _b; | ||
this.topicPage.categories = __spread(this.topicPage.categories, [{ uri: uri, wgt: wgt, required: required, excluded: excluded }]); | ||
}; | ||
/** | ||
* Add a news source to the topic page | ||
* @param sourceUri uri of the news source to add to the topic page | ||
* @param uri uri of the news source to add to the topic page | ||
* @param weight importance of the news source (typically in range 1 - 50) | ||
*/ | ||
TopicPage.prototype.addSource = function (sourceUri, weight) { | ||
if (!_.isNumber(weight)) { | ||
TopicPage.prototype.addSource = function (uri, wgt, args) { | ||
if (args === void 0) { args = {}; } | ||
if (!_.isNumber(wgt)) { | ||
throw new Error("Weight value has to be a positive or negative number"); | ||
} | ||
this.topicPage.sources = __spread(this.topicPage.sources, [{ uri: sourceUri, wgt: weight }]); | ||
var _a = args.excluded, excluded = _a === void 0 ? false : _a; | ||
this.topicPage.sources = __spread(this.topicPage.sources, [{ uri: uri, wgt: wgt, excluded: excluded }]); | ||
}; | ||
/** | ||
* Add a list of relevant sources by identifying them by their geographic location | ||
* @param sourceLocationUri uri of the location where the sources should be geographically located | ||
* @param uri uri of the location where the sources should be geographically located | ||
* @param weight importance of the provided list of sources (typically in range 1 - 50) | ||
*/ | ||
TopicPage.prototype.addSourceLocation = function (sourceLocationUri, weight) { | ||
if (!_.isNumber(weight)) { | ||
TopicPage.prototype.addSourceLocation = function (uri, wgt, args) { | ||
if (args === void 0) { args = {}; } | ||
if (!_.isNumber(wgt)) { | ||
throw new Error("Weight value has to be a positive or negative number"); | ||
} | ||
this.topicPage.sourceLocations = __spread(this.topicPage.sourceLocations, [{ uri: sourceLocationUri, wgt: weight }]); | ||
var _a = args.excluded, excluded = _a === void 0 ? false : _a; | ||
this.topicPage.sourceLocations = __spread(this.topicPage.sourceLocations, [{ uri: uri, wgt: wgt, excluded: excluded }]); | ||
}; | ||
@@ -423,7 +436,9 @@ /** | ||
*/ | ||
TopicPage.prototype.addSourceGroup = function (sourceGroupUri, weight) { | ||
if (!_.isNumber(weight)) { | ||
TopicPage.prototype.addSourceGroup = function (uri, wgt, args) { | ||
if (args === void 0) { args = {}; } | ||
if (!_.isNumber(wgt)) { | ||
throw new Error("Weight value has to be a positive or negative number"); | ||
} | ||
this.topicPage.sourceGroups = __spread(this.topicPage.sourceGroups, [{ uri: sourceGroupUri, wgt: weight }]); | ||
var _a = args.excluded, excluded = _a === void 0 ? false : _a; | ||
this.topicPage.sourceGroups = __spread(this.topicPage.sourceGroups, [{ uri: uri, wgt: wgt, excluded: excluded }]); | ||
}; | ||
@@ -430,0 +445,0 @@ /** |
@@ -5,3 +5,3 @@ { | ||
"description": "Package containing wrapper functions for Event Registry API", | ||
"version": "8.8.0", | ||
"version": "8.9.0", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "main": "./dist/index.js", |
@@ -37,3 +37,9 @@ import axios, { AxiosResponse, AxiosRequestConfig } from "axios"; | ||
private readonly lock: Semaphore; | ||
private readonly stopStatusCodes = [ | ||
204, | ||
400, | ||
401, | ||
403, | ||
530, | ||
]; | ||
constructor(config: EventRegistryStatic.Config = {}) { | ||
@@ -87,3 +93,3 @@ this.lock = new Semaphore(1); | ||
} | ||
if (err.response.status === 530 || err.response.status === 400 || err.response.status === 204) { | ||
if (_.includes(this.stopStatusCodes, err.response.status)) { | ||
return Promise.reject(err); | ||
@@ -90,0 +96,0 @@ } |
@@ -252,10 +252,19 @@ import * as fs from "fs"; | ||
* Add a relevant concept to the topic page | ||
* @param conceptUri uri of the concept to be added | ||
* @param uri uri of the concept to be added | ||
* @param weight importance of the provided concept (typically in range 1 - 50) | ||
*/ | ||
public addConcept(uri: string, wgt: number, label?: string, conceptType?: string) { | ||
public addConcept(uri: string, wgt: number, args: EventRegistryStatic.TopicPageAddConceptArguments = {}) { | ||
if (!_.isNumber(wgt)) { | ||
throw new Error("Weight value has to be a positive or negative number"); | ||
} | ||
const concept = { uri, wgt }; | ||
const { | ||
label, | ||
conceptType, | ||
required = false, | ||
excluded = false, | ||
} = args; | ||
if (required && excluded) { | ||
throw new Error("Parameters required and excluded can not be true at the same time"); | ||
} | ||
const concept = { uri, wgt, required, excluded }; | ||
if (!_.isUndefined(label)) { | ||
@@ -275,7 +284,11 @@ _.set(concept, "label", label); | ||
*/ | ||
public addKeyword(keyword: string, weight: number) { | ||
if (!_.isNumber(weight)) { | ||
public addKeyword(keyword: string, wgt: number, args: EventRegistryStatic.TopicPageAddKeywordArguments = {}) { | ||
if (!_.isNumber(wgt)) { | ||
throw new Error("Weight value has to be a positive or negative number"); | ||
} | ||
this.topicPage.keywords = [...this.topicPage.keywords, {keyword: keyword, wgt: weight}]; | ||
const { | ||
required = false, | ||
excluded = false, | ||
} = args; | ||
this.topicPage.keywords = [...this.topicPage.keywords, {keyword, wgt, required, excluded}]; | ||
} | ||
@@ -285,10 +298,14 @@ | ||
* Add a relevant category to the topic page | ||
* @param categoryUri uri of the category to be added | ||
* @param uri uri of the category to be added | ||
* @param weight importance of the provided category (typically in range 1 - 50) | ||
*/ | ||
public addCategory(categoryUri: string, weight: number) { | ||
if (!_.isNumber(weight)) { | ||
public addCategory(uri: string, wgt: number, args: EventRegistryStatic.TopicPageAddCategoryArguments = {}) { | ||
if (!_.isNumber(wgt)) { | ||
throw new Error("Weight value has to be a positive or negative number"); | ||
} | ||
this.topicPage.categories = [...this.topicPage.categories, {uri: categoryUri, wgt: weight}]; | ||
const { | ||
required = false, | ||
excluded = false, | ||
} = args; | ||
this.topicPage.categories = [...this.topicPage.categories, {uri, wgt, required, excluded}]; | ||
} | ||
@@ -298,10 +315,13 @@ | ||
* Add a news source to the topic page | ||
* @param sourceUri uri of the news source to add to the topic page | ||
* @param uri uri of the news source to add to the topic page | ||
* @param weight importance of the news source (typically in range 1 - 50) | ||
*/ | ||
public addSource(sourceUri: string, weight: number) { | ||
if (!_.isNumber(weight)) { | ||
public addSource(uri: string, wgt: number, args: EventRegistryStatic.TopicPageAddSourceArguments = {}) { | ||
if (!_.isNumber(wgt)) { | ||
throw new Error("Weight value has to be a positive or negative number"); | ||
} | ||
this.topicPage.sources = [...this.topicPage.sources, {uri: sourceUri, wgt: weight}]; | ||
const { | ||
excluded = false, | ||
} = args; | ||
this.topicPage.sources = [...this.topicPage.sources, {uri, wgt, excluded}]; | ||
} | ||
@@ -311,10 +331,13 @@ | ||
* Add a list of relevant sources by identifying them by their geographic location | ||
* @param sourceLocationUri uri of the location where the sources should be geographically located | ||
* @param uri uri of the location where the sources should be geographically located | ||
* @param weight importance of the provided list of sources (typically in range 1 - 50) | ||
*/ | ||
public addSourceLocation(sourceLocationUri: string, weight: number) { | ||
if (!_.isNumber(weight)) { | ||
public addSourceLocation(uri: string, wgt: number, args: EventRegistryStatic.TopicPageAddSourceLocationArguments = {}) { | ||
if (!_.isNumber(wgt)) { | ||
throw new Error("Weight value has to be a positive or negative number"); | ||
} | ||
this.topicPage.sourceLocations = [...this.topicPage.sourceLocations, {uri: sourceLocationUri, wgt: weight}]; | ||
const { | ||
excluded = false, | ||
} = args; | ||
this.topicPage.sourceLocations = [...this.topicPage.sourceLocations, {uri, wgt, excluded}]; | ||
} | ||
@@ -327,7 +350,10 @@ | ||
*/ | ||
public addSourceGroup(sourceGroupUri: string, weight: number) { | ||
if (!_.isNumber(weight)) { | ||
public addSourceGroup(uri: string, wgt: number, args: EventRegistryStatic.TopicPageAddSourceGroupArguments = {}) { | ||
if (!_.isNumber(wgt)) { | ||
throw new Error("Weight value has to be a positive or negative number"); | ||
} | ||
this.topicPage.sourceGroups = [...this.topicPage.sourceGroups, {uri: sourceGroupUri, wgt: weight}]; | ||
const { | ||
excluded = false, | ||
} = args; | ||
this.topicPage.sourceGroups = [...this.topicPage.sourceGroups, {uri, wgt, excluded}]; | ||
} | ||
@@ -334,0 +360,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1028312
111
18362