@visulima/email 1.0.0-alpha.2 → 1.0.0-alpha.21

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.
Files changed (231) hide show
  1. package/CHANGELOG.md +246 -0
  2. package/LICENSE.md +536 -899
  3. package/README.md +36 -21
  4. package/dist/crypto/index.d.ts +147 -4
  5. package/dist/crypto/index.js +1 -1
  6. package/dist/index.d.ts +785 -9
  7. package/dist/index.js +1 -1
  8. package/dist/packem_shared/{DkimSigner-pFd4c3fZ.js → DkimSigner-CT2DSHD1.js} +4 -4
  9. package/dist/packem_shared/Mail-D93oo_9g.js +1 -0
  10. package/dist/packem_shared/MailMessage-BvaH5tZZ.js +1 -0
  11. package/dist/packem_shared/{SmimeEncrypter-CBevU534.js → SmimeEncrypter-ZhHEgDwY.js} +2 -2
  12. package/dist/packem_shared/{SmimeSigner-CObA4jzT.js → SmimeSigner-CYSVF6ez.js} +1 -1
  13. package/dist/packem_shared/{ahaSendProvider-DlFKEQ6D.js → ahaSendProvider-DOAAW65O.js} +1 -1
  14. package/dist/packem_shared/{attachment-processor-2rHmfa7j.js → attachment-processor-DsmIomKc.js} +1 -1
  15. package/dist/packem_shared/{awsSesProvider-Ba-eVJxZ.js → awsSesProvider-DX1630Ms.js} +7 -7
  16. package/dist/packem_shared/azureProvider-EkNYKAiF.js +1 -0
  17. package/dist/packem_shared/{brevoProvider-5p6jjiK9.js → brevoProvider-CkR4U4RD.js} +1 -1
  18. package/dist/packem_shared/build-mime-message-6xstxaUV.js +2 -0
  19. package/dist/packem_shared/defineProvider-CtLH0VBE.js +1 -0
  20. package/dist/packem_shared/detectMimeType-bo5oxfnt.js +1 -0
  21. package/dist/packem_shared/failoverProvider-W5ctAhdC.js +1 -0
  22. package/dist/packem_shared/httpProvider-DUg1AQfO.js +1 -0
  23. package/dist/packem_shared/{infobipProvider-CtLwrUaP.js → infobipProvider-BhTsWi7e.js} +1 -1
  24. package/dist/packem_shared/{mailCrabProvider-CM_CFDca.js → mailCrabProvider-B7H6HwWu.js} +1 -1
  25. package/dist/packem_shared/mailPaceProvider-DRt6Z9Hr.js +1 -0
  26. package/dist/packem_shared/{mailerSendProvider-CeeIXFnW.js → mailerSendProvider-Dx_iHInH.js} +1 -1
  27. package/dist/packem_shared/mailgunProvider-ChkLGZZW.js +1 -0
  28. package/dist/packem_shared/mailjetProvider-BMRhNe6H.js +1 -0
  29. package/dist/packem_shared/{mailomatProvider-DMQmjKHT.js → mailomatProvider-CydV-JB6.js} +1 -1
  30. package/dist/packem_shared/{mailtrapProvider-BN3UBEQw.js → mailtrapProvider-CuAfJWDr.js} +1 -1
  31. package/dist/packem_shared/{make-request-BDzF9W9D.js → make-request-CaT4d5oC.js} +1 -1
  32. package/dist/packem_shared/{mandrillProvider-370y7CLu.js → mandrillProvider-BBeLbaw0.js} +1 -1
  33. package/dist/packem_shared/mockProvider-C0P1lKOy.js +1 -0
  34. package/dist/packem_shared/{nodemailerProvider-_w8QXMU-.js → nodemailerProvider-DFcvoVFv.js} +1 -1
  35. package/dist/packem_shared/{opentelemetryProvider-C_ZXOLSd.js → opentelemetryProvider-Dwv88G3O.js} +1 -1
  36. package/dist/packem_shared/{plunkProvider-DfJumQ4U.js → plunkProvider-BQyjG6YT.js} +1 -1
  37. package/dist/packem_shared/{postalProvider-Bavx2FcH.js → postalProvider-DPHQ620q.js} +1 -1
  38. package/dist/packem_shared/{postmarkProvider-DFC0uvjO.js → postmarkProvider-bMTC2gdJ.js} +1 -1
  39. package/dist/packem_shared/provider.d-DcfYeGJJ.d.ts +28 -0
  40. package/dist/packem_shared/readFile-BAVMZg5e-C4whBIPd.js +1 -0
  41. package/dist/packem_shared/resendProvider-Cns1tvF5.js +1 -0
  42. package/dist/packem_shared/roundRobinProvider-FvZQKl6n.js +1 -0
  43. package/dist/packem_shared/{scalewayProvider-be1HPimL.js → scalewayProvider-O1dHz7iJ.js} +1 -1
  44. package/dist/packem_shared/{sendGridProvider-BVI1sq3n.js → sendGridProvider-DmywC-eT.js} +1 -1
  45. package/dist/packem_shared/{smtpProvider-BV-ufR53.js → smtpProvider-Unjao_fn.js} +8 -8
  46. package/dist/packem_shared/sweegoProvider-D086G6xG.js +1 -0
  47. package/dist/packem_shared/types.d-CNnnk-Ya.d.ts +102 -0
  48. package/dist/packem_shared/types.d-nyR1ty1Q.d.ts +9 -0
  49. package/dist/packem_shared/types.d-wwpgA3to.d.ts +204 -0
  50. package/dist/packem_shared/validate-email-options-DPo3SgC0.js +1 -0
  51. package/dist/packem_shared/zeptomailProvider-DKKEpEsW.js +1 -0
  52. package/dist/providers/ahasend/index.d.ts +36 -3
  53. package/dist/providers/ahasend/index.js +1 -1
  54. package/dist/providers/aws-ses/index.d.ts +47 -3
  55. package/dist/providers/aws-ses/index.js +1 -1
  56. package/dist/providers/azure/index.d.ts +52 -3
  57. package/dist/providers/azure/index.js +1 -1
  58. package/dist/providers/brevo/index.d.ts +65 -3
  59. package/dist/providers/brevo/index.js +1 -1
  60. package/dist/providers/failover/index.d.ts +27 -3
  61. package/dist/providers/failover/index.js +1 -1
  62. package/dist/providers/http/index.d.ts +35 -3
  63. package/dist/providers/http/index.js +1 -1
  64. package/dist/providers/infobip/index.d.ts +56 -3
  65. package/dist/providers/infobip/index.js +1 -1
  66. package/dist/providers/mailcrab/index.d.ts +32 -3
  67. package/dist/providers/mailcrab/index.js +1 -1
  68. package/dist/providers/mailersend/index.d.ts +51 -3
  69. package/dist/providers/mailersend/index.js +1 -1
  70. package/dist/providers/mailgun/index.d.ts +73 -3
  71. package/dist/providers/mailgun/index.js +1 -1
  72. package/dist/providers/mailjet/index.d.ts +72 -3
  73. package/dist/providers/mailjet/index.js +1 -1
  74. package/dist/providers/mailomat/index.d.ts +40 -3
  75. package/dist/providers/mailomat/index.js +1 -1
  76. package/dist/providers/mailpace/index.d.ts +52 -3
  77. package/dist/providers/mailpace/index.js +1 -1
  78. package/dist/providers/mailtrap/index.d.ts +44 -3
  79. package/dist/providers/mailtrap/index.js +1 -1
  80. package/dist/providers/mandrill/index.d.ts +87 -3
  81. package/dist/providers/mandrill/index.js +1 -1
  82. package/dist/providers/mock/index.d.ts +59 -3
  83. package/dist/providers/mock/index.js +1 -1
  84. package/dist/providers/nodemailer/index.d.ts +38 -3
  85. package/dist/providers/nodemailer/index.js +1 -1
  86. package/dist/providers/opentelemetry/index.d.ts +529 -3
  87. package/dist/providers/opentelemetry/index.js +1 -1
  88. package/dist/providers/plunk/index.d.ts +38 -3
  89. package/dist/providers/plunk/index.js +1 -1
  90. package/dist/providers/postal/index.d.ts +48 -3
  91. package/dist/providers/postal/index.js +1 -1
  92. package/dist/providers/postmark/index.d.ts +60 -3
  93. package/dist/providers/postmark/index.js +1 -1
  94. package/dist/providers/resend/index.d.ts +51 -3
  95. package/dist/providers/resend/index.js +1 -1
  96. package/dist/providers/roundrobin/index.d.ts +27 -3
  97. package/dist/providers/roundrobin/index.js +1 -1
  98. package/dist/providers/scaleway/index.d.ts +44 -3
  99. package/dist/providers/scaleway/index.js +1 -1
  100. package/dist/providers/sendgrid/index.d.ts +84 -3
  101. package/dist/providers/sendgrid/index.js +1 -1
  102. package/dist/providers/smtp/index.d.ts +71 -3
  103. package/dist/providers/smtp/index.js +1 -1
  104. package/dist/providers/sweego/index.d.ts +40 -3
  105. package/dist/providers/sweego/index.js +1 -1
  106. package/dist/providers/zeptomail/index.d.ts +37 -3
  107. package/dist/providers/zeptomail/index.js +1 -1
  108. package/dist/template-engines/handlebars.d.ts +23 -22
  109. package/dist/template-engines/handlebars.js +1 -1
  110. package/dist/template-engines/html-to-text.d.ts +24 -24
  111. package/dist/template-engines/mjml.d.ts +10 -10
  112. package/dist/template-engines/react-email.d.ts +9 -9
  113. package/dist/template-engines/vue-email.d.ts +9 -9
  114. package/dist/utils/cache.d.ts +49 -48
  115. package/dist/utils/format-email-address.d.ts +8 -7
  116. package/dist/utils/normalize-email-aliases.d.ts +20 -20
  117. package/dist/utils/parse-address.d.ts +18 -17
  118. package/dist/utils/parse-address.js +1 -1
  119. package/dist/utils/validation/check-mx-records.d.ts +36 -35
  120. package/dist/utils/validation/disposable-email-domains.d.ts +1 -13
  121. package/dist/utils/validation/role-accounts.d.ts +18 -18
  122. package/dist/utils/validation/validate-email.d.ts +5 -5
  123. package/dist/utils/validation/verify-email.d.ts +45 -42
  124. package/dist/utils/validation/verify-email.js +1 -1
  125. package/dist/utils/validation/verify-smtp.d.ts +35 -34
  126. package/dist/utils/validation/verify-smtp.js +1 -1
  127. package/package.json +61 -61
  128. package/dist/attachment-helpers.d.ts +0 -64
  129. package/dist/crypto/dkim-signer.d.ts +0 -48
  130. package/dist/crypto/smime-encrypter.d.ts +0 -53
  131. package/dist/crypto/smime-signer.d.ts +0 -48
  132. package/dist/crypto/types.d.ts +0 -101
  133. package/dist/draft-mail-message.d.ts +0 -13
  134. package/dist/errors/email-error.d.ts +0 -17
  135. package/dist/errors/required-option-error.d.ts +0 -10
  136. package/dist/mail-message.d.ts +0 -425
  137. package/dist/mail.d.ts +0 -206
  138. package/dist/packem_shared/Mail-6Bltpy_p.js +0 -1
  139. package/dist/packem_shared/MailMessage-B76GPBBA.js +0 -1
  140. package/dist/packem_shared/azureProvider-CQYAkgVF.js +0 -1
  141. package/dist/packem_shared/build-mime-message-IYaUqqPJ.js +0 -2
  142. package/dist/packem_shared/defineProvider-B9rSklAJ.js +0 -1
  143. package/dist/packem_shared/detectMimeType-S8WRsNtY.js +0 -1
  144. package/dist/packem_shared/failoverProvider-CAHQQueo.js +0 -1
  145. package/dist/packem_shared/httpProvider-CZD6LZX3.js +0 -1
  146. package/dist/packem_shared/mailPaceProvider-B6yKvh6z.js +0 -1
  147. package/dist/packem_shared/mailgunProvider-mmjKzouh.js +0 -1
  148. package/dist/packem_shared/mailjetProvider-DwN6i0VA.js +0 -1
  149. package/dist/packem_shared/mockProvider-DN5ZwutD.js +0 -1
  150. package/dist/packem_shared/readFile-BlZxbhCU-C8bCdiA2.js +0 -1
  151. package/dist/packem_shared/resendProvider-CfqU7UdE.js +0 -1
  152. package/dist/packem_shared/roundRobinProvider-1WQnuKR8.js +0 -1
  153. package/dist/packem_shared/sweegoProvider-7419CSAq.js +0 -1
  154. package/dist/packem_shared/validate-email-options-DfJ7llf8.js +0 -1
  155. package/dist/packem_shared/zeptomailProvider-C2lh0Xmo.js +0 -1
  156. package/dist/providers/ahasend/provider.d.ts +0 -7
  157. package/dist/providers/ahasend/types.d.ts +0 -28
  158. package/dist/providers/aws-ses/provider.d.ts +0 -8
  159. package/dist/providers/aws-ses/types.d.ts +0 -38
  160. package/dist/providers/azure/provider.d.ts +0 -7
  161. package/dist/providers/azure/types.d.ts +0 -44
  162. package/dist/providers/brevo/provider.d.ts +0 -7
  163. package/dist/providers/brevo/types.d.ts +0 -57
  164. package/dist/providers/failover/provider.d.ts +0 -7
  165. package/dist/providers/failover/types.d.ts +0 -19
  166. package/dist/providers/http/provider.d.ts +0 -7
  167. package/dist/providers/http/types.d.ts +0 -27
  168. package/dist/providers/infobip/provider.d.ts +0 -7
  169. package/dist/providers/infobip/types.d.ts +0 -48
  170. package/dist/providers/mailcrab/provider.d.ts +0 -9
  171. package/dist/providers/mailcrab/types.d.ts +0 -22
  172. package/dist/providers/mailersend/provider.d.ts +0 -7
  173. package/dist/providers/mailersend/types.d.ts +0 -43
  174. package/dist/providers/mailgun/provider.d.ts +0 -7
  175. package/dist/providers/mailgun/types.d.ts +0 -65
  176. package/dist/providers/mailjet/provider.d.ts +0 -7
  177. package/dist/providers/mailjet/types.d.ts +0 -64
  178. package/dist/providers/mailomat/provider.d.ts +0 -7
  179. package/dist/providers/mailomat/types.d.ts +0 -32
  180. package/dist/providers/mailpace/provider.d.ts +0 -7
  181. package/dist/providers/mailpace/types.d.ts +0 -44
  182. package/dist/providers/mailtrap/provider.d.ts +0 -7
  183. package/dist/providers/mailtrap/types.d.ts +0 -36
  184. package/dist/providers/mandrill/provider.d.ts +0 -7
  185. package/dist/providers/mandrill/types.d.ts +0 -79
  186. package/dist/providers/mock/provider.d.ts +0 -8
  187. package/dist/providers/mock/types.d.ts +0 -50
  188. package/dist/providers/nodemailer/provider.d.ts +0 -7
  189. package/dist/providers/nodemailer/types.d.ts +0 -30
  190. package/dist/providers/opentelemetry/provider.d.ts +0 -8
  191. package/dist/providers/opentelemetry/types.d.ts +0 -31
  192. package/dist/providers/plunk/provider.d.ts +0 -7
  193. package/dist/providers/plunk/types.d.ts +0 -30
  194. package/dist/providers/postal/provider.d.ts +0 -7
  195. package/dist/providers/postal/types.d.ts +0 -40
  196. package/dist/providers/postmark/provider.d.ts +0 -7
  197. package/dist/providers/postmark/types.d.ts +0 -52
  198. package/dist/providers/provider.d.ts +0 -27
  199. package/dist/providers/resend/provider.d.ts +0 -7
  200. package/dist/providers/resend/types.d.ts +0 -43
  201. package/dist/providers/roundrobin/provider.d.ts +0 -7
  202. package/dist/providers/roundrobin/types.d.ts +0 -19
  203. package/dist/providers/scaleway/provider.d.ts +0 -7
  204. package/dist/providers/scaleway/types.d.ts +0 -36
  205. package/dist/providers/sendgrid/provider.d.ts +0 -7
  206. package/dist/providers/sendgrid/types.d.ts +0 -76
  207. package/dist/providers/smtp/provider.d.ts +0 -7
  208. package/dist/providers/smtp/types.d.ts +0 -63
  209. package/dist/providers/sweego/provider.d.ts +0 -7
  210. package/dist/providers/sweego/types.d.ts +0 -32
  211. package/dist/providers/utils/address-formatter.d.ts +0 -139
  212. package/dist/providers/utils/attachment-processor.d.ts +0 -58
  213. package/dist/providers/utils/index.d.ts +0 -4
  214. package/dist/providers/utils/payload-builder.d.ts +0 -78
  215. package/dist/providers/utils/provider-base.d.ts +0 -69
  216. package/dist/providers/zeptomail/provider.d.ts +0 -7
  217. package/dist/providers/zeptomail/types.d.ts +0 -29
  218. package/dist/template-engines/types.d.ts +0 -8
  219. package/dist/types.d.ts +0 -203
  220. package/dist/utils/build-mime-message.d.ts +0 -8
  221. package/dist/utils/create-logger.d.ts +0 -16
  222. package/dist/utils/format-email-addresses.d.ts +0 -8
  223. package/dist/utils/generate-boundary.d.ts +0 -7
  224. package/dist/utils/generate-message-id.d.ts +0 -6
  225. package/dist/utils/headers-to-record.d.ts +0 -9
  226. package/dist/utils/is-port-available.d.ts +0 -9
  227. package/dist/utils/make-request.d.ts +0 -18
  228. package/dist/utils/retry.d.ts +0 -10
  229. package/dist/utils/sanitize-header.d.ts +0 -14
  230. package/dist/utils/to-base64.d.ts +0 -8
  231. package/dist/utils/validation/validate-email-options.d.ts +0 -8
@@ -1,78 +0,0 @@
1
- import type { EmailAddress, EmailOptions } from "../../types.d.ts";
2
- /**
3
- * Common payload building utilities for email providers
4
- */
5
- export declare class PayloadBuilder {
6
- private payload;
7
- constructor(initialPayload?: Record<string, unknown>);
8
- /**
9
- * Sets a field in the payload.
10
- * @param key The field key to set.
11
- * @param value The field value to set (undefined and null values are ignored).
12
- * @returns This instance for method chaining.
13
- */
14
- set(key: string, value: unknown): this;
15
- /**
16
- * Sets multiple fields conditionally in the payload.
17
- * @param fields An object containing key-value pairs to set.
18
- * @returns This instance for method chaining.
19
- */
20
- setMultiple(fields: Record<string, unknown>): this;
21
- /**
22
- * Adds recipients (to, cc, bcc) to the payload using a formatter function.
23
- * @param emailOptions The email options containing recipient addresses.
24
- * @param formatter A function to format the addresses for the specific provider.
25
- * @returns This instance for method chaining.
26
- */
27
- addRecipients(emailOptions: EmailOptions, formatter: (addresses: EmailAddress | EmailAddress[]) => unknown): this;
28
- /**
29
- * Adds standard email fields (subject, html, text, replyTo) to the payload.
30
- * @param emailOptions The email options containing the standard fields.
31
- * @returns This instance for method chaining.
32
- */
33
- addStandardFields(emailOptions: EmailOptions): this;
34
- /**
35
- * Adds template-related fields to the payload.
36
- * @param emailOptions The email options containing template information.
37
- * @param templateKey The key name to use for the template ID (default: "template_id").
38
- * @returns This instance for method chaining.
39
- */
40
- addTemplateFields(emailOptions: EmailOptions, templateKey?: string): this;
41
- /**
42
- * Adds scheduling fields to the payload for delayed sending.
43
- * @param emailOptions The email options containing scheduling information.
44
- * @returns This instance for method chaining.
45
- */
46
- addSchedulingFields(emailOptions: EmailOptions): this;
47
- /**
48
- * Adds tags to the payload for email categorization.
49
- * @param emailOptions The email options containing tags.
50
- * @param formatter An optional function to format tags for the specific provider.
51
- * @returns This instance for method chaining.
52
- */
53
- addTags(emailOptions: EmailOptions, formatter?: (tags: unknown[]) => unknown): this;
54
- /**
55
- * Adds custom headers to the payload.
56
- * @param emailOptions The email options containing custom headers.
57
- * @param formatter An optional function to format headers for the specific provider.
58
- * @returns This instance for method chaining.
59
- */
60
- addHeaders(emailOptions: EmailOptions, formatter?: (headers: Record<string, string>) => unknown): this;
61
- /**
62
- * Adds a batch ID to the payload for batch email operations.
63
- * @param emailOptions The email options containing the batch ID.
64
- * @returns This instance for method chaining.
65
- */
66
- addBatchId(emailOptions: EmailOptions): this;
67
- /**
68
- * Builds and returns the final payload object.
69
- * @returns The complete payload object ready for API submission.
70
- */
71
- build(): Record<string, unknown>;
72
- }
73
- /**
74
- * Creates a new payload builder instance.
75
- * @param initialPayload Optional initial payload object to start with.
76
- * @returns A new PayloadBuilder instance.
77
- */
78
- export declare const createPayloadBuilder: (initialPayload?: Record<string, unknown>) => PayloadBuilder;
@@ -1,69 +0,0 @@
1
- import EmailError from "../../errors/email-error.d.ts";
2
- import type { MaybePromise } from "../../types.d.ts";
3
- /**
4
- * Logger interface with debug, error, info, and warn methods
5
- */
6
- type Logger = {
7
- debug: (message: string, ...args: unknown[]) => void;
8
- error: (message: string, ...args: unknown[]) => void;
9
- info: (message: string, ...args: unknown[]) => void;
10
- warn: (message: string, ...args: unknown[]) => void;
11
- };
12
- /**
13
- * Common provider configuration interface
14
- */
15
- export interface BaseProviderConfig {
16
- debug?: boolean;
17
- logger?: Console;
18
- timeout?: number;
19
- }
20
- /**
21
- * Provider initialization state management
22
- */
23
- export declare class ProviderState {
24
- private isInitialized;
25
- /**
26
- * Checks if the provider has been initialized.
27
- * @returns True if the provider is initialized, false otherwise.
28
- */
29
- get initialized(): boolean;
30
- /**
31
- * Marks the provider as initialized.
32
- */
33
- setInitialized(): void;
34
- /**
35
- * Ensures the provider is initialized, initializing it if not already done.
36
- * @param initializeFunction The function to call for initialization.
37
- * @param providerName The name of the provider (for error messages).
38
- * @throws {EmailError} When initialization fails.
39
- */
40
- ensureInitialized(initializeFunction: () => MaybePromise<void>, providerName: string): Promise<void>;
41
- }
42
- /**
43
- * Creates a logger instance for a provider.
44
- * @param providerName The name of the provider (used as prefix in log messages).
45
- * @param customLogger Optional Console instance for logging output.
46
- * @returns A logger instance with debug, error, info, and warn methods.
47
- */
48
- export declare const createProviderLogger: (providerName: string, customLogger?: Console) => Logger;
49
- /**
50
- * Checks if an HTTP response indicates success (2xx status codes).
51
- * @param result The result object containing response data and success status.
52
- * @param result.data The response data object.
53
- * @param result.success The success flag indicating if the request was successful.
54
- * @returns True if the response indicates success, false otherwise.
55
- */
56
- export declare const isSuccessfulResponse: (result: {
57
- data?: unknown;
58
- success: boolean;
59
- }) => boolean;
60
- /**
61
- * Handles errors from provider operations and converts them to EmailError instances.
62
- * @param providerName The name of the provider where the error occurred.
63
- * @param operation The operation that failed.
64
- * @param error The error that occurred.
65
- * @param logger Optional logger instance for debug messages.
66
- * @returns An EmailError instance with appropriate error information.
67
- */
68
- export declare const handleProviderError: (providerName: string, operation: string, error: unknown, logger?: Logger) => EmailError;
69
- export {};
@@ -1,7 +0,0 @@
1
- import type { ProviderFactory } from "../provider.d.ts";
2
- import type { ZeptomailConfig, ZeptomailEmailOptions } from "./types.d.ts";
3
- /**
4
- * Zeptomail Provider for sending emails through Zeptomail API
5
- */
6
- declare const zeptomailProvider: ProviderFactory<ZeptomailConfig, unknown, ZeptomailEmailOptions>;
7
- export default zeptomailProvider;
@@ -1,29 +0,0 @@
1
- import type { BaseConfig, EmailOptions } from "../../types.d.ts";
2
- /**
3
- * Zeptomail configuration
4
- */
5
- export interface ZeptomailConfig extends BaseConfig {
6
- endpoint?: string;
7
- token: string;
8
- }
9
- /**
10
- * Zeptomail-specific email options
11
- */
12
- export interface ZeptomailEmailOptions extends EmailOptions {
13
- /**
14
- * Client reference - identifier set by the user to track a particular transaction
15
- */
16
- clientReference?: string;
17
- /**
18
- * MIME headers - additional headers sent in the email for reference
19
- */
20
- mimeHeaders?: Record<string, string>;
21
- /**
22
- * Track email clicks - enables tracking for click events
23
- */
24
- trackClicks?: boolean;
25
- /**
26
- * Track email opens - enables tracking for open events
27
- */
28
- trackOpens?: boolean;
29
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Template render function type.
3
- * @param template Template content (string, React component, etc.).
4
- * @param data Data/variables to pass to the template.
5
- * @param options Options specific to the template engine.
6
- * @returns Rendered HTML string.
7
- */
8
- export type TemplateRenderer = (template: unknown, data?: Record<string, unknown>, options?: Record<string, unknown>) => string | Promise<string>;
package/dist/types.d.ts DELETED
@@ -1,203 +0,0 @@
1
- import type { Buffer } from "node:buffer";
2
- /**
3
- * Utility type for values that can be promises
4
- */
5
- export type MaybePromise<T> = T | Promise<T>;
6
- /**
7
- * Feature flags indicating what capabilities a provider supports
8
- */
9
- export interface FeatureFlags {
10
- attachments?: boolean;
11
- batchSending?: boolean;
12
- customHeaders?: boolean;
13
- html?: boolean;
14
- replyTo?: boolean;
15
- scheduling?: boolean;
16
- tagging?: boolean;
17
- templates?: boolean;
18
- tracking?: boolean;
19
- }
20
- /**
21
- * Base configuration for all providers
22
- */
23
- export interface BaseConfig {
24
- debug?: boolean;
25
- logger?: Console;
26
- retries?: number;
27
- timeout?: number;
28
- }
29
- /**
30
- * Email address with optional name
31
- */
32
- export interface EmailAddress {
33
- email: string;
34
- name?: string;
35
- }
36
- /**
37
- * Email attachment
38
- */
39
- export interface Attachment {
40
- /**
41
- * Content-ID for inline attachments (used in HTML with cid:)
42
- */
43
- cid?: string;
44
- /**
45
- * Attachment content (string, Buffer, or Promise&lt;Uint8Array> for async loading)
46
- * Required if path, href, or raw are not provided
47
- */
48
- content?: string | Buffer | Promise<Uint8Array>;
49
- /**
50
- * Content disposition: 'attachment' (default) or 'inline'
51
- */
52
- contentDisposition?: "attachment" | "inline";
53
- /**
54
- * MIME type of the attachment
55
- */
56
- contentType?: string;
57
- /**
58
- * Content transfer encoding (e.g., 'base64', '7bit', 'quoted-printable')
59
- */
60
- encoding?: string;
61
- /**
62
- * Filename for the attachment
63
- */
64
- filename: string;
65
- /**
66
- * Custom headers for this attachment
67
- */
68
- headers?: Record<string, string>;
69
- /**
70
- * URL to fetch attachment from
71
- * Alternative to content or path
72
- */
73
- href?: string;
74
- /**
75
- * HTTP headers to use when fetching from href
76
- */
77
- httpHeaders?: Record<string, string>;
78
- /**
79
- * File path to read attachment from
80
- * Alternative to content
81
- */
82
- path?: string;
83
- /**
84
- * Raw attachment data (alternative to content)
85
- * Can be used for pre-encoded content
86
- */
87
- raw?: string | Buffer;
88
- }
89
- /**
90
- * Email tag for categorization
91
- */
92
- export interface EmailTag {
93
- name: string;
94
- value: string;
95
- }
96
- /**
97
- * Priority levels for email messages
98
- */
99
- export type Priority = "high" | "normal" | "low";
100
- /**
101
- * Represents the headers of an email message.
102
- * This type is a supertype of the standard `Headers` class, which is used to manage HTTP headers.
103
- * Note that this type does not include methods for modifying the headers,
104
- * such as `append`, `delete`, or `set`. It is intended to be used for
105
- * read-only access to the headers of an email message.
106
- */
107
- export type ImmutableHeaders = Omit<Headers, "append" | "delete" | "set">;
108
- /**
109
- * Email headers can be either a plain object or an ImmutableHeaders instance
110
- */
111
- export type EmailHeaders = Record<string, string> | ImmutableHeaders;
112
- /**
113
- * Options for calendar event attachments
114
- */
115
- export interface CalendarEventOptions {
116
- /**
117
- * Alternative text for the calendar event
118
- */
119
- alternativeText?: string;
120
- /**
121
- * Method for the calendar event (e.g., 'REQUEST', 'CANCEL', 'REPLY')
122
- */
123
- method?: string;
124
- }
125
- /**
126
- * Common email options that all providers support
127
- */
128
- export interface EmailOptions {
129
- attachments?: Attachment[];
130
- bcc?: EmailAddress | EmailAddress[];
131
- cc?: EmailAddress | EmailAddress[];
132
- from: EmailAddress;
133
- headers?: EmailHeaders;
134
- html?: string;
135
- icalEvent?: CalendarEventOptions & {
136
- content?: string;
137
- href?: string;
138
- path?: string;
139
- };
140
- priority?: Priority;
141
- replyTo?: EmailAddress;
142
- subject: string;
143
- tags?: string[];
144
- text?: string;
145
- to: EmailAddress | EmailAddress[];
146
- }
147
- /**
148
- * Result of sending an email
149
- */
150
- export interface EmailResult {
151
- messageId: string;
152
- provider?: string;
153
- response?: unknown;
154
- sent: boolean;
155
- timestamp: Date;
156
- }
157
- /**
158
- * Receipt type for email sending results
159
- * Uses discriminated union for type safety
160
- */
161
- export type Receipt = {
162
- /**
163
- * The unique identifier for the message that was sent
164
- */
165
- readonly messageId: string;
166
- /**
167
- * Optional provider name
168
- */
169
- readonly provider?: string;
170
- /**
171
- * Optional response data from provider
172
- */
173
- readonly response?: unknown;
174
- /**
175
- * Indicates that the email was sent successfully
176
- */
177
- readonly successful: true;
178
- /**
179
- * Timestamp when email was sent
180
- */
181
- readonly timestamp: Date;
182
- } | {
183
- /**
184
- * An array of error messages that occurred during the sending process
185
- */
186
- readonly errorMessages: ReadonlyArray<string>;
187
- /**
188
- * Optional provider name
189
- */
190
- readonly provider?: string;
191
- /**
192
- * Indicates that the email failed to send
193
- */
194
- readonly successful: false;
195
- };
196
- /**
197
- * Generic result type
198
- */
199
- export interface Result<T = unknown> {
200
- data?: T;
201
- error?: Error | unknown;
202
- success: boolean;
203
- }
@@ -1,8 +0,0 @@
1
- import type { EmailOptions } from "../types.d.ts";
2
- /**
3
- * Builds a MIME-formatted email message from email options.
4
- * @param options The email options to build the MIME message from.
5
- * @returns The MIME-formatted email message as a string.
6
- */
7
- declare const buildMimeMessage: <T extends EmailOptions>(options: T) => Promise<string>;
8
- export default buildMimeMessage;
@@ -1,16 +0,0 @@
1
- /**
2
- * Logger interface with debug, error, info, and warn methods.
3
- */
4
- export type Logger = {
5
- debug: (message: string, ...args: unknown[]) => void;
6
- error: (message: string, ...args: unknown[]) => void;
7
- info: (message: string, ...args: unknown[]) => void;
8
- warn: (message: string, ...args: unknown[]) => void;
9
- };
10
- /**
11
- * Creates a logger instance for a provider with optional console output.
12
- * @param providerName The name of the provider (used as prefix in log messages).
13
- * @param logger Optional Console instance. If provided, logs will be displayed with prefixes. If not provided, returns a no-op logger.
14
- * @returns A logger instance with debug, error, info, and warn methods.
15
- */
16
- export declare const createLogger: (providerName: string, logger?: Console) => Logger;
@@ -1,8 +0,0 @@
1
- import type { EmailAddress } from "../types.d.ts";
2
- /**
3
- * Formats a list of email addresses into a comma-separated string.
4
- * @param addresses The email address(es) to format (single or array).
5
- * @returns The formatted email addresses string (comma-separated if multiple).
6
- */
7
- declare const formatEmailAddresses: (addresses: EmailAddress | EmailAddress[]) => string;
8
- export default formatEmailAddresses;
@@ -1,7 +0,0 @@
1
- /**
2
- * Generates a unique boundary string for MIME multipart email messages.
3
- * Works across Node.js, Deno, Bun, and Workers.
4
- * @returns A unique boundary string for MIME multipart messages.
5
- */
6
- declare const generateBoundary: () => string;
7
- export default generateBoundary;
@@ -1,6 +0,0 @@
1
- /**
2
- * Generates a unique message ID for email messages.
3
- * @returns A unique message ID in the format &lt;timestamp.random@visulima.local>.
4
- */
5
- declare const generateMessageId: () => string;
6
- export default generateMessageId;
@@ -1,9 +0,0 @@
1
- import type { EmailHeaders } from "../types.d.ts";
2
- /**
3
- * Converts EmailHeaders (Record&lt;string, string> or ImmutableHeaders) to Record&lt;string, string>.
4
- * This allows us to work with headers uniformly regardless of their input type.
5
- * @param headers The headers to convert (Record or ImmutableHeaders).
6
- * @returns A plain object Record&lt;string, string> representation of the headers.
7
- */
8
- declare const headersToRecord: (headers: EmailHeaders) => Record<string, string>;
9
- export default headersToRecord;
@@ -1,9 +0,0 @@
1
- /**
2
- * Checks if a port is available on a host.
3
- * Works across environments with polyfills.
4
- * @param host The hostname or IP address to check.
5
- * @param port The port number to check.
6
- * @returns Promise that resolves to true if the port is available, false otherwise.
7
- */
8
- declare const isPortAvailable: (host: string, port: number) => Promise<boolean>;
9
- export default isPortAvailable;
@@ -1,18 +0,0 @@
1
- import type { Result } from "../types.d.ts";
2
- /**
3
- * Request options compatible with both Fetch API and Node.js http
4
- */
5
- export interface RequestOptions {
6
- [key: string]: unknown;
7
- headers?: Record<string, string>;
8
- method?: string;
9
- timeout?: number;
10
- }
11
- /**
12
- * Makes an HTTP request using Fetch API (compatible with Node.js 20.19+, Deno, Bun, Cloudflare Workers).
13
- * @param url The URL to make the request to.
14
- * @param options Request options including method, headers, and timeout.
15
- * @param data Optional request body data (string, Buffer, or Uint8Array).
16
- * @returns A result object containing the response data or error.
17
- */
18
- export declare const makeRequest: (url: string | URL, options?: RequestOptions, data?: string | Buffer | Uint8Array) => Promise<Result<unknown>>;
@@ -1,10 +0,0 @@
1
- import type { Result } from "../types.d.ts";
2
- /**
3
- * Helper function to retry an async function with exponential backoff.
4
- * @param function_ The async function to retry.
5
- * @param retries Number of retry attempts (default: 3).
6
- * @param delay Initial delay in milliseconds (default: 300, doubles on each retry).
7
- * @returns A result object containing the function result or error.
8
- */
9
- declare const retry: <T>(function_: () => Promise<Result<T>>, retries?: number, delay?: number) => Promise<Result<T>>;
10
- export default retry;
@@ -1,14 +0,0 @@
1
- /**
2
- * Sanitizes header values to prevent CRLF injection attacks.
3
- * Removes carriage return (\r) and line feed (\n) characters.
4
- * @param value The header value to sanitize.
5
- * @returns The sanitized header value with CR/LF characters removed.
6
- */
7
- export declare const sanitizeHeaderValue: (value: string) => string;
8
- /**
9
- * Sanitizes header names to prevent CRLF injection attacks.
10
- * Removes carriage return (\r) and line feed (\n) characters.
11
- * @param name The header name to sanitize.
12
- * @returns The sanitized header name with CR/LF characters removed.
13
- */
14
- export declare const sanitizeHeaderName: (name: string) => string;
@@ -1,8 +0,0 @@
1
- /**
2
- * Converts content to a base64-encoded string.
3
- * Works across Node.js, Deno, Bun, and Workers.
4
- * @param content The content to convert (string, Buffer, Uint8Array, or ArrayLike&lt;number>).
5
- * @returns The base64-encoded string.
6
- */
7
- declare const toBase64: (content: string | Buffer | Uint8Array | ArrayLike<number>) => string;
8
- export default toBase64;
@@ -1,8 +0,0 @@
1
- import type { EmailOptions } from "../../types.d.ts";
2
- /**
3
- * Validates email options and returns any validation errors.
4
- * @param options The email options to validate.
5
- * @returns Array of error messages (empty if validation passes).
6
- */
7
- declare const validateEmailOptions: <T extends EmailOptions>(options: T) => string[];
8
- export default validateEmailOptions;