ztechno_core 0.0.57 → 0.0.59
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/lib/mail_service.d.ts +4 -2
- package/lib/mail_service.js +12 -2
- package/lib/sql_service.d.ts +6 -0
- package/lib/sql_service.js +4 -0
- package/lib/typings/mail_types.d.ts +2 -0
- package/package.json +1 -1
package/lib/mail_service.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { MailOptionsHtml, MailOptionsText, MailResponse, MailServiceOptions } from './typings/mail_types';
|
|
1
|
+
import { MailOptions, MailOptionsHtml, MailOptionsText, MailResponse, MailServiceOptions } from './typings/mail_types';
|
|
2
2
|
export declare class ZMailService {
|
|
3
3
|
private opt;
|
|
4
|
+
protected get sql(): import('./sql_service').ZSqlService;
|
|
4
5
|
constructor(opt: MailServiceOptions);
|
|
5
|
-
|
|
6
|
+
protected allowSend(mailOpts: MailOptions): Promise<boolean>;
|
|
7
|
+
send(mailOpts: MailOptionsText | MailOptionsHtml): Promise<MailResponse | undefined>;
|
|
6
8
|
}
|
package/lib/mail_service.js
CHANGED
|
@@ -8,10 +8,20 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
8
8
|
exports.ZMailService = void 0;
|
|
9
9
|
const nodemailer_1 = __importDefault(require('nodemailer'));
|
|
10
10
|
class ZMailService {
|
|
11
|
+
get sql() {
|
|
12
|
+
return this.opt.sqlService;
|
|
13
|
+
}
|
|
11
14
|
constructor(opt) {
|
|
12
15
|
this.opt = opt;
|
|
13
16
|
}
|
|
14
|
-
|
|
17
|
+
async allowSend(mailOpts) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
async send(mailOpts) {
|
|
21
|
+
const allow = await this.allowSend(mailOpts);
|
|
22
|
+
if (!allow) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
15
25
|
const mailTransporter = nodemailer_1.default.createTransport({
|
|
16
26
|
service: 'gmail',
|
|
17
27
|
auth: this.opt.auth,
|
|
@@ -25,7 +35,7 @@ class ZMailService {
|
|
|
25
35
|
dkim: this.opt.dkim ?? mailOpts.dkim,
|
|
26
36
|
priority: mailOpts.priority,
|
|
27
37
|
};
|
|
28
|
-
return new Promise((resolve, reject) => {
|
|
38
|
+
return await new Promise((resolve, reject) => {
|
|
29
39
|
mailTransporter.sendMail(mailDetails, function (err, data) {
|
|
30
40
|
return err ? reject(err) : resolve(data);
|
|
31
41
|
});
|
package/lib/sql_service.d.ts
CHANGED
package/lib/sql_service.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import SMTPTransport from 'nodemailer/lib/smtp-transport';
|
|
2
|
+
import { ZSqlService } from '../sql_service';
|
|
2
3
|
interface OptionalOptions {
|
|
3
4
|
cacheDir?:
|
|
4
5
|
| string
|
|
@@ -33,6 +34,7 @@ export type MailServiceOptions = {
|
|
|
33
34
|
};
|
|
34
35
|
mailSender: string;
|
|
35
36
|
dkim?: SingleDKIMKeyOptions;
|
|
37
|
+
sqlService?: ZSqlService;
|
|
36
38
|
};
|
|
37
39
|
export type MailOptionsBase = {
|
|
38
40
|
recipient: string;
|