@medusajs/notification-sendgrid 2.22.0-snapshot-20261020204851 → 2.22.0

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 (3) hide show
  1. package/AGENTS.md +54 -0
  2. package/README.md +106 -0
  3. package/package.json +7 -3
package/AGENTS.md ADDED
@@ -0,0 +1,54 @@
1
+ # @medusajs/notification-sendgrid
2
+
3
+ Notification Module provider that sends emails through SendGrid (`@sendgrid/mail`), using either SendGrid dynamic templates or inline HTML.
4
+
5
+ ## Using this package
6
+
7
+ ```ts
8
+ module.exports = defineConfig({
9
+ modules: [
10
+ {
11
+ resolve: "@medusajs/medusa/notification",
12
+ options: {
13
+ providers: [
14
+ {
15
+ resolve: "@medusajs/medusa/notification-sendgrid",
16
+ id: "sendgrid",
17
+ options: {
18
+ channels: ["email"],
19
+ api_key: process.env.SENDGRID_API_KEY,
20
+ from: process.env.SENDGRID_FROM,
21
+ },
22
+ },
23
+ ],
24
+ },
25
+ },
26
+ ],
27
+ })
28
+ ```
29
+
30
+ - Options (`SendgridNotificationServiceOptions`): `api_key`, `from` (default sender). `channels` is read by the Notification Module.
31
+ - Send with `Modules.NOTIFICATION` `createNotifications({ to, channel: "email", template, data })`; `template` is the SendGrid dynamic template ID and `data` becomes `dynamicTemplateData`.
32
+ - Docs: https://docs.medusajs.com/resources/infrastructure-modules/notification/sendgrid.md
33
+ - Build a custom notification provider: https://docs.medusajs.com/resources/references/notification-provider-module.md
34
+
35
+ ## Architecture
36
+
37
+ - `src/services/sendgrid.ts`: `SendgridNotificationService extends AbstractNotificationProviderService`, `static identifier = "notification-sendgrid"`. Implements only `send`.
38
+ - `sendgrid.setApiKey` is called in the constructor; `@sendgrid/mail` is a module-level singleton.
39
+ - Reference for a custom email notification provider (attachments, per-notification `from`, `provider_data`).
40
+
41
+ ## Development
42
+
43
+ - `yarn build`, `yarn test`
44
+ - `yarn test:integration`: `integration-tests/__tests__/services.spec.ts` mocks `@sendgrid/mail` (no network).
45
+
46
+ ## Gotchas
47
+
48
+ - If the notification has `content`, `content.subject` and `content.html` are sent and `template` is ignored (SendGrid can't mix HTML and templates). `content.text` is never sent.
49
+ - `notification.from` overrides the configured `from` when non-empty.
50
+ - `provider_data.personalizations` is passed straight to SendGrid and replaces the top-level `to`, so include recipients inside it.
51
+ - Attachments: `content` must be base64; `disposition` defaults to `"attachment"`.
52
+ - Errors are rethrown as `UNEXPECTED_STATE` with `Failed to send email: {code} - {SendGrid message}`; the notification is then marked failed.
53
+ - No options validation: a missing `api_key` only surfaces when sending.
54
+ - Only one provider per channel: don't also register `notification-local` for `email`.
package/README.md CHANGED
@@ -0,0 +1,106 @@
1
+ <p align="center">
2
+ <a href="https://www.medusajs.com">
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/59018053/229103275-b5e482bb-4601-46e6-8142-244f531cebdb.svg">
5
+ <source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/59018053/229103726-e5b529a3-9b3f-4970-8a1f-c6af37f087bf.svg">
6
+ <img alt="Medusa logo" src="https://user-images.githubusercontent.com/59018053/229103726-e5b529a3-9b3f-4970-8a1f-c6af37f087bf.svg">
7
+ </picture>
8
+ </a>
9
+ </p>
10
+ <h1 align="center">
11
+ @medusajs/notification-sendgrid
12
+ </h1>
13
+
14
+ <h4 align="center">
15
+ <a href="https://docs.medusajs.com">Documentation</a> |
16
+ <a href="https://www.medusajs.com">Website</a>
17
+ </h4>
18
+
19
+ <p align="center">
20
+ Building blocks for digital commerce
21
+ </p>
22
+ <p align="center">
23
+ <a href="https://github.com/medusajs/medusa/blob/develop/LICENSE">
24
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="Medusa is released under the MIT license." />
25
+ </a>
26
+ <a href="https://github.com/medusajs/medusa/blob/develop/CONTRIBUTING.md">
27
+ <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat" alt="PRs welcome!" />
28
+ </a>
29
+ <a href="https://discord.gg/xpCwq3Kfn8">
30
+ <img src="https://img.shields.io/badge/chat-on%20discord-7289DA.svg" alt="Discord Chat" />
31
+ </a>
32
+ <a href="https://twitter.com/intent/follow?screen_name=medusajs">
33
+ <img src="https://img.shields.io/twitter/follow/medusajs.svg?label=Follow%20@medusajs" alt="Follow @medusajs" />
34
+ </a>
35
+ </p>
36
+
37
+ SendGrid Notification Module Provider for Medusa: sends email notifications through SendGrid, using SendGrid dynamic templates or raw HTML content. Use it to send transactional emails, such as order confirmations or password resets. It ships with `@medusajs/medusa` and is registered through the `@medusajs/medusa/notification-sendgrid` path.
38
+
39
+ ## At a glance
40
+
41
+ | | |
42
+ | --- | --- |
43
+ | Package | `@medusajs/notification-sendgrid` |
44
+ | Type | Module Provider (Notification Module) |
45
+ | Provider ID | `notification-sendgrid` |
46
+ | Registered by default | No |
47
+ | Import from | `@medusajs/medusa/notification-sendgrid` |
48
+
49
+ ## Features
50
+
51
+ - Sends a notification's `template` as a SendGrid dynamic template ID, with the notification's `data` as the template data.
52
+ - Sends a notification's `content` (`subject` and `html`) instead of a template when it's set.
53
+ - Supports attachments, a per-notification `from` address, and SendGrid `personalizations` through `provider_data`.
54
+
55
+ ## Installation
56
+
57
+ No installation needed. The provider is a dependency of `@medusajs/medusa`.
58
+
59
+ ## Usage
60
+
61
+ Register the provider in the Notification Module's `providers` array in `medusa-config.ts` for the `email` channel. Each channel can be handled by only one provider.
62
+
63
+ ```ts
64
+ import { defineConfig } from "@medusajs/framework/utils"
65
+
66
+ module.exports = defineConfig({
67
+ // ...
68
+ modules: [
69
+ {
70
+ resolve: "@medusajs/medusa/notification",
71
+ options: {
72
+ providers: [
73
+ {
74
+ resolve: "@medusajs/medusa/notification-sendgrid",
75
+ id: "sendgrid",
76
+ options: {
77
+ channels: ["email"],
78
+ api_key: process.env.SENDGRID_API_KEY,
79
+ from: process.env.SENDGRID_FROM,
80
+ },
81
+ },
82
+ ],
83
+ },
84
+ },
85
+ ],
86
+ })
87
+ ```
88
+
89
+ ## Configuration
90
+
91
+ | Option | Type | Description | Default |
92
+ | --- | --- | --- | --- |
93
+ | `channels` | `string[]` | Read by the Notification Module. The channels this provider handles; use `["email"]`. | `[]` |
94
+ | `api_key` | `string` | Required. Your SendGrid API key. | - |
95
+ | `from` | `string` | Required. The default sender email address. | - |
96
+
97
+ | Environment variable | Description |
98
+ | --- | --- |
99
+ | `SENDGRID_API_KEY` | Value for `api_key`, as used in the example above. |
100
+ | `SENDGRID_FROM` | Value for `from`, as used in the example above. |
101
+
102
+ ## Resources
103
+
104
+ - [SendGrid Notification Module Provider](https://docs.medusajs.com/resources/infrastructure-modules/notification/sendgrid)
105
+ - [Send Notifications](https://docs.medusajs.com/resources/infrastructure-modules/notification/send-notification)
106
+ - [Notification Module](https://docs.medusajs.com/resources/infrastructure-modules/notification)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/notification-sendgrid",
3
- "version": "2.22.0-snapshot-20261020204851",
3
+ "version": "2.22.0",
4
4
  "description": "Sendgrid notification provider for Medusa",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -13,10 +13,14 @@
13
13
  },
14
14
  "files": [
15
15
  "dist",
16
+ "AGENTS.md",
16
17
  "!dist/**/__tests__",
17
18
  "!dist/**/__mocks__",
18
19
  "!dist/**/__fixtures__"
19
20
  ],
21
+ "llms": "https://docs.medusajs.com/llms.txt",
22
+ "llmsFull": "https://docs.medusajs.com/llms-full.txt",
23
+ "mcpServer": "https://docs.medusajs.com/mcp",
20
24
  "engines": {
21
25
  "node": ">=22.22.0"
22
26
  },
@@ -29,13 +33,13 @@
29
33
  "watch": "yarn run -T tsc --watch"
30
34
  },
31
35
  "devDependencies": {
32
- "@medusajs/framework": "2.22.0-snapshot-20261020204851"
36
+ "@medusajs/framework": "2.22.0"
33
37
  },
34
38
  "dependencies": {
35
39
  "@sendgrid/mail": "^8.1.6"
36
40
  },
37
41
  "peerDependencies": {
38
- "@medusajs/framework": "2.22.0-snapshot-20261020204851"
42
+ "@medusajs/framework": "2.22.0"
39
43
  },
40
44
  "keywords": [
41
45
  "medusa-provider",