eventregistry 8.11.2 → 9.1.0

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 +44 -0
  28. package/dist/logger.js +144 -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,799 +1,826 @@
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
- return new (P || (P = Promise))(function (resolve, reject) {
17
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
20
- step((generator = generator.apply(thisArg, _arguments || [])).next());
21
- });
22
- };
23
- var __generator = (this && this.__generator) || function (thisArg, body) {
24
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
25
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
26
- function verb(n) { return function (v) { return step([n, v]); }; }
27
- function step(op) {
28
- if (f) throw new TypeError("Generator is already executing.");
29
- while (_) try {
30
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
31
- if (y = 0, t) op = [op[0] & 2, t.value];
32
- switch (op[0]) {
33
- case 0: case 1: t = op; break;
34
- case 4: _.label++; return { value: op[1], done: false };
35
- case 5: _.label++; y = op[1]; op = [0]; continue;
36
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
37
- default:
38
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
39
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
40
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
41
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
42
- if (t[2]) _.ops.pop();
43
- _.trys.pop(); continue;
44
- }
45
- op = body.call(thisArg, _);
46
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
47
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
- }
49
- };
50
- var __rest = (this && this.__rest) || function (s, e) {
51
- var t = {};
52
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
53
- t[p] = s[p];
54
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
55
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
56
- t[p[i]] = s[p[i]];
57
- return t;
58
- };
59
- var __read = (this && this.__read) || function (o, n) {
60
- var m = typeof Symbol === "function" && o[Symbol.iterator];
61
- if (!m) return o;
62
- var i = m.call(o), r, ar = [], e;
63
- try {
64
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
65
- }
66
- catch (error) { e = { error: error }; }
67
- finally {
68
- try {
69
- if (r && !r.done && (m = i["return"])) m.call(i);
70
- }
71
- finally { if (e) throw e.error; }
72
- }
73
- return ar;
74
- };
75
- var __spread = (this && this.__spread) || function () {
76
- for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
77
- return ar;
78
- };
79
- Object.defineProperty(exports, "__esModule", { value: true });
80
- var _ = require("lodash");
81
- var base_1 = require("./base");
82
- var query_1 = require("./query");
83
- var returnInfo_1 = require("./returnInfo");
84
- /**
85
- * @class QueryEvents
86
- * Class for obtaining available info for one or more events in the Event Registry
87
- */
88
- var QueryEvents = /** @class */ (function (_super) {
89
- __extends(QueryEvents, _super);
90
- function QueryEvents(args) {
91
- if (args === void 0) { args = {}; }
92
- var _this = _super.call(this) || this;
93
- _this.params = {};
94
- var keywords = args.keywords, conceptUri = args.conceptUri, categoryUri = args.categoryUri, sourceUri = args.sourceUri, sourceLocationUri = args.sourceLocationUri, sourceGroupUri = args.sourceGroupUri, authorUri = args.authorUri, locationUri = args.locationUri, lang = args.lang, dateStart = args.dateStart, dateEnd = args.dateEnd, reportingDateStart = args.reportingDateStart, reportingDateEnd = args.reportingDateEnd, _a = args.minSentiment, minSentiment = _a === void 0 ? -1 : _a, _b = args.maxSentiment, maxSentiment = _b === void 0 ? 1 : _b, minArticlesInEvent = args.minArticlesInEvent, maxArticlesInEvent = args.maxArticlesInEvent, dateMentionStart = args.dateMentionStart, dateMentionEnd = args.dateMentionEnd, ignoreKeywords = args.ignoreKeywords, ignoreConceptUri = args.ignoreConceptUri, ignoreCategoryUri = args.ignoreCategoryUri, ignoreSourceUri = args.ignoreSourceUri, ignoreSourceLocationUri = args.ignoreSourceLocationUri, ignoreSourceGroupUri = args.ignoreSourceGroupUri, ignoreAuthorUri = args.ignoreAuthorUri, ignoreLocationUri = args.ignoreLocationUri, ignoreLang = args.ignoreLang, _c = args.keywordsLoc, keywordsLoc = _c === void 0 ? "body" : _c, _d = args.ignoreKeywordsLoc, ignoreKeywordsLoc = _d === void 0 ? "body" : _d, _e = args.categoryIncludeSub, categoryIncludeSub = _e === void 0 ? true : _e, _f = args.ignoreCategoryIncludeSub, ignoreCategoryIncludeSub = _f === void 0 ? true : _f, _g = args.requestedResult, requestedResult = _g === void 0 ? new RequestEventsInfo() : _g;
95
- _this.setVal("action", "getEvents");
96
- _this.setQueryArrVal(keywords, "keyword", "keywordOper", "and");
97
- _this.setQueryArrVal(conceptUri, "conceptUri", "conceptOper", "and");
98
- _this.setQueryArrVal(categoryUri, "categoryUri", "categoryOper", "or");
99
- _this.setQueryArrVal(sourceUri, "sourceUri", undefined, "or");
100
- _this.setQueryArrVal(sourceLocationUri, "sourceLocationUri", undefined, "or");
101
- _this.setQueryArrVal(sourceGroupUri, "sourceGroupUri", undefined, "or");
102
- _this.setQueryArrVal(authorUri, "authorUri", "authorOper", "or");
103
- _this.setQueryArrVal(locationUri, "locationUri", undefined, "or");
104
- _this.setQueryArrVal(lang, "lang", undefined, "or");
105
- if (!_.isUndefined(dateStart)) {
106
- _this.setDateVal("dateStart", dateStart);
107
- }
108
- if (!_.isUndefined(dateEnd)) {
109
- _this.setDateVal("dateEnd", dateEnd);
110
- }
111
- if (!_.isUndefined(reportingDateStart)) {
112
- _this.setDateVal("reportingDateStart", reportingDateStart);
113
- }
114
- if (!_.isUndefined(reportingDateEnd)) {
115
- _this.setDateVal("reportingDateEnd", reportingDateEnd);
116
- }
117
- if (minSentiment > -1 && minSentiment <= 1) {
118
- _this.setVal("minSentiment", minSentiment);
119
- }
120
- if (maxSentiment >= -1 && maxSentiment < 1) {
121
- _this.setVal("maxSentiment", maxSentiment);
122
- }
123
- _this.setValIfNotDefault("minArticlesInEvent", minArticlesInEvent, undefined);
124
- _this.setValIfNotDefault("maxArticlesInEvent", maxArticlesInEvent, undefined);
125
- if (!_.isUndefined(dateMentionStart)) {
126
- _this.setDateVal("dateMentionStart", dateMentionStart);
127
- }
128
- if (!_.isUndefined(dateMentionEnd)) {
129
- _this.setDateVal("dateMentionEnd", dateMentionEnd);
130
- }
131
- // for the negative conditions, only the OR is a valid operator type
132
- _this.setQueryArrVal(ignoreKeywords, "ignoreKeywords", undefined, "or");
133
- _this.setQueryArrVal(ignoreConceptUri, "ignoreConceptUri", undefined, "or");
134
- _this.setQueryArrVal(ignoreCategoryUri, "ignoreCategoryUri", undefined, "or");
135
- _this.setQueryArrVal(ignoreSourceUri, "ignoreSourceUri", undefined, "or");
136
- _this.setQueryArrVal(ignoreSourceLocationUri, "ignoreSourceLocationUri", undefined, "or");
137
- _this.setQueryArrVal(ignoreSourceGroupUri, "ignoreSourceGroupUri", undefined, "or");
138
- _this.setQueryArrVal(ignoreAuthorUri, "ignoreAuthorUri", undefined, "or");
139
- _this.setQueryArrVal(ignoreLocationUri, "ignoreLocationUri", undefined, "or");
140
- _this.setQueryArrVal(ignoreLang, "ignoreLang", undefined, "or");
141
- _this.setValIfNotDefault("keywordLoc", keywordsLoc, "body");
142
- _this.setValIfNotDefault("ignoreKeywordLoc", ignoreKeywordsLoc, "body");
143
- _this.setValIfNotDefault("categoryIncludeSub", categoryIncludeSub, true);
144
- _this.setValIfNotDefault("ignoreCategoryIncludeSub", ignoreCategoryIncludeSub, true);
145
- _this.setRequestedResult(requestedResult);
146
- return _this;
147
- }
148
- Object.defineProperty(QueryEvents.prototype, "path", {
149
- get: function () {
150
- return "/api/v1/event";
151
- },
152
- enumerable: true,
153
- configurable: true
154
- });
155
- /**
156
- * Set the single result type that you would like to be returned. Any previously set result types will be overwritten.
157
- * Result types can be the classes that extend RequestEvent base class (see classes below).
158
- */
159
- QueryEvents.prototype.setRequestedResult = function (requestEvents) {
160
- if (!(requestEvents instanceof RequestEvents)) {
161
- throw new Error("QueryEvents class can only accept result requests that are of type RequestEvents");
162
- }
163
- this.resultTypeList = [
164
- requestEvents,
165
- ];
166
- };
167
- /**
168
- * Set a custom list of event uris. The results will be then computed on this list - no query will be done (all conditions will be ignored).
169
- */
170
- QueryEvents.initWithEventUriList = function (uriList) {
171
- var query = new QueryEvents();
172
- if (!_.isArray(uriList)) {
173
- throw new Error("uriList has to be a list of strings that represent event uris");
174
- }
175
- query.params = {
176
- action: "getEvents",
177
- eventUriList: _.join(uriList, ","),
178
- };
179
- return query;
180
- };
181
- QueryEvents.initWithEventUriWgtList = function (uriWgtList) {
182
- var query = new QueryEvents();
183
- if (!_.isArray(uriWgtList)) {
184
- throw new Error("uriWgtList has to be a list of strings that represent event uris");
185
- }
186
- query.params = {
187
- action: "getEvents",
188
- eventUriWgtList: _.join(uriWgtList, ","),
189
- };
190
- return query;
191
- };
192
- QueryEvents.initWithComplexQuery = function (complexQuery) {
193
- var query = new QueryEvents();
194
- if (complexQuery instanceof query_1.ComplexEventQuery) {
195
- query.setVal("query", JSON.stringify(complexQuery.getQuery()));
196
- }
197
- else if (_.isString(complexQuery)) {
198
- try {
199
- JSON.parse(complexQuery);
200
- }
201
- catch (_a) {
202
- console.error("Failed to parse the provided string content as a JSON object. Please check the content provided as a parameter to the initWithComplexQuery() method");
203
- }
204
- query.setVal("query", complexQuery);
205
- }
206
- else if (_.isObject(complexQuery)) {
207
- query.setVal("query", JSON.stringify(complexQuery));
208
- }
209
- else {
210
- throw new Error("The instance of query parameter was not a ComplexEventQuery, a string or an object");
211
- }
212
- return query;
213
- };
214
- return QueryEvents;
215
- }(base_1.Query));
216
- exports.QueryEvents = QueryEvents;
217
- /**
218
- * @class QueryEventsIter
219
- * Class for iterating through all the events via callbacks
220
- */
221
- var QueryEventsIter = /** @class */ (function (_super) {
222
- __extends(QueryEventsIter, _super);
223
- function QueryEventsIter(er, args) {
224
- if (args === void 0) { args = {}; }
225
- var _this = _super.call(this, args) || this;
226
- _this.page = 0;
227
- _this.pages = 1;
228
- _this.items = [];
229
- _this.returnedSoFar = 0;
230
- _this.index = 0;
231
- _this.callback = _.noop;
232
- _this.doneCallback = _.noop;
233
- var _a = args.sortBy, sortBy = _a === void 0 ? "rel" : _a, _b = args.sortByAsc, sortByAsc = _b === void 0 ? false : _b, _c = args.returnInfo, returnInfo = _c === void 0 ? undefined : _c, _d = args.maxItems, maxItems = _d === void 0 ? -1 : _d;
234
- _this.er = er;
235
- _this.sortBy = sortBy;
236
- _this.sortByAsc = sortByAsc;
237
- _this.returnInfo = returnInfo;
238
- _this.maxItems = maxItems;
239
- return _this;
240
- }
241
- /**
242
- * Async Iterator function that returns the next item in the list of events
243
- */
244
- QueryEventsIter.prototype[Symbol.asyncIterator] = function () {
245
- var _this = this;
246
- return {
247
- next: function () { return __awaiter(_this, void 0, void 0, function () {
248
- var item;
249
- return __generator(this, function (_a) {
250
- switch (_a.label) {
251
- case 0:
252
- if (!(this.index >= this.items.length)) return [3 /*break*/, 2];
253
- return [4 /*yield*/, this.getNextBatch()];
254
- case 1:
255
- _a.sent();
256
- _a.label = 2;
257
- case 2:
258
- item = this.items[this.index];
259
- this.index++;
260
- return [2 /*return*/, { value: item, done: !item }];
261
- }
262
- });
263
- }); },
264
- };
265
- };
266
- QueryEventsIter.prototype.count = function () {
267
- return __awaiter(this, void 0, void 0, function () {
268
- var response;
269
- return __generator(this, function (_a) {
270
- switch (_a.label) {
271
- case 0:
272
- this.setRequestedResult(new RequestEventsInfo());
273
- return [4 /*yield*/, this.er.execQuery(this)];
274
- case 1:
275
- response = _a.sent();
276
- if (_.has(response, "error")) {
277
- console.error(_.get(response, "error"));
278
- }
279
- return [2 /*return*/, _.get(response, "events.totalResults", 0)];
280
- }
281
- });
282
- });
283
- };
284
- /**
285
- * Execute query and fetch batches of events of the specified size (eventBatchSize)
286
- * @param callback callback function that'll be called every time we get a new batch of events from the backend
287
- * @param doneCallback callback function that'll be called when everything is complete
288
- */
289
- QueryEventsIter.prototype.execQuery = function (callback, doneCallback) {
290
- if (callback) {
291
- this.callback = callback;
292
- }
293
- if (doneCallback) {
294
- this.doneCallback = doneCallback;
295
- }
296
- this.iterate();
297
- };
298
- QueryEventsIter.initWithComplexQuery = function (er, complexQuery, args) {
299
- if (args === void 0) { args = {}; }
300
- var query = new QueryEventsIter(er, args);
301
- if (complexQuery instanceof query_1.ComplexEventQuery) {
302
- query.setVal("query", JSON.stringify(complexQuery.getQuery()));
303
- }
304
- else if (_.isString(complexQuery)) {
305
- query.setVal("query", complexQuery);
306
- }
307
- else if (_.isObject(complexQuery)) {
308
- query.setVal("query", JSON.stringify(complexQuery));
309
- }
310
- else {
311
- throw new Error("The instance of query parameter was not a ComplexEventQuery, a string or an object");
312
- }
313
- return query;
314
- };
315
- QueryEventsIter.prototype.iterate = function () {
316
- return __awaiter(this, void 0, void 0, function () {
317
- return __generator(this, function (_a) {
318
- switch (_a.label) {
319
- case 0:
320
- if (!this.current) return [3 /*break*/, 1];
321
- this.callback(this.current);
322
- this.index += 1;
323
- return [3 /*break*/, 3];
324
- case 1: return [4 /*yield*/, this.getNextBatch()];
325
- case 2:
326
- if (!(_a.sent())) {
327
- this.doneCallback(this.errorMessage);
328
- return [2 /*return*/];
329
- }
330
- _a.label = 3;
331
- case 3: return [2 /*return*/, this.iterate()];
332
- }
333
- });
334
- });
335
- };
336
- /**
337
- * Extract the results according to maxItems
338
- * @param response response from the backend
339
- */
340
- QueryEventsIter.prototype.extractResults = function (response) {
341
- var results = _.get(response, "events.results", []);
342
- var extractedSize = this.maxItems !== -1 ? this.maxItems - this.returnedSoFar : _.size(results);
343
- return _.compact(_.pullAt(results, _.range(0, extractedSize)));
344
- };
345
- Object.defineProperty(QueryEventsIter.prototype, "current", {
346
- get: function () {
347
- return this.items[this.index] || undefined;
348
- },
349
- enumerable: true,
350
- configurable: true
351
- });
352
- QueryEventsIter.prototype.getNextBatch = function () {
353
- return __awaiter(this, void 0, void 0, function () {
354
- var requestEventsInfo, response, error, results, error_1;
355
- return __generator(this, function (_a) {
356
- switch (_a.label) {
357
- case 0:
358
- _a.trys.push([0, 2, , 3]);
359
- this.page += 1;
360
- if (this.page > this.pages || (this.maxItems !== -1 && this.returnedSoFar >= this.maxItems)) {
361
- return [2 /*return*/, false];
362
- }
363
- requestEventsInfo = new RequestEventsInfo({
364
- page: this.page,
365
- count: 50,
366
- sortBy: this.sortBy,
367
- sortByAsc: this.sortByAsc,
368
- returnInfo: this.returnInfo,
369
- });
370
- this.setRequestedResult(requestEventsInfo);
371
- if (this.er.verboseOutput) {
372
- console.log("Downloading event page " + this.page + "...");
373
- }
374
- return [4 /*yield*/, this.er.execQuery(this, this.er.allowUseOfArchive)];
375
- case 1:
376
- response = _a.sent();
377
- error = _.get(response, "error", "");
378
- if (error) {
379
- this.errorMessage = "Error while obtaining a list of events: " + _.get(response, "error");
380
- }
381
- else {
382
- this.pages = _.get(response, "events.pages", 0);
383
- }
384
- results = this.extractResults(response);
385
- this.returnedSoFar += _.size(results);
386
- this.items = __spread(this.items, results);
387
- return [2 /*return*/, true];
388
- case 2:
389
- error_1 = _a.sent();
390
- console.error(error_1);
391
- return [2 /*return*/, false];
392
- case 3: return [2 /*return*/];
393
- }
394
- });
395
- });
396
- };
397
- return QueryEventsIter;
398
- }(QueryEvents));
399
- exports.QueryEventsIter = QueryEventsIter;
400
- var RequestEvents = /** @class */ (function () {
401
- function RequestEvents() {
402
- }
403
- return RequestEvents;
404
- }());
405
- exports.RequestEvents = RequestEvents;
406
- /**
407
- * @class RequestEventsInfo
408
- * Return event details for resulting events.
409
- */
410
- var RequestEventsInfo = /** @class */ (function (_super) {
411
- __extends(RequestEventsInfo, _super);
412
- function RequestEventsInfo(args) {
413
- if (args === void 0) { args = {}; }
414
- var _this = _super.call(this) || this;
415
- _this.resultType = "events";
416
- var _a = args.page, page = _a === void 0 ? 1 : _a, _b = args.count, count = _b === void 0 ? 50 : _b, _c = args.sortBy, sortBy = _c === void 0 ? "rel" : _c, _d = args.sortByAsc, sortByAsc = _d === void 0 ? false : _d, _e = args.returnInfo, returnInfo = _e === void 0 ? undefined : _e;
417
- if (page < 1) {
418
- throw new RangeError("Page has to be >= 1");
419
- }
420
- if (count > 50) {
421
- throw new RangeError("At most 50 events can be returned per call");
422
- }
423
- _this.params = {};
424
- _this.params["eventsPage"] = page;
425
- _this.params["eventsCount"] = count;
426
- _this.params["eventsSortBy"] = sortBy;
427
- _this.params["eventsSortByAsc"] = sortByAsc;
428
- if (!!returnInfo) {
429
- _this.params = _.extend({}, _this.params, returnInfo.getParams("events"));
430
- }
431
- return _this;
432
- }
433
- return RequestEventsInfo;
434
- }(RequestEvents));
435
- exports.RequestEventsInfo = RequestEventsInfo;
436
- /**
437
- * @class RequestEventsUriList
438
- * Return a simple list of event uris together with the scores for resulting events.
439
- */
440
- var RequestEventsUriWgtList = /** @class */ (function (_super) {
441
- __extends(RequestEventsUriWgtList, _super);
442
- function RequestEventsUriWgtList(args) {
443
- if (args === void 0) { args = {}; }
444
- var _this = _super.call(this) || this;
445
- _this.resultType = "uriWgtList";
446
- var _a = args.page, page = _a === void 0 ? 1 : _a, _b = args.count, count = _b === void 0 ? 50000 : _b, _c = args.sortBy, sortBy = _c === void 0 ? "rel" : _c, _d = args.sortByAsc, sortByAsc = _d === void 0 ? false : _d, unsupported = __rest(args, ["page", "count", "sortBy", "sortByAsc"]);
447
- if (!_.isEmpty(unsupported)) {
448
- console.warn("RequestEventsUriWgtList: Unsupported parameters detected: " + JSON.stringify(unsupported) + ". Please check the documentation.");
449
- }
450
- if (page < 1) {
451
- throw new RangeError("Page has to be >= 1");
452
- }
453
- if (count > 100000) {
454
- throw new RangeError("At most 100000 results can be returned per call");
455
- }
456
- _this.params = {};
457
- _this.params["uriWgtListPage"] = page;
458
- _this.params["uriWgtListCount"] = count;
459
- _this.params["uriWgtListSortBy"] = sortBy;
460
- _this.params["uriWgtListSortByAsc"] = sortByAsc;
461
- return _this;
462
- }
463
- Object.defineProperty(RequestEventsUriWgtList.prototype, "page", {
464
- set: function (page) {
465
- if (page < 1) {
466
- throw new RangeError("Page has to be >= 1");
467
- }
468
- _.set(this.params, "uriWgtListPage", page);
469
- },
470
- enumerable: true,
471
- configurable: true
472
- });
473
- return RequestEventsUriWgtList;
474
- }(RequestEvents));
475
- exports.RequestEventsUriWgtList = RequestEventsUriWgtList;
476
- /**
477
- * @class RequestEventsTimeAggr
478
- * Return time distribution of resulting events.
479
- */
480
- var RequestEventsTimeAggr = /** @class */ (function (_super) {
481
- __extends(RequestEventsTimeAggr, _super);
482
- function RequestEventsTimeAggr() {
483
- var _this = _super !== null && _super.apply(this, arguments) || this;
484
- _this.resultType = "timeAggr";
485
- return _this;
486
- }
487
- return RequestEventsTimeAggr;
488
- }(RequestEvents));
489
- exports.RequestEventsTimeAggr = RequestEventsTimeAggr;
490
- /**
491
- * Return keyword aggregate (tag cloud) on words in articles in resulting events.
492
- * @class RequestEventsTimeAggr
493
- */
494
- var RequestEventsKeywordAggr = /** @class */ (function (_super) {
495
- __extends(RequestEventsKeywordAggr, _super);
496
- /**
497
- * @param lang: in which language to produce the list of top keywords. If undefined, then compute on all articles
498
- */
499
- function RequestEventsKeywordAggr(lang) {
500
- var _this = _super.call(this) || this;
501
- _this.resultType = "keywordAggr";
502
- _this.params = {};
503
- if (!_.isUndefined(lang)) {
504
- _this.params["keywordAggrLang"] = lang;
505
- }
506
- return _this;
507
- }
508
- return RequestEventsKeywordAggr;
509
- }(RequestEvents));
510
- exports.RequestEventsKeywordAggr = RequestEventsKeywordAggr;
511
- /**
512
- * @class RequestEventsLocAggr
513
- * Return aggregate of locations of resulting events.
514
- */
515
- var RequestEventsLocAggr = /** @class */ (function (_super) {
516
- __extends(RequestEventsLocAggr, _super);
517
- function RequestEventsLocAggr(args) {
518
- if (args === void 0) { args = {}; }
519
- var _this = _super.call(this) || this;
520
- _this.resultType = "locAggr";
521
- var _a = args.eventsSampleSize, eventsSampleSize = _a === void 0 ? 100000 : _a, _b = args.returnInfo, returnInfo = _b === void 0 ? new returnInfo_1.ReturnInfo() : _b, unsupported = __rest(args, ["eventsSampleSize", "returnInfo"]);
522
- if (!_.isEmpty(unsupported)) {
523
- console.warn("RequestEventsLocAggr: Unsupported parameters detected: " + JSON.stringify(unsupported) + ". Please check the documentation.");
524
- }
525
- if (eventsSampleSize > 100000) {
526
- throw new RangeError("At most 100000 results can be used for computing");
527
- }
528
- _this.params = {};
529
- _this.params["locAggrSampleSize"] = eventsSampleSize;
530
- _this.params = _.extend({}, _this.params, returnInfo.getParams("locAggr"));
531
- return _this;
532
- }
533
- return RequestEventsLocAggr;
534
- }(RequestEvents));
535
- exports.RequestEventsLocAggr = RequestEventsLocAggr;
536
- /**
537
- * @class RequestEventsLocTimeAggr
538
- * Return aggregate of locations and times of resulting events.
539
- */
540
- var RequestEventsLocTimeAggr = /** @class */ (function (_super) {
541
- __extends(RequestEventsLocTimeAggr, _super);
542
- function RequestEventsLocTimeAggr(args) {
543
- if (args === void 0) { args = {}; }
544
- var _this = _super.call(this) || this;
545
- _this.resultType = "locTimeAggr";
546
- var _a = args.eventsSampleSize, eventsSampleSize = _a === void 0 ? 100000 : _a, _b = args.returnInfo, returnInfo = _b === void 0 ? new returnInfo_1.ReturnInfo() : _b, unsupported = __rest(args, ["eventsSampleSize", "returnInfo"]);
547
- if (!_.isEmpty(unsupported)) {
548
- console.warn("RequestEventsLocTimeAggr: Unsupported parameters detected: " + JSON.stringify(unsupported) + ". Please check the documentation.");
549
- }
550
- if (eventsSampleSize > 100000) {
551
- throw new RangeError("At most 100000 results can be used for computing");
552
- }
553
- _this.params = {};
554
- _this.params["locTimeAggrSampleSize"] = eventsSampleSize;
555
- _this.params = _.extend({}, _this.params, returnInfo.getParams("locTimeAggr"));
556
- return _this;
557
- }
558
- return RequestEventsLocTimeAggr;
559
- }(RequestEvents));
560
- exports.RequestEventsLocTimeAggr = RequestEventsLocTimeAggr;
561
- /**
562
- * @class RequestEventsConceptAggr
563
- * Compute which concept are the most frequently occurring in the list of resulting events.
564
- */
565
- var RequestEventsConceptAggr = /** @class */ (function (_super) {
566
- __extends(RequestEventsConceptAggr, _super);
567
- function RequestEventsConceptAggr(args) {
568
- if (args === void 0) { args = {}; }
569
- var _this = _super.call(this) || this;
570
- _this.resultType = "conceptAggr";
571
- var _a = args.conceptCount, conceptCount = _a === void 0 ? 20 : _a, _b = args.eventsSampleSize, eventsSampleSize = _b === void 0 ? 100000 : _b, _c = args.returnInfo, returnInfo = _c === void 0 ? new returnInfo_1.ReturnInfo() : _c;
572
- if (conceptCount > 200) {
573
- throw new RangeError("At most 200 top concepts can be returned");
574
- }
575
- if (eventsSampleSize > 300000) {
576
- throw new RangeError("At most 300000 results can be used for computing");
577
- }
578
- _this.params = {};
579
- _this.params["conceptAggrConceptCount"] = conceptCount;
580
- _this.params["conceptAggrSampleSize"] = eventsSampleSize;
581
- _this.params = _.extend({}, _this.params, returnInfo.getParams("conceptAggr"));
582
- return _this;
583
- }
584
- return RequestEventsConceptAggr;
585
- }(RequestEvents));
586
- exports.RequestEventsConceptAggr = RequestEventsConceptAggr;
587
- /**
588
- * @class RequestEventsConceptGraph
589
- * Compute which concept pairs frequently co-occur together in the resulting events.
590
- */
591
- var RequestEventsConceptGraph = /** @class */ (function (_super) {
592
- __extends(RequestEventsConceptGraph, _super);
593
- function RequestEventsConceptGraph(args) {
594
- if (args === void 0) { args = {}; }
595
- var _this = _super.call(this) || this;
596
- _this.resultType = "conceptGraph";
597
- var _a = args.conceptCount, conceptCount = _a === void 0 ? 25 : _a, _b = args.linkCount, linkCount = _b === void 0 ? 150 : _b, _c = args.eventsSampleSize, eventsSampleSize = _c === void 0 ? 50000 : _c, _d = args.returnInfo, returnInfo = _d === void 0 ? new returnInfo_1.ReturnInfo() : _d;
598
- if (conceptCount > 1000) {
599
- throw new RangeError("At most 1000 top concepts can be returned");
600
- }
601
- if (linkCount > 2000) {
602
- throw new RangeError("At most 2000 links between concepts can be returned");
603
- }
604
- if (eventsSampleSize > 300000) {
605
- throw new RangeError("At most 300000 results can be used for computing");
606
- }
607
- _this.params = {};
608
- _this.params["conceptGraphConceptCount"] = conceptCount;
609
- _this.params["conceptGraphLinkCount"] = linkCount;
610
- _this.params["conceptGraphSampleSize"] = eventsSampleSize;
611
- _this.params = _.extend({}, _this.params, returnInfo.getParams("conceptGraph"));
612
- return _this;
613
- }
614
- return RequestEventsConceptGraph;
615
- }(RequestEvents));
616
- exports.RequestEventsConceptGraph = RequestEventsConceptGraph;
617
- /**
618
- * @class RequestEventsConceptMatrix
619
- * Get a matrix of concepts and their dependencies.
620
- * For individual concept pairs return how frequently
621
- * they co-occur in the resulting events and how "surprising" this is,
622
- * based on the frequency of individual concepts.
623
- */
624
- var RequestEventsConceptMatrix = /** @class */ (function (_super) {
625
- __extends(RequestEventsConceptMatrix, _super);
626
- function RequestEventsConceptMatrix(args) {
627
- if (args === void 0) { args = {}; }
628
- var _this = _super.call(this) || this;
629
- _this.resultType = "conceptMatrix";
630
- var _a = args.conceptCount, conceptCount = _a === void 0 ? 25 : _a, _b = args.measure, measure = _b === void 0 ? "pmi" : _b, _c = args.eventsSampleSize, eventsSampleSize = _c === void 0 ? 100000 : _c, _d = args.returnInfo, returnInfo = _d === void 0 ? new returnInfo_1.ReturnInfo() : _d;
631
- if (conceptCount > 200) {
632
- throw new RangeError("At most 200 top concepts can be returned");
633
- }
634
- if (eventsSampleSize > 300000) {
635
- throw new RangeError("At most 300000 results can be used for computing");
636
- }
637
- _this.params = {};
638
- _this.params["conceptMatrixConceptCount"] = conceptCount;
639
- _this.params["conceptMatrixMeasure"] = measure;
640
- _this.params["conceptMatrixSampleSize"] = eventsSampleSize;
641
- _this.params = _.extend({}, _this.params, returnInfo.getParams("conceptMatrix"));
642
- return _this;
643
- }
644
- return RequestEventsConceptMatrix;
645
- }(RequestEvents));
646
- exports.RequestEventsConceptMatrix = RequestEventsConceptMatrix;
647
- /**
648
- * @class RequestEventsConceptTrends
649
- * Return a list of top trending concepts and their daily trending info over time
650
- */
651
- var RequestEventsConceptTrends = /** @class */ (function (_super) {
652
- __extends(RequestEventsConceptTrends, _super);
653
- function RequestEventsConceptTrends(args) {
654
- if (args === void 0) { args = {}; }
655
- var _this = _super.call(this) || this;
656
- _this.resultType = "conceptTrends";
657
- var _a = args.conceptCount, conceptCount = _a === void 0 ? 10 : _a, _b = args.conceptUris, conceptUris = _b === void 0 ? [] : _b, _c = args.returnInfo, returnInfo = _c === void 0 ? new returnInfo_1.ReturnInfo() : _c;
658
- if (conceptCount > 50) {
659
- throw new RangeError("At most 50 top concepts can be returned");
660
- }
661
- _this.params = {};
662
- _this.params["conceptTrendsConceptCount"] = conceptCount;
663
- if (!_.isEmpty(conceptUris)) {
664
- _this.params["conceptTrendsConceptUri"] = conceptUris;
665
- }
666
- _this.params = _.extend({}, _this.params, returnInfo.getParams("conceptTrends"));
667
- return _this;
668
- }
669
- return RequestEventsConceptTrends;
670
- }(RequestEvents));
671
- exports.RequestEventsConceptTrends = RequestEventsConceptTrends;
672
- /**
673
- * @class RequestEventsSourceAggr
674
- * Return top news sources that report about the events that match the search conditions
675
- */
676
- var RequestEventsSourceAggr = /** @class */ (function (_super) {
677
- __extends(RequestEventsSourceAggr, _super);
678
- function RequestEventsSourceAggr(args) {
679
- if (args === void 0) { args = {}; }
680
- var _this = _super.call(this) || this;
681
- _this.resultType = "sourceAggr";
682
- var _a = args.sourceCount, sourceCount = _a === void 0 ? 30 : _a, _b = args.eventsSampleSize, eventsSampleSize = _b === void 0 ? 50000 : _b, _c = args.returnInfo, returnInfo = _c === void 0 ? new returnInfo_1.ReturnInfo() : _c;
683
- if (sourceCount > 200) {
684
- throw new RangeError("At most 200 top sources can be returned");
685
- }
686
- if (eventsSampleSize > 100000) {
687
- throw new RangeError("At most 100000 results can be used for computing");
688
- }
689
- _this.params = {};
690
- _this.params["sourceAggrSourceCount"] = sourceCount;
691
- _this.params["sourceAggrSampleSize"] = eventsSampleSize;
692
- _this.params = _.extend({}, _this.params, returnInfo.getParams("sourceAggr"));
693
- return _this;
694
- }
695
- return RequestEventsSourceAggr;
696
- }(RequestEvents));
697
- exports.RequestEventsSourceAggr = RequestEventsSourceAggr;
698
- /**
699
- * @class RequestEventsDateMentionAggr
700
- * Return events and the dates that are mentioned in articles about these events
701
- */
702
- var RequestEventsDateMentionAggr = /** @class */ (function (_super) {
703
- __extends(RequestEventsDateMentionAggr, _super);
704
- function RequestEventsDateMentionAggr(args) {
705
- if (args === void 0) { args = {}; }
706
- var _this = _super.call(this) || this;
707
- _this.resultType = "dateMentionAggr";
708
- var _a = args.minDaysApart, minDaysApart = _a === void 0 ? 0 : _a, _b = args.minDateMentionCount, minDateMentionCount = _b === void 0 ? 5 : _b, _c = args.eventsSampleSize, eventsSampleSize = _c === void 0 ? 100000 : _c, _d = args.returnInfo, returnInfo = _d === void 0 ? new returnInfo_1.ReturnInfo() : _d;
709
- if (eventsSampleSize > 300000) {
710
- throw new RangeError("At most 300000 results can be used for computing");
711
- }
712
- _this.params = {};
713
- _this.params["dateMentionAggrMinDaysApart"] = minDaysApart;
714
- _this.params["dateMentionAggrMinDateMentionCount"] = minDateMentionCount;
715
- _this.params["dateMentionAggrSampleSize"] = eventsSampleSize;
716
- _this.params = _.extend({}, _this.params, returnInfo.getParams("dateMentionAggr"));
717
- return _this;
718
- }
719
- return RequestEventsDateMentionAggr;
720
- }(RequestEvents));
721
- exports.RequestEventsDateMentionAggr = RequestEventsDateMentionAggr;
722
- /**
723
- * @class RequestEventsEventClusters
724
- * Return hierarchical clustering of events into smaller clusters. 2-means clustering is applied on each node in the tree
725
- */
726
- var RequestEventsEventClusters = /** @class */ (function (_super) {
727
- __extends(RequestEventsEventClusters, _super);
728
- function RequestEventsEventClusters(args) {
729
- if (args === void 0) { args = {}; }
730
- var _this = _super.call(this) || this;
731
- _this.resultType = "eventClusters";
732
- var _a = args.keywordCount, keywordCount = _a === void 0 ? 30 : _a, _b = args.maxEventsToCluster, maxEventsToCluster = _b === void 0 ? 10000 : _b, _c = args.returnInfo, returnInfo = _c === void 0 ? new returnInfo_1.ReturnInfo() : _c;
733
- if (keywordCount > 100) {
734
- throw new RangeError("At most 100 keywords can be reported in each of the clusters");
735
- }
736
- if (maxEventsToCluster > 10000) {
737
- throw new RangeError("At most 10000 events can be clustered together");
738
- }
739
- _this.params = {};
740
- _this.params["eventClustersKeywordCount"] = keywordCount;
741
- _this.params["eventClustersMaxEventsToCluster"] = maxEventsToCluster;
742
- _this.params = _.extend({}, _this.params, returnInfo.getParams("eventClusters"));
743
- return _this;
744
- }
745
- return RequestEventsEventClusters;
746
- }(RequestEvents));
747
- exports.RequestEventsEventClusters = RequestEventsEventClusters;
748
- /**
749
- * @class RequestEventsCategoryAggr
750
- * Return distribution of events into dmoz categories.
751
- */
752
- var RequestEventsCategoryAggr = /** @class */ (function (_super) {
753
- __extends(RequestEventsCategoryAggr, _super);
754
- function RequestEventsCategoryAggr(returnInfo) {
755
- if (returnInfo === void 0) { returnInfo = new returnInfo_1.ReturnInfo(); }
756
- var _this = _super.call(this) || this;
757
- _this.resultType = "categoryAggr";
758
- _this.params = returnInfo.getParams("categoryAggr");
759
- return _this;
760
- }
761
- return RequestEventsCategoryAggr;
762
- }(RequestEvents));
763
- exports.RequestEventsCategoryAggr = RequestEventsCategoryAggr;
764
- /**
765
- * @class RequestEventsRecentActivity
766
- * Return a list of recently changed events that match search conditions.
767
- */
768
- var RequestEventsRecentActivity = /** @class */ (function (_super) {
769
- __extends(RequestEventsRecentActivity, _super);
770
- function RequestEventsRecentActivity(args) {
771
- if (args === void 0) { args = {}; }
772
- var _this = _super.call(this) || this;
773
- _this.resultType = "recentActivityEvents";
774
- var _a = args.maxEventCount, maxEventCount = _a === void 0 ? 50 : _a, updatesAfterTm = args.updatesAfterTm, updatesAfterMinsAgo = args.updatesAfterMinsAgo, _b = args.mandatoryLocation, mandatoryLocation = _b === void 0 ? true : _b, _c = args.minAvgCosSim, minAvgCosSim = _c === void 0 ? 0 : _c, _d = args.returnInfo, returnInfo = _d === void 0 ? undefined : _d;
775
- if (maxEventCount > 2000) {
776
- throw new RangeError("At most 2000 events can be returned");
777
- }
778
- if (!_.isUndefined(updatesAfterTm) && !_.isUndefined(updatesAfterMinsAgo)) {
779
- throw new Error("You should specify either updatesAfterTm or updatesAfterMinsAgo parameter, but not both");
780
- }
781
- _this.params = {};
782
- _this.params["recentActivityEventsMaxEventCount"] = maxEventCount;
783
- _this.params["recentActivityEventsMandatoryLocation"] = mandatoryLocation;
784
- if (!_.isUndefined(updatesAfterTm)) {
785
- _this.params["recentActivityEventsUpdatesAfterTm"] = base_1.QueryParamsBase.encodeDateTime(updatesAfterTm);
786
- }
787
- if (!_.isUndefined(updatesAfterMinsAgo)) {
788
- _this.params["recentActivityEventsUpdatesAfterMinsAgo"] = updatesAfterMinsAgo;
789
- }
790
- _this.params["recentActivityEventsMinAvgCosSim"] = minAvgCosSim;
791
- if (!!returnInfo) {
792
- _this.params = _.extend({}, _this.params, returnInfo.getParams("recentActivityEvents"));
793
- }
794
- return _this;
795
- }
796
- return RequestEventsRecentActivity;
797
- }(RequestEvents));
798
- exports.RequestEventsRecentActivity = RequestEventsRecentActivity;
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
+ return new (P || (P = Promise))(function (resolve, reject) {
31
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
35
+ });
36
+ };
37
+ var __generator = (this && this.__generator) || function (thisArg, body) {
38
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
39
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
40
+ function verb(n) { return function (v) { return step([n, v]); }; }
41
+ function step(op) {
42
+ if (f) throw new TypeError("Generator is already executing.");
43
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
44
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
45
+ if (y = 0, t) op = [op[0] & 2, t.value];
46
+ switch (op[0]) {
47
+ case 0: case 1: t = op; break;
48
+ case 4: _.label++; return { value: op[1], done: false };
49
+ case 5: _.label++; y = op[1]; op = [0]; continue;
50
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
51
+ default:
52
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
53
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
54
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
55
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
56
+ if (t[2]) _.ops.pop();
57
+ _.trys.pop(); continue;
58
+ }
59
+ op = body.call(thisArg, _);
60
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
61
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
+ }
63
+ };
64
+ var __rest = (this && this.__rest) || function (s, e) {
65
+ var t = {};
66
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
67
+ t[p] = s[p];
68
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
69
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
70
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
71
+ t[p[i]] = s[p[i]];
72
+ }
73
+ return t;
74
+ };
75
+ var __read = (this && this.__read) || function (o, n) {
76
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
77
+ if (!m) return o;
78
+ var i = m.call(o), r, ar = [], e;
79
+ try {
80
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
81
+ }
82
+ catch (error) { e = { error: error }; }
83
+ finally {
84
+ try {
85
+ if (r && !r.done && (m = i["return"])) m.call(i);
86
+ }
87
+ finally { if (e) throw e.error; }
88
+ }
89
+ return ar;
90
+ };
91
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
92
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
93
+ if (ar || !(i in from)) {
94
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
95
+ ar[i] = from[i];
96
+ }
97
+ }
98
+ return to.concat(ar || Array.prototype.slice.call(from));
99
+ };
100
+ Object.defineProperty(exports, "__esModule", { value: true });
101
+ exports.RequestEventsRecentActivity = exports.RequestEventsCategoryAggr = exports.RequestEventsEventClusters = exports.RequestEventsDateMentionAggr = exports.RequestEventsSourceAggr = exports.RequestEventsConceptTrends = exports.RequestEventsConceptMatrix = exports.RequestEventsConceptGraph = exports.RequestEventsConceptAggr = exports.RequestEventsLocTimeAggr = exports.RequestEventsLocAggr = exports.RequestEventsKeywordAggr = exports.RequestEventsTimeAggr = exports.RequestEventsUriWgtList = exports.RequestEventsInfo = exports.RequestEvents = exports.QueryEventsIter = exports.QueryEvents = void 0;
102
+ var base_1 = require("./base");
103
+ var query_1 = require("./query");
104
+ var returnInfo_1 = require("./returnInfo");
105
+ var logger_1 = require("./logger");
106
+ /**
107
+ * @class QueryEvents
108
+ * Class for obtaining available info for one or more events in the Event Registry
109
+ */
110
+ var QueryEvents = /** @class */ (function (_super) {
111
+ __extends(QueryEvents, _super);
112
+ function QueryEvents(args) {
113
+ if (args === void 0) { args = {}; }
114
+ var _this = _super.call(this) || this;
115
+ _this.params = {};
116
+ var keywords = args.keywords, conceptUri = args.conceptUri, categoryUri = args.categoryUri, sourceUri = args.sourceUri, sourceLocationUri = args.sourceLocationUri, sourceGroupUri = args.sourceGroupUri, authorUri = args.authorUri, locationUri = args.locationUri, lang = args.lang, dateStart = args.dateStart, dateEnd = args.dateEnd, reportingDateStart = args.reportingDateStart, reportingDateEnd = args.reportingDateEnd, _a = args.minSentiment, minSentiment = _a === void 0 ? -1 : _a, _b = args.maxSentiment, maxSentiment = _b === void 0 ? 1 : _b, minArticlesInEvent = args.minArticlesInEvent, maxArticlesInEvent = args.maxArticlesInEvent, dateMentionStart = args.dateMentionStart, dateMentionEnd = args.dateMentionEnd, ignoreKeywords = args.ignoreKeywords, ignoreConceptUri = args.ignoreConceptUri, ignoreCategoryUri = args.ignoreCategoryUri, ignoreSourceUri = args.ignoreSourceUri, ignoreSourceLocationUri = args.ignoreSourceLocationUri, ignoreSourceGroupUri = args.ignoreSourceGroupUri, ignoreAuthorUri = args.ignoreAuthorUri, ignoreLocationUri = args.ignoreLocationUri, ignoreLang = args.ignoreLang, _c = args.keywordsLoc, keywordsLoc = _c === void 0 ? "body" : _c, _d = args.ignoreKeywordsLoc, ignoreKeywordsLoc = _d === void 0 ? "body" : _d, _e = args.keywordSearchMode, keywordSearchMode = _e === void 0 ? "phrase" : _e, _f = args.ignoreKeywordSearchMode, ignoreKeywordSearchMode = _f === void 0 ? "phrase" : _f, _g = args.categoryIncludeSub, categoryIncludeSub = _g === void 0 ? true : _g, _h = args.ignoreCategoryIncludeSub, ignoreCategoryIncludeSub = _h === void 0 ? true : _h, _j = args.requestedResult, requestedResult = _j === void 0 ? new RequestEventsInfo() : _j;
117
+ _this.setVal("action", "getEvents");
118
+ _this.setQueryArrVal(keywords, "keyword", "keywordOper", "and");
119
+ _this.setQueryArrVal(conceptUri, "conceptUri", "conceptOper", "and");
120
+ _this.setQueryArrVal(categoryUri, "categoryUri", "categoryOper", "or");
121
+ _this.setQueryArrVal(sourceUri, "sourceUri", undefined, "or");
122
+ _this.setQueryArrVal(sourceLocationUri, "sourceLocationUri", undefined, "or");
123
+ _this.setQueryArrVal(sourceGroupUri, "sourceGroupUri", undefined, "or");
124
+ _this.setQueryArrVal(authorUri, "authorUri", "authorOper", "or");
125
+ _this.setQueryArrVal(locationUri, "locationUri", undefined, "or");
126
+ _this.setQueryArrVal(lang, "lang", undefined, "or");
127
+ if (dateStart !== undefined) {
128
+ _this.setDateVal("dateStart", dateStart);
129
+ }
130
+ if (dateEnd !== undefined) {
131
+ _this.setDateVal("dateEnd", dateEnd);
132
+ }
133
+ if (reportingDateStart !== undefined) {
134
+ _this.setDateVal("reportingDateStart", reportingDateStart);
135
+ }
136
+ if (reportingDateEnd !== undefined) {
137
+ _this.setDateVal("reportingDateEnd", reportingDateEnd);
138
+ }
139
+ if (minSentiment > -1 && minSentiment <= 1) {
140
+ _this.setVal("minSentiment", minSentiment);
141
+ }
142
+ if (maxSentiment >= -1 && maxSentiment < 1) {
143
+ _this.setVal("maxSentiment", maxSentiment);
144
+ }
145
+ _this.setValIfNotDefault("minArticlesInEvent", minArticlesInEvent, undefined);
146
+ _this.setValIfNotDefault("maxArticlesInEvent", maxArticlesInEvent, undefined);
147
+ if (dateMentionStart !== undefined) {
148
+ _this.setDateVal("dateMentionStart", dateMentionStart);
149
+ }
150
+ if (dateMentionEnd !== undefined) {
151
+ _this.setDateVal("dateMentionEnd", dateMentionEnd);
152
+ }
153
+ // for the negative conditions, only the OR is a valid operator type
154
+ _this.setQueryArrVal(ignoreKeywords, "ignoreKeywords", undefined, "or");
155
+ _this.setQueryArrVal(ignoreConceptUri, "ignoreConceptUri", undefined, "or");
156
+ _this.setQueryArrVal(ignoreCategoryUri, "ignoreCategoryUri", undefined, "or");
157
+ _this.setQueryArrVal(ignoreSourceUri, "ignoreSourceUri", undefined, "or");
158
+ _this.setQueryArrVal(ignoreSourceLocationUri, "ignoreSourceLocationUri", undefined, "or");
159
+ _this.setQueryArrVal(ignoreSourceGroupUri, "ignoreSourceGroupUri", undefined, "or");
160
+ _this.setQueryArrVal(ignoreAuthorUri, "ignoreAuthorUri", undefined, "or");
161
+ _this.setQueryArrVal(ignoreLocationUri, "ignoreLocationUri", undefined, "or");
162
+ _this.setQueryArrVal(ignoreLang, "ignoreLang", undefined, "or");
163
+ _this.setValIfNotDefault("keywordLoc", keywordsLoc, "body");
164
+ _this.setValIfNotDefault("ignoreKeywordLoc", ignoreKeywordsLoc, "body");
165
+ _this.setValIfNotDefault("keywordSearchMode", keywordSearchMode, "phrase");
166
+ _this.setValIfNotDefault("ignoreKeywordSearchMode", ignoreKeywordSearchMode, "phrase");
167
+ _this.setValIfNotDefault("categoryIncludeSub", categoryIncludeSub, true);
168
+ _this.setValIfNotDefault("ignoreCategoryIncludeSub", ignoreCategoryIncludeSub, true);
169
+ _this.setRequestedResult(requestedResult);
170
+ return _this;
171
+ }
172
+ Object.defineProperty(QueryEvents.prototype, "path", {
173
+ get: function () {
174
+ return "/api/v1/event";
175
+ },
176
+ enumerable: false,
177
+ configurable: true
178
+ });
179
+ /**
180
+ * Set the single result type that you would like to be returned. Any previously set result types will be overwritten.
181
+ * Result types can be the classes that extend RequestEvent base class (see classes below).
182
+ */
183
+ QueryEvents.prototype.setRequestedResult = function (requestEvents) {
184
+ if (!(requestEvents instanceof RequestEvents)) {
185
+ throw new Error("QueryEvents class can only accept result requests that are of type RequestEvents");
186
+ }
187
+ this.resultTypeList = [
188
+ requestEvents,
189
+ ];
190
+ };
191
+ /**
192
+ * Set a custom list of event uris. The results will be then computed on this list - no query will be done (all conditions will be ignored).
193
+ */
194
+ QueryEvents.initWithEventUriList = function (uriList) {
195
+ var query = new QueryEvents();
196
+ if (!Array.isArray(uriList)) {
197
+ throw new Error("uriList has to be a list of strings that represent event uris");
198
+ }
199
+ query.params = {
200
+ action: "getEvents",
201
+ eventUriList: uriList.join(","),
202
+ };
203
+ return query;
204
+ };
205
+ QueryEvents.initWithEventUriWgtList = function (uriWgtList) {
206
+ var query = new QueryEvents();
207
+ if (!Array.isArray(uriWgtList)) {
208
+ throw new Error("uriWgtList has to be a list of strings that represent event uris");
209
+ }
210
+ query.params = {
211
+ action: "getEvents",
212
+ eventUriWgtList: uriWgtList.join(","),
213
+ };
214
+ return query;
215
+ };
216
+ QueryEvents.initWithComplexQuery = function (complexQuery) {
217
+ var query = new QueryEvents();
218
+ if (complexQuery instanceof query_1.ComplexEventQuery) {
219
+ query.setVal("query", JSON.stringify(complexQuery.getQuery()));
220
+ }
221
+ else if (typeof complexQuery === 'string') {
222
+ try {
223
+ JSON.parse(complexQuery);
224
+ }
225
+ catch (_a) {
226
+ logger_1.Logger.error("Failed to parse the provided string content as a JSON object. Please check the content provided as a parameter to the initWithComplexQuery() method");
227
+ }
228
+ query.setVal("query", complexQuery);
229
+ }
230
+ else if (typeof complexQuery === 'object' && complexQuery !== null) {
231
+ query.setVal("query", JSON.stringify(complexQuery));
232
+ }
233
+ else {
234
+ throw new Error("The instance of query parameter was not a ComplexEventQuery, a string or an object");
235
+ }
236
+ return query;
237
+ };
238
+ return QueryEvents;
239
+ }(base_1.Query));
240
+ exports.QueryEvents = QueryEvents;
241
+ /**
242
+ * @class QueryEventsIter
243
+ * Class for iterating through all the events via callbacks
244
+ */
245
+ var QueryEventsIter = /** @class */ (function (_super) {
246
+ __extends(QueryEventsIter, _super);
247
+ function QueryEventsIter(er, args) {
248
+ if (args === void 0) { args = {}; }
249
+ var _this = _super.call(this, args) || this;
250
+ _this.page = 0;
251
+ _this.pages = 1;
252
+ _this.items = [];
253
+ _this.returnedSoFar = 0;
254
+ _this.index = 0;
255
+ _this.callback = function () { return undefined; };
256
+ _this.doneCallback = function () { return undefined; };
257
+ var _a = args.sortBy, sortBy = _a === void 0 ? "rel" : _a, _b = args.sortByAsc, sortByAsc = _b === void 0 ? false : _b, _c = args.returnInfo, returnInfo = _c === void 0 ? undefined : _c, _d = args.maxItems, maxItems = _d === void 0 ? -1 : _d;
258
+ _this.er = er;
259
+ _this.sortBy = sortBy;
260
+ _this.sortByAsc = sortByAsc;
261
+ _this.returnInfo = returnInfo;
262
+ _this.maxItems = maxItems;
263
+ return _this;
264
+ }
265
+ /**
266
+ * Async Iterator function that returns the next item in the list of events
267
+ */
268
+ QueryEventsIter.prototype[Symbol.asyncIterator] = function () {
269
+ var _this = this;
270
+ return {
271
+ next: function () { return __awaiter(_this, void 0, void 0, function () {
272
+ var item;
273
+ return __generator(this, function (_a) {
274
+ switch (_a.label) {
275
+ case 0:
276
+ if (!(this.index >= this.items.length)) return [3 /*break*/, 2];
277
+ return [4 /*yield*/, this.getNextBatch()];
278
+ case 1:
279
+ _a.sent();
280
+ _a.label = 2;
281
+ case 2:
282
+ item = this.items[this.index];
283
+ this.index++;
284
+ return [2 /*return*/, { value: item, done: !item }];
285
+ }
286
+ });
287
+ }); },
288
+ };
289
+ };
290
+ QueryEventsIter.prototype.count = function () {
291
+ return __awaiter(this, void 0, void 0, function () {
292
+ var response;
293
+ var _a;
294
+ return __generator(this, function (_b) {
295
+ switch (_b.label) {
296
+ case 0:
297
+ this.setRequestedResult(new RequestEventsInfo());
298
+ return [4 /*yield*/, this.er.execQuery(this)];
299
+ case 1:
300
+ response = _b.sent();
301
+ if (response === null || response === void 0 ? void 0 : response.error) {
302
+ this.er.logger.error(response.error);
303
+ }
304
+ return [2 /*return*/, ((_a = response === null || response === void 0 ? void 0 : response.events) === null || _a === void 0 ? void 0 : _a.totalResults) || 0];
305
+ }
306
+ });
307
+ });
308
+ };
309
+ /**
310
+ * Execute query and fetch batches of events of the specified size (eventBatchSize)
311
+ * @param callback callback function that'll be called every time we get a new batch of events from the backend
312
+ * @param doneCallback callback function that'll be called when everything is complete
313
+ */
314
+ QueryEventsIter.prototype.execQuery = function (callback, doneCallback) {
315
+ if (callback) {
316
+ this.callback = callback;
317
+ }
318
+ if (doneCallback) {
319
+ this.doneCallback = doneCallback;
320
+ }
321
+ this.iterate();
322
+ };
323
+ QueryEventsIter.initWithComplexQuery = function (er, complexQuery, args) {
324
+ if (args === void 0) { args = {}; }
325
+ var query = new QueryEventsIter(er, args);
326
+ if (complexQuery instanceof query_1.ComplexEventQuery) {
327
+ query.setVal("query", JSON.stringify(complexQuery.getQuery()));
328
+ }
329
+ else if (typeof complexQuery === "string") {
330
+ query.setVal("query", complexQuery);
331
+ }
332
+ else if (typeof complexQuery === "object" && complexQuery !== null) {
333
+ query.setVal("query", JSON.stringify(complexQuery));
334
+ }
335
+ else {
336
+ throw new Error("The instance of query parameter was not a ComplexEventQuery, a string or an object");
337
+ }
338
+ return query;
339
+ };
340
+ QueryEventsIter.prototype.iterate = function () {
341
+ return __awaiter(this, void 0, void 0, function () {
342
+ return __generator(this, function (_a) {
343
+ switch (_a.label) {
344
+ case 0:
345
+ if (!this.current) return [3 /*break*/, 1];
346
+ this.callback(this.current);
347
+ this.index += 1;
348
+ return [3 /*break*/, 3];
349
+ case 1: return [4 /*yield*/, this.getNextBatch()];
350
+ case 2:
351
+ if (!(_a.sent())) {
352
+ this.doneCallback(this.errorMessage);
353
+ return [2 /*return*/];
354
+ }
355
+ _a.label = 3;
356
+ case 3: return [2 /*return*/, this.iterate()];
357
+ }
358
+ });
359
+ });
360
+ };
361
+ /**
362
+ * Extract the results according to maxItems
363
+ * @param response response from the backend
364
+ */
365
+ QueryEventsIter.prototype.extractResults = function (response) {
366
+ var _a;
367
+ var results = ((_a = response === null || response === void 0 ? void 0 : response.events) === null || _a === void 0 ? void 0 : _a.results) || [];
368
+ var extractedSize = this.maxItems !== -1 ? this.maxItems - this.returnedSoFar : results.length;
369
+ return results.slice(0, extractedSize).filter(Boolean);
370
+ };
371
+ Object.defineProperty(QueryEventsIter.prototype, "current", {
372
+ get: function () {
373
+ return this.items[this.index] || undefined;
374
+ },
375
+ enumerable: false,
376
+ configurable: true
377
+ });
378
+ QueryEventsIter.prototype.getNextBatch = function () {
379
+ return __awaiter(this, void 0, void 0, function () {
380
+ var requestEventsInfo, response, error, results, error_1;
381
+ var _a;
382
+ return __generator(this, function (_b) {
383
+ switch (_b.label) {
384
+ case 0:
385
+ _b.trys.push([0, 2, , 3]);
386
+ this.page += 1;
387
+ if (this.page > this.pages || (this.maxItems !== -1 && this.returnedSoFar >= this.maxItems)) {
388
+ return [2 /*return*/, false];
389
+ }
390
+ requestEventsInfo = new RequestEventsInfo({
391
+ page: this.page,
392
+ count: 50,
393
+ sortBy: this.sortBy,
394
+ sortByAsc: this.sortByAsc,
395
+ returnInfo: this.returnInfo,
396
+ });
397
+ this.setRequestedResult(requestEventsInfo);
398
+ if (this.er.verboseOutput) {
399
+ this.er.logger.info("Downloading event page ".concat(this.page, "..."));
400
+ }
401
+ return [4 /*yield*/, this.er.execQuery(this, this.er.allowUseOfArchive)];
402
+ case 1:
403
+ response = _b.sent();
404
+ error = response.error || "";
405
+ if (error) {
406
+ this.errorMessage = "Error while obtaining a list of events: ".concat(response.error);
407
+ }
408
+ else {
409
+ this.pages = ((_a = response.events) === null || _a === void 0 ? void 0 : _a.pages) || 0;
410
+ }
411
+ results = this.extractResults(response);
412
+ this.returnedSoFar += results.length;
413
+ this.items = __spreadArray(__spreadArray([], __read(this.items), false), __read(results), false);
414
+ return [2 /*return*/, true];
415
+ case 2:
416
+ error_1 = _b.sent();
417
+ this.er.logger.error(error_1);
418
+ return [2 /*return*/, false];
419
+ case 3: return [2 /*return*/];
420
+ }
421
+ });
422
+ });
423
+ };
424
+ return QueryEventsIter;
425
+ }(QueryEvents));
426
+ exports.QueryEventsIter = QueryEventsIter;
427
+ var RequestEvents = /** @class */ (function () {
428
+ function RequestEvents() {
429
+ }
430
+ return RequestEvents;
431
+ }());
432
+ exports.RequestEvents = RequestEvents;
433
+ /**
434
+ * @class RequestEventsInfo
435
+ * Return event details for resulting events.
436
+ */
437
+ var RequestEventsInfo = /** @class */ (function (_super) {
438
+ __extends(RequestEventsInfo, _super);
439
+ function RequestEventsInfo(args) {
440
+ if (args === void 0) { args = {}; }
441
+ var _this = _super.call(this) || this;
442
+ _this.resultType = "events";
443
+ var _a = args.page, page = _a === void 0 ? 1 : _a, _b = args.count, count = _b === void 0 ? 50 : _b, _c = args.sortBy, sortBy = _c === void 0 ? "rel" : _c, _d = args.sortByAsc, sortByAsc = _d === void 0 ? false : _d, _e = args.returnInfo, returnInfo = _e === void 0 ? undefined : _e;
444
+ if (page < 1) {
445
+ throw new RangeError("Page has to be >= 1");
446
+ }
447
+ if (count > 50) {
448
+ throw new RangeError("At most 50 events can be returned per call");
449
+ }
450
+ _this.params = {};
451
+ _this.params["eventsPage"] = page;
452
+ _this.params["eventsCount"] = count;
453
+ _this.params["eventsSortBy"] = sortBy;
454
+ _this.params["eventsSortByAsc"] = sortByAsc;
455
+ if (!!returnInfo) {
456
+ _this.params = __assign(__assign({}, _this.params), returnInfo.getParams("events"));
457
+ }
458
+ return _this;
459
+ }
460
+ return RequestEventsInfo;
461
+ }(RequestEvents));
462
+ exports.RequestEventsInfo = RequestEventsInfo;
463
+ /**
464
+ * @class RequestEventsUriList
465
+ * Return a simple list of event uris together with the scores for resulting events.
466
+ */
467
+ var RequestEventsUriWgtList = /** @class */ (function (_super) {
468
+ __extends(RequestEventsUriWgtList, _super);
469
+ function RequestEventsUriWgtList(args) {
470
+ if (args === void 0) { args = {}; }
471
+ var _this = _super.call(this) || this;
472
+ _this.resultType = "uriWgtList";
473
+ var _a = args.page, page = _a === void 0 ? 1 : _a, _b = args.count, count = _b === void 0 ? 50000 : _b, _c = args.sortBy, sortBy = _c === void 0 ? "rel" : _c, _d = args.sortByAsc, sortByAsc = _d === void 0 ? false : _d, unsupported = __rest(args, ["page", "count", "sortBy", "sortByAsc"]);
474
+ if (Object.keys(unsupported).length !== 0) {
475
+ logger_1.Logger.warn("RequestEventsUriWgtList: Unsupported parameters detected: ".concat(JSON.stringify(unsupported), ". Please check the documentation."));
476
+ }
477
+ if (page < 1) {
478
+ throw new RangeError("Page has to be >= 1");
479
+ }
480
+ if (count > 100000) {
481
+ throw new RangeError("At most 100000 results can be returned per call");
482
+ }
483
+ _this.params = {};
484
+ _this.params["uriWgtListPage"] = page;
485
+ _this.params["uriWgtListCount"] = count;
486
+ _this.params["uriWgtListSortBy"] = sortBy;
487
+ _this.params["uriWgtListSortByAsc"] = sortByAsc;
488
+ return _this;
489
+ }
490
+ Object.defineProperty(RequestEventsUriWgtList.prototype, "page", {
491
+ set: function (page) {
492
+ if (page < 1) {
493
+ throw new RangeError("Page has to be >= 1");
494
+ }
495
+ this.params["uriWgtListPage"] = page;
496
+ },
497
+ enumerable: false,
498
+ configurable: true
499
+ });
500
+ return RequestEventsUriWgtList;
501
+ }(RequestEvents));
502
+ exports.RequestEventsUriWgtList = RequestEventsUriWgtList;
503
+ /**
504
+ * @class RequestEventsTimeAggr
505
+ * Return time distribution of resulting events.
506
+ */
507
+ var RequestEventsTimeAggr = /** @class */ (function (_super) {
508
+ __extends(RequestEventsTimeAggr, _super);
509
+ function RequestEventsTimeAggr() {
510
+ var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
511
+ _this.resultType = "timeAggr";
512
+ return _this;
513
+ }
514
+ return RequestEventsTimeAggr;
515
+ }(RequestEvents));
516
+ exports.RequestEventsTimeAggr = RequestEventsTimeAggr;
517
+ /**
518
+ * Return keyword aggregate (tag cloud) on words in articles in resulting events.
519
+ * @class RequestEventsTimeAggr
520
+ */
521
+ var RequestEventsKeywordAggr = /** @class */ (function (_super) {
522
+ __extends(RequestEventsKeywordAggr, _super);
523
+ /**
524
+ * @param lang: in which language to produce the list of top keywords. If undefined, then compute on all articles
525
+ */
526
+ function RequestEventsKeywordAggr(lang) {
527
+ var _this = _super.call(this) || this;
528
+ _this.resultType = "keywordAggr";
529
+ _this.params = {};
530
+ if (lang !== undefined) {
531
+ _this.params["keywordAggrLang"] = lang;
532
+ }
533
+ return _this;
534
+ }
535
+ return RequestEventsKeywordAggr;
536
+ }(RequestEvents));
537
+ exports.RequestEventsKeywordAggr = RequestEventsKeywordAggr;
538
+ /**
539
+ * @class RequestEventsLocAggr
540
+ * Return aggregate of locations of resulting events.
541
+ */
542
+ var RequestEventsLocAggr = /** @class */ (function (_super) {
543
+ __extends(RequestEventsLocAggr, _super);
544
+ function RequestEventsLocAggr(args) {
545
+ if (args === void 0) { args = {}; }
546
+ var _this = _super.call(this) || this;
547
+ _this.resultType = "locAggr";
548
+ var _a = args.eventsSampleSize, eventsSampleSize = _a === void 0 ? 100000 : _a, _b = args.returnInfo, returnInfo = _b === void 0 ? new returnInfo_1.ReturnInfo() : _b, unsupported = __rest(args, ["eventsSampleSize", "returnInfo"]);
549
+ if (Object.keys(unsupported).length !== 0) {
550
+ logger_1.Logger.warn("RequestEventsLocAggr: Unsupported parameters detected: ".concat(JSON.stringify(unsupported), ". Please check the documentation."));
551
+ }
552
+ if (eventsSampleSize > 100000) {
553
+ throw new RangeError("At most 100000 results can be used for computing");
554
+ }
555
+ _this.params = {};
556
+ _this.params["locAggrSampleSize"] = eventsSampleSize;
557
+ _this.params = __assign(__assign({}, _this.params), returnInfo.getParams("locAggr"));
558
+ return _this;
559
+ }
560
+ return RequestEventsLocAggr;
561
+ }(RequestEvents));
562
+ exports.RequestEventsLocAggr = RequestEventsLocAggr;
563
+ /**
564
+ * @class RequestEventsLocTimeAggr
565
+ * Return aggregate of locations and times of resulting events.
566
+ */
567
+ var RequestEventsLocTimeAggr = /** @class */ (function (_super) {
568
+ __extends(RequestEventsLocTimeAggr, _super);
569
+ function RequestEventsLocTimeAggr(args) {
570
+ if (args === void 0) { args = {}; }
571
+ var _this = _super.call(this) || this;
572
+ _this.resultType = "locTimeAggr";
573
+ var _a = args.eventsSampleSize, eventsSampleSize = _a === void 0 ? 100000 : _a, _b = args.returnInfo, returnInfo = _b === void 0 ? new returnInfo_1.ReturnInfo() : _b, unsupported = __rest(args, ["eventsSampleSize", "returnInfo"]);
574
+ if (Object.keys(unsupported).length !== 0) {
575
+ logger_1.Logger.warn("RequestEventsLocTimeAggr: Unsupported parameters detected: ".concat(JSON.stringify(unsupported), ". Please check the documentation."));
576
+ }
577
+ if (eventsSampleSize > 100000) {
578
+ throw new RangeError("At most 100000 results can be used for computing");
579
+ }
580
+ _this.params = {};
581
+ _this.params["locTimeAggrSampleSize"] = eventsSampleSize;
582
+ _this.params = __assign(__assign({}, _this.params), returnInfo.getParams("locTimeAggr"));
583
+ return _this;
584
+ }
585
+ return RequestEventsLocTimeAggr;
586
+ }(RequestEvents));
587
+ exports.RequestEventsLocTimeAggr = RequestEventsLocTimeAggr;
588
+ /**
589
+ * @class RequestEventsConceptAggr
590
+ * Compute which concept are the most frequently occurring in the list of resulting events.
591
+ */
592
+ var RequestEventsConceptAggr = /** @class */ (function (_super) {
593
+ __extends(RequestEventsConceptAggr, _super);
594
+ function RequestEventsConceptAggr(args) {
595
+ if (args === void 0) { args = {}; }
596
+ var _this = _super.call(this) || this;
597
+ _this.resultType = "conceptAggr";
598
+ var _a = args.conceptCount, conceptCount = _a === void 0 ? 20 : _a, _b = args.eventsSampleSize, eventsSampleSize = _b === void 0 ? 100000 : _b, _c = args.returnInfo, returnInfo = _c === void 0 ? new returnInfo_1.ReturnInfo() : _c;
599
+ if (conceptCount > 200) {
600
+ throw new RangeError("At most 200 top concepts can be returned");
601
+ }
602
+ if (eventsSampleSize > 300000) {
603
+ throw new RangeError("At most 300000 results can be used for computing");
604
+ }
605
+ _this.params = {};
606
+ _this.params["conceptAggrConceptCount"] = conceptCount;
607
+ _this.params["conceptAggrSampleSize"] = eventsSampleSize;
608
+ _this.params = __assign(__assign({}, _this.params), returnInfo.getParams("conceptAggr"));
609
+ return _this;
610
+ }
611
+ return RequestEventsConceptAggr;
612
+ }(RequestEvents));
613
+ exports.RequestEventsConceptAggr = RequestEventsConceptAggr;
614
+ /**
615
+ * @class RequestEventsConceptGraph
616
+ * Compute which concept pairs frequently co-occur together in the resulting events.
617
+ */
618
+ var RequestEventsConceptGraph = /** @class */ (function (_super) {
619
+ __extends(RequestEventsConceptGraph, _super);
620
+ function RequestEventsConceptGraph(args) {
621
+ if (args === void 0) { args = {}; }
622
+ var _this = _super.call(this) || this;
623
+ _this.resultType = "conceptGraph";
624
+ var _a = args.conceptCount, conceptCount = _a === void 0 ? 25 : _a, _b = args.linkCount, linkCount = _b === void 0 ? 150 : _b, _c = args.eventsSampleSize, eventsSampleSize = _c === void 0 ? 50000 : _c, _d = args.returnInfo, returnInfo = _d === void 0 ? new returnInfo_1.ReturnInfo() : _d;
625
+ if (conceptCount > 1000) {
626
+ throw new RangeError("At most 1000 top concepts can be returned");
627
+ }
628
+ if (linkCount > 2000) {
629
+ throw new RangeError("At most 2000 links between concepts can be returned");
630
+ }
631
+ if (eventsSampleSize > 300000) {
632
+ throw new RangeError("At most 300000 results can be used for computing");
633
+ }
634
+ _this.params = {};
635
+ _this.params["conceptGraphConceptCount"] = conceptCount;
636
+ _this.params["conceptGraphLinkCount"] = linkCount;
637
+ _this.params["conceptGraphSampleSize"] = eventsSampleSize;
638
+ _this.params = __assign(__assign({}, _this.params), returnInfo.getParams("conceptGraph"));
639
+ return _this;
640
+ }
641
+ return RequestEventsConceptGraph;
642
+ }(RequestEvents));
643
+ exports.RequestEventsConceptGraph = RequestEventsConceptGraph;
644
+ /**
645
+ * @class RequestEventsConceptMatrix
646
+ * Get a matrix of concepts and their dependencies.
647
+ * For individual concept pairs return how frequently
648
+ * they co-occur in the resulting events and how "surprising" this is,
649
+ * based on the frequency of individual concepts.
650
+ */
651
+ var RequestEventsConceptMatrix = /** @class */ (function (_super) {
652
+ __extends(RequestEventsConceptMatrix, _super);
653
+ function RequestEventsConceptMatrix(args) {
654
+ if (args === void 0) { args = {}; }
655
+ var _this = _super.call(this) || this;
656
+ _this.resultType = "conceptMatrix";
657
+ var _a = args.conceptCount, conceptCount = _a === void 0 ? 25 : _a, _b = args.measure, measure = _b === void 0 ? "pmi" : _b, _c = args.eventsSampleSize, eventsSampleSize = _c === void 0 ? 100000 : _c, _d = args.returnInfo, returnInfo = _d === void 0 ? new returnInfo_1.ReturnInfo() : _d;
658
+ if (conceptCount > 200) {
659
+ throw new RangeError("At most 200 top concepts can be returned");
660
+ }
661
+ if (eventsSampleSize > 300000) {
662
+ throw new RangeError("At most 300000 results can be used for computing");
663
+ }
664
+ _this.params = {};
665
+ _this.params["conceptMatrixConceptCount"] = conceptCount;
666
+ _this.params["conceptMatrixMeasure"] = measure;
667
+ _this.params["conceptMatrixSampleSize"] = eventsSampleSize;
668
+ _this.params = __assign(__assign({}, _this.params), returnInfo.getParams("conceptMatrix"));
669
+ return _this;
670
+ }
671
+ return RequestEventsConceptMatrix;
672
+ }(RequestEvents));
673
+ exports.RequestEventsConceptMatrix = RequestEventsConceptMatrix;
674
+ /**
675
+ * @class RequestEventsConceptTrends
676
+ * Return a list of top trending concepts and their daily trending info over time
677
+ */
678
+ var RequestEventsConceptTrends = /** @class */ (function (_super) {
679
+ __extends(RequestEventsConceptTrends, _super);
680
+ function RequestEventsConceptTrends(args) {
681
+ if (args === void 0) { args = {}; }
682
+ var _this = _super.call(this) || this;
683
+ _this.resultType = "conceptTrends";
684
+ var _a = args.conceptCount, conceptCount = _a === void 0 ? 10 : _a, _b = args.conceptUris, conceptUris = _b === void 0 ? [] : _b, _c = args.returnInfo, returnInfo = _c === void 0 ? new returnInfo_1.ReturnInfo() : _c;
685
+ if (conceptCount > 50) {
686
+ throw new RangeError("At most 50 top concepts can be returned");
687
+ }
688
+ _this.params = {};
689
+ _this.params["conceptTrendsConceptCount"] = conceptCount;
690
+ if (conceptUris.length > 0) {
691
+ _this.params["conceptTrendsConceptUri"] = conceptUris;
692
+ }
693
+ _this.params = __assign(__assign({}, _this.params), returnInfo.getParams("conceptTrends"));
694
+ return _this;
695
+ }
696
+ return RequestEventsConceptTrends;
697
+ }(RequestEvents));
698
+ exports.RequestEventsConceptTrends = RequestEventsConceptTrends;
699
+ /**
700
+ * @class RequestEventsSourceAggr
701
+ * Return top news sources that report about the events that match the search conditions
702
+ */
703
+ var RequestEventsSourceAggr = /** @class */ (function (_super) {
704
+ __extends(RequestEventsSourceAggr, _super);
705
+ function RequestEventsSourceAggr(args) {
706
+ if (args === void 0) { args = {}; }
707
+ var _this = _super.call(this) || this;
708
+ _this.resultType = "sourceAggr";
709
+ var _a = args.sourceCount, sourceCount = _a === void 0 ? 30 : _a, _b = args.eventsSampleSize, eventsSampleSize = _b === void 0 ? 50000 : _b, _c = args.returnInfo, returnInfo = _c === void 0 ? new returnInfo_1.ReturnInfo() : _c;
710
+ if (sourceCount > 200) {
711
+ throw new RangeError("At most 200 top sources can be returned");
712
+ }
713
+ if (eventsSampleSize > 100000) {
714
+ throw new RangeError("At most 100000 results can be used for computing");
715
+ }
716
+ _this.params = {};
717
+ _this.params["sourceAggrSourceCount"] = sourceCount;
718
+ _this.params["sourceAggrSampleSize"] = eventsSampleSize;
719
+ _this.params = __assign(__assign({}, _this.params), returnInfo.getParams("sourceAggr"));
720
+ return _this;
721
+ }
722
+ return RequestEventsSourceAggr;
723
+ }(RequestEvents));
724
+ exports.RequestEventsSourceAggr = RequestEventsSourceAggr;
725
+ /**
726
+ * @class RequestEventsDateMentionAggr
727
+ * Return events and the dates that are mentioned in articles about these events
728
+ */
729
+ var RequestEventsDateMentionAggr = /** @class */ (function (_super) {
730
+ __extends(RequestEventsDateMentionAggr, _super);
731
+ function RequestEventsDateMentionAggr(args) {
732
+ if (args === void 0) { args = {}; }
733
+ var _this = _super.call(this) || this;
734
+ _this.resultType = "dateMentionAggr";
735
+ var _a = args.minDaysApart, minDaysApart = _a === void 0 ? 0 : _a, _b = args.minDateMentionCount, minDateMentionCount = _b === void 0 ? 5 : _b, _c = args.eventsSampleSize, eventsSampleSize = _c === void 0 ? 100000 : _c, _d = args.returnInfo, returnInfo = _d === void 0 ? new returnInfo_1.ReturnInfo() : _d;
736
+ if (eventsSampleSize > 300000) {
737
+ throw new RangeError("At most 300000 results can be used for computing");
738
+ }
739
+ _this.params = {};
740
+ _this.params["dateMentionAggrMinDaysApart"] = minDaysApart;
741
+ _this.params["dateMentionAggrMinDateMentionCount"] = minDateMentionCount;
742
+ _this.params["dateMentionAggrSampleSize"] = eventsSampleSize;
743
+ _this.params = __assign(__assign({}, _this.params), returnInfo.getParams("dateMentionAggr"));
744
+ return _this;
745
+ }
746
+ return RequestEventsDateMentionAggr;
747
+ }(RequestEvents));
748
+ exports.RequestEventsDateMentionAggr = RequestEventsDateMentionAggr;
749
+ /**
750
+ * @class RequestEventsEventClusters
751
+ * Return hierarchical clustering of events into smaller clusters. 2-means clustering is applied on each node in the tree
752
+ */
753
+ var RequestEventsEventClusters = /** @class */ (function (_super) {
754
+ __extends(RequestEventsEventClusters, _super);
755
+ function RequestEventsEventClusters(args) {
756
+ if (args === void 0) { args = {}; }
757
+ var _this = _super.call(this) || this;
758
+ _this.resultType = "eventClusters";
759
+ var _a = args.keywordCount, keywordCount = _a === void 0 ? 30 : _a, _b = args.maxEventsToCluster, maxEventsToCluster = _b === void 0 ? 10000 : _b, _c = args.returnInfo, returnInfo = _c === void 0 ? new returnInfo_1.ReturnInfo() : _c;
760
+ if (keywordCount > 100) {
761
+ throw new RangeError("At most 100 keywords can be reported in each of the clusters");
762
+ }
763
+ if (maxEventsToCluster > 10000) {
764
+ throw new RangeError("At most 10000 events can be clustered together");
765
+ }
766
+ _this.params = {};
767
+ _this.params["eventClustersKeywordCount"] = keywordCount;
768
+ _this.params["eventClustersMaxEventsToCluster"] = maxEventsToCluster;
769
+ _this.params = __assign(__assign({}, _this.params), returnInfo.getParams("eventClusters"));
770
+ return _this;
771
+ }
772
+ return RequestEventsEventClusters;
773
+ }(RequestEvents));
774
+ exports.RequestEventsEventClusters = RequestEventsEventClusters;
775
+ /**
776
+ * @class RequestEventsCategoryAggr
777
+ * Return distribution of events into dmoz categories.
778
+ */
779
+ var RequestEventsCategoryAggr = /** @class */ (function (_super) {
780
+ __extends(RequestEventsCategoryAggr, _super);
781
+ function RequestEventsCategoryAggr(returnInfo) {
782
+ if (returnInfo === void 0) { returnInfo = new returnInfo_1.ReturnInfo(); }
783
+ var _this = _super.call(this) || this;
784
+ _this.resultType = "categoryAggr";
785
+ _this.params = returnInfo.getParams("categoryAggr");
786
+ return _this;
787
+ }
788
+ return RequestEventsCategoryAggr;
789
+ }(RequestEvents));
790
+ exports.RequestEventsCategoryAggr = RequestEventsCategoryAggr;
791
+ /**
792
+ * @class RequestEventsRecentActivity
793
+ * Return a list of recently changed events that match search conditions.
794
+ */
795
+ var RequestEventsRecentActivity = /** @class */ (function (_super) {
796
+ __extends(RequestEventsRecentActivity, _super);
797
+ function RequestEventsRecentActivity(args) {
798
+ if (args === void 0) { args = {}; }
799
+ var _this = _super.call(this) || this;
800
+ _this.resultType = "recentActivityEvents";
801
+ var _a = args.maxEventCount, maxEventCount = _a === void 0 ? 50 : _a, updatesAfterTm = args.updatesAfterTm, updatesAfterMinsAgo = args.updatesAfterMinsAgo, _b = args.mandatoryLocation, mandatoryLocation = _b === void 0 ? true : _b, _c = args.minAvgCosSim, minAvgCosSim = _c === void 0 ? 0 : _c, _d = args.returnInfo, returnInfo = _d === void 0 ? undefined : _d;
802
+ if (maxEventCount > 2000) {
803
+ throw new RangeError("At most 2000 events can be returned");
804
+ }
805
+ if (updatesAfterTm !== undefined && updatesAfterMinsAgo !== undefined) {
806
+ throw new Error("You should specify either updatesAfterTm or updatesAfterMinsAgo parameter, but not both");
807
+ }
808
+ _this.params = {};
809
+ _this.params["recentActivityEventsMaxEventCount"] = maxEventCount;
810
+ _this.params["recentActivityEventsMandatoryLocation"] = mandatoryLocation;
811
+ if (updatesAfterTm !== undefined) {
812
+ _this.params["recentActivityEventsUpdatesAfterTm"] = base_1.QueryParamsBase.encodeDateTime(updatesAfterTm);
813
+ }
814
+ if (updatesAfterMinsAgo !== undefined) {
815
+ _this.params["recentActivityEventsUpdatesAfterMinsAgo"] = updatesAfterMinsAgo;
816
+ }
817
+ _this.params["recentActivityEventsMinAvgCosSim"] = minAvgCosSim;
818
+ if (!!returnInfo) {
819
+ _this.params = __assign(__assign({}, _this.params), returnInfo.getParams("recentActivityEvents"));
820
+ }
821
+ return _this;
822
+ }
823
+ return RequestEventsRecentActivity;
824
+ }(RequestEvents));
825
+ exports.RequestEventsRecentActivity = RequestEventsRecentActivity;
799
826
  //# sourceMappingURL=queryEvents.js.map