medusa-plugin-ses 2.0.2 → 2.0.4
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 +1 -1
- package/services/ses.js +5 -6
- package/.babelrc +0 -13
- package/jest.config.js +0 -3
- package/src/api/index.js +0 -33
- package/src/services/ses.js +0 -1291
- 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
package/services/ses.js
CHANGED
|
@@ -364,10 +364,9 @@ var SESService = /*#__PURE__*/function (_NotificationService) {
|
|
|
364
364
|
html: html,
|
|
365
365
|
text: text
|
|
366
366
|
};
|
|
367
|
-
|
|
368
|
-
_context4.next = 21;
|
|
367
|
+
_context4.next = 20;
|
|
369
368
|
return this.fetchAttachments(event, data, attachmentGenerator);
|
|
370
|
-
case
|
|
369
|
+
case 20:
|
|
371
370
|
attachments = _context4.sent;
|
|
372
371
|
if (attachments !== null && attachments !== void 0 && attachments.length) {
|
|
373
372
|
sendOptions.has_attachments = true;
|
|
@@ -382,14 +381,14 @@ var SESService = /*#__PURE__*/function (_NotificationService) {
|
|
|
382
381
|
}
|
|
383
382
|
|
|
384
383
|
//const status = await this.transporter_.sendMail(sendOptions).then(() => "sent").catch(() => "failed")
|
|
385
|
-
_context4.next =
|
|
384
|
+
_context4.next = 24;
|
|
386
385
|
return this.transporter_.sendMail(sendOptions).then(function () {
|
|
387
386
|
status = "sent";
|
|
388
387
|
})["catch"](function (error) {
|
|
389
388
|
status = "failed";
|
|
390
389
|
console.log(error);
|
|
391
390
|
});
|
|
392
|
-
case
|
|
391
|
+
case 24:
|
|
393
392
|
// We don't want heavy docs stored in DB
|
|
394
393
|
delete sendOptions.attachments;
|
|
395
394
|
return _context4.abrupt("return", {
|
|
@@ -397,7 +396,7 @@ var SESService = /*#__PURE__*/function (_NotificationService) {
|
|
|
397
396
|
status: status,
|
|
398
397
|
data: sendOptions
|
|
399
398
|
});
|
|
400
|
-
case
|
|
399
|
+
case 26:
|
|
401
400
|
case "end":
|
|
402
401
|
return _context4.stop();
|
|
403
402
|
}
|
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
|
-
}
|