@clxmedia/emailhub-client 1.1.2 → 1.1.4
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/dist/client.d.ts +49 -0
- package/dist/client.js +59 -1
- package/package.json +3 -1
package/dist/client.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ export declare enum EmailHubPriorityLevel {
|
|
|
3
3
|
NORMAL = "normal",
|
|
4
4
|
BULK = "bulk"
|
|
5
5
|
}
|
|
6
|
+
export declare enum EmailHubEnvironment {
|
|
7
|
+
emailhub = "emailhub",
|
|
8
|
+
localhost = "localhost"
|
|
9
|
+
}
|
|
6
10
|
export interface EmailHubAttachment {
|
|
7
11
|
ContentType: string;
|
|
8
12
|
Filename: string;
|
|
@@ -60,11 +64,55 @@ export interface EmailHubSenderProfile {
|
|
|
60
64
|
updated_at?: string;
|
|
61
65
|
verified_at?: string;
|
|
62
66
|
}
|
|
67
|
+
export declare class MockEmailHubClient {
|
|
68
|
+
readonly environment: EmailHubEnvironment;
|
|
69
|
+
createSenderProfile(_domain: string): Promise<{
|
|
70
|
+
guid: string;
|
|
71
|
+
id: number;
|
|
72
|
+
domain_name: string;
|
|
73
|
+
domain_id: string;
|
|
74
|
+
mailjet_sender_id: string;
|
|
75
|
+
dkim_txt_name: string;
|
|
76
|
+
dkim_txt_value: string;
|
|
77
|
+
dkim_status: string;
|
|
78
|
+
token_txt_name: string;
|
|
79
|
+
token_txt_value: string;
|
|
80
|
+
spf_txt_value: string;
|
|
81
|
+
spf_status: string;
|
|
82
|
+
created_at: string;
|
|
83
|
+
updated_at?: string;
|
|
84
|
+
verified_at?: string;
|
|
85
|
+
}>;
|
|
86
|
+
checkSenderProfile(domainGuid: string): Promise<{
|
|
87
|
+
guid: string;
|
|
88
|
+
verified_at: string;
|
|
89
|
+
id: number;
|
|
90
|
+
domain_name: string;
|
|
91
|
+
domain_id: string;
|
|
92
|
+
mailjet_sender_id: string;
|
|
93
|
+
dkim_txt_name: string;
|
|
94
|
+
dkim_txt_value: string;
|
|
95
|
+
dkim_status: string;
|
|
96
|
+
token_txt_name: string;
|
|
97
|
+
token_txt_value: string;
|
|
98
|
+
spf_txt_value: string;
|
|
99
|
+
spf_status: string;
|
|
100
|
+
created_at: string;
|
|
101
|
+
updated_at?: string;
|
|
102
|
+
}>;
|
|
103
|
+
deleteSenderProfile(): Promise<void>;
|
|
104
|
+
sendEmail(msg: EmailHubMessage, options?: {
|
|
105
|
+
priority?: EmailHubPriorityLevel;
|
|
106
|
+
writeToLog?: boolean;
|
|
107
|
+
}): Promise<string>;
|
|
108
|
+
}
|
|
63
109
|
export declare class EmailHubClient {
|
|
110
|
+
readonly environment: EmailHubEnvironment;
|
|
64
111
|
private sender;
|
|
65
112
|
private server;
|
|
66
113
|
private pubsubClient;
|
|
67
114
|
constructor(cfg: EmailHubConfig);
|
|
115
|
+
static new(cfg: EmailHubConfig): EmailHubClient | MockEmailHubClient;
|
|
68
116
|
private loadPubSubClient;
|
|
69
117
|
static validateEmailAddress(email?: string, regex?: RegExp): boolean;
|
|
70
118
|
createSenderProfile(domain: string): Promise<EmailHubSenderProfile>;
|
|
@@ -73,5 +121,6 @@ export declare class EmailHubClient {
|
|
|
73
121
|
deleteSenderProfile(domainGuid: string): Promise<HttpStatusCode>;
|
|
74
122
|
sendEmail(msg: EmailHubMessage, options?: {
|
|
75
123
|
priority?: EmailHubPriorityLevel;
|
|
124
|
+
writeToLog?: boolean;
|
|
76
125
|
}): Promise<string>;
|
|
77
126
|
}
|
package/dist/client.js
CHANGED
|
@@ -9,8 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.EmailHubClient = exports.EmailHubPriorityLevel = void 0;
|
|
12
|
+
exports.EmailHubClient = exports.MockEmailHubClient = exports.EmailHubEnvironment = exports.EmailHubPriorityLevel = void 0;
|
|
13
13
|
const pubsub_1 = require("@google-cloud/pubsub");
|
|
14
|
+
const luxon_1 = require("luxon");
|
|
14
15
|
const uuid = require("uuid");
|
|
15
16
|
const Pako = require("pako");
|
|
16
17
|
const axios_1 = require("axios");
|
|
@@ -19,13 +20,70 @@ var EmailHubPriorityLevel;
|
|
|
19
20
|
EmailHubPriorityLevel["NORMAL"] = "normal";
|
|
20
21
|
EmailHubPriorityLevel["BULK"] = "bulk";
|
|
21
22
|
})(EmailHubPriorityLevel = exports.EmailHubPriorityLevel || (exports.EmailHubPriorityLevel = {}));
|
|
23
|
+
var EmailHubEnvironment;
|
|
24
|
+
(function (EmailHubEnvironment) {
|
|
25
|
+
EmailHubEnvironment["emailhub"] = "emailhub";
|
|
26
|
+
EmailHubEnvironment["localhost"] = "localhost";
|
|
27
|
+
})(EmailHubEnvironment = exports.EmailHubEnvironment || (exports.EmailHubEnvironment = {}));
|
|
22
28
|
const DEFAULT_EMAIL_HUB_URL = 'https://emailhub.clxp.us';
|
|
23
29
|
const DEFAULT_EMAIL_REGEX = /^([a-z0-9])([a-z\.0-9_%\-\+\*'’!#`&\$/]*)@(.+)\.(.+)$/;
|
|
30
|
+
const mockEmailHubSenderProfile = {
|
|
31
|
+
id: 1,
|
|
32
|
+
guid: 'mock-guid',
|
|
33
|
+
domain_name: 'mock-domain-name',
|
|
34
|
+
domain_id: 'mock-domain-id',
|
|
35
|
+
mailjet_sender_id: 'mock-mailjet-sender-id',
|
|
36
|
+
dkim_txt_name: 'mock-dkim-txt-name',
|
|
37
|
+
dkim_txt_value: 'mock-dkim-txt-value',
|
|
38
|
+
dkim_status: 'OK',
|
|
39
|
+
token_txt_name: 'mock-token-txt-name',
|
|
40
|
+
token_txt_value: 'mock-token-txt-value',
|
|
41
|
+
spf_txt_value: 'mock-spf-txt-value',
|
|
42
|
+
spf_status: 'Error',
|
|
43
|
+
created_at: luxon_1.DateTime.local().toISO(),
|
|
44
|
+
updated_at: luxon_1.DateTime.local().toISO(),
|
|
45
|
+
verified_at: undefined
|
|
46
|
+
};
|
|
47
|
+
class MockEmailHubClient {
|
|
48
|
+
constructor() {
|
|
49
|
+
this.environment = EmailHubEnvironment.localhost;
|
|
50
|
+
}
|
|
51
|
+
createSenderProfile(_domain) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
return Object.assign(Object.assign({}, mockEmailHubSenderProfile), { guid: uuid.v4() });
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
checkSenderProfile(domainGuid) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
return Object.assign(Object.assign({}, mockEmailHubSenderProfile), { guid: domainGuid, verified_at: luxon_1.DateTime.local().toISO() });
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
deleteSenderProfile() {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
return;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
sendEmail(msg, options) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
if (options === null || options === void 0 ? void 0 : options.writeToLog) {
|
|
69
|
+
console.log('----------------Begin mock email send-----------------');
|
|
70
|
+
console.log(JSON.stringify(msg));
|
|
71
|
+
console.log('----------------End mock email send-----------------');
|
|
72
|
+
}
|
|
73
|
+
return uuid.v4();
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.MockEmailHubClient = MockEmailHubClient;
|
|
24
78
|
class EmailHubClient {
|
|
25
79
|
constructor(cfg) {
|
|
80
|
+
this.environment = EmailHubEnvironment.emailhub;
|
|
26
81
|
this.sender = cfg.sender;
|
|
27
82
|
this.server = cfg.server ? cfg.server : DEFAULT_EMAIL_HUB_URL;
|
|
28
83
|
}
|
|
84
|
+
static new(cfg) {
|
|
85
|
+
return (cfg.sender.guid && cfg.sender.secret) ? new EmailHubClient(cfg) : new MockEmailHubClient();
|
|
86
|
+
}
|
|
29
87
|
loadPubSubClient() {
|
|
30
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
89
|
if (this.pubsubClient) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clxmedia/emailhub-client",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "CLXperience EmailHub Client",
|
|
5
5
|
"author": "Brandon Thompson <brandont@clxmedia.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,12 +37,14 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@google-cloud/pubsub": "^3.6.0",
|
|
39
39
|
"axios": "^1.4.0",
|
|
40
|
+
"luxon": "^3.3.0",
|
|
40
41
|
"pako": "^2.1.0",
|
|
41
42
|
"uuid": "^9.0.0"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@types/axios": "^0.14.0",
|
|
45
46
|
"@types/jest": "28.1.7",
|
|
47
|
+
"@types/luxon": "^3.3.0",
|
|
46
48
|
"@types/node": "^20.1.7",
|
|
47
49
|
"@types/pako": "^2.0.0",
|
|
48
50
|
"@types/supertest": "2.0.12",
|