@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.
- package/FUNCTIONS.md +124 -0
- package/REACT_QUERY.md +354 -0
- package/README.md +1032 -0
- package/docs/sdks/authentication/README.md +247 -0
- package/docs/sdks/credentials/README.md +372 -0
- package/docs/sdks/integrations/README.md +631 -0
- package/docs/sdks/messages/README.md +318 -0
- package/docs/sdks/notifications/README.md +226 -0
- package/docs/sdks/novu/README.md +598 -0
- package/docs/sdks/novumessages/README.md +329 -0
- package/docs/sdks/novunotifications/README.md +235 -0
- package/docs/sdks/novusubscribers/README.md +340 -0
- package/docs/sdks/preferences/README.md +221 -0
- package/docs/sdks/properties/README.md +111 -0
- package/docs/sdks/stats/README.md +226 -0
- package/docs/sdks/subscribers/README.md +763 -0
- package/docs/sdks/topics/README.md +541 -0
- package/docs/sdks/webhooks/README.md +117 -0
- package/docs/sdks/workflows/README.md +1123 -0
- package/funcs/cancel.d.ts.map +1 -1
- package/funcs/cancel.js +1 -0
- package/funcs/cancel.js.map +1 -1
- package/funcs/environmentsGenerateSession.d.ts +10 -0
- package/funcs/environmentsGenerateSession.d.ts.map +1 -0
- package/funcs/environmentsGenerateSession.js +131 -0
- package/funcs/environmentsGenerateSession.js.map +1 -0
- package/funcs/environmentsRetrieve.d.ts +10 -0
- package/funcs/environmentsRetrieve.d.ts.map +1 -0
- package/funcs/environmentsRetrieve.js +131 -0
- package/funcs/environmentsRetrieve.js.map +1 -0
- package/funcs/integrationsCreate.d.ts.map +1 -1
- package/funcs/integrationsCreate.js +1 -0
- package/funcs/integrationsCreate.js.map +1 -1
- package/funcs/integrationsDelete.d.ts.map +1 -1
- package/funcs/integrationsDelete.js +1 -0
- package/funcs/integrationsDelete.js.map +1 -1
- package/funcs/integrationsList.d.ts.map +1 -1
- package/funcs/integrationsList.js +1 -0
- package/funcs/integrationsList.js.map +1 -1
- package/funcs/integrationsListActive.d.ts.map +1 -1
- package/funcs/integrationsListActive.js +1 -0
- package/funcs/integrationsListActive.js.map +1 -1
- package/funcs/integrationsSetAsPrimary.d.ts.map +1 -1
- package/funcs/integrationsSetAsPrimary.js +1 -0
- package/funcs/integrationsSetAsPrimary.js.map +1 -1
- package/funcs/integrationsUpdate.d.ts.map +1 -1
- package/funcs/integrationsUpdate.js +1 -0
- package/funcs/integrationsUpdate.js.map +1 -1
- package/funcs/integrationsWebhooksRetrieve.d.ts.map +1 -1
- package/funcs/integrationsWebhooksRetrieve.js +1 -0
- package/funcs/integrationsWebhooksRetrieve.js.map +1 -1
- package/funcs/messagesDelete.d.ts.map +1 -1
- package/funcs/messagesDelete.js +1 -0
- package/funcs/messagesDelete.js.map +1 -1
- package/funcs/messagesDeleteByTransactionId.d.ts.map +1 -1
- package/funcs/messagesDeleteByTransactionId.js +1 -0
- package/funcs/messagesDeleteByTransactionId.js.map +1 -1
- package/funcs/messagesRetrieve.d.ts.map +1 -1
- package/funcs/messagesRetrieve.js +1 -0
- package/funcs/messagesRetrieve.js.map +1 -1
- package/funcs/notificationsList.d.ts.map +1 -1
- package/funcs/notificationsList.js +2 -0
- package/funcs/notificationsList.js.map +1 -1
- package/funcs/notificationsRetrieve.d.ts.map +1 -1
- package/funcs/notificationsRetrieve.js +1 -0
- package/funcs/notificationsRetrieve.js.map +1 -1
- package/funcs/notificationsStatsGraph.d.ts.map +1 -1
- package/funcs/notificationsStatsGraph.js +1 -0
- package/funcs/notificationsStatsGraph.js.map +1 -1
- package/funcs/notificationsStatsRetrieve.d.ts.map +1 -1
- package/funcs/notificationsStatsRetrieve.js +1 -0
- package/funcs/notificationsStatsRetrieve.js.map +1 -1
- package/funcs/subscribersAuthenticationChatAccessOauth.d.ts.map +1 -1
- package/funcs/subscribersAuthenticationChatAccessOauth.js +1 -0
- package/funcs/subscribersAuthenticationChatAccessOauth.js.map +1 -1
- package/funcs/subscribersAuthenticationChatAccessOauthCallBack.d.ts.map +1 -1
- package/funcs/subscribersAuthenticationChatAccessOauthCallBack.js +1 -0
- package/funcs/subscribersAuthenticationChatAccessOauthCallBack.js.map +1 -1
- package/funcs/subscribersCreate.d.ts.map +1 -1
- package/funcs/subscribersCreate.js +2 -1
- package/funcs/subscribersCreate.js.map +1 -1
- package/funcs/subscribersCreateBulk.d.ts.map +1 -1
- package/funcs/subscribersCreateBulk.js +1 -0
- package/funcs/subscribersCreateBulk.js.map +1 -1
- package/funcs/subscribersCredentialsAppend.d.ts.map +1 -1
- package/funcs/subscribersCredentialsAppend.js +1 -0
- package/funcs/subscribersCredentialsAppend.js.map +1 -1
- package/funcs/subscribersCredentialsDelete.d.ts.map +1 -1
- package/funcs/subscribersCredentialsDelete.js +1 -0
- package/funcs/subscribersCredentialsDelete.js.map +1 -1
- package/funcs/subscribersCredentialsUpdate.d.ts.map +1 -1
- package/funcs/subscribersCredentialsUpdate.js +1 -0
- package/funcs/subscribersCredentialsUpdate.js.map +1 -1
- package/funcs/subscribersDelete.d.ts.map +1 -1
- package/funcs/subscribersDelete.js +1 -0
- package/funcs/subscribersDelete.js.map +1 -1
- package/funcs/subscribersList.d.ts.map +1 -1
- package/funcs/subscribersList.js +1 -0
- package/funcs/subscribersList.js.map +1 -1
- package/funcs/subscribersMessagesMarkAll.d.ts.map +1 -1
- package/funcs/subscribersMessagesMarkAll.js +1 -0
- package/funcs/subscribersMessagesMarkAll.js.map +1 -1
- package/funcs/subscribersMessagesMarkAllAs.d.ts.map +1 -1
- package/funcs/subscribersMessagesMarkAllAs.js +1 -0
- package/funcs/subscribersMessagesMarkAllAs.js.map +1 -1
- package/funcs/subscribersMessagesUpdateAsSeen.d.ts.map +1 -1
- package/funcs/subscribersMessagesUpdateAsSeen.js +1 -0
- package/funcs/subscribersMessagesUpdateAsSeen.js.map +1 -1
- package/funcs/subscribersNotificationsFeed.d.ts.map +1 -1
- package/funcs/subscribersNotificationsFeed.js +1 -0
- package/funcs/subscribersNotificationsFeed.js.map +1 -1
- package/funcs/subscribersNotificationsUnseenCount.d.ts.map +1 -1
- package/funcs/subscribersNotificationsUnseenCount.js +1 -0
- package/funcs/subscribersNotificationsUnseenCount.js.map +1 -1
- package/funcs/subscribersPatch.d.ts.map +1 -1
- package/funcs/subscribersPatch.js +1 -0
- package/funcs/subscribersPatch.js.map +1 -1
- package/funcs/subscribersPreferencesList.d.ts.map +1 -1
- package/funcs/subscribersPreferencesList.js +1 -0
- package/funcs/subscribersPreferencesList.js.map +1 -1
- package/funcs/subscribersPreferencesUpdate.d.ts.map +1 -1
- package/funcs/subscribersPreferencesUpdate.js +1 -0
- package/funcs/subscribersPreferencesUpdate.js.map +1 -1
- package/funcs/subscribersPropertiesUpdateOnlineFlag.d.ts.map +1 -1
- package/funcs/subscribersPropertiesUpdateOnlineFlag.js +1 -0
- package/funcs/subscribersPropertiesUpdateOnlineFlag.js.map +1 -1
- package/funcs/subscribersRetrieve.d.ts.map +1 -1
- package/funcs/subscribersRetrieve.js +1 -0
- package/funcs/subscribersRetrieve.js.map +1 -1
- package/funcs/subscribersSearch.d.ts.map +1 -1
- package/funcs/subscribersSearch.js +1 -0
- package/funcs/subscribersSearch.js.map +1 -1
- package/funcs/topicsCreate.d.ts.map +1 -1
- package/funcs/topicsCreate.js +1 -0
- package/funcs/topicsCreate.js.map +1 -1
- package/funcs/topicsDelete.d.ts.map +1 -1
- package/funcs/topicsDelete.js +1 -0
- package/funcs/topicsDelete.js.map +1 -1
- package/funcs/topicsList.d.ts.map +1 -1
- package/funcs/topicsList.js +1 -0
- package/funcs/topicsList.js.map +1 -1
- package/funcs/topicsRename.d.ts.map +1 -1
- package/funcs/topicsRename.js +1 -0
- package/funcs/topicsRename.js.map +1 -1
- package/funcs/topicsRetrieve.d.ts.map +1 -1
- package/funcs/topicsRetrieve.js +1 -0
- package/funcs/topicsRetrieve.js.map +1 -1
- package/funcs/topicsSubscribersAssign.d.ts.map +1 -1
- package/funcs/topicsSubscribersAssign.js +1 -0
- package/funcs/topicsSubscribersAssign.js.map +1 -1
- package/funcs/topicsSubscribersRemove.d.ts.map +1 -1
- package/funcs/topicsSubscribersRemove.js +1 -0
- package/funcs/topicsSubscribersRemove.js.map +1 -1
- package/funcs/topicsSubscribersRetrieve.d.ts.map +1 -1
- package/funcs/topicsSubscribersRetrieve.js +1 -0
- package/funcs/topicsSubscribersRetrieve.js.map +1 -1
- package/funcs/trigger.d.ts.map +1 -1
- package/funcs/trigger.js +1 -0
- package/funcs/trigger.js.map +1 -1
- package/funcs/triggerBroadcast.d.ts.map +1 -1
- package/funcs/triggerBroadcast.js +1 -0
- package/funcs/triggerBroadcast.js.map +1 -1
- package/funcs/triggerBulk.d.ts.map +1 -1
- package/funcs/triggerBulk.js +1 -0
- package/funcs/triggerBulk.js.map +1 -1
- package/funcs/workflowsCreate.d.ts.map +1 -1
- package/funcs/workflowsCreate.js +1 -0
- package/funcs/workflowsCreate.js.map +1 -1
- package/funcs/workflowsDelete.d.ts.map +1 -1
- package/funcs/workflowsDelete.js +1 -0
- package/funcs/workflowsDelete.js.map +1 -1
- package/funcs/workflowsGetStepData.d.ts.map +1 -1
- package/funcs/workflowsGetStepData.js +1 -0
- package/funcs/workflowsGetStepData.js.map +1 -1
- package/funcs/workflowsGetWorkflowTestData.d.ts.map +1 -1
- package/funcs/workflowsGetWorkflowTestData.js +1 -0
- package/funcs/workflowsGetWorkflowTestData.js.map +1 -1
- package/funcs/workflowsRetrieve.d.ts.map +1 -1
- package/funcs/workflowsRetrieve.js +1 -0
- package/funcs/workflowsRetrieve.js.map +1 -1
- package/funcs/workflowsUpdate.d.ts.map +1 -1
- package/funcs/workflowsUpdate.js +1 -0
- package/funcs/workflowsUpdate.js.map +1 -1
- package/funcs/workflowsWorkflowControllerGeneratePreview.d.ts.map +1 -1
- package/funcs/workflowsWorkflowControllerGeneratePreview.js +1 -0
- package/funcs/workflowsWorkflowControllerGeneratePreview.js.map +1 -1
- package/funcs/workflowsWorkflowControllerPatchWorkflow.d.ts.map +1 -1
- package/funcs/workflowsWorkflowControllerPatchWorkflow.js +1 -0
- package/funcs/workflowsWorkflowControllerPatchWorkflow.js.map +1 -1
- package/funcs/workflowsWorkflowControllerPatchWorkflowStepData.d.ts.map +1 -1
- package/funcs/workflowsWorkflowControllerPatchWorkflowStepData.js +1 -0
- package/funcs/workflowsWorkflowControllerPatchWorkflowStepData.js.map +1 -1
- package/funcs/workflowsWorkflowControllerSearchWorkflows.d.ts.map +1 -1
- package/funcs/workflowsWorkflowControllerSearchWorkflows.js +1 -0
- package/funcs/workflowsWorkflowControllerSearchWorkflows.js.map +1 -1
- package/funcs/workflowsWorkflowControllerSync.d.ts.map +1 -1
- package/funcs/workflowsWorkflowControllerSync.js +1 -0
- package/funcs/workflowsWorkflowControllerSync.js.map +1 -1
- package/hooks/types.d.ts +1 -0
- package/hooks/types.d.ts.map +1 -1
- package/lib/config.d.ts +2 -2
- package/lib/config.js +2 -2
- package/lib/security.d.ts.map +1 -1
- package/lib/security.js.map +1 -1
- package/models/components/activitynotificationtemplateresponsedto.d.ts +6 -0
- package/models/components/activitynotificationtemplateresponsedto.d.ts.map +1 -1
- package/models/components/activitynotificationtemplateresponsedto.js +3 -0
- package/models/components/activitynotificationtemplateresponsedto.js.map +1 -1
- package/models/components/createsubscriberrequestdto.d.ts +28 -50
- package/models/components/createsubscriberrequestdto.d.ts.map +1 -1
- package/models/components/createsubscriberrequestdto.js +17 -41
- package/models/components/createsubscriberrequestdto.js.map +1 -1
- package/models/components/getenvironmenttagsdto.d.ts +29 -0
- package/models/components/getenvironmenttagsdto.d.ts.map +1 -0
- package/models/components/getenvironmenttagsdto.js +59 -0
- package/models/components/getenvironmenttagsdto.js.map +1 -0
- package/models/components/index.d.ts +1 -0
- package/models/components/index.d.ts.map +1 -1
- package/models/components/index.js +1 -0
- package/models/components/index.js.map +1 -1
- package/models/components/patchsubscriberrequestdto.d.ts +0 -5
- package/models/components/patchsubscriberrequestdto.d.ts.map +1 -1
- package/models/components/patchsubscriberrequestdto.js +0 -2
- package/models/components/patchsubscriberrequestdto.js.map +1 -1
- package/models/components/sessiongeneratedresponsedto.d.ts +32 -0
- package/models/components/sessiongeneratedresponsedto.d.ts.map +1 -0
- package/models/components/sessiongeneratedresponsedto.js +59 -0
- package/models/components/sessiongeneratedresponsedto.js.map +1 -0
- package/models/components/subscriberpayloaddto.d.ts +5 -0
- package/models/components/subscriberpayloaddto.d.ts.map +1 -1
- package/models/components/subscriberpayloaddto.js +2 -0
- package/models/components/subscriberpayloaddto.js.map +1 -1
- package/models/components/triggereventresponsedto.d.ts +3 -0
- package/models/components/triggereventresponsedto.d.ts.map +1 -1
- package/models/components/triggereventresponsedto.js +1 -0
- package/models/components/triggereventresponsedto.js.map +1 -1
- package/models/components/workfloworiginenum.d.ts +37 -0
- package/models/components/workfloworiginenum.d.ts.map +1 -0
- package/models/components/workfloworiginenum.js +54 -0
- package/models/components/workfloworiginenum.js.map +1 -0
- package/models/operations/environmentscontrollergeneratesession.d.ts +66 -0
- package/models/operations/environmentscontrollergeneratesession.d.ts.map +1 -0
- package/models/operations/environmentscontrollergeneratesession.js +110 -0
- package/models/operations/environmentscontrollergeneratesession.js.map +1 -0
- package/models/operations/environmentscontrollergetenvironmenttags.d.ts +66 -0
- package/models/operations/environmentscontrollergetenvironmenttags.d.ts.map +1 -0
- package/models/operations/environmentscontrollergetenvironmenttags.js +110 -0
- package/models/operations/environmentscontrollergetenvironmenttags.js.map +1 -0
- package/models/operations/notificationscontrollerlistnotifications.d.ts +5 -0
- package/models/operations/notificationscontrollerlistnotifications.d.ts.map +1 -1
- package/models/operations/notificationscontrollerlistnotifications.js +2 -0
- package/models/operations/notificationscontrollerlistnotifications.js.map +1 -1
- package/package.json +1 -1
- package/react-query/environmentsGenerateSession.d.ts +18 -0
- package/react-query/environmentsGenerateSession.d.ts.map +1 -0
- package/react-query/environmentsGenerateSession.js +41 -0
- package/react-query/environmentsGenerateSession.js.map +1 -0
- package/react-query/environmentsRetrieve.d.ts +30 -0
- package/react-query/environmentsRetrieve.d.ts.map +1 -0
- package/react-query/environmentsRetrieve.js +70 -0
- package/react-query/environmentsRetrieve.js.map +1 -0
- package/react-query/notificationsList.d.ts +3 -0
- package/react-query/notificationsList.d.ts.map +1 -1
- package/react-query/notificationsList.js +1 -0
- package/react-query/notificationsList.js.map +1 -1
- package/sdk/environments.d.ts +13 -0
- package/sdk/environments.d.ts.map +1 -0
- package/sdk/environments.js +26 -0
- package/sdk/environments.js.map +1 -0
- package/sources/json-development.json +32352 -0
- package/src/funcs/cancel.ts +1 -0
- package/src/funcs/integrationsCreate.ts +1 -0
- package/src/funcs/integrationsDelete.ts +1 -0
- package/src/funcs/integrationsList.ts +1 -0
- package/src/funcs/integrationsListActive.ts +1 -0
- package/src/funcs/integrationsSetAsPrimary.ts +1 -0
- package/src/funcs/integrationsUpdate.ts +1 -0
- package/src/funcs/integrationsWebhooksRetrieve.ts +1 -0
- package/src/funcs/messagesDelete.ts +1 -0
- package/src/funcs/messagesDeleteByTransactionId.ts +1 -0
- package/src/funcs/messagesRetrieve.ts +1 -0
- package/src/funcs/notificationsList.ts +2 -0
- package/src/funcs/notificationsRetrieve.ts +1 -0
- package/src/funcs/notificationsStatsGraph.ts +1 -0
- package/src/funcs/notificationsStatsRetrieve.ts +1 -0
- package/src/funcs/subscribersAuthenticationChatAccessOauth.ts +1 -0
- package/src/funcs/subscribersAuthenticationChatAccessOauthCallBack.ts +1 -0
- package/src/funcs/subscribersCreate.ts +2 -1
- package/src/funcs/subscribersCreateBulk.ts +1 -0
- package/src/funcs/subscribersCredentialsAppend.ts +1 -0
- package/src/funcs/subscribersCredentialsDelete.ts +1 -0
- package/src/funcs/subscribersCredentialsUpdate.ts +1 -0
- package/src/funcs/subscribersDelete.ts +1 -0
- package/src/funcs/subscribersList.ts +1 -0
- package/src/funcs/subscribersMessagesMarkAll.ts +1 -0
- package/src/funcs/subscribersMessagesMarkAllAs.ts +1 -0
- package/src/funcs/subscribersMessagesUpdateAsSeen.ts +1 -0
- package/src/funcs/subscribersNotificationsFeed.ts +1 -0
- package/src/funcs/subscribersNotificationsUnseenCount.ts +1 -0
- package/src/funcs/subscribersPatch.ts +1 -0
- package/src/funcs/subscribersPreferencesList.ts +1 -0
- package/src/funcs/subscribersPreferencesUpdate.ts +1 -0
- package/src/funcs/subscribersPropertiesUpdateOnlineFlag.ts +1 -0
- package/src/funcs/subscribersRetrieve.ts +1 -0
- package/src/funcs/subscribersSearch.ts +1 -0
- package/src/funcs/topicsCreate.ts +1 -0
- package/src/funcs/topicsDelete.ts +1 -0
- package/src/funcs/topicsList.ts +1 -0
- package/src/funcs/topicsRename.ts +1 -0
- package/src/funcs/topicsRetrieve.ts +1 -0
- package/src/funcs/topicsSubscribersAssign.ts +1 -0
- package/src/funcs/topicsSubscribersRemove.ts +1 -0
- package/src/funcs/topicsSubscribersRetrieve.ts +1 -0
- package/src/funcs/trigger.ts +1 -0
- package/src/funcs/triggerBroadcast.ts +1 -0
- package/src/funcs/triggerBulk.ts +1 -0
- package/src/funcs/workflowsCreate.ts +1 -0
- package/src/funcs/workflowsDelete.ts +1 -0
- package/src/funcs/workflowsGetStepData.ts +1 -0
- package/src/funcs/workflowsGetWorkflowTestData.ts +1 -0
- package/src/funcs/workflowsRetrieve.ts +1 -0
- package/src/funcs/workflowsUpdate.ts +1 -0
- package/src/funcs/workflowsWorkflowControllerGeneratePreview.ts +1 -0
- package/src/funcs/workflowsWorkflowControllerPatchWorkflow.ts +1 -0
- package/src/funcs/workflowsWorkflowControllerPatchWorkflowStepData.ts +1 -0
- package/src/funcs/workflowsWorkflowControllerSearchWorkflows.ts +1 -0
- package/src/funcs/workflowsWorkflowControllerSync.ts +1 -0
- package/src/hooks/types.ts +1 -0
- package/src/lib/config.ts +2 -2
- package/src/lib/security.ts +0 -1
- package/src/models/components/activitynotificationtemplateresponsedto.ts +12 -0
- package/src/models/components/createsubscriberrequestdto.ts +41 -111
- package/src/models/components/index.ts +1 -0
- package/src/models/components/patchsubscriberrequestdto.ts +0 -7
- package/src/models/components/subscriberpayloaddto.ts +7 -0
- package/src/models/components/triggereventresponsedto.ts +1 -0
- package/src/models/components/workfloworiginenum.ts +40 -0
- package/src/models/operations/notificationscontrollerlistnotifications.ts +7 -0
- package/src/react-query/notificationsList.ts +4 -0
package/README.md
ADDED
|
@@ -0,0 +1,1032 @@
|
|
|
1
|
+
# @novu/api
|
|
2
|
+
|
|
3
|
+
Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@novu/api* API.
|
|
4
|
+
|
|
5
|
+
<div align="left">
|
|
6
|
+
<a href="https://www.speakeasy.com/?utm_source=@novu/api&utm_campaign=typescript"><img src="https://custom-icon-badges.demolab.com/badge/-Built%20By%20Speakeasy-212015?style=for-the-badge&logoColor=FBE331&logo=speakeasy&labelColor=545454" /></a>
|
|
7
|
+
<a href="https://opensource.org/licenses/MIT">
|
|
8
|
+
<img src="https://img.shields.io/badge/License-MIT-blue.svg" style="width: 100px; height: 28px;" />
|
|
9
|
+
</a>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
<br /><br />
|
|
14
|
+
> [!IMPORTANT]
|
|
15
|
+
> This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your [workspace](https://app.speakeasy.com/org/novu/novu). Delete this section before > publishing to a package manager.
|
|
16
|
+
|
|
17
|
+
<!-- Start Summary [summary] -->
|
|
18
|
+
## Summary
|
|
19
|
+
|
|
20
|
+
Novu API: Novu REST API. Please see https://docs.novu.co/api-reference for more details.
|
|
21
|
+
|
|
22
|
+
For more information about the API: [Novu Documentation](https://docs.novu.co)
|
|
23
|
+
<!-- End Summary [summary] -->
|
|
24
|
+
|
|
25
|
+
<!-- Start Table of Contents [toc] -->
|
|
26
|
+
## Table of Contents
|
|
27
|
+
<!-- $toc-max-depth=2 -->
|
|
28
|
+
* [@novu/api](#novuapi)
|
|
29
|
+
* [SDK Installation](#sdk-installation)
|
|
30
|
+
* [Requirements](#requirements)
|
|
31
|
+
* [SDK Example Usage](#sdk-example-usage)
|
|
32
|
+
* [Authentication](#authentication)
|
|
33
|
+
* [Available Resources and Operations](#available-resources-and-operations)
|
|
34
|
+
* [Standalone functions](#standalone-functions)
|
|
35
|
+
* [React hooks with TanStack Query](#react-hooks-with-tanstack-query)
|
|
36
|
+
* [Pagination](#pagination)
|
|
37
|
+
* [Retries](#retries)
|
|
38
|
+
* [Error Handling](#error-handling)
|
|
39
|
+
* [Server Selection](#server-selection)
|
|
40
|
+
* [Custom HTTP Client](#custom-http-client)
|
|
41
|
+
* [Debugging](#debugging)
|
|
42
|
+
* [Development](#development)
|
|
43
|
+
* [Maturity](#maturity)
|
|
44
|
+
* [Contributions](#contributions)
|
|
45
|
+
|
|
46
|
+
<!-- End Table of Contents [toc] -->
|
|
47
|
+
|
|
48
|
+
<!-- Start SDK Installation [installation] -->
|
|
49
|
+
## SDK Installation
|
|
50
|
+
|
|
51
|
+
> [!TIP]
|
|
52
|
+
> To finish publishing your SDK to npm and others you must [run your first generation action](https://www.speakeasy.com/docs/github-setup#step-by-step-guide).
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
The SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [bun](https://bun.sh/) or [yarn](https://classic.yarnpkg.com/en/) package managers.
|
|
56
|
+
|
|
57
|
+
### NPM
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npm add <UNSET>
|
|
61
|
+
# Install optional peer dependencies if you plan to use React hooks
|
|
62
|
+
npm add @tanstack/react-query react react-dom
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### PNPM
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pnpm add <UNSET>
|
|
69
|
+
# Install optional peer dependencies if you plan to use React hooks
|
|
70
|
+
pnpm add @tanstack/react-query react react-dom
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Bun
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
bun add <UNSET>
|
|
77
|
+
# Install optional peer dependencies if you plan to use React hooks
|
|
78
|
+
bun add @tanstack/react-query react react-dom
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Yarn
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
yarn add <UNSET> zod
|
|
85
|
+
# Install optional peer dependencies if you plan to use React hooks
|
|
86
|
+
yarn add @tanstack/react-query react react-dom
|
|
87
|
+
|
|
88
|
+
# Note that Yarn does not install peer dependencies automatically. You will need
|
|
89
|
+
# to install zod as shown above.
|
|
90
|
+
```
|
|
91
|
+
<!-- End SDK Installation [installation] -->
|
|
92
|
+
|
|
93
|
+
<!-- Start Requirements [requirements] -->
|
|
94
|
+
## Requirements
|
|
95
|
+
|
|
96
|
+
For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
|
|
97
|
+
<!-- End Requirements [requirements] -->
|
|
98
|
+
|
|
99
|
+
<!-- Start SDK Example Usage [usage] -->
|
|
100
|
+
## SDK Example Usage
|
|
101
|
+
|
|
102
|
+
### Trigger Notification Event
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
import { Novu } from "@novu/api";
|
|
106
|
+
|
|
107
|
+
const novu = new Novu({
|
|
108
|
+
security: {
|
|
109
|
+
secretKey: "YOUR_SECRET_KEY_HERE",
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
async function run() {
|
|
114
|
+
const result = await novu.trigger({
|
|
115
|
+
workflowId: "workflow_identifier",
|
|
116
|
+
payload: {
|
|
117
|
+
"comment_id": "string",
|
|
118
|
+
"post": {
|
|
119
|
+
"text": "string",
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
overrides: {
|
|
123
|
+
"fcm": {
|
|
124
|
+
"data": {
|
|
125
|
+
"key": "value",
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
to: {
|
|
130
|
+
subscriberId: "<id>",
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// Handle the result
|
|
135
|
+
console.log(result);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
run();
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Trigger Notification Events in Bulk
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
import { Novu } from "@novu/api";
|
|
146
|
+
|
|
147
|
+
const novu = new Novu({
|
|
148
|
+
security: {
|
|
149
|
+
secretKey: "YOUR_SECRET_KEY_HERE",
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
async function run() {
|
|
154
|
+
const result = await novu.triggerBulk({
|
|
155
|
+
events: [
|
|
156
|
+
{
|
|
157
|
+
workflowId: "workflow_identifier",
|
|
158
|
+
payload: {
|
|
159
|
+
"comment_id": "string",
|
|
160
|
+
"post": {
|
|
161
|
+
"text": "string",
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
overrides: {
|
|
165
|
+
"fcm": {
|
|
166
|
+
"data": {
|
|
167
|
+
"key": "value",
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
to: {
|
|
172
|
+
subscriberId: "<id>",
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
workflowId: "workflow_identifier",
|
|
177
|
+
payload: {
|
|
178
|
+
"comment_id": "string",
|
|
179
|
+
"post": {
|
|
180
|
+
"text": "string",
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
overrides: {
|
|
184
|
+
"fcm": {
|
|
185
|
+
"data": {
|
|
186
|
+
"key": "value",
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
to: [
|
|
191
|
+
{
|
|
192
|
+
topicKey: "<value>",
|
|
193
|
+
type: "Subscriber",
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
workflowId: "workflow_identifier",
|
|
199
|
+
payload: {
|
|
200
|
+
"comment_id": "string",
|
|
201
|
+
"post": {
|
|
202
|
+
"text": "string",
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
overrides: {
|
|
206
|
+
"fcm": {
|
|
207
|
+
"data": {
|
|
208
|
+
"key": "value",
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
to: [
|
|
213
|
+
"SUBSCRIBER_ID",
|
|
214
|
+
"SUBSCRIBER_ID",
|
|
215
|
+
],
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
// Handle the result
|
|
221
|
+
console.log(result);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
run();
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Broadcast Event to All
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
import { Novu } from "@novu/api";
|
|
232
|
+
|
|
233
|
+
const novu = new Novu({
|
|
234
|
+
security: {
|
|
235
|
+
secretKey: "YOUR_SECRET_KEY_HERE",
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
async function run() {
|
|
240
|
+
const result = await novu.triggerBroadcast({
|
|
241
|
+
name: "<value>",
|
|
242
|
+
payload: {
|
|
243
|
+
"comment_id": "string",
|
|
244
|
+
"post": {
|
|
245
|
+
"text": "string",
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
// Handle the result
|
|
251
|
+
console.log(result);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
run();
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Cancel Triggered Event
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
import { Novu } from "@novu/api";
|
|
262
|
+
|
|
263
|
+
const novu = new Novu({
|
|
264
|
+
security: {
|
|
265
|
+
secretKey: "YOUR_SECRET_KEY_HERE",
|
|
266
|
+
},
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
async function run() {
|
|
270
|
+
const result = await novu.cancel("<id>");
|
|
271
|
+
|
|
272
|
+
// Handle the result
|
|
273
|
+
console.log(result);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
run();
|
|
277
|
+
|
|
278
|
+
```
|
|
279
|
+
<!-- End SDK Example Usage [usage] -->
|
|
280
|
+
|
|
281
|
+
<!-- Start Authentication [security] -->
|
|
282
|
+
## Authentication
|
|
283
|
+
|
|
284
|
+
### Per-Client Security Schemes
|
|
285
|
+
|
|
286
|
+
This SDK supports the following security schemes globally:
|
|
287
|
+
|
|
288
|
+
| Name | Type | Scheme |
|
|
289
|
+
| ------------ | ------ | ----------- |
|
|
290
|
+
| `secretKey` | apiKey | API key |
|
|
291
|
+
| `bearerAuth` | http | HTTP Bearer |
|
|
292
|
+
|
|
293
|
+
You can set the security parameters through the `security` optional parameter when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example:
|
|
294
|
+
```typescript
|
|
295
|
+
import { Novu } from "@novu/api";
|
|
296
|
+
|
|
297
|
+
const novu = new Novu({
|
|
298
|
+
security: {
|
|
299
|
+
secretKey: "YOUR_SECRET_KEY_HERE",
|
|
300
|
+
},
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
async function run() {
|
|
304
|
+
const result = await novu.trigger({
|
|
305
|
+
workflowId: "workflow_identifier",
|
|
306
|
+
payload: {
|
|
307
|
+
"comment_id": "string",
|
|
308
|
+
"post": {
|
|
309
|
+
"text": "string",
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
overrides: {
|
|
313
|
+
"fcm": {
|
|
314
|
+
"data": {
|
|
315
|
+
"key": "value",
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
to: {
|
|
320
|
+
subscriberId: "<id>",
|
|
321
|
+
},
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
// Handle the result
|
|
325
|
+
console.log(result);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
run();
|
|
329
|
+
|
|
330
|
+
```
|
|
331
|
+
<!-- End Authentication [security] -->
|
|
332
|
+
|
|
333
|
+
<!-- Start Available Resources and Operations [operations] -->
|
|
334
|
+
## Available Resources and Operations
|
|
335
|
+
|
|
336
|
+
<details open>
|
|
337
|
+
<summary>Available methods</summary>
|
|
338
|
+
|
|
339
|
+
### [integrations](docs/sdks/integrations/README.md)
|
|
340
|
+
|
|
341
|
+
* [list](docs/sdks/integrations/README.md#list) - Get integrations
|
|
342
|
+
* [create](docs/sdks/integrations/README.md#create) - Create integration
|
|
343
|
+
* [listActive](docs/sdks/integrations/README.md#listactive) - Get active integrations
|
|
344
|
+
* [update](docs/sdks/integrations/README.md#update) - Update integration
|
|
345
|
+
* [delete](docs/sdks/integrations/README.md#delete) - Delete integration
|
|
346
|
+
* [setAsPrimary](docs/sdks/integrations/README.md#setasprimary) - Set integration as primary
|
|
347
|
+
|
|
348
|
+
#### [integrations.webhooks](docs/sdks/webhooks/README.md)
|
|
349
|
+
|
|
350
|
+
* [retrieve](docs/sdks/webhooks/README.md#retrieve) - Get webhook support status for provider
|
|
351
|
+
|
|
352
|
+
### [messages](docs/sdks/messages/README.md)
|
|
353
|
+
|
|
354
|
+
* [retrieve](docs/sdks/messages/README.md#retrieve) - Get messages
|
|
355
|
+
* [delete](docs/sdks/messages/README.md#delete) - Delete message
|
|
356
|
+
* [deleteByTransactionId](docs/sdks/messages/README.md#deletebytransactionid) - Delete messages by transactionId
|
|
357
|
+
|
|
358
|
+
### [notifications](docs/sdks/notifications/README.md)
|
|
359
|
+
|
|
360
|
+
* [list](docs/sdks/notifications/README.md#list) - Get notifications
|
|
361
|
+
* [retrieve](docs/sdks/notifications/README.md#retrieve) - Get notification
|
|
362
|
+
|
|
363
|
+
#### [notifications.stats](docs/sdks/stats/README.md)
|
|
364
|
+
|
|
365
|
+
* [retrieve](docs/sdks/stats/README.md#retrieve) - Get notification statistics
|
|
366
|
+
* [graph](docs/sdks/stats/README.md#graph) - Get notification graph statistics
|
|
367
|
+
|
|
368
|
+
### [Novu SDK](docs/sdks/novu/README.md)
|
|
369
|
+
|
|
370
|
+
* [trigger](docs/sdks/novu/README.md#trigger) - Trigger event
|
|
371
|
+
* [triggerBulk](docs/sdks/novu/README.md#triggerbulk) - Bulk trigger event
|
|
372
|
+
* [triggerBroadcast](docs/sdks/novu/README.md#triggerbroadcast) - Broadcast event to all
|
|
373
|
+
* [cancel](docs/sdks/novu/README.md#cancel) - Cancel triggered event
|
|
374
|
+
|
|
375
|
+
### [subscribers](docs/sdks/subscribers/README.md)
|
|
376
|
+
|
|
377
|
+
* [list](docs/sdks/subscribers/README.md#list) - Get subscribers
|
|
378
|
+
* [createBulk](docs/sdks/subscribers/README.md#createbulk) - Bulk create subscribers
|
|
379
|
+
* [search](docs/sdks/subscribers/README.md#search) - Search for subscribers
|
|
380
|
+
* [create](docs/sdks/subscribers/README.md#create) - Create subscriber
|
|
381
|
+
* [retrieve](docs/sdks/subscribers/README.md#retrieve) - Get subscriber
|
|
382
|
+
* [patch](docs/sdks/subscribers/README.md#patch) - Patch subscriber
|
|
383
|
+
* [delete](docs/sdks/subscribers/README.md#delete) - Delete subscriber
|
|
384
|
+
|
|
385
|
+
#### [subscribers.authentication](docs/sdks/authentication/README.md)
|
|
386
|
+
|
|
387
|
+
* [chatAccessOauthCallBack](docs/sdks/authentication/README.md#chataccessoauthcallback) - Handle providers oauth redirect
|
|
388
|
+
* [chatAccessOauth](docs/sdks/authentication/README.md#chataccessoauth) - Handle chat oauth
|
|
389
|
+
|
|
390
|
+
#### [subscribers.credentials](docs/sdks/credentials/README.md)
|
|
391
|
+
|
|
392
|
+
* [update](docs/sdks/credentials/README.md#update) - Update subscriber credentials
|
|
393
|
+
* [append](docs/sdks/credentials/README.md#append) - Modify subscriber credentials
|
|
394
|
+
* [delete](docs/sdks/credentials/README.md#delete) - Delete subscriber credentials by providerId
|
|
395
|
+
|
|
396
|
+
#### [subscribers.messages](docs/sdks/novumessages/README.md)
|
|
397
|
+
|
|
398
|
+
* [markAllAs](docs/sdks/novumessages/README.md#markallas) - Mark a subscriber messages as seen, read, unseen or unread
|
|
399
|
+
* [markAll](docs/sdks/novumessages/README.md#markall) - Marks all the subscriber messages as read, unread, seen or unseen. Optionally you can pass feed id (or array) to mark messages of a particular feed.
|
|
400
|
+
* [updateAsSeen](docs/sdks/novumessages/README.md#updateasseen) - Mark message action as seen
|
|
401
|
+
|
|
402
|
+
#### [subscribers.notifications](docs/sdks/novunotifications/README.md)
|
|
403
|
+
|
|
404
|
+
* [feed](docs/sdks/novunotifications/README.md#feed) - Get in-app notification feed for a particular subscriber
|
|
405
|
+
* [unseenCount](docs/sdks/novunotifications/README.md#unseencount) - Get the unseen in-app notifications count for subscribers feed
|
|
406
|
+
|
|
407
|
+
#### [subscribers.preferences](docs/sdks/preferences/README.md)
|
|
408
|
+
|
|
409
|
+
* [list](docs/sdks/preferences/README.md#list) - Get subscriber preferences
|
|
410
|
+
* [update](docs/sdks/preferences/README.md#update) - Update subscriber global or workflow specific preferences
|
|
411
|
+
|
|
412
|
+
#### [subscribers.properties](docs/sdks/properties/README.md)
|
|
413
|
+
|
|
414
|
+
* [updateOnlineFlag](docs/sdks/properties/README.md#updateonlineflag) - Update subscriber online status
|
|
415
|
+
|
|
416
|
+
### [topics](docs/sdks/topics/README.md)
|
|
417
|
+
|
|
418
|
+
* [create](docs/sdks/topics/README.md#create) - Topic creation
|
|
419
|
+
* [list](docs/sdks/topics/README.md#list) - Get topic list filtered
|
|
420
|
+
* [delete](docs/sdks/topics/README.md#delete) - Delete topic
|
|
421
|
+
* [retrieve](docs/sdks/topics/README.md#retrieve) - Get topic
|
|
422
|
+
* [rename](docs/sdks/topics/README.md#rename) - Rename a topic
|
|
423
|
+
|
|
424
|
+
#### [topics.subscribers](docs/sdks/novusubscribers/README.md)
|
|
425
|
+
|
|
426
|
+
* [assign](docs/sdks/novusubscribers/README.md#assign) - Subscribers addition
|
|
427
|
+
* [retrieve](docs/sdks/novusubscribers/README.md#retrieve) - Check topic subscriber
|
|
428
|
+
* [remove](docs/sdks/novusubscribers/README.md#remove) - Subscribers removal
|
|
429
|
+
|
|
430
|
+
### [workflows](docs/sdks/workflows/README.md)
|
|
431
|
+
|
|
432
|
+
* [create](docs/sdks/workflows/README.md#create)
|
|
433
|
+
* [workflowControllerSearchWorkflows](docs/sdks/workflows/README.md#workflowcontrollersearchworkflows)
|
|
434
|
+
* [workflowControllerSync](docs/sdks/workflows/README.md#workflowcontrollersync)
|
|
435
|
+
* [update](docs/sdks/workflows/README.md#update)
|
|
436
|
+
* [retrieve](docs/sdks/workflows/README.md#retrieve)
|
|
437
|
+
* [delete](docs/sdks/workflows/README.md#delete)
|
|
438
|
+
* [workflowControllerPatchWorkflow](docs/sdks/workflows/README.md#workflowcontrollerpatchworkflow)
|
|
439
|
+
* [workflowControllerGeneratePreview](docs/sdks/workflows/README.md#workflowcontrollergeneratepreview)
|
|
440
|
+
* [getStepData](docs/sdks/workflows/README.md#getstepdata)
|
|
441
|
+
* [workflowControllerPatchWorkflowStepData](docs/sdks/workflows/README.md#workflowcontrollerpatchworkflowstepdata)
|
|
442
|
+
* [getWorkflowTestData](docs/sdks/workflows/README.md#getworkflowtestdata)
|
|
443
|
+
|
|
444
|
+
</details>
|
|
445
|
+
<!-- End Available Resources and Operations [operations] -->
|
|
446
|
+
|
|
447
|
+
<!-- Start Standalone functions [standalone-funcs] -->
|
|
448
|
+
## Standalone functions
|
|
449
|
+
|
|
450
|
+
All the methods listed above are available as standalone functions. These
|
|
451
|
+
functions are ideal for use in applications running in the browser, serverless
|
|
452
|
+
runtimes or other environments where application bundle size is a primary
|
|
453
|
+
concern. When using a bundler to build your application, all unused
|
|
454
|
+
functionality will be either excluded from the final bundle or tree-shaken away.
|
|
455
|
+
|
|
456
|
+
To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).
|
|
457
|
+
|
|
458
|
+
<details>
|
|
459
|
+
|
|
460
|
+
<summary>Available standalone functions</summary>
|
|
461
|
+
|
|
462
|
+
- [`cancel`](docs/sdks/novu/README.md#cancel) - Cancel triggered event
|
|
463
|
+
- [`integrationsCreate`](docs/sdks/integrations/README.md#create) - Create integration
|
|
464
|
+
- [`integrationsDelete`](docs/sdks/integrations/README.md#delete) - Delete integration
|
|
465
|
+
- [`integrationsList`](docs/sdks/integrations/README.md#list) - Get integrations
|
|
466
|
+
- [`integrationsListActive`](docs/sdks/integrations/README.md#listactive) - Get active integrations
|
|
467
|
+
- [`integrationsSetAsPrimary`](docs/sdks/integrations/README.md#setasprimary) - Set integration as primary
|
|
468
|
+
- [`integrationsUpdate`](docs/sdks/integrations/README.md#update) - Update integration
|
|
469
|
+
- [`integrationsWebhooksRetrieve`](docs/sdks/webhooks/README.md#retrieve) - Get webhook support status for provider
|
|
470
|
+
- [`messagesDelete`](docs/sdks/messages/README.md#delete) - Delete message
|
|
471
|
+
- [`messagesDeleteByTransactionId`](docs/sdks/messages/README.md#deletebytransactionid) - Delete messages by transactionId
|
|
472
|
+
- [`messagesRetrieve`](docs/sdks/messages/README.md#retrieve) - Get messages
|
|
473
|
+
- [`notificationsList`](docs/sdks/notifications/README.md#list) - Get notifications
|
|
474
|
+
- [`notificationsRetrieve`](docs/sdks/notifications/README.md#retrieve) - Get notification
|
|
475
|
+
- [`notificationsStatsGraph`](docs/sdks/stats/README.md#graph) - Get notification graph statistics
|
|
476
|
+
- [`notificationsStatsRetrieve`](docs/sdks/stats/README.md#retrieve) - Get notification statistics
|
|
477
|
+
- [`subscribersAuthenticationChatAccessOauth`](docs/sdks/authentication/README.md#chataccessoauth) - Handle chat oauth
|
|
478
|
+
- [`subscribersAuthenticationChatAccessOauthCallBack`](docs/sdks/authentication/README.md#chataccessoauthcallback) - Handle providers oauth redirect
|
|
479
|
+
- [`subscribersCreate`](docs/sdks/subscribers/README.md#create) - Create subscriber
|
|
480
|
+
- [`subscribersCreateBulk`](docs/sdks/subscribers/README.md#createbulk) - Bulk create subscribers
|
|
481
|
+
- [`subscribersCredentialsAppend`](docs/sdks/credentials/README.md#append) - Modify subscriber credentials
|
|
482
|
+
- [`subscribersCredentialsDelete`](docs/sdks/credentials/README.md#delete) - Delete subscriber credentials by providerId
|
|
483
|
+
- [`subscribersCredentialsUpdate`](docs/sdks/credentials/README.md#update) - Update subscriber credentials
|
|
484
|
+
- [`subscribersDelete`](docs/sdks/subscribers/README.md#delete) - Delete subscriber
|
|
485
|
+
- [`subscribersList`](docs/sdks/subscribers/README.md#list) - Get subscribers
|
|
486
|
+
- [`subscribersMessagesMarkAll`](docs/sdks/novumessages/README.md#markall) - Marks all the subscriber messages as read, unread, seen or unseen. Optionally you can pass feed id (or array) to mark messages of a particular feed.
|
|
487
|
+
- [`subscribersMessagesMarkAllAs`](docs/sdks/novumessages/README.md#markallas) - Mark a subscriber messages as seen, read, unseen or unread
|
|
488
|
+
- [`subscribersMessagesUpdateAsSeen`](docs/sdks/novumessages/README.md#updateasseen) - Mark message action as seen
|
|
489
|
+
- [`subscribersNotificationsFeed`](docs/sdks/novunotifications/README.md#feed) - Get in-app notification feed for a particular subscriber
|
|
490
|
+
- [`subscribersNotificationsUnseenCount`](docs/sdks/novunotifications/README.md#unseencount) - Get the unseen in-app notifications count for subscribers feed
|
|
491
|
+
- [`subscribersPatch`](docs/sdks/subscribers/README.md#patch) - Patch subscriber
|
|
492
|
+
- [`subscribersPreferencesList`](docs/sdks/preferences/README.md#list) - Get subscriber preferences
|
|
493
|
+
- [`subscribersPreferencesUpdate`](docs/sdks/preferences/README.md#update) - Update subscriber global or workflow specific preferences
|
|
494
|
+
- [`subscribersPropertiesUpdateOnlineFlag`](docs/sdks/properties/README.md#updateonlineflag) - Update subscriber online status
|
|
495
|
+
- [`subscribersRetrieve`](docs/sdks/subscribers/README.md#retrieve) - Get subscriber
|
|
496
|
+
- [`subscribersSearch`](docs/sdks/subscribers/README.md#search) - Search for subscribers
|
|
497
|
+
- [`topicsCreate`](docs/sdks/topics/README.md#create) - Topic creation
|
|
498
|
+
- [`topicsDelete`](docs/sdks/topics/README.md#delete) - Delete topic
|
|
499
|
+
- [`topicsList`](docs/sdks/topics/README.md#list) - Get topic list filtered
|
|
500
|
+
- [`topicsRename`](docs/sdks/topics/README.md#rename) - Rename a topic
|
|
501
|
+
- [`topicsRetrieve`](docs/sdks/topics/README.md#retrieve) - Get topic
|
|
502
|
+
- [`topicsSubscribersAssign`](docs/sdks/novusubscribers/README.md#assign) - Subscribers addition
|
|
503
|
+
- [`topicsSubscribersRemove`](docs/sdks/novusubscribers/README.md#remove) - Subscribers removal
|
|
504
|
+
- [`topicsSubscribersRetrieve`](docs/sdks/novusubscribers/README.md#retrieve) - Check topic subscriber
|
|
505
|
+
- [`trigger`](docs/sdks/novu/README.md#trigger) - Trigger event
|
|
506
|
+
- [`triggerBroadcast`](docs/sdks/novu/README.md#triggerbroadcast) - Broadcast event to all
|
|
507
|
+
- [`triggerBulk`](docs/sdks/novu/README.md#triggerbulk) - Bulk trigger event
|
|
508
|
+
- [`workflowsCreate`](docs/sdks/workflows/README.md#create)
|
|
509
|
+
- [`workflowsDelete`](docs/sdks/workflows/README.md#delete)
|
|
510
|
+
- [`workflowsGetStepData`](docs/sdks/workflows/README.md#getstepdata)
|
|
511
|
+
- [`workflowsGetWorkflowTestData`](docs/sdks/workflows/README.md#getworkflowtestdata)
|
|
512
|
+
- [`workflowsRetrieve`](docs/sdks/workflows/README.md#retrieve)
|
|
513
|
+
- [`workflowsUpdate`](docs/sdks/workflows/README.md#update)
|
|
514
|
+
- [`workflowsWorkflowControllerGeneratePreview`](docs/sdks/workflows/README.md#workflowcontrollergeneratepreview)
|
|
515
|
+
- [`workflowsWorkflowControllerPatchWorkflow`](docs/sdks/workflows/README.md#workflowcontrollerpatchworkflow)
|
|
516
|
+
- [`workflowsWorkflowControllerPatchWorkflowStepData`](docs/sdks/workflows/README.md#workflowcontrollerpatchworkflowstepdata)
|
|
517
|
+
- [`workflowsWorkflowControllerSearchWorkflows`](docs/sdks/workflows/README.md#workflowcontrollersearchworkflows)
|
|
518
|
+
- [`workflowsWorkflowControllerSync`](docs/sdks/workflows/README.md#workflowcontrollersync)
|
|
519
|
+
|
|
520
|
+
</details>
|
|
521
|
+
<!-- End Standalone functions [standalone-funcs] -->
|
|
522
|
+
|
|
523
|
+
<!-- Start React hooks with TanStack Query [react-query] -->
|
|
524
|
+
## React hooks with TanStack Query
|
|
525
|
+
|
|
526
|
+
React hooks built on [TanStack Query][tanstack-query] are included in this SDK.
|
|
527
|
+
These hooks and the utility functions provided alongside them can be used to
|
|
528
|
+
build rich applications that pull data from the API using one of the most
|
|
529
|
+
popular asynchronous state management library.
|
|
530
|
+
|
|
531
|
+
[tanstack-query]: https://tanstack.com/query/v5/docs/framework/react/overview
|
|
532
|
+
|
|
533
|
+
To learn about this feature and how to get started, check
|
|
534
|
+
[REACT_QUERY.md](./REACT_QUERY.md).
|
|
535
|
+
|
|
536
|
+
> [!WARNING]
|
|
537
|
+
>
|
|
538
|
+
> This feature is currently in **preview** and is subject to breaking changes
|
|
539
|
+
> within the current major version of the SDK as we gather user feedback on it.
|
|
540
|
+
|
|
541
|
+
<details>
|
|
542
|
+
|
|
543
|
+
<summary>Available React hooks</summary>
|
|
544
|
+
|
|
545
|
+
- [`useCancelMutation`](docs/sdks/novu/README.md#cancel) - Cancel triggered event
|
|
546
|
+
- [`useIntegrationsCreateMutation`](docs/sdks/integrations/README.md#create) - Create integration
|
|
547
|
+
- [`useIntegrationsDeleteMutation`](docs/sdks/integrations/README.md#delete) - Delete integration
|
|
548
|
+
- [`useIntegrationsList`](docs/sdks/integrations/README.md#list) - Get integrations
|
|
549
|
+
- [`useIntegrationsListActive`](docs/sdks/integrations/README.md#listactive) - Get active integrations
|
|
550
|
+
- [`useIntegrationsSetAsPrimaryMutation`](docs/sdks/integrations/README.md#setasprimary) - Set integration as primary
|
|
551
|
+
- [`useIntegrationsUpdateMutation`](docs/sdks/integrations/README.md#update) - Update integration
|
|
552
|
+
- [`useIntegrationsWebhooksRetrieve`](docs/sdks/webhooks/README.md#retrieve) - Get webhook support status for provider
|
|
553
|
+
- [`useMessagesDeleteByTransactionIdMutation`](docs/sdks/messages/README.md#deletebytransactionid) - Delete messages by transactionId
|
|
554
|
+
- [`useMessagesDeleteMutation`](docs/sdks/messages/README.md#delete) - Delete message
|
|
555
|
+
- [`useMessagesRetrieve`](docs/sdks/messages/README.md#retrieve) - Get messages
|
|
556
|
+
- [`useNotificationsList`](docs/sdks/notifications/README.md#list) - Get notifications
|
|
557
|
+
- [`useNotificationsRetrieve`](docs/sdks/notifications/README.md#retrieve) - Get notification
|
|
558
|
+
- [`useNotificationsStatsGraph`](docs/sdks/stats/README.md#graph) - Get notification graph statistics
|
|
559
|
+
- [`useNotificationsStatsRetrieve`](docs/sdks/stats/README.md#retrieve) - Get notification statistics
|
|
560
|
+
- [`useSubscribersAuthenticationChatAccessOauth`](docs/sdks/authentication/README.md#chataccessoauth) - Handle chat oauth
|
|
561
|
+
- [`useSubscribersAuthenticationChatAccessOauthCallBack`](docs/sdks/authentication/README.md#chataccessoauthcallback) - Handle providers oauth redirect
|
|
562
|
+
- [`useSubscribersCreateBulkMutation`](docs/sdks/subscribers/README.md#createbulk) - Bulk create subscribers
|
|
563
|
+
- [`useSubscribersCreateMutation`](docs/sdks/subscribers/README.md#create) - Create subscriber
|
|
564
|
+
- [`useSubscribersCredentialsAppendMutation`](docs/sdks/credentials/README.md#append) - Modify subscriber credentials
|
|
565
|
+
- [`useSubscribersCredentialsDeleteMutation`](docs/sdks/credentials/README.md#delete) - Delete subscriber credentials by providerId
|
|
566
|
+
- [`useSubscribersCredentialsUpdateMutation`](docs/sdks/credentials/README.md#update) - Update subscriber credentials
|
|
567
|
+
- [`useSubscribersDeleteMutation`](docs/sdks/subscribers/README.md#delete) - Delete subscriber
|
|
568
|
+
- [`useSubscribersList`](docs/sdks/subscribers/README.md#list) - Get subscribers
|
|
569
|
+
- [`useSubscribersMessagesMarkAllAsMutation`](docs/sdks/novumessages/README.md#markallas) - Mark a subscriber messages as seen, read, unseen or unread
|
|
570
|
+
- [`useSubscribersMessagesMarkAllMutation`](docs/sdks/novumessages/README.md#markall) - Marks all the subscriber messages as read, unread, seen or unseen. Optionally you can pass feed id (or array) to mark messages of a particular feed.
|
|
571
|
+
- [`useSubscribersMessagesUpdateAsSeenMutation`](docs/sdks/novumessages/README.md#updateasseen) - Mark message action as seen
|
|
572
|
+
- [`useSubscribersNotificationsFeed`](docs/sdks/novunotifications/README.md#feed) - Get in-app notification feed for a particular subscriber
|
|
573
|
+
- [`useSubscribersNotificationsUnseenCount`](docs/sdks/novunotifications/README.md#unseencount) - Get the unseen in-app notifications count for subscribers feed
|
|
574
|
+
- [`useSubscribersPatchMutation`](docs/sdks/subscribers/README.md#patch) - Patch subscriber
|
|
575
|
+
- [`useSubscribersPreferencesList`](docs/sdks/preferences/README.md#list) - Get subscriber preferences
|
|
576
|
+
- [`useSubscribersPreferencesUpdateMutation`](docs/sdks/preferences/README.md#update) - Update subscriber global or workflow specific preferences
|
|
577
|
+
- [`useSubscribersPropertiesUpdateOnlineFlagMutation`](docs/sdks/properties/README.md#updateonlineflag) - Update subscriber online status
|
|
578
|
+
- [`useSubscribersRetrieve`](docs/sdks/subscribers/README.md#retrieve) - Get subscriber
|
|
579
|
+
- [`useSubscribersSearch`](docs/sdks/subscribers/README.md#search) - Search for subscribers
|
|
580
|
+
- [`useTopicsCreateMutation`](docs/sdks/topics/README.md#create) - Topic creation
|
|
581
|
+
- [`useTopicsDeleteMutation`](docs/sdks/topics/README.md#delete) - Delete topic
|
|
582
|
+
- [`useTopicsList`](docs/sdks/topics/README.md#list) - Get topic list filtered
|
|
583
|
+
- [`useTopicsRenameMutation`](docs/sdks/topics/README.md#rename) - Rename a topic
|
|
584
|
+
- [`useTopicsRetrieve`](docs/sdks/topics/README.md#retrieve) - Get topic
|
|
585
|
+
- [`useTopicsSubscribersAssignMutation`](docs/sdks/novusubscribers/README.md#assign) - Subscribers addition
|
|
586
|
+
- [`useTopicsSubscribersRemoveMutation`](docs/sdks/novusubscribers/README.md#remove) - Subscribers removal
|
|
587
|
+
- [`useTopicsSubscribersRetrieve`](docs/sdks/novusubscribers/README.md#retrieve) - Check topic subscriber
|
|
588
|
+
- [`useTriggerBroadcastMutation`](docs/sdks/novu/README.md#triggerbroadcast) - Broadcast event to all
|
|
589
|
+
- [`useTriggerBulkMutation`](docs/sdks/novu/README.md#triggerbulk) - Bulk trigger event
|
|
590
|
+
- [`useTriggerMutation`](docs/sdks/novu/README.md#trigger) - Trigger event
|
|
591
|
+
- [`useWorkflowsCreateMutation`](docs/sdks/workflows/README.md#create)
|
|
592
|
+
- [`useWorkflowsDeleteMutation`](docs/sdks/workflows/README.md#delete)
|
|
593
|
+
- [`useWorkflowsGetStepData`](docs/sdks/workflows/README.md#getstepdata)
|
|
594
|
+
- [`useWorkflowsGetWorkflowTestData`](docs/sdks/workflows/README.md#getworkflowtestdata)
|
|
595
|
+
- [`useWorkflowsRetrieve`](docs/sdks/workflows/README.md#retrieve)
|
|
596
|
+
- [`useWorkflowsUpdateMutation`](docs/sdks/workflows/README.md#update)
|
|
597
|
+
- [`useWorkflowsWorkflowControllerGeneratePreviewMutation`](docs/sdks/workflows/README.md#workflowcontrollergeneratepreview)
|
|
598
|
+
- [`useWorkflowsWorkflowControllerPatchWorkflowMutation`](docs/sdks/workflows/README.md#workflowcontrollerpatchworkflow)
|
|
599
|
+
- [`useWorkflowsWorkflowControllerPatchWorkflowStepDataMutation`](docs/sdks/workflows/README.md#workflowcontrollerpatchworkflowstepdata)
|
|
600
|
+
- [`useWorkflowsWorkflowControllerSearchWorkflows`](docs/sdks/workflows/README.md#workflowcontrollersearchworkflows)
|
|
601
|
+
- [`useWorkflowsWorkflowControllerSyncMutation`](docs/sdks/workflows/README.md#workflowcontrollersync)
|
|
602
|
+
|
|
603
|
+
</details>
|
|
604
|
+
<!-- End React hooks with TanStack Query [react-query] -->
|
|
605
|
+
|
|
606
|
+
<!-- Start Pagination [pagination] -->
|
|
607
|
+
## Pagination
|
|
608
|
+
|
|
609
|
+
Some of the endpoints in this SDK support pagination. To use pagination, you
|
|
610
|
+
make your SDK calls as usual, but the returned response object will also be an
|
|
611
|
+
async iterable that can be consumed using the [`for await...of`][for-await-of]
|
|
612
|
+
syntax.
|
|
613
|
+
|
|
614
|
+
[for-await-of]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of
|
|
615
|
+
|
|
616
|
+
Here's an example of one such pagination call:
|
|
617
|
+
|
|
618
|
+
```typescript
|
|
619
|
+
import { Novu } from "@novu/api";
|
|
620
|
+
|
|
621
|
+
const novu = new Novu({
|
|
622
|
+
security: {
|
|
623
|
+
secretKey: "YOUR_SECRET_KEY_HERE",
|
|
624
|
+
},
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
async function run() {
|
|
628
|
+
const result = await novu.subscribers.list();
|
|
629
|
+
|
|
630
|
+
for await (const page of result) {
|
|
631
|
+
// Handle the page
|
|
632
|
+
console.log(page);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
run();
|
|
637
|
+
|
|
638
|
+
```
|
|
639
|
+
<!-- End Pagination [pagination] -->
|
|
640
|
+
|
|
641
|
+
<!-- Start Retries [retries] -->
|
|
642
|
+
## Retries
|
|
643
|
+
|
|
644
|
+
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
|
|
645
|
+
|
|
646
|
+
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
|
|
647
|
+
```typescript
|
|
648
|
+
import { Novu } from "@novu/api";
|
|
649
|
+
|
|
650
|
+
const novu = new Novu({
|
|
651
|
+
security: {
|
|
652
|
+
secretKey: "YOUR_SECRET_KEY_HERE",
|
|
653
|
+
},
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
async function run() {
|
|
657
|
+
const result = await novu.trigger({
|
|
658
|
+
workflowId: "workflow_identifier",
|
|
659
|
+
payload: {
|
|
660
|
+
"comment_id": "string",
|
|
661
|
+
"post": {
|
|
662
|
+
"text": "string",
|
|
663
|
+
},
|
|
664
|
+
},
|
|
665
|
+
overrides: {
|
|
666
|
+
"fcm": {
|
|
667
|
+
"data": {
|
|
668
|
+
"key": "value",
|
|
669
|
+
},
|
|
670
|
+
},
|
|
671
|
+
},
|
|
672
|
+
to: {
|
|
673
|
+
subscriberId: "<id>",
|
|
674
|
+
},
|
|
675
|
+
}, {
|
|
676
|
+
retries: {
|
|
677
|
+
strategy: "backoff",
|
|
678
|
+
backoff: {
|
|
679
|
+
initialInterval: 1,
|
|
680
|
+
maxInterval: 50,
|
|
681
|
+
exponent: 1.1,
|
|
682
|
+
maxElapsedTime: 100,
|
|
683
|
+
},
|
|
684
|
+
retryConnectionErrors: false,
|
|
685
|
+
},
|
|
686
|
+
});
|
|
687
|
+
|
|
688
|
+
// Handle the result
|
|
689
|
+
console.log(result);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
run();
|
|
693
|
+
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
|
|
697
|
+
```typescript
|
|
698
|
+
import { Novu } from "@novu/api";
|
|
699
|
+
|
|
700
|
+
const novu = new Novu({
|
|
701
|
+
retryConfig: {
|
|
702
|
+
strategy: "backoff",
|
|
703
|
+
backoff: {
|
|
704
|
+
initialInterval: 1,
|
|
705
|
+
maxInterval: 50,
|
|
706
|
+
exponent: 1.1,
|
|
707
|
+
maxElapsedTime: 100,
|
|
708
|
+
},
|
|
709
|
+
retryConnectionErrors: false,
|
|
710
|
+
},
|
|
711
|
+
security: {
|
|
712
|
+
secretKey: "YOUR_SECRET_KEY_HERE",
|
|
713
|
+
},
|
|
714
|
+
});
|
|
715
|
+
|
|
716
|
+
async function run() {
|
|
717
|
+
const result = await novu.trigger({
|
|
718
|
+
workflowId: "workflow_identifier",
|
|
719
|
+
payload: {
|
|
720
|
+
"comment_id": "string",
|
|
721
|
+
"post": {
|
|
722
|
+
"text": "string",
|
|
723
|
+
},
|
|
724
|
+
},
|
|
725
|
+
overrides: {
|
|
726
|
+
"fcm": {
|
|
727
|
+
"data": {
|
|
728
|
+
"key": "value",
|
|
729
|
+
},
|
|
730
|
+
},
|
|
731
|
+
},
|
|
732
|
+
to: {
|
|
733
|
+
subscriberId: "<id>",
|
|
734
|
+
},
|
|
735
|
+
});
|
|
736
|
+
|
|
737
|
+
// Handle the result
|
|
738
|
+
console.log(result);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
run();
|
|
742
|
+
|
|
743
|
+
```
|
|
744
|
+
<!-- End Retries [retries] -->
|
|
745
|
+
|
|
746
|
+
<!-- Start Error Handling [errors] -->
|
|
747
|
+
## Error Handling
|
|
748
|
+
|
|
749
|
+
Some methods specify known errors which can be thrown. All the known errors are enumerated in the `models/errors/errors.ts` module. The known errors for a method are documented under the *Errors* tables in SDK docs. For example, the `trigger` method may throw the following errors:
|
|
750
|
+
|
|
751
|
+
| Error Type | Status Code | Content Type |
|
|
752
|
+
| ------------------------- | -------------------------------------- | ---------------- |
|
|
753
|
+
| errors.ErrorDto | 414 | application/json |
|
|
754
|
+
| errors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
|
|
755
|
+
| errors.ValidationErrorDto | 422 | application/json |
|
|
756
|
+
| errors.ErrorDto | 500 | application/json |
|
|
757
|
+
| errors.SDKError | 4XX, 5XX | \*/\* |
|
|
758
|
+
|
|
759
|
+
If the method throws an error and it is not captured by the known errors, it will default to throwing a `SDKError`.
|
|
760
|
+
|
|
761
|
+
```typescript
|
|
762
|
+
import { Novu } from "@novu/api";
|
|
763
|
+
import {
|
|
764
|
+
ErrorDto,
|
|
765
|
+
SDKValidationError,
|
|
766
|
+
ValidationErrorDto,
|
|
767
|
+
} from "@novu/api/models/errors";
|
|
768
|
+
|
|
769
|
+
const novu = new Novu({
|
|
770
|
+
security: {
|
|
771
|
+
secretKey: "YOUR_SECRET_KEY_HERE",
|
|
772
|
+
},
|
|
773
|
+
});
|
|
774
|
+
|
|
775
|
+
async function run() {
|
|
776
|
+
let result;
|
|
777
|
+
try {
|
|
778
|
+
result = await novu.trigger({
|
|
779
|
+
workflowId: "workflow_identifier",
|
|
780
|
+
payload: {
|
|
781
|
+
"comment_id": "string",
|
|
782
|
+
"post": {
|
|
783
|
+
"text": "string",
|
|
784
|
+
},
|
|
785
|
+
},
|
|
786
|
+
overrides: {
|
|
787
|
+
"fcm": {
|
|
788
|
+
"data": {
|
|
789
|
+
"key": "value",
|
|
790
|
+
},
|
|
791
|
+
},
|
|
792
|
+
},
|
|
793
|
+
to: {
|
|
794
|
+
subscriberId: "<id>",
|
|
795
|
+
},
|
|
796
|
+
});
|
|
797
|
+
|
|
798
|
+
// Handle the result
|
|
799
|
+
console.log(result);
|
|
800
|
+
} catch (err) {
|
|
801
|
+
switch (true) {
|
|
802
|
+
// The server response does not match the expected SDK schema
|
|
803
|
+
case (err instanceof SDKValidationError): {
|
|
804
|
+
// Pretty-print will provide a human-readable multi-line error message
|
|
805
|
+
console.error(err.pretty());
|
|
806
|
+
// Raw value may also be inspected
|
|
807
|
+
console.error(err.rawValue);
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
case (err instanceof ErrorDto): {
|
|
811
|
+
// Handle err.data$: ErrorDtoData
|
|
812
|
+
console.error(err);
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
case (err instanceof ErrorDto): {
|
|
816
|
+
// Handle err.data$: ErrorDtoData
|
|
817
|
+
console.error(err);
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
case (err instanceof ValidationErrorDto): {
|
|
821
|
+
// Handle err.data$: ValidationErrorDtoData
|
|
822
|
+
console.error(err);
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
case (err instanceof ErrorDto): {
|
|
826
|
+
// Handle err.data$: ErrorDtoData
|
|
827
|
+
console.error(err);
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
default: {
|
|
831
|
+
// Other errors such as network errors, see HTTPClientErrors for more details
|
|
832
|
+
throw err;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
run();
|
|
839
|
+
|
|
840
|
+
```
|
|
841
|
+
|
|
842
|
+
Validation errors can also occur when either method arguments or data returned from the server do not match the expected format. The `SDKValidationError` that is thrown as a result will capture the raw value that failed validation in an attribute called `rawValue`. Additionally, a `pretty()` method is available on this error that can be used to log a nicely formatted multi-line string since validation errors can list many issues and the plain error string may be difficult read when debugging.
|
|
843
|
+
|
|
844
|
+
In some rare cases, the SDK can fail to get a response from the server or even make the request due to unexpected circumstances such as network conditions. These types of errors are captured in the `models/errors/httpclienterrors.ts` module:
|
|
845
|
+
|
|
846
|
+
| HTTP Client Error | Description |
|
|
847
|
+
| ---------------------------------------------------- | ---------------------------------------------------- |
|
|
848
|
+
| RequestAbortedError | HTTP request was aborted by the client |
|
|
849
|
+
| RequestTimeoutError | HTTP request timed out due to an AbortSignal signal |
|
|
850
|
+
| ConnectionError | HTTP client was unable to make a request to a server |
|
|
851
|
+
| InvalidRequestError | Any input used to create a request is invalid |
|
|
852
|
+
| UnexpectedClientError | Unrecognised or unexpected error |
|
|
853
|
+
<!-- End Error Handling [errors] -->
|
|
854
|
+
|
|
855
|
+
<!-- Start Server Selection [server] -->
|
|
856
|
+
## Server Selection
|
|
857
|
+
|
|
858
|
+
### Select Server by Index
|
|
859
|
+
|
|
860
|
+
You can override the default server globally by passing a server index to the `serverIdx: number` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:
|
|
861
|
+
|
|
862
|
+
| # | Server |
|
|
863
|
+
| --- | ------------------------ |
|
|
864
|
+
| 0 | `https://api.novu.co` |
|
|
865
|
+
| 1 | `https://eu.api.novu.co` |
|
|
866
|
+
|
|
867
|
+
#### Example
|
|
868
|
+
|
|
869
|
+
```typescript
|
|
870
|
+
import { Novu } from "@novu/api";
|
|
871
|
+
|
|
872
|
+
const novu = new Novu({
|
|
873
|
+
serverIdx: 1,
|
|
874
|
+
security: {
|
|
875
|
+
secretKey: "YOUR_SECRET_KEY_HERE",
|
|
876
|
+
},
|
|
877
|
+
});
|
|
878
|
+
|
|
879
|
+
async function run() {
|
|
880
|
+
const result = await novu.trigger({
|
|
881
|
+
workflowId: "workflow_identifier",
|
|
882
|
+
payload: {
|
|
883
|
+
"comment_id": "string",
|
|
884
|
+
"post": {
|
|
885
|
+
"text": "string",
|
|
886
|
+
},
|
|
887
|
+
},
|
|
888
|
+
overrides: {
|
|
889
|
+
"fcm": {
|
|
890
|
+
"data": {
|
|
891
|
+
"key": "value",
|
|
892
|
+
},
|
|
893
|
+
},
|
|
894
|
+
},
|
|
895
|
+
to: {
|
|
896
|
+
subscriberId: "<id>",
|
|
897
|
+
},
|
|
898
|
+
});
|
|
899
|
+
|
|
900
|
+
// Handle the result
|
|
901
|
+
console.log(result);
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
run();
|
|
905
|
+
|
|
906
|
+
```
|
|
907
|
+
|
|
908
|
+
### Override Server URL Per-Client
|
|
909
|
+
|
|
910
|
+
The default server can also be overridden globally by passing a URL to the `serverURL: string` optional parameter when initializing the SDK client instance. For example:
|
|
911
|
+
```typescript
|
|
912
|
+
import { Novu } from "@novu/api";
|
|
913
|
+
|
|
914
|
+
const novu = new Novu({
|
|
915
|
+
serverURL: "https://api.novu.co",
|
|
916
|
+
security: {
|
|
917
|
+
secretKey: "YOUR_SECRET_KEY_HERE",
|
|
918
|
+
},
|
|
919
|
+
});
|
|
920
|
+
|
|
921
|
+
async function run() {
|
|
922
|
+
const result = await novu.trigger({
|
|
923
|
+
workflowId: "workflow_identifier",
|
|
924
|
+
payload: {
|
|
925
|
+
"comment_id": "string",
|
|
926
|
+
"post": {
|
|
927
|
+
"text": "string",
|
|
928
|
+
},
|
|
929
|
+
},
|
|
930
|
+
overrides: {
|
|
931
|
+
"fcm": {
|
|
932
|
+
"data": {
|
|
933
|
+
"key": "value",
|
|
934
|
+
},
|
|
935
|
+
},
|
|
936
|
+
},
|
|
937
|
+
to: {
|
|
938
|
+
subscriberId: "<id>",
|
|
939
|
+
},
|
|
940
|
+
});
|
|
941
|
+
|
|
942
|
+
// Handle the result
|
|
943
|
+
console.log(result);
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
run();
|
|
947
|
+
|
|
948
|
+
```
|
|
949
|
+
<!-- End Server Selection [server] -->
|
|
950
|
+
|
|
951
|
+
<!-- Start Custom HTTP Client [http-client] -->
|
|
952
|
+
## Custom HTTP Client
|
|
953
|
+
|
|
954
|
+
The TypeScript SDK makes API calls using an `HTTPClient` that wraps the native
|
|
955
|
+
[Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). This
|
|
956
|
+
client is a thin wrapper around `fetch` and provides the ability to attach hooks
|
|
957
|
+
around the request lifecycle that can be used to modify the request or handle
|
|
958
|
+
errors and response.
|
|
959
|
+
|
|
960
|
+
The `HTTPClient` constructor takes an optional `fetcher` argument that can be
|
|
961
|
+
used to integrate a third-party HTTP client or when writing tests to mock out
|
|
962
|
+
the HTTP client and feed in fixtures.
|
|
963
|
+
|
|
964
|
+
The following example shows how to use the `"beforeRequest"` hook to to add a
|
|
965
|
+
custom header and a timeout to requests and how to use the `"requestError"` hook
|
|
966
|
+
to log errors:
|
|
967
|
+
|
|
968
|
+
```typescript
|
|
969
|
+
import { Novu } from "@novu/api";
|
|
970
|
+
import { HTTPClient } from "@novu/api/lib/http";
|
|
971
|
+
|
|
972
|
+
const httpClient = new HTTPClient({
|
|
973
|
+
// fetcher takes a function that has the same signature as native `fetch`.
|
|
974
|
+
fetcher: (request) => {
|
|
975
|
+
return fetch(request);
|
|
976
|
+
}
|
|
977
|
+
});
|
|
978
|
+
|
|
979
|
+
httpClient.addHook("beforeRequest", (request) => {
|
|
980
|
+
const nextRequest = new Request(request, {
|
|
981
|
+
signal: request.signal || AbortSignal.timeout(5000)
|
|
982
|
+
});
|
|
983
|
+
|
|
984
|
+
nextRequest.headers.set("x-custom-header", "custom value");
|
|
985
|
+
|
|
986
|
+
return nextRequest;
|
|
987
|
+
});
|
|
988
|
+
|
|
989
|
+
httpClient.addHook("requestError", (error, request) => {
|
|
990
|
+
console.group("Request Error");
|
|
991
|
+
console.log("Reason:", `${error}`);
|
|
992
|
+
console.log("Endpoint:", `${request.method} ${request.url}`);
|
|
993
|
+
console.groupEnd();
|
|
994
|
+
});
|
|
995
|
+
|
|
996
|
+
const sdk = new Novu({ httpClient });
|
|
997
|
+
```
|
|
998
|
+
<!-- End Custom HTTP Client [http-client] -->
|
|
999
|
+
|
|
1000
|
+
<!-- Start Debugging [debug] -->
|
|
1001
|
+
## Debugging
|
|
1002
|
+
|
|
1003
|
+
You can setup your SDK to emit debug logs for SDK requests and responses.
|
|
1004
|
+
|
|
1005
|
+
You can pass a logger that matches `console`'s interface as an SDK option.
|
|
1006
|
+
|
|
1007
|
+
> [!WARNING]
|
|
1008
|
+
> Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.
|
|
1009
|
+
|
|
1010
|
+
```typescript
|
|
1011
|
+
import { Novu } from "@novu/api";
|
|
1012
|
+
|
|
1013
|
+
const sdk = new Novu({ debugLogger: console });
|
|
1014
|
+
```
|
|
1015
|
+
<!-- End Debugging [debug] -->
|
|
1016
|
+
|
|
1017
|
+
<!-- Placeholder for Future Speakeasy SDK Sections -->
|
|
1018
|
+
|
|
1019
|
+
# Development
|
|
1020
|
+
|
|
1021
|
+
## Maturity
|
|
1022
|
+
|
|
1023
|
+
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
|
|
1024
|
+
to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally
|
|
1025
|
+
looking for the latest version.
|
|
1026
|
+
|
|
1027
|
+
## Contributions
|
|
1028
|
+
|
|
1029
|
+
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.
|
|
1030
|
+
We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
|
|
1031
|
+
|
|
1032
|
+
### SDK Created by [Speakeasy](https://www.speakeasy.com/?utm_source=@novu/api&utm_campaign=typescript)
|