@schemavaults/send-email 0.2.1 → 0.3.1

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
@@ -51,6 +51,36 @@ await sendEmail({
51
51
  });
52
52
  ```
53
53
 
54
+ ### Choose a transport
55
+
56
+ When the target `@schemavaults/mail-server` instance has more than one transport configured, the optional `transport` field selects which one delivers the email. Omit it to let the mail-server use its default transport.
57
+
58
+ ```ts
59
+ await sendEmail({
60
+ body: {
61
+ to: "user@example.com",
62
+ subject: "Hello",
63
+ message: { text: "Hello.", html: "<p>Hello.</p>" },
64
+ transport: "smtp-primary",
65
+ },
66
+ });
67
+
68
+ // Equivalently, as a call-level override (sets `body.transport`):
69
+ await sendEmail({
70
+ transport: "smtp-primary",
71
+ body: { to: "user@example.com", subject: "Hello", message: { /* ... */ } },
72
+ });
73
+ ```
74
+
75
+ The same applies to `sendEmailToMailingList()`, and to the CLI via the global `--transport <name>` flag:
76
+
77
+ ```bash
78
+ bunx schemavaults-send-email --transport smtp-primary send \
79
+ --to user@example.com --subject "Hello" --text "Hello." --html "<p>Hello.</p>"
80
+ ```
81
+
82
+ Transport names are defined by whoever configures the mail-server; this package only validates that the value looks like an identifier. An unknown transport name is rejected by the mail-server, not by the client.
83
+
54
84
  ### Send to a mailing list
55
85
 
56
86
  ```ts
@@ -109,6 +139,8 @@ interface ISendEmailOpts {
109
139
  bearerToken?: string; // overrides SCHEMAVAULTS_MAIL_API_KEY
110
140
  mailServerUrl?: string; // overrides resolved server URL
111
141
  environment?: "production" | "development" | "staging";
142
+ dryRun?: boolean; // convenience; sets body.dryRun
143
+ transport?: string; // convenience; sets body.transport
112
144
  }
113
145
  ```
114
146
 
@@ -123,6 +155,8 @@ interface ISendEmailToMailingListOpts {
123
155
  bearerToken?: string;
124
156
  mailServerUrl?: string;
125
157
  environment?: "production" | "development" | "staging";
158
+ dryRun?: boolean; // convenience; sets body.dryRun
159
+ transport?: string; // convenience; sets body.transport
126
160
  }
127
161
  ```
128
162
 
@@ -159,6 +193,10 @@ Returns a Zod schema for validating send-email request bodies. Pass `true` to al
159
193
 
160
194
  Zod schema for validating template IDs: lowercase alphanumeric with hyphens/underscores, 1-64 characters, must start with a letter.
161
195
 
196
+ ### `transportIdSchema`
197
+
198
+ Zod schema for validating transport names: lowercase alphanumeric with hyphens/underscores, 1-64 characters, must start with a lowercase letter and end with a lowercase alphanumeric character. Whether a well-formed name corresponds to a transport the mail-server actually has configured is decided server-side.
199
+
162
200
  ## Request body shape
163
201
 
164
202
  The `message` field accepts either a template reference or raw content:
@@ -176,6 +214,8 @@ type SendEmailRequestBody = {
176
214
  replyTo?: string;
177
215
  cc?: string | string[];
178
216
  bcc?: string | string[];
217
+ dryRun?: boolean; // server validates without dispatching
218
+ transport?: string; // which mail-server transport delivers this email
179
219
  };
180
220
  ```
181
221
 
package/bun.lock CHANGED
@@ -5,8 +5,8 @@
5
5
  "": {
6
6
  "name": "@schemavaults/send-email",
7
7
  "dependencies": {
8
- "commander": "^14.0.1",
9
- "zod": "3.25.8",
8
+ "commander": "14.0.1",
9
+ "zod": "4.4.3",
10
10
  },
11
11
  "devDependencies": {
12
12
  "@eslint/js": "9.39.1",
@@ -168,7 +168,7 @@
168
168
 
169
169
  "color-name": ["color-name@1.1.4", "", {}, "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="],
170
170
 
171
- "commander": ["commander@14.0.3", "", {}, "sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw=="],
171
+ "commander": ["commander@14.0.1", "", {}, "sha512-2JkV3gUZUVrbNA+1sjBOYLsMZ5cEEl8GTFP2a4AVz5hvasAMCQ1D2l2le/cX+pV4N6ZU17zjUahLpIXRrnWL8A=="],
172
172
 
173
173
  "concat-map": ["concat-map@0.0.1", "", {}, "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="],
174
174
 
@@ -352,7 +352,7 @@
352
352
 
353
353
  "yocto-queue": ["yocto-queue@0.1.0", "", {}, "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q=="],
354
354
 
355
- "zod": ["zod@3.25.8", "", {}, "sha512-iJPWX8HoZ2VE21VrhHGU9jVo/kVDUQyqM9vF0MxDhW/fp2sAl1eVwGJgiYZdHGiMwQJImXIW80lKk0MnfDxqiQ=="],
355
+ "zod": ["zod@4.4.3", "", {}, "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ=="],
356
356
 
357
357
  "@eslint-community/eslint-utils/eslint-visitor-keys": ["eslint-visitor-keys@3.4.3", "", {}, "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag=="],
358
358