eventregistry 9.1.0 → 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 -10
- 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 -144
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const __version__ = "10.0.0";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,42 +1,71 @@
|
|
|
1
|
-
{
|
|
2
|
-
"author": "Anže Sršen",
|
|
3
|
-
"name": "eventregistry",
|
|
4
|
-
"description": "Package containing wrapper functions for Event Registry API",
|
|
5
|
-
"version": "
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
1
|
+
{
|
|
2
|
+
"author": "Anže Sršen",
|
|
3
|
+
"name": "eventregistry",
|
|
4
|
+
"description": "Package containing wrapper functions for Event Registry API",
|
|
5
|
+
"version": "10.0.0",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"main": "./dist/cjs/index.js",
|
|
9
|
+
"module": "./dist/esm/index.js",
|
|
10
|
+
"types": "./dist/cjs/index.d.ts",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": {
|
|
15
|
+
"types": "./dist/esm/index.d.ts",
|
|
16
|
+
"default": "./dist/esm/index.js"
|
|
17
|
+
},
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./dist/cjs/index.d.ts",
|
|
20
|
+
"default": "./dist/cjs/index.js"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/EventRegistry/event-registry-node-js.git"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"src",
|
|
31
|
+
"MIGRATION.md",
|
|
32
|
+
"CHANGELOG.md"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"clean": "rimraf dist",
|
|
36
|
+
"build": "npm run clean && npm run build:cjs && npm run build:esm",
|
|
37
|
+
"build:cjs": "tsc --project tsconfig.cjs.json && node scripts/write-dist-package.js cjs",
|
|
38
|
+
"build:esm": "tsc --project tsconfig.esm.json && node scripts/write-dist-package.js esm",
|
|
39
|
+
"build:watch": "npm run clean && tsc --watch --project tsconfig.cjs.json",
|
|
40
|
+
"lint": "eslint \"src/**/*.ts\"",
|
|
41
|
+
"example:check": "tsc --noEmit -p examples/tsconfig.json",
|
|
42
|
+
"example": "npx --yes tsx --tsconfig examples/tsconfig.json",
|
|
43
|
+
"pretest": "tsc --project ./test/tsconfig.json",
|
|
44
|
+
"test": "jasmine --config=./test/jasmine.json",
|
|
45
|
+
"test:live": "node scripts/run-tests-with-mode.js live",
|
|
46
|
+
"test:record": "node scripts/run-tests-with-mode.js record",
|
|
47
|
+
"test:unit": "vitest run",
|
|
48
|
+
"test:unit:watch": "vitest",
|
|
49
|
+
"check:package": "npm run build && publint",
|
|
50
|
+
"prepublishOnly": "npm run build"
|
|
51
|
+
},
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=18.0.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/jasmine": "5.1.8",
|
|
57
|
+
"@types/node": "24.11.0",
|
|
58
|
+
"@typescript-eslint/eslint-plugin": "^8.67.0",
|
|
59
|
+
"@typescript-eslint/parser": "^8.67.0",
|
|
60
|
+
"eslint": "^9.39.5",
|
|
61
|
+
"eslint-plugin-import": "2.32.0",
|
|
62
|
+
"eslint-plugin-jsdoc": "50.8.0",
|
|
63
|
+
"eslint-plugin-prefer-arrow": "1.2.3",
|
|
64
|
+
"jasmine": "5.12.0",
|
|
65
|
+
"publint": "^0.3.23",
|
|
66
|
+
"rimraf": "^5.0.10",
|
|
67
|
+
"typescript": "5.8.3",
|
|
68
|
+
"typescript-eslint": "^8.67.0",
|
|
69
|
+
"vitest": "^5.0.3"
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/analytics.ts
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { EventRegistry } from "./eventRegistry";
|
|
2
|
+
import { ER } from "./types";
|
|
3
|
+
|
|
4
|
+
// The Analytics class can be used for access the text analytics services provided by the Event Registry.
|
|
5
|
+
// These include:
|
|
6
|
+
// - text annotation: identifying the list of entities and non-entities mentioned in the provided text
|
|
7
|
+
// - text categorization: identification of up to 5 categories that describe the topic of the given text.
|
|
8
|
+
// The list of available categories come from DMOZ open directory. Currently, only English text can be categorized!
|
|
9
|
+
// - sentiment detection: what is the sentiment expressed in the given text
|
|
10
|
+
// - language detection: detect in which language is the given text written
|
|
11
|
+
|
|
12
|
+
// NOTE: the functionality is currently in BETA. The API calls or the provided outputs may change in the future.
|
|
13
|
+
|
|
14
|
+
export class Analytics {
|
|
15
|
+
/**
|
|
16
|
+
* @param eventRegistry: instance of EventRegistry class
|
|
17
|
+
*/
|
|
18
|
+
constructor(private er: EventRegistry) { }
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Identify the list of entities and nonentities mentioned in the text
|
|
22
|
+
* @param text input text to annotate
|
|
23
|
+
* @param lang language of the provided document (can be an ISO2 or ISO3 code). If None is provided, the language will be automatically detected
|
|
24
|
+
*/
|
|
25
|
+
public async annotate(text: string, lang?: string[], customParams?: {[name: string]: unknown}): Promise<ER.Analytics.Response.Annotate> {
|
|
26
|
+
let params = { lang, text };
|
|
27
|
+
if (!!customParams) {
|
|
28
|
+
params = {...params, ...customParams};
|
|
29
|
+
}
|
|
30
|
+
const response = await this.er.jsonRequestAnalytics("/api/v1/annotate", params);
|
|
31
|
+
return response?.data as ER.Analytics.Response.Annotate;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Determine the set of up to 5 categories the text is about. Currently, only English text can be categorized!
|
|
36
|
+
* @param text input text to categorize
|
|
37
|
+
* @param taxonomy: which taxonomy use for categorization. Options:
|
|
38
|
+
* - "dmoz" (over 5000 categories in 3 levels, English language only)
|
|
39
|
+
* - "news" (general news categorization, 9 categories, any langauge)
|
|
40
|
+
* @param concepts optional list of concept URIs to bias categorization
|
|
41
|
+
*/
|
|
42
|
+
public async categorize(text: string, taxonomy: "dmoz" | "news" = "dmoz", concepts?: string[]): Promise<ER.Analytics.Response.Categorize> {
|
|
43
|
+
const params: { text: string; taxonomy: "dmoz" | "news"; concepts?: string[] } = { text, taxonomy };
|
|
44
|
+
if (Array.isArray(concepts) && concepts.length > 0) {
|
|
45
|
+
params.concepts = concepts;
|
|
46
|
+
}
|
|
47
|
+
const response = await this.er.jsonRequestAnalytics("/api/v1/categorize", params);
|
|
48
|
+
return response?.data as ER.Analytics.Response.Categorize;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* determine the sentiment of the provided text in English language
|
|
53
|
+
* @param text input text to categorize
|
|
54
|
+
* @param method method to use to compute the sentiment. possible values are "vocabulary" (vocabulary based sentiment analysis) and "rnn" (neural network based sentiment classification)
|
|
55
|
+
*/
|
|
56
|
+
public async sentiment(text: string, method = "vocabulary", sentences = 10, returnSentences = true): Promise<ER.Analytics.Response.Sentiment> {
|
|
57
|
+
if (!["vocabulary", "rnn"].includes(method)) {
|
|
58
|
+
throw new Error("method: Please pass in either 'vocabulary' or 'rnn'");
|
|
59
|
+
}
|
|
60
|
+
const params = {
|
|
61
|
+
text,
|
|
62
|
+
method,
|
|
63
|
+
sentences,
|
|
64
|
+
returnSentences
|
|
65
|
+
};
|
|
66
|
+
const response = await this.er.jsonRequestAnalytics("/api/v1/sentiment", params);
|
|
67
|
+
return response?.data as ER.Analytics.Response.Sentiment;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public async semanticSimilarity(text1: string, text2: string, distanceMeasure: "cosine" | "jaccard" = "cosine"): Promise<ER.Analytics.Response.SentimentSimilarity> {
|
|
71
|
+
const response = await this.er.jsonRequestAnalytics("/api/v1/semanticSimilarity", { text1, text2, distanceMeasure });
|
|
72
|
+
return response?.data as ER.Analytics.Response.SentimentSimilarity;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Determine the language of the given text
|
|
77
|
+
* @param text input text to analyse
|
|
78
|
+
*/
|
|
79
|
+
public async detectLanguage(text: string): Promise<ER.Analytics.Response.DetectLanguage> {
|
|
80
|
+
const response = await this.er.jsonRequestAnalytics("/api/v1/detectLanguage", { text });
|
|
81
|
+
return response?.data as ER.Analytics.Response.DetectLanguage;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Extract all available information about an article available at url `url`.
|
|
85
|
+
* Returned information will include article title, body, authors, links in the articles,...
|
|
86
|
+
* @param url article url that'll be used for extraction
|
|
87
|
+
* @param proxyUrl proxy that should be used for downloading article information. format: {schema}://{username}:{pass}@{proxy url/ip}
|
|
88
|
+
*/
|
|
89
|
+
public async extractArticleInfo(url: string, proxyUrl?: string, headers?: {[name: string]: unknown}, cookies?: {[name: string]: unknown}): Promise<ER.Analytics.Response.ExtractArticleInfo> {
|
|
90
|
+
const params: Record<string, string> = { url };
|
|
91
|
+
if (!!proxyUrl) {
|
|
92
|
+
params.proxyUrl = proxyUrl;
|
|
93
|
+
}
|
|
94
|
+
const response = await this.er.jsonRequestAnalytics("/api/v1/extractArticleInfo", params, headers, cookies);
|
|
95
|
+
return response?.data as ER.Analytics.Response.ExtractArticleInfo;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Extract named entities from the provided text. Supported languages are English, German, Spanish and Chinese.
|
|
100
|
+
* @param text: text on which to extract named entities
|
|
101
|
+
*/
|
|
102
|
+
public async ner(text: string) {
|
|
103
|
+
const response = await this.er.jsonRequestAnalytics("/api/v1/ner", { text });
|
|
104
|
+
return response?.data;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Create a new topic and train it using the tweets that match the twitterQuery
|
|
109
|
+
* @param twitterQuery string containing the content to search for. It can be a Twitter user account (using "@" prefix or user's Twitter url),a hash tag (using "#" prefix) or a regular keyword.
|
|
110
|
+
* @param args Object which contains a host of optional parameters
|
|
111
|
+
*/
|
|
112
|
+
public async trainTopicOnTweets(twitterQuery: string, args: ER.Analytics.TrainTopicOnTweetsArguments = {}): Promise<ER.Analytics.Response> {
|
|
113
|
+
const {
|
|
114
|
+
useTweetText = true,
|
|
115
|
+
useIdfNormalization = true,
|
|
116
|
+
normalization = "linear",
|
|
117
|
+
maxTweets = 2000,
|
|
118
|
+
maxUsedLinks = 500,
|
|
119
|
+
ignoreConceptTypes = [],
|
|
120
|
+
maxConcepts = 20,
|
|
121
|
+
maxCategories = 10,
|
|
122
|
+
notifyEmailAddress = undefined
|
|
123
|
+
} = args;
|
|
124
|
+
if (maxTweets > 5000) {
|
|
125
|
+
throw new Error("We can analyze at most 5000 tweets");
|
|
126
|
+
}
|
|
127
|
+
const params: Record<string, unknown> = {
|
|
128
|
+
twitterQuery,
|
|
129
|
+
useTweetText,
|
|
130
|
+
useIdfNormalization,
|
|
131
|
+
normalization,
|
|
132
|
+
maxTweets,
|
|
133
|
+
maxUsedLinks,
|
|
134
|
+
maxConcepts,
|
|
135
|
+
maxCategories
|
|
136
|
+
};
|
|
137
|
+
if (notifyEmailAddress) {
|
|
138
|
+
params.notifyEmailAddress = notifyEmailAddress;
|
|
139
|
+
}
|
|
140
|
+
if (ignoreConceptTypes && Object.keys(ignoreConceptTypes).length > 0) {
|
|
141
|
+
params.ignoreConceptTypes = ignoreConceptTypes;
|
|
142
|
+
}
|
|
143
|
+
const response = await this.er.jsonRequestAnalytics("/api/v1/trainTopicOnTwitter", params);
|
|
144
|
+
return response?.data as ER.Analytics.Response;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Create a new topic to train. The user should remember the "uri" parameter returned in the result.
|
|
149
|
+
* @param name name of the topic we want to create
|
|
150
|
+
* @returns object containing the "uri" property that should be used in the follow-up call to trainTopic* methods
|
|
151
|
+
*/
|
|
152
|
+
public async trainTopicCreateTopic(name: string): Promise<ER.Analytics.Response> {
|
|
153
|
+
const response = await this.er.jsonRequestAnalytics("/api/v1/trainTopic", { action: "createTopic", name });
|
|
154
|
+
return response?.data as ER.Analytics.Response;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* If the topic is already existing, clear the definition of the topic. Use this if you want to retrain an existing topic
|
|
159
|
+
* @param uri uri of the topic (obtained by calling trainTopicCreateTopic method) to clear
|
|
160
|
+
*/
|
|
161
|
+
public async trainTopicClearTopic(uri: string): Promise<ER.Analytics.Response> {
|
|
162
|
+
const response = await this.er.jsonRequestAnalytics("/api/v1/trainTopic", { action: "clearTopic", uri });
|
|
163
|
+
return response?.data as ER.Analytics.Response;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Add the information extracted from the provided "text" to the topic with uri "uri".
|
|
168
|
+
* @param uri uri of the topic (obtained by calling trainTopicCreateTopic method)
|
|
169
|
+
* @param text text to analyze and extract information from
|
|
170
|
+
*/
|
|
171
|
+
public async trainTopicAddDocument(uri: string, text: string): Promise<ER.Analytics.Response> {
|
|
172
|
+
const response = await this.er.jsonRequestAnalytics("/api/v1/trainTopic", { action: "addDocument", uri, text });
|
|
173
|
+
return response?.data as ER.Analytics.Response;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Retrieve topic for the topic for which you have already finished training
|
|
178
|
+
* @param uri uri of the topic (obtained by calling trainTopicCreateTopic method)
|
|
179
|
+
* @returns returns the trained topic: { concepts: [], categories: [] }
|
|
180
|
+
*/
|
|
181
|
+
public async trainTopicGetTrainedTopic(uri: string, args: ER.Analytics.TrainTopicGetTrainedTopicArguments = {}): Promise<ER.Analytics.Response> {
|
|
182
|
+
const {
|
|
183
|
+
maxConcepts = 20,
|
|
184
|
+
maxCategories = 10,
|
|
185
|
+
idfNormalization = true
|
|
186
|
+
} = args;
|
|
187
|
+
const params = {
|
|
188
|
+
action: "getTrainedTopic",
|
|
189
|
+
uri: uri,
|
|
190
|
+
maxConcepts: maxConcepts,
|
|
191
|
+
maxCategories: maxCategories,
|
|
192
|
+
idfNormalization: idfNormalization
|
|
193
|
+
};
|
|
194
|
+
const response = await this.er.jsonRequestAnalytics("/api/v1/trainTopic", params);
|
|
195
|
+
return response?.data as ER.Analytics.Response;
|
|
196
|
+
}
|
|
197
|
+
}
|
package/src/base.ts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { Logger } from "./logger";
|
|
2
|
+
|
|
3
|
+
export const mainLangs = ["eng", "deu", "zho", "slv", "spa"];
|
|
4
|
+
export const allLangs = [ "eng", "deu", "spa", "cat", "por", "ita", "fra", "rus", "ara", "tur", "zho", "slv", "hrv", "srp" ];
|
|
5
|
+
// Utility classes for Event Registry
|
|
6
|
+
|
|
7
|
+
export class QueryItems {
|
|
8
|
+
public static AND = (items: unknown[]): QueryItems => new QueryItems("$and", items);
|
|
9
|
+
public static OR = (items: unknown[]): QueryItems => new QueryItems("$or", items);
|
|
10
|
+
|
|
11
|
+
private oper: string;
|
|
12
|
+
private items: unknown[];
|
|
13
|
+
|
|
14
|
+
constructor(oper: string, items: unknown[]) {
|
|
15
|
+
this.oper = oper;
|
|
16
|
+
this.items = items;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public getOper() {
|
|
20
|
+
return this.oper;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public getItems() {
|
|
24
|
+
return this.items;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @class QueryParamsBase
|
|
30
|
+
* Base class for Query and AdminQuery
|
|
31
|
+
* used for storing parameters for a query. Parameter values can either be
|
|
32
|
+
* simple values (set by setVal()) or an array of values (set by multiple
|
|
33
|
+
* calls to addArrayVal() method)
|
|
34
|
+
*/
|
|
35
|
+
export class QueryParamsBase {
|
|
36
|
+
protected params: Record<string, unknown> = {};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Encode datetime into UTC ISO format which can be sent to ER.
|
|
40
|
+
*/
|
|
41
|
+
public static encodeDateTime(val: string | Date, format?: string): string {
|
|
42
|
+
const date = val instanceof Date ? val : new Date(val);
|
|
43
|
+
if (isNaN(date.getTime())) {
|
|
44
|
+
throw new Error("Datetime was not recognizable. Use `new Date()` or string in ISO format");
|
|
45
|
+
}
|
|
46
|
+
if (format === "YYYY-MM-DD") {
|
|
47
|
+
return date.toISOString().slice(0, 10);
|
|
48
|
+
}
|
|
49
|
+
return date.toISOString();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Return the parameters.
|
|
54
|
+
*/
|
|
55
|
+
public getQueryParams() {
|
|
56
|
+
return this.params;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Set a value of a property in the query.
|
|
61
|
+
*/
|
|
62
|
+
public setVal(key: string, value: unknown) {
|
|
63
|
+
this.params[key] = value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Do we have in the query property named 'key'?
|
|
68
|
+
*/
|
|
69
|
+
public hasVal(key: string): boolean {
|
|
70
|
+
return this.params.hasOwnProperty(key);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Remove the value of a property key (if existing).
|
|
75
|
+
*/
|
|
76
|
+
public clearVal(key: string) {
|
|
77
|
+
delete this.params[key];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Add a value to an array of values for a property.
|
|
82
|
+
*/
|
|
83
|
+
public addArrayVal(key: string, val: unknown) {
|
|
84
|
+
this.params[key] = [...(this.params[key] || []) as unknown[], val];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Set value in query params if the 'val' is different from 'defVal'.
|
|
89
|
+
*/
|
|
90
|
+
public setValIfNotDefault(propName: string, val: unknown, defVal: unknown) {
|
|
91
|
+
if (val !== defVal) {
|
|
92
|
+
this.setVal(propName, val);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Set a property value that represents date.
|
|
98
|
+
* Value can be string in YYYY-MM-DD format or a Date object.
|
|
99
|
+
*/
|
|
100
|
+
public setDateVal(propName: string, val: string | Date) {
|
|
101
|
+
this.setVal(propName, QueryParamsBase.encodeDateTime(val, "YYYY-MM-DD"));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Parse the value "value" and use it to set the property propName and the operator with name propOperName
|
|
106
|
+
* @param value String, QueryItems or an array.
|
|
107
|
+
* @param propName Values to be set using property name propName.
|
|
108
|
+
* @param propOperName Property to set containing the "and" or "or". Relevant only if multiple items are provided in "value". Can be None if only one value is possible.
|
|
109
|
+
* @param defaultOperName Which operator should be used in case "value" is an array. If an array, we will print also a warning to suggest use of QueryItems.
|
|
110
|
+
*/
|
|
111
|
+
public setQueryArrVal(value: string | QueryItems | unknown[] | undefined, propName: string, propOperName: string | undefined, defaultOperName: string) {
|
|
112
|
+
if (!value) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (value instanceof QueryItems) {
|
|
117
|
+
this.params[propName] = value.getItems();
|
|
118
|
+
const formattedOperator = value.getOper().replace(/\$/g, "");
|
|
119
|
+
if (propOperName) {
|
|
120
|
+
this.params[propOperName] = formattedOperator;
|
|
121
|
+
}
|
|
122
|
+
if (propOperName === undefined && formattedOperator !== defaultOperName) {
|
|
123
|
+
throw new Error(`An invalid operator type '${formattedOperator}' was used for property '${propName}'`);
|
|
124
|
+
}
|
|
125
|
+
} else if (typeof value === "string") {
|
|
126
|
+
this.params[propName] = value;
|
|
127
|
+
} else if (Array.isArray(value)) {
|
|
128
|
+
this.params[propName] = value;
|
|
129
|
+
if (propOperName !== undefined) {
|
|
130
|
+
this.params[propOperName] = defaultOperName;
|
|
131
|
+
if (value.length > 1) {
|
|
132
|
+
Logger.warn(`
|
|
133
|
+
Warning: The value of parameter '${propName}' was provided as a list and '${defaultOperName}' operator was used implicitly between the items.
|
|
134
|
+
We suggest specifying the list using the QueryItems.AND() or QueryItems.OR() to ensure the appropriate operator is used.
|
|
135
|
+
`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
throw new Error(`Parameter '${propName}' was of unsupported type. It should either be None, a string or an instance of QueryItems`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export abstract class Query<T> extends QueryParamsBase {
|
|
145
|
+
public resultTypeList: T[] = [];
|
|
146
|
+
/**
|
|
147
|
+
* Set it to a default path.
|
|
148
|
+
*/
|
|
149
|
+
protected internalPath: string = "";
|
|
150
|
+
protected params: Record<string, unknown> = {};
|
|
151
|
+
|
|
152
|
+
public get path() {
|
|
153
|
+
return this.internalPath;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
public set path(path) {
|
|
157
|
+
this.internalPath = path;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Prepare the request parameters
|
|
162
|
+
*/
|
|
163
|
+
public getQueryParams() {
|
|
164
|
+
if (this.resultTypeList.length === 0) {
|
|
165
|
+
throw new Error("The query does not have any result type specified. No sense in performing such a query");
|
|
166
|
+
}
|
|
167
|
+
let allParams = this.params;
|
|
168
|
+
for (const resultType of this.resultTypeList) {
|
|
169
|
+
allParams = { ...allParams, ...(resultType as Record<string, Record<string, unknown>>)?.params };
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const formattedResultTypeList = this.getFormattedResultTypeList();
|
|
173
|
+
if (formattedResultTypeList?.length > 0) {
|
|
174
|
+
allParams = { ...allParams, resultType: formattedResultTypeList };
|
|
175
|
+
}
|
|
176
|
+
return structuredClone(allParams);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
public getFormattedResultTypeList() {
|
|
180
|
+
if (!this.resultTypeList.every((result) => (result as Record<string, string>)?.resultType !== undefined)) {
|
|
181
|
+
return [];
|
|
182
|
+
}
|
|
183
|
+
if (this.resultTypeList.length === 1) {
|
|
184
|
+
return (this.resultTypeList[0] as Record<string, string>)?.resultType;
|
|
185
|
+
} else {
|
|
186
|
+
return this.resultTypeList.map((result) => (result as Record<string, string>)?.resultType);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
public abstract setRequestedResult(args: unknown): void;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Utility function used in conjunction with a async/await and/or Promise
|
|
195
|
+
*/
|
|
196
|
+
export function sleep(ms: number): Promise<void> {
|
|
197
|
+
return new Promise((resolve) => {
|
|
198
|
+
setTimeout(resolve, ms);
|
|
199
|
+
});
|
|
200
|
+
}
|
package/src/counts.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { QueryParamsBase } from "./base";
|
|
2
|
+
import { ReturnInfo } from "./returnInfo";
|
|
3
|
+
import { ER } from "./types";
|
|
4
|
+
|
|
5
|
+
// provides classes for obtaining information about how frequently individual concepts or categories
|
|
6
|
+
// have been mentioned in news articles (if source == "news") of in social media (if source == "social")
|
|
7
|
+
|
|
8
|
+
export abstract class CountsBase extends QueryParamsBase {
|
|
9
|
+
public get path() {
|
|
10
|
+
return "/api/v1/counters";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @class GetCounts
|
|
16
|
+
* Obtain information about how frequently a concept or category is mentioned in the articles on particular dates
|
|
17
|
+
* by specifying source="custom" one can obtain counts for custom concepts, such as stocks, macroeconomic indicators, etc. The uri
|
|
18
|
+
* for these can be found using EventRegistry.getCustomConceptUri() method.
|
|
19
|
+
* Usage example:
|
|
20
|
+
*
|
|
21
|
+
* q = GetCounts([er.getConceptUri("Obama"), er.getConceptUri("ebola")])
|
|
22
|
+
* ret = er.execQuery(q)
|
|
23
|
+
*
|
|
24
|
+
* Return object:
|
|
25
|
+
*
|
|
26
|
+
* {
|
|
27
|
+
* "http://en.wikipedia.org/wiki/Barack_Obama": [
|
|
28
|
+
* {
|
|
29
|
+
* "count": 1,
|
|
30
|
+
* "date": "2015-05-07"
|
|
31
|
+
* },
|
|
32
|
+
* {
|
|
33
|
+
* "count": 4,
|
|
34
|
+
* "date": "2015-05-08"
|
|
35
|
+
* },
|
|
36
|
+
* ...
|
|
37
|
+
* ],
|
|
38
|
+
* "http://en.wikipedia.org/wiki/Ebola_virus_disease": [
|
|
39
|
+
* {
|
|
40
|
+
* "count": 0,
|
|
41
|
+
* "date": "2015-05-07"
|
|
42
|
+
* },
|
|
43
|
+
* ...a
|
|
44
|
+
* ]
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* @param uriOrUriList: concept/category uri or a list of uris
|
|
48
|
+
* @param args Object which contains a host of optional parameters
|
|
49
|
+
*/
|
|
50
|
+
export class GetCounts extends CountsBase {
|
|
51
|
+
constructor(uriOrUriList: string | string[], args: ER.Counts.Arguments = {}) {
|
|
52
|
+
super();
|
|
53
|
+
const {source = "news", type = "concept", dateStart = undefined, dateEnd = undefined, returnInfo = new ReturnInfo()} = args;
|
|
54
|
+
this.setVal("action", "getCounts");
|
|
55
|
+
this.setVal("source", source);
|
|
56
|
+
this.setVal("type", type);
|
|
57
|
+
this.setVal("uri", uriOrUriList);
|
|
58
|
+
if (dateStart !== undefined) {
|
|
59
|
+
this.setDateVal("dateStart", dateStart);
|
|
60
|
+
}
|
|
61
|
+
if (dateEnd !== undefined) {
|
|
62
|
+
this.setDateVal("dateEnd", dateEnd);
|
|
63
|
+
}
|
|
64
|
+
this.params = { ...this.params, ...returnInfo.getParams() };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @class GetCountsEx
|
|
70
|
+
* Obtain information about how frequently a concept or category is mentioned in the articles on particular dates
|
|
71
|
+
* Similar to GetCounts, but the output is more friendly for a larger set of provided uris/ids at once
|
|
72
|
+
* Usage example:
|
|
73
|
+
* q = GetCountsEx(type = "category")
|
|
74
|
+
* q.queryById(range(10)) # return trends of first 10 categories
|
|
75
|
+
* ret = er.execQuery(q)
|
|
76
|
+
* Return object:
|
|
77
|
+
* {
|
|
78
|
+
* "categoryInfo": [
|
|
79
|
+
* {
|
|
80
|
+
* "id": 0,
|
|
81
|
+
* "label": "Root",
|
|
82
|
+
* "uri": "http://www.dmoz.org"
|
|
83
|
+
* },
|
|
84
|
+
* {
|
|
85
|
+
* "id": 1,
|
|
86
|
+
* "label": "Recreation",
|
|
87
|
+
* "uri": "http://www.dmoz.org/Recreation"
|
|
88
|
+
* },
|
|
89
|
+
* ...
|
|
90
|
+
* ],
|
|
91
|
+
* "counts": [
|
|
92
|
+
* {
|
|
93
|
+
* "0": 23, "1": 42, "2": 52, "3": 32, "4": 21, "5": 65, "6": 32, "7": 654, "8": 1, "9": 34,
|
|
94
|
+
* "date": "2015-05-07"
|
|
95
|
+
* },
|
|
96
|
+
* ...
|
|
97
|
+
* ]
|
|
98
|
+
* }
|
|
99
|
+
* @param uriOrUriList: concept/category uri or a list of uris
|
|
100
|
+
* @param args Object which contains a host of optional parameters
|
|
101
|
+
*/
|
|
102
|
+
export class GetCountsEx extends CountsBase {
|
|
103
|
+
constructor(uriOrUriList: string | string[], args: ER.Counts.Arguments = {}) {
|
|
104
|
+
super();
|
|
105
|
+
const {source = "news", type = "concept", dateStart = undefined, dateEnd = undefined, returnInfo = new ReturnInfo()} = args;
|
|
106
|
+
this.setVal("action", "GetCountsEx");
|
|
107
|
+
this.setVal("source", source);
|
|
108
|
+
this.setVal("type", type);
|
|
109
|
+
this.setVal("uri", uriOrUriList);
|
|
110
|
+
if (dateStart !== undefined) {
|
|
111
|
+
this.setDateVal("dateStart", dateStart);
|
|
112
|
+
}
|
|
113
|
+
if (dateEnd !== undefined) {
|
|
114
|
+
this.setDateVal("dateEnd", dateEnd);
|
|
115
|
+
}
|
|
116
|
+
this.params = { ...this.params, ...returnInfo.getParams() };
|
|
117
|
+
}
|
|
118
|
+
}
|