medusa-plugin-ses 2.0.6 → 2.0.7

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.
Files changed (2) hide show
  1. package/api/index.js +12 -11
  2. package/package.json +5 -5
package/api/index.js CHANGED
@@ -7,25 +7,26 @@ exports["default"] = void 0;
7
7
  var _express = require("express");
8
8
  var _bodyParser = _interopRequireDefault(require("body-parser"));
9
9
  var _medusaCoreUtils = require("medusa-core-utils");
10
+ var _zod = require("zod");
10
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
12
  var router = (0, _express.Router)();
12
13
  var _default = function _default(app) {
13
14
  router.use(_bodyParser["default"].json());
14
15
  router.post("/ses/send", function (req, res) {
15
16
  var sesService = req.scope.resolve("sesService");
16
- var schema = _medusaCoreUtils.Validator.object().keys({
17
- template_id: _medusaCoreUtils.Validator.string().required(),
18
- from: _medusaCoreUtils.Validator.string().required(),
19
- to: _medusaCoreUtils.Validator.string().required(),
20
- data: _medusaCoreUtils.Validator.object().optional()["default"]({})
17
+ var schema = _zod.z.object({
18
+ template_id: _zod.z.string().min(1),
19
+ from: _zod.z.string().min(1),
20
+ to: _zod.z.string().min(1),
21
+ data: _zod.z.object({}).required()["default"]({})
21
22
  });
22
- var _schema$validate = schema.validate(req.body),
23
- value = _schema$validate.value,
24
- error = _schema$validate.error;
25
- if (error) {
26
- throw new _medusaCoreUtils.MedusaError(_medusaCoreUtils.MedusaError.Types.INVALID_DATA, error.details);
23
+ var _schema$safeParse = schema.safeParse(req.body),
24
+ success = _schema$safeParse.success,
25
+ error = _schema$safeParse.error;
26
+ if (!success) {
27
+ throw new _medusaCoreUtils.MedusaError(_medusaCoreUtils.MedusaError.Types.INVALID_DATA, error);
27
28
  }
28
- sesService.sendEmail(value.template_id, value.from, value.to, value.data).then(function (result) {
29
+ sesService.sendEmail(req.body.template_id, req.body.from, req.body.to, req.body.data).then(function (result) {
29
30
  return res.json({
30
31
  result: result
31
32
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "medusa-plugin-ses",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": "AWS SES transactional emails using local handlebars templates",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -19,13 +19,12 @@
19
19
  "@babel/preset-env": "^7.7.5",
20
20
  "@babel/register": "^7.7.4",
21
21
  "@babel/runtime": "^7.9.6",
22
+ "awilix": "^8.0.0",
22
23
  "client-sessions": "^0.8.0",
23
24
  "cross-env": "^5.2.1",
24
25
  "jest": "^25.5.2",
25
- "medusa-interfaces": "^1.3.7",
26
26
  "medusa-core-utils": "^1.2.0",
27
- "medusa-test-utils": "^1.1.40",
28
- "awilix": "^8.0.0"
27
+ "medusa-test-utils": "^1.1.40"
29
28
  },
30
29
  "scripts": {
31
30
  "prepare": "cross-env NODE_ENV=production yarn run build",
@@ -45,7 +44,8 @@
45
44
  "fs": "^0.0.1-security",
46
45
  "handlebars": "^4.7.7",
47
46
  "nodemailer": "^6.9.1",
48
- "path": "^0.12.7"
47
+ "path": "^0.12.7",
48
+ "zod": "^3.21.4"
49
49
  },
50
50
  "gitHead": "3bbd1e8507e00bc471de6ae3c30207999a4a4011",
51
51
  "keywords": [