@webiny/api-mailer 6.6.0-alpha.12 → 6.6.0-alpha.13
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.js +4 -8
- package/MailerFeature.js.map +1 -1
- package/constants.d.ts +0 -2
- package/constants.js +1 -3
- package/constants.js.map +1 -1
- package/domain/TransportSettings/abstractions.d.ts +47 -0
- package/domain/TransportSettings/abstractions.js +5 -0
- package/domain/TransportSettings/abstractions.js.map +1 -0
- package/domain/TransportSettings/findDefinition.d.ts +6 -0
- package/domain/TransportSettings/findDefinition.js +13 -0
- package/domain/TransportSettings/findDefinition.js.map +1 -0
- package/domain/errors.d.ts +15 -9
- package/domain/errors.js +27 -17
- package/domain/errors.js.map +1 -1
- package/exports/api/mailer.d.ts +3 -2
- package/exports/api/mailer.js +3 -2
- package/features/GetSettings/GetSettingsRepository.d.ts +5 -4
- package/features/GetSettings/GetSettingsRepository.js +23 -27
- package/features/GetSettings/GetSettingsRepository.js.map +1 -1
- package/features/GetSettings/GetSettingsUseCase.d.ts +11 -3
- package/features/GetSettings/GetSettingsUseCase.js +29 -4
- package/features/GetSettings/GetSettingsUseCase.js.map +1 -1
- package/features/GetSettings/abstractions.d.ts +14 -6
- package/features/GetSettings/abstractions.js.map +1 -1
- package/features/GetSettings/feature.js +1 -1
- package/features/GetSettings/feature.js.map +1 -1
- package/features/GetSettings/index.d.ts +1 -0
- package/features/SaveSettings/SaveSettingsRepository.d.ts +3 -2
- package/features/SaveSettings/SaveSettingsRepository.js +44 -22
- package/features/SaveSettings/SaveSettingsRepository.js.map +1 -1
- package/features/SaveSettings/SaveSettingsUseCase.d.ts +5 -7
- package/features/SaveSettings/SaveSettingsUseCase.js +25 -24
- package/features/SaveSettings/SaveSettingsUseCase.js.map +1 -1
- package/features/SaveSettings/abstractions.d.ts +12 -20
- package/features/SaveSettings/abstractions.js.map +1 -1
- package/features/SaveSettings/feature.js +1 -1
- package/features/SaveSettings/feature.js.map +1 -1
- package/features/SaveSettings/index.d.ts +1 -0
- package/graphql/MailerSchemaFactory.js +31 -44
- package/graphql/MailerSchemaFactory.js.map +1 -1
- package/index.d.ts +10 -0
- package/index.js +7 -0
- package/package.json +13 -15
- package/types.d.ts +0 -9
- package/domain/CodeMailerSettings/abstractions.d.ts +0 -8
- package/domain/CodeMailerSettings/abstractions.js +0 -5
- package/domain/CodeMailerSettings/abstractions.js.map +0 -1
- package/features/CodeMailerSettings/CodeMailerSettings.d.ts +0 -12
- package/features/CodeMailerSettings/CodeMailerSettings.js +0 -23
- package/features/CodeMailerSettings/CodeMailerSettings.js.map +0 -1
- package/features/CodeMailerSettings/feature.d.ts +0 -4
- package/features/CodeMailerSettings/feature.js +0 -11
- package/features/CodeMailerSettings/feature.js.map +0 -1
- package/features/SaveSettings/validation.d.ts +0 -10
- package/features/SaveSettings/validation.js +0 -21
- package/features/SaveSettings/validation.js.map +0 -1
- package/features/SmtpTransport/SmtpConfig.d.ts +0 -6
- package/features/SmtpTransport/SmtpConfig.js +0 -26
- package/features/SmtpTransport/SmtpConfig.js.map +0 -1
- package/features/SmtpTransport/SmtpMailTransport.d.ts +0 -78
- package/features/SmtpTransport/SmtpMailTransport.js +0 -61
- package/features/SmtpTransport/SmtpMailTransport.js.map +0 -1
- package/features/SmtpTransport/SmtpMailTransportFactory.d.ts +0 -12
- package/features/SmtpTransport/SmtpMailTransportFactory.js +0 -26
- package/features/SmtpTransport/SmtpMailTransportFactory.js.map +0 -1
- package/features/SmtpTransport/feature.d.ts +0 -4
- package/features/SmtpTransport/feature.js +0 -11
- package/features/SmtpTransport/feature.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-mailer",
|
|
3
|
-
"version": "6.6.0-alpha.
|
|
3
|
+
"version": "6.6.0-alpha.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -18,26 +18,24 @@
|
|
|
18
18
|
"description": "The API to send e-mails.",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@webiny/api-graphql": "6.6.0-alpha.
|
|
22
|
-
"@webiny/feature": "6.6.0-alpha.
|
|
23
|
-
"@webiny/plugins": "6.6.0-alpha.
|
|
21
|
+
"@webiny/api-graphql": "6.6.0-alpha.13",
|
|
22
|
+
"@webiny/feature": "6.6.0-alpha.13",
|
|
23
|
+
"@webiny/plugins": "6.6.0-alpha.13",
|
|
24
24
|
"email-addresses": "5.0.0",
|
|
25
|
-
"nodemailer": "10.3.1",
|
|
26
25
|
"zod": "4.6.7"
|
|
27
26
|
},
|
|
28
27
|
"devDependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@webiny/api": "6.6.0-alpha.
|
|
31
|
-
"@webiny/api-core": "6.6.0-alpha.
|
|
32
|
-
"@webiny/build-tools": "6.6.0-alpha.
|
|
33
|
-
"@webiny/db-dynamodb": "6.6.0-alpha.
|
|
28
|
+
"@webiny/api": "6.6.0-alpha.13",
|
|
29
|
+
"@webiny/api-core": "6.6.0-alpha.13",
|
|
30
|
+
"@webiny/api-kernel-core": "6.6.0-alpha.13",
|
|
31
|
+
"@webiny/build-tools": "6.6.0-alpha.13",
|
|
32
|
+
"@webiny/db-dynamodb": "6.6.0-alpha.13",
|
|
34
33
|
"@webiny/di": "2.0.0",
|
|
35
|
-
"@webiny/
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"rimraf": "6.1.3",
|
|
34
|
+
"@webiny/handler": "6.6.0-alpha.13",
|
|
35
|
+
"graphql": "16.15.0",
|
|
36
|
+
"rimraf": "6.1.4",
|
|
39
37
|
"typescript": "7.0.2",
|
|
40
|
-
"vitest": "5.
|
|
38
|
+
"vitest": "5.1.1"
|
|
41
39
|
},
|
|
42
40
|
"publishConfig": {
|
|
43
41
|
"access": "public"
|
package/types.d.ts
CHANGED
|
@@ -31,13 +31,4 @@ interface BaseTransportSendData {
|
|
|
31
31
|
replyTo?: string;
|
|
32
32
|
}
|
|
33
33
|
export type TransportSendData = BaseTransportSendData & (TransportSendToData | TransportSendBccData | TransportSendCcData);
|
|
34
|
-
export interface TransportSettings {
|
|
35
|
-
host: string;
|
|
36
|
-
port: number;
|
|
37
|
-
secure: boolean;
|
|
38
|
-
user: string;
|
|
39
|
-
password: string;
|
|
40
|
-
from: string;
|
|
41
|
-
replyTo?: string;
|
|
42
|
-
}
|
|
43
34
|
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { TransportSettings } from "../../types.js";
|
|
2
|
-
export interface ICodeMailerSettings {
|
|
3
|
-
get(transportName: string): TransportSettings | null;
|
|
4
|
-
}
|
|
5
|
-
export declare const CodeMailerSettings: import("@webiny/di").Abstraction<ICodeMailerSettings>;
|
|
6
|
-
export declare namespace CodeMailerSettings {
|
|
7
|
-
type Interface = ICodeMailerSettings;
|
|
8
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"domain/CodeMailerSettings/abstractions.js","sources":["../../../src/domain/CodeMailerSettings/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { TransportSettings } from \"~/types.js\";\n\nexport interface ICodeMailerSettings {\n get(transportName: string): TransportSettings | null;\n}\n\nexport const CodeMailerSettings = createAbstraction<ICodeMailerSettings>(\"CodeMailerSettings\");\n\nexport namespace CodeMailerSettings {\n export type Interface = ICodeMailerSettings;\n}\n"],"names":["CodeMailerSettings","createAbstraction"],"mappings":";AAOO,MAAMA,qBAAqBC,kBAAuC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BuildParams } from "@webiny/api-core/features/buildParams/index.js";
|
|
2
|
-
import { CodeMailerSettings as Abstraction } from "../../domain/CodeMailerSettings/abstractions.js";
|
|
3
|
-
import type { TransportSettings } from "../../types.js";
|
|
4
|
-
declare class CodeMailerSettingsImpl implements Abstraction.Interface {
|
|
5
|
-
private buildParams;
|
|
6
|
-
constructor(buildParams: BuildParams.Interface);
|
|
7
|
-
get(transportName: string): TransportSettings | null;
|
|
8
|
-
}
|
|
9
|
-
export declare const CodeMailerSettings: typeof CodeMailerSettingsImpl & {
|
|
10
|
-
__abstraction: import("@webiny/di").Abstraction<import("~/domain/CodeMailerSettings/abstractions.js").ICodeMailerSettings>;
|
|
11
|
-
};
|
|
12
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { BuildParams } from "@webiny/api-core/features/buildParams/index.js";
|
|
2
|
-
import { CodeMailerSettings } from "../../domain/CodeMailerSettings/abstractions.js";
|
|
3
|
-
import { SMTP_TRANSPORT_NAME } from "../../constants.js";
|
|
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) return null;
|
|
11
|
-
const value = this.buildParams.get(SMTP_BUILD_PARAM_KEY);
|
|
12
|
-
return value ?? null;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
const CodeMailerSettings_CodeMailerSettings = CodeMailerSettings.createImplementation({
|
|
16
|
-
implementation: CodeMailerSettingsImpl,
|
|
17
|
-
dependencies: [
|
|
18
|
-
BuildParams
|
|
19
|
-
]
|
|
20
|
-
});
|
|
21
|
-
export { CodeMailerSettings_CodeMailerSettings as CodeMailerSettings };
|
|
22
|
-
|
|
23
|
-
//# sourceMappingURL=CodeMailerSettings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"features/CodeMailerSettings/CodeMailerSettings.js","sources":["../../../src/features/CodeMailerSettings/CodeMailerSettings.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\";\nimport { SMTP_TRANSPORT_NAME } from \"~/constants.js\";\n\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"],"names":["SMTP_BUILD_PARAM_KEY","CodeMailerSettingsImpl","buildParams","transportName","SMTP_TRANSPORT_NAME","value","CodeMailerSettings","Abstraction","BuildParams"],"mappings":";;;AAKA,MAAMA,uBAAuB;AAE7B,MAAMC;IACF,YAAoBC,WAAkC,CAAE;aAApCA,WAAW,GAAXA;IAAqC;IAEzD,IAAIC,aAAqB,EAA4B;QACjD,IAAIA,kBAAkBC,qBAClB,OAAO;QAEX,MAAMC,QAAQ,IAAI,CAAC,WAAW,CAAC,GAAG,CAAoBL;QACtD,OAAOK,SAAS;IACpB;AACJ;AAEO,MAAMC,wCAAqBC,mBAAAA,oBAAgC,CAAC;IAC/D,gBAAgBN;IAChB,cAAc;QAACO;KAAY;AAC/B"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createFeature } from "@webiny/feature/api";
|
|
2
|
-
import { CodeMailerSettings } from "./CodeMailerSettings.js";
|
|
3
|
-
const CodeMailerSettingsFeature = createFeature({
|
|
4
|
-
name: "Mailer/CodeMailerSettings",
|
|
5
|
-
register (container) {
|
|
6
|
-
container.register(CodeMailerSettings).inSingletonScope();
|
|
7
|
-
}
|
|
8
|
-
});
|
|
9
|
-
export { CodeMailerSettingsFeature };
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"features/CodeMailerSettings/feature.js","sources":["../../../src/features/CodeMailerSettings/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { CodeMailerSettings } from \"./CodeMailerSettings.js\";\n\nexport const CodeMailerSettingsFeature = createFeature({\n name: \"Mailer/CodeMailerSettings\",\n register(container) {\n container.register(CodeMailerSettings).inSingletonScope();\n }\n});\n"],"names":["CodeMailerSettingsFeature","createFeature","container","CodeMailerSettings"],"mappings":";;AAGO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,oBAAoB,gBAAgB;IAC3D;AACJ"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import zod from "zod";
|
|
2
|
-
export declare const saveValidation: zod.ZodObject<{
|
|
3
|
-
from: zod.ZodString;
|
|
4
|
-
port: zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodNumber>>>;
|
|
5
|
-
replyTo: zod.ZodPreprocess<zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodString>>>, unknown>;
|
|
6
|
-
host: zod.ZodString;
|
|
7
|
-
user: zod.ZodString;
|
|
8
|
-
secure: zod.ZodOptional<zod.ZodBoolean>;
|
|
9
|
-
password: zod.ZodPipe<zod.ZodOptional<zod.ZodOptional<zod.ZodNullable<zod.ZodString>>>, zod.ZodTransform<string | null, string | null | undefined>>;
|
|
10
|
-
}, zod.core.$strip>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import zod from "zod";
|
|
2
|
-
import { isMailboxAddress } from "../../utils/isMailboxAddress.js";
|
|
3
|
-
const validation_password = zod.string().describe("Password");
|
|
4
|
-
const mailboxAddress = zod.string().refine(isMailboxAddress, {
|
|
5
|
-
message: "Invalid email address."
|
|
6
|
-
});
|
|
7
|
-
const common = {
|
|
8
|
-
from: mailboxAddress.describe("Mail from"),
|
|
9
|
-
port: zod.number().optional().nullish().describe("Port"),
|
|
10
|
-
replyTo: zod.preprocess((value)=>"" === value ? null : value, mailboxAddress.optional().nullish()).describe("Mail reply-to"),
|
|
11
|
-
host: zod.string().describe("Hostname"),
|
|
12
|
-
user: zod.string().describe("User")
|
|
13
|
-
};
|
|
14
|
-
const saveValidation = zod.object({
|
|
15
|
-
...common,
|
|
16
|
-
secure: zod.boolean().optional().describe("Use TLS/SSL"),
|
|
17
|
-
password: validation_password.nullish().optional().transform((value)=>void 0 === value ? null : value)
|
|
18
|
-
});
|
|
19
|
-
export { saveValidation };
|
|
20
|
-
|
|
21
|
-
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"features/SaveSettings/validation.js","sources":["../../../src/features/SaveSettings/validation.ts"],"sourcesContent":["import zod from \"zod\";\nimport { isMailboxAddress } from \"~/utils/isMailboxAddress.js\";\n\nconst password = zod.string().describe(\"Password\");\n\nconst mailboxAddress = zod.string().refine(isMailboxAddress, { message: \"Invalid email address.\" });\n\nconst common = {\n from: mailboxAddress.describe(\"Mail from\"),\n port: zod.number().optional().nullish().describe(\"Port\"),\n replyTo: zod\n .preprocess(\n // We need to set empty strings to `null` before address validation kicks in.\n value => (value === \"\" ? null : value),\n mailboxAddress.optional().nullish()\n )\n .describe(\"Mail reply-to\"),\n host: zod.string().describe(\"Hostname\"),\n user: zod.string().describe(\"User\")\n};\n\nexport const saveValidation = zod.object({\n ...common,\n secure: zod.boolean().optional().describe(\"Use TLS/SSL\"),\n password: password\n .nullish()\n .optional()\n .transform(value => {\n return value === undefined ? null : value;\n })\n});\n"],"names":["password","zod","mailboxAddress","isMailboxAddress","common","value","saveValidation","undefined"],"mappings":";;AAGA,MAAMA,sBAAWC,IAAI,MAAM,GAAG,QAAQ,CAAC;AAEvC,MAAMC,iBAAiBD,IAAI,MAAM,GAAG,MAAM,CAACE,kBAAkB;IAAE,SAAS;AAAyB;AAEjG,MAAMC,SAAS;IACX,MAAMF,eAAe,QAAQ,CAAC;IAC9B,MAAMD,IAAI,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;IACjD,SAASA,IAAAA,UACM,CAEPI,CAAAA,QAAUA,AAAU,OAAVA,QAAe,OAAOA,OAChCH,eAAe,QAAQ,GAAG,OAAO,IAEpC,QAAQ,CAAC;IACd,MAAMD,IAAI,MAAM,GAAG,QAAQ,CAAC;IAC5B,MAAMA,IAAI,MAAM,GAAG,QAAQ,CAAC;AAChC;AAEO,MAAMK,iBAAiBL,IAAI,MAAM,CAAC;IACrC,GAAGG,MAAM;IACT,QAAQH,IAAI,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC1C,UAAUD,oBACL,OAAO,GACP,QAAQ,GACR,SAAS,CAACK,CAAAA,QACAA,AAAUE,WAAVF,QAAsB,OAAOA;AAEhD"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { TransportSettings } from "../../types.js";
|
|
2
|
-
import type SMTPTransport from "nodemailer/lib/smtp-transport";
|
|
3
|
-
export type SmtpTransportConfig = SMTPTransport.Options;
|
|
4
|
-
export declare class SmtpConfig {
|
|
5
|
-
static fromTransportSettings(settings: TransportSettings): SmtpTransportConfig;
|
|
6
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const configDefaults = {
|
|
2
|
-
socketTimeout: 15000,
|
|
3
|
-
connectionTimeout: 15000,
|
|
4
|
-
greetingTimeout: 15000
|
|
5
|
-
};
|
|
6
|
-
class SmtpConfig {
|
|
7
|
-
static fromTransportSettings(settings) {
|
|
8
|
-
const baseConfig = {
|
|
9
|
-
host: settings.host,
|
|
10
|
-
port: settings.port,
|
|
11
|
-
secure: settings.secure,
|
|
12
|
-
auth: {
|
|
13
|
-
user: settings.user,
|
|
14
|
-
pass: settings.password
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
return Object.keys(configDefaults).reduce((config, key)=>{
|
|
18
|
-
const configKey = key;
|
|
19
|
-
if (void 0 === config[configKey] || null === config[configKey]) config[configKey] = configDefaults[configKey];
|
|
20
|
-
return config;
|
|
21
|
-
}, baseConfig);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
export { SmtpConfig };
|
|
25
|
-
|
|
26
|
-
//# sourceMappingURL=SmtpConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type SMTPTransport from "nodemailer/lib/smtp-transport";
|
|
2
|
-
import { MailTransport } from "../../domain/MailTransport/abstractions.js";
|
|
3
|
-
export declare class SmtpMailTransport implements MailTransport.Interface {
|
|
4
|
-
private readonly defaultFrom?;
|
|
5
|
-
private readonly defaultReplyTo?;
|
|
6
|
-
readonly name = "Mailer/SmtpTransport";
|
|
7
|
-
private readonly transporter;
|
|
8
|
-
constructor(config: SMTPTransport.Options, defaultFrom?: string | undefined, defaultReplyTo?: string | undefined);
|
|
9
|
-
send(params: MailTransport.SendParams): Promise<{
|
|
10
|
-
result: string;
|
|
11
|
-
error: null;
|
|
12
|
-
} | {
|
|
13
|
-
result: null;
|
|
14
|
-
error: {
|
|
15
|
-
message: string;
|
|
16
|
-
code: string;
|
|
17
|
-
data: {
|
|
18
|
-
[key: string]: any;
|
|
19
|
-
ehlo?: string[] | undefined;
|
|
20
|
-
rejectedErrors?: import("nodemailer").NodemailerError[] | undefined;
|
|
21
|
-
envelopeTime: number;
|
|
22
|
-
messageTime: number;
|
|
23
|
-
messageSize: number;
|
|
24
|
-
serverMessageId?: string | undefined;
|
|
25
|
-
envelope: import("nodemailer/lib/mime-node").MimeNodeEnvelope;
|
|
26
|
-
messageId: string;
|
|
27
|
-
accepted: string[];
|
|
28
|
-
rejected: string[];
|
|
29
|
-
response: string;
|
|
30
|
-
pending?: string[] | undefined;
|
|
31
|
-
message?: any;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
} | {
|
|
35
|
-
result: null;
|
|
36
|
-
error: {
|
|
37
|
-
message: string;
|
|
38
|
-
code: any;
|
|
39
|
-
data: {
|
|
40
|
-
to?: string[];
|
|
41
|
-
cc?: string[];
|
|
42
|
-
bcc: string[];
|
|
43
|
-
from?: string;
|
|
44
|
-
subject: string;
|
|
45
|
-
text?: string;
|
|
46
|
-
html?: string;
|
|
47
|
-
replyTo?: string;
|
|
48
|
-
command: any;
|
|
49
|
-
response: any;
|
|
50
|
-
responseCode: any;
|
|
51
|
-
} | {
|
|
52
|
-
to?: string[];
|
|
53
|
-
cc: string[];
|
|
54
|
-
bcc?: string[];
|
|
55
|
-
from?: string;
|
|
56
|
-
subject: string;
|
|
57
|
-
text?: string;
|
|
58
|
-
html?: string;
|
|
59
|
-
replyTo?: string;
|
|
60
|
-
command: any;
|
|
61
|
-
response: any;
|
|
62
|
-
responseCode: any;
|
|
63
|
-
} | {
|
|
64
|
-
to: string[];
|
|
65
|
-
cc?: string[];
|
|
66
|
-
bcc?: string[];
|
|
67
|
-
from?: string;
|
|
68
|
-
subject: string;
|
|
69
|
-
text?: string;
|
|
70
|
-
html?: string;
|
|
71
|
-
replyTo?: string;
|
|
72
|
-
command: any;
|
|
73
|
-
response: any;
|
|
74
|
-
responseCode: any;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
}>;
|
|
78
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import nodemailer from "nodemailer";
|
|
2
|
-
import { SMTP_TRANSPORT_NAME } from "../../constants.js";
|
|
3
|
-
const getErrorMessage = (ex)=>{
|
|
4
|
-
if (ex.message) return ex.message;
|
|
5
|
-
if (Array.isArray(ex.errors)) return ex.errors.map((error)=>error.message).filter(Boolean).join("; ");
|
|
6
|
-
return "";
|
|
7
|
-
};
|
|
8
|
-
class SmtpMailTransport {
|
|
9
|
-
constructor(config, defaultFrom, defaultReplyTo){
|
|
10
|
-
this.defaultFrom = defaultFrom;
|
|
11
|
-
this.defaultReplyTo = defaultReplyTo;
|
|
12
|
-
this.name = SMTP_TRANSPORT_NAME;
|
|
13
|
-
this.transporter = nodemailer.createTransport(config);
|
|
14
|
-
}
|
|
15
|
-
async send(params) {
|
|
16
|
-
const { replyTo, text, html, to, bcc, cc, from, subject } = params;
|
|
17
|
-
try {
|
|
18
|
-
const result = await this.transporter.sendMail({
|
|
19
|
-
replyTo: replyTo || this.defaultReplyTo || void 0,
|
|
20
|
-
bcc,
|
|
21
|
-
cc,
|
|
22
|
-
from: from || this.defaultFrom || void 0,
|
|
23
|
-
text,
|
|
24
|
-
html,
|
|
25
|
-
to,
|
|
26
|
-
subject
|
|
27
|
-
});
|
|
28
|
-
if (result.messageId) return {
|
|
29
|
-
result: result.response,
|
|
30
|
-
error: null
|
|
31
|
-
};
|
|
32
|
-
return {
|
|
33
|
-
result: null,
|
|
34
|
-
error: {
|
|
35
|
-
message: "nodemailer.sendMail does not have a messageId in the result. Something went wrong...",
|
|
36
|
-
code: "MAILER_ERROR",
|
|
37
|
-
data: {
|
|
38
|
-
...result
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
} catch (ex) {
|
|
43
|
-
return {
|
|
44
|
-
result: null,
|
|
45
|
-
error: {
|
|
46
|
-
message: getErrorMessage(ex),
|
|
47
|
-
code: ex.code,
|
|
48
|
-
data: {
|
|
49
|
-
...params,
|
|
50
|
-
command: ex.command,
|
|
51
|
-
response: ex.response,
|
|
52
|
-
responseCode: ex.responseCode
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
export { SmtpMailTransport };
|
|
60
|
-
|
|
61
|
-
//# sourceMappingURL=SmtpMailTransport.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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\";\nimport { SMTP_TRANSPORT_NAME } from \"~/constants.js\";\n\n/*\n * A host with both IPv4 and IPv6 addresses (`localhost`, most mail providers) fails to connect\n * with an AggregateError: one error per address and an empty message of its own.\n */\nconst getErrorMessage = (ex: any): string => {\n if (ex.message) {\n return ex.message;\n }\n if (Array.isArray(ex.errors)) {\n return ex.errors\n .map((error: Error) => error.message)\n .filter(Boolean)\n .join(\"; \");\n }\n return \"\";\n};\n\nexport class SmtpMailTransport implements MailTransport.Interface {\n public readonly name = SMTP_TRANSPORT_NAME;\n private readonly transporter: Transporter<SMTPTransport.SentMessageInfo>;\n\n constructor(\n config: SMTPTransport.Options,\n private readonly defaultFrom?: string,\n private readonly defaultReplyTo?: string\n ) {\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: replyTo || this.defaultReplyTo || undefined,\n bcc,\n cc,\n // An explicit sender wins; otherwise the configured settings sender (R201).\n // An empty default counts as none, so a missing settings `from` changes nothing.\n from: from || this.defaultFrom || undefined,\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: getErrorMessage(ex),\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":["getErrorMessage","ex","Array","error","Boolean","SmtpMailTransport","config","defaultFrom","defaultReplyTo","SMTP_TRANSPORT_NAME","nodemailer","params","replyTo","text","html","to","bcc","cc","from","subject","result","undefined"],"mappings":";;AAUA,MAAMA,kBAAkB,CAACC;IACrB,IAAIA,GAAG,OAAO,EACV,OAAOA,GAAG,OAAO;IAErB,IAAIC,MAAM,OAAO,CAACD,GAAG,MAAM,GACvB,OAAOA,GAAG,MAAM,CACX,GAAG,CAAC,CAACE,QAAiBA,MAAM,OAAO,EACnC,MAAM,CAACC,SACP,IAAI,CAAC;IAEd,OAAO;AACX;AAEO,MAAMC;IAIT,YACIC,MAA6B,EACZC,WAAoB,EACpBC,cAAuB,CAC1C;aAFmBD,WAAW,GAAXA;aACAC,cAAc,GAAdA;aANL,IAAI,GAAGC;QAQnB,IAAI,CAAC,WAAW,GAAGC,WAAW,eAAe,CAACJ;IAClD;IAEA,MAAM,KAAKK,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;gBAC3C,SAASR,WAAW,IAAI,CAAC,cAAc,IAAIS;gBAC3CL;gBACAC;gBAGA,MAAMC,QAAQ,IAAI,CAAC,WAAW,IAAIG;gBAClCR;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,OAAOnB,IAAS;YAKd,OAAO;gBACH,QAAQ;gBACR,OAAO;oBACH,SAASD,gBAAgBC;oBACzB,MAAMA,GAAG,IAAI;oBACb,MAAM;wBACF,GAAGU,MAAM;wBACT,SAASV,GAAG,OAAO;wBACnB,UAAUA,GAAG,QAAQ;wBACrB,cAAcA,GAAG,YAAY;oBACjC;gBACJ;YACJ;QACJ;IACJ;AACJ"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
|
|
2
|
-
import { GetSettingsRepository } from "../../features/GetSettings/abstractions.js";
|
|
3
|
-
declare class SmtpMailTransportFactoryImpl implements MailTransportFactory.Interface {
|
|
4
|
-
private getSettingsRepository;
|
|
5
|
-
readonly name = "Mailer/SmtpTransport";
|
|
6
|
-
constructor(getSettingsRepository: GetSettingsRepository.Interface);
|
|
7
|
-
createTransport(): MailTransportFactory.Return;
|
|
8
|
-
}
|
|
9
|
-
export declare const SmtpMailTransportFactory: typeof SmtpMailTransportFactoryImpl & {
|
|
10
|
-
__abstraction: import("@webiny/di").Abstraction<import("~/domain/MailTransport/abstractions.js").IMailTransportFactory>;
|
|
11
|
-
};
|
|
12
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
|
|
2
|
-
import { GetSettingsRepository } from "../GetSettings/abstractions.js";
|
|
3
|
-
import { SmtpMailTransport } from "./SmtpMailTransport.js";
|
|
4
|
-
import { SmtpConfig } from "./SmtpConfig.js";
|
|
5
|
-
import { SMTP_TRANSPORT_NAME } from "../../constants.js";
|
|
6
|
-
class SmtpMailTransportFactoryImpl {
|
|
7
|
-
constructor(getSettingsRepository){
|
|
8
|
-
this.getSettingsRepository = getSettingsRepository;
|
|
9
|
-
this.name = SMTP_TRANSPORT_NAME;
|
|
10
|
-
}
|
|
11
|
-
async createTransport() {
|
|
12
|
-
const result = await this.getSettingsRepository.get(this.name);
|
|
13
|
-
const { settings } = result.value;
|
|
14
|
-
if (!settings) return null;
|
|
15
|
-
return new SmtpMailTransport(SmtpConfig.fromTransportSettings(settings), settings.from, settings.replyTo);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
const SmtpMailTransportFactory = MailTransportFactory.createImplementation({
|
|
19
|
-
implementation: SmtpMailTransportFactoryImpl,
|
|
20
|
-
dependencies: [
|
|
21
|
-
GetSettingsRepository
|
|
22
|
-
]
|
|
23
|
-
});
|
|
24
|
-
export { SmtpMailTransportFactory };
|
|
25
|
-
|
|
26
|
-
//# sourceMappingURL=SmtpMailTransportFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"features/SmtpTransport/SmtpMailTransportFactory.js","sources":["../../../src/features/SmtpTransport/SmtpMailTransportFactory.ts"],"sourcesContent":["import { MailTransportFactory } from \"~/domain/MailTransport/abstractions.js\";\nimport { GetSettingsRepository } from \"~/features/GetSettings/abstractions.js\";\nimport { SmtpMailTransport } from \"~/features/SmtpTransport/SmtpMailTransport.js\";\nimport { SmtpConfig } from \"~/features/SmtpTransport/SmtpConfig.js\";\nimport { SMTP_TRANSPORT_NAME } from \"~/constants.js\";\n\nclass SmtpMailTransportFactoryImpl implements MailTransportFactory.Interface {\n public readonly name = SMTP_TRANSPORT_NAME;\n\n constructor(private getSettingsRepository: GetSettingsRepository.Interface) {}\n\n // The settings come from code when `Api.Mailer.Smtp` sets them, otherwise from the settings form.\n async createTransport(): MailTransportFactory.Return {\n const result = await this.getSettingsRepository.get(this.name);\n const { settings } = result.value;\n if (!settings) {\n return null;\n }\n\n return new SmtpMailTransport(\n SmtpConfig.fromTransportSettings(settings),\n settings.from,\n settings.replyTo\n );\n }\n}\n\nexport const SmtpMailTransportFactory = MailTransportFactory.createImplementation({\n implementation: SmtpMailTransportFactoryImpl,\n dependencies: [GetSettingsRepository]\n});\n"],"names":["SmtpMailTransportFactoryImpl","getSettingsRepository","SMTP_TRANSPORT_NAME","result","settings","SmtpMailTransport","SmtpConfig","SmtpMailTransportFactory","MailTransportFactory","GetSettingsRepository"],"mappings":";;;;;AAMA,MAAMA;IAGF,YAAoBC,qBAAsD,CAAE;aAAxDA,qBAAqB,GAArBA;aAFJ,IAAI,GAAGC;IAEsD;IAG7E,MAAM,kBAA+C;QACjD,MAAMC,SAAS,MAAM,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI;QAC7D,MAAM,EAAEC,QAAQ,EAAE,GAAGD,OAAO,KAAK;QACjC,IAAI,CAACC,UACD,OAAO;QAGX,OAAO,IAAIC,kBACPC,WAAW,qBAAqB,CAACF,WACjCA,SAAS,IAAI,EACbA,SAAS,OAAO;IAExB;AACJ;AAEO,MAAMG,2BAA2BC,qBAAqB,oBAAoB,CAAC;IAC9E,gBAAgBR;IAChB,cAAc;QAACS;KAAsB;AACzC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createFeature } from "@webiny/feature/api";
|
|
2
|
-
import { SmtpMailTransportFactory } from "./SmtpMailTransportFactory.js";
|
|
3
|
-
const SmtpTransportFeature = createFeature({
|
|
4
|
-
name: "SmtpTransport",
|
|
5
|
-
register (container) {
|
|
6
|
-
container.register(SmtpMailTransportFactory).inSingletonScope();
|
|
7
|
-
}
|
|
8
|
-
});
|
|
9
|
-
export { SmtpTransportFeature };
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|