eventregistry 8.10.1 → 8.10.3

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 (70) hide show
  1. package/dist/eventRegistry.d.ts +1 -0
  2. package/dist/eventRegistry.js +10 -2
  3. package/dist/eventRegistry.js.map +1 -1
  4. package/dist/queryArticles.js +1 -1
  5. package/dist/queryArticles.js.map +1 -1
  6. package/dist/queryEvent.js +1 -1
  7. package/dist/queryEvent.js.map +1 -1
  8. package/dist/queryEvents.js +1 -1
  9. package/dist/queryEvents.js.map +1 -1
  10. package/dist/queryMentions.js +1 -1
  11. package/dist/queryMentions.js.map +1 -1
  12. package/{src → dist}/types.d.ts +199 -255
  13. package/dist/types.js +3 -0
  14. package/dist/types.js.map +1 -0
  15. package/package.json +6 -5
  16. package/CHANGELOG.md +0 -116
  17. package/dist/correlations.d.ts +0 -50
  18. package/dist/correlations.js +0 -397
  19. package/dist/correlations.js.map +0 -1
  20. package/examples/autoSuggestionsExamples.ts +0 -46
  21. package/examples/countsExamples.ts +0 -34
  22. package/examples/dailySharesExamples.ts +0 -54
  23. package/examples/eventForTextExamples.ts +0 -32
  24. package/examples/feedOfNewArticlesExamples.ts +0 -82
  25. package/examples/feedOfNewEventsExamples.ts +0 -70
  26. package/examples/queryArticleExamples.ts +0 -42
  27. package/examples/queryArticlesExamples.ts +0 -248
  28. package/examples/queryEventExamples.ts +0 -99
  29. package/examples/queryEventsExamples.ts +0 -232
  30. package/examples/queryMentionsExamples.ts +0 -20
  31. package/examples/topicPageExamples.ts +0 -99
  32. package/examples/trendsExamples.ts +0 -34
  33. package/src/analytics.ts +0 -181
  34. package/src/base.ts +0 -198
  35. package/src/counts.ts +0 -119
  36. package/src/dailyShares.ts +0 -48
  37. package/src/eventForText.ts +0 -61
  38. package/src/eventRegistry.ts +0 -733
  39. package/src/index.ts +0 -125
  40. package/src/info.ts +0 -121
  41. package/src/query.ts +0 -257
  42. package/src/queryArticle.ts +0 -139
  43. package/src/queryArticles.ts +0 -608
  44. package/src/queryEvent.ts +0 -473
  45. package/src/queryEvents.ts +0 -689
  46. package/src/queryMentions.ts +0 -516
  47. package/src/queryStory.ts +0 -152
  48. package/src/recent.ts +0 -63
  49. package/src/returnInfo.ts +0 -363
  50. package/src/topicPage.ts +0 -479
  51. package/src/trends.ts +0 -63
  52. package/test/index.d.ts +0 -18
  53. package/test/jasmine.json +0 -10
  54. package/test/spec/analytics.spec.ts +0 -150
  55. package/test/spec/autoSuggestions.spec.ts +0 -54
  56. package/test/spec/info.spec.ts +0 -84
  57. package/test/spec/invalidQueries.spec.ts +0 -147
  58. package/test/spec/queryArticle.spec.ts +0 -62
  59. package/test/spec/queryArticles.spec.ts +0 -541
  60. package/test/spec/queryArticlesComplex.spec.ts +0 -298
  61. package/test/spec/queryEvent.spec.ts +0 -194
  62. package/test/spec/queryEvents.spec.ts +0 -491
  63. package/test/spec/queryEventsComplex.spec.ts +0 -188
  64. package/test/spec/queryPaging.spec.ts +0 -318
  65. package/test/spec/returnInfo.spec.ts +0 -34
  66. package/test/spec/topicPage.spec.ts +0 -83
  67. package/test/spec/utils.ts +0 -436
  68. package/test/tsconfig.json +0 -31
  69. package/tsconfig.json +0 -32
  70. package/tslint.json +0 -25
package/src/recent.ts DELETED
@@ -1,63 +0,0 @@
1
- import * as _ from "lodash";
2
- import { QueryParamsBase } from "./base";
3
- import { EventRegistry } from "./eventRegistry";
4
- import { ReturnInfo } from "./returnInfo";
5
-
6
- export class GetRecentEvents extends QueryParamsBase {
7
- private er: EventRegistry;
8
- constructor(er: EventRegistry, { mandatoryLang = undefined,
9
- mandatoryLocation = true,
10
- returnInfo = new ReturnInfo(),
11
- } = {}) {
12
- super();
13
- this.er = er;
14
- this.setVal("recentActivityEventsMandatoryLocation", mandatoryLocation);
15
- if (!_.isUndefined(mandatoryLang)) {
16
- this.setVal("recentActivityEventsMandatoryLang", mandatoryLang);
17
- }
18
- this.params = _.extend({}, this.params, returnInfo.getParams("recentActivityEvents"));
19
- }
20
-
21
- public get path() {
22
- return "/api/v1/minuteStreamEvents";
23
- }
24
-
25
- public async getUpdates() {
26
- const response = await this.er.execQuery(this);
27
- return _.get(response, "recentActivityEvents.activity", {});
28
- }
29
- }
30
-
31
- export class GetRecentArticles extends QueryParamsBase {
32
- private er: EventRegistry;
33
- constructor(er: EventRegistry, { mandatorySourceLocation = undefined,
34
- lang = undefined,
35
- returnInfo = new ReturnInfo(),
36
- ...kwargs
37
- } = {}) {
38
- super();
39
- this.er = er;
40
- this.setVal("recentActivityArticlesMandatorySourceLocation", mandatorySourceLocation);
41
- if (!_.isUndefined(lang)) {
42
- this.setVal("recentActivityArticlesLang", lang);
43
- }
44
- this.params = _.extend({}, this.params, kwargs);
45
- this.params = _.extend({}, this.params, returnInfo.getParams("recentActivityArticles"));
46
- }
47
-
48
- public get path() {
49
- return "/api/v1/minuteStreamArticles";
50
- }
51
-
52
- public async getUpdates() {
53
- const response = await this.er.execQuery(this);
54
- if (_.has(response, "recentActivityArticles")) {
55
- for (const [key, value] of _.entries(_.get(response, "recentActivityArticles.newestUri", {}))) {
56
- const splitKey = _.split(key, "");
57
- this.setVal("recentActivityArticles" + _.upperCase(splitKey[0]) + _.join(_.tail(splitKey)), value);
58
- }
59
- return _.get(response, "recentActivityArticles.activity", []);
60
- }
61
- return [];
62
- }
63
- }
package/src/returnInfo.ts DELETED
@@ -1,363 +0,0 @@
1
- import * as _ from "lodash";
2
- import { EventRegistryStatic } from "./types";
3
- import * as fs from "fs";
4
-
5
- export abstract class ReturnInfoFlagsBase<T extends {}> {
6
- protected type: string;
7
- private data = {};
8
-
9
- public setFlag(key: string, value: boolean, defaultValue?: boolean) {
10
- this.setProperty("Include" + this.type + _.upperFirst(key), value, defaultValue);
11
- }
12
-
13
- public setValue(key: string, value: any, defaultValue?: any, skipKeyMod = false) {
14
- const constructedKey = skipKeyMod ? _.upperFirst(key) : this.type + _.upperFirst(key);
15
- this.setProperty(constructedKey, value, defaultValue);
16
- }
17
-
18
- public getProperties(prefix = "") {
19
- return _.mapKeys(this.data, (value, key) => {
20
- if (_.startsWith(_.toLower(key), _.toLower(prefix))) {
21
- return _.camelCase(key);
22
- } else {
23
- return _.camelCase(prefix + key);
24
- }
25
- });
26
- }
27
-
28
- public addProperties(properties: object) {
29
- if (properties instanceof Object) {
30
- for (const name in properties) {
31
- if (properties.hasOwnProperty(name)) {
32
- const value = properties[name];
33
- if (typeof value === "boolean") {
34
- this.setFlag(name, value, !value);
35
- } else {
36
- this.setValue(name, value);
37
- }
38
- }
39
- }
40
- }
41
- }
42
-
43
- private setProperty(key, value, defaultValue?) {
44
- if (value !== defaultValue) {
45
- _.set(this.data, key, value);
46
- }
47
- }
48
-
49
- }
50
-
51
- export class ReturnInfo {
52
- private articleInfo: ArticleInfoFlags;
53
- private eventInfo: EventInfoFlags;
54
- private sourceInfo: SourceInfoFlags;
55
- private categoryInfo: CategoryInfoFlags;
56
- private conceptInfo: ConceptInfoFlags;
57
- private locationInfo: LocationInfoFlags;
58
- private storyInfo: StoryInfoFlags;
59
- private conceptClassInfo: ConceptClassInfoFlags;
60
- private conceptFolderInfo: ConceptFolderInfoFlags;
61
- // Accepts all InfoFlags
62
- constructor({
63
- articleInfo = new ArticleInfoFlags(),
64
- eventInfo = new EventInfoFlags(),
65
- sourceInfo = new SourceInfoFlags(),
66
- categoryInfo = new CategoryInfoFlags(),
67
- conceptInfo = new ConceptInfoFlags(),
68
- locationInfo = new LocationInfoFlags(),
69
- storyInfo = new StoryInfoFlags(),
70
- conceptClassInfo = new ConceptClassInfoFlags(),
71
- conceptFolderInfo = new ConceptFolderInfoFlags(),
72
- ...unsupported
73
- } = {}) {
74
- if (!_.isEmpty(unsupported)) {
75
- console.warn(`ReturnInfo: Unsupported parameters detected: ${JSON.stringify(unsupported)}. Please check the documentation.`);
76
- }
77
- this.articleInfo = articleInfo;
78
- this.eventInfo = eventInfo;
79
- this.sourceInfo = sourceInfo;
80
- this.categoryInfo = categoryInfo;
81
- this.conceptInfo = conceptInfo;
82
- this.locationInfo = locationInfo;
83
- this.storyInfo = storyInfo;
84
- this.conceptClassInfo = conceptClassInfo;
85
- this.conceptFolderInfo = conceptFolderInfo;
86
- }
87
-
88
- public getParams(prefix?: string) {
89
- return _.extend(
90
- {},
91
- this.articleInfo.getProperties(prefix),
92
- this.eventInfo.getProperties(prefix),
93
- this.sourceInfo.getProperties(prefix),
94
- this.categoryInfo.getProperties(prefix),
95
- this.conceptInfo.getProperties(prefix),
96
- this.locationInfo.getProperties(prefix),
97
- this.storyInfo.getProperties(prefix),
98
- this.conceptClassInfo.getProperties(prefix),
99
- this.conceptFolderInfo.getProperties(prefix),
100
- );
101
- }
102
-
103
- /**
104
- * load the configuration for the ReturnInfo from a filename
105
- * @param filename filename that contains the json configuration to use in the ReturnInfo
106
- */
107
- public static loadFromFile(filename: string): ReturnInfo {
108
- if (!(fs && fs.existsSync(filename))) {
109
- throw new Error(`File ${filename} does not exist`);
110
- }
111
- const conf = JSON.parse(fs.readFileSync(filename, "utf8"));
112
- return new ReturnInfo({
113
- articleInfo: new ArticleInfoFlags(_.get(conf, "articleInfo", {})),
114
- eventInfo: new EventInfoFlags(_.get(conf, "eventInfo", {})),
115
- sourceInfo: new SourceInfoFlags(_.get(conf, "sourceInfo", {})),
116
- categoryInfo: new CategoryInfoFlags(_.get(conf, "categoryInfo", {})),
117
- conceptInfo: new ConceptInfoFlags(_.get(conf, "conceptInfo", {})),
118
- locationInfo: new LocationInfoFlags(_.get(conf, "locationInfo", {})),
119
- storyInfo: new StoryInfoFlags(_.get(conf, "storyInfo", {})),
120
- conceptClassInfo: new ConceptClassInfoFlags(_.get(conf, "conceptClassInfo", {})),
121
- conceptFolderInfo: new ConceptFolderInfoFlags(_.get(conf, "conceptFolderInfo", {})),
122
- });
123
- }
124
- }
125
-
126
- export class ArticleInfoFlags extends ReturnInfoFlagsBase<EventRegistryStatic.ReturnInfo.ArticleInfoFlags> {
127
- constructor(params: EventRegistryStatic.ReturnInfo.ArticleInfo = {}) {
128
- super();
129
- this.type = "Article";
130
- const {
131
- bodyLen = -1,
132
- basicInfo = true,
133
- title = true,
134
- body = true,
135
- url = true,
136
- eventUri = true,
137
- authors = true,
138
- concepts = false,
139
- categories = false,
140
- links = false,
141
- videos = false,
142
- image = true,
143
- socialScore = false,
144
- sentiment = true,
145
- location = false,
146
- extractedDates = false,
147
- originalArticle = false,
148
- storyUri = false,
149
- ...properties
150
- } = params;
151
- this.setValue("bodyLen", bodyLen);
152
- this.setFlag("basicInfo", basicInfo);
153
- this.setFlag("title", title);
154
- this.setFlag("body", body);
155
- this.setFlag("url", url);
156
- this.setFlag("eventUri", eventUri);
157
- this.setFlag("authors", authors);
158
- this.setFlag("concepts", concepts);
159
- this.setFlag("categories", categories);
160
- this.setFlag("links", links);
161
- this.setFlag("videos", videos);
162
- this.setFlag("image", image);
163
- this.setFlag("socialScore", socialScore);
164
- this.setFlag("sentiment", sentiment);
165
- this.setFlag("location", location);
166
- this.setFlag("extractedDates", extractedDates);
167
- this.setFlag("originalArticle", originalArticle);
168
- this.setFlag("storyUri", storyUri);
169
- this.addProperties(properties);
170
- }
171
- }
172
-
173
- export class StoryInfoFlags extends ReturnInfoFlagsBase<EventRegistryStatic.ReturnInfo.StoryInfoFlags> {
174
- constructor(params: EventRegistryStatic.ReturnInfo.StoryInfo = {}) {
175
- super();
176
- this.type = "Story";
177
- const {
178
- basicStats = true,
179
- location = true,
180
- date = false,
181
- title = false,
182
- summary = false,
183
- concepts = false,
184
- categories = false,
185
- medoidArticle = false,
186
- infoArticle = false,
187
- commonDates = false,
188
- socialScore = false,
189
- imageCount = 0,
190
- ...properties
191
- } = params;
192
- this.setFlag("basicStats", basicStats);
193
- this.setFlag("location", location);
194
- this.setFlag("date", date);
195
- this.setFlag("title", title);
196
- this.setFlag("summary", summary);
197
- this.setFlag("concepts", concepts);
198
- this.setFlag("categories", categories);
199
- this.setFlag("medoidArticle", medoidArticle);
200
- this.setFlag("infoArticle", infoArticle);
201
- this.setFlag("commonDates", commonDates);
202
- this.setFlag("socialScore", socialScore);
203
- this.setValue("imageCount", imageCount);
204
- this.addProperties(properties);
205
- }
206
- }
207
-
208
- export class EventInfoFlags extends ReturnInfoFlagsBase<EventRegistryStatic.ReturnInfo.EventInfoFlags> {
209
- constructor(params: EventRegistryStatic.ReturnInfo.EventInfo = {}) {
210
- super();
211
- this.type = "Event";
212
- const {
213
- title = true,
214
- summary = true,
215
- articleCounts = true,
216
- concepts = true,
217
- categories = true,
218
- date = true,
219
- commonDates = false,
220
- infoArticle = false,
221
- stories = false,
222
- socialScore = false,
223
- imageCount = 0,
224
- ...properties
225
- } = params;
226
- this.setFlag("title", title);
227
- this.setFlag("summary", summary);
228
- this.setFlag("articleCounts", articleCounts);
229
- this.setFlag("concepts", concepts);
230
- this.setFlag("categories", categories);
231
- this.setFlag("date", date);
232
- this.setFlag("commonDates", commonDates);
233
- this.setFlag("infoArticle", infoArticle as boolean);
234
- this.setFlag("stories", stories);
235
- this.setFlag("socialScore", socialScore);
236
- this.setValue("imageCount", imageCount);
237
- this.addProperties(properties);
238
- }
239
- }
240
-
241
- export class SourceInfoFlags extends ReturnInfoFlagsBase<EventRegistryStatic.ReturnInfo.SourceInfoFlags> {
242
- constructor(params: EventRegistryStatic.ReturnInfo.SourceInfo = {}) {
243
- super();
244
- const {
245
- title = true,
246
- description = false,
247
- location = false,
248
- ranking = false,
249
- image = false,
250
- socialMedia = false,
251
- ...properties
252
- } = params;
253
- this.type = "Source";
254
- this.setFlag("title", title);
255
- this.setFlag("description", description);
256
- this.setFlag("location", location);
257
- this.setFlag("ranking", ranking);
258
- this.setFlag("image", image);
259
- this.setFlag("socialMedia", socialMedia);
260
- this.addProperties(properties);
261
- }
262
- }
263
-
264
- export class CategoryInfoFlags extends ReturnInfoFlagsBase<EventRegistryStatic.ReturnInfo.CategoryInfoFlags> {
265
- constructor(params: EventRegistryStatic.ReturnInfo.CategoryInfo = {}) {
266
- super();
267
- this.type = "Category";
268
- const {
269
- trendingScore = true,
270
- ...properties
271
- } = params;
272
- this.setFlag("trendingScore", trendingScore);
273
- this.addProperties(properties);
274
- }
275
- }
276
-
277
- export class ConceptInfoFlags extends ReturnInfoFlagsBase<EventRegistryStatic.ReturnInfo.ConceptInfoFlags> {
278
- constructor(params: EventRegistryStatic.ReturnInfo.ConceptInfo = {}) {
279
- super();
280
- this.type = "Concept";
281
- const {
282
- type = "concepts",
283
- lang = "eng",
284
- label = true,
285
- synonyms = false,
286
- image = false,
287
- description = false,
288
- trendingScore = false,
289
- maxConceptsPerType = 20,
290
- ...properties
291
- } = params;
292
- this.setValue("type", type);
293
- this.setValue("lang", lang);
294
- this.setFlag("label", label);
295
- this.setFlag("synonyms", synonyms);
296
- this.setFlag("image", image);
297
- this.setFlag("description", description);
298
- this.setFlag("trendingScore", trendingScore);
299
- this.setValue("maxConceptsPerType", maxConceptsPerType, 20, true);
300
- this.addProperties(properties);
301
- }
302
- }
303
-
304
- export class LocationInfoFlags extends ReturnInfoFlagsBase<EventRegistryStatic.ReturnInfo.LocationInfoFlags> {
305
- constructor(params: EventRegistryStatic.ReturnInfo.LocationInfo = {}) {
306
- super();
307
- this.type = "Location";
308
- const {
309
- label = true,
310
- wikiUri = false,
311
- geoNamesId = false,
312
- population = false,
313
- geoLocation = false,
314
- countryArea = false,
315
- countryDetails = false,
316
- countryContinent = false,
317
- placeFeatureCode = false,
318
- placeCountry = true,
319
- ...properties
320
- } = params;
321
- this.setFlag("label", label);
322
- this.setFlag("wikiUri", wikiUri);
323
- this.setFlag("geoNamesId", geoNamesId);
324
- this.setFlag("population", population);
325
- this.setFlag("geoLocation", geoLocation);
326
- this.setFlag("countryArea", countryArea);
327
- this.setFlag("countryDetails", countryDetails);
328
- this.setFlag("countryContinent", countryContinent);
329
- this.setFlag("placeFeatureCode", placeFeatureCode);
330
- this.setFlag("placeCountry", placeCountry);
331
- this.addProperties(properties);
332
- }
333
- }
334
-
335
- export class ConceptClassInfoFlags extends ReturnInfoFlagsBase<EventRegistryStatic.ReturnInfo.ConceptClassInfoFlags> {
336
- constructor(params: EventRegistryStatic.ReturnInfo.ConceptClassInfo = {}) {
337
- super();
338
- this.type = "ConceptClass";
339
- const {
340
- parentLabels = true,
341
- concepts = false,
342
- ...properties
343
- } = params;
344
- this.setFlag("parentLabels", parentLabels);
345
- this.setFlag("concepts", concepts);
346
- this.addProperties(properties);
347
- }
348
- }
349
-
350
- export class ConceptFolderInfoFlags extends ReturnInfoFlagsBase<EventRegistryStatic.ReturnInfo.ConceptFolderInfoFlags> {
351
- constructor(params: EventRegistryStatic.ReturnInfo.ConceptFolderInfo = {}) {
352
- super();
353
- this.type = "ConceptFolder";
354
- const {
355
- definition = true,
356
- owner = false,
357
- ...properties
358
- } = params;
359
- this.setFlag("owner", definition);
360
- this.setFlag("owner", owner);
361
- this.addProperties(properties);
362
- }
363
- }