@fabrika/email 0.9.0-dev.4 → 0.9.0-dev.41
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/package.json +27 -2
- package/src/ahasend.ts +172 -0
- package/src/brevo.ts +158 -0
- package/src/cloudflare.ts +144 -0
- package/src/conformance.ts +68 -0
- package/src/content.ts +3 -1
- package/src/directory.ts +4 -1
- package/src/email.ts +14 -0
- package/src/http-sender.ts +138 -0
- package/src/http.ts +30 -4
- package/src/index.ts +2 -0
- package/src/lettermint.ts +153 -0
- package/src/memory.ts +3 -1
- package/src/platform-wire.ts +6 -0
- package/src/platform.ts +51 -4
- package/src/postmark.ts +136 -0
- package/src/providers.ts +36 -2
- package/src/resend.ts +48 -85
- package/src/smartemailing.ts +30 -74
- package/src/validation.ts +34 -3
- package/types/src/ahasend.d.ts +26 -0
- package/types/src/brevo.d.ts +19 -0
- package/types/src/cloudflare.d.ts +20 -0
- package/types/src/conformance.d.ts +2 -0
- package/types/src/content.d.ts +1 -0
- package/types/src/directory.d.ts +3 -0
- package/types/src/email.d.ts +14 -0
- package/types/src/http-sender.d.ts +49 -0
- package/types/src/http.d.ts +4 -1
- package/types/src/index.d.ts +1 -1
- package/types/src/lettermint.d.ts +19 -0
- package/types/src/platform.d.ts +19 -0
- package/types/src/postmark.d.ts +19 -0
- package/types/src/providers.d.ts +27 -1
- package/types/src/resend.d.ts +9 -8
- package/types/src/smartemailing.d.ts +13 -9
- package/types/src/validation.d.ts +9 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type EmailProvider } from './config.js';
|
|
2
|
+
import { EmailDeliveryError, type EmailMessage, type EmailSenderCapabilities } from './email.js';
|
|
3
|
+
import { type HttpEmailRequest, HttpEmailSender, type HttpEmailSenderOptions } from './http-sender.js';
|
|
4
|
+
import type { ProviderResponse } from './http.js';
|
|
5
|
+
export interface CloudflareEmailSenderOptions extends HttpEmailSenderOptions {
|
|
6
|
+
/** An account API token with the Email Sending Write permission and nothing else. */
|
|
7
|
+
readonly apiToken: string;
|
|
8
|
+
/** The account the token sends for: the path of every request. */
|
|
9
|
+
readonly accountId: string;
|
|
10
|
+
}
|
|
11
|
+
/** A refusal's body carries numeric codes and machine-readable messages; only the status is read. */
|
|
12
|
+
export declare class CloudflareEmailSender extends HttpEmailSender {
|
|
13
|
+
#private;
|
|
14
|
+
readonly capabilities: EmailSenderCapabilities;
|
|
15
|
+
constructor(options: CloudflareEmailSenderOptions);
|
|
16
|
+
protected request(message: EmailMessage): HttpEmailRequest;
|
|
17
|
+
protected messageId(response: ProviderResponse, message: EmailMessage): string | undefined;
|
|
18
|
+
protected refusal(response: ProviderResponse): EmailDeliveryError | undefined;
|
|
19
|
+
}
|
|
20
|
+
export declare const cloudflareEmailProvider: EmailProvider;
|
|
@@ -13,6 +13,8 @@ export interface WireMessage {
|
|
|
13
13
|
readonly unsubscribeUrl?: string;
|
|
14
14
|
/** Each attachment with its bytes as base64. */
|
|
15
15
|
readonly attachments?: readonly EmailAttachmentContent[];
|
|
16
|
+
/** Whether the provider got it as broadcast mail, on its channel for them where it has one. */
|
|
17
|
+
readonly broadcast?: boolean;
|
|
16
18
|
}
|
|
17
19
|
/** A stored or sent message in wire terms: what a local harness answers for an `EmailMessage` it kept. */
|
|
18
20
|
export declare function wireMessageOf(message: EmailMessage): WireMessage;
|
package/types/src/content.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export interface EmailContent {
|
|
|
14
14
|
readonly replyTo?: string;
|
|
15
15
|
readonly fromName?: string;
|
|
16
16
|
readonly unsubscribeUrl?: string;
|
|
17
|
+
readonly broadcast?: true;
|
|
17
18
|
readonly attachments?: readonly EmailAttachmentContent[];
|
|
18
19
|
}
|
|
19
20
|
export declare function sameEmailContent(left: EmailContent, right: EmailContent): boolean;
|
package/types/src/directory.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ declare const capturedEmailSchema: z.ZodObject<{
|
|
|
11
11
|
replyTo: z.ZodOptional<z.ZodString>;
|
|
12
12
|
fromName: z.ZodOptional<z.ZodString>;
|
|
13
13
|
unsubscribeUrl: z.ZodOptional<z.ZodString>;
|
|
14
|
+
broadcast: z.ZodOptional<z.ZodLiteral<true>>;
|
|
14
15
|
attachments: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
15
16
|
filename: z.ZodString;
|
|
16
17
|
contentType: z.ZodString;
|
|
@@ -36,6 +37,7 @@ declare const capturedEmailSchema: z.ZodObject<{
|
|
|
36
37
|
replyTo?: string | undefined;
|
|
37
38
|
fromName?: string | undefined;
|
|
38
39
|
unsubscribeUrl?: string | undefined;
|
|
40
|
+
broadcast?: true | undefined;
|
|
39
41
|
attachments?: readonly {
|
|
40
42
|
filename: string;
|
|
41
43
|
contentType: string;
|
|
@@ -52,6 +54,7 @@ declare const capturedEmailSchema: z.ZodObject<{
|
|
|
52
54
|
replyTo?: string | undefined;
|
|
53
55
|
fromName?: string | undefined;
|
|
54
56
|
unsubscribeUrl?: string | undefined;
|
|
57
|
+
broadcast?: true | undefined;
|
|
55
58
|
attachments?: readonly {
|
|
56
59
|
filename: string;
|
|
57
60
|
contentType: string;
|
package/types/src/email.d.ts
CHANGED
|
@@ -21,6 +21,12 @@ export interface EmailMessage {
|
|
|
21
21
|
* <url>` and `List-Unsubscribe-Post: List-Unsubscribe=One-Click`. A transport without `listUnsubscribe` refuses it.
|
|
22
22
|
*/
|
|
23
23
|
readonly unsubscribeUrl?: string;
|
|
24
|
+
/**
|
|
25
|
+
* One message of a send to many recipients (a newsletter, an announcement), not a reply to what the recipient did.
|
|
26
|
+
* A provider keeps such mail apart from transactional mail, and the law and the mailbox providers ask it to carry
|
|
27
|
+
* an unsubscribe, so it needs `unsubscribeUrl`. A transport without `broadcast` refuses it.
|
|
28
|
+
*/
|
|
29
|
+
readonly broadcast?: boolean;
|
|
24
30
|
/**
|
|
25
31
|
* Files the message carries, at most `MAX_EMAIL_ATTACHMENTS`, together at most the transport's `maxAttachmentBytes`.
|
|
26
32
|
* A transport without `maxAttachmentBytes` refuses a message that has any; an empty list is none.
|
|
@@ -43,6 +49,14 @@ export interface EmailSenderCapabilities {
|
|
|
43
49
|
readonly listUnsubscribe?: boolean;
|
|
44
50
|
/** The most attachment bytes one message carries, every file together; absent: it sends no attachments. */
|
|
45
51
|
readonly maxAttachmentBytes?: number;
|
|
52
|
+
/** File extensions it refuses an attachment for, lowercase and without the dot; absent: none. */
|
|
53
|
+
readonly refusedAttachmentExtensions?: readonly string[];
|
|
54
|
+
/** The only file extensions it sends an attachment with, lowercase and without the dot; absent: any. */
|
|
55
|
+
readonly attachmentExtensions?: readonly string[];
|
|
56
|
+
/** The fewest characters a text or HTML body has once trimmed; absent: any body that is not blank. */
|
|
57
|
+
readonly minBodyLength?: number;
|
|
58
|
+
/** Whether it sends a `broadcast` message, on its provider's channel for them where it has one; absent is no. */
|
|
59
|
+
readonly broadcast?: boolean;
|
|
46
60
|
}
|
|
47
61
|
export interface EmailSender {
|
|
48
62
|
readonly capabilities: EmailSenderCapabilities;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { EmailSenderIdentity } from './config.js';
|
|
3
|
+
import { EmailDeliveryError, type EmailDeliveryResult, type EmailFetch, type EmailMessage, type EmailSender, type EmailSenderCapabilities } from './email.js';
|
|
4
|
+
import { type ProviderResponse } from './http.js';
|
|
5
|
+
/** The options every HTTP adapter takes beside its credentials. */
|
|
6
|
+
export interface HttpEmailSenderOptions {
|
|
7
|
+
readonly from: EmailSenderIdentity;
|
|
8
|
+
readonly fetch?: EmailFetch;
|
|
9
|
+
readonly timeoutMs?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface HttpEmailRequest {
|
|
12
|
+
readonly url: string;
|
|
13
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
14
|
+
readonly body: unknown;
|
|
15
|
+
}
|
|
16
|
+
export declare abstract class HttpEmailSender implements EmailSender {
|
|
17
|
+
#private;
|
|
18
|
+
abstract readonly capabilities: EmailSenderCapabilities;
|
|
19
|
+
protected readonly from: EmailSenderIdentity;
|
|
20
|
+
/** `label` names the provider in every message, `provider` in every result. An adapter checks its credentials first. */
|
|
21
|
+
protected constructor(names: {
|
|
22
|
+
readonly label: string;
|
|
23
|
+
readonly provider: string;
|
|
24
|
+
}, options: HttpEmailSenderOptions);
|
|
25
|
+
/** The request for a message that passed validation. */
|
|
26
|
+
protected abstract request(message: EmailMessage): HttpEmailRequest | Promise<HttpEmailRequest>;
|
|
27
|
+
/** The message id of a 2xx answer to `message`; undefined when the answer is not a valid success. May throw a refusal. */
|
|
28
|
+
protected abstract messageId(response: ProviderResponse, message: EmailMessage): string | undefined;
|
|
29
|
+
/** A failed answer to the message the provider tells apart beyond its status; undefined leaves it to `refusalByStatus`. */
|
|
30
|
+
protected refusal(_response: ProviderResponse, _message: EmailMessage): EmailDeliveryError | undefined;
|
|
31
|
+
send(message: EmailMessage, signal: AbortSignal): Promise<EmailDeliveryResult>;
|
|
32
|
+
}
|
|
33
|
+
/** The classification of a failed answer by its status alone, for every answer an adapter does not tell apart. */
|
|
34
|
+
export declare function refusalByStatus(label: string, status: number): EmailDeliveryError;
|
|
35
|
+
/** `Name <address>` for an API that takes the sender as one header value; validation keeps the name quotable. */
|
|
36
|
+
export declare function formatMailbox(address: string, name: string | undefined): string;
|
|
37
|
+
/** An API key or token: non-empty visible ASCII, so it fits a header unchanged. */
|
|
38
|
+
export declare function isCredential(value: string): boolean;
|
|
39
|
+
/** The name of a provider's stream or route: 1..64 letters, digits, `_` and `-`. */
|
|
40
|
+
export declare function isChannelName(value: string): boolean;
|
|
41
|
+
/** A provider variable that holds a credential. */
|
|
42
|
+
export declare const credentialVariable: z.ZodEffects<z.ZodString, string, string>;
|
|
43
|
+
/** An optional provider variable: empty is absent, and a present value must pass `valid`. */
|
|
44
|
+
export declare function optionalVariable(valid: (value: string) => boolean): z.ZodEffects<z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>, string | undefined, string | undefined>;
|
|
45
|
+
/**
|
|
46
|
+
* The message's key as a provider that takes at most `maxLength` characters sends it. A longer key is sent as its
|
|
47
|
+
* SHA-256, which keeps one key one key: a retry sends the same digest, another message another.
|
|
48
|
+
*/
|
|
49
|
+
export declare function providerIdempotencyKey(key: string, maxLength: number): Promise<string>;
|
package/types/src/http.d.ts
CHANGED
|
@@ -15,6 +15,9 @@ export interface ProviderResponse {
|
|
|
15
15
|
/** The parsed JSON body, or undefined when it is not JSON. Never put into an error. */
|
|
16
16
|
readonly body: unknown;
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* The answer with its body already read, so an abort or a timeout while the body arrives is classified as one. A redirect
|
|
20
|
+
* is never followed: a followed one would send the credential headers and the message to wherever it points.
|
|
21
|
+
*/
|
|
19
22
|
export declare function postToProvider(request: ProviderRequest): Promise<ProviderResponse>;
|
|
20
23
|
export declare function parseTimeout(label: string, value: number | undefined): number;
|
package/types/src/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export { EMAIL_PROVIDER_VARIABLE, emailSenderFromEnv, NO_EMAIL_PROVIDER, parsePr
|
|
|
2
2
|
export type { EmailEnvironment, EmailProvider, EmailProviderRegistry, EmailProviderVariable, EmailSenderIdentity, EmailTransportConfig, } from './config.js';
|
|
3
3
|
export { attachmentBytes, EMAIL_DELIVERY_ERRORS, EmailDeliveryError, mayRetryDelivery, oneClickUnsubscribeHeaders } from './email.js';
|
|
4
4
|
export type { EmailAttachment, EmailDeliveryErrorCode, EmailDeliveryErrorOptions, EmailDeliveryOutcome, EmailDeliveryResult, EmailFetch, EmailMessage, EmailSender, EmailSenderCapabilities, } from './email.js';
|
|
5
|
-
export { isUnsubscribeUrl, isValidAttachmentFilename, isValidEmailAddress, isValidEmailDisplayName, isValidEmailFrom, MAX_EMAIL_ATTACHMENTS, MAX_EMAIL_SUBJECT_LENGTH, MAX_UNSUBSCRIBE_URL_LENGTH, validateEmailAttachments, validateEmailMessage, } from './validation.js';
|
|
5
|
+
export { isUnsubscribeUrl, isValidAttachmentFilename, isValidEmailAddress, isValidEmailDisplayName, isValidEmailFrom, MAX_EMAIL_ATTACHMENTS, MAX_EMAIL_SUBJECT_LENGTH, MAX_UNSUBSCRIBE_URL_LENGTH, validateEmailAttachments, validateEmailBodies, validateEmailBroadcast, validateEmailMessage, } from './validation.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type EmailProvider } from './config.js';
|
|
2
|
+
import { EmailDeliveryError, type EmailMessage, type EmailSenderCapabilities } from './email.js';
|
|
3
|
+
import { type HttpEmailRequest, HttpEmailSender, type HttpEmailSenderOptions } from './http-sender.js';
|
|
4
|
+
import type { ProviderResponse } from './http.js';
|
|
5
|
+
export interface LettermintEmailSenderOptions extends HttpEmailSenderOptions {
|
|
6
|
+
/** A project API token: it sends through that project's default route. */
|
|
7
|
+
readonly projectToken: string;
|
|
8
|
+
/** The slug of the project's broadcast route, which a `broadcast` message goes through; `broadcast` by default. */
|
|
9
|
+
readonly broadcastRoute?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class LettermintEmailSender extends HttpEmailSender {
|
|
12
|
+
#private;
|
|
13
|
+
readonly capabilities: EmailSenderCapabilities;
|
|
14
|
+
constructor(options: LettermintEmailSenderOptions);
|
|
15
|
+
protected request(message: EmailMessage): Promise<HttpEmailRequest>;
|
|
16
|
+
protected messageId(response: ProviderResponse): string | undefined;
|
|
17
|
+
protected refusal(response: ProviderResponse, message: EmailMessage): EmailDeliveryError | undefined;
|
|
18
|
+
}
|
|
19
|
+
export declare const lettermintEmailProvider: EmailProvider;
|
package/types/src/platform.d.ts
CHANGED
|
@@ -17,3 +17,22 @@ export declare class PlatformEmailSender implements EmailSender {
|
|
|
17
17
|
constructor(options: PlatformEmailSenderOptions);
|
|
18
18
|
send(message: EmailMessage, signal: AbortSignal): Promise<EmailDeliveryResult>;
|
|
19
19
|
}
|
|
20
|
+
export interface InstallationMailSenderOptions {
|
|
21
|
+
/** Control's http(s) origin; the send path is appended to it. */
|
|
22
|
+
readonly url: string;
|
|
23
|
+
/** The secret the service shares with Control, which its key derives from (`installationMailKey`). */
|
|
24
|
+
readonly secret: string;
|
|
25
|
+
readonly fetch?: EmailFetch;
|
|
26
|
+
readonly timeoutMs?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* An installation service's sender to Control's relay: a `PlatformEmailSender` under `installationMailKey(secret)`,
|
|
30
|
+
* built at the first send because deriving the key is asynchronous. A send that cannot build it (a URL that is not an
|
|
31
|
+
* origin, a secret that is not usable) throws and keeps nothing, so the next send builds it again.
|
|
32
|
+
*/
|
|
33
|
+
export declare function installationMailSender(options: InstallationMailSenderOptions): EmailSender;
|
|
34
|
+
/**
|
|
35
|
+
* `http(s)://host[:port]` exactly as written: no path, query, fragment or credentials. The one check of a relay's origin,
|
|
36
|
+
* for the sender, IAM's boot and IAM's Cloudflare deploy (which also requires `https:`).
|
|
37
|
+
*/
|
|
38
|
+
export declare function isHttpOrigin(value: string): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type EmailProvider } from './config.js';
|
|
2
|
+
import { EmailDeliveryError, type EmailMessage, type EmailSenderCapabilities } from './email.js';
|
|
3
|
+
import { type HttpEmailRequest, HttpEmailSender, type HttpEmailSenderOptions } from './http-sender.js';
|
|
4
|
+
import type { ProviderResponse } from './http.js';
|
|
5
|
+
export interface PostmarkEmailSenderOptions extends HttpEmailSenderOptions {
|
|
6
|
+
/** A server token: it sends through that server's default transactional stream. */
|
|
7
|
+
readonly serverToken: string;
|
|
8
|
+
/** The ID of the server's broadcast stream, which a `broadcast` message goes through; `broadcast` by default. */
|
|
9
|
+
readonly broadcastStream?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class PostmarkEmailSender extends HttpEmailSender {
|
|
12
|
+
#private;
|
|
13
|
+
readonly capabilities: EmailSenderCapabilities;
|
|
14
|
+
constructor(options: PostmarkEmailSenderOptions);
|
|
15
|
+
protected request(message: EmailMessage): HttpEmailRequest;
|
|
16
|
+
protected messageId(response: ProviderResponse): string | undefined;
|
|
17
|
+
protected refusal(response: ProviderResponse): EmailDeliveryError | undefined;
|
|
18
|
+
}
|
|
19
|
+
export declare const postmarkEmailProvider: EmailProvider;
|
package/types/src/providers.d.ts
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
import type { EmailProviderVariable } from './config.js';
|
|
2
|
+
/**
|
|
3
|
+
* The providers `FABRIKA_EMAIL_PROVIDER` can name in a stock installation, sorted by name: the order every help text
|
|
4
|
+
* and refusal lists them in. Memory and Directory are composition inputs.
|
|
5
|
+
*/
|
|
2
6
|
export declare const builtinEmailProviders: {
|
|
7
|
+
ahasend: import("./config.js").EmailProvider;
|
|
8
|
+
brevo: import("./config.js").EmailProvider;
|
|
9
|
+
cloudflare: import("./config.js").EmailProvider;
|
|
10
|
+
lettermint: import("./config.js").EmailProvider;
|
|
11
|
+
postmark: import("./config.js").EmailProvider;
|
|
3
12
|
resend: import("./config.js").EmailProvider;
|
|
4
13
|
smartemailing: import("./config.js").EmailProvider;
|
|
5
14
|
};
|
|
15
|
+
/** Every built-in provider's own variables, in registry order: what the installers write and the workflow passes on. */
|
|
16
|
+
export declare const builtinEmailProviderVariables: readonly EmailProviderVariable[];
|
|
17
|
+
/**
|
|
18
|
+
* The first framework release whose registry holds each built-in provider. An application on an older release builds
|
|
19
|
+
* its sender from its own registry, so it cannot be handed one it lacks; Control refuses that deploy. `null`: every
|
|
20
|
+
* release that sends through the installation (`mailer: 'installation'`, from 0.5.0) holds it. A new provider names
|
|
21
|
+
* the release after the newest one published without it.
|
|
22
|
+
*/
|
|
23
|
+
export declare const builtinEmailProviderSince: {
|
|
24
|
+
readonly ahasend: "0.8.2";
|
|
25
|
+
readonly brevo: "0.9.0-dev.17";
|
|
26
|
+
readonly cloudflare: "0.9.0";
|
|
27
|
+
readonly lettermint: "0.8.2";
|
|
28
|
+
readonly postmark: "0.8.2";
|
|
29
|
+
readonly resend: null;
|
|
30
|
+
readonly smartemailing: null;
|
|
31
|
+
};
|
package/types/src/resend.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { type EmailProvider
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { type EmailProvider } from './config.js';
|
|
2
|
+
import { EmailDeliveryError, type EmailMessage, type EmailSenderCapabilities } from './email.js';
|
|
3
|
+
import { type HttpEmailRequest, HttpEmailSender, type HttpEmailSenderOptions } from './http-sender.js';
|
|
4
|
+
import type { ProviderResponse } from './http.js';
|
|
5
|
+
export interface ResendEmailSenderOptions extends HttpEmailSenderOptions {
|
|
4
6
|
readonly apiKey: string;
|
|
5
|
-
readonly from: EmailSenderIdentity;
|
|
6
|
-
readonly fetch?: EmailFetch;
|
|
7
|
-
readonly timeoutMs?: number;
|
|
8
7
|
}
|
|
9
|
-
export declare class ResendEmailSender
|
|
8
|
+
export declare class ResendEmailSender extends HttpEmailSender {
|
|
10
9
|
#private;
|
|
11
10
|
readonly capabilities: EmailSenderCapabilities;
|
|
12
11
|
constructor(options: ResendEmailSenderOptions);
|
|
13
|
-
|
|
12
|
+
protected request(message: EmailMessage): HttpEmailRequest;
|
|
13
|
+
protected messageId(response: ProviderResponse): string | undefined;
|
|
14
|
+
protected refusal(response: ProviderResponse): EmailDeliveryError | undefined;
|
|
14
15
|
}
|
|
15
16
|
export declare const resendEmailProvider: EmailProvider;
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
import { type EmailProvider
|
|
2
|
-
import { type
|
|
3
|
-
|
|
1
|
+
import { type EmailProvider } from './config.js';
|
|
2
|
+
import { type EmailMessage, type EmailSenderCapabilities } from './email.js';
|
|
3
|
+
import { type HttpEmailRequest, HttpEmailSender, type HttpEmailSenderOptions } from './http-sender.js';
|
|
4
|
+
import type { ProviderResponse } from './http.js';
|
|
5
|
+
export interface SmartEmailingEmailSenderOptions extends HttpEmailSenderOptions {
|
|
4
6
|
/** The account's user name or e-mail: the first half of the Basic credential. */
|
|
5
7
|
readonly username: string;
|
|
6
8
|
readonly apiKey: string;
|
|
7
|
-
readonly from: EmailSenderIdentity;
|
|
8
9
|
/** Groups the messages in SmartEmailing's statistics. */
|
|
9
10
|
readonly tag?: string;
|
|
10
|
-
readonly fetch?: EmailFetch;
|
|
11
|
-
readonly timeoutMs?: number;
|
|
12
11
|
}
|
|
13
|
-
|
|
12
|
+
/** Its error body's `message` is free text that may quote the request, so a refusal is classified by status alone. */
|
|
13
|
+
export declare class SmartEmailingEmailSender extends HttpEmailSender {
|
|
14
14
|
#private;
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* The API takes up to five tasks a request, but `send` carries one. Its API documents no message headers, so a
|
|
17
|
+
* one-click unsubscribe is refused rather than sent without one.
|
|
18
|
+
*/
|
|
16
19
|
readonly capabilities: EmailSenderCapabilities;
|
|
17
20
|
constructor(options: SmartEmailingEmailSenderOptions);
|
|
18
|
-
|
|
21
|
+
protected request(message: EmailMessage): HttpEmailRequest;
|
|
22
|
+
protected messageId(response: ProviderResponse): string | undefined;
|
|
19
23
|
}
|
|
20
24
|
export declare const smartEmailingEmailProvider: EmailProvider;
|
|
@@ -15,10 +15,17 @@ export declare function isValidEmailDisplayName(value: string): boolean;
|
|
|
15
15
|
export declare function isValidEmailSenderIdentity(identity: EmailSenderIdentity): boolean;
|
|
16
16
|
export declare function validateEmailMessage(message: EmailMessage): void;
|
|
17
17
|
/**
|
|
18
|
-
* Refuses a message whose attachments `capabilities` does not carry: any attachment where the transport sends none,
|
|
19
|
-
* more bytes together than its `maxAttachmentBytes
|
|
18
|
+
* Refuses a message whose attachments `capabilities` does not carry: any attachment where the transport sends none,
|
|
19
|
+
* more bytes together than its `maxAttachmentBytes`, or a file whose extension it refuses or does not list in
|
|
20
|
+
* `attachmentExtensions`. `label` names the transport in the message.
|
|
20
21
|
*/
|
|
21
22
|
export declare function validateEmailAttachments(message: EmailMessage, capabilities: EmailSenderCapabilities, label: string): void;
|
|
23
|
+
/** Refuses a `broadcast` message where the transport sends none. */
|
|
24
|
+
export declare function validateEmailBroadcast(message: EmailMessage, capabilities: EmailSenderCapabilities, label: string): void;
|
|
25
|
+
/** Refuses a text or HTML body shorter than the transport's `minBodyLength`, counted in characters once trimmed. */
|
|
26
|
+
export declare function validateEmailBodies(message: EmailMessage, capabilities: EmailSenderCapabilities, label: string): void;
|
|
27
|
+
/** The extension after the last dot, lowercase; empty without one. */
|
|
28
|
+
export declare function extensionOf(filename: string): string;
|
|
22
29
|
/** The most files one message carries. */
|
|
23
30
|
export declare const MAX_EMAIL_ATTACHMENTS = 20;
|
|
24
31
|
/** 1..255 characters, no control characters, no path separator and no `"`, so every transport can quote it. */
|