medusa-plugin-ses 2.0.1 → 2.0.3

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 CHANGED
@@ -56,7 +56,7 @@ SES_TEMPLATE_PATH="/full/absolute/path/to/medusa-server/data/templates"
56
56
 
57
57
  - The SES_FROM email address must be a verified sender in your AWS account.
58
58
 
59
- - The template path is the relative path from the medusa-server root folder. For example, create a 'data/templates' folder and make 'data/templates' the SES_TEMPLATE_PATH variable.
59
+ - The template path must be the full absolute path to the folder. For example, if your build runs from /home/medusa/medusa-server/, create a 'data/templates' folder and include the entire path in the SES_TEMPLATE_PATH variable.
60
60
  ```
61
61
  medusa-server // root directory
62
62
  |-data
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "medusa-plugin-ses",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "AWS SES transactional emails using local handlebars templates",
5
5
  "main": "index.js",
6
6
  "repository": {
package/services/ses.js CHANGED
@@ -295,8 +295,8 @@ var SESService = /*#__PURE__*/function (_NotificationService) {
295
295
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
296
296
  while (1) switch (_context3.prev = _context3.next) {
297
297
  case 0:
298
- base = _path["default"].resolve(__dirname, '../../../', this.options_.template_path, templateId); // The absolute path below is useful when using yarn link or npm link
299
- //const base = path.resolve(this.options_.template_path, templateId)
298
+ //const base = path.resolve(__dirname, '../../../', this.options_.template_path, templateId)
299
+ base = _path["default"].resolve(this.options_.template_path, templateId);
300
300
  subjectTemplate = _handlebars["default"].compile(_fs["default"].readFileSync(_path["default"].join(base, 'subject.hbs'), "utf8"));
301
301
  htmlTemplate = _handlebars["default"].compile(_fs["default"].readFileSync(_path["default"].join(base, 'html.hbs'), "utf8"));
302
302
  textTemplate = _handlebars["default"].compile(_fs["default"].readFileSync(_path["default"].join(base, 'text.hbs'), "utf8"));
@@ -364,10 +364,9 @@ var SESService = /*#__PURE__*/function (_NotificationService) {
364
364
  html: html,
365
365
  text: text
366
366
  };
367
- console.log(sendOptions);
368
- _context4.next = 21;
367
+ _context4.next = 20;
369
368
  return this.fetchAttachments(event, data, attachmentGenerator);
370
- case 21:
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 = 25;
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 25:
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 27:
399
+ case 26:
401
400
  case "end":
402
401
  return _context4.stop();
403
402
  }
@@ -227,9 +227,8 @@ class SESService extends NotificationService {
227
227
  }
228
228
 
229
229
  async compileTemplate(templateId, data) {
230
- const base = path.resolve(__dirname, '../../../', this.options_.template_path, templateId)
231
- // The absolute path below is useful when using yarn link or npm link
232
- //const base = path.resolve(this.options_.template_path, templateId)
230
+ //const base = path.resolve(__dirname, '../../../', this.options_.template_path, templateId)
231
+ const base = path.resolve(this.options_.template_path, templateId)
233
232
  const subjectTemplate = Handlebars.compile(fs.readFileSync(path.join(base, 'subject.hbs'), "utf8"))
234
233
  const htmlTemplate = Handlebars.compile(fs.readFileSync(path.join(base, 'html.hbs'), "utf8"))
235
234
  const textTemplate = Handlebars.compile(fs.readFileSync(path.join(base, 'text.hbs'), "utf8"))
@@ -260,7 +259,6 @@ class SESService extends NotificationService {
260
259
  html,
261
260
  text
262
261
  }
263
- console.log(sendOptions)
264
262
 
265
263
  const attachments = await this.fetchAttachments(
266
264
  event,