mailchannels-sdk 0.7.5 โ†’ 0.7.7

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/README.md CHANGED
@@ -12,10 +12,10 @@ Node.js SDK to integrate [MailChannels API](https://docs.mailchannels.net/) into
12
12
  This library provides a simple way to interact with the [MailChannels API](https://docs.mailchannels.net/). It is written in TypeScript and can be used in both JavaScript and TypeScript projects and in different runtimes.
13
13
  <!-- #endregion overview -->
14
14
 
15
- <!-- #region note -->
15
+ <!-- #region disclaimer -->
16
16
  > [!IMPORTANT]
17
17
  > **Disclaimer**: This library is not associated with [MailChannels Corporation](https://mailchannels.com/).
18
- <!-- #endregion note -->
18
+ <!-- #endregion disclaimer -->
19
19
 
20
20
  - [โœจ Release Notes](CHANGELOG.md)
21
21
  - [๐Ÿ“– Documentation](https://mailchannels.yizack.com)
@@ -24,31 +24,43 @@ This library provides a simple way to interact with the [MailChannels API](https
24
24
 
25
25
  - ๐Ÿš€ [Features](#features)
26
26
  - ๐Ÿ“ [Requirements](#requirements)
27
- - ๐Ÿƒ [Quick setup](#quick-setup)
28
- - ๐Ÿšง [Roadmap](#roadmap)
27
+ - ๐Ÿ“ฆ [Installation](#installation)
28
+ - ๐Ÿ“š [Usage](#usage)
29
+ - ๐Ÿ“ [Naming Conventions](#naming-conventions)
29
30
  - โš–๏ธ [License](#license)
30
31
  - ๐Ÿ’ป [Development](#development)
32
+ - ๐Ÿงช [Local simulator](#local-simulator)
31
33
 
32
34
  ## <a name="features">๐Ÿš€ Features</a>
33
35
 
36
+ <!-- #region features -->
37
+ This SDK fully supports all features and operations available in the [MailChannels API](https://docs.mailchannels.net/). It is actively maintained to ensure compatibility and to quickly add support for new API features as they are released.
38
+
39
+ Some of the things you can do with the SDK:
40
+
34
41
  - Send transactional emails
35
42
  - Check DKIM, SPF & Domain Lockdown
36
43
  - Configure DKIM keys
37
44
  - Webhook notifications
38
45
  - Manage sub-accounts
39
46
  - Retrieve metrics
47
+ - Inspect webhook delivery batches
40
48
  - Handle suppressions
41
49
  - Configure inbound domains
42
50
  - Manage account and recipient lists
43
51
 
52
+ > [!TIP]
53
+ > For a detailed reference mapping each SDK method to its corresponding MailChannels API endpoint reference, see the [SDK-API Mapping](https://mailchannels.yizack.com/sdk-api-mapping)
54
+ <!-- #endregion features -->
55
+
44
56
  ## <a name="requirements">๐Ÿ“ Requirements</a>
45
57
 
46
58
  - [Create a MailChannels account](https://www.mailchannels.com/pricing/#for_devs)
47
59
  - [Create an API key](https://console.mailchannels.net/settings/accountSettings#APIKeys)
48
60
 
49
- ## <a name="quick-setup">๐Ÿƒ Quick setup</a>
61
+ ## <a name="installation">๐Ÿ“ฆ Installation</a>
50
62
 
51
- 1. Add `mailchannels-sdk` dependency to your project
63
+ Add `mailchannels-sdk` dependency to your project
52
64
 
53
65
  ```sh
54
66
  # npm
@@ -61,92 +73,43 @@ yarn add mailchannels-sdk
61
73
  pnpm add mailchannels-sdk
62
74
  ```
63
75
 
76
+ ## <a name="usage">๐Ÿ“š Usage</a>
77
+
78
+ To authenticate, you'll need an API key. You can create and manage API keys in **Dashboard** > **Account Settings** > **API Keys**.
79
+
80
+ Pass your API key while initializing a new MailChannels client.
81
+
82
+ ```ts
83
+ import { MailChannels } from 'mailchannels-sdk'
84
+
85
+ const mailchannels = new MailChannels('your-api-key')
86
+ ```
87
+
88
+ Send an email:
89
+
90
+ ```ts
91
+ const { data, error } = await mailchannels.emails.send({
92
+ from: 'Name <from@example.com>',
93
+ to: 'to@example.com',
94
+ subject: 'Test email',
95
+ html: '<p>Hello World</p>'
96
+ })
97
+ ```
98
+
99
+ ## <a name="naming-conventions">๐Ÿ“ Naming Conventions</a>
100
+
101
+ <!-- #region naming-conventions -->
102
+ Most properties in the MailChannels API use `snake_case`. To follow JavaScript conventions, the SDK adopts `camelCase` for all properties. This means:
103
+
104
+ - Most options and responses match the API docs, but field names are `camelCase` rather than `snake_case`.
105
+ - Some fields are grouped into nested objects or renamed for simplicity and better developer experience.
106
+ - While most fields match the API docs (just with `camelCase`), a few may be simplified or reorganized to feel more natural for JavaScript developers.
107
+ <!-- #endregion naming-conventions -->
108
+
64
109
  ## <a name="license">โš–๏ธ License</a>
65
110
 
66
111
  [MIT License](LICENSE)
67
112
 
68
- <!-- #region roadmap -->
69
- ## <a name="roadmap">๐Ÿšง Roadmap</a>
70
-
71
- Already implemented features are marked with a checkmark. Please open an issue if you find any bugs or missing features.
72
-
73
- > [!NOTE]
74
- > Links below point to the official MailChannels API documentation, options and responses may differ slightly when using this SDK. Please refer to the [documentation](https://mailchannels.yizack.com) for the correct usage of each feature.
75
-
76
- ### [Email API](https://docs.mailchannels.net/email-api/api-reference/email-api)
77
-
78
- - ๐Ÿ“ง Emails
79
- - โœ… [Send an Email](https://docs.mailchannels.net/email-api/api-reference/send-an-email)
80
- - โœ… [Send an Email Asynchronously](https://docs.mailchannels.net/email-api/api-reference/send-an-email-asynchronously)
81
- - โœ… [DKIM, SPF & Domain Lockdown Check](https://docs.mailchannels.net/email-api/api-reference/dkim-spf-domain-lockdown-check)
82
- - โœ… [Create DKIM Key Pair](https://docs.mailchannels.net/email-api/api-reference/create-dkim-key-pair)
83
- - โœ… [Retrieve DKIM Keys](https://docs.mailchannels.net/email-api/api-reference/retrieve-dkim-keys)
84
- - โœ… [Update DKIM Key Status](https://docs.mailchannels.net/email-api/api-reference/update-dkim-key-status)
85
- - โœ… [Rotate DKIM Key Pair](https://docs.mailchannels.net/email-api/api-reference/rotate-dkim-key-pair)
86
- - ๐Ÿ“ข Webhooks
87
- - โœ… [Enroll for Webhook Notifications](https://docs.mailchannels.net/email-api/api-reference/enroll-for-webhook-notifications)
88
- - โœ… [Retrieve Customer Webhooks](https://docs.mailchannels.net/email-api/api-reference/retrieve-customer-webhooks)
89
- - โœ… [Delete Customer Webhooks](https://docs.mailchannels.net/email-api/api-reference/delete-customer-webhooks)
90
- - โœ… [Retrieve Webhook Signing Key](https://docs.mailchannels.net/email-api/api-reference/retrieve-webhook-signing-key)
91
- - โœ… [Validate Enrolled Webhook](https://docs.mailchannels.net/email-api/api-reference/validate-enrolled-webhook)
92
- - ๐Ÿชช Sub-accounts
93
- - โœ… [Create Sub-account](https://docs.mailchannels.net/email-api/api-reference/create-sub-account)
94
- - โœ… [Retrieve Sub-accounts](https://docs.mailchannels.net/email-api/api-reference/retrieve-sub-accounts)
95
- - โœ… [Delete Sub-account](https://docs.mailchannels.net/email-api/api-reference/delete-sub-account)
96
- - โœ… [Suspend Sub-account](https://docs.mailchannels.net/email-api/api-reference/suspend-sub-account)
97
- - โœ… [Activate Sub-account](https://docs.mailchannels.net/email-api/api-reference/activate-sub-account)
98
- - โœ… [Create Sub-account API Key](https://docs.mailchannels.net/email-api/api-reference/create-sub-account-api-key)
99
- - โœ… [Delete Sub-account API Key](https://docs.mailchannels.net/email-api/api-reference/delete-sub-account-api-key)
100
- - โœ… [Retrieve Sub-account API Keys](https://docs.mailchannels.net/email-api/api-reference/retrieve-sub-account-api-keys)
101
- - โœ… [Create Sub-account SMTP Password](https://docs.mailchannels.net/email-api/api-reference/create-sub-account-smtp-password)
102
- - โœ… [Delete Sub-account SMTP Password](https://docs.mailchannels.net/email-api/api-reference/delete-sub-account-smtp-password)
103
- - โœ… [Retrieve Sub-account SMTP Passwords](https://docs.mailchannels.net/email-api/api-reference/retrieve-sub-account-smtp-passwords)
104
- - โœ… [Retrieve Sub-account Limit](https://docs.mailchannels.net/email-api/api-reference/retrieve-sub-account-limit)
105
- - โœ… [Set Sub-account Limit](https://docs.mailchannels.net/email-api/api-reference/set-sub-account-limit)
106
- - โœ… [Delete Sub-account Limit](https://docs.mailchannels.net/email-api/api-reference/delete-sub-account-limit)
107
- - โœ… [Retrieve Sub-account Usage Stats](https://docs.mailchannels.net/email-api/api-reference/retrieve-sub-account-usage-stats)
108
- - ๐Ÿ“Š Metrics
109
- - โœ… [Retrieve Engagement Metrics](https://docs.mailchannels.net/email-api/api-reference/retrieve-engagement-metrics)
110
- - โœ… [Retrieve Performance Metrics](https://docs.mailchannels.net/email-api/api-reference/retrieve-performance-metrics)
111
- - โœ… [Retrieve Recipient Behaviour Metrics](https://docs.mailchannels.net/email-api/api-reference/retrieve-recipient-behaviour-metrics)
112
- - โœ… [Retrieve Usage Stats](https://docs.mailchannels.net/email-api/api-reference/retrieve-usage-stats)
113
- - โœ… [Retrieve Volume Metrics](https://docs.mailchannels.net/email-api/api-reference/retrieve-volume-metrics)
114
- - โœ… [Retrieve Sender Metrics](https://docs.mailchannels.net/email-api/api-reference/retrieve-sender-metrics)
115
- - ๐Ÿšซ Suppressions
116
- - โœ… [Create Suppression Entries](https://docs.mailchannels.net/email-api/api-reference/create-suppression-entries)
117
- - โœ… [Delete Suppression Entry](https://docs.mailchannels.net/email-api/api-reference/delete-suppression-entry)
118
- - โœ… [Retrieve Suppression List](https://docs.mailchannels.net/email-api/api-reference/retrieve-suppression-list)
119
-
120
- ### [Inbound API](https://docs.mailchannels.net/inbound-api/API-reference/inbound-api)
121
-
122
- - ๐ŸŒ Domains
123
- - โœ… [Provision domain](https://docs.mailchannels.net/inbound-api/API-reference/provision-domain)
124
- - โœ… [Remove domain](https://docs.mailchannels.net/inbound-api/API-reference/remove-domain)
125
- - โœ… [List domains](https://docs.mailchannels.net/inbound-api/API-reference/list-domains)
126
- - โœ… [Bulk provision domains](https://docs.mailchannels.net/inbound-api/API-reference/bulk-provision-domains)
127
- - โœ… [Add domain list entry](https://docs.mailchannels.net/inbound-api/API-reference/add-domain-list-entry)
128
- - โœ… [Get domain list entries](https://docs.mailchannels.net/inbound-api/API-reference/get-domain-list-entries)
129
- - โœ… [Delete domain list entry](https://docs.mailchannels.net/inbound-api/API-reference/delete-domain-list-entry)
130
- - โœ… [Create login link](https://docs.mailchannels.net/inbound-api/API-reference/create-login-link)
131
- - โœ… [Bulk create login links](https://docs.mailchannels.net/inbound-api/API-reference/bulk-create-login-links)
132
- - โœ… [Set downstream address](https://docs.mailchannels.net/inbound-api/API-reference/set-downstream-address)
133
- - โœ… [Fetch downstream addresses](https://docs.mailchannels.net/inbound-api/API-reference/fetch-downstream-addresses)
134
- - โœ… [Update API key](https://docs.mailchannels.net/inbound-api/API-reference/update-api-key)
135
- - ๐Ÿ“‹ Lists
136
- - โœ… [Add item to customer list](https://docs.mailchannels.net/inbound-api/API-reference/add-item-to-customer-list)
137
- - โœ… [Delete item from customer list](https://docs.mailchannels.net/inbound-api/API-reference/delete-item-from-customer-list)
138
- - โœ… [Get customer list entries](https://docs.mailchannels.net/inbound-api/API-reference/get-customer-list-entries)
139
- - ๐Ÿ“ฅ Users
140
- - โœ… [Create a recipient](https://docs.mailchannels.net/inbound-api/API-reference/create-a-recipient)
141
- - โœ… [Add item to recipient list](https://docs.mailchannels.net/inbound-api/API-reference/add-item-to-recipient-list)
142
- - โœ… [Get recipient list entries](https://docs.mailchannels.net/inbound-api/API-reference/get-recipient-list-entries)
143
- - โœ… [Delete item from recipient list](https://docs.mailchannels.net/inbound-api/API-reference/delete-item-from-recipient-list)
144
- - โš™๏ธ Service
145
- - โœ… [Retrieve the condition of the service](https://docs.mailchannels.net/inbound-api/API-reference/retrieve-the-condition-of-the-service)
146
- - โœ… [Submit a false negative or false positive report](https://docs.mailchannels.net/inbound-api/API-reference/submit-a-false-negative-or-false-positive-report)
147
- - โœ… [Get a list of your subscriptions to MailChannels Inbound](https://docs.mailchannels.net/inbound-api/API-reference/get-a-list-of-your-subscriptions-to-mail-channels-inbound)
148
- <!-- #endregion roadmap -->
149
-
150
113
  ## <a name="development">๐Ÿ’ป Development</a>
151
114
 
152
115
  <details>
@@ -169,12 +132,72 @@ pnpm test:watch
169
132
  # Run typecheck
170
133
  pnpm test:types
171
134
 
135
+ # Refresh API parity fixtures
136
+ pnpm parity:fixtures
137
+
138
+ # Run the local Email API simulator
139
+ pnpm simulate:email-api
140
+
172
141
  # Release new version
173
142
  pnpm release
174
143
  ```
175
144
 
176
145
  </details>
177
146
 
147
+ ## <a name="local-simulator">๐Ÿงช Local simulator</a>
148
+
149
+ This repo includes a small local MailChannels Email API simulator at [scripts/email-api-simulator.mjs](./scripts/email-api-simulator.mjs). It keeps state in memory and emulates the SDK-supported Email API endpoints so you can test your application without calling the real MailChannels service.
150
+
151
+ ### Start the simulator
152
+
153
+ ```sh
154
+ # default: http://127.0.0.1:8787
155
+ pnpm simulate:email-api
156
+ ```
157
+
158
+ You can override the bind address with environment variables:
159
+
160
+ ```sh
161
+ MAILCHANNELS_SIMULATOR_HOST=127.0.0.1 MAILCHANNELS_SIMULATOR_PORT=8787 pnpm simulate:email-api
162
+ ```
163
+
164
+ ### Point the SDK at the simulator
165
+
166
+ Use the optional `baseUrl` constructor option when creating the client:
167
+
168
+ ```ts
169
+ import { MailChannels } from 'mailchannels-sdk'
170
+
171
+ const mailchannels = new MailChannels('local-test-key', {
172
+ baseUrl: 'http://127.0.0.1:8787'
173
+ })
174
+
175
+ const { data, error } = await mailchannels.emails.send({
176
+ from: 'sender@example.com',
177
+ to: 'recipient@example.com',
178
+ subject: 'Hello from the simulator',
179
+ html: '<p>Local test</p>'
180
+ })
181
+ ```
182
+
183
+ ### What the simulator supports today
184
+
185
+ - Email sends and async sends
186
+ - Domain checks
187
+ - DKIM key create, list, rotate, and update
188
+ - Webhook enrollment, listing, validation, signing key lookup, and batch inspection
189
+ - Sub-account lifecycle, API keys, SMTP passwords, limits, and usage
190
+ - Engagement, performance, recipient behaviour, sender, volume, and usage metrics
191
+ - Suppression create, list, and delete
192
+
193
+ ### Current limitations
194
+
195
+ - State is in-memory only and is reset when the process stops
196
+ - Any non-empty `X-API-Key` is accepted, with separate in-memory state per API key
197
+ - Webhook responses are simulated locally, but the simulator does not yet emit real webhook callbacks to your application
198
+
199
+ The next planned expansion is outbound webhook delivery so client applications can test webhook ingestion flows against the simulator as well.
200
+
178
201
  <!-- Badges -->
179
202
  [npm-version-src]: https://img.shields.io/npm/v/mailchannels-sdk.svg?style=flat&colorA=070a30&colorB=35a047
180
203
  [npm-version-href]: https://npmjs.com/package/mailchannels-sdk