@allthings/cloud-toolkit 2.1.0 → 2.2.0-dev.2

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/dist/lib.cjs.js CHANGED
@@ -313,32 +313,40 @@ const DEFAULT_CLIENT_CONFIG = {
313
313
  clientConfig: { region: 'eu-west-1' },
314
314
  };
315
315
  const sendMail = async (config, transport, options, from) => {
316
- if (!options.html && !options.text) {
317
- if (config.logger) {
318
- config.logger.error('The option text or html needs to be set.');
316
+ try {
317
+ if (!options.html && !options.text) {
318
+ if (config.logger) {
319
+ config.logger.error('The option text or html needs to be set.');
320
+ }
321
+ return false;
319
322
  }
320
- return false;
321
- }
322
- if (!options.to || !options.subject) {
323
- if (config.logger) {
324
- config.logger.error('The fields to and subject have to be set.');
323
+ if (!options.to || !options.subject) {
324
+ if (config.logger) {
325
+ config.logger.error('The fields to and subject have to be set.');
326
+ }
327
+ return false;
325
328
  }
326
- return false;
327
- }
328
- const transportResponse = await transport.sendMail({
329
- from,
330
- ...options,
331
- });
332
- if (config.logger) {
333
- config.logger.info(`Transporter response: ${JSON.stringify(transportResponse)}`);
329
+ const transportResponse = await transport.sendMail({
330
+ from,
331
+ ...options,
332
+ });
333
+ if (config.responseCallback) {
334
+ await config.responseCallback(transportResponse);
335
+ }
336
+ if (!transportResponse) {
337
+ if (config.logger) {
338
+ config.logger.error('Sending email failed!');
339
+ }
340
+ return false;
341
+ }
342
+ return true;
334
343
  }
335
- if (!transportResponse) {
344
+ catch (error) {
336
345
  if (config.logger) {
337
- config.logger.error('Sending email failed!');
346
+ config.logger.error(error);
338
347
  }
339
348
  return false;
340
349
  }
341
- return true;
342
350
  };
343
351
  const ses = (fromEmailAddress, userConfig) => {
344
352
  const { clientConfig, ...config } = {
package/dist/lib.esm.js CHANGED
@@ -293,32 +293,40 @@ const DEFAULT_CLIENT_CONFIG = {
293
293
  clientConfig: { region: 'eu-west-1' },
294
294
  };
295
295
  const sendMail = async (config, transport, options, from) => {
296
- if (!options.html && !options.text) {
297
- if (config.logger) {
298
- config.logger.error('The option text or html needs to be set.');
296
+ try {
297
+ if (!options.html && !options.text) {
298
+ if (config.logger) {
299
+ config.logger.error('The option text or html needs to be set.');
300
+ }
301
+ return false;
299
302
  }
300
- return false;
301
- }
302
- if (!options.to || !options.subject) {
303
- if (config.logger) {
304
- config.logger.error('The fields to and subject have to be set.');
303
+ if (!options.to || !options.subject) {
304
+ if (config.logger) {
305
+ config.logger.error('The fields to and subject have to be set.');
306
+ }
307
+ return false;
305
308
  }
306
- return false;
307
- }
308
- const transportResponse = await transport.sendMail({
309
- from,
310
- ...options,
311
- });
312
- if (config.logger) {
313
- config.logger.info(`Transporter response: ${JSON.stringify(transportResponse)}`);
309
+ const transportResponse = await transport.sendMail({
310
+ from,
311
+ ...options,
312
+ });
313
+ if (config.responseCallback) {
314
+ await config.responseCallback(transportResponse);
315
+ }
316
+ if (!transportResponse) {
317
+ if (config.logger) {
318
+ config.logger.error('Sending email failed!');
319
+ }
320
+ return false;
321
+ }
322
+ return true;
314
323
  }
315
- if (!transportResponse) {
324
+ catch (error) {
316
325
  if (config.logger) {
317
- config.logger.error('Sending email failed!');
326
+ config.logger.error(error);
318
327
  }
319
328
  return false;
320
329
  }
321
- return true;
322
330
  };
323
331
  const ses = (fromEmailAddress, userConfig) => {
324
332
  const { clientConfig, ...config } = {