@geekmidas/emailkit 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,30 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+
25
+ Object.defineProperty(exports, '__toESM', {
26
+ enumerable: true,
27
+ get: function () {
28
+ return __toESM;
29
+ }
30
+ });
@@ -0,0 +1,68 @@
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ const nodemailer = require_chunk.__toESM(require("nodemailer"));
3
+ const react_dom_server = require_chunk.__toESM(require("react-dom/server"));
4
+
5
+ //#region src/client.ts
6
+ var SMTPClient = class {
7
+ transporter;
8
+ config;
9
+ constructor(config) {
10
+ this.config = config;
11
+ this.transporter = nodemailer.default.createTransport(config.smtp);
12
+ }
13
+ async send(options) {
14
+ const mailOptions = {
15
+ ...this.config.defaults,
16
+ ...options
17
+ };
18
+ if (!mailOptions.text && !mailOptions.html) throw new Error("Either text or html content must be provided");
19
+ const info = await this.transporter.sendMail(mailOptions);
20
+ return {
21
+ messageId: info.messageId,
22
+ accepted: info.accepted || [],
23
+ rejected: info.rejected || [],
24
+ response: info.response
25
+ };
26
+ }
27
+ async sendTemplate(template, options) {
28
+ const templateFn = this.config.templates[template];
29
+ if (!templateFn) throw new Error(`Template "${String(template)}" not found`);
30
+ const element = templateFn(options.props);
31
+ const html = (0, react_dom_server.renderToStaticMarkup)(element);
32
+ return this.send({
33
+ ...options,
34
+ html
35
+ });
36
+ }
37
+ async verify() {
38
+ try {
39
+ await this.transporter.verify();
40
+ return true;
41
+ } catch {
42
+ return false;
43
+ }
44
+ }
45
+ async close() {
46
+ this.transporter.close();
47
+ }
48
+ getTemplateNames() {
49
+ return Object.keys(this.config.templates);
50
+ }
51
+ };
52
+ function createEmailClient(config) {
53
+ return new SMTPClient(config);
54
+ }
55
+
56
+ //#endregion
57
+ Object.defineProperty(exports, 'SMTPClient', {
58
+ enumerable: true,
59
+ get: function () {
60
+ return SMTPClient;
61
+ }
62
+ });
63
+ Object.defineProperty(exports, 'createEmailClient', {
64
+ enumerable: true,
65
+ get: function () {
66
+ return createEmailClient;
67
+ }
68
+ });
@@ -0,0 +1,56 @@
1
+ import nodemailer from "nodemailer";
2
+ import { renderToStaticMarkup } from "react-dom/server";
3
+
4
+ //#region src/client.ts
5
+ var SMTPClient = class {
6
+ transporter;
7
+ config;
8
+ constructor(config) {
9
+ this.config = config;
10
+ this.transporter = nodemailer.createTransport(config.smtp);
11
+ }
12
+ async send(options) {
13
+ const mailOptions = {
14
+ ...this.config.defaults,
15
+ ...options
16
+ };
17
+ if (!mailOptions.text && !mailOptions.html) throw new Error("Either text or html content must be provided");
18
+ const info = await this.transporter.sendMail(mailOptions);
19
+ return {
20
+ messageId: info.messageId,
21
+ accepted: info.accepted || [],
22
+ rejected: info.rejected || [],
23
+ response: info.response
24
+ };
25
+ }
26
+ async sendTemplate(template, options) {
27
+ const templateFn = this.config.templates[template];
28
+ if (!templateFn) throw new Error(`Template "${String(template)}" not found`);
29
+ const element = templateFn(options.props);
30
+ const html = renderToStaticMarkup(element);
31
+ return this.send({
32
+ ...options,
33
+ html
34
+ });
35
+ }
36
+ async verify() {
37
+ try {
38
+ await this.transporter.verify();
39
+ return true;
40
+ } catch {
41
+ return false;
42
+ }
43
+ }
44
+ async close() {
45
+ this.transporter.close();
46
+ }
47
+ getTemplateNames() {
48
+ return Object.keys(this.config.templates);
49
+ }
50
+ };
51
+ function createEmailClient(config) {
52
+ return new SMTPClient(config);
53
+ }
54
+
55
+ //#endregion
56
+ export { SMTPClient, createEmailClient };
@@ -0,0 +1,4 @@
1
+ const require_client = require('./client-7k6es7pg.cjs');
2
+
3
+ exports.SMTPClient = require_client.SMTPClient;
4
+ exports.createEmailClient = require_client.createEmailClient;
@@ -0,0 +1,3 @@
1
+ import { SMTPClient, createEmailClient } from "./client-B7LjRjRM.mjs";
2
+
3
+ export { SMTPClient, createEmailClient };
package/dist/index.cjs ADDED
@@ -0,0 +1,4 @@
1
+ const require_client = require('./client-7k6es7pg.cjs');
2
+
3
+ exports.SMTPClient = require_client.SMTPClient;
4
+ exports.createEmailClient = require_client.createEmailClient;
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { SMTPClient, createEmailClient } from "./client-B7LjRjRM.mjs";
2
+
3
+ export { SMTPClient, createEmailClient };