@comet/brevo-api 9.0.0-beta.1 → 9.0.0-beta.3
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/lib/blacklisted-contacts/blacklisted-contacts.service.js +18 -30
- package/lib/blacklisted-contacts/blacklisted-contacts.service.js.map +1 -1
- package/lib/brevo-api/brevo-api-campaigns.service.js +121 -187
- package/lib/brevo-api/brevo-api-campaigns.service.js.map +1 -1
- package/lib/brevo-api/brevo-api-contact.service.d.ts.map +1 -1
- package/lib/brevo-api/brevo-api-contact.service.js +195 -283
- package/lib/brevo-api/brevo-api-contact.service.js.map +1 -1
- package/lib/brevo-api/brevo-api-folders.service.js +19 -47
- package/lib/brevo-api/brevo-api-folders.service.js.map +1 -1
- package/lib/brevo-api/brevo-api-sender.service.js +8 -19
- package/lib/brevo-api/brevo-api-sender.service.js.map +1 -1
- package/lib/brevo-api/brevo-api-transactional-mails.service.js +22 -32
- package/lib/brevo-api/brevo-api-transactional-mails.service.js.map +1 -1
- package/lib/brevo-api/brevo-api.utils.d.ts +1 -1
- package/lib/brevo-api/brevo-api.utils.d.ts.map +1 -1
- package/lib/brevo-api/dto/brevo-api-campaign.d.ts +1 -1
- package/lib/brevo-api/dto/brevo-api-campaign.d.ts.map +1 -1
- package/lib/brevo-config/brevo-config.resolver.js +67 -106
- package/lib/brevo-config/brevo-config.resolver.js.map +1 -1
- package/lib/brevo-contact/brevo-contact-import.console.js +24 -39
- package/lib/brevo-contact/brevo-contact-import.console.js.map +1 -1
- package/lib/brevo-contact/brevo-contact-import.resolver.js +27 -38
- package/lib/brevo-contact/brevo-contact-import.resolver.js.map +1 -1
- package/lib/brevo-contact/brevo-contact-import.service.d.ts.map +1 -1
- package/lib/brevo-contact/brevo-contact-import.service.js +108 -146
- package/lib/brevo-contact/brevo-contact-import.service.js.map +1 -1
- package/lib/brevo-contact/brevo-contact.console.js +20 -31
- package/lib/brevo-contact/brevo-contact.console.js.map +1 -1
- package/lib/brevo-contact/brevo-contact.resolver.d.ts.map +1 -1
- package/lib/brevo-contact/brevo-contact.resolver.js +154 -181
- package/lib/brevo-contact/brevo-contact.resolver.js.map +1 -1
- package/lib/brevo-contact/brevo-contacts.service.js +88 -103
- package/lib/brevo-contact/brevo-contacts.service.js.map +1 -1
- package/lib/brevo-contact/ecg-rtr-list/ecg-rtr-list.service.d.ts.map +1 -1
- package/lib/brevo-contact/ecg-rtr-list/ecg-rtr-list.service.js +36 -49
- package/lib/brevo-contact/ecg-rtr-list/ecg-rtr-list.service.js.map +1 -1
- package/lib/brevo-contact/validator/redirect-url.validator.js +10 -21
- package/lib/brevo-contact/validator/redirect-url.validator.js.map +1 -1
- package/lib/brevo-email-import-log/brevo-email-import-log.service.js +14 -26
- package/lib/brevo-email-import-log/brevo-email-import-log.service.js.map +1 -1
- package/lib/config/brevo-module.config.d.ts +8 -8
- package/lib/config/brevo-module.config.d.ts.map +1 -1
- package/lib/email-campaign/email-campaign.resolver.js +112 -143
- package/lib/email-campaign/email-campaign.resolver.js.map +1 -1
- package/lib/email-campaign/email-campaigns.service.js +77 -94
- package/lib/email-campaign/email-campaigns.service.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/mikro-orm/migrations/Migration20240115095733.js +2 -13
- package/lib/mikro-orm/migrations/Migration20240115095733.js.map +1 -1
- package/lib/mikro-orm/migrations/Migration20240118144808.js +3 -14
- package/lib/mikro-orm/migrations/Migration20240118144808.js.map +1 -1
- package/lib/mikro-orm/migrations/Migration20240123145606.js +4 -15
- package/lib/mikro-orm/migrations/Migration20240123145606.js.map +1 -1
- package/lib/mikro-orm/migrations/Migration20240527112204.js +2 -13
- package/lib/mikro-orm/migrations/Migration20240527112204.js.map +1 -1
- package/lib/mikro-orm/migrations/Migration20240619092554.js +2 -13
- package/lib/mikro-orm/migrations/Migration20240619092554.js.map +1 -1
- package/lib/mikro-orm/migrations/Migration20240619145217.js +2 -13
- package/lib/mikro-orm/migrations/Migration20240619145217.js.map +1 -1
- package/lib/mikro-orm/migrations/Migration20240621102349.js +4 -15
- package/lib/mikro-orm/migrations/Migration20240621102349.js.map +1 -1
- package/lib/mikro-orm/migrations/Migration20240819214939.js +7 -18
- package/lib/mikro-orm/migrations/Migration20240819214939.js.map +1 -1
- package/lib/mikro-orm/migrations/Migration20240830112400.js +3 -14
- package/lib/mikro-orm/migrations/Migration20240830112400.js.map +1 -1
- package/lib/mikro-orm/migrations/Migration20241016123307.js +2 -13
- package/lib/mikro-orm/migrations/Migration20241016123307.js.map +1 -1
- package/lib/mikro-orm/migrations/Migration20241018110515.js +2 -13
- package/lib/mikro-orm/migrations/Migration20241018110515.js.map +1 -1
- package/lib/mikro-orm/migrations/Migration20241022144400.js +2 -13
- package/lib/mikro-orm/migrations/Migration20241022144400.js.map +1 -1
- package/lib/mikro-orm/migrations/Migration20241024071748.js +2 -13
- package/lib/mikro-orm/migrations/Migration20241024071748.js.map +1 -1
- package/lib/mikro-orm/migrations/Migration20241119101706.js +3 -14
- package/lib/mikro-orm/migrations/Migration20241119101706.js.map +1 -1
- package/lib/mikro-orm/migrations/Migration20250221073825.js +2 -13
- package/lib/mikro-orm/migrations/Migration20250221073825.js.map +1 -1
- package/lib/mikro-orm/migrations/Migration20250317131301.js +2 -13
- package/lib/mikro-orm/migrations/Migration20250317131301.js.map +1 -1
- package/lib/mikro-orm/migrations/Migration20250321132034.js +2 -13
- package/lib/mikro-orm/migrations/Migration20250321132034.js.map +1 -1
- package/lib/mikro-orm/migrations/Migration20250703155205.js +7 -18
- package/lib/mikro-orm/migrations/Migration20250703155205.js.map +1 -1
- package/lib/mikro-orm/migrations/migrations.d.ts +1 -1
- package/lib/mikro-orm/migrations/migrations.d.ts.map +1 -1
- package/lib/target-group/target-group.resolver.d.ts.map +1 -1
- package/lib/target-group/target-group.resolver.js +93 -115
- package/lib/target-group/target-group.resolver.js.map +1 -1
- package/lib/target-group/target-groups.service.d.ts.map +1 -1
- package/lib/target-group/target-groups.service.js +87 -105
- package/lib/target-group/target-groups.service.js.map +1 -1
- package/lib/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +21 -16
|
@@ -11,15 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
15
|
exports.BrevoContactsService = void 0;
|
|
25
16
|
const nestjs_1 = require("@mikro-orm/nestjs");
|
|
@@ -34,7 +25,6 @@ const subscribe_response_enum_1 = require("./dto/subscribe-response.enum");
|
|
|
34
25
|
const ecg_rtr_list_service_1 = require("./ecg-rtr-list/ecg-rtr-list.service");
|
|
35
26
|
let BrevoContactsService = class BrevoContactsService {
|
|
36
27
|
constructor(config, brevoConfigRepository, blacklistedContactsRepository, brevoContactsApiService, ecgRtrListService, targetGroupService, brevoEmailImportLogService) {
|
|
37
|
-
var _a;
|
|
38
28
|
this.config = config;
|
|
39
29
|
this.brevoConfigRepository = brevoConfigRepository;
|
|
40
30
|
this.blacklistedContactsRepository = blacklistedContactsRepository;
|
|
@@ -42,116 +32,111 @@ let BrevoContactsService = class BrevoContactsService {
|
|
|
42
32
|
this.ecgRtrListService = ecgRtrListService;
|
|
43
33
|
this.targetGroupService = targetGroupService;
|
|
44
34
|
this.brevoEmailImportLogService = brevoEmailImportLogService;
|
|
45
|
-
this.secretKey =
|
|
35
|
+
this.secretKey = this.config.contactsWithoutDoi?.emailHashKey;
|
|
46
36
|
}
|
|
47
|
-
createContact(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
37
|
+
async createContact({ email, attributes, redirectionUrl, scope, templateId, listIds, sendDoubleOptIn, responsibleUserId, contactSource, }) {
|
|
38
|
+
const existingContact = await this.brevoContactsApiService.getContactInfoByEmail(email, scope);
|
|
39
|
+
if (existingContact) {
|
|
40
|
+
return subscribe_response_enum_1.SubscribeResponse.ERROR_CONTACT_ALREADY_EXISTS;
|
|
41
|
+
}
|
|
42
|
+
const mainTargetGroupForScope = await this.targetGroupService.createIfNotExistMainTargetGroupForScope(scope);
|
|
43
|
+
const targetGroupIds = await this.getTargetGroupIdsForNewContact({ scope, contactAttributes: attributes });
|
|
44
|
+
const brevoIds = [mainTargetGroupForScope.brevoId, ...targetGroupIds];
|
|
45
|
+
if (listIds) {
|
|
46
|
+
brevoIds.push(...listIds);
|
|
47
|
+
}
|
|
48
|
+
if (!sendDoubleOptIn && responsibleUserId) {
|
|
49
|
+
if (!this.secretKey) {
|
|
50
|
+
throw new Error("There is no `emailHashKey` defined in the environment variables.");
|
|
58
51
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const hashedEmail = (0, hash_util_1.hashEmail)(email, this.secretKey);
|
|
64
|
-
const blacklistedContactAvailable = yield this.blacklistedContactsRepository.findOne({ hashedEmail: hashedEmail });
|
|
65
|
-
if (blacklistedContactAvailable) {
|
|
66
|
-
return subscribe_response_enum_1.SubscribeResponse.ERROR_CONTACT_IS_BLACKLISTED;
|
|
67
|
-
}
|
|
68
|
-
if (contactSource) {
|
|
69
|
-
const created = yield this.brevoContactsApiService.createBrevoContactWithoutDoubleOptIn({ email, attributes }, brevoIds, templateId, scope);
|
|
70
|
-
if (created) {
|
|
71
|
-
yield this.brevoEmailImportLogService.addContactToLogs(email, responsibleUserId, scope, contactSource);
|
|
72
|
-
return subscribe_response_enum_1.SubscribeResponse.SUCCESSFUL;
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
return subscribe_response_enum_1.SubscribeResponse.ERROR_UNKNOWN;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
52
|
+
const hashedEmail = (0, hash_util_1.hashEmail)(email, this.secretKey);
|
|
53
|
+
const blacklistedContactAvailable = await this.blacklistedContactsRepository.findOne({ hashedEmail: hashedEmail });
|
|
54
|
+
if (blacklistedContactAvailable) {
|
|
55
|
+
return subscribe_response_enum_1.SubscribeResponse.ERROR_CONTACT_IS_BLACKLISTED;
|
|
78
56
|
}
|
|
79
|
-
|
|
80
|
-
const created =
|
|
57
|
+
if (contactSource) {
|
|
58
|
+
const created = await this.brevoContactsApiService.createBrevoContactWithoutDoubleOptIn({ email, attributes }, brevoIds, templateId, scope);
|
|
81
59
|
if (created) {
|
|
60
|
+
await this.brevoEmailImportLogService.addContactToLogs(email, responsibleUserId, scope, contactSource);
|
|
82
61
|
return subscribe_response_enum_1.SubscribeResponse.SUCCESSFUL;
|
|
83
62
|
}
|
|
84
63
|
else {
|
|
85
64
|
return subscribe_response_enum_1.SubscribeResponse.ERROR_UNKNOWN;
|
|
86
65
|
}
|
|
87
66
|
}
|
|
88
|
-
|
|
89
|
-
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const created = await this.brevoContactsApiService.createDoubleOptInBrevoContact({ email, redirectionUrl, attributes }, brevoIds, templateId, scope);
|
|
70
|
+
if (created) {
|
|
71
|
+
return subscribe_response_enum_1.SubscribeResponse.SUCCESSFUL;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
return subscribe_response_enum_1.SubscribeResponse.ERROR_UNKNOWN;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return subscribe_response_enum_1.SubscribeResponse.ERROR_UNKNOWN;
|
|
90
78
|
}
|
|
91
|
-
createTestContact(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return created;
|
|
96
|
-
});
|
|
79
|
+
async createTestContact({ email, attributes, scope, }) {
|
|
80
|
+
const testTargetGroupForScope = await this.targetGroupService.createIfNotExistTestTargetGroupForScope(scope);
|
|
81
|
+
const created = await this.brevoContactsApiService.createTestContact({ email, attributes }, [testTargetGroupForScope.brevoId], scope);
|
|
82
|
+
return created;
|
|
97
83
|
}
|
|
98
|
-
getTargetGroupIdsForNewContact(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
targetGroupIds.push(targetGroup.brevoId);
|
|
113
|
-
}
|
|
84
|
+
async getTargetGroupIdsForNewContact({ contactAttributes, scope, }) {
|
|
85
|
+
let offset = 0;
|
|
86
|
+
let totalCount = 0;
|
|
87
|
+
const targetGroupIds = [];
|
|
88
|
+
const limit = 50;
|
|
89
|
+
const where = { isMainList: false, scope };
|
|
90
|
+
do {
|
|
91
|
+
const [targetGroups, totalContactLists] = await this.targetGroupService.findTargetGroups({ offset, limit, where });
|
|
92
|
+
totalCount = totalContactLists;
|
|
93
|
+
offset += targetGroups.length;
|
|
94
|
+
for (const targetGroup of targetGroups) {
|
|
95
|
+
const contactIsInTargetGroup = this.targetGroupService.checkIfContactIsInTargetGroupByAttributes(contactAttributes, targetGroup.filters);
|
|
96
|
+
if (contactIsInTargetGroup) {
|
|
97
|
+
targetGroupIds.push(targetGroup.brevoId);
|
|
114
98
|
}
|
|
115
|
-
} while (offset < totalCount);
|
|
116
|
-
return targetGroupIds;
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
subscribeBrevoContact(data, scope) {
|
|
120
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
if ((yield this.ecgRtrListService.getContainedEcgRtrListEmails([data.email])).length > 0) {
|
|
122
|
-
return subscribe_response_enum_1.SubscribeResponse.ERROR_CONTAINED_IN_ECG_RTR_LIST;
|
|
123
99
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return subscribe_response_enum_1.SubscribeResponse.
|
|
100
|
+
} while (offset < totalCount);
|
|
101
|
+
return targetGroupIds;
|
|
102
|
+
}
|
|
103
|
+
async subscribeBrevoContact(data, scope) {
|
|
104
|
+
if ((await this.ecgRtrListService.getContainedEcgRtrListEmails([data.email])).length > 0) {
|
|
105
|
+
return subscribe_response_enum_1.SubscribeResponse.ERROR_CONTAINED_IN_ECG_RTR_LIST;
|
|
106
|
+
}
|
|
107
|
+
const brevoConfig = await this.brevoConfigRepository.findOneOrFail({ scope });
|
|
108
|
+
const created = await this.createContact({
|
|
109
|
+
...data,
|
|
110
|
+
scope,
|
|
111
|
+
templateId: brevoConfig.doubleOptInTemplateId,
|
|
112
|
+
sendDoubleOptIn: true,
|
|
130
113
|
});
|
|
114
|
+
if (created) {
|
|
115
|
+
return subscribe_response_enum_1.SubscribeResponse.SUCCESSFUL;
|
|
116
|
+
}
|
|
117
|
+
return subscribe_response_enum_1.SubscribeResponse.ERROR_UNKNOWN;
|
|
131
118
|
}
|
|
132
|
-
getTargetGroupIdsForExistingContact(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
targetGroupIds.push(targetGroup.brevoId);
|
|
147
|
-
}
|
|
148
|
-
if (targetGroup.assignedContactsTargetGroupBrevoId && (contact === null || contact === void 0 ? void 0 : contact.listIds.includes(targetGroup.assignedContactsTargetGroupBrevoId))) {
|
|
149
|
-
targetGroupIds.push(targetGroup.brevoId, targetGroup.assignedContactsTargetGroupBrevoId);
|
|
150
|
-
}
|
|
119
|
+
async getTargetGroupIdsForExistingContact({ contact }) {
|
|
120
|
+
let offset = 0;
|
|
121
|
+
let totalCount = 0;
|
|
122
|
+
const targetGroupIds = [];
|
|
123
|
+
const limit = 50;
|
|
124
|
+
const where = { isMainList: false };
|
|
125
|
+
do {
|
|
126
|
+
const [targetGroups, totalContactLists] = await this.targetGroupService.findTargetGroups({ offset, limit, where });
|
|
127
|
+
totalCount = totalContactLists;
|
|
128
|
+
offset += targetGroups.length;
|
|
129
|
+
for (const targetGroup of targetGroups) {
|
|
130
|
+
const contactIsInTargetGroupByAttributes = this.targetGroupService.checkIfContactIsInTargetGroupByAttributes(contact?.attributes, targetGroup.filters);
|
|
131
|
+
if (contactIsInTargetGroupByAttributes) {
|
|
132
|
+
targetGroupIds.push(targetGroup.brevoId);
|
|
151
133
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
134
|
+
if (targetGroup.assignedContactsTargetGroupBrevoId && contact?.listIds.includes(targetGroup.assignedContactsTargetGroupBrevoId)) {
|
|
135
|
+
targetGroupIds.push(targetGroup.brevoId, targetGroup.assignedContactsTargetGroupBrevoId);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
} while (offset < totalCount);
|
|
139
|
+
return targetGroupIds;
|
|
155
140
|
}
|
|
156
141
|
};
|
|
157
142
|
exports.BrevoContactsService = BrevoContactsService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brevo-contacts.service.js","sourceRoot":"","sources":["../../src/brevo-contact/brevo-contacts.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"brevo-contacts.service.js","sourceRoot":"","sources":["../../src/brevo-contact/brevo-contacts.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;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d.ts","sourceRoot":"","sources":["../../../src/brevo-contact/ecg-rtr-list/ecg-rtr-list.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ecg-rtr-list.service.d.ts","sourceRoot":"","sources":["../../../src/brevo-contact/ecg-rtr-list/ecg-rtr-list.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAGrE,qBACa,iBAAiB;IACe,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,iBAAiB;IAE7E,4BAA4B,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IA+DvE,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;CAc7C"}
|
|
@@ -11,15 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
14
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
15
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
16
|
};
|
|
@@ -27,53 +18,49 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
27
18
|
exports.EcgRtrListService = void 0;
|
|
28
19
|
const common_1 = require("@nestjs/common");
|
|
29
20
|
const crypto_1 = __importDefault(require("crypto"));
|
|
30
|
-
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
31
21
|
const brevo_module_constants_1 = require("../../config/brevo-module.constants");
|
|
32
22
|
let EcgRtrListService = class EcgRtrListService {
|
|
33
23
|
constructor(config) {
|
|
34
24
|
this.config = config;
|
|
35
25
|
}
|
|
36
|
-
getContainedEcgRtrListEmails(emails) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
26
|
+
async getContainedEcgRtrListEmails(emails) {
|
|
27
|
+
const emailsAndHashedEmails = emails.map((email) => ({
|
|
28
|
+
email,
|
|
29
|
+
hashedEmail: crypto_1.default.createHash("sha512").update(this.prepareEmailForHash(email)).digest("hex"),
|
|
30
|
+
}));
|
|
31
|
+
let domains = emails.map((email) => email.substring(email.indexOf("@") + 1));
|
|
32
|
+
domains = [...new Set(domains)];
|
|
33
|
+
const domainsAndHashedDomains = domains.map((domain) => {
|
|
34
|
+
return {
|
|
35
|
+
domain,
|
|
36
|
+
hashedDomain: crypto_1.default.createHash("sha512").update(domain.toLowerCase()).digest("hex"),
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
const emailsAndDomains = [
|
|
40
|
+
...emailsAndHashedEmails.map((item) => item.hashedEmail),
|
|
41
|
+
...domainsAndHashedDomains.map((item) => item.hashedDomain),
|
|
42
|
+
];
|
|
43
|
+
const headers = { "X-API-KEY": this.config.ecgRtrList.apiKey, "Content-Type": "application/json" };
|
|
44
|
+
const body = { emails: emailsAndDomains, contained: true, hashed: true };
|
|
45
|
+
const response = await fetch("https://ecg.rtr.at/dev/api/v1/emails/check/batch", { method: "POST", body: JSON.stringify(body), headers });
|
|
46
|
+
if (!response.ok) {
|
|
47
|
+
throw new Error("ECG-RTR List check could not be executed.");
|
|
48
|
+
}
|
|
49
|
+
const data = (await response.json());
|
|
50
|
+
const hashedResponseValues = data.emails ?? [];
|
|
51
|
+
let containedEmails = [];
|
|
52
|
+
for (const hashedResponseValue of hashedResponseValues) {
|
|
53
|
+
const email = emailsAndHashedEmails.find((item) => item.hashedEmail === hashedResponseValue)?.email;
|
|
54
|
+
const domain = domainsAndHashedDomains.find((item) => item.hashedDomain === hashedResponseValue)?.domain;
|
|
55
|
+
if (domain) {
|
|
56
|
+
const emailsWithDomain = emails.filter((item) => item.endsWith(`@${domain}`));
|
|
57
|
+
containedEmails = containedEmails.concat(emailsWithDomain);
|
|
62
58
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const email = (_b = emailsAndHashedEmails.find((item) => item.hashedEmail === hashedResponseValue)) === null || _b === void 0 ? void 0 : _b.email;
|
|
66
|
-
const domain = (_c = domainsAndHashedDomains.find((item) => item.hashedDomain === hashedResponseValue)) === null || _c === void 0 ? void 0 : _c.domain;
|
|
67
|
-
if (domain) {
|
|
68
|
-
const emailsWithDomain = emails.filter((item) => item.endsWith(`@${domain}`));
|
|
69
|
-
containedEmails = containedEmails.concat(emailsWithDomain);
|
|
70
|
-
}
|
|
71
|
-
if (email) {
|
|
72
|
-
containedEmails.push(email);
|
|
73
|
-
}
|
|
59
|
+
if (email) {
|
|
60
|
+
containedEmails.push(email);
|
|
74
61
|
}
|
|
75
|
-
|
|
76
|
-
|
|
62
|
+
}
|
|
63
|
+
return containedEmails;
|
|
77
64
|
}
|
|
78
65
|
prepareEmailForHash(email) {
|
|
79
66
|
const emailParts = email.toLowerCase().split("@");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecg-rtr-list.service.js","sourceRoot":"","sources":["../../../src/brevo-contact/ecg-rtr-list/ecg-rtr-list.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ecg-rtr-list.service.js","sourceRoot":"","sources":["../../../src/brevo-contact/ecg-rtr-list/ecg-rtr-list.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,oDAA4B;AAG5B,gFAA0E;AAGnE,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC1B,YAA0D,MAAyB;QAAzB,WAAM,GAAN,MAAM,CAAmB;IAAG,CAAC;IAEvF,KAAK,CAAC,4BAA4B,CAAC,MAAgB;QAW/C,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACjD,KAAK;YACL,WAAW,EAAE,gBAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SACjG,CAAC,CAAC,CAAC;QAGJ,IAAI,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC7E,OAAO,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;QAGhC,MAAM,uBAAuB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YACnD,OAAO;gBACH,MAAM;gBACN,YAAY,EAAE,gBAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aACvF,CAAC;QACN,CAAC,CAAC,CAAC;QAEH,MAAM,gBAAgB,GAAG;YACrB,G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AAC;gBACT,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC;gBAC9E,eAAe,GAAG,eAAe,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;YAC/D,CAAC;YAED,IAAI,KAAK,EAAE,CAAC;gBACR,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC;QACL,CAAC;QAED,OAAO,eAAe,CAAC;IAC3B,CAAC;IAED,mBAAmB,CAAC,KAAa;QAI7B,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAElD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,MAAM,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC1C,CAAC;QAED,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAEjD,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;CACJ,CAAA;AAhFY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;IAEI,WAAA,IAAA,eAAM,EAAC,4CAAmB,CAAC,CAAA;;GAD/B,iBAAiB,CAgF7B"}
|
|
@@ -11,15 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
15
|
exports.IsValidRedirectURLConstraint = exports.IsValidRedirectURL = void 0;
|
|
25
16
|
const nestjs_1 = require("@mikro-orm/nestjs");
|
|
@@ -44,18 +35,16 @@ let IsValidRedirectURLConstraint = class IsValidRedirectURLConstraint {
|
|
|
44
35
|
this.config = config;
|
|
45
36
|
this.brevoConfigRepository = brevoConfigRepository;
|
|
46
37
|
}
|
|
47
|
-
validate(urlToValidate, args) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return false;
|
|
58
|
-
});
|
|
38
|
+
async validate(urlToValidate, args) {
|
|
39
|
+
const [scope] = args.constraints;
|
|
40
|
+
const configForScope = await this.brevoConfigRepository.findOneOrFail({ scope });
|
|
41
|
+
if (!configForScope) {
|
|
42
|
+
throw Error("Scope does not exist");
|
|
43
|
+
}
|
|
44
|
+
if (urlToValidate?.startsWith(configForScope.allowedRedirectionUrl)) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
59
48
|
}
|
|
60
49
|
defaultMessage() {
|
|
61
50
|
return `URL is not supported`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redirect-url.validator.js","sourceRoot":"","sources":["../../../src/brevo-contact/validator/redirect-url.validator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"redirect-url.validator.js","sourceRoot":"","sources":["../../../src/brevo-contact/validator/redirect-url.validator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AE,KAAK,EAAE,IAAI,EAAE,CAAC;IAChE,IAAA,mBAAU,GAAE;IAGJ,WAAA,IAAA,eAAM,EAAC,4CAAmB,CAAC,CAAA;IAC3B,WAAA,IAAA,yBAAgB,EAAC,aAAa,CAAC,CAAA;6CAAyC,6BAAgB;GAHpF,4BAA4B,CAwBxC"}
|
|
@@ -11,15 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
15
|
exports.BrevoEmailImportLogService = void 0;
|
|
25
16
|
const nestjs_1 = require("@mikro-orm/nestjs");
|
|
@@ -33,24 +24,21 @@ let BrevoEmailImportLogService = class BrevoEmailImportLogService {
|
|
|
33
24
|
this.repository = repository;
|
|
34
25
|
this.entityManager = entityManager;
|
|
35
26
|
}
|
|
36
|
-
addContactToLogs(email, responsibleUserId, scope, contactSource, importId) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
contactSource,
|
|
49
|
-
importId,
|
|
50
|
-
});
|
|
51
|
-
yield this.entityManager.flush();
|
|
52
|
-
return log;
|
|
27
|
+
async addContactToLogs(email, responsibleUserId, scope, contactSource, importId) {
|
|
28
|
+
if (!this.config.contactsWithoutDoi?.emailHashKey) {
|
|
29
|
+
throw new Error("There is no `emailHashKey` defined in the environment variables.");
|
|
30
|
+
}
|
|
31
|
+
const log = this.repository.create({
|
|
32
|
+
importedEmail: (0, hash_util_1.hashEmail)(email, this.config.contactsWithoutDoi.emailHashKey),
|
|
33
|
+
responsibleUserId,
|
|
34
|
+
scope,
|
|
35
|
+
createdAt: new Date(),
|
|
36
|
+
updatedAt: new Date(),
|
|
37
|
+
contactSource,
|
|
38
|
+
importId,
|
|
53
39
|
});
|
|
40
|
+
await this.entityManager.flush();
|
|
41
|
+
return log;
|
|
54
42
|
}
|
|
55
43
|
};
|
|
56
44
|
exports.BrevoEmailImportLogService = BrevoEmailImportLogService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brevo-email-import-log.service.js","sourceRoot":"","sources":["../../src/brevo-email-import-log/brevo-email-import-log.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"brevo-email-import-log.service.js","sourceRoot":"","sources":["../../src/brevo-email-import-log/brevo-email-import-log.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,8CAAqD;AACrD,sDAAwE;AACxE,2CAAoD;AAIpD,6EAAuE;AACvE,iDAA8C;AAIvC,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IACnC,YACkD,MAAyB,EACb,UAA0D,EACnG,aAA4B;QAFC,WAAM,GAAN,MAAM,CAAmB;QACb,eAAU,GAAV,UAAU,CAAgD;QACnG,kBAAa,GAAb,aAAa,CAAe;IAC9C,CAAC;IACG,KAAK,CAAC,gBAAgB,CACzB,KAAa,EACb,iBAAyB,EACzB,KAAkC,EAClC,aAA4B,EAC5B,QAAiB;QAEjB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,YAAY,EAAE,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;QACxF,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;YAC/B,aAAa,EAAE,IAAA,qBAAS,EAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,YAAY,CAAC;YAC5E,iBAAiB;YACjB,KAAK;YACL,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,aAAa;YACb,QAAQ;SACX,CAAC,CAAC;QACH,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QACjC,OAAO,GAAG,CAAC;IACf,CAAC;CACJ,CAAA;AA5BY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,mBAAU,GAAE;IAGJ,WAAA,IAAA,eAAM,EAAC,4CAAmB,CAAC,CAAA;IAC3B,WAAA,IAAA,yBAAgB,EAAC,qBAAqB,CAAC,CAAA;6CAA8B,6BAAgB;QACtD,0BAAa;GAJxC,0BAA0B,CA4BtC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import type { Block } from "@comet/cms-api";
|
|
2
|
+
import type { Type } from "@nestjs/common";
|
|
3
|
+
import type { EmailCampaignInterface } from "src/email-campaign/entities/email-campaign-entity.factory";
|
|
4
|
+
import type { TargetGroupInterface } from "src/target-group/entity/target-group-entity.factory";
|
|
5
|
+
import type { BrevoContactAttributesInterface, EmailCampaignScopeInterface } from "src/types";
|
|
6
|
+
import type { BlacklistedContactsInterface } from "../blacklisted-contacts/entity/blacklisted-contacts.entity.factory";
|
|
7
|
+
import type { BrevoEmailImportLogInterface } from "../brevo-email-import-log/entity/brevo-email-import-log.entity.factory";
|
|
8
|
+
import type { BrevoContactFilterAttributesInterface } from "../types";
|
|
9
9
|
interface FrontendConfig {
|
|
10
10
|
url: string;
|
|
11
11
|
basicAuth: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brevo-module.config.d.ts","sourceRoot":"","sources":["../../src/config/brevo-module.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"brevo-module.config.d.ts","sourceRoot":"","sources":["../../src/config/brevo-module.config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2DAA2D,CAAC;AACxG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qDAAqD,CAAC;AAChG,OAAO,KAAK,EAAE,+BAA+B,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAE9F,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oEAAoE,CAAC;AACvH,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,wEAAwE,CAAC;AAC3H,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,UAAU,CAAC;AAEtE,UAAU,cAAc;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE;QACP,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;KACpB,CAAC;CACL;AAED,MAAM,WAAW,iBAAiB;IAC9B,KAAK,EAAE;QACH,aAAa,EAAE,CAAC,KAAK,EAAE,2BAA2B,KAAK;YACnD,MAAM,EAAE,MAAM,CAAC;YACf,oBAAoB,EAAE,MAAM,CAAC;SAChC,CAAC;QACF,mBAAmB,CAAC,EAAE,IAAI,CAAC,4BAA4B,CAAC,CAAC;QACzD,sBAAsB,CAAC,EAAE,IAAI,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