eventregistry 9.1.1 → 11.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/AGENT-RECIPES.md +86 -0
- package/CHANGELOG.md +254 -0
- package/LICENSE +21 -21
- package/MIGRATION.md +195 -0
- package/README.md +340 -234
- package/dist/cjs/abort.d.ts +14 -0
- package/dist/cjs/abort.js +71 -0
- package/dist/cjs/abort.js.map +1 -0
- 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 +195 -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/cjs/errors.d.ts +66 -0
- package/dist/cjs/errors.js +75 -0
- package/dist/cjs/errors.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} +167 -36
- package/dist/cjs/eventRegistry.js +939 -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 +13 -0
- package/dist/cjs/fluent/recent.js +21 -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/guards.d.ts +12 -0
- package/dist/cjs/guards.js +75 -0
- package/dist/cjs/guards.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 +23 -0
- package/dist/cjs/http.js +141 -0
- package/dist/cjs/http.js.map +1 -0
- package/dist/cjs/index.d.ts +54 -0
- package/dist/{index.js → cjs/index.js} +104 -3
- 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} +15 -11
- package/dist/cjs/logger.js +183 -0
- package/dist/cjs/logger.js.map +1 -0
- package/dist/cjs/mutex.d.ts +7 -0
- package/dist/cjs/mutex.js +44 -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 +121 -0
- package/dist/cjs/queryArticle.js.map +1 -0
- package/dist/{queryArticles.d.ts → cjs/queryArticles.d.ts} +36 -69
- package/dist/cjs/queryArticles.js +457 -0
- package/dist/cjs/queryArticles.js.map +1 -0
- package/dist/{queryEvent.d.ts → cjs/queryEvent.d.ts} +7 -6
- package/dist/cjs/queryEvent.js +423 -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 +568 -0
- package/dist/cjs/queryEvents.js.map +1 -0
- package/dist/cjs/queryIterator.d.ts +36 -0
- package/dist/cjs/queryIterator.js +85 -0
- package/dist/cjs/queryIterator.js.map +1 -0
- package/dist/{queryMentions.d.ts → cjs/queryMentions.d.ts} +19 -18
- package/dist/cjs/queryMentions.js +446 -0
- package/dist/cjs/queryMentions.js.map +1 -0
- package/dist/{queryStory.d.ts → cjs/queryStory.d.ts} +24 -21
- package/dist/cjs/queryStory.js +120 -0
- package/dist/cjs/queryStory.js.map +1 -0
- package/dist/cjs/recent.d.ts +35 -0
- package/dist/cjs/recent.js +81 -0
- package/dist/cjs/recent.js.map +1 -0
- package/dist/cjs/recentFeed.d.ts +35 -0
- package/dist/cjs/recentFeed.js +76 -0
- package/dist/cjs/recentFeed.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 +458 -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} +195 -37
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/usage.d.ts +39 -0
- package/dist/cjs/usage.js +62 -0
- package/dist/cjs/usage.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/abort.d.ts +14 -0
- package/dist/esm/abort.js +65 -0
- package/dist/esm/abort.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 +188 -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/errors.d.ts +66 -0
- package/dist/esm/errors.js +67 -0
- package/dist/esm/errors.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 +375 -0
- package/dist/esm/eventRegistry.js +901 -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 +13 -0
- package/dist/esm/fluent/recent.js +17 -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/guards.d.ts +12 -0
- package/dist/esm/guards.js +70 -0
- package/dist/esm/guards.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 +23 -0
- package/dist/esm/http.js +138 -0
- package/dist/esm/http.js.map +1 -0
- package/dist/esm/index.d.ts +54 -0
- package/dist/esm/index.js +51 -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 +49 -0
- package/dist/esm/logger.js +146 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/mutex.d.ts +7 -0
- package/dist/esm/mutex.js +40 -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 +112 -0
- package/dist/esm/queryArticle.js.map +1 -0
- package/dist/esm/queryArticles.d.ts +111 -0
- package/dist/esm/queryArticles.js +439 -0
- package/dist/esm/queryArticles.js.map +1 -0
- package/dist/esm/queryEvent.d.ts +141 -0
- package/dist/esm/queryEvent.js +409 -0
- package/dist/esm/queryEvent.js.map +1 -0
- package/dist/esm/queryEvents.d.ts +201 -0
- package/dist/esm/queryEvents.js +546 -0
- package/dist/esm/queryEvents.js.map +1 -0
- package/dist/esm/queryIterator.d.ts +36 -0
- package/dist/esm/queryIterator.js +81 -0
- package/dist/esm/queryIterator.js.map +1 -0
- package/dist/esm/queryMentions.d.ts +97 -0
- package/dist/esm/queryMentions.js +431 -0
- package/dist/esm/queryMentions.js.map +1 -0
- package/dist/esm/queryStory.d.ts +61 -0
- package/dist/esm/queryStory.js +110 -0
- package/dist/esm/queryStory.js.map +1 -0
- package/dist/esm/recent.d.ts +35 -0
- package/dist/esm/recent.js +76 -0
- package/dist/esm/recent.js.map +1 -0
- package/dist/esm/recentFeed.d.ts +35 -0
- package/dist/esm/recentFeed.js +70 -0
- package/dist/esm/recentFeed.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 +421 -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 +2611 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/usage.d.ts +39 -0
- package/dist/esm/usage.js +58 -0
- package/dist/esm/usage.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 +80 -42
- package/src/abort.ts +70 -0
- package/src/analytics.ts +197 -0
- package/src/base.ts +206 -0
- package/src/counts.ts +118 -0
- package/src/dailyShares.ts +46 -0
- package/src/data.ts +310 -0
- package/src/errors.ts +105 -0
- package/src/eventForText.ts +60 -0
- package/src/eventRegistry.ts +1105 -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 +19 -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/guards.ts +79 -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 +169 -0
- package/src/index.ts +212 -0
- package/src/info.ts +120 -0
- package/src/logger.ts +182 -0
- package/src/mutex.ts +40 -0
- package/src/query.ts +258 -0
- package/src/queryArticle.ts +139 -0
- package/src/queryArticles.ts +584 -0
- package/src/queryEvent.ts +510 -0
- package/src/queryEvents.ts +673 -0
- package/src/queryIterator.ts +100 -0
- package/src/queryMentions.ts +559 -0
- package/src/queryStory.ts +159 -0
- package/src/recent.ts +98 -0
- package/src/recentFeed.ts +91 -0
- package/src/returnInfo.ts +372 -0
- package/src/topicPage.ts +485 -0
- package/src/topicPages.ts +18 -0
- package/src/trends.ts +62 -0
- package/src/types.ts +2737 -0
- package/src/usage.ts +79 -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.d.ts +0 -23
- 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,43 @@
|
|
|
1
|
+
import { EventRegistry } from "../eventRegistry";
|
|
2
|
+
import { QueryEvents, QueryEventsIter, RequestEventsInfo } from "../queryEvents";
|
|
3
|
+
import { QueryEvent, RequestEventInfo } from "../queryEvent";
|
|
4
|
+
import { ReturnInfo } from "../returnInfo";
|
|
5
|
+
import { ER } from "../types";
|
|
6
|
+
import { Data } from "../data";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Build a `QueryEvents` + `RequestEventsInfo` and execute it in one call.
|
|
10
|
+
*/
|
|
11
|
+
export async function searchEvents(
|
|
12
|
+
er: EventRegistry,
|
|
13
|
+
args: Omit<ER.QueryEvents.Arguments, "requestedResult">
|
|
14
|
+
& Pick<ER.QueryEvents.RequestEventsInfoArguments, "count" | "page" | "sortBy" | "sortByAsc" | "returnInfo"> = {}
|
|
15
|
+
): Promise<ER.Response> {
|
|
16
|
+
const { count = 50, page, sortBy, sortByAsc, returnInfo, ...queryArgs } = args;
|
|
17
|
+
const q = new QueryEvents(queryArgs);
|
|
18
|
+
q.setRequestedResult(new RequestEventsInfo({ count, page, sortBy, sortByAsc, returnInfo }));
|
|
19
|
+
return er.execQuery(q);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Async-iterate over all matching events, paging automatically.
|
|
24
|
+
*/
|
|
25
|
+
export function iterateEvents(
|
|
26
|
+
er: EventRegistry,
|
|
27
|
+
args: ER.QueryEvents.IteratorArguments = {}
|
|
28
|
+
): AsyncIterable<Data.Event> {
|
|
29
|
+
return new QueryEventsIter(er, args);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Fetch a single event by uri. `returnInfo` matches `RequestEventInfo`'s constructor argument.
|
|
34
|
+
*/
|
|
35
|
+
export async function getEvent(
|
|
36
|
+
er: EventRegistry,
|
|
37
|
+
eventUri: string,
|
|
38
|
+
args: { returnInfo?: ReturnInfo } = {}
|
|
39
|
+
): Promise<ER.Response> {
|
|
40
|
+
const q = new QueryEvent(eventUri);
|
|
41
|
+
q.setRequestedResult(args.returnInfo ? new RequestEventInfo(args.returnInfo) : new RequestEventInfo());
|
|
42
|
+
return er.execQuery(q);
|
|
43
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { EventRegistry } from "../eventRegistry";
|
|
2
|
+
import { GetCategoryInfo, GetConceptInfo, GetSourceInfo, GetSourceStats } from "../info";
|
|
3
|
+
import { ER } from "../types";
|
|
4
|
+
|
|
5
|
+
export async function getSourceInfo(
|
|
6
|
+
er: EventRegistry,
|
|
7
|
+
args: ER.Info.GetSourceInfoArguments = {}
|
|
8
|
+
): Promise<ER.Response> {
|
|
9
|
+
return er.execQuery(new GetSourceInfo(args));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export async function getConceptInfo(
|
|
13
|
+
er: EventRegistry,
|
|
14
|
+
args: ER.Info.GetConceptInfoArguments = {}
|
|
15
|
+
): Promise<ER.Response> {
|
|
16
|
+
return er.execQuery(new GetConceptInfo(args));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function getCategoryInfo(
|
|
20
|
+
er: EventRegistry,
|
|
21
|
+
args: ER.Info.GetCategoryInfoArguments = {}
|
|
22
|
+
): Promise<ER.Response> {
|
|
23
|
+
return er.execQuery(new GetCategoryInfo(args));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function getSourceStats(
|
|
27
|
+
er: EventRegistry,
|
|
28
|
+
sourceUri?: string
|
|
29
|
+
): Promise<ER.Response> {
|
|
30
|
+
return er.execQuery(new GetSourceStats(sourceUri));
|
|
31
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { EventRegistry } from "../eventRegistry";
|
|
2
|
+
import { QueryMentions, QueryMentionsIter, RequestMentionsInfo } from "../queryMentions";
|
|
3
|
+
import { ER } from "../types";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Build a `QueryMentions` + `RequestMentionsInfo` and execute it in one call.
|
|
7
|
+
*/
|
|
8
|
+
export async function searchMentions(
|
|
9
|
+
er: EventRegistry,
|
|
10
|
+
args: Omit<ER.QueryMentions.Arguments, "requestedResult">
|
|
11
|
+
& Pick<ER.QueryMentions.RequestMentionsInfoArguments, "count" | "page" | "sortBy" | "sortByAsc" | "returnInfo"> = {}
|
|
12
|
+
): Promise<ER.Response> {
|
|
13
|
+
const { count = 100, page, sortBy, sortByAsc, returnInfo, ...queryArgs } = args;
|
|
14
|
+
const q = new QueryMentions(queryArgs);
|
|
15
|
+
q.setRequestedResult(new RequestMentionsInfo({ count, page, sortBy, sortByAsc, returnInfo }));
|
|
16
|
+
return er.execQuery(q);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Async-iterate over all matching mentions, paging automatically.
|
|
21
|
+
*/
|
|
22
|
+
export function iterateMentions(
|
|
23
|
+
er: EventRegistry,
|
|
24
|
+
args: ER.QueryMentions.IteratorArguments = {}
|
|
25
|
+
): AsyncIterable<Record<string, unknown>> {
|
|
26
|
+
return new QueryMentionsIter(er, args);
|
|
27
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EventRegistry } from "../eventRegistry";
|
|
2
|
+
import { GetRecentArticles, GetRecentEvents } from "../recent";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `GetRecentEvents`'s execute path is its own `getUpdates()` method (not `er.execQuery`).
|
|
6
|
+
*/
|
|
7
|
+
export async function getRecentEvents(
|
|
8
|
+
er: EventRegistry,
|
|
9
|
+
args: ConstructorParameters<typeof GetRecentEvents>[1] = {}
|
|
10
|
+
): ReturnType<GetRecentEvents["getUpdates"]> {
|
|
11
|
+
return new GetRecentEvents(er, args).getUpdates();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* `GetRecentArticles`'s execute path is its own `getUpdates()` method (not `er.execQuery`).
|
|
16
|
+
*/
|
|
17
|
+
export async function getRecentArticles(
|
|
18
|
+
er: EventRegistry,
|
|
19
|
+
args: ConstructorParameters<typeof GetRecentArticles>[1] = {}
|
|
20
|
+
): ReturnType<GetRecentArticles["getUpdates"]> {
|
|
21
|
+
return new GetRecentArticles(er, args).getUpdates();
|
|
22
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EventRegistry } from "../eventRegistry";
|
|
2
|
+
import { GetTopSharedArticles, GetTopSharedEvents } from "../dailyShares";
|
|
3
|
+
import { ER } from "../types";
|
|
4
|
+
|
|
5
|
+
export async function getTopSharedArticles(
|
|
6
|
+
er: EventRegistry,
|
|
7
|
+
args: ER.DailyShares.Arguments = {}
|
|
8
|
+
): Promise<ER.Response> {
|
|
9
|
+
return er.execQuery(new GetTopSharedArticles(args));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export async function getTopSharedEvents(
|
|
13
|
+
er: EventRegistry,
|
|
14
|
+
args: ER.DailyShares.Arguments = {}
|
|
15
|
+
): Promise<ER.Response> {
|
|
16
|
+
return er.execQuery(new GetTopSharedEvents(args));
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EventRegistry } from "../eventRegistry";
|
|
2
|
+
import { QueryStory, RequestStory, RequestStoryInfo } from "../queryStory";
|
|
3
|
+
import { ER } from "../types";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Build a `QueryStory` + result request and execute it in one call.
|
|
7
|
+
*/
|
|
8
|
+
export async function getStory(
|
|
9
|
+
er: EventRegistry,
|
|
10
|
+
storyUriOrList: string | string[],
|
|
11
|
+
requestStory: RequestStory = new RequestStoryInfo()
|
|
12
|
+
): Promise<ER.Response> {
|
|
13
|
+
const q = new QueryStory(storyUriOrList);
|
|
14
|
+
q.setRequestedResult(requestStory);
|
|
15
|
+
return er.execQuery(q);
|
|
16
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { EventRegistry } from "../eventRegistry";
|
|
2
|
+
import { TopicPage } from "../topicPage";
|
|
3
|
+
import { TopicPages } from "../topicPages";
|
|
4
|
+
import { ER } from "../types";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Return the list of topic pages owned by the current user.
|
|
8
|
+
* Thin wrapper around `TopicPages.getMyTopicPages()`.
|
|
9
|
+
*/
|
|
10
|
+
export async function getMyTopicPages(er: EventRegistry): Promise<unknown[]> {
|
|
11
|
+
const pages = new TopicPages(er);
|
|
12
|
+
return pages.getMyTopicPages();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Load an existing topic page definition from Event Registry by uri.
|
|
17
|
+
*/
|
|
18
|
+
export async function loadTopicPage(er: EventRegistry, uri: string): Promise<ER.TopicPage> {
|
|
19
|
+
const topicPage = new TopicPage(er);
|
|
20
|
+
return topicPage.loadTopicPageFromER(uri);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Create a new, empty `TopicPage` builder bound to this `EventRegistry` instance.
|
|
25
|
+
*/
|
|
26
|
+
export function createTopicPage(er: EventRegistry): TopicPage {
|
|
27
|
+
return new TopicPage(er);
|
|
28
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { EventRegistry } from "../eventRegistry";
|
|
2
|
+
import {
|
|
3
|
+
GetTrendingCategories,
|
|
4
|
+
GetTrendingConceptGroups,
|
|
5
|
+
GetTrendingConcepts,
|
|
6
|
+
GetTrendingCustomItems
|
|
7
|
+
} from "../trends";
|
|
8
|
+
import { ER } from "../types";
|
|
9
|
+
|
|
10
|
+
export async function getTrendingConcepts(
|
|
11
|
+
er: EventRegistry,
|
|
12
|
+
args: ConstructorParameters<typeof GetTrendingConcepts>[0] = {}
|
|
13
|
+
): Promise<ER.Response> {
|
|
14
|
+
return er.execQuery(new GetTrendingConcepts(args));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function getTrendingCategories(
|
|
18
|
+
er: EventRegistry,
|
|
19
|
+
args: ConstructorParameters<typeof GetTrendingCategories>[0] = {}
|
|
20
|
+
): Promise<ER.Response> {
|
|
21
|
+
return er.execQuery(new GetTrendingCategories(args));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function getTrendingCustomItems(
|
|
25
|
+
er: EventRegistry,
|
|
26
|
+
args: ConstructorParameters<typeof GetTrendingCustomItems>[0] = {}
|
|
27
|
+
): Promise<ER.Response> {
|
|
28
|
+
return er.execQuery(new GetTrendingCustomItems(args));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function getTrendingConceptGroups(
|
|
32
|
+
er: EventRegistry,
|
|
33
|
+
args: ConstructorParameters<typeof GetTrendingConceptGroups>[0] = {}
|
|
34
|
+
): Promise<ER.Response> {
|
|
35
|
+
return er.execQuery(new GetTrendingConceptGroups(args));
|
|
36
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { EventRegistry } from "../eventRegistry";
|
|
2
|
+
import { ER } from "../types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Awaits a getXUri() lookup and throws a consistent "no match" error if it came back empty.
|
|
6
|
+
* Backs every resolver below — they all follow the same resolve-or-throw shape.
|
|
7
|
+
*/
|
|
8
|
+
async function resolveOrThrow(resolve: () => Promise<string | undefined>, kind: string, label: string): Promise<string> {
|
|
9
|
+
const uri = await resolve();
|
|
10
|
+
if (!uri) {
|
|
11
|
+
throw new Error(`No ${kind} uri found for label "${label}"`);
|
|
12
|
+
}
|
|
13
|
+
return uri;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Resolve a concept label into its Event Registry concept uri.
|
|
18
|
+
* Thin wrapper around `EventRegistry.getConceptUri()`. Throws if no match is found.
|
|
19
|
+
*/
|
|
20
|
+
export async function conceptUri(er: EventRegistry, label: string, args: ER.GetConceptUriArguments = {}): Promise<string> {
|
|
21
|
+
return resolveOrThrow(() => er.getConceptUri(label, args), "concept", label);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Resolve a dmoz category label into its Event Registry category uri.
|
|
26
|
+
* Thin wrapper around `EventRegistry.getCategoryUri()`. Throws if no match is found.
|
|
27
|
+
*/
|
|
28
|
+
export async function categoryUri(er: EventRegistry, label: string): Promise<string> {
|
|
29
|
+
return resolveOrThrow(() => er.getCategoryUri(label), "category", label);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Resolve a news source name into its Event Registry source uri.
|
|
34
|
+
* Thin wrapper around `EventRegistry.getNewsSourceUri()`. Throws if no match is found.
|
|
35
|
+
*/
|
|
36
|
+
export async function sourceUri(er: EventRegistry, label: string, dataType: ER.DataType[] | ER.DataType = ["news", "pr", "blog"]): Promise<string> {
|
|
37
|
+
return resolveOrThrow(() => er.getNewsSourceUri(label, dataType), "source", label);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Resolve a source group name into its Event Registry source group uri.
|
|
42
|
+
* Thin wrapper around `EventRegistry.getSourceGroupUri()`. Throws if no match is found.
|
|
43
|
+
*/
|
|
44
|
+
export async function sourceGroupUri(er: EventRegistry, label: string): Promise<string> {
|
|
45
|
+
return resolveOrThrow(() => er.getSourceGroupUri(label), "source group", label);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Resolve a location label into its Event Registry location uri.
|
|
50
|
+
* Thin wrapper around `EventRegistry.getLocationUri()`. Throws if no match is found.
|
|
51
|
+
*/
|
|
52
|
+
export async function locationUri(er: EventRegistry, label: string, args: ER.GetLocationUriArguments = {}): Promise<string> {
|
|
53
|
+
return resolveOrThrow(() => er.getLocationUri(label, args), "location", label);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Resolve an event type label into its Event Registry event type uri.
|
|
58
|
+
* Thin wrapper around `EventRegistry.getEventTypeUri()`. Throws if no match is found.
|
|
59
|
+
*/
|
|
60
|
+
export async function eventTypeUri(er: EventRegistry, label: string): Promise<string> {
|
|
61
|
+
return resolveOrThrow(() => er.getEventTypeUri(label), "event type", label);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Resolve a concept class label into its Event Registry concept class uri.
|
|
66
|
+
* Thin wrapper around `EventRegistry.getConceptClassUri()`. Throws if no match is found.
|
|
67
|
+
*/
|
|
68
|
+
export async function conceptClassUri(er: EventRegistry, label: string, lang = "eng"): Promise<string> {
|
|
69
|
+
return resolveOrThrow(() => er.getConceptClassUri(label, lang), "concept class", label);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Resolve an author name into its Event Registry author uri.
|
|
74
|
+
* Thin wrapper around `EventRegistry.getAuthorUri()`. Throws if no match is found.
|
|
75
|
+
*/
|
|
76
|
+
export async function authorUri(er: EventRegistry, label: string): Promise<string> {
|
|
77
|
+
return resolveOrThrow(() => er.getAuthorUri(label), "author", label);
|
|
78
|
+
}
|
package/src/http.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { abortReason, abortableSleep } from "./abort";
|
|
2
|
+
import { ErApiError, parseRetryAfter } from "./errors";
|
|
3
|
+
|
|
4
|
+
export interface ErHttpResponse<T = unknown> {
|
|
5
|
+
data: T;
|
|
6
|
+
status: number;
|
|
7
|
+
statusText: string;
|
|
8
|
+
headers: Headers;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ErHttpRequest {
|
|
12
|
+
url: string;
|
|
13
|
+
method?: string;
|
|
14
|
+
body?: unknown;
|
|
15
|
+
headers?: Record<string, string>;
|
|
16
|
+
/** Per-attempt timeout. For an overall deadline use `signal` (see `composeSignal`). */
|
|
17
|
+
timeoutMs?: number;
|
|
18
|
+
/** Aborts the call: no further attempt starts and a pending backoff wait is cancelled. */
|
|
19
|
+
signal?: AbortSignal;
|
|
20
|
+
retry?: number;
|
|
21
|
+
/** Base of the backoff schedule: attempt n waits about `retryDelayMs * 2^n`, capped at `maxRetryDelayMs`. */
|
|
22
|
+
retryDelayMs?: number;
|
|
23
|
+
maxRetryDelayMs?: number;
|
|
24
|
+
stopStatusCodes?: number[];
|
|
25
|
+
responseType?: "json" | "text";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Largest delay `setTimeout` accepts; anything bigger overflows and fires after about 1 ms. */
|
|
29
|
+
const MAX_TIMER_MS = 2 ** 31 - 1;
|
|
30
|
+
|
|
31
|
+
/** Exponential backoff with equal jitter; the fixed `retryDelayMs` is the base of the schedule. */
|
|
32
|
+
function backoffDelay(attempt: number, baseMs: number, maxMs: number): number {
|
|
33
|
+
const capped = Math.min(maxMs, baseMs * 2 ** Math.min(attempt, 30));
|
|
34
|
+
return Math.round(capped / 2 + Math.random() * (capped / 2));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function scalarText(value: unknown): string | undefined {
|
|
38
|
+
return typeof value === "string" || typeof value === "number" ? String(value) : undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function toApiError(response: Response): Promise<ErApiError> {
|
|
42
|
+
let apiError: string | undefined;
|
|
43
|
+
let apiCode: string | undefined;
|
|
44
|
+
try {
|
|
45
|
+
const body = JSON.parse(await response.text()) as Record<string, unknown>;
|
|
46
|
+
const err = body?.error;
|
|
47
|
+
if (typeof err === "string") {
|
|
48
|
+
apiError = err;
|
|
49
|
+
} else if (err && typeof err === "object") {
|
|
50
|
+
const obj = err as Record<string, unknown>;
|
|
51
|
+
apiError = typeof obj.message === "string" ? obj.message : undefined;
|
|
52
|
+
apiCode = scalarText(obj.code);
|
|
53
|
+
}
|
|
54
|
+
apiCode ??= scalarText(body?.errorCode);
|
|
55
|
+
} catch {
|
|
56
|
+
// body is empty or not JSON: status line is all we have
|
|
57
|
+
}
|
|
58
|
+
const tokens = Number(response.headers.get("req-tokens"));
|
|
59
|
+
return new ErApiError({
|
|
60
|
+
status: response.status,
|
|
61
|
+
statusText: response.statusText,
|
|
62
|
+
apiCode,
|
|
63
|
+
apiError,
|
|
64
|
+
requestId: response.headers.get("x-request-id") ?? response.headers.get("req-id") ?? undefined,
|
|
65
|
+
tokens: response.headers.has("req-tokens") && Number.isFinite(tokens) ? tokens : undefined,
|
|
66
|
+
retryAfterMs: parseRetryAfter(response.headers.get("retry-after"))
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function isFetchNetworkError(error: unknown): boolean {
|
|
71
|
+
if (!(error instanceof TypeError)) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
const message = error.message.toLowerCase();
|
|
75
|
+
return message.includes("fetch failed") || message.includes("failed to fetch") || message.includes("network");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Programmer / parse errors must not spin on retry: -1. Network TypeErrors still retry. */
|
|
79
|
+
function isNonRetryableClientError(error: unknown): boolean {
|
|
80
|
+
if (error instanceof SyntaxError) {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
return error instanceof TypeError && !isFetchNetworkError(error);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export async function erFetch<T = unknown>(req: ErHttpRequest): Promise<ErHttpResponse<T>> {
|
|
87
|
+
const method = req.method ?? "POST";
|
|
88
|
+
const timeoutMs = req.timeoutMs ?? 600_000;
|
|
89
|
+
const retry = req.retry ?? 0;
|
|
90
|
+
const retryDelayMs = req.retryDelayMs ?? 5000;
|
|
91
|
+
const maxRetryDelayMs = req.maxRetryDelayMs ?? 30_000;
|
|
92
|
+
const stopStatusCodes = req.stopStatusCodes ?? [204, 400, 401, 403, 530];
|
|
93
|
+
const serializedBody = req.body !== undefined ? JSON.stringify(req.body) : undefined;
|
|
94
|
+
|
|
95
|
+
let attempt = 0;
|
|
96
|
+
for (;;) {
|
|
97
|
+
req.signal?.throwIfAborted();
|
|
98
|
+
const controller = new AbortController();
|
|
99
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
100
|
+
const onAbort = () => controller.abort(req.signal?.reason);
|
|
101
|
+
req.signal?.addEventListener("abort", onAbort, { once: true });
|
|
102
|
+
try {
|
|
103
|
+
const init: RequestInit = {
|
|
104
|
+
method,
|
|
105
|
+
headers: {
|
|
106
|
+
"content-type": "application/json",
|
|
107
|
+
...(req.headers ?? {})
|
|
108
|
+
},
|
|
109
|
+
signal: controller.signal
|
|
110
|
+
};
|
|
111
|
+
if (serializedBody !== undefined) {
|
|
112
|
+
init.body = serializedBody;
|
|
113
|
+
}
|
|
114
|
+
const response = await fetch(req.url, init);
|
|
115
|
+
clearTimeout(timer);
|
|
116
|
+
|
|
117
|
+
if (response.status === 200) {
|
|
118
|
+
const data = (req.responseType === "text"
|
|
119
|
+
? await response.text()
|
|
120
|
+
: await response.json()) as T;
|
|
121
|
+
return {
|
|
122
|
+
data,
|
|
123
|
+
status: response.status,
|
|
124
|
+
statusText: response.statusText,
|
|
125
|
+
headers: response.headers
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const apiError = await toApiError(response);
|
|
130
|
+
if (stopStatusCodes.includes(response.status)) {
|
|
131
|
+
throw apiError;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (retry >= 0 && attempt >= retry) {
|
|
135
|
+
throw Object.assign(apiError, { __retryCount: attempt });
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const honourRetryAfter = response.status === 429 || response.status === 503;
|
|
139
|
+
const delay = honourRetryAfter && apiError.retryAfterMs !== undefined
|
|
140
|
+
? Math.min(apiError.retryAfterMs, maxRetryDelayMs, MAX_TIMER_MS)
|
|
141
|
+
: backoffDelay(attempt, retryDelayMs, maxRetryDelayMs);
|
|
142
|
+
attempt += 1;
|
|
143
|
+
await abortableSleep(delay, req.signal);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
clearTimeout(timer);
|
|
146
|
+
if (req.signal?.aborted) {
|
|
147
|
+
// the caller cancelled: never retry
|
|
148
|
+
throw abortReason(req.signal);
|
|
149
|
+
}
|
|
150
|
+
const status = (error as { response?: { status?: number } })?.response?.status;
|
|
151
|
+
if (status !== undefined && stopStatusCodes.includes(status)) {
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
if (isNonRetryableClientError(error)) {
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
157
|
+
if (retry >= 0 && attempt >= retry) {
|
|
158
|
+
// Rethrow the original thrown value (it may not be an Error) with the retry count attached.
|
|
159
|
+
// eslint-disable-next-line @typescript-eslint/only-throw-error
|
|
160
|
+
throw Object.assign(error as object, { __retryCount: attempt });
|
|
161
|
+
}
|
|
162
|
+
const delay = backoffDelay(attempt, retryDelayMs, maxRetryDelayMs);
|
|
163
|
+
attempt += 1;
|
|
164
|
+
await abortableSleep(delay, req.signal);
|
|
165
|
+
} finally {
|
|
166
|
+
req.signal?.removeEventListener("abort", onAbort);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
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 { ErApiError, ErBudgetExceededError, ErTimeoutError, ErValidationError } from "./errors";
|
|
13
|
+
export { validateResponse } from "./guards";
|
|
14
|
+
export { Usage } from "./usage";
|
|
15
|
+
export type { LastCallUsage } from "./usage";
|
|
16
|
+
export { ER } from "./types";
|
|
17
|
+
export {
|
|
18
|
+
GetSourceInfo,
|
|
19
|
+
GetConceptInfo,
|
|
20
|
+
GetCategoryInfo,
|
|
21
|
+
GetSourceStats
|
|
22
|
+
} from "./info";
|
|
23
|
+
export {
|
|
24
|
+
BaseQuery,
|
|
25
|
+
CombinedQuery,
|
|
26
|
+
ComplexArticleQuery,
|
|
27
|
+
ComplexEventQuery
|
|
28
|
+
} from "./query";
|
|
29
|
+
export {
|
|
30
|
+
QueryArticle,
|
|
31
|
+
RequestArticleInfo,
|
|
32
|
+
RequestArticleSimilarArticles,
|
|
33
|
+
RequestArticleDuplicatedArticles,
|
|
34
|
+
RequestArticleOriginalArticle
|
|
35
|
+
} from "./queryArticle";
|
|
36
|
+
export {
|
|
37
|
+
QueryArticles,
|
|
38
|
+
QueryArticlesIter,
|
|
39
|
+
RequestArticlesInfo,
|
|
40
|
+
RequestArticlesUriWgtList,
|
|
41
|
+
RequestArticlesTimeAggr,
|
|
42
|
+
RequestArticlesConceptAggr,
|
|
43
|
+
RequestArticlesCategoryAggr,
|
|
44
|
+
RequestArticlesSourceAggr,
|
|
45
|
+
RequestArticlesKeywordAggr,
|
|
46
|
+
RequestArticlesConceptGraph,
|
|
47
|
+
RequestArticlesConceptMatrix,
|
|
48
|
+
RequestArticlesConceptTrends,
|
|
49
|
+
RequestArticlesDateMentionAggr,
|
|
50
|
+
RequestArticlesRecentActivity
|
|
51
|
+
} from "./queryArticles";
|
|
52
|
+
export {
|
|
53
|
+
QueryEvent,
|
|
54
|
+
QueryEventArticlesIter,
|
|
55
|
+
RequestEventInfo,
|
|
56
|
+
RequestEventArticles,
|
|
57
|
+
RequestEventArticleUriWgts,
|
|
58
|
+
RequestEventKeywordAggr,
|
|
59
|
+
RequestEventSourceAggr,
|
|
60
|
+
RequestEventDateMentionAggr,
|
|
61
|
+
RequestEventArticleTrend,
|
|
62
|
+
RequestEventSimilarEvents
|
|
63
|
+
} from "./queryEvent";
|
|
64
|
+
export {
|
|
65
|
+
QueryEvents,
|
|
66
|
+
QueryEventsIter,
|
|
67
|
+
RequestEventsInfo,
|
|
68
|
+
RequestEventsUriWgtList,
|
|
69
|
+
RequestEventsTimeAggr,
|
|
70
|
+
RequestEventsKeywordAggr,
|
|
71
|
+
RequestEventsLocAggr,
|
|
72
|
+
RequestEventsLocTimeAggr,
|
|
73
|
+
RequestEventsConceptAggr,
|
|
74
|
+
RequestEventsConceptGraph,
|
|
75
|
+
RequestEventsConceptMatrix,
|
|
76
|
+
RequestEventsConceptTrends,
|
|
77
|
+
RequestEventsSourceAggr,
|
|
78
|
+
RequestEventsDateMentionAggr,
|
|
79
|
+
RequestEventsEventClusters,
|
|
80
|
+
RequestEventsCategoryAggr,
|
|
81
|
+
RequestEventsRecentActivity,
|
|
82
|
+
RequestEventsBreakingEvents
|
|
83
|
+
} from "./queryEvents";
|
|
84
|
+
export {
|
|
85
|
+
QueryMentions,
|
|
86
|
+
QueryMentionsIter,
|
|
87
|
+
RequestMentions,
|
|
88
|
+
RequestMentionsInfo,
|
|
89
|
+
RequestMentionsUriWgtList,
|
|
90
|
+
RequestMentionsTimeAggr,
|
|
91
|
+
RequestMentionsConceptAggr,
|
|
92
|
+
RequestMentionsCategoryAggr,
|
|
93
|
+
RequestMentionsSourceAggr,
|
|
94
|
+
RequestMentionsKeywordAggr,
|
|
95
|
+
RequestMentionsConceptGraph,
|
|
96
|
+
RequestMentionsRecentActivity
|
|
97
|
+
} from "./queryMentions";
|
|
98
|
+
export {
|
|
99
|
+
QueryStory,
|
|
100
|
+
RequestStoryInfo,
|
|
101
|
+
RequestStoryArticles,
|
|
102
|
+
RequestStoryArticleUris,
|
|
103
|
+
RequestStoryArticleTrend,
|
|
104
|
+
RequestStorySimilarStories
|
|
105
|
+
} from "./queryStory";
|
|
106
|
+
export {
|
|
107
|
+
GetRecentEvents,
|
|
108
|
+
GetRecentArticles
|
|
109
|
+
} from "./recent";
|
|
110
|
+
export type { RecentCursor } from "./recent";
|
|
111
|
+
export {
|
|
112
|
+
ReturnInfo,
|
|
113
|
+
ArticleInfoFlags,
|
|
114
|
+
StoryInfoFlags,
|
|
115
|
+
EventInfoFlags,
|
|
116
|
+
SourceInfoFlags,
|
|
117
|
+
CategoryInfoFlags,
|
|
118
|
+
ConceptInfoFlags,
|
|
119
|
+
LocationInfoFlags,
|
|
120
|
+
ConceptClassInfoFlags,
|
|
121
|
+
ConceptFolderInfoFlags
|
|
122
|
+
} from "./returnInfo";
|
|
123
|
+
export {
|
|
124
|
+
GetTrendingConcepts,
|
|
125
|
+
GetTrendingCategories,
|
|
126
|
+
GetTrendingCustomItems,
|
|
127
|
+
GetTrendingConceptGroups
|
|
128
|
+
} from "./trends";
|
|
129
|
+
export {
|
|
130
|
+
TopicPage
|
|
131
|
+
} from "./topicPage";
|
|
132
|
+
export {
|
|
133
|
+
TopicPages
|
|
134
|
+
} from "./topicPages";
|
|
135
|
+
export {
|
|
136
|
+
LogLevel,
|
|
137
|
+
Logger
|
|
138
|
+
} from "./logger";
|
|
139
|
+
export {
|
|
140
|
+
searchArticles,
|
|
141
|
+
iterateArticles,
|
|
142
|
+
getArticle
|
|
143
|
+
} from "./helpers/articles";
|
|
144
|
+
export {
|
|
145
|
+
searchEvents,
|
|
146
|
+
iterateEvents,
|
|
147
|
+
getEvent
|
|
148
|
+
} from "./helpers/events";
|
|
149
|
+
export {
|
|
150
|
+
searchMentions,
|
|
151
|
+
iterateMentions
|
|
152
|
+
} from "./helpers/mentions";
|
|
153
|
+
export { getStory } from "./helpers/stories";
|
|
154
|
+
export {
|
|
155
|
+
getTrendingConcepts,
|
|
156
|
+
getTrendingCategories,
|
|
157
|
+
getTrendingCustomItems,
|
|
158
|
+
getTrendingConceptGroups
|
|
159
|
+
} from "./helpers/trends";
|
|
160
|
+
export { getCounts, getCountsEx } from "./helpers/counts";
|
|
161
|
+
export { getTopSharedArticles, getTopSharedEvents } from "./helpers/shares";
|
|
162
|
+
export { getRecentEvents, getRecentArticles } from "./helpers/recent";
|
|
163
|
+
export { RecentFeed, recentArticlesFeed, recentEventsFeed } from "./recentFeed";
|
|
164
|
+
export type { RecentFeedOptions } from "./recentFeed";
|
|
165
|
+
export {
|
|
166
|
+
getSourceInfo,
|
|
167
|
+
getConceptInfo,
|
|
168
|
+
getCategoryInfo,
|
|
169
|
+
getSourceStats
|
|
170
|
+
} from "./helpers/info";
|
|
171
|
+
export {
|
|
172
|
+
conceptUri,
|
|
173
|
+
categoryUri,
|
|
174
|
+
sourceUri,
|
|
175
|
+
sourceGroupUri,
|
|
176
|
+
locationUri,
|
|
177
|
+
eventTypeUri,
|
|
178
|
+
conceptClassUri,
|
|
179
|
+
authorUri
|
|
180
|
+
} from "./helpers/uri";
|
|
181
|
+
export {
|
|
182
|
+
getMyTopicPages,
|
|
183
|
+
loadTopicPage,
|
|
184
|
+
createTopicPage
|
|
185
|
+
} from "./helpers/topicPages";
|
|
186
|
+
export {
|
|
187
|
+
annotateText,
|
|
188
|
+
categorizeText,
|
|
189
|
+
analyzeSentiment,
|
|
190
|
+
semanticSimilarity,
|
|
191
|
+
detectLanguage,
|
|
192
|
+
extractArticleInfo,
|
|
193
|
+
ner,
|
|
194
|
+
trainTopicOnTweets,
|
|
195
|
+
trainTopicCreateTopic,
|
|
196
|
+
trainTopicClearTopic,
|
|
197
|
+
trainTopicAddDocument,
|
|
198
|
+
trainTopicGetTrainedTopic
|
|
199
|
+
} from "./helpers/analytics";
|
|
200
|
+
export { getEventForText } from "./helpers/eventForText";
|
|
201
|
+
export { ArticlesFluent } from "./fluent/articles";
|
|
202
|
+
export { EventsFluent } from "./fluent/events";
|
|
203
|
+
export { MentionsFluent } from "./fluent/mentions";
|
|
204
|
+
export { StoriesFluent } from "./fluent/stories";
|
|
205
|
+
export { TrendsFluent } from "./fluent/trends";
|
|
206
|
+
export { CountsFluent } from "./fluent/counts";
|
|
207
|
+
export { SharesFluent } from "./fluent/shares";
|
|
208
|
+
export { RecentFluent } from "./fluent/recent";
|
|
209
|
+
export { InfoFluent } from "./fluent/info";
|
|
210
|
+
export { TopicPagesFluent } from "./fluent/topicPages";
|
|
211
|
+
export { AnalyticsFluent } from "./fluent/analytics";
|
|
212
|
+
export { EventForTextFluent, createEventForTextFluent } from "./fluent/eventForText";
|