eventregistry 8.11.2 → 9.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/analytics.d.ts +82 -82
  2. package/dist/analytics.js +336 -330
  3. package/dist/analytics.js.map +1 -1
  4. package/dist/base.d.ts +82 -81
  5. package/dist/base.js +261 -219
  6. package/dist/base.js.map +1 -1
  7. package/dist/counts.d.ts +81 -81
  8. package/dist/counts.js +162 -149
  9. package/dist/counts.js.map +1 -1
  10. package/dist/dailyShares.d.ts +10 -10
  11. package/dist/dailyShares.js +90 -77
  12. package/dist/dailyShares.js.map +1 -1
  13. package/dist/data.d.ts +269 -268
  14. package/dist/data.js +3 -3
  15. package/dist/eventForText.d.ts +48 -48
  16. package/dist/eventForText.js +126 -123
  17. package/dist/eventForText.js.map +1 -1
  18. package/dist/eventRegistry.d.ts +244 -224
  19. package/dist/eventRegistry.js +1098 -1018
  20. package/dist/eventRegistry.js.map +1 -1
  21. package/dist/index.d.ts +21 -20
  22. package/dist/index.js +128 -122
  23. package/dist/index.js.map +1 -1
  24. package/dist/info.d.ts +61 -61
  25. package/dist/info.js +171 -158
  26. package/dist/info.js.map +1 -1
  27. package/dist/logger.d.ts +45 -0
  28. package/dist/logger.js +156 -0
  29. package/dist/logger.js.map +1 -0
  30. package/dist/query.d.ts +53 -53
  31. package/dist/query.js +333 -290
  32. package/dist/query.js.map +1 -1
  33. package/dist/queryArticle.d.ts +61 -61
  34. package/dist/queryArticle.js +183 -168
  35. package/dist/queryArticle.js.map +1 -1
  36. package/dist/queryArticles.d.ts +144 -160
  37. package/dist/queryArticles.js +729 -701
  38. package/dist/queryArticles.js.map +1 -1
  39. package/dist/queryEvent.d.ts +140 -140
  40. package/dist/queryEvent.js +587 -569
  41. package/dist/queryEvent.js.map +1 -1
  42. package/dist/queryEvents.d.ts +210 -210
  43. package/dist/queryEvents.js +825 -798
  44. package/dist/queryEvents.js.map +1 -1
  45. package/dist/queryMentions.d.ts +96 -96
  46. package/dist/queryMentions.js +637 -600
  47. package/dist/queryMentions.js.map +1 -1
  48. package/dist/queryStory.d.ts +58 -58
  49. package/dist/queryStory.js +194 -174
  50. package/dist/queryStory.js.map +1 -1
  51. package/dist/recent.d.ts +23 -23
  52. package/dist/recent.js +199 -179
  53. package/dist/recent.js.map +1 -1
  54. package/dist/returnInfo.d.ts +68 -66
  55. package/dist/returnInfo.js +332 -304
  56. package/dist/returnInfo.js.map +1 -1
  57. package/dist/topicPage.d.ts +157 -157
  58. package/dist/topicPage.js +599 -604
  59. package/dist/topicPage.js.map +1 -1
  60. package/dist/trends.d.ts +35 -35
  61. package/dist/trends.js +115 -102
  62. package/dist/trends.js.map +1 -1
  63. package/dist/types.d.ts +2453 -2155
  64. package/dist/types.js +2 -2
  65. package/package.json +13 -13
package/dist/query.js CHANGED
@@ -1,291 +1,334 @@
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 __read = (this && this.__read) || function (o, n) {
16
- var m = typeof Symbol === "function" && o[Symbol.iterator];
17
- if (!m) return o;
18
- var i = m.call(o), r, ar = [], e;
19
- try {
20
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
21
- }
22
- catch (error) { e = { error: error }; }
23
- finally {
24
- try {
25
- if (r && !r.done && (m = i["return"])) m.call(i);
26
- }
27
- finally { if (e) throw e.error; }
28
- }
29
- return ar;
30
- };
31
- var __spread = (this && this.__spread) || function () {
32
- for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
33
- return ar;
34
- };
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- var _ = require("lodash");
37
- var base_1 = require("./base");
38
- var QueryCore = /** @class */ (function () {
39
- function QueryCore() {
40
- this.queryObj = {};
41
- }
42
- QueryCore.prototype.getQuery = function () {
43
- return this.queryObj;
44
- };
45
- QueryCore.prototype.setQueryParam = function (paramName, val) {
46
- this.queryObj[paramName] = val;
47
- };
48
- QueryCore.prototype.setValIfNotDefault = function (propName, value, defVal) {
49
- if (value !== defVal) {
50
- this.queryObj[propName] = value;
51
- }
52
- };
53
- return QueryCore;
54
- }());
55
- exports.QueryCore = QueryCore;
56
- var BaseQuery = /** @class */ (function (_super) {
57
- __extends(BaseQuery, _super);
58
- /**
59
- * @param args Object which contains a host of optional parameters
60
- */
61
- function BaseQuery(args) {
62
- if (args === void 0) { args = {}; }
63
- var _this = _super.call(this) || this;
64
- _.defaults(args, {
65
- keywordLoc: "body",
66
- categoryIncludeSub: true,
67
- });
68
- _this.setQueryArrVal("keyword", args.keyword);
69
- _this.setQueryArrVal("conceptUri", args.conceptUri);
70
- _this.setQueryArrVal("categoryUri", args.categoryUri);
71
- _this.setQueryArrVal("sourceUri", args.sourceUri);
72
- _this.setQueryArrVal("locationUri", args.locationUri);
73
- _this.setQueryArrVal("lang", args.lang);
74
- if (!_.isNil(args.dateStart)) {
75
- _this.queryObj["dateStart"] = base_1.QueryParamsBase.encodeDateTime(args.dateStart, "YYYY-MM-DD");
76
- }
77
- if (!_.isNil(args.dateEnd)) {
78
- _this.queryObj["dateEnd"] = base_1.QueryParamsBase.encodeDateTime(args.dateEnd, "YYYY-MM-DD");
79
- }
80
- if (!_.isNil(args.dateMention)) {
81
- if (_.isArray(args.dateMention)) {
82
- _this.queryObj["dateMention"] = _.map(args.dateMention, function (date) { return base_1.QueryParamsBase.encodeDateTime(date, "YYYY-MM-DD"); });
83
- }
84
- else {
85
- _this.queryObj["dateMention"] = base_1.QueryParamsBase.encodeDateTime(args.dateMention, "YYYY-MM-DD");
86
- }
87
- }
88
- _this.setQueryArrVal("sourceLocationUri", args.sourceLocationUri);
89
- _this.setQueryArrVal("sourceGroupUri", args.sourceGroupUri);
90
- _this.setQueryArrVal("authorUri", args.authorUri);
91
- if (!args.categoryIncludeSub) {
92
- _this.queryObj["categoryIncludeSub"] = false;
93
- }
94
- if (args.keywordLoc !== "body") {
95
- _this.queryObj["keywordLoc"] = args.keywordLoc;
96
- }
97
- if (!_.isNil(args.minMaxArticlesInEvent)) {
98
- if (!_.isArray() || _.size(args.minMaxArticlesInEvent) !== 2) {
99
- throw new Error("minMaxArticlesInEvent parameter should either be None or a tuple with two integer values");
100
- }
101
- _this.queryObj["minArticlesInEvent"] = args.minMaxArticlesInEvent[0];
102
- _this.queryObj["maxArticlesInEvent"] = args.minMaxArticlesInEvent[1];
103
- }
104
- if (!_.isNil(args.exclude)) {
105
- if (!(args.exclude instanceof QueryCore)) {
106
- throw new Error("exclude parameter was not a CombinedQuery or BaseQuery instance");
107
- }
108
- _this.queryObj["$not"] = args.exclude.getQuery();
109
- }
110
- return _this;
111
- }
112
- BaseQuery.prototype.setQueryArrVal = function (propName, value) {
113
- if (_.isNil(value)) {
114
- return;
115
- }
116
- if (value instanceof base_1.QueryItems) {
117
- _.set(this.queryObj, propName + "." + value.getOper(), value.getItems());
118
- }
119
- else if (_.isString(value)) {
120
- _.set(this.queryObj, propName, value);
121
- }
122
- else {
123
- throw new Error("Parameter '" + propName + "' was of unsupported type. It should either be undefined, a string or an instance of QueryItems");
124
- }
125
- };
126
- return BaseQuery;
127
- }(QueryCore));
128
- exports.BaseQuery = BaseQuery;
129
- var CombinedQuery = /** @class */ (function (_super) {
130
- __extends(CombinedQuery, _super);
131
- function CombinedQuery() {
132
- return _super !== null && _super.apply(this, arguments) || this;
133
- }
134
- /**
135
- * Create a combined query with multiple items on which to perform an AND operation
136
- * @param queryArr a list of items on which to perform an AND operation. Items can be either a CombinedQuery or BaseQuery instances.
137
- * @param exclude Used to filter out results matching the other criteria specified in this query
138
- */
139
- CombinedQuery.AND = function (queryArr, exclude) {
140
- if (!_.isArray(queryArr)) {
141
- throw new Error("provided argument as not a list");
142
- }
143
- if (_.isEmpty(queryArr)) {
144
- throw new Error("queryArr had an empty list");
145
- }
146
- var query = new CombinedQuery();
147
- query.queryObj["$and"] = [];
148
- _.each(queryArr, function (item) {
149
- if (!(item instanceof QueryCore)) {
150
- throw new Error("item in the list was not a CombinedQuery or BaseQuery instance");
151
- }
152
- query.queryObj["$and"] = __spread(query.queryObj["$and"], [item.getQuery()]);
153
- });
154
- if (!_.isNil(exclude)) {
155
- if (!(exclude instanceof QueryCore)) {
156
- throw new Error("exclude parameter was not a CombinedQuery or BaseQuery instance");
157
- }
158
- query.setQueryParam("$not", exclude.getQuery());
159
- }
160
- return query;
161
- };
162
- /**
163
- * Create a combined query with multiple items on which to perform an OR operation
164
- * @param queryArr A list of items on which to perform an OR operation.
165
- * @param exclude Used to filter out results matching the other criteria specified in this query.
166
- */
167
- CombinedQuery.OR = function (queryArr, exclude) {
168
- if (!_.isArray(queryArr)) {
169
- throw new Error("provided argument as not a list");
170
- }
171
- if (_.isEmpty(queryArr)) {
172
- throw new Error("queryArr had an empty list");
173
- }
174
- var query = new CombinedQuery();
175
- query.queryObj["$or"] = [];
176
- _.each(queryArr, function (item) {
177
- if (!(item instanceof QueryCore)) {
178
- throw new Error("item in the list was not a CombinedQuery or BaseQuery instance");
179
- }
180
- query.queryObj["$or"] = __spread(query.queryObj["$or"], [item.getQuery()]);
181
- });
182
- if (!_.isNil(exclude)) {
183
- if (!(exclude instanceof QueryCore)) {
184
- throw new Error("exclude parameter was not a CombinedQuery or BaseQuery instance");
185
- }
186
- query.setQueryParam("$not", exclude.getQuery());
187
- }
188
- return query;
189
- };
190
- return CombinedQuery;
191
- }(QueryCore));
192
- exports.CombinedQuery = CombinedQuery;
193
- /**
194
- * @class ComplexArticleQuery
195
- * Create an article query using a complex query
196
- */
197
- var ComplexArticleQuery = /** @class */ (function (_super) {
198
- __extends(ComplexArticleQuery, _super);
199
- /**
200
- * @param query An instance of CombinedQuery or BaseQuery to use to find articles that match the conditions
201
- * @param args Object which contains a host of optional parameters
202
- */
203
- function ComplexArticleQuery(query, args) {
204
- if (args === void 0) { args = {}; }
205
- var _this = _super.call(this) || this;
206
- _.defaults(args, {
207
- dataType: "news",
208
- minSentiment: undefined,
209
- maxSentiment: undefined,
210
- minSocialScore: 0,
211
- minFacebookShares: 0,
212
- startSourceRankPercentile: 0,
213
- endSourceRankPercentile: 0,
214
- isDuplicateFilter: "keepAll",
215
- hasDuplicateFilter: "keepAll",
216
- eventFilter: "keepAll",
217
- });
218
- if (!(query instanceof QueryCore)) {
219
- throw new Error("query parameter was not a CombinedQuery or BaseQuery instance");
220
- }
221
- _this.queryObj["$query"] = query.getQuery();
222
- var filter = {};
223
- if (_.get(args, "dataType") !== "news") {
224
- filter["dataType"] = _.get(args, "dataType");
225
- }
226
- if (!!_.get(args, "minSentiment")) {
227
- filter["minSentiment"] = _.get(args, "minSentiment");
228
- }
229
- if (!!_.get(args, "maxSentiment")) {
230
- filter["maxSentiment"] = _.get(args, "maxSentiment");
231
- }
232
- if (_.get(args, "minSocialScore") > 0) {
233
- filter["minSocialScore"] = _.get(args, "minSocialScore");
234
- }
235
- if (_.get(args, "minFacebookShares") > 0) {
236
- filter["minFacebookShares"] = _.get(args, "minFacebookShares");
237
- }
238
- if (_.get(args, "startSourceRankPercentile") !== 0) {
239
- filter["startSourceRankPercentile"] = _.get(args, "startSourceRankPercentile");
240
- }
241
- if (_.get(args, "endSourceRankPercentile") !== 0) {
242
- filter["endSourceRankPercentile"] = _.get(args, "endSourceRankPercentile");
243
- }
244
- if (_.get(args, "isDuplicateFilter") !== "keepAll") {
245
- filter["isDuplicate"] = _.get(args, "isDuplicateFilter");
246
- }
247
- if (_.get(args, "hasDuplicateFilter") !== "keepAll") {
248
- filter["hasDuplicate"] = _.get(args, "hasDuplicateFilter");
249
- }
250
- if (_.get(args, "eventFilter") !== "keepAll") {
251
- filter["hasEvent"] = _.get(args, "eventFilter");
252
- }
253
- if (!_.isEmpty(filter)) {
254
- _this.queryObj["$filter"] = filter;
255
- }
256
- return _this;
257
- }
258
- return ComplexArticleQuery;
259
- }(QueryCore));
260
- exports.ComplexArticleQuery = ComplexArticleQuery;
261
- /**
262
- * @class ComplexEventQuery
263
- */
264
- var ComplexEventQuery = /** @class */ (function (_super) {
265
- __extends(ComplexEventQuery, _super);
266
- /**
267
- * @param query an instance of CombinedQuery or BaseQuery to use to find events that match the conditions
268
- */
269
- function ComplexEventQuery(query, args) {
270
- if (args === void 0) { args = {}; }
271
- var _this = _super.call(this) || this;
272
- if (!(query instanceof QueryCore)) {
273
- throw new Error("query parameter was not a CombinedQuery or BaseQuery instance");
274
- }
275
- _this.queryObj["$query"] = query.getQuery();
276
- var filter = {};
277
- if (!!_.get(args, "minSentiment")) {
278
- filter["minSentiment"] = _.get(args, "minSentiment");
279
- }
280
- if (!!_.get(args, "maxSentiment")) {
281
- filter["maxSentiment"] = _.get(args, "maxSentiment");
282
- }
283
- if (!_.isEmpty(filter)) {
284
- _this.queryObj["$filter"] = filter;
285
- }
286
- return _this;
287
- }
288
- return ComplexEventQuery;
289
- }(QueryCore));
290
- exports.ComplexEventQuery = ComplexEventQuery;
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 __values = (this && this.__values) || function(o) {
29
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
30
+ if (m) return m.call(o);
31
+ if (o && typeof o.length === "number") return {
32
+ next: function () {
33
+ if (o && i >= o.length) o = void 0;
34
+ return { value: o && o[i++], done: !o };
35
+ }
36
+ };
37
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
38
+ };
39
+ var __read = (this && this.__read) || function (o, n) {
40
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
41
+ if (!m) return o;
42
+ var i = m.call(o), r, ar = [], e;
43
+ try {
44
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
45
+ }
46
+ catch (error) { e = { error: error }; }
47
+ finally {
48
+ try {
49
+ if (r && !r.done && (m = i["return"])) m.call(i);
50
+ }
51
+ finally { if (e) throw e.error; }
52
+ }
53
+ return ar;
54
+ };
55
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
56
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
57
+ if (ar || !(i in from)) {
58
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
59
+ ar[i] = from[i];
60
+ }
61
+ }
62
+ return to.concat(ar || Array.prototype.slice.call(from));
63
+ };
64
+ Object.defineProperty(exports, "__esModule", { value: true });
65
+ exports.ComplexEventQuery = exports.ComplexArticleQuery = exports.CombinedQuery = exports.BaseQuery = exports.QueryCore = void 0;
66
+ var base_1 = require("./base");
67
+ var QueryCore = /** @class */ (function () {
68
+ function QueryCore() {
69
+ this.queryObj = {};
70
+ }
71
+ QueryCore.prototype.getQuery = function () {
72
+ return this.queryObj;
73
+ };
74
+ QueryCore.prototype.setQueryParam = function (paramName, val) {
75
+ this.queryObj[paramName] = val;
76
+ };
77
+ QueryCore.prototype.setValIfNotDefault = function (propName, value, defVal) {
78
+ if (value !== defVal) {
79
+ this.queryObj[propName] = value;
80
+ }
81
+ };
82
+ return QueryCore;
83
+ }());
84
+ exports.QueryCore = QueryCore;
85
+ var BaseQuery = /** @class */ (function (_super) {
86
+ __extends(BaseQuery, _super);
87
+ /**
88
+ * @param args Object which contains a host of optional parameters
89
+ */
90
+ function BaseQuery(parameters) {
91
+ if (parameters === void 0) { parameters = {}; }
92
+ var _this = _super.call(this) || this;
93
+ var defaults = {
94
+ keywordLoc: "body",
95
+ categoryIncludeSub: true,
96
+ };
97
+ var args = __assign(__assign({}, defaults), parameters);
98
+ _this.setQueryArrVal("keyword", args.keyword);
99
+ _this.setQueryArrVal("conceptUri", args.conceptUri);
100
+ _this.setQueryArrVal("categoryUri", args.categoryUri);
101
+ _this.setQueryArrVal("sourceUri", args.sourceUri);
102
+ _this.setQueryArrVal("locationUri", args.locationUri);
103
+ _this.setQueryArrVal("lang", args.lang);
104
+ if (args.dateStart != null) {
105
+ _this.queryObj["dateStart"] = base_1.QueryParamsBase.encodeDateTime(args.dateStart, "YYYY-MM-DD");
106
+ }
107
+ if (args.dateEnd != null) {
108
+ _this.queryObj["dateEnd"] = base_1.QueryParamsBase.encodeDateTime(args.dateEnd, "YYYY-MM-DD");
109
+ }
110
+ if (args.dateMention != null) {
111
+ if (Array.isArray(args.dateMention)) {
112
+ _this.queryObj["dateMention"] = args.dateMention.map(function (date) { return base_1.QueryParamsBase.encodeDateTime(date, "YYYY-MM-DD"); });
113
+ }
114
+ else {
115
+ _this.queryObj["dateMention"] = base_1.QueryParamsBase.encodeDateTime(args.dateMention, "YYYY-MM-DD");
116
+ }
117
+ }
118
+ _this.setQueryArrVal("sourceLocationUri", args.sourceLocationUri);
119
+ _this.setQueryArrVal("sourceGroupUri", args.sourceGroupUri);
120
+ _this.setQueryArrVal("authorUri", args.authorUri);
121
+ if (!args.categoryIncludeSub) {
122
+ _this.queryObj["categoryIncludeSub"] = false;
123
+ }
124
+ if (args.keywordLoc !== "body") {
125
+ _this.queryObj["keywordLoc"] = args.keywordLoc;
126
+ }
127
+ if (args.minMaxArticlesInEvent != null) {
128
+ if (!Array.isArray(args.minMaxArticlesInEvent) || args.minMaxArticlesInEvent.length !== 2) {
129
+ throw new Error("minMaxArticlesInEvent parameter should either be None or a tuple with two integer values");
130
+ }
131
+ _this.queryObj["minArticlesInEvent"] = args.minMaxArticlesInEvent[0];
132
+ _this.queryObj["maxArticlesInEvent"] = args.minMaxArticlesInEvent[1];
133
+ }
134
+ if (args.exclude != null) {
135
+ if (!(args.exclude instanceof QueryCore)) {
136
+ throw new Error("exclude parameter was not a CombinedQuery or BaseQuery instance");
137
+ }
138
+ _this.queryObj["$not"] = args.exclude.getQuery();
139
+ }
140
+ return _this;
141
+ }
142
+ BaseQuery.prototype.setQueryArrVal = function (propName, value) {
143
+ if (value === null || value === undefined) {
144
+ return;
145
+ }
146
+ if (value instanceof base_1.QueryItems) {
147
+ this.queryObj[propName] = this.queryObj[propName] || {};
148
+ this.queryObj[propName][value.getOper()] = value.getItems();
149
+ }
150
+ else if (typeof value === "string") {
151
+ this.queryObj[propName] = value;
152
+ }
153
+ else {
154
+ throw new Error("Parameter '".concat(propName, "' was of unsupported type. It should either be undefined, a string or an instance of QueryItems"));
155
+ }
156
+ };
157
+ return BaseQuery;
158
+ }(QueryCore));
159
+ exports.BaseQuery = BaseQuery;
160
+ var CombinedQuery = /** @class */ (function (_super) {
161
+ __extends(CombinedQuery, _super);
162
+ function CombinedQuery() {
163
+ return _super !== null && _super.apply(this, arguments) || this;
164
+ }
165
+ /**
166
+ * Create a combined query with multiple items on which to perform an AND operation
167
+ * @param queryArr a list of items on which to perform an AND operation. Items can be either a CombinedQuery or BaseQuery instances.
168
+ * @param exclude Used to filter out results matching the other criteria specified in this query
169
+ */
170
+ CombinedQuery.AND = function (queryArr, exclude) {
171
+ var e_1, _a;
172
+ if (!Array.isArray(queryArr)) {
173
+ throw new Error("provided argument as not a list");
174
+ }
175
+ if (queryArr.length === 0) {
176
+ throw new Error("queryArr had an empty list");
177
+ }
178
+ var query = new CombinedQuery();
179
+ query.queryObj["$and"] = [];
180
+ try {
181
+ for (var queryArr_1 = __values(queryArr), queryArr_1_1 = queryArr_1.next(); !queryArr_1_1.done; queryArr_1_1 = queryArr_1.next()) {
182
+ var item = queryArr_1_1.value;
183
+ if (!(item instanceof QueryCore)) {
184
+ throw new Error("item in the list was not a CombinedQuery or BaseQuery instance");
185
+ }
186
+ query.queryObj["$and"] = __spreadArray(__spreadArray([], __read(query.queryObj["$and"]), false), [item.getQuery()], false);
187
+ }
188
+ }
189
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
190
+ finally {
191
+ try {
192
+ if (queryArr_1_1 && !queryArr_1_1.done && (_a = queryArr_1.return)) _a.call(queryArr_1);
193
+ }
194
+ finally { if (e_1) throw e_1.error; }
195
+ }
196
+ if (exclude !== null && exclude !== undefined) {
197
+ if (!(exclude instanceof QueryCore)) {
198
+ throw new Error("exclude parameter was not a CombinedQuery or BaseQuery instance");
199
+ }
200
+ query.setQueryParam("$not", exclude.getQuery());
201
+ }
202
+ return query;
203
+ };
204
+ /**
205
+ * Create a combined query with multiple items on which to perform an OR operation
206
+ * @param queryArr A list of items on which to perform an OR operation.
207
+ * @param exclude Used to filter out results matching the other criteria specified in this query.
208
+ */
209
+ CombinedQuery.OR = function (queryArr, exclude) {
210
+ if (!Array.isArray(queryArr)) {
211
+ throw new Error("provided argument as not a list");
212
+ }
213
+ if (queryArr.length === 0) {
214
+ throw new Error("queryArr had an empty list");
215
+ }
216
+ var query = new CombinedQuery();
217
+ query.queryObj["$or"] = [];
218
+ queryArr.forEach(function (item) {
219
+ if (!(item instanceof QueryCore)) {
220
+ throw new Error("item in the list was not a CombinedQuery or BaseQuery instance");
221
+ }
222
+ query.queryObj["$or"] = __spreadArray(__spreadArray([], __read(query.queryObj["$or"]), false), [item.getQuery()], false);
223
+ });
224
+ if (exclude !== null && exclude !== undefined) {
225
+ if (!(exclude instanceof QueryCore)) {
226
+ throw new Error("exclude parameter was not a CombinedQuery or BaseQuery instance");
227
+ }
228
+ query.setQueryParam("$not", exclude.getQuery());
229
+ }
230
+ return query;
231
+ };
232
+ return CombinedQuery;
233
+ }(QueryCore));
234
+ exports.CombinedQuery = CombinedQuery;
235
+ /**
236
+ * @class ComplexArticleQuery
237
+ * Create an article query using a complex query
238
+ */
239
+ var ComplexArticleQuery = /** @class */ (function (_super) {
240
+ __extends(ComplexArticleQuery, _super);
241
+ /**
242
+ * @param query An instance of CombinedQuery or BaseQuery to use to find articles that match the conditions
243
+ * @param args Object which contains a host of optional parameters
244
+ */
245
+ function ComplexArticleQuery(query, args) {
246
+ if (args === void 0) { args = {}; }
247
+ var _this = _super.call(this) || this;
248
+ var defaults = {
249
+ dataType: "news",
250
+ minSentiment: undefined,
251
+ maxSentiment: undefined,
252
+ minSocialScore: 0,
253
+ minFacebookShares: 0,
254
+ startSourceRankPercentile: 0,
255
+ endSourceRankPercentile: 0,
256
+ isDuplicateFilter: "keepAll",
257
+ hasDuplicateFilter: "keepAll",
258
+ eventFilter: "keepAll",
259
+ };
260
+ args = __assign(__assign({}, defaults), args);
261
+ if (!(query instanceof QueryCore)) {
262
+ throw new Error("query parameter was not a CombinedQuery or BaseQuery instance");
263
+ }
264
+ _this.queryObj["$query"] = query.getQuery();
265
+ var filter = {};
266
+ if (args.dataType !== "news") {
267
+ filter["dataType"] = args.dataType;
268
+ }
269
+ if (args.minSentiment) {
270
+ filter["minSentiment"] = args.minSentiment;
271
+ }
272
+ if (args.maxSentiment) {
273
+ filter["maxSentiment"] = args.maxSentiment;
274
+ }
275
+ if (args.minSocialScore > 0) {
276
+ filter["minSocialScore"] = args.minSocialScore;
277
+ }
278
+ if (args.minFacebookShares > 0) {
279
+ filter["minFacebookShares"] = args.minFacebookShares;
280
+ }
281
+ if (args.startSourceRankPercentile !== 0) {
282
+ filter["startSourceRankPercentile"] = args.startSourceRankPercentile;
283
+ }
284
+ if (args.endSourceRankPercentile !== 0) {
285
+ filter["endSourceRankPercentile"] = args.endSourceRankPercentile;
286
+ }
287
+ if (args.isDuplicateFilter !== "keepAll") {
288
+ filter["isDuplicate"] = args.isDuplicateFilter;
289
+ }
290
+ if (args.hasDuplicateFilter !== "keepAll") {
291
+ filter["hasDuplicate"] = args.hasDuplicateFilter;
292
+ }
293
+ if (args.eventFilter !== "keepAll") {
294
+ filter["hasEvent"] = args.eventFilter;
295
+ }
296
+ if (Object.keys(filter).length > 0) {
297
+ _this.queryObj["$filter"] = filter;
298
+ }
299
+ return _this;
300
+ }
301
+ return ComplexArticleQuery;
302
+ }(QueryCore));
303
+ exports.ComplexArticleQuery = ComplexArticleQuery;
304
+ /**
305
+ * @class ComplexEventQuery
306
+ */
307
+ var ComplexEventQuery = /** @class */ (function (_super) {
308
+ __extends(ComplexEventQuery, _super);
309
+ /**
310
+ * @param query an instance of CombinedQuery or BaseQuery to use to find events that match the conditions
311
+ */
312
+ function ComplexEventQuery(query, args) {
313
+ if (args === void 0) { args = {}; }
314
+ var _this = _super.call(this) || this;
315
+ if (!(query instanceof QueryCore)) {
316
+ throw new Error("query parameter was not a CombinedQuery or BaseQuery instance");
317
+ }
318
+ _this.queryObj["$query"] = query.getQuery();
319
+ var filter = {};
320
+ if (args === null || args === void 0 ? void 0 : args.minSentiment) {
321
+ filter["minSentiment"] = args.minSentiment;
322
+ }
323
+ if (args === null || args === void 0 ? void 0 : args.maxSentiment) {
324
+ filter["maxSentiment"] = args.maxSentiment;
325
+ }
326
+ if (Object.keys(filter).length > 0) {
327
+ _this.queryObj["$filter"] = filter;
328
+ }
329
+ return _this;
330
+ }
331
+ return ComplexEventQuery;
332
+ }(QueryCore));
333
+ exports.ComplexEventQuery = ComplexEventQuery;
291
334
  //# sourceMappingURL=query.js.map