@webiny/api-mailer 0.0.0-unstable.e6f0dc8ca7 → 0.0.0-unstable.eb81deee7e
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/MailerFeature.d.ts +4 -0
- package/MailerFeature.js +25 -0
- package/MailerFeature.js.map +1 -0
- package/constants.js +2 -1
- package/constants.js.map +1 -1
- package/domain/CodeMailerSettings/abstractions.js +2 -1
- package/domain/CodeMailerSettings/abstractions.js.map +1 -1
- package/domain/MailTransport/abstractions.d.ts +1 -7
- package/domain/MailTransport/abstractions.js +3 -3
- package/domain/MailTransport/abstractions.js.map +1 -1
- package/domain/MailerService/abstractions.d.ts +2 -2
- package/domain/MailerService/abstractions.js +2 -1
- package/domain/MailerService/abstractions.js.map +1 -1
- package/domain/MailerService/errors.d.ts +4 -0
- package/domain/MailerService/errors.js +29 -24
- package/domain/MailerService/errors.js.map +1 -1
- package/domain/errors.js +40 -44
- package/domain/errors.js.map +1 -1
- package/exports/api/mailer.js +3 -5
- package/features/CodeMailerSettings/CodeMailerSettings.js +23 -0
- package/features/CodeMailerSettings/CodeMailerSettings.js.map +1 -0
- package/features/CodeMailerSettings/feature.js +7 -6
- package/features/CodeMailerSettings/feature.js.map +1 -1
- package/features/DummyTransport/DummyMailTransport.js +11 -9
- package/features/DummyTransport/DummyMailTransport.js.map +1 -1
- package/features/DummyTransport/DummyMailTransportFactory.d.ts +1 -0
- package/features/DummyTransport/DummyMailTransportFactory.js +13 -7
- package/features/DummyTransport/DummyMailTransportFactory.js.map +1 -1
- package/features/DummyTransport/feature.js +6 -5
- package/features/DummyTransport/feature.js.map +1 -1
- package/features/GetSettings/GetSettingsRepository.js +43 -45
- package/features/GetSettings/GetSettingsRepository.js.map +1 -1
- package/features/GetSettings/GetSettingsUseCase.js +13 -10
- package/features/GetSettings/GetSettingsUseCase.js.map +1 -1
- package/features/GetSettings/abstractions.js +3 -2
- package/features/GetSettings/abstractions.js.map +1 -1
- package/features/GetSettings/feature.js +7 -6
- package/features/GetSettings/feature.js.map +1 -1
- package/features/GetSettings/index.js +1 -3
- package/features/MailerService/MailerService.d.ts +3 -4
- package/features/MailerService/MailerService.js +49 -43
- package/features/MailerService/MailerService.js.map +1 -1
- package/features/MailerService/feature.js +6 -7
- package/features/MailerService/feature.js.map +1 -1
- package/features/SaveSettings/SaveSettingsRepository.js +32 -46
- package/features/SaveSettings/SaveSettingsRepository.js.map +1 -1
- package/features/SaveSettings/SaveSettingsUseCase.d.ts +4 -4
- package/features/SaveSettings/SaveSettingsUseCase.js +44 -57
- package/features/SaveSettings/SaveSettingsUseCase.js.map +1 -1
- package/features/SaveSettings/abstractions.d.ts +1 -0
- package/features/SaveSettings/abstractions.js +5 -17
- package/features/SaveSettings/abstractions.js.map +1 -1
- package/features/SaveSettings/events.js +16 -11
- package/features/SaveSettings/events.js.map +1 -1
- package/features/SaveSettings/feature.js +7 -6
- package/features/SaveSettings/feature.js.map +1 -1
- package/features/SaveSettings/index.js +1 -3
- package/features/SaveSettings/validation.d.ts +2 -1
- package/features/SaveSettings/validation.js +12 -14
- package/features/SaveSettings/validation.js.map +1 -1
- package/features/SendMail/SendMailUseCase.d.ts +1 -1
- package/features/SendMail/SendMailUseCase.js +40 -47
- package/features/SendMail/SendMailUseCase.js.map +1 -1
- package/features/SendMail/abstractions.js +5 -8
- package/features/SendMail/abstractions.js.map +1 -1
- package/features/SendMail/events.js +23 -16
- package/features/SendMail/events.js.map +1 -1
- package/features/SendMail/feature.js +6 -5
- package/features/SendMail/feature.js.map +1 -1
- package/features/SendMail/index.js +1 -3
- package/features/SmtpTransport/SmtpConfig.js +21 -24
- package/features/SmtpTransport/SmtpConfig.js.map +1 -1
- package/features/SmtpTransport/SmtpMailTransport.d.ts +9 -9
- package/features/SmtpTransport/SmtpMailTransport.js +47 -61
- package/features/SmtpTransport/SmtpMailTransport.js.map +1 -1
- package/features/SmtpTransport/SmtpMailTransportFactory.d.ts +1 -0
- package/features/SmtpTransport/SmtpMailTransportFactory.js +13 -7
- package/features/SmtpTransport/SmtpMailTransportFactory.js.map +1 -1
- package/features/SmtpTransport/feature.js +6 -5
- package/features/SmtpTransport/feature.js.map +1 -1
- package/graphql/MailerSchemaFactory.d.ts +10 -0
- package/graphql/MailerSchemaFactory.js +120 -0
- package/graphql/MailerSchemaFactory.js.map +1 -0
- package/index.d.ts +1 -2
- package/index.js +1 -26
- package/package.json +21 -22
- package/types.d.ts +1 -0
- package/types.js +0 -3
- package/utils/isMailboxAddress.js +3 -10
- package/utils/isMailboxAddress.js.map +1 -1
- package/exports/api/mailer.js.map +0 -1
- package/features/CodeMailerSettings/CodeMailerSettingsImpl.js +0 -22
- package/features/CodeMailerSettings/CodeMailerSettingsImpl.js.map +0 -1
- package/features/GetSettings/index.js.map +0 -1
- package/features/MailerService/ActiveTransport.d.ts +0 -10
- package/features/MailerService/ActiveTransport.js +0 -20
- package/features/MailerService/ActiveTransport.js.map +0 -1
- package/features/SaveSettings/index.js.map +0 -1
- package/features/SendMail/index.js.map +0 -1
- package/graphql/settings.d.ts +0 -3
- package/graphql/settings.js +0 -127
- package/graphql/settings.js.map +0 -1
- package/index.js.map +0 -1
- package/types.js.map +0 -1
- /package/features/CodeMailerSettings/{CodeMailerSettingsImpl.d.ts → CodeMailerSettings.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/SmtpTransport/SmtpConfig.js","sources":["../../../src/features/SmtpTransport/SmtpConfig.ts"],"sourcesContent":["import type { TransportSettings } from \"~/types.js\";\nimport type SMTPTransport from \"nodemailer/lib/smtp-transport\";\n\nexport type SmtpTransportConfig = SMTPTransport.Options;\n\nconst configDefaults: Partial<SmtpTransportConfig> = {\n socketTimeout: 15000,\n connectionTimeout: 15000,\n greetingTimeout: 15000\n};\n\nexport class SmtpConfig {\n static fromTransportSettings(settings: TransportSettings): SmtpTransportConfig {\n const baseConfig: SmtpTransportConfig = {\n host: settings.host,\n port: settings.port,\n secure: settings.secure,\n auth: {\n user: settings.user,\n pass: settings.password\n }\n };\n\n // Apply defaults\n return Object.keys(configDefaults).reduce<SmtpTransportConfig>((config, key) => {\n const configKey = key as keyof SmtpTransportConfig;\n if (config[configKey] === undefined || config[configKey] === null) {\n // @ts-expect-error\n config[configKey] = configDefaults[configKey];\n }\n return config;\n }, baseConfig);\n }\n}\n"],"names":["configDefaults","SmtpConfig","settings","baseConfig","Object","config","key","configKey","undefined"],"mappings":"AAKA,MAAMA,iBAA+C;IACjD,eAAe;IACf,mBAAmB;IACnB,iBAAiB;AACrB;AAEO,MAAMC;IACT,OAAO,sBAAsBC,QAA2B,EAAuB;QAC3E,MAAMC,aAAkC;YACpC,MAAMD,SAAS,IAAI;YACnB,MAAMA,SAAS,IAAI;YACnB,QAAQA,SAAS,MAAM;YACvB,MAAM;gBACF,MAAMA,SAAS,IAAI;gBACnB,MAAMA,SAAS,QAAQ;YAC3B;QACJ;QAGA,OAAOE,OAAO,IAAI,CAACJ,gBAAgB,MAAM,CAAsB,CAACK,QAAQC;YACpE,MAAMC,YAAYD;YAClB,IAAID,AAAsBG,WAAtBH,MAAM,CAACE,UAAU,IAAkBF,AAAsB,SAAtBA,MAAM,CAACE,UAAU,EAEpDF,MAAM,CAACE,UAAU,GAAGP,cAAc,CAACO,UAAU;YAEjD,OAAOF;QACX,GAAGF;IACP;AACJ"}
|
|
@@ -27,21 +27,18 @@ export declare class SmtpMailTransport implements MailTransport.Interface {
|
|
|
27
27
|
message: any;
|
|
28
28
|
code: any;
|
|
29
29
|
data: {
|
|
30
|
-
|
|
31
|
-
response: any;
|
|
32
|
-
responseCode: any;
|
|
33
|
-
to: string[];
|
|
30
|
+
to?: string[];
|
|
34
31
|
cc?: string[];
|
|
35
|
-
bcc
|
|
32
|
+
bcc: string[];
|
|
36
33
|
from?: string;
|
|
37
34
|
subject: string;
|
|
38
35
|
text?: string;
|
|
39
36
|
html?: string;
|
|
40
37
|
replyTo?: string;
|
|
41
|
-
} | {
|
|
42
38
|
command: any;
|
|
43
39
|
response: any;
|
|
44
40
|
responseCode: any;
|
|
41
|
+
} | {
|
|
45
42
|
to?: string[];
|
|
46
43
|
cc: string[];
|
|
47
44
|
bcc?: string[];
|
|
@@ -50,18 +47,21 @@ export declare class SmtpMailTransport implements MailTransport.Interface {
|
|
|
50
47
|
text?: string;
|
|
51
48
|
html?: string;
|
|
52
49
|
replyTo?: string;
|
|
53
|
-
} | {
|
|
54
50
|
command: any;
|
|
55
51
|
response: any;
|
|
56
52
|
responseCode: any;
|
|
57
|
-
|
|
53
|
+
} | {
|
|
54
|
+
to: string[];
|
|
58
55
|
cc?: string[];
|
|
59
|
-
bcc
|
|
56
|
+
bcc?: string[];
|
|
60
57
|
from?: string;
|
|
61
58
|
subject: string;
|
|
62
59
|
text?: string;
|
|
63
60
|
html?: string;
|
|
64
61
|
replyTo?: string;
|
|
62
|
+
command: any;
|
|
63
|
+
response: any;
|
|
64
|
+
responseCode: any;
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
67
|
}>;
|
|
@@ -1,67 +1,53 @@
|
|
|
1
1
|
import nodemailer from "nodemailer";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// config (or anything else a future nodemailer version stamps onto
|
|
49
|
-
// its errors) in error responses.
|
|
50
|
-
return {
|
|
51
|
-
result: null,
|
|
52
|
-
error: {
|
|
53
|
-
message: ex.message,
|
|
54
|
-
code: ex.code,
|
|
55
|
-
data: {
|
|
56
|
-
...params,
|
|
57
|
-
command: ex.command,
|
|
58
|
-
response: ex.response,
|
|
59
|
-
responseCode: ex.responseCode
|
|
60
|
-
}
|
|
2
|
+
class SmtpMailTransport {
|
|
3
|
+
constructor(config){
|
|
4
|
+
this.name = "Mailer/SmtpTransport";
|
|
5
|
+
this.transporter = nodemailer.createTransport(config);
|
|
6
|
+
}
|
|
7
|
+
async send(params) {
|
|
8
|
+
const { replyTo, text, html, to, bcc, cc, from, subject } = params;
|
|
9
|
+
try {
|
|
10
|
+
const result = await this.transporter.sendMail({
|
|
11
|
+
replyTo,
|
|
12
|
+
bcc,
|
|
13
|
+
cc,
|
|
14
|
+
from,
|
|
15
|
+
text,
|
|
16
|
+
html,
|
|
17
|
+
to,
|
|
18
|
+
subject
|
|
19
|
+
});
|
|
20
|
+
if (result.messageId) return {
|
|
21
|
+
result: result.response,
|
|
22
|
+
error: null
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
result: null,
|
|
26
|
+
error: {
|
|
27
|
+
message: "nodemailer.sendMail does not have a messageId in the result. Something went wrong...",
|
|
28
|
+
code: "MAILER_ERROR",
|
|
29
|
+
data: {
|
|
30
|
+
...result
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
} catch (ex) {
|
|
35
|
+
return {
|
|
36
|
+
result: null,
|
|
37
|
+
error: {
|
|
38
|
+
message: ex.message,
|
|
39
|
+
code: ex.code,
|
|
40
|
+
data: {
|
|
41
|
+
...params,
|
|
42
|
+
command: ex.command,
|
|
43
|
+
response: ex.response,
|
|
44
|
+
responseCode: ex.responseCode
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
61
48
|
}
|
|
62
|
-
};
|
|
63
49
|
}
|
|
64
|
-
}
|
|
65
50
|
}
|
|
51
|
+
export { SmtpMailTransport };
|
|
66
52
|
|
|
67
53
|
//# sourceMappingURL=SmtpMailTransport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/SmtpTransport/SmtpMailTransport.js","sources":["../../../src/features/SmtpTransport/SmtpMailTransport.ts"],"sourcesContent":["import type { Transporter } from \"nodemailer\";\nimport nodemailer from \"nodemailer\";\nimport type SMTPTransport from \"nodemailer/lib/smtp-transport\";\nimport { MailTransport } from \"~/domain/MailTransport/abstractions.js\";\n\nexport class SmtpMailTransport implements MailTransport.Interface {\n public readonly name = \"Mailer/SmtpTransport\";\n private readonly transporter: Transporter<SMTPTransport.SentMessageInfo>;\n\n constructor(config: SMTPTransport.Options) {\n this.transporter = nodemailer.createTransport(config);\n }\n\n async send(params: MailTransport.SendParams) {\n const { replyTo, text, html, to, bcc, cc, from, subject } = params;\n\n try {\n const result = await this.transporter.sendMail({\n replyTo,\n bcc,\n cc,\n from,\n text,\n html,\n to,\n subject\n });\n\n if (result.messageId) {\n return {\n result: result.response,\n error: null\n };\n }\n\n return {\n result: null,\n error: {\n message:\n \"nodemailer.sendMail does not have a messageId in the result. Something went wrong...\",\n code: \"MAILER_ERROR\",\n data: {\n ...result\n }\n }\n };\n } catch (ex: any) {\n // Allow-list specific nodemailer/SMTP error fields. Spreading `ex`\n // or `ex.data` blindly would risk surfacing the transporter's auth\n // config (or anything else a future nodemailer version stamps onto\n // its errors) in error responses.\n return {\n result: null,\n error: {\n message: ex.message,\n code: ex.code,\n data: {\n ...params,\n command: ex.command,\n response: ex.response,\n responseCode: ex.responseCode\n }\n }\n };\n }\n }\n}\n"],"names":["SmtpMailTransport","config","nodemailer","params","replyTo","text","html","to","bcc","cc","from","subject","result","ex"],"mappings":";AAKO,MAAMA;IAIT,YAAYC,MAA6B,CAAE;aAH3B,IAAI,GAAG;QAInB,IAAI,CAAC,WAAW,GAAGC,WAAW,eAAe,CAACD;IAClD;IAEA,MAAM,KAAKE,MAAgC,EAAE;QACzC,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAEC,IAAI,EAAEC,EAAE,EAAEC,GAAG,EAAEC,EAAE,EAAEC,IAAI,EAAEC,OAAO,EAAE,GAAGR;QAE5D,IAAI;YACA,MAAMS,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;gBAC3CR;gBACAI;gBACAC;gBACAC;gBACAL;gBACAC;gBACAC;gBACAI;YACJ;YAEA,IAAIC,OAAO,SAAS,EAChB,OAAO;gBACH,QAAQA,OAAO,QAAQ;gBACvB,OAAO;YACX;YAGJ,OAAO;gBACH,QAAQ;gBACR,OAAO;oBACH,SACI;oBACJ,MAAM;oBACN,MAAM;wBACF,GAAGA,MAAM;oBACb;gBACJ;YACJ;QACJ,EAAE,OAAOC,IAAS;YAKd,OAAO;gBACH,QAAQ;gBACR,OAAO;oBACH,SAASA,GAAG,OAAO;oBACnB,MAAMA,GAAG,IAAI;oBACb,MAAM;wBACF,GAAGV,MAAM;wBACT,SAASU,GAAG,OAAO;wBACnB,UAAUA,GAAG,QAAQ;wBACrB,cAAcA,GAAG,YAAY;oBACjC;gBACJ;YACJ;QACJ;IACJ;AACJ"}
|
|
@@ -2,6 +2,7 @@ import { MailTransportFactory } from "../../domain/MailTransport/abstractions.js
|
|
|
2
2
|
import type { TransportSettings } from "../../types.js";
|
|
3
3
|
declare class SmtpMailTransportFactoryImpl implements MailTransportFactory.Interface {
|
|
4
4
|
readonly name = "Mailer/SmtpTransport";
|
|
5
|
+
canUse(settings: TransportSettings | null): boolean;
|
|
5
6
|
createTransport(settings: TransportSettings): MailTransportFactory.Return;
|
|
6
7
|
}
|
|
7
8
|
export declare const SmtpMailTransportFactory: typeof SmtpMailTransportFactoryImpl & {
|
|
@@ -2,14 +2,20 @@ import { MailTransportFactory } from "../../domain/MailTransport/abstractions.js
|
|
|
2
2
|
import { SmtpMailTransport } from "./SmtpMailTransport.js";
|
|
3
3
|
import { SmtpConfig } from "./SmtpConfig.js";
|
|
4
4
|
class SmtpMailTransportFactoryImpl {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
canUse(settings) {
|
|
6
|
+
return null !== settings;
|
|
7
|
+
}
|
|
8
|
+
async createTransport(settings) {
|
|
9
|
+
return new SmtpMailTransport(SmtpConfig.fromTransportSettings(settings));
|
|
10
|
+
}
|
|
11
|
+
constructor(){
|
|
12
|
+
this.name = "Mailer/SmtpTransport";
|
|
13
|
+
}
|
|
9
14
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
const SmtpMailTransportFactory = MailTransportFactory.createImplementation({
|
|
16
|
+
implementation: SmtpMailTransportFactoryImpl,
|
|
17
|
+
dependencies: []
|
|
13
18
|
});
|
|
19
|
+
export { SmtpMailTransportFactory };
|
|
14
20
|
|
|
15
21
|
//# sourceMappingURL=SmtpMailTransportFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/SmtpTransport/SmtpMailTransportFactory.js","sources":["../../../src/features/SmtpTransport/SmtpMailTransportFactory.ts"],"sourcesContent":["import { MailTransportFactory } from \"~/domain/MailTransport/abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\nimport { SmtpMailTransport } from \"~/features/SmtpTransport/SmtpMailTransport.js\";\nimport { SmtpConfig } from \"~/features/SmtpTransport/SmtpConfig.js\";\n\nclass SmtpMailTransportFactoryImpl implements MailTransportFactory.Interface {\n public readonly name = \"Mailer/SmtpTransport\";\n\n canUse(settings: TransportSettings | null): boolean {\n return settings !== null;\n }\n\n async createTransport(settings: TransportSettings): MailTransportFactory.Return {\n return new SmtpMailTransport(SmtpConfig.fromTransportSettings(settings));\n }\n}\n\nexport const SmtpMailTransportFactory = MailTransportFactory.createImplementation({\n implementation: SmtpMailTransportFactoryImpl,\n dependencies: []\n});\n"],"names":["SmtpMailTransportFactoryImpl","settings","SmtpMailTransport","SmtpConfig","SmtpMailTransportFactory","MailTransportFactory"],"mappings":";;;AAKA,MAAMA;IAGF,OAAOC,QAAkC,EAAW;QAChD,OAAOA,AAAa,SAAbA;IACX;IAEA,MAAM,gBAAgBA,QAA2B,EAA+B;QAC5E,OAAO,IAAIC,kBAAkBC,WAAW,qBAAqB,CAACF;IAClE;;aARgB,IAAI,GAAG;;AAS3B;AAEO,MAAMG,2BAA2BC,qBAAqB,oBAAoB,CAAC;IAC9E,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { SmtpMailTransportFactory } from "./SmtpMailTransportFactory.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const SmtpTransportFeature = createFeature({
|
|
4
|
+
name: "SmtpTransport",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(SmtpMailTransportFactory).inSingletonScope();
|
|
7
|
+
}
|
|
8
8
|
});
|
|
9
|
+
export { SmtpTransportFeature };
|
|
9
10
|
|
|
10
11
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/SmtpTransport/feature.js","sources":["../../../src/features/SmtpTransport/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { SmtpMailTransportFactory } from \"./SmtpMailTransportFactory.js\";\n\nexport const SmtpTransportFeature = createFeature({\n name: \"SmtpTransport\",\n register(container) {\n container.register(SmtpMailTransportFactory).inSingletonScope();\n }\n});\n"],"names":["SmtpTransportFeature","createFeature","container","SmtpMailTransportFactory"],"mappings":";;AAGO,MAAMA,uBAAuBC,cAAc;IAC9C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,0BAA0B,gBAAgB;IACjE;AACJ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import type { IGraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js";
|
|
3
|
+
declare class MailerSchemaFactoryImpl implements GraphQLSchemaFactory.Interface {
|
|
4
|
+
getSchemaKey: () => string;
|
|
5
|
+
execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder>;
|
|
6
|
+
}
|
|
7
|
+
export declare const MailerSchemaFactory: typeof MailerSchemaFactoryImpl & {
|
|
8
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-graphql/graphql/abstractions.public").IGraphQLSchemaFactory>;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { GraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import { staticSchemaKey } from "@webiny/api-graphql/graphql/staticSchemaKey.js";
|
|
3
|
+
import { ErrorResponse } from "@webiny/api-graphql/responses.js";
|
|
4
|
+
import { GetSettingsUseCase } from "../features/GetSettings/abstractions.js";
|
|
5
|
+
import { SaveSettingsUseCase } from "../features/SaveSettings/abstractions.js";
|
|
6
|
+
const SMTP_TRANSPORT_NAME = "Mailer/SmtpTransport";
|
|
7
|
+
const toPublicSettings = (settings, source)=>{
|
|
8
|
+
if (!settings) return null;
|
|
9
|
+
const { password: _password, ...publicSettings } = settings;
|
|
10
|
+
return {
|
|
11
|
+
...publicSettings,
|
|
12
|
+
source
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
class MailerSchemaFactoryImpl {
|
|
16
|
+
async execute(builder) {
|
|
17
|
+
builder.addTypeDefs(`
|
|
18
|
+
type MailerTransportSettingsError {
|
|
19
|
+
message: String!
|
|
20
|
+
code: String
|
|
21
|
+
data: JSON
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type MailerTransportSettings {
|
|
25
|
+
host: String
|
|
26
|
+
port: Number
|
|
27
|
+
secure: Boolean
|
|
28
|
+
user: String
|
|
29
|
+
from: String
|
|
30
|
+
replyTo: String
|
|
31
|
+
source: String
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type MailerTransportSettingsResponse {
|
|
35
|
+
data: MailerTransportSettings
|
|
36
|
+
error: MailerTransportSettingsError
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type MailerQuery {
|
|
40
|
+
getSettings: MailerTransportSettingsResponse!
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
input MailerTransportSettingsInput {
|
|
44
|
+
host: String!
|
|
45
|
+
port: Number
|
|
46
|
+
secure: Boolean
|
|
47
|
+
user: String!
|
|
48
|
+
password: String
|
|
49
|
+
from: String!
|
|
50
|
+
replyTo: String
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
type MailerMutation {
|
|
54
|
+
saveSettings(data: MailerTransportSettingsInput!): MailerTransportSettingsResponse!
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
extend type Query {
|
|
58
|
+
mailer: MailerQuery
|
|
59
|
+
}
|
|
60
|
+
extend type Mutation {
|
|
61
|
+
mailer: MailerMutation
|
|
62
|
+
}
|
|
63
|
+
`);
|
|
64
|
+
builder.addResolver({
|
|
65
|
+
path: "Query.mailer",
|
|
66
|
+
resolver: ()=>async ()=>({})
|
|
67
|
+
});
|
|
68
|
+
builder.addResolver({
|
|
69
|
+
path: "Mutation.mailer",
|
|
70
|
+
resolver: ()=>async ()=>({})
|
|
71
|
+
});
|
|
72
|
+
builder.addResolver({
|
|
73
|
+
path: "MailerQuery.getSettings",
|
|
74
|
+
dependencies: [
|
|
75
|
+
GetSettingsUseCase
|
|
76
|
+
],
|
|
77
|
+
resolver: (getSettings)=>async ()=>{
|
|
78
|
+
try {
|
|
79
|
+
const result = await getSettings.execute(SMTP_TRANSPORT_NAME);
|
|
80
|
+
const { settings, source } = result.value;
|
|
81
|
+
return {
|
|
82
|
+
data: toPublicSettings(settings, source),
|
|
83
|
+
error: null
|
|
84
|
+
};
|
|
85
|
+
} catch (ex) {
|
|
86
|
+
return new ErrorResponse(ex);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
builder.addResolver({
|
|
91
|
+
path: "MailerMutation.saveSettings",
|
|
92
|
+
dependencies: [
|
|
93
|
+
SaveSettingsUseCase
|
|
94
|
+
],
|
|
95
|
+
resolver: (saveSettings)=>async ({ args })=>{
|
|
96
|
+
try {
|
|
97
|
+
const result = await saveSettings.execute(args.data);
|
|
98
|
+
if (result.isFail()) return new ErrorResponse(result.error);
|
|
99
|
+
return {
|
|
100
|
+
data: toPublicSettings(result.value, "storage"),
|
|
101
|
+
error: null
|
|
102
|
+
};
|
|
103
|
+
} catch (ex) {
|
|
104
|
+
return new ErrorResponse(ex);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
return builder;
|
|
109
|
+
}
|
|
110
|
+
constructor(){
|
|
111
|
+
this.getSchemaKey = staticSchemaKey("api-mailer/MailerSchemaFactoryImpl");
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const MailerSchemaFactory = GraphQLSchemaFactory.createImplementation({
|
|
115
|
+
implementation: MailerSchemaFactoryImpl,
|
|
116
|
+
dependencies: []
|
|
117
|
+
});
|
|
118
|
+
export { MailerSchemaFactory };
|
|
119
|
+
|
|
120
|
+
//# sourceMappingURL=MailerSchemaFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/MailerSchemaFactory.js","sources":["../../src/graphql/MailerSchemaFactory.ts"],"sourcesContent":["import { GraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport { staticSchemaKey } from \"@webiny/api-graphql/graphql/staticSchemaKey.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { ErrorResponse } from \"@webiny/api-graphql/responses.js\";\nimport { GetSettingsUseCase } from \"~/features/GetSettings/abstractions.js\";\nimport { SaveSettingsUseCase } from \"~/features/SaveSettings/abstractions.js\";\nimport type { MailerSettingsSource } from \"~/features/GetSettings/abstractions.js\";\nimport type { SaveSettingsInput } from \"~/features/SaveSettings/abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\n\nconst SMTP_TRANSPORT_NAME = \"Mailer/SmtpTransport\";\n\n// Strip `password` before the settings leave the server and tack on `source`\n// so the admin UI can branch on code-vs-storage. Accepts both the full\n// `TransportSettings` (from getSettings) and the already-stripped\n// `Omit<TransportSettings, \"password\">` (from saveSettings) — defense in depth\n// even when the input type carries no password to begin with.\nconst toPublicSettings = (\n settings: TransportSettings | Omit<TransportSettings, \"password\"> | null,\n source: MailerSettingsSource\n): (Omit<TransportSettings, \"password\"> & { source: MailerSettingsSource }) | null => {\n if (!settings) {\n return null;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { password: _password, ...publicSettings } = settings as TransportSettings;\n return { ...publicSettings, source };\n};\n\nclass MailerSchemaFactoryImpl implements GraphQLSchemaFactory.Interface {\n public getSchemaKey = staticSchemaKey(\"api-mailer/MailerSchemaFactoryImpl\");\n\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n builder.addTypeDefs(`\n type MailerTransportSettingsError {\n message: String!\n code: String\n data: JSON\n }\n\n type MailerTransportSettings {\n host: String\n port: Number\n secure: Boolean\n user: String\n from: String\n replyTo: String\n source: String\n }\n\n type MailerTransportSettingsResponse {\n data: MailerTransportSettings\n error: MailerTransportSettingsError\n }\n\n type MailerQuery {\n getSettings: MailerTransportSettingsResponse!\n }\n\n input MailerTransportSettingsInput {\n host: String!\n port: Number\n secure: Boolean\n user: String!\n password: String\n from: String!\n replyTo: String\n }\n\n type MailerMutation {\n saveSettings(data: MailerTransportSettingsInput!): MailerTransportSettingsResponse!\n }\n\n extend type Query {\n mailer: MailerQuery\n }\n extend type Mutation {\n mailer: MailerMutation\n }\n `);\n\n builder.addResolver({\n path: \"Query.mailer\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"Mutation.mailer\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"MailerQuery.getSettings\",\n dependencies: [GetSettingsUseCase],\n resolver: (getSettings: GetSettingsUseCase.Interface) => async () => {\n try {\n const result = await getSettings.execute(SMTP_TRANSPORT_NAME);\n\n const { settings, source } = result.value;\n\n return {\n data: toPublicSettings(settings, source),\n error: null\n };\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n }\n });\n\n builder.addResolver<{ data: SaveSettingsInput }>({\n path: \"MailerMutation.saveSettings\",\n dependencies: [SaveSettingsUseCase],\n resolver:\n (saveSettings: SaveSettingsUseCase.Interface) =>\n async ({ args }) => {\n try {\n const result = await saveSettings.execute(args.data);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return {\n data: toPublicSettings(result.value, \"storage\"),\n error: null\n };\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n }\n });\n\n return builder;\n }\n}\n\nexport const MailerSchemaFactory = GraphQLSchemaFactory.createImplementation({\n implementation: MailerSchemaFactoryImpl,\n dependencies: []\n});\n"],"names":["SMTP_TRANSPORT_NAME","toPublicSettings","settings","source","_password","publicSettings","MailerSchemaFactoryImpl","builder","GetSettingsUseCase","getSettings","result","ex","ErrorResponse","SaveSettingsUseCase","saveSettings","args","staticSchemaKey","MailerSchemaFactory","GraphQLSchemaFactory"],"mappings":";;;;;AAUA,MAAMA,sBAAsB;AAO5B,MAAMC,mBAAmB,CACrBC,UACAC;IAEA,IAAI,CAACD,UACD,OAAO;IAGX,MAAM,EAAE,UAAUE,SAAS,EAAE,GAAGC,gBAAgB,GAAGH;IACnD,OAAO;QAAE,GAAGG,cAAc;QAAEF;IAAO;AACvC;AAEA,MAAMG;IAGF,MAAM,QAAQC,OAA8B,EAAkC;QAC1EA,QAAQ,WAAW,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA8CrB,CAAC;QAEDA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,UAAU,IAAM,UAAa,EAAC;QAClC;QAEAA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,UAAU,IAAM,UAAa,EAAC;QAClC;QAEAA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc;gBAACC;aAAmB;YAClC,UAAU,CAACC,cAA8C;oBACrD,IAAI;wBACA,MAAMC,SAAS,MAAMD,YAAY,OAAO,CAACT;wBAEzC,MAAM,EAAEE,QAAQ,EAAEC,MAAM,EAAE,GAAGO,OAAO,KAAK;wBAEzC,OAAO;4BACH,MAAMT,iBAAiBC,UAAUC;4BACjC,OAAO;wBACX;oBACJ,EAAE,OAAOQ,IAAI;wBACT,OAAO,IAAIC,cAAcD;oBAC7B;gBACJ;QACJ;QAEAJ,QAAQ,WAAW,CAA8B;YAC7C,MAAM;YACN,cAAc;gBAACM;aAAoB;YACnC,UACI,CAACC,eACD,OAAO,EAAEC,IAAI,EAAE;oBACX,IAAI;wBACA,MAAML,SAAS,MAAMI,aAAa,OAAO,CAACC,KAAK,IAAI;wBAEnD,IAAIL,OAAO,MAAM,IACb,OAAO,IAAIE,cAAcF,OAAO,KAAK;wBAGzC,OAAO;4BACH,MAAMT,iBAAiBS,OAAO,KAAK,EAAE;4BACrC,OAAO;wBACX;oBACJ,EAAE,OAAOC,IAAI;wBACT,OAAO,IAAIC,cAAcD;oBAC7B;gBACJ;QACR;QAEA,OAAOJ;IACX;;aAxGO,YAAY,GAAGS,gBAAgB;;AAyG1C;AAEO,MAAMC,sBAAsBC,qBAAqB,oBAAoB,CAAC;IACzE,gBAAgBZ;IAChB,cAAc,EAAE;AACpB"}
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
+
export { MailerFeature } from "./MailerFeature.js";
|
|
1
2
|
export { MailerService } from "./domain/MailerService/abstractions.js";
|
|
2
3
|
export type { IMailerService, IMailerServiceErrors } from "./domain/MailerService/abstractions.js";
|
|
3
|
-
export declare const createMailerContext: () => import("@webiny/api").ContextPlugin<import("@webiny/api/types.js").Context>;
|
|
4
|
-
export declare const createMailerGraphQL: () => import("@webiny/handler-graphql/index.js").GraphQLSchemaPlugin<import("@webiny/api/types.js").Context>;
|
package/index.js
CHANGED
|
@@ -1,27 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { CodeMailerSettingsFeature } from "./features/CodeMailerSettings/feature.js";
|
|
3
|
-
import { GetSettingsFeature } from "./features/GetSettings/feature.js";
|
|
4
|
-
import { SaveSettingsFeature } from "./features/SaveSettings/feature.js";
|
|
5
|
-
import { DummyTransportFeature } from "./features/DummyTransport/feature.js";
|
|
6
|
-
import { SmtpTransportFeature } from "./features/SmtpTransport/feature.js";
|
|
7
|
-
import { MailerServiceFeature } from "./features/MailerService/feature.js";
|
|
8
|
-
import { SendMailFeature } from "./features/SendMail/feature.js";
|
|
9
|
-
import { createSettingsGraphQL } from "./graphql/settings.js";
|
|
1
|
+
export { MailerFeature } from "./MailerFeature.js";
|
|
10
2
|
export { MailerService } from "./domain/MailerService/abstractions.js";
|
|
11
|
-
export const createMailerContext = () => {
|
|
12
|
-
return createContextPlugin(context => {
|
|
13
|
-
// Register all features.
|
|
14
|
-
CodeMailerSettingsFeature.register(context.container);
|
|
15
|
-
DummyTransportFeature.register(context.container);
|
|
16
|
-
SmtpTransportFeature.register(context.container);
|
|
17
|
-
GetSettingsFeature.register(context.container);
|
|
18
|
-
SaveSettingsFeature.register(context.container);
|
|
19
|
-
MailerServiceFeature.register(context.container);
|
|
20
|
-
SendMailFeature.register(context.container);
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
export const createMailerGraphQL = () => {
|
|
24
|
-
return createSettingsGraphQL();
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-mailer",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.eb81deee7e",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -18,33 +18,32 @@
|
|
|
18
18
|
"description": "The API to send e-mails.",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@webiny/api": "0.0.0-unstable.
|
|
22
|
-
"@webiny/
|
|
23
|
-
"@webiny/
|
|
24
|
-
"@webiny/handler-graphql": "0.0.0-unstable.e6f0dc8ca7",
|
|
25
|
-
"@webiny/plugins": "0.0.0-unstable.e6f0dc8ca7",
|
|
21
|
+
"@webiny/api-graphql": "0.0.0-unstable.eb81deee7e",
|
|
22
|
+
"@webiny/feature": "0.0.0-unstable.eb81deee7e",
|
|
23
|
+
"@webiny/plugins": "0.0.0-unstable.eb81deee7e",
|
|
26
24
|
"email-addresses": "5.0.0",
|
|
27
|
-
"nodemailer": "
|
|
25
|
+
"nodemailer": "9.0.5",
|
|
28
26
|
"zod": "4.4.3"
|
|
29
27
|
},
|
|
30
28
|
"devDependencies": {
|
|
31
|
-
"@types/nodemailer": "8.0.
|
|
32
|
-
"@webiny/api
|
|
33
|
-
"@webiny/
|
|
34
|
-
"@webiny/
|
|
35
|
-
"@webiny/
|
|
36
|
-
"@webiny/
|
|
37
|
-
"@webiny/handler-
|
|
38
|
-
"@webiny/
|
|
39
|
-
"graphql": "16.14.
|
|
40
|
-
"jest-dynalite": "3.6.1",
|
|
29
|
+
"@types/nodemailer": "8.0.1",
|
|
30
|
+
"@webiny/api": "0.0.0-unstable.eb81deee7e",
|
|
31
|
+
"@webiny/api-core": "0.0.0-unstable.eb81deee7e",
|
|
32
|
+
"@webiny/build-tools": "0.0.0-unstable.eb81deee7e",
|
|
33
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.eb81deee7e",
|
|
34
|
+
"@webiny/di": "1.1.0",
|
|
35
|
+
"@webiny/event-handler-core": "0.0.0-unstable.eb81deee7e",
|
|
36
|
+
"@webiny/handler": "0.0.0-unstable.eb81deee7e",
|
|
37
|
+
"graphql": "16.14.2",
|
|
41
38
|
"rimraf": "6.1.3",
|
|
42
|
-
"typescript": "
|
|
43
|
-
"vitest": "4.1.
|
|
39
|
+
"typescript": "7.0.2",
|
|
40
|
+
"vitest": "4.1.11"
|
|
44
41
|
},
|
|
45
42
|
"publishConfig": {
|
|
46
|
-
"access": "public"
|
|
47
|
-
"directory": "dist"
|
|
43
|
+
"access": "public"
|
|
48
44
|
},
|
|
49
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "8476da73b653c89cc1474d968baf55c1b0ae0e5f",
|
|
46
|
+
"webiny": {
|
|
47
|
+
"publishFrom": "dist"
|
|
48
|
+
}
|
|
50
49
|
}
|
package/types.d.ts
CHANGED
package/types.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* RFC 5322 mailbox validator. Accepts both addr-spec ("addr@domain") and
|
|
5
|
-
* name-addr ("Display Name <addr@domain>") forms — both are valid SMTP
|
|
6
|
-
* From / Reply-To inputs that nodemailer and most providers accept.
|
|
7
|
-
*/
|
|
8
|
-
export const isMailboxAddress = value => {
|
|
9
|
-
return emailAddresses.parseOneAddress(value) !== null;
|
|
10
|
-
};
|
|
1
|
+
import email_addresses from "email-addresses";
|
|
2
|
+
const isMailboxAddress = (value)=>null !== email_addresses.parseOneAddress(value);
|
|
3
|
+
export { isMailboxAddress };
|
|
11
4
|
|
|
12
5
|
//# sourceMappingURL=isMailboxAddress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/isMailboxAddress.js","sources":["../../src/utils/isMailboxAddress.ts"],"sourcesContent":["import emailAddresses from \"email-addresses\";\n\n/**\n * RFC 5322 mailbox validator. Accepts both addr-spec (\"addr@domain\") and\n * name-addr (\"Display Name <addr@domain>\") forms — both are valid SMTP\n * From / Reply-To inputs that nodemailer and most providers accept.\n */\nexport const isMailboxAddress = (value: string): boolean => {\n return emailAddresses.parseOneAddress(value) !== null;\n};\n"],"names":["isMailboxAddress","value","emailAddresses"],"mappings":";AAOO,MAAMA,mBAAmB,CAACC,QACtBC,AAA0C,SAA1CA,gBAAAA,eAA8B,CAACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["SendMailUseCase","MailSendErrorEventHandler","MailBeforeSendEventHandler","MailAfterSendEventHandler","GetSettingsUseCase","GetSettingsRepository","SaveSettingsUseCase","SaveSettingsRepository","MailerSettingsAfterSaveEventHandler","MailerSettingsBeforeSaveEventHandler","MailerService"],"sources":["mailer.ts"],"sourcesContent":["export {\n SendMailUseCase,\n MailSendErrorEventHandler,\n MailBeforeSendEventHandler,\n MailAfterSendEventHandler\n} from \"~/features/SendMail/index.js\";\nexport { GetSettingsUseCase, GetSettingsRepository } from \"~/features/GetSettings/index.js\";\nexport {\n SaveSettingsUseCase,\n SaveSettingsRepository,\n MailerSettingsAfterSaveEventHandler,\n MailerSettingsBeforeSaveEventHandler\n} from \"~/features/SaveSettings/index.js\";\nexport { MailerService } from \"~/domain/MailerService/abstractions.js\";\n"],"mappings":"AAAA,SACIA,eAAe,EACfC,yBAAyB,EACzBC,0BAA0B,EAC1BC,yBAAyB;AAE7B,SAASC,kBAAkB,EAAEC,qBAAqB;AAClD,SACIC,mBAAmB,EACnBC,sBAAsB,EACtBC,mCAAmC,EACnCC,oCAAoC;AAExC,SAASC,aAAa","ignoreList":[]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BuildParams } from "@webiny/api-core/features/buildParams/index.js";
|
|
2
|
-
import { CodeMailerSettings as Abstraction } from "../../domain/CodeMailerSettings/abstractions.js";
|
|
3
|
-
const SMTP_TRANSPORT_NAME = "Mailer/SmtpTransport";
|
|
4
|
-
const SMTP_BUILD_PARAM_KEY = "Mailer.SmtpSettings";
|
|
5
|
-
class CodeMailerSettingsImpl {
|
|
6
|
-
constructor(buildParams) {
|
|
7
|
-
this.buildParams = buildParams;
|
|
8
|
-
}
|
|
9
|
-
get(transportName) {
|
|
10
|
-
if (transportName !== SMTP_TRANSPORT_NAME) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
const value = this.buildParams.get(SMTP_BUILD_PARAM_KEY);
|
|
14
|
-
return value ?? null;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export const CodeMailerSettings = Abstraction.createImplementation({
|
|
18
|
-
implementation: CodeMailerSettingsImpl,
|
|
19
|
-
dependencies: [BuildParams]
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
//# sourceMappingURL=CodeMailerSettingsImpl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["BuildParams","CodeMailerSettings","Abstraction","SMTP_TRANSPORT_NAME","SMTP_BUILD_PARAM_KEY","CodeMailerSettingsImpl","constructor","buildParams","get","transportName","value","createImplementation","implementation","dependencies"],"sources":["CodeMailerSettingsImpl.ts"],"sourcesContent":["import { BuildParams } from \"@webiny/api-core/features/buildParams/index.js\";\nimport { CodeMailerSettings as Abstraction } from \"~/domain/CodeMailerSettings/abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\n\nconst SMTP_TRANSPORT_NAME = \"Mailer/SmtpTransport\";\nconst SMTP_BUILD_PARAM_KEY = \"Mailer.SmtpSettings\";\n\nclass CodeMailerSettingsImpl implements Abstraction.Interface {\n constructor(private buildParams: BuildParams.Interface) {}\n\n get(transportName: string): TransportSettings | null {\n if (transportName !== SMTP_TRANSPORT_NAME) {\n return null;\n }\n const value = this.buildParams.get<TransportSettings>(SMTP_BUILD_PARAM_KEY);\n return value ?? null;\n }\n}\n\nexport const CodeMailerSettings = Abstraction.createImplementation({\n implementation: CodeMailerSettingsImpl,\n dependencies: [BuildParams]\n});\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,gDAAgD;AAC5E,SAASC,kBAAkB,IAAIC,WAAW;AAG1C,MAAMC,mBAAmB,GAAG,sBAAsB;AAClD,MAAMC,oBAAoB,GAAG,qBAAqB;AAElD,MAAMC,sBAAsB,CAAkC;EAC1DC,WAAWA,CAASC,WAAkC,EAAE;IAAA,KAApCA,WAAkC,GAAlCA,WAAkC;EAAG;EAEzDC,GAAGA,CAACC,aAAqB,EAA4B;IACjD,IAAIA,aAAa,KAAKN,mBAAmB,EAAE;MACvC,OAAO,IAAI;IACf;IACA,MAAMO,KAAK,GAAG,IAAI,CAACH,WAAW,CAACC,GAAG,CAAoBJ,oBAAoB,CAAC;IAC3E,OAAOM,KAAK,IAAI,IAAI;EACxB;AACJ;AAEA,OAAO,MAAMT,kBAAkB,GAAGC,WAAW,CAACS,oBAAoB,CAAC;EAC/DC,cAAc,EAAEP,sBAAsB;EACtCQ,YAAY,EAAE,CAACb,WAAW;AAC9B,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["GetSettingsUseCase","GetSettingsRepository"],"sources":["index.ts"],"sourcesContent":["export { GetSettingsUseCase, GetSettingsRepository } from \"./abstractions.js\";\n"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,qBAAqB","ignoreList":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ActiveTransport as ActiveTransportAbstraction, MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
|
|
2
|
-
declare class ActiveTransportImpl implements ActiveTransportAbstraction.Interface {
|
|
3
|
-
private transportFactories;
|
|
4
|
-
constructor(transportFactories: MailTransportFactory.Interface[]);
|
|
5
|
-
name(): string | null;
|
|
6
|
-
}
|
|
7
|
-
export declare const ActiveTransport: typeof ActiveTransportImpl & {
|
|
8
|
-
__abstraction: import("@webiny/di").Abstraction<import("~/domain/MailTransport/abstractions.js").IActiveTransport>;
|
|
9
|
-
};
|
|
10
|
-
export {};
|