eventregistry 9.1.1 → 10.0.0
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/CHANGELOG.md +207 -0
- package/LICENSE +21 -21
- package/MIGRATION.md +177 -0
- package/README.md +292 -234
- package/dist/{analytics.d.ts → cjs/analytics.d.ts} +2 -1
- package/dist/cjs/analytics.js +174 -0
- package/dist/cjs/analytics.js.map +1 -0
- package/dist/{base.d.ts → cjs/base.d.ts} +9 -9
- package/dist/cjs/base.js +189 -0
- package/dist/cjs/base.js.map +1 -0
- package/dist/cjs/counts.js +120 -0
- package/dist/cjs/counts.js.map +1 -0
- package/dist/cjs/dailyShares.js +46 -0
- package/dist/cjs/dailyShares.js.map +1 -0
- package/dist/{data.d.ts → cjs/data.d.ts} +32 -5
- package/dist/cjs/data.js.map +1 -0
- package/dist/{eventForText.d.ts → cjs/eventForText.d.ts} +1 -1
- package/dist/cjs/eventForText.js +61 -0
- package/dist/cjs/eventForText.js.map +1 -0
- package/dist/{eventRegistry.d.ts → cjs/eventRegistry.d.ts} +127 -28
- package/dist/cjs/eventRegistry.js +887 -0
- package/dist/cjs/eventRegistry.js.map +1 -0
- package/dist/cjs/fluent/analytics.d.ts +24 -0
- package/dist/cjs/fluent/analytics.js +47 -0
- package/dist/cjs/fluent/analytics.js.map +1 -0
- package/dist/cjs/fluent/articles.d.ts +23 -0
- package/dist/cjs/fluent/articles.js +34 -0
- package/dist/cjs/fluent/articles.js.map +1 -0
- package/dist/cjs/fluent/counts.d.ts +8 -0
- package/dist/cjs/fluent/counts.js +17 -0
- package/dist/cjs/fluent/counts.js.map +1 -0
- package/dist/cjs/fluent/eventForText.d.ts +4 -0
- package/dist/cjs/fluent/eventForText.js +8 -0
- package/dist/cjs/fluent/eventForText.js.map +1 -0
- package/dist/cjs/fluent/events.d.ts +23 -0
- package/dist/cjs/fluent/events.js +34 -0
- package/dist/cjs/fluent/events.js.map +1 -0
- package/dist/cjs/fluent/info.d.ts +10 -0
- package/dist/cjs/fluent/info.js +23 -0
- package/dist/cjs/fluent/info.js.map +1 -0
- package/dist/cjs/fluent/mentions.d.ts +18 -0
- package/dist/cjs/fluent/mentions.js +31 -0
- package/dist/cjs/fluent/mentions.js.map +1 -0
- package/dist/cjs/fluent/recent.d.ts +8 -0
- package/dist/cjs/fluent/recent.js +17 -0
- package/dist/cjs/fluent/recent.js.map +1 -0
- package/dist/cjs/fluent/shares.d.ts +8 -0
- package/dist/cjs/fluent/shares.js +17 -0
- package/dist/cjs/fluent/shares.js.map +1 -0
- package/dist/cjs/fluent/stories.d.ts +8 -0
- package/dist/cjs/fluent/stories.js +14 -0
- package/dist/cjs/fluent/stories.js.map +1 -0
- package/dist/cjs/fluent/topicPages.d.ts +10 -0
- package/dist/cjs/fluent/topicPages.js +20 -0
- package/dist/cjs/fluent/topicPages.js.map +1 -0
- package/dist/cjs/fluent/trends.d.ts +11 -0
- package/dist/cjs/fluent/trends.js +23 -0
- package/dist/cjs/fluent/trends.js.map +1 -0
- package/dist/cjs/helpers/analytics.d.ts +68 -0
- package/dist/cjs/helpers/analytics.js +100 -0
- package/dist/cjs/helpers/analytics.js.map +1 -0
- package/dist/cjs/helpers/articles.d.ts +24 -0
- package/dist/cjs/helpers/articles.js +31 -0
- package/dist/cjs/helpers/articles.js.map +1 -0
- package/dist/cjs/helpers/counts.d.ts +4 -0
- package/dist/cjs/helpers/counts.js +12 -0
- package/dist/cjs/helpers/counts.js.map +1 -0
- package/dist/cjs/helpers/eventForText.d.ts +6 -0
- package/dist/cjs/helpers/eventForText.js +13 -0
- package/dist/cjs/helpers/eventForText.js.map +1 -0
- package/dist/cjs/helpers/events.d.ts +18 -0
- package/dist/cjs/helpers/events.js +31 -0
- package/dist/cjs/helpers/events.js.map +1 -0
- package/dist/cjs/helpers/info.d.ts +6 -0
- package/dist/cjs/helpers/info.js +20 -0
- package/dist/cjs/helpers/info.js.map +1 -0
- package/dist/cjs/helpers/mentions.d.ts +10 -0
- package/dist/cjs/helpers/mentions.js +21 -0
- package/dist/cjs/helpers/mentions.js.map +1 -0
- package/dist/cjs/helpers/recent.d.ts +10 -0
- package/dist/cjs/helpers/recent.js +18 -0
- package/dist/cjs/helpers/recent.js.map +1 -0
- package/dist/cjs/helpers/shares.d.ts +4 -0
- package/dist/cjs/helpers/shares.js +12 -0
- package/dist/cjs/helpers/shares.js.map +1 -0
- package/dist/cjs/helpers/stories.d.ts +7 -0
- package/dist/cjs/helpers/stories.js +13 -0
- package/dist/cjs/helpers/stories.js.map +1 -0
- package/dist/cjs/helpers/topicPages.d.ts +16 -0
- package/dist/cjs/helpers/topicPages.js +29 -0
- package/dist/cjs/helpers/topicPages.js.map +1 -0
- package/dist/cjs/helpers/trends.d.ts +7 -0
- package/dist/cjs/helpers/trends.js +20 -0
- package/dist/cjs/helpers/trends.js.map +1 -0
- package/dist/cjs/helpers/uri.d.ts +42 -0
- package/dist/cjs/helpers/uri.js +78 -0
- package/dist/cjs/helpers/uri.js.map +1 -0
- package/dist/cjs/http.d.ts +18 -0
- package/dist/cjs/http.js +88 -0
- package/dist/cjs/http.js.map +1 -0
- package/dist/cjs/index.d.ts +47 -0
- package/dist/{index.js → cjs/index.js} +90 -2
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/info.js +115 -0
- package/dist/cjs/info.js.map +1 -0
- package/dist/{logger.d.ts → cjs/logger.d.ts} +13 -11
- package/dist/cjs/logger.js +179 -0
- package/dist/cjs/logger.js.map +1 -0
- package/dist/cjs/mutex.d.ts +6 -0
- package/dist/cjs/mutex.js +27 -0
- package/dist/cjs/mutex.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/{query.d.ts → cjs/query.d.ts} +5 -8
- package/dist/cjs/query.js +248 -0
- package/dist/cjs/query.js.map +1 -0
- package/dist/{queryArticle.d.ts → cjs/queryArticle.d.ts} +5 -5
- package/dist/cjs/queryArticle.js +120 -0
- package/dist/cjs/queryArticle.js.map +1 -0
- package/dist/{queryArticles.d.ts → cjs/queryArticles.d.ts} +40 -73
- package/dist/cjs/queryArticles.js +456 -0
- package/dist/cjs/queryArticles.js.map +1 -0
- package/dist/{queryEvent.d.ts → cjs/queryEvent.d.ts} +6 -6
- package/dist/cjs/queryEvent.js +417 -0
- package/dist/cjs/queryEvent.js.map +1 -0
- package/dist/{queryEvents.d.ts → cjs/queryEvents.d.ts} +30 -39
- package/dist/cjs/queryEvents.js +567 -0
- package/dist/cjs/queryEvents.js.map +1 -0
- package/dist/cjs/queryIterator.d.ts +34 -0
- package/dist/cjs/queryIterator.js +77 -0
- package/dist/cjs/queryIterator.js.map +1 -0
- package/dist/{queryMentions.d.ts → cjs/queryMentions.d.ts} +18 -18
- package/dist/cjs/queryMentions.js +440 -0
- package/dist/cjs/queryMentions.js.map +1 -0
- package/dist/{queryStory.d.ts → cjs/queryStory.d.ts} +23 -23
- package/dist/cjs/queryStory.js +120 -0
- package/dist/cjs/queryStory.js.map +1 -0
- package/dist/{recent.d.ts → cjs/recent.d.ts} +8 -8
- package/dist/cjs/recent.js +63 -0
- package/dist/cjs/recent.js.map +1 -0
- package/dist/{returnInfo.d.ts → cjs/returnInfo.d.ts} +21 -23
- package/dist/cjs/returnInfo.js +292 -0
- package/dist/cjs/returnInfo.js.map +1 -0
- package/dist/{topicPage.d.ts → cjs/topicPage.d.ts} +3 -3
- package/dist/cjs/topicPage.js +454 -0
- package/dist/cjs/topicPage.js.map +1 -0
- package/dist/cjs/topicPages.d.ts +13 -0
- package/dist/cjs/topicPages.js +22 -0
- package/dist/cjs/topicPages.js.map +1 -0
- package/dist/{trends.d.ts → cjs/trends.d.ts} +13 -13
- package/dist/cjs/trends.js +64 -0
- package/dist/cjs/trends.js.map +1 -0
- package/dist/{types.d.ts → cjs/types.d.ts} +135 -33
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/version.d.ts +1 -0
- package/dist/cjs/version.js +5 -0
- package/dist/cjs/version.js.map +1 -0
- package/dist/esm/analytics.d.ts +83 -0
- package/dist/esm/analytics.js +170 -0
- package/dist/esm/analytics.js.map +1 -0
- package/dist/esm/base.d.ts +82 -0
- package/dist/esm/base.js +182 -0
- package/dist/esm/base.js.map +1 -0
- package/dist/esm/counts.d.ts +81 -0
- package/dist/esm/counts.js +114 -0
- package/dist/esm/counts.js.map +1 -0
- package/dist/esm/dailyShares.d.ts +10 -0
- package/dist/esm/dailyShares.js +41 -0
- package/dist/esm/dailyShares.js.map +1 -0
- package/dist/esm/data.d.ts +296 -0
- package/dist/esm/data.js +3 -0
- package/dist/esm/data.js.map +1 -0
- package/dist/esm/eventForText.d.ts +48 -0
- package/dist/esm/eventForText.js +57 -0
- package/dist/esm/eventForText.js.map +1 -0
- package/dist/esm/eventRegistry.d.ts +343 -0
- package/dist/esm/eventRegistry.js +849 -0
- package/dist/esm/eventRegistry.js.map +1 -0
- package/dist/esm/fluent/analytics.d.ts +24 -0
- package/dist/esm/fluent/analytics.js +43 -0
- package/dist/esm/fluent/analytics.js.map +1 -0
- package/dist/esm/fluent/articles.d.ts +23 -0
- package/dist/esm/fluent/articles.js +30 -0
- package/dist/esm/fluent/articles.js.map +1 -0
- package/dist/esm/fluent/counts.d.ts +8 -0
- package/dist/esm/fluent/counts.js +13 -0
- package/dist/esm/fluent/counts.js.map +1 -0
- package/dist/esm/fluent/eventForText.d.ts +4 -0
- package/dist/esm/fluent/eventForText.js +5 -0
- package/dist/esm/fluent/eventForText.js.map +1 -0
- package/dist/esm/fluent/events.d.ts +23 -0
- package/dist/esm/fluent/events.js +30 -0
- package/dist/esm/fluent/events.js.map +1 -0
- package/dist/esm/fluent/info.d.ts +10 -0
- package/dist/esm/fluent/info.js +19 -0
- package/dist/esm/fluent/info.js.map +1 -0
- package/dist/esm/fluent/mentions.d.ts +18 -0
- package/dist/esm/fluent/mentions.js +27 -0
- package/dist/esm/fluent/mentions.js.map +1 -0
- package/dist/esm/fluent/recent.d.ts +8 -0
- package/dist/esm/fluent/recent.js +13 -0
- package/dist/esm/fluent/recent.js.map +1 -0
- package/dist/esm/fluent/shares.d.ts +8 -0
- package/dist/esm/fluent/shares.js +13 -0
- package/dist/esm/fluent/shares.js.map +1 -0
- package/dist/esm/fluent/stories.d.ts +8 -0
- package/dist/esm/fluent/stories.js +10 -0
- package/dist/esm/fluent/stories.js.map +1 -0
- package/dist/esm/fluent/topicPages.d.ts +10 -0
- package/dist/esm/fluent/topicPages.js +16 -0
- package/dist/esm/fluent/topicPages.js.map +1 -0
- package/dist/esm/fluent/trends.d.ts +11 -0
- package/dist/esm/fluent/trends.js +19 -0
- package/dist/esm/fluent/trends.js.map +1 -0
- package/dist/esm/helpers/analytics.d.ts +68 -0
- package/dist/esm/helpers/analytics.js +86 -0
- package/dist/esm/helpers/analytics.js.map +1 -0
- package/dist/esm/helpers/articles.d.ts +24 -0
- package/dist/esm/helpers/articles.js +26 -0
- package/dist/esm/helpers/articles.js.map +1 -0
- package/dist/esm/helpers/counts.d.ts +4 -0
- package/dist/esm/helpers/counts.js +8 -0
- package/dist/esm/helpers/counts.js.map +1 -0
- package/dist/esm/helpers/eventForText.d.ts +6 -0
- package/dist/esm/helpers/eventForText.js +10 -0
- package/dist/esm/helpers/eventForText.js.map +1 -0
- package/dist/esm/helpers/events.d.ts +18 -0
- package/dist/esm/helpers/events.js +26 -0
- package/dist/esm/helpers/events.js.map +1 -0
- package/dist/esm/helpers/info.d.ts +6 -0
- package/dist/esm/helpers/info.js +14 -0
- package/dist/esm/helpers/info.js.map +1 -0
- package/dist/esm/helpers/mentions.d.ts +10 -0
- package/dist/esm/helpers/mentions.js +17 -0
- package/dist/esm/helpers/mentions.js.map +1 -0
- package/dist/esm/helpers/recent.d.ts +10 -0
- package/dist/esm/helpers/recent.js +14 -0
- package/dist/esm/helpers/recent.js.map +1 -0
- package/dist/esm/helpers/shares.d.ts +4 -0
- package/dist/esm/helpers/shares.js +8 -0
- package/dist/esm/helpers/shares.js.map +1 -0
- package/dist/esm/helpers/stories.d.ts +7 -0
- package/dist/esm/helpers/stories.js +10 -0
- package/dist/esm/helpers/stories.js.map +1 -0
- package/dist/esm/helpers/topicPages.d.ts +16 -0
- package/dist/esm/helpers/topicPages.js +24 -0
- package/dist/esm/helpers/topicPages.js.map +1 -0
- package/dist/esm/helpers/trends.d.ts +7 -0
- package/dist/esm/helpers/trends.js +14 -0
- package/dist/esm/helpers/trends.js.map +1 -0
- package/dist/esm/helpers/uri.d.ts +42 -0
- package/dist/esm/helpers/uri.js +68 -0
- package/dist/esm/helpers/uri.js.map +1 -0
- package/dist/esm/http.d.ts +18 -0
- package/dist/esm/http.js +85 -0
- package/dist/esm/http.js.map +1 -0
- package/dist/esm/index.d.ts +47 -0
- package/dist/esm/index.js +47 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/info.d.ts +61 -0
- package/dist/esm/info.js +108 -0
- package/dist/esm/info.js.map +1 -0
- package/dist/esm/logger.d.ts +47 -0
- package/dist/esm/logger.js +142 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/mutex.d.ts +6 -0
- package/dist/esm/mutex.js +23 -0
- package/dist/esm/mutex.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/query.d.ts +50 -0
- package/dist/esm/query.js +240 -0
- package/dist/esm/query.js.map +1 -0
- package/dist/esm/queryArticle.d.ts +61 -0
- package/dist/esm/queryArticle.js +111 -0
- package/dist/esm/queryArticle.js.map +1 -0
- package/dist/esm/queryArticles.d.ts +111 -0
- package/dist/esm/queryArticles.js +438 -0
- package/dist/esm/queryArticles.js.map +1 -0
- package/dist/esm/queryEvent.d.ts +140 -0
- package/dist/esm/queryEvent.js +403 -0
- package/dist/esm/queryEvent.js.map +1 -0
- package/dist/esm/queryEvents.d.ts +201 -0
- package/dist/esm/queryEvents.js +545 -0
- package/dist/esm/queryEvents.js.map +1 -0
- package/dist/esm/queryIterator.d.ts +34 -0
- package/dist/esm/queryIterator.js +73 -0
- package/dist/esm/queryIterator.js.map +1 -0
- package/dist/esm/queryMentions.d.ts +96 -0
- package/dist/esm/queryMentions.js +425 -0
- package/dist/esm/queryMentions.js.map +1 -0
- package/dist/esm/queryStory.d.ts +58 -0
- package/dist/esm/queryStory.js +110 -0
- package/dist/esm/queryStory.js.map +1 -0
- package/dist/esm/recent.d.ts +23 -0
- package/dist/esm/recent.js +58 -0
- package/dist/esm/recent.js.map +1 -0
- package/dist/esm/returnInfo.d.ts +66 -0
- package/dist/esm/returnInfo.js +245 -0
- package/dist/esm/returnInfo.js.map +1 -0
- package/dist/esm/topicPage.d.ts +157 -0
- package/dist/esm/topicPage.js +417 -0
- package/dist/esm/topicPage.js.map +1 -0
- package/dist/esm/topicPages.d.ts +13 -0
- package/dist/esm/topicPages.js +18 -0
- package/dist/esm/topicPages.js.map +1 -0
- package/dist/esm/trends.d.ts +35 -0
- package/dist/esm/trends.js +56 -0
- package/dist/esm/trends.js.map +1 -0
- package/dist/esm/types.d.ts +2555 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/version.d.ts +1 -0
- package/dist/esm/version.js +2 -0
- package/dist/esm/version.js.map +1 -0
- package/package.json +71 -42
- package/src/analytics.ts +197 -0
- package/src/base.ts +200 -0
- package/src/counts.ts +118 -0
- package/src/dailyShares.ts +46 -0
- package/src/data.ts +310 -0
- package/src/eventForText.ts +60 -0
- package/src/eventRegistry.ts +1005 -0
- package/src/fluent/analytics.ts +84 -0
- package/src/fluent/articles.ts +40 -0
- package/src/fluent/counts.ts +15 -0
- package/src/fluent/eventForText.ts +10 -0
- package/src/fluent/events.ts +40 -0
- package/src/fluent/info.ts +23 -0
- package/src/fluent/mentions.ts +34 -0
- package/src/fluent/recent.ts +15 -0
- package/src/fluent/shares.ts +15 -0
- package/src/fluent/stories.ts +12 -0
- package/src/fluent/topicPages.ts +20 -0
- package/src/fluent/trends.ts +34 -0
- package/src/helpers/analytics.ts +134 -0
- package/src/helpers/articles.ts +42 -0
- package/src/helpers/counts.ts +19 -0
- package/src/helpers/eventForText.ts +16 -0
- package/src/helpers/events.ts +43 -0
- package/src/helpers/info.ts +31 -0
- package/src/helpers/mentions.ts +27 -0
- package/src/helpers/recent.ts +22 -0
- package/src/helpers/shares.ts +17 -0
- package/src/helpers/stories.ts +16 -0
- package/src/helpers/topicPages.ts +28 -0
- package/src/helpers/trends.ts +36 -0
- package/src/helpers/uri.ts +78 -0
- package/src/http.ts +110 -0
- package/src/index.ts +205 -0
- package/src/info.ts +120 -0
- package/src/logger.ts +177 -0
- package/src/mutex.ts +22 -0
- package/src/query.ts +258 -0
- package/src/queryArticle.ts +138 -0
- package/src/queryArticles.ts +576 -0
- package/src/queryEvent.ts +503 -0
- package/src/queryEvents.ts +672 -0
- package/src/queryIterator.ts +89 -0
- package/src/queryMentions.ts +552 -0
- package/src/queryStory.ts +152 -0
- package/src/recent.ts +73 -0
- package/src/returnInfo.ts +372 -0
- package/src/topicPage.ts +481 -0
- package/src/topicPages.ts +18 -0
- package/src/trends.ts +62 -0
- package/src/types.ts +2678 -0
- package/src/version.ts +1 -0
- package/dist/analytics.js +0 -337
- package/dist/analytics.js.map +0 -1
- package/dist/base.js +0 -262
- package/dist/base.js.map +0 -1
- package/dist/counts.js +0 -163
- package/dist/counts.js.map +0 -1
- package/dist/dailyShares.js +0 -91
- package/dist/dailyShares.js.map +0 -1
- package/dist/data.js.map +0 -1
- package/dist/eventForText.js +0 -127
- package/dist/eventForText.js.map +0 -1
- package/dist/eventRegistry.js +0 -1099
- package/dist/eventRegistry.js.map +0 -1
- package/dist/index.d.ts +0 -21
- package/dist/index.js.map +0 -1
- package/dist/info.js +0 -172
- package/dist/info.js.map +0 -1
- package/dist/logger.js +0 -156
- package/dist/logger.js.map +0 -1
- package/dist/query.js +0 -334
- package/dist/query.js.map +0 -1
- package/dist/queryArticle.js +0 -184
- package/dist/queryArticle.js.map +0 -1
- package/dist/queryArticles.js +0 -730
- package/dist/queryArticles.js.map +0 -1
- package/dist/queryEvent.js +0 -588
- package/dist/queryEvent.js.map +0 -1
- package/dist/queryEvents.js +0 -826
- package/dist/queryEvents.js.map +0 -1
- package/dist/queryMentions.js +0 -638
- package/dist/queryMentions.js.map +0 -1
- package/dist/queryStory.js +0 -195
- package/dist/queryStory.js.map +0 -1
- package/dist/recent.js +0 -200
- package/dist/recent.js.map +0 -1
- package/dist/returnInfo.js +0 -333
- package/dist/returnInfo.js.map +0 -1
- package/dist/topicPage.js +0 -600
- package/dist/topicPage.js.map +0 -1
- package/dist/trends.js +0 -116
- package/dist/trends.js.map +0 -1
- package/dist/types.js.map +0 -1
- /package/dist/{counts.d.ts → cjs/counts.d.ts} +0 -0
- /package/dist/{dailyShares.d.ts → cjs/dailyShares.d.ts} +0 -0
- /package/dist/{data.js → cjs/data.js} +0 -0
- /package/dist/{info.d.ts → cjs/info.d.ts} +0 -0
- /package/dist/{types.js → cjs/types.js} +0 -0
package/src/topicPage.ts
ADDED
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import { QueryParamsBase } from "./base";
|
|
3
|
+
import { EventRegistry } from "./eventRegistry";
|
|
4
|
+
import { ReturnInfo } from "./returnInfo";
|
|
5
|
+
import { ER } from "./types";
|
|
6
|
+
import { ErHttpResponse } from "./http";
|
|
7
|
+
|
|
8
|
+
export class TopicPage extends QueryParamsBase {
|
|
9
|
+
private topicPage: ER.TopicPage;
|
|
10
|
+
private readonly emptyTopicPage: ER.TopicPage = {
|
|
11
|
+
autoAddArticles: true,
|
|
12
|
+
articleHasDuplicate: "keepAll",
|
|
13
|
+
articleHasEvent: "keepAll",
|
|
14
|
+
articleIsDuplicate: "skipDuplicates",
|
|
15
|
+
maxDaysBack: 7,
|
|
16
|
+
articleTreshWgt: 0,
|
|
17
|
+
eventTreshWgt: 0,
|
|
18
|
+
concepts: [],
|
|
19
|
+
keywords: [],
|
|
20
|
+
categories: [],
|
|
21
|
+
sources: [],
|
|
22
|
+
sourceGroups: [],
|
|
23
|
+
sourceLocations: [],
|
|
24
|
+
locations: [],
|
|
25
|
+
langs: [],
|
|
26
|
+
restrictToSetConcepts: false,
|
|
27
|
+
restrictToSetCategories: false,
|
|
28
|
+
restrictToSetSources: false,
|
|
29
|
+
restrictToSetLocations: false,
|
|
30
|
+
dataType: [ "news" ]
|
|
31
|
+
};
|
|
32
|
+
private concept: ErHttpResponse<ER.Response> = {} as ErHttpResponse<ER.Response>;
|
|
33
|
+
|
|
34
|
+
constructor(private eventRegistry: EventRegistry) {
|
|
35
|
+
super();
|
|
36
|
+
this.topicPage = this.createEmptyTopicPage();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private isTopicPage(definition: object): definition is ER.TopicPage {
|
|
40
|
+
return Object.keys(this.emptyTopicPage).sort().toString() === Object.keys(definition).sort().toString();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private createEmptyTopicPage(): ER.TopicPage {
|
|
44
|
+
return this.emptyTopicPage;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Load an existing topic page from Event Registry based on the topic page URI
|
|
49
|
+
* @param uri uri of the topic page saved in your Event Registry account
|
|
50
|
+
*/
|
|
51
|
+
public async loadTopicPageFromER(uri: string) {
|
|
52
|
+
const params = {
|
|
53
|
+
action: "getTopicPageJson",
|
|
54
|
+
includeConceptDescription: true,
|
|
55
|
+
includeConceptImage: true,
|
|
56
|
+
includeTopicPageDefinition: true,
|
|
57
|
+
includeTopicPageOwner: true,
|
|
58
|
+
uri: uri
|
|
59
|
+
};
|
|
60
|
+
this.topicPage = this.createEmptyTopicPage();
|
|
61
|
+
this.concept = await this.eventRegistry.jsonRequest("/api/v1/topicPage", params);
|
|
62
|
+
if (this.concept?.data?.error) {
|
|
63
|
+
throw new Error(this.concept.data.error || "");
|
|
64
|
+
}
|
|
65
|
+
this.topicPage = {...this.topicPage, ...(this.concept.data?.topicPage || {})};
|
|
66
|
+
return this.topicPage;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Load the topic page definition from an object
|
|
71
|
+
* @param definition topic page definition
|
|
72
|
+
*/
|
|
73
|
+
public loadTopicPageFromDefinition(definition: object) {
|
|
74
|
+
if (this.isTopicPage(definition)) {
|
|
75
|
+
this.topicPage = definition;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Load topic page from an existing file
|
|
81
|
+
* @param filepath file that contains the topic page definition
|
|
82
|
+
*/
|
|
83
|
+
public loadTopicPageFromFile(filepath: string) {
|
|
84
|
+
if (fs && fs.existsSync(filepath)) {
|
|
85
|
+
const definition = JSON.parse(fs.readFileSync(filepath, "utf8"));
|
|
86
|
+
if (this.isTopicPage(definition)) {
|
|
87
|
+
this.topicPage = definition;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Return an object containing the topic page definition. you can use it to load a topic page later
|
|
94
|
+
*/
|
|
95
|
+
public saveTopicPageDefinition(): ER.TopicPage {
|
|
96
|
+
return this.topicPage;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Save the topic page definition to a file
|
|
101
|
+
* @param filepath location of the file to which you'll save the topic page definition
|
|
102
|
+
*/
|
|
103
|
+
public saveTopicPageDefinitionToFile(filepath: string) {
|
|
104
|
+
fs.writeFileSync(filepath, JSON.stringify(this.topicPage, null, 4), "utf8");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* What is the minimum total weight that an article has to have in order to get it among the results?
|
|
109
|
+
*/
|
|
110
|
+
public set articleThreshold(value: number) {
|
|
111
|
+
if (typeof value === "number" && value >= 0) {
|
|
112
|
+
this.topicPage.articleTreshWgt = value;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* What is the minimum total weight that an event has to have in order to get it among the results?
|
|
118
|
+
*/
|
|
119
|
+
public set eventThreshold(value: number) {
|
|
120
|
+
if (typeof value === "number" && value >= 0) {
|
|
121
|
+
this.topicPage.eventTreshWgt = value;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Some articles can be duplicates of other articles. What should be done with them. Possible values are:
|
|
127
|
+
* "skipDuplicates" (skip the resulting articles that are duplicates of other articles),
|
|
128
|
+
* "keepOnlyDuplicates" (return only the duplicate articles) and
|
|
129
|
+
* "keepAll" (no filtering, default)
|
|
130
|
+
*/
|
|
131
|
+
public set articleIsDuplicateFilter(value: "skipDuplicates" | "keepOnlyDuplicates" | "keepAll") {
|
|
132
|
+
if (value === "skipDuplicates" || value === "keepOnlyDuplicates" || value === "keepAll") {
|
|
133
|
+
this.topicPage.articleIsDuplicate = value;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Some articles describe a known event and some don't. This filter allows you to filter the resulting articles based on this criteria.
|
|
139
|
+
* Possible values are:
|
|
140
|
+
* "skipArticlesWithoutEvent" (skip articles that are not describing any known event in ER),
|
|
141
|
+
* "keepOnlyArticlesWithoutEvent" (return only the articles that are not describing any known event in ER) and
|
|
142
|
+
* "keepAll" (no filtering, default)
|
|
143
|
+
*/
|
|
144
|
+
public set articleHasEventFilter(value: "skipArticlesWithoutEvent" | "keepOnlyArticlesWithoutEvent" | "keepAll") {
|
|
145
|
+
if (value === "skipArticlesWithoutEvent" || value === "keepOnlyArticlesWithoutEvent" || value === "keepAll") {
|
|
146
|
+
this.topicPage.articleHasEvent = value;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Some articles are later copied by others. What should be done with such articles. Possible values are:
|
|
152
|
+
* "skipHasDuplicates" (skip the articles that have been later copied by others),
|
|
153
|
+
* "keepOnlyHasDuplicates" (return only the articles that have been later copied by others) and
|
|
154
|
+
* "keepAll" (no filtering, default)
|
|
155
|
+
*/
|
|
156
|
+
public set articleHasDuplicateFilter(value: "skipHasDuplicates" | "keepOnlyHasDuplicates" | "keepAll") {
|
|
157
|
+
if (value === "skipHasDuplicates" || value === "keepOnlyHasDuplicates" || value === "keepAll") {
|
|
158
|
+
this.topicPage.articleHasDuplicate = value;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* What data types should we search? "news" (news content, default), "pr" (press releases), or "blog".
|
|
164
|
+
* If you want to use multiple data types, put them in an array (e.g. ["news", "pr"])
|
|
165
|
+
*/
|
|
166
|
+
public set dataTypes(dataTypes: ER.DataType | ER.DataType[]) {
|
|
167
|
+
this.topicPage.dataType = dataTypes;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
public set sourceRankStartPercentile(startPercentile: number) {
|
|
171
|
+
if (startPercentile === undefined) {
|
|
172
|
+
startPercentile = 0;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (startPercentile < 0 || startPercentile > 90) {
|
|
176
|
+
throw new RangeError("startPercentile is out of valid values (0 - 90)");
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (this.topicPage.endSourceRankPercentile !== null && typeof this.topicPage.endSourceRankPercentile === "number" && startPercentile >= this.topicPage.endSourceRankPercentile) {
|
|
180
|
+
throw new RangeError("startPercentile has to be smaller than endPercentile");
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (startPercentile % 10 !== 0) {
|
|
184
|
+
throw new Error("startPecentile has to be a multiple of 10");
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
this.topicPage.startSourceRankPercentile = startPercentile;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
public set sourceRankEndPercentile(endPercentile: number) {
|
|
191
|
+
if (endPercentile === undefined) {
|
|
192
|
+
endPercentile = 100;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (endPercentile < 10 || endPercentile > 100) {
|
|
196
|
+
throw new RangeError("endPercentile is out of valid values (10 - 100)");
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (this.topicPage.startSourceRankPercentile !== null && typeof this.topicPage.startSourceRankPercentile === 'number' && this.topicPage.startSourceRankPercentile >= endPercentile) {
|
|
200
|
+
throw new RangeError("startPercentile has to be smaller than endPercentile");
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (endPercentile % 10 !== 0) {
|
|
204
|
+
throw new Error("endPercentile has to be a multiple of 10");
|
|
205
|
+
}
|
|
206
|
+
this.topicPage.endSourceRankPercentile = endPercentile;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* What is the maximum allowed age of the results?
|
|
211
|
+
*/
|
|
212
|
+
public set maxDaysBack(maxDaysBack: number) {
|
|
213
|
+
if (typeof maxDaysBack !== "number" || maxDaysBack < 0) {
|
|
214
|
+
throw new Error("maxDaysBack value has to be a positive number");
|
|
215
|
+
}
|
|
216
|
+
if (maxDaysBack <= 0) {
|
|
217
|
+
throw new RangeError("maxDaysBack value has to be a positive number");
|
|
218
|
+
}
|
|
219
|
+
this.topicPage.maxDaysBack = maxDaysBack;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
public clearConcepts() {
|
|
223
|
+
this.topicPage.concepts = [];
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
public clearKeywords() {
|
|
227
|
+
this.topicPage.keywords = [];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
public clearCategories() {
|
|
231
|
+
this.topicPage.categories = [];
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
public clearSources() {
|
|
235
|
+
this.topicPage.sources = [];
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
public clearSourceLocations() {
|
|
239
|
+
this.topicPage.sourceLocations = [];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
public clearSourceGroups() {
|
|
243
|
+
this.topicPage.sourceGroups = [];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
public clearLocations() {
|
|
247
|
+
this.topicPage.locations = [];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Add a relevant concept to the topic page
|
|
252
|
+
* @param uri uri of the concept to be added
|
|
253
|
+
* @param weight importance of the provided concept (typically in range 1 - 50)
|
|
254
|
+
*/
|
|
255
|
+
public addConcept(uri: string, wgt: number, args: ER.TopicPageAddConceptArguments = {}) {
|
|
256
|
+
if (typeof wgt !== "number") {
|
|
257
|
+
throw new Error("Weight value has to be a positive or negative number");
|
|
258
|
+
}
|
|
259
|
+
const {
|
|
260
|
+
label,
|
|
261
|
+
conceptType,
|
|
262
|
+
required = false,
|
|
263
|
+
excluded = false
|
|
264
|
+
} = args;
|
|
265
|
+
if (required && excluded) {
|
|
266
|
+
throw new Error("Parameters required and excluded can not be true at the same time");
|
|
267
|
+
}
|
|
268
|
+
const concept: Record<string, string | number | boolean> = { uri, wgt, required, excluded };
|
|
269
|
+
if (label !== undefined) {
|
|
270
|
+
concept.label = label;
|
|
271
|
+
}
|
|
272
|
+
if (conceptType !== undefined) {
|
|
273
|
+
concept.type = conceptType;
|
|
274
|
+
}
|
|
275
|
+
this.topicPage.concepts = [...this.topicPage.concepts, concept];
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Add a relevant keyword to the topic page
|
|
280
|
+
* @param keyword keyword or phrase to be added
|
|
281
|
+
* @param weight importance of the provided keyword (typically in range 1 - 50)
|
|
282
|
+
*/
|
|
283
|
+
public addKeyword(keyword: string, wgt: number, args: ER.TopicPageAddKeywordArguments = {}) {
|
|
284
|
+
if (typeof wgt !== "number") {
|
|
285
|
+
throw new Error("Weight value has to be a positive or negative number");
|
|
286
|
+
}
|
|
287
|
+
const {
|
|
288
|
+
required = false,
|
|
289
|
+
excluded = false
|
|
290
|
+
} = args;
|
|
291
|
+
this.topicPage.keywords = [...this.topicPage.keywords, {keyword, wgt, required, excluded}];
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Add a relevant category to the topic page
|
|
296
|
+
* @param uri uri of the category to be added
|
|
297
|
+
* @param weight importance of the provided category (typically in range 1 - 50)
|
|
298
|
+
*/
|
|
299
|
+
public addCategory(uri: string, wgt: number, args: ER.TopicPageAddCategoryArguments = {}) {
|
|
300
|
+
if (typeof wgt !== "number") {
|
|
301
|
+
throw new Error("Weight value has to be a positive or negative number");
|
|
302
|
+
}
|
|
303
|
+
const {
|
|
304
|
+
required = false,
|
|
305
|
+
excluded = false
|
|
306
|
+
} = args;
|
|
307
|
+
this.topicPage.categories = [...this.topicPage.categories, {uri, wgt, required, excluded}];
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Add a news source to the topic page
|
|
312
|
+
* @param uri uri of the news source to add to the topic page
|
|
313
|
+
* @param weight importance of the news source (typically in range 1 - 50)
|
|
314
|
+
*/
|
|
315
|
+
public addSource(uri: string, wgt: number, args: ER.TopicPageAddSourceArguments = {}) {
|
|
316
|
+
if (typeof wgt !== "number") {
|
|
317
|
+
throw new Error("Weight value has to be a positive or negative number");
|
|
318
|
+
}
|
|
319
|
+
const {
|
|
320
|
+
excluded = false
|
|
321
|
+
} = args;
|
|
322
|
+
this.topicPage.sources = [...this.topicPage.sources, {uri, wgt, excluded}];
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Add a list of relevant sources by identifying them by their geographic location
|
|
327
|
+
* @param uri uri of the location where the sources should be geographically located
|
|
328
|
+
* @param weight importance of the provided list of sources (typically in range 1 - 50)
|
|
329
|
+
*/
|
|
330
|
+
public addSourceLocation(uri: string, wgt: number, args: ER.TopicPageAddSourceLocationArguments = {}) {
|
|
331
|
+
if (typeof wgt !== "number") {
|
|
332
|
+
throw new Error("Weight value has to be a positive or negative number");
|
|
333
|
+
}
|
|
334
|
+
const {
|
|
335
|
+
excluded = false
|
|
336
|
+
} = args;
|
|
337
|
+
this.topicPage.sourceLocations = [...this.topicPage.sourceLocations, {uri, wgt, excluded}];
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Add a list of relevant sources by specifying a whole source group to the topic page
|
|
342
|
+
* @param sourceGroupUri uri of the source group to add
|
|
343
|
+
* @param weight importance of the provided list of sources (typically in range 1 - 50)
|
|
344
|
+
*/
|
|
345
|
+
public addSourceGroup(uri: string, wgt: number, args: ER.TopicPageAddSourceGroupArguments = {}) {
|
|
346
|
+
if (typeof wgt !== "number") {
|
|
347
|
+
throw new Error("Weight value has to be a positive or negative number");
|
|
348
|
+
}
|
|
349
|
+
const {
|
|
350
|
+
excluded = false
|
|
351
|
+
} = args;
|
|
352
|
+
this.topicPage.sourceGroups = [...this.topicPage.sourceGroups, {uri, wgt, excluded}];
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Add relevant location to the topic page
|
|
357
|
+
* @param locationUri uri of the location to add
|
|
358
|
+
* @param weight importance of the provided location (typically in range 1 - 50)
|
|
359
|
+
*/
|
|
360
|
+
public addLocation(locationUri: string, weight: number) {
|
|
361
|
+
if (typeof weight !== "number") {
|
|
362
|
+
throw new Error("Weight value has to be a positive or negative number");
|
|
363
|
+
}
|
|
364
|
+
this.topicPage.locations = [...this.topicPage.locations, {uri: locationUri, wgt: weight}];
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Restrict the results to the list of specified languages
|
|
369
|
+
*/
|
|
370
|
+
public set languages(languages: string | string[]) {
|
|
371
|
+
if (!Array.isArray(languages)) {
|
|
372
|
+
languages = [languages];
|
|
373
|
+
}
|
|
374
|
+
if (languages.every((language) => language.length === 3)) {
|
|
375
|
+
this.topicPage.langs = languages;
|
|
376
|
+
} else {
|
|
377
|
+
throw new Error("Expected to get language in ISO3 code");
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* if true then the results have to mention at least one of the specified concepts or keywords
|
|
383
|
+
*/
|
|
384
|
+
public set restrictToSetConceptsAndKeywords(restrict: boolean) {
|
|
385
|
+
if (typeof restrict !== "boolean") {
|
|
386
|
+
throw new Error("Restrict value has to be a boolean value");
|
|
387
|
+
}
|
|
388
|
+
this.topicPage.restrictToSetConcepts = restrict;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* if set to true then return only results that are assigned to one of the specified categories
|
|
393
|
+
*/
|
|
394
|
+
public set restrictToSetCategories(restrict: boolean) {
|
|
395
|
+
if (typeof restrict !== "boolean") {
|
|
396
|
+
throw new Error("Restrict value has to be a boolean value");
|
|
397
|
+
}
|
|
398
|
+
this.topicPage.restrictToSetCategories = restrict;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* if set to true then return only results from one of the specified news sources
|
|
403
|
+
* this includes also sources set by source groups or by source locations
|
|
404
|
+
*/
|
|
405
|
+
public set restrictToSetSources(restrict: boolean) {
|
|
406
|
+
if (typeof restrict !== "boolean") {
|
|
407
|
+
throw new Error("Restrict value has to be a boolean value");
|
|
408
|
+
}
|
|
409
|
+
this.topicPage.restrictToSetSources = restrict;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* if set to true, then return only results that are located at one of the specified locations
|
|
414
|
+
*/
|
|
415
|
+
public set restrictToSetLocations(restrict: boolean) {
|
|
416
|
+
if (typeof restrict !== "boolean") {
|
|
417
|
+
throw new Error("Restrict value has to be a boolean value");
|
|
418
|
+
}
|
|
419
|
+
this.topicPage.restrictToSetLocations = restrict;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Return a list of articles that match the topic page
|
|
424
|
+
* @param args {ER.TopicPageArticles} Object which contains a host of optional parameters
|
|
425
|
+
*/
|
|
426
|
+
public async getArticles(args: ER.TopicPageArticles = {}) {
|
|
427
|
+
const {page = 1, count = 100, sortBy = "rel", sortByAsc = false, returnInfo = new ReturnInfo(), ...otherParameters} = args;
|
|
428
|
+
if (page < 1) {
|
|
429
|
+
throw new RangeError("page has to be >= 1");
|
|
430
|
+
}
|
|
431
|
+
if (count > 100) {
|
|
432
|
+
throw new RangeError("At most 100 articles can be returned at a time");
|
|
433
|
+
}
|
|
434
|
+
let params = {
|
|
435
|
+
action: "getArticlesForTopicPage",
|
|
436
|
+
resultType: "articles",
|
|
437
|
+
dataType: this.topicPage.dataType,
|
|
438
|
+
articlesCount: count,
|
|
439
|
+
articlesSortBy: sortBy,
|
|
440
|
+
articlesSortByAsc: sortByAsc,
|
|
441
|
+
articlesPage: page,
|
|
442
|
+
topicPage: JSON.stringify(this.topicPage),
|
|
443
|
+
...returnInfo.getParams()
|
|
444
|
+
};
|
|
445
|
+
if (Object.keys(otherParameters).length > 0) {
|
|
446
|
+
params = {...params, ...otherParameters};
|
|
447
|
+
}
|
|
448
|
+
const request = await this.eventRegistry.jsonRequest("/api/v1/article", params);
|
|
449
|
+
return request?.data ?? {articles: {results: []}};
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Return a list of events that match the topic page
|
|
453
|
+
* @param args {ER.TopicPageEvents} Object which contains a host of optional parameters
|
|
454
|
+
*/
|
|
455
|
+
public async getEvents(args: ER.TopicPageEvents = {}) {
|
|
456
|
+
const {page = 1, count = 50, sortBy = "rel", sortByAsc = false, returnInfo = new ReturnInfo(), ...otherParameters} = args;
|
|
457
|
+
if (page < 1) {
|
|
458
|
+
throw new RangeError("page has to be >= 1");
|
|
459
|
+
}
|
|
460
|
+
if (count > 50) {
|
|
461
|
+
throw new RangeError("At most 50 events can be returned at a time");
|
|
462
|
+
}
|
|
463
|
+
let params = {
|
|
464
|
+
action: "getEventsForTopicPage",
|
|
465
|
+
resultType: "events",
|
|
466
|
+
dataType: this.topicPage.dataType,
|
|
467
|
+
eventsCount: count,
|
|
468
|
+
eventsSortBy: sortBy,
|
|
469
|
+
eventsSortByAsc: sortByAsc,
|
|
470
|
+
eventsPage: page,
|
|
471
|
+
topicPage: JSON.stringify(this.topicPage),
|
|
472
|
+
...returnInfo.getParams()
|
|
473
|
+
};
|
|
474
|
+
if (Object.keys(otherParameters).length > 0) {
|
|
475
|
+
params = {...params, ...otherParameters};
|
|
476
|
+
}
|
|
477
|
+
const request = await this.eventRegistry.jsonRequest("/api/v1/event", params);
|
|
478
|
+
return request?.data ?? {events: {results: []}};
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EventRegistry } from "./eventRegistry";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @class TopicPages
|
|
5
|
+
* Helper for listing topic pages owned by the authenticated user.
|
|
6
|
+
*/
|
|
7
|
+
export class TopicPages {
|
|
8
|
+
constructor(private eventRegistry: EventRegistry) { }
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Return the list of topic pages owned by the current user.
|
|
12
|
+
*/
|
|
13
|
+
public async getMyTopicPages(): Promise<unknown[]> {
|
|
14
|
+
const response = await this.eventRegistry.jsonRequest("/api/v1/user/getUserProfile", {});
|
|
15
|
+
const profile = response?.data as { ownedTopicPages?: unknown[] } | undefined;
|
|
16
|
+
return profile?.ownedTopicPages ?? [];
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/trends.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { QueryParamsBase } from "./base";
|
|
2
|
+
import { ReturnInfo } from "./returnInfo";
|
|
3
|
+
|
|
4
|
+
export abstract class TrendsBase extends QueryParamsBase {
|
|
5
|
+
public get path() {
|
|
6
|
+
return "/api/v1/trends";
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class GetTrendingConcepts extends TrendsBase {
|
|
11
|
+
constructor({source = "news", count = 20, conceptType = ["person", "org", "loc"], returnInfo = new ReturnInfo()} = {}) {
|
|
12
|
+
super();
|
|
13
|
+
this.setVal("action", "getTrendingConcepts");
|
|
14
|
+
this.setVal("source", source);
|
|
15
|
+
if (source !== "social") {
|
|
16
|
+
this.setVal("dataType", source);
|
|
17
|
+
}
|
|
18
|
+
this.setVal("conceptCount", count);
|
|
19
|
+
this.setVal("conceptType", conceptType);
|
|
20
|
+
this.params = {...this.params, ...returnInfo.getParams()};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class GetTrendingCategories extends TrendsBase {
|
|
25
|
+
constructor({source = "news", count = 20, returnInfo = new ReturnInfo()} = {}) {
|
|
26
|
+
super();
|
|
27
|
+
this.setVal("action", "getTrendingCategories");
|
|
28
|
+
this.setVal("source", source);
|
|
29
|
+
if (source !== "social") {
|
|
30
|
+
this.setVal("dataType", source);
|
|
31
|
+
}
|
|
32
|
+
this.setVal("categoryCount", count);
|
|
33
|
+
this.params = {...this.params, ...returnInfo.getParams()};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export class GetTrendingCustomItems extends TrendsBase {
|
|
38
|
+
constructor({count = 20, returnInfo = new ReturnInfo()} = {}) {
|
|
39
|
+
super();
|
|
40
|
+
this.setVal("action", "getTrendingCustom");
|
|
41
|
+
this.setVal("conceptCount", count);
|
|
42
|
+
this.params = {...this.params, ...returnInfo.getParams()};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export class GetTrendingConceptGroups extends TrendsBase {
|
|
47
|
+
constructor({source = "news", count = 20, returnInfo = new ReturnInfo()} = {}) {
|
|
48
|
+
super();
|
|
49
|
+
this.setVal("action", "getConceptTrendGroups");
|
|
50
|
+
this.setVal("source", source);
|
|
51
|
+
this.setVal("conceptCount", count);
|
|
52
|
+
this.params = {...this.params, ...returnInfo.getParams()};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public getConceptTypeGroups(types = ["person", "org", "loc"]) {
|
|
56
|
+
this.setVal("conceptType", types);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public getConceptClassUris(conceptClassUris: string | string[]) {
|
|
60
|
+
this.setVal("conceptClassUri", conceptClassUris);
|
|
61
|
+
}
|
|
62
|
+
}
|