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,601 +1,638 @@
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 returnInfo_1 = require("./returnInfo");
83
- var QueryMentions = /** @class */ (function (_super) {
84
- __extends(QueryMentions, _super);
85
- function QueryMentions(args) {
86
- if (args === void 0) { args = {}; }
87
- var _this = _super.call(this) || this;
88
- _this.params = {};
89
- var eventTypeUri = args.eventTypeUri, keywords = args.keywords, conceptUri = args.conceptUri, categoryUri = args.categoryUri, sourceUri = args.sourceUri, sourceLocationUri = args.sourceLocationUri, sourceGroupUri = args.sourceGroupUri, industryUri = args.industryUri, locationUri = args.locationUri, lang = args.lang, dateStart = args.dateStart, dateEnd = args.dateEnd, ignoreEventTypeUri = args.ignoreEventTypeUri, ignoreKeywords = args.ignoreKeywords, ignoreConceptUri = args.ignoreConceptUri, ignoreCategoryUri = args.ignoreCategoryUri, ignoreSourceUri = args.ignoreSourceUri, ignoreSourceLocationUri = args.ignoreSourceLocationUri, ignoreSourceGroupUri = args.ignoreSourceGroupUri, ignoreIndustryUri = args.ignoreIndustryUri, ignoreLocationUri = args.ignoreLocationUri, ignoreLang = args.ignoreLang, showDuplicates = args.showDuplicates, _a = args.startSourceRankPercentile, startSourceRankPercentile = _a === void 0 ? 0 : _a, _b = args.endSourceRankPercentile, endSourceRankPercentile = _b === void 0 ? 100 : _b, _c = args.minSentiment, minSentiment = _c === void 0 ? -1 : _c, _d = args.maxSentiment, maxSentiment = _d === void 0 ? 1 : _d, _e = args.requestedResult, requestedResult = _e === void 0 ? new RequestMentions() : _e;
90
- _this.setVal("action", "getMentions");
91
- _this.setQueryArrVal(eventTypeUri, "eventTypeUri", undefined, "or");
92
- _this.setQueryArrVal(keywords, "keyword", "keywordOper", "and");
93
- _this.setQueryArrVal(conceptUri, "conceptUri", "conceptOper", "and");
94
- _this.setQueryArrVal(categoryUri, "categoryUri", "categoryOper", "or");
95
- _this.setQueryArrVal(sourceUri, "sourceUri", undefined, "or");
96
- _this.setQueryArrVal(sourceLocationUri, "sourceLocationUri", undefined, "or");
97
- _this.setQueryArrVal(sourceGroupUri, "sourceGroupUri", undefined, "or");
98
- _this.setQueryArrVal(industryUri, "industryUri", "industryOper", "or");
99
- _this.setQueryArrVal(locationUri, "locationUri", undefined, "or");
100
- _this.setQueryArrVal(lang, "lang", undefined, "or");
101
- if (!_.isUndefined(dateStart)) {
102
- _this.setDateVal("dateStart", dateStart);
103
- }
104
- if (!_.isUndefined(dateEnd)) {
105
- _this.setDateVal("dateEnd", dateEnd);
106
- }
107
- _this.setQueryArrVal(ignoreEventTypeUri, "ignoreEventTypeUri", undefined, "or");
108
- _this.setQueryArrVal(ignoreKeywords, "ignoreKeywords", undefined, "or");
109
- _this.setQueryArrVal(ignoreConceptUri, "ignoreConceptUri", undefined, "or");
110
- _this.setQueryArrVal(ignoreCategoryUri, "ignoreCategoryUri", undefined, "or");
111
- _this.setQueryArrVal(ignoreSourceUri, "ignoreSourceUri", undefined, "or");
112
- _this.setQueryArrVal(ignoreSourceLocationUri, "ignoreSourceLocationUri", undefined, "or");
113
- _this.setQueryArrVal(ignoreSourceGroupUri, "ignoreSourceGroupUri", undefined, "or");
114
- _this.setQueryArrVal(ignoreIndustryUri, "ignoreIndustryUri", undefined, "or");
115
- _this.setQueryArrVal(ignoreLocationUri, "ignoreLocationUri", undefined, "or");
116
- _this.setQueryArrVal(ignoreLang, "ignoreLang", undefined, "or");
117
- _this.setValIfNotDefault("showDuplicates", showDuplicates, false);
118
- if (startSourceRankPercentile < 0 || startSourceRankPercentile % 10 !== 0 || startSourceRankPercentile > 100) {
119
- throw new Error("StartSourceRankPercentile: Value should be in range 0-90 and divisible by 10.");
120
- }
121
- if (endSourceRankPercentile < 0 || endSourceRankPercentile % 10 !== 0 || endSourceRankPercentile > 100) {
122
- throw new Error("EndSourceRankPercentile: Value should be in range 0-90 and divisible by 10.");
123
- }
124
- if (startSourceRankPercentile > endSourceRankPercentile) {
125
- throw new Error("SourceRankPercentile: startSourceRankPercentile should be less than endSourceRankPercentile");
126
- }
127
- if (startSourceRankPercentile !== 0) {
128
- _this.setVal("startSourceRankPercentile", startSourceRankPercentile);
129
- }
130
- if (endSourceRankPercentile !== 100) {
131
- _this.setVal("endSourceRankPercentile", endSourceRankPercentile);
132
- }
133
- if (minSentiment > -1 && minSentiment <= 1) {
134
- _this.setVal("minSentiment", minSentiment);
135
- }
136
- if (maxSentiment >= -1 && maxSentiment < 1) {
137
- _this.setVal("maxSentiment", maxSentiment);
138
- }
139
- _this.setRequestedResult(requestedResult);
140
- return _this;
141
- }
142
- Object.defineProperty(QueryMentions.prototype, "path", {
143
- get: function () {
144
- return "/api/v1/eventType/mention";
145
- },
146
- enumerable: true,
147
- configurable: true
148
- });
149
- /**
150
- * Set the single result type that you would like to be returned. Any previously set result types will be overwritten.
151
- * Result types can be the classes that extend RequestMentions base class (see classes below).
152
- */
153
- QueryMentions.prototype.setRequestedResult = function (requestMentions) {
154
- if (!(requestMentions instanceof RequestMentions)) {
155
- throw new Error("QueryMentions class can only accept result requests that are of type RequestMentions");
156
- }
157
- this.resultTypeList = [
158
- requestMentions,
159
- ];
160
- };
161
- QueryMentions.initWithMentionUriList = function (uriList) {
162
- var q = new QueryMentions();
163
- if (!_.isArray(uriList)) {
164
- throw new Error("uriList has to be a list of strings that represent mention uris");
165
- }
166
- q.params = {
167
- action: "getMentions",
168
- mentionUri: uriList,
169
- };
170
- };
171
- QueryMentions.initWithMentionUriWgtList = function (uriWgtList) {
172
- var q = new QueryMentions();
173
- if (!_.isArray(uriWgtList)) {
174
- throw new Error("uriList has to be a list of strings that represent mention uris");
175
- }
176
- q.params = {
177
- action: "getMentions",
178
- mentionUriWgtList: _.join(uriWgtList, ","),
179
- };
180
- return q;
181
- };
182
- QueryMentions.initWithComplexQuery = function (complexQuery) {
183
- var query = new QueryMentions();
184
- if (_.isString(complexQuery)) {
185
- query.setVal("query", complexQuery);
186
- }
187
- else if (_.isObject(complexQuery)) {
188
- query.setVal("query", JSON.stringify(complexQuery));
189
- }
190
- else {
191
- throw new Error("The instance of query parameter was not a string or an object");
192
- }
193
- return query;
194
- };
195
- return QueryMentions;
196
- }(base_1.Query));
197
- exports.QueryMentions = QueryMentions;
198
- var QueryMentionsIter = /** @class */ (function (_super) {
199
- __extends(QueryMentionsIter, _super);
200
- function QueryMentionsIter(er, args) {
201
- if (args === void 0) { args = {}; }
202
- var _this = _super.call(this, args) || this;
203
- _this.page = 0;
204
- _this.pages = 1;
205
- _this.items = [];
206
- _this.returnedSoFar = 0;
207
- _this.index = 0;
208
- _this.callback = _.noop;
209
- _this.doneCallback = _.noop;
210
- 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;
211
- _this.er = er;
212
- _this.sortBy = sortBy;
213
- _this.sortByAsc = sortByAsc;
214
- _this.returnInfo = returnInfo;
215
- _this.maxItems = maxItems;
216
- return _this;
217
- }
218
- QueryMentionsIter.prototype[Symbol.asyncIterator] = function () {
219
- var _this = this;
220
- return {
221
- next: function () { return __awaiter(_this, void 0, void 0, function () {
222
- var item;
223
- return __generator(this, function (_a) {
224
- switch (_a.label) {
225
- case 0:
226
- if (!(this.index >= this.items.length)) return [3 /*break*/, 2];
227
- return [4 /*yield*/, this.getNextBatch()];
228
- case 1:
229
- _a.sent();
230
- _a.label = 2;
231
- case 2:
232
- item = this.items[this.index];
233
- this.index++;
234
- return [2 /*return*/, { value: item, done: !item }];
235
- }
236
- });
237
- }); },
238
- };
239
- };
240
- QueryMentionsIter.prototype.count = function () {
241
- return __awaiter(this, void 0, void 0, function () {
242
- var response;
243
- return __generator(this, function (_a) {
244
- switch (_a.label) {
245
- case 0:
246
- this.setRequestedResult(new RequestMentionsInfo());
247
- return [4 /*yield*/, this.er.execQuery(this)];
248
- case 1:
249
- response = _a.sent();
250
- if (_.has(response, "error")) {
251
- console.error(_.get(response, "error"));
252
- }
253
- return [2 /*return*/, _.get(response, "mentions.totalResults", 0)];
254
- }
255
- });
256
- });
257
- };
258
- /**
259
- * Execute query and fetch batches of articles of the specified size (eventBatchSize)
260
- * @param callback callback function that'll be called every time we get a new batch of events from the backend
261
- * @param doneCallback callback function that'll be called when everything is complete
262
- */
263
- QueryMentionsIter.prototype.execQuery = function (callback, doneCallback) {
264
- if (callback) {
265
- this.callback = callback;
266
- }
267
- if (doneCallback) {
268
- this.doneCallback = doneCallback;
269
- }
270
- this.iterate();
271
- };
272
- QueryMentionsIter.initWithComplexQuery = function (er, complexQuery, args) {
273
- if (args === void 0) { args = {}; }
274
- var query = new QueryMentionsIter(er, args);
275
- if (_.isString(complexQuery)) {
276
- query.setVal("query", complexQuery);
277
- }
278
- else if (_.isObject(complexQuery)) {
279
- query.setVal("query", JSON.stringify(complexQuery));
280
- }
281
- else {
282
- throw new Error("The instance of query parameter was not a string or an object");
283
- }
284
- return query;
285
- };
286
- QueryMentionsIter.prototype.iterate = function () {
287
- return __awaiter(this, void 0, void 0, function () {
288
- return __generator(this, function (_a) {
289
- switch (_a.label) {
290
- case 0:
291
- if (!this.current) return [3 /*break*/, 1];
292
- this.callback(this.current);
293
- this.index += 1;
294
- return [3 /*break*/, 3];
295
- case 1: return [4 /*yield*/, this.getNextBatch()];
296
- case 2:
297
- if (!(_a.sent())) {
298
- this.doneCallback(this.errorMessage);
299
- return [2 /*return*/];
300
- }
301
- _a.label = 3;
302
- case 3: return [2 /*return*/, this.iterate()];
303
- }
304
- });
305
- });
306
- };
307
- /**
308
- * Extract the results according to maxItems
309
- * @param response response from the backend
310
- */
311
- QueryMentionsIter.prototype.extractResults = function (response) {
312
- var results = _.get(response, "mentions.results", []);
313
- var extractedSize = this.maxItems !== -1 ? this.maxItems - this.returnedSoFar : _.size(results);
314
- return _.compact(_.pullAt(results, _.range(0, extractedSize)));
315
- };
316
- Object.defineProperty(QueryMentionsIter.prototype, "current", {
317
- get: function () {
318
- return this.items[this.index] || undefined;
319
- },
320
- enumerable: true,
321
- configurable: true
322
- });
323
- QueryMentionsIter.prototype.getNextBatch = function () {
324
- return __awaiter(this, void 0, void 0, function () {
325
- var requestMentionsInfo, response, error, results, error_1;
326
- return __generator(this, function (_a) {
327
- switch (_a.label) {
328
- case 0:
329
- _a.trys.push([0, 2, , 3]);
330
- this.page += 1;
331
- if (this.page > this.pages || (this.maxItems !== -1 && this.returnedSoFar >= this.maxItems)) {
332
- return [2 /*return*/, false];
333
- }
334
- requestMentionsInfo = new RequestMentionsInfo({
335
- page: this.page,
336
- count: 50,
337
- sortBy: this.sortBy,
338
- sortByAsc: this.sortByAsc,
339
- returnInfo: this.returnInfo,
340
- });
341
- this.setRequestedResult(requestMentionsInfo);
342
- if (this.er.verboseOutput) {
343
- console.log("Downloading mentions page " + this.page + "...");
344
- }
345
- return [4 /*yield*/, this.er.execQuery(this, this.er.allowUseOfArchive)];
346
- case 1:
347
- response = _a.sent();
348
- error = _.get(response, "error", "");
349
- if (error) {
350
- this.errorMessage = "Error while obtaining a list of mentions: " + _.get(response, "error");
351
- }
352
- else {
353
- this.pages = _.get(response, "mentions.pages", 0);
354
- }
355
- results = this.extractResults(response);
356
- this.returnedSoFar += _.size(results);
357
- this.items = __spread(this.items, results);
358
- return [2 /*return*/, true];
359
- case 2:
360
- error_1 = _a.sent();
361
- console.error(error_1);
362
- return [2 /*return*/, false];
363
- case 3: return [2 /*return*/];
364
- }
365
- });
366
- });
367
- };
368
- return QueryMentionsIter;
369
- }(QueryMentions));
370
- exports.QueryMentionsIter = QueryMentionsIter;
371
- var RequestMentions = /** @class */ (function () {
372
- function RequestMentions() {
373
- }
374
- return RequestMentions;
375
- }());
376
- exports.RequestMentions = RequestMentions;
377
- var RequestMentionsInfo = /** @class */ (function (_super) {
378
- __extends(RequestMentionsInfo, _super);
379
- function RequestMentionsInfo(args) {
380
- if (args === void 0) { args = {}; }
381
- var _this = _super.call(this) || this;
382
- _this.resultType = "mentions";
383
- var _a = args.page, page = _a === void 0 ? 1 : _a, _b = args.count, count = _b === void 0 ? 100 : _b, _c = args.sortBy, sortBy = _c === void 0 ? "date" : _c, _d = args.sortByAsc, sortByAsc = _d === void 0 ? false : _d, _e = args.returnInfo, returnInfo = _e === void 0 ? undefined : _e;
384
- if (page < 1) {
385
- throw new RangeError("Page has to be >= 1");
386
- }
387
- if (count > 100) {
388
- throw new RangeError("At most 100 mentions can be returned per call");
389
- }
390
- _this.params = {};
391
- _this.params["mentionsPage"] = page;
392
- _this.params["mentionsCount"] = count;
393
- _this.params["mentionsSortBy"] = sortBy;
394
- _this.params["mentionsSortByAsc"] = sortByAsc;
395
- if (!!returnInfo) {
396
- _this.params = _.extend({}, _this.params, returnInfo.getParams("mentions"));
397
- }
398
- return _this;
399
- }
400
- Object.defineProperty(RequestMentionsInfo.prototype, "page", {
401
- set: function (page) {
402
- if (page < 1) {
403
- throw new RangeError("Page has to be >= 1");
404
- }
405
- _.set(this.params, "mentionsPage", page);
406
- },
407
- enumerable: true,
408
- configurable: true
409
- });
410
- return RequestMentionsInfo;
411
- }(RequestMentions));
412
- exports.RequestMentionsInfo = RequestMentionsInfo;
413
- var RequestMentionsUriWgtList = /** @class */ (function (_super) {
414
- __extends(RequestMentionsUriWgtList, _super);
415
- function RequestMentionsUriWgtList(args) {
416
- if (args === void 0) { args = {}; }
417
- var _this = _super.call(this) || this;
418
- _this.resultType = "uriWgtList";
419
- var _a = args.page, page = _a === void 0 ? 1 : _a, _b = args.count, count = _b === void 0 ? 10000 : _b, _c = args.sortBy, sortBy = _c === void 0 ? "fq" : _c, _d = args.sortByAsc, sortByAsc = _d === void 0 ? false : _d, unsupported = __rest(args, ["page", "count", "sortBy", "sortByAsc"]);
420
- if (!_.isEmpty(unsupported)) {
421
- console.warn("RequestMentionsUriWgtList: Unsupported parameters detected: " + JSON.stringify(unsupported) + ". Please check the documentation.");
422
- }
423
- if (page < 1) {
424
- throw new RangeError("Page has to be >= 1");
425
- }
426
- if (count > 50000) {
427
- throw new RangeError("At most 50000 results can be returned per call");
428
- }
429
- _this.params = {};
430
- _this.params["uriWgtListPage"] = page;
431
- _this.params["uriWgtListCount"] = count;
432
- _this.params["uriWgtListSortBy"] = sortBy;
433
- _this.params["uriWgtListSortByAsc"] = sortByAsc;
434
- return _this;
435
- }
436
- Object.defineProperty(RequestMentionsUriWgtList.prototype, "page", {
437
- set: function (page) {
438
- if (page < 1) {
439
- throw new RangeError("Page has to be >= 1");
440
- }
441
- _.set(this.params, "uriWgtListPage", page);
442
- },
443
- enumerable: true,
444
- configurable: true
445
- });
446
- return RequestMentionsUriWgtList;
447
- }(RequestMentions));
448
- exports.RequestMentionsUriWgtList = RequestMentionsUriWgtList;
449
- var RequestMentionsTimeAggr = /** @class */ (function (_super) {
450
- __extends(RequestMentionsTimeAggr, _super);
451
- function RequestMentionsTimeAggr() {
452
- var _this = _super !== null && _super.apply(this, arguments) || this;
453
- _this.resultType = "timeAggr";
454
- return _this;
455
- }
456
- return RequestMentionsTimeAggr;
457
- }(RequestMentions));
458
- exports.RequestMentionsTimeAggr = RequestMentionsTimeAggr;
459
- var RequestMentionsConceptAggr = /** @class */ (function (_super) {
460
- __extends(RequestMentionsConceptAggr, _super);
461
- function RequestMentionsConceptAggr(args) {
462
- if (args === void 0) { args = {}; }
463
- var _this = _super.call(this) || this;
464
- _this.resultType = "conceptAggr";
465
- var _a = args.conceptCount, conceptCount = _a === void 0 ? 25 : _a, _b = args.mentionsSampleSize, mentionsSampleSize = _b === void 0 ? 100000 : _b, _c = args.conceptScoring, conceptScoring = _c === void 0 ? "importance" : _c, _d = args.conceptCountPerType, conceptCountPerType = _d === void 0 ? undefined : _d, _e = args.returnInfo, returnInfo = _e === void 0 ? new returnInfo_1.ReturnInfo() : _e;
466
- if (conceptCount > 500) {
467
- throw new RangeError("At most 500 top concepts can be returned");
468
- }
469
- if (mentionsSampleSize > 20000) {
470
- throw new RangeError("At most 20000 results can be used for computing");
471
- }
472
- _this.params = {};
473
- _this.params["conceptAggrConceptCount"] = conceptCount;
474
- _this.params["conceptAggrSampleSize"] = mentionsSampleSize;
475
- _this.params["conceptAggrScoring"] = conceptScoring;
476
- if (!!conceptCountPerType) {
477
- _this.params["conceptAggrConceptCountPerType"] = conceptCountPerType;
478
- }
479
- _this.params = _.extend({}, _this.params, returnInfo.getParams("conceptAggr"));
480
- return _this;
481
- }
482
- return RequestMentionsConceptAggr;
483
- }(RequestMentions));
484
- exports.RequestMentionsConceptAggr = RequestMentionsConceptAggr;
485
- var RequestMentionsCategoryAggr = /** @class */ (function (_super) {
486
- __extends(RequestMentionsCategoryAggr, _super);
487
- function RequestMentionsCategoryAggr(args) {
488
- if (args === void 0) { args = {}; }
489
- var _this = _super.call(this) || this;
490
- _this.resultType = "categoryAggr";
491
- var _a = args.mentionsSampleSize, mentionsSampleSize = _a === void 0 ? 20000 : _a, _b = args.returnInfo, returnInfo = _b === void 0 ? new returnInfo_1.ReturnInfo() : _b;
492
- if (mentionsSampleSize > 50000) {
493
- throw new RangeError("At most 50000 results can be used for aggregation");
494
- }
495
- _this.params["categoryAggrSampleSize"] = mentionsSampleSize;
496
- _this.params = returnInfo.getParams("categoryAggr");
497
- return _this;
498
- }
499
- return RequestMentionsCategoryAggr;
500
- }(RequestMentions));
501
- exports.RequestMentionsCategoryAggr = RequestMentionsCategoryAggr;
502
- var RequestMentionsSourceAggr = /** @class */ (function (_super) {
503
- __extends(RequestMentionsSourceAggr, _super);
504
- function RequestMentionsSourceAggr(args) {
505
- if (args === void 0) { args = {}; }
506
- var _this = _super.call(this) || this;
507
- _this.resultType = "sourceAggr";
508
- var _a = args.sourceCount, sourceCount = _a === void 0 ? 50 : _a, _b = args.normalizeBySourceArts, normalizeBySourceArts = _b === void 0 ? false : _b, _c = args.returnInfo, returnInfo = _c === void 0 ? new returnInfo_1.ReturnInfo() : _c;
509
- _this.params["sourceAggrSourceCount"] = sourceCount;
510
- _this.params = returnInfo.getParams("sourceAggr");
511
- return _this;
512
- }
513
- return RequestMentionsSourceAggr;
514
- }(RequestMentions));
515
- exports.RequestMentionsSourceAggr = RequestMentionsSourceAggr;
516
- var RequestMentionsKeywordAggr = /** @class */ (function (_super) {
517
- __extends(RequestMentionsKeywordAggr, _super);
518
- function RequestMentionsKeywordAggr(args) {
519
- if (args === void 0) { args = {}; }
520
- var _this = _super.call(this) || this;
521
- _this.resultType = "keywordAggr";
522
- var _a = args.mentionsSampleSize, mentionsSampleSize = _a === void 0 ? 2000 : _a;
523
- if (mentionsSampleSize > 20000) {
524
- throw new RangeError("At most 20000 results can be used for aggregation");
525
- }
526
- _this.params["keywordAggrSampleSize"] = mentionsSampleSize;
527
- return _this;
528
- }
529
- return RequestMentionsKeywordAggr;
530
- }(RequestMentions));
531
- exports.RequestMentionsKeywordAggr = RequestMentionsKeywordAggr;
532
- var RequestMentionsConceptGraph = /** @class */ (function (_super) {
533
- __extends(RequestMentionsConceptGraph, _super);
534
- function RequestMentionsConceptGraph(args) {
535
- if (args === void 0) { args = {}; }
536
- var _this = _super.call(this) || this;
537
- _this.resultType = "conceptGraph";
538
- var _a = args.conceptCount, conceptCount = _a === void 0 ? 25 : _a, _b = args.linkCount, linkCount = _b === void 0 ? 50 : _b, _c = args.mentionsSampleSize, mentionsSampleSize = _c === void 0 ? 10000 : _c, _d = args.skipQueryConcepts, skipQueryConcepts = _d === void 0 ? true : _d, _e = args.returnInfo, returnInfo = _e === void 0 ? new returnInfo_1.ReturnInfo() : _e;
539
- if (conceptCount > 1000) {
540
- throw new RangeError("At most 1000 top concepts can be returned");
541
- }
542
- if (linkCount > 2000) {
543
- throw new RangeError("At most 2000 links between concepts can be returned");
544
- }
545
- if (mentionsSampleSize > 50000) {
546
- throw new RangeError("At most 50000 results can be used for computing");
547
- }
548
- _this.params = {};
549
- _this.params["conceptGraphConceptCount"] = conceptCount;
550
- _this.params["conceptGraphLinkCount"] = linkCount;
551
- _this.params["conceptGraphSampleSize"] = mentionsSampleSize;
552
- _this.params["conceptGraphSkipQueryConcepts"] = skipQueryConcepts;
553
- _this.params = _.extend({}, _this.params, returnInfo.getParams("conceptGraph"));
554
- return _this;
555
- }
556
- return RequestMentionsConceptGraph;
557
- }(RequestMentions));
558
- exports.RequestMentionsConceptGraph = RequestMentionsConceptGraph;
559
- var RequestMentionsRecentActivity = /** @class */ (function (_super) {
560
- __extends(RequestMentionsRecentActivity, _super);
561
- function RequestMentionsRecentActivity(args) {
562
- if (args === void 0) { args = {}; }
563
- var _this = _super.call(this) || this;
564
- _this.resultType = "recentActivityMentions";
565
- var _a = args.maxMentionCount, maxMentionCount = _a === void 0 ? 100 : _a, _b = args.updatesAfterUri, updatesAfterUri = _b === void 0 ? undefined : _b, _c = args.updatesAfterTm, updatesAfterTm = _c === void 0 ? undefined : _c, _d = args.updatesAfterMinsAgo, updatesAfterMinsAgo = _d === void 0 ? undefined : _d, _e = args.updatesUntilTm, updatesUntilTm = _e === void 0 ? undefined : _e, _f = args.updatesUntilMinsAgo, updatesUntilMinsAgo = _f === void 0 ? undefined : _f, _g = args.mandatorySourceLocation, mandatorySourceLocation = _g === void 0 ? false : _g, _h = args.returnInfo, returnInfo = _h === void 0 ? undefined : _h;
566
- if (maxMentionCount > 2000) {
567
- throw new RangeError("At most 2000 mentions can be returned");
568
- }
569
- if (!_.isUndefined(updatesAfterTm) && !_.isUndefined(updatesAfterMinsAgo)) {
570
- throw new Error("You should specify either updatesAfterTm or updatesAfterMinsAgo parameter, but not both");
571
- }
572
- if (!_.isUndefined(updatesUntilTm) && !_.isUndefined(updatesUntilMinsAgo)) {
573
- throw new Error("You should specify either updatesUntilTm or updatesUntilMinsAgo parameter, but not both");
574
- }
575
- _this.params = {};
576
- _this.params["recentActivityMentionsMaxMentionCount"] = maxMentionCount;
577
- if (!_.isUndefined(updatesAfterTm)) {
578
- _this.params["recentActivityMentionsUpdatesAfterTm"] = base_1.QueryParamsBase.encodeDateTime(updatesAfterTm);
579
- }
580
- if (!_.isUndefined(updatesAfterMinsAgo)) {
581
- _this.params["recentActivityMentionsUpdatesAfterMinsAgo"] = updatesAfterMinsAgo;
582
- }
583
- if (!_.isUndefined(updatesUntilTm)) {
584
- _this.params["recentActivityMentionsUpdatesUntilTm"] = base_1.QueryParamsBase.encodeDateTime(updatesUntilTm);
585
- }
586
- if (!_.isUndefined(updatesUntilMinsAgo)) {
587
- _this.params["recentActivityMentionsUpdatesUntilMinsAgo"] = updatesUntilMinsAgo;
588
- }
589
- if (!_.isUndefined(updatesAfterUri)) {
590
- _this.params["recentActivityMentionsUpdatesAfterUri"] = updatesAfterUri;
591
- }
592
- _this.params["recentActivityMentionsMandatorySourceLocation"] = mandatorySourceLocation;
593
- if (!_.isUndefined(returnInfo)) {
594
- _this.params = _.extend({}, _this.params, returnInfo.getParams("recentActivityMentions"));
595
- }
596
- return _this;
597
- }
598
- return RequestMentionsRecentActivity;
599
- }(RequestMentions));
600
- exports.RequestMentionsRecentActivity = RequestMentionsRecentActivity;
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.RequestMentionsRecentActivity = exports.RequestMentionsConceptGraph = exports.RequestMentionsKeywordAggr = exports.RequestMentionsSourceAggr = exports.RequestMentionsCategoryAggr = exports.RequestMentionsConceptAggr = exports.RequestMentionsTimeAggr = exports.RequestMentionsUriWgtList = exports.RequestMentionsInfo = exports.RequestMentions = exports.QueryMentionsIter = exports.QueryMentions = void 0;
102
+ var base_1 = require("./base");
103
+ var returnInfo_1 = require("./returnInfo");
104
+ var logger_1 = require("./logger");
105
+ var QueryMentions = /** @class */ (function (_super) {
106
+ __extends(QueryMentions, _super);
107
+ function QueryMentions(args) {
108
+ if (args === void 0) { args = {}; }
109
+ var _this = _super.call(this) || this;
110
+ _this.params = {};
111
+ var eventTypeUri = args.eventTypeUri, keywords = args.keywords, conceptUri = args.conceptUri, categoryUri = args.categoryUri, sourceUri = args.sourceUri, sourceLocationUri = args.sourceLocationUri, sourceGroupUri = args.sourceGroupUri, industryUri = args.industryUri, sdgUri = args.sdgUri, sasbUri = args.sasbUri, esgUri = args.esgUri, locationUri = args.locationUri, lang = args.lang, dateStart = args.dateStart, dateEnd = args.dateEnd, ignoreEventTypeUri = args.ignoreEventTypeUri, ignoreKeywords = args.ignoreKeywords, ignoreConceptUri = args.ignoreConceptUri, ignoreCategoryUri = args.ignoreCategoryUri, ignoreSourceUri = args.ignoreSourceUri, ignoreSourceLocationUri = args.ignoreSourceLocationUri, ignoreSourceGroupUri = args.ignoreSourceGroupUri, ignoreIndustryUri = args.ignoreIndustryUri, ignoreSdgUri = args.ignoreSdgUri, ignoreSasbUri = args.ignoreSasbUri, ignoreEsgUri = args.ignoreEsgUri, ignoreLocationUri = args.ignoreLocationUri, ignoreLang = args.ignoreLang, showDuplicates = args.showDuplicates, _a = args.startSourceRankPercentile, startSourceRankPercentile = _a === void 0 ? 0 : _a, _b = args.endSourceRankPercentile, endSourceRankPercentile = _b === void 0 ? 100 : _b, _c = args.minSentiment, minSentiment = _c === void 0 ? -1 : _c, _d = args.maxSentiment, maxSentiment = _d === void 0 ? 1 : _d, minSentenceIndex = args.minSentenceIndex, maxSentenceIndex = args.maxSentenceIndex, _e = args.requestedResult, requestedResult = _e === void 0 ? new RequestMentions() : _e;
112
+ _this.setVal("action", "getMentions");
113
+ _this.setQueryArrVal(eventTypeUri, "eventTypeUri", undefined, "or");
114
+ _this.setQueryArrVal(keywords, "keyword", "keywordOper", "and");
115
+ _this.setQueryArrVal(conceptUri, "conceptUri", "conceptOper", "and");
116
+ _this.setQueryArrVal(categoryUri, "categoryUri", "categoryOper", "or");
117
+ _this.setQueryArrVal(sourceUri, "sourceUri", undefined, "or");
118
+ _this.setQueryArrVal(sourceLocationUri, "sourceLocationUri", undefined, "or");
119
+ _this.setQueryArrVal(sourceGroupUri, "sourceGroupUri", undefined, "or");
120
+ _this.setQueryArrVal(industryUri, "industryUri", "industryOper", "or");
121
+ _this.setQueryArrVal(sdgUri, "sdgUri", undefined, "or");
122
+ _this.setQueryArrVal(sasbUri, "sasbUri", undefined, "or");
123
+ _this.setQueryArrVal(esgUri, "esgUri", undefined, "or");
124
+ _this.setQueryArrVal(locationUri, "locationUri", undefined, "or");
125
+ _this.setQueryArrVal(lang, "lang", undefined, "or");
126
+ if (dateStart !== undefined) {
127
+ _this.setDateVal("dateStart", dateStart);
128
+ }
129
+ if (dateEnd !== undefined) {
130
+ _this.setDateVal("dateEnd", dateEnd);
131
+ }
132
+ _this.setQueryArrVal(ignoreEventTypeUri, "ignoreEventTypeUri", undefined, "or");
133
+ _this.setQueryArrVal(ignoreKeywords, "ignoreKeywords", undefined, "or");
134
+ _this.setQueryArrVal(ignoreConceptUri, "ignoreConceptUri", undefined, "or");
135
+ _this.setQueryArrVal(ignoreCategoryUri, "ignoreCategoryUri", undefined, "or");
136
+ _this.setQueryArrVal(ignoreSourceUri, "ignoreSourceUri", undefined, "or");
137
+ _this.setQueryArrVal(ignoreSourceLocationUri, "ignoreSourceLocationUri", undefined, "or");
138
+ _this.setQueryArrVal(ignoreSourceGroupUri, "ignoreSourceGroupUri", undefined, "or");
139
+ _this.setQueryArrVal(ignoreIndustryUri, "ignoreIndustryUri", undefined, "or");
140
+ _this.setQueryArrVal(ignoreSdgUri, "ignoreSdgUri", undefined, "or");
141
+ _this.setQueryArrVal(ignoreSasbUri, "ignoreSasbUri", undefined, "or");
142
+ _this.setQueryArrVal(ignoreEsgUri, "ignoreEsgUri", undefined, "or");
143
+ _this.setQueryArrVal(ignoreLocationUri, "ignoreLocationUri", undefined, "or");
144
+ _this.setQueryArrVal(ignoreLang, "ignoreLang", undefined, "or");
145
+ _this.setValIfNotDefault("showDuplicates", showDuplicates, false);
146
+ if (startSourceRankPercentile < 0 || startSourceRankPercentile % 10 !== 0 || startSourceRankPercentile > 100) {
147
+ throw new Error("StartSourceRankPercentile: Value should be in range 0-90 and divisible by 10.");
148
+ }
149
+ if (endSourceRankPercentile < 0 || endSourceRankPercentile % 10 !== 0 || endSourceRankPercentile > 100) {
150
+ throw new Error("EndSourceRankPercentile: Value should be in range 0-90 and divisible by 10.");
151
+ }
152
+ if (startSourceRankPercentile > endSourceRankPercentile) {
153
+ throw new Error("SourceRankPercentile: startSourceRankPercentile should be less than endSourceRankPercentile");
154
+ }
155
+ if (startSourceRankPercentile !== 0) {
156
+ _this.setVal("startSourceRankPercentile", startSourceRankPercentile);
157
+ }
158
+ if (endSourceRankPercentile !== 100) {
159
+ _this.setVal("endSourceRankPercentile", endSourceRankPercentile);
160
+ }
161
+ if (minSentiment > -1 && minSentiment <= 1) {
162
+ _this.setVal("minSentiment", minSentiment);
163
+ }
164
+ if (maxSentiment >= -1 && maxSentiment < 1) {
165
+ _this.setVal("maxSentiment", maxSentiment);
166
+ }
167
+ if (!!minSentenceIndex && minSentenceIndex > 0) {
168
+ _this.setVal("minSentenceIndex", minSentenceIndex);
169
+ }
170
+ if (!!maxSentenceIndex && maxSentenceIndex > 0) {
171
+ _this.setVal("maxSentenceIndex", maxSentenceIndex);
172
+ }
173
+ _this.setRequestedResult(requestedResult);
174
+ return _this;
175
+ }
176
+ Object.defineProperty(QueryMentions.prototype, "path", {
177
+ get: function () {
178
+ return "/api/v1/eventType/mention";
179
+ },
180
+ enumerable: false,
181
+ configurable: true
182
+ });
183
+ /**
184
+ * Set the single result type that you would like to be returned. Any previously set result types will be overwritten.
185
+ * Result types can be the classes that extend RequestMentions base class (see classes below).
186
+ */
187
+ QueryMentions.prototype.setRequestedResult = function (requestMentions) {
188
+ if (!(requestMentions instanceof RequestMentions)) {
189
+ throw new Error("QueryMentions class can only accept result requests that are of type RequestMentions");
190
+ }
191
+ this.resultTypeList = [
192
+ requestMentions,
193
+ ];
194
+ };
195
+ QueryMentions.initWithMentionUriList = function (uriList) {
196
+ var q = new QueryMentions();
197
+ if (!Array.isArray(uriList)) {
198
+ throw new Error("uriList has to be a list of strings that represent mention uris");
199
+ }
200
+ q.params = {
201
+ action: "getMentions",
202
+ mentionUri: uriList,
203
+ };
204
+ };
205
+ QueryMentions.initWithMentionUriWgtList = function (uriWgtList) {
206
+ var q = new QueryMentions();
207
+ if (!Array.isArray(uriWgtList)) {
208
+ throw new Error("uriList has to be a list of strings that represent mention uris");
209
+ }
210
+ q.params = {
211
+ action: "getMentions",
212
+ mentionUriWgtList: uriWgtList.join(","),
213
+ };
214
+ return q;
215
+ };
216
+ QueryMentions.initWithComplexQuery = function (complexQuery) {
217
+ var query = new QueryMentions();
218
+ if (typeof complexQuery === "string") {
219
+ query.setVal("query", complexQuery);
220
+ }
221
+ else if (typeof complexQuery === "object" && complexQuery !== null) {
222
+ query.setVal("query", JSON.stringify(complexQuery));
223
+ }
224
+ else {
225
+ throw new Error("The instance of query parameter was not a string or an object");
226
+ }
227
+ return query;
228
+ };
229
+ return QueryMentions;
230
+ }(base_1.Query));
231
+ exports.QueryMentions = QueryMentions;
232
+ var QueryMentionsIter = /** @class */ (function (_super) {
233
+ __extends(QueryMentionsIter, _super);
234
+ function QueryMentionsIter(er, args) {
235
+ if (args === void 0) { args = {}; }
236
+ var _this = _super.call(this, args) || this;
237
+ _this.page = 0;
238
+ _this.pages = 1;
239
+ _this.items = [];
240
+ _this.returnedSoFar = 0;
241
+ _this.index = 0;
242
+ _this.callback = function () { };
243
+ _this.doneCallback = function () { };
244
+ 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;
245
+ _this.er = er;
246
+ _this.sortBy = sortBy;
247
+ _this.sortByAsc = sortByAsc;
248
+ _this.returnInfo = returnInfo;
249
+ _this.maxItems = maxItems;
250
+ return _this;
251
+ }
252
+ QueryMentionsIter.prototype[Symbol.asyncIterator] = function () {
253
+ var _this = this;
254
+ return {
255
+ next: function () { return __awaiter(_this, void 0, void 0, function () {
256
+ var item;
257
+ return __generator(this, function (_a) {
258
+ switch (_a.label) {
259
+ case 0:
260
+ if (!(this.index >= this.items.length)) return [3 /*break*/, 2];
261
+ return [4 /*yield*/, this.getNextBatch()];
262
+ case 1:
263
+ _a.sent();
264
+ _a.label = 2;
265
+ case 2:
266
+ item = this.items[this.index];
267
+ this.index++;
268
+ return [2 /*return*/, { value: item, done: !item }];
269
+ }
270
+ });
271
+ }); },
272
+ };
273
+ };
274
+ QueryMentionsIter.prototype.count = function () {
275
+ return __awaiter(this, void 0, void 0, function () {
276
+ var response;
277
+ var _a;
278
+ return __generator(this, function (_b) {
279
+ switch (_b.label) {
280
+ case 0:
281
+ this.setRequestedResult(new RequestMentionsInfo());
282
+ return [4 /*yield*/, this.er.execQuery(this)];
283
+ case 1:
284
+ response = _b.sent();
285
+ if (response === null || response === void 0 ? void 0 : response.error) {
286
+ this.er.logger.error(response.error);
287
+ }
288
+ return [2 /*return*/, ((_a = response.mentions) === null || _a === void 0 ? void 0 : _a.totalResults) || 0];
289
+ }
290
+ });
291
+ });
292
+ };
293
+ /**
294
+ * Execute query and fetch batches of articles of the specified size (eventBatchSize)
295
+ * @param callback callback function that'll be called every time we get a new batch of events from the backend
296
+ * @param doneCallback callback function that'll be called when everything is complete
297
+ */
298
+ QueryMentionsIter.prototype.execQuery = function (callback, doneCallback) {
299
+ if (callback) {
300
+ this.callback = callback;
301
+ }
302
+ if (doneCallback) {
303
+ this.doneCallback = doneCallback;
304
+ }
305
+ this.iterate();
306
+ };
307
+ QueryMentionsIter.initWithComplexQuery = function (er, complexQuery, args) {
308
+ if (args === void 0) { args = {}; }
309
+ var query = new QueryMentionsIter(er, args);
310
+ if (typeof complexQuery === "string") {
311
+ query.setVal("query", complexQuery);
312
+ }
313
+ else if (typeof complexQuery === "object" && complexQuery !== null) {
314
+ query.setVal("query", JSON.stringify(complexQuery));
315
+ }
316
+ else {
317
+ throw new Error("The instance of query parameter was not a string or an object");
318
+ }
319
+ return query;
320
+ };
321
+ QueryMentionsIter.prototype.iterate = function () {
322
+ return __awaiter(this, void 0, void 0, function () {
323
+ return __generator(this, function (_a) {
324
+ switch (_a.label) {
325
+ case 0:
326
+ if (!this.current) return [3 /*break*/, 1];
327
+ this.callback(this.current);
328
+ this.index += 1;
329
+ return [3 /*break*/, 3];
330
+ case 1: return [4 /*yield*/, this.getNextBatch()];
331
+ case 2:
332
+ if (!(_a.sent())) {
333
+ this.doneCallback(this.errorMessage);
334
+ return [2 /*return*/];
335
+ }
336
+ _a.label = 3;
337
+ case 3: return [2 /*return*/, this.iterate()];
338
+ }
339
+ });
340
+ });
341
+ };
342
+ /**
343
+ * Extract the results according to maxItems
344
+ * @param response response from the backend
345
+ */
346
+ QueryMentionsIter.prototype.extractResults = function (response) {
347
+ var _a;
348
+ var results = ((_a = response.mentions) === null || _a === void 0 ? void 0 : _a.results) || [];
349
+ var extractedSize = this.maxItems !== -1 ? this.maxItems - this.returnedSoFar : results.length;
350
+ return results.slice(0, extractedSize).filter(Boolean);
351
+ };
352
+ Object.defineProperty(QueryMentionsIter.prototype, "current", {
353
+ get: function () {
354
+ return this.items[this.index] || undefined;
355
+ },
356
+ enumerable: false,
357
+ configurable: true
358
+ });
359
+ QueryMentionsIter.prototype.getNextBatch = function () {
360
+ return __awaiter(this, void 0, void 0, function () {
361
+ var requestMentionsInfo, response, error, results, error_1;
362
+ var _a;
363
+ return __generator(this, function (_b) {
364
+ switch (_b.label) {
365
+ case 0:
366
+ _b.trys.push([0, 2, , 3]);
367
+ this.page += 1;
368
+ if (this.page > this.pages || (this.maxItems !== -1 && this.returnedSoFar >= this.maxItems)) {
369
+ return [2 /*return*/, false];
370
+ }
371
+ requestMentionsInfo = new RequestMentionsInfo({
372
+ page: this.page,
373
+ count: 50,
374
+ sortBy: this.sortBy,
375
+ sortByAsc: this.sortByAsc,
376
+ returnInfo: this.returnInfo,
377
+ });
378
+ this.setRequestedResult(requestMentionsInfo);
379
+ if (this.er.verboseOutput) {
380
+ this.er.logger.info("Downloading mentions page ".concat(this.page, "..."));
381
+ }
382
+ return [4 /*yield*/, this.er.execQuery(this, this.er.allowUseOfArchive)];
383
+ case 1:
384
+ response = _b.sent();
385
+ error = (response === null || response === void 0 ? void 0 : response.error) || "";
386
+ if (error) {
387
+ this.errorMessage = "Error while obtaining a list of mentions: ".concat(response === null || response === void 0 ? void 0 : response.error);
388
+ }
389
+ else {
390
+ this.pages = ((_a = response.mentions) === null || _a === void 0 ? void 0 : _a.pages) || 0;
391
+ }
392
+ results = this.extractResults(response);
393
+ this.returnedSoFar += results.length;
394
+ this.items = __spreadArray(__spreadArray([], __read(this.items), false), __read(results), false);
395
+ return [2 /*return*/, true];
396
+ case 2:
397
+ error_1 = _b.sent();
398
+ this.er.logger.error(error_1);
399
+ return [2 /*return*/, false];
400
+ case 3: return [2 /*return*/];
401
+ }
402
+ });
403
+ });
404
+ };
405
+ return QueryMentionsIter;
406
+ }(QueryMentions));
407
+ exports.QueryMentionsIter = QueryMentionsIter;
408
+ var RequestMentions = /** @class */ (function () {
409
+ function RequestMentions() {
410
+ }
411
+ return RequestMentions;
412
+ }());
413
+ exports.RequestMentions = RequestMentions;
414
+ var RequestMentionsInfo = /** @class */ (function (_super) {
415
+ __extends(RequestMentionsInfo, _super);
416
+ function RequestMentionsInfo(args) {
417
+ if (args === void 0) { args = {}; }
418
+ var _this = _super.call(this) || this;
419
+ _this.resultType = "mentions";
420
+ var _a = args.page, page = _a === void 0 ? 1 : _a, _b = args.count, count = _b === void 0 ? 100 : _b, _c = args.sortBy, sortBy = _c === void 0 ? "date" : _c, _d = args.sortByAsc, sortByAsc = _d === void 0 ? false : _d, _e = args.returnInfo, returnInfo = _e === void 0 ? undefined : _e;
421
+ if (page < 1) {
422
+ throw new RangeError("Page has to be >= 1");
423
+ }
424
+ if (count > 100) {
425
+ throw new RangeError("At most 100 mentions can be returned per call");
426
+ }
427
+ _this.params = {};
428
+ _this.params["mentionsPage"] = page;
429
+ _this.params["mentionsCount"] = count;
430
+ _this.params["mentionsSortBy"] = sortBy;
431
+ _this.params["mentionsSortByAsc"] = sortByAsc;
432
+ if (returnInfo) {
433
+ _this.params = __assign(__assign({}, _this.params), returnInfo.getParams("mentions"));
434
+ }
435
+ return _this;
436
+ }
437
+ Object.defineProperty(RequestMentionsInfo.prototype, "page", {
438
+ set: function (page) {
439
+ if (page < 1) {
440
+ throw new RangeError("Page has to be >= 1");
441
+ }
442
+ this.params["mentionsPage"] = page;
443
+ },
444
+ enumerable: false,
445
+ configurable: true
446
+ });
447
+ return RequestMentionsInfo;
448
+ }(RequestMentions));
449
+ exports.RequestMentionsInfo = RequestMentionsInfo;
450
+ var RequestMentionsUriWgtList = /** @class */ (function (_super) {
451
+ __extends(RequestMentionsUriWgtList, _super);
452
+ function RequestMentionsUriWgtList(args) {
453
+ if (args === void 0) { args = {}; }
454
+ var _this = _super.call(this) || this;
455
+ _this.resultType = "uriWgtList";
456
+ var _a = args.page, page = _a === void 0 ? 1 : _a, _b = args.count, count = _b === void 0 ? 10000 : _b, _c = args.sortBy, sortBy = _c === void 0 ? "fq" : _c, _d = args.sortByAsc, sortByAsc = _d === void 0 ? false : _d, unsupported = __rest(args, ["page", "count", "sortBy", "sortByAsc"]);
457
+ if (Object.keys(unsupported).length !== 0) {
458
+ logger_1.Logger.warn("RequestMentionsUriWgtList: Unsupported parameters detected: ".concat(JSON.stringify(unsupported), ". Please check the documentation."));
459
+ }
460
+ if (page < 1) {
461
+ throw new RangeError("Page has to be >= 1");
462
+ }
463
+ if (count > 50000) {
464
+ throw new RangeError("At most 50000 results can be returned per call");
465
+ }
466
+ _this.params = {};
467
+ _this.params["uriWgtListPage"] = page;
468
+ _this.params["uriWgtListCount"] = count;
469
+ _this.params["uriWgtListSortBy"] = sortBy;
470
+ _this.params["uriWgtListSortByAsc"] = sortByAsc;
471
+ return _this;
472
+ }
473
+ Object.defineProperty(RequestMentionsUriWgtList.prototype, "page", {
474
+ set: function (page) {
475
+ if (page < 1) {
476
+ throw new RangeError("Page has to be >= 1");
477
+ }
478
+ this.params["uriWgtListPage"] = page;
479
+ },
480
+ enumerable: false,
481
+ configurable: true
482
+ });
483
+ return RequestMentionsUriWgtList;
484
+ }(RequestMentions));
485
+ exports.RequestMentionsUriWgtList = RequestMentionsUriWgtList;
486
+ var RequestMentionsTimeAggr = /** @class */ (function (_super) {
487
+ __extends(RequestMentionsTimeAggr, _super);
488
+ function RequestMentionsTimeAggr() {
489
+ var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
490
+ _this.resultType = "timeAggr";
491
+ return _this;
492
+ }
493
+ return RequestMentionsTimeAggr;
494
+ }(RequestMentions));
495
+ exports.RequestMentionsTimeAggr = RequestMentionsTimeAggr;
496
+ var RequestMentionsConceptAggr = /** @class */ (function (_super) {
497
+ __extends(RequestMentionsConceptAggr, _super);
498
+ function RequestMentionsConceptAggr(args) {
499
+ if (args === void 0) { args = {}; }
500
+ var _this = _super.call(this) || this;
501
+ _this.resultType = "conceptAggr";
502
+ var _a = args.conceptCount, conceptCount = _a === void 0 ? 25 : _a, _b = args.mentionsSampleSize, mentionsSampleSize = _b === void 0 ? 100000 : _b, _c = args.conceptScoring, conceptScoring = _c === void 0 ? "importance" : _c, _d = args.conceptCountPerType, conceptCountPerType = _d === void 0 ? undefined : _d, _e = args.returnInfo, returnInfo = _e === void 0 ? new returnInfo_1.ReturnInfo() : _e;
503
+ if (conceptCount > 500) {
504
+ throw new RangeError("At most 500 top concepts can be returned");
505
+ }
506
+ if (mentionsSampleSize > 20000) {
507
+ throw new RangeError("At most 20000 results can be used for computing");
508
+ }
509
+ _this.params = {};
510
+ _this.params["conceptAggrConceptCount"] = conceptCount;
511
+ _this.params["conceptAggrSampleSize"] = mentionsSampleSize;
512
+ _this.params["conceptAggrScoring"] = conceptScoring;
513
+ if (!!conceptCountPerType) {
514
+ _this.params["conceptAggrConceptCountPerType"] = conceptCountPerType;
515
+ }
516
+ _this.params = __assign(__assign({}, _this.params), returnInfo.getParams("conceptAggr"));
517
+ return _this;
518
+ }
519
+ return RequestMentionsConceptAggr;
520
+ }(RequestMentions));
521
+ exports.RequestMentionsConceptAggr = RequestMentionsConceptAggr;
522
+ var RequestMentionsCategoryAggr = /** @class */ (function (_super) {
523
+ __extends(RequestMentionsCategoryAggr, _super);
524
+ function RequestMentionsCategoryAggr(args) {
525
+ if (args === void 0) { args = {}; }
526
+ var _this = _super.call(this) || this;
527
+ _this.resultType = "categoryAggr";
528
+ var _a = args.mentionsSampleSize, mentionsSampleSize = _a === void 0 ? 20000 : _a, _b = args.returnInfo, returnInfo = _b === void 0 ? new returnInfo_1.ReturnInfo() : _b;
529
+ if (mentionsSampleSize > 50000) {
530
+ throw new RangeError("At most 50000 results can be used for aggregation");
531
+ }
532
+ _this.params["categoryAggrSampleSize"] = mentionsSampleSize;
533
+ _this.params = returnInfo.getParams("categoryAggr");
534
+ return _this;
535
+ }
536
+ return RequestMentionsCategoryAggr;
537
+ }(RequestMentions));
538
+ exports.RequestMentionsCategoryAggr = RequestMentionsCategoryAggr;
539
+ var RequestMentionsSourceAggr = /** @class */ (function (_super) {
540
+ __extends(RequestMentionsSourceAggr, _super);
541
+ function RequestMentionsSourceAggr(args) {
542
+ if (args === void 0) { args = {}; }
543
+ var _this = _super.call(this) || this;
544
+ _this.resultType = "sourceAggr";
545
+ var _a = args.sourceCount, sourceCount = _a === void 0 ? 50 : _a, _b = args.normalizeBySourceArts, normalizeBySourceArts = _b === void 0 ? false : _b, _c = args.returnInfo, returnInfo = _c === void 0 ? new returnInfo_1.ReturnInfo() : _c;
546
+ _this.params["sourceAggrSourceCount"] = sourceCount;
547
+ _this.params = returnInfo.getParams("sourceAggr");
548
+ return _this;
549
+ }
550
+ return RequestMentionsSourceAggr;
551
+ }(RequestMentions));
552
+ exports.RequestMentionsSourceAggr = RequestMentionsSourceAggr;
553
+ var RequestMentionsKeywordAggr = /** @class */ (function (_super) {
554
+ __extends(RequestMentionsKeywordAggr, _super);
555
+ function RequestMentionsKeywordAggr(args) {
556
+ if (args === void 0) { args = {}; }
557
+ var _this = _super.call(this) || this;
558
+ _this.resultType = "keywordAggr";
559
+ var _a = args.mentionsSampleSize, mentionsSampleSize = _a === void 0 ? 2000 : _a;
560
+ if (mentionsSampleSize > 20000) {
561
+ throw new RangeError("At most 20000 results can be used for aggregation");
562
+ }
563
+ _this.params["keywordAggrSampleSize"] = mentionsSampleSize;
564
+ return _this;
565
+ }
566
+ return RequestMentionsKeywordAggr;
567
+ }(RequestMentions));
568
+ exports.RequestMentionsKeywordAggr = RequestMentionsKeywordAggr;
569
+ var RequestMentionsConceptGraph = /** @class */ (function (_super) {
570
+ __extends(RequestMentionsConceptGraph, _super);
571
+ function RequestMentionsConceptGraph(args) {
572
+ if (args === void 0) { args = {}; }
573
+ var _this = _super.call(this) || this;
574
+ _this.resultType = "conceptGraph";
575
+ var _a = args.conceptCount, conceptCount = _a === void 0 ? 25 : _a, _b = args.linkCount, linkCount = _b === void 0 ? 50 : _b, _c = args.mentionsSampleSize, mentionsSampleSize = _c === void 0 ? 10000 : _c, _d = args.skipQueryConcepts, skipQueryConcepts = _d === void 0 ? true : _d, _e = args.returnInfo, returnInfo = _e === void 0 ? new returnInfo_1.ReturnInfo() : _e;
576
+ if (conceptCount > 1000) {
577
+ throw new RangeError("At most 1000 top concepts can be returned");
578
+ }
579
+ if (linkCount > 2000) {
580
+ throw new RangeError("At most 2000 links between concepts can be returned");
581
+ }
582
+ if (mentionsSampleSize > 50000) {
583
+ throw new RangeError("At most 50000 results can be used for computing");
584
+ }
585
+ _this.params = {};
586
+ _this.params["conceptGraphConceptCount"] = conceptCount;
587
+ _this.params["conceptGraphLinkCount"] = linkCount;
588
+ _this.params["conceptGraphSampleSize"] = mentionsSampleSize;
589
+ _this.params["conceptGraphSkipQueryConcepts"] = skipQueryConcepts;
590
+ _this.params = __assign(__assign({}, _this.params), returnInfo.getParams("conceptGraph"));
591
+ return _this;
592
+ }
593
+ return RequestMentionsConceptGraph;
594
+ }(RequestMentions));
595
+ exports.RequestMentionsConceptGraph = RequestMentionsConceptGraph;
596
+ var RequestMentionsRecentActivity = /** @class */ (function (_super) {
597
+ __extends(RequestMentionsRecentActivity, _super);
598
+ function RequestMentionsRecentActivity(args) {
599
+ if (args === void 0) { args = {}; }
600
+ var _this = _super.call(this) || this;
601
+ _this.resultType = "recentActivityMentions";
602
+ var _a = args.maxMentionCount, maxMentionCount = _a === void 0 ? 100 : _a, _b = args.updatesAfterUri, updatesAfterUri = _b === void 0 ? undefined : _b, _c = args.updatesAfterTm, updatesAfterTm = _c === void 0 ? undefined : _c, _d = args.updatesAfterMinsAgo, updatesAfterMinsAgo = _d === void 0 ? undefined : _d, _e = args.updatesUntilTm, updatesUntilTm = _e === void 0 ? undefined : _e, _f = args.updatesUntilMinsAgo, updatesUntilMinsAgo = _f === void 0 ? undefined : _f, _g = args.mandatorySourceLocation, mandatorySourceLocation = _g === void 0 ? false : _g, _h = args.returnInfo, returnInfo = _h === void 0 ? undefined : _h;
603
+ if (maxMentionCount > 2000) {
604
+ throw new RangeError("At most 2000 mentions can be returned");
605
+ }
606
+ if (updatesAfterTm !== undefined && updatesAfterMinsAgo !== undefined) {
607
+ throw new Error("You should specify either updatesAfterTm or updatesAfterMinsAgo parameter, but not both");
608
+ }
609
+ if (updatesUntilTm !== undefined && updatesUntilMinsAgo !== undefined) {
610
+ throw new Error("You should specify either updatesUntilTm or updatesUntilMinsAgo parameter, but not both");
611
+ }
612
+ _this.params = {};
613
+ _this.params["recentActivityMentionsMaxMentionCount"] = maxMentionCount;
614
+ if (updatesAfterTm !== undefined) {
615
+ _this.params["recentActivityMentionsUpdatesAfterTm"] = base_1.QueryParamsBase.encodeDateTime(updatesAfterTm);
616
+ }
617
+ if (updatesAfterMinsAgo !== undefined) {
618
+ _this.params["recentActivityMentionsUpdatesAfterMinsAgo"] = updatesAfterMinsAgo;
619
+ }
620
+ if (updatesUntilTm !== undefined) {
621
+ _this.params["recentActivityMentionsUpdatesUntilTm"] = base_1.QueryParamsBase.encodeDateTime(updatesUntilTm);
622
+ }
623
+ if (updatesUntilMinsAgo !== undefined) {
624
+ _this.params["recentActivityMentionsUpdatesUntilMinsAgo"] = updatesUntilMinsAgo;
625
+ }
626
+ if (updatesAfterUri !== undefined) {
627
+ _this.params["recentActivityMentionsUpdatesAfterUri"] = updatesAfterUri;
628
+ }
629
+ _this.params["recentActivityMentionsMandatorySourceLocation"] = mandatorySourceLocation;
630
+ if (returnInfo !== undefined) {
631
+ _this.params = __assign(__assign({}, _this.params), returnInfo.getParams("recentActivityMentions"));
632
+ }
633
+ return _this;
634
+ }
635
+ return RequestMentionsRecentActivity;
636
+ }(RequestMentions));
637
+ exports.RequestMentionsRecentActivity = RequestMentionsRecentActivity;
601
638
  //# sourceMappingURL=queryMentions.js.map