@memberjunction/communication-sendgrid 2.112.0 → 2.113.1
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 { BaseCommunicationProvider, CreateDraftParams, CreateDraftResult, ForwardMessageParams, ForwardMessageResult, GetMessagesParams, GetMessagesResult, MessageResult, ProcessedMessage, ReplyToMessageParams, ReplyToMessageResult } from
|
|
1
|
+
import { BaseCommunicationProvider, CreateDraftParams, CreateDraftResult, ForwardMessageParams, ForwardMessageResult, GetMessagesParams, GetMessagesResult, MessageResult, ProcessedMessage, ReplyToMessageParams, ReplyToMessageResult } from "@memberjunction/communication-types";
|
|
2
2
|
/**
|
|
3
3
|
* Implementation of the SendGrid provider for sending and receiving messages
|
|
4
4
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SendGridProvider.d.ts","sourceRoot":"","sources":["../src/SendGridProvider.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"SendGridProvider.d.ts","sourceRoot":"","sources":["../src/SendGridProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAMrR;;GAEG;AACH,qBACa,gBAAiB,SAAQ,yBAAyB;IAC3D;;OAEG;IACU,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;IA0EjF;;OAEG;IACU,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAI/E;;OAEG;IACI,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAIlF;;OAEG;IACI,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAIlF;;OAEG;IACU,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAMlF;AAED,wBAAgB,YAAY,SAE3B"}
|
package/dist/SendGridProvider.js
CHANGED
|
@@ -14,7 +14,7 @@ const communication_types_1 = require("@memberjunction/communication-types");
|
|
|
14
14
|
const global_1 = require("@memberjunction/global");
|
|
15
15
|
const mail_1 = __importDefault(require("@sendgrid/mail"));
|
|
16
16
|
const config_1 = require("./config");
|
|
17
|
-
const
|
|
17
|
+
const core_1 = require("@memberjunction/core");
|
|
18
18
|
/**
|
|
19
19
|
* Implementation of the SendGrid provider for sending and receiving messages
|
|
20
20
|
*/
|
|
@@ -30,7 +30,7 @@ let SendGridProvider = class SendGridProvider extends communication_types_1.Base
|
|
|
30
30
|
to: message.To,
|
|
31
31
|
from: {
|
|
32
32
|
email: from,
|
|
33
|
-
name: message.FromName
|
|
33
|
+
name: message.FromName
|
|
34
34
|
},
|
|
35
35
|
cc: message.CCRecipients,
|
|
36
36
|
bcc: message.BCCRecipients,
|
|
@@ -39,16 +39,16 @@ let SendGridProvider = class SendGridProvider extends communication_types_1.Base
|
|
|
39
39
|
html: message.ProcessedHTMLBody,
|
|
40
40
|
trackingSettings: {
|
|
41
41
|
subscriptionTracking: {
|
|
42
|
-
enable: false
|
|
43
|
-
}
|
|
44
|
-
}
|
|
42
|
+
enable: false
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
45
|
};
|
|
46
46
|
/*
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
* Should be ready to go - but needs SG testing.
|
|
48
|
+
if(message.Headers){
|
|
49
|
+
msg.headers = Object.fromEntries(Object.entries(message.Headers).map(([key, value]) => [`X-${key}`, value])) as Record<string, string>;
|
|
50
|
+
}
|
|
51
|
+
*/
|
|
52
52
|
if (message.SendAt) {
|
|
53
53
|
const time = message.SendAt.getTime();
|
|
54
54
|
const unitTime = Math.floor(time / 1000);
|
|
@@ -56,34 +56,31 @@ let SendGridProvider = class SendGridProvider extends communication_types_1.Base
|
|
|
56
56
|
}
|
|
57
57
|
try {
|
|
58
58
|
//not using await syntax here because we dont get a return value
|
|
59
|
-
return mail_1.default
|
|
60
|
-
.send(msg)
|
|
61
|
-
.then((result) => {
|
|
59
|
+
return mail_1.default.send(msg).then((result) => {
|
|
62
60
|
if (result && result.length > 0 && result[0].statusCode >= 200 && result[0].statusCode < 300) {
|
|
63
|
-
(0,
|
|
61
|
+
(0, core_1.LogStatus)(`Email sent to ${msg.to}: ${result[0].statusCode}`);
|
|
64
62
|
return {
|
|
65
63
|
Message: message,
|
|
66
64
|
Success: true,
|
|
67
|
-
Error: ''
|
|
65
|
+
Error: ''
|
|
68
66
|
};
|
|
69
67
|
}
|
|
70
68
|
else {
|
|
71
|
-
(0,
|
|
72
|
-
(0,
|
|
69
|
+
(0, core_1.LogError)(`Error sending email to ${msg.to}:`, undefined, result);
|
|
70
|
+
(0, core_1.LogError)(result[0].body);
|
|
73
71
|
return {
|
|
74
72
|
Message: message,
|
|
75
73
|
Success: false,
|
|
76
|
-
Error: result[0].toString()
|
|
74
|
+
Error: result[0].toString()
|
|
77
75
|
};
|
|
78
76
|
}
|
|
79
|
-
})
|
|
80
|
-
.
|
|
81
|
-
(0,
|
|
82
|
-
(0, global_2.LogError)(error?.response?.body);
|
|
77
|
+
}).catch((error) => {
|
|
78
|
+
(0, core_1.LogError)(`Error sending email to ${msg.to}:`, undefined, error);
|
|
79
|
+
(0, core_1.LogError)(error?.response?.body);
|
|
83
80
|
return {
|
|
84
81
|
Message: message,
|
|
85
82
|
Success: false,
|
|
86
|
-
Error: error.message
|
|
83
|
+
Error: error.message
|
|
87
84
|
};
|
|
88
85
|
});
|
|
89
86
|
}
|
|
@@ -91,7 +88,7 @@ let SendGridProvider = class SendGridProvider extends communication_types_1.Base
|
|
|
91
88
|
return {
|
|
92
89
|
Message: message,
|
|
93
90
|
Success: false,
|
|
94
|
-
Error: error.message
|
|
91
|
+
Error: error.message
|
|
95
92
|
};
|
|
96
93
|
}
|
|
97
94
|
}
|
|
@@ -99,19 +96,19 @@ let SendGridProvider = class SendGridProvider extends communication_types_1.Base
|
|
|
99
96
|
* Fetches messages from the provider
|
|
100
97
|
*/
|
|
101
98
|
async GetMessages(params) {
|
|
102
|
-
throw new Error(
|
|
99
|
+
throw new Error("SendGridProvider does not support fetching messages");
|
|
103
100
|
}
|
|
104
101
|
/**
|
|
105
102
|
* Forwards a message to another client using the provider
|
|
106
103
|
*/
|
|
107
104
|
ForwardMessage(params) {
|
|
108
|
-
throw new Error(
|
|
105
|
+
throw new Error("SendGridProvider does not support forwarding messages");
|
|
109
106
|
}
|
|
110
107
|
/**
|
|
111
108
|
* Replies to a message using the provider
|
|
112
109
|
*/
|
|
113
110
|
ReplyToMessage(params) {
|
|
114
|
-
throw new Error(
|
|
111
|
+
throw new Error("SendGridProvider does not support replying to messages");
|
|
115
112
|
}
|
|
116
113
|
/**
|
|
117
114
|
* SendGrid does not support creating draft messages
|
|
@@ -119,7 +116,7 @@ let SendGridProvider = class SendGridProvider extends communication_types_1.Base
|
|
|
119
116
|
async CreateDraft(params) {
|
|
120
117
|
return {
|
|
121
118
|
Success: false,
|
|
122
|
-
ErrorMessage: 'SendGrid does not support creating draft messages. Drafts are only supported by email providers with mailbox access (Gmail, MS Graph).'
|
|
119
|
+
ErrorMessage: 'SendGrid does not support creating draft messages. Drafts are only supported by email providers with mailbox access (Gmail, MS Graph).'
|
|
123
120
|
};
|
|
124
121
|
}
|
|
125
122
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SendGridProvider.js","sourceRoot":"","sources":["../src/SendGridProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"SendGridProvider.js","sourceRoot":"","sources":["../src/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,MAAyB;QAC9C,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IAC3E,CAAC;IAED;;OAEG;IACI,cAAc,CAAC,MAA4B;QAC9C,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC7E,CAAC;IAED;;OAEG;IACI,cAAc,CAAC,MAA4B;QAC9C,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC9E,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,WAAW,CAAC,MAAyB;QAC9C,OAAO;YACH,OAAO,EAAE,KAAK;YACd,YAAY,EAAE,wIAAwI;SACzJ,CAAC;IACN,CAAC;CACJ,CAAA;AA5GY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAa,EAAC,+CAAyB,EAAE,UAAU,CAAC;GACxC,gBAAgB,CA4G5B;AAED,SAAgB,YAAY;IACxB,kEAAkE;AACtE,CAAC;AAFD,oCAEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/communication-sendgrid",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.113.1",
|
|
4
4
|
"description": "MemberJunction: SendGrid Provider for the MJ Communication Framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,9 +19,10 @@
|
|
|
19
19
|
"typescript": "^5.4.5"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@memberjunction/global": "2.
|
|
23
|
-
"@memberjunction/core
|
|
24
|
-
"@memberjunction/
|
|
22
|
+
"@memberjunction/global": "2.113.1",
|
|
23
|
+
"@memberjunction/core": "2.113.1",
|
|
24
|
+
"@memberjunction/core-entities": "2.113.1",
|
|
25
|
+
"@memberjunction/communication-types": "2.113.1",
|
|
25
26
|
"@sendgrid/mail": "^8.1.3"
|
|
26
27
|
},
|
|
27
28
|
"repository": {
|