Add provider data to notifications (#14104)
## Summary
**What** —
Add a providerData field to notifications
**Why** —
We need the ability to pass dynamic fields to specific providers. E.g. CC and BCC for emails
**How** —
Just adding the field to the model
**Testing** —
Added the field to existing tests
## Checklist
Please ensure the following before requesting a review:
- [x] I have added a **changeset** for this PR
- Every non-breaking change should be marked as a **patch**
- To add a changeset, run `yarn changeset` and follow the prompts
- [x] The changes are covered by relevant **tests**
- [x] I have verified the code works as intended locally
- [ ] I have linked the related issue(s) if applicable
---
> [!NOTE]
> Adds `provider_data` to notifications (types, workflow input, DB model/migration) and forwards it in the Medusa Cloud Email provider, with tests updated accordingly.
>
> - **Data/Schema**:
> - Add `provider_data` (`jsonb`) to `notification` model and DB via migration `Migration20251121150408` and snapshot update.
> - **Types/DTOs**:
> - Add optional `provider_data` to `CreateNotificationDTO`, `NotificationDTO`, and `ProviderSendNotificationDTO`.
> - **Workflows**:
> - Extend `send-notifications` step input with `provider_data`.
> - **Providers**:
> - Medusa Cloud Email: include `provider_data` in outgoing request payload.
> - **Tests**:
> - Update integration tests to pass and assert `provider_data` propagation.
> - **Changeset**:
> - Patch bumps for `@medusajs/notification`, `@medusajs/core-flows`, `@medusajs/types`.
>
> <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 6f114c75c974a145ef60213637d7c41bc605a0bf. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup>
This commit is contained in:
+4
-2
@@ -80,7 +80,8 @@ moduleIntegrationTestRunner<INotificationModuleService>({
|
||||
from: "sender@verified.com",
|
||||
template: "some-template",
|
||||
channel: "email",
|
||||
data: {},
|
||||
data: { link: "http://test.com" },
|
||||
provider_data: { cc: "cc@test.com" },
|
||||
} as CreateNotificationDTO
|
||||
|
||||
const result = await service.createNotifications(notification)
|
||||
@@ -91,7 +92,8 @@ moduleIntegrationTestRunner<INotificationModuleService>({
|
||||
from: "sender@verified.com",
|
||||
template: "some-template",
|
||||
channel: "email",
|
||||
data: {},
|
||||
data: { link: "http://test.com" },
|
||||
provider_data: { cc: "cc@test.com" },
|
||||
provider_id: "test-provider",
|
||||
external_id: "external_id",
|
||||
status: NotificationStatus.SUCCESS,
|
||||
|
||||
+9
@@ -20,6 +20,9 @@ const testNotification = {
|
||||
data: {
|
||||
link: "https://test.com",
|
||||
},
|
||||
provider_data: {
|
||||
cc: "cc@test.com",
|
||||
},
|
||||
}
|
||||
|
||||
moduleIntegrationTestRunner<INotificationModuleService>({
|
||||
@@ -58,6 +61,9 @@ moduleIntegrationTestRunner<INotificationModuleService>({
|
||||
data: {
|
||||
link: "https://test.com",
|
||||
},
|
||||
provider_data: {
|
||||
cc: "cc@test.com",
|
||||
},
|
||||
provider_id: "cloud",
|
||||
external_id: "external_id_1",
|
||||
status: NotificationStatus.SUCCESS,
|
||||
@@ -79,6 +85,9 @@ moduleIntegrationTestRunner<INotificationModuleService>({
|
||||
data: {
|
||||
link: "https://test.com",
|
||||
},
|
||||
provider_data: {
|
||||
cc: "cc@test.com",
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user