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
@@ -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
- }