@teleporthq/teleport-plugin-next-workflows 0.44.9 → 0.44.10
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/__tests__/ai-error-contract.test.ts +10 -0
- package/__tests__/continue-on-error.test.ts +27 -0
- package/__tests__/email-node-recipients.test.ts +288 -0
- package/__tests__/sent-email-log-module.test.ts +54 -0
- package/dist/cjs/executor-generator.d.ts.map +1 -1
- package/dist/cjs/executor-generator.js +4 -1
- package/dist/cjs/executor-generator.js.map +1 -1
- package/dist/cjs/nodes/email/email-mailersend.d.ts.map +1 -1
- package/dist/cjs/nodes/email/email-mailersend.js +55 -48
- package/dist/cjs/nodes/email/email-mailersend.js.map +1 -1
- package/dist/cjs/nodes/email/email-mailgun.d.ts.map +1 -1
- package/dist/cjs/nodes/email/email-mailgun.js +44 -32
- package/dist/cjs/nodes/email/email-mailgun.js.map +1 -1
- package/dist/cjs/nodes/email/email-postmark.d.ts.map +1 -1
- package/dist/cjs/nodes/email/email-postmark.js +44 -31
- package/dist/cjs/nodes/email/email-postmark.js.map +1 -1
- package/dist/cjs/nodes/email/email-recipients.d.ts +28 -0
- package/dist/cjs/nodes/email/email-recipients.d.ts.map +1 -0
- package/dist/cjs/nodes/email/email-recipients.js +74 -0
- package/dist/cjs/nodes/email/email-recipients.js.map +1 -0
- package/dist/cjs/nodes/email/email-resend.d.ts.map +1 -1
- package/dist/cjs/nodes/email/email-resend.js +42 -28
- package/dist/cjs/nodes/email/email-resend.js.map +1 -1
- package/dist/cjs/nodes/email/email-sendgrid.d.ts.map +1 -1
- package/dist/cjs/nodes/email/email-sendgrid.js +56 -41
- package/dist/cjs/nodes/email/email-sendgrid.js.map +1 -1
- package/dist/cjs/sent-email-log/sent-email-log-code.d.ts.map +1 -1
- package/dist/cjs/sent-email-log/sent-email-log-code.js +17 -1
- package/dist/cjs/sent-email-log/sent-email-log-code.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/executor-generator.d.ts.map +1 -1
- package/dist/esm/executor-generator.js +4 -1
- package/dist/esm/executor-generator.js.map +1 -1
- package/dist/esm/nodes/email/email-mailersend.d.ts.map +1 -1
- package/dist/esm/nodes/email/email-mailersend.js +55 -48
- package/dist/esm/nodes/email/email-mailersend.js.map +1 -1
- package/dist/esm/nodes/email/email-mailgun.d.ts.map +1 -1
- package/dist/esm/nodes/email/email-mailgun.js +44 -32
- package/dist/esm/nodes/email/email-mailgun.js.map +1 -1
- package/dist/esm/nodes/email/email-postmark.d.ts.map +1 -1
- package/dist/esm/nodes/email/email-postmark.js +44 -31
- package/dist/esm/nodes/email/email-postmark.js.map +1 -1
- package/dist/esm/nodes/email/email-recipients.d.ts +28 -0
- package/dist/esm/nodes/email/email-recipients.d.ts.map +1 -0
- package/dist/esm/nodes/email/email-recipients.js +71 -0
- package/dist/esm/nodes/email/email-recipients.js.map +1 -0
- package/dist/esm/nodes/email/email-resend.d.ts.map +1 -1
- package/dist/esm/nodes/email/email-resend.js +42 -28
- package/dist/esm/nodes/email/email-resend.js.map +1 -1
- package/dist/esm/nodes/email/email-sendgrid.d.ts.map +1 -1
- package/dist/esm/nodes/email/email-sendgrid.js +56 -41
- package/dist/esm/nodes/email/email-sendgrid.js.map +1 -1
- package/dist/esm/sent-email-log/sent-email-log-code.d.ts.map +1 -1
- package/dist/esm/sent-email-log/sent-email-log-code.js +17 -1
- package/dist/esm/sent-email-log/sent-email-log-code.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/executor-generator.ts +4 -1
- package/src/nodes/email/email-mailersend.ts +72 -55
- package/src/nodes/email/email-mailgun.ts +51 -36
- package/src/nodes/email/email-postmark.ts +51 -35
- package/src/nodes/email/email-recipients.ts +86 -0
- package/src/nodes/email/email-resend.ts +49 -31
- package/src/nodes/email/email-sendgrid.ts +63 -44
- package/src/sent-email-log/sent-email-log-code.ts +17 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor-generator.d.ts","sourceRoot":"","sources":["../../src/executor-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAGlB,MAAM,gBAAgB,CAAA;AAKvB,MAAM,WAAW,yBAAyB;IACxC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,iBAAiB,CAAA;CACjC;AAID,eAAO,MAAM,8BAA8B,aAAa,yBAAyB,KAAQ,
|
|
1
|
+
{"version":3,"file":"executor-generator.d.ts","sourceRoot":"","sources":["../../src/executor-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAGlB,MAAM,gBAAgB,CAAA;AAKvB,MAAM,WAAW,yBAAyB;IACxC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,iBAAiB,CAAA;CACjC;AAID,eAAO,MAAM,8BAA8B,aAAa,yBAAyB,KAAQ,MAugDxF,CAAA;AAED,eAAO,MAAM,yBAAyB,QAAO,MA+nB5C,CAAA"}
|
|
@@ -876,9 +876,12 @@ async function settlePendingNodePromises(context) {
|
|
|
876
876
|
// ({ error: '...' } / { success: false }) or through the AI-node contract
|
|
877
877
|
// ({ error: true, message, code } — provider/auth failures). Both must halt
|
|
878
878
|
// the workflow; treating error:true as success used to let the pipeline limp
|
|
879
|
-
// into downstream NOT NULL violations.
|
|
879
|
+
// into downstream NOT NULL violations. A result that says success: true is
|
|
880
|
+
// the node's own verdict: an email node that reached some of its recipients
|
|
881
|
+
// reports success with the refused addresses under error, and goes on.
|
|
880
882
|
function isFatalNodeResult(result) {
|
|
881
883
|
if (!result) return false;
|
|
884
|
+
if (result.success === true) return false;
|
|
882
885
|
return result.success === false ||
|
|
883
886
|
(typeof result.error === 'string' && result.error) ||
|
|
884
887
|
result.error === true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor-generator.js","sourceRoot":"","sources":["../../src/executor-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,8BAA8B,EAC9B,iCAAiC,GAClC,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6nBR,CAAA;AACD,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-mailersend.d.ts","sourceRoot":"","sources":["../../../../src/nodes/email/email-mailersend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAmB,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"email-mailersend.d.ts","sourceRoot":"","sources":["../../../../src/nodes/email/email-mailersend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAmB,MAAM,UAAU,CAAA;AA4FhE,eAAO,MAAM,eAAe,EAAE,oBAY7B,CAAA"}
|
|
@@ -1,65 +1,72 @@
|
|
|
1
1
|
import { handlerToString } from '../types';
|
|
2
|
+
import { assertHandlerHasNoModuleRefs } from '../analytics/commerce-tracking';
|
|
3
|
+
import { EMAIL_RECIPIENTS_HELPER_SOURCE } from './email-recipients';
|
|
2
4
|
async function email_mailersend(config, context) {
|
|
3
5
|
const apiKey = config.apiKey;
|
|
4
6
|
const from = config.from;
|
|
5
7
|
const fromName = config.fromName || '';
|
|
6
|
-
const to = config.to;
|
|
7
8
|
const subject = config.subject;
|
|
8
9
|
const body = config.body;
|
|
9
10
|
const replyTo = config.replyTo;
|
|
10
11
|
const cc = config.cc;
|
|
11
12
|
const bcc = config.bcc;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
const recipients = __emailRecipients(config.to);
|
|
14
|
+
async function sendTo(to) {
|
|
15
|
+
try {
|
|
16
|
+
const __nodeRequire = typeof __non_webpack_require__ !== 'undefined' ? __non_webpack_require__ : require;
|
|
17
|
+
const mailersendPkg = __nodeRequire('mailersend');
|
|
18
|
+
const MailerSend = mailersendPkg.MailerSend;
|
|
19
|
+
const EmailParams = mailersendPkg.EmailParams;
|
|
20
|
+
const Sender = mailersendPkg.Sender;
|
|
21
|
+
const Recipient = mailersendPkg.Recipient;
|
|
22
|
+
const mailerSend = new MailerSend({ apiKey });
|
|
23
|
+
const sentFrom = new Sender(from, fromName);
|
|
24
|
+
const recipient = typeof to === 'object' && to.email
|
|
25
|
+
? new Recipient(to.email, to.name || '')
|
|
26
|
+
: new Recipient(to, '');
|
|
27
|
+
const emailParams = new EmailParams()
|
|
28
|
+
.setFrom(sentFrom)
|
|
29
|
+
.setTo([recipient])
|
|
30
|
+
.setSubject(subject)
|
|
31
|
+
.setHtml(body);
|
|
32
|
+
if (replyTo) {
|
|
33
|
+
emailParams.setReplyTo(new Sender(replyTo));
|
|
25
34
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
35
|
+
if (cc) {
|
|
36
|
+
const ccList = Array.isArray(cc) ? cc : [cc];
|
|
37
|
+
emailParams.setCc(ccList.map(function (email) {
|
|
38
|
+
return new Recipient(typeof email === 'object' ? email.email : email, '');
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
if (bcc) {
|
|
42
|
+
const bccList = Array.isArray(bcc) ? bcc : [bcc];
|
|
43
|
+
emailParams.setBcc(bccList.map(function (email) {
|
|
44
|
+
return new Recipient(typeof email === 'object' ? email.email : email, '');
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
const response = await mailerSend.email.send(emailParams);
|
|
48
|
+
const statusCode = response && response.statusCode;
|
|
49
|
+
if (statusCode === 202 || statusCode === 200) {
|
|
50
|
+
const messageId = (response.headers && response.headers['x-message-id']) || '';
|
|
51
|
+
return { messageId, success: true };
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
messageId: '',
|
|
55
|
+
success: false,
|
|
56
|
+
error: (response.body && response.body.message) || 'Failed to send email',
|
|
57
|
+
};
|
|
47
58
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (statusCode === 202 || statusCode === 200) {
|
|
51
|
-
const messageId = (response.headers && response.headers['x-message-id']) || '';
|
|
52
|
-
return { messageId, success: true };
|
|
59
|
+
catch (err) {
|
|
60
|
+
return { messageId: '', success: false, error: err.message };
|
|
53
61
|
}
|
|
54
|
-
return {
|
|
55
|
-
messageId: '',
|
|
56
|
-
success: false,
|
|
57
|
-
error: (response.body && response.body.message) || 'Failed to send email',
|
|
58
|
-
};
|
|
59
62
|
}
|
|
60
|
-
|
|
61
|
-
return { messageId: '', success: false, error:
|
|
63
|
+
if (recipients.length === 0) {
|
|
64
|
+
return { messageId: '', success: false, error: 'No recipient' };
|
|
65
|
+
}
|
|
66
|
+
if (recipients.length === 1) {
|
|
67
|
+
return sendTo(recipients[0]);
|
|
62
68
|
}
|
|
69
|
+
return __emailDeliveries({ recipients, send: sendTo, idKey: 'messageId' });
|
|
63
70
|
}
|
|
64
71
|
export const emailMailersend = {
|
|
65
72
|
nodeType: 'email-mailersend',
|
|
@@ -68,7 +75,7 @@ export const emailMailersend = {
|
|
|
68
75
|
mailersend: '^2.0.0',
|
|
69
76
|
},
|
|
70
77
|
generateHandler() {
|
|
71
|
-
return handlerToString(email_mailersend);
|
|
78
|
+
return assertHandlerHasNoModuleRefs(handlerToString(email_mailersend) + '\n' + EMAIL_RECIPIENTS_HELPER_SOURCE, 'email-mailersend');
|
|
72
79
|
},
|
|
73
80
|
};
|
|
74
81
|
//# sourceMappingURL=email-mailersend.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-mailersend.js","sourceRoot":"","sources":["../../../../src/nodes/email/email-mailersend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,eAAe,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"email-mailersend.js","sourceRoot":"","sources":["../../../../src/nodes/email/email-mailersend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAA;AAC7E,OAAO,EAAE,8BAA8B,EAAuB,MAAM,oBAAoB,CAAA;AAOxF,KAAK,UAAU,gBAAgB,CAAC,MAAW,EAAE,OAAgC;IAC3E,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;IAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;IACxB,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAA;IACtC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;IAC9B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;IACxB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;IAC9B,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,CAAA;IACpB,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAA;IACtB,MAAM,UAAU,GAAG,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAE/C,KAAK,UAAU,MAAM,CAAC,EAAO;QAC3B,IAAI;YACF,MAAM,aAAa,GACjB,OAAO,uBAAuB,KAAK,WAAW,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,OAAO,CAAA;YACpF,MAAM,aAAa,GAAG,aAAa,CAAC,YAAY,CAAC,CAAA;YACjD,MAAM,UAAU,GAAG,aAAa,CAAC,UAAU,CAAA;YAC3C,MAAM,WAAW,GAAG,aAAa,CAAC,WAAW,CAAA;YAC7C,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,C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C,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;KAC7B;IACD,OAAO,iBAAiB,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAA;AAC5E,CAAC;AACD,MAAM,CAAC,MAAM,eAAe,GAAyB;IACnD,QAAQ,EAAE,kBAAkB;IAC5B,YAAY,EAAE,QAAQ;IACtB,YAAY,EAAE;QACZ,UAAU,EAAE,QAAQ;KACrB;IACD,eAAe;QACb,OAAO,4BAA4B,CACjC,eAAe,CAAC,gBAAgB,CAAC,GAAG,IAAI,GAAG,8BAA8B,EACzE,kBAAkB,CACnB,CAAA;IACH,CAAC;CACF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-mailgun.d.ts","sourceRoot":"","sources":["../../../../src/nodes/email/email-mailgun.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAmB,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"email-mailgun.d.ts","sourceRoot":"","sources":["../../../../src/nodes/email/email-mailgun.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAmB,MAAM,UAAU,CAAA;AAuEhE,eAAO,MAAM,YAAY,EAAE,oBAiB1B,CAAA"}
|
|
@@ -1,51 +1,59 @@
|
|
|
1
1
|
import { EmailSender } from '@teleporthq/teleport-shared';
|
|
2
2
|
import { handlerToString } from '../types';
|
|
3
3
|
import { assertHandlerHasNoModuleRefs } from '../analytics/commerce-tracking';
|
|
4
|
+
import { EMAIL_RECIPIENTS_HELPER_SOURCE } from './email-recipients';
|
|
4
5
|
async function email_mailgun(config, context) {
|
|
5
6
|
const apiKey = config.apiKey;
|
|
6
7
|
const domain = config.domain;
|
|
7
8
|
const from = config.from;
|
|
8
9
|
const fromName = config.fromName || '';
|
|
9
|
-
const to = config.to;
|
|
10
10
|
const subject = config.subject;
|
|
11
11
|
const body = config.body;
|
|
12
12
|
const replyTo = config.replyTo;
|
|
13
13
|
const cc = config.cc;
|
|
14
14
|
const bcc = config.bcc;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
clientOpts
|
|
15
|
+
const recipients = __emailRecipients(config.to);
|
|
16
|
+
async function sendTo(to) {
|
|
17
|
+
try {
|
|
18
|
+
const __nodeRequire = typeof __non_webpack_require__ !== 'undefined' ? __non_webpack_require__ : require;
|
|
19
|
+
const Mailgun = __nodeRequire('mailgun.js');
|
|
20
|
+
const FormData = __nodeRequire('form-data');
|
|
21
|
+
const mailgun = new Mailgun(FormData);
|
|
22
|
+
const clientOpts = { username: 'api', key: apiKey };
|
|
23
|
+
if (config.region === 'eu') {
|
|
24
|
+
clientOpts.url = 'https://api.eu.mailgun.net';
|
|
25
|
+
}
|
|
26
|
+
const mg = mailgun.client(clientOpts);
|
|
27
|
+
const msgPayload = {
|
|
28
|
+
from: __emailSender({ from, name: fromName }).header,
|
|
29
|
+
to: [to],
|
|
30
|
+
subject,
|
|
31
|
+
html: body,
|
|
32
|
+
};
|
|
33
|
+
if (replyTo) {
|
|
34
|
+
msgPayload['h:Reply-To'] = replyTo;
|
|
35
|
+
}
|
|
36
|
+
if (cc) {
|
|
37
|
+
msgPayload.cc = Array.isArray(cc) ? cc.join(', ') : cc;
|
|
38
|
+
}
|
|
39
|
+
if (bcc) {
|
|
40
|
+
msgPayload.bcc = Array.isArray(bcc) ? bcc.join(', ') : bcc;
|
|
41
|
+
}
|
|
42
|
+
const result = await mg.messages.create(domain, msgPayload);
|
|
43
|
+
return { messageId: result.id || '', success: true };
|
|
23
44
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const msgPayload = {
|
|
28
|
-
from: fromField,
|
|
29
|
-
to: toField,
|
|
30
|
-
subject,
|
|
31
|
-
html: body,
|
|
32
|
-
};
|
|
33
|
-
if (replyTo) {
|
|
34
|
-
msgPayload['h:Reply-To'] = replyTo;
|
|
45
|
+
catch (err) {
|
|
46
|
+
const error = err;
|
|
47
|
+
return { messageId: '', success: false, error: error.message || 'Failed to send email' };
|
|
35
48
|
}
|
|
36
|
-
if (cc) {
|
|
37
|
-
msgPayload.cc = Array.isArray(cc) ? cc.join(', ') : cc;
|
|
38
|
-
}
|
|
39
|
-
if (bcc) {
|
|
40
|
-
msgPayload.bcc = Array.isArray(bcc) ? bcc.join(', ') : bcc;
|
|
41
|
-
}
|
|
42
|
-
const result = await mg.messages.create(domain, msgPayload);
|
|
43
|
-
return { messageId: result.id || '', success: true };
|
|
44
49
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
if (recipients.length === 0) {
|
|
51
|
+
return { messageId: '', success: false, error: 'No recipient' };
|
|
52
|
+
}
|
|
53
|
+
if (recipients.length === 1) {
|
|
54
|
+
return sendTo(recipients[0]);
|
|
48
55
|
}
|
|
56
|
+
return __emailDeliveries({ recipients, send: sendTo, idKey: 'messageId' });
|
|
49
57
|
}
|
|
50
58
|
export const emailMailgun = {
|
|
51
59
|
nodeType: 'email-mailgun',
|
|
@@ -55,7 +63,11 @@ export const emailMailgun = {
|
|
|
55
63
|
'form-data': '^4.0.0',
|
|
56
64
|
},
|
|
57
65
|
generateHandler() {
|
|
58
|
-
return assertHandlerHasNoModuleRefs(handlerToString(email_mailgun) +
|
|
66
|
+
return assertHandlerHasNoModuleRefs(handlerToString(email_mailgun) +
|
|
67
|
+
'\n' +
|
|
68
|
+
EmailSender.generateEmailSenderHelperCode() +
|
|
69
|
+
'\n' +
|
|
70
|
+
EMAIL_RECIPIENTS_HELPER_SOURCE, 'email-mailgun');
|
|
59
71
|
},
|
|
60
72
|
};
|
|
61
73
|
//# sourceMappingURL=email-mailgun.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-mailgun.js","sourceRoot":"","sources":["../../../../src/nodes/email/email-mailgun.ts"],"names":[],"mappings":"AAAA,OAAO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,MAAM,KAAK,GAAG,GAAU,CAAA;YACxB,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,IAAI,sBAAsB,EAAE,CAAA;SACzF;IACH,CAAC;IAED,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;QAC3B,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,CAAA;KAChE;IACD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;QAC3B,OAAO,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;KAC7B;IACD,OAAO,iBAAiB,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAA;AAC5E,CAAC;AACD,MAAM,CAAC,MAAM,YAAY,GAAyB;IAChD,QAAQ,EAAE,eAAe;IACzB,YAAY,EAAE,QAAQ;IACtB,YAAY,EAAE;QACZ,YAAY,EAAE,SAAS;QACvB,WAAW,EAAE,QAAQ;KACtB;IACD,eAAe;QACb,OAAO,4BAA4B,CACjC,eAAe,CAAC,aAAa,CAAC;YAC5B,IAAI;YACJ,WAAW,CAAC,6BAA6B,EAAE;YAC3C,IAAI;YACJ,8BAA8B,EAChC,eAAe,CAChB,CAAA;IACH,CAAC;CACF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-postmark.d.ts","sourceRoot":"","sources":["../../../../src/nodes/email/email-postmark.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAmB,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"email-postmark.d.ts","sourceRoot":"","sources":["../../../../src/nodes/email/email-postmark.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAmB,MAAM,UAAU,CAAA;AAuEhE,eAAO,MAAM,aAAa,EAAE,oBAgB3B,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { EmailSender } from '@teleporthq/teleport-shared';
|
|
2
2
|
import { handlerToString } from '../types';
|
|
3
3
|
import { assertHandlerHasNoModuleRefs } from '../analytics/commerce-tracking';
|
|
4
|
+
import { EMAIL_RECIPIENTS_HELPER_SOURCE } from './email-recipients';
|
|
4
5
|
async function email_postmark(config, context) {
|
|
5
6
|
const serverToken = config.serverToken;
|
|
6
7
|
const from = config.from;
|
|
7
8
|
const fromName = config.fromName;
|
|
8
|
-
const to = config.to;
|
|
9
9
|
const subject = config.subject;
|
|
10
10
|
const body = config.body;
|
|
11
11
|
const replyTo = config.replyTo;
|
|
@@ -13,39 +13,48 @@ async function email_postmark(config, context) {
|
|
|
13
13
|
const bcc = config.bcc;
|
|
14
14
|
const tag = config.tag;
|
|
15
15
|
const trackOpens = config.trackOpens;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
const recipients = __emailRecipients(config.to);
|
|
17
|
+
async function sendTo(to) {
|
|
18
|
+
try {
|
|
19
|
+
const __nodeRequire = typeof __non_webpack_require__ !== 'undefined' ? __non_webpack_require__ : require;
|
|
20
|
+
const postmark = __nodeRequire('postmark');
|
|
21
|
+
const client = new postmark.ServerClient(serverToken);
|
|
22
|
+
const emailPayload = {
|
|
23
|
+
From: __emailSender({ from, name: fromName }).header,
|
|
24
|
+
To: to,
|
|
25
|
+
Subject: subject,
|
|
26
|
+
HtmlBody: body,
|
|
27
|
+
};
|
|
28
|
+
if (replyTo) {
|
|
29
|
+
emailPayload.ReplyTo = replyTo;
|
|
30
|
+
}
|
|
31
|
+
if (cc) {
|
|
32
|
+
emailPayload.Cc = Array.isArray(cc) ? cc.join(', ') : cc;
|
|
33
|
+
}
|
|
34
|
+
if (bcc) {
|
|
35
|
+
emailPayload.Bcc = Array.isArray(bcc) ? bcc.join(', ') : bcc;
|
|
36
|
+
}
|
|
37
|
+
if (tag) {
|
|
38
|
+
emailPayload.Tag = tag;
|
|
39
|
+
}
|
|
40
|
+
if (trackOpens !== undefined) {
|
|
41
|
+
emailPayload.TrackOpens = trackOpens;
|
|
42
|
+
}
|
|
43
|
+
const result = await client.sendEmail(emailPayload);
|
|
44
|
+
return { messageId: result.MessageID || '', success: true };
|
|
29
45
|
}
|
|
30
|
-
|
|
31
|
-
|
|
46
|
+
catch (err) {
|
|
47
|
+
const error = err;
|
|
48
|
+
return { messageId: '', success: false, error: error.message || 'Failed to send email' };
|
|
32
49
|
}
|
|
33
|
-
if (bcc) {
|
|
34
|
-
emailPayload.Bcc = Array.isArray(bcc) ? bcc.join(', ') : bcc;
|
|
35
|
-
}
|
|
36
|
-
if (tag) {
|
|
37
|
-
emailPayload.Tag = tag;
|
|
38
|
-
}
|
|
39
|
-
if (trackOpens !== undefined) {
|
|
40
|
-
emailPayload.TrackOpens = trackOpens;
|
|
41
|
-
}
|
|
42
|
-
const result = await client.sendEmail(emailPayload);
|
|
43
|
-
return { messageId: result.MessageID || '', success: true };
|
|
44
50
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
if (recipients.length === 0) {
|
|
52
|
+
return { messageId: '', success: false, error: 'No recipient' };
|
|
53
|
+
}
|
|
54
|
+
if (recipients.length === 1) {
|
|
55
|
+
return sendTo(recipients[0]);
|
|
48
56
|
}
|
|
57
|
+
return __emailDeliveries({ recipients, send: sendTo, idKey: 'messageId' });
|
|
49
58
|
}
|
|
50
59
|
export const emailPostmark = {
|
|
51
60
|
nodeType: 'email-postmark',
|
|
@@ -54,7 +63,11 @@ export const emailPostmark = {
|
|
|
54
63
|
postmark: '^4.0.0',
|
|
55
64
|
},
|
|
56
65
|
generateHandler() {
|
|
57
|
-
return assertHandlerHasNoModuleRefs(handlerToString(email_postmark) +
|
|
66
|
+
return assertHandlerHasNoModuleRefs(handlerToString(email_postmark) +
|
|
67
|
+
'\n' +
|
|
68
|
+
EmailSender.generateEmailSenderHelperCode() +
|
|
69
|
+
'\n' +
|
|
70
|
+
EMAIL_RECIPIENTS_HELPER_SOURCE, 'email-postmark');
|
|
58
71
|
},
|
|
59
72
|
};
|
|
60
73
|
//# sourceMappingURL=email-postmark.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-postmark.js","sourceRoot":"","sources":["../../../../src/nodes/email/email-postmark.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAwB,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"email-postmark.js","sourceRoot":"","sources":["../../../../src/nodes/email/email-postmark.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAwB,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAA;AAC7E,OAAO,EAAE,8BAA8B,EAAuB,MAAM,oBAAoB,CAAA;AASxF,KAAK,UAAU,cAAc,CAAC,MAAW,EAAE,OAAgC;IACzE,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAA;IACtC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;IACxB,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAA;IAChC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;IAC9B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;IACxB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;IAC9B,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,CAAA;IACpB,MAAM,GAAG,GAAG,MAAM,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UAAU,GAAG,UAAU,CAAA;aACrC;YAED,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAA;YAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;SAC5D;QAAC,OAAO,GAAY,EAAE;YACrB,MAAM,KAAK,GAAG,GAAU,CAAA;YACxB,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,IAAI,sBAAsB,EAAE,CAAA;SACzF;IACH,CAAC;IAED,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;QAC3B,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,CAAA;KAChE;IACD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;QAC3B,OAAO,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;KAC7B;IACD,OAAO,iBAAiB,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAA;AAC5E,CAAC;AACD,MAAM,CAAC,MAAM,aAAa,GAAyB;IACjD,QAAQ,EAAE,gBAAgB;IAC1B,YAAY,EAAE,QAAQ;IACtB,YAAY,EAAE;QACZ,QAAQ,EAAE,QAAQ;KACnB;IACD,eAAe;QACb,OAAO,4BAA4B,CACjC,eAAe,CAAC,cAAc,CAAC;YAC7B,IAAI;YACJ,WAAW,CAAC,6BAA6B,EAAE;YAC3C,IAAI;YACJ,8BAA8B,EAChC,gBAAgB,CACjB,CAAA;IACH,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a workflow email node reaches SEVERAL recipients: one provider call per
|
|
3
|
+
* address, so one refused address (a sender that only delivers to the account
|
|
4
|
+
* owner, a provider account still pending approval) never blocks the others,
|
|
5
|
+
* and the sent-email ledger can say exactly who got the email.
|
|
6
|
+
*
|
|
7
|
+
* Appended to the five `email-*` handlers the way `__emailSender` is: a
|
|
8
|
+
* serialized handler has no module scope, so each declares these ambiently
|
|
9
|
+
* and `generateHandler` concatenates this source. A STRING LITERAL with
|
|
10
|
+
* ONE-parameter functions, for the reasons `commerce-tracking.ts` gives (a
|
|
11
|
+
* consumer's minifier inlines a single-use `.toString()`, and
|
|
12
|
+
* `resolveHandlerEntryName` picks a minified entry point by its 2-param arity).
|
|
13
|
+
*/
|
|
14
|
+
export interface EmailDelivery {
|
|
15
|
+
to: string;
|
|
16
|
+
success: boolean;
|
|
17
|
+
id?: string;
|
|
18
|
+
messageId?: string;
|
|
19
|
+
error?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface EmailDeliveriesPlan {
|
|
22
|
+
recipients: unknown[];
|
|
23
|
+
send: (recipient: unknown) => Promise<unknown>;
|
|
24
|
+
/** The key the handler reports the provider's message id under. */
|
|
25
|
+
idKey: 'id' | 'messageId';
|
|
26
|
+
}
|
|
27
|
+
export declare const EMAIL_RECIPIENTS_HELPER_SOURCE = "\n// The address of one recipient entry: a string, or MailerSend's { email, name }.\nfunction __emailAddressOf(entry) {\n if (typeof entry === 'string') return entry.trim();\n if (entry && typeof entry === 'object' && typeof entry.email === 'string') return entry.email.trim();\n return '';\n}\n\n// A node's `to` as a list with no empty entries and no address twice\n// (case-insensitive); each entry keeps the shape it arrived in.\nfunction __emailRecipients(to) {\n var entries = Array.isArray(to) ? to : [to];\n var seen = {};\n var recipients = [];\n for (var i = 0; i < entries.length; i++) {\n var key = __emailAddressOf(entries[i]).toLowerCase();\n if (!key || seen[key]) continue;\n seen[key] = true;\n recipients.push(entries[i]);\n }\n return recipients;\n}\n\n// Sends to each recipient in turn through plan.send (one recipient per call)\n// and reports the whole: the first delivered id, success when at least one\n// was delivered, the refused addresses with their reasons, and one delivery\n// per recipient.\nasync function __emailDeliveries(plan) {\n var deliveries = [];\n for (var i = 0; i < plan.recipients.length; i++) {\n var recipient = plan.recipients[i];\n var outcome;\n try {\n outcome = await plan.send(recipient);\n } catch (err) {\n outcome = { success: false, error: (err && err.message) || String(err) };\n }\n var delivery = { to: __emailAddressOf(recipient), success: outcome.success === true };\n if (delivery.success) {\n delivery[plan.idKey] = outcome[plan.idKey] || '';\n } else {\n delivery.error = outcome.error || 'Failed to send email';\n }\n deliveries.push(delivery);\n }\n var delivered = deliveries.filter(function (d) { return d.success; });\n var refused = deliveries.filter(function (d) { return !d.success; });\n var result = {};\n result[plan.idKey] = delivered.length ? delivered[0][plan.idKey] : '';\n result.success = delivered.length > 0;\n if (refused.length) {\n result.error = 'refused for ' + refused.map(function (d) { return d.to + ' (' + d.error + ')'; }).join('; ');\n }\n result.deliveries = deliveries;\n return result;\n}\n";
|
|
28
|
+
//# sourceMappingURL=email-recipients.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-recipients.d.ts","sourceRoot":"","sources":["../../../../src/nodes/email/email-recipients.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,OAAO,CAAA;IAChB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,OAAO,EAAE,CAAA;IACrB,IAAI,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IAC9C,mEAAmE;IACnE,KAAK,EAAE,IAAI,GAAG,WAAW,CAAA;CAC1B;AAED,eAAO,MAAM,8BAA8B,ooEAwD1C,CAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a workflow email node reaches SEVERAL recipients: one provider call per
|
|
3
|
+
* address, so one refused address (a sender that only delivers to the account
|
|
4
|
+
* owner, a provider account still pending approval) never blocks the others,
|
|
5
|
+
* and the sent-email ledger can say exactly who got the email.
|
|
6
|
+
*
|
|
7
|
+
* Appended to the five `email-*` handlers the way `__emailSender` is: a
|
|
8
|
+
* serialized handler has no module scope, so each declares these ambiently
|
|
9
|
+
* and `generateHandler` concatenates this source. A STRING LITERAL with
|
|
10
|
+
* ONE-parameter functions, for the reasons `commerce-tracking.ts` gives (a
|
|
11
|
+
* consumer's minifier inlines a single-use `.toString()`, and
|
|
12
|
+
* `resolveHandlerEntryName` picks a minified entry point by its 2-param arity).
|
|
13
|
+
*/
|
|
14
|
+
export const EMAIL_RECIPIENTS_HELPER_SOURCE = `
|
|
15
|
+
// The address of one recipient entry: a string, or MailerSend's { email, name }.
|
|
16
|
+
function __emailAddressOf(entry) {
|
|
17
|
+
if (typeof entry === 'string') return entry.trim();
|
|
18
|
+
if (entry && typeof entry === 'object' && typeof entry.email === 'string') return entry.email.trim();
|
|
19
|
+
return '';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// A node's \`to\` as a list with no empty entries and no address twice
|
|
23
|
+
// (case-insensitive); each entry keeps the shape it arrived in.
|
|
24
|
+
function __emailRecipients(to) {
|
|
25
|
+
var entries = Array.isArray(to) ? to : [to];
|
|
26
|
+
var seen = {};
|
|
27
|
+
var recipients = [];
|
|
28
|
+
for (var i = 0; i < entries.length; i++) {
|
|
29
|
+
var key = __emailAddressOf(entries[i]).toLowerCase();
|
|
30
|
+
if (!key || seen[key]) continue;
|
|
31
|
+
seen[key] = true;
|
|
32
|
+
recipients.push(entries[i]);
|
|
33
|
+
}
|
|
34
|
+
return recipients;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Sends to each recipient in turn through plan.send (one recipient per call)
|
|
38
|
+
// and reports the whole: the first delivered id, success when at least one
|
|
39
|
+
// was delivered, the refused addresses with their reasons, and one delivery
|
|
40
|
+
// per recipient.
|
|
41
|
+
async function __emailDeliveries(plan) {
|
|
42
|
+
var deliveries = [];
|
|
43
|
+
for (var i = 0; i < plan.recipients.length; i++) {
|
|
44
|
+
var recipient = plan.recipients[i];
|
|
45
|
+
var outcome;
|
|
46
|
+
try {
|
|
47
|
+
outcome = await plan.send(recipient);
|
|
48
|
+
} catch (err) {
|
|
49
|
+
outcome = { success: false, error: (err && err.message) || String(err) };
|
|
50
|
+
}
|
|
51
|
+
var delivery = { to: __emailAddressOf(recipient), success: outcome.success === true };
|
|
52
|
+
if (delivery.success) {
|
|
53
|
+
delivery[plan.idKey] = outcome[plan.idKey] || '';
|
|
54
|
+
} else {
|
|
55
|
+
delivery.error = outcome.error || 'Failed to send email';
|
|
56
|
+
}
|
|
57
|
+
deliveries.push(delivery);
|
|
58
|
+
}
|
|
59
|
+
var delivered = deliveries.filter(function (d) { return d.success; });
|
|
60
|
+
var refused = deliveries.filter(function (d) { return !d.success; });
|
|
61
|
+
var result = {};
|
|
62
|
+
result[plan.idKey] = delivered.length ? delivered[0][plan.idKey] : '';
|
|
63
|
+
result.success = delivered.length > 0;
|
|
64
|
+
if (refused.length) {
|
|
65
|
+
result.error = 'refused for ' + refused.map(function (d) { return d.to + ' (' + d.error + ')'; }).join('; ');
|
|
66
|
+
}
|
|
67
|
+
result.deliveries = deliveries;
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
//# sourceMappingURL=email-recipients.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-recipients.js","sourceRoot":"","sources":["../../../../src/nodes/email/email-recipients.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAiBH,MAAM,CAAC,MAAM,8BAA8B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwD7C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-resend.d.ts","sourceRoot":"","sources":["../../../../src/nodes/email/email-resend.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAmB,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"email-resend.d.ts","sourceRoot":"","sources":["../../../../src/nodes/email/email-resend.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAmB,MAAM,UAAU,CAAA;AAoEhE,eAAO,MAAM,WAAW,EAAE,oBAgBzB,CAAA"}
|