Comparing version 1.2.0 to 1.2.1
@@ -7,5 +7,305 @@ 'use strict'; | ||
var _regeneratorRuntime = _interopDefault(require('regenerator-runtime')); | ||
var Pino = _interopDefault(require('pino')); | ||
function _regeneratorRuntime() { | ||
_regeneratorRuntime = function () { | ||
return exports; | ||
}; | ||
var exports = {}, | ||
Op = Object.prototype, | ||
hasOwn = Op.hasOwnProperty, | ||
defineProperty = Object.defineProperty || function (obj, key, desc) { | ||
obj[key] = desc.value; | ||
}, | ||
$Symbol = "function" == typeof Symbol ? Symbol : {}, | ||
iteratorSymbol = $Symbol.iterator || "@@iterator", | ||
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", | ||
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; | ||
function define(obj, key, value) { | ||
return Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0 | ||
}), obj[key]; | ||
} | ||
try { | ||
define({}, ""); | ||
} catch (err) { | ||
define = function (obj, key, value) { | ||
return obj[key] = value; | ||
}; | ||
} | ||
function wrap(innerFn, outerFn, self, tryLocsList) { | ||
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, | ||
generator = Object.create(protoGenerator.prototype), | ||
context = new Context(tryLocsList || []); | ||
return defineProperty(generator, "_invoke", { | ||
value: makeInvokeMethod(innerFn, self, context) | ||
}), generator; | ||
} | ||
function tryCatch(fn, obj, arg) { | ||
try { | ||
return { | ||
type: "normal", | ||
arg: fn.call(obj, arg) | ||
}; | ||
} catch (err) { | ||
return { | ||
type: "throw", | ||
arg: err | ||
}; | ||
} | ||
} | ||
exports.wrap = wrap; | ||
var ContinueSentinel = {}; | ||
function Generator() {} | ||
function GeneratorFunction() {} | ||
function GeneratorFunctionPrototype() {} | ||
var IteratorPrototype = {}; | ||
define(IteratorPrototype, iteratorSymbol, function () { | ||
return this; | ||
}); | ||
var getProto = Object.getPrototypeOf, | ||
NativeIteratorPrototype = getProto && getProto(getProto(values([]))); | ||
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); | ||
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); | ||
function defineIteratorMethods(prototype) { | ||
["next", "throw", "return"].forEach(function (method) { | ||
define(prototype, method, function (arg) { | ||
return this._invoke(method, arg); | ||
}); | ||
}); | ||
} | ||
function AsyncIterator(generator, PromiseImpl) { | ||
function invoke(method, arg, resolve, reject) { | ||
var record = tryCatch(generator[method], generator, arg); | ||
if ("throw" !== record.type) { | ||
var result = record.arg, | ||
value = result.value; | ||
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { | ||
invoke("next", value, resolve, reject); | ||
}, function (err) { | ||
invoke("throw", err, resolve, reject); | ||
}) : PromiseImpl.resolve(value).then(function (unwrapped) { | ||
result.value = unwrapped, resolve(result); | ||
}, function (error) { | ||
return invoke("throw", error, resolve, reject); | ||
}); | ||
} | ||
reject(record.arg); | ||
} | ||
var previousPromise; | ||
defineProperty(this, "_invoke", { | ||
value: function (method, arg) { | ||
function callInvokeWithMethodAndArg() { | ||
return new PromiseImpl(function (resolve, reject) { | ||
invoke(method, arg, resolve, reject); | ||
}); | ||
} | ||
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); | ||
} | ||
}); | ||
} | ||
function makeInvokeMethod(innerFn, self, context) { | ||
var state = "suspendedStart"; | ||
return function (method, arg) { | ||
if ("executing" === state) throw new Error("Generator is already running"); | ||
if ("completed" === state) { | ||
if ("throw" === method) throw arg; | ||
return doneResult(); | ||
} | ||
for (context.method = method, context.arg = arg;;) { | ||
var delegate = context.delegate; | ||
if (delegate) { | ||
var delegateResult = maybeInvokeDelegate(delegate, context); | ||
if (delegateResult) { | ||
if (delegateResult === ContinueSentinel) continue; | ||
return delegateResult; | ||
} | ||
} | ||
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { | ||
if ("suspendedStart" === state) throw state = "completed", context.arg; | ||
context.dispatchException(context.arg); | ||
} else "return" === context.method && context.abrupt("return", context.arg); | ||
state = "executing"; | ||
var record = tryCatch(innerFn, self, context); | ||
if ("normal" === record.type) { | ||
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; | ||
return { | ||
value: record.arg, | ||
done: context.done | ||
}; | ||
} | ||
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); | ||
} | ||
}; | ||
} | ||
function maybeInvokeDelegate(delegate, context) { | ||
var methodName = context.method, | ||
method = delegate.iterator[methodName]; | ||
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; | ||
var record = tryCatch(method, delegate.iterator, context.arg); | ||
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; | ||
var info = record.arg; | ||
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); | ||
} | ||
function pushTryEntry(locs) { | ||
var entry = { | ||
tryLoc: locs[0] | ||
}; | ||
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); | ||
} | ||
function resetTryEntry(entry) { | ||
var record = entry.completion || {}; | ||
record.type = "normal", delete record.arg, entry.completion = record; | ||
} | ||
function Context(tryLocsList) { | ||
this.tryEntries = [{ | ||
tryLoc: "root" | ||
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); | ||
} | ||
function values(iterable) { | ||
if (iterable) { | ||
var iteratorMethod = iterable[iteratorSymbol]; | ||
if (iteratorMethod) return iteratorMethod.call(iterable); | ||
if ("function" == typeof iterable.next) return iterable; | ||
if (!isNaN(iterable.length)) { | ||
var i = -1, | ||
next = function next() { | ||
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; | ||
return next.value = undefined, next.done = !0, next; | ||
}; | ||
return next.next = next; | ||
} | ||
} | ||
return { | ||
next: doneResult | ||
}; | ||
} | ||
function doneResult() { | ||
return { | ||
value: undefined, | ||
done: !0 | ||
}; | ||
} | ||
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { | ||
value: GeneratorFunctionPrototype, | ||
configurable: !0 | ||
}), defineProperty(GeneratorFunctionPrototype, "constructor", { | ||
value: GeneratorFunction, | ||
configurable: !0 | ||
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { | ||
var ctor = "function" == typeof genFun && genFun.constructor; | ||
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); | ||
}, exports.mark = function (genFun) { | ||
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; | ||
}, exports.awrap = function (arg) { | ||
return { | ||
__await: arg | ||
}; | ||
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { | ||
return this; | ||
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { | ||
void 0 === PromiseImpl && (PromiseImpl = Promise); | ||
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); | ||
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { | ||
return result.done ? result.value : iter.next(); | ||
}); | ||
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { | ||
return this; | ||
}), define(Gp, "toString", function () { | ||
return "[object Generator]"; | ||
}), exports.keys = function (val) { | ||
var object = Object(val), | ||
keys = []; | ||
for (var key in object) keys.push(key); | ||
return keys.reverse(), function next() { | ||
for (; keys.length;) { | ||
var key = keys.pop(); | ||
if (key in object) return next.value = key, next.done = !1, next; | ||
} | ||
return next.done = !0, next; | ||
}; | ||
}, exports.values = values, Context.prototype = { | ||
constructor: Context, | ||
reset: function (skipTempReset) { | ||
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); | ||
}, | ||
stop: function () { | ||
this.done = !0; | ||
var rootRecord = this.tryEntries[0].completion; | ||
if ("throw" === rootRecord.type) throw rootRecord.arg; | ||
return this.rval; | ||
}, | ||
dispatchException: function (exception) { | ||
if (this.done) throw exception; | ||
var context = this; | ||
function handle(loc, caught) { | ||
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; | ||
} | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i], | ||
record = entry.completion; | ||
if ("root" === entry.tryLoc) return handle("end"); | ||
if (entry.tryLoc <= this.prev) { | ||
var hasCatch = hasOwn.call(entry, "catchLoc"), | ||
hasFinally = hasOwn.call(entry, "finallyLoc"); | ||
if (hasCatch && hasFinally) { | ||
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); | ||
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); | ||
} else if (hasCatch) { | ||
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); | ||
} else { | ||
if (!hasFinally) throw new Error("try statement without catch or finally"); | ||
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); | ||
} | ||
} | ||
} | ||
}, | ||
abrupt: function (type, arg) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { | ||
var finallyEntry = entry; | ||
break; | ||
} | ||
} | ||
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); | ||
var record = finallyEntry ? finallyEntry.completion : {}; | ||
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); | ||
}, | ||
complete: function (record, afterLoc) { | ||
if ("throw" === record.type) throw record.arg; | ||
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; | ||
}, | ||
finish: function (finallyLoc) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; | ||
} | ||
}, | ||
catch: function (tryLoc) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.tryLoc === tryLoc) { | ||
var record = entry.completion; | ||
if ("throw" === record.type) { | ||
var thrown = record.arg; | ||
resetTryEntry(entry); | ||
} | ||
return thrown; | ||
} | ||
} | ||
throw new Error("illegal catch attempt"); | ||
}, | ||
delegateYield: function (iterable, resultName, nextLoc) { | ||
return this.delegate = { | ||
iterator: values(iterable), | ||
resultName: resultName, | ||
nextLoc: nextLoc | ||
}, "next" === this.method && (this.arg = undefined), ContinueSentinel; | ||
} | ||
}, exports; | ||
} | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
@@ -19,3 +319,2 @@ try { | ||
} | ||
if (info.done) { | ||
@@ -27,18 +326,14 @@ resolve(value); | ||
} | ||
function _asyncToGenerator(fn) { | ||
return function () { | ||
var self = this, | ||
args = arguments; | ||
args = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
} | ||
function _throw(err) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
} | ||
_next(undefined); | ||
@@ -49,3 +344,4 @@ }); | ||
var SendimTransportInterface = // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function | ||
var SendimTransportInterface = | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function | ||
function SendimTransportInterface(_config) {}; | ||
@@ -59,179 +355,138 @@ var Sendim = /*#__PURE__*/function () { | ||
} | ||
var _proto = Sendim.prototype; | ||
_proto.addTransport = /*#__PURE__*/function () { | ||
var _addTransport = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(transport, config, transportName) { | ||
var _addTransport = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(transport, config, transportName) { | ||
var newTransport; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
//@ts-ignore | ||
newTransport = new transport(config); | ||
_context.next = 3; | ||
return newTransport.isHealthy(); | ||
case 3: | ||
if (_context.sent) { | ||
_context.next = 6; | ||
break; | ||
} | ||
this.logger.error("[SENDIM] Transport " + newTransport.providerName + " is not healthy !"); | ||
throw 'Transport is not healthy !'; | ||
case 6: | ||
if (!this.transports[transportName || newTransport.providerName]) { | ||
_context.next = 9; | ||
break; | ||
} | ||
this.logger.error("[SAVIM] Provider " + (transportName || newTransport.providerName) + " is not healthy !"); | ||
throw 'Provider already exist !'; | ||
case 9: | ||
this.transports[newTransport.providerName] = newTransport; | ||
case 10: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
//@ts-ignore | ||
newTransport = new transport(config); | ||
_context.next = 3; | ||
return newTransport.isHealthy(); | ||
case 3: | ||
if (_context.sent) { | ||
_context.next = 6; | ||
break; | ||
} | ||
this.logger.error("[SENDIM] Transport " + newTransport.providerName + " is not healthy !"); | ||
throw 'Transport is not healthy !'; | ||
case 6: | ||
if (!this.transports[transportName || newTransport.providerName]) { | ||
_context.next = 9; | ||
break; | ||
} | ||
this.logger.error("[SAVIM] Provider " + (transportName || newTransport.providerName) + " is not healthy !"); | ||
throw 'Provider already exist !'; | ||
case 9: | ||
this.transports[newTransport.providerName] = newTransport; | ||
case 10: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee, this); | ||
})); | ||
function addTransport(_x, _x2, _x3) { | ||
return _addTransport.apply(this, arguments); | ||
} | ||
return addTransport; | ||
}(); | ||
_proto.removeTransport = /*#__PURE__*/function () { | ||
var _removeTransport = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(transportName) { | ||
return _regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
if (this.transports[transportName]) { | ||
delete this.transports[transportName]; | ||
} | ||
case 1: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
var _removeTransport = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(transportName) { | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) switch (_context2.prev = _context2.next) { | ||
case 0: | ||
if (this.transports[transportName]) { | ||
delete this.transports[transportName]; | ||
} | ||
case 1: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
}, _callee2, this); | ||
})); | ||
function removeTransport(_x4) { | ||
return _removeTransport.apply(this, arguments); | ||
} | ||
return removeTransport; | ||
}(); | ||
_proto.sendRawMail = /*#__PURE__*/function () { | ||
var _sendRawMail = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(options, transportName) { | ||
var _sendRawMail = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(options, transportName) { | ||
var transportKeys, transport; | ||
return _regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
transportKeys = Object.keys(this.transports); | ||
if (transportName && this.transports[transportName]) { | ||
transport = this.transports[transportName]; | ||
} //@ts-ignore | ||
if (!transport && (transportKeys == null ? void 0 : transportKeys.length) > 0) { | ||
transport = this.transports[transportKeys[0]]; | ||
} //@ts-ignore | ||
if (transport) { | ||
_context3.next = 8; | ||
break; | ||
} | ||
this.logger.debug("[SENDIM] Send raw email"); | ||
this.logger.debug(options); | ||
_context3.next = 12; | ||
return _regeneratorRuntime().wrap(function _callee3$(_context3) { | ||
while (1) switch (_context3.prev = _context3.next) { | ||
case 0: | ||
transportKeys = Object.keys(this.transports); | ||
if (transportName && this.transports[transportName]) { | ||
transport = this.transports[transportName]; | ||
} | ||
//@ts-ignore | ||
if (!transport && (transportKeys == null ? void 0 : transportKeys.length) > 0) { | ||
transport = this.transports[transportKeys[0]]; | ||
} | ||
//@ts-ignore | ||
if (transport) { | ||
_context3.next = 8; | ||
break; | ||
case 8: | ||
this.logger.debug("[SENDIM] Send raw email (Transport: " + transport.providerName + ") "); | ||
this.logger.debug(options); | ||
_context3.next = 12; | ||
return transport.sendRawMail(options); | ||
case 12: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
this.logger.debug("[SENDIM] Send raw email"); | ||
this.logger.debug(options); | ||
_context3.next = 12; | ||
break; | ||
case 8: | ||
this.logger.debug("[SENDIM] Send raw email (Transport: " + transport.providerName + ") "); | ||
this.logger.debug(options); | ||
_context3.next = 12; | ||
return transport.sendRawMail(options); | ||
case 12: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
}, _callee3, this); | ||
})); | ||
function sendRawMail(_x5, _x6) { | ||
return _sendRawMail.apply(this, arguments); | ||
} | ||
return sendRawMail; | ||
}(); | ||
_proto.sendTransactionalMail = /*#__PURE__*/function () { | ||
var _sendTransactionalMail = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(options, transportName) { | ||
var _sendTransactionalMail = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options, transportName) { | ||
var transportKeys, transport; | ||
return _regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
transportKeys = Object.keys(this.transports); | ||
if (transportName && this.transports[transportName]) { | ||
transport = this.transports[transportName]; | ||
} //@ts-ignore | ||
if (!transport && (transportKeys == null ? void 0 : transportKeys.length) > 0) { | ||
transport = this.transports[transportKeys[0]]; | ||
} //@ts-ignore | ||
if (transport) { | ||
_context4.next = 8; | ||
break; | ||
} | ||
this.logger.debug("[SENDIM] Send transactional email (Template: " + options.templateId + ")"); | ||
this.logger.debug(options); | ||
_context4.next = 12; | ||
return _regeneratorRuntime().wrap(function _callee4$(_context4) { | ||
while (1) switch (_context4.prev = _context4.next) { | ||
case 0: | ||
transportKeys = Object.keys(this.transports); | ||
if (transportName && this.transports[transportName]) { | ||
transport = this.transports[transportName]; | ||
} | ||
//@ts-ignore | ||
if (!transport && (transportKeys == null ? void 0 : transportKeys.length) > 0) { | ||
transport = this.transports[transportKeys[0]]; | ||
} | ||
//@ts-ignore | ||
if (transport) { | ||
_context4.next = 8; | ||
break; | ||
case 8: | ||
this.logger.debug("[SENDIM] Send transactional email (Template: " + options.templateId + " / Transport: " + transport.providerName + ") "); | ||
this.logger.debug(options); | ||
_context4.next = 12; | ||
return transport.sendTransactionalMail(options); | ||
case 12: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
} | ||
this.logger.debug("[SENDIM] Send transactional email (Template: " + options.templateId + ")"); | ||
this.logger.debug(options); | ||
_context4.next = 12; | ||
break; | ||
case 8: | ||
this.logger.debug("[SENDIM] Send transactional email (Template: " + options.templateId + " / Transport: " + transport.providerName + ") "); | ||
this.logger.debug(options); | ||
_context4.next = 12; | ||
return transport.sendTransactionalMail(options); | ||
case 12: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
}, _callee4, this); | ||
})); | ||
function sendTransactionalMail(_x7, _x8) { | ||
return _sendTransactionalMail.apply(this, arguments); | ||
} | ||
return sendTransactionalMail; | ||
}(); | ||
return Sendim; | ||
@@ -238,0 +493,0 @@ }(); |
@@ -1,2 +0,2 @@ | ||
"use strict";function r(r){return r&&"object"==typeof r&&"default"in r?r.default:r}Object.defineProperty(exports,"__esModule",{value:!0});var t=r(require("regenerator-runtime")),e=r(require("pino"));function n(r,t,e,n,a,s,i){try{var o=r[s](i),u=o.value}catch(r){return void e(r)}o.done?t(u):Promise.resolve(u).then(n,a)}function a(r){return function(){var t=this,e=arguments;return new Promise((function(a,s){var i=r.apply(t,e);function o(r){n(i,a,s,o,u,"next",r)}function u(r){n(i,a,s,o,u,"throw",r)}o(void 0)}))}}exports.Sendim=function(){function r(r){this.transports={},this.logger=e({level:r||"info"})}var n=r.prototype;return n.addTransport=function(){var r=a(t.mark((function r(e,n,a){var s;return t.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return s=new e(n),r.next=3,s.isHealthy();case 3:if(r.sent){r.next=6;break}throw this.logger.error("[SENDIM] Transport "+s.providerName+" is not healthy !"),"Transport is not healthy !";case 6:if(!this.transports[a||s.providerName]){r.next=9;break}throw this.logger.error("[SAVIM] Provider "+(a||s.providerName)+" is not healthy !"),"Provider already exist !";case 9:this.transports[s.providerName]=s;case 10:case"end":return r.stop()}}),r,this)})));return function(t,e,n){return r.apply(this,arguments)}}(),n.removeTransport=function(){var r=a(t.mark((function r(e){return t.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:this.transports[e]&&delete this.transports[e];case 1:case"end":return r.stop()}}),r,this)})));return function(t){return r.apply(this,arguments)}}(),n.sendRawMail=function(){var r=a(t.mark((function r(e,n){var a,s;return t.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=Object.keys(this.transports),n&&this.transports[n]&&(s=this.transports[n]),!s&&(null==a?void 0:a.length)>0&&(s=this.transports[a[0]]),s){r.next=8;break}this.logger.debug("[SENDIM] Send raw email"),this.logger.debug(e),r.next=12;break;case 8:return this.logger.debug("[SENDIM] Send raw email (Transport: "+s.providerName+") "),this.logger.debug(e),r.next=12,s.sendRawMail(e);case 12:case"end":return r.stop()}}),r,this)})));return function(t,e){return r.apply(this,arguments)}}(),n.sendTransactionalMail=function(){var r=a(t.mark((function r(e,n){var a,s;return t.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=Object.keys(this.transports),n&&this.transports[n]&&(s=this.transports[n]),!s&&(null==a?void 0:a.length)>0&&(s=this.transports[a[0]]),s){r.next=8;break}this.logger.debug("[SENDIM] Send transactional email (Template: "+e.templateId+")"),this.logger.debug(e),r.next=12;break;case 8:return this.logger.debug("[SENDIM] Send transactional email (Template: "+e.templateId+" / Transport: "+s.providerName+") "),this.logger.debug(e),r.next=12,s.sendTransactionalMail(e);case 12:case"end":return r.stop()}}),r,this)})));return function(t,e){return r.apply(this,arguments)}}(),r}(),exports.SendimTransportInterface=function(r){}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,r=(t=require("pino"))&&"object"==typeof t&&"default"in t?t.default:t;function e(){e=function(){return t};var t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,r,e){t[r]=e.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{u({},"")}catch(t){u=function(t,r,e){return t[r]=e}}function h(t,r,e,n){var i=Object.create((r&&r.prototype instanceof p?r:p).prototype),a=new S(n||[]);return o(i,"_invoke",{value:L(t,e,a)}),i}function l(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=h;var f={};function p(){}function d(){}function v(){}var y={};u(y,a,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(j([])));m&&m!==r&&n.call(m,a)&&(y=m);var w=v.prototype=p.prototype=Object.create(y);function x(t){["next","throw","return"].forEach((function(r){u(t,r,(function(t){return this._invoke(r,t)}))}))}function b(t,r){var e;o(this,"_invoke",{value:function(o,i){function a(){return new r((function(e,a){!function e(o,i,a,c){var s=l(t[o],t,i);if("throw"!==s.type){var u=s.arg,h=u.value;return h&&"object"==typeof h&&n.call(h,"__await")?r.resolve(h.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):r.resolve(h).then((function(t){u.value=t,a(u)}),(function(t){return e("throw",t,a,c)}))}c(s.arg)}(o,i,e,a)}))}return e=e?e.then(a,a):a()}})}function L(t,r,e){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(e.method=o,e.arg=i;;){var a=e.delegate;if(a){var c=E(a,e);if(c){if(c===f)continue;return c}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===n)throw n="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n="executing";var s=l(t,r,e);if("normal"===s.type){if(n=e.done?"completed":"suspendedYield",s.arg===f)continue;return{value:s.arg,done:e.done}}"throw"===s.type&&(n="completed",e.method="throw",e.arg=s.arg)}}}function E(t,r){var e=r.method,n=t.iterator[e];if(void 0===n)return r.delegate=null,"throw"===e&&t.iterator.return&&(r.method="return",r.arg=void 0,E(t,r),"throw"===r.method)||"return"!==e&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+e+"' method")),f;var o=l(n,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,f;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,f):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,f)}function k(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function N(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function j(t){if(t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var e=-1,o=function r(){for(;++e<t.length;)if(n.call(t,e))return r.value=t[e],r.done=!1,r;return r.value=void 0,r.done=!0,r};return o.next=o}}return{next:O}}function O(){return{value:void 0,done:!0}}return d.prototype=v,o(w,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:d,configurable:!0}),d.displayName=u(v,s,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===d||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,u(t,s,"GeneratorFunction")),t.prototype=Object.create(w),t},t.awrap=function(t){return{__await:t}},x(b.prototype),u(b.prototype,c,(function(){return this})),t.AsyncIterator=b,t.async=function(r,e,n,o,i){void 0===i&&(i=Promise);var a=new b(h(r,e,n,o),i);return t.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},x(w),u(w,s,"Generator"),u(w,a,(function(){return this})),u(w,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=j,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(N),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function e(e,n){return a.type="throw",a.arg=t,r.next=e,n&&(r.method="next",r.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return e("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return e(i.catchLoc,!0);if(this.prev<i.finallyLoc)return e(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return e(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return e(i.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),f},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),N(e),f}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;N(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:j(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=void 0),f}},t}function n(t,r,e,n,o,i,a){try{var c=t[i](a),s=c.value}catch(t){return void e(t)}c.done?r(s):Promise.resolve(s).then(n,o)}function o(t){return function(){var r=this,e=arguments;return new Promise((function(o,i){var a=t.apply(r,e);function c(t){n(a,o,i,c,s,"next",t)}function s(t){n(a,o,i,c,s,"throw",t)}c(void 0)}))}}exports.Sendim=function(){function t(t){this.transports={},this.logger=r({level:t||"info"})}var n=t.prototype;return n.addTransport=function(){var t=o(e().mark((function t(r,n,o){var i;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=new r(n),t.next=3,i.isHealthy();case 3:if(t.sent){t.next=6;break}throw this.logger.error("[SENDIM] Transport "+i.providerName+" is not healthy !"),"Transport is not healthy !";case 6:if(!this.transports[o||i.providerName]){t.next=9;break}throw this.logger.error("[SAVIM] Provider "+(o||i.providerName)+" is not healthy !"),"Provider already exist !";case 9:this.transports[i.providerName]=i;case 10:case"end":return t.stop()}}),t,this)})));return function(r,e,n){return t.apply(this,arguments)}}(),n.removeTransport=function(){var t=o(e().mark((function t(r){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.transports[r]&&delete this.transports[r];case 1:case"end":return t.stop()}}),t,this)})));return function(r){return t.apply(this,arguments)}}(),n.sendRawMail=function(){var t=o(e().mark((function t(r,n){var o,i;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=Object.keys(this.transports),n&&this.transports[n]&&(i=this.transports[n]),!i&&(null==o?void 0:o.length)>0&&(i=this.transports[o[0]]),i){t.next=8;break}this.logger.debug("[SENDIM] Send raw email"),this.logger.debug(r),t.next=12;break;case 8:return this.logger.debug("[SENDIM] Send raw email (Transport: "+i.providerName+") "),this.logger.debug(r),t.next=12,i.sendRawMail(r);case 12:case"end":return t.stop()}}),t,this)})));return function(r,e){return t.apply(this,arguments)}}(),n.sendTransactionalMail=function(){var t=o(e().mark((function t(r,n){var o,i;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=Object.keys(this.transports),n&&this.transports[n]&&(i=this.transports[n]),!i&&(null==o?void 0:o.length)>0&&(i=this.transports[o[0]]),i){t.next=8;break}this.logger.debug("[SENDIM] Send transactional email (Template: "+r.templateId+")"),this.logger.debug(r),t.next=12;break;case 8:return this.logger.debug("[SENDIM] Send transactional email (Template: "+r.templateId+" / Transport: "+i.providerName+") "),this.logger.debug(r),t.next=12,i.sendTransactionalMail(r);case 12:case"end":return t.stop()}}),t,this)})));return function(r,e){return t.apply(this,arguments)}}(),t}(),exports.SendimTransportInterface=function(t){}; | ||
//# sourceMappingURL=sendim.cjs.production.min.js.map |
@@ -1,4 +0,304 @@ | ||
import _regeneratorRuntime from 'regenerator-runtime'; | ||
import Pino from 'pino'; | ||
function _regeneratorRuntime() { | ||
_regeneratorRuntime = function () { | ||
return exports; | ||
}; | ||
var exports = {}, | ||
Op = Object.prototype, | ||
hasOwn = Op.hasOwnProperty, | ||
defineProperty = Object.defineProperty || function (obj, key, desc) { | ||
obj[key] = desc.value; | ||
}, | ||
$Symbol = "function" == typeof Symbol ? Symbol : {}, | ||
iteratorSymbol = $Symbol.iterator || "@@iterator", | ||
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", | ||
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; | ||
function define(obj, key, value) { | ||
return Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0 | ||
}), obj[key]; | ||
} | ||
try { | ||
define({}, ""); | ||
} catch (err) { | ||
define = function (obj, key, value) { | ||
return obj[key] = value; | ||
}; | ||
} | ||
function wrap(innerFn, outerFn, self, tryLocsList) { | ||
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, | ||
generator = Object.create(protoGenerator.prototype), | ||
context = new Context(tryLocsList || []); | ||
return defineProperty(generator, "_invoke", { | ||
value: makeInvokeMethod(innerFn, self, context) | ||
}), generator; | ||
} | ||
function tryCatch(fn, obj, arg) { | ||
try { | ||
return { | ||
type: "normal", | ||
arg: fn.call(obj, arg) | ||
}; | ||
} catch (err) { | ||
return { | ||
type: "throw", | ||
arg: err | ||
}; | ||
} | ||
} | ||
exports.wrap = wrap; | ||
var ContinueSentinel = {}; | ||
function Generator() {} | ||
function GeneratorFunction() {} | ||
function GeneratorFunctionPrototype() {} | ||
var IteratorPrototype = {}; | ||
define(IteratorPrototype, iteratorSymbol, function () { | ||
return this; | ||
}); | ||
var getProto = Object.getPrototypeOf, | ||
NativeIteratorPrototype = getProto && getProto(getProto(values([]))); | ||
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); | ||
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); | ||
function defineIteratorMethods(prototype) { | ||
["next", "throw", "return"].forEach(function (method) { | ||
define(prototype, method, function (arg) { | ||
return this._invoke(method, arg); | ||
}); | ||
}); | ||
} | ||
function AsyncIterator(generator, PromiseImpl) { | ||
function invoke(method, arg, resolve, reject) { | ||
var record = tryCatch(generator[method], generator, arg); | ||
if ("throw" !== record.type) { | ||
var result = record.arg, | ||
value = result.value; | ||
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { | ||
invoke("next", value, resolve, reject); | ||
}, function (err) { | ||
invoke("throw", err, resolve, reject); | ||
}) : PromiseImpl.resolve(value).then(function (unwrapped) { | ||
result.value = unwrapped, resolve(result); | ||
}, function (error) { | ||
return invoke("throw", error, resolve, reject); | ||
}); | ||
} | ||
reject(record.arg); | ||
} | ||
var previousPromise; | ||
defineProperty(this, "_invoke", { | ||
value: function (method, arg) { | ||
function callInvokeWithMethodAndArg() { | ||
return new PromiseImpl(function (resolve, reject) { | ||
invoke(method, arg, resolve, reject); | ||
}); | ||
} | ||
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); | ||
} | ||
}); | ||
} | ||
function makeInvokeMethod(innerFn, self, context) { | ||
var state = "suspendedStart"; | ||
return function (method, arg) { | ||
if ("executing" === state) throw new Error("Generator is already running"); | ||
if ("completed" === state) { | ||
if ("throw" === method) throw arg; | ||
return doneResult(); | ||
} | ||
for (context.method = method, context.arg = arg;;) { | ||
var delegate = context.delegate; | ||
if (delegate) { | ||
var delegateResult = maybeInvokeDelegate(delegate, context); | ||
if (delegateResult) { | ||
if (delegateResult === ContinueSentinel) continue; | ||
return delegateResult; | ||
} | ||
} | ||
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { | ||
if ("suspendedStart" === state) throw state = "completed", context.arg; | ||
context.dispatchException(context.arg); | ||
} else "return" === context.method && context.abrupt("return", context.arg); | ||
state = "executing"; | ||
var record = tryCatch(innerFn, self, context); | ||
if ("normal" === record.type) { | ||
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; | ||
return { | ||
value: record.arg, | ||
done: context.done | ||
}; | ||
} | ||
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); | ||
} | ||
}; | ||
} | ||
function maybeInvokeDelegate(delegate, context) { | ||
var methodName = context.method, | ||
method = delegate.iterator[methodName]; | ||
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; | ||
var record = tryCatch(method, delegate.iterator, context.arg); | ||
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; | ||
var info = record.arg; | ||
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); | ||
} | ||
function pushTryEntry(locs) { | ||
var entry = { | ||
tryLoc: locs[0] | ||
}; | ||
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); | ||
} | ||
function resetTryEntry(entry) { | ||
var record = entry.completion || {}; | ||
record.type = "normal", delete record.arg, entry.completion = record; | ||
} | ||
function Context(tryLocsList) { | ||
this.tryEntries = [{ | ||
tryLoc: "root" | ||
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); | ||
} | ||
function values(iterable) { | ||
if (iterable) { | ||
var iteratorMethod = iterable[iteratorSymbol]; | ||
if (iteratorMethod) return iteratorMethod.call(iterable); | ||
if ("function" == typeof iterable.next) return iterable; | ||
if (!isNaN(iterable.length)) { | ||
var i = -1, | ||
next = function next() { | ||
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; | ||
return next.value = undefined, next.done = !0, next; | ||
}; | ||
return next.next = next; | ||
} | ||
} | ||
return { | ||
next: doneResult | ||
}; | ||
} | ||
function doneResult() { | ||
return { | ||
value: undefined, | ||
done: !0 | ||
}; | ||
} | ||
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { | ||
value: GeneratorFunctionPrototype, | ||
configurable: !0 | ||
}), defineProperty(GeneratorFunctionPrototype, "constructor", { | ||
value: GeneratorFunction, | ||
configurable: !0 | ||
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { | ||
var ctor = "function" == typeof genFun && genFun.constructor; | ||
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); | ||
}, exports.mark = function (genFun) { | ||
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; | ||
}, exports.awrap = function (arg) { | ||
return { | ||
__await: arg | ||
}; | ||
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { | ||
return this; | ||
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { | ||
void 0 === PromiseImpl && (PromiseImpl = Promise); | ||
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); | ||
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { | ||
return result.done ? result.value : iter.next(); | ||
}); | ||
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { | ||
return this; | ||
}), define(Gp, "toString", function () { | ||
return "[object Generator]"; | ||
}), exports.keys = function (val) { | ||
var object = Object(val), | ||
keys = []; | ||
for (var key in object) keys.push(key); | ||
return keys.reverse(), function next() { | ||
for (; keys.length;) { | ||
var key = keys.pop(); | ||
if (key in object) return next.value = key, next.done = !1, next; | ||
} | ||
return next.done = !0, next; | ||
}; | ||
}, exports.values = values, Context.prototype = { | ||
constructor: Context, | ||
reset: function (skipTempReset) { | ||
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); | ||
}, | ||
stop: function () { | ||
this.done = !0; | ||
var rootRecord = this.tryEntries[0].completion; | ||
if ("throw" === rootRecord.type) throw rootRecord.arg; | ||
return this.rval; | ||
}, | ||
dispatchException: function (exception) { | ||
if (this.done) throw exception; | ||
var context = this; | ||
function handle(loc, caught) { | ||
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; | ||
} | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i], | ||
record = entry.completion; | ||
if ("root" === entry.tryLoc) return handle("end"); | ||
if (entry.tryLoc <= this.prev) { | ||
var hasCatch = hasOwn.call(entry, "catchLoc"), | ||
hasFinally = hasOwn.call(entry, "finallyLoc"); | ||
if (hasCatch && hasFinally) { | ||
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); | ||
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); | ||
} else if (hasCatch) { | ||
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); | ||
} else { | ||
if (!hasFinally) throw new Error("try statement without catch or finally"); | ||
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); | ||
} | ||
} | ||
} | ||
}, | ||
abrupt: function (type, arg) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { | ||
var finallyEntry = entry; | ||
break; | ||
} | ||
} | ||
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); | ||
var record = finallyEntry ? finallyEntry.completion : {}; | ||
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); | ||
}, | ||
complete: function (record, afterLoc) { | ||
if ("throw" === record.type) throw record.arg; | ||
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; | ||
}, | ||
finish: function (finallyLoc) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; | ||
} | ||
}, | ||
catch: function (tryLoc) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.tryLoc === tryLoc) { | ||
var record = entry.completion; | ||
if ("throw" === record.type) { | ||
var thrown = record.arg; | ||
resetTryEntry(entry); | ||
} | ||
return thrown; | ||
} | ||
} | ||
throw new Error("illegal catch attempt"); | ||
}, | ||
delegateYield: function (iterable, resultName, nextLoc) { | ||
return this.delegate = { | ||
iterator: values(iterable), | ||
resultName: resultName, | ||
nextLoc: nextLoc | ||
}, "next" === this.method && (this.arg = undefined), ContinueSentinel; | ||
} | ||
}, exports; | ||
} | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
@@ -12,3 +312,2 @@ try { | ||
} | ||
if (info.done) { | ||
@@ -20,18 +319,14 @@ resolve(value); | ||
} | ||
function _asyncToGenerator(fn) { | ||
return function () { | ||
var self = this, | ||
args = arguments; | ||
args = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
} | ||
function _throw(err) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
} | ||
_next(undefined); | ||
@@ -42,3 +337,4 @@ }); | ||
var SendimTransportInterface = // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function | ||
var SendimTransportInterface = | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function | ||
function SendimTransportInterface(_config) {}; | ||
@@ -52,179 +348,138 @@ var Sendim = /*#__PURE__*/function () { | ||
} | ||
var _proto = Sendim.prototype; | ||
_proto.addTransport = /*#__PURE__*/function () { | ||
var _addTransport = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(transport, config, transportName) { | ||
var _addTransport = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(transport, config, transportName) { | ||
var newTransport; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
//@ts-ignore | ||
newTransport = new transport(config); | ||
_context.next = 3; | ||
return newTransport.isHealthy(); | ||
case 3: | ||
if (_context.sent) { | ||
_context.next = 6; | ||
break; | ||
} | ||
this.logger.error("[SENDIM] Transport " + newTransport.providerName + " is not healthy !"); | ||
throw 'Transport is not healthy !'; | ||
case 6: | ||
if (!this.transports[transportName || newTransport.providerName]) { | ||
_context.next = 9; | ||
break; | ||
} | ||
this.logger.error("[SAVIM] Provider " + (transportName || newTransport.providerName) + " is not healthy !"); | ||
throw 'Provider already exist !'; | ||
case 9: | ||
this.transports[newTransport.providerName] = newTransport; | ||
case 10: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
//@ts-ignore | ||
newTransport = new transport(config); | ||
_context.next = 3; | ||
return newTransport.isHealthy(); | ||
case 3: | ||
if (_context.sent) { | ||
_context.next = 6; | ||
break; | ||
} | ||
this.logger.error("[SENDIM] Transport " + newTransport.providerName + " is not healthy !"); | ||
throw 'Transport is not healthy !'; | ||
case 6: | ||
if (!this.transports[transportName || newTransport.providerName]) { | ||
_context.next = 9; | ||
break; | ||
} | ||
this.logger.error("[SAVIM] Provider " + (transportName || newTransport.providerName) + " is not healthy !"); | ||
throw 'Provider already exist !'; | ||
case 9: | ||
this.transports[newTransport.providerName] = newTransport; | ||
case 10: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee, this); | ||
})); | ||
function addTransport(_x, _x2, _x3) { | ||
return _addTransport.apply(this, arguments); | ||
} | ||
return addTransport; | ||
}(); | ||
_proto.removeTransport = /*#__PURE__*/function () { | ||
var _removeTransport = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(transportName) { | ||
return _regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
if (this.transports[transportName]) { | ||
delete this.transports[transportName]; | ||
} | ||
case 1: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
var _removeTransport = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(transportName) { | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) switch (_context2.prev = _context2.next) { | ||
case 0: | ||
if (this.transports[transportName]) { | ||
delete this.transports[transportName]; | ||
} | ||
case 1: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
}, _callee2, this); | ||
})); | ||
function removeTransport(_x4) { | ||
return _removeTransport.apply(this, arguments); | ||
} | ||
return removeTransport; | ||
}(); | ||
_proto.sendRawMail = /*#__PURE__*/function () { | ||
var _sendRawMail = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(options, transportName) { | ||
var _sendRawMail = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(options, transportName) { | ||
var transportKeys, transport; | ||
return _regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
transportKeys = Object.keys(this.transports); | ||
if (transportName && this.transports[transportName]) { | ||
transport = this.transports[transportName]; | ||
} //@ts-ignore | ||
if (!transport && (transportKeys == null ? void 0 : transportKeys.length) > 0) { | ||
transport = this.transports[transportKeys[0]]; | ||
} //@ts-ignore | ||
if (transport) { | ||
_context3.next = 8; | ||
break; | ||
} | ||
this.logger.debug("[SENDIM] Send raw email"); | ||
this.logger.debug(options); | ||
_context3.next = 12; | ||
return _regeneratorRuntime().wrap(function _callee3$(_context3) { | ||
while (1) switch (_context3.prev = _context3.next) { | ||
case 0: | ||
transportKeys = Object.keys(this.transports); | ||
if (transportName && this.transports[transportName]) { | ||
transport = this.transports[transportName]; | ||
} | ||
//@ts-ignore | ||
if (!transport && (transportKeys == null ? void 0 : transportKeys.length) > 0) { | ||
transport = this.transports[transportKeys[0]]; | ||
} | ||
//@ts-ignore | ||
if (transport) { | ||
_context3.next = 8; | ||
break; | ||
case 8: | ||
this.logger.debug("[SENDIM] Send raw email (Transport: " + transport.providerName + ") "); | ||
this.logger.debug(options); | ||
_context3.next = 12; | ||
return transport.sendRawMail(options); | ||
case 12: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
this.logger.debug("[SENDIM] Send raw email"); | ||
this.logger.debug(options); | ||
_context3.next = 12; | ||
break; | ||
case 8: | ||
this.logger.debug("[SENDIM] Send raw email (Transport: " + transport.providerName + ") "); | ||
this.logger.debug(options); | ||
_context3.next = 12; | ||
return transport.sendRawMail(options); | ||
case 12: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
}, _callee3, this); | ||
})); | ||
function sendRawMail(_x5, _x6) { | ||
return _sendRawMail.apply(this, arguments); | ||
} | ||
return sendRawMail; | ||
}(); | ||
_proto.sendTransactionalMail = /*#__PURE__*/function () { | ||
var _sendTransactionalMail = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(options, transportName) { | ||
var _sendTransactionalMail = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options, transportName) { | ||
var transportKeys, transport; | ||
return _regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
transportKeys = Object.keys(this.transports); | ||
if (transportName && this.transports[transportName]) { | ||
transport = this.transports[transportName]; | ||
} //@ts-ignore | ||
if (!transport && (transportKeys == null ? void 0 : transportKeys.length) > 0) { | ||
transport = this.transports[transportKeys[0]]; | ||
} //@ts-ignore | ||
if (transport) { | ||
_context4.next = 8; | ||
break; | ||
} | ||
this.logger.debug("[SENDIM] Send transactional email (Template: " + options.templateId + ")"); | ||
this.logger.debug(options); | ||
_context4.next = 12; | ||
return _regeneratorRuntime().wrap(function _callee4$(_context4) { | ||
while (1) switch (_context4.prev = _context4.next) { | ||
case 0: | ||
transportKeys = Object.keys(this.transports); | ||
if (transportName && this.transports[transportName]) { | ||
transport = this.transports[transportName]; | ||
} | ||
//@ts-ignore | ||
if (!transport && (transportKeys == null ? void 0 : transportKeys.length) > 0) { | ||
transport = this.transports[transportKeys[0]]; | ||
} | ||
//@ts-ignore | ||
if (transport) { | ||
_context4.next = 8; | ||
break; | ||
case 8: | ||
this.logger.debug("[SENDIM] Send transactional email (Template: " + options.templateId + " / Transport: " + transport.providerName + ") "); | ||
this.logger.debug(options); | ||
_context4.next = 12; | ||
return transport.sendTransactionalMail(options); | ||
case 12: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
} | ||
this.logger.debug("[SENDIM] Send transactional email (Template: " + options.templateId + ")"); | ||
this.logger.debug(options); | ||
_context4.next = 12; | ||
break; | ||
case 8: | ||
this.logger.debug("[SENDIM] Send transactional email (Template: " + options.templateId + " / Transport: " + transport.providerName + ") "); | ||
this.logger.debug(options); | ||
_context4.next = 12; | ||
return transport.sendTransactionalMail(options); | ||
case 12: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
}, _callee4, this); | ||
})); | ||
function sendTransactionalMail(_x7, _x8) { | ||
return _sendTransactionalMail.apply(this, arguments); | ||
} | ||
return sendTransactionalMail; | ||
}(); | ||
return Sendim; | ||
@@ -231,0 +486,0 @@ }(); |
{ | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"license": "MIT", | ||
@@ -67,4 +67,4 @@ "main": "dist/index.js", | ||
"@types/jest": "^29.5.0", | ||
"@typescript-eslint/eslint-plugin": "5.58.0", | ||
"@typescript-eslint/parser": "5.58.0", | ||
"@typescript-eslint/eslint-plugin": "5.59.0", | ||
"@typescript-eslint/parser": "5.59.0", | ||
"eslint": "8.38.0", | ||
@@ -71,0 +71,0 @@ "eslint-config-prettier": "8.8.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
86591
1182
0