medusa-plugin-ses 2.0.3 → 2.0.5
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/package.json +3 -6
- package/services/ses.js +7 -8
- package/.babelrc +0 -13
- package/jest.config.js +0 -3
- package/src/api/index.js +0 -33
- package/src/services/ses.js +0 -1290
- package/src/subscribers/order.js +0 -20
- package/src/subscribers/restock.js +0 -41
- package/src/subscribers/user.js +0 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "medusa-plugin-ses",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "AWS SES transactional emails using local handlebars templates",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -21,8 +21,7 @@
|
|
|
21
21
|
"@babel/runtime": "^7.9.6",
|
|
22
22
|
"client-sessions": "^0.8.0",
|
|
23
23
|
"cross-env": "^5.2.1",
|
|
24
|
-
"jest": "^25.5.2"
|
|
25
|
-
"medusa-interfaces": "^1.3.4"
|
|
24
|
+
"jest": "^25.5.2"
|
|
26
25
|
},
|
|
27
26
|
"scripts": {
|
|
28
27
|
"prepare": "cross-env NODE_ENV=production yarn run build",
|
|
@@ -30,9 +29,7 @@
|
|
|
30
29
|
"build": "babel src --out-dir . --ignore '**/__tests__','**/__mocks__'",
|
|
31
30
|
"watch": "babel -w src --out-dir . --ignore '**/__tests__','**/__mocks__'"
|
|
32
31
|
},
|
|
33
|
-
"peerDependencies": {
|
|
34
|
-
"medusa-interfaces": "^1.3.4"
|
|
35
|
-
},
|
|
32
|
+
"peerDependencies": {},
|
|
36
33
|
"dependencies": {
|
|
37
34
|
"@aws-sdk/client-ses": "^3.241.0",
|
|
38
35
|
"@babel/plugin-transform-classes": "^7.9.5",
|
package/services/ses.js
CHANGED
|
@@ -331,19 +331,19 @@ var SESService = /*#__PURE__*/function (_NotificationService) {
|
|
|
331
331
|
}
|
|
332
332
|
return _context4.abrupt("return", false);
|
|
333
333
|
case 3:
|
|
334
|
-
|
|
335
|
-
templateId = this.getLocalizedTemplateId(event, data.locale) || templateId;
|
|
336
|
-
}
|
|
337
|
-
_context4.next = 6;
|
|
334
|
+
_context4.next = 5;
|
|
338
335
|
return this.fetchData(event, eventData, attachmentGenerator);
|
|
339
|
-
case
|
|
336
|
+
case 5:
|
|
340
337
|
data = _context4.sent;
|
|
341
338
|
if (data) {
|
|
342
|
-
_context4.next =
|
|
339
|
+
_context4.next = 8;
|
|
343
340
|
break;
|
|
344
341
|
}
|
|
345
342
|
return _context4.abrupt("return", false);
|
|
346
|
-
case
|
|
343
|
+
case 8:
|
|
344
|
+
if (data.locale) {
|
|
345
|
+
templateId = this.getLocalizedTemplateId(event, data.locale) || templateId;
|
|
346
|
+
}
|
|
347
347
|
_context4.next = 11;
|
|
348
348
|
return this.compileTemplate(templateId, data);
|
|
349
349
|
case 11:
|
|
@@ -369,7 +369,6 @@ var SESService = /*#__PURE__*/function (_NotificationService) {
|
|
|
369
369
|
case 20:
|
|
370
370
|
attachments = _context4.sent;
|
|
371
371
|
if (attachments !== null && attachments !== void 0 && attachments.length) {
|
|
372
|
-
sendOptions.has_attachments = true;
|
|
373
372
|
sendOptions.attachments = attachments.map(function (a) {
|
|
374
373
|
return {
|
|
375
374
|
content: a.base64,
|
package/.babelrc
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"plugins": [
|
|
3
|
-
"@babel/plugin-proposal-class-properties",
|
|
4
|
-
"@babel/plugin-transform-instanceof",
|
|
5
|
-
"@babel/plugin-transform-classes"
|
|
6
|
-
],
|
|
7
|
-
"presets": ["@babel/preset-env"],
|
|
8
|
-
"env": {
|
|
9
|
-
"test": {
|
|
10
|
-
"plugins": ["@babel/plugin-transform-runtime"]
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
package/jest.config.js
DELETED
package/src/api/index.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Router } from "express"
|
|
2
|
-
import bodyParser from "body-parser"
|
|
3
|
-
import { Validator, MedusaError } from "medusa-core-utils"
|
|
4
|
-
|
|
5
|
-
const router = Router()
|
|
6
|
-
|
|
7
|
-
export default (app) => {
|
|
8
|
-
router.use(bodyParser.json())
|
|
9
|
-
|
|
10
|
-
router.post("/ses/send",(req, res) => {
|
|
11
|
-
const sesService = req.scope.resolve("sesService")
|
|
12
|
-
|
|
13
|
-
const schema = Validator.object().keys({
|
|
14
|
-
template_id: Validator.string().required(),
|
|
15
|
-
from: Validator.string().required(),
|
|
16
|
-
to: Validator.string().required(),
|
|
17
|
-
data: Validator.object().optional().default({}),
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
const { value, error } = schema.validate(req.body)
|
|
21
|
-
if (error) {
|
|
22
|
-
throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
sesService.sendEmail(value.template_id, value.from, value.to, value.data).then((result) => {
|
|
26
|
-
return res.json({
|
|
27
|
-
result
|
|
28
|
-
})
|
|
29
|
-
})
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
return router
|
|
33
|
-
}
|