biz-email-builder-shared 1.6.72 → 1.6.74
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,4 +1,4 @@
|
|
|
1
|
-
import { ISendGridConfig } from
|
|
2
|
-
import { Recipient } from
|
|
1
|
+
import { ISendGridConfig } from "../entity";
|
|
2
|
+
import { Recipient } from "./types";
|
|
3
3
|
export declare function sendFromSendGrid(config: ISendGridConfig, recipient: Recipient, subject: string, text: string, isHtml: boolean, analytics: any): Promise<any>;
|
|
4
4
|
//# sourceMappingURL=sendFromSendGrid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendFromSendGrid.d.ts","sourceRoot":"","sources":["../../src/utilities/sendFromSendGrid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"sendFromSendGrid.d.ts","sourceRoot":"","sources":["../../src/utilities/sendFromSendGrid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAMpC,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,gBA8CnJ"}
|
|
@@ -2,18 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sendFromSendGrid = sendFromSendGrid;
|
|
4
4
|
function normalizeEmails(input) {
|
|
5
|
-
return Array.isArray(input)
|
|
6
|
-
? input.map((email) => ({ email }))
|
|
7
|
-
: [{ email: input }];
|
|
5
|
+
return Array.isArray(input) ? input.map((email) => ({ email })) : [{ email: input }];
|
|
8
6
|
}
|
|
9
7
|
async function sendFromSendGrid(config, recipient, subject, text, isHtml, analytics) {
|
|
10
8
|
var _a;
|
|
11
|
-
const client = require(
|
|
9
|
+
const client = require("@sendgrid/client");
|
|
12
10
|
client.setApiKey(config.api_key);
|
|
13
|
-
const contentType = isHtml ?
|
|
11
|
+
const contentType = isHtml ? "text/html" : "text/plain";
|
|
14
12
|
const request = {
|
|
15
|
-
method:
|
|
16
|
-
url:
|
|
13
|
+
method: "POST",
|
|
14
|
+
url: "/v3/mail/send",
|
|
17
15
|
body: {
|
|
18
16
|
personalizations: [
|
|
19
17
|
{
|
|
@@ -21,24 +19,24 @@ async function sendFromSendGrid(config, recipient, subject, text, isHtml, analyt
|
|
|
21
19
|
cc: recipient.cc ? normalizeEmails(recipient.cc) : undefined,
|
|
22
20
|
bcc: recipient.bcc ? normalizeEmails(recipient.bcc) : undefined,
|
|
23
21
|
subject,
|
|
24
|
-
|
|
25
|
-
}
|
|
22
|
+
},
|
|
26
23
|
],
|
|
27
24
|
from: {
|
|
28
|
-
email: config.email
|
|
25
|
+
email: config.email,
|
|
29
26
|
},
|
|
30
27
|
content: [
|
|
31
28
|
{
|
|
32
29
|
type: contentType,
|
|
33
|
-
value: text
|
|
34
|
-
}
|
|
30
|
+
value: text,
|
|
31
|
+
},
|
|
35
32
|
],
|
|
36
33
|
tracking_settings: {
|
|
37
34
|
open_tracking: {
|
|
38
35
|
enable: true,
|
|
39
|
-
substitution_tag: "%opentrack%"
|
|
36
|
+
substitution_tag: "%opentrack%",
|
|
40
37
|
}
|
|
41
|
-
}
|
|
38
|
+
},
|
|
39
|
+
custom_args: Object.assign({}, ((analytics === null || analytics === void 0 ? void 0 : analytics.custom_args) || {}))
|
|
42
40
|
}
|
|
43
41
|
};
|
|
44
42
|
try {
|
|
@@ -46,7 +44,7 @@ async function sendFromSendGrid(config, recipient, subject, text, isHtml, analyt
|
|
|
46
44
|
return response;
|
|
47
45
|
}
|
|
48
46
|
catch (error) {
|
|
49
|
-
console.error(
|
|
47
|
+
console.error("SendGrid client error:", ((_a = error.response) === null || _a === void 0 ? void 0 : _a.body) || error.message);
|
|
50
48
|
throw error;
|
|
51
49
|
}
|
|
52
50
|
}
|