@stacksjs/email 0.58.72 → 0.59.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.
package/README.md CHANGED
@@ -145,7 +145,6 @@ For casual chit-chat with others using this package:
145
145
  Many thanks to the following core technologies & people who have contributed to this package:
146
146
 
147
147
  - [Chris Breuer](https://github.com/chrisbbreuer)
148
- - [Novu](https://novu.co/)
149
148
  - [All Contributors](../../contributors)
150
149
 
151
150
  ## 📄 License
@@ -0,0 +1 @@
1
+ export * as ses from './ses';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { RenderOptions } from './template';
2
+ import type { Message } from './types';
3
+ export declare class Email {
4
+ private message;
5
+ private client;
6
+ constructor(message: Message);
7
+ send(options?: RenderOptions): Promise<{
8
+ message: string;
9
+ } | undefined>;
10
+ onError(error: Error): Promise<{
11
+ message: string;
12
+ } | undefined>;
13
+ onSuccess(): Promise<{
14
+ message: string;
15
+ } | undefined> | undefined;
16
+ }
17
+ export type { Message };
18
+ export declare const email: (options: Message) => Email;
19
+ export default Email;
@@ -0,0 +1,3 @@
1
+ export * from './drivers';
2
+ export * from './email.ts';
3
+ export * from './types';
package/dist/index.js CHANGED
@@ -1,287 +1,79 @@
1
1
  // @bun
2
- var __defProp = Object.defineProperty;
3
- var __export = (target, all) => {
4
- for (var name in all)
5
- __defProp(target, name, {
6
- get: all[name],
7
- enumerable: true,
8
- configurable: true,
9
- set: (newValue) => all[name] = () => newValue
10
- });
11
- };
12
-
13
- // src/drivers/sendgrid.ts
14
- var exports_sendgrid = {};
15
- __export(exports_sendgrid, {
16
- send: () => {
17
- {
18
- return send3;
19
- }
20
- },
21
- Send: () => {
22
- {
23
- return send3;
24
- }
25
- }
26
- });
27
- import {SendgridEmailProvider} from "@novu/sendgrid";
28
- import {notification as notification2} from "@stacksjs/config";
29
-
30
- // src/send.ts
31
- import {italic, log} from "@stacksjs/cli";
32
- import {ResultAsync} from "@stacksjs/error-handling";
33
- import * as Maizzle from "@maizzle/framework";
34
-
35
- // src/utils/config.ts
36
- var exports_config = {};
37
- __export(exports_config, {
38
- email: () => {
39
- {
40
- return email;
41
- }
42
- },
43
- default: () => {
44
- {
45
- return config_default;
46
- }
47
- }
48
- });
49
- import {notification} from "@stacksjs/config";
50
- var email = notification.email;
51
- var config_default = {
52
- email
53
- };
2
+ // src/drivers/ses.ts
3
+ var exports_ses = {};
4
+ // src/email.ts
5
+ import {SES} from "@aws-sdk/client-ses";
54
6
 
55
- // src/send.ts
56
- async function send(options, provider, providerName, css) {
57
- const template = `
58
- <extends src="./src/notifications/src/utils/template.html">
59
- <block name="template">
60
- ${options.html}
61
- </block>
62
- </extends>`;
63
- await Maizzle.render(template, {
64
- tailwind: {
65
- css,
66
- maizzle: exports_config
67
- }
68
- }).then(({ html }) => {
69
- options.html = html;
70
- }).catch((error) => log.error(`Failed to render email template using provider: ${italic(providerName)}.`, error));
71
- return ResultAsync.fromPromise(provider.sendMessage(options), () => new Error(`Failed to send message using provider: ${italic(providerName)}`));
72
- }
7
+ // src/template.ts
8
+ import process from "process";
9
+ import {config} from "@vue-email/compiler";
10
+ import {path as path2} from "@stacksjs/path";
11
+ var email = config(path2.resourcesPath("emails"), {
12
+ verbose: !!process.env.DEBUG
13
+ });
14
+ var template = async (path3, options) => await email.render(path3, options);
73
15
 
74
- // src/drivers/sendgrid.ts
75
- async function send3(options, css) {
76
- return send(options, driver, "Sendgrid", css);
77
- }
78
- var env = notification2.email;
79
- var service = notification2.email?.drivers.sendgrid;
80
- var driver = new SendgridEmailProvider({
81
- apiKey: service?.key || "",
82
- from: env?.from.address || "",
83
- senderName: service?.senderName || ""
84
- });
85
- // src/drivers/mailgun.ts
86
- var exports_mailgun = {};
87
- __export(exports_mailgun, {
88
- send: () => {
89
- {
90
- return send5;
91
- }
92
- },
93
- Send: () => {
94
- {
95
- return send5;
96
- }
97
- }
98
- });
99
- import {MailgunEmailProvider} from "@novu/mailgun";
100
- import {notification as notification3} from "@stacksjs/config";
101
- async function send5(options, css) {
102
- return send(options, provider, "Mailgun", css);
103
- }
104
- var env2 = notification3.email;
105
- var service2 = notification3.email?.drivers.mailgun;
106
- var provider = new MailgunEmailProvider({
107
- apiKey: service2?.key || "",
108
- domain: service2?.domain || "",
109
- username: service2?.username || "",
110
- from: env2?.from.address || ""
111
- });
112
- // src/drivers/mailjet.ts
113
- var exports_mailjet = {};
114
- __export(exports_mailjet, {
115
- send: () => {
116
- {
117
- return send7;
118
- }
119
- },
120
- Send: () => {
121
- {
122
- return send7;
123
- }
124
- }
125
- });
126
- import {MailjetEmailProvider} from "@novu/mailjet";
127
- import {notification as notification4} from "@stacksjs/config";
128
- async function send7(options, css) {
129
- return send(options, provider2, "Mailjet", css);
130
- }
131
- var env3 = notification4.email;
132
- var service3 = notification4.email?.drivers.mailjet;
133
- var provider2 = new MailjetEmailProvider({
134
- apiKey: service3?.key || "",
135
- apiSecret: service3?.secret || "",
136
- from: env3?.from.address || "",
137
- senderName: env3?.from.name || ""
138
- });
139
- // src/drivers/mandrill.ts
140
- var exports_mandrill = {};
141
- // src/drivers/netcore.ts
142
- var exports_netcore = {};
143
- __export(exports_netcore, {
144
- send: () => {
145
- {
146
- return send9;
147
- }
148
- },
149
- Send: () => {
150
- {
151
- return send9;
152
- }
153
- }
154
- });
155
- import {NetCoreProvider} from "@novu/netcore";
156
- import {notification as notification5} from "@stacksjs/config";
157
- async function send9(options, css) {
158
- return send(options, provider3, "Netcore", css);
159
- }
160
- var env4 = notification5.email;
161
- var service4 = notification5.email?.drivers.netcore;
162
- var provider3 = new NetCoreProvider({
163
- apiKey: service4?.key || "",
164
- from: env4?.from.address || ""
165
- });
166
- // src/drivers/nodemailer.ts
167
- var exports_nodemailer = {};
168
- __export(exports_nodemailer, {
169
- send: () => {
170
- {
171
- return send11;
172
- }
173
- },
174
- Send: () => {
175
- {
176
- return send11;
177
- }
16
+ // src/email.ts
17
+ class Email {
18
+ message;
19
+ client;
20
+ constructor(message) {
21
+ this.message = message;
22
+ this.client = new SES({ region: "us-east-1" });
23
+ this.message = message;
178
24
  }
179
- });
180
- import {NodemailerProvider} from "@novu/nodemailer";
181
- import {notification as notification6} from "@stacksjs/config";
182
- async function send11(options, css) {
183
- return send(options, provider4, "Nodemailer", css);
184
- }
185
- var env5 = notification6.email;
186
- var service5 = notification6.email?.drivers.nodemailer;
187
- var provider4 = new NodemailerProvider({
188
- from: env5?.from.address || "",
189
- host: service5?.host || "",
190
- user: service5?.user,
191
- password: service5?.password,
192
- port: service5?.port || 587,
193
- secure: service5?.secure
194
- });
195
- // src/drivers/postmark.ts
196
- var exports_postmark = {};
197
- __export(exports_postmark, {
198
- send: () => {
199
- {
200
- return send13;
201
- }
202
- },
203
- Send: () => {
204
- {
205
- return send13;
25
+ async send(options) {
26
+ log.info("Sending email...");
27
+ const path3 = this.message.template;
28
+ try {
29
+ const templ = await template(path3, options);
30
+ const params = {
31
+ Source: this.message.from?.address || "",
32
+ Destination: {
33
+ ToAddresses: [this.message.to]
34
+ },
35
+ Message: {
36
+ Body: {
37
+ Html: {
38
+ Charset: "UTF-8",
39
+ Data: templ.html
40
+ }
41
+ },
42
+ Subject: {
43
+ Charset: "UTF-8",
44
+ Data: this.message.subject
45
+ }
46
+ }
47
+ };
48
+ await this.client.sendEmail(params);
49
+ let returnMsg = { message: "Email sent" };
50
+ if (this.message.handle)
51
+ returnMsg = await this.message.handle();
52
+ await this.onSuccess();
53
+ return returnMsg;
54
+ } catch (error) {
55
+ return this.onError(error);
206
56
  }
207
57
  }
208
- });
209
- import {PostmarkEmailProvider} from "@novu/postmark";
210
- import {notification as notification7} from "@stacksjs/config";
211
- async function send13(options, css) {
212
- return send(options, provider5, "Postmark", css);
213
- }
214
- var env6 = notification7.email;
215
- var service6 = notification7.email?.drivers.postmark;
216
- var provider5 = new PostmarkEmailProvider({
217
- apiKey: service6?.key || "",
218
- from: env6?.from.address || ""
219
- });
220
- // src/drivers/ses.ts
221
- var exports_ses = {};
222
- __export(exports_ses, {
223
- send: () => {
224
- {
225
- return send14;
226
- }
227
- },
228
- Send: () => {
229
- {
230
- return send14;
231
- }
58
+ async onError(error) {
59
+ log.error(error);
60
+ if (!this.message.onError)
61
+ return;
62
+ return await this.message.onError(error);
232
63
  }
233
- });
234
- import {SESEmailProvider} from "@novu/ses";
235
- import {notification as notification8} from "@stacksjs/config";
236
- async function send14(options, css) {
237
- return sendEmail(options, provider6, "Ses", css);
238
- }
239
- var email2 = notification8.email;
240
- var env7 = email2?.drivers?.ses;
241
- var provider6 = new SESEmailProvider({
242
- region: env7?.region || "us-east-1",
243
- accessKeyId: env7?.key || "",
244
- secretAccessKey: env7?.secret || "",
245
- senderName: email2?.from.name || "Stacks",
246
- from: email2?.from.address || ""
247
- });
248
- // src/drivers/emailjs.ts
249
- var exports_emailjs = {};
250
- __export(exports_emailjs, {
251
- send: () => {
252
- {
253
- return send16;
254
- }
255
- },
256
- Send: () => {
257
- {
258
- return send16;
64
+ onSuccess() {
65
+ try {
66
+ if (!this.message.onSuccess)
67
+ return;
68
+ this.message.onSuccess();
69
+ } catch (error) {
70
+ return this.onError(error);
259
71
  }
260
72
  }
261
- });
262
- import {EmailJsProvider} from "@novu/emailjs";
263
- import {notification as notification9} from "@stacksjs/config";
264
- async function send16(options, css) {
265
- return send(options, provider7, "EmailJS", css);
266
73
  }
267
- var env8 = notification9.email;
268
- var service7 = notification9.email?.drivers.emailjs;
269
- var provider7 = new EmailJsProvider({
270
- from: env8?.from.address || "",
271
- host: service7?.host || "",
272
- user: service7?.user,
273
- password: service7?.password,
274
- port: service7?.port || 587,
275
- secure: service7?.secure
276
- });
74
+ var email2 = (options) => new Email(options);
277
75
  export {
278
76
  exports_ses as ses,
279
- exports_sendgrid as sendgrid,
280
- exports_postmark as postmark,
281
- exports_nodemailer as nodemailer,
282
- exports_netcore as netcore,
283
- exports_mandrill as mandrill,
284
- exports_mailjet as mailjet,
285
- exports_mailgun as mailgun,
286
- exports_emailjs as emailjs
77
+ email2 as email,
78
+ Email
287
79
  };
@@ -0,0 +1,6 @@
1
+ import type { I18n } from 'vue-email';
2
+ export interface RenderOptions {
3
+ props?: Record<string, unknown>;
4
+ i18n?: I18n;
5
+ }
6
+ export declare const template: (path: string, options?: RenderOptions) => Promise<import("@vue-email/compiler").Result>;
@@ -0,0 +1,41 @@
1
+ export interface Message {
2
+ name: string;
3
+ subject: string;
4
+ to: string;
5
+ from?: {
6
+ name: string;
7
+ address: string;
8
+ };
9
+ template: string;
10
+ handle?: () => Promise<{
11
+ message: string;
12
+ }>;
13
+ onError?: (error: Error) => Promise<{
14
+ message: string;
15
+ }>;
16
+ onSuccess?: () => void;
17
+ }
18
+ export interface SendEmailParams {
19
+ Source: string;
20
+ Destination: {
21
+ ToAddresses: string[];
22
+ };
23
+ Message: {
24
+ Body: {
25
+ Html: {
26
+ Charset: 'UTF-8';
27
+ Data: string;
28
+ };
29
+ };
30
+ Subject: {
31
+ Charset: 'UTF-8';
32
+ Data: string;
33
+ };
34
+ };
35
+ }
36
+ export interface EmailParams {
37
+ to: string;
38
+ from: string;
39
+ subject: string;
40
+ html: string;
41
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/email",
3
3
  "type": "module",
4
- "version": "0.58.72",
4
+ "version": "0.59.1",
5
5
  "description": "The Stacks Email integration. Painlessly create & manage your inboxes, templates, and send emails.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -19,16 +19,9 @@
19
19
  "email",
20
20
  "ses",
21
21
  "aws",
22
- "maizzle",
23
22
  "stacks",
24
23
  "emailjs",
25
- "mailgun",
26
- "mailjet",
27
- "mandrill",
28
- "netcore",
29
- "nodemailer",
30
- "postmark",
31
- "sendgrid"
24
+ "mailgun"
32
25
  ],
33
26
  "exports": {
34
27
  ".": {
@@ -57,38 +50,18 @@
57
50
  "prepublishOnly": "bun --bun run build"
58
51
  },
59
52
  "peerDependencies": {
60
- "@maizzle/framework": "^4.7.6",
61
53
  "@stacksjs/cli": "latest",
62
54
  "@stacksjs/config": "latest",
63
55
  "@stacksjs/error-handling": "latest",
64
56
  "@stacksjs/types": "latest"
65
57
  },
66
58
  "dependencies": {
67
- "@maizzle/framework": "^4.7.6",
68
- "@novu/stateless": "^0.23.1",
69
59
  "@stacksjs/cli": "latest",
70
60
  "@stacksjs/config": "latest",
71
61
  "@stacksjs/error-handling": "latest",
72
62
  "@stacksjs/types": "latest",
73
- "@types/mailparser": "^3.4.4",
74
- "aws-sdk": "^2.1559.0",
75
- "mailparser": "^3.6.7",
76
- "mime": "^4.0.1",
77
- "moment": "^2.30.1",
78
- "nodemailer": "^6.9.9",
79
- "uuid": "^9.0.1"
80
- },
81
- "optionalDependencies": {
82
- "@novu/emailjs": "^0.23.1",
83
- "@novu/mailgun": "^0.23.1",
84
- "@novu/mailjet": "^0.23.1",
85
- "@novu/mandrill": "^0.23.1",
86
- "@novu/netcore": "^0.23.1",
87
- "@novu/node": "^0.23.1",
88
- "@novu/nodemailer": "^0.23.1",
89
- "@novu/postmark": "^0.23.1",
90
- "@novu/sendgrid": "^0.23.1",
91
- "@novu/ses": "^0.23.1"
63
+ "aws-sdk": "^2.1571.0",
64
+ "vue-email": "^0.8.10"
92
65
  },
93
66
  "devDependencies": {
94
67
  "@stacksjs/development": "latest"
@@ -1,9 +1,3 @@
1
- export * as sendgrid from './sendgrid'
2
- export * as mailgun from './mailgun'
3
- export * as mailjet from './mailjet'
4
- export * as mandrill from './mandrill'
5
- export * as netcore from './netcore'
6
- export * as nodemailer from './nodemailer'
7
- export * as postmark from './postmark'
1
+ // export * as mailgun from './mailgun'
2
+ // export * as nodemailer from './nodemailer'
8
3
  export * as ses from './ses'
9
- export * as emailjs from './emailjs'
@@ -1,21 +1,21 @@
1
- import { MailgunEmailProvider } from '@novu/mailgun'
2
- import type { EmailOptions } from '@stacksjs/types'
3
- import type { ResultAsync } from '@stacksjs/error-handling'
4
- import { notification } from '@stacksjs/config'
5
- import { send as sendEmail } from '../send'
6
-
7
- const env = notification.email
8
- const service = notification.email?.drivers.mailgun
9
-
10
- const provider = new MailgunEmailProvider({
11
- apiKey: service?.key || '',
12
- domain: service?.domain || '',
13
- username: service?.username || '',
14
- from: env?.from.address || '',
15
- })
16
-
17
- async function send(options: EmailOptions, css?: string): Promise<ResultAsync<any, Error>> {
18
- return sendEmail(options, provider, 'Mailgun', css)
19
- }
20
-
21
- export { send as Send, send }
1
+ // import { MailgunEmailProvider } from '@novu/mailgun'
2
+ // import type { EmailOptions } from '@stacksjs/types'
3
+ // import type { ResultAsync } from '@stacksjs/error-handling'
4
+ // import { notification } from '@stacksjs/config'
5
+ // import { send as sendEmail } from '../send'
6
+ //
7
+ // const env = notification.email
8
+ // const service = notification.email?.drivers.mailgun
9
+ //
10
+ // const provider = new MailgunEmailProvider({
11
+ // apiKey: service?.key || '',
12
+ // domain: service?.domain || '',
13
+ // username: service?.username || '',
14
+ // from: env?.from.address || '',
15
+ // })
16
+ //
17
+ // async function send(options: EmailOptions, css?: string): Promise<ResultAsync<any, Error>> {
18
+ // return sendEmail(options, provider, 'Mailgun', css)
19
+ // }
20
+ //
21
+ // export { send as Send, send }
@@ -1,23 +1,23 @@
1
- import { NodemailerProvider } from '@novu/nodemailer'
2
- import type { EmailOptions } from '@stacksjs/types'
3
- import type { ResultAsync } from '@stacksjs/error-handling'
4
- import { notification } from '@stacksjs/config'
5
- import { send as sendEmail } from '../send'
6
-
7
- const env = notification.email
8
- const service = notification.email?.drivers.nodemailer
9
-
10
- const provider = new NodemailerProvider({
11
- from: env?.from.address || '',
12
- host: service?.host || '',
13
- user: service?.user,
14
- password: service?.password,
15
- port: service?.port || 587,
16
- secure: service?.secure,
17
- })
18
-
19
- async function send(options: EmailOptions, css?: string): Promise<ResultAsync<any, Error>> {
20
- return sendEmail(options, provider, 'Nodemailer', css)
21
- }
22
-
23
- export { send as Send, send }
1
+ // import { NodemailerProvider } from '@novu/nodemailer'
2
+ // import type { EmailOptions } from '@stacksjs/types'
3
+ // import type { ResultAsync } from '@stacksjs/error-handling'
4
+ // import { notification } from '@stacksjs/config'
5
+ // import { send as sendEmail } from '../send'
6
+ //
7
+ // const env = notification.email
8
+ // const service = notification.email?.drivers.nodemailer
9
+ //
10
+ // const provider = new NodemailerProvider({
11
+ // from: env?.from.address || '',
12
+ // host: service?.host || '',
13
+ // user: service?.user,
14
+ // password: service?.password,
15
+ // port: service?.port || 587,
16
+ // secure: service?.secure,
17
+ // })
18
+ //
19
+ // async function send(options: EmailOptions, css?: string): Promise<ResultAsync<any, Error>> {
20
+ // return sendEmail(options, provider, 'Nodemailer', css)
21
+ // }
22
+ //
23
+ // export { send as Send, send }
@@ -1,22 +1,23 @@
1
- import { SESEmailProvider } from '@novu/ses'
2
- import type { EmailOptions } from '@stacksjs/types'
3
- import { notification } from '@stacksjs/config'
4
- import type { ResultAsync } from '@stacksjs/error-handling'
1
+ // import { SESEmailProvider } from '@novu/ses'
2
+ // import type { EmailOptions } from '@stacksjs/types'
3
+ // import { notification } from '@stacksjs/config'
4
+ // import type { ResultAsync } from '@stacksjs/error-handling'
5
+ // import { send as sendEmail } from '../send'
5
6
 
6
- const email = notification.email
7
- const env = email?.drivers?.ses
7
+ // const email = notification.email
8
+ // const env = email?.drivers?.ses
8
9
 
10
+ // // const provider = new SESEmailProvider({
9
11
  // const provider = new SESEmailProvider({
10
- const provider = new SESEmailProvider({
11
- region: env?.region || 'us-east-1',
12
- accessKeyId: env?.key || '',
13
- secretAccessKey: env?.secret || '',
14
- senderName: email?.from.name || 'Stacks',
15
- from: email?.from.address || '',
16
- })
12
+ // region: env?.region || 'us-east-1',
13
+ // accessKeyId: env?.key || '',
14
+ // secretAccessKey: env?.secret || '',
15
+ // senderName: email?.from.name || 'Stacks',
16
+ // from: email?.from.address || '',
17
+ // })
17
18
 
18
- async function send(options: EmailOptions, css?: string): Promise<ResultAsync<any, Error>> {
19
- return sendEmail(options, provider, 'Ses', css)
20
- }
19
+ // async function send(options: EmailOptions, css?: string): Promise<ResultAsync<any, Error>> {
20
+ // return sendEmail(options, provider, 'Ses', css)
21
+ // }
21
22
 
22
- export { send as Send, send }
23
+ // export { send as Send, send }