@yimingliao/cms 0.0.215 → 0.0.218
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/dist/src/server/infrastructure/email/create-send-email.js +24 -6
- package/dist/src/server/interfaces/apis/emails/emails-api.js +8 -3
- package/dist/types/src/server/applications/emails/auth/create-email-verification-email.d.ts +1 -1
- package/dist/types/src/server/applications/emails/auth/create-forgot-password-email.d.ts +1 -1
- package/dist/types/src/server/applications/emails/auth/create-forgot-password-email.d.ts.map +1 -1
- package/dist/types/src/server/applications/emails/inquiry/create-new-inquiry-email.d.ts +1 -1
- package/dist/types/src/server/applications/emails/inquiry/create-new-inquiry-email.d.ts.map +1 -1
- package/dist/types/src/server/infrastructure/email/create-send-email.d.ts +7 -4
- package/dist/types/src/server/infrastructure/email/create-send-email.d.ts.map +1 -1
- package/dist/types/src/server/interfaces/apis/emails/emails-api.d.ts +1 -4
- package/dist/types/src/server/interfaces/apis/emails/emails-api.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
function createSendEmail({
|
|
2
2
|
transporter,
|
|
3
|
-
config
|
|
3
|
+
config,
|
|
4
|
+
logger
|
|
4
5
|
}) {
|
|
5
6
|
return async function sendEmail(options) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
try {
|
|
8
|
+
const info = await transporter.sendMail({
|
|
9
|
+
from: `${config.fromName} <${config.fromAddress}>`,
|
|
10
|
+
replyTo: `${config.replyToName} <${config.replyToaddress}>`,
|
|
11
|
+
...options
|
|
12
|
+
});
|
|
13
|
+
logger.info("Email sent", {
|
|
14
|
+
to: options.to,
|
|
15
|
+
subject: options.subject,
|
|
16
|
+
messageId: info.messageId,
|
|
17
|
+
accepted: info.accepted,
|
|
18
|
+
rejected: info.rejected
|
|
19
|
+
});
|
|
20
|
+
return info;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
logger.error("Email failed", {
|
|
23
|
+
to: options.to,
|
|
24
|
+
subject: options.subject,
|
|
25
|
+
error
|
|
26
|
+
});
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
11
29
|
};
|
|
12
30
|
}
|
|
13
31
|
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server';
|
|
2
|
+
import '../../../../constants/paths/auth.js';
|
|
3
|
+
import '../../../../constants/paths/main.js';
|
|
4
|
+
import '../../../../constants/paths/resources.js';
|
|
5
|
+
import '../../../../constants/redirect-paths.js';
|
|
6
|
+
import { EMAILS } from '../../../../constants/emails.js';
|
|
2
7
|
|
|
3
8
|
function createEmailsApi(ctx) {
|
|
4
|
-
return function emailsApi(
|
|
9
|
+
return function emailsApi() {
|
|
5
10
|
const {
|
|
6
11
|
middlewares: { authMiddleware },
|
|
7
12
|
api: { executeApi, ipRateLimiter }
|
|
@@ -89,8 +94,8 @@ function createEmailsApi(ctx) {
|
|
|
89
94
|
<h1>CMS Email Templates</h1>
|
|
90
95
|
|
|
91
96
|
<ul>
|
|
92
|
-
${
|
|
93
|
-
(
|
|
97
|
+
${Object.entries(EMAILS).map(
|
|
98
|
+
([key, { filePath }]) => `
|
|
94
99
|
<li>
|
|
95
100
|
<a href="/api/v1/cms/emails/${filePath}">
|
|
96
101
|
<div class="key">${key}</div>
|
|
@@ -16,7 +16,7 @@ export declare function createEmailVerificationEmail({ renderEmailTemplate, send
|
|
|
16
16
|
generateHtml: (replacements?: {
|
|
17
17
|
emailVerificationUrl: string;
|
|
18
18
|
}) => Promise<string>;
|
|
19
|
-
send: ({ translator, email, newEmail }: SendParams) => Promise<
|
|
19
|
+
send: ({ translator, email, newEmail }: SendParams) => Promise<import("nodemailer/lib/sendmail-transport").SentMessageInfo>;
|
|
20
20
|
};
|
|
21
21
|
export {};
|
|
22
22
|
//# sourceMappingURL=create-email-verification-email.d.ts.map
|
|
@@ -14,7 +14,7 @@ export declare function createForgotPasswordEmail({ renderEmailTemplate, sendEma
|
|
|
14
14
|
generateHtml: (replacements?: {
|
|
15
15
|
passwordResetUrl: string;
|
|
16
16
|
}) => Promise<string>;
|
|
17
|
-
send: ({ translator, email, passwordResetToken }: SendParams) => Promise<
|
|
17
|
+
send: ({ translator, email, passwordResetToken }: SendParams) => Promise<import("nodemailer/lib/sendmail-transport").SentMessageInfo>;
|
|
18
18
|
};
|
|
19
19
|
export {};
|
|
20
20
|
//# sourceMappingURL=create-forgot-password-email.d.ts.map
|
package/dist/types/src/server/applications/emails/auth/create-forgot-password-email.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-forgot-password-email.d.ts","sourceRoot":"","sources":["../../../../../../../src/server/applications/emails/auth/create-forgot-password-email.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-forgot-password-email.d.ts","sourceRoot":"","sources":["../../../../../../../src/server/applications/emails/auth/create-forgot-password-email.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,eAAe,EAChB,MAAM,yBAAyB,CAAC;AAGjC,UAAU,UAAU;IAClB,UAAU,EAAE;QAAE,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;KAAE,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,yBAAyB,CAAC,EACxC,mBAAmB,EACnB,SAAS,EACT,MAAM,GACP,EAAE;IACD,mBAAmB,EAAE,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;IAClE,SAAS,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;IAC9C,MAAM,EAAE,MAAM,CAAC;CAChB;kCAC4C;QAAE,gBAAgB,EAAE,MAAM,CAAA;KAAE;sDAOR,UAAU;EAgB1E"}
|
|
@@ -13,7 +13,7 @@ export declare function createNewInquiryEmail({ renderEmailTemplate, sendEmail,
|
|
|
13
13
|
generateHtml: (replacements?: {
|
|
14
14
|
url: string;
|
|
15
15
|
}) => Promise<string>;
|
|
16
|
-
send: ({ translator, email }: SendParams) => Promise<
|
|
16
|
+
send: ({ translator, email }: SendParams) => Promise<import("nodemailer/lib/sendmail-transport").SentMessageInfo>;
|
|
17
17
|
};
|
|
18
18
|
export {};
|
|
19
19
|
//# sourceMappingURL=create-new-inquiry-email.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-new-inquiry-email.d.ts","sourceRoot":"","sources":["../../../../../../../src/server/applications/emails/inquiry/create-new-inquiry-email.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-new-inquiry-email.d.ts","sourceRoot":"","sources":["../../../../../../../src/server/applications/emails/inquiry/create-new-inquiry-email.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,eAAe,EAChB,MAAM,yBAAyB,CAAC;AAGjC,UAAU,UAAU;IAClB,UAAU,EAAE;QAAE,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;KAAE,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,qBAAqB,CAAC,EACpC,mBAAmB,EACnB,SAAS,EACT,MAAM,GACP,EAAE;IACD,mBAAmB,EAAE,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;IAClE,SAAS,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;IAC9C,MAAM,EAAE,MAAM,CAAC;CAChB;kCAC4C;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE;kCAIf,UAAU;EAgBtD"}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { Logger } from "logry";
|
|
2
|
+
import type SendmailTransport from "nodemailer/lib/sendmail-transport";
|
|
3
|
+
import { type Transporter } from "nodemailer";
|
|
2
4
|
interface SendEmailOptions {
|
|
3
5
|
to: string;
|
|
4
6
|
subject: string;
|
|
5
7
|
html: string;
|
|
6
8
|
}
|
|
7
|
-
export declare function createSendEmail({ transporter, config, }: {
|
|
8
|
-
transporter: Transporter
|
|
9
|
+
export declare function createSendEmail({ transporter, config, logger, }: {
|
|
10
|
+
transporter: Transporter<SendmailTransport.SentMessageInfo>;
|
|
9
11
|
config: {
|
|
10
12
|
fromName: string;
|
|
11
13
|
fromAddress: string;
|
|
12
14
|
replyToName: string;
|
|
13
15
|
replyToaddress: string;
|
|
14
16
|
};
|
|
15
|
-
|
|
17
|
+
logger: Logger;
|
|
18
|
+
}): (options: SendEmailOptions) => Promise<SendmailTransport.SentMessageInfo>;
|
|
16
19
|
export {};
|
|
17
20
|
//# sourceMappingURL=create-send-email.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-send-email.d.ts","sourceRoot":"","sources":["../../../../../../src/server/infrastructure/email/create-send-email.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"create-send-email.d.ts","sourceRoot":"","sources":["../../../../../../src/server/infrastructure/email/create-send-email.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,iBAAiB,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,UAAU,gBAAgB;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,eAAe,CAAC,EAC9B,WAAW,EACX,MAAM,EACN,MAAM,GACP,EAAE;IACD,WAAW,EAAE,WAAW,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;IAC5D,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,MAAM,EAAE,MAAM,CAAC;CAChB,IAEG,SAAS,gBAAgB,KACxB,OAAO,CAAC,iBAAiB,CAAC,eAAe,CAAC,CA2B9C"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import type { ApiContext } from "../api-context";
|
|
2
2
|
import { NextResponse } from "next/server";
|
|
3
|
-
export declare function createEmailsApi(ctx: ApiContext): (
|
|
4
|
-
key: string;
|
|
5
|
-
filePath: string;
|
|
6
|
-
}>) => Promise<NextResponse<unknown>>;
|
|
3
|
+
export declare function createEmailsApi(ctx: ApiContext): () => Promise<NextResponse<unknown>>;
|
|
7
4
|
//# sourceMappingURL=emails-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emails-api.d.ts","sourceRoot":"","sources":["../../../../../../../src/server/interfaces/apis/emails/emails-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"emails-api.d.ts","sourceRoot":"","sources":["../../../../../../../src/server/interfaces/apis/emails/emails-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,wBAAgB,eAAe,CAAC,GAAG,EAAE,UAAU,wCAqH9C"}
|