@webiny/api-mailer 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7be00a75a9
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 +10 -13
- package/constants.d.ts +1 -0
- package/constants.js +4 -0
- package/constants.js.map +1 -0
- package/domain/CodeMailerSettings/abstractions.d.ts +8 -0
- package/domain/CodeMailerSettings/abstractions.js +5 -0
- package/domain/CodeMailerSettings/abstractions.js.map +1 -0
- package/domain/MailTransport/abstractions.d.ts +26 -0
- package/domain/MailTransport/abstractions.js +7 -0
- package/domain/MailTransport/abstractions.js.map +1 -0
- package/domain/MailerService/abstractions.d.ts +19 -0
- package/domain/MailerService/abstractions.js +5 -0
- package/domain/MailerService/abstractions.js.map +1 -0
- package/domain/MailerService/errors.d.ts +16 -0
- package/domain/MailerService/errors.js +28 -0
- package/domain/MailerService/errors.js.map +1 -0
- package/domain/errors.d.ts +28 -0
- package/domain/errors.js +48 -0
- package/domain/errors.js.map +1 -0
- package/exports/api/mailer.d.ts +4 -0
- package/exports/api/mailer.js +4 -0
- package/features/CodeMailerSettings/CodeMailerSettingsImpl.d.ts +12 -0
- package/features/CodeMailerSettings/CodeMailerSettingsImpl.js +23 -0
- package/features/CodeMailerSettings/CodeMailerSettingsImpl.js.map +1 -0
- package/features/CodeMailerSettings/feature.d.ts +4 -0
- package/features/CodeMailerSettings/feature.js +11 -0
- package/features/CodeMailerSettings/feature.js.map +1 -0
- package/features/DummyTransport/DummyMailTransport.d.ts +9 -0
- package/features/DummyTransport/DummyMailTransport.js +14 -0
- package/features/DummyTransport/DummyMailTransport.js.map +1 -0
- package/features/DummyTransport/DummyMailTransportFactory.d.ts +9 -0
- package/features/DummyTransport/DummyMailTransportFactory.js +17 -0
- package/features/DummyTransport/DummyMailTransportFactory.js.map +1 -0
- package/features/DummyTransport/feature.d.ts +4 -0
- package/features/DummyTransport/feature.js +11 -0
- package/features/DummyTransport/feature.js.map +1 -0
- package/features/GetSettings/GetSettingsRepository.d.ts +16 -0
- package/features/GetSettings/GetSettingsRepository.js +54 -0
- package/features/GetSettings/GetSettingsRepository.js.map +1 -0
- package/features/GetSettings/GetSettingsUseCase.d.ts +11 -0
- package/features/GetSettings/GetSettingsUseCase.js +18 -0
- package/features/GetSettings/GetSettingsUseCase.js.map +1 -0
- package/features/GetSettings/abstractions.d.ts +22 -0
- package/features/GetSettings/abstractions.js +6 -0
- package/features/GetSettings/abstractions.js.map +1 -0
- package/features/GetSettings/feature.d.ts +4 -0
- package/features/GetSettings/feature.js +13 -0
- package/features/GetSettings/feature.js.map +1 -0
- package/features/GetSettings/index.d.ts +1 -0
- package/features/GetSettings/index.js +1 -0
- package/features/MailerService/ActiveTransport.d.ts +10 -0
- package/features/MailerService/ActiveTransport.js +24 -0
- package/features/MailerService/ActiveTransport.js.map +1 -0
- package/features/MailerService/MailerService.d.ts +16 -0
- package/features/MailerService/MailerService.js +49 -0
- package/features/MailerService/MailerService.js.map +1 -0
- package/features/MailerService/feature.d.ts +4 -0
- package/features/MailerService/feature.js +13 -0
- package/features/MailerService/feature.js.map +1 -0
- package/features/SaveSettings/SaveSettingsRepository.d.ts +13 -0
- package/features/SaveSettings/SaveSettingsRepository.js +43 -0
- package/features/SaveSettings/SaveSettingsRepository.js.map +1 -0
- package/features/SaveSettings/SaveSettingsUseCase.d.ts +18 -0
- package/features/SaveSettings/SaveSettingsUseCase.js +51 -0
- package/features/SaveSettings/SaveSettingsUseCase.js.map +1 -0
- package/features/SaveSettings/abstractions.d.ts +61 -0
- package/features/SaveSettings/abstractions.js +8 -0
- package/features/SaveSettings/abstractions.js.map +1 -0
- package/features/SaveSettings/events.d.ts +10 -0
- package/features/SaveSettings/events.js +21 -0
- package/features/SaveSettings/events.js.map +1 -0
- package/features/SaveSettings/feature.d.ts +4 -0
- package/features/SaveSettings/feature.js +13 -0
- package/features/SaveSettings/feature.js.map +1 -0
- package/features/SaveSettings/index.d.ts +1 -0
- package/features/SaveSettings/index.js +1 -0
- package/features/SaveSettings/validation.d.ts +9 -0
- package/features/SaveSettings/validation.js +20 -0
- package/features/SaveSettings/validation.js.map +1 -0
- package/features/SendMail/SendMailUseCase.d.ts +16 -0
- package/features/SendMail/SendMailUseCase.js +58 -0
- package/features/SendMail/SendMailUseCase.js.map +1 -0
- package/features/SendMail/abstractions.d.ts +45 -0
- package/features/SendMail/abstractions.js +8 -0
- package/features/SendMail/abstractions.js.map +1 -0
- package/features/SendMail/events.d.ts +14 -0
- package/features/SendMail/events.js +29 -0
- package/features/SendMail/events.js.map +1 -0
- package/features/SendMail/feature.d.ts +4 -0
- package/features/SendMail/feature.js +11 -0
- package/features/SendMail/feature.js.map +1 -0
- package/features/SendMail/index.d.ts +1 -0
- package/features/SendMail/index.js +1 -0
- package/features/SmtpTransport/SmtpConfig.d.ts +6 -0
- package/features/SmtpTransport/SmtpConfig.js +25 -0
- package/features/SmtpTransport/SmtpConfig.js.map +1 -0
- package/features/SmtpTransport/SmtpMailTransport.d.ts +68 -0
- package/features/SmtpTransport/SmtpMailTransport.js +53 -0
- package/features/SmtpTransport/SmtpMailTransport.js.map +1 -0
- package/features/SmtpTransport/SmtpMailTransportFactory.d.ts +10 -0
- package/features/SmtpTransport/SmtpMailTransportFactory.js +18 -0
- package/features/SmtpTransport/SmtpMailTransportFactory.js.map +1 -0
- package/features/SmtpTransport/feature.d.ts +4 -0
- package/features/SmtpTransport/feature.js +11 -0
- package/features/SmtpTransport/feature.js.map +1 -0
- package/graphql/settings.d.ts +2 -2
- package/graphql/settings.js +71 -73
- package/graphql/settings.js.map +1 -1
- package/index.d.ts +4 -8
- package/index.js +23 -89
- package/index.js.map +1 -1
- package/package.json +32 -45
- package/types.d.ts +2 -109
- package/types.js +0 -5
- package/utils/isMailboxAddress.d.ts +6 -0
- package/utils/isMailboxAddress.js +5 -0
- package/utils/isMailboxAddress.js.map +1 -0
- package/context.d.ts +0 -3
- package/context.js +0 -24
- package/context.js.map +0 -1
- package/crud/group.d.ts +0 -2
- package/crud/group.js +0 -21
- package/crud/group.js.map +0 -1
- package/crud/mailer/onBeforeSend.d.ts +0 -7
- package/crud/mailer/onBeforeSend.js +0 -69
- package/crud/mailer/onBeforeSend.js.map +0 -1
- package/crud/mailer.crud.d.ts +0 -2
- package/crud/mailer.crud.js +0 -123
- package/crud/mailer.crud.js.map +0 -1
- package/crud/settings/hooks.d.ts +0 -5
- package/crud/settings/hooks.js +0 -55
- package/crud/settings/hooks.js.map +0 -1
- package/crud/settings/model.d.ts +0 -3
- package/crud/settings/model.js +0 -90
- package/crud/settings/model.js.map +0 -1
- package/crud/settings/password.d.ts +0 -7
- package/crud/settings/password.js +0 -71
- package/crud/settings/password.js.map +0 -1
- package/crud/settings/secret.d.ts +0 -1
- package/crud/settings/secret.js +0 -23
- package/crud/settings/secret.js.map +0 -1
- package/crud/settings/transform.d.ts +0 -13
- package/crud/settings/transform.js +0 -56
- package/crud/settings/transform.js.map +0 -1
- package/crud/settings/validation.d.ts +0 -4
- package/crud/settings/validation.js +0 -38
- package/crud/settings/validation.js.map +0 -1
- package/crud/settings.crud.d.ts +0 -5
- package/crud/settings.crud.js +0 -331
- package/crud/settings.crud.js.map +0 -1
- package/crud/transport/onTransportBeforeSend.d.ts +0 -7
- package/crud/transport/onTransportBeforeSend.js +0 -69
- package/crud/transport/onTransportBeforeSend.js.map +0 -1
- package/crud/transporter.crud.d.ts +0 -2
- package/crud/transporter.crud.js +0 -193
- package/crud/transporter.crud.js.map +0 -1
- package/graphql/index.d.ts +0 -1
- package/graphql/index.js +0 -14
- package/graphql/index.js.map +0 -1
- package/mailers/createDummyMailer.d.ts +0 -5
- package/mailers/createDummyMailer.js +0 -24
- package/mailers/createDummyMailer.js.map +0 -1
- package/mailers/createSmtpMailer.d.ts +0 -13
- package/mailers/createSmtpMailer.js +0 -106
- package/mailers/createSmtpMailer.js.map +0 -1
- package/plugins/CreateTransportPlugin.d.ts +0 -17
- package/plugins/CreateTransportPlugin.js +0 -34
- package/plugins/CreateTransportPlugin.js.map +0 -1
- package/plugins/index.d.ts +0 -1
- package/plugins/index.js +0 -18
- package/plugins/index.js.map +0 -1
- package/transports/createDummyTransport.d.ts +0 -5
- package/transports/createDummyTransport.js +0 -25
- package/transports/createDummyTransport.js.map +0 -1
- package/transports/createSmtpTransport.d.ts +0 -12
- package/transports/createSmtpTransport.js +0 -101
- package/transports/createSmtpTransport.js.map +0 -1
- package/types.js.map +0 -1
package/index.js
CHANGED
|
@@ -1,89 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return _plugins.createTransport;
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
29
|
-
|
|
30
|
-
var _context = require("./context");
|
|
31
|
-
|
|
32
|
-
var _createDummyTransport = require("./transports/createDummyTransport");
|
|
33
|
-
|
|
34
|
-
var _createSmtpTransport = require("./transports/createSmtpTransport");
|
|
35
|
-
|
|
36
|
-
var _plugins = require("./plugins");
|
|
37
|
-
|
|
38
|
-
var _model = require("./crud/settings/model");
|
|
39
|
-
|
|
40
|
-
var _group = require("./crud/group");
|
|
41
|
-
|
|
42
|
-
var _graphql = require("./graphql");
|
|
43
|
-
|
|
44
|
-
const createMailerContext = () => {
|
|
45
|
-
const group = (0, _group.createGroup)();
|
|
46
|
-
return [group,
|
|
47
|
-
/**
|
|
48
|
-
* Groups and models to use via the CMS
|
|
49
|
-
*/
|
|
50
|
-
(0, _model.createSettingsModel)(group),
|
|
51
|
-
/**
|
|
52
|
-
* If something is wrong with the smtp mailer, we will initialize the dummy one.
|
|
53
|
-
*/
|
|
54
|
-
(0, _plugins.createTransport)(async () => {
|
|
55
|
-
const plugin = await (0, _createDummyTransport.createDummyTransport)();
|
|
56
|
-
plugin.name = "dummy-default";
|
|
57
|
-
return plugin;
|
|
58
|
-
}),
|
|
59
|
-
/**
|
|
60
|
-
* Smtp mailer goes into the plugins after the dummy one because plugins are loaded in reverse.
|
|
61
|
-
*/
|
|
62
|
-
(0, _plugins.createTransport)(async ({
|
|
63
|
-
settings
|
|
64
|
-
}) => {
|
|
65
|
-
/**
|
|
66
|
-
* We need to map our settings to the required settings for the SMTP NodeMailer transport.
|
|
67
|
-
*/
|
|
68
|
-
const config = (0, _objectSpread2.default)({}, settings || {});
|
|
69
|
-
|
|
70
|
-
if (settings) {
|
|
71
|
-
config.auth = {
|
|
72
|
-
user: settings.user,
|
|
73
|
-
pass: settings.password
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const plugin = await (0, _createSmtpTransport.createSmtpTransport)(config);
|
|
78
|
-
plugin.name = "smtp-default";
|
|
79
|
-
return plugin;
|
|
80
|
-
}), (0, _context.createMailerContext)()];
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
exports.createMailerContext = createMailerContext;
|
|
84
|
-
|
|
85
|
-
const createMailerGraphQL = () => {
|
|
86
|
-
return [...(0, _graphql.createGraphQL)()];
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
exports.createMailerGraphQL = createMailerGraphQL;
|
|
1
|
+
import { createContextPlugin } from "@webiny/api";
|
|
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";
|
|
10
|
+
const createMailerContext = ()=>createContextPlugin((context)=>{
|
|
11
|
+
CodeMailerSettingsFeature.register(context.container);
|
|
12
|
+
DummyTransportFeature.register(context.container);
|
|
13
|
+
SmtpTransportFeature.register(context.container);
|
|
14
|
+
GetSettingsFeature.register(context.container);
|
|
15
|
+
SaveSettingsFeature.register(context.container);
|
|
16
|
+
MailerServiceFeature.register(context.container);
|
|
17
|
+
SendMailFeature.register(context.container);
|
|
18
|
+
});
|
|
19
|
+
const createMailerGraphQL = ()=>createSettingsGraphQL();
|
|
20
|
+
export { MailerService } from "./domain/MailerService/abstractions.js";
|
|
21
|
+
export { createMailerContext, createMailerGraphQL };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { createContextPlugin } from \"@webiny/api\";\nimport { CodeMailerSettingsFeature } from \"~/features/CodeMailerSettings/feature.js\";\nimport { GetSettingsFeature } from \"~/features/GetSettings/feature.js\";\nimport { SaveSettingsFeature } from \"~/features/SaveSettings/feature.js\";\nimport { DummyTransportFeature } from \"~/features/DummyTransport/feature.js\";\nimport { SmtpTransportFeature } from \"~/features/SmtpTransport/feature.js\";\nimport { MailerServiceFeature } from \"~/features/MailerService/feature.js\";\nimport { SendMailFeature } from \"~/features/SendMail/feature.js\";\nimport { createSettingsGraphQL } from \"~/graphql/settings.js\";\n\nexport { MailerService } from \"./domain/MailerService/abstractions.js\";\nexport type { IMailerService, IMailerServiceErrors } from \"./domain/MailerService/abstractions.js\";\n\nexport const createMailerContext = () => {\n return createContextPlugin(context => {\n // Register all features.\n CodeMailerSettingsFeature.register(context.container);\n DummyTransportFeature.register(context.container);\n SmtpTransportFeature.register(context.container);\n GetSettingsFeature.register(context.container);\n SaveSettingsFeature.register(context.container);\n MailerServiceFeature.register(context.container);\n SendMailFeature.register(context.container);\n });\n};\n\nexport const createMailerGraphQL = () => {\n return createSettingsGraphQL();\n};\n"],"names":["createMailerContext","createContextPlugin","context","CodeMailerSettingsFeature","DummyTransportFeature","SmtpTransportFeature","GetSettingsFeature","SaveSettingsFeature","MailerServiceFeature","SendMailFeature","createMailerGraphQL","createSettingsGraphQL"],"mappings":";;;;;;;;;AAaO,MAAMA,sBAAsB,IACxBC,oBAAoBC,CAAAA;QAEvBC,0BAA0B,QAAQ,CAACD,QAAQ,SAAS;QACpDE,sBAAsB,QAAQ,CAACF,QAAQ,SAAS;QAChDG,qBAAqB,QAAQ,CAACH,QAAQ,SAAS;QAC/CI,mBAAmB,QAAQ,CAACJ,QAAQ,SAAS;QAC7CK,oBAAoB,QAAQ,CAACL,QAAQ,SAAS;QAC9CM,qBAAqB,QAAQ,CAACN,QAAQ,SAAS;QAC/CO,gBAAgB,QAAQ,CAACP,QAAQ,SAAS;IAC9C;AAGG,MAAMQ,sBAAsB,IACxBC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-mailer",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.0.0-unstable.7be00a75a9",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
5
9
|
"repository": {
|
|
6
10
|
"type": "git",
|
|
7
11
|
"url": "https://github.com/webiny/webiny-js.git",
|
|
@@ -14,52 +18,35 @@
|
|
|
14
18
|
"description": "The API to send e-mails.",
|
|
15
19
|
"license": "MIT",
|
|
16
20
|
"dependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"@webiny/api": "0.0.0-unstable.
|
|
19
|
-
"@webiny/
|
|
20
|
-
"@webiny/
|
|
21
|
-
"@webiny/
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"joi": "17.6.2",
|
|
26
|
-
"lodash": "4.17.21",
|
|
27
|
-
"nodemailer": "6.8.0"
|
|
21
|
+
"@webiny/api": "0.0.0-unstable.7be00a75a9",
|
|
22
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.7be00a75a9",
|
|
23
|
+
"@webiny/feature": "0.0.0-unstable.7be00a75a9",
|
|
24
|
+
"@webiny/handler-graphql": "0.0.0-unstable.7be00a75a9",
|
|
25
|
+
"@webiny/plugins": "0.0.0-unstable.7be00a75a9",
|
|
26
|
+
"email-addresses": "5.0.0",
|
|
27
|
+
"nodemailer": "8.0.7",
|
|
28
|
+
"zod": "4.4.3"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@webiny/
|
|
37
|
-
"@webiny/
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"@webiny/cli": "^0.0.0-unstable.78f581c1d2",
|
|
44
|
-
"@webiny/db-dynamodb": "^0.0.0-unstable.78f581c1d2",
|
|
45
|
-
"@webiny/handler": "^0.0.0-unstable.78f581c1d2",
|
|
46
|
-
"@webiny/handler-aws": "^0.0.0-unstable.78f581c1d2",
|
|
47
|
-
"@webiny/handler-db": "^0.0.0-unstable.78f581c1d2",
|
|
48
|
-
"@webiny/project-utils": "^0.0.0-unstable.78f581c1d2",
|
|
49
|
-
"graphql": "^15.7.2",
|
|
50
|
-
"jest": "^28.1.0",
|
|
51
|
-
"jest-dynalite": "^3.6.1",
|
|
52
|
-
"rimraf": "^3.0.2",
|
|
53
|
-
"ttypescript": "^1.5.12",
|
|
54
|
-
"typescript": "4.7.4"
|
|
31
|
+
"@types/nodemailer": "8.0.0",
|
|
32
|
+
"@webiny/api-core": "0.0.0-unstable.7be00a75a9",
|
|
33
|
+
"@webiny/build-tools": "0.0.0-unstable.7be00a75a9",
|
|
34
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.7be00a75a9",
|
|
35
|
+
"@webiny/handler": "0.0.0-unstable.7be00a75a9",
|
|
36
|
+
"@webiny/handler-aws": "0.0.0-unstable.7be00a75a9",
|
|
37
|
+
"@webiny/handler-db": "0.0.0-unstable.7be00a75a9",
|
|
38
|
+
"@webiny/project-utils": "0.0.0-unstable.7be00a75a9",
|
|
39
|
+
"graphql": "16.14.0",
|
|
40
|
+
"jest-dynalite": "3.6.1",
|
|
41
|
+
"rimraf": "6.1.3",
|
|
42
|
+
"typescript": "6.0.3",
|
|
43
|
+
"vitest": "4.1.7"
|
|
55
44
|
},
|
|
56
45
|
"publishConfig": {
|
|
57
|
-
"access": "public"
|
|
58
|
-
"directory": "dist"
|
|
59
|
-
},
|
|
60
|
-
"scripts": {
|
|
61
|
-
"build": "yarn webiny run build",
|
|
62
|
-
"watch": "yarn webiny run watch"
|
|
46
|
+
"access": "public"
|
|
63
47
|
},
|
|
64
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "8476da73b653c89cc1474d968baf55c1b0ae0e5f",
|
|
49
|
+
"webiny": {
|
|
50
|
+
"publishFrom": "dist"
|
|
51
|
+
}
|
|
65
52
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,106 +1,3 @@
|
|
|
1
|
-
import { CmsContext } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import { Topic } from "@webiny/pubsub/types";
|
|
3
|
-
export interface MailerTransporterContext<T extends Transport = Transport> {
|
|
4
|
-
onTransportBeforeSend: Topic<OnTransportBeforeSendParams>;
|
|
5
|
-
onTransportAfterSend: Topic<OnTransportAfterSendParams>;
|
|
6
|
-
onTransportError: Topic<OnTransportErrorParams>;
|
|
7
|
-
getTransport: () => Promise<T | null>;
|
|
8
|
-
sendMail: <D>(data: TransportSendData) => Promise<TransportSendResponse<D>>;
|
|
9
|
-
}
|
|
10
|
-
export interface MailerSettingsCreateParams {
|
|
11
|
-
input: Partial<TransportSettings>;
|
|
12
|
-
}
|
|
13
|
-
export interface MailerSettingsUpdateParams {
|
|
14
|
-
input: Partial<TransportSettings>;
|
|
15
|
-
original?: ExtendedTransportSettings | null;
|
|
16
|
-
}
|
|
17
|
-
export interface MailerSettingsSaveParams {
|
|
18
|
-
input: Partial<TransportSettings>;
|
|
19
|
-
}
|
|
20
|
-
export interface OnSettingsBeforeGetTopicParams {
|
|
21
|
-
tenant: string;
|
|
22
|
-
}
|
|
23
|
-
export interface OnSettingsAfterGetTopicParams {
|
|
24
|
-
tenant: string;
|
|
25
|
-
settings: TransportSettings | null;
|
|
26
|
-
}
|
|
27
|
-
export interface OnSettingsGetErrorTopicParams {
|
|
28
|
-
tenant: string;
|
|
29
|
-
error: Error;
|
|
30
|
-
}
|
|
31
|
-
export interface OnSettingsBeforeCreateTopicParams {
|
|
32
|
-
settings: TransportSettings;
|
|
33
|
-
}
|
|
34
|
-
export interface OnSettingsAfterCreateTopicParams {
|
|
35
|
-
settings: TransportSettings;
|
|
36
|
-
}
|
|
37
|
-
export interface OnSettingsCreateErrorTopicParams {
|
|
38
|
-
settings: TransportSettings;
|
|
39
|
-
error: Error;
|
|
40
|
-
}
|
|
41
|
-
export interface OnSettingsBeforeUpdateTopicParams {
|
|
42
|
-
settings: TransportSettings;
|
|
43
|
-
original: TransportSettings;
|
|
44
|
-
}
|
|
45
|
-
export interface OnSettingsAfterUpdateTopicParams {
|
|
46
|
-
original: TransportSettings;
|
|
47
|
-
settings: TransportSettings;
|
|
48
|
-
}
|
|
49
|
-
export interface OnSettingsUpdateErrorTopicParams {
|
|
50
|
-
original: TransportSettings;
|
|
51
|
-
settings: TransportSettings;
|
|
52
|
-
error: Error;
|
|
53
|
-
}
|
|
54
|
-
export interface ExtendedTransportSettings extends TransportSettings {
|
|
55
|
-
id: string;
|
|
56
|
-
}
|
|
57
|
-
export interface MailerSettingsContext {
|
|
58
|
-
getSettings: () => Promise<ExtendedTransportSettings | null>;
|
|
59
|
-
/**
|
|
60
|
-
* Method should not be used outside of mailer
|
|
61
|
-
* @internal
|
|
62
|
-
*/
|
|
63
|
-
createSettings: (params: MailerSettingsCreateParams) => Promise<TransportSettings>;
|
|
64
|
-
/**
|
|
65
|
-
* Method should not be used outside of mailer
|
|
66
|
-
* @internal
|
|
67
|
-
*/
|
|
68
|
-
updateSettings: (params: MailerSettingsUpdateParams) => Promise<TransportSettings>;
|
|
69
|
-
/**
|
|
70
|
-
* Use to store the settings data.
|
|
71
|
-
*/
|
|
72
|
-
saveSettings: (params: MailerSettingsSaveParams) => Promise<TransportSettings>;
|
|
73
|
-
/**
|
|
74
|
-
* Lifecycle events
|
|
75
|
-
*/
|
|
76
|
-
onSettingsBeforeGet: Topic<OnSettingsBeforeGetTopicParams>;
|
|
77
|
-
onSettingsAfterGet: Topic<OnSettingsAfterGetTopicParams>;
|
|
78
|
-
onSettingsGetError: Topic<OnSettingsGetErrorTopicParams>;
|
|
79
|
-
onSettingsBeforeCreate: Topic<OnSettingsBeforeCreateTopicParams>;
|
|
80
|
-
onSettingsAfterCreate: Topic<OnSettingsAfterCreateTopicParams>;
|
|
81
|
-
onSettingsCreateError: Topic<OnSettingsCreateErrorTopicParams>;
|
|
82
|
-
onSettingsBeforeUpdate: Topic<OnSettingsBeforeUpdateTopicParams>;
|
|
83
|
-
onSettingsAfterUpdate: Topic<OnSettingsAfterUpdateTopicParams>;
|
|
84
|
-
onSettingsUpdateError: Topic<OnSettingsUpdateErrorTopicParams>;
|
|
85
|
-
}
|
|
86
|
-
export interface MailerContextObject<T extends Transport = Transport> extends MailerTransporterContext<T>, MailerSettingsContext {
|
|
87
|
-
}
|
|
88
|
-
export interface MailerContext extends CmsContext {
|
|
89
|
-
mailer: MailerContextObject;
|
|
90
|
-
}
|
|
91
|
-
export interface OnTransportBeforeSendParams {
|
|
92
|
-
data: TransportSendData;
|
|
93
|
-
transport: Transport;
|
|
94
|
-
}
|
|
95
|
-
export interface OnTransportAfterSendParams {
|
|
96
|
-
data: TransportSendData;
|
|
97
|
-
transport: Transport;
|
|
98
|
-
}
|
|
99
|
-
export interface OnTransportErrorParams {
|
|
100
|
-
error: Error;
|
|
101
|
-
data: TransportSendData;
|
|
102
|
-
transport: Transport;
|
|
103
|
-
}
|
|
104
1
|
/**
|
|
105
2
|
* Interface to implement the actual mailer.
|
|
106
3
|
*/
|
|
@@ -129,15 +26,11 @@ interface BaseTransportSendData {
|
|
|
129
26
|
bcc?: string[];
|
|
130
27
|
from?: string;
|
|
131
28
|
subject: string;
|
|
132
|
-
text
|
|
29
|
+
text?: string;
|
|
133
30
|
html?: string;
|
|
134
31
|
replyTo?: string;
|
|
135
32
|
}
|
|
136
|
-
export
|
|
137
|
-
export interface Transport<T = any> {
|
|
138
|
-
name: string;
|
|
139
|
-
send: (params: TransportSendData) => Promise<TransportSendResponse<T>>;
|
|
140
|
-
}
|
|
33
|
+
export type TransportSendData = BaseTransportSendData & (TransportSendToData | TransportSendBccData | TransportSendCcData);
|
|
141
34
|
export interface TransportSettings {
|
|
142
35
|
host: string;
|
|
143
36
|
port: number;
|
package/types.js
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC 5322 mailbox validator. Accepts both addr-spec ("addr@domain") and
|
|
3
|
+
* name-addr ("Display Name <addr@domain>") forms — both are valid SMTP
|
|
4
|
+
* From / Reply-To inputs that nodemailer and most providers accept.
|
|
5
|
+
*/
|
|
6
|
+
export declare const isMailboxAddress: (value: string) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/context.d.ts
DELETED
package/context.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.createMailerContext = void 0;
|
|
9
|
-
|
|
10
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
|
-
var _api = require("@webiny/api");
|
|
13
|
-
|
|
14
|
-
var _transporter = require("./crud/transporter.crud");
|
|
15
|
-
|
|
16
|
-
var _settings = require("./crud/settings.crud");
|
|
17
|
-
|
|
18
|
-
const createMailerContext = () => {
|
|
19
|
-
return new _api.ContextPlugin(async context => {
|
|
20
|
-
context.mailer = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, await (0, _transporter.createTransporterCrud)(context)), await (0, _settings.createSettingsCrud)(context));
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
exports.createMailerContext = createMailerContext;
|
package/context.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createMailerContext","ContextPlugin","context","mailer","createTransporterCrud","createSettingsCrud"],"sources":["context.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { MailerContext } from \"./types\";\nimport { createTransporterCrud } from \"~/crud/transporter.crud\";\nimport { createSettingsCrud } from \"~/crud/settings.crud\";\n\nexport const createMailerContext = () => {\n return new ContextPlugin<MailerContext>(async context => {\n context.mailer = {\n ...(await createTransporterCrud(context)),\n ...(await createSettingsCrud(context))\n };\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAEA;;AACA;;AAEO,MAAMA,mBAAmB,GAAG,MAAM;EACrC,OAAO,IAAIC,kBAAJ,CAAiC,MAAMC,OAAN,IAAiB;IACrDA,OAAO,CAACC,MAAR,+DACQ,MAAM,IAAAC,kCAAA,EAAsBF,OAAtB,CADd,GAEQ,MAAM,IAAAG,4BAAA,EAAmBH,OAAnB,CAFd;EAIH,CALM,CAAP;AAMH,CAPM"}
|
package/crud/group.d.ts
DELETED
package/crud/group.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createGroup = void 0;
|
|
7
|
-
|
|
8
|
-
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
9
|
-
|
|
10
|
-
const createGroup = () => {
|
|
11
|
-
return (0, _apiHeadlessCms.createCmsGroup)({
|
|
12
|
-
name: "Mailer Group",
|
|
13
|
-
description: "Mailer Group for CMS",
|
|
14
|
-
id: "mailerGroup",
|
|
15
|
-
slug: "mailerGroup",
|
|
16
|
-
icon: "none",
|
|
17
|
-
isPrivate: true
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
exports.createGroup = createGroup;
|
package/crud/group.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createGroup","createCmsGroup","name","description","id","slug","icon","isPrivate"],"sources":["group.ts"],"sourcesContent":["import { CmsGroupPlugin, createCmsGroup } from \"@webiny/api-headless-cms\";\n\nexport const createGroup = (): CmsGroupPlugin => {\n return createCmsGroup({\n name: \"Mailer Group\",\n description: \"Mailer Group for CMS\",\n id: \"mailerGroup\",\n slug: \"mailerGroup\",\n icon: \"none\",\n isPrivate: true\n });\n};\n"],"mappings":";;;;;;;AAAA;;AAEO,MAAMA,WAAW,GAAG,MAAsB;EAC7C,OAAO,IAAAC,8BAAA,EAAe;IAClBC,IAAI,EAAE,cADY;IAElBC,WAAW,EAAE,sBAFK;IAGlBC,EAAE,EAAE,aAHc;IAIlBC,IAAI,EAAE,aAJY;IAKlBC,IAAI,EAAE,MALY;IAMlBC,SAAS,EAAE;EANO,CAAf,CAAP;AAQH,CATM"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Topic } from "@webiny/pubsub/types";
|
|
2
|
-
import { OnBeforeMailerSendParams } from "../../types";
|
|
3
|
-
interface AttachOnBeforeSendParams {
|
|
4
|
-
onBeforeSend: Topic<OnBeforeMailerSendParams>;
|
|
5
|
-
}
|
|
6
|
-
export declare const attachOnBeforeSend: (params: AttachOnBeforeSendParams) => void;
|
|
7
|
-
export {};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.attachOnBeforeSend = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _joi = _interopRequireDefault(require("joi"));
|
|
13
|
-
|
|
14
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
-
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
-
|
|
20
|
-
const requiredString = _joi.default.string().required();
|
|
21
|
-
|
|
22
|
-
const requiredEmail = requiredString.email();
|
|
23
|
-
|
|
24
|
-
const schema = _joi.default.object({
|
|
25
|
-
to: _joi.default.array().items(requiredEmail).required(),
|
|
26
|
-
from: requiredEmail,
|
|
27
|
-
subject: requiredString.max(1024),
|
|
28
|
-
cc: _joi.default.array().items(requiredEmail),
|
|
29
|
-
bcc: _joi.default.array().items(requiredEmail),
|
|
30
|
-
replyTo: _joi.default.string().email(),
|
|
31
|
-
text: requiredString.min(10),
|
|
32
|
-
html: _joi.default.string()
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const attachOnBeforeSend = params => {
|
|
36
|
-
const {
|
|
37
|
-
onBeforeSend
|
|
38
|
-
} = params;
|
|
39
|
-
onBeforeSend.subscribe(async ({
|
|
40
|
-
data: input
|
|
41
|
-
}) => {
|
|
42
|
-
let result;
|
|
43
|
-
|
|
44
|
-
try {
|
|
45
|
-
result = await schema.validate(input);
|
|
46
|
-
|
|
47
|
-
if (!result.error) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
} catch (ex) {
|
|
51
|
-
throw new _error.default({
|
|
52
|
-
message: "Error while validating e-mail params.",
|
|
53
|
-
code: "VALIDATION_ERROR",
|
|
54
|
-
data: {
|
|
55
|
-
input,
|
|
56
|
-
error: ex
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
throw new _error.default({
|
|
62
|
-
message: "Error while validating e-mail params.",
|
|
63
|
-
code: "VALIDATION_ERROR",
|
|
64
|
-
data: _objectSpread({}, result.error)
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
exports.attachOnBeforeSend = attachOnBeforeSend;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["requiredString","joi","string","required","requiredEmail","email","schema","object","to","array","items","from","subject","max","cc","bcc","replyTo","text","min","html","attachOnBeforeSend","params","onBeforeSend","subscribe","data","input","result","validate","error","ex","WebinyError","message","code"],"sources":["onBeforeSend.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { MailerSendData, OnBeforeMailerSendParams } from \"~/types\";\nimport joi from \"joi\";\nimport WebinyError from \"@webiny/error\";\n\nconst requiredString = joi.string().required();\nconst requiredEmail = requiredString.email();\n\nconst schema = joi.object<MailerSendData>({\n to: joi.array().items(requiredEmail).required(),\n from: requiredEmail,\n subject: requiredString.max(1024),\n cc: joi.array().items(requiredEmail),\n bcc: joi.array().items(requiredEmail),\n replyTo: joi.string().email(),\n text: requiredString.min(10),\n html: joi.string()\n});\n\ninterface AttachOnBeforeSendParams {\n onBeforeSend: Topic<OnBeforeMailerSendParams>;\n}\nexport const attachOnBeforeSend = (params: AttachOnBeforeSendParams) => {\n const { onBeforeSend } = params;\n\n onBeforeSend.subscribe(async ({ data: input }) => {\n let result: joi.ValidationResult<MailerSendData>;\n try {\n result = await schema.validate(input);\n\n if (!result.error) {\n return;\n }\n } catch (ex) {\n throw new WebinyError({\n message: \"Error while validating e-mail params.\",\n code: \"VALIDATION_ERROR\",\n data: {\n input,\n error: ex\n }\n });\n }\n throw new WebinyError({\n message: \"Error while validating e-mail params.\",\n code: \"VALIDATION_ERROR\",\n data: {\n ...result.error\n }\n });\n });\n};\n"],"mappings":";;;;;;;;;;;AAEA;;AACA;;;;;;AAEA,MAAMA,cAAc,GAAGC,YAAA,CAAIC,MAAJ,GAAaC,QAAb,EAAvB;;AACA,MAAMC,aAAa,GAAGJ,cAAc,CAACK,KAAf,EAAtB;;AAEA,MAAMC,MAAM,GAAGL,YAAA,CAAIM,MAAJ,CAA2B;EACtCC,EAAE,EAAEP,YAAA,CAAIQ,KAAJ,GAAYC,KAAZ,CAAkBN,aAAlB,EAAiCD,QAAjC,EADkC;EAEtCQ,IAAI,EAAEP,aAFgC;EAGtCQ,OAAO,EAAEZ,cAAc,CAACa,GAAf,CAAmB,IAAnB,CAH6B;EAItCC,EAAE,EAAEb,YAAA,CAAIQ,KAAJ,GAAYC,KAAZ,CAAkBN,aAAlB,CAJkC;EAKtCW,GAAG,EAAEd,YAAA,CAAIQ,KAAJ,GAAYC,KAAZ,CAAkBN,aAAlB,CALiC;EAMtCY,OAAO,EAAEf,YAAA,CAAIC,MAAJ,GAAaG,KAAb,EAN6B;EAOtCY,IAAI,EAAEjB,cAAc,CAACkB,GAAf,CAAmB,EAAnB,CAPgC;EAQtCC,IAAI,EAAElB,YAAA,CAAIC,MAAJ;AARgC,CAA3B,CAAf;;AAcO,MAAMkB,kBAAkB,GAAIC,MAAD,IAAsC;EACpE,MAAM;IAAEC;EAAF,IAAmBD,MAAzB;EAEAC,YAAY,CAACC,SAAb,CAAuB,OAAO;IAAEC,IAAI,EAAEC;EAAR,CAAP,KAA2B;IAC9C,IAAIC,MAAJ;;IACA,IAAI;MACAA,MAAM,GAAG,MAAMpB,MAAM,CAACqB,QAAP,CAAgBF,KAAhB,CAAf;;MAEA,IAAI,CAACC,MAAM,CAACE,KAAZ,EAAmB;QACf;MACH;IACJ,CAND,CAME,OAAOC,EAAP,EAAW;MACT,MAAM,IAAIC,cAAJ,CAAgB;QAClBC,OAAO,EAAE,uCADS;QAElBC,IAAI,EAAE,kBAFY;QAGlBR,IAAI,EAAE;UACFC,KADE;UAEFG,KAAK,EAAEC;QAFL;MAHY,CAAhB,CAAN;IAQH;;IACD,MAAM,IAAIC,cAAJ,CAAgB;MAClBC,OAAO,EAAE,uCADS;MAElBC,IAAI,EAAE,kBAFY;MAGlBR,IAAI,oBACGE,MAAM,CAACE,KADV;IAHc,CAAhB,CAAN;EAOH,CAzBD;AA0BH,CA7BM"}
|
package/crud/mailer.crud.d.ts
DELETED