@novu/api 2.6.5 → 2.6.6

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 (339) hide show
  1. package/FUNCTIONS.md +124 -0
  2. package/REACT_QUERY.md +354 -0
  3. package/README.md +1032 -0
  4. package/docs/sdks/authentication/README.md +247 -0
  5. package/docs/sdks/credentials/README.md +372 -0
  6. package/docs/sdks/integrations/README.md +631 -0
  7. package/docs/sdks/messages/README.md +318 -0
  8. package/docs/sdks/notifications/README.md +226 -0
  9. package/docs/sdks/novu/README.md +598 -0
  10. package/docs/sdks/novumessages/README.md +329 -0
  11. package/docs/sdks/novunotifications/README.md +235 -0
  12. package/docs/sdks/novusubscribers/README.md +340 -0
  13. package/docs/sdks/preferences/README.md +221 -0
  14. package/docs/sdks/properties/README.md +111 -0
  15. package/docs/sdks/stats/README.md +226 -0
  16. package/docs/sdks/subscribers/README.md +763 -0
  17. package/docs/sdks/topics/README.md +541 -0
  18. package/docs/sdks/webhooks/README.md +117 -0
  19. package/docs/sdks/workflows/README.md +1123 -0
  20. package/funcs/cancel.d.ts.map +1 -1
  21. package/funcs/cancel.js +1 -0
  22. package/funcs/cancel.js.map +1 -1
  23. package/funcs/environmentsGenerateSession.d.ts +10 -0
  24. package/funcs/environmentsGenerateSession.d.ts.map +1 -0
  25. package/funcs/environmentsGenerateSession.js +131 -0
  26. package/funcs/environmentsGenerateSession.js.map +1 -0
  27. package/funcs/environmentsRetrieve.d.ts +10 -0
  28. package/funcs/environmentsRetrieve.d.ts.map +1 -0
  29. package/funcs/environmentsRetrieve.js +131 -0
  30. package/funcs/environmentsRetrieve.js.map +1 -0
  31. package/funcs/integrationsCreate.d.ts.map +1 -1
  32. package/funcs/integrationsCreate.js +1 -0
  33. package/funcs/integrationsCreate.js.map +1 -1
  34. package/funcs/integrationsDelete.d.ts.map +1 -1
  35. package/funcs/integrationsDelete.js +1 -0
  36. package/funcs/integrationsDelete.js.map +1 -1
  37. package/funcs/integrationsList.d.ts.map +1 -1
  38. package/funcs/integrationsList.js +1 -0
  39. package/funcs/integrationsList.js.map +1 -1
  40. package/funcs/integrationsListActive.d.ts.map +1 -1
  41. package/funcs/integrationsListActive.js +1 -0
  42. package/funcs/integrationsListActive.js.map +1 -1
  43. package/funcs/integrationsSetAsPrimary.d.ts.map +1 -1
  44. package/funcs/integrationsSetAsPrimary.js +1 -0
  45. package/funcs/integrationsSetAsPrimary.js.map +1 -1
  46. package/funcs/integrationsUpdate.d.ts.map +1 -1
  47. package/funcs/integrationsUpdate.js +1 -0
  48. package/funcs/integrationsUpdate.js.map +1 -1
  49. package/funcs/integrationsWebhooksRetrieve.d.ts.map +1 -1
  50. package/funcs/integrationsWebhooksRetrieve.js +1 -0
  51. package/funcs/integrationsWebhooksRetrieve.js.map +1 -1
  52. package/funcs/messagesDelete.d.ts.map +1 -1
  53. package/funcs/messagesDelete.js +1 -0
  54. package/funcs/messagesDelete.js.map +1 -1
  55. package/funcs/messagesDeleteByTransactionId.d.ts.map +1 -1
  56. package/funcs/messagesDeleteByTransactionId.js +1 -0
  57. package/funcs/messagesDeleteByTransactionId.js.map +1 -1
  58. package/funcs/messagesRetrieve.d.ts.map +1 -1
  59. package/funcs/messagesRetrieve.js +1 -0
  60. package/funcs/messagesRetrieve.js.map +1 -1
  61. package/funcs/notificationsList.d.ts.map +1 -1
  62. package/funcs/notificationsList.js +2 -0
  63. package/funcs/notificationsList.js.map +1 -1
  64. package/funcs/notificationsRetrieve.d.ts.map +1 -1
  65. package/funcs/notificationsRetrieve.js +1 -0
  66. package/funcs/notificationsRetrieve.js.map +1 -1
  67. package/funcs/notificationsStatsGraph.d.ts.map +1 -1
  68. package/funcs/notificationsStatsGraph.js +1 -0
  69. package/funcs/notificationsStatsGraph.js.map +1 -1
  70. package/funcs/notificationsStatsRetrieve.d.ts.map +1 -1
  71. package/funcs/notificationsStatsRetrieve.js +1 -0
  72. package/funcs/notificationsStatsRetrieve.js.map +1 -1
  73. package/funcs/subscribersAuthenticationChatAccessOauth.d.ts.map +1 -1
  74. package/funcs/subscribersAuthenticationChatAccessOauth.js +1 -0
  75. package/funcs/subscribersAuthenticationChatAccessOauth.js.map +1 -1
  76. package/funcs/subscribersAuthenticationChatAccessOauthCallBack.d.ts.map +1 -1
  77. package/funcs/subscribersAuthenticationChatAccessOauthCallBack.js +1 -0
  78. package/funcs/subscribersAuthenticationChatAccessOauthCallBack.js.map +1 -1
  79. package/funcs/subscribersCreate.d.ts.map +1 -1
  80. package/funcs/subscribersCreate.js +2 -1
  81. package/funcs/subscribersCreate.js.map +1 -1
  82. package/funcs/subscribersCreateBulk.d.ts.map +1 -1
  83. package/funcs/subscribersCreateBulk.js +1 -0
  84. package/funcs/subscribersCreateBulk.js.map +1 -1
  85. package/funcs/subscribersCredentialsAppend.d.ts.map +1 -1
  86. package/funcs/subscribersCredentialsAppend.js +1 -0
  87. package/funcs/subscribersCredentialsAppend.js.map +1 -1
  88. package/funcs/subscribersCredentialsDelete.d.ts.map +1 -1
  89. package/funcs/subscribersCredentialsDelete.js +1 -0
  90. package/funcs/subscribersCredentialsDelete.js.map +1 -1
  91. package/funcs/subscribersCredentialsUpdate.d.ts.map +1 -1
  92. package/funcs/subscribersCredentialsUpdate.js +1 -0
  93. package/funcs/subscribersCredentialsUpdate.js.map +1 -1
  94. package/funcs/subscribersDelete.d.ts.map +1 -1
  95. package/funcs/subscribersDelete.js +1 -0
  96. package/funcs/subscribersDelete.js.map +1 -1
  97. package/funcs/subscribersList.d.ts.map +1 -1
  98. package/funcs/subscribersList.js +1 -0
  99. package/funcs/subscribersList.js.map +1 -1
  100. package/funcs/subscribersMessagesMarkAll.d.ts.map +1 -1
  101. package/funcs/subscribersMessagesMarkAll.js +1 -0
  102. package/funcs/subscribersMessagesMarkAll.js.map +1 -1
  103. package/funcs/subscribersMessagesMarkAllAs.d.ts.map +1 -1
  104. package/funcs/subscribersMessagesMarkAllAs.js +1 -0
  105. package/funcs/subscribersMessagesMarkAllAs.js.map +1 -1
  106. package/funcs/subscribersMessagesUpdateAsSeen.d.ts.map +1 -1
  107. package/funcs/subscribersMessagesUpdateAsSeen.js +1 -0
  108. package/funcs/subscribersMessagesUpdateAsSeen.js.map +1 -1
  109. package/funcs/subscribersNotificationsFeed.d.ts.map +1 -1
  110. package/funcs/subscribersNotificationsFeed.js +1 -0
  111. package/funcs/subscribersNotificationsFeed.js.map +1 -1
  112. package/funcs/subscribersNotificationsUnseenCount.d.ts.map +1 -1
  113. package/funcs/subscribersNotificationsUnseenCount.js +1 -0
  114. package/funcs/subscribersNotificationsUnseenCount.js.map +1 -1
  115. package/funcs/subscribersPatch.d.ts.map +1 -1
  116. package/funcs/subscribersPatch.js +1 -0
  117. package/funcs/subscribersPatch.js.map +1 -1
  118. package/funcs/subscribersPreferencesList.d.ts.map +1 -1
  119. package/funcs/subscribersPreferencesList.js +1 -0
  120. package/funcs/subscribersPreferencesList.js.map +1 -1
  121. package/funcs/subscribersPreferencesUpdate.d.ts.map +1 -1
  122. package/funcs/subscribersPreferencesUpdate.js +1 -0
  123. package/funcs/subscribersPreferencesUpdate.js.map +1 -1
  124. package/funcs/subscribersPropertiesUpdateOnlineFlag.d.ts.map +1 -1
  125. package/funcs/subscribersPropertiesUpdateOnlineFlag.js +1 -0
  126. package/funcs/subscribersPropertiesUpdateOnlineFlag.js.map +1 -1
  127. package/funcs/subscribersRetrieve.d.ts.map +1 -1
  128. package/funcs/subscribersRetrieve.js +1 -0
  129. package/funcs/subscribersRetrieve.js.map +1 -1
  130. package/funcs/subscribersSearch.d.ts.map +1 -1
  131. package/funcs/subscribersSearch.js +1 -0
  132. package/funcs/subscribersSearch.js.map +1 -1
  133. package/funcs/topicsCreate.d.ts.map +1 -1
  134. package/funcs/topicsCreate.js +1 -0
  135. package/funcs/topicsCreate.js.map +1 -1
  136. package/funcs/topicsDelete.d.ts.map +1 -1
  137. package/funcs/topicsDelete.js +1 -0
  138. package/funcs/topicsDelete.js.map +1 -1
  139. package/funcs/topicsList.d.ts.map +1 -1
  140. package/funcs/topicsList.js +1 -0
  141. package/funcs/topicsList.js.map +1 -1
  142. package/funcs/topicsRename.d.ts.map +1 -1
  143. package/funcs/topicsRename.js +1 -0
  144. package/funcs/topicsRename.js.map +1 -1
  145. package/funcs/topicsRetrieve.d.ts.map +1 -1
  146. package/funcs/topicsRetrieve.js +1 -0
  147. package/funcs/topicsRetrieve.js.map +1 -1
  148. package/funcs/topicsSubscribersAssign.d.ts.map +1 -1
  149. package/funcs/topicsSubscribersAssign.js +1 -0
  150. package/funcs/topicsSubscribersAssign.js.map +1 -1
  151. package/funcs/topicsSubscribersRemove.d.ts.map +1 -1
  152. package/funcs/topicsSubscribersRemove.js +1 -0
  153. package/funcs/topicsSubscribersRemove.js.map +1 -1
  154. package/funcs/topicsSubscribersRetrieve.d.ts.map +1 -1
  155. package/funcs/topicsSubscribersRetrieve.js +1 -0
  156. package/funcs/topicsSubscribersRetrieve.js.map +1 -1
  157. package/funcs/trigger.d.ts.map +1 -1
  158. package/funcs/trigger.js +1 -0
  159. package/funcs/trigger.js.map +1 -1
  160. package/funcs/triggerBroadcast.d.ts.map +1 -1
  161. package/funcs/triggerBroadcast.js +1 -0
  162. package/funcs/triggerBroadcast.js.map +1 -1
  163. package/funcs/triggerBulk.d.ts.map +1 -1
  164. package/funcs/triggerBulk.js +1 -0
  165. package/funcs/triggerBulk.js.map +1 -1
  166. package/funcs/workflowsCreate.d.ts.map +1 -1
  167. package/funcs/workflowsCreate.js +1 -0
  168. package/funcs/workflowsCreate.js.map +1 -1
  169. package/funcs/workflowsDelete.d.ts.map +1 -1
  170. package/funcs/workflowsDelete.js +1 -0
  171. package/funcs/workflowsDelete.js.map +1 -1
  172. package/funcs/workflowsGetStepData.d.ts.map +1 -1
  173. package/funcs/workflowsGetStepData.js +1 -0
  174. package/funcs/workflowsGetStepData.js.map +1 -1
  175. package/funcs/workflowsGetWorkflowTestData.d.ts.map +1 -1
  176. package/funcs/workflowsGetWorkflowTestData.js +1 -0
  177. package/funcs/workflowsGetWorkflowTestData.js.map +1 -1
  178. package/funcs/workflowsRetrieve.d.ts.map +1 -1
  179. package/funcs/workflowsRetrieve.js +1 -0
  180. package/funcs/workflowsRetrieve.js.map +1 -1
  181. package/funcs/workflowsUpdate.d.ts.map +1 -1
  182. package/funcs/workflowsUpdate.js +1 -0
  183. package/funcs/workflowsUpdate.js.map +1 -1
  184. package/funcs/workflowsWorkflowControllerGeneratePreview.d.ts.map +1 -1
  185. package/funcs/workflowsWorkflowControllerGeneratePreview.js +1 -0
  186. package/funcs/workflowsWorkflowControllerGeneratePreview.js.map +1 -1
  187. package/funcs/workflowsWorkflowControllerPatchWorkflow.d.ts.map +1 -1
  188. package/funcs/workflowsWorkflowControllerPatchWorkflow.js +1 -0
  189. package/funcs/workflowsWorkflowControllerPatchWorkflow.js.map +1 -1
  190. package/funcs/workflowsWorkflowControllerPatchWorkflowStepData.d.ts.map +1 -1
  191. package/funcs/workflowsWorkflowControllerPatchWorkflowStepData.js +1 -0
  192. package/funcs/workflowsWorkflowControllerPatchWorkflowStepData.js.map +1 -1
  193. package/funcs/workflowsWorkflowControllerSearchWorkflows.d.ts.map +1 -1
  194. package/funcs/workflowsWorkflowControllerSearchWorkflows.js +1 -0
  195. package/funcs/workflowsWorkflowControllerSearchWorkflows.js.map +1 -1
  196. package/funcs/workflowsWorkflowControllerSync.d.ts.map +1 -1
  197. package/funcs/workflowsWorkflowControllerSync.js +1 -0
  198. package/funcs/workflowsWorkflowControllerSync.js.map +1 -1
  199. package/hooks/types.d.ts +1 -0
  200. package/hooks/types.d.ts.map +1 -1
  201. package/lib/config.d.ts +2 -2
  202. package/lib/config.js +2 -2
  203. package/lib/security.d.ts.map +1 -1
  204. package/lib/security.js.map +1 -1
  205. package/models/components/activitynotificationtemplateresponsedto.d.ts +6 -0
  206. package/models/components/activitynotificationtemplateresponsedto.d.ts.map +1 -1
  207. package/models/components/activitynotificationtemplateresponsedto.js +3 -0
  208. package/models/components/activitynotificationtemplateresponsedto.js.map +1 -1
  209. package/models/components/createsubscriberrequestdto.d.ts +28 -50
  210. package/models/components/createsubscriberrequestdto.d.ts.map +1 -1
  211. package/models/components/createsubscriberrequestdto.js +17 -41
  212. package/models/components/createsubscriberrequestdto.js.map +1 -1
  213. package/models/components/getenvironmenttagsdto.d.ts +29 -0
  214. package/models/components/getenvironmenttagsdto.d.ts.map +1 -0
  215. package/models/components/getenvironmenttagsdto.js +59 -0
  216. package/models/components/getenvironmenttagsdto.js.map +1 -0
  217. package/models/components/index.d.ts +1 -0
  218. package/models/components/index.d.ts.map +1 -1
  219. package/models/components/index.js +1 -0
  220. package/models/components/index.js.map +1 -1
  221. package/models/components/patchsubscriberrequestdto.d.ts +0 -5
  222. package/models/components/patchsubscriberrequestdto.d.ts.map +1 -1
  223. package/models/components/patchsubscriberrequestdto.js +0 -2
  224. package/models/components/patchsubscriberrequestdto.js.map +1 -1
  225. package/models/components/sessiongeneratedresponsedto.d.ts +32 -0
  226. package/models/components/sessiongeneratedresponsedto.d.ts.map +1 -0
  227. package/models/components/sessiongeneratedresponsedto.js +59 -0
  228. package/models/components/sessiongeneratedresponsedto.js.map +1 -0
  229. package/models/components/subscriberpayloaddto.d.ts +5 -0
  230. package/models/components/subscriberpayloaddto.d.ts.map +1 -1
  231. package/models/components/subscriberpayloaddto.js +2 -0
  232. package/models/components/subscriberpayloaddto.js.map +1 -1
  233. package/models/components/triggereventresponsedto.d.ts +3 -0
  234. package/models/components/triggereventresponsedto.d.ts.map +1 -1
  235. package/models/components/triggereventresponsedto.js +1 -0
  236. package/models/components/triggereventresponsedto.js.map +1 -1
  237. package/models/components/workfloworiginenum.d.ts +37 -0
  238. package/models/components/workfloworiginenum.d.ts.map +1 -0
  239. package/models/components/workfloworiginenum.js +54 -0
  240. package/models/components/workfloworiginenum.js.map +1 -0
  241. package/models/operations/environmentscontrollergeneratesession.d.ts +66 -0
  242. package/models/operations/environmentscontrollergeneratesession.d.ts.map +1 -0
  243. package/models/operations/environmentscontrollergeneratesession.js +110 -0
  244. package/models/operations/environmentscontrollergeneratesession.js.map +1 -0
  245. package/models/operations/environmentscontrollergetenvironmenttags.d.ts +66 -0
  246. package/models/operations/environmentscontrollergetenvironmenttags.d.ts.map +1 -0
  247. package/models/operations/environmentscontrollergetenvironmenttags.js +110 -0
  248. package/models/operations/environmentscontrollergetenvironmenttags.js.map +1 -0
  249. package/models/operations/notificationscontrollerlistnotifications.d.ts +5 -0
  250. package/models/operations/notificationscontrollerlistnotifications.d.ts.map +1 -1
  251. package/models/operations/notificationscontrollerlistnotifications.js +2 -0
  252. package/models/operations/notificationscontrollerlistnotifications.js.map +1 -1
  253. package/package.json +1 -1
  254. package/react-query/environmentsGenerateSession.d.ts +18 -0
  255. package/react-query/environmentsGenerateSession.d.ts.map +1 -0
  256. package/react-query/environmentsGenerateSession.js +41 -0
  257. package/react-query/environmentsGenerateSession.js.map +1 -0
  258. package/react-query/environmentsRetrieve.d.ts +30 -0
  259. package/react-query/environmentsRetrieve.d.ts.map +1 -0
  260. package/react-query/environmentsRetrieve.js +70 -0
  261. package/react-query/environmentsRetrieve.js.map +1 -0
  262. package/react-query/notificationsList.d.ts +3 -0
  263. package/react-query/notificationsList.d.ts.map +1 -1
  264. package/react-query/notificationsList.js +1 -0
  265. package/react-query/notificationsList.js.map +1 -1
  266. package/sdk/environments.d.ts +13 -0
  267. package/sdk/environments.d.ts.map +1 -0
  268. package/sdk/environments.js +26 -0
  269. package/sdk/environments.js.map +1 -0
  270. package/sources/json-development.json +32352 -0
  271. package/src/funcs/cancel.ts +1 -0
  272. package/src/funcs/integrationsCreate.ts +1 -0
  273. package/src/funcs/integrationsDelete.ts +1 -0
  274. package/src/funcs/integrationsList.ts +1 -0
  275. package/src/funcs/integrationsListActive.ts +1 -0
  276. package/src/funcs/integrationsSetAsPrimary.ts +1 -0
  277. package/src/funcs/integrationsUpdate.ts +1 -0
  278. package/src/funcs/integrationsWebhooksRetrieve.ts +1 -0
  279. package/src/funcs/messagesDelete.ts +1 -0
  280. package/src/funcs/messagesDeleteByTransactionId.ts +1 -0
  281. package/src/funcs/messagesRetrieve.ts +1 -0
  282. package/src/funcs/notificationsList.ts +2 -0
  283. package/src/funcs/notificationsRetrieve.ts +1 -0
  284. package/src/funcs/notificationsStatsGraph.ts +1 -0
  285. package/src/funcs/notificationsStatsRetrieve.ts +1 -0
  286. package/src/funcs/subscribersAuthenticationChatAccessOauth.ts +1 -0
  287. package/src/funcs/subscribersAuthenticationChatAccessOauthCallBack.ts +1 -0
  288. package/src/funcs/subscribersCreate.ts +2 -1
  289. package/src/funcs/subscribersCreateBulk.ts +1 -0
  290. package/src/funcs/subscribersCredentialsAppend.ts +1 -0
  291. package/src/funcs/subscribersCredentialsDelete.ts +1 -0
  292. package/src/funcs/subscribersCredentialsUpdate.ts +1 -0
  293. package/src/funcs/subscribersDelete.ts +1 -0
  294. package/src/funcs/subscribersList.ts +1 -0
  295. package/src/funcs/subscribersMessagesMarkAll.ts +1 -0
  296. package/src/funcs/subscribersMessagesMarkAllAs.ts +1 -0
  297. package/src/funcs/subscribersMessagesUpdateAsSeen.ts +1 -0
  298. package/src/funcs/subscribersNotificationsFeed.ts +1 -0
  299. package/src/funcs/subscribersNotificationsUnseenCount.ts +1 -0
  300. package/src/funcs/subscribersPatch.ts +1 -0
  301. package/src/funcs/subscribersPreferencesList.ts +1 -0
  302. package/src/funcs/subscribersPreferencesUpdate.ts +1 -0
  303. package/src/funcs/subscribersPropertiesUpdateOnlineFlag.ts +1 -0
  304. package/src/funcs/subscribersRetrieve.ts +1 -0
  305. package/src/funcs/subscribersSearch.ts +1 -0
  306. package/src/funcs/topicsCreate.ts +1 -0
  307. package/src/funcs/topicsDelete.ts +1 -0
  308. package/src/funcs/topicsList.ts +1 -0
  309. package/src/funcs/topicsRename.ts +1 -0
  310. package/src/funcs/topicsRetrieve.ts +1 -0
  311. package/src/funcs/topicsSubscribersAssign.ts +1 -0
  312. package/src/funcs/topicsSubscribersRemove.ts +1 -0
  313. package/src/funcs/topicsSubscribersRetrieve.ts +1 -0
  314. package/src/funcs/trigger.ts +1 -0
  315. package/src/funcs/triggerBroadcast.ts +1 -0
  316. package/src/funcs/triggerBulk.ts +1 -0
  317. package/src/funcs/workflowsCreate.ts +1 -0
  318. package/src/funcs/workflowsDelete.ts +1 -0
  319. package/src/funcs/workflowsGetStepData.ts +1 -0
  320. package/src/funcs/workflowsGetWorkflowTestData.ts +1 -0
  321. package/src/funcs/workflowsRetrieve.ts +1 -0
  322. package/src/funcs/workflowsUpdate.ts +1 -0
  323. package/src/funcs/workflowsWorkflowControllerGeneratePreview.ts +1 -0
  324. package/src/funcs/workflowsWorkflowControllerPatchWorkflow.ts +1 -0
  325. package/src/funcs/workflowsWorkflowControllerPatchWorkflowStepData.ts +1 -0
  326. package/src/funcs/workflowsWorkflowControllerSearchWorkflows.ts +1 -0
  327. package/src/funcs/workflowsWorkflowControllerSync.ts +1 -0
  328. package/src/hooks/types.ts +1 -0
  329. package/src/lib/config.ts +2 -2
  330. package/src/lib/security.ts +0 -1
  331. package/src/models/components/activitynotificationtemplateresponsedto.ts +12 -0
  332. package/src/models/components/createsubscriberrequestdto.ts +41 -111
  333. package/src/models/components/index.ts +1 -0
  334. package/src/models/components/patchsubscriberrequestdto.ts +0 -7
  335. package/src/models/components/subscriberpayloaddto.ts +7 -0
  336. package/src/models/components/triggereventresponsedto.ts +1 -0
  337. package/src/models/components/workfloworiginenum.ts +40 -0
  338. package/src/models/operations/notificationscontrollerlistnotifications.ts +7 -0
  339. package/src/react-query/notificationsList.ts +4 -0
package/FUNCTIONS.md ADDED
@@ -0,0 +1,124 @@
1
+ # Standalone Functions
2
+
3
+ > [!NOTE]
4
+ > This section is useful if you are using a bundler and targetting browsers and
5
+ > runtimes where the size of an application affects performance and load times.
6
+
7
+ Every method in this SDK is also available as a standalone function. This
8
+ alternative API is suitable when targetting the browser or serverless runtimes
9
+ and using a bundler to build your application since all unused functionality
10
+ will be tree-shaken away. This includes code for unused methods, Zod schemas,
11
+ encoding helpers and response handlers. The result is dramatically smaller
12
+ impact on the application's final bundle size which grows very slowly as you use
13
+ more and more functionality from this SDK.
14
+
15
+ Calling methods through the main SDK class remains a valid and generally more
16
+ more ergonomic option. Standalone functions represent an optimisation for a
17
+ specific category of applications.
18
+
19
+ ## Example
20
+
21
+ ```typescript
22
+ import { NovuCore } from "@novu/api/core.js";
23
+ import { trigger } from "@novu/api/funcs/trigger.js";
24
+ import { SDKValidationError } from "@novu/api/models/errors/sdkvalidationerror.js";
25
+
26
+ // Use `NovuCore` for best tree-shaking performance.
27
+ // You can create one instance of it to use across an application.
28
+ const novu = new NovuCore({
29
+ security: {
30
+ secretKey: "YOUR_SECRET_KEY_HERE",
31
+ },
32
+ });
33
+
34
+ async function run() {
35
+ const res = await trigger(novu, {
36
+ workflowId: "workflow_identifier",
37
+ payload: {
38
+ "comment_id": "string",
39
+ "post": {
40
+ "text": "string",
41
+ },
42
+ },
43
+ overrides: {
44
+ "fcm": {
45
+ "data": {
46
+ "key": "value",
47
+ },
48
+ },
49
+ },
50
+ to: {
51
+ subscriberId: "<id>",
52
+ },
53
+ });
54
+
55
+ switch (true) {
56
+ case res.ok:
57
+ // The success case will be handled outside of the switch block
58
+ break;
59
+ case res.error instanceof SDKValidationError:
60
+ // Pretty-print validation errors.
61
+ return console.log(res.error.pretty());
62
+ case res.error instanceof Error:
63
+ return console.log(res.error);
64
+ default:
65
+ // TypeScript's type checking will fail on the following line if the above
66
+ // cases were not exhaustive.
67
+ res.error satisfies never;
68
+ throw new Error("Assertion failed: expected error checks to be exhaustive: " + res.error);
69
+ }
70
+
71
+
72
+ const { value: result } = res;
73
+
74
+ // Handle the result
75
+ console.log(result);
76
+ }
77
+
78
+ run();
79
+ ```
80
+
81
+ ## Result types
82
+
83
+ Standalone functions differ from SDK methods in that they return a
84
+ `Result<Value, Error>` type to capture _known errors_ and document them using
85
+ the type system. By avoiding throwing errors, application code maintains clear
86
+ control flow and error-handling become part of the regular flow of application
87
+ code.
88
+
89
+ > We use the term "known errors" because standalone functions, and JavaScript
90
+ > code in general, can still throw unexpected errors such as `TypeError`s,
91
+ > `RangeError`s and `DOMException`s. Exhaustively catching all errors may be
92
+ > something this SDK addresses in the future. Nevertheless, there is still a lot
93
+ > of benefit from capturing most errors and turning them into values.
94
+
95
+ The second reason for this style of programming is because these functions will
96
+ typically be used in front-end applications where exception throwing is
97
+ sometimes discouraged or considered unidiomatic. React and similar ecosystems
98
+ and libraries tend to promote this style of programming so that components
99
+ render useful content under all states (loading, success, error and so on).
100
+
101
+ The general pattern when calling standalone functions looks like this:
102
+
103
+ ```typescript
104
+ import { Core } from "<sdk-package-name>";
105
+ import { fetchSomething } from "<sdk-package-name>/funcs/fetchSomething.js";
106
+
107
+ const client = new Core();
108
+
109
+ async function run() {
110
+ const result = await fetchSomething(client, { id: "123" });
111
+ if (!result.ok) {
112
+ // You can throw the error or handle it. It's your choice now.
113
+ throw result.error;
114
+ }
115
+
116
+ console.log(result.value);
117
+ }
118
+
119
+ run();
120
+ ```
121
+
122
+ Notably, `result.error` above will have an explicit type compared to a try-catch
123
+ variation where the error in the catch block can only be of type `unknown` (or
124
+ `any` depending on your TypeScript settings).
package/REACT_QUERY.md ADDED
@@ -0,0 +1,354 @@
1
+ # React hooks
2
+
3
+ This SDK provides React hooks and utilies for making queries and mutations that
4
+ can take the pain out of building front-end applications for the web or React
5
+ Native.
6
+
7
+ They are built as a thin wrapper around [TanStack Query for React v5][rq], a
8
+ powerful, asynchronous state management library. A good understanding of that
9
+ library will be very helpful while using them. In addition to hooks, there are
10
+ several helper functions that can be used for cache management and data fetching
11
+ during server-rendering and in React Server Components.
12
+
13
+ ## Getting started
14
+
15
+ To get started using React hooks, you will need to inject TanStack query and an
16
+ SDK instance into your application. Typically, this will be done high up in
17
+ your React app at the root or layout component. For example:
18
+
19
+ ```tsx
20
+ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
21
+ import { NovuCore } from "@novu/api";
22
+ import { NovuProvider } from "@novu/api/react-query";
23
+
24
+ const queryClient = new QueryClient();
25
+ const novu = new NovuCore({
26
+ security: {
27
+ secretKey: "YOUR_SECRET_KEY_HERE",
28
+ },
29
+ });
30
+
31
+ // Retries are handled by the underlying SDK.
32
+ queryClient.setQueryDefaults(["@novu/api"], { retry: false });
33
+ queryClient.setMutationDefaults(["@novu/api"], { retry: false });
34
+
35
+ export function App() {
36
+ return (
37
+ <QueryClientProvider client={queryClient}>
38
+ <NovuProvider client={novu}>
39
+ {/* Your app logic starts here */}
40
+ </NovuProvider>
41
+ </QueryClientProvider>
42
+ );
43
+ }
44
+ ```
45
+
46
+ ## Queries
47
+
48
+ Query hooks are the basic building block for fetching data. In addition to
49
+ request data, they take the same options as the [`useQuery` hook][use-query]
50
+ from TanStack Query.
51
+
52
+ [use-query]: https://tanstack.com/query/v5/docs/framework/react/reference/useQuery
53
+
54
+ ```tsx
55
+ import { useNotificationsList } from "@novu/api/react-query/notificationsList.js";
56
+
57
+ export function Example() {
58
+ const { data, error, status } = useNotificationsList({});
59
+
60
+ // Render the UI here...
61
+ }
62
+ ```
63
+
64
+ ### Query timeouts and retries
65
+
66
+ Since the underlying SDK handles request timeouts and retries, there are a few
67
+ more options provided by the query hooks to control these behaviors.
68
+
69
+ ```tsx
70
+ import { useState } from "react";
71
+ import { useNotificationsList } from "@novu/api/react-query/notificationsList.js";
72
+
73
+ export function ExampleWithOptions() {
74
+ const [enabled, setEnabled] = useState(true);
75
+ const { data, error, status } = useNotificationsList(
76
+ {},
77
+ {
78
+ // TanStack Query options:
79
+ enabled,
80
+ staleTime: 60 * 1000, // 1 minute
81
+ gcTime: 5 * 60 * 1000, // 5 minutes
82
+
83
+ // Request options for the underlying API call:
84
+ timeoutMs: 1000,
85
+ retryCodes: ["5XX"],
86
+ retries: {
87
+ strategy: "backoff",
88
+ backoff: {
89
+ initialInterval: 500,
90
+ maxInterval: 10 * 1000, // 10 seconds
91
+ exponent: 1.5,
92
+ maxElapsedTime: 60 * 1000, // 1 minute
93
+ },
94
+ },
95
+ }
96
+ );
97
+
98
+ // Render the UI here...
99
+ }
100
+ ```
101
+
102
+
103
+ ## Mutations
104
+
105
+ Operations that can have side-effects in this SDK are exposed as mutation hooks.
106
+ These can be integrated into HTML forms to submit data to the API. They also
107
+ take the same options as the [`useMutation` hook][use-mutation] from TanStack
108
+ Query.
109
+
110
+ [use-mutation]: https://tanstack.com/query/v5/docs/framework/react/reference/useMutation
111
+
112
+ ```tsx
113
+ import { useTriggerMutation } from "@novu/api/react-query/trigger.js";
114
+
115
+ export function Example() {
116
+ const { mutate, status } = useTriggerMutation();
117
+
118
+ return (
119
+ <form
120
+ onSubmit={(e) => {
121
+ e.preventDefault();
122
+
123
+ // Read form data here...
124
+
125
+ mutate({
126
+ workflowId: "workflow_identifier",
127
+ payload: {
128
+ "comment_id": "string",
129
+ "post": {
130
+ "text": "string",
131
+ },
132
+ },
133
+ overrides: {
134
+ "fcm": {
135
+ "data": {
136
+ "key": "value",
137
+ },
138
+ },
139
+ },
140
+ to: {
141
+ subscriberId: "<id>",
142
+ },
143
+ });
144
+ }}
145
+ >
146
+ {/* Form fields go here... */}
147
+ <button type="submit" disabled={status === "pending"}>Submit</button>
148
+ </form>
149
+ );
150
+ }
151
+ ```
152
+
153
+ ### Mutation timeouts and retries
154
+
155
+ Since the underlying SDK handles request timeouts and retries, there are a few
156
+ more options provided by the mutation hooks to control these behaviors.
157
+
158
+ ```tsx
159
+ import { useTriggerMutation } from "@novu/api/react-query/trigger.js";
160
+
161
+ export function ExampleWithOptions() {
162
+ const { mutate, status } = useTriggerMutation({
163
+ // TanStack Query options:
164
+ networkMode: "online",
165
+ gcTime: 5 * 60 * 1000, // 5 minutes
166
+
167
+ // Request options for the underlying API call:
168
+ timeoutMs: 1000,
169
+ retryCodes: ["5XX"],
170
+ retries: {
171
+ strategy: "backoff",
172
+ backoff: {
173
+ initialInterval: 500,
174
+ maxInterval: 10 * 1000, // 10 seconds
175
+ exponent: 1.5,
176
+ maxElapsedTime: 60 * 1000, // 1 minute
177
+ },
178
+ },
179
+ });
180
+
181
+ // Render the UI here...
182
+ }
183
+ ```
184
+
185
+
186
+ ## Cache invalidation
187
+
188
+ In many instances, triggering a mutation hook requires invalidating specific
189
+ query data currently residing in the TanStack Query's cache. Alongside every
190
+ query hook there are two functions that help invalidate cached data:
191
+
192
+ ```tsx
193
+ import { useQueryClient } from "@tanstack/react-query";
194
+ import { invalidateNotificationsList, invalidateAllNotificationsList } from "@novu/api/react-query/notificationsList.js";
195
+ // Replace this with a real mutation
196
+ import { useExampleMutation } from "@novu/api/react-query/example.js";
197
+
198
+ export function Example() {
199
+ const { queryClient } = useQueryClient();
200
+ const { mutate, status } = useExampleMutation();
201
+
202
+ return (
203
+ <form
204
+ onSubmit={(e) => {
205
+ e.preventDefault();
206
+
207
+ const formData = new FormData(e.target);
208
+
209
+ mutate(formData, {
210
+ onSuccess: () => {
211
+ // Invalidate a single cache entry:
212
+ invalidateNotificationsList(queryClient, /* ... arguments ... */);
213
+ // OR, invalidate all cache entries for the query targets:
214
+ invalidateAllNotificationsList(queryClient);
215
+ },
216
+ });
217
+ }}
218
+ >
219
+ {/* Form fields go here... */}
220
+
221
+ <button type="submit" disabled={status === "pending"}>Submit</button>
222
+ </form>
223
+ );
224
+ }
225
+ ```
226
+
227
+
228
+ ## Pagination
229
+
230
+ Certain queries may have pagination enabled if the underlying API supports it.
231
+ In these cases, additional "infinite" query hooks are exposed to help build
232
+ infinite scrolling and "load more" user interfaces.
233
+
234
+ > [!NOTE]
235
+ >
236
+ > The original query hooks will still be available and if you are building a
237
+ > more explicit pagination UI with page numbers and next/previous buttons then
238
+ > those hooks may be more suitable.
239
+
240
+ ```tsx
241
+ import { useSubscribersListInfinite } from "@novu/api/react-query/subscribersList.js";
242
+
243
+ export function Example() {
244
+ const { data, error, status, fetchNextPage, hasNextPage } = useSubscribersListInfinite();
245
+
246
+ return (
247
+ <div>
248
+ {/* Render pages here... */}
249
+
250
+ {hasNextPage ? (
251
+ <div>
252
+ <button onClick={() => fetchNextPage()}>Load more</button>
253
+ </div>
254
+ ) : null}
255
+ </div>
256
+ );
257
+ }
258
+ ```
259
+
260
+
261
+ ## Integration with React Suspense
262
+
263
+ TanStack Query predates React Suspense and out of the box it does a great job at
264
+ exposing the lifecycle of asynchronous tasks. However, if you are already using
265
+ Suspense in your app, the default hooks will not trigger suspense boundaries.
266
+ This is why the library and, by extension, this SDK also provide equivalent
267
+ hooks that integrate neatly with React Suspense.
268
+
269
+ ```tsx
270
+ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
271
+ import { ErrorBoundary } from "react-error-boundary";
272
+
273
+ import { NovuCore } from "@novu/api";
274
+ import { NovuProvider } from "@novu/api/react-query";
275
+ import { useNotificationsListSuspense } from "@novu/api/react-query/notificationsList.js";
276
+
277
+ const queryClient = new QueryClient();
278
+ const novu = new NovuCore({
279
+ security: {
280
+ secretKey: "YOUR_SECRET_KEY_HERE",
281
+ },
282
+ });
283
+
284
+ export function App() {
285
+ return (
286
+ <QueryClientProvider client={queryClient}>
287
+ <NovuProvider client={novu}>
288
+ <QueryErrorResetBoundary>
289
+ {({ reset }) => (
290
+ <ErrorBoundary
291
+ fallbackRender={({ error, resetErrorBoundary }) => (
292
+ <div>
293
+ There was an error!{' '}
294
+ <Button onClick={() => resetErrorBoundary()}>Try again</Button>
295
+ <pre>{error.message}</pre>
296
+ </div>
297
+ )}
298
+ onReset={reset}
299
+ >
300
+ <React.Suspense fallback={<h1>Loading...</h1>}>
301
+ <Example />
302
+ </React.Suspense>
303
+ </ErrorBoundary>
304
+ )}
305
+ </QueryErrorResetBoundary>
306
+ </NovuProvider>
307
+ </QueryClientProvider>
308
+ );
309
+ }
310
+
311
+ function Example() {
312
+ const { data } = useNotificationsListSuspense({});
313
+
314
+ // Render the UI here...
315
+ }
316
+ ```
317
+
318
+
319
+ ## Server-rendering and React Server Components
320
+
321
+ Query hooks are also side-loaded with prefetch helper functions. These functions
322
+ can be used to fetch data from the API during server-rendering and in React
323
+ Server Components so that it can be available immediately on page load to any
324
+ components that use the corresponding hooks:
325
+ ```tsx
326
+ import {
327
+ dehydrate,
328
+ HydrationBoundary,
329
+ QueryClient,
330
+ } from "@tanstack/react-query";
331
+ import { NovuCore } from "@novu/api";
332
+ import { prefetchNotificationsList } from "@novu/api/react-query/notificationsList.js";
333
+
334
+ export default async function Page() {
335
+ const queryClient = new QueryClient();
336
+ const novu = new NovuCore({
337
+ security: {
338
+ secretKey: "YOUR_SECRET_KEY_HERE",
339
+ },
340
+ });
341
+
342
+ await prefetchNotificationsList(queryClient, novu, {});
343
+
344
+ return (
345
+ // HydrationBoundary is a Client Component, so hydration will happen there.
346
+ <HydrationBoundary state={dehydrate(queryClient)}>
347
+ {/* Client components under this point will also have data on page load. */}
348
+ </HydrationBoundary>
349
+ );
350
+ }
351
+ ```
352
+
353
+
354
+ [rq]: https://tanstack.com/query/v5/docs/framework/react/overview