mailchannels-sdk 0.7.9 โ 0.7.11
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 +66 -46
- package/dist/_chunks/simulator.mjs +743 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +50 -0
- package/dist/mailchannels.mjs +94 -93
- package/package.json +15 -12
package/README.md
CHANGED
|
@@ -12,24 +12,19 @@ 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 disclaimer -->
|
|
16
|
-
> [!IMPORTANT]
|
|
17
|
-
> **Disclaimer**: This library is not associated with [MailChannels Corporation](https://mailchannels.com/).
|
|
18
|
-
<!-- #endregion disclaimer -->
|
|
19
|
-
|
|
20
15
|
- [โจ Release Notes](CHANGELOG.md)
|
|
21
16
|
- [๐ Documentation](https://mailchannels.yizack.com)
|
|
22
17
|
|
|
23
18
|
## Contents
|
|
24
19
|
|
|
25
20
|
- ๐ [Features](#features)
|
|
26
|
-
- ๐ [
|
|
21
|
+
- ๐ [Prerequisites](#prerequisites)
|
|
27
22
|
- ๐ฆ [Installation](#installation)
|
|
28
23
|
- ๐ [Usage](#usage)
|
|
29
24
|
- ๐ [Naming Conventions](#naming-conventions)
|
|
25
|
+
- ๐งช [Local simulator](#local-simulator)
|
|
30
26
|
- โ๏ธ [License](#license)
|
|
31
27
|
- ๐ป [Development](#development)
|
|
32
|
-
- ๐งช [Local simulator](#local-simulator)
|
|
33
28
|
|
|
34
29
|
## <a name="features">๐ Features</a>
|
|
35
30
|
|
|
@@ -46,6 +41,7 @@ Some of the things you can do with the SDK:
|
|
|
46
41
|
- Retrieve metrics
|
|
47
42
|
- Inspect webhook delivery batches
|
|
48
43
|
- Handle suppressions
|
|
44
|
+
- Run a local simulator for development testing
|
|
49
45
|
- Configure inbound domains
|
|
50
46
|
- Manage account and recipient lists
|
|
51
47
|
|
|
@@ -53,7 +49,7 @@ Some of the things you can do with the SDK:
|
|
|
53
49
|
> 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
50
|
<!-- #endregion features -->
|
|
55
51
|
|
|
56
|
-
## <a name="
|
|
52
|
+
## <a name="prerequisites">๐ Prerequisites</a>
|
|
57
53
|
|
|
58
54
|
- [Create a MailChannels account](https://www.mailchannels.com/pricing/#for_devs)
|
|
59
55
|
- [Create an API key](https://console.mailchannels.net/settings/accountSettings#APIKeys)
|
|
@@ -106,59 +102,44 @@ Most properties in the MailChannels API use `snake_case`. To follow JavaScript c
|
|
|
106
102
|
- 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
103
|
<!-- #endregion naming-conventions -->
|
|
108
104
|
|
|
109
|
-
## <a name="
|
|
110
|
-
|
|
111
|
-
[MIT License](LICENSE)
|
|
112
|
-
|
|
113
|
-
## <a name="development">๐ป Development</a>
|
|
114
|
-
|
|
115
|
-
<details>
|
|
116
|
-
<summary>Local development</summary>
|
|
117
|
-
|
|
118
|
-
```sh
|
|
119
|
-
# Install dependencies
|
|
120
|
-
pnpm install
|
|
121
|
-
|
|
122
|
-
# Build the package
|
|
123
|
-
pnpm build
|
|
124
|
-
|
|
125
|
-
# Run Oxlint
|
|
126
|
-
pnpm lint
|
|
105
|
+
## <a name="local-simulator">๐งช Local simulator</a>
|
|
127
106
|
|
|
128
|
-
#
|
|
129
|
-
|
|
130
|
-
pnpm test:watch
|
|
107
|
+
<!-- #region simulator -->
|
|
108
|
+
This package includes a local MailChannels simulator you can run via the CLI. It holds state in memory and emulates the SDK-supported endpoints, letting you develop and test your application locally without hitting the real MailChannels service.
|
|
131
109
|
|
|
132
|
-
|
|
133
|
-
|
|
110
|
+
| API | Source |
|
|
111
|
+
| ----------- | -------------------------------------------------------------------------------------------------------------- |
|
|
112
|
+
| Email API | [`src/simulator/email-api.mjs`](https://github.com/Yizack/mailchannels/blob/main/src/simulator/email-api.mjs) |
|
|
113
|
+
| Inbound API | N/A |
|
|
134
114
|
|
|
135
|
-
|
|
136
|
-
|
|
115
|
+
> [!IMPORTANT]
|
|
116
|
+
> The simulator approximates the MailChannels service for local development and testing. It is not a production implementation and may differ from the live service.
|
|
137
117
|
|
|
138
|
-
|
|
139
|
-
pnpm simulate:email-api
|
|
118
|
+
### Start the simulator
|
|
140
119
|
|
|
141
|
-
|
|
142
|
-
|
|
120
|
+
```sh
|
|
121
|
+
# default: http://127.0.0.1:8787
|
|
122
|
+
npx mailchannels-sdk simulate
|
|
143
123
|
```
|
|
144
124
|
|
|
145
|
-
|
|
125
|
+
### Options
|
|
146
126
|
|
|
147
|
-
|
|
127
|
+
| Option | Description | Default |
|
|
128
|
+
| ----------------- | ----------------------- | ----------- |
|
|
129
|
+
| `--port <number>` | Port to listen on | `8787` |
|
|
130
|
+
| `--host <host>` | Host address | `127.0.0.1` |
|
|
131
|
+
| `--silent` | Suppress simulator logs | `false` |
|
|
148
132
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
### Start the simulator
|
|
133
|
+
You can override the bind address with the `--host` and `--port` options:
|
|
152
134
|
|
|
153
135
|
```sh
|
|
154
|
-
|
|
155
|
-
pnpm simulate:email-api
|
|
136
|
+
npx mailchannels-sdk simulate --host 127.0.0.1 --port 8787
|
|
156
137
|
```
|
|
157
138
|
|
|
158
|
-
|
|
139
|
+
Disable logs with the `--silent` option:
|
|
159
140
|
|
|
160
141
|
```sh
|
|
161
|
-
|
|
142
|
+
npx mailchannels-sdk simulate --silent
|
|
162
143
|
```
|
|
163
144
|
|
|
164
145
|
### Point the SDK at the simulator
|
|
@@ -197,6 +178,45 @@ const { data, error } = await mailchannels.emails.send({
|
|
|
197
178
|
- Webhook responses are simulated locally, but the simulator does not yet emit real webhook callbacks to your application
|
|
198
179
|
|
|
199
180
|
The next planned expansion is outbound webhook delivery so client applications can test webhook ingestion flows against the simulator as well.
|
|
181
|
+
<!-- #endregion simulator -->
|
|
182
|
+
|
|
183
|
+
## <a name="license">โ๏ธ License</a>
|
|
184
|
+
|
|
185
|
+
[MIT License](LICENSE)
|
|
186
|
+
|
|
187
|
+
## <a name="development">๐ป Development</a>
|
|
188
|
+
|
|
189
|
+
<details>
|
|
190
|
+
<summary>Local development</summary>
|
|
191
|
+
|
|
192
|
+
```sh
|
|
193
|
+
# Install dependencies
|
|
194
|
+
pnpm install
|
|
195
|
+
|
|
196
|
+
# Build the package
|
|
197
|
+
pnpm build
|
|
198
|
+
|
|
199
|
+
# Run Oxlint
|
|
200
|
+
pnpm lint
|
|
201
|
+
|
|
202
|
+
# Run Vitest
|
|
203
|
+
pnpm test
|
|
204
|
+
pnpm test:watch
|
|
205
|
+
|
|
206
|
+
# Run typecheck
|
|
207
|
+
pnpm test:types
|
|
208
|
+
|
|
209
|
+
# Refresh API parity fixtures
|
|
210
|
+
pnpm parity:fixtures
|
|
211
|
+
|
|
212
|
+
# Run the local simulator
|
|
213
|
+
pnpm simulate
|
|
214
|
+
|
|
215
|
+
# Release new version
|
|
216
|
+
pnpm release
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
</details>
|
|
200
220
|
|
|
201
221
|
<!-- Badges -->
|
|
202
222
|
[npm-version-src]: https://img.shields.io/npm/v/mailchannels-sdk.svg?style=flat&colorA=070a30&colorB=35a047
|