@webiny/api-mailer 0.0.0-unstable.fcdad0bc61 → 0.0.0-unstable.fdd9228b5d
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/context.d.ts +1 -1
- package/context.js +6 -10
- package/context.js.map +1 -1
- package/crud/settings/hooks.d.ts +1 -1
- package/crud/settings/hooks.js +5 -18
- package/crud/settings/hooks.js.map +1 -1
- package/crud/settings/model.d.ts +1 -2
- package/crud/settings/model.js +15 -33
- package/crud/settings/model.js.map +1 -1
- package/crud/settings/password.js +2 -18
- package/crud/settings/password.js.map +1 -1
- package/crud/settings/secret.js +2 -6
- package/crud/settings/secret.js.map +1 -1
- package/crud/settings/transform.d.ts +2 -2
- package/crud/settings/transform.js +9 -19
- package/crud/settings/transform.js.map +1 -1
- package/crud/settings/validation.d.ts +45 -4
- package/crud/settings/validation.js +18 -28
- package/crud/settings/validation.js.map +1 -1
- package/crud/settings.crud.d.ts +1 -1
- package/crud/settings.crud.js +138 -200
- package/crud/settings.crud.js.map +1 -1
- package/crud/transport/onTransportBeforeSend.d.ts +2 -2
- package/crud/transport/onTransportBeforeSend.js +30 -37
- package/crud/transport/onTransportBeforeSend.js.map +1 -1
- package/crud/transporter.crud.d.ts +1 -1
- package/crud/transporter.crud.js +9 -44
- package/crud/transporter.crud.js.map +1 -1
- package/graphql/index.js +2 -3
- package/graphql/index.js.map +1 -1
- package/graphql/settings.d.ts +1 -1
- package/graphql/settings.js +12 -18
- package/graphql/settings.js.map +1 -1
- package/index.d.ts +3 -6
- package/index.js +37 -43
- package/index.js.map +1 -1
- package/package.json +28 -39
- package/plugins/CreateTransportPlugin.d.ts +1 -1
- package/plugins/CreateTransportPlugin.js +3 -13
- package/plugins/CreateTransportPlugin.js.map +1 -1
- package/plugins/index.js +3 -3
- package/plugins/index.js.map +1 -1
- package/transports/createDummyTransport.d.ts +1 -1
- package/transports/createDummyTransport.js +3 -3
- package/transports/createDummyTransport.js.map +1 -1
- package/transports/createSmtpTransport.d.ts +5 -4
- package/transports/createSmtpTransport.js +14 -21
- package/transports/createSmtpTransport.js.map +1 -1
- package/transports/index.d.ts +2 -0
- package/transports/index.js +29 -0
- package/transports/index.js.map +1 -0
- package/types.d.ts +4 -4
- package/types.js +3 -1
- package/types.js.map +1 -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/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/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.fdd9228b5d",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,52 +14,41 @@
|
|
|
14
14
|
"description": "The API to send e-mails.",
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"@webiny/api": "0.0.0-unstable.
|
|
19
|
-
"@webiny/
|
|
20
|
-
"@webiny/
|
|
21
|
-
"@webiny/
|
|
22
|
-
"@webiny/
|
|
23
|
-
"
|
|
24
|
-
"crypto-js": "4.1.1",
|
|
25
|
-
"joi": "17.6.2",
|
|
17
|
+
"@webiny/api": "0.0.0-unstable.fdd9228b5d",
|
|
18
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.fdd9228b5d",
|
|
19
|
+
"@webiny/error": "0.0.0-unstable.fdd9228b5d",
|
|
20
|
+
"@webiny/handler-graphql": "0.0.0-unstable.fdd9228b5d",
|
|
21
|
+
"@webiny/plugins": "0.0.0-unstable.fdd9228b5d",
|
|
22
|
+
"@webiny/pubsub": "0.0.0-unstable.fdd9228b5d",
|
|
23
|
+
"crypto-js": "4.2.0",
|
|
26
24
|
"lodash": "4.17.21",
|
|
27
|
-
"nodemailer": "6.
|
|
25
|
+
"nodemailer": "6.9.16",
|
|
26
|
+
"zod": "3.23.8"
|
|
28
27
|
},
|
|
29
28
|
"devDependencies": {
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@webiny/
|
|
37
|
-
"@webiny/
|
|
38
|
-
"@webiny/
|
|
39
|
-
"@webiny/
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"@webiny/handler": "^0.0.0-unstable.fcdad0bc61",
|
|
46
|
-
"@webiny/handler-aws": "^0.0.0-unstable.fcdad0bc61",
|
|
47
|
-
"@webiny/handler-db": "^0.0.0-unstable.fcdad0bc61",
|
|
48
|
-
"@webiny/project-utils": "^0.0.0-unstable.fcdad0bc61",
|
|
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"
|
|
29
|
+
"@types/crypto-js": "4.2.2",
|
|
30
|
+
"@types/nodemailer": "6.4.17",
|
|
31
|
+
"@webiny/api-i18n": "0.0.0-unstable.fdd9228b5d",
|
|
32
|
+
"@webiny/api-security": "0.0.0-unstable.fdd9228b5d",
|
|
33
|
+
"@webiny/api-tenancy": "0.0.0-unstable.fdd9228b5d",
|
|
34
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.fdd9228b5d",
|
|
35
|
+
"@webiny/handler": "0.0.0-unstable.fdd9228b5d",
|
|
36
|
+
"@webiny/handler-aws": "0.0.0-unstable.fdd9228b5d",
|
|
37
|
+
"@webiny/handler-db": "0.0.0-unstable.fdd9228b5d",
|
|
38
|
+
"@webiny/project-utils": "0.0.0-unstable.fdd9228b5d",
|
|
39
|
+
"graphql": "15.9.0",
|
|
40
|
+
"jest": "29.7.0",
|
|
41
|
+
"jest-dynalite": "3.6.1",
|
|
42
|
+
"rimraf": "6.0.1",
|
|
43
|
+
"typescript": "5.3.3"
|
|
55
44
|
},
|
|
56
45
|
"publishConfig": {
|
|
57
46
|
"access": "public",
|
|
58
47
|
"directory": "dist"
|
|
59
48
|
},
|
|
60
49
|
"scripts": {
|
|
61
|
-
"build": "
|
|
62
|
-
"watch": "
|
|
50
|
+
"build": "node ../cli/bin.js run build",
|
|
51
|
+
"watch": "node ../cli/bin.js run watch"
|
|
63
52
|
},
|
|
64
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "fdd9228b5d2636463e8a34b6e0d26eea1e29c01d"
|
|
65
54
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Plugin as BasePlugin } from "@webiny/plugins";
|
|
2
|
-
import { Transport, MailerContext, TransportSettings } from "../types";
|
|
2
|
+
import type { Transport, MailerContext, TransportSettings } from "../types";
|
|
3
3
|
interface TransportParams {
|
|
4
4
|
settings: TransportSettings | null;
|
|
5
5
|
context: MailerContext;
|
|
@@ -1,34 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.createTransport = exports.CreateTransportPlugin = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
7
|
var _plugins = require("@webiny/plugins");
|
|
13
|
-
|
|
14
8
|
class CreateTransportPlugin extends _plugins.Plugin {
|
|
9
|
+
static type = "mailer.builder.plugin";
|
|
15
10
|
constructor(cb) {
|
|
16
11
|
super();
|
|
17
|
-
(0, _defineProperty2.default)(this, "cb", void 0);
|
|
18
12
|
this.cb = cb;
|
|
19
13
|
}
|
|
20
|
-
|
|
21
14
|
async buildMailerTransport(params) {
|
|
22
15
|
return this.cb(params);
|
|
23
16
|
}
|
|
24
|
-
|
|
25
17
|
}
|
|
26
|
-
|
|
27
18
|
exports.CreateTransportPlugin = CreateTransportPlugin;
|
|
28
|
-
(0, _defineProperty2.default)(CreateTransportPlugin, "type", "mailer.builder.plugin");
|
|
29
|
-
|
|
30
19
|
const createTransport = cb => {
|
|
31
20
|
return new CreateTransportPlugin(cb);
|
|
32
21
|
};
|
|
22
|
+
exports.createTransport = createTransport;
|
|
33
23
|
|
|
34
|
-
|
|
24
|
+
//# sourceMappingURL=CreateTransportPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CreateTransportPlugin","BasePlugin","constructor","cb","buildMailerTransport","params","createTransport"],"sources":["CreateTransportPlugin.ts"],"sourcesContent":["import { Plugin as BasePlugin } from \"@webiny/plugins\";\nimport { Transport, MailerContext, TransportSettings } from \"~/types\";\n\ninterface TransportParams {\n settings: TransportSettings | null;\n context: MailerContext;\n}\n\nexport interface CreateTransportCallable<T> {\n (params: TransportParams): Promise<T>;\n}\n\nexport class CreateTransportPlugin<T extends Transport = Transport> extends BasePlugin {\n public static override type = \"mailer.builder.plugin\";\n\n private readonly cb: CreateTransportCallable<T>;\n\n public constructor(cb: CreateTransportCallable<T>) {\n super();\n this.cb = cb;\n }\n\n public async buildMailerTransport(params: TransportParams): Promise<T> {\n return this.cb(params);\n }\n}\n\nexport const createTransport = <T extends Transport = Transport>(\n cb: CreateTransportCallable<T>\n) => {\n return new CreateTransportPlugin<T>(cb);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_plugins","require","CreateTransportPlugin","BasePlugin","type","constructor","cb","buildMailerTransport","params","exports","createTransport"],"sources":["CreateTransportPlugin.ts"],"sourcesContent":["import { Plugin as BasePlugin } from \"@webiny/plugins\";\nimport type { Transport, MailerContext, TransportSettings } from \"~/types\";\n\ninterface TransportParams {\n settings: TransportSettings | null;\n context: MailerContext;\n}\n\nexport interface CreateTransportCallable<T> {\n (params: TransportParams): Promise<T>;\n}\n\nexport class CreateTransportPlugin<T extends Transport = Transport> extends BasePlugin {\n public static override type = \"mailer.builder.plugin\";\n\n private readonly cb: CreateTransportCallable<T>;\n\n public constructor(cb: CreateTransportCallable<T>) {\n super();\n this.cb = cb;\n }\n\n public async buildMailerTransport(params: TransportParams): Promise<T> {\n return this.cb(params);\n }\n}\n\nexport const createTransport = <T extends Transport = Transport>(\n cb: CreateTransportCallable<T>\n) => {\n return new CreateTransportPlugin<T>(cb);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAYO,MAAMC,qBAAqB,SAA0CC,eAAU,CAAC;EACnF,OAAuBC,IAAI,GAAG,uBAAuB;EAI9CC,WAAWA,CAACC,EAA8B,EAAE;IAC/C,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EAEA,MAAaC,oBAAoBA,CAACC,MAAuB,EAAc;IACnE,OAAO,IAAI,CAACF,EAAE,CAACE,MAAM,CAAC;EAC1B;AACJ;AAACC,OAAA,CAAAP,qBAAA,GAAAA,qBAAA;AAEM,MAAMQ,eAAe,GACxBJ,EAA8B,IAC7B;EACD,OAAO,IAAIJ,qBAAqB,CAAII,EAAE,CAAC;AAC3C,CAAC;AAACG,OAAA,CAAAC,eAAA,GAAAA,eAAA","ignoreList":[]}
|
package/plugins/index.js
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
var _CreateTransportPlugin = require("./CreateTransportPlugin");
|
|
8
|
-
|
|
9
7
|
Object.keys(_CreateTransportPlugin).forEach(function (key) {
|
|
10
8
|
if (key === "default" || key === "__esModule") return;
|
|
11
9
|
if (key in exports && exports[key] === _CreateTransportPlugin[key]) return;
|
|
@@ -15,4 +13,6 @@ Object.keys(_CreateTransportPlugin).forEach(function (key) {
|
|
|
15
13
|
return _CreateTransportPlugin[key];
|
|
16
14
|
}
|
|
17
15
|
});
|
|
18
|
-
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
package/plugins/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./CreateTransportPlugin\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_CreateTransportPlugin","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from \"./CreateTransportPlugin\";\n"],"mappings":";;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,sBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,sBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,sBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -4,11 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createDummyTransport = void 0;
|
|
7
|
-
|
|
8
7
|
const createDummyTransport = () => {
|
|
9
8
|
const sent = [];
|
|
10
9
|
return {
|
|
11
|
-
name: "dummy-default",
|
|
10
|
+
name: "mailer.dummy-default",
|
|
12
11
|
send: async params => {
|
|
13
12
|
sent.push(params);
|
|
14
13
|
return {
|
|
@@ -21,5 +20,6 @@ const createDummyTransport = () => {
|
|
|
21
20
|
}
|
|
22
21
|
};
|
|
23
22
|
};
|
|
23
|
+
exports.createDummyTransport = createDummyTransport;
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
//# sourceMappingURL=createDummyTransport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createDummyTransport","sent","name","send","params","push","result","error","getAllSent"],"sources":["createDummyTransport.ts"],"sourcesContent":["import { Transport, TransportSendData } from \"~/types\";\n\nexport interface DummyTransport extends Transport {\n getAllSent: () => TransportSendData[];\n}\nexport const createDummyTransport = (): DummyTransport => {\n const sent: TransportSendData[] = [];\n\n return {\n name: \"dummy-default\",\n send: async params => {\n sent.push(params);\n return {\n result: true,\n error: null\n };\n },\n getAllSent: () => {\n return sent;\n }\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["createDummyTransport","sent","name","send","params","push","result","error","getAllSent","exports"],"sources":["createDummyTransport.ts"],"sourcesContent":["import type { Transport, TransportSendData } from \"~/types\";\n\nexport interface DummyTransport extends Transport {\n getAllSent: () => TransportSendData[];\n}\nexport const createDummyTransport = (): DummyTransport => {\n const sent: TransportSendData[] = [];\n\n return {\n name: \"mailer.dummy-default\",\n send: async params => {\n sent.push(params);\n return {\n result: true,\n error: null\n };\n },\n getAllSent: () => {\n return sent;\n }\n };\n};\n"],"mappings":";;;;;;AAKO,MAAMA,oBAAoB,GAAGA,CAAA,KAAsB;EACtD,MAAMC,IAAyB,GAAG,EAAE;EAEpC,OAAO;IACHC,IAAI,EAAE,sBAAsB;IAC5BC,IAAI,EAAE,MAAMC,MAAM,IAAI;MAClBH,IAAI,CAACI,IAAI,CAACD,MAAM,CAAC;MACjB,OAAO;QACHE,MAAM,EAAE,IAAI;QACZC,KAAK,EAAE;MACX,CAAC;IACL,CAAC;IACDC,UAAU,EAAEA,CAAA,KAAM;MACd,OAAOP,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAACQ,OAAA,CAAAT,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* Nodemailer docs
|
|
3
3
|
* https://nodemailer.com/about/
|
|
4
4
|
*/
|
|
5
|
-
import { Transport } from "../types";
|
|
6
|
-
import { Transporter } from "nodemailer";
|
|
7
|
-
import
|
|
8
|
-
|
|
5
|
+
import type { Transport } from "../types";
|
|
6
|
+
import type { Transporter } from "nodemailer";
|
|
7
|
+
import type { Options } from "nodemailer/lib/smtp-transport";
|
|
8
|
+
import type SMTPTransport from "nodemailer/lib/smtp-transport";
|
|
9
|
+
export type SmtpTransportConfig = Options;
|
|
9
10
|
export interface SmtpTransport extends Transport {
|
|
10
11
|
transporter: Transporter<SMTPTransport.SentMessageInfo>;
|
|
11
12
|
}
|
|
@@ -1,50 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createSmtpTransport = void 0;
|
|
9
|
-
|
|
10
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
9
|
var _nodemailer = _interopRequireDefault(require("nodemailer"));
|
|
15
|
-
|
|
16
10
|
/**
|
|
17
11
|
* Nodemailer docs
|
|
18
12
|
* https://nodemailer.com/about/
|
|
19
13
|
*/
|
|
14
|
+
|
|
20
15
|
const configDefaults = {
|
|
21
16
|
socketTimeout: 15000,
|
|
22
17
|
connectionTimeout: 15000,
|
|
23
18
|
greetingTimeout: 15000
|
|
24
19
|
};
|
|
25
|
-
|
|
26
20
|
const applyDefaults = initialConfig => {
|
|
27
21
|
return Object.keys(configDefaults).reduce((config, key) => {
|
|
28
22
|
const configKey = key;
|
|
29
|
-
|
|
30
23
|
if (config[configKey] === undefined || config[configKey] === null) {
|
|
31
|
-
// @ts-
|
|
24
|
+
// @ts-expect-error
|
|
32
25
|
config[configKey] = configDefaults[configKey];
|
|
33
26
|
}
|
|
34
|
-
|
|
35
27
|
return config;
|
|
36
|
-
},
|
|
28
|
+
}, {
|
|
29
|
+
...initialConfig
|
|
30
|
+
});
|
|
37
31
|
};
|
|
38
|
-
|
|
39
32
|
const createSmtpTransport = initialConfig => {
|
|
40
33
|
if (!initialConfig || typeof initialConfig !== "object" || Object.keys(initialConfig).length === 0) {
|
|
41
34
|
throw new _error.default("There is no configuration for the SMTP transport.");
|
|
42
35
|
}
|
|
43
|
-
|
|
44
36
|
const config = applyDefaults(initialConfig);
|
|
45
|
-
|
|
46
37
|
const transporter = _nodemailer.default.createTransport(config);
|
|
47
|
-
|
|
48
38
|
return {
|
|
49
39
|
name: "smtp-default",
|
|
50
40
|
transporter,
|
|
@@ -59,7 +49,6 @@ const createSmtpTransport = initialConfig => {
|
|
|
59
49
|
from,
|
|
60
50
|
subject
|
|
61
51
|
} = params;
|
|
62
|
-
|
|
63
52
|
try {
|
|
64
53
|
const result = await transporter.sendMail({
|
|
65
54
|
replyTo,
|
|
@@ -71,18 +60,18 @@ const createSmtpTransport = initialConfig => {
|
|
|
71
60
|
to,
|
|
72
61
|
subject
|
|
73
62
|
});
|
|
74
|
-
|
|
75
63
|
if (result.messageId) {
|
|
76
64
|
return {
|
|
77
65
|
result: result.response,
|
|
78
66
|
error: null
|
|
79
67
|
};
|
|
80
68
|
}
|
|
81
|
-
|
|
82
69
|
throw new _error.default({
|
|
83
70
|
message: "nodemailer.sendMail does not have a messageId in the result. Something went wrong...",
|
|
84
71
|
code: "MAILER_ERROR",
|
|
85
|
-
data:
|
|
72
|
+
data: {
|
|
73
|
+
...result
|
|
74
|
+
}
|
|
86
75
|
});
|
|
87
76
|
} catch (ex) {
|
|
88
77
|
return {
|
|
@@ -90,12 +79,16 @@ const createSmtpTransport = initialConfig => {
|
|
|
90
79
|
error: {
|
|
91
80
|
message: ex.message,
|
|
92
81
|
code: ex.code,
|
|
93
|
-
data:
|
|
82
|
+
data: {
|
|
83
|
+
...params,
|
|
84
|
+
...ex.data
|
|
85
|
+
}
|
|
94
86
|
}
|
|
95
87
|
};
|
|
96
88
|
}
|
|
97
89
|
}
|
|
98
90
|
};
|
|
99
91
|
};
|
|
92
|
+
exports.createSmtpTransport = createSmtpTransport;
|
|
100
93
|
|
|
101
|
-
|
|
94
|
+
//# sourceMappingURL=createSmtpTransport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["configDefaults","socketTimeout","connectionTimeout","greetingTimeout","applyDefaults","initialConfig","Object","keys","reduce","config","key","configKey","undefined","createSmtpTransport","length","WebinyError","transporter","nodemailer","createTransport","name","send","params","replyTo","text","html","to","bcc","cc","from","subject","result","sendMail","messageId","response","error","message","code","data","ex"],"sources":["createSmtpTransport.ts"],"sourcesContent":["/**\n * Nodemailer docs\n * https://nodemailer.com/about/\n */\nimport { Transport } from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_nodemailer","configDefaults","socketTimeout","connectionTimeout","greetingTimeout","applyDefaults","initialConfig","Object","keys","reduce","config","key","configKey","undefined","createSmtpTransport","length","WebinyError","transporter","nodemailer","createTransport","name","send","params","replyTo","text","html","to","bcc","cc","from","subject","result","sendMail","messageId","response","error","message","code","data","ex","exports"],"sources":["createSmtpTransport.ts"],"sourcesContent":["/**\n * Nodemailer docs\n * https://nodemailer.com/about/\n */\nimport type { Transport } from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport type { Transporter } from \"nodemailer\";\nimport nodemailer from \"nodemailer\";\nimport type { Options } from \"nodemailer/lib/smtp-transport\";\nimport type SMTPTransport from \"nodemailer/lib/smtp-transport\";\n\nexport type SmtpTransportConfig = Options;\n\nexport interface SmtpTransport extends Transport {\n transporter: Transporter<SMTPTransport.SentMessageInfo>;\n}\n\nconst configDefaults: Partial<SmtpTransportConfig> = {\n socketTimeout: 15000,\n connectionTimeout: 15000,\n greetingTimeout: 15000\n};\n\nconst applyDefaults = (\n initialConfig: Partial<SmtpTransportConfig>\n): Partial<SmtpTransportConfig> => {\n return Object.keys(configDefaults).reduce<Partial<SmtpTransportConfig>>(\n (config, key) => {\n const configKey = key as unknown as keyof SmtpTransportConfig;\n if (config[configKey] === undefined || config[configKey] === null) {\n // @ts-expect-error\n config[configKey] = configDefaults[configKey];\n }\n\n return config;\n },\n { ...initialConfig }\n );\n};\n\nexport const createSmtpTransport = (\n initialConfig?: Partial<SmtpTransportConfig> | null\n): SmtpTransport => {\n if (\n !initialConfig ||\n typeof initialConfig !== \"object\" ||\n Object.keys(initialConfig).length === 0\n ) {\n throw new WebinyError(\"There is no configuration for the SMTP transport.\");\n }\n\n const config = applyDefaults(initialConfig);\n\n const transporter = nodemailer.createTransport(config);\n\n return {\n name: \"smtp-default\",\n transporter,\n send: async params => {\n const { replyTo, text, html, to, bcc, cc, from, subject } = params;\n\n try {\n const result = await transporter.sendMail({\n replyTo,\n bcc,\n cc,\n from,\n text,\n html,\n to,\n subject\n });\n if (result.messageId) {\n return {\n result: result.response,\n error: null\n };\n }\n\n throw new WebinyError({\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 } catch (ex) {\n return {\n result: null,\n error: {\n message: ex.message,\n code: ex.code,\n data: {\n ...params,\n ...ex.data\n }\n }\n };\n }\n }\n };\n};\n"],"mappings":";;;;;;;AAKA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AAPA;AACA;AACA;AACA;;AAcA,MAAME,cAA4C,GAAG;EACjDC,aAAa,EAAE,KAAK;EACpBC,iBAAiB,EAAE,KAAK;EACxBC,eAAe,EAAE;AACrB,CAAC;AAED,MAAMC,aAAa,GACfC,aAA2C,IACZ;EAC/B,OAAOC,MAAM,CAACC,IAAI,CAACP,cAAc,CAAC,CAACQ,MAAM,CACrC,CAACC,MAAM,EAAEC,GAAG,KAAK;IACb,MAAMC,SAAS,GAAGD,GAA2C;IAC7D,IAAID,MAAM,CAACE,SAAS,CAAC,KAAKC,SAAS,IAAIH,MAAM,CAACE,SAAS,CAAC,KAAK,IAAI,EAAE;MAC/D;MACAF,MAAM,CAACE,SAAS,CAAC,GAAGX,cAAc,CAACW,SAAS,CAAC;IACjD;IAEA,OAAOF,MAAM;EACjB,CAAC,EACD;IAAE,GAAGJ;EAAc,CACvB,CAAC;AACL,CAAC;AAEM,MAAMQ,mBAAmB,GAC5BR,aAAmD,IACnC;EAChB,IACI,CAACA,aAAa,IACd,OAAOA,aAAa,KAAK,QAAQ,IACjCC,MAAM,CAACC,IAAI,CAACF,aAAa,CAAC,CAACS,MAAM,KAAK,CAAC,EACzC;IACE,MAAM,IAAIC,cAAW,CAAC,mDAAmD,CAAC;EAC9E;EAEA,MAAMN,MAAM,GAAGL,aAAa,CAACC,aAAa,CAAC;EAE3C,MAAMW,WAAW,GAAGC,mBAAU,CAACC,eAAe,CAACT,MAAM,CAAC;EAEtD,OAAO;IACHU,IAAI,EAAE,cAAc;IACpBH,WAAW;IACXI,IAAI,EAAE,MAAMC,MAAM,IAAI;MAClB,MAAM;QAAEC,OAAO;QAAEC,IAAI;QAAEC,IAAI;QAAEC,EAAE;QAAEC,GAAG;QAAEC,EAAE;QAAEC,IAAI;QAAEC;MAAQ,CAAC,GAAGR,MAAM;MAElE,IAAI;QACA,MAAMS,MAAM,GAAG,MAAMd,WAAW,CAACe,QAAQ,CAAC;UACtCT,OAAO;UACPI,GAAG;UACHC,EAAE;UACFC,IAAI;UACJL,IAAI;UACJC,IAAI;UACJC,EAAE;UACFI;QACJ,CAAC,CAAC;QACF,IAAIC,MAAM,CAACE,SAAS,EAAE;UAClB,OAAO;YACHF,MAAM,EAAEA,MAAM,CAACG,QAAQ;YACvBC,KAAK,EAAE;UACX,CAAC;QACL;QAEA,MAAM,IAAInB,cAAW,CAAC;UAClBoB,OAAO,EACH,sFAAsF;UAC1FC,IAAI,EAAE,cAAc;UACpBC,IAAI,EAAE;YACF,GAAGP;UACP;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,OAAOQ,EAAE,EAAE;QACT,OAAO;UACHR,MAAM,EAAE,IAAI;UACZI,KAAK,EAAE;YACHC,OAAO,EAAEG,EAAE,CAACH,OAAO;YACnBC,IAAI,EAAEE,EAAE,CAACF,IAAI;YACbC,IAAI,EAAE;cACF,GAAGhB,MAAM;cACT,GAAGiB,EAAE,CAACD;YACV;UACJ;QACJ,CAAC;MACL;IACJ;EACJ,CAAC;AACL,CAAC;AAACE,OAAA,CAAA1B,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _createDummyTransport = require("./createDummyTransport");
|
|
7
|
+
Object.keys(_createDummyTransport).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _createDummyTransport[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _createDummyTransport[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _createSmtpTransport = require("./createSmtpTransport");
|
|
18
|
+
Object.keys(_createSmtpTransport).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _createSmtpTransport[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _createSmtpTransport[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_createDummyTransport","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_createSmtpTransport"],"sources":["index.ts"],"sourcesContent":["export * from \"./createDummyTransport\";\nexport * from \"./createSmtpTransport\";\n"],"mappings":";;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,qBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,qBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,qBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,oBAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,oBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,oBAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,oBAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
package/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CmsContext } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import { Topic } from "@webiny/pubsub/types";
|
|
1
|
+
import type { CmsContext } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import type { Topic } from "@webiny/pubsub/types";
|
|
3
3
|
export interface MailerTransporterContext<T extends Transport = Transport> {
|
|
4
4
|
onTransportBeforeSend: Topic<OnTransportBeforeSendParams>;
|
|
5
5
|
onTransportAfterSend: Topic<OnTransportAfterSendParams>;
|
|
@@ -129,11 +129,11 @@ interface BaseTransportSendData {
|
|
|
129
129
|
bcc?: string[];
|
|
130
130
|
from?: string;
|
|
131
131
|
subject: string;
|
|
132
|
-
text
|
|
132
|
+
text?: string;
|
|
133
133
|
html?: string;
|
|
134
134
|
replyTo?: string;
|
|
135
135
|
}
|
|
136
|
-
export
|
|
136
|
+
export type TransportSendData = BaseTransportSendData & (TransportSendToData | TransportSendBccData | TransportSendCcData);
|
|
137
137
|
export interface Transport<T = any> {
|
|
138
138
|
name: string;
|
|
139
139
|
send: (params: TransportSendData) => Promise<TransportSendResponse<T>>;
|
package/types.js
CHANGED
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\n\nexport interface MailerTransporterContext<T extends Transport = Transport> {\n onTransportBeforeSend: Topic<OnTransportBeforeSendParams>;\n onTransportAfterSend: Topic<OnTransportAfterSendParams>;\n onTransportError: Topic<OnTransportErrorParams>;\n getTransport: () => Promise<T | null>;\n sendMail: <D>(data: TransportSendData) => Promise<TransportSendResponse<D>>;\n}\n\nexport interface MailerSettingsCreateParams {\n input: Partial<TransportSettings>;\n}\nexport interface MailerSettingsUpdateParams {\n input: Partial<TransportSettings>;\n original?: ExtendedTransportSettings | null;\n}\n\nexport interface MailerSettingsSaveParams {\n input: Partial<TransportSettings>;\n}\n\nexport interface OnSettingsBeforeGetTopicParams {\n tenant: string;\n}\n\nexport interface OnSettingsAfterGetTopicParams {\n tenant: string;\n settings: TransportSettings | null;\n}\n\nexport interface OnSettingsGetErrorTopicParams {\n tenant: string;\n error: Error;\n}\n\nexport interface OnSettingsBeforeCreateTopicParams {\n settings: TransportSettings;\n}\n\nexport interface OnSettingsAfterCreateTopicParams {\n settings: TransportSettings;\n}\n\nexport interface OnSettingsCreateErrorTopicParams {\n settings: TransportSettings;\n error: Error;\n}\n\nexport interface OnSettingsBeforeUpdateTopicParams {\n settings: TransportSettings;\n original: TransportSettings;\n}\n\nexport interface OnSettingsAfterUpdateTopicParams {\n original: TransportSettings;\n settings: TransportSettings;\n}\n\nexport interface OnSettingsUpdateErrorTopicParams {\n original: TransportSettings;\n settings: TransportSettings;\n error: Error;\n}\n\nexport interface ExtendedTransportSettings extends TransportSettings {\n id: string;\n}\n\nexport interface MailerSettingsContext {\n getSettings: () => Promise<ExtendedTransportSettings | null>;\n /**\n * Method should not be used outside of mailer\n * @internal\n */\n createSettings: (params: MailerSettingsCreateParams) => Promise<TransportSettings>;\n /**\n * Method should not be used outside of mailer\n * @internal\n */\n updateSettings: (params: MailerSettingsUpdateParams) => Promise<TransportSettings>;\n /**\n * Use to store the settings data.\n */\n saveSettings: (params: MailerSettingsSaveParams) => Promise<TransportSettings>;\n /**\n * Lifecycle events\n */\n onSettingsBeforeGet: Topic<OnSettingsBeforeGetTopicParams>;\n onSettingsAfterGet: Topic<OnSettingsAfterGetTopicParams>;\n onSettingsGetError: Topic<OnSettingsGetErrorTopicParams>;\n onSettingsBeforeCreate: Topic<OnSettingsBeforeCreateTopicParams>;\n onSettingsAfterCreate: Topic<OnSettingsAfterCreateTopicParams>;\n onSettingsCreateError: Topic<OnSettingsCreateErrorTopicParams>;\n onSettingsBeforeUpdate: Topic<OnSettingsBeforeUpdateTopicParams>;\n onSettingsAfterUpdate: Topic<OnSettingsAfterUpdateTopicParams>;\n onSettingsUpdateError: Topic<OnSettingsUpdateErrorTopicParams>;\n}\n\nexport interface MailerContextObject<T extends Transport = Transport>\n extends MailerTransporterContext<T>,\n MailerSettingsContext {}\nexport interface MailerContext extends CmsContext {\n mailer: MailerContextObject;\n}\n\nexport interface OnTransportBeforeSendParams {\n data: TransportSendData;\n transport: Transport;\n}\nexport interface OnTransportAfterSendParams {\n data: TransportSendData;\n transport: Transport;\n}\nexport interface OnTransportErrorParams {\n error: Error;\n data: TransportSendData;\n transport: Transport;\n}\n\n/**\n * Interface to implement the actual mailer.\n */\nexport interface TransportSendResponse<T = any> {\n result: T | null;\n error: {\n message: string;\n code: string;\n data?: {\n [key: string]: any;\n };\n } | null;\n}\n\ninterface TransportSendToData {\n to: string[];\n}\ninterface TransportSendCcData {\n cc: string[];\n}\ninterface TransportSendBccData {\n bcc: string[];\n}\n\ninterface BaseTransportSendData {\n to?: string[];\n cc?: string[];\n bcc?: string[];\n from?: string;\n subject: string;\n text
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport type { Topic } from \"@webiny/pubsub/types\";\n\nexport interface MailerTransporterContext<T extends Transport = Transport> {\n onTransportBeforeSend: Topic<OnTransportBeforeSendParams>;\n onTransportAfterSend: Topic<OnTransportAfterSendParams>;\n onTransportError: Topic<OnTransportErrorParams>;\n getTransport: () => Promise<T | null>;\n sendMail: <D>(data: TransportSendData) => Promise<TransportSendResponse<D>>;\n}\n\nexport interface MailerSettingsCreateParams {\n input: Partial<TransportSettings>;\n}\nexport interface MailerSettingsUpdateParams {\n input: Partial<TransportSettings>;\n original?: ExtendedTransportSettings | null;\n}\n\nexport interface MailerSettingsSaveParams {\n input: Partial<TransportSettings>;\n}\n\nexport interface OnSettingsBeforeGetTopicParams {\n tenant: string;\n}\n\nexport interface OnSettingsAfterGetTopicParams {\n tenant: string;\n settings: TransportSettings | null;\n}\n\nexport interface OnSettingsGetErrorTopicParams {\n tenant: string;\n error: Error;\n}\n\nexport interface OnSettingsBeforeCreateTopicParams {\n settings: TransportSettings;\n}\n\nexport interface OnSettingsAfterCreateTopicParams {\n settings: TransportSettings;\n}\n\nexport interface OnSettingsCreateErrorTopicParams {\n settings: TransportSettings;\n error: Error;\n}\n\nexport interface OnSettingsBeforeUpdateTopicParams {\n settings: TransportSettings;\n original: TransportSettings;\n}\n\nexport interface OnSettingsAfterUpdateTopicParams {\n original: TransportSettings;\n settings: TransportSettings;\n}\n\nexport interface OnSettingsUpdateErrorTopicParams {\n original: TransportSettings;\n settings: TransportSettings;\n error: Error;\n}\n\nexport interface ExtendedTransportSettings extends TransportSettings {\n id: string;\n}\n\nexport interface MailerSettingsContext {\n getSettings: () => Promise<ExtendedTransportSettings | null>;\n /**\n * Method should not be used outside of mailer\n * @internal\n */\n createSettings: (params: MailerSettingsCreateParams) => Promise<TransportSettings>;\n /**\n * Method should not be used outside of mailer\n * @internal\n */\n updateSettings: (params: MailerSettingsUpdateParams) => Promise<TransportSettings>;\n /**\n * Use to store the settings data.\n */\n saveSettings: (params: MailerSettingsSaveParams) => Promise<TransportSettings>;\n /**\n * Lifecycle events\n */\n onSettingsBeforeGet: Topic<OnSettingsBeforeGetTopicParams>;\n onSettingsAfterGet: Topic<OnSettingsAfterGetTopicParams>;\n onSettingsGetError: Topic<OnSettingsGetErrorTopicParams>;\n onSettingsBeforeCreate: Topic<OnSettingsBeforeCreateTopicParams>;\n onSettingsAfterCreate: Topic<OnSettingsAfterCreateTopicParams>;\n onSettingsCreateError: Topic<OnSettingsCreateErrorTopicParams>;\n onSettingsBeforeUpdate: Topic<OnSettingsBeforeUpdateTopicParams>;\n onSettingsAfterUpdate: Topic<OnSettingsAfterUpdateTopicParams>;\n onSettingsUpdateError: Topic<OnSettingsUpdateErrorTopicParams>;\n}\n\nexport interface MailerContextObject<T extends Transport = Transport>\n extends MailerTransporterContext<T>,\n MailerSettingsContext {}\nexport interface MailerContext extends CmsContext {\n mailer: MailerContextObject;\n}\n\nexport interface OnTransportBeforeSendParams {\n data: TransportSendData;\n transport: Transport;\n}\nexport interface OnTransportAfterSendParams {\n data: TransportSendData;\n transport: Transport;\n}\nexport interface OnTransportErrorParams {\n error: Error;\n data: TransportSendData;\n transport: Transport;\n}\n\n/**\n * Interface to implement the actual mailer.\n */\nexport interface TransportSendResponse<T = any> {\n result: T | null;\n error: {\n message: string;\n code: string;\n data?: {\n [key: string]: any;\n };\n } | null;\n}\n\ninterface TransportSendToData {\n to: string[];\n}\ninterface TransportSendCcData {\n cc: string[];\n}\ninterface TransportSendBccData {\n bcc: string[];\n}\n\ninterface BaseTransportSendData {\n to?: string[];\n cc?: string[];\n bcc?: string[];\n from?: string;\n subject: string;\n text?: string;\n html?: string;\n replyTo?: string;\n}\n\nexport type TransportSendData = BaseTransportSendData &\n (TransportSendToData | TransportSendBccData | TransportSendCcData);\nexport interface Transport<T = any> {\n name: string;\n send: (params: TransportSendData) => Promise<TransportSendResponse<T>>;\n}\n\nexport interface TransportSettings {\n host: string;\n port: number;\n user: string;\n password: string;\n from: string;\n replyTo?: string;\n}\n"],"mappings":"","ignoreList":[]}
|
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