@lobb-js/lobb-ext-mail 0.4.4 → 0.5.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 +1 -0
- package/extensions/mail/index.ts +24 -9
- package/extensions/mail/tests/mail.test.ts +1 -11
- package/package.json +3 -3
package/README.md
CHANGED
package/extensions/mail/index.ts
CHANGED
|
@@ -1,20 +1,35 @@
|
|
|
1
|
-
import type { Extension
|
|
1
|
+
import type { Extension } from "@lobb-js/core";
|
|
2
2
|
import type { ExtensionConfig } from "./extensionConfigSchema.ts";
|
|
3
3
|
import nodemailer from "nodemailer";
|
|
4
|
-
import
|
|
4
|
+
import { z } from "zod";
|
|
5
5
|
|
|
6
6
|
export function mail(extensionConfig: ExtensionConfig): Extension {
|
|
7
7
|
let transporter: ReturnType<typeof nodemailer.createTransport>;
|
|
8
8
|
return {
|
|
9
9
|
name: "mail",
|
|
10
10
|
icon: "Mail",
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return await transporter.sendMail(messageOptions);
|
|
11
|
+
events: [
|
|
12
|
+
{
|
|
13
|
+
name: "mail.send",
|
|
14
|
+
inputSchema: z.object({}).passthrough(),
|
|
15
|
+
outputSchema: z.object({}).passthrough(),
|
|
17
16
|
},
|
|
18
|
-
|
|
17
|
+
],
|
|
18
|
+
workflows: [
|
|
19
|
+
{
|
|
20
|
+
name: "mail_init",
|
|
21
|
+
eventName: "core.init",
|
|
22
|
+
handler: async () => {
|
|
23
|
+
transporter = nodemailer.createTransport(extensionConfig.transporter);
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "mail_send",
|
|
28
|
+
eventName: "mail.send",
|
|
29
|
+
handler: async (input) => {
|
|
30
|
+
return await transporter.sendMail(input);
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
],
|
|
19
34
|
};
|
|
20
35
|
}
|
|
@@ -18,23 +18,13 @@ describe("Mail Operations", () => {
|
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
it("mail should be sent successfully", async () => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (!extension) {
|
|
24
|
-
throw new Error("Couldn't find the mail extension");
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const services = extension.services!(lobb) as { sendMail: Function };
|
|
28
|
-
|
|
29
|
-
// sending the mail to the smtp server
|
|
30
|
-
await services.sendMail({
|
|
21
|
+
await lobb.eventSystem.emit("mail.send", {
|
|
31
22
|
from: "sender@example.com",
|
|
32
23
|
to: "recipient@example.com",
|
|
33
24
|
subject: "Test email",
|
|
34
25
|
text: "test email from the unit tests",
|
|
35
26
|
});
|
|
36
27
|
|
|
37
|
-
// getting the mail message from the smtp server
|
|
38
28
|
const receivedMail = SmtpServer.getReceivedMail();
|
|
39
29
|
|
|
40
30
|
expect(receivedMail.subject).toBe("Test email");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobb-js/lobb-ext-mail",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"postpublish": "lobb-ext-postpublish"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@lobb-js/core": "^0.
|
|
34
|
+
"@lobb-js/core": "^0.32.1",
|
|
35
35
|
"nodemailer": "^6.9.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@lobb-js/studio": "^0.
|
|
38
|
+
"@lobb-js/studio": "^0.29.1",
|
|
39
39
|
"@sveltejs/package": "^2.5.7",
|
|
40
40
|
"@sveltejs/adapter-node": "^5.5.4",
|
|
41
41
|
"@sveltejs/kit": "^2.60.1",
|