@lobb-js/lobb-ext-mail 0.5.0 → 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 CHANGED
@@ -1 +1,2 @@
1
1
  # @lobb-js/lobb-ext-mail
2
+
@@ -1,20 +1,35 @@
1
- import type { Extension, Lobb } from "@lobb-js/core";
1
+ import type { Extension } from "@lobb-js/core";
2
2
  import type { ExtensionConfig } from "./extensionConfigSchema.ts";
3
3
  import nodemailer from "nodemailer";
4
- import type { SendMailOptions } from "nodemailer";
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
- init: async (lobb: Lobb) => {
12
- transporter = nodemailer.createTransport(extensionConfig.transporter);
13
- },
14
- services: (_lobb: Lobb) => ({
15
- sendMail: async (messageOptions: SendMailOptions): Promise<any> => {
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
- const extension = lobb.configManager.getExtension("mail");
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.5.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.31.9",
34
+ "@lobb-js/core": "^0.32.1",
35
35
  "nodemailer": "^6.9.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@lobb-js/studio": "^0.29.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",