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.
- package/dist/eventRegistry.d.ts +1 -0
- package/dist/eventRegistry.js +10 -2
- package/dist/eventRegistry.js.map +1 -1
- package/dist/queryArticles.js +1 -1
- package/dist/queryArticles.js.map +1 -1
- package/dist/queryEvent.js +1 -1
- package/dist/queryEvent.js.map +1 -1
- package/dist/queryEvents.js +1 -1
- package/dist/queryEvents.js.map +1 -1
- package/dist/queryMentions.js +1 -1
- package/dist/queryMentions.js.map +1 -1
- package/{src → dist}/types.d.ts +199 -255
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +6 -5
- package/CHANGELOG.md +0 -116
- package/dist/correlations.d.ts +0 -50
- package/dist/correlations.js +0 -397
- package/dist/correlations.js.map +0 -1
- package/examples/autoSuggestionsExamples.ts +0 -46
- package/examples/countsExamples.ts +0 -34
- package/examples/dailySharesExamples.ts +0 -54
- package/examples/eventForTextExamples.ts +0 -32
- package/examples/feedOfNewArticlesExamples.ts +0 -82
- package/examples/feedOfNewEventsExamples.ts +0 -70
- package/examples/queryArticleExamples.ts +0 -42
- package/examples/queryArticlesExamples.ts +0 -248
- package/examples/queryEventExamples.ts +0 -99
- package/examples/queryEventsExamples.ts +0 -232
- package/examples/queryMentionsExamples.ts +0 -20
- package/examples/topicPageExamples.ts +0 -99
- package/examples/trendsExamples.ts +0 -34
- package/src/analytics.ts +0 -181
- package/src/base.ts +0 -198
- package/src/counts.ts +0 -119
- package/src/dailyShares.ts +0 -48
- package/src/eventForText.ts +0 -61
- package/src/eventRegistry.ts +0 -733
- package/src/index.ts +0 -125
- package/src/info.ts +0 -121
- package/src/query.ts +0 -257
- package/src/queryArticle.ts +0 -139
- package/src/queryArticles.ts +0 -608
- package/src/queryEvent.ts +0 -473
- package/src/queryEvents.ts +0 -689
- package/src/queryMentions.ts +0 -516
- package/src/queryStory.ts +0 -152
- package/src/recent.ts +0 -63
- package/src/returnInfo.ts +0 -363
- package/src/topicPage.ts +0 -479
- package/src/trends.ts +0 -63
- package/test/index.d.ts +0 -18
- package/test/jasmine.json +0 -10
- package/test/spec/analytics.spec.ts +0 -150
- package/test/spec/autoSuggestions.spec.ts +0 -54
- package/test/spec/info.spec.ts +0 -84
- package/test/spec/invalidQueries.spec.ts +0 -147
- package/test/spec/queryArticle.spec.ts +0 -62
- package/test/spec/queryArticles.spec.ts +0 -541
- package/test/spec/queryArticlesComplex.spec.ts +0 -298
- package/test/spec/queryEvent.spec.ts +0 -194
- package/test/spec/queryEvents.spec.ts +0 -491
- package/test/spec/queryEventsComplex.spec.ts +0 -188
- package/test/spec/queryPaging.spec.ts +0 -318
- package/test/spec/returnInfo.spec.ts +0 -34
- package/test/spec/topicPage.spec.ts +0 -83
- package/test/spec/utils.ts +0 -436
- package/test/tsconfig.json +0 -31
- package/tsconfig.json +0 -32
- package/tslint.json +0 -25
package/src/index.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export { Analytics } from "./analytics";
|
|
3
|
-
export { QueryItems } from "./base";
|
|
4
|
-
export { GetCounts, GetCountsEx } from "./counts";
|
|
5
|
-
export { GetTopSharedArticles, GetTopSharedEvents } from "./dailyShares";
|
|
6
|
-
export { GetEventForText } from "./eventForText";
|
|
7
|
-
export {
|
|
8
|
-
EventRegistry,
|
|
9
|
-
ArticleMapper,
|
|
10
|
-
} from "./eventRegistry";
|
|
11
|
-
export { sleep, mainLangs, allLangs } from "./base";
|
|
12
|
-
export { EventRegistryStatic } from "./types";
|
|
13
|
-
export {
|
|
14
|
-
GetSourceInfo,
|
|
15
|
-
GetConceptInfo,
|
|
16
|
-
GetCategoryInfo,
|
|
17
|
-
GetSourceStats,
|
|
18
|
-
} from "./info";
|
|
19
|
-
export {
|
|
20
|
-
BaseQuery,
|
|
21
|
-
CombinedQuery,
|
|
22
|
-
ComplexArticleQuery,
|
|
23
|
-
ComplexEventQuery,
|
|
24
|
-
} from "./query";
|
|
25
|
-
export {
|
|
26
|
-
QueryArticle,
|
|
27
|
-
RequestArticleInfo,
|
|
28
|
-
RequestArticleSimilarArticles,
|
|
29
|
-
RequestArticleDuplicatedArticles,
|
|
30
|
-
RequestArticleOriginalArticle,
|
|
31
|
-
} from "./queryArticle";
|
|
32
|
-
export {
|
|
33
|
-
QueryArticles,
|
|
34
|
-
QueryArticlesIter,
|
|
35
|
-
RequestArticlesInfo,
|
|
36
|
-
RequestArticlesUriWgtList,
|
|
37
|
-
RequestArticlesTimeAggr,
|
|
38
|
-
RequestArticlesConceptAggr,
|
|
39
|
-
RequestArticlesCategoryAggr,
|
|
40
|
-
RequestArticlesSourceAggr,
|
|
41
|
-
RequestArticlesKeywordAggr,
|
|
42
|
-
RequestArticlesConceptGraph,
|
|
43
|
-
RequestArticlesConceptMatrix,
|
|
44
|
-
RequestArticlesConceptTrends,
|
|
45
|
-
RequestArticlesDateMentionAggr,
|
|
46
|
-
RequestArticlesRecentActivity,
|
|
47
|
-
} from "./queryArticles";
|
|
48
|
-
export {
|
|
49
|
-
QueryEvent,
|
|
50
|
-
QueryEventArticlesIter,
|
|
51
|
-
RequestEventInfo,
|
|
52
|
-
RequestEventArticles,
|
|
53
|
-
RequestEventArticleUriWgts,
|
|
54
|
-
RequestEventKeywordAggr,
|
|
55
|
-
RequestEventSourceAggr,
|
|
56
|
-
RequestEventDateMentionAggr,
|
|
57
|
-
RequestEventArticleTrend,
|
|
58
|
-
RequestEventSimilarEvents,
|
|
59
|
-
} from "./queryEvent";
|
|
60
|
-
export {
|
|
61
|
-
QueryEvents,
|
|
62
|
-
QueryEventsIter,
|
|
63
|
-
RequestEventsInfo,
|
|
64
|
-
RequestEventsUriWgtList,
|
|
65
|
-
RequestEventsTimeAggr,
|
|
66
|
-
RequestEventsKeywordAggr,
|
|
67
|
-
RequestEventsLocAggr,
|
|
68
|
-
RequestEventsLocTimeAggr,
|
|
69
|
-
RequestEventsConceptAggr,
|
|
70
|
-
RequestEventsConceptGraph,
|
|
71
|
-
RequestEventsConceptMatrix,
|
|
72
|
-
RequestEventsConceptTrends,
|
|
73
|
-
RequestEventsSourceAggr,
|
|
74
|
-
RequestEventsDateMentionAggr,
|
|
75
|
-
RequestEventsEventClusters,
|
|
76
|
-
RequestEventsCategoryAggr,
|
|
77
|
-
RequestEventsRecentActivity,
|
|
78
|
-
} from "./queryEvents";
|
|
79
|
-
export {
|
|
80
|
-
QueryMentions,
|
|
81
|
-
QueryMentionsIter,
|
|
82
|
-
RequestMentions,
|
|
83
|
-
RequestMentionsInfo,
|
|
84
|
-
RequestMentionsUriWgtList,
|
|
85
|
-
RequestMentionsTimeAggr,
|
|
86
|
-
RequestMentionsConceptAggr,
|
|
87
|
-
RequestMentionsCategoryAggr,
|
|
88
|
-
RequestMentionsSourceAggr,
|
|
89
|
-
RequestMentionsKeywordAggr,
|
|
90
|
-
RequestMentionsConceptGraph,
|
|
91
|
-
RequestMentionsRecentActivity,
|
|
92
|
-
} from "./queryMentions";
|
|
93
|
-
export {
|
|
94
|
-
QueryStory,
|
|
95
|
-
RequestStoryInfo,
|
|
96
|
-
RequestStoryArticles,
|
|
97
|
-
RequestStoryArticleUris,
|
|
98
|
-
RequestStoryArticleTrend,
|
|
99
|
-
RequestStorySimilarStories,
|
|
100
|
-
} from "./queryStory";
|
|
101
|
-
export {
|
|
102
|
-
GetRecentEvents,
|
|
103
|
-
GetRecentArticles,
|
|
104
|
-
} from "./recent";
|
|
105
|
-
export {
|
|
106
|
-
ReturnInfo,
|
|
107
|
-
ArticleInfoFlags,
|
|
108
|
-
StoryInfoFlags,
|
|
109
|
-
EventInfoFlags,
|
|
110
|
-
SourceInfoFlags,
|
|
111
|
-
CategoryInfoFlags,
|
|
112
|
-
ConceptInfoFlags,
|
|
113
|
-
LocationInfoFlags,
|
|
114
|
-
ConceptClassInfoFlags,
|
|
115
|
-
ConceptFolderInfoFlags,
|
|
116
|
-
} from "./returnInfo";
|
|
117
|
-
export {
|
|
118
|
-
GetTrendingConcepts,
|
|
119
|
-
GetTrendingCategories,
|
|
120
|
-
GetTrendingCustomItems,
|
|
121
|
-
GetTrendingConceptGroups,
|
|
122
|
-
} from "./trends";
|
|
123
|
-
export {
|
|
124
|
-
TopicPage,
|
|
125
|
-
} from "./topicPage";
|
package/src/info.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import * as _ from "lodash";
|
|
2
|
-
import { QueryParamsBase } from "./base";
|
|
3
|
-
import { ReturnInfo } from "./returnInfo";
|
|
4
|
-
import { EventRegistryStatic } from "./types";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @class GetSourceInfo
|
|
8
|
-
* Obtain desired information about one or more news sources
|
|
9
|
-
*/
|
|
10
|
-
export class GetSourceInfo extends QueryParamsBase {
|
|
11
|
-
/**
|
|
12
|
-
* @param args Object which contains a host of optional parameters
|
|
13
|
-
*/
|
|
14
|
-
constructor(args: EventRegistryStatic.Info.GetSourceInfoArguments = {}) {
|
|
15
|
-
super();
|
|
16
|
-
const {uriOrUriList, returnInfo = new ReturnInfo()} = args;
|
|
17
|
-
this.setVal("action", "getInfo");
|
|
18
|
-
if (!_.isUndefined(uriOrUriList)) {
|
|
19
|
-
this.queryByUri(uriOrUriList);
|
|
20
|
-
}
|
|
21
|
-
this.params = _.extend({}, this.params, returnInfo.getParams("source"));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* search sources by uri(s)
|
|
26
|
-
*/
|
|
27
|
-
public queryByUri(uriOrUriList: string | string[]) {
|
|
28
|
-
this.setVal("uri", uriOrUriList);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* search concepts by id(s)
|
|
33
|
-
*/
|
|
34
|
-
public queryById(idOrIdList: string | string[]) {
|
|
35
|
-
this.setVal("id", idOrIdList);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public get path(): string {
|
|
39
|
-
return "/api/v1/source";
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @class GetConceptInfo
|
|
45
|
-
* Obtain information about concepts
|
|
46
|
-
*/
|
|
47
|
-
export class GetConceptInfo extends QueryParamsBase {
|
|
48
|
-
constructor(args: EventRegistryStatic.Info.GetConceptInfoArguments = {}) {
|
|
49
|
-
super();
|
|
50
|
-
const {uriOrUriList, returnInfo = new ReturnInfo()} = args;
|
|
51
|
-
this.setVal("action", "getInfo");
|
|
52
|
-
if (!_.isUndefined(uriOrUriList)) {
|
|
53
|
-
this.setVal("uri", uriOrUriList);
|
|
54
|
-
}
|
|
55
|
-
this.params = _.extend({}, this.params, returnInfo.getParams("concept"));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
public get path(): string {
|
|
59
|
-
return "/api/v1/concept";
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @class GetCategoryInfo
|
|
65
|
-
* Obtain information about categories
|
|
66
|
-
*/
|
|
67
|
-
export class GetCategoryInfo extends QueryParamsBase {
|
|
68
|
-
constructor(args: EventRegistryStatic.Info.GetCategoryInfoArguments = {}) {
|
|
69
|
-
super();
|
|
70
|
-
const {uriOrUriList, returnInfo = new ReturnInfo()} = args;
|
|
71
|
-
this.setVal("action", "getInfo");
|
|
72
|
-
if (!_.isUndefined(uriOrUriList)) {
|
|
73
|
-
this.queryByUri(uriOrUriList);
|
|
74
|
-
}
|
|
75
|
-
this.params = _.extend({}, this.params, returnInfo.getParams("category"));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* search concepts by uri(s)
|
|
80
|
-
*/
|
|
81
|
-
public queryByUri(uriOrUriList: string | string[]) {
|
|
82
|
-
this.setVal("uri", uriOrUriList);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
public get path(): string {
|
|
86
|
-
return "/api/v1/category";
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* @class GetSourceStats
|
|
92
|
-
* get stats about one or more sources - return json object will include:
|
|
93
|
-
* "uri"
|
|
94
|
-
* "id"
|
|
95
|
-
* "totalArticles" - total number of articles from this source
|
|
96
|
-
* "withStory" - number of articles assigned to a story (cluster)
|
|
97
|
-
* "duplicates" - number of articles that are duplicates of another article
|
|
98
|
-
* "duplicatesFromSameSource" - number of articles that are copies from articles
|
|
99
|
-
* from the same source (not true duplicates, just updates of own articles)
|
|
100
|
-
* "dailyCounts" - json object with date as the key and number of articles for that day as the value
|
|
101
|
-
*/
|
|
102
|
-
export class GetSourceStats extends QueryParamsBase {
|
|
103
|
-
constructor(sourceUri?: string) {
|
|
104
|
-
super();
|
|
105
|
-
this.setVal("action", "getStats");
|
|
106
|
-
if (sourceUri) {
|
|
107
|
-
this.setVal("uri", sourceUri);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* get stats about one or more sources specified by their uris
|
|
113
|
-
*/
|
|
114
|
-
public queryByUri(uriOrUriList: string | string[]) {
|
|
115
|
-
this.setVal("uri", uriOrUriList);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
public get path(): string {
|
|
119
|
-
return "/api/v1/source";
|
|
120
|
-
}
|
|
121
|
-
}
|
package/src/query.ts
DELETED
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
import * as _ from "lodash";
|
|
2
|
-
import { QueryItems, QueryParamsBase } from "./base";
|
|
3
|
-
import { EventRegistryStatic } from "./types";
|
|
4
|
-
|
|
5
|
-
export abstract class QueryCore {
|
|
6
|
-
protected queryObj;
|
|
7
|
-
|
|
8
|
-
constructor() {
|
|
9
|
-
this.queryObj = {};
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
public getQuery() {
|
|
13
|
-
return this.queryObj;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
public setQueryParam(paramName: string, val: unknown) {
|
|
17
|
-
this.queryObj[paramName] = val;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
protected setValIfNotDefault(propName: string, value: unknown, defVal: unknown) {
|
|
21
|
-
if (value !== defVal) {
|
|
22
|
-
this.queryObj[propName] = value;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export class BaseQuery extends QueryCore {
|
|
28
|
-
protected queryObj;
|
|
29
|
-
/**
|
|
30
|
-
* @param args Object which contains a host of optional parameters
|
|
31
|
-
*/
|
|
32
|
-
constructor(args: EventRegistryStatic.Query.BaseQueryArguments = {}) {
|
|
33
|
-
super();
|
|
34
|
-
_.defaults(args, {
|
|
35
|
-
keywordLoc: "body",
|
|
36
|
-
categoryIncludeSub: true,
|
|
37
|
-
});
|
|
38
|
-
this.setQueryArrVal("keyword", args.keyword);
|
|
39
|
-
this.setQueryArrVal("conceptUri", args.conceptUri);
|
|
40
|
-
this.setQueryArrVal("categoryUri", args.categoryUri);
|
|
41
|
-
this.setQueryArrVal("sourceUri", args.sourceUri);
|
|
42
|
-
this.setQueryArrVal("locationUri", args.locationUri);
|
|
43
|
-
this.setQueryArrVal("lang", args.lang);
|
|
44
|
-
|
|
45
|
-
if (!_.isNil(args.dateStart)) {
|
|
46
|
-
this.queryObj["dateStart"] = QueryParamsBase.encodeDateTime(args.dateStart, "YYYY-MM-DD");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (!_.isNil(args.dateEnd)) {
|
|
50
|
-
this.queryObj["dateEnd"] = QueryParamsBase.encodeDateTime(args.dateEnd, "YYYY-MM-DD");
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (!_.isNil(args.dateMention)) {
|
|
54
|
-
if (_.isArray(args.dateMention)) {
|
|
55
|
-
this.queryObj["dateMention"] = _.map(args.dateMention, (date) => QueryParamsBase.encodeDateTime(date, "YYYY-MM-DD"));
|
|
56
|
-
} else {
|
|
57
|
-
this.queryObj["dateMention"] = QueryParamsBase.encodeDateTime(args.dateMention, "YYYY-MM-DD");
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
this.setQueryArrVal("sourceLocationUri", args.sourceLocationUri);
|
|
61
|
-
this.setQueryArrVal("sourceGroupUri", args.sourceGroupUri);
|
|
62
|
-
this.setQueryArrVal("authorUri", args.authorUri);
|
|
63
|
-
|
|
64
|
-
if (!args.categoryIncludeSub) {
|
|
65
|
-
this.queryObj["categoryIncludeSub"] = false;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (args.keywordLoc !== "body") {
|
|
69
|
-
this.queryObj["keywordLoc"] = args.keywordLoc;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (!_.isNil(args.minMaxArticlesInEvent)) {
|
|
73
|
-
if (!_.isArray() || _.size(args.minMaxArticlesInEvent) !== 2) {
|
|
74
|
-
throw new Error("minMaxArticlesInEvent parameter should either be None or a tuple with two integer values");
|
|
75
|
-
}
|
|
76
|
-
this.queryObj["minArticlesInEvent"] = args.minMaxArticlesInEvent[0];
|
|
77
|
-
this.queryObj["maxArticlesInEvent"] = args.minMaxArticlesInEvent[1];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (!_.isNil(args.exclude)) {
|
|
81
|
-
if (!(args.exclude instanceof QueryCore)) {
|
|
82
|
-
throw new Error("exclude parameter was not a CombinedQuery or BaseQuery instance");
|
|
83
|
-
}
|
|
84
|
-
this.queryObj["$not"] = args.exclude.getQuery();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
protected setQueryArrVal(propName, value: string | string[] | QueryItems) {
|
|
89
|
-
if (_.isNil(value)) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (value instanceof QueryItems) {
|
|
93
|
-
_.set(this.queryObj, `${propName}.${value.getOper()}`, value.getItems());
|
|
94
|
-
} else if (_.isString(value)) {
|
|
95
|
-
_.set(this.queryObj, propName, value);
|
|
96
|
-
} else {
|
|
97
|
-
throw new Error(`Parameter '${propName}' was of unsupported type. It should either be undefined, a string or an instance of QueryItems`);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export class CombinedQuery extends QueryCore {
|
|
103
|
-
protected queryObj;
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Create a combined query with multiple items on which to perform an AND operation
|
|
107
|
-
* @param queryArr a list of items on which to perform an AND operation. Items can be either a CombinedQuery or BaseQuery instances.
|
|
108
|
-
* @param exclude Used to filter out results matching the other criteria specified in this query
|
|
109
|
-
*/
|
|
110
|
-
public static AND(queryArr: Array<BaseQuery | CombinedQuery>, exclude?: BaseQuery | CombinedQuery) {
|
|
111
|
-
if (!_.isArray(queryArr)) {
|
|
112
|
-
throw new Error("provided argument as not a list");
|
|
113
|
-
}
|
|
114
|
-
if (_.isEmpty(queryArr)) {
|
|
115
|
-
throw new Error("queryArr had an empty list");
|
|
116
|
-
}
|
|
117
|
-
const query = new CombinedQuery();
|
|
118
|
-
query.queryObj["$and"] = [];
|
|
119
|
-
_.each(queryArr, (item) => {
|
|
120
|
-
if (!(item instanceof QueryCore)) {
|
|
121
|
-
throw new Error("item in the list was not a CombinedQuery or BaseQuery instance");
|
|
122
|
-
}
|
|
123
|
-
query.queryObj["$and"] = [...query.queryObj["$and"], item.getQuery()];
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
if (!_.isNil(exclude)) {
|
|
127
|
-
if (!(exclude instanceof QueryCore)) {
|
|
128
|
-
throw new Error("exclude parameter was not a CombinedQuery or BaseQuery instance");
|
|
129
|
-
}
|
|
130
|
-
query.setQueryParam("$not", exclude.getQuery());
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return query;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Create a combined query with multiple items on which to perform an OR operation
|
|
138
|
-
* @param queryArr A list of items on which to perform an OR operation.
|
|
139
|
-
* @param exclude Used to filter out results matching the other criteria specified in this query.
|
|
140
|
-
*/
|
|
141
|
-
public static OR(queryArr: Array<BaseQuery | CombinedQuery>, exclude?: BaseQuery | CombinedQuery) {
|
|
142
|
-
if (!_.isArray(queryArr)) {
|
|
143
|
-
throw new Error("provided argument as not a list");
|
|
144
|
-
}
|
|
145
|
-
if (_.isEmpty(queryArr)) {
|
|
146
|
-
throw new Error("queryArr had an empty list");
|
|
147
|
-
}
|
|
148
|
-
const query = new CombinedQuery();
|
|
149
|
-
query.queryObj["$or"] = [];
|
|
150
|
-
_.each(queryArr, (item) => {
|
|
151
|
-
if (!(item instanceof QueryCore)) {
|
|
152
|
-
throw new Error("item in the list was not a CombinedQuery or BaseQuery instance");
|
|
153
|
-
}
|
|
154
|
-
query.queryObj["$or"] = [...query.queryObj["$or"], item.getQuery()];
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
if (!_.isNil(exclude)) {
|
|
158
|
-
if (!(exclude instanceof QueryCore)) {
|
|
159
|
-
throw new Error("exclude parameter was not a CombinedQuery or BaseQuery instance");
|
|
160
|
-
}
|
|
161
|
-
query.setQueryParam("$not", exclude.getQuery());
|
|
162
|
-
}
|
|
163
|
-
return query;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* @class ComplexArticleQuery
|
|
169
|
-
* Create an article query using a complex query
|
|
170
|
-
*/
|
|
171
|
-
export class ComplexArticleQuery extends QueryCore {
|
|
172
|
-
protected queryObj;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* @param query An instance of CombinedQuery or BaseQuery to use to find articles that match the conditions
|
|
176
|
-
* @param args Object which contains a host of optional parameters
|
|
177
|
-
*/
|
|
178
|
-
constructor(query: CombinedQuery | BaseQuery, args: EventRegistryStatic.Query.ComplexArticleQueryArguments = {}) {
|
|
179
|
-
super();
|
|
180
|
-
_.defaults(args, {
|
|
181
|
-
dataType: "news",
|
|
182
|
-
minSentiment: undefined,
|
|
183
|
-
maxSentiment: undefined,
|
|
184
|
-
minSocialScore: 0,
|
|
185
|
-
minFacebookShares: 0,
|
|
186
|
-
startSourceRankPercentile: 0,
|
|
187
|
-
endSourceRankPercentile: 0,
|
|
188
|
-
isDuplicateFilter: "keepAll",
|
|
189
|
-
hasDuplicateFilter: "keepAll",
|
|
190
|
-
eventFilter: "keepAll",
|
|
191
|
-
});
|
|
192
|
-
if (!(query instanceof QueryCore)) {
|
|
193
|
-
throw new Error("query parameter was not a CombinedQuery or BaseQuery instance");
|
|
194
|
-
}
|
|
195
|
-
this.queryObj["$query"] = query.getQuery();
|
|
196
|
-
const filter = {};
|
|
197
|
-
if (_.get(args, "dataType") !== "news") {
|
|
198
|
-
filter["dataType"] = _.get(args, "dataType");
|
|
199
|
-
}
|
|
200
|
-
if (!!_.get(args, "minSentiment")) {
|
|
201
|
-
filter["minSentiment"] = _.get(args, "minSentiment");
|
|
202
|
-
}
|
|
203
|
-
if (!!_.get(args, "maxSentiment")) {
|
|
204
|
-
filter["maxSentiment"] = _.get(args, "maxSentiment");
|
|
205
|
-
}
|
|
206
|
-
if (_.get(args, "minSocialScore") > 0) {
|
|
207
|
-
filter["minSocialScore"] = _.get(args, "minSocialScore");
|
|
208
|
-
}
|
|
209
|
-
if (_.get(args, "minFacebookShares") > 0) {
|
|
210
|
-
filter["minFacebookShares"] = _.get(args, "minFacebookShares");
|
|
211
|
-
}
|
|
212
|
-
if (_.get(args, "startSourceRankPercentile") !== 0) {
|
|
213
|
-
filter["startSourceRankPercentile"] = _.get(args, "startSourceRankPercentile");
|
|
214
|
-
}
|
|
215
|
-
if (_.get(args, "endSourceRankPercentile") !== 0) {
|
|
216
|
-
filter["endSourceRankPercentile"] = _.get(args, "endSourceRankPercentile");
|
|
217
|
-
}
|
|
218
|
-
if (_.get(args, "isDuplicateFilter") !== "keepAll") {
|
|
219
|
-
filter["isDuplicate"] = _.get(args, "isDuplicateFilter");
|
|
220
|
-
}
|
|
221
|
-
if (_.get(args, "hasDuplicateFilter") !== "keepAll") {
|
|
222
|
-
filter["hasDuplicate"] = _.get(args, "hasDuplicateFilter");
|
|
223
|
-
}
|
|
224
|
-
if (_.get(args, "eventFilter") !== "keepAll") {
|
|
225
|
-
filter["hasEvent"] = _.get(args, "eventFilter");
|
|
226
|
-
}
|
|
227
|
-
if (!_.isEmpty(filter)) {
|
|
228
|
-
this.queryObj["$filter"] = filter;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* @class ComplexEventQuery
|
|
235
|
-
*/
|
|
236
|
-
export class ComplexEventQuery extends QueryCore {
|
|
237
|
-
/**
|
|
238
|
-
* @param query an instance of CombinedQuery or BaseQuery to use to find events that match the conditions
|
|
239
|
-
*/
|
|
240
|
-
constructor(query: BaseQuery | CombinedQuery, args: EventRegistryStatic.Query.ComplexEventQueryArguments = {}) {
|
|
241
|
-
super();
|
|
242
|
-
if (!(query instanceof QueryCore)) {
|
|
243
|
-
throw new Error("query parameter was not a CombinedQuery or BaseQuery instance");
|
|
244
|
-
}
|
|
245
|
-
this.queryObj["$query"] = query.getQuery();
|
|
246
|
-
const filter = {};
|
|
247
|
-
if (!!_.get(args, "minSentiment")) {
|
|
248
|
-
filter["minSentiment"] = _.get(args, "minSentiment");
|
|
249
|
-
}
|
|
250
|
-
if (!!_.get(args, "maxSentiment")) {
|
|
251
|
-
filter["maxSentiment"] = _.get(args, "maxSentiment");
|
|
252
|
-
}
|
|
253
|
-
if (!_.isEmpty(filter)) {
|
|
254
|
-
this.queryObj["$filter"] = filter;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
package/src/queryArticle.ts
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import * as _ from "lodash";
|
|
2
|
-
import { Query } from "./base";
|
|
3
|
-
import { ArticleInfoFlags, ReturnInfo } from "./returnInfo";
|
|
4
|
-
import { EventRegistryStatic } from "./types";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @class QueryArticle
|
|
8
|
-
* Class for obtaining available info for one or more articles in the Event Registry
|
|
9
|
-
*/
|
|
10
|
-
export class QueryArticle extends Query<RequestArticle> {
|
|
11
|
-
/**
|
|
12
|
-
* @param articleUriOrUriList a single article uri or a list of article uris
|
|
13
|
-
* @param requestedResult the information to return as the result of the query. By default return the information about the article
|
|
14
|
-
*/
|
|
15
|
-
constructor(articleUriOrUriList: string | string[], requestedResult = new RequestArticleInfo()) {
|
|
16
|
-
super();
|
|
17
|
-
this.setVal("action", "getArticle");
|
|
18
|
-
this.setVal("articleUri", articleUriOrUriList);
|
|
19
|
-
this.setRequestedResult(requestedResult);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public get path() {
|
|
23
|
-
return "/api/v1/article";
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Set the single result type that you would like to be returned.
|
|
28
|
-
* If some other request type was previously set, it will be overwritten.
|
|
29
|
-
* Result types can be the classes that extend RequestArticle base class (see classes below).
|
|
30
|
-
*/
|
|
31
|
-
public setRequestedResult(requestArticle) {
|
|
32
|
-
if (!(requestArticle instanceof RequestArticle)) {
|
|
33
|
-
throw Error("QueryArticle class can only accept result requests that are of type RequestArticle");
|
|
34
|
-
}
|
|
35
|
-
this.resultTypeList = [requestArticle];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export class RequestArticle {}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Return details about the article
|
|
44
|
-
*/
|
|
45
|
-
export class RequestArticleInfo extends RequestArticle {
|
|
46
|
-
public resultType = "info";
|
|
47
|
-
public params;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @param returnInfo what details should be included in the returned information
|
|
51
|
-
*/
|
|
52
|
-
constructor(returnInfo = new ReturnInfo({articleInfo: new ArticleInfoFlags({ bodyLen: -1})})) {
|
|
53
|
-
super();
|
|
54
|
-
this.params = returnInfo.getParams("info");
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Return a list of similar articles based on the CCA
|
|
60
|
-
*/
|
|
61
|
-
export class RequestArticleSimilarArticles extends RequestArticle {
|
|
62
|
-
public resultType = "similarArticles";
|
|
63
|
-
public params;
|
|
64
|
-
constructor(args: EventRegistryStatic.QueryArticle.RequestArticleSimilarArticlesArguments = {}) {
|
|
65
|
-
super();
|
|
66
|
-
const {
|
|
67
|
-
page = 1,
|
|
68
|
-
count = 20,
|
|
69
|
-
lang = ["eng"],
|
|
70
|
-
limitPerLang = -1,
|
|
71
|
-
returnInfo = new ReturnInfo({ articleInfo: new ArticleInfoFlags({ bodyLen: -1 })}),
|
|
72
|
-
...unsupported
|
|
73
|
-
} = args;
|
|
74
|
-
if (!_.isEmpty(unsupported)) {
|
|
75
|
-
console.warn(`RequestArticleSimilarArticles: Unsupported parameters detected: ${JSON.stringify(unsupported)}. Please check the documentation.`);
|
|
76
|
-
}
|
|
77
|
-
if (page < 1) {
|
|
78
|
-
throw new RangeError("page has to be >= 1");
|
|
79
|
-
}
|
|
80
|
-
if (count > 200) {
|
|
81
|
-
throw new RangeError("at most 200 articles can be returned per call");
|
|
82
|
-
}
|
|
83
|
-
this.params = {};
|
|
84
|
-
this.params["similarArticlesPage"] = page;
|
|
85
|
-
this.params["similarArticlesCount"] = count;
|
|
86
|
-
this.params["similarArticlesLang"] = lang;
|
|
87
|
-
this.params["similarArticlesLimitPerLang"] = limitPerLang;
|
|
88
|
-
this.params = _.extend({}, this.params, returnInfo.getParams("similarArticles"));
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* return a list of duplicated articles of the current article
|
|
94
|
-
*/
|
|
95
|
-
export class RequestArticleDuplicatedArticles extends RequestArticle {
|
|
96
|
-
public resultType = "duplicatedArticles";
|
|
97
|
-
public params;
|
|
98
|
-
constructor(args: EventRegistryStatic.QueryArticle.RequestArticleDuplicatedArticlesArguments = {}) {
|
|
99
|
-
super();
|
|
100
|
-
const {
|
|
101
|
-
page = 1,
|
|
102
|
-
count = 20,
|
|
103
|
-
sortBy = "cosSim",
|
|
104
|
-
sortByAsc = false,
|
|
105
|
-
returnInfo = new ReturnInfo({ articleInfo: new ArticleInfoFlags({ bodyLen: -1 })}),
|
|
106
|
-
...unsupported
|
|
107
|
-
} = args;
|
|
108
|
-
if (!_.isEmpty(unsupported)) {
|
|
109
|
-
console.warn(`RequestArticleDuplicatedArticles: Unsupported parameters detected: ${JSON.stringify(unsupported)}. Please check the documentation.`);
|
|
110
|
-
}
|
|
111
|
-
if (page < 1) {
|
|
112
|
-
throw new RangeError("page has to be >= 1");
|
|
113
|
-
}
|
|
114
|
-
if (count > 200) {
|
|
115
|
-
throw new RangeError("at most 200 articles can be returned per call");
|
|
116
|
-
}
|
|
117
|
-
this.params = {};
|
|
118
|
-
this.params["duplicatedArticlesPage"] = page;
|
|
119
|
-
this.params["duplicatedArticlesCount"] = count;
|
|
120
|
-
this.params["duplicatedArticlesSortBy"] = sortBy;
|
|
121
|
-
this.params["duplicatedArticlesSortByAsc"] = sortByAsc;
|
|
122
|
-
this.params = _.extend({}, this.params, returnInfo.getParams("duplicatedArticles"));
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* return the article that is the original of the given article (the current article is a duplicate)
|
|
128
|
-
*/
|
|
129
|
-
export class RequestArticleOriginalArticle extends RequestArticle {
|
|
130
|
-
public resultType = "originalArticle";
|
|
131
|
-
public params;
|
|
132
|
-
/**
|
|
133
|
-
* @param returnInfo: what details should be included in the returned information
|
|
134
|
-
*/
|
|
135
|
-
constructor(returnInfo = new ReturnInfo({articleInfo: new ArticleInfoFlags({bodyLen: -1})})) {
|
|
136
|
-
super();
|
|
137
|
-
this.params = returnInfo.getParams("originalArticle");
|
|
138
|
-
}
|
|
139
|
-
}
|