eventregistry 8.10.1 → 8.10.2

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 (59) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/{src → dist}/types.d.ts +199 -255
  3. package/dist/types.js +3 -0
  4. package/dist/types.js.map +1 -0
  5. package/package.json +6 -5
  6. package/dist/correlations.d.ts +0 -50
  7. package/dist/correlations.js +0 -397
  8. package/dist/correlations.js.map +0 -1
  9. package/examples/autoSuggestionsExamples.ts +0 -46
  10. package/examples/countsExamples.ts +0 -34
  11. package/examples/dailySharesExamples.ts +0 -54
  12. package/examples/eventForTextExamples.ts +0 -32
  13. package/examples/feedOfNewArticlesExamples.ts +0 -82
  14. package/examples/feedOfNewEventsExamples.ts +0 -70
  15. package/examples/queryArticleExamples.ts +0 -42
  16. package/examples/queryArticlesExamples.ts +0 -248
  17. package/examples/queryEventExamples.ts +0 -99
  18. package/examples/queryEventsExamples.ts +0 -232
  19. package/examples/queryMentionsExamples.ts +0 -20
  20. package/examples/topicPageExamples.ts +0 -99
  21. package/examples/trendsExamples.ts +0 -34
  22. package/src/analytics.ts +0 -181
  23. package/src/base.ts +0 -198
  24. package/src/counts.ts +0 -119
  25. package/src/dailyShares.ts +0 -48
  26. package/src/eventForText.ts +0 -61
  27. package/src/eventRegistry.ts +0 -733
  28. package/src/index.ts +0 -125
  29. package/src/info.ts +0 -121
  30. package/src/query.ts +0 -257
  31. package/src/queryArticle.ts +0 -139
  32. package/src/queryArticles.ts +0 -608
  33. package/src/queryEvent.ts +0 -473
  34. package/src/queryEvents.ts +0 -689
  35. package/src/queryMentions.ts +0 -516
  36. package/src/queryStory.ts +0 -152
  37. package/src/recent.ts +0 -63
  38. package/src/returnInfo.ts +0 -363
  39. package/src/topicPage.ts +0 -479
  40. package/src/trends.ts +0 -63
  41. package/test/index.d.ts +0 -18
  42. package/test/jasmine.json +0 -10
  43. package/test/spec/analytics.spec.ts +0 -150
  44. package/test/spec/autoSuggestions.spec.ts +0 -54
  45. package/test/spec/info.spec.ts +0 -84
  46. package/test/spec/invalidQueries.spec.ts +0 -147
  47. package/test/spec/queryArticle.spec.ts +0 -62
  48. package/test/spec/queryArticles.spec.ts +0 -541
  49. package/test/spec/queryArticlesComplex.spec.ts +0 -298
  50. package/test/spec/queryEvent.spec.ts +0 -194
  51. package/test/spec/queryEvents.spec.ts +0 -491
  52. package/test/spec/queryEventsComplex.spec.ts +0 -188
  53. package/test/spec/queryPaging.spec.ts +0 -318
  54. package/test/spec/returnInfo.spec.ts +0 -34
  55. package/test/spec/topicPage.spec.ts +0 -83
  56. package/test/spec/utils.ts +0 -436
  57. package/test/tsconfig.json +0 -31
  58. package/tsconfig.json +0 -32
  59. package/tslint.json +0 -25
@@ -1,436 +0,0 @@
1
- import * as _ from "lodash";
2
- import {
3
- ArticleInfoFlags,
4
- CategoryInfoFlags,
5
- ConceptInfoFlags,
6
- EventInfoFlags,
7
- EventRegistry,
8
- LocationInfoFlags,
9
- QueryArticles,
10
- QueryEvents,
11
- RequestArticlesUriWgtList,
12
- RequestEventsUriWgtList,
13
- ReturnInfo,
14
- SourceInfoFlags,
15
- StoryInfoFlags,
16
-
17
- } from "../../src/index";
18
-
19
- interface ValidationObj {
20
- pass: boolean;
21
- message?: string;
22
- }
23
-
24
- export class Utils {
25
-
26
- public articleInfo;
27
- public sourceInfo;
28
- public conceptInfo;
29
- public locationInfo;
30
- public categoryInfo;
31
- public eventInfo;
32
- public storyInfo;
33
- public returnInfo: ReturnInfo;
34
- public er: EventRegistry;
35
-
36
- constructor() {
37
- jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
38
- this.articleInfo = new ArticleInfoFlags({ concepts: true,
39
- storyUri: true,
40
- originalArticle: true,
41
- categories: true,
42
- videos: true,
43
- image: true,
44
- location: true,
45
- extractedDates: true,
46
- socialScore: true,
47
- duplicateList: true,
48
- });
49
- this.sourceInfo = new SourceInfoFlags({ description: true,
50
- location: true,
51
- ranking: true,
52
- image: true,
53
- articleCount: true,
54
- socialMedia: true,
55
- sourceGroups: true,
56
- });
57
- this.conceptInfo = new ConceptInfoFlags({ type: ["concepts", "entities"],
58
- lang: ["eng", "spa"],
59
- synonyms: true,
60
- image: true,
61
- description: true,
62
- trendingScore: true,
63
- maxConceptsPerType: 50,
64
- });
65
- this.locationInfo = new LocationInfoFlags({ wikiUri: true,
66
- label: true,
67
- geoNamesId: true,
68
- geoLocation: true,
69
- population: true,
70
- countryArea: true,
71
- countryDetails: true,
72
- countryContinent: true,
73
- placeFeatureCode: true,
74
- placeCountry: true,
75
- });
76
- this.categoryInfo = new CategoryInfoFlags({ trendingScore: true });
77
- this.eventInfo = new EventInfoFlags({ commonDates: true, stories: true, socialScore: true, categories: true, imageCount: 2 });
78
- this.storyInfo = new StoryInfoFlags({ categories: true,
79
- date: true,
80
- concepts: true,
81
- title: true,
82
- summary: true,
83
- medoidArticle: true,
84
- commonDates: true,
85
- socialScore: true,
86
- imageCount: 2,
87
- });
88
- this.returnInfo = new ReturnInfo({ articleInfo: this.articleInfo,
89
- sourceInfo: this.sourceInfo,
90
- conceptInfo: this.conceptInfo,
91
- locationInfo: this.locationInfo,
92
- categoryInfo: this.categoryInfo,
93
- eventInfo: this.eventInfo,
94
- storyInfo: this.storyInfo,
95
- });
96
- }
97
-
98
- public static initAPI(): EventRegistry {
99
- return new EventRegistry();
100
- }
101
-
102
- public async getArticlesQueryUriListForComplexQuery(er, cq) {
103
- const q = QueryArticles.initWithComplexQuery(cq);
104
- return await this.getQueryUriListForQueryArticles(er, q);
105
- }
106
-
107
- public async getEventsQueryUriListForComplexQuery(er, cq) {
108
- const q = QueryEvents.initWithComplexQuery(cq);
109
- return await this.getQueryUriListForQueryEvents(er, q);
110
- }
111
-
112
- public async getQueryUriListForQueryArticles(er, q) {
113
- const requestArticlesUriList = new RequestArticlesUriWgtList({count: 50000});
114
- q.setRequestedResult(requestArticlesUriList);
115
- const response = await er.execQuery(q);
116
- if (_.has(response, "error")) {
117
- throw new Error(_.get(response, "error"));
118
- }
119
-
120
- return _.get(response, "uriWgtList");
121
- }
122
-
123
- public async getQueryUriListForQueryEvents(er, q) {
124
- const requestEventsUriList = new RequestEventsUriWgtList({count: 50000});
125
- q.setRequestedResult(requestEventsUriList);
126
- const response = await er.execQuery(q);
127
- if (_.has(response, "error")) {
128
- throw new Error(_.get(response, "error"));
129
- }
130
-
131
- return _.get(response, "uriWgtList");
132
- }
133
-
134
- public ensureValidConcept(concept) {
135
- let result: ValidationObj = { pass: true };
136
- const propertyNames = ["uri", "label", "synonyms", "image", "trendingScore"];
137
- result = this.validateProperties(concept, "concept", propertyNames);
138
- if (!_.includes(["person", "loc", "org", "wiki"], _.get(concept, "type"))) {
139
- result = { pass: false, message: `Expected concept to be an entity type, but got ${_.get(concept, "type")}` };
140
- }
141
-
142
- if (_.has(concept, "location") && !_.isNil(_.get(concept, "location"))) {
143
- result = this.ensureValidLocation(_.get(concept, "location"));
144
- }
145
-
146
- return result;
147
- }
148
-
149
- public ensureValidLocation(location) {
150
- let result = { pass: true };
151
- const propertyNames = ["wikiUri", "label", "lat", "long", "geoNamesId", "population"];
152
- result = this.validateProperties(location, "location", propertyNames);
153
- switch (_.get(location, "type")) {
154
- case "country":
155
- result = this.validateProperties(location, "location", ["area", "code2", "code3", "webExt", "continent"]);
156
- break;
157
- case "place":
158
- result = this.validateProperties(location, "location", ["featureCode", "country"]);
159
- break;
160
- }
161
- return result;
162
- }
163
-
164
- public ensureValidArticle(article) {
165
- let result: ValidationObj = { pass: true };
166
- const propertyNames = [ "url",
167
- "uri",
168
- "title",
169
- "body",
170
- "source",
171
- "location",
172
- "duplicateList",
173
- "originalArticle",
174
- "time",
175
- "date",
176
- "categories",
177
- "lang",
178
- "extractedDates",
179
- "concepts",
180
- ];
181
- result = this.validateProperties(article, "article", propertyNames);
182
-
183
- _.each(_.get(article, "concepts", []), (concept) => {
184
- result = this.ensureValidConcept(concept);
185
- });
186
- if (!_.get(article, "isDuplicate") && !_.has(article, "eventUri")) {
187
- result = {pass: false, message: "Non duplicates should have event uris "};
188
- }
189
- return result;
190
- }
191
-
192
- public ensureValidEvent(event) {
193
- let result: ValidationObj = { pass: true };
194
- const propertyNames = [ "uri",
195
- "title",
196
- "summary",
197
- "articleCounts",
198
- "concepts",
199
- "categories",
200
- "location",
201
- "eventDate",
202
- "commonDates",
203
- "stories",
204
- "socialScore",
205
- "images",
206
- ];
207
- result = this.validateProperties(event, "event", propertyNames);
208
-
209
- _.each(_.get(event, "concepts", []), (concept) => {
210
- result = this.ensureValidConcept(concept);
211
- });
212
-
213
- _.each(_.get(event, "stories", []), (story) => {
214
- result = this.ensureValidStory(story);
215
- });
216
-
217
- _.each(_.get(event, "categories", []), (category) => {
218
- result = this.ensureValidCategory(category);
219
- });
220
-
221
- if (_.has(event, "location") && !_.isNil(_.get(event, "location"))) {
222
- result = this.ensureValidLocation(_.get(event, "location"));
223
- }
224
- return result;
225
- }
226
-
227
- public ensureValidStory(story) {
228
- const propertyNames = [ "uri",
229
- "title",
230
- "summary",
231
- "concepts",
232
- "categories",
233
- "location",
234
- "storyDate",
235
- "averageDate",
236
- "commonDates",
237
- "socialScore",
238
- "images",
239
- ];
240
- let result = this.validateProperties(story, "story", propertyNames);
241
- if (_.has(story, "location") && !_.isNil(_.get(story, "location"))) {
242
- result = this.ensureValidLocation(_.get(story, "location"));
243
- }
244
- return result;
245
- }
246
-
247
- public ensureValidGeneralArticleList(articleList) {
248
- let result: ValidationObj = { pass: true };
249
- if (!_.has(articleList, "articles")) {
250
- result = { pass: false, message: "Expected to get 'articles'" };
251
- }
252
- _.each(_.get(articleList, "articles.results", []), (article) => {
253
- result = this.ensureValidArticle(article);
254
- });
255
- return result;
256
- }
257
-
258
- public ensureValidGeneralEventList(eventList) {
259
- let result: ValidationObj = { pass: true };
260
- if (!_.has(eventList, "events")) {
261
- result = { pass: false, message: "Expected to get 'events'" };
262
- }
263
- _.each(_.get(eventList, "events.results", []), (event) => {
264
- result = this.ensureValidEvent(event);
265
- });
266
- return result;
267
- }
268
-
269
- public ensureValidCategory(category) {
270
- const propertyNames = ["uri", "trendingScore"];
271
- return this.validateProperties(category, "category", propertyNames);
272
- }
273
-
274
- public ensureValidSource(source) {
275
- const propertyNames = ["uri", "title", "description", "image", "favicon", "location", "ranking", "socialMedia"];
276
- return this.validateProperties(source, "source", propertyNames);
277
- }
278
-
279
- public ensureItemHasConcept(item, conceptUri) {
280
- if (!_.has(item, "concepts")) {
281
- return { pass: false, message: "Item doesn't contain concept array"};
282
- }
283
-
284
- if (!_.find(_.get(item, "concepts", []), ({uri}) => uri === conceptUri )) {
285
- return { pass: false, message: `Item doesn't contain ${conceptUri}`};
286
- }
287
- return { pass: true };
288
- }
289
-
290
- public ensureItemHasCategory(item, categoryUri) {
291
- if (!_.has(item, "categories")) {
292
- return { pass: false, message: "Item doesn't contain categories array"};
293
- }
294
-
295
- if (!_.some(_.get(item, "categories", []), (category) => _.includes(_.get(category, "uri"), categoryUri) )) {
296
- return { pass: false, message: `Item doesn't contain ${categoryUri}`};
297
- }
298
- return { pass: true };
299
- }
300
-
301
- public ensureItemHasSource(item, sourceUri) {
302
- if (_.get(item, "source.uri") !== sourceUri) {
303
- return {pass: false, message: `Source is not '${sourceUri}'`};
304
- }
305
- return { pass: true };
306
- }
307
-
308
- public ensureArticleBodyContainsText(article, text) {
309
- if (!_.has(article, "body")) {
310
- return { pass: false, message: "Article did not contain body"};
311
- }
312
- if (!this.doesContainText(_.get(article, "body", ""), text)) {
313
- return { pass: false, message: `"Article body did not contain text '${text}'`};
314
- }
315
- return { pass: true };
316
- }
317
-
318
- public ensureObjectContains(obj, propName: string) {
319
- if (!_.has(obj, propName)) {
320
- return { pass: false, message: `Specified object doesn't contain property ${propName}.`};
321
- }
322
- return { pass: true};
323
- }
324
-
325
- private validateProperties(item: object, objectName: string, propertyNames: string[]): ValidationObj {
326
- for (const propName of propertyNames) {
327
- if (!_.has(item, propName)) {
328
- return { pass: false, message: `Property '${propName}' was expected in a ${objectName}.` };
329
- }
330
- }
331
- return { pass: true };
332
- }
333
-
334
- private doesContainText(text, searchQuery) {
335
- return _.includes(_.deburr(text), _.deburr(searchQuery));
336
- }
337
- }
338
-
339
- const utils = new Utils();
340
-
341
- beforeEach(() => {
342
- jasmine.DEFAULT_TIMEOUT_INTERVAL = 120 * 1000;
343
- jasmine.addMatchers({
344
- toBeValidConcept: () => {
345
- return {
346
- compare: (concept) => {
347
- return utils.ensureValidConcept(concept);
348
- },
349
- };
350
- },
351
- toBeValidArticle: () => {
352
- return {
353
- compare: (article) => {
354
- return utils.ensureValidArticle(article);
355
- },
356
- };
357
- },
358
- toBeValidEvent: () => {
359
- return {
360
- compare: (event) => {
361
- return utils.ensureValidEvent(event);
362
- },
363
- };
364
- },
365
- toBeValidGeneralEventList: () => {
366
- return {
367
- compare: (eventList) => {
368
- return utils.ensureValidGeneralEventList(eventList);
369
- },
370
- };
371
- },
372
- toBeValidStory: () => {
373
- return {
374
- compare: (story) => {
375
- return utils.ensureValidStory(story);
376
- },
377
- };
378
- },
379
- toBeValidGeneralArticleList: () => {
380
- return {
381
- compare: (articleList) => {
382
- return utils.ensureValidGeneralArticleList(articleList);
383
- },
384
- };
385
- },
386
- toBeValidCategory: () => {
387
- return {
388
- compare: (category) => {
389
- return utils.ensureValidCategory(category);
390
- },
391
- };
392
- },
393
- toBeValidSource: () => {
394
- return {
395
- compare: (source) => {
396
- return utils.ensureValidSource(source);
397
- },
398
- };
399
- },
400
- toContainConcept: () => {
401
- return {
402
- compare: (item, conceptUri) => {
403
- return utils.ensureItemHasConcept(item, conceptUri);
404
- },
405
- };
406
- },
407
- toContainSource: () => {
408
- return {
409
- compare: (item, sourceUri) => {
410
- return utils.ensureItemHasSource(item, sourceUri);
411
- },
412
- };
413
- },
414
- toContainCategory: () => {
415
- return {
416
- compare: (item, categoryUri) => {
417
- return utils.ensureItemHasCategory(item, categoryUri);
418
- },
419
- };
420
- },
421
- toContainBodyText: () => {
422
- return {
423
- compare: (article, text) => {
424
- return utils.ensureArticleBodyContainsText(article, text);
425
- },
426
- };
427
- },
428
- toHaveProperty: () => {
429
- return {
430
- compare: (obj, propName) => {
431
- return utils.ensureObjectContains(obj, propName);
432
- },
433
- };
434
- },
435
- });
436
- });
@@ -1,31 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es5",
4
- "experimentalDecorators": true,
5
- "noImplicitAny": false,
6
- "module": "commonjs",
7
- "sourceMap": true,
8
- "alwaysStrict": true,
9
- "outDir": "dist/",
10
- "typeRoots": [
11
- "../node_modules/@types"
12
- ],
13
- "lib": [
14
- "dom",
15
- "es2015",
16
- "es5",
17
- "es6",
18
- "es2017",
19
- "esnext"
20
- ]
21
- },
22
- "include": [
23
- "./spec/**/*.ts"
24
- ],
25
- "files": [
26
- "index.d.ts"
27
- ],
28
- "exclude": [
29
- "node_modules"
30
- ]
31
- }
package/tsconfig.json DELETED
@@ -1,32 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es5",
4
- "experimentalDecorators": true,
5
- "noImplicitAny": false,
6
- "module": "commonjs",
7
- "moduleResolution": "node",
8
- "downlevelIteration": true,
9
- "declaration": true,
10
- "sourceMap": true,
11
- "alwaysStrict": true,
12
- "outDir": "dist/",
13
- "typeRoots": [
14
- "node_modules/@types"
15
- ],
16
- "lib": [
17
- "dom",
18
- "es2015",
19
- "es5",
20
- "es6",
21
- "es2017",
22
- "esnext",
23
- ]
24
- },
25
- "include": [
26
- "src/types.d.ts",
27
- "src/index.ts"
28
- ],
29
- "exclude": [
30
- "node_modules"
31
- ]
32
- }
package/tslint.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- "extends": "tslint:recommended",
3
- "rules": {
4
- "max-line-length": [true, 240],
5
- "ordered-imports": false,
6
- "object-literal-sort-keys": false,
7
- "object-literal-shorthand": false,
8
- "member-ordering": false,
9
- "no-string-literal": false,
10
- "no-unnecessary-initializer": false,
11
- "trailing-comma": [true, {"esSpecCompliant": true}],
12
- "radix": false,
13
- "no-bitwise": false,
14
- "max-classes-per-file": false,
15
- "interface-name": [
16
- false
17
- ],
18
- "variable-name": [
19
- false
20
- ],
21
- "no-console": [
22
- false
23
- ]
24
- }
25
- }