@schemavaults/send-email 0.3.0 → 0.4.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.
- package/README.md +94 -1
- package/bun.lock +4 -4
- package/dist/cli.js +14377 -3777
- package/dist/cli.js.map +1 -1
- package/dist/create-email-attachment-from-file.d.ts +9 -0
- package/dist/create-email-attachment-from-file.js +27 -0
- package/dist/create-email-attachment-from-file.js.map +1 -0
- package/dist/create-email-attachment.d.ts +43 -0
- package/dist/create-email-attachment.js +58 -0
- package/dist/create-email-attachment.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/send-email-request-body-schema.d.ts +38 -113
- package/dist/send-email-request-body-schema.js +9 -0
- package/dist/send-email-request-body-schema.js.map +1 -1
- package/dist/send-email.d.ts +9 -0
- package/dist/send-email.js +8 -1
- package/dist/send-email.js.map +1 -1
- package/dist/validators/email-attachment-schema.d.ts +64 -0
- package/dist/validators/email-attachment-schema.js +120 -0
- package/dist/validators/email-attachment-schema.js.map +1 -0
- package/package.json +8 -3
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,SAAS;AAET,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,sBAAsB,MAAM,8BAA8B,CAAC;AAClE,OAAO,kBAAkB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,SAAS;AAET,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CA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AAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type EmailAttachmentInput } from "./create-email-attachment.js";
|
|
2
|
+
import type { EmailAttachment } from "./validators/email-attachment-schema.js";
|
|
3
|
+
export type ICreateEmailAttachmentFromFileOpts = Partial<Pick<EmailAttachmentInput, "filename" | "contentType" | "contentId">>;
|
|
4
|
+
/**
|
|
5
|
+
* Read a file from disk and turn it into a validated {@link EmailAttachment}.
|
|
6
|
+
* The file's basename is used as the attachment filename unless overridden.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createEmailAttachmentFromFile(path: string, opts?: ICreateEmailAttachmentFromFileOpts): Promise<EmailAttachment>;
|
|
9
|
+
export default createEmailAttachmentFromFile;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// create-email-attachment-from-file.ts
|
|
2
|
+
//
|
|
3
|
+
// Node/Bun only: reads from the filesystem. Deliberately NOT re-exported from
|
|
4
|
+
// the package's main entry point, which must stay free of `node:` imports so
|
|
5
|
+
// it can be bundled for environments without a filesystem. Import it via the
|
|
6
|
+
// "@schemavaults/send-email/create-email-attachment-from-file" subpath.
|
|
7
|
+
// `src/browser-compatibility.test.ts` enforces this separation.
|
|
8
|
+
import { readFile } from "node:fs/promises";
|
|
9
|
+
import { basename } from "node:path";
|
|
10
|
+
import { createEmailAttachment, } from "./create-email-attachment.js";
|
|
11
|
+
/**
|
|
12
|
+
* Read a file from disk and turn it into a validated {@link EmailAttachment}.
|
|
13
|
+
* The file's basename is used as the attachment filename unless overridden.
|
|
14
|
+
*/
|
|
15
|
+
export async function createEmailAttachmentFromFile(path, opts = {}) {
|
|
16
|
+
const bytes = await readFile(path);
|
|
17
|
+
return createEmailAttachment({
|
|
18
|
+
filename: opts.filename ?? basename(path),
|
|
19
|
+
content: bytes,
|
|
20
|
+
...(opts.contentType !== undefined
|
|
21
|
+
? { contentType: opts.contentType }
|
|
22
|
+
: {}),
|
|
23
|
+
...(opts.contentId !== undefined ? { contentId: opts.contentId } : {}),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export default createEmailAttachmentFromFile;
|
|
27
|
+
//# sourceMappingURL=create-email-attachment-from-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-email-attachment-from-file.js","sourceRoot":"","sources":["../src/create-email-attachment-from-file.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,6EAA6E;AAC7E,wEAAwE;AACxE,gEAAgE;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EACL,qBAAqB,GAEtB,MAAM,2BAA2B,CAAC;AAOnC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,IAAY,EACZ,OAA2C,EAAE;IAE7C,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO,qBAAqB,CAAC;QAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC;QACzC,OAAO,EAAE,KAAK;QACd,GAAG,CAAC,IAAI,CAAC,WAAW,KAAK,SAAS;YAChC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;YACnC,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvE,CAAC,CAAC;AACL,CAAC;AAED,eAAe,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type EmailAttachment } from "./validators/email-attachment-schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Input accepted by {@link createEmailAttachment}. A ready-made
|
|
4
|
+
* {@link EmailAttachment} is also valid input (its `content` is base64,
|
|
5
|
+
* which is the default string interpretation), so the two can be mixed
|
|
6
|
+
* freely in `ISendEmailOpts.attachments`.
|
|
7
|
+
*/
|
|
8
|
+
export interface EmailAttachmentInput {
|
|
9
|
+
/** Name the recipient's mail client shows for the file. */
|
|
10
|
+
filename: string;
|
|
11
|
+
/**
|
|
12
|
+
* The file's bytes. Binary data may be passed as a `Uint8Array` (Node's
|
|
13
|
+
* `Buffer` included) or an `ArrayBuffer`. A string is treated as
|
|
14
|
+
* base64-encoded bytes -- the request body's wire format -- unless
|
|
15
|
+
* `encoding` is set to "utf8", in which case the string itself is the
|
|
16
|
+
* file's (plain-text) content.
|
|
17
|
+
*/
|
|
18
|
+
content: string | Uint8Array | ArrayBuffer;
|
|
19
|
+
/**
|
|
20
|
+
* How to interpret a string `content`. Ignored for binary content.
|
|
21
|
+
* - "base64" (default): `content` is already base64-encoded.
|
|
22
|
+
* - "utf8": `content` is the file's text and will be encoded here.
|
|
23
|
+
*/
|
|
24
|
+
encoding?: "base64" | "utf8";
|
|
25
|
+
/** MIME type; derived from the filename's extension when omitted. */
|
|
26
|
+
contentType?: string;
|
|
27
|
+
/** Content-ID for inline use via `cid:` references in the HTML body. */
|
|
28
|
+
contentId?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Base64-encode raw bytes, with the standard alphabet and padding. Uses
|
|
32
|
+
* `Buffer` where available (Node, Bun) and falls back to `btoa` elsewhere.
|
|
33
|
+
*/
|
|
34
|
+
export declare function encodeBytesAsBase64(bytes: Uint8Array): string;
|
|
35
|
+
/**
|
|
36
|
+
* Build a validated {@link EmailAttachment} for `body.attachments`, taking
|
|
37
|
+
* care of base64-encoding binary or plain-text content.
|
|
38
|
+
*
|
|
39
|
+
* @throws TypeError when the resulting attachment fails validation (bad
|
|
40
|
+
* filename, malformed base64, unsupported content type, ...).
|
|
41
|
+
*/
|
|
42
|
+
export declare function createEmailAttachment(input: EmailAttachmentInput): EmailAttachment;
|
|
43
|
+
export default createEmailAttachment;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// create-email-attachment.ts
|
|
2
|
+
import { emailAttachmentSchema, } from "./validators/email-attachment-schema.js";
|
|
3
|
+
/**
|
|
4
|
+
* Base64-encode raw bytes, with the standard alphabet and padding. Uses
|
|
5
|
+
* `Buffer` where available (Node, Bun) and falls back to `btoa` elsewhere.
|
|
6
|
+
*/
|
|
7
|
+
export function encodeBytesAsBase64(bytes) {
|
|
8
|
+
if (typeof Buffer !== "undefined" && typeof Buffer.from === "function") {
|
|
9
|
+
return Buffer.from(bytes).toString("base64");
|
|
10
|
+
}
|
|
11
|
+
let binary = "";
|
|
12
|
+
const CHUNK_SIZE = 0x8000;
|
|
13
|
+
for (let i = 0; i < bytes.length; i += CHUNK_SIZE) {
|
|
14
|
+
binary += String.fromCharCode(...bytes.subarray(i, i + CHUNK_SIZE));
|
|
15
|
+
}
|
|
16
|
+
return btoa(binary);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Build a validated {@link EmailAttachment} for `body.attachments`, taking
|
|
20
|
+
* care of base64-encoding binary or plain-text content.
|
|
21
|
+
*
|
|
22
|
+
* @throws TypeError when the resulting attachment fails validation (bad
|
|
23
|
+
* filename, malformed base64, unsupported content type, ...).
|
|
24
|
+
*/
|
|
25
|
+
export function createEmailAttachment(input) {
|
|
26
|
+
let content;
|
|
27
|
+
if (typeof input.content === "string") {
|
|
28
|
+
content =
|
|
29
|
+
input.encoding === "utf8"
|
|
30
|
+
? encodeBytesAsBase64(new TextEncoder().encode(input.content))
|
|
31
|
+
: input.content;
|
|
32
|
+
}
|
|
33
|
+
else if (input.content instanceof Uint8Array) {
|
|
34
|
+
content = encodeBytesAsBase64(input.content);
|
|
35
|
+
}
|
|
36
|
+
else if (input.content instanceof ArrayBuffer) {
|
|
37
|
+
content = encodeBytesAsBase64(new Uint8Array(input.content));
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
throw new TypeError("Expected attachment 'content' to be a string, Uint8Array or ArrayBuffer!", { cause: `Received type '${typeof input.content}'` });
|
|
41
|
+
}
|
|
42
|
+
const candidate = {
|
|
43
|
+
filename: input.filename,
|
|
44
|
+
content,
|
|
45
|
+
...(input.contentType !== undefined
|
|
46
|
+
? { contentType: input.contentType }
|
|
47
|
+
: {}),
|
|
48
|
+
...(input.contentId !== undefined ? { contentId: input.contentId } : {}),
|
|
49
|
+
};
|
|
50
|
+
const parsed = emailAttachmentSchema.safeParse(candidate);
|
|
51
|
+
if (!parsed.success) {
|
|
52
|
+
const reasons = parsed.error.issues.map((issue) => issue.message);
|
|
53
|
+
throw new TypeError(`Invalid email attachment '${String(input.filename)}': ${reasons.join(" ")}`);
|
|
54
|
+
}
|
|
55
|
+
return parsed.data;
|
|
56
|
+
}
|
|
57
|
+
export default createEmailAttachment;
|
|
58
|
+
//# sourceMappingURL=create-email-attachment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-email-attachment.js","sourceRoot":"","sources":["../src/create-email-attachment.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAE7B,OAAO,EAEL,qBAAqB,GACtB,MAAM,sCAAsC,CAAC;AA+B9C;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAiB;IACnD,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACvE,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;IACD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,MAAM,UAAU,GAAG,MAAM,CAAC;IAC1B,KAAK,IAAI,CAAC,GAAG,CAA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AC,EAAE,CAAC;QACP,GAAG,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzE,CAAC;IAEF,MAAM,MAAM,GAAG,qBAAqB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAC1D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAClE,MAAM,IAAI,SAAS,CACjB,6BAA6B,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAC7E,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED,eAAe,qBAAqB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,10 @@ export { sendEmailRequestBodySchema, createSendEmailRequestBodySchema, } from ".
|
|
|
2
2
|
export type { SendEmailRequestBody } from "./send-email-request-body-schema.js";
|
|
3
3
|
export { emailTemplateIdSchema } from "./validators/email-template-id-schema.js";
|
|
4
4
|
export { transportIdSchema } from "./validators/transport-id-schema.js";
|
|
5
|
+
export { emailAttachmentSchema, emailAttachmentsSchema, MAX_ATTACHMENTS_PER_EMAIL, MAX_TOTAL_ATTACHMENT_BYTES, } from "./validators/email-attachment-schema.js";
|
|
6
|
+
export type { EmailAttachment } from "./validators/email-attachment-schema.js";
|
|
7
|
+
export { createEmailAttachment } from "./create-email-attachment.js";
|
|
8
|
+
export type { EmailAttachmentInput } from "./create-email-attachment.js";
|
|
5
9
|
export { sendEmail, sendEmail as default, } from "./send-email.js";
|
|
6
10
|
export type { ISendEmailOpts } from './send-email.js';
|
|
7
11
|
export { getSchemaVaultsMailApiKey, } from "./env/get-api-key.js";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { sendEmailRequestBodySchema, createSendEmailRequestBodySchema, } from "./send-email-request-body-schema.js";
|
|
2
2
|
export { emailTemplateIdSchema } from "./validators/email-template-id-schema.js";
|
|
3
3
|
export { transportIdSchema } from "./validators/transport-id-schema.js";
|
|
4
|
+
export { emailAttachmentSchema, emailAttachmentsSchema, MAX_ATTACHMENTS_PER_EMAIL, MAX_TOTAL_ATTACHMENT_BYTES, } from "./validators/email-attachment-schema.js";
|
|
5
|
+
export { createEmailAttachment } from "./create-email-attachment.js";
|
|
4
6
|
export { sendEmail, sendEmail as default, } from "./send-email.js";
|
|
5
7
|
export { getSchemaVaultsMailApiKey, } from "./env/get-api-key.js";
|
|
6
8
|
export { getSchemaVaultsMailingListId, } from "./env/get-mailing-list-id.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,GACjC,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAE9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,EACL,SAAS,EACT,SAAS,IAAI,OAAO,GACrB,MAAM,cAAc,CAAC;AAKtB,OAAO,EACL,yBAAyB,GAC1B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,4BAA4B,GAC7B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,gBAAgB,EACjB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EACL,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,GACjC,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAE9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EACL,SAAS,EACT,SAAS,IAAI,OAAO,GACrB,MAAM,cAAc,CAAC;AAKtB,OAAO,EACL,yBAAyB,GAC1B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,4BAA4B,GAC7B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,gBAAgB,EACjB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EACL,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -1,71 +1,33 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare function createRecipientSchema(allow_mailing_list_ids_as_recipients?: boolean): z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString
|
|
2
|
+
export declare function createRecipientSchema(allow_mailing_list_ids_as_recipients?: boolean): z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodString]> | z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
5
5
|
* @param allow_mailing_list_ids_as_recipients
|
|
6
6
|
* @returns Schema for validating send-email request body
|
|
7
7
|
*/
|
|
8
8
|
export declare function createSendEmailRequestBodySchema(allow_mailing_list_ids_as_recipients?: boolean): z.ZodObject<{
|
|
9
|
-
|
|
10
|
-
template_id: z.ZodString;
|
|
11
|
-
template_props: z.ZodUnknown;
|
|
12
|
-
}, "strict", z.ZodTypeAny, {
|
|
13
|
-
template_id: string;
|
|
14
|
-
template_props?: unknown;
|
|
15
|
-
}, {
|
|
16
|
-
template_id: string;
|
|
17
|
-
template_props?: unknown;
|
|
18
|
-
}>, z.ZodObject<{
|
|
19
|
-
text: z.ZodString;
|
|
20
|
-
html: z.ZodString;
|
|
21
|
-
}, "strict", z.ZodTypeAny, {
|
|
22
|
-
text: string;
|
|
23
|
-
html: string;
|
|
24
|
-
}, {
|
|
25
|
-
text: string;
|
|
26
|
-
html: string;
|
|
27
|
-
}>]>;
|
|
28
|
-
to: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodString]> | z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
9
|
+
to: z.ZodNonOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodString]> | z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
29
10
|
from: z.ZodOptional<z.ZodString>;
|
|
30
|
-
subject: z.ZodString
|
|
11
|
+
subject: z.ZodNonOptional<z.ZodString>;
|
|
12
|
+
message: z.ZodNonOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
13
|
+
template_id: z.ZodNonOptional<z.ZodString>;
|
|
14
|
+
template_props: z.ZodUnknown;
|
|
15
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
16
|
+
text: z.ZodNonOptional<z.ZodString>;
|
|
17
|
+
html: z.ZodNonOptional<z.ZodString>;
|
|
18
|
+
}, z.core.$strict>]>>;
|
|
31
19
|
replyTo: z.ZodOptional<z.ZodString>;
|
|
32
|
-
cc: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString
|
|
33
|
-
bcc: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString
|
|
20
|
+
cc: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
21
|
+
bcc: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
34
22
|
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
35
23
|
transport: z.ZodOptional<z.ZodString>;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
to: string | string[];
|
|
45
|
-
subject: string;
|
|
46
|
-
from?: string | undefined;
|
|
47
|
-
replyTo?: string | undefined;
|
|
48
|
-
cc?: string | string[] | undefined;
|
|
49
|
-
bcc?: string | string[] | undefined;
|
|
50
|
-
dryRun?: boolean | undefined;
|
|
51
|
-
transport?: string | undefined;
|
|
52
|
-
}, {
|
|
53
|
-
message: {
|
|
54
|
-
template_id: string;
|
|
55
|
-
template_props?: unknown;
|
|
56
|
-
} | {
|
|
57
|
-
text: string;
|
|
58
|
-
html: string;
|
|
59
|
-
};
|
|
60
|
-
to: string | string[];
|
|
61
|
-
subject: string;
|
|
62
|
-
from?: string | undefined;
|
|
63
|
-
replyTo?: string | undefined;
|
|
64
|
-
cc?: string | string[] | undefined;
|
|
65
|
-
bcc?: string | string[] | undefined;
|
|
66
|
-
dryRun?: boolean | undefined;
|
|
67
|
-
transport?: string | undefined;
|
|
68
|
-
}>;
|
|
24
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
25
|
+
filename: z.ZodNonOptional<z.ZodString>;
|
|
26
|
+
content: z.ZodNonOptional<z.ZodBase64>;
|
|
27
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
28
|
+
contentId: z.ZodOptional<z.ZodString>;
|
|
29
|
+
}, z.core.$strict>>>;
|
|
30
|
+
}, z.core.$strict>;
|
|
69
31
|
/**
|
|
70
32
|
* Default send email request body schema
|
|
71
33
|
* @see createSendEmailRequestBodySchema
|
|
@@ -74,65 +36,28 @@ export declare function createSendEmailRequestBodySchema(allow_mailing_list_ids_
|
|
|
74
36
|
* with allow_mailing_list_ids_as_recipients = true to accept UUIDs
|
|
75
37
|
*/
|
|
76
38
|
export declare const sendEmailRequestBodySchema: z.ZodObject<{
|
|
77
|
-
|
|
78
|
-
template_id: z.ZodString;
|
|
79
|
-
template_props: z.ZodUnknown;
|
|
80
|
-
}, "strict", z.ZodTypeAny, {
|
|
81
|
-
template_id: string;
|
|
82
|
-
template_props?: unknown;
|
|
83
|
-
}, {
|
|
84
|
-
template_id: string;
|
|
85
|
-
template_props?: unknown;
|
|
86
|
-
}>, z.ZodObject<{
|
|
87
|
-
text: z.ZodString;
|
|
88
|
-
html: z.ZodString;
|
|
89
|
-
}, "strict", z.ZodTypeAny, {
|
|
90
|
-
text: string;
|
|
91
|
-
html: string;
|
|
92
|
-
}, {
|
|
93
|
-
text: string;
|
|
94
|
-
html: string;
|
|
95
|
-
}>]>;
|
|
96
|
-
to: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodString]> | z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
39
|
+
to: z.ZodNonOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodString]> | z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
97
40
|
from: z.ZodOptional<z.ZodString>;
|
|
98
|
-
subject: z.ZodString
|
|
41
|
+
subject: z.ZodNonOptional<z.ZodString>;
|
|
42
|
+
message: z.ZodNonOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
43
|
+
template_id: z.ZodNonOptional<z.ZodString>;
|
|
44
|
+
template_props: z.ZodUnknown;
|
|
45
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
46
|
+
text: z.ZodNonOptional<z.ZodString>;
|
|
47
|
+
html: z.ZodNonOptional<z.ZodString>;
|
|
48
|
+
}, z.core.$strict>]>>;
|
|
99
49
|
replyTo: z.ZodOptional<z.ZodString>;
|
|
100
|
-
cc: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString
|
|
101
|
-
bcc: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString
|
|
50
|
+
cc: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
51
|
+
bcc: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
102
52
|
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
103
53
|
transport: z.ZodOptional<z.ZodString>;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
};
|
|
112
|
-
to: string | string[];
|
|
113
|
-
subject: string;
|
|
114
|
-
from?: string | undefined;
|
|
115
|
-
replyTo?: string | undefined;
|
|
116
|
-
cc?: string | string[] | undefined;
|
|
117
|
-
bcc?: string | string[] | undefined;
|
|
118
|
-
dryRun?: boolean | undefined;
|
|
119
|
-
transport?: string | undefined;
|
|
120
|
-
}, {
|
|
121
|
-
message: {
|
|
122
|
-
template_id: string;
|
|
123
|
-
template_props?: unknown;
|
|
124
|
-
} | {
|
|
125
|
-
text: string;
|
|
126
|
-
html: string;
|
|
127
|
-
};
|
|
128
|
-
to: string | string[];
|
|
129
|
-
subject: string;
|
|
130
|
-
from?: string | undefined;
|
|
131
|
-
replyTo?: string | undefined;
|
|
132
|
-
cc?: string | string[] | undefined;
|
|
133
|
-
bcc?: string | string[] | undefined;
|
|
134
|
-
dryRun?: boolean | undefined;
|
|
135
|
-
transport?: string | undefined;
|
|
136
|
-
}>;
|
|
54
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
55
|
+
filename: z.ZodNonOptional<z.ZodString>;
|
|
56
|
+
content: z.ZodNonOptional<z.ZodBase64>;
|
|
57
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
58
|
+
contentId: z.ZodOptional<z.ZodString>;
|
|
59
|
+
}, z.core.$strict>>>;
|
|
60
|
+
}, z.core.$strict>;
|
|
137
61
|
export type SendEmailRequestBody = z.infer<typeof sendEmailRequestBodySchema>;
|
|
62
|
+
export type { EmailAttachment } from "./validators/email-attachment-schema.js";
|
|
138
63
|
export default createSendEmailRequestBodySchema;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { emailTemplateIdSchema } from "./validators/email-template-id-schema.js";
|
|
3
3
|
import { transportIdSchema } from "./validators/transport-id-schema.js";
|
|
4
|
+
import { emailAttachmentsSchema } from "./validators/email-attachment-schema.js";
|
|
4
5
|
const sendEmailTemplateOptions = z
|
|
5
6
|
.object({
|
|
6
7
|
template_id: emailTemplateIdSchema,
|
|
@@ -69,6 +70,14 @@ export function createSendEmailRequestBodySchema(allow_mailing_list_ids_as_recip
|
|
|
69
70
|
* mail-server picks its own default transport.
|
|
70
71
|
*/
|
|
71
72
|
transport: transportIdSchema.optional(),
|
|
73
|
+
/**
|
|
74
|
+
* Files to attach to the email. Each attachment carries its bytes as a
|
|
75
|
+
* base64 string (request bodies are JSON); see `createEmailAttachment`
|
|
76
|
+
* for encoding binary or plain-text content. Between 1 and
|
|
77
|
+
* `MAX_ATTACHMENTS_PER_EMAIL` files, totalling at most
|
|
78
|
+
* `MAX_TOTAL_ATTACHMENT_BYTES` once decoded. Omit when there are none.
|
|
79
|
+
*/
|
|
80
|
+
attachments: emailAttachmentsSchema.optional(),
|
|
72
81
|
})
|
|
73
82
|
.required({
|
|
74
83
|
to: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-email-request-body-schema.js","sourceRoot":"","sources":["../src/send-email-request-body-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
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EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;QAC9B;;;;;WAKG;QACH,SAAS,EAAE,iBAAiB,CAAC,QAAQ,EAAE;QACvC;;;;;;WAMG;QACH,WAAW,EAAE,sBAAsB,CAAC,QAAQ,EAAE;KAC/C,CAAC;SACD,QAAQ,CAAC;QACR,EAAE,EAAE,IAAI;QACR,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,IAAI;KACd,CAAC;SACD,MAAM,EAAE,CAAC;AACd,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,gCAAgC,EAAE,CAAC;AAM7E,eAAe,gCAAgC,CAAC"}
|
package/dist/send-email.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type SendEmailRequestBody } from "./send-email-request-body-schema.js";
|
|
2
|
+
import { type EmailAttachmentInput } from "./create-email-attachment.js";
|
|
2
3
|
import getSchemaVaultsMailApiKey from "./env/get-api-key.js";
|
|
3
4
|
export interface ISendEmailOpts {
|
|
4
5
|
body: SendEmailRequestBody;
|
|
@@ -10,6 +11,14 @@ export interface ISendEmailOpts {
|
|
|
10
11
|
* mail-server's configured transports should deliver this email.
|
|
11
12
|
*/
|
|
12
13
|
transport?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Convenience for `body.attachments` -- files to attach to the email.
|
|
16
|
+
* Unlike `body.attachments`, binary content (`Uint8Array`, `Buffer`,
|
|
17
|
+
* `ArrayBuffer`) and plain text (`encoding: "utf8"`) are accepted here
|
|
18
|
+
* and base64-encoded for you; see `createEmailAttachment`. Appended after
|
|
19
|
+
* any attachments already present on `body`.
|
|
20
|
+
*/
|
|
21
|
+
attachments?: EmailAttachmentInput[];
|
|
13
22
|
}
|
|
14
23
|
export { getSchemaVaultsMailApiKey };
|
|
15
24
|
export declare function sendEmail({ body, ...opts }: ISendEmailOpts): Promise<void>;
|
package/dist/send-email.js
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
// send-email.ts
|
|
2
2
|
import { createSendEmailRequestBodySchema, } from "./send-email-request-body-schema.js";
|
|
3
|
+
import { createEmailAttachment, } from "./create-email-attachment.js";
|
|
3
4
|
import getSchemaVaultsMailApiKey from "./env/get-api-key.js";
|
|
4
5
|
import parseMailServerUrlWithEnvFallback from "./parse-mail-server-url-with-env-fallback.js";
|
|
5
6
|
const body_schema = createSendEmailRequestBodySchema(true);
|
|
6
7
|
export { getSchemaVaultsMailApiKey };
|
|
7
8
|
export async function sendEmail({ body, ...opts }) {
|
|
9
|
+
const { attachments: bodyAttachments, ...bodyWithoutAttachments } = body;
|
|
10
|
+
const attachments = [
|
|
11
|
+
...(bodyAttachments ?? []),
|
|
12
|
+
...(opts.attachments ?? []).map(createEmailAttachment),
|
|
13
|
+
];
|
|
8
14
|
const effectiveBody = {
|
|
9
|
-
...
|
|
15
|
+
...bodyWithoutAttachments,
|
|
10
16
|
...(typeof opts.dryRun === "boolean" ? { dryRun: opts.dryRun } : {}),
|
|
11
17
|
...(typeof opts.transport === "string" ? { transport: opts.transport } : {}),
|
|
18
|
+
...(attachments.length > 0 ? { attachments } : {}),
|
|
12
19
|
};
|
|
13
20
|
const parsed = await body_schema.safeParseAsync(effectiveBody);
|
|
14
21
|
if (!parsed.success) {
|
package/dist/send-email.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-email.js","sourceRoot":"","sources":["../src/send-email.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAEhB,OAAO,EAEL,gCAAgC,GACjC,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"send-email.js","sourceRoot":"","sources":["../src/send-email.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAEhB,OAAO,EAEL,gCAAgC,GACjC,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,qBAAqB,GAEtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,yBAAyB,MAAM,mBAAmB,CAAC;AAC1D,OAAO,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,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IACD,IAAI,CAAC,CAAC,SAAS,IAAI,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IAED,OAAO;AACT,CAAC;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Maximum number of attachments accepted on a single email.
|
|
4
|
+
*/
|
|
5
|
+
export declare const MAX_ATTACHMENTS_PER_EMAIL: number;
|
|
6
|
+
/**
|
|
7
|
+
* Maximum combined size, in decoded bytes, of every attachment on a single
|
|
8
|
+
* email (25 MiB). Most receiving mail systems reject whole messages larger
|
|
9
|
+
* than this, so bigger payloads would never be deliverable regardless of
|
|
10
|
+
* which transport the mail-server uses. The mail-server (and the platform
|
|
11
|
+
* it is hosted on) may enforce a lower limit of its own.
|
|
12
|
+
*/
|
|
13
|
+
export declare const MAX_TOTAL_ATTACHMENT_BYTES: number;
|
|
14
|
+
/**
|
|
15
|
+
* Number of bytes a (padded, whitespace-free) base64 string decodes to,
|
|
16
|
+
* computed without actually decoding it.
|
|
17
|
+
*/
|
|
18
|
+
export declare function base64DecodedByteLength(base64: string): number;
|
|
19
|
+
/**
|
|
20
|
+
* Name the recipient's mail client shows for the attached file. Unicode is
|
|
21
|
+
* allowed; path separators and control characters are not.
|
|
22
|
+
*/
|
|
23
|
+
export declare const attachmentFilenameSchema: z.ZodString;
|
|
24
|
+
/**
|
|
25
|
+
* The attached file's bytes, base64-encoded (standard alphabet, padded, no
|
|
26
|
+
* line breaks). Request bodies are JSON, so binary content has to travel
|
|
27
|
+
* as text.
|
|
28
|
+
*/
|
|
29
|
+
export declare const attachmentContentSchema: z.ZodBase64;
|
|
30
|
+
/**
|
|
31
|
+
* MIME type of the attachment, e.g. "application/pdf" or
|
|
32
|
+
* "text/csv; charset=utf-8". When omitted, the mail-server's transport
|
|
33
|
+
* derives it from the filename's extension.
|
|
34
|
+
*/
|
|
35
|
+
export declare const attachmentContentTypeSchema: z.ZodString;
|
|
36
|
+
/**
|
|
37
|
+
* Content-ID for inline attachments. Setting it marks the attachment as
|
|
38
|
+
* inline so the HTML body can reference it as `<img src="cid:<contentId>">`.
|
|
39
|
+
* Pass the bare identifier -- without the angle brackets.
|
|
40
|
+
*/
|
|
41
|
+
export declare const attachmentContentIdSchema: z.ZodString;
|
|
42
|
+
/**
|
|
43
|
+
* A single file attached to an email, in the shape accepted by the
|
|
44
|
+
* `@schemavaults/mail-server` `/api/send` route.
|
|
45
|
+
*/
|
|
46
|
+
export declare const emailAttachmentSchema: z.ZodObject<{
|
|
47
|
+
filename: z.ZodNonOptional<z.ZodString>;
|
|
48
|
+
content: z.ZodNonOptional<z.ZodBase64>;
|
|
49
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
50
|
+
contentId: z.ZodOptional<z.ZodString>;
|
|
51
|
+
}, z.core.$strict>;
|
|
52
|
+
export type EmailAttachment = z.infer<typeof emailAttachmentSchema>;
|
|
53
|
+
/**
|
|
54
|
+
* The full list of attachments on one email: between 1 and
|
|
55
|
+
* {@link MAX_ATTACHMENTS_PER_EMAIL} files whose decoded sizes add up to at
|
|
56
|
+
* most {@link MAX_TOTAL_ATTACHMENT_BYTES}.
|
|
57
|
+
*/
|
|
58
|
+
export declare const emailAttachmentsSchema: z.ZodArray<z.ZodObject<{
|
|
59
|
+
filename: z.ZodNonOptional<z.ZodString>;
|
|
60
|
+
content: z.ZodNonOptional<z.ZodBase64>;
|
|
61
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
62
|
+
contentId: z.ZodOptional<z.ZodString>;
|
|
63
|
+
}, z.core.$strict>>;
|
|
64
|
+
export default emailAttachmentSchema;
|