@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,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var mitt = require('mitt');
4
- var client = require('@novu/client');
5
4
  var io = require('socket.io-client');
5
+ var client = require('@novu/client');
6
6
 
7
7
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
8
 
@@ -127,18 +127,32 @@ var PreferenceOverrideSourceEnum = /* @__PURE__ */ ((PreferenceOverrideSourceEnu
127
127
  PreferenceOverrideSourceEnum2["WORKFLOW_OVERRIDE"] = "workflowOverride";
128
128
  return PreferenceOverrideSourceEnum2;
129
129
  })(PreferenceOverrideSourceEnum || {});
130
- var _instance, _mittEmitter;
131
- var _NovuEventEmitter = class _NovuEventEmitter {
130
+
131
+ // src/utils/arrays.ts
132
+ var arrayValuesEqual = (arr1, arr2) => {
133
+ if (arr1 === arr2) {
134
+ return true;
135
+ }
136
+ if (!arr1 || !arr2) {
137
+ return false;
138
+ }
139
+ if (arr1.length !== arr2.length) {
140
+ return false;
141
+ }
142
+ return arr1.every((value, index) => value === arr2[index]);
143
+ };
144
+ var areTagsEqual = (tags1, tags2) => {
145
+ return arrayValuesEqual(tags1, tags2) || !tags1 && (tags2 == null ? void 0 : tags2.length) === 0 || (tags1 == null ? void 0 : tags1.length) === 0 && !tags2;
146
+ };
147
+ var isSameFilter = (filter1, filter2) => {
148
+ return areTagsEqual(filter1.tags, filter2.tags) && filter1.read === filter2.read && filter1.archived === filter2.archived;
149
+ };
150
+ var _mittEmitter;
151
+ var NovuEventEmitter = class {
132
152
  constructor() {
133
153
  __privateAdd(this, _mittEmitter);
134
154
  __privateSet(this, _mittEmitter, mitt__default.default());
135
155
  }
136
- static getInstance(options) {
137
- if (options == null ? void 0 : options.recreate) {
138
- __privateSet(_NovuEventEmitter, _instance, new _NovuEventEmitter());
139
- }
140
- return __privateGet(_NovuEventEmitter, _instance);
141
- }
142
156
  on(eventName, listener) {
143
157
  __privateGet(this, _mittEmitter).on(eventName, listener);
144
158
  }
@@ -149,10 +163,7 @@ var _NovuEventEmitter = class _NovuEventEmitter {
149
163
  __privateGet(this, _mittEmitter).emit(type, event);
150
164
  }
151
165
  };
152
- _instance = new WeakMap();
153
166
  _mittEmitter = new WeakMap();
154
- __privateAdd(_NovuEventEmitter, _instance);
155
- var NovuEventEmitter = _NovuEventEmitter;
156
167
 
157
168
  // src/utils/errors.ts
158
169
  var NovuError = class extends Error {
@@ -161,139 +172,18 @@ var NovuError = class extends Error {
161
172
  this.originalError = originalError;
162
173
  }
163
174
  };
164
- var NOVU_API_VERSION = "2024-06-26";
165
- var INBOX_ROUTE = "/inbox";
166
- var INBOX_NOTIFICATIONS_ROUTE = `${INBOX_ROUTE}/notifications`;
167
- var _httpClient;
168
- var InboxService = class {
169
- constructor(options = {}) {
170
- this.isSessionInitialized = false;
171
- __privateAdd(this, _httpClient);
172
- __privateSet(this, _httpClient, new client.HttpClient(options));
173
- __privateGet(this, _httpClient).updateHeaders({
174
- "Novu-API-Version": NOVU_API_VERSION
175
- });
176
- }
177
- initializeSession(_0) {
178
- return __async(this, arguments, function* ({
179
- applicationIdentifier,
180
- subscriberId,
181
- subscriberHash
182
- }) {
183
- const response = yield __privateGet(this, _httpClient).post(`${INBOX_ROUTE}/session`, {
184
- applicationIdentifier,
185
- subscriberId,
186
- subscriberHash
187
- });
188
- __privateGet(this, _httpClient).setAuthorizationToken(response.token);
189
- this.isSessionInitialized = true;
190
- return response;
191
- });
192
- }
193
- fetchNotifications({
194
- after,
195
- archived,
196
- limit = 10,
197
- offset,
198
- read: read2,
199
- tags
200
- }) {
201
- const queryParams = new URLSearchParams(`limit=${limit}`);
202
- if (after) {
203
- queryParams.append("after", after);
204
- }
205
- if (offset) {
206
- queryParams.append("offset", `${offset}`);
207
- }
208
- if (tags) {
209
- tags.forEach((tag) => queryParams.append("tags[]", tag));
210
- }
211
- if (read2 !== void 0) {
212
- queryParams.append("read", `${read2}`);
213
- }
214
- if (archived !== void 0) {
215
- queryParams.append("archived", `${archived}`);
216
- }
217
- return __privateGet(this, _httpClient).getFullResponse(`${INBOX_NOTIFICATIONS_ROUTE}?${queryParams.toString()}`);
218
- }
219
- count({ filters }) {
220
- return __privateGet(this, _httpClient).getFullResponse(`${INBOX_NOTIFICATIONS_ROUTE}/count?filters=${JSON.stringify(filters)}`);
221
- }
222
- read(notificationId) {
223
- return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/read`);
224
- }
225
- unread(notificationId) {
226
- return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/unread`);
227
- }
228
- archive(notificationId) {
229
- return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/archive`);
230
- }
231
- unarchive(notificationId) {
232
- return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/unarchive`);
233
- }
234
- readAll({ tags }) {
235
- return __privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/read`, { tags });
236
- }
237
- archiveAll({ tags }) {
238
- return __privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/archive`, { tags });
239
- }
240
- archiveAllRead({ tags }) {
241
- return __privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/read-archive`, { tags });
242
- }
243
- completeAction({
244
- actionType,
245
- notificationId
246
- }) {
247
- return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/complete`, {
248
- actionType
249
- });
250
- }
251
- revertAction({
252
- actionType,
253
- notificationId
254
- }) {
255
- return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/revert`, {
256
- actionType
257
- });
258
- }
259
- fetchPreferences() {
260
- return __privateGet(this, _httpClient).get(`${INBOX_ROUTE}/preferences`);
261
- }
262
- updateGlobalPreferences(channelPreferences) {
263
- return __privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/preferences`, channelPreferences);
264
- }
265
- updateWorkflowPreferences({
266
- workflowId,
267
- channelPreferences
268
- }) {
269
- return __privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/preferences/${workflowId}`, channelPreferences);
270
- }
271
- };
272
- _httpClient = new WeakMap();
273
-
274
- // src/utils/inbox-service-singleton.ts
275
- var _instance2;
276
- var _InboxServiceSingleton = class _InboxServiceSingleton {
277
- static getInstance(options) {
278
- const isNeedsToRecreate = !!options;
279
- if (isNeedsToRecreate) {
280
- __privateSet(_InboxServiceSingleton, _instance2, new InboxService(options));
281
- }
282
- return __privateGet(_InboxServiceSingleton, _instance2);
283
- }
284
- };
285
- _instance2 = new WeakMap();
286
- __privateAdd(_InboxServiceSingleton, _instance2);
287
- var InboxServiceSingleton = _InboxServiceSingleton;
288
175
 
289
176
  // src/base-module.ts
290
177
  var _callsQueue, _sessionError;
291
178
  var BaseModule = class {
292
- constructor() {
179
+ constructor({
180
+ inboxServiceInstance,
181
+ eventEmitterInstance
182
+ }) {
293
183
  __privateAdd(this, _callsQueue, []);
294
184
  __privateAdd(this, _sessionError);
295
- this._emitter = NovuEventEmitter.getInstance();
296
- this._inboxService = InboxServiceSingleton.getInstance();
185
+ this._emitter = eventEmitterInstance;
186
+ this._inboxService = inboxServiceInstance;
297
187
  this._emitter.on("session.initialize.resolved", ({ error, data }) => {
298
188
  if (data) {
299
189
  this.onSessionSuccess(data);
@@ -337,11 +227,11 @@ _sessionError = new WeakMap();
337
227
  // src/notifications/notification.ts
338
228
  var _emitter, _inboxService;
339
229
  var Notification = class {
340
- constructor(notification) {
230
+ constructor(notification, emitter, inboxService) {
341
231
  __privateAdd(this, _emitter);
342
232
  __privateAdd(this, _inboxService);
343
- __privateSet(this, _emitter, NovuEventEmitter.getInstance());
344
- __privateSet(this, _inboxService, InboxServiceSingleton.getInstance());
233
+ __privateSet(this, _emitter, emitter);
234
+ __privateSet(this, _inboxService, inboxService);
345
235
  this.id = notification.id;
346
236
  this.subject = notification.subject;
347
237
  this.body = notification.body;
@@ -463,19 +353,26 @@ var read = (_0) => __async(void 0, [_0], function* ({
463
353
  apiService,
464
354
  args
465
355
  }) {
466
- const { notificationId, optimisticValue } = getNotificationDetails(args, {
467
- isRead: true,
468
- readAt: (/* @__PURE__ */ new Date()).toISOString(),
469
- isArchived: false,
470
- archivedAt: void 0
471
- });
356
+ const { notificationId, optimisticValue } = getNotificationDetails(
357
+ args,
358
+ {
359
+ isRead: true,
360
+ readAt: (/* @__PURE__ */ new Date()).toISOString(),
361
+ isArchived: false,
362
+ archivedAt: void 0
363
+ },
364
+ {
365
+ emitter,
366
+ apiService
367
+ }
368
+ );
472
369
  try {
473
370
  emitter.emit("notification.read.pending", {
474
371
  args,
475
372
  data: optimisticValue
476
373
  });
477
374
  const response = yield apiService.read(notificationId);
478
- const updatedNotification = new Notification(response);
375
+ const updatedNotification = new Notification(response, emitter, apiService);
479
376
  emitter.emit("notification.read.resolved", { args, data: updatedNotification });
480
377
  return { data: updatedNotification };
481
378
  } catch (error) {
@@ -488,19 +385,26 @@ var unread = (_0) => __async(void 0, [_0], function* ({
488
385
  apiService,
489
386
  args
490
387
  }) {
491
- const { notificationId, optimisticValue } = getNotificationDetails(args, {
492
- isRead: false,
493
- readAt: null,
494
- isArchived: false,
495
- archivedAt: void 0
496
- });
388
+ const { notificationId, optimisticValue } = getNotificationDetails(
389
+ args,
390
+ {
391
+ isRead: false,
392
+ readAt: null,
393
+ isArchived: false,
394
+ archivedAt: void 0
395
+ },
396
+ {
397
+ emitter,
398
+ apiService
399
+ }
400
+ );
497
401
  try {
498
402
  emitter.emit("notification.unread.pending", {
499
403
  args,
500
404
  data: optimisticValue
501
405
  });
502
406
  const response = yield apiService.unread(notificationId);
503
- const updatedNotification = new Notification(response);
407
+ const updatedNotification = new Notification(response, emitter, apiService);
504
408
  emitter.emit("notification.unread.resolved", { args, data: updatedNotification });
505
409
  return { data: updatedNotification };
506
410
  } catch (error) {
@@ -513,19 +417,26 @@ var archive = (_0) => __async(void 0, [_0], function* ({
513
417
  apiService,
514
418
  args
515
419
  }) {
516
- const { notificationId, optimisticValue } = getNotificationDetails(args, {
517
- isArchived: true,
518
- archivedAt: (/* @__PURE__ */ new Date()).toISOString(),
519
- isRead: true,
520
- readAt: (/* @__PURE__ */ new Date()).toISOString()
521
- });
420
+ const { notificationId, optimisticValue } = getNotificationDetails(
421
+ args,
422
+ {
423
+ isArchived: true,
424
+ archivedAt: (/* @__PURE__ */ new Date()).toISOString(),
425
+ isRead: true,
426
+ readAt: (/* @__PURE__ */ new Date()).toISOString()
427
+ },
428
+ {
429
+ emitter,
430
+ apiService
431
+ }
432
+ );
522
433
  try {
523
434
  emitter.emit("notification.archive.pending", {
524
435
  args,
525
436
  data: optimisticValue
526
437
  });
527
438
  const response = yield apiService.archive(notificationId);
528
- const updatedNotification = new Notification(response);
439
+ const updatedNotification = new Notification(response, emitter, apiService);
529
440
  emitter.emit("notification.archive.resolved", { args, data: updatedNotification });
530
441
  return { data: updatedNotification };
531
442
  } catch (error) {
@@ -538,19 +449,26 @@ var unarchive = (_0) => __async(void 0, [_0], function* ({
538
449
  apiService,
539
450
  args
540
451
  }) {
541
- const { notificationId, optimisticValue } = getNotificationDetails(args, {
542
- isArchived: false,
543
- archivedAt: null,
544
- isRead: true,
545
- readAt: (/* @__PURE__ */ new Date()).toISOString()
546
- });
452
+ const { notificationId, optimisticValue } = getNotificationDetails(
453
+ args,
454
+ {
455
+ isArchived: false,
456
+ archivedAt: null,
457
+ isRead: true,
458
+ readAt: (/* @__PURE__ */ new Date()).toISOString()
459
+ },
460
+ {
461
+ emitter,
462
+ apiService
463
+ }
464
+ );
547
465
  try {
548
466
  emitter.emit("notification.unarchive.pending", {
549
467
  args,
550
468
  data: optimisticValue
551
469
  });
552
470
  const response = yield apiService.unarchive(notificationId);
553
- const updatedNotification = new Notification(response);
471
+ const updatedNotification = new Notification(response, emitter, apiService);
554
472
  emitter.emit("notification.unarchive.resolved", { args, data: updatedNotification });
555
473
  return { data: updatedNotification };
556
474
  } catch (error) {
@@ -573,14 +491,17 @@ var completeAction = (_0) => __async(void 0, [_0], function* ({
573
491
  isCompleted: true
574
492
  })
575
493
  };
576
- const { notificationId, optimisticValue } = getNotificationDetails(args, optimisticUpdate);
494
+ const { notificationId, optimisticValue } = getNotificationDetails(args, optimisticUpdate, {
495
+ emitter,
496
+ apiService
497
+ });
577
498
  try {
578
499
  emitter.emit("notification.complete_action.pending", {
579
500
  args,
580
501
  data: optimisticValue
581
502
  });
582
503
  const response = yield apiService.completeAction({ actionType, notificationId });
583
- const updatedNotification = new Notification(response);
504
+ const updatedNotification = new Notification(response, emitter, apiService);
584
505
  emitter.emit("notification.complete_action.resolved", { args, data: updatedNotification });
585
506
  return { data: updatedNotification };
586
507
  } catch (error) {
@@ -603,14 +524,17 @@ var revertAction = (_0) => __async(void 0, [_0], function* ({
603
524
  isCompleted: false
604
525
  })
605
526
  };
606
- const { notificationId, optimisticValue } = getNotificationDetails(args, optimisticUpdate);
527
+ const { notificationId, optimisticValue } = getNotificationDetails(args, optimisticUpdate, {
528
+ emitter,
529
+ apiService
530
+ });
607
531
  try {
608
532
  emitter.emit("notification.revert_action.pending", {
609
533
  args,
610
534
  data: optimisticValue
611
535
  });
612
536
  const response = yield apiService.revertAction({ actionType, notificationId });
613
- const updatedNotification = new Notification(response);
537
+ const updatedNotification = new Notification(response, emitter, apiService);
614
538
  emitter.emit("notification.revert_action.resolved", { args, data: updatedNotification });
615
539
  return { data: updatedNotification };
616
540
  } catch (error) {
@@ -618,11 +542,15 @@ var revertAction = (_0) => __async(void 0, [_0], function* ({
618
542
  return { error: new NovuError("Failed to fetch notifications", error) };
619
543
  }
620
544
  });
621
- var getNotificationDetails = (args, update) => {
545
+ var getNotificationDetails = (args, update, dependencies) => {
622
546
  if ("notification" in args) {
623
547
  return {
624
548
  notificationId: args.notification.id,
625
- optimisticValue: new Notification(__spreadValues(__spreadValues({}, args.notification), update))
549
+ optimisticValue: new Notification(
550
+ __spreadValues(__spreadValues({}, args.notification), update),
551
+ dependencies.emitter,
552
+ dependencies.apiService
553
+ )
626
554
  };
627
555
  } else {
628
556
  return {
@@ -639,12 +567,16 @@ var readAll = (_0) => __async(void 0, [_0], function* ({
639
567
  try {
640
568
  const notifications = notificationsCache.getUniqueNotifications({ tags });
641
569
  const optimisticNotifications = notifications.map(
642
- (notification) => new Notification(__spreadProps(__spreadValues({}, notification), {
643
- isRead: true,
644
- readAt: (/* @__PURE__ */ new Date()).toISOString(),
645
- isArchived: false,
646
- archivedAt: void 0
647
- }))
570
+ (notification) => new Notification(
571
+ __spreadProps(__spreadValues({}, notification), {
572
+ isRead: true,
573
+ readAt: (/* @__PURE__ */ new Date()).toISOString(),
574
+ isArchived: false,
575
+ archivedAt: void 0
576
+ }),
577
+ emitter,
578
+ inboxService
579
+ )
648
580
  );
649
581
  emitter.emit("notifications.read_all.pending", { args: { tags }, data: optimisticNotifications });
650
582
  yield inboxService.readAll({ tags });
@@ -664,12 +596,16 @@ var archiveAll = (_0) => __async(void 0, [_0], function* ({
664
596
  try {
665
597
  const notifications = notificationsCache.getUniqueNotifications({ tags });
666
598
  const optimisticNotifications = notifications.map(
667
- (notification) => new Notification(__spreadProps(__spreadValues({}, notification), {
668
- isRead: true,
669
- readAt: (/* @__PURE__ */ new Date()).toISOString(),
670
- isArchived: true,
671
- archivedAt: (/* @__PURE__ */ new Date()).toISOString()
672
- }))
599
+ (notification) => new Notification(
600
+ __spreadProps(__spreadValues({}, notification), {
601
+ isRead: true,
602
+ readAt: (/* @__PURE__ */ new Date()).toISOString(),
603
+ isArchived: true,
604
+ archivedAt: (/* @__PURE__ */ new Date()).toISOString()
605
+ }),
606
+ emitter,
607
+ inboxService
608
+ )
673
609
  );
674
610
  emitter.emit("notifications.archive_all.pending", { args: { tags }, data: optimisticNotifications });
675
611
  yield inboxService.archiveAll({ tags });
@@ -689,7 +625,11 @@ var archiveAllRead = (_0) => __async(void 0, [_0], function* ({
689
625
  try {
690
626
  const notifications = notificationsCache.getUniqueNotifications({ tags, read: true });
691
627
  const optimisticNotifications = notifications.map(
692
- (notification) => new Notification(__spreadProps(__spreadValues({}, notification), { isArchived: true, archivedAt: (/* @__PURE__ */ new Date()).toISOString() }))
628
+ (notification) => new Notification(
629
+ __spreadProps(__spreadValues({}, notification), { isArchived: true, archivedAt: (/* @__PURE__ */ new Date()).toISOString() }),
630
+ emitter,
631
+ inboxService
632
+ )
693
633
  );
694
634
  emitter.emit("notifications.archive_all_read.pending", { args: { tags }, data: optimisticNotifications });
695
635
  yield inboxService.archiveAllRead({ tags });
@@ -732,26 +672,6 @@ var InMemoryCache = class {
732
672
  };
733
673
  _cache = new WeakMap();
734
674
 
735
- // src/utils/arrays.ts
736
- var arrayValuesEqual = (arr1, arr2) => {
737
- if (arr1 === arr2) {
738
- return true;
739
- }
740
- if (!arr1 || !arr2) {
741
- return false;
742
- }
743
- if (arr1.length !== arr2.length) {
744
- return false;
745
- }
746
- return arr1.every((value, index) => value === arr2[index]);
747
- };
748
- var areTagsEqual = (tags1, tags2) => {
749
- return arrayValuesEqual(tags1, tags2) || !tags1 && (tags2 == null ? void 0 : tags2.length) === 0 || (tags1 == null ? void 0 : tags1.length) === 0 && !tags2;
750
- };
751
- var isSameFilter = (filter1, filter2) => {
752
- return areTagsEqual(filter1.tags, filter2.tags) && filter1.read === filter2.read && filter1.archived === filter2.archived;
753
- };
754
-
755
675
  // src/cache/notifications-cache.ts
756
676
  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]) => {
757
677
  acc[key] = value;
@@ -786,7 +706,7 @@ var removeEvents = [
786
706
  ];
787
707
  var _emitter2, _cache2;
788
708
  var NotificationsCache = class {
789
- constructor() {
709
+ constructor({ emitter }) {
790
710
  __privateAdd(this, _emitter2);
791
711
  /**
792
712
  * The key is the stringified notifications filter, the values are the paginated notifications.
@@ -848,7 +768,7 @@ var NotificationsCache = class {
848
768
  });
849
769
  });
850
770
  };
851
- __privateSet(this, _emitter2, NovuEventEmitter.getInstance());
771
+ __privateSet(this, _emitter2, emitter);
852
772
  updateEvents.forEach((event) => {
853
773
  __privateGet(this, _emitter2).on(event, this.handleNotificationEvent());
854
774
  });
@@ -931,10 +851,19 @@ _cache2 = new WeakMap();
931
851
  // src/notifications/notifications.ts
932
852
  var _useCache;
933
853
  var Notifications = class extends BaseModule {
934
- constructor({ useCache }) {
935
- super();
854
+ constructor({
855
+ useCache,
856
+ inboxServiceInstance,
857
+ eventEmitterInstance
858
+ }) {
859
+ super({
860
+ eventEmitterInstance,
861
+ inboxServiceInstance
862
+ });
936
863
  __privateAdd(this, _useCache);
937
- this.cache = new NotificationsCache();
864
+ this.cache = new NotificationsCache({
865
+ emitter: eventEmitterInstance
866
+ });
938
867
  __privateSet(this, _useCache, useCache);
939
868
  }
940
869
  list() {
@@ -952,7 +881,7 @@ var Notifications = class extends BaseModule {
952
881
  data = {
953
882
  hasMore: response.hasMore,
954
883
  filter: response.filter,
955
- notifications: response.data.map((el) => new Notification(el))
884
+ notifications: response.data.map((el) => new Notification(el, this._emitter, this._inboxService))
956
885
  };
957
886
  if (__privateGet(this, _useCache)) {
958
887
  this.cache.set(args, data);
@@ -1152,12 +1081,12 @@ _useCache = new WeakMap();
1152
1081
  // src/session/session.ts
1153
1082
  var _emitter3, _inboxService2, _options;
1154
1083
  var Session = class {
1155
- constructor(options) {
1084
+ constructor(options, inboxServiceInstance, eventEmitterInstance) {
1156
1085
  __privateAdd(this, _emitter3);
1157
1086
  __privateAdd(this, _inboxService2);
1158
1087
  __privateAdd(this, _options);
1159
- __privateSet(this, _emitter3, NovuEventEmitter.getInstance());
1160
- __privateSet(this, _inboxService2, InboxServiceSingleton.getInstance());
1088
+ __privateSet(this, _emitter3, eventEmitterInstance);
1089
+ __privateSet(this, _inboxService2, inboxServiceInstance);
1161
1090
  __privateSet(this, _options, options);
1162
1091
  }
1163
1092
  initialize() {
@@ -1184,11 +1113,11 @@ _options = new WeakMap();
1184
1113
  // src/preferences/preference.ts
1185
1114
  var _emitter4, _apiService;
1186
1115
  var Preference = class {
1187
- constructor(preference) {
1116
+ constructor(preference, { emitterInstance, inboxServiceInstance }) {
1188
1117
  __privateAdd(this, _emitter4);
1189
1118
  __privateAdd(this, _apiService);
1190
- __privateSet(this, _emitter4, NovuEventEmitter.getInstance());
1191
- __privateSet(this, _apiService, InboxServiceSingleton.getInstance());
1119
+ __privateSet(this, _emitter4, emitterInstance);
1120
+ __privateSet(this, _apiService, inboxServiceInstance);
1192
1121
  this.level = preference.level;
1193
1122
  this.enabled = preference.enabled;
1194
1123
  this.channels = preference.channels;
@@ -1225,9 +1154,15 @@ var updatePreference = (_0) => __async(void 0, [_0], function* ({
1225
1154
  try {
1226
1155
  emitter.emit("preference.update.pending", {
1227
1156
  args,
1228
- data: args.preference ? new Preference(__spreadProps(__spreadValues({}, args.preference), {
1229
- channels: __spreadValues(__spreadValues({}, args.preference.channels), channelPreferences)
1230
- })) : void 0
1157
+ data: args.preference ? new Preference(
1158
+ __spreadProps(__spreadValues({}, args.preference), {
1159
+ channels: __spreadValues(__spreadValues({}, args.preference.channels), channelPreferences)
1160
+ }),
1161
+ {
1162
+ emitterInstance: emitter,
1163
+ inboxServiceInstance: apiService
1164
+ }
1165
+ ) : void 0
1231
1166
  });
1232
1167
  let response;
1233
1168
  if (workflowId) {
@@ -1235,7 +1170,10 @@ var updatePreference = (_0) => __async(void 0, [_0], function* ({
1235
1170
  } else {
1236
1171
  response = yield apiService.updateGlobalPreferences(channelPreferences);
1237
1172
  }
1238
- const preference = new Preference(response);
1173
+ const preference = new Preference(response, {
1174
+ emitterInstance: emitter,
1175
+ inboxServiceInstance: apiService
1176
+ });
1239
1177
  emitter.emit("preference.update.resolved", { args, data: preference });
1240
1178
  return { data: preference };
1241
1179
  } catch (error) {
@@ -1249,7 +1187,7 @@ var updateEvents2 = ["preference.update.pending", "preference.update.resolved"];
1249
1187
  var DEFAULT_KEY = "default";
1250
1188
  var _emitter5, _cache3;
1251
1189
  var PreferencesCache = class {
1252
- constructor() {
1190
+ constructor({ emitterInstance }) {
1253
1191
  __privateAdd(this, _emitter5);
1254
1192
  __privateAdd(this, _cache3);
1255
1193
  this.updatePreference = (key, data) => {
@@ -1286,7 +1224,7 @@ var PreferencesCache = class {
1286
1224
  });
1287
1225
  });
1288
1226
  };
1289
- __privateSet(this, _emitter5, NovuEventEmitter.getInstance());
1227
+ __privateSet(this, _emitter5, emitterInstance);
1290
1228
  updateEvents2.forEach((event) => {
1291
1229
  __privateGet(this, _emitter5).on(event, this.handlePreferenceEvent);
1292
1230
  });
@@ -1308,10 +1246,19 @@ _cache3 = new WeakMap();
1308
1246
  // src/preferences/preferences.ts
1309
1247
  var _useCache2;
1310
1248
  var Preferences = class extends BaseModule {
1311
- constructor({ useCache }) {
1312
- super();
1249
+ constructor({
1250
+ useCache,
1251
+ inboxServiceInstance,
1252
+ eventEmitterInstance
1253
+ }) {
1254
+ super({
1255
+ eventEmitterInstance,
1256
+ inboxServiceInstance
1257
+ });
1313
1258
  __privateAdd(this, _useCache2);
1314
- this.cache = new PreferencesCache();
1259
+ this.cache = new PreferencesCache({
1260
+ emitterInstance: this._emitter
1261
+ });
1315
1262
  __privateSet(this, _useCache2, useCache);
1316
1263
  }
1317
1264
  list() {
@@ -1322,7 +1269,12 @@ var Preferences = class extends BaseModule {
1322
1269
  this._emitter.emit("preferences.list.pending", { args: void 0, data });
1323
1270
  if (!data) {
1324
1271
  const response = yield this._inboxService.fetchPreferences();
1325
- data = response.map((el) => new Preference(el));
1272
+ data = response.map(
1273
+ (el) => new Preference(el, {
1274
+ emitterInstance: this._emitter,
1275
+ inboxServiceInstance: this._inboxService
1276
+ })
1277
+ );
1326
1278
  if (__privateGet(this, _useCache2)) {
1327
1279
  this.cache.set(data);
1328
1280
  }
@@ -1417,8 +1369,15 @@ var mapToNotification = ({
1417
1369
  };
1418
1370
  var _token, _emitter6, _socketIo, _socketUrl, _notificationReceived, _unseenCountChanged, _unreadCountChanged, _Socket_instances, initializeSocket_fn;
1419
1371
  var Socket = class extends BaseModule {
1420
- constructor({ socketUrl }) {
1421
- super();
1372
+ constructor({
1373
+ socketUrl,
1374
+ inboxServiceInstance,
1375
+ eventEmitterInstance
1376
+ }) {
1377
+ super({
1378
+ eventEmitterInstance,
1379
+ inboxServiceInstance
1380
+ });
1422
1381
  __privateAdd(this, _Socket_instances);
1423
1382
  __privateAdd(this, _token);
1424
1383
  __privateAdd(this, _emitter6);
@@ -1426,7 +1385,7 @@ var Socket = class extends BaseModule {
1426
1385
  __privateAdd(this, _socketUrl);
1427
1386
  __privateAdd(this, _notificationReceived, ({ message }) => {
1428
1387
  __privateGet(this, _emitter6).emit(NOTIFICATION_RECEIVED, {
1429
- result: new Notification(mapToNotification(message))
1388
+ result: new Notification(mapToNotification(message), __privateGet(this, _emitter6), this._inboxService)
1430
1389
  });
1431
1390
  });
1432
1391
  __privateAdd(this, _unseenCountChanged, ({ unseenCount }) => {
@@ -1439,7 +1398,7 @@ var Socket = class extends BaseModule {
1439
1398
  result: unreadCount
1440
1399
  });
1441
1400
  });
1442
- __privateSet(this, _emitter6, NovuEventEmitter.getInstance());
1401
+ __privateSet(this, _emitter6, eventEmitterInstance);
1443
1402
  __privateSet(this, _socketUrl, socketUrl != null ? socketUrl : PRODUCTION_SOCKET_URL);
1444
1403
  }
1445
1404
  onSessionSuccess({ token }) {
@@ -1500,40 +1459,167 @@ initializeSocket_fn = function() {
1500
1459
 
1501
1460
  // src/utils/config.ts
1502
1461
  var PRODUCTION_BACKEND_URL = "https://api.novu.co";
1462
+ var NOVU_API_VERSION = "2024-06-26";
1463
+ var INBOX_ROUTE = "/inbox";
1464
+ var INBOX_NOTIFICATIONS_ROUTE = `${INBOX_ROUTE}/notifications`;
1465
+ var _httpClient;
1466
+ var InboxService = class {
1467
+ constructor(options = {}) {
1468
+ this.isSessionInitialized = false;
1469
+ __privateAdd(this, _httpClient);
1470
+ __privateSet(this, _httpClient, new client.HttpClient(options));
1471
+ __privateGet(this, _httpClient).updateHeaders({
1472
+ "Novu-API-Version": NOVU_API_VERSION
1473
+ });
1474
+ }
1475
+ initializeSession(_0) {
1476
+ return __async(this, arguments, function* ({
1477
+ applicationIdentifier,
1478
+ subscriberId,
1479
+ subscriberHash
1480
+ }) {
1481
+ const response = yield __privateGet(this, _httpClient).post(`${INBOX_ROUTE}/session`, {
1482
+ applicationIdentifier,
1483
+ subscriberId,
1484
+ subscriberHash
1485
+ });
1486
+ __privateGet(this, _httpClient).setAuthorizationToken(response.token);
1487
+ this.isSessionInitialized = true;
1488
+ return response;
1489
+ });
1490
+ }
1491
+ fetchNotifications({
1492
+ after,
1493
+ archived,
1494
+ limit = 10,
1495
+ offset,
1496
+ read: read2,
1497
+ tags
1498
+ }) {
1499
+ const queryParams = new URLSearchParams(`limit=${limit}`);
1500
+ if (after) {
1501
+ queryParams.append("after", after);
1502
+ }
1503
+ if (offset) {
1504
+ queryParams.append("offset", `${offset}`);
1505
+ }
1506
+ if (tags) {
1507
+ tags.forEach((tag) => queryParams.append("tags[]", tag));
1508
+ }
1509
+ if (read2 !== void 0) {
1510
+ queryParams.append("read", `${read2}`);
1511
+ }
1512
+ if (archived !== void 0) {
1513
+ queryParams.append("archived", `${archived}`);
1514
+ }
1515
+ return __privateGet(this, _httpClient).getFullResponse(`${INBOX_NOTIFICATIONS_ROUTE}?${queryParams.toString()}`);
1516
+ }
1517
+ count({ filters }) {
1518
+ return __privateGet(this, _httpClient).getFullResponse(`${INBOX_NOTIFICATIONS_ROUTE}/count?filters=${JSON.stringify(filters)}`);
1519
+ }
1520
+ read(notificationId) {
1521
+ return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/read`);
1522
+ }
1523
+ unread(notificationId) {
1524
+ return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/unread`);
1525
+ }
1526
+ archive(notificationId) {
1527
+ return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/archive`);
1528
+ }
1529
+ unarchive(notificationId) {
1530
+ return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/unarchive`);
1531
+ }
1532
+ readAll({ tags }) {
1533
+ return __privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/read`, { tags });
1534
+ }
1535
+ archiveAll({ tags }) {
1536
+ return __privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/archive`, { tags });
1537
+ }
1538
+ archiveAllRead({ tags }) {
1539
+ return __privateGet(this, _httpClient).post(`${INBOX_NOTIFICATIONS_ROUTE}/read-archive`, { tags });
1540
+ }
1541
+ completeAction({
1542
+ actionType,
1543
+ notificationId
1544
+ }) {
1545
+ return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/complete`, {
1546
+ actionType
1547
+ });
1548
+ }
1549
+ revertAction({
1550
+ actionType,
1551
+ notificationId
1552
+ }) {
1553
+ return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/revert`, {
1554
+ actionType
1555
+ });
1556
+ }
1557
+ fetchPreferences() {
1558
+ return __privateGet(this, _httpClient).get(`${INBOX_ROUTE}/preferences`);
1559
+ }
1560
+ updateGlobalPreferences(channelPreferences) {
1561
+ return __privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/preferences`, channelPreferences);
1562
+ }
1563
+ updateWorkflowPreferences({
1564
+ workflowId,
1565
+ channelPreferences
1566
+ }) {
1567
+ return __privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/preferences/${workflowId}`, channelPreferences);
1568
+ }
1569
+ };
1570
+ _httpClient = new WeakMap();
1503
1571
 
1504
1572
  // src/novu.ts
1505
- var _emitter7, _session, _socket;
1573
+ var _emitter7, _session, _socket, _inboxService3;
1506
1574
  var Novu = class {
1507
1575
  constructor(options) {
1508
1576
  __privateAdd(this, _emitter7);
1509
1577
  __privateAdd(this, _session);
1510
1578
  __privateAdd(this, _socket);
1579
+ __privateAdd(this, _inboxService3);
1511
1580
  var _a, _b, _c;
1512
- InboxServiceSingleton.getInstance({ backendUrl: (_a = options.backendUrl) != null ? _a : PRODUCTION_BACKEND_URL });
1513
- __privateSet(this, _emitter7, NovuEventEmitter.getInstance({ recreate: true }));
1514
- __privateSet(this, _session, new Session({
1515
- applicationIdentifier: options.applicationIdentifier,
1516
- subscriberId: options.subscriberId,
1517
- subscriberHash: options.subscriberHash
1518
- }));
1581
+ __privateSet(this, _inboxService3, new InboxService({ backendUrl: (_a = options.backendUrl) != null ? _a : PRODUCTION_BACKEND_URL }));
1582
+ __privateSet(this, _emitter7, new NovuEventEmitter());
1583
+ __privateSet(this, _session, new Session(
1584
+ {
1585
+ applicationIdentifier: options.applicationIdentifier,
1586
+ subscriberId: options.subscriberId,
1587
+ subscriberHash: options.subscriberHash
1588
+ },
1589
+ __privateGet(this, _inboxService3),
1590
+ __privateGet(this, _emitter7)
1591
+ ));
1519
1592
  __privateGet(this, _session).initialize();
1520
- this.notifications = new Notifications({ useCache: (_b = options.useCache) != null ? _b : true });
1521
- this.preferences = new Preferences({ useCache: (_c = options.useCache) != null ? _c : true });
1522
- __privateSet(this, _socket, new Socket({ socketUrl: options.socketUrl }));
1523
- }
1524
- on(eventName, listener) {
1525
- if (__privateGet(this, _socket).isSocketEvent(eventName)) {
1526
- __privateGet(this, _socket).initialize();
1527
- }
1528
- __privateGet(this, _emitter7).on(eventName, listener);
1529
- }
1530
- off(eventName, listener) {
1531
- __privateGet(this, _emitter7).off(eventName, listener);
1593
+ this.notifications = new Notifications({
1594
+ useCache: (_b = options.useCache) != null ? _b : true,
1595
+ inboxServiceInstance: __privateGet(this, _inboxService3),
1596
+ eventEmitterInstance: __privateGet(this, _emitter7)
1597
+ });
1598
+ this.preferences = new Preferences({
1599
+ useCache: (_c = options.useCache) != null ? _c : true,
1600
+ inboxServiceInstance: __privateGet(this, _inboxService3),
1601
+ eventEmitterInstance: __privateGet(this, _emitter7)
1602
+ });
1603
+ __privateSet(this, _socket, new Socket({
1604
+ socketUrl: options.socketUrl,
1605
+ eventEmitterInstance: __privateGet(this, _emitter7),
1606
+ inboxServiceInstance: __privateGet(this, _inboxService3)
1607
+ }));
1608
+ this.on = (eventName, listener) => {
1609
+ if (__privateGet(this, _socket).isSocketEvent(eventName)) {
1610
+ __privateGet(this, _socket).initialize();
1611
+ }
1612
+ __privateGet(this, _emitter7).on(eventName, listener);
1613
+ };
1614
+ this.off = (eventName, listener) => {
1615
+ __privateGet(this, _emitter7).off(eventName, listener);
1616
+ };
1532
1617
  }
1533
1618
  };
1534
1619
  _emitter7 = new WeakMap();
1535
1620
  _session = new WeakMap();
1536
1621
  _socket = new WeakMap();
1622
+ _inboxService3 = new WeakMap();
1537
1623
 
1538
1624
  exports.ActionTypeEnum = ActionTypeEnum;
1539
1625
  exports.ChannelType = ChannelType;
@@ -1554,4 +1640,5 @@ exports.__privateMethod = __privateMethod;
1554
1640
  exports.__privateSet = __privateSet;
1555
1641
  exports.__spreadProps = __spreadProps;
1556
1642
  exports.__spreadValues = __spreadValues;
1643
+ exports.areTagsEqual = areTagsEqual;
1557
1644
  exports.isSameFilter = isSameFilter;