@develit-services/notification 0.6.0 → 0.6.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.
- package/dist/export/worker.cjs +80 -51
- package/dist/export/worker.mjs +80 -51
- package/package.json +1 -1
package/dist/export/worker.cjs
CHANGED
|
@@ -145,24 +145,28 @@ let NotificationServiceBase = class extends backendSdk.develitWorker(
|
|
|
145
145
|
);
|
|
146
146
|
}
|
|
147
147
|
await this.emailConnector.sendEmail(email);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
148
|
+
try {
|
|
149
|
+
await this.pushToQueue(this.env.AUDIT_LOGS_QUEUE, {
|
|
150
|
+
logType: "event",
|
|
151
|
+
service: "notification",
|
|
152
|
+
correlationId: backendSdk.uuidv4(),
|
|
153
|
+
eventType: "notification.email_sent",
|
|
154
|
+
actorUserId: userId,
|
|
155
|
+
actorEmail: userId || "SYSTEM",
|
|
156
|
+
targetType: "email",
|
|
157
|
+
targetId: email.to,
|
|
158
|
+
sourceIp: ip,
|
|
159
|
+
userAgent,
|
|
160
|
+
outcome: "success",
|
|
161
|
+
description: `Email sent to ${email.to}`,
|
|
162
|
+
details: JSON.stringify({
|
|
163
|
+
subject: email.subject,
|
|
164
|
+
templateId: email.templateId
|
|
165
|
+
})
|
|
166
|
+
});
|
|
167
|
+
} catch (e) {
|
|
168
|
+
console.error("Failed to push email audit log", e);
|
|
169
|
+
}
|
|
166
170
|
return {};
|
|
167
171
|
}
|
|
168
172
|
);
|
|
@@ -195,21 +199,25 @@ let NotificationServiceBase = class extends backendSdk.develitWorker(
|
|
|
195
199
|
);
|
|
196
200
|
}
|
|
197
201
|
await this.smsConnector.sendSms({ message, to });
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
202
|
+
try {
|
|
203
|
+
await this.pushToQueue(this.env.AUDIT_LOGS_QUEUE, {
|
|
204
|
+
logType: "event",
|
|
205
|
+
service: "notification",
|
|
206
|
+
correlationId: backendSdk.uuidv4(),
|
|
207
|
+
eventType: "notification.sms_sent",
|
|
208
|
+
actorUserId: userId,
|
|
209
|
+
actorEmail: userId || "SYSTEM",
|
|
210
|
+
targetType: "sms",
|
|
211
|
+
targetId: to,
|
|
212
|
+
sourceIp: ip,
|
|
213
|
+
userAgent,
|
|
214
|
+
outcome: "success",
|
|
215
|
+
description: `SMS sent to ${to}`,
|
|
216
|
+
details: JSON.stringify({ message })
|
|
217
|
+
});
|
|
218
|
+
} catch (e) {
|
|
219
|
+
console.error("Failed to push sms audit log", e);
|
|
220
|
+
}
|
|
213
221
|
return {};
|
|
214
222
|
}
|
|
215
223
|
);
|
|
@@ -290,8 +298,25 @@ let NotificationServiceBase = class extends backendSdk.develitWorker(
|
|
|
290
298
|
},
|
|
291
299
|
{ successMessage: "Slack sent." },
|
|
292
300
|
async (params) => {
|
|
293
|
-
const { slack } = params;
|
|
301
|
+
const { slack, metadata } = params;
|
|
294
302
|
await this.slackConnector.sendNotificationToAllSlack(slack.message);
|
|
303
|
+
await this.pushToQueue(this.env.AUDIT_LOGS_QUEUE, {
|
|
304
|
+
logType: "event",
|
|
305
|
+
service: "notification",
|
|
306
|
+
correlationId: backendSdk.uuidv4(),
|
|
307
|
+
eventType: "notification.slack_sent",
|
|
308
|
+
actorUserId: metadata?.initiator?.userId,
|
|
309
|
+
actorEmail: metadata?.initiator?.userId || "SYSTEM",
|
|
310
|
+
targetType: "slack",
|
|
311
|
+
targetId: "all-channels",
|
|
312
|
+
sourceIp: metadata?.ip,
|
|
313
|
+
userAgent: metadata?.userAgent,
|
|
314
|
+
outcome: "success",
|
|
315
|
+
description: "Slack notification sent",
|
|
316
|
+
details: JSON.stringify({
|
|
317
|
+
message: slack.message
|
|
318
|
+
})
|
|
319
|
+
});
|
|
295
320
|
return {};
|
|
296
321
|
}
|
|
297
322
|
);
|
|
@@ -343,23 +368,27 @@ let NotificationServiceBase = class extends backendSdk.develitWorker(
|
|
|
343
368
|
this.webhookConnector = new webhook_connector.WebhookConnector(privateKey);
|
|
344
369
|
}
|
|
345
370
|
await this.webhookConnector.sendWebhook(webhook);
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
371
|
+
try {
|
|
372
|
+
await this.pushToQueue(this.env.AUDIT_LOGS_QUEUE, {
|
|
373
|
+
logType: "event",
|
|
374
|
+
service: "notification",
|
|
375
|
+
correlationId: backendSdk.uuidv4(),
|
|
376
|
+
eventType: "notification.webhook_sent",
|
|
377
|
+
actorUserId: userId,
|
|
378
|
+
actorEmail: userId || "SYSTEM",
|
|
379
|
+
targetType: "webhook",
|
|
380
|
+
targetId: webhook.url,
|
|
381
|
+
sourceIp: ip,
|
|
382
|
+
userAgent,
|
|
383
|
+
outcome: "success",
|
|
384
|
+
description: `Webhook sent to ${webhook.url}`,
|
|
385
|
+
details: JSON.stringify({
|
|
386
|
+
url: webhook.url
|
|
387
|
+
})
|
|
388
|
+
});
|
|
389
|
+
} catch (e) {
|
|
390
|
+
console.error("Failed to push webhook audit log", e);
|
|
391
|
+
}
|
|
363
392
|
return {};
|
|
364
393
|
}
|
|
365
394
|
);
|
package/dist/export/worker.mjs
CHANGED
|
@@ -141,24 +141,28 @@ let NotificationServiceBase = class extends develitWorker(
|
|
|
141
141
|
);
|
|
142
142
|
}
|
|
143
143
|
await this.emailConnector.sendEmail(email);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
144
|
+
try {
|
|
145
|
+
await this.pushToQueue(this.env.AUDIT_LOGS_QUEUE, {
|
|
146
|
+
logType: "event",
|
|
147
|
+
service: "notification",
|
|
148
|
+
correlationId: uuidv4(),
|
|
149
|
+
eventType: "notification.email_sent",
|
|
150
|
+
actorUserId: userId,
|
|
151
|
+
actorEmail: userId || "SYSTEM",
|
|
152
|
+
targetType: "email",
|
|
153
|
+
targetId: email.to,
|
|
154
|
+
sourceIp: ip,
|
|
155
|
+
userAgent,
|
|
156
|
+
outcome: "success",
|
|
157
|
+
description: `Email sent to ${email.to}`,
|
|
158
|
+
details: JSON.stringify({
|
|
159
|
+
subject: email.subject,
|
|
160
|
+
templateId: email.templateId
|
|
161
|
+
})
|
|
162
|
+
});
|
|
163
|
+
} catch (e) {
|
|
164
|
+
console.error("Failed to push email audit log", e);
|
|
165
|
+
}
|
|
162
166
|
return {};
|
|
163
167
|
}
|
|
164
168
|
);
|
|
@@ -191,21 +195,25 @@ let NotificationServiceBase = class extends develitWorker(
|
|
|
191
195
|
);
|
|
192
196
|
}
|
|
193
197
|
await this.smsConnector.sendSms({ message, to });
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
198
|
+
try {
|
|
199
|
+
await this.pushToQueue(this.env.AUDIT_LOGS_QUEUE, {
|
|
200
|
+
logType: "event",
|
|
201
|
+
service: "notification",
|
|
202
|
+
correlationId: uuidv4(),
|
|
203
|
+
eventType: "notification.sms_sent",
|
|
204
|
+
actorUserId: userId,
|
|
205
|
+
actorEmail: userId || "SYSTEM",
|
|
206
|
+
targetType: "sms",
|
|
207
|
+
targetId: to,
|
|
208
|
+
sourceIp: ip,
|
|
209
|
+
userAgent,
|
|
210
|
+
outcome: "success",
|
|
211
|
+
description: `SMS sent to ${to}`,
|
|
212
|
+
details: JSON.stringify({ message })
|
|
213
|
+
});
|
|
214
|
+
} catch (e) {
|
|
215
|
+
console.error("Failed to push sms audit log", e);
|
|
216
|
+
}
|
|
209
217
|
return {};
|
|
210
218
|
}
|
|
211
219
|
);
|
|
@@ -286,8 +294,25 @@ let NotificationServiceBase = class extends develitWorker(
|
|
|
286
294
|
},
|
|
287
295
|
{ successMessage: "Slack sent." },
|
|
288
296
|
async (params) => {
|
|
289
|
-
const { slack } = params;
|
|
297
|
+
const { slack, metadata } = params;
|
|
290
298
|
await this.slackConnector.sendNotificationToAllSlack(slack.message);
|
|
299
|
+
await this.pushToQueue(this.env.AUDIT_LOGS_QUEUE, {
|
|
300
|
+
logType: "event",
|
|
301
|
+
service: "notification",
|
|
302
|
+
correlationId: uuidv4(),
|
|
303
|
+
eventType: "notification.slack_sent",
|
|
304
|
+
actorUserId: metadata?.initiator?.userId,
|
|
305
|
+
actorEmail: metadata?.initiator?.userId || "SYSTEM",
|
|
306
|
+
targetType: "slack",
|
|
307
|
+
targetId: "all-channels",
|
|
308
|
+
sourceIp: metadata?.ip,
|
|
309
|
+
userAgent: metadata?.userAgent,
|
|
310
|
+
outcome: "success",
|
|
311
|
+
description: "Slack notification sent",
|
|
312
|
+
details: JSON.stringify({
|
|
313
|
+
message: slack.message
|
|
314
|
+
})
|
|
315
|
+
});
|
|
291
316
|
return {};
|
|
292
317
|
}
|
|
293
318
|
);
|
|
@@ -339,23 +364,27 @@ let NotificationServiceBase = class extends develitWorker(
|
|
|
339
364
|
this.webhookConnector = new WebhookConnector(privateKey);
|
|
340
365
|
}
|
|
341
366
|
await this.webhookConnector.sendWebhook(webhook);
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
367
|
+
try {
|
|
368
|
+
await this.pushToQueue(this.env.AUDIT_LOGS_QUEUE, {
|
|
369
|
+
logType: "event",
|
|
370
|
+
service: "notification",
|
|
371
|
+
correlationId: uuidv4(),
|
|
372
|
+
eventType: "notification.webhook_sent",
|
|
373
|
+
actorUserId: userId,
|
|
374
|
+
actorEmail: userId || "SYSTEM",
|
|
375
|
+
targetType: "webhook",
|
|
376
|
+
targetId: webhook.url,
|
|
377
|
+
sourceIp: ip,
|
|
378
|
+
userAgent,
|
|
379
|
+
outcome: "success",
|
|
380
|
+
description: `Webhook sent to ${webhook.url}`,
|
|
381
|
+
details: JSON.stringify({
|
|
382
|
+
url: webhook.url
|
|
383
|
+
})
|
|
384
|
+
});
|
|
385
|
+
} catch (e) {
|
|
386
|
+
console.error("Failed to push webhook audit log", e);
|
|
387
|
+
}
|
|
359
388
|
return {};
|
|
360
389
|
}
|
|
361
390
|
);
|