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.
Files changed (450) hide show
  1. package/AGENT-RECIPES.md +86 -0
  2. package/CHANGELOG.md +254 -0
  3. package/LICENSE +21 -21
  4. package/MIGRATION.md +195 -0
  5. package/README.md +340 -234
  6. package/dist/cjs/abort.d.ts +14 -0
  7. package/dist/cjs/abort.js +71 -0
  8. package/dist/cjs/abort.js.map +1 -0
  9. package/dist/{analytics.d.ts → cjs/analytics.d.ts} +2 -1
  10. package/dist/cjs/analytics.js +174 -0
  11. package/dist/cjs/analytics.js.map +1 -0
  12. package/dist/{base.d.ts → cjs/base.d.ts} +9 -9
  13. package/dist/cjs/base.js +195 -0
  14. package/dist/cjs/base.js.map +1 -0
  15. package/dist/cjs/counts.js +120 -0
  16. package/dist/cjs/counts.js.map +1 -0
  17. package/dist/cjs/dailyShares.js +46 -0
  18. package/dist/cjs/dailyShares.js.map +1 -0
  19. package/dist/{data.d.ts → cjs/data.d.ts} +32 -5
  20. package/dist/cjs/data.js.map +1 -0
  21. package/dist/cjs/errors.d.ts +66 -0
  22. package/dist/cjs/errors.js +75 -0
  23. package/dist/cjs/errors.js.map +1 -0
  24. package/dist/{eventForText.d.ts → cjs/eventForText.d.ts} +1 -1
  25. package/dist/cjs/eventForText.js +61 -0
  26. package/dist/cjs/eventForText.js.map +1 -0
  27. package/dist/{eventRegistry.d.ts → cjs/eventRegistry.d.ts} +167 -36
  28. package/dist/cjs/eventRegistry.js +939 -0
  29. package/dist/cjs/eventRegistry.js.map +1 -0
  30. package/dist/cjs/fluent/analytics.d.ts +24 -0
  31. package/dist/cjs/fluent/analytics.js +47 -0
  32. package/dist/cjs/fluent/analytics.js.map +1 -0
  33. package/dist/cjs/fluent/articles.d.ts +23 -0
  34. package/dist/cjs/fluent/articles.js +34 -0
  35. package/dist/cjs/fluent/articles.js.map +1 -0
  36. package/dist/cjs/fluent/counts.d.ts +8 -0
  37. package/dist/cjs/fluent/counts.js +17 -0
  38. package/dist/cjs/fluent/counts.js.map +1 -0
  39. package/dist/cjs/fluent/eventForText.d.ts +4 -0
  40. package/dist/cjs/fluent/eventForText.js +8 -0
  41. package/dist/cjs/fluent/eventForText.js.map +1 -0
  42. package/dist/cjs/fluent/events.d.ts +23 -0
  43. package/dist/cjs/fluent/events.js +34 -0
  44. package/dist/cjs/fluent/events.js.map +1 -0
  45. package/dist/cjs/fluent/info.d.ts +10 -0
  46. package/dist/cjs/fluent/info.js +23 -0
  47. package/dist/cjs/fluent/info.js.map +1 -0
  48. package/dist/cjs/fluent/mentions.d.ts +18 -0
  49. package/dist/cjs/fluent/mentions.js +31 -0
  50. package/dist/cjs/fluent/mentions.js.map +1 -0
  51. package/dist/cjs/fluent/recent.d.ts +13 -0
  52. package/dist/cjs/fluent/recent.js +21 -0
  53. package/dist/cjs/fluent/recent.js.map +1 -0
  54. package/dist/cjs/fluent/shares.d.ts +8 -0
  55. package/dist/cjs/fluent/shares.js +17 -0
  56. package/dist/cjs/fluent/shares.js.map +1 -0
  57. package/dist/cjs/fluent/stories.d.ts +8 -0
  58. package/dist/cjs/fluent/stories.js +14 -0
  59. package/dist/cjs/fluent/stories.js.map +1 -0
  60. package/dist/cjs/fluent/topicPages.d.ts +10 -0
  61. package/dist/cjs/fluent/topicPages.js +20 -0
  62. package/dist/cjs/fluent/topicPages.js.map +1 -0
  63. package/dist/cjs/fluent/trends.d.ts +11 -0
  64. package/dist/cjs/fluent/trends.js +23 -0
  65. package/dist/cjs/fluent/trends.js.map +1 -0
  66. package/dist/cjs/guards.d.ts +12 -0
  67. package/dist/cjs/guards.js +75 -0
  68. package/dist/cjs/guards.js.map +1 -0
  69. package/dist/cjs/helpers/analytics.d.ts +68 -0
  70. package/dist/cjs/helpers/analytics.js +100 -0
  71. package/dist/cjs/helpers/analytics.js.map +1 -0
  72. package/dist/cjs/helpers/articles.d.ts +24 -0
  73. package/dist/cjs/helpers/articles.js +31 -0
  74. package/dist/cjs/helpers/articles.js.map +1 -0
  75. package/dist/cjs/helpers/counts.d.ts +4 -0
  76. package/dist/cjs/helpers/counts.js +12 -0
  77. package/dist/cjs/helpers/counts.js.map +1 -0
  78. package/dist/cjs/helpers/eventForText.d.ts +6 -0
  79. package/dist/cjs/helpers/eventForText.js +13 -0
  80. package/dist/cjs/helpers/eventForText.js.map +1 -0
  81. package/dist/cjs/helpers/events.d.ts +18 -0
  82. package/dist/cjs/helpers/events.js +31 -0
  83. package/dist/cjs/helpers/events.js.map +1 -0
  84. package/dist/cjs/helpers/info.d.ts +6 -0
  85. package/dist/cjs/helpers/info.js +20 -0
  86. package/dist/cjs/helpers/info.js.map +1 -0
  87. package/dist/cjs/helpers/mentions.d.ts +10 -0
  88. package/dist/cjs/helpers/mentions.js +21 -0
  89. package/dist/cjs/helpers/mentions.js.map +1 -0
  90. package/dist/cjs/helpers/recent.d.ts +10 -0
  91. package/dist/cjs/helpers/recent.js +18 -0
  92. package/dist/cjs/helpers/recent.js.map +1 -0
  93. package/dist/cjs/helpers/shares.d.ts +4 -0
  94. package/dist/cjs/helpers/shares.js +12 -0
  95. package/dist/cjs/helpers/shares.js.map +1 -0
  96. package/dist/cjs/helpers/stories.d.ts +7 -0
  97. package/dist/cjs/helpers/stories.js +13 -0
  98. package/dist/cjs/helpers/stories.js.map +1 -0
  99. package/dist/cjs/helpers/topicPages.d.ts +16 -0
  100. package/dist/cjs/helpers/topicPages.js +29 -0
  101. package/dist/cjs/helpers/topicPages.js.map +1 -0
  102. package/dist/cjs/helpers/trends.d.ts +7 -0
  103. package/dist/cjs/helpers/trends.js +20 -0
  104. package/dist/cjs/helpers/trends.js.map +1 -0
  105. package/dist/cjs/helpers/uri.d.ts +42 -0
  106. package/dist/cjs/helpers/uri.js +78 -0
  107. package/dist/cjs/helpers/uri.js.map +1 -0
  108. package/dist/cjs/http.d.ts +23 -0
  109. package/dist/cjs/http.js +141 -0
  110. package/dist/cjs/http.js.map +1 -0
  111. package/dist/cjs/index.d.ts +54 -0
  112. package/dist/{index.js → cjs/index.js} +104 -3
  113. package/dist/cjs/index.js.map +1 -0
  114. package/dist/cjs/info.js +115 -0
  115. package/dist/cjs/info.js.map +1 -0
  116. package/dist/{logger.d.ts → cjs/logger.d.ts} +15 -11
  117. package/dist/cjs/logger.js +183 -0
  118. package/dist/cjs/logger.js.map +1 -0
  119. package/dist/cjs/mutex.d.ts +7 -0
  120. package/dist/cjs/mutex.js +44 -0
  121. package/dist/cjs/mutex.js.map +1 -0
  122. package/dist/cjs/package.json +3 -0
  123. package/dist/{query.d.ts → cjs/query.d.ts} +5 -8
  124. package/dist/cjs/query.js +248 -0
  125. package/dist/cjs/query.js.map +1 -0
  126. package/dist/{queryArticle.d.ts → cjs/queryArticle.d.ts} +5 -5
  127. package/dist/cjs/queryArticle.js +121 -0
  128. package/dist/cjs/queryArticle.js.map +1 -0
  129. package/dist/{queryArticles.d.ts → cjs/queryArticles.d.ts} +36 -69
  130. package/dist/cjs/queryArticles.js +457 -0
  131. package/dist/cjs/queryArticles.js.map +1 -0
  132. package/dist/{queryEvent.d.ts → cjs/queryEvent.d.ts} +7 -6
  133. package/dist/cjs/queryEvent.js +423 -0
  134. package/dist/cjs/queryEvent.js.map +1 -0
  135. package/dist/{queryEvents.d.ts → cjs/queryEvents.d.ts} +30 -39
  136. package/dist/cjs/queryEvents.js +568 -0
  137. package/dist/cjs/queryEvents.js.map +1 -0
  138. package/dist/cjs/queryIterator.d.ts +36 -0
  139. package/dist/cjs/queryIterator.js +85 -0
  140. package/dist/cjs/queryIterator.js.map +1 -0
  141. package/dist/{queryMentions.d.ts → cjs/queryMentions.d.ts} +19 -18
  142. package/dist/cjs/queryMentions.js +446 -0
  143. package/dist/cjs/queryMentions.js.map +1 -0
  144. package/dist/{queryStory.d.ts → cjs/queryStory.d.ts} +24 -21
  145. package/dist/cjs/queryStory.js +120 -0
  146. package/dist/cjs/queryStory.js.map +1 -0
  147. package/dist/cjs/recent.d.ts +35 -0
  148. package/dist/cjs/recent.js +81 -0
  149. package/dist/cjs/recent.js.map +1 -0
  150. package/dist/cjs/recentFeed.d.ts +35 -0
  151. package/dist/cjs/recentFeed.js +76 -0
  152. package/dist/cjs/recentFeed.js.map +1 -0
  153. package/dist/{returnInfo.d.ts → cjs/returnInfo.d.ts} +21 -23
  154. package/dist/cjs/returnInfo.js +292 -0
  155. package/dist/cjs/returnInfo.js.map +1 -0
  156. package/dist/{topicPage.d.ts → cjs/topicPage.d.ts} +3 -3
  157. package/dist/cjs/topicPage.js +458 -0
  158. package/dist/cjs/topicPage.js.map +1 -0
  159. package/dist/cjs/topicPages.d.ts +13 -0
  160. package/dist/cjs/topicPages.js +22 -0
  161. package/dist/cjs/topicPages.js.map +1 -0
  162. package/dist/{trends.d.ts → cjs/trends.d.ts} +13 -13
  163. package/dist/cjs/trends.js +64 -0
  164. package/dist/cjs/trends.js.map +1 -0
  165. package/dist/{types.d.ts → cjs/types.d.ts} +195 -37
  166. package/dist/cjs/types.js.map +1 -0
  167. package/dist/cjs/usage.d.ts +39 -0
  168. package/dist/cjs/usage.js +62 -0
  169. package/dist/cjs/usage.js.map +1 -0
  170. package/dist/cjs/version.d.ts +1 -0
  171. package/dist/cjs/version.js +5 -0
  172. package/dist/cjs/version.js.map +1 -0
  173. package/dist/esm/abort.d.ts +14 -0
  174. package/dist/esm/abort.js +65 -0
  175. package/dist/esm/abort.js.map +1 -0
  176. package/dist/esm/analytics.d.ts +83 -0
  177. package/dist/esm/analytics.js +170 -0
  178. package/dist/esm/analytics.js.map +1 -0
  179. package/dist/esm/base.d.ts +82 -0
  180. package/dist/esm/base.js +188 -0
  181. package/dist/esm/base.js.map +1 -0
  182. package/dist/esm/counts.d.ts +81 -0
  183. package/dist/esm/counts.js +114 -0
  184. package/dist/esm/counts.js.map +1 -0
  185. package/dist/esm/dailyShares.d.ts +10 -0
  186. package/dist/esm/dailyShares.js +41 -0
  187. package/dist/esm/dailyShares.js.map +1 -0
  188. package/dist/esm/data.d.ts +296 -0
  189. package/dist/esm/data.js +3 -0
  190. package/dist/esm/data.js.map +1 -0
  191. package/dist/esm/errors.d.ts +66 -0
  192. package/dist/esm/errors.js +67 -0
  193. package/dist/esm/errors.js.map +1 -0
  194. package/dist/esm/eventForText.d.ts +48 -0
  195. package/dist/esm/eventForText.js +57 -0
  196. package/dist/esm/eventForText.js.map +1 -0
  197. package/dist/esm/eventRegistry.d.ts +375 -0
  198. package/dist/esm/eventRegistry.js +901 -0
  199. package/dist/esm/eventRegistry.js.map +1 -0
  200. package/dist/esm/fluent/analytics.d.ts +24 -0
  201. package/dist/esm/fluent/analytics.js +43 -0
  202. package/dist/esm/fluent/analytics.js.map +1 -0
  203. package/dist/esm/fluent/articles.d.ts +23 -0
  204. package/dist/esm/fluent/articles.js +30 -0
  205. package/dist/esm/fluent/articles.js.map +1 -0
  206. package/dist/esm/fluent/counts.d.ts +8 -0
  207. package/dist/esm/fluent/counts.js +13 -0
  208. package/dist/esm/fluent/counts.js.map +1 -0
  209. package/dist/esm/fluent/eventForText.d.ts +4 -0
  210. package/dist/esm/fluent/eventForText.js +5 -0
  211. package/dist/esm/fluent/eventForText.js.map +1 -0
  212. package/dist/esm/fluent/events.d.ts +23 -0
  213. package/dist/esm/fluent/events.js +30 -0
  214. package/dist/esm/fluent/events.js.map +1 -0
  215. package/dist/esm/fluent/info.d.ts +10 -0
  216. package/dist/esm/fluent/info.js +19 -0
  217. package/dist/esm/fluent/info.js.map +1 -0
  218. package/dist/esm/fluent/mentions.d.ts +18 -0
  219. package/dist/esm/fluent/mentions.js +27 -0
  220. package/dist/esm/fluent/mentions.js.map +1 -0
  221. package/dist/esm/fluent/recent.d.ts +13 -0
  222. package/dist/esm/fluent/recent.js +17 -0
  223. package/dist/esm/fluent/recent.js.map +1 -0
  224. package/dist/esm/fluent/shares.d.ts +8 -0
  225. package/dist/esm/fluent/shares.js +13 -0
  226. package/dist/esm/fluent/shares.js.map +1 -0
  227. package/dist/esm/fluent/stories.d.ts +8 -0
  228. package/dist/esm/fluent/stories.js +10 -0
  229. package/dist/esm/fluent/stories.js.map +1 -0
  230. package/dist/esm/fluent/topicPages.d.ts +10 -0
  231. package/dist/esm/fluent/topicPages.js +16 -0
  232. package/dist/esm/fluent/topicPages.js.map +1 -0
  233. package/dist/esm/fluent/trends.d.ts +11 -0
  234. package/dist/esm/fluent/trends.js +19 -0
  235. package/dist/esm/fluent/trends.js.map +1 -0
  236. package/dist/esm/guards.d.ts +12 -0
  237. package/dist/esm/guards.js +70 -0
  238. package/dist/esm/guards.js.map +1 -0
  239. package/dist/esm/helpers/analytics.d.ts +68 -0
  240. package/dist/esm/helpers/analytics.js +86 -0
  241. package/dist/esm/helpers/analytics.js.map +1 -0
  242. package/dist/esm/helpers/articles.d.ts +24 -0
  243. package/dist/esm/helpers/articles.js +26 -0
  244. package/dist/esm/helpers/articles.js.map +1 -0
  245. package/dist/esm/helpers/counts.d.ts +4 -0
  246. package/dist/esm/helpers/counts.js +8 -0
  247. package/dist/esm/helpers/counts.js.map +1 -0
  248. package/dist/esm/helpers/eventForText.d.ts +6 -0
  249. package/dist/esm/helpers/eventForText.js +10 -0
  250. package/dist/esm/helpers/eventForText.js.map +1 -0
  251. package/dist/esm/helpers/events.d.ts +18 -0
  252. package/dist/esm/helpers/events.js +26 -0
  253. package/dist/esm/helpers/events.js.map +1 -0
  254. package/dist/esm/helpers/info.d.ts +6 -0
  255. package/dist/esm/helpers/info.js +14 -0
  256. package/dist/esm/helpers/info.js.map +1 -0
  257. package/dist/esm/helpers/mentions.d.ts +10 -0
  258. package/dist/esm/helpers/mentions.js +17 -0
  259. package/dist/esm/helpers/mentions.js.map +1 -0
  260. package/dist/esm/helpers/recent.d.ts +10 -0
  261. package/dist/esm/helpers/recent.js +14 -0
  262. package/dist/esm/helpers/recent.js.map +1 -0
  263. package/dist/esm/helpers/shares.d.ts +4 -0
  264. package/dist/esm/helpers/shares.js +8 -0
  265. package/dist/esm/helpers/shares.js.map +1 -0
  266. package/dist/esm/helpers/stories.d.ts +7 -0
  267. package/dist/esm/helpers/stories.js +10 -0
  268. package/dist/esm/helpers/stories.js.map +1 -0
  269. package/dist/esm/helpers/topicPages.d.ts +16 -0
  270. package/dist/esm/helpers/topicPages.js +24 -0
  271. package/dist/esm/helpers/topicPages.js.map +1 -0
  272. package/dist/esm/helpers/trends.d.ts +7 -0
  273. package/dist/esm/helpers/trends.js +14 -0
  274. package/dist/esm/helpers/trends.js.map +1 -0
  275. package/dist/esm/helpers/uri.d.ts +42 -0
  276. package/dist/esm/helpers/uri.js +68 -0
  277. package/dist/esm/helpers/uri.js.map +1 -0
  278. package/dist/esm/http.d.ts +23 -0
  279. package/dist/esm/http.js +138 -0
  280. package/dist/esm/http.js.map +1 -0
  281. package/dist/esm/index.d.ts +54 -0
  282. package/dist/esm/index.js +51 -0
  283. package/dist/esm/index.js.map +1 -0
  284. package/dist/esm/info.d.ts +61 -0
  285. package/dist/esm/info.js +108 -0
  286. package/dist/esm/info.js.map +1 -0
  287. package/dist/esm/logger.d.ts +49 -0
  288. package/dist/esm/logger.js +146 -0
  289. package/dist/esm/logger.js.map +1 -0
  290. package/dist/esm/mutex.d.ts +7 -0
  291. package/dist/esm/mutex.js +40 -0
  292. package/dist/esm/mutex.js.map +1 -0
  293. package/dist/esm/package.json +3 -0
  294. package/dist/esm/query.d.ts +50 -0
  295. package/dist/esm/query.js +240 -0
  296. package/dist/esm/query.js.map +1 -0
  297. package/dist/esm/queryArticle.d.ts +61 -0
  298. package/dist/esm/queryArticle.js +112 -0
  299. package/dist/esm/queryArticle.js.map +1 -0
  300. package/dist/esm/queryArticles.d.ts +111 -0
  301. package/dist/esm/queryArticles.js +439 -0
  302. package/dist/esm/queryArticles.js.map +1 -0
  303. package/dist/esm/queryEvent.d.ts +141 -0
  304. package/dist/esm/queryEvent.js +409 -0
  305. package/dist/esm/queryEvent.js.map +1 -0
  306. package/dist/esm/queryEvents.d.ts +201 -0
  307. package/dist/esm/queryEvents.js +546 -0
  308. package/dist/esm/queryEvents.js.map +1 -0
  309. package/dist/esm/queryIterator.d.ts +36 -0
  310. package/dist/esm/queryIterator.js +81 -0
  311. package/dist/esm/queryIterator.js.map +1 -0
  312. package/dist/esm/queryMentions.d.ts +97 -0
  313. package/dist/esm/queryMentions.js +431 -0
  314. package/dist/esm/queryMentions.js.map +1 -0
  315. package/dist/esm/queryStory.d.ts +61 -0
  316. package/dist/esm/queryStory.js +110 -0
  317. package/dist/esm/queryStory.js.map +1 -0
  318. package/dist/esm/recent.d.ts +35 -0
  319. package/dist/esm/recent.js +76 -0
  320. package/dist/esm/recent.js.map +1 -0
  321. package/dist/esm/recentFeed.d.ts +35 -0
  322. package/dist/esm/recentFeed.js +70 -0
  323. package/dist/esm/recentFeed.js.map +1 -0
  324. package/dist/esm/returnInfo.d.ts +66 -0
  325. package/dist/esm/returnInfo.js +245 -0
  326. package/dist/esm/returnInfo.js.map +1 -0
  327. package/dist/esm/topicPage.d.ts +157 -0
  328. package/dist/esm/topicPage.js +421 -0
  329. package/dist/esm/topicPage.js.map +1 -0
  330. package/dist/esm/topicPages.d.ts +13 -0
  331. package/dist/esm/topicPages.js +18 -0
  332. package/dist/esm/topicPages.js.map +1 -0
  333. package/dist/esm/trends.d.ts +35 -0
  334. package/dist/esm/trends.js +56 -0
  335. package/dist/esm/trends.js.map +1 -0
  336. package/dist/esm/types.d.ts +2611 -0
  337. package/dist/esm/types.js +2 -0
  338. package/dist/esm/types.js.map +1 -0
  339. package/dist/esm/usage.d.ts +39 -0
  340. package/dist/esm/usage.js +58 -0
  341. package/dist/esm/usage.js.map +1 -0
  342. package/dist/esm/version.d.ts +1 -0
  343. package/dist/esm/version.js +2 -0
  344. package/dist/esm/version.js.map +1 -0
  345. package/package.json +80 -42
  346. package/src/abort.ts +70 -0
  347. package/src/analytics.ts +197 -0
  348. package/src/base.ts +206 -0
  349. package/src/counts.ts +118 -0
  350. package/src/dailyShares.ts +46 -0
  351. package/src/data.ts +310 -0
  352. package/src/errors.ts +105 -0
  353. package/src/eventForText.ts +60 -0
  354. package/src/eventRegistry.ts +1105 -0
  355. package/src/fluent/analytics.ts +84 -0
  356. package/src/fluent/articles.ts +40 -0
  357. package/src/fluent/counts.ts +15 -0
  358. package/src/fluent/eventForText.ts +10 -0
  359. package/src/fluent/events.ts +40 -0
  360. package/src/fluent/info.ts +23 -0
  361. package/src/fluent/mentions.ts +34 -0
  362. package/src/fluent/recent.ts +19 -0
  363. package/src/fluent/shares.ts +15 -0
  364. package/src/fluent/stories.ts +12 -0
  365. package/src/fluent/topicPages.ts +20 -0
  366. package/src/fluent/trends.ts +34 -0
  367. package/src/guards.ts +79 -0
  368. package/src/helpers/analytics.ts +134 -0
  369. package/src/helpers/articles.ts +42 -0
  370. package/src/helpers/counts.ts +19 -0
  371. package/src/helpers/eventForText.ts +16 -0
  372. package/src/helpers/events.ts +43 -0
  373. package/src/helpers/info.ts +31 -0
  374. package/src/helpers/mentions.ts +27 -0
  375. package/src/helpers/recent.ts +22 -0
  376. package/src/helpers/shares.ts +17 -0
  377. package/src/helpers/stories.ts +16 -0
  378. package/src/helpers/topicPages.ts +28 -0
  379. package/src/helpers/trends.ts +36 -0
  380. package/src/helpers/uri.ts +78 -0
  381. package/src/http.ts +169 -0
  382. package/src/index.ts +212 -0
  383. package/src/info.ts +120 -0
  384. package/src/logger.ts +182 -0
  385. package/src/mutex.ts +40 -0
  386. package/src/query.ts +258 -0
  387. package/src/queryArticle.ts +139 -0
  388. package/src/queryArticles.ts +584 -0
  389. package/src/queryEvent.ts +510 -0
  390. package/src/queryEvents.ts +673 -0
  391. package/src/queryIterator.ts +100 -0
  392. package/src/queryMentions.ts +559 -0
  393. package/src/queryStory.ts +159 -0
  394. package/src/recent.ts +98 -0
  395. package/src/recentFeed.ts +91 -0
  396. package/src/returnInfo.ts +372 -0
  397. package/src/topicPage.ts +485 -0
  398. package/src/topicPages.ts +18 -0
  399. package/src/trends.ts +62 -0
  400. package/src/types.ts +2737 -0
  401. package/src/usage.ts +79 -0
  402. package/src/version.ts +1 -0
  403. package/dist/analytics.js +0 -337
  404. package/dist/analytics.js.map +0 -1
  405. package/dist/base.js +0 -262
  406. package/dist/base.js.map +0 -1
  407. package/dist/counts.js +0 -163
  408. package/dist/counts.js.map +0 -1
  409. package/dist/dailyShares.js +0 -91
  410. package/dist/dailyShares.js.map +0 -1
  411. package/dist/data.js.map +0 -1
  412. package/dist/eventForText.js +0 -127
  413. package/dist/eventForText.js.map +0 -1
  414. package/dist/eventRegistry.js +0 -1099
  415. package/dist/eventRegistry.js.map +0 -1
  416. package/dist/index.d.ts +0 -21
  417. package/dist/index.js.map +0 -1
  418. package/dist/info.js +0 -172
  419. package/dist/info.js.map +0 -1
  420. package/dist/logger.js +0 -156
  421. package/dist/logger.js.map +0 -1
  422. package/dist/query.js +0 -334
  423. package/dist/query.js.map +0 -1
  424. package/dist/queryArticle.js +0 -184
  425. package/dist/queryArticle.js.map +0 -1
  426. package/dist/queryArticles.js +0 -730
  427. package/dist/queryArticles.js.map +0 -1
  428. package/dist/queryEvent.js +0 -588
  429. package/dist/queryEvent.js.map +0 -1
  430. package/dist/queryEvents.js +0 -826
  431. package/dist/queryEvents.js.map +0 -1
  432. package/dist/queryMentions.js +0 -638
  433. package/dist/queryMentions.js.map +0 -1
  434. package/dist/queryStory.js +0 -195
  435. package/dist/queryStory.js.map +0 -1
  436. package/dist/recent.d.ts +0 -23
  437. package/dist/recent.js +0 -200
  438. package/dist/recent.js.map +0 -1
  439. package/dist/returnInfo.js +0 -333
  440. package/dist/returnInfo.js.map +0 -1
  441. package/dist/topicPage.js +0 -600
  442. package/dist/topicPage.js.map +0 -1
  443. package/dist/trends.js +0 -116
  444. package/dist/trends.js.map +0 -1
  445. package/dist/types.js.map +0 -1
  446. /package/dist/{counts.d.ts → cjs/counts.d.ts} +0 -0
  447. /package/dist/{dailyShares.d.ts → cjs/dailyShares.d.ts} +0 -0
  448. /package/dist/{data.js → cjs/data.js} +0 -0
  449. /package/dist/{info.d.ts → cjs/info.d.ts} +0 -0
  450. /package/dist/{types.js → cjs/types.js} +0 -0
@@ -1,1099 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- var __rest = (this && this.__rest) || function (s, e) {
50
- var t = {};
51
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
52
- t[p] = s[p];
53
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
54
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
55
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
56
- t[p[i]] = s[p[i]];
57
- }
58
- return t;
59
- };
60
- Object.defineProperty(exports, "__esModule", { value: true });
61
- exports.ArticleMapper = exports.EventRegistry = void 0;
62
- var axios_1 = require("axios");
63
- var fs = require("fs");
64
- var moment = require("moment");
65
- var semaphore_async_await_1 = require("semaphore-async-await");
66
- var returnInfo_1 = require("./returnInfo");
67
- var base_1 = require("./base");
68
- var logger_1 = require("./logger");
69
- /**
70
- * @class EventRegistry
71
- * Main class responsible for obtaining results form the Event Registry
72
- */
73
- var EventRegistry = /** @class */ (function () {
74
- function EventRegistry(config) {
75
- if (config === void 0) { config = {}; }
76
- var _this = this;
77
- var _a, _b;
78
- this.config = {
79
- host: "http://eventregistry.org",
80
- hostAnalytics: "http://analytics.eventregistry.org",
81
- logging: false,
82
- minDelayBetweenRequests: 1,
83
- repeatFailedRequestCount: 2,
84
- verboseOutput: false,
85
- allowUseOfArchive: true,
86
- };
87
- this.headers = {};
88
- this.dailyAvailableRequests = -1;
89
- this.remainingAvailableRequests = -1;
90
- this.lastQueryTime = 0;
91
- this._logRequests = false;
92
- this.stopStatusCodes = [
93
- 204,
94
- 400,
95
- 401,
96
- 403,
97
- 530,
98
- ];
99
- this.lock = new semaphore_async_await_1.default(1);
100
- this._logRequests = this.config.logging;
101
- this.logger = logger_1.Logger.createInstance({ logging: this.config.logging, logRequests: this._logRequests });
102
- if (fs && fs.existsSync(this.config.settingsFName || "settings.json")) {
103
- var localConfig = JSON.parse(fs.readFileSync(this.config.settingsFName || "settings.json", "utf8"));
104
- this.config = __assign(__assign(__assign({}, this.config), localConfig), config);
105
- if ((config === null || config === void 0 ? void 0 : config.apiKey) !== undefined) {
106
- this.logger.debug("found apiKey in settings file which will be used for making requests");
107
- this.config.apiKey = config.apiKey;
108
- }
109
- }
110
- else {
111
- this.config = __assign(__assign({}, this.config), config);
112
- if (!!config.apiKey) {
113
- this.logger.debug("using user provided API key for making requests");
114
- }
115
- }
116
- if (((_a = this.config) === null || _a === void 0 ? void 0 : _a.apiKey) === undefined || ((_b = this.config) === null || _b === void 0 ? void 0 : _b.apiKey) === null) {
117
- this.logger.info("No API key was provided. You will be allowed to perform only a very limited number of requests per day.");
118
- }
119
- this.logger.debug("Event Registry host: ".concat(this.config.host));
120
- this.logger.debug("Text analytics host: ".concat(this.config.hostAnalytics));
121
- this.config.minDelayBetweenRequests *= 1000;
122
- axios_1.default.interceptors.response.use(undefined, function (err) {
123
- // If config does not exist or the retry option is not set, reject
124
- if (!err.config || !err.config.retry) {
125
- return Promise.reject(err);
126
- }
127
- if (_this.stopStatusCodes.includes(err.response.status)) {
128
- return Promise.reject(err);
129
- }
130
- // Set the variable for keeping track of the retry count
131
- err.config.__retryCount = err.config.__retryCount || 0;
132
- // Check if we've maxed out the total number of retries
133
- if (err.config.__retryCount >= err.config.retry) {
134
- // Reject with the error
135
- return Promise.reject(err);
136
- }
137
- err.config.__retryCount += 1;
138
- return new Promise(function (resolve) {
139
- setTimeout(function () { return resolve(); }, err.config.retryDelay || 1);
140
- }).then(function () { return (0, axios_1.default)(err.config); });
141
- });
142
- }
143
- /**
144
- * Should all requests be logged to a file or not?
145
- */
146
- EventRegistry.prototype.setLogging = function (logging) {
147
- this._logRequests = logging;
148
- this.logger.toggleRequestLogging(logging);
149
- };
150
- Object.defineProperty(EventRegistry.prototype, "allowUseOfArchive", {
151
- get: function () {
152
- return this.config.allowUseOfArchive;
153
- },
154
- enumerable: false,
155
- configurable: true
156
- });
157
- Object.defineProperty(EventRegistry.prototype, "verboseOutput", {
158
- get: function () {
159
- return this.config.verboseOutput;
160
- },
161
- enumerable: false,
162
- configurable: true
163
- });
164
- /**
165
- * Main method for executing the search queries.
166
- * @param query instance of Query class
167
- */
168
- EventRegistry.prototype.execQuery = function (query_1) {
169
- return __awaiter(this, arguments, void 0, function (query, allowUseOfArchive) {
170
- var params, request;
171
- var _a;
172
- if (allowUseOfArchive === void 0) { allowUseOfArchive = this.config.allowUseOfArchive; }
173
- return __generator(this, function (_b) {
174
- switch (_b.label) {
175
- case 0:
176
- params = query.getQueryParams();
177
- return [4 /*yield*/, this.jsonRequest(query.path, params, allowUseOfArchive)];
178
- case 1:
179
- request = _b.sent();
180
- if (!(request === null || request === void 0 ? void 0 : request.data) && ((_a = this.config) === null || _a === void 0 ? void 0 : _a.verboseOutput)) {
181
- this.logger.error("Request did not return with the 'data' property.");
182
- }
183
- return [2 /*return*/, ((request === null || request === void 0 ? void 0 : request.data) || {})];
184
- }
185
- });
186
- });
187
- };
188
- EventRegistry.prototype.jsonRequestAnalytics = function (path, parameters, headers, cookies) {
189
- return __awaiter(this, void 0, void 0, function () {
190
- var request, args, cookieString, errorMessage, error_1;
191
- var _a, _b, _c, _d, _e, _f;
192
- return __generator(this, function (_g) {
193
- switch (_g.label) {
194
- case 0: return [4 /*yield*/, this.lock.acquire()];
195
- case 1:
196
- _g.sent();
197
- _g.label = 2;
198
- case 2:
199
- _g.trys.push([2, 4, 5, 6]);
200
- parameters = __assign(__assign({}, parameters), { apiKey: (_a = this.config) === null || _a === void 0 ? void 0 : _a.apiKey });
201
- args = {
202
- url: path,
203
- method: "POST",
204
- baseURL: this.config.hostAnalytics,
205
- data: parameters,
206
- timeout: 600000,
207
- responseType: "json",
208
- maxRedirects: 5,
209
- };
210
- if (!!headers) {
211
- args = __assign(__assign({}, args), { headers: headers });
212
- }
213
- if (!!cookies) {
214
- cookieString = Object.keys(cookies).map(function (key) { return key + "=" + cookies[key]; }).join(";") + ";";
215
- args = __assign(__assign({}, args), { headers: __assign(__assign({}, args.headers), { Cookie: cookieString }) });
216
- }
217
- return [4 /*yield*/, axios_1.default.request(args)];
218
- case 3:
219
- request = _g.sent();
220
- this.headers = (request === null || request === void 0 ? void 0 : request.headers) || {};
221
- if ((request === null || request === void 0 ? void 0 : request.status) !== 200) {
222
- throw new Error(request === null || request === void 0 ? void 0 : request.statusText);
223
- }
224
- errorMessage = ((_b = request === null || request === void 0 ? void 0 : request.data) === null || _b === void 0 ? void 0 : _b.error) || "";
225
- if (errorMessage) {
226
- throw new Error(errorMessage);
227
- }
228
- return [3 /*break*/, 6];
229
- case 4:
230
- error_1 = _g.sent();
231
- request = { data: { error: error_1 } };
232
- if (this.config.verboseOutput) {
233
- this.logger.error("Event Registry Analytics exception while executing the request.");
234
- if (error_1 && error_1.stack && error_1.message) {
235
- this.logger.error(error_1.message);
236
- }
237
- else {
238
- this.logger.error("".concat((_c = error_1 === null || error_1 === void 0 ? void 0 : error_1.response) === null || _c === void 0 ? void 0 : _c.status, ": ").concat((_d = error_1 === null || error_1 === void 0 ? void 0 : error_1.response) === null || _d === void 0 ? void 0 : _d.statusText, " => ").concat((_e = error_1 === null || error_1 === void 0 ? void 0 : error_1.response) === null || _e === void 0 ? void 0 : _e.data));
239
- }
240
- }
241
- // try to print out the error that should be passed by in case the server is down or responds with errors
242
- if ((_f = this.config) === null || _f === void 0 ? void 0 : _f.logging) {
243
- this.logger.error((error_1 === null || error_1 === void 0 ? void 0 : error_1.errno) || error_1);
244
- }
245
- return [3 /*break*/, 6];
246
- case 5:
247
- this.lock.release();
248
- return [7 /*endfinally*/];
249
- case 6: return [2 /*return*/, request];
250
- }
251
- });
252
- });
253
- };
254
- /**
255
- * Make a request for json data
256
- * @param path url on er (e.g. "/api/v1/article")
257
- * @param parameters Optional parameters to be included in the request
258
- */
259
- EventRegistry.prototype.jsonRequest = function (path_1, parameters_1) {
260
- return __awaiter(this, arguments, void 0, function (path, parameters, allowUseOfArchive) {
261
- var request, current, errorMessage, error_2;
262
- var _a, _b, _c, _d, _e, _f;
263
- if (allowUseOfArchive === void 0) { allowUseOfArchive = this.config.allowUseOfArchive; }
264
- return __generator(this, function (_g) {
265
- switch (_g.label) {
266
- case 0:
267
- current = moment.utc().milliseconds();
268
- if (!(this.lastQueryTime && current - this.lastQueryTime < this.config.minDelayBetweenRequests)) return [3 /*break*/, 2];
269
- return [4 /*yield*/, (0, base_1.sleep)(this.config.minDelayBetweenRequests - (current - this.lastQueryTime))];
270
- case 1:
271
- _g.sent();
272
- _g.label = 2;
273
- case 2: return [4 /*yield*/, this.lock.acquire()];
274
- case 3:
275
- _g.sent();
276
- if (this._logRequests) {
277
- if (Object.keys(parameters || {}).length > 0) {
278
- this.logger.logRequest("# " + JSON.stringify(parameters) + "\n");
279
- }
280
- this.logger.logRequest(path + "\n\n");
281
- }
282
- this.lastQueryTime = current;
283
- _g.label = 4;
284
- case 4:
285
- _g.trys.push([4, 6, 7, 8]);
286
- parameters = __assign(__assign({}, parameters), { apiKey: (_a = this.config) === null || _a === void 0 ? void 0 : _a.apiKey });
287
- if (!allowUseOfArchive) {
288
- parameters = __assign(__assign({}, parameters), { forceMaxDataTimeWindow: 31 });
289
- }
290
- return [4 /*yield*/, axios_1.default.request({
291
- url: path,
292
- method: "POST",
293
- baseURL: this.config.host,
294
- data: parameters,
295
- timeout: 600000,
296
- responseType: "json",
297
- maxRedirects: 5,
298
- retry: this.config.repeatFailedRequestCount,
299
- })];
300
- case 5:
301
- request = _g.sent();
302
- this.headers = (request === null || request === void 0 ? void 0 : request.headers) || {};
303
- if ((request === null || request === void 0 ? void 0 : request.status) !== 200) {
304
- throw new Error(request === null || request === void 0 ? void 0 : request.statusText);
305
- }
306
- if (this.getLastHeader("warning")) {
307
- this.logger.warn("WARNING: ".concat(this.getLastHeader("warning")));
308
- }
309
- this.dailyAvailableRequests = Number(this.getLastHeader("x-ratelimit-limit", "-1"));
310
- this.remainingAvailableRequests = Number(this.getLastHeader("x-ratelimit-remaining", "-1"));
311
- errorMessage = ((_b = request === null || request === void 0 ? void 0 : request.data) === null || _b === void 0 ? void 0 : _b.error) || "";
312
- if (errorMessage) {
313
- throw new Error(errorMessage);
314
- }
315
- return [3 /*break*/, 8];
316
- case 6:
317
- error_2 = _g.sent();
318
- request = { data: { error: error_2 } };
319
- // try to print out the error that should be passed by in case the server is down or responds with errors
320
- if (this.config.verboseOutput) {
321
- this.logger.error("Event Registry exception while executing the request.");
322
- if (error_2 && error_2.stack && error_2.message) {
323
- this.logger.error(error_2.message);
324
- }
325
- else {
326
- this.logger.error("".concat((_c = error_2 === null || error_2 === void 0 ? void 0 : error_2.response) === null || _c === void 0 ? void 0 : _c.status, ": ").concat((_d = error_2 === null || error_2 === void 0 ? void 0 : error_2.response) === null || _d === void 0 ? void 0 : _d.statusText, " => ").concat((_e = error_2 === null || error_2 === void 0 ? void 0 : error_2.response) === null || _e === void 0 ? void 0 : _e.data));
327
- }
328
- }
329
- if ((_f = this.config) === null || _f === void 0 ? void 0 : _f.logging) {
330
- this.logger.error((error_2 === null || error_2 === void 0 ? void 0 : error_2.errno) || error_2);
331
- }
332
- return [3 /*break*/, 8];
333
- case 7:
334
- this.lock.release();
335
- return [7 /*endfinally*/];
336
- case 8: return [2 /*return*/, request];
337
- }
338
- });
339
- });
340
- };
341
- /**
342
- * get the number of requests that are still available for the user today. Information is only accessible after you make some query.
343
- */
344
- EventRegistry.prototype.getRemainingAvailableRequests = function () {
345
- return this.remainingAvailableRequests;
346
- };
347
- /**
348
- * get the total number of requests that the user can make in a day. Information is only accessible after you make some query.
349
- */
350
- EventRegistry.prototype.getDailyAvailableRequests = function () {
351
- return this.dailyAvailableRequests;
352
- };
353
- /**
354
- * Return the headers returned in the response object of the last executed request
355
- */
356
- EventRegistry.prototype.getLastHeaders = function () {
357
- return this.headers;
358
- };
359
- /**
360
- * Get a value of the header headerName that was set in the headers in the last response object
361
- */
362
- EventRegistry.prototype.getLastHeader = function (headerName, dfltVal) {
363
- var _a, _b;
364
- return (_b = (_a = this.headers) === null || _a === void 0 ? void 0 : _a[headerName]) !== null && _b !== void 0 ? _b : dfltVal;
365
- };
366
- /**
367
- * print some statistics about the last executed request
368
- */
369
- EventRegistry.prototype.printLastReqStats = function () {
370
- this.logger.info("Tokens used by the request: ".concat(this.getLastHeader("req-tokens")));
371
- this.logger.info("Performed action: ".concat(this.getLastHeader("req-action")));
372
- this.logger.info("Was archive used for the query: ".concat(this.getLastReqArchiveUse() ? "Yes" : "No"));
373
- };
374
- /**
375
- * return true or false depending on whether the last request used the archive or not
376
- */
377
- EventRegistry.prototype.getLastReqArchiveUse = function () {
378
- return this.getLastHeader("req-archive", "0") === "1";
379
- };
380
- /**
381
- * Return the number of used and total available tokens. Can be used at any time (also before making queries)
382
- */
383
- EventRegistry.prototype.getUsageInfo = function () {
384
- return __awaiter(this, void 0, void 0, function () {
385
- var request;
386
- return __generator(this, function (_a) {
387
- switch (_a.label) {
388
- case 0: return [4 /*yield*/, this.jsonRequest("/api/v1/usage")];
389
- case 1:
390
- request = _a.sent();
391
- return [2 /*return*/, request.data];
392
- }
393
- });
394
- });
395
- };
396
- EventRegistry.prototype.getServiceStatus = function () {
397
- return __awaiter(this, void 0, void 0, function () {
398
- var request;
399
- return __generator(this, function (_a) {
400
- switch (_a.label) {
401
- case 0: return [4 /*yield*/, this.jsonRequest("/api/v1/getServiceStatus")];
402
- case 1:
403
- request = _a.sent();
404
- return [2 /*return*/, request.data];
405
- }
406
- });
407
- });
408
- };
409
- EventRegistry.prototype.getUrl = function (query) {
410
- var _a;
411
- if (!(query instanceof base_1.QueryParamsBase)) {
412
- if (this.config.verboseOutput) {
413
- this.logger.warn("query parameter should be an instance of a class that has Query as a base class, such as QueryArticles or QueryEvents");
414
- }
415
- }
416
- var allParams = query.getQueryParams();
417
- return "".concat((_a = this.config) === null || _a === void 0 ? void 0 : _a.host).concat(query === null || query === void 0 ? void 0 : query.path, "?").concat(Object.keys(allParams).map(function (key) { return "".concat(key, "=").concat(allParams[key]); }).join("&"));
418
- };
419
- /**
420
- * Return a list of concepts that contain the given prefix.
421
- * Returned matching concepts are sorted based on their frequency of occurrence in news (from most to least frequent)
422
- * @param prefix input text that should be contained in the concept
423
- * @param args Object which contains a host of optional parameters
424
- */
425
- EventRegistry.prototype.suggestConcepts = function (prefix_1) {
426
- return __awaiter(this, arguments, void 0, function (prefix, args) {
427
- var _a, sources, _b, lang, _c, conceptLang, _d, page, _e, count, _f, returnInfo, otherParams, params, request;
428
- if (args === void 0) { args = {}; }
429
- return __generator(this, function (_g) {
430
- switch (_g.label) {
431
- case 0:
432
- _a = args.sources, sources = _a === void 0 ? ["concepts"] : _a, _b = args.lang, lang = _b === void 0 ? "eng" : _b, _c = args.conceptLang, conceptLang = _c === void 0 ? "eng" : _c, _d = args.page, page = _d === void 0 ? 1 : _d, _e = args.count, count = _e === void 0 ? 20 : _e, _f = args.returnInfo, returnInfo = _f === void 0 ? new returnInfo_1.ReturnInfo() : _f, otherParams = __rest(args, ["sources", "lang", "conceptLang", "page", "count", "returnInfo"]);
433
- if (page <= 0) {
434
- throw new RangeError("page parameter should be above 0");
435
- }
436
- params = {
437
- prefix: prefix,
438
- source: sources,
439
- lang: lang,
440
- conceptLang: conceptLang,
441
- page: page,
442
- count: count,
443
- };
444
- params = __assign(__assign(__assign({}, params), otherParams), returnInfo.getParams());
445
- return [4 /*yield*/, this.jsonRequest("/api/v1/suggestConceptsFast", params)];
446
- case 1:
447
- request = _g.sent();
448
- return [2 /*return*/, request.data];
449
- }
450
- });
451
- });
452
- };
453
- /**
454
- * Return a list of dmoz categories that contain the prefix
455
- * @param prefix input text that should be contained in the category name
456
- * @param args Object which contains a host of optional parameters
457
- */
458
- EventRegistry.prototype.suggestCategories = function (prefix_1) {
459
- return __awaiter(this, arguments, void 0, function (prefix, args) {
460
- var _a, page, _b, count, _c, returnInfo, otherParams, params, request;
461
- if (args === void 0) { args = {}; }
462
- return __generator(this, function (_d) {
463
- switch (_d.label) {
464
- case 0:
465
- _a = args.page, page = _a === void 0 ? 1 : _a, _b = args.count, count = _b === void 0 ? 20 : _b, _c = args.returnInfo, returnInfo = _c === void 0 ? new returnInfo_1.ReturnInfo() : _c, otherParams = __rest(args, ["page", "count", "returnInfo"]);
466
- if (page <= 0) {
467
- throw new RangeError("page parameter should be above 0");
468
- }
469
- params = { prefix: prefix, page: page, count: count };
470
- params = __assign(__assign(__assign({}, params), otherParams), returnInfo.getParams());
471
- return [4 /*yield*/, this.jsonRequest("/api/v1/suggestCategoriesFast", params)];
472
- case 1:
473
- request = _d.sent();
474
- return [2 /*return*/, request.data];
475
- }
476
- });
477
- });
478
- };
479
- /**
480
- * Return a list of news sources that match the prefix
481
- * @param prefix input text that should be contained in the source name or uri
482
- * @param args Object which contains a host of optional parameters
483
- */
484
- EventRegistry.prototype.suggestNewsSources = function (prefix_1) {
485
- return __awaiter(this, arguments, void 0, function (prefix, args) {
486
- var _a, page, _b, count, _c, dataType, otherParams, request;
487
- if (args === void 0) { args = {}; }
488
- return __generator(this, function (_d) {
489
- switch (_d.label) {
490
- case 0:
491
- _a = args.page, page = _a === void 0 ? 1 : _a, _b = args.count, count = _b === void 0 ? 20 : _b, _c = args.dataType, dataType = _c === void 0 ? ["news", "pr", "blog"] : _c, otherParams = __rest(args, ["page", "count", "dataType"]);
492
- if (page <= 0) {
493
- throw new RangeError("page parameter should be above 0");
494
- }
495
- return [4 /*yield*/, this.jsonRequest("/api/v1/suggestSourcesFast", __assign({ prefix: prefix, page: page, dataType: dataType, count: count }, otherParams))];
496
- case 1:
497
- request = _d.sent();
498
- return [2 /*return*/, request.data];
499
- }
500
- });
501
- });
502
- };
503
- /**
504
- * Return a list of news source groups that match the prefix
505
- * @param prefix input text that should be contained in the source group name or uri
506
- * @param args Object which contains a host of optional parameters
507
- */
508
- EventRegistry.prototype.suggestSourceGroups = function (prefix_1) {
509
- return __awaiter(this, arguments, void 0, function (prefix, args) {
510
- var _a, page, _b, count, otherParams, request;
511
- if (args === void 0) { args = {}; }
512
- return __generator(this, function (_c) {
513
- switch (_c.label) {
514
- case 0:
515
- _a = args.page, page = _a === void 0 ? 1 : _a, _b = args.count, count = _b === void 0 ? 20 : _b, otherParams = __rest(args, ["page", "count"]);
516
- if (page <= 0) {
517
- throw new RangeError("page parameter should be above 0");
518
- }
519
- return [4 /*yield*/, this.jsonRequest("/api/v1/suggestSourceGroups", __assign({ prefix: prefix, page: page, count: count }, otherParams))];
520
- case 1:
521
- request = _c.sent();
522
- return [2 /*return*/, request.data];
523
- }
524
- });
525
- });
526
- };
527
- /**
528
- * Return a list of geo locations (cities or countries) that contain the prefix
529
- * @param prefix input text that should be contained in the location name
530
- * @param args Object which contains a host of optional parameters
531
- */
532
- EventRegistry.prototype.suggestLocations = function (prefix_1) {
533
- return __awaiter(this, arguments, void 0, function (prefix, args) {
534
- var _a, sources, _b, lang, _c, count, _d, countryUri, sortByDistanceTo, _e, returnInfo, otherParams, params, request;
535
- if (args === void 0) { args = {}; }
536
- return __generator(this, function (_f) {
537
- switch (_f.label) {
538
- case 0:
539
- _a = args.sources, sources = _a === void 0 ? ["place", "country"] : _a, _b = args.lang, lang = _b === void 0 ? "eng" : _b, _c = args.count, count = _c === void 0 ? 20 : _c, _d = args.countryUri, countryUri = _d === void 0 ? "" : _d, sortByDistanceTo = args.sortByDistanceTo, _e = args.returnInfo, returnInfo = _e === void 0 ? new returnInfo_1.ReturnInfo() : _e, otherParams = __rest(args, ["sources", "lang", "count", "countryUri", "sortByDistanceTo", "returnInfo"]);
540
- params = {
541
- prefix: prefix,
542
- count: count,
543
- source: sources,
544
- lang: lang,
545
- countryUri: countryUri,
546
- };
547
- params = __assign(__assign(__assign({}, params), otherParams), returnInfo === null || returnInfo === void 0 ? void 0 : returnInfo.getParams());
548
- if (sortByDistanceTo) {
549
- if (!Array.isArray(sortByDistanceTo)) {
550
- throw new Error("sortByDistanceTo has to contain a tuple with latitude and longitude of the location");
551
- }
552
- if (sortByDistanceTo.length !== 2) {
553
- throw new Error("The sortByDistanceTo should contain two numbers");
554
- }
555
- params["closeToLat"] = sortByDistanceTo[0];
556
- params["closeToLon"] = sortByDistanceTo[1];
557
- }
558
- return [4 /*yield*/, this.jsonRequest("/api/v1/suggestLocationsFast", params)];
559
- case 1:
560
- request = _f.sent();
561
- return [2 /*return*/, request === null || request === void 0 ? void 0 : request.data];
562
- }
563
- });
564
- });
565
- };
566
- /**
567
- * Return a list of geo locations (cities or places) that are close to the provided (lat, long) values
568
- * @param latitude latitude part of the coordinate
569
- * @param longitude longitude part of the coordinate
570
- * @param radiusKm radius in kilometers around the coordinates inside which the locations should be returned
571
- * @param args Object which contains a host of optional parameters
572
- */
573
- EventRegistry.prototype.suggestLocationsAtCoordinate = function (latitude_1, longitude_1, radiusKm_1) {
574
- return __awaiter(this, arguments, void 0, function (latitude, longitude, radiusKm, args) {
575
- var _a, limitToCities, _b, lang, _c, count, _d, ignoreNonWiki, _e, returnInfo, otherParams, params, request;
576
- if (args === void 0) { args = {}; }
577
- return __generator(this, function (_f) {
578
- switch (_f.label) {
579
- case 0:
580
- _a = args.limitToCities, limitToCities = _a === void 0 ? false : _a, _b = args.lang, lang = _b === void 0 ? "eng" : _b, _c = args.count, count = _c === void 0 ? 20 : _c, _d = args.ignoreNonWiki, ignoreNonWiki = _d === void 0 ? true : _d, _e = args.returnInfo, returnInfo = _e === void 0 ? new returnInfo_1.ReturnInfo() : _e, otherParams = __rest(args, ["limitToCities", "lang", "count", "ignoreNonWiki", "returnInfo"]);
581
- if (typeof latitude !== "number") {
582
- throw new Error("The 'latitude' should be a number");
583
- }
584
- if (typeof longitude !== "number") {
585
- throw new Error("The 'longitude' should be a number");
586
- }
587
- params = {
588
- action: "getLocationsAtCoordinate",
589
- lat: latitude,
590
- lon: longitude,
591
- radius: radiusKm,
592
- limitToCities: limitToCities,
593
- count: count,
594
- lang: lang,
595
- };
596
- params = __assign(__assign(__assign({}, params), otherParams), returnInfo === null || returnInfo === void 0 ? void 0 : returnInfo.getParams());
597
- return [4 /*yield*/, this.jsonRequest("/api/v1/suggestLocationsFast", params)];
598
- case 1:
599
- request = _f.sent();
600
- return [2 /*return*/, request === null || request === void 0 ? void 0 : request.data];
601
- }
602
- });
603
- });
604
- };
605
- /**
606
- * Return a list of news sources that are close to the provided (lat, long) values
607
- * @param latitude latitude part of the coordinate
608
- * @param longitude longitude part of the coordinate
609
- * @param radiusKm radius in kilometers around the coordinates inside which the news sources should be located
610
- * @param count number of returned suggestions
611
- */
612
- EventRegistry.prototype.suggestSourcesAtCoordinate = function (latitude_1, longitude_1, radiusKm_1) {
613
- return __awaiter(this, arguments, void 0, function (latitude, longitude, radiusKm, count) {
614
- var _i, params, request;
615
- if (count === void 0) { count = 20; }
616
- var otherParams = [];
617
- for (_i = 4; _i < arguments.length; _i++) {
618
- otherParams[_i - 4] = arguments[_i];
619
- }
620
- return __generator(this, function (_a) {
621
- switch (_a.label) {
622
- case 0:
623
- if (typeof latitude !== "number") {
624
- throw new Error("The 'latitude' should be a number");
625
- }
626
- if (typeof longitude !== "number") {
627
- throw new Error("The 'longitude' should be a number");
628
- }
629
- params = __assign({ action: "getSourcesAtCoordinate", lat: latitude, lon: longitude, radius: radiusKm, count: count }, otherParams);
630
- return [4 /*yield*/, this.jsonRequest("/api/v1/suggestSourcesFast", params)];
631
- case 1:
632
- request = _a.sent();
633
- return [2 /*return*/, request === null || request === void 0 ? void 0 : request.data];
634
- }
635
- });
636
- });
637
- };
638
- /**
639
- * Return a list of news sources that are close to the provided (lat, long) values
640
- * @param conceptUri concept that represents a geographic location for which we would like to obtain a list of sources located at the place
641
- * @param args Object which contains a host of optional parameters
642
- */
643
- EventRegistry.prototype.suggestSourcesAtPlace = function (conceptUri_1) {
644
- return __awaiter(this, arguments, void 0, function (conceptUri, args) {
645
- var _a, page, _b, count, _c, dataType, otherParams, params, request;
646
- if (args === void 0) { args = {}; }
647
- return __generator(this, function (_d) {
648
- switch (_d.label) {
649
- case 0:
650
- _a = args.page, page = _a === void 0 ? 1 : _a, _b = args.count, count = _b === void 0 ? 20 : _b, _c = args.dataType, dataType = _c === void 0 ? "news" : _c, otherParams = __rest(args, ["page", "count", "dataType"]);
651
- params = __assign({ action: "getSourcesAtPlace", conceptUri: conceptUri, page: page, count: count, dataType: dataType }, otherParams);
652
- return [4 /*yield*/, this.jsonRequest("/api/v1/suggestSourcesFast", params)];
653
- case 1:
654
- request = _d.sent();
655
- return [2 /*return*/, request.data];
656
- }
657
- });
658
- });
659
- };
660
- /**
661
- * Return a list of news sources that match the prefix
662
- * @param prefix: input text that should be contained in the author name and source url
663
- * @param page: page of results
664
- * @param count: number of returned suggestions
665
- */
666
- EventRegistry.prototype.suggestAuthors = function (prefix_1) {
667
- return __awaiter(this, arguments, void 0, function (prefix, page, count) {
668
- var _i, params, request;
669
- if (page === void 0) { page = 1; }
670
- if (count === void 0) { count = 20; }
671
- var otherParams = [];
672
- for (_i = 3; _i < arguments.length; _i++) {
673
- otherParams[_i - 3] = arguments[_i];
674
- }
675
- return __generator(this, function (_a) {
676
- switch (_a.label) {
677
- case 0:
678
- if (page <= 0) {
679
- throw new Error("Page parameter should be above 0.");
680
- }
681
- params = __assign({ prefix: prefix, page: page, count: count }, otherParams);
682
- return [4 /*yield*/, this.jsonRequest("/api/v1/suggestAuthorsFast", params)];
683
- case 1:
684
- request = _a.sent();
685
- return [2 /*return*/, request.data];
686
- }
687
- });
688
- });
689
- };
690
- /**
691
- * Return a list of event types that match the prefix
692
- * @param prefix: input text that should be contained in the industry name
693
- * @param page: page of results
694
- * @param count: number of returned suggestions
695
- */
696
- EventRegistry.prototype.suggestEventTypes = function (prefix_1) {
697
- return __awaiter(this, arguments, void 0, function (prefix, page, count) {
698
- var _i, params, request;
699
- if (page === void 0) { page = 1; }
700
- if (count === void 0) { count = 20; }
701
- var otherParams = [];
702
- for (_i = 3; _i < arguments.length; _i++) {
703
- otherParams[_i - 3] = arguments[_i];
704
- }
705
- return __generator(this, function (_a) {
706
- switch (_a.label) {
707
- case 0:
708
- if (page <= 0) {
709
- throw new Error("Page parameter should be above 0.");
710
- }
711
- params = __assign({ prefix: prefix, page: page, count: count }, otherParams);
712
- return [4 /*yield*/, this.jsonRequest("/api/v1/eventType/suggestEventTypes", params)];
713
- case 1:
714
- request = _a.sent();
715
- return [2 /*return*/, request.data];
716
- }
717
- });
718
- });
719
- };
720
- /**
721
- * Return a list of industries that match the prefix. Note: Industries can only be used when querying mentions (QueryMentions, QueryMentionsIter)
722
- * @param prefix: input text that should be contained in the industry name
723
- * @param page: page of results
724
- * @param count: number of returned suggestions
725
- */
726
- EventRegistry.prototype.suggestIndustries = function (prefix_1) {
727
- return __awaiter(this, arguments, void 0, function (prefix, page, count) {
728
- var _i, params, request;
729
- if (page === void 0) { page = 1; }
730
- if (count === void 0) { count = 20; }
731
- var otherParams = [];
732
- for (_i = 3; _i < arguments.length; _i++) {
733
- otherParams[_i - 3] = arguments[_i];
734
- }
735
- return __generator(this, function (_a) {
736
- switch (_a.label) {
737
- case 0:
738
- if (page <= 0) {
739
- throw new Error("Page parameter should be above 0.");
740
- }
741
- params = __assign({ prefix: prefix, page: page, count: count }, otherParams);
742
- return [4 /*yield*/, this.jsonRequest("/api/v1/eventType/suggestIndustries", params)];
743
- case 1:
744
- request = _a.sent();
745
- return [2 /*return*/, request.data];
746
- }
747
- });
748
- });
749
- };
750
- /**
751
- * Return a list of SDG uris. Note: Industries can only be used when querying mentions (QueryMentions, QueryMentionsIter)
752
- */
753
- EventRegistry.prototype.getSdgUris = function () {
754
- return __awaiter(this, void 0, void 0, function () {
755
- var request;
756
- return __generator(this, function (_a) {
757
- switch (_a.label) {
758
- case 0: return [4 /*yield*/, this.jsonRequest("/api/v1/eventType/sdg/getItems")];
759
- case 1:
760
- request = _a.sent();
761
- return [2 /*return*/, request.data];
762
- }
763
- });
764
- });
765
- };
766
- /**
767
- * Return a list of SASB uris. Note: SASB uris can only be used when querying mentions (QueryMentions, QueryMentionsIter)
768
- */
769
- EventRegistry.prototype.getSasbUris = function () {
770
- return __awaiter(this, void 0, void 0, function () {
771
- var request;
772
- return __generator(this, function (_a) {
773
- switch (_a.label) {
774
- case 0: return [4 /*yield*/, this.jsonRequest("/api/v1/eventType/sasb/getItems")];
775
- case 1:
776
- request = _a.sent();
777
- return [2 /*return*/, request.data];
778
- }
779
- });
780
- });
781
- };
782
- /**
783
- * Return a list of concept classes that match the given prefix
784
- * @param prefix input text that should be contained in the category name
785
- * @param args Object which contains a host of optional parameters
786
- */
787
- EventRegistry.prototype.suggestConceptClasses = function (prefix_1) {
788
- return __awaiter(this, arguments, void 0, function (prefix, args) {
789
- var _a, lang, _b, conceptLang, _c, source, _d, page, _e, count, _f, returnInfo, otherParams, params, request;
790
- if (args === void 0) { args = {}; }
791
- return __generator(this, function (_g) {
792
- switch (_g.label) {
793
- case 0:
794
- _a = args.lang, lang = _a === void 0 ? "eng" : _a, _b = args.conceptLang, conceptLang = _b === void 0 ? "eng" : _b, _c = args.source, source = _c === void 0 ? ["dbpedia", "custom"] : _c, _d = args.page, page = _d === void 0 ? 1 : _d, _e = args.count, count = _e === void 0 ? 20 : _e, _f = args.returnInfo, returnInfo = _f === void 0 ? new returnInfo_1.ReturnInfo() : _f, otherParams = __rest(args, ["lang", "conceptLang", "source", "page", "count", "returnInfo"]);
795
- if (page < 1) {
796
- throw new Error("page parameter should be above 0");
797
- }
798
- params = { prefix: prefix, lang: lang, conceptLang: conceptLang, source: source, page: page, count: count };
799
- params = __assign(__assign(__assign({}, params), otherParams), returnInfo === null || returnInfo === void 0 ? void 0 : returnInfo.getParams());
800
- return [4 /*yield*/, this.jsonRequest("/api/v1/suggestConceptClasses", params)];
801
- case 1:
802
- request = _g.sent();
803
- return [2 /*return*/, request === null || request === void 0 ? void 0 : request.data];
804
- }
805
- });
806
- });
807
- };
808
- /**
809
- * return a concept uri that is the best match for the given concept label
810
- * if there are multiple matches for the given conceptLabel,
811
- * they are sorted based on their frequency of occurrence in news (most to least frequent)
812
- * @param conceptLabel partial or full name of the concept for which to return the concept uri
813
- * @param args Object which contains a host of optional parameters
814
- */
815
- EventRegistry.prototype.getConceptUri = function (conceptLabel_1) {
816
- return __awaiter(this, arguments, void 0, function (conceptLabel, args) {
817
- var _a, lang, _b, sources, matches;
818
- var _c;
819
- if (args === void 0) { args = {}; }
820
- return __generator(this, function (_d) {
821
- switch (_d.label) {
822
- case 0:
823
- _a = args.lang, lang = _a === void 0 ? "eng" : _a, _b = args.sources, sources = _b === void 0 ? ["concepts"] : _b;
824
- return [4 /*yield*/, this.suggestConcepts(conceptLabel, { lang: lang, sources: sources })];
825
- case 1:
826
- matches = _d.sent();
827
- return [2 /*return*/, (_c = matches === null || matches === void 0 ? void 0 : matches[0]) === null || _c === void 0 ? void 0 : _c.uri];
828
- }
829
- });
830
- });
831
- };
832
- /**
833
- * Return a location uri that is the best match for the given location label
834
- * @param locationLabel partial or full location name for which to return the location uri
835
- * @param args Object which contains a host of optional parameters
836
- */
837
- EventRegistry.prototype.getLocationUri = function (locationLabel_1) {
838
- return __awaiter(this, arguments, void 0, function (locationLabel, args) {
839
- var _a, lang, _b, sources, countryUri, sortByDistanceTo, matches;
840
- var _c;
841
- if (args === void 0) { args = {}; }
842
- return __generator(this, function (_d) {
843
- switch (_d.label) {
844
- case 0:
845
- _a = args.lang, lang = _a === void 0 ? "eng" : _a, _b = args.sources, sources = _b === void 0 ? ["place", "country"] : _b, countryUri = args.countryUri, sortByDistanceTo = args.sortByDistanceTo;
846
- return [4 /*yield*/, this.suggestLocations(locationLabel, { lang: lang, sources: sources, countryUri: countryUri, sortByDistanceTo: sortByDistanceTo })];
847
- case 1:
848
- matches = _d.sent();
849
- return [2 /*return*/, (_c = matches === null || matches === void 0 ? void 0 : matches[0]) === null || _c === void 0 ? void 0 : _c.wikiUri];
850
- }
851
- });
852
- });
853
- };
854
- /**
855
- * Return a category uri that is the best match for the given label
856
- * @param categoryLabel partial or full name of the category for which to return category uri
857
- */
858
- EventRegistry.prototype.getCategoryUri = function (categoryLabel) {
859
- return __awaiter(this, void 0, void 0, function () {
860
- var matches;
861
- var _a;
862
- return __generator(this, function (_b) {
863
- switch (_b.label) {
864
- case 0: return [4 /*yield*/, this.suggestCategories(categoryLabel)];
865
- case 1:
866
- matches = _b.sent();
867
- return [2 /*return*/, (_a = matches === null || matches === void 0 ? void 0 : matches[0]) === null || _a === void 0 ? void 0 : _a.uri];
868
- }
869
- });
870
- });
871
- };
872
- /**
873
- * Return the news source that best matches the source name
874
- * @param sourceName partial or full name of the source or source uri for which to return source uri
875
- * @param dataType: return the source uri that provides content of these data types
876
- */
877
- EventRegistry.prototype.getNewsSourceUri = function (sourceName_1) {
878
- return __awaiter(this, arguments, void 0, function (sourceName, dataType) {
879
- var matches;
880
- var _a;
881
- if (dataType === void 0) { dataType = ["news", "pr", "blog"]; }
882
- return __generator(this, function (_b) {
883
- switch (_b.label) {
884
- case 0: return [4 /*yield*/, this.suggestNewsSources(sourceName, { dataType: dataType })];
885
- case 1:
886
- matches = _b.sent();
887
- return [2 /*return*/, (_a = matches === null || matches === void 0 ? void 0 : matches[0]) === null || _a === void 0 ? void 0 : _a.uri];
888
- }
889
- });
890
- });
891
- };
892
- /**
893
- * alternative (shorter) name for the method getNewsSourceUri()
894
- */
895
- EventRegistry.prototype.getSourceUri = function (sourceName_1) {
896
- return __awaiter(this, arguments, void 0, function (sourceName, dataType) {
897
- if (dataType === void 0) { dataType = ["news", "pr", "blog"]; }
898
- return __generator(this, function (_a) {
899
- switch (_a.label) {
900
- case 0: return [4 /*yield*/, this.getNewsSourceUri(sourceName, dataType)];
901
- case 1: return [2 /*return*/, _a.sent()];
902
- }
903
- });
904
- });
905
- };
906
- /**
907
- * Return the URI of the source group that best matches the name
908
- * @param sourceGroupName partial or full name of the source group
909
- */
910
- EventRegistry.prototype.getSourceGroupUri = function (sourceGroupName) {
911
- return __awaiter(this, void 0, void 0, function () {
912
- var matches;
913
- var _a;
914
- return __generator(this, function (_b) {
915
- switch (_b.label) {
916
- case 0: return [4 /*yield*/, this.suggestSourceGroups(sourceGroupName)];
917
- case 1:
918
- matches = _b.sent();
919
- return [2 /*return*/, (_a = matches === null || matches === void 0 ? void 0 : matches[0]) === null || _a === void 0 ? void 0 : _a.uri];
920
- }
921
- });
922
- });
923
- };
924
- /**
925
- * Return a uri of the concept class that is the best match for the given label
926
- * @param classLabel partial or full name of the concept class for which to return class uri
927
- * @param lang language in which the class label is specified
928
- */
929
- EventRegistry.prototype.getConceptClassUri = function (classLabel_1) {
930
- return __awaiter(this, arguments, void 0, function (classLabel, lang) {
931
- var matches;
932
- var _a;
933
- if (lang === void 0) { lang = "eng"; }
934
- return __generator(this, function (_b) {
935
- switch (_b.label) {
936
- case 0: return [4 /*yield*/, this.suggestConceptClasses(classLabel, { lang: lang })];
937
- case 1:
938
- matches = _b.sent();
939
- return [2 /*return*/, (_a = matches === null || matches === void 0 ? void 0 : matches[0]) === null || _a === void 0 ? void 0 : _a.uri];
940
- }
941
- });
942
- });
943
- };
944
- /**
945
- * Return detailed information about a particular concept
946
- * @param conceptUri uri of the concept
947
- * @param returnInfo what details about the concept should be included in the returned information
948
- */
949
- EventRegistry.prototype.getConceptInfo = function (conceptUri, returnInfo) {
950
- return __awaiter(this, void 0, void 0, function () {
951
- var conceptInfo, params, request;
952
- var _a;
953
- return __generator(this, function (_b) {
954
- switch (_b.label) {
955
- case 0:
956
- if (!returnInfo) {
957
- conceptInfo = new returnInfo_1.ConceptInfoFlags({ synonyms: true, image: true, description: true });
958
- returnInfo = new returnInfo_1.ReturnInfo({ conceptInfo: conceptInfo });
959
- }
960
- params = {
961
- uri: conceptUri,
962
- action: "getInfo",
963
- };
964
- params = __assign(__assign({}, params), ((_a = returnInfo === null || returnInfo === void 0 ? void 0 : returnInfo.getParams()) !== null && _a !== void 0 ? _a : {}));
965
- return [4 /*yield*/, this.jsonRequest("/api/v1/concept/getInfo", params)];
966
- case 1:
967
- request = _b.sent();
968
- return [2 /*return*/, request.data];
969
- }
970
- });
971
- });
972
- };
973
- /**
974
- * return author uri that is the best match for the given author name (and potentially source url)
975
- * if there are multiple matches for the given author name, they are sorted based on the number of articles they have written (from most to least frequent)
976
- * @param authorName: partial or full name of the author, potentially also containing the source url (e.g. "george brown nytimes")
977
- */
978
- EventRegistry.prototype.getAuthorUri = function (authorName) {
979
- return __awaiter(this, void 0, void 0, function () {
980
- var matches;
981
- var _a;
982
- return __generator(this, function (_b) {
983
- switch (_b.label) {
984
- case 0: return [4 /*yield*/, this.suggestAuthors(authorName)];
985
- case 1:
986
- matches = _b.sent();
987
- return [2 /*return*/, (_a = matches === null || matches === void 0 ? void 0 : matches[0]) === null || _a === void 0 ? void 0 : _a.uri];
988
- }
989
- });
990
- });
991
- };
992
- EventRegistry.getUriFromUriWgt = function (uriWgtList) {
993
- if (!Array.isArray(uriWgtList)) {
994
- throw new Error("uriWgtList has to be a list of strings that represent article uris");
995
- }
996
- return uriWgtList.map(function (uriWgt) { return uriWgt.split(":")[0]; });
997
- };
998
- // Additional utility functions
999
- /**
1000
- * If you have article urls and you want to query them in ER you first have to obtain their uris in the ER.
1001
- * @param articleUrls a single article url or a list of article urls
1002
- */
1003
- EventRegistry.prototype.getArticleUris = function (articleUrls) {
1004
- return __awaiter(this, void 0, void 0, function () {
1005
- var request;
1006
- return __generator(this, function (_a) {
1007
- switch (_a.label) {
1008
- case 0:
1009
- if (!Array.isArray(articleUrls) && typeof articleUrls !== "string") {
1010
- throw new Error("Expected a single article url or a list of urls");
1011
- }
1012
- return [4 /*yield*/, this.jsonRequest("/api/v1/articleMapper", { articleUrl: articleUrls })];
1013
- case 1:
1014
- request = _a.sent();
1015
- return [2 /*return*/, request.data];
1016
- }
1017
- });
1018
- });
1019
- };
1020
- /**
1021
- * Return information about the latest imported article
1022
- */
1023
- EventRegistry.prototype.getSourceGroups = function () {
1024
- return __awaiter(this, void 0, void 0, function () {
1025
- var request;
1026
- return __generator(this, function (_a) {
1027
- switch (_a.label) {
1028
- case 0: return [4 /*yield*/, this.jsonRequest("/api/v1/sourceGroup/getSourceGroups", { action: "getSourceGroups" })];
1029
- case 1:
1030
- request = _a.sent();
1031
- return [2 /*return*/, request.data];
1032
- }
1033
- });
1034
- });
1035
- };
1036
- /**
1037
- * Return info about the source group
1038
- */
1039
- EventRegistry.prototype.getSourceGroup = function (sourceGroupUri) {
1040
- return __awaiter(this, void 0, void 0, function () {
1041
- var request;
1042
- return __generator(this, function (_a) {
1043
- switch (_a.label) {
1044
- case 0: return [4 /*yield*/, this.jsonRequest("/api/v1/sourceGroup/getSourceGroupInfo", { action: "getSourceGroupInfo", uri: sourceGroupUri })];
1045
- case 1:
1046
- request = _a.sent();
1047
- return [2 /*return*/, request.data];
1048
- }
1049
- });
1050
- });
1051
- };
1052
- return EventRegistry;
1053
- }());
1054
- exports.EventRegistry = EventRegistry;
1055
- /**
1056
- * @class ArticleMapper
1057
- * Create instance of article mapper it will map from article urls to article uris
1058
- * the mappings can be remembered so it will not repeat requests for the same article urls
1059
- */
1060
- var ArticleMapper = /** @class */ (function () {
1061
- function ArticleMapper(er, rememberMapping) {
1062
- if (rememberMapping === void 0) { rememberMapping = true; }
1063
- this.articleUrlToUri = {};
1064
- this.rememberMappings = true;
1065
- this.er = er;
1066
- this.rememberMappings = rememberMapping;
1067
- }
1068
- /**
1069
- * Given the article url, return an array with 0, 1 or more article uris.
1070
- * Not all returned article uris are necessarily valid anymore.
1071
- * For news sources of lower importance we remove the duplicated articles and just keep the latest content
1072
- * @param articleUrl string containing the article url
1073
- */
1074
- ArticleMapper.prototype.getArticleUri = function (articleUrl) {
1075
- return __awaiter(this, void 0, void 0, function () {
1076
- var response, value;
1077
- var _a;
1078
- return __generator(this, function (_b) {
1079
- switch (_b.label) {
1080
- case 0:
1081
- if (this.articleUrlToUri.hasOwnProperty(articleUrl)) {
1082
- return [2 /*return*/, this.articleUrlToUri[articleUrl]];
1083
- }
1084
- return [4 /*yield*/, this.er.getArticleUris(articleUrl)];
1085
- case 1:
1086
- response = _b.sent();
1087
- value = response === null || response === void 0 ? void 0 : response[articleUrl];
1088
- if (this.rememberMappings && value) {
1089
- this.articleUrlToUri = __assign(__assign({}, this.articleUrlToUri), (_a = {}, _a[articleUrl] = value, _a));
1090
- }
1091
- return [2 /*return*/, value];
1092
- }
1093
- });
1094
- });
1095
- };
1096
- return ArticleMapper;
1097
- }());
1098
- exports.ArticleMapper = ArticleMapper;
1099
- //# sourceMappingURL=eventRegistry.js.map