eventregistry 8.11.2 → 9.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/analytics.d.ts +82 -82
  2. package/dist/analytics.js +336 -330
  3. package/dist/analytics.js.map +1 -1
  4. package/dist/base.d.ts +82 -81
  5. package/dist/base.js +261 -219
  6. package/dist/base.js.map +1 -1
  7. package/dist/counts.d.ts +81 -81
  8. package/dist/counts.js +162 -149
  9. package/dist/counts.js.map +1 -1
  10. package/dist/dailyShares.d.ts +10 -10
  11. package/dist/dailyShares.js +90 -77
  12. package/dist/dailyShares.js.map +1 -1
  13. package/dist/data.d.ts +269 -268
  14. package/dist/data.js +3 -3
  15. package/dist/eventForText.d.ts +48 -48
  16. package/dist/eventForText.js +126 -123
  17. package/dist/eventForText.js.map +1 -1
  18. package/dist/eventRegistry.d.ts +244 -224
  19. package/dist/eventRegistry.js +1098 -1018
  20. package/dist/eventRegistry.js.map +1 -1
  21. package/dist/index.d.ts +21 -20
  22. package/dist/index.js +128 -122
  23. package/dist/index.js.map +1 -1
  24. package/dist/info.d.ts +61 -61
  25. package/dist/info.js +171 -158
  26. package/dist/info.js.map +1 -1
  27. package/dist/logger.d.ts +45 -0
  28. package/dist/logger.js +156 -0
  29. package/dist/logger.js.map +1 -0
  30. package/dist/query.d.ts +53 -53
  31. package/dist/query.js +333 -290
  32. package/dist/query.js.map +1 -1
  33. package/dist/queryArticle.d.ts +61 -61
  34. package/dist/queryArticle.js +183 -168
  35. package/dist/queryArticle.js.map +1 -1
  36. package/dist/queryArticles.d.ts +144 -160
  37. package/dist/queryArticles.js +729 -701
  38. package/dist/queryArticles.js.map +1 -1
  39. package/dist/queryEvent.d.ts +140 -140
  40. package/dist/queryEvent.js +587 -569
  41. package/dist/queryEvent.js.map +1 -1
  42. package/dist/queryEvents.d.ts +210 -210
  43. package/dist/queryEvents.js +825 -798
  44. package/dist/queryEvents.js.map +1 -1
  45. package/dist/queryMentions.d.ts +96 -96
  46. package/dist/queryMentions.js +637 -600
  47. package/dist/queryMentions.js.map +1 -1
  48. package/dist/queryStory.d.ts +58 -58
  49. package/dist/queryStory.js +194 -174
  50. package/dist/queryStory.js.map +1 -1
  51. package/dist/recent.d.ts +23 -23
  52. package/dist/recent.js +199 -179
  53. package/dist/recent.js.map +1 -1
  54. package/dist/returnInfo.d.ts +68 -66
  55. package/dist/returnInfo.js +332 -304
  56. package/dist/returnInfo.js.map +1 -1
  57. package/dist/topicPage.d.ts +157 -157
  58. package/dist/topicPage.js +599 -604
  59. package/dist/topicPage.js.map +1 -1
  60. package/dist/trends.d.ts +35 -35
  61. package/dist/trends.js +115 -102
  62. package/dist/trends.js.map +1 -1
  63. package/dist/types.d.ts +2453 -2155
  64. package/dist/types.js +2 -2
  65. package/package.json +13 -13
@@ -1,305 +1,333 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- }
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- var __rest = (this && this.__rest) || function (s, e) {
16
- var t = {};
17
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
18
- t[p] = s[p];
19
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
20
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
21
- t[p[i]] = s[p[i]];
22
- return t;
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- var _ = require("lodash");
26
- var fs = require("fs");
27
- var ReturnInfoFlagsBase = /** @class */ (function () {
28
- function ReturnInfoFlagsBase() {
29
- this.data = {};
30
- }
31
- ReturnInfoFlagsBase.prototype.setFlag = function (key, value, defaultValue) {
32
- this.setProperty("Include" + this.type + _.upperFirst(key), value, defaultValue);
33
- };
34
- ReturnInfoFlagsBase.prototype.setValue = function (key, value, defaultValue, skipKeyMod) {
35
- if (skipKeyMod === void 0) { skipKeyMod = false; }
36
- var constructedKey = skipKeyMod ? _.upperFirst(key) : this.type + _.upperFirst(key);
37
- this.setProperty(constructedKey, value, defaultValue);
38
- };
39
- ReturnInfoFlagsBase.prototype.getProperties = function (prefix) {
40
- if (prefix === void 0) { prefix = ""; }
41
- return _.mapKeys(this.data, function (value, key) {
42
- if (_.startsWith(_.toLower(key), _.toLower(prefix))) {
43
- return _.camelCase(key);
44
- }
45
- else {
46
- return _.camelCase(prefix + key);
47
- }
48
- });
49
- };
50
- ReturnInfoFlagsBase.prototype.addProperties = function (properties) {
51
- if (properties instanceof Object) {
52
- for (var name_1 in properties) {
53
- if (properties.hasOwnProperty(name_1)) {
54
- var value = properties[name_1];
55
- if (typeof value === "boolean") {
56
- this.setFlag(name_1, value, !value);
57
- }
58
- else {
59
- this.setValue(name_1, value);
60
- }
61
- }
62
- }
63
- }
64
- };
65
- ReturnInfoFlagsBase.prototype.setProperty = function (key, value, defaultValue) {
66
- if (value !== defaultValue) {
67
- _.set(this.data, key, value);
68
- }
69
- };
70
- return ReturnInfoFlagsBase;
71
- }());
72
- exports.ReturnInfoFlagsBase = ReturnInfoFlagsBase;
73
- var ReturnInfo = /** @class */ (function () {
74
- // Accepts all InfoFlags
75
- function ReturnInfo(_a) {
76
- if (_a === void 0) { _a = {}; }
77
- var _b = _a.articleInfo, articleInfo = _b === void 0 ? new ArticleInfoFlags() : _b, _c = _a.eventInfo, eventInfo = _c === void 0 ? new EventInfoFlags() : _c, _d = _a.sourceInfo, sourceInfo = _d === void 0 ? new SourceInfoFlags() : _d, _e = _a.categoryInfo, categoryInfo = _e === void 0 ? new CategoryInfoFlags() : _e, _f = _a.conceptInfo, conceptInfo = _f === void 0 ? new ConceptInfoFlags() : _f, _g = _a.locationInfo, locationInfo = _g === void 0 ? new LocationInfoFlags() : _g, _h = _a.storyInfo, storyInfo = _h === void 0 ? new StoryInfoFlags() : _h, _j = _a.conceptClassInfo, conceptClassInfo = _j === void 0 ? new ConceptClassInfoFlags() : _j, _k = _a.conceptFolderInfo, conceptFolderInfo = _k === void 0 ? new ConceptFolderInfoFlags() : _k, unsupported = __rest(_a, ["articleInfo", "eventInfo", "sourceInfo", "categoryInfo", "conceptInfo", "locationInfo", "storyInfo", "conceptClassInfo", "conceptFolderInfo"]);
78
- if (!_.isEmpty(unsupported)) {
79
- console.warn("ReturnInfo: Unsupported parameters detected: " + JSON.stringify(unsupported) + ". Please check the documentation.");
80
- }
81
- this.articleInfo = articleInfo;
82
- this.eventInfo = eventInfo;
83
- this.sourceInfo = sourceInfo;
84
- this.categoryInfo = categoryInfo;
85
- this.conceptInfo = conceptInfo;
86
- this.locationInfo = locationInfo;
87
- this.storyInfo = storyInfo;
88
- this.conceptClassInfo = conceptClassInfo;
89
- this.conceptFolderInfo = conceptFolderInfo;
90
- }
91
- ReturnInfo.prototype.getParams = function (prefix) {
92
- return _.extend({}, this.articleInfo.getProperties(prefix), this.eventInfo.getProperties(prefix), this.sourceInfo.getProperties(prefix), this.categoryInfo.getProperties(prefix), this.conceptInfo.getProperties(prefix), this.locationInfo.getProperties(prefix), this.storyInfo.getProperties(prefix), this.conceptClassInfo.getProperties(prefix), this.conceptFolderInfo.getProperties(prefix));
93
- };
94
- /**
95
- * load the configuration for the ReturnInfo from a filename
96
- * @param filename filename that contains the json configuration to use in the ReturnInfo
97
- */
98
- ReturnInfo.loadFromFile = function (filename) {
99
- if (!(fs && fs.existsSync(filename))) {
100
- throw new Error("File " + filename + " does not exist");
101
- }
102
- var conf = JSON.parse(fs.readFileSync(filename, "utf8"));
103
- return new ReturnInfo({
104
- articleInfo: new ArticleInfoFlags(_.get(conf, "articleInfo", {})),
105
- eventInfo: new EventInfoFlags(_.get(conf, "eventInfo", {})),
106
- sourceInfo: new SourceInfoFlags(_.get(conf, "sourceInfo", {})),
107
- categoryInfo: new CategoryInfoFlags(_.get(conf, "categoryInfo", {})),
108
- conceptInfo: new ConceptInfoFlags(_.get(conf, "conceptInfo", {})),
109
- locationInfo: new LocationInfoFlags(_.get(conf, "locationInfo", {})),
110
- storyInfo: new StoryInfoFlags(_.get(conf, "storyInfo", {})),
111
- conceptClassInfo: new ConceptClassInfoFlags(_.get(conf, "conceptClassInfo", {})),
112
- conceptFolderInfo: new ConceptFolderInfoFlags(_.get(conf, "conceptFolderInfo", {})),
113
- });
114
- };
115
- return ReturnInfo;
116
- }());
117
- exports.ReturnInfo = ReturnInfo;
118
- var ArticleInfoFlags = /** @class */ (function (_super) {
119
- __extends(ArticleInfoFlags, _super);
120
- function ArticleInfoFlags(params) {
121
- if (params === void 0) { params = {}; }
122
- var _this = _super.call(this) || this;
123
- _this.type = "Article";
124
- var _a = params.bodyLen, bodyLen = _a === void 0 ? -1 : _a, _b = params.basicInfo, basicInfo = _b === void 0 ? true : _b, _c = params.title, title = _c === void 0 ? true : _c, _d = params.body, body = _d === void 0 ? true : _d, _e = params.url, url = _e === void 0 ? true : _e, _f = params.eventUri, eventUri = _f === void 0 ? true : _f, _g = params.authors, authors = _g === void 0 ? true : _g, _h = params.concepts, concepts = _h === void 0 ? false : _h, _j = params.categories, categories = _j === void 0 ? false : _j, _k = params.links, links = _k === void 0 ? false : _k, _l = params.videos, videos = _l === void 0 ? false : _l, _m = params.image, image = _m === void 0 ? true : _m, _o = params.socialScore, socialScore = _o === void 0 ? false : _o, _p = params.sentiment, sentiment = _p === void 0 ? true : _p, _q = params.location, location = _q === void 0 ? false : _q, _r = params.extractedDates, extractedDates = _r === void 0 ? false : _r, _s = params.originalArticle, originalArticle = _s === void 0 ? false : _s, _t = params.storyUri, storyUri = _t === void 0 ? false : _t, properties = __rest(params, ["bodyLen", "basicInfo", "title", "body", "url", "eventUri", "authors", "concepts", "categories", "links", "videos", "image", "socialScore", "sentiment", "location", "extractedDates", "originalArticle", "storyUri"]);
125
- _this.setValue("bodyLen", bodyLen);
126
- _this.setFlag("basicInfo", basicInfo);
127
- _this.setFlag("title", title);
128
- _this.setFlag("body", body);
129
- _this.setFlag("url", url);
130
- _this.setFlag("eventUri", eventUri);
131
- _this.setFlag("authors", authors);
132
- _this.setFlag("concepts", concepts);
133
- _this.setFlag("categories", categories);
134
- _this.setFlag("links", links);
135
- _this.setFlag("videos", videos);
136
- _this.setFlag("image", image);
137
- _this.setFlag("socialScore", socialScore);
138
- _this.setFlag("sentiment", sentiment);
139
- _this.setFlag("location", location);
140
- _this.setFlag("extractedDates", extractedDates);
141
- _this.setFlag("originalArticle", originalArticle);
142
- _this.setFlag("storyUri", storyUri);
143
- _this.addProperties(properties);
144
- return _this;
145
- }
146
- return ArticleInfoFlags;
147
- }(ReturnInfoFlagsBase));
148
- exports.ArticleInfoFlags = ArticleInfoFlags;
149
- var StoryInfoFlags = /** @class */ (function (_super) {
150
- __extends(StoryInfoFlags, _super);
151
- function StoryInfoFlags(params) {
152
- if (params === void 0) { params = {}; }
153
- var _this = _super.call(this) || this;
154
- _this.type = "Story";
155
- var _a = params.basicStats, basicStats = _a === void 0 ? true : _a, _b = params.location, location = _b === void 0 ? true : _b, _c = params.date, date = _c === void 0 ? false : _c, _d = params.title, title = _d === void 0 ? false : _d, _e = params.summary, summary = _e === void 0 ? false : _e, _f = params.concepts, concepts = _f === void 0 ? false : _f, _g = params.categories, categories = _g === void 0 ? false : _g, _h = params.medoidArticle, medoidArticle = _h === void 0 ? false : _h, _j = params.infoArticle, infoArticle = _j === void 0 ? false : _j, _k = params.commonDates, commonDates = _k === void 0 ? false : _k, _l = params.socialScore, socialScore = _l === void 0 ? false : _l, _m = params.imageCount, imageCount = _m === void 0 ? 0 : _m, properties = __rest(params, ["basicStats", "location", "date", "title", "summary", "concepts", "categories", "medoidArticle", "infoArticle", "commonDates", "socialScore", "imageCount"]);
156
- _this.setFlag("basicStats", basicStats);
157
- _this.setFlag("location", location);
158
- _this.setFlag("date", date);
159
- _this.setFlag("title", title);
160
- _this.setFlag("summary", summary);
161
- _this.setFlag("concepts", concepts);
162
- _this.setFlag("categories", categories);
163
- _this.setFlag("medoidArticle", medoidArticle);
164
- _this.setFlag("infoArticle", infoArticle);
165
- _this.setFlag("commonDates", commonDates);
166
- _this.setFlag("socialScore", socialScore);
167
- _this.setValue("imageCount", imageCount);
168
- _this.addProperties(properties);
169
- return _this;
170
- }
171
- return StoryInfoFlags;
172
- }(ReturnInfoFlagsBase));
173
- exports.StoryInfoFlags = StoryInfoFlags;
174
- var EventInfoFlags = /** @class */ (function (_super) {
175
- __extends(EventInfoFlags, _super);
176
- function EventInfoFlags(params) {
177
- if (params === void 0) { params = {}; }
178
- var _this = _super.call(this) || this;
179
- _this.type = "Event";
180
- var _a = params.title, title = _a === void 0 ? true : _a, _b = params.summary, summary = _b === void 0 ? true : _b, _c = params.articleCounts, articleCounts = _c === void 0 ? true : _c, _d = params.concepts, concepts = _d === void 0 ? true : _d, _e = params.categories, categories = _e === void 0 ? true : _e, _f = params.date, date = _f === void 0 ? true : _f, _g = params.commonDates, commonDates = _g === void 0 ? false : _g, _h = params.infoArticle, infoArticle = _h === void 0 ? false : _h, _j = params.stories, stories = _j === void 0 ? false : _j, _k = params.socialScore, socialScore = _k === void 0 ? false : _k, _l = params.imageCount, imageCount = _l === void 0 ? 0 : _l, properties = __rest(params, ["title", "summary", "articleCounts", "concepts", "categories", "date", "commonDates", "infoArticle", "stories", "socialScore", "imageCount"]);
181
- _this.setFlag("title", title);
182
- _this.setFlag("summary", summary);
183
- _this.setFlag("articleCounts", articleCounts);
184
- _this.setFlag("concepts", concepts);
185
- _this.setFlag("categories", categories);
186
- _this.setFlag("date", date);
187
- _this.setFlag("commonDates", commonDates);
188
- _this.setFlag("infoArticle", infoArticle);
189
- _this.setFlag("stories", stories);
190
- _this.setFlag("socialScore", socialScore);
191
- _this.setValue("imageCount", imageCount);
192
- _this.addProperties(properties);
193
- return _this;
194
- }
195
- return EventInfoFlags;
196
- }(ReturnInfoFlagsBase));
197
- exports.EventInfoFlags = EventInfoFlags;
198
- var SourceInfoFlags = /** @class */ (function (_super) {
199
- __extends(SourceInfoFlags, _super);
200
- function SourceInfoFlags(params) {
201
- if (params === void 0) { params = {}; }
202
- var _this = _super.call(this) || this;
203
- var _a = params.title, title = _a === void 0 ? true : _a, _b = params.description, description = _b === void 0 ? false : _b, _c = params.location, location = _c === void 0 ? false : _c, _d = params.ranking, ranking = _d === void 0 ? false : _d, _e = params.image, image = _e === void 0 ? false : _e, _f = params.socialMedia, socialMedia = _f === void 0 ? false : _f, properties = __rest(params, ["title", "description", "location", "ranking", "image", "socialMedia"]);
204
- _this.type = "Source";
205
- _this.setFlag("title", title);
206
- _this.setFlag("description", description);
207
- _this.setFlag("location", location);
208
- _this.setFlag("ranking", ranking);
209
- _this.setFlag("image", image);
210
- _this.setFlag("socialMedia", socialMedia);
211
- _this.addProperties(properties);
212
- return _this;
213
- }
214
- return SourceInfoFlags;
215
- }(ReturnInfoFlagsBase));
216
- exports.SourceInfoFlags = SourceInfoFlags;
217
- var CategoryInfoFlags = /** @class */ (function (_super) {
218
- __extends(CategoryInfoFlags, _super);
219
- function CategoryInfoFlags(params) {
220
- if (params === void 0) { params = {}; }
221
- var _this = _super.call(this) || this;
222
- _this.type = "Category";
223
- var _a = params.trendingScore, trendingScore = _a === void 0 ? true : _a, properties = __rest(params, ["trendingScore"]);
224
- _this.setFlag("trendingScore", trendingScore);
225
- _this.addProperties(properties);
226
- return _this;
227
- }
228
- return CategoryInfoFlags;
229
- }(ReturnInfoFlagsBase));
230
- exports.CategoryInfoFlags = CategoryInfoFlags;
231
- var ConceptInfoFlags = /** @class */ (function (_super) {
232
- __extends(ConceptInfoFlags, _super);
233
- function ConceptInfoFlags(params) {
234
- if (params === void 0) { params = {}; }
235
- var _this = _super.call(this) || this;
236
- _this.type = "Concept";
237
- var _a = params.type, type = _a === void 0 ? "concepts" : _a, _b = params.lang, lang = _b === void 0 ? "eng" : _b, _c = params.label, label = _c === void 0 ? true : _c, _d = params.synonyms, synonyms = _d === void 0 ? false : _d, _e = params.image, image = _e === void 0 ? false : _e, _f = params.description, description = _f === void 0 ? false : _f, _g = params.trendingScore, trendingScore = _g === void 0 ? false : _g, _h = params.maxConceptsPerType, maxConceptsPerType = _h === void 0 ? 20 : _h, properties = __rest(params, ["type", "lang", "label", "synonyms", "image", "description", "trendingScore", "maxConceptsPerType"]);
238
- _this.setValue("type", type);
239
- _this.setValue("lang", lang);
240
- _this.setFlag("label", label);
241
- _this.setFlag("synonyms", synonyms);
242
- _this.setFlag("image", image);
243
- _this.setFlag("description", description);
244
- _this.setFlag("trendingScore", trendingScore);
245
- _this.setValue("maxConceptsPerType", maxConceptsPerType, 20, true);
246
- _this.addProperties(properties);
247
- return _this;
248
- }
249
- return ConceptInfoFlags;
250
- }(ReturnInfoFlagsBase));
251
- exports.ConceptInfoFlags = ConceptInfoFlags;
252
- var LocationInfoFlags = /** @class */ (function (_super) {
253
- __extends(LocationInfoFlags, _super);
254
- function LocationInfoFlags(params) {
255
- if (params === void 0) { params = {}; }
256
- var _this = _super.call(this) || this;
257
- _this.type = "Location";
258
- var _a = params.label, label = _a === void 0 ? true : _a, _b = params.wikiUri, wikiUri = _b === void 0 ? false : _b, _c = params.geoNamesId, geoNamesId = _c === void 0 ? false : _c, _d = params.population, population = _d === void 0 ? false : _d, _e = params.geoLocation, geoLocation = _e === void 0 ? false : _e, _f = params.countryArea, countryArea = _f === void 0 ? false : _f, _g = params.countryDetails, countryDetails = _g === void 0 ? false : _g, _h = params.countryContinent, countryContinent = _h === void 0 ? false : _h, _j = params.placeFeatureCode, placeFeatureCode = _j === void 0 ? false : _j, _k = params.placeCountry, placeCountry = _k === void 0 ? true : _k, properties = __rest(params, ["label", "wikiUri", "geoNamesId", "population", "geoLocation", "countryArea", "countryDetails", "countryContinent", "placeFeatureCode", "placeCountry"]);
259
- _this.setFlag("label", label);
260
- _this.setFlag("wikiUri", wikiUri);
261
- _this.setFlag("geoNamesId", geoNamesId);
262
- _this.setFlag("population", population);
263
- _this.setFlag("geoLocation", geoLocation);
264
- _this.setFlag("countryArea", countryArea);
265
- _this.setFlag("countryDetails", countryDetails);
266
- _this.setFlag("countryContinent", countryContinent);
267
- _this.setFlag("placeFeatureCode", placeFeatureCode);
268
- _this.setFlag("placeCountry", placeCountry);
269
- _this.addProperties(properties);
270
- return _this;
271
- }
272
- return LocationInfoFlags;
273
- }(ReturnInfoFlagsBase));
274
- exports.LocationInfoFlags = LocationInfoFlags;
275
- var ConceptClassInfoFlags = /** @class */ (function (_super) {
276
- __extends(ConceptClassInfoFlags, _super);
277
- function ConceptClassInfoFlags(params) {
278
- if (params === void 0) { params = {}; }
279
- var _this = _super.call(this) || this;
280
- _this.type = "ConceptClass";
281
- var _a = params.parentLabels, parentLabels = _a === void 0 ? true : _a, _b = params.concepts, concepts = _b === void 0 ? false : _b, properties = __rest(params, ["parentLabels", "concepts"]);
282
- _this.setFlag("parentLabels", parentLabels);
283
- _this.setFlag("concepts", concepts);
284
- _this.addProperties(properties);
285
- return _this;
286
- }
287
- return ConceptClassInfoFlags;
288
- }(ReturnInfoFlagsBase));
289
- exports.ConceptClassInfoFlags = ConceptClassInfoFlags;
290
- var ConceptFolderInfoFlags = /** @class */ (function (_super) {
291
- __extends(ConceptFolderInfoFlags, _super);
292
- function ConceptFolderInfoFlags(params) {
293
- if (params === void 0) { params = {}; }
294
- var _this = _super.call(this) || this;
295
- _this.type = "ConceptFolder";
296
- var _a = params.definition, definition = _a === void 0 ? true : _a, _b = params.owner, owner = _b === void 0 ? false : _b, properties = __rest(params, ["definition", "owner"]);
297
- _this.setFlag("owner", definition);
298
- _this.setFlag("owner", owner);
299
- _this.addProperties(properties);
300
- return _this;
301
- }
302
- return ConceptFolderInfoFlags;
303
- }(ReturnInfoFlagsBase));
304
- exports.ConceptFolderInfoFlags = ConceptFolderInfoFlags;
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ var __rest = (this && this.__rest) || function (s, e) {
29
+ var t = {};
30
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
31
+ t[p] = s[p];
32
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
33
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
34
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
35
+ t[p[i]] = s[p[i]];
36
+ }
37
+ return t;
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.ConceptFolderInfoFlags = exports.ConceptClassInfoFlags = exports.LocationInfoFlags = exports.ConceptInfoFlags = exports.CategoryInfoFlags = exports.SourceInfoFlags = exports.EventInfoFlags = exports.StoryInfoFlags = exports.ArticleInfoFlags = exports.ReturnInfo = exports.ReturnInfoFlagsBase = void 0;
41
+ var fs = require("fs");
42
+ var logger_1 = require("./logger");
43
+ var ReturnInfoFlagsBase = /** @class */ (function () {
44
+ function ReturnInfoFlagsBase() {
45
+ this.data = {};
46
+ }
47
+ ReturnInfoFlagsBase.prototype.setFlag = function (key, value, defaultValue) {
48
+ this.setProperty("Include" + this.type + key.charAt(0).toUpperCase() + key.slice(1), value, defaultValue);
49
+ };
50
+ ReturnInfoFlagsBase.prototype.setValue = function (key, value, defaultValue, skipKeyMod) {
51
+ if (skipKeyMod === void 0) { skipKeyMod = false; }
52
+ var constructedKey = skipKeyMod ? key.charAt(0).toUpperCase() + key.slice(1) : this.type + key.charAt(0).toUpperCase() + key.slice(1);
53
+ this.setProperty(constructedKey, value, defaultValue);
54
+ };
55
+ ReturnInfoFlagsBase.prototype.getProperties = function (prefix) {
56
+ if (prefix === void 0) { prefix = ""; }
57
+ var result = {};
58
+ for (var key in this.data) {
59
+ if (Object.prototype.hasOwnProperty.call(this.data, key)) {
60
+ var value = this.data[key];
61
+ var lowercaseKey = key.toLowerCase();
62
+ var lowercasePrefix = prefix.toLowerCase();
63
+ if (lowercaseKey.startsWith(lowercasePrefix)) {
64
+ result[this.camelCase(key)] = value;
65
+ }
66
+ else {
67
+ result[this.camelCase(prefix + key)] = value;
68
+ }
69
+ }
70
+ }
71
+ return result;
72
+ };
73
+ ReturnInfoFlagsBase.prototype.camelCase = function (str) {
74
+ return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
75
+ return index === 0 ? word.toLowerCase() : word.toUpperCase();
76
+ }).replace(/\s+/g, '');
77
+ };
78
+ ReturnInfoFlagsBase.prototype.addProperties = function (properties) {
79
+ if (properties instanceof Object) {
80
+ for (var name_1 in properties) {
81
+ if (properties.hasOwnProperty(name_1)) {
82
+ var value = properties[name_1];
83
+ if (typeof value === "boolean") {
84
+ this.setFlag(name_1, value, !value);
85
+ }
86
+ else {
87
+ this.setValue(name_1, value);
88
+ }
89
+ }
90
+ }
91
+ }
92
+ };
93
+ ReturnInfoFlagsBase.prototype.setProperty = function (key, value, defaultValue) {
94
+ if (value !== defaultValue) {
95
+ this.data[key] = value;
96
+ }
97
+ };
98
+ return ReturnInfoFlagsBase;
99
+ }());
100
+ exports.ReturnInfoFlagsBase = ReturnInfoFlagsBase;
101
+ var ReturnInfo = /** @class */ (function () {
102
+ // Accepts all InfoFlags
103
+ function ReturnInfo(_a) {
104
+ if (_a === void 0) { _a = {}; }
105
+ var _b = _a.articleInfo, articleInfo = _b === void 0 ? new ArticleInfoFlags() : _b, _c = _a.eventInfo, eventInfo = _c === void 0 ? new EventInfoFlags() : _c, _d = _a.sourceInfo, sourceInfo = _d === void 0 ? new SourceInfoFlags() : _d, _e = _a.categoryInfo, categoryInfo = _e === void 0 ? new CategoryInfoFlags() : _e, _f = _a.conceptInfo, conceptInfo = _f === void 0 ? new ConceptInfoFlags() : _f, _g = _a.locationInfo, locationInfo = _g === void 0 ? new LocationInfoFlags() : _g, _h = _a.storyInfo, storyInfo = _h === void 0 ? new StoryInfoFlags() : _h, _j = _a.conceptClassInfo, conceptClassInfo = _j === void 0 ? new ConceptClassInfoFlags() : _j, _k = _a.conceptFolderInfo, conceptFolderInfo = _k === void 0 ? new ConceptFolderInfoFlags() : _k, unsupported = __rest(_a, ["articleInfo", "eventInfo", "sourceInfo", "categoryInfo", "conceptInfo", "locationInfo", "storyInfo", "conceptClassInfo", "conceptFolderInfo"]);
106
+ if (Object.keys(unsupported).length > 0) {
107
+ logger_1.Logger.warn("ReturnInfo: Unsupported parameters detected: ".concat(JSON.stringify(unsupported), ". Please check the documentation."));
108
+ }
109
+ this.articleInfo = articleInfo;
110
+ this.eventInfo = eventInfo;
111
+ this.sourceInfo = sourceInfo;
112
+ this.categoryInfo = categoryInfo;
113
+ this.conceptInfo = conceptInfo;
114
+ this.locationInfo = locationInfo;
115
+ this.storyInfo = storyInfo;
116
+ this.conceptClassInfo = conceptClassInfo;
117
+ this.conceptFolderInfo = conceptFolderInfo;
118
+ }
119
+ ReturnInfo.prototype.getParams = function (prefix) {
120
+ return __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, this.articleInfo.getProperties(prefix)), this.eventInfo.getProperties(prefix)), this.sourceInfo.getProperties(prefix)), this.categoryInfo.getProperties(prefix)), this.conceptInfo.getProperties(prefix)), this.locationInfo.getProperties(prefix)), this.storyInfo.getProperties(prefix)), this.conceptClassInfo.getProperties(prefix)), this.conceptFolderInfo.getProperties(prefix));
121
+ };
122
+ /**
123
+ * load the configuration for the ReturnInfo from a filename
124
+ * @param filename filename that contains the json configuration to use in the ReturnInfo
125
+ */
126
+ ReturnInfo.loadFromFile = function (filename) {
127
+ if (!(fs && fs.existsSync(filename))) {
128
+ throw new Error("File ".concat(filename, " does not exist"));
129
+ }
130
+ var conf = JSON.parse(fs.readFileSync(filename, "utf8"));
131
+ return new ReturnInfo({
132
+ articleInfo: new ArticleInfoFlags(conf.articleInfo || {}),
133
+ eventInfo: new EventInfoFlags(conf.eventInfo || {}),
134
+ sourceInfo: new SourceInfoFlags(conf.sourceInfo || {}),
135
+ categoryInfo: new CategoryInfoFlags(conf.categoryInfo || {}),
136
+ conceptInfo: new ConceptInfoFlags(conf.conceptInfo || {}),
137
+ locationInfo: new LocationInfoFlags(conf.locationInfo || {}),
138
+ storyInfo: new StoryInfoFlags(conf.storyInfo || {}),
139
+ conceptClassInfo: new ConceptClassInfoFlags(conf.conceptClassInfo || {}),
140
+ conceptFolderInfo: new ConceptFolderInfoFlags(conf.conceptFolderInfo || {}),
141
+ });
142
+ };
143
+ return ReturnInfo;
144
+ }());
145
+ exports.ReturnInfo = ReturnInfo;
146
+ var ArticleInfoFlags = /** @class */ (function (_super) {
147
+ __extends(ArticleInfoFlags, _super);
148
+ function ArticleInfoFlags(params) {
149
+ if (params === void 0) { params = {}; }
150
+ var _this = _super.call(this) || this;
151
+ _this.type = "Article";
152
+ var _a = params.bodyLen, bodyLen = _a === void 0 ? -1 : _a, _b = params.basicInfo, basicInfo = _b === void 0 ? true : _b, _c = params.title, title = _c === void 0 ? true : _c, _d = params.body, body = _d === void 0 ? true : _d, _e = params.url, url = _e === void 0 ? true : _e, _f = params.eventUri, eventUri = _f === void 0 ? true : _f, _g = params.authors, authors = _g === void 0 ? true : _g, _h = params.concepts, concepts = _h === void 0 ? false : _h, _j = params.categories, categories = _j === void 0 ? false : _j, _k = params.links, links = _k === void 0 ? false : _k, _l = params.videos, videos = _l === void 0 ? false : _l, _m = params.image, image = _m === void 0 ? true : _m, _o = params.socialScore, socialScore = _o === void 0 ? false : _o, _p = params.sentiment, sentiment = _p === void 0 ? true : _p, _q = params.location, location = _q === void 0 ? false : _q, _r = params.extractedDates, extractedDates = _r === void 0 ? false : _r, _s = params.originalArticle, originalArticle = _s === void 0 ? false : _s, _t = params.storyUri, storyUri = _t === void 0 ? false : _t, properties = __rest(params, ["bodyLen", "basicInfo", "title", "body", "url", "eventUri", "authors", "concepts", "categories", "links", "videos", "image", "socialScore", "sentiment", "location", "extractedDates", "originalArticle", "storyUri"]);
153
+ _this.setValue("bodyLen", bodyLen);
154
+ _this.setFlag("basicInfo", basicInfo);
155
+ _this.setFlag("title", title);
156
+ _this.setFlag("body", body);
157
+ _this.setFlag("url", url);
158
+ _this.setFlag("eventUri", eventUri);
159
+ _this.setFlag("authors", authors);
160
+ _this.setFlag("concepts", concepts);
161
+ _this.setFlag("categories", categories);
162
+ _this.setFlag("links", links);
163
+ _this.setFlag("videos", videos);
164
+ _this.setFlag("image", image);
165
+ _this.setFlag("socialScore", socialScore);
166
+ _this.setFlag("sentiment", sentiment);
167
+ _this.setFlag("location", location);
168
+ _this.setFlag("extractedDates", extractedDates);
169
+ _this.setFlag("originalArticle", originalArticle);
170
+ _this.setFlag("storyUri", storyUri);
171
+ _this.addProperties(properties);
172
+ return _this;
173
+ }
174
+ return ArticleInfoFlags;
175
+ }(ReturnInfoFlagsBase));
176
+ exports.ArticleInfoFlags = ArticleInfoFlags;
177
+ var StoryInfoFlags = /** @class */ (function (_super) {
178
+ __extends(StoryInfoFlags, _super);
179
+ function StoryInfoFlags(params) {
180
+ if (params === void 0) { params = {}; }
181
+ var _this = _super.call(this) || this;
182
+ _this.type = "Story";
183
+ var _a = params.basicStats, basicStats = _a === void 0 ? true : _a, _b = params.location, location = _b === void 0 ? true : _b, _c = params.date, date = _c === void 0 ? false : _c, _d = params.title, title = _d === void 0 ? false : _d, _e = params.summary, summary = _e === void 0 ? false : _e, _f = params.concepts, concepts = _f === void 0 ? false : _f, _g = params.categories, categories = _g === void 0 ? false : _g, _h = params.medoidArticle, medoidArticle = _h === void 0 ? false : _h, _j = params.infoArticle, infoArticle = _j === void 0 ? false : _j, _k = params.commonDates, commonDates = _k === void 0 ? false : _k, _l = params.socialScore, socialScore = _l === void 0 ? false : _l, _m = params.imageCount, imageCount = _m === void 0 ? 0 : _m, properties = __rest(params, ["basicStats", "location", "date", "title", "summary", "concepts", "categories", "medoidArticle", "infoArticle", "commonDates", "socialScore", "imageCount"]);
184
+ _this.setFlag("basicStats", basicStats);
185
+ _this.setFlag("location", location);
186
+ _this.setFlag("date", date);
187
+ _this.setFlag("title", title);
188
+ _this.setFlag("summary", summary);
189
+ _this.setFlag("concepts", concepts);
190
+ _this.setFlag("categories", categories);
191
+ _this.setFlag("medoidArticle", medoidArticle);
192
+ _this.setFlag("infoArticle", infoArticle);
193
+ _this.setFlag("commonDates", commonDates);
194
+ _this.setFlag("socialScore", socialScore);
195
+ _this.setValue("imageCount", imageCount);
196
+ _this.addProperties(properties);
197
+ return _this;
198
+ }
199
+ return StoryInfoFlags;
200
+ }(ReturnInfoFlagsBase));
201
+ exports.StoryInfoFlags = StoryInfoFlags;
202
+ var EventInfoFlags = /** @class */ (function (_super) {
203
+ __extends(EventInfoFlags, _super);
204
+ function EventInfoFlags(params) {
205
+ if (params === void 0) { params = {}; }
206
+ var _this = _super.call(this) || this;
207
+ _this.type = "Event";
208
+ var _a = params.title, title = _a === void 0 ? true : _a, _b = params.summary, summary = _b === void 0 ? true : _b, _c = params.articleCounts, articleCounts = _c === void 0 ? true : _c, _d = params.concepts, concepts = _d === void 0 ? true : _d, _e = params.categories, categories = _e === void 0 ? true : _e, _f = params.date, date = _f === void 0 ? true : _f, _g = params.commonDates, commonDates = _g === void 0 ? false : _g, _h = params.infoArticle, infoArticle = _h === void 0 ? false : _h, _j = params.stories, stories = _j === void 0 ? false : _j, _k = params.socialScore, socialScore = _k === void 0 ? false : _k, _l = params.imageCount, imageCount = _l === void 0 ? 0 : _l, properties = __rest(params, ["title", "summary", "articleCounts", "concepts", "categories", "date", "commonDates", "infoArticle", "stories", "socialScore", "imageCount"]);
209
+ _this.setFlag("title", title);
210
+ _this.setFlag("summary", summary);
211
+ _this.setFlag("articleCounts", articleCounts);
212
+ _this.setFlag("concepts", concepts);
213
+ _this.setFlag("categories", categories);
214
+ _this.setFlag("date", date);
215
+ _this.setFlag("commonDates", commonDates);
216
+ _this.setFlag("infoArticle", infoArticle);
217
+ _this.setFlag("stories", stories);
218
+ _this.setFlag("socialScore", socialScore);
219
+ _this.setValue("imageCount", imageCount);
220
+ _this.addProperties(properties);
221
+ return _this;
222
+ }
223
+ return EventInfoFlags;
224
+ }(ReturnInfoFlagsBase));
225
+ exports.EventInfoFlags = EventInfoFlags;
226
+ var SourceInfoFlags = /** @class */ (function (_super) {
227
+ __extends(SourceInfoFlags, _super);
228
+ function SourceInfoFlags(params) {
229
+ if (params === void 0) { params = {}; }
230
+ var _this = _super.call(this) || this;
231
+ var _a = params.title, title = _a === void 0 ? true : _a, _b = params.description, description = _b === void 0 ? false : _b, _c = params.location, location = _c === void 0 ? false : _c, _d = params.ranking, ranking = _d === void 0 ? false : _d, _e = params.image, image = _e === void 0 ? false : _e, _f = params.socialMedia, socialMedia = _f === void 0 ? false : _f, properties = __rest(params, ["title", "description", "location", "ranking", "image", "socialMedia"]);
232
+ _this.type = "Source";
233
+ _this.setFlag("title", title);
234
+ _this.setFlag("description", description);
235
+ _this.setFlag("location", location);
236
+ _this.setFlag("ranking", ranking);
237
+ _this.setFlag("image", image);
238
+ _this.setFlag("socialMedia", socialMedia);
239
+ _this.addProperties(properties);
240
+ return _this;
241
+ }
242
+ return SourceInfoFlags;
243
+ }(ReturnInfoFlagsBase));
244
+ exports.SourceInfoFlags = SourceInfoFlags;
245
+ var CategoryInfoFlags = /** @class */ (function (_super) {
246
+ __extends(CategoryInfoFlags, _super);
247
+ function CategoryInfoFlags(params) {
248
+ if (params === void 0) { params = {}; }
249
+ var _this = _super.call(this) || this;
250
+ _this.type = "Category";
251
+ var _a = params.trendingScore, trendingScore = _a === void 0 ? true : _a, properties = __rest(params, ["trendingScore"]);
252
+ _this.setFlag("trendingScore", trendingScore);
253
+ _this.addProperties(properties);
254
+ return _this;
255
+ }
256
+ return CategoryInfoFlags;
257
+ }(ReturnInfoFlagsBase));
258
+ exports.CategoryInfoFlags = CategoryInfoFlags;
259
+ var ConceptInfoFlags = /** @class */ (function (_super) {
260
+ __extends(ConceptInfoFlags, _super);
261
+ function ConceptInfoFlags(params) {
262
+ if (params === void 0) { params = {}; }
263
+ var _this = _super.call(this) || this;
264
+ _this.type = "Concept";
265
+ var _a = params.type, type = _a === void 0 ? "concepts" : _a, _b = params.lang, lang = _b === void 0 ? "eng" : _b, _c = params.label, label = _c === void 0 ? true : _c, _d = params.synonyms, synonyms = _d === void 0 ? false : _d, _e = params.image, image = _e === void 0 ? false : _e, _f = params.description, description = _f === void 0 ? false : _f, _g = params.trendingScore, trendingScore = _g === void 0 ? false : _g, _h = params.maxConceptsPerType, maxConceptsPerType = _h === void 0 ? 20 : _h, properties = __rest(params, ["type", "lang", "label", "synonyms", "image", "description", "trendingScore", "maxConceptsPerType"]);
266
+ _this.setValue("type", type);
267
+ _this.setValue("lang", lang);
268
+ _this.setFlag("label", label);
269
+ _this.setFlag("synonyms", synonyms);
270
+ _this.setFlag("image", image);
271
+ _this.setFlag("description", description);
272
+ _this.setFlag("trendingScore", trendingScore);
273
+ _this.setValue("maxConceptsPerType", maxConceptsPerType, 20, true);
274
+ _this.addProperties(properties);
275
+ return _this;
276
+ }
277
+ return ConceptInfoFlags;
278
+ }(ReturnInfoFlagsBase));
279
+ exports.ConceptInfoFlags = ConceptInfoFlags;
280
+ var LocationInfoFlags = /** @class */ (function (_super) {
281
+ __extends(LocationInfoFlags, _super);
282
+ function LocationInfoFlags(params) {
283
+ if (params === void 0) { params = {}; }
284
+ var _this = _super.call(this) || this;
285
+ _this.type = "Location";
286
+ var _a = params.label, label = _a === void 0 ? true : _a, _b = params.wikiUri, wikiUri = _b === void 0 ? false : _b, _c = params.geoNamesId, geoNamesId = _c === void 0 ? false : _c, _d = params.population, population = _d === void 0 ? false : _d, _e = params.geoLocation, geoLocation = _e === void 0 ? false : _e, _f = params.countryArea, countryArea = _f === void 0 ? false : _f, _g = params.countryDetails, countryDetails = _g === void 0 ? false : _g, _h = params.countryContinent, countryContinent = _h === void 0 ? false : _h, _j = params.placeFeatureCode, placeFeatureCode = _j === void 0 ? false : _j, _k = params.placeCountry, placeCountry = _k === void 0 ? true : _k, properties = __rest(params, ["label", "wikiUri", "geoNamesId", "population", "geoLocation", "countryArea", "countryDetails", "countryContinent", "placeFeatureCode", "placeCountry"]);
287
+ _this.setFlag("label", label);
288
+ _this.setFlag("wikiUri", wikiUri);
289
+ _this.setFlag("geoNamesId", geoNamesId);
290
+ _this.setFlag("population", population);
291
+ _this.setFlag("geoLocation", geoLocation);
292
+ _this.setFlag("countryArea", countryArea);
293
+ _this.setFlag("countryDetails", countryDetails);
294
+ _this.setFlag("countryContinent", countryContinent);
295
+ _this.setFlag("placeFeatureCode", placeFeatureCode);
296
+ _this.setFlag("placeCountry", placeCountry);
297
+ _this.addProperties(properties);
298
+ return _this;
299
+ }
300
+ return LocationInfoFlags;
301
+ }(ReturnInfoFlagsBase));
302
+ exports.LocationInfoFlags = LocationInfoFlags;
303
+ var ConceptClassInfoFlags = /** @class */ (function (_super) {
304
+ __extends(ConceptClassInfoFlags, _super);
305
+ function ConceptClassInfoFlags(params) {
306
+ if (params === void 0) { params = {}; }
307
+ var _this = _super.call(this) || this;
308
+ _this.type = "ConceptClass";
309
+ var _a = params.parentLabels, parentLabels = _a === void 0 ? true : _a, _b = params.concepts, concepts = _b === void 0 ? false : _b, properties = __rest(params, ["parentLabels", "concepts"]);
310
+ _this.setFlag("parentLabels", parentLabels);
311
+ _this.setFlag("concepts", concepts);
312
+ _this.addProperties(properties);
313
+ return _this;
314
+ }
315
+ return ConceptClassInfoFlags;
316
+ }(ReturnInfoFlagsBase));
317
+ exports.ConceptClassInfoFlags = ConceptClassInfoFlags;
318
+ var ConceptFolderInfoFlags = /** @class */ (function (_super) {
319
+ __extends(ConceptFolderInfoFlags, _super);
320
+ function ConceptFolderInfoFlags(params) {
321
+ if (params === void 0) { params = {}; }
322
+ var _this = _super.call(this) || this;
323
+ _this.type = "ConceptFolder";
324
+ var _a = params.definition, definition = _a === void 0 ? true : _a, _b = params.owner, owner = _b === void 0 ? false : _b, properties = __rest(params, ["definition", "owner"]);
325
+ _this.setFlag("owner", definition);
326
+ _this.setFlag("owner", owner);
327
+ _this.addProperties(properties);
328
+ return _this;
329
+ }
330
+ return ConceptFolderInfoFlags;
331
+ }(ReturnInfoFlagsBase));
332
+ exports.ConceptFolderInfoFlags = ConceptFolderInfoFlags;
305
333
  //# sourceMappingURL=returnInfo.js.map