@novu/js 2.0.1 → 2.1.1

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 (317) hide show
  1. package/dist/cjs/{chunk-PMLVIUWC.cjs → chunk-D7P7KCZI.js} +342 -255
  2. package/dist/cjs/index.d.ts +8 -0
  3. package/dist/cjs/index.js +58 -0
  4. package/dist/cjs/novu-04KlkBy4.d.ts +528 -0
  5. package/dist/cjs/ui/index.d.ts +145 -0
  6. package/dist/cjs/ui/{index.cjs → index.js} +218 -141
  7. package/dist/esm/{chunk-LDGUT6MH.mjs → chunk-APRCCICD.mjs} +342 -256
  8. package/dist/esm/index.d.mts +8 -0
  9. package/dist/esm/index.mjs +1 -1
  10. package/dist/esm/novu-04KlkBy4.d.mts +528 -0
  11. package/dist/esm/ui/index.d.mts +145 -0
  12. package/dist/esm/ui/index.mjs +131 -54
  13. package/dist/novu.min.js +10 -10
  14. package/dist/novu.min.js.gz +0 -0
  15. package/package.json +24 -16
  16. package/ui/package.json +5 -0
  17. package/dist/cjs/index.cjs +0 -50
  18. package/dist/types/api/inbox-service.d.ts +0 -65
  19. package/dist/types/api/inbox-service.d.ts.map +0 -1
  20. package/dist/types/api/index.d.ts +0 -2
  21. package/dist/types/api/index.d.ts.map +0 -1
  22. package/dist/types/base-module.d.ts +0 -13
  23. package/dist/types/base-module.d.ts.map +0 -1
  24. package/dist/types/cache/in-memory-cache.d.ts +0 -13
  25. package/dist/types/cache/in-memory-cache.d.ts.map +0 -1
  26. package/dist/types/cache/index.d.ts +0 -2
  27. package/dist/types/cache/index.d.ts.map +0 -1
  28. package/dist/types/cache/notifications-cache.d.ts +0 -22
  29. package/dist/types/cache/notifications-cache.d.ts.map +0 -1
  30. package/dist/types/cache/preferences-cache.d.ts +0 -11
  31. package/dist/types/cache/preferences-cache.d.ts.map +0 -1
  32. package/dist/types/cache/types.d.ts +0 -10
  33. package/dist/types/cache/types.d.ts.map +0 -1
  34. package/dist/types/event-emitter/index.d.ts +0 -3
  35. package/dist/types/event-emitter/index.d.ts.map +0 -1
  36. package/dist/types/event-emitter/novu-event-emitter.d.ts +0 -14
  37. package/dist/types/event-emitter/novu-event-emitter.d.ts.map +0 -1
  38. package/dist/types/event-emitter/types.d.ts +0 -85
  39. package/dist/types/event-emitter/types.d.ts.map +0 -1
  40. package/dist/types/index.d.ts +0 -3
  41. package/dist/types/index.d.ts.map +0 -1
  42. package/dist/types/notifications/helpers.d.ts +0 -57
  43. package/dist/types/notifications/helpers.d.ts.map +0 -1
  44. package/dist/types/notifications/index.d.ts +0 -4
  45. package/dist/types/notifications/index.d.ts.map +0 -1
  46. package/dist/types/notifications/notification.d.ts +0 -33
  47. package/dist/types/notifications/notification.d.ts.map +0 -1
  48. package/dist/types/notifications/notifications.d.ts +0 -44
  49. package/dist/types/notifications/notifications.d.ts.map +0 -1
  50. package/dist/types/notifications/types.d.ts +0 -55
  51. package/dist/types/notifications/types.d.ts.map +0 -1
  52. package/dist/types/novu.d.ts +0 -14
  53. package/dist/types/novu.d.ts.map +0 -1
  54. package/dist/types/preferences/helpers.d.ts +0 -11
  55. package/dist/types/preferences/helpers.d.ts.map +0 -1
  56. package/dist/types/preferences/index.d.ts +0 -2
  57. package/dist/types/preferences/index.d.ts.map +0 -1
  58. package/dist/types/preferences/preference.d.ts +0 -15
  59. package/dist/types/preferences/preference.d.ts.map +0 -1
  60. package/dist/types/preferences/preferences.d.ts +0 -15
  61. package/dist/types/preferences/preferences.d.ts.map +0 -1
  62. package/dist/types/preferences/types.d.ts +0 -15
  63. package/dist/types/preferences/types.d.ts.map +0 -1
  64. package/dist/types/session/index.d.ts +0 -3
  65. package/dist/types/session/index.d.ts.map +0 -1
  66. package/dist/types/session/session.d.ts +0 -7
  67. package/dist/types/session/session.d.ts.map +0 -1
  68. package/dist/types/session/types.d.ts +0 -6
  69. package/dist/types/session/types.d.ts.map +0 -1
  70. package/dist/types/types.d.ts +0 -150
  71. package/dist/types/types.d.ts.map +0 -1
  72. package/dist/types/ui/api/hooks/index.d.ts +0 -6
  73. package/dist/types/ui/api/hooks/index.d.ts.map +0 -1
  74. package/dist/types/ui/api/hooks/useArchiveAll.d.ts +0 -10
  75. package/dist/types/ui/api/hooks/useArchiveAll.d.ts.map +0 -1
  76. package/dist/types/ui/api/hooks/useArchiveAllRead.d.ts +0 -10
  77. package/dist/types/ui/api/hooks/useArchiveAllRead.d.ts.map +0 -1
  78. package/dist/types/ui/api/hooks/useNotifications.d.ts +0 -17
  79. package/dist/types/ui/api/hooks/useNotifications.d.ts.map +0 -1
  80. package/dist/types/ui/api/hooks/usePreferences.d.ts +0 -9
  81. package/dist/types/ui/api/hooks/usePreferences.d.ts.map +0 -1
  82. package/dist/types/ui/api/hooks/useReadAll.d.ts +0 -10
  83. package/dist/types/ui/api/hooks/useReadAll.d.ts.map +0 -1
  84. package/dist/types/ui/api/index.d.ts +0 -2
  85. package/dist/types/ui/api/index.d.ts.map +0 -1
  86. package/dist/types/ui/components/ExternalElementRenderer.d.ts +0 -7
  87. package/dist/types/ui/components/ExternalElementRenderer.d.ts.map +0 -1
  88. package/dist/types/ui/components/Inbox.d.ts +0 -24
  89. package/dist/types/ui/components/Inbox.d.ts.map +0 -1
  90. package/dist/types/ui/components/InboxTabs/InboxTab.d.ts +0 -16
  91. package/dist/types/ui/components/InboxTabs/InboxTab.d.ts.map +0 -1
  92. package/dist/types/ui/components/InboxTabs/InboxTabs.d.ts +0 -11
  93. package/dist/types/ui/components/InboxTabs/InboxTabs.d.ts.map +0 -1
  94. package/dist/types/ui/components/InboxTabs/index.d.ts +0 -2
  95. package/dist/types/ui/components/InboxTabs/index.d.ts.map +0 -1
  96. package/dist/types/ui/components/InboxTabs/useTabsDropdown.d.ts +0 -11
  97. package/dist/types/ui/components/InboxTabs/useTabsDropdown.d.ts.map +0 -1
  98. package/dist/types/ui/components/Notification/DefaultNotification.d.ts +0 -12
  99. package/dist/types/ui/components/Notification/DefaultNotification.d.ts.map +0 -1
  100. package/dist/types/ui/components/Notification/NewMessagesCta.d.ts +0 -6
  101. package/dist/types/ui/components/Notification/NewMessagesCta.d.ts.map +0 -1
  102. package/dist/types/ui/components/Notification/Notification.d.ts +0 -12
  103. package/dist/types/ui/components/Notification/Notification.d.ts.map +0 -1
  104. package/dist/types/ui/components/Notification/NotificationList.d.ts +0 -14
  105. package/dist/types/ui/components/Notification/NotificationList.d.ts.map +0 -1
  106. package/dist/types/ui/components/Notification/NotificationListSkeleton.d.ts +0 -7
  107. package/dist/types/ui/components/Notification/NotificationListSkeleton.d.ts.map +0 -1
  108. package/dist/types/ui/components/Notification/index.d.ts +0 -3
  109. package/dist/types/ui/components/Notification/index.d.ts.map +0 -1
  110. package/dist/types/ui/components/Renderer.d.ts +0 -44
  111. package/dist/types/ui/components/Renderer.d.ts.map +0 -1
  112. package/dist/types/ui/components/elements/Bell/Bell.d.ts +0 -8
  113. package/dist/types/ui/components/elements/Bell/Bell.d.ts.map +0 -1
  114. package/dist/types/ui/components/elements/Bell/DefaultBellContainer.d.ts +0 -6
  115. package/dist/types/ui/components/elements/Bell/DefaultBellContainer.d.ts.map +0 -1
  116. package/dist/types/ui/components/elements/Bell/index.d.ts +0 -2
  117. package/dist/types/ui/components/elements/Bell/index.d.ts.map +0 -1
  118. package/dist/types/ui/components/elements/Footer.d.ts +0 -2
  119. package/dist/types/ui/components/elements/Footer.d.ts.map +0 -1
  120. package/dist/types/ui/components/elements/Header/ActionsContainer.d.ts +0 -6
  121. package/dist/types/ui/components/elements/Header/ActionsContainer.d.ts.map +0 -1
  122. package/dist/types/ui/components/elements/Header/Header.d.ts +0 -6
  123. package/dist/types/ui/components/elements/Header/Header.d.ts.map +0 -1
  124. package/dist/types/ui/components/elements/Header/MoreActionsDropdown.d.ts +0 -2
  125. package/dist/types/ui/components/elements/Header/MoreActionsDropdown.d.ts.map +0 -1
  126. package/dist/types/ui/components/elements/Header/MoreActionsOptions.d.ts +0 -9
  127. package/dist/types/ui/components/elements/Header/MoreActionsOptions.d.ts.map +0 -1
  128. package/dist/types/ui/components/elements/Header/PreferencesHeader.d.ts +0 -6
  129. package/dist/types/ui/components/elements/Header/PreferencesHeader.d.ts.map +0 -1
  130. package/dist/types/ui/components/elements/Header/index.d.ts +0 -3
  131. package/dist/types/ui/components/elements/Header/index.d.ts.map +0 -1
  132. package/dist/types/ui/components/elements/InboxStatus/InboxStatusDropdown.d.ts +0 -2
  133. package/dist/types/ui/components/elements/InboxStatus/InboxStatusDropdown.d.ts.map +0 -1
  134. package/dist/types/ui/components/elements/InboxStatus/InboxStatusOptions.d.ts +0 -14
  135. package/dist/types/ui/components/elements/InboxStatus/InboxStatusOptions.d.ts.map +0 -1
  136. package/dist/types/ui/components/elements/InboxStatus/constants.d.ts +0 -11
  137. package/dist/types/ui/components/elements/InboxStatus/constants.d.ts.map +0 -1
  138. package/dist/types/ui/components/elements/Preferences/ChannelRow.d.ts +0 -18
  139. package/dist/types/ui/components/elements/Preferences/ChannelRow.d.ts.map +0 -1
  140. package/dist/types/ui/components/elements/Preferences/LoadingScreen.d.ts +0 -2
  141. package/dist/types/ui/components/elements/Preferences/LoadingScreen.d.ts.map +0 -1
  142. package/dist/types/ui/components/elements/Preferences/Preferences.d.ts +0 -2
  143. package/dist/types/ui/components/elements/Preferences/Preferences.d.ts.map +0 -1
  144. package/dist/types/ui/components/elements/Preferences/Switch.d.ts +0 -8
  145. package/dist/types/ui/components/elements/Preferences/Switch.d.ts.map +0 -1
  146. package/dist/types/ui/components/elements/Preferences/index.d.ts +0 -2
  147. package/dist/types/ui/components/elements/Preferences/index.d.ts.map +0 -1
  148. package/dist/types/ui/components/elements/Root.d.ts +0 -3
  149. package/dist/types/ui/components/elements/Root.d.ts.map +0 -1
  150. package/dist/types/ui/components/elements/index.d.ts +0 -6
  151. package/dist/types/ui/components/elements/index.d.ts.map +0 -1
  152. package/dist/types/ui/components/index.d.ts +0 -4
  153. package/dist/types/ui/components/index.d.ts.map +0 -1
  154. package/dist/types/ui/components/primitives/Button.d.ts +0 -13
  155. package/dist/types/ui/components/primitives/Button.d.ts.map +0 -1
  156. package/dist/types/ui/components/primitives/Dropdown/DropdownContent.d.ts +0 -8
  157. package/dist/types/ui/components/primitives/Dropdown/DropdownContent.d.ts.map +0 -1
  158. package/dist/types/ui/components/primitives/Dropdown/DropdownItem.d.ts +0 -9
  159. package/dist/types/ui/components/primitives/Dropdown/DropdownItem.d.ts.map +0 -1
  160. package/dist/types/ui/components/primitives/Dropdown/DropdownRoot.d.ts +0 -4
  161. package/dist/types/ui/components/primitives/Dropdown/DropdownRoot.d.ts.map +0 -1
  162. package/dist/types/ui/components/primitives/Dropdown/DropdownTrigger.d.ts +0 -8
  163. package/dist/types/ui/components/primitives/Dropdown/DropdownTrigger.d.ts.map +0 -1
  164. package/dist/types/ui/components/primitives/Dropdown/index.d.ts +0 -44
  165. package/dist/types/ui/components/primitives/Dropdown/index.d.ts.map +0 -1
  166. package/dist/types/ui/components/primitives/Popover/PopoverClose.d.ts +0 -7
  167. package/dist/types/ui/components/primitives/Popover/PopoverClose.d.ts.map +0 -1
  168. package/dist/types/ui/components/primitives/Popover/PopoverContent.d.ts +0 -9
  169. package/dist/types/ui/components/primitives/Popover/PopoverContent.d.ts.map +0 -1
  170. package/dist/types/ui/components/primitives/Popover/PopoverRoot.d.ts +0 -23
  171. package/dist/types/ui/components/primitives/Popover/PopoverRoot.d.ts.map +0 -1
  172. package/dist/types/ui/components/primitives/Popover/PopoverTrigger.d.ts +0 -9
  173. package/dist/types/ui/components/primitives/Popover/PopoverTrigger.d.ts.map +0 -1
  174. package/dist/types/ui/components/primitives/Popover/index.d.ts +0 -28
  175. package/dist/types/ui/components/primitives/Popover/index.d.ts.map +0 -1
  176. package/dist/types/ui/components/primitives/Skeleton.d.ts +0 -14
  177. package/dist/types/ui/components/primitives/Skeleton.d.ts.map +0 -1
  178. package/dist/types/ui/components/primitives/Tabs/TabsContent.d.ts +0 -10
  179. package/dist/types/ui/components/primitives/Tabs/TabsContent.d.ts.map +0 -1
  180. package/dist/types/ui/components/primitives/Tabs/TabsList.d.ts +0 -11
  181. package/dist/types/ui/components/primitives/Tabs/TabsList.d.ts.map +0 -1
  182. package/dist/types/ui/components/primitives/Tabs/TabsRoot.d.ts +0 -20
  183. package/dist/types/ui/components/primitives/Tabs/TabsRoot.d.ts.map +0 -1
  184. package/dist/types/ui/components/primitives/Tabs/TabsTrigger.d.ts +0 -13
  185. package/dist/types/ui/components/primitives/Tabs/TabsTrigger.d.ts.map +0 -1
  186. package/dist/types/ui/components/primitives/Tabs/index.d.ts +0 -35
  187. package/dist/types/ui/components/primitives/Tabs/index.d.ts.map +0 -1
  188. package/dist/types/ui/components/primitives/Tabs/useKeyboardNavigation.d.ts +0 -7
  189. package/dist/types/ui/components/primitives/Tabs/useKeyboardNavigation.d.ts.map +0 -1
  190. package/dist/types/ui/components/primitives/Tooltip/TooltipContent.d.ts +0 -9
  191. package/dist/types/ui/components/primitives/Tooltip/TooltipContent.d.ts.map +0 -1
  192. package/dist/types/ui/components/primitives/Tooltip/TooltipRoot.d.ts +0 -21
  193. package/dist/types/ui/components/primitives/Tooltip/TooltipRoot.d.ts.map +0 -1
  194. package/dist/types/ui/components/primitives/Tooltip/TooltipTrigger.d.ts +0 -9
  195. package/dist/types/ui/components/primitives/Tooltip/TooltipTrigger.d.ts.map +0 -1
  196. package/dist/types/ui/components/primitives/Tooltip/index.d.ts +0 -21
  197. package/dist/types/ui/components/primitives/Tooltip/index.d.ts.map +0 -1
  198. package/dist/types/ui/components/primitives/index.d.ts +0 -5
  199. package/dist/types/ui/components/primitives/index.d.ts.map +0 -1
  200. package/dist/types/ui/config/appearanceKeys.d.ts +0 -2
  201. package/dist/types/ui/config/appearanceKeys.d.ts.map +0 -1
  202. package/dist/types/ui/config/defaultLocalization.d.ts +0 -26
  203. package/dist/types/ui/config/defaultLocalization.d.ts.map +0 -1
  204. package/dist/types/ui/config/defaultVariables.d.ts +0 -3
  205. package/dist/types/ui/config/defaultVariables.d.ts.map +0 -1
  206. package/dist/types/ui/config/index.d.ts +0 -4
  207. package/dist/types/ui/config/index.d.ts.map +0 -1
  208. package/dist/types/ui/context/AppearanceContext.d.ts +0 -17
  209. package/dist/types/ui/context/AppearanceContext.d.ts.map +0 -1
  210. package/dist/types/ui/context/CountContext.d.ts +0 -23
  211. package/dist/types/ui/context/CountContext.d.ts.map +0 -1
  212. package/dist/types/ui/context/FocusManagerContext.d.ts +0 -12
  213. package/dist/types/ui/context/FocusManagerContext.d.ts.map +0 -1
  214. package/dist/types/ui/context/InboxContext.d.ts +0 -25
  215. package/dist/types/ui/context/InboxContext.d.ts.map +0 -1
  216. package/dist/types/ui/context/LocalizationContext.d.ts +0 -24
  217. package/dist/types/ui/context/LocalizationContext.d.ts.map +0 -1
  218. package/dist/types/ui/context/NovuContext.d.ts +0 -11
  219. package/dist/types/ui/context/NovuContext.d.ts.map +0 -1
  220. package/dist/types/ui/context/index.d.ts +0 -7
  221. package/dist/types/ui/context/index.d.ts.map +0 -1
  222. package/dist/types/ui/helpers/browser.d.ts +0 -2
  223. package/dist/types/ui/helpers/browser.d.ts.map +0 -1
  224. package/dist/types/ui/helpers/constants.d.ts +0 -5
  225. package/dist/types/ui/helpers/constants.d.ts.map +0 -1
  226. package/dist/types/ui/helpers/createDelayedLoading.d.ts +0 -3
  227. package/dist/types/ui/helpers/createDelayedLoading.d.ts.map +0 -1
  228. package/dist/types/ui/helpers/createInfiniteScroll.d.ts +0 -19
  229. package/dist/types/ui/helpers/createInfiniteScroll.d.ts.map +0 -1
  230. package/dist/types/ui/helpers/formatToRelativeTime.d.ts +0 -6
  231. package/dist/types/ui/helpers/formatToRelativeTime.d.ts.map +0 -1
  232. package/dist/types/ui/helpers/index.d.ts +0 -7
  233. package/dist/types/ui/helpers/index.d.ts.map +0 -1
  234. package/dist/types/ui/helpers/types.d.ts +0 -4
  235. package/dist/types/ui/helpers/types.d.ts.map +0 -1
  236. package/dist/types/ui/helpers/useBrowserTabsChannel.d.ts +0 -7
  237. package/dist/types/ui/helpers/useBrowserTabsChannel.d.ts.map +0 -1
  238. package/dist/types/ui/helpers/useFocusTrap.d.ts +0 -7
  239. package/dist/types/ui/helpers/useFocusTrap.d.ts.map +0 -1
  240. package/dist/types/ui/helpers/useNovuEvent.d.ts +0 -6
  241. package/dist/types/ui/helpers/useNovuEvent.d.ts.map +0 -1
  242. package/dist/types/ui/helpers/useStyle.d.ts +0 -3
  243. package/dist/types/ui/helpers/useStyle.d.ts.map +0 -1
  244. package/dist/types/ui/helpers/useUncontrolledState.d.ts +0 -9
  245. package/dist/types/ui/helpers/useUncontrolledState.d.ts.map +0 -1
  246. package/dist/types/ui/helpers/useWebSocketEvent.d.ts +0 -6
  247. package/dist/types/ui/helpers/useWebSocketEvent.d.ts.map +0 -1
  248. package/dist/types/ui/helpers/utils.d.ts +0 -33
  249. package/dist/types/ui/helpers/utils.d.ts.map +0 -1
  250. package/dist/types/ui/icons/Archive.d.ts +0 -3
  251. package/dist/types/ui/icons/Archive.d.ts.map +0 -1
  252. package/dist/types/ui/icons/ArchiveRead.d.ts +0 -3
  253. package/dist/types/ui/icons/ArchiveRead.d.ts.map +0 -1
  254. package/dist/types/ui/icons/ArrowDropDown.d.ts +0 -3
  255. package/dist/types/ui/icons/ArrowDropDown.d.ts.map +0 -1
  256. package/dist/types/ui/icons/ArrowLeft.d.ts +0 -3
  257. package/dist/types/ui/icons/ArrowLeft.d.ts.map +0 -1
  258. package/dist/types/ui/icons/BellIcon.d.ts +0 -3
  259. package/dist/types/ui/icons/BellIcon.d.ts.map +0 -1
  260. package/dist/types/ui/icons/Chat.d.ts +0 -3
  261. package/dist/types/ui/icons/Chat.d.ts.map +0 -1
  262. package/dist/types/ui/icons/Check.d.ts +0 -3
  263. package/dist/types/ui/icons/Check.d.ts.map +0 -1
  264. package/dist/types/ui/icons/Dots.d.ts +0 -3
  265. package/dist/types/ui/icons/Dots.d.ts.map +0 -1
  266. package/dist/types/ui/icons/Email.d.ts +0 -3
  267. package/dist/types/ui/icons/Email.d.ts.map +0 -1
  268. package/dist/types/ui/icons/EmptyIcon.d.ts +0 -3
  269. package/dist/types/ui/icons/EmptyIcon.d.ts.map +0 -1
  270. package/dist/types/ui/icons/InApp.d.ts +0 -3
  271. package/dist/types/ui/icons/InApp.d.ts.map +0 -1
  272. package/dist/types/ui/icons/Inbox.d.ts +0 -3
  273. package/dist/types/ui/icons/Inbox.d.ts.map +0 -1
  274. package/dist/types/ui/icons/Lock.d.ts +0 -2
  275. package/dist/types/ui/icons/Lock.d.ts.map +0 -1
  276. package/dist/types/ui/icons/Novu.d.ts +0 -3
  277. package/dist/types/ui/icons/Novu.d.ts.map +0 -1
  278. package/dist/types/ui/icons/Push.d.ts +0 -3
  279. package/dist/types/ui/icons/Push.d.ts.map +0 -1
  280. package/dist/types/ui/icons/ReadAll.d.ts +0 -3
  281. package/dist/types/ui/icons/ReadAll.d.ts.map +0 -1
  282. package/dist/types/ui/icons/Settings.d.ts +0 -3
  283. package/dist/types/ui/icons/Settings.d.ts.map +0 -1
  284. package/dist/types/ui/icons/Sms.d.ts +0 -3
  285. package/dist/types/ui/icons/Sms.d.ts.map +0 -1
  286. package/dist/types/ui/icons/Unarchive.d.ts +0 -3
  287. package/dist/types/ui/icons/Unarchive.d.ts.map +0 -1
  288. package/dist/types/ui/icons/Unread.d.ts +0 -3
  289. package/dist/types/ui/icons/Unread.d.ts.map +0 -1
  290. package/dist/types/ui/icons/index.d.ts +0 -20
  291. package/dist/types/ui/icons/index.d.ts.map +0 -1
  292. package/dist/types/ui/index.d.ts +0 -6
  293. package/dist/types/ui/index.d.ts.map +0 -1
  294. package/dist/types/ui/novuUI.d.ts +0 -25
  295. package/dist/types/ui/novuUI.d.ts.map +0 -1
  296. package/dist/types/ui/themes/dark.d.ts +0 -3
  297. package/dist/types/ui/themes/dark.d.ts.map +0 -1
  298. package/dist/types/ui/themes/index.d.ts +0 -2
  299. package/dist/types/ui/themes/index.d.ts.map +0 -1
  300. package/dist/types/ui/types.d.ts +0 -57
  301. package/dist/types/ui/types.d.ts.map +0 -1
  302. package/dist/types/umd.d.ts +0 -2
  303. package/dist/types/umd.d.ts.map +0 -1
  304. package/dist/types/utils/arrays.d.ts +0 -2
  305. package/dist/types/utils/arrays.d.ts.map +0 -1
  306. package/dist/types/utils/config.d.ts +0 -2
  307. package/dist/types/utils/config.d.ts.map +0 -1
  308. package/dist/types/utils/errors.d.ts +0 -5
  309. package/dist/types/utils/errors.d.ts.map +0 -1
  310. package/dist/types/utils/inbox-service-singleton.d.ts +0 -6
  311. package/dist/types/utils/inbox-service-singleton.d.ts.map +0 -1
  312. package/dist/types/utils/notification-utils.d.ts +0 -6
  313. package/dist/types/utils/notification-utils.d.ts.map +0 -1
  314. package/dist/types/ws/index.d.ts +0 -2
  315. package/dist/types/ws/index.d.ts.map +0 -1
  316. package/dist/types/ws/socket.d.ts +0 -13
  317. package/dist/types/ws/socket.d.ts.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import mitt from 'mitt';
2
- import { HttpClient } from '@novu/client';
3
2
  import io from 'socket.io-client';
3
+ import { HttpClient } from '@novu/client';
4
4
 
5
5
  var __defProp = Object.defineProperty;
6
6
  var __defProps = Object.defineProperties;
@@ -120,18 +120,32 @@ var PreferenceOverrideSourceEnum = /* @__PURE__ */ ((PreferenceOverrideSourceEnu
120
120
  PreferenceOverrideSourceEnum2["WORKFLOW_OVERRIDE"] = "workflowOverride";
121
121
  return PreferenceOverrideSourceEnum2;
122
122
  })(PreferenceOverrideSourceEnum || {});
123
- var _instance, _mittEmitter;
124
- var _NovuEventEmitter = class _NovuEventEmitter {
123
+
124
+ // src/utils/arrays.ts
125
+ var arrayValuesEqual = (arr1, arr2) => {
126
+ if (arr1 === arr2) {
127
+ return true;
128
+ }
129
+ if (!arr1 || !arr2) {
130
+ return false;
131
+ }
132
+ if (arr1.length !== arr2.length) {
133
+ return false;
134
+ }
135
+ return arr1.every((value, index) => value === arr2[index]);
136
+ };
137
+ var areTagsEqual = (tags1, tags2) => {
138
+ return arrayValuesEqual(tags1, tags2) || !tags1 && (tags2 == null ? void 0 : tags2.length) === 0 || (tags1 == null ? void 0 : tags1.length) === 0 && !tags2;
139
+ };
140
+ var isSameFilter = (filter1, filter2) => {
141
+ return areTagsEqual(filter1.tags, filter2.tags) && filter1.read === filter2.read && filter1.archived === filter2.archived;
142
+ };
143
+ var _mittEmitter;
144
+ var NovuEventEmitter = class {
125
145
  constructor() {
126
146
  __privateAdd(this, _mittEmitter);
127
147
  __privateSet(this, _mittEmitter, mitt());
128
148
  }
129
- static getInstance(options) {
130
- if (options == null ? void 0 : options.recreate) {
131
- __privateSet(_NovuEventEmitter, _instance, new _NovuEventEmitter());
132
- }
133
- return __privateGet(_NovuEventEmitter, _instance);
134
- }
135
149
  on(eventName, listener) {
136
150
  __privateGet(this, _mittEmitter).on(eventName, listener);
137
151
  }
@@ -142,10 +156,7 @@ var _NovuEventEmitter = class _NovuEventEmitter {
142
156
  __privateGet(this, _mittEmitter).emit(type, event);
143
157
  }
144
158
  };
145
- _instance = new WeakMap();
146
159
  _mittEmitter = new WeakMap();
147
- __privateAdd(_NovuEventEmitter, _instance);
148
- var NovuEventEmitter = _NovuEventEmitter;
149
160
 
150
161
  // src/utils/errors.ts
151
162
  var NovuError = class extends Error {
@@ -154,139 +165,18 @@ var NovuError = class extends Error {
154
165
  this.originalError = originalError;
155
166
  }
156
167
  };
157
- var NOVU_API_VERSION = "2024-06-26";
158
- var INBOX_ROUTE = "/inbox";
159
- var INBOX_NOTIFICATIONS_ROUTE = `${INBOX_ROUTE}/notifications`;
160
- var _httpClient;
161
- var InboxService = class {
162
- constructor(options = {}) {
163
- this.isSessionInitialized = false;
164
- __privateAdd(this, _httpClient);
165
- __privateSet(this, _httpClient, new HttpClient(options));
166
- __privateGet(this, _httpClient).updateHeaders({
167
- "Novu-API-Version": NOVU_API_VERSION
168
- });
169
- }
170
- initializeSession(_0) {
171
- return __async(this, arguments, function* ({
172
- applicationIdentifier,
173
- subscriberId,
174
- subscriberHash
175
- }) {
176
- const response = yield __privateGet(this, _httpClient).post(`${INBOX_ROUTE}/session`, {
177
- applicationIdentifier,
178
- subscriberId,
179
- subscriberHash
180
- });
181
- __privateGet(this, _httpClient).setAuthorizationToken(response.token);
182
- this.isSessionInitialized = true;
183
- return response;
184
- });
185
- }
186
- fetchNotifications({
187
- after,
188
- archived,
189
- limit = 10,
190
- offset,
191
- read: read2,
192
- tags
193
- }) {
194
- const queryParams = new URLSearchParams(`limit=${limit}`);
195
- if (after) {
196
- queryParams.append("after", after);
197
- }
198
- if (offset) {
199
- queryParams.append("offset", `${offset}`);
200
- }
201
- if (tags) {
202
- tags.forEach((tag) => queryParams.append("tags[]", tag));
203
- }
204
- if (read2 !== void 0) {
205
- queryParams.append("read", `${read2}`);
206
- }
207
- if (archived !== void 0) {
208
- queryParams.append("archived", `${archived}`);
209
- }
210
- return __privateGet(this, _httpClient).getFullResponse(`${INBOX_NOTIFICATIONS_ROUTE}?${queryParams.toString()}`);
211
- }
212
- count({ filters }) {
213
- return __privateGet(this, _httpClient).getFullResponse(`${INBOX_NOTIFICATIONS_ROUTE}/count?filters=${JSON.stringify(filters)}`);
214
- }
215
- read(notificationId) {
216
- return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/read`);
217
- }
218
- unread(notificationId) {
219
- return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/unread`);
220
- }
221
- archive(notificationId) {
222
- return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/archive`);
223
- }
224
- unarchive(notificationId) {
225
- return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/unarchive`);
226
- }
227
- readAll({ tags }) {
228
- return __privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/read`, { tags });
229
- }
230
- archiveAll({ tags }) {
231
- return __privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/archive`, { tags });
232
- }
233
- archiveAllRead({ tags }) {
234
- return __privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/read-archive`, { tags });
235
- }
236
- completeAction({
237
- actionType,
238
- notificationId
239
- }) {
240
- return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/complete`, {
241
- actionType
242
- });
243
- }
244
- revertAction({
245
- actionType,
246
- notificationId
247
- }) {
248
- return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/revert`, {
249
- actionType
250
- });
251
- }
252
- fetchPreferences() {
253
- return __privateGet(this, _httpClient).get(`${INBOX_ROUTE}/preferences`);
254
- }
255
- updateGlobalPreferences(channelPreferences) {
256
- return __privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/preferences`, channelPreferences);
257
- }
258
- updateWorkflowPreferences({
259
- workflowId,
260
- channelPreferences
261
- }) {
262
- return __privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/preferences/${workflowId}`, channelPreferences);
263
- }
264
- };
265
- _httpClient = new WeakMap();
266
-
267
- // src/utils/inbox-service-singleton.ts
268
- var _instance2;
269
- var _InboxServiceSingleton = class _InboxServiceSingleton {
270
- static getInstance(options) {
271
- const isNeedsToRecreate = !!options;
272
- if (isNeedsToRecreate) {
273
- __privateSet(_InboxServiceSingleton, _instance2, new InboxService(options));
274
- }
275
- return __privateGet(_InboxServiceSingleton, _instance2);
276
- }
277
- };
278
- _instance2 = new WeakMap();
279
- __privateAdd(_InboxServiceSingleton, _instance2);
280
- var InboxServiceSingleton = _InboxServiceSingleton;
281
168
 
282
169
  // src/base-module.ts
283
170
  var _callsQueue, _sessionError;
284
171
  var BaseModule = class {
285
- constructor() {
172
+ constructor({
173
+ inboxServiceInstance,
174
+ eventEmitterInstance
175
+ }) {
286
176
  __privateAdd(this, _callsQueue, []);
287
177
  __privateAdd(this, _sessionError);
288
- this._emitter = NovuEventEmitter.getInstance();
289
- this._inboxService = InboxServiceSingleton.getInstance();
178
+ this._emitter = eventEmitterInstance;
179
+ this._inboxService = inboxServiceInstance;
290
180
  this._emitter.on("session.initialize.resolved", ({ error, data }) => {
291
181
  if (data) {
292
182
  this.onSessionSuccess(data);
@@ -330,11 +220,11 @@ _sessionError = new WeakMap();
330
220
  // src/notifications/notification.ts
331
221
  var _emitter, _inboxService;
332
222
  var Notification = class {
333
- constructor(notification) {
223
+ constructor(notification, emitter, inboxService) {
334
224
  __privateAdd(this, _emitter);
335
225
  __privateAdd(this, _inboxService);
336
- __privateSet(this, _emitter, NovuEventEmitter.getInstance());
337
- __privateSet(this, _inboxService, InboxServiceSingleton.getInstance());
226
+ __privateSet(this, _emitter, emitter);
227
+ __privateSet(this, _inboxService, inboxService);
338
228
  this.id = notification.id;
339
229
  this.subject = notification.subject;
340
230
  this.body = notification.body;
@@ -456,19 +346,26 @@ var read = (_0) => __async(void 0, [_0], function* ({
456
346
  apiService,
457
347
  args
458
348
  }) {
459
- const { notificationId, optimisticValue } = getNotificationDetails(args, {
460
- isRead: true,
461
- readAt: (/* @__PURE__ */ new Date()).toISOString(),
462
- isArchived: false,
463
- archivedAt: void 0
464
- });
349
+ const { notificationId, optimisticValue } = getNotificationDetails(
350
+ args,
351
+ {
352
+ isRead: true,
353
+ readAt: (/* @__PURE__ */ new Date()).toISOString(),
354
+ isArchived: false,
355
+ archivedAt: void 0
356
+ },
357
+ {
358
+ emitter,
359
+ apiService
360
+ }
361
+ );
465
362
  try {
466
363
  emitter.emit("notification.read.pending", {
467
364
  args,
468
365
  data: optimisticValue
469
366
  });
470
367
  const response = yield apiService.read(notificationId);
471
- const updatedNotification = new Notification(response);
368
+ const updatedNotification = new Notification(response, emitter, apiService);
472
369
  emitter.emit("notification.read.resolved", { args, data: updatedNotification });
473
370
  return { data: updatedNotification };
474
371
  } catch (error) {
@@ -481,19 +378,26 @@ var unread = (_0) => __async(void 0, [_0], function* ({
481
378
  apiService,
482
379
  args
483
380
  }) {
484
- const { notificationId, optimisticValue } = getNotificationDetails(args, {
485
- isRead: false,
486
- readAt: null,
487
- isArchived: false,
488
- archivedAt: void 0
489
- });
381
+ const { notificationId, optimisticValue } = getNotificationDetails(
382
+ args,
383
+ {
384
+ isRead: false,
385
+ readAt: null,
386
+ isArchived: false,
387
+ archivedAt: void 0
388
+ },
389
+ {
390
+ emitter,
391
+ apiService
392
+ }
393
+ );
490
394
  try {
491
395
  emitter.emit("notification.unread.pending", {
492
396
  args,
493
397
  data: optimisticValue
494
398
  });
495
399
  const response = yield apiService.unread(notificationId);
496
- const updatedNotification = new Notification(response);
400
+ const updatedNotification = new Notification(response, emitter, apiService);
497
401
  emitter.emit("notification.unread.resolved", { args, data: updatedNotification });
498
402
  return { data: updatedNotification };
499
403
  } catch (error) {
@@ -506,19 +410,26 @@ var archive = (_0) => __async(void 0, [_0], function* ({
506
410
  apiService,
507
411
  args
508
412
  }) {
509
- const { notificationId, optimisticValue } = getNotificationDetails(args, {
510
- isArchived: true,
511
- archivedAt: (/* @__PURE__ */ new Date()).toISOString(),
512
- isRead: true,
513
- readAt: (/* @__PURE__ */ new Date()).toISOString()
514
- });
413
+ const { notificationId, optimisticValue } = getNotificationDetails(
414
+ args,
415
+ {
416
+ isArchived: true,
417
+ archivedAt: (/* @__PURE__ */ new Date()).toISOString(),
418
+ isRead: true,
419
+ readAt: (/* @__PURE__ */ new Date()).toISOString()
420
+ },
421
+ {
422
+ emitter,
423
+ apiService
424
+ }
425
+ );
515
426
  try {
516
427
  emitter.emit("notification.archive.pending", {
517
428
  args,
518
429
  data: optimisticValue
519
430
  });
520
431
  const response = yield apiService.archive(notificationId);
521
- const updatedNotification = new Notification(response);
432
+ const updatedNotification = new Notification(response, emitter, apiService);
522
433
  emitter.emit("notification.archive.resolved", { args, data: updatedNotification });
523
434
  return { data: updatedNotification };
524
435
  } catch (error) {
@@ -531,19 +442,26 @@ var unarchive = (_0) => __async(void 0, [_0], function* ({
531
442
  apiService,
532
443
  args
533
444
  }) {
534
- const { notificationId, optimisticValue } = getNotificationDetails(args, {
535
- isArchived: false,
536
- archivedAt: null,
537
- isRead: true,
538
- readAt: (/* @__PURE__ */ new Date()).toISOString()
539
- });
445
+ const { notificationId, optimisticValue } = getNotificationDetails(
446
+ args,
447
+ {
448
+ isArchived: false,
449
+ archivedAt: null,
450
+ isRead: true,
451
+ readAt: (/* @__PURE__ */ new Date()).toISOString()
452
+ },
453
+ {
454
+ emitter,
455
+ apiService
456
+ }
457
+ );
540
458
  try {
541
459
  emitter.emit("notification.unarchive.pending", {
542
460
  args,
543
461
  data: optimisticValue
544
462
  });
545
463
  const response = yield apiService.unarchive(notificationId);
546
- const updatedNotification = new Notification(response);
464
+ const updatedNotification = new Notification(response, emitter, apiService);
547
465
  emitter.emit("notification.unarchive.resolved", { args, data: updatedNotification });
548
466
  return { data: updatedNotification };
549
467
  } catch (error) {
@@ -566,14 +484,17 @@ var completeAction = (_0) => __async(void 0, [_0], function* ({
566
484
  isCompleted: true
567
485
  })
568
486
  };
569
- const { notificationId, optimisticValue } = getNotificationDetails(args, optimisticUpdate);
487
+ const { notificationId, optimisticValue } = getNotificationDetails(args, optimisticUpdate, {
488
+ emitter,
489
+ apiService
490
+ });
570
491
  try {
571
492
  emitter.emit("notification.complete_action.pending", {
572
493
  args,
573
494
  data: optimisticValue
574
495
  });
575
496
  const response = yield apiService.completeAction({ actionType, notificationId });
576
- const updatedNotification = new Notification(response);
497
+ const updatedNotification = new Notification(response, emitter, apiService);
577
498
  emitter.emit("notification.complete_action.resolved", { args, data: updatedNotification });
578
499
  return { data: updatedNotification };
579
500
  } catch (error) {
@@ -596,14 +517,17 @@ var revertAction = (_0) => __async(void 0, [_0], function* ({
596
517
  isCompleted: false
597
518
  })
598
519
  };
599
- const { notificationId, optimisticValue } = getNotificationDetails(args, optimisticUpdate);
520
+ const { notificationId, optimisticValue } = getNotificationDetails(args, optimisticUpdate, {
521
+ emitter,
522
+ apiService
523
+ });
600
524
  try {
601
525
  emitter.emit("notification.revert_action.pending", {
602
526
  args,
603
527
  data: optimisticValue
604
528
  });
605
529
  const response = yield apiService.revertAction({ actionType, notificationId });
606
- const updatedNotification = new Notification(response);
530
+ const updatedNotification = new Notification(response, emitter, apiService);
607
531
  emitter.emit("notification.revert_action.resolved", { args, data: updatedNotification });
608
532
  return { data: updatedNotification };
609
533
  } catch (error) {
@@ -611,11 +535,15 @@ var revertAction = (_0) => __async(void 0, [_0], function* ({
611
535
  return { error: new NovuError("Failed to fetch notifications", error) };
612
536
  }
613
537
  });
614
- var getNotificationDetails = (args, update) => {
538
+ var getNotificationDetails = (args, update, dependencies) => {
615
539
  if ("notification" in args) {
616
540
  return {
617
541
  notificationId: args.notification.id,
618
- optimisticValue: new Notification(__spreadValues(__spreadValues({}, args.notification), update))
542
+ optimisticValue: new Notification(
543
+ __spreadValues(__spreadValues({}, args.notification), update),
544
+ dependencies.emitter,
545
+ dependencies.apiService
546
+ )
619
547
  };
620
548
  } else {
621
549
  return {
@@ -632,12 +560,16 @@ var readAll = (_0) => __async(void 0, [_0], function* ({
632
560
  try {
633
561
  const notifications = notificationsCache.getUniqueNotifications({ tags });
634
562
  const optimisticNotifications = notifications.map(
635
- (notification) => new Notification(__spreadProps(__spreadValues({}, notification), {
636
- isRead: true,
637
- readAt: (/* @__PURE__ */ new Date()).toISOString(),
638
- isArchived: false,
639
- archivedAt: void 0
640
- }))
563
+ (notification) => new Notification(
564
+ __spreadProps(__spreadValues({}, notification), {
565
+ isRead: true,
566
+ readAt: (/* @__PURE__ */ new Date()).toISOString(),
567
+ isArchived: false,
568
+ archivedAt: void 0
569
+ }),
570
+ emitter,
571
+ inboxService
572
+ )
641
573
  );
642
574
  emitter.emit("notifications.read_all.pending", { args: { tags }, data: optimisticNotifications });
643
575
  yield inboxService.readAll({ tags });
@@ -657,12 +589,16 @@ var archiveAll = (_0) => __async(void 0, [_0], function* ({
657
589
  try {
658
590
  const notifications = notificationsCache.getUniqueNotifications({ tags });
659
591
  const optimisticNotifications = notifications.map(
660
- (notification) => new Notification(__spreadProps(__spreadValues({}, notification), {
661
- isRead: true,
662
- readAt: (/* @__PURE__ */ new Date()).toISOString(),
663
- isArchived: true,
664
- archivedAt: (/* @__PURE__ */ new Date()).toISOString()
665
- }))
592
+ (notification) => new Notification(
593
+ __spreadProps(__spreadValues({}, notification), {
594
+ isRead: true,
595
+ readAt: (/* @__PURE__ */ new Date()).toISOString(),
596
+ isArchived: true,
597
+ archivedAt: (/* @__PURE__ */ new Date()).toISOString()
598
+ }),
599
+ emitter,
600
+ inboxService
601
+ )
666
602
  );
667
603
  emitter.emit("notifications.archive_all.pending", { args: { tags }, data: optimisticNotifications });
668
604
  yield inboxService.archiveAll({ tags });
@@ -682,7 +618,11 @@ var archiveAllRead = (_0) => __async(void 0, [_0], function* ({
682
618
  try {
683
619
  const notifications = notificationsCache.getUniqueNotifications({ tags, read: true });
684
620
  const optimisticNotifications = notifications.map(
685
- (notification) => new Notification(__spreadProps(__spreadValues({}, notification), { isArchived: true, archivedAt: (/* @__PURE__ */ new Date()).toISOString() }))
621
+ (notification) => new Notification(
622
+ __spreadProps(__spreadValues({}, notification), { isArchived: true, archivedAt: (/* @__PURE__ */ new Date()).toISOString() }),
623
+ emitter,
624
+ inboxService
625
+ )
686
626
  );
687
627
  emitter.emit("notifications.archive_all_read.pending", { args: { tags }, data: optimisticNotifications });
688
628
  yield inboxService.archiveAllRead({ tags });
@@ -725,26 +665,6 @@ var InMemoryCache = class {
725
665
  };
726
666
  _cache = new WeakMap();
727
667
 
728
- // src/utils/arrays.ts
729
- var arrayValuesEqual = (arr1, arr2) => {
730
- if (arr1 === arr2) {
731
- return true;
732
- }
733
- if (!arr1 || !arr2) {
734
- return false;
735
- }
736
- if (arr1.length !== arr2.length) {
737
- return false;
738
- }
739
- return arr1.every((value, index) => value === arr2[index]);
740
- };
741
- var areTagsEqual = (tags1, tags2) => {
742
- return arrayValuesEqual(tags1, tags2) || !tags1 && (tags2 == null ? void 0 : tags2.length) === 0 || (tags1 == null ? void 0 : tags1.length) === 0 && !tags2;
743
- };
744
- var isSameFilter = (filter1, filter2) => {
745
- return areTagsEqual(filter1.tags, filter2.tags) && filter1.read === filter2.read && filter1.archived === filter2.archived;
746
- };
747
-
748
668
  // src/cache/notifications-cache.ts
749
669
  var excludeEmpty = ({ tags, read: read2, archived, limit, offset, after }) => Object.entries({ tags, read: read2, archived, limit, offset, after }).filter(([_, value]) => value !== null && value !== void 0 && !(Array.isArray(value) && value.length === 0)).reduce((acc, [key, value]) => {
750
670
  acc[key] = value;
@@ -779,7 +699,7 @@ var removeEvents = [
779
699
  ];
780
700
  var _emitter2, _cache2;
781
701
  var NotificationsCache = class {
782
- constructor() {
702
+ constructor({ emitter }) {
783
703
  __privateAdd(this, _emitter2);
784
704
  /**
785
705
  * The key is the stringified notifications filter, the values are the paginated notifications.
@@ -841,7 +761,7 @@ var NotificationsCache = class {
841
761
  });
842
762
  });
843
763
  };
844
- __privateSet(this, _emitter2, NovuEventEmitter.getInstance());
764
+ __privateSet(this, _emitter2, emitter);
845
765
  updateEvents.forEach((event) => {
846
766
  __privateGet(this, _emitter2).on(event, this.handleNotificationEvent());
847
767
  });
@@ -924,10 +844,19 @@ _cache2 = new WeakMap();
924
844
  // src/notifications/notifications.ts
925
845
  var _useCache;
926
846
  var Notifications = class extends BaseModule {
927
- constructor({ useCache }) {
928
- super();
847
+ constructor({
848
+ useCache,
849
+ inboxServiceInstance,
850
+ eventEmitterInstance
851
+ }) {
852
+ super({
853
+ eventEmitterInstance,
854
+ inboxServiceInstance
855
+ });
929
856
  __privateAdd(this, _useCache);
930
- this.cache = new NotificationsCache();
857
+ this.cache = new NotificationsCache({
858
+ emitter: eventEmitterInstance
859
+ });
931
860
  __privateSet(this, _useCache, useCache);
932
861
  }
933
862
  list() {
@@ -945,7 +874,7 @@ var Notifications = class extends BaseModule {
945
874
  data = {
946
875
  hasMore: response.hasMore,
947
876
  filter: response.filter,
948
- notifications: response.data.map((el) => new Notification(el))
877
+ notifications: response.data.map((el) => new Notification(el, this._emitter, this._inboxService))
949
878
  };
950
879
  if (__privateGet(this, _useCache)) {
951
880
  this.cache.set(args, data);
@@ -1145,12 +1074,12 @@ _useCache = new WeakMap();
1145
1074
  // src/session/session.ts
1146
1075
  var _emitter3, _inboxService2, _options;
1147
1076
  var Session = class {
1148
- constructor(options) {
1077
+ constructor(options, inboxServiceInstance, eventEmitterInstance) {
1149
1078
  __privateAdd(this, _emitter3);
1150
1079
  __privateAdd(this, _inboxService2);
1151
1080
  __privateAdd(this, _options);
1152
- __privateSet(this, _emitter3, NovuEventEmitter.getInstance());
1153
- __privateSet(this, _inboxService2, InboxServiceSingleton.getInstance());
1081
+ __privateSet(this, _emitter3, eventEmitterInstance);
1082
+ __privateSet(this, _inboxService2, inboxServiceInstance);
1154
1083
  __privateSet(this, _options, options);
1155
1084
  }
1156
1085
  initialize() {
@@ -1177,11 +1106,11 @@ _options = new WeakMap();
1177
1106
  // src/preferences/preference.ts
1178
1107
  var _emitter4, _apiService;
1179
1108
  var Preference = class {
1180
- constructor(preference) {
1109
+ constructor(preference, { emitterInstance, inboxServiceInstance }) {
1181
1110
  __privateAdd(this, _emitter4);
1182
1111
  __privateAdd(this, _apiService);
1183
- __privateSet(this, _emitter4, NovuEventEmitter.getInstance());
1184
- __privateSet(this, _apiService, InboxServiceSingleton.getInstance());
1112
+ __privateSet(this, _emitter4, emitterInstance);
1113
+ __privateSet(this, _apiService, inboxServiceInstance);
1185
1114
  this.level = preference.level;
1186
1115
  this.enabled = preference.enabled;
1187
1116
  this.channels = preference.channels;
@@ -1218,9 +1147,15 @@ var updatePreference = (_0) => __async(void 0, [_0], function* ({
1218
1147
  try {
1219
1148
  emitter.emit("preference.update.pending", {
1220
1149
  args,
1221
- data: args.preference ? new Preference(__spreadProps(__spreadValues({}, args.preference), {
1222
- channels: __spreadValues(__spreadValues({}, args.preference.channels), channelPreferences)
1223
- })) : void 0
1150
+ data: args.preference ? new Preference(
1151
+ __spreadProps(__spreadValues({}, args.preference), {
1152
+ channels: __spreadValues(__spreadValues({}, args.preference.channels), channelPreferences)
1153
+ }),
1154
+ {
1155
+ emitterInstance: emitter,
1156
+ inboxServiceInstance: apiService
1157
+ }
1158
+ ) : void 0
1224
1159
  });
1225
1160
  let response;
1226
1161
  if (workflowId) {
@@ -1228,7 +1163,10 @@ var updatePreference = (_0) => __async(void 0, [_0], function* ({
1228
1163
  } else {
1229
1164
  response = yield apiService.updateGlobalPreferences(channelPreferences);
1230
1165
  }
1231
- const preference = new Preference(response);
1166
+ const preference = new Preference(response, {
1167
+ emitterInstance: emitter,
1168
+ inboxServiceInstance: apiService
1169
+ });
1232
1170
  emitter.emit("preference.update.resolved", { args, data: preference });
1233
1171
  return { data: preference };
1234
1172
  } catch (error) {
@@ -1242,7 +1180,7 @@ var updateEvents2 = ["preference.update.pending", "preference.update.resolved"];
1242
1180
  var DEFAULT_KEY = "default";
1243
1181
  var _emitter5, _cache3;
1244
1182
  var PreferencesCache = class {
1245
- constructor() {
1183
+ constructor({ emitterInstance }) {
1246
1184
  __privateAdd(this, _emitter5);
1247
1185
  __privateAdd(this, _cache3);
1248
1186
  this.updatePreference = (key, data) => {
@@ -1279,7 +1217,7 @@ var PreferencesCache = class {
1279
1217
  });
1280
1218
  });
1281
1219
  };
1282
- __privateSet(this, _emitter5, NovuEventEmitter.getInstance());
1220
+ __privateSet(this, _emitter5, emitterInstance);
1283
1221
  updateEvents2.forEach((event) => {
1284
1222
  __privateGet(this, _emitter5).on(event, this.handlePreferenceEvent);
1285
1223
  });
@@ -1301,10 +1239,19 @@ _cache3 = new WeakMap();
1301
1239
  // src/preferences/preferences.ts
1302
1240
  var _useCache2;
1303
1241
  var Preferences = class extends BaseModule {
1304
- constructor({ useCache }) {
1305
- super();
1242
+ constructor({
1243
+ useCache,
1244
+ inboxServiceInstance,
1245
+ eventEmitterInstance
1246
+ }) {
1247
+ super({
1248
+ eventEmitterInstance,
1249
+ inboxServiceInstance
1250
+ });
1306
1251
  __privateAdd(this, _useCache2);
1307
- this.cache = new PreferencesCache();
1252
+ this.cache = new PreferencesCache({
1253
+ emitterInstance: this._emitter
1254
+ });
1308
1255
  __privateSet(this, _useCache2, useCache);
1309
1256
  }
1310
1257
  list() {
@@ -1315,7 +1262,12 @@ var Preferences = class extends BaseModule {
1315
1262
  this._emitter.emit("preferences.list.pending", { args: void 0, data });
1316
1263
  if (!data) {
1317
1264
  const response = yield this._inboxService.fetchPreferences();
1318
- data = response.map((el) => new Preference(el));
1265
+ data = response.map(
1266
+ (el) => new Preference(el, {
1267
+ emitterInstance: this._emitter,
1268
+ inboxServiceInstance: this._inboxService
1269
+ })
1270
+ );
1319
1271
  if (__privateGet(this, _useCache2)) {
1320
1272
  this.cache.set(data);
1321
1273
  }
@@ -1410,8 +1362,15 @@ var mapToNotification = ({
1410
1362
  };
1411
1363
  var _token, _emitter6, _socketIo, _socketUrl, _notificationReceived, _unseenCountChanged, _unreadCountChanged, _Socket_instances, initializeSocket_fn;
1412
1364
  var Socket = class extends BaseModule {
1413
- constructor({ socketUrl }) {
1414
- super();
1365
+ constructor({
1366
+ socketUrl,
1367
+ inboxServiceInstance,
1368
+ eventEmitterInstance
1369
+ }) {
1370
+ super({
1371
+ eventEmitterInstance,
1372
+ inboxServiceInstance
1373
+ });
1415
1374
  __privateAdd(this, _Socket_instances);
1416
1375
  __privateAdd(this, _token);
1417
1376
  __privateAdd(this, _emitter6);
@@ -1419,7 +1378,7 @@ var Socket = class extends BaseModule {
1419
1378
  __privateAdd(this, _socketUrl);
1420
1379
  __privateAdd(this, _notificationReceived, ({ message }) => {
1421
1380
  __privateGet(this, _emitter6).emit(NOTIFICATION_RECEIVED, {
1422
- result: new Notification(mapToNotification(message))
1381
+ result: new Notification(mapToNotification(message), __privateGet(this, _emitter6), this._inboxService)
1423
1382
  });
1424
1383
  });
1425
1384
  __privateAdd(this, _unseenCountChanged, ({ unseenCount }) => {
@@ -1432,7 +1391,7 @@ var Socket = class extends BaseModule {
1432
1391
  result: unreadCount
1433
1392
  });
1434
1393
  });
1435
- __privateSet(this, _emitter6, NovuEventEmitter.getInstance());
1394
+ __privateSet(this, _emitter6, eventEmitterInstance);
1436
1395
  __privateSet(this, _socketUrl, socketUrl != null ? socketUrl : PRODUCTION_SOCKET_URL);
1437
1396
  }
1438
1397
  onSessionSuccess({ token }) {
@@ -1493,39 +1452,166 @@ initializeSocket_fn = function() {
1493
1452
 
1494
1453
  // src/utils/config.ts
1495
1454
  var PRODUCTION_BACKEND_URL = "https://api.novu.co";
1455
+ var NOVU_API_VERSION = "2024-06-26";
1456
+ var INBOX_ROUTE = "/inbox";
1457
+ var INBOX_NOTIFICATIONS_ROUTE = `${INBOX_ROUTE}/notifications`;
1458
+ var _httpClient;
1459
+ var InboxService = class {
1460
+ constructor(options = {}) {
1461
+ this.isSessionInitialized = false;
1462
+ __privateAdd(this, _httpClient);
1463
+ __privateSet(this, _httpClient, new HttpClient(options));
1464
+ __privateGet(this, _httpClient).updateHeaders({
1465
+ "Novu-API-Version": NOVU_API_VERSION
1466
+ });
1467
+ }
1468
+ initializeSession(_0) {
1469
+ return __async(this, arguments, function* ({
1470
+ applicationIdentifier,
1471
+ subscriberId,
1472
+ subscriberHash
1473
+ }) {
1474
+ const response = yield __privateGet(this, _httpClient).post(`${INBOX_ROUTE}/session`, {
1475
+ applicationIdentifier,
1476
+ subscriberId,
1477
+ subscriberHash
1478
+ });
1479
+ __privateGet(this, _httpClient).setAuthorizationToken(response.token);
1480
+ this.isSessionInitialized = true;
1481
+ return response;
1482
+ });
1483
+ }
1484
+ fetchNotifications({
1485
+ after,
1486
+ archived,
1487
+ limit = 10,
1488
+ offset,
1489
+ read: read2,
1490
+ tags
1491
+ }) {
1492
+ const queryParams = new URLSearchParams(`limit=${limit}`);
1493
+ if (after) {
1494
+ queryParams.append("after", after);
1495
+ }
1496
+ if (offset) {
1497
+ queryParams.append("offset", `${offset}`);
1498
+ }
1499
+ if (tags) {
1500
+ tags.forEach((tag) => queryParams.append("tags[]", tag));
1501
+ }
1502
+ if (read2 !== void 0) {
1503
+ queryParams.append("read", `${read2}`);
1504
+ }
1505
+ if (archived !== void 0) {
1506
+ queryParams.append("archived", `${archived}`);
1507
+ }
1508
+ return __privateGet(this, _httpClient).getFullResponse(`${INBOX_NOTIFICATIONS_ROUTE}?${queryParams.toString()}`);
1509
+ }
1510
+ count({ filters }) {
1511
+ return __privateGet(this, _httpClient).getFullResponse(`${INBOX_NOTIFICATIONS_ROUTE}/count?filters=${JSON.stringify(filters)}`);
1512
+ }
1513
+ read(notificationId) {
1514
+ return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/read`);
1515
+ }
1516
+ unread(notificationId) {
1517
+ return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/unread`);
1518
+ }
1519
+ archive(notificationId) {
1520
+ return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/archive`);
1521
+ }
1522
+ unarchive(notificationId) {
1523
+ return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/unarchive`);
1524
+ }
1525
+ readAll({ tags }) {
1526
+ return __privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/read`, { tags });
1527
+ }
1528
+ archiveAll({ tags }) {
1529
+ return __privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/archive`, { tags });
1530
+ }
1531
+ archiveAllRead({ tags }) {
1532
+ return __privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/read-archive`, { tags });
1533
+ }
1534
+ completeAction({
1535
+ actionType,
1536
+ notificationId
1537
+ }) {
1538
+ return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/complete`, {
1539
+ actionType
1540
+ });
1541
+ }
1542
+ revertAction({
1543
+ actionType,
1544
+ notificationId
1545
+ }) {
1546
+ return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/revert`, {
1547
+ actionType
1548
+ });
1549
+ }
1550
+ fetchPreferences() {
1551
+ return __privateGet(this, _httpClient).get(`${INBOX_ROUTE}/preferences`);
1552
+ }
1553
+ updateGlobalPreferences(channelPreferences) {
1554
+ return __privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/preferences`, channelPreferences);
1555
+ }
1556
+ updateWorkflowPreferences({
1557
+ workflowId,
1558
+ channelPreferences
1559
+ }) {
1560
+ return __privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/preferences/${workflowId}`, channelPreferences);
1561
+ }
1562
+ };
1563
+ _httpClient = new WeakMap();
1496
1564
 
1497
1565
  // src/novu.ts
1498
- var _emitter7, _session, _socket;
1566
+ var _emitter7, _session, _socket, _inboxService3;
1499
1567
  var Novu = class {
1500
1568
  constructor(options) {
1501
1569
  __privateAdd(this, _emitter7);
1502
1570
  __privateAdd(this, _session);
1503
1571
  __privateAdd(this, _socket);
1572
+ __privateAdd(this, _inboxService3);
1504
1573
  var _a, _b, _c;
1505
- InboxServiceSingleton.getInstance({ backendUrl: (_a = options.backendUrl) != null ? _a : PRODUCTION_BACKEND_URL });
1506
- __privateSet(this, _emitter7, NovuEventEmitter.getInstance({ recreate: true }));
1507
- __privateSet(this, _session, new Session({
1508
- applicationIdentifier: options.applicationIdentifier,
1509
- subscriberId: options.subscriberId,
1510
- subscriberHash: options.subscriberHash
1511
- }));
1574
+ __privateSet(this, _inboxService3, new InboxService({ backendUrl: (_a = options.backendUrl) != null ? _a : PRODUCTION_BACKEND_URL }));
1575
+ __privateSet(this, _emitter7, new NovuEventEmitter());
1576
+ __privateSet(this, _session, new Session(
1577
+ {
1578
+ applicationIdentifier: options.applicationIdentifier,
1579
+ subscriberId: options.subscriberId,
1580
+ subscriberHash: options.subscriberHash
1581
+ },
1582
+ __privateGet(this, _inboxService3),
1583
+ __privateGet(this, _emitter7)
1584
+ ));
1512
1585
  __privateGet(this, _session).initialize();
1513
- this.notifications = new Notifications({ useCache: (_b = options.useCache) != null ? _b : true });
1514
- this.preferences = new Preferences({ useCache: (_c = options.useCache) != null ? _c : true });
1515
- __privateSet(this, _socket, new Socket({ socketUrl: options.socketUrl }));
1516
- }
1517
- on(eventName, listener) {
1518
- if (__privateGet(this, _socket).isSocketEvent(eventName)) {
1519
- __privateGet(this, _socket).initialize();
1520
- }
1521
- __privateGet(this, _emitter7).on(eventName, listener);
1522
- }
1523
- off(eventName, listener) {
1524
- __privateGet(this, _emitter7).off(eventName, listener);
1586
+ this.notifications = new Notifications({
1587
+ useCache: (_b = options.useCache) != null ? _b : true,
1588
+ inboxServiceInstance: __privateGet(this, _inboxService3),
1589
+ eventEmitterInstance: __privateGet(this, _emitter7)
1590
+ });
1591
+ this.preferences = new Preferences({
1592
+ useCache: (_c = options.useCache) != null ? _c : true,
1593
+ inboxServiceInstance: __privateGet(this, _inboxService3),
1594
+ eventEmitterInstance: __privateGet(this, _emitter7)
1595
+ });
1596
+ __privateSet(this, _socket, new Socket({
1597
+ socketUrl: options.socketUrl,
1598
+ eventEmitterInstance: __privateGet(this, _emitter7),
1599
+ inboxServiceInstance: __privateGet(this, _inboxService3)
1600
+ }));
1601
+ this.on = (eventName, listener) => {
1602
+ if (__privateGet(this, _socket).isSocketEvent(eventName)) {
1603
+ __privateGet(this, _socket).initialize();
1604
+ }
1605
+ __privateGet(this, _emitter7).on(eventName, listener);
1606
+ };
1607
+ this.off = (eventName, listener) => {
1608
+ __privateGet(this, _emitter7).off(eventName, listener);
1609
+ };
1525
1610
  }
1526
1611
  };
1527
1612
  _emitter7 = new WeakMap();
1528
1613
  _session = new WeakMap();
1529
1614
  _socket = new WeakMap();
1615
+ _inboxService3 = new WeakMap();
1530
1616
 
1531
- export { ActionTypeEnum, ChannelType, CtaType, NotificationActionStatus, NotificationButton, NotificationStatus, Novu, PreferenceLevel, PreferenceOverrideSource, PreferenceOverrideSourceEnum, WebSocketEvent, __async, __objRest, __privateAdd, __privateGet, __privateMethod, __privateSet, __spreadProps, __spreadValues, isSameFilter };
1617
+ export { ActionTypeEnum, ChannelType, CtaType, NotificationActionStatus, NotificationButton, NotificationStatus, Novu, PreferenceLevel, PreferenceOverrideSource, PreferenceOverrideSourceEnum, WebSocketEvent, __async, __objRest, __privateAdd, __privateGet, __privateMethod, __privateSet, __spreadProps, __spreadValues, areTagsEqual, isSameFilter };