chore(types,notification): Make template nullable on emails (#13889)
* chore: Make template nullable on emails * Create curvy-lamps-float.md
This commit is contained in:
1 parent
ef7b9b9375
commit
01ee437926
6 files changed
+61
-6
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/notification": patch
|
||||||
|
"@medusajs/types": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
chore: Make template nullable on emails
|
||||||
@@ -18,7 +18,7 @@ export interface CreateNotificationDTO {
|
|||||||
/**
|
/**
|
||||||
* The template name in the provider's system.
|
* The template name in the provider's system.
|
||||||
*/
|
*/
|
||||||
template: string
|
template?: string | null
|
||||||
/**
|
/**
|
||||||
* The data that gets passed over to the provider for rendering the notification.
|
* The data that gets passed over to the provider for rendering the notification.
|
||||||
*/
|
*/
|
||||||
|
|||||||
+24
@@ -108,6 +108,30 @@ moduleIntegrationTestRunner<INotificationModuleService>({
|
|||||||
provider_id: "test-provider",
|
provider_id: "test-provider",
|
||||||
external_id: "external_id",
|
external_id: "external_id",
|
||||||
status: NotificationStatus.SUCCESS,
|
status: NotificationStatus.SUCCESS,
|
||||||
|
template: "signup-template",
|
||||||
|
})
|
||||||
|
)
|
||||||
|
expect(dbEntry).not.toHaveProperty("content")
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should send a notification without a template", async () => {
|
||||||
|
const notification = {
|
||||||
|
to: "admin@medusa.com",
|
||||||
|
channel: "email",
|
||||||
|
content: {
|
||||||
|
html: "<p>Welcome to medusa</p>",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await service.createNotifications(notification)
|
||||||
|
const dbEntry = await service.retrieveNotification(result.id)
|
||||||
|
|
||||||
|
expect(dbEntry).toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
provider_id: "test-provider",
|
||||||
|
external_id: "external_id",
|
||||||
|
status: NotificationStatus.SUCCESS,
|
||||||
|
template: null,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
expect(dbEntry).not.toHaveProperty("content")
|
expect(dbEntry).not.toHaveProperty("content")
|
||||||
|
|||||||
@@ -93,6 +93,7 @@
|
|||||||
"keyName": "IDX_notification_provider_deleted_at",
|
"keyName": "IDX_notification_provider_deleted_at",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_provider_deleted_at\" ON \"notification_provider\" (deleted_at) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_provider_deleted_at\" ON \"notification_provider\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
@@ -103,12 +104,14 @@
|
|||||||
"id"
|
"id"
|
||||||
],
|
],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
"unique": true
|
"unique": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"checks": [],
|
"checks": [],
|
||||||
"foreignKeys": {}
|
"foreignKeys": {},
|
||||||
|
"nativeEnums": {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columns": {
|
"columns": {
|
||||||
@@ -145,7 +148,7 @@
|
|||||||
"unsigned": false,
|
"unsigned": false,
|
||||||
"autoincrement": false,
|
"autoincrement": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": false,
|
"nullable": true,
|
||||||
"mappedType": "text"
|
"mappedType": "text"
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
@@ -284,6 +287,7 @@
|
|||||||
"keyName": "IDX_notification_receiver_id",
|
"keyName": "IDX_notification_receiver_id",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_receiver_id\" ON \"notification\" (receiver_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_receiver_id\" ON \"notification\" (receiver_id) WHERE deleted_at IS NULL"
|
||||||
@@ -292,6 +296,7 @@
|
|||||||
"keyName": "IDX_notification_idempotency_key_unique",
|
"keyName": "IDX_notification_idempotency_key_unique",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_notification_idempotency_key_unique\" ON \"notification\" (idempotency_key) WHERE deleted_at IS NULL"
|
"expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_notification_idempotency_key_unique\" ON \"notification\" (idempotency_key) WHERE deleted_at IS NULL"
|
||||||
@@ -300,6 +305,7 @@
|
|||||||
"keyName": "IDX_notification_provider_id",
|
"keyName": "IDX_notification_provider_id",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_provider_id\" ON \"notification\" (provider_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_provider_id\" ON \"notification\" (provider_id) WHERE deleted_at IS NULL"
|
||||||
@@ -308,6 +314,7 @@
|
|||||||
"keyName": "IDX_notification_deleted_at",
|
"keyName": "IDX_notification_deleted_at",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_deleted_at\" ON \"notification\" (deleted_at) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_deleted_at\" ON \"notification\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
@@ -318,6 +325,7 @@
|
|||||||
"id"
|
"id"
|
||||||
],
|
],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
"unique": true
|
"unique": true
|
||||||
}
|
}
|
||||||
@@ -337,7 +345,9 @@
|
|||||||
"deleteRule": "set null",
|
"deleteRule": "set null",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"nativeEnums": {}
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"nativeEnums": {}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { Migration } from '@mikro-orm/migrations';
|
||||||
|
|
||||||
|
export class Migration20251028172715 extends Migration {
|
||||||
|
|
||||||
|
override async up(): Promise<void> {
|
||||||
|
this.addSql(`alter table if exists "notification" alter column "template" type text using ("template"::text);`);
|
||||||
|
this.addSql(`alter table if exists "notification" alter column "template" drop not null;`);
|
||||||
|
}
|
||||||
|
|
||||||
|
override async down(): Promise<void> {
|
||||||
|
this.addSql(`alter table if exists "notification" alter column "template" type text using ("template"::text);`);
|
||||||
|
this.addSql(`alter table if exists "notification" alter column "template" set not null;`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ export const Notification = model.define("notification", {
|
|||||||
to: model.text().searchable(),
|
to: model.text().searchable(),
|
||||||
channel: model.text(),
|
channel: model.text(),
|
||||||
// The template name in the provider's system.
|
// The template name in the provider's system.
|
||||||
template: model.text(),
|
template: model.text().nullable(),
|
||||||
// The data that gets passed over to the provider for rendering the notification.
|
// The data that gets passed over to the provider for rendering the notification.
|
||||||
data: model.json().nullable(),
|
data: model.json().nullable(),
|
||||||
// This can be the event name, the workflow, or anything else that can help to identify what triggered the notification.
|
// This can be the event name, the workflow, or anything else that can help to identify what triggered the notification.
|
||||||
|
|||||||
Reference in new issue
Block a user