@things-factory/integration-email 9.1.19 → 10.0.0-beta.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const nodemailer = tslib_1.__importStar(require("nodemailer"));
|
|
5
|
-
require("ses");
|
|
6
5
|
const integration_base_1 = require("@things-factory/integration-base");
|
|
7
6
|
const debug = require('debug')('things-factory:email-send');
|
|
8
7
|
async function emailSend(step, { logger, domain, data, lng, variables }) {
|
|
@@ -22,21 +21,14 @@ async function emailSend(step, { logger, domain, data, lng, variables }) {
|
|
|
22
21
|
pass
|
|
23
22
|
}
|
|
24
23
|
});
|
|
25
|
-
const
|
|
26
|
-
domain,
|
|
27
|
-
user,
|
|
28
|
-
lng,
|
|
29
|
-
data,
|
|
30
|
-
variables,
|
|
31
|
-
console
|
|
32
|
-
});
|
|
24
|
+
const scope = { domain, user, lng, data, variables, console };
|
|
33
25
|
let evalFrom, evalTo, evalSubject, evalContents, evalHtml;
|
|
34
26
|
try {
|
|
35
|
-
evalFrom =
|
|
36
|
-
evalTo =
|
|
37
|
-
evalSubject =
|
|
38
|
-
evalContents =
|
|
39
|
-
evalHtml =
|
|
27
|
+
evalFrom = (0, integration_base_1.evaluateTemplate)(from, scope);
|
|
28
|
+
evalTo = (0, integration_base_1.evaluateTemplate)(to, scope);
|
|
29
|
+
evalSubject = (0, integration_base_1.evaluateTemplate)(subject, scope);
|
|
30
|
+
evalContents = (0, integration_base_1.evaluateTemplate)(contents, scope);
|
|
31
|
+
evalHtml = (0, integration_base_1.evaluateTemplate)(html, scope);
|
|
40
32
|
}
|
|
41
33
|
catch (err) {
|
|
42
34
|
throw new Error(`Failed to evaluate template: ${err.message}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-send.js","sourceRoot":"","sources":["../../../server/engine/task/email-send.ts"],"names":[],"mappings":";;;AAAA,+DAAwC;AACxC,
|
|
1
|
+
{"version":3,"file":"email-send.js","sourceRoot":"","sources":["../../../server/engine/task/email-send.ts"],"names":[],"mappings":";;;AAAA,+DAAwC;AACxC,uEAAoG;AAEpG,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,2BAA2B,CAAC,CAAA;AAE3D,KAAK,UAAU,SAAS,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE;IACrE,MAAM,EACJ,UAAU,EACV,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,EAC9C,GAAG,IAAI,CAAA;IAER,MAAM,MAAM,GAAG,MAAM,oCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IACtF,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,KAAK,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAA;QACtC,MAAM,IAAI,KAAK,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAA;IAClD,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,GAAG,CAAC,uBAAuB,EAAE,MAAM,GAAG,KAAK,CAAC,0BAA0B,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,MAAM,CAAA;IAElH,MAAM,WAAW,GAAG,UAAU,CAAC,eAAe,CAAC;QAC7C,IAAI;QACJ,IAAI;QACJ,MAAM;QACN,IAAI,EAAE;YACJ,IAAI;YACJ,IAAI;SACL;KACF,CAAC,CAAA;IAEF,MAAM,KAAK,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAA;IAE7D,IAAI,QAAQ,EAAE,MAAM,EAAE,WA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E,GAAG;SACV;KACF;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,YAAY;QACnB,QAAQ,EAAE;YACR,QAAQ,EAAE,MAAM;YAChB,eAAe,EAAE,IAAI;SACtB;QACD,MAAM,EAAE;YACN,IAAI,EAAE,GAAG;SACV;KACF;CACF,CAAA;AAED,SAAS,CAAC,IAAI,GAAG,6BAA6B,CAAA;AAE9C,+BAAY,CAAC,mBAAmB,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA","sourcesContent":["import * as nodemailer from 'nodemailer'\nimport { ConnectionManager, TaskRegistry, evaluateTemplate } from '@things-factory/integration-base'\n\nconst debug = require('debug')('things-factory:email-send')\n\nasync function emailSend(step, { logger, domain, data, lng, variables }) {\n const {\n connection,\n params: { from, to, subject, contents, html }\n } = step\n\n const client = await ConnectionManager.getConnectionInstanceByName(domain, connection)\n if (!client) {\n debug(`no connection : ${connection}`)\n throw new Error(`no connection : ${connection}`)\n }\n\n const { host, port = 587 /* SSL은 465 TLS는 587 */, secure = false /* SSL은 true TLS는 false */, user, pass } = client\n\n const transporter = nodemailer.createTransport({\n host,\n port,\n secure,\n auth: {\n user,\n pass\n }\n })\n\n const scope = { domain, user, lng, data, variables, console }\n\n let evalFrom, evalTo, evalSubject, evalContents, evalHtml\n try {\n evalFrom = evaluateTemplate(from, scope)\n evalTo = evaluateTemplate(to, scope)\n evalSubject = evaluateTemplate(subject, scope)\n evalContents = evaluateTemplate(contents, scope)\n evalHtml = evaluateTemplate(html, scope)\n } catch (err) {\n throw new Error(`Failed to evaluate template: ${err.message}`)\n }\n\n const info = await transporter.sendMail({\n from: evalFrom,\n to: evalTo,\n subject: evalSubject,\n text: evalContents,\n html: evalHtml\n })\n\n return {\n data: info\n }\n}\n\nemailSend.parameterSpec = [\n {\n type: 'string',\n name: 'from',\n label: 'email.from'\n },\n {\n type: 'string',\n name: 'to',\n label: 'email.to'\n },\n {\n type: 'string',\n name: 'subject',\n label: 'email.subject'\n },\n {\n type: 'textarea',\n name: 'contents',\n label: 'email.contents',\n property: {\n language: 'text',\n showLineNumbers: true\n },\n styles: {\n flex: '1'\n }\n },\n {\n type: 'textarea',\n name: 'html',\n label: 'email.html',\n property: {\n language: 'text',\n showLineNumbers: true\n },\n styles: {\n flex: '1'\n }\n }\n]\n\nemailSend.help = 'integration/task/email-send'\n\nTaskRegistry.registerTaskHandler('email-send', emailSend)\n"]}
|