@holo-js/mail 0.1.3

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.
@@ -0,0 +1,320 @@
1
+ import { HoloAppEnv, NormalizedHoloMailConfig } from '@holo-js/config';
2
+ export { defineMailConfig } from '@holo-js/config';
3
+
4
+ declare const MAIL_PRIORITY_VALUES: readonly ["high", "normal", "low"];
5
+ declare const MAIL_ATTACHMENT_DISPOSITIONS: readonly ["attachment", "inline"];
6
+ type MailJsonPrimitive = string | number | boolean | null;
7
+ type MailJsonValue = MailJsonPrimitive | readonly MailJsonValue[] | {
8
+ readonly [key: string]: MailJsonValue;
9
+ };
10
+ interface MailJsonObject {
11
+ readonly [key: string]: MailJsonValue;
12
+ }
13
+ type MailPriority = (typeof MAIL_PRIORITY_VALUES)[number];
14
+ type MailDelayValue = number | Date;
15
+ type MailAttachmentDisposition = (typeof MAIL_ATTACHMENT_DISPOSITIONS)[number];
16
+ type MailPreviewFormat = 'html' | 'json' | 'text';
17
+ type MailContentSourceKind = 'text' | 'html' | 'markdown' | 'render';
18
+ interface MailAddress {
19
+ readonly email: string;
20
+ readonly name?: string;
21
+ }
22
+ type MailAddressInput = string | {
23
+ readonly email: string;
24
+ readonly name?: string;
25
+ };
26
+ type MailRecipientsInput = MailAddressInput | readonly MailAddressInput[];
27
+ interface MailRenderSource {
28
+ readonly view: string;
29
+ readonly props?: MailJsonObject;
30
+ }
31
+ interface MailViewRenderInput {
32
+ readonly view: string;
33
+ readonly props?: MailJsonObject;
34
+ }
35
+ interface MailQueueOptions {
36
+ readonly queued?: boolean;
37
+ readonly connection?: string;
38
+ readonly queue?: string;
39
+ readonly afterCommit?: boolean;
40
+ }
41
+ type MailAttachmentContent = string | Uint8Array;
42
+ interface MailAttachmentBase {
43
+ readonly name?: string;
44
+ readonly contentType?: string;
45
+ readonly disposition?: MailAttachmentDisposition;
46
+ readonly contentId?: string;
47
+ }
48
+ interface MailPathAttachment extends MailAttachmentBase {
49
+ readonly path: string;
50
+ }
51
+ interface MailStorageAttachment extends MailAttachmentBase {
52
+ readonly storage: {
53
+ readonly path: string;
54
+ readonly disk?: string;
55
+ };
56
+ }
57
+ interface MailContentAttachment extends MailAttachmentBase {
58
+ readonly content: MailAttachmentContent;
59
+ readonly name: string;
60
+ }
61
+ interface MailResolvedAttachmentPayload extends MailAttachmentBase {
62
+ readonly path?: string;
63
+ readonly storage?: {
64
+ readonly path: string;
65
+ readonly disk?: string;
66
+ };
67
+ readonly content?: MailAttachmentContent;
68
+ readonly name?: string;
69
+ }
70
+ interface MailResolvableAttachment extends MailAttachmentBase {
71
+ readonly resolve: () => MailResolvedAttachmentPayload | Promise<MailResolvedAttachmentPayload>;
72
+ }
73
+ type MailAttachmentInput = MailPathAttachment | MailStorageAttachment | MailContentAttachment | MailResolvableAttachment;
74
+ interface MailAttachmentHelperOptions extends MailAttachmentBase {
75
+ readonly disposition?: MailAttachmentDisposition;
76
+ }
77
+ interface MailStorageAttachmentHelperOptions extends MailAttachmentHelperOptions {
78
+ readonly disk?: string;
79
+ }
80
+ interface MailContentAttachmentHelperOptions extends MailAttachmentHelperOptions {
81
+ readonly name: string;
82
+ }
83
+ interface MailDefinitionInput {
84
+ readonly mailer?: string;
85
+ readonly from?: MailAddressInput;
86
+ readonly replyTo?: MailAddressInput;
87
+ readonly to: MailRecipientsInput;
88
+ readonly cc?: MailRecipientsInput;
89
+ readonly bcc?: MailRecipientsInput;
90
+ readonly subject: string;
91
+ readonly text?: string;
92
+ readonly html?: string;
93
+ readonly markdown?: string;
94
+ readonly render?: MailRenderSource;
95
+ readonly markdownWrapper?: string;
96
+ readonly attachments?: readonly MailAttachmentInput[];
97
+ readonly headers?: Readonly<Record<string, string>>;
98
+ readonly tags?: readonly string[];
99
+ readonly metadata?: MailJsonObject;
100
+ readonly priority?: MailPriority;
101
+ readonly queue?: boolean | MailQueueOptions;
102
+ readonly delay?: MailDelayValue;
103
+ }
104
+ type MailOverrideInput = Readonly<Partial<MailDefinitionInput>>;
105
+ interface MailDefinition {
106
+ readonly mailer?: string;
107
+ readonly from?: MailAddress;
108
+ readonly replyTo?: MailAddress;
109
+ readonly to: readonly MailAddress[];
110
+ readonly cc: readonly MailAddress[];
111
+ readonly bcc: readonly MailAddress[];
112
+ readonly subject: string;
113
+ readonly text?: string;
114
+ readonly html?: string;
115
+ readonly markdown?: string;
116
+ readonly render?: Readonly<MailRenderSource>;
117
+ readonly markdownWrapper?: string;
118
+ readonly attachments: readonly MailAttachmentInput[];
119
+ readonly headers: Readonly<Record<string, string>>;
120
+ readonly tags: readonly string[];
121
+ readonly metadata?: MailJsonObject;
122
+ readonly priority?: MailPriority;
123
+ readonly queue?: boolean | Readonly<MailQueueOptions>;
124
+ readonly delay?: MailDelayValue;
125
+ }
126
+ interface MailAttachmentMetadata {
127
+ readonly source: 'path' | 'storage' | 'content' | 'resolve';
128
+ readonly name?: string;
129
+ readonly contentType?: string;
130
+ readonly disposition: MailAttachmentDisposition;
131
+ readonly contentId?: string;
132
+ }
133
+ interface MailAttachmentResolutionContext {
134
+ readonly queued: boolean;
135
+ }
136
+ interface ResolvedMailAttachment extends MailAttachmentMetadata {
137
+ readonly name: string;
138
+ readonly path?: string;
139
+ readonly storage?: {
140
+ readonly path: string;
141
+ readonly disk?: string;
142
+ };
143
+ readonly content?: MailAttachmentContent;
144
+ }
145
+ interface MailAttachmentResolutionPlan extends MailAttachmentMetadata {
146
+ readonly queuedSafe: boolean;
147
+ resolve(): Promise<ResolvedMailAttachment>;
148
+ }
149
+ interface ResolvedMail {
150
+ readonly from: MailAddress;
151
+ readonly replyTo: MailAddress;
152
+ readonly to: readonly MailAddress[];
153
+ readonly cc: readonly MailAddress[];
154
+ readonly bcc: readonly MailAddress[];
155
+ readonly subject: string;
156
+ readonly html?: string;
157
+ readonly text?: string;
158
+ readonly attachments: readonly ResolvedMailAttachment[];
159
+ readonly headers: Readonly<Record<string, string>>;
160
+ readonly tags: readonly string[];
161
+ readonly metadata?: MailJsonObject;
162
+ readonly priority?: MailPriority;
163
+ }
164
+ interface MailPreviewResult extends Omit<ResolvedMail, 'attachments'> {
165
+ readonly attachments: readonly MailAttachmentMetadata[];
166
+ readonly source: Readonly<{
167
+ readonly kind: MailContentSourceKind;
168
+ readonly markdown?: string;
169
+ readonly rawHtml?: string;
170
+ readonly render?: Readonly<MailRenderSource>;
171
+ }>;
172
+ }
173
+ interface MailSendResult {
174
+ readonly messageId: string;
175
+ readonly mailer: string;
176
+ readonly driver: string;
177
+ readonly queued: boolean;
178
+ readonly deferred?: boolean;
179
+ readonly providerMessageId?: string;
180
+ readonly provider?: Readonly<Record<string, unknown>>;
181
+ }
182
+ interface MailDriverExecutionContext {
183
+ readonly messageId: string;
184
+ readonly mailer: string;
185
+ readonly driver: string;
186
+ readonly queued: boolean;
187
+ readonly deferred?: boolean;
188
+ }
189
+ interface MailDriver<TResult extends MailSendResult = MailSendResult> {
190
+ send(mail: Readonly<ResolvedMail>, context: Readonly<MailDriverExecutionContext>): TResult | Promise<TResult>;
191
+ }
192
+ interface BuiltInMailDriverRegistry {
193
+ readonly preview: MailDriver;
194
+ readonly log: MailDriver;
195
+ readonly fake: MailDriver;
196
+ readonly smtp: MailDriver;
197
+ }
198
+ interface HoloMailDriverRegistry {
199
+ }
200
+ type MailDriverRegistry = BuiltInMailDriverRegistry & HoloMailDriverRegistry;
201
+ type MailDriverName = Extract<keyof MailDriverRegistry, string>;
202
+ interface MailSendOptions {
203
+ readonly mailer?: string;
204
+ readonly connection?: string;
205
+ readonly queue?: string;
206
+ readonly delay?: MailDelayValue;
207
+ readonly afterCommit?: boolean;
208
+ }
209
+ interface MailSendInput {
210
+ readonly mail: MailDefinition;
211
+ readonly attachments: readonly ResolvedMailAttachment[];
212
+ readonly options: Readonly<MailSendOptions>;
213
+ }
214
+ interface MailPreviewInput {
215
+ readonly mail: MailDefinition;
216
+ }
217
+ interface MailRenderPreviewInput extends MailPreviewInput {
218
+ readonly format: MailPreviewFormat;
219
+ }
220
+ interface MailPreviewPolicy {
221
+ readonly environment: HoloAppEnv;
222
+ readonly allowedEnvironments: readonly HoloAppEnv[];
223
+ }
224
+ interface MailViewRenderer {
225
+ (input: MailViewRenderInput): string | Promise<string>;
226
+ }
227
+ interface MailRuntimeBindings {
228
+ readonly config?: NormalizedHoloMailConfig;
229
+ readonly renderView?: MailViewRenderer;
230
+ send?(input: MailSendInput): MailSendResult | Promise<MailSendResult>;
231
+ preview?(input: MailPreviewInput): MailPreviewResult | Promise<MailPreviewResult>;
232
+ renderPreview?(input: MailRenderPreviewInput): Response | Promise<Response>;
233
+ }
234
+ interface RegisterMailDriverOptions {
235
+ readonly replaceExisting?: boolean;
236
+ }
237
+ interface RegisteredMailDriver<TDriver extends string = string> {
238
+ readonly name: TDriver;
239
+ readonly driver: MailDriver;
240
+ }
241
+ interface PendingMailSend<TResult = MailSendResult> extends PromiseLike<TResult> {
242
+ using(name: string): PendingMailSend<TResult>;
243
+ onConnection(name: string): PendingMailSend<TResult>;
244
+ onQueue(name: string): PendingMailSend<TResult>;
245
+ delay(value: MailDelayValue): PendingMailSend<TResult>;
246
+ afterCommit(): PendingMailSend<TResult>;
247
+ then<TResult1 = TResult, TResult2 = never>(onfulfilled?: ((value: TResult) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
248
+ catch<TResult1 = never>(onrejected?: ((reason: unknown) => TResult1 | PromiseLike<TResult1>) | null): Promise<TResult | TResult1>;
249
+ finally(onfinally?: (() => void) | null): Promise<TResult>;
250
+ }
251
+ declare function isObject(value: unknown): value is Record<string, unknown>;
252
+ declare function normalizeOptionalString(value: string | undefined, label: string): string | undefined;
253
+ declare function normalizeRequiredString(value: string, label: string): string;
254
+ declare function normalizeDelayValue(value: MailDelayValue, label: string): MailDelayValue;
255
+ declare function normalizeJsonValue(value: unknown, label: string): MailJsonValue;
256
+ declare function normalizeHeaders(headers: Readonly<Record<string, string>> | undefined): Readonly<Record<string, string>>;
257
+ declare function normalizeTags(tags: readonly string[] | undefined): readonly string[];
258
+ declare function normalizeViewIdentifier(value: string, label: string): string;
259
+ declare function isValidEmail(value: string): boolean;
260
+ declare function normalizeAddress(input: MailAddressInput, label: string): MailAddress;
261
+ declare function normalizeRecipients(value: MailRecipientsInput | undefined, label: string, required: boolean): readonly MailAddress[];
262
+ declare function normalizePriority(value: MailPriority | undefined): MailPriority | undefined;
263
+ declare function inferAttachmentName(value: MailAttachmentInput): string | undefined;
264
+ declare function inferMimeTypeFromName(name: string | undefined): string | undefined;
265
+ declare function inferAttachmentSource(value: MailAttachmentInput): MailAttachmentMetadata['source'];
266
+ declare function createAttachmentMetadata(attachment: MailAttachmentInput): MailAttachmentMetadata;
267
+ declare function normalizeAttachment(input: MailAttachmentInput, index: number): MailAttachmentInput;
268
+ declare function normalizeAttachments(attachments: readonly MailAttachmentInput[] | undefined): readonly MailAttachmentInput[];
269
+ declare function resolveNormalizedAttachment(attachment: MailAttachmentInput): ResolvedMailAttachment;
270
+ declare function isAttachmentQueueSafe(attachment: MailAttachmentInput): boolean;
271
+ declare function resolveAttachmentDefinition(attachment: MailAttachmentInput): Promise<MailAttachmentInput>;
272
+ declare function createAttachmentResolutionPlan(attachment: MailAttachmentInput, context: MailAttachmentResolutionContext): MailAttachmentResolutionPlan;
273
+ declare function createAttachmentResolutionPlans(attachments: readonly MailAttachmentInput[], context: MailAttachmentResolutionContext): readonly MailAttachmentResolutionPlan[];
274
+ declare function normalizeRenderSource(render: MailRenderSource | undefined): Readonly<MailRenderSource> | undefined;
275
+ declare function normalizeQueueOptions(value: boolean | MailQueueOptions | undefined): boolean | Readonly<MailQueueOptions> | undefined;
276
+ declare function isMailDefinition(value: unknown): value is MailDefinition;
277
+ declare function mergeMailDefinitionInputs(base: MailDefinition | MailDefinitionInput, overrides: MailOverrideInput | undefined): MailDefinitionInput;
278
+ declare function normalizeMailDefinition(input: MailDefinition | MailDefinitionInput): MailDefinition;
279
+ declare function defineMail<TMail extends MailDefinitionInput>(input: TMail): MailDefinition;
280
+ declare function attachFromPath(path: string, options?: MailAttachmentHelperOptions): MailPathAttachment;
281
+ declare function attachFromStorage(path: string, options?: MailStorageAttachmentHelperOptions): MailStorageAttachment;
282
+ declare function attachContent(content: MailAttachmentContent, options: MailContentAttachmentHelperOptions): MailContentAttachment;
283
+ declare const mailInternals: {
284
+ BUILT_IN_MAIL_DRIVERS: readonly ["preview", "log", "fake", "smtp"];
285
+ HOLO_MAIL_DEFINITION_MARKER: symbol;
286
+ MAIL_ATTACHMENT_DISPOSITIONS: readonly ["attachment", "inline"];
287
+ MAIL_PRIORITY_VALUES: readonly ["high", "normal", "low"];
288
+ attachContent: typeof attachContent;
289
+ attachFromPath: typeof attachFromPath;
290
+ attachFromStorage: typeof attachFromStorage;
291
+ createAttachmentMetadata: typeof createAttachmentMetadata;
292
+ createAttachmentResolutionPlan: typeof createAttachmentResolutionPlan;
293
+ createAttachmentResolutionPlans: typeof createAttachmentResolutionPlans;
294
+ inferMimeTypeFromName: typeof inferMimeTypeFromName;
295
+ inferAttachmentName: typeof inferAttachmentName;
296
+ inferAttachmentSource: typeof inferAttachmentSource;
297
+ isObject: typeof isObject;
298
+ isAttachmentQueueSafe: typeof isAttachmentQueueSafe;
299
+ isValidEmail: typeof isValidEmail;
300
+ mergeMailDefinitionInputs: typeof mergeMailDefinitionInputs;
301
+ normalizeAddress: typeof normalizeAddress;
302
+ normalizeAttachment: typeof normalizeAttachment;
303
+ normalizeAttachments: typeof normalizeAttachments;
304
+ normalizeDelayValue: typeof normalizeDelayValue;
305
+ normalizeHeaders: typeof normalizeHeaders;
306
+ normalizeJsonValue: typeof normalizeJsonValue;
307
+ normalizeMailDefinition: typeof normalizeMailDefinition;
308
+ normalizeOptionalString: typeof normalizeOptionalString;
309
+ normalizePriority: typeof normalizePriority;
310
+ normalizeQueueOptions: typeof normalizeQueueOptions;
311
+ normalizeRecipients: typeof normalizeRecipients;
312
+ normalizeRenderSource: typeof normalizeRenderSource;
313
+ normalizeRequiredString: typeof normalizeRequiredString;
314
+ resolveAttachmentDefinition: typeof resolveAttachmentDefinition;
315
+ resolveNormalizedAttachment: typeof resolveNormalizedAttachment;
316
+ normalizeTags: typeof normalizeTags;
317
+ normalizeViewIdentifier: typeof normalizeViewIdentifier;
318
+ };
319
+
320
+ export { type BuiltInMailDriverRegistry, type HoloMailDriverRegistry, type MailAddress, type MailAddressInput, type MailAttachmentBase, type MailAttachmentContent, type MailAttachmentDisposition, type MailAttachmentHelperOptions, type MailAttachmentInput, type MailAttachmentMetadata, type MailAttachmentResolutionContext, type MailAttachmentResolutionPlan, type MailContentAttachment, type MailContentAttachmentHelperOptions, type MailContentSourceKind, type MailDefinition, type MailDefinitionInput, type MailDelayValue, type MailDriver, type MailDriverExecutionContext, type MailDriverName, type MailDriverRegistry, type MailJsonObject, type MailJsonValue, type MailOverrideInput, type MailPathAttachment, type MailPreviewFormat, type MailPreviewInput, type MailPreviewPolicy, type MailPreviewResult, type MailPriority, type MailQueueOptions, type MailRecipientsInput, type MailRenderPreviewInput, type MailRenderSource, type MailResolvableAttachment, type MailResolvedAttachmentPayload, type MailRuntimeBindings, type MailSendInput, type MailSendOptions, type MailSendResult, type MailStorageAttachment, type MailStorageAttachmentHelperOptions, type MailViewRenderInput, type MailViewRenderer, type PendingMailSend, type RegisterMailDriverOptions, type RegisteredMailDriver, type ResolvedMail, type ResolvedMailAttachment, attachContent, attachFromPath, attachFromStorage, createAttachmentMetadata, createAttachmentResolutionPlan, createAttachmentResolutionPlans, defineMail, inferMimeTypeFromName, isAttachmentQueueSafe, isMailDefinition, mailInternals, mergeMailDefinitionInputs, normalizeMailDefinition, resolveAttachmentDefinition, resolveNormalizedAttachment };
@@ -0,0 +1,36 @@
1
+ import {
2
+ attachContent,
3
+ attachFromPath,
4
+ attachFromStorage,
5
+ createAttachmentMetadata,
6
+ createAttachmentResolutionPlan,
7
+ createAttachmentResolutionPlans,
8
+ defineMail,
9
+ defineMailConfig,
10
+ inferMimeTypeFromName,
11
+ isAttachmentQueueSafe,
12
+ isMailDefinition,
13
+ mailInternals,
14
+ mergeMailDefinitionInputs,
15
+ normalizeMailDefinition,
16
+ resolveAttachmentDefinition,
17
+ resolveNormalizedAttachment
18
+ } from "./chunk-UB6ANQ2F.mjs";
19
+ export {
20
+ attachContent,
21
+ attachFromPath,
22
+ attachFromStorage,
23
+ createAttachmentMetadata,
24
+ createAttachmentResolutionPlan,
25
+ createAttachmentResolutionPlans,
26
+ defineMail,
27
+ defineMailConfig,
28
+ inferMimeTypeFromName,
29
+ isAttachmentQueueSafe,
30
+ isMailDefinition,
31
+ mailInternals,
32
+ mergeMailDefinitionInputs,
33
+ normalizeMailDefinition,
34
+ resolveAttachmentDefinition,
35
+ resolveNormalizedAttachment
36
+ };