@gus-eip/loggers 4.2.5 → 4.2.7

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.
@@ -152,7 +152,9 @@ let CloudWatchLoggerService = class CloudWatchLoggerService {
152
152
  entityKey: fullLogObject.entityKey || '',
153
153
  event: fullLogObject.event || '',
154
154
  status,
155
- message: type === 'error' ? fullLogObject.errorMessage : fullLogObject.logMessage,
155
+ message: type === 'error'
156
+ ? fullLogObject.errorMessage
157
+ : fullLogObject.logMessage,
156
158
  logGroupName: this.logGroupName,
157
159
  };
158
160
  const sqsUrl = await ssm_utils_1.ssmUtils.getSqsUrl();
@@ -199,40 +201,114 @@ let CloudWatchLoggerService = class CloudWatchLoggerService {
199
201
  : typeof summary === 'object'
200
202
  ? JSON.stringify(summary)
201
203
  : summary;
202
- const alertMessage = {
203
- '@type': 'MessageCard',
204
- '@context': 'http://schema.org/extensions',
205
- summary: 'System Alert',
206
- themeColor: 'FF0000',
207
- title: `🚨 ${title} 🚨`,
208
- sections: [
209
- {
210
- facts: [
211
- {
212
- name: 'summary:',
213
- value: summaryMsg,
214
- },
215
- {
216
- name: 'component:',
217
- value: handler,
218
- },
219
- {
220
- name: 'timestamp:',
221
- value: timestamp,
222
- },
223
- {
224
- name: 'type:',
225
- value: type,
226
- },
227
- {
228
- name: '',
229
- value: `[Click here for more details](https://eu-west-1.console.aws.amazon.com/cloudwatch/home?region=eu-west-1#logsV2:log-groups/log-group/${this.logGroupName}/log-events/${logStreamName})`,
204
+ const awsLogUrl = `https://eu-west-1.console.aws.amazon.com/cloudwatch/home?region=eu-west-1#logsV2:log-groups/log-group/${this.logGroupName}/log-events/${logStreamName}`;
205
+ const isPowerAutomate = webhookUrl.includes('powerautomate');
206
+ const alertMessage = isPowerAutomate
207
+ ? {
208
+ attachments: [
209
+ {
210
+ contentType: 'application/vnd.microsoft.card.adaptive',
211
+ content: {
212
+ type: 'AdaptiveCard',
213
+ version: '1.4',
214
+ body: [
215
+ {
216
+ type: 'TextBlock',
217
+ text: `🚨 ${title} 🚨`,
218
+ weight: 'Bolder',
219
+ size: 'Large',
220
+ color: type === 'Error'
221
+ ? 'Attention'
222
+ : type === 'Warning'
223
+ ? 'Warning'
224
+ : 'Good',
225
+ },
226
+ {
227
+ type: 'TextBlock',
228
+ text: `Handler: ${handler}`,
229
+ wrap: true,
230
+ },
231
+ {
232
+ type: 'TextBlock',
233
+ text: `Timestamp: ${timestamp}`,
234
+ wrap: true,
235
+ },
236
+ {
237
+ type: 'TextBlock',
238
+ text: `Type: ${type}`,
239
+ wrap: true,
240
+ },
241
+ {
242
+ type: 'Container',
243
+ items: summary.map((item) => ({
244
+ type: 'Container',
245
+ items: Object.entries(item).map(([key, value]) => ({
246
+ type: 'ColumnSet',
247
+ columns: [
248
+ {
249
+ type: 'Column',
250
+ width: 'auto',
251
+ items: [
252
+ {
253
+ type: 'TextBlock',
254
+ text: key,
255
+ weight: 'Bolder',
256
+ wrap: true,
257
+ },
258
+ ],
259
+ },
260
+ {
261
+ type: 'Column',
262
+ width: 'stretch',
263
+ items: [
264
+ {
265
+ type: 'TextBlock',
266
+ text: typeof value === 'object'
267
+ ? JSON.stringify(value, null, 2)
268
+ : String(value !== null && value !== void 0 ? value : ''),
269
+ wrap: true,
270
+ },
271
+ ],
272
+ },
273
+ ],
274
+ })),
275
+ separator: true,
276
+ })),
277
+ },
278
+ ],
279
+ actions: [
280
+ {
281
+ type: 'Action.OpenUrl',
282
+ title: '🔍 View AWS Logs',
283
+ url: awsLogUrl,
284
+ },
285
+ ],
230
286
  },
231
- ],
232
- markdown: true,
233
- },
234
- ],
235
- };
287
+ },
288
+ ],
289
+ }
290
+ : {
291
+ '@type': 'MessageCard',
292
+ '@context': 'http://schema.org/extensions',
293
+ summary: 'System Alert',
294
+ themeColor: 'FF0000',
295
+ title: `🚨 ${title} 🚨`,
296
+ sections: [
297
+ {
298
+ facts: [
299
+ { name: 'summary:', value: summaryMsg },
300
+ { name: 'component:', value: handler },
301
+ { name: 'timestamp:', value: timestamp },
302
+ { name: 'type:', value: type },
303
+ {
304
+ name: '',
305
+ value: `[Click here for more details](${awsLogUrl})`,
306
+ },
307
+ ],
308
+ markdown: true,
309
+ },
310
+ ],
311
+ };
236
312
  try {
237
313
  await axios_1.default.post(webhookUrl, alertMessage, {
238
314
  headers: {
package/dist/enum.d.ts CHANGED
@@ -471,6 +471,18 @@ export declare class LoggerEnum {
471
471
  CREATE_ADMISSION_APPLICATION_INITIATED: string;
472
472
  CREATE_ADMISSION_APPLICATION_COMPLETED: string;
473
473
  PROCESSING_OBJECT_TYPES_INITIATED: string;
474
+ CLOSE_CAMPAIGN_MEETING: string;
475
+ INVOKE_ZOOM_BOX_SYNC_TASK: string;
476
+ CREATE_CAMPAIGN: string;
477
+ UPDATE_CAMPAIGN: string;
478
+ REGISTER_CAMPAIGN_MEMBER: string;
479
+ GET_CAMPAIGN: string;
480
+ GET_CAMPAIGN_MEMBER: string;
481
+ URL_VALIDATION: string;
482
+ DELETE_ZOOM_RECORDING: string;
483
+ INITIATE_FILE_SYNC: string;
484
+ COMPLETED_FILE_SYNC: string;
485
+ FILE_SYNC_ZOOM_BOX: string;
474
486
  };
475
487
  UseCase: {
476
488
  PROGRAM_INFO: string;
@@ -607,6 +619,12 @@ export declare class LoggerEnum {
607
619
  SUPPORTING_INFORMATION: string;
608
620
  RECOMMENDATIONS: string;
609
621
  STUDENT_ACCESSIBILITY_AND_DECLARATIONS: string;
622
+ WEBINAR_CREATED: string;
623
+ WEBINAR_ENDED: string;
624
+ WEBINAR_REGISTRATION_CREATED: string;
625
+ WEBINAR_RECORDING_COMPLETED: string;
626
+ ZOOM_WEBINAR_EVENT_RECEIVED: string;
627
+ ZOOM_WEBHOOK_URL_VALIDATION: string;
610
628
  };
611
629
  Component: {
612
630
  OAP_FRONTEND: string;
@@ -682,5 +700,14 @@ export declare class LoggerEnum {
682
700
  SFTP_CONNECTOR: string;
683
701
  UNFC_GUS_SALESFORCE_INTEGRATION_HANDLER: string;
684
702
  UNFC_GUS_SALESFORCE_INTEGRATION_QUEUE: string;
703
+ ZOOM_INTEGRATION_PROCESS_HANDLER: string;
704
+ ZOOM_INTEGRAION_SERVICE: string;
705
+ ZOOM_BOX_SYNC_ALERT_JOB_SCHEDULER: string;
706
+ ZOOM_BOX_SYNC_ALERTING_HANDLER: string;
707
+ ZOOM_BOX_SYNC_SERVICE: string;
708
+ ZOOM_EVENTS_QUEUE: string;
709
+ ZOOM_WEBHOOK: string;
710
+ BOX: string;
711
+ ZOOM: string;
685
712
  };
686
713
  }
package/dist/enum.js CHANGED
@@ -482,6 +482,18 @@ let LoggerEnum = class LoggerEnum {
482
482
  CREATE_ADMISSION_APPLICATION_INITIATED: 'CREATE_ADMISSION_APPLICATION_INITIATED',
483
483
  CREATE_ADMISSION_APPLICATION_COMPLETED: 'CREATE_ADMISSION_APPLICATION_COMPLETED',
484
484
  PROCESSING_OBJECT_TYPES_INITIATED: 'PROCESSING_OBJECT_TYPES_INITIATED',
485
+ CLOSE_CAMPAIGN_MEETING: 'CLOSE_CAMPAIGN_MEETING',
486
+ INVOKE_ZOOM_BOX_SYNC_TASK: 'INVOKE_ZOOM_BOX_SYNC_TASK',
487
+ CREATE_CAMPAIGN: 'CREATE_CAMPAIGN',
488
+ UPDATE_CAMPAIGN: 'UPDATE_CAMPAIGN',
489
+ REGISTER_CAMPAIGN_MEMBER: 'REGISTER_CAMPAIGN_MEMBER',
490
+ GET_CAMPAIGN: 'GET_CAMPAIGN',
491
+ GET_CAMPAIGN_MEMBER: 'GET_CAMPAIGN_MEMBER',
492
+ URL_VALIDATION: 'URL_VALIDATION',
493
+ DELETE_ZOOM_RECORDING: 'DELETE_ZOOM_RECORDING',
494
+ INITIATE_FILE_SYNC: 'INITIATE_FILE_SYNC',
495
+ COMPLETED_FILE_SYNC: 'COMPLETED_FILE_SYNC',
496
+ FILE_SYNC_ZOOM_BOX: 'FILE_SYNC_ZOOM_BOX',
485
497
  };
486
498
  this.UseCase = {
487
499
  PROGRAM_INFO: 'SAVE_PROGRAMME_DETAILS',
@@ -618,6 +630,12 @@ let LoggerEnum = class LoggerEnum {
618
630
  SUPPORTING_INFORMATION: 'SAVE_SUPPORTING_INFORMATION',
619
631
  RECOMMENDATIONS: 'SAVE_RECOMMENDATIONS',
620
632
  STUDENT_ACCESSIBILITY_AND_DECLARATIONS: 'SAVE_STUDENT_ACCESSIBILITY_AND_DECLARATIONS',
633
+ WEBINAR_CREATED: 'WEBINAR_CREATED',
634
+ WEBINAR_ENDED: 'WEBINAR_ENDED',
635
+ WEBINAR_REGISTRATION_CREATED: 'WEBINAR_REGISTRATION_CREATED',
636
+ WEBINAR_RECORDING_COMPLETED: 'WEBINAR_RECORDING_COMPLETED',
637
+ ZOOM_WEBINAR_EVENT_RECEIVED: 'ZOOM_WEBINAR_EVENT_RECEIVED',
638
+ ZOOM_WEBHOOK_URL_VALIDATION: 'ZOOM_WEBHOOK_URL_VALIDATION',
621
639
  };
622
640
  this.Component = {
623
641
  OAP_FRONTEND: 'OAP-FRONTEND',
@@ -693,6 +711,15 @@ let LoggerEnum = class LoggerEnum {
693
711
  SFTP_CONNECTOR: 'SFTP_CONNECTOR',
694
712
  UNFC_GUS_SALESFORCE_INTEGRATION_HANDLER: 'UNFC_GUS_SALESFORCE_INTEGRATION_HANDLER',
695
713
  UNFC_GUS_SALESFORCE_INTEGRATION_QUEUE: 'UNFC_GUS_SALESFORCE_INTEGRATION_QUEUE',
714
+ ZOOM_INTEGRATION_PROCESS_HANDLER: 'ZOOM_INTEGRATION_PROCESS_HANDLER',
715
+ ZOOM_INTEGRAION_SERVICE: 'ZOOM_INTEGRAION_SERVICE',
716
+ ZOOM_BOX_SYNC_ALERT_JOB_SCHEDULER: 'ZOOM_BOX_SYNC_ALERT_JOB_SCHEDULER',
717
+ ZOOM_BOX_SYNC_ALERTING_HANDLER: 'ZOOM_BOX_SYNC_ALERTING_HANDLER',
718
+ ZOOM_BOX_SYNC_SERVICE: 'ZOOM_BOX_SYNC_SERVICE',
719
+ ZOOM_EVENTS_QUEUE: 'ZOOM_EVENTS_QUEUE',
720
+ ZOOM_WEBHOOK: 'ZOOM_WEBHOOK',
721
+ BOX: 'BOX',
722
+ ZOOM: 'ZOOM',
696
723
  };
697
724
  }
698
725
  };
package/dist/test.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const axios: any;
2
+ declare function sendNotificationtoTeams(title: any, summary: any, handler: any, logStreamName: any, isFormattingRequired: boolean, type: any): Promise<any>;
package/dist/test.js ADDED
@@ -0,0 +1,168 @@
1
+ const axios = require('axios');
2
+ async function sendNotificationtoTeams(title, summary, handler, logStreamName, isFormattingRequired = true, type) {
3
+ console.log('Notification summary', summary);
4
+ const webhookUrl = 'https://gus.webhook.office.com/webhookb2/a7847242-acac-4b2e-9d64-a3818681a2ec@5665ee7a-3634-4975-9c21-2778cda48edd/IncomingWebhook/6b32fef8240843359b1b3e902fb4d716/e06d3c50-7be6-44a2-87e7-48a4696d8297/V26sOW3X1erzRoeQSKP8rq1toiHD1Qtr41icu1ZxSHyh01';
5
+ const timestamp = new Date().toISOString();
6
+ let headers;
7
+ let headerRow;
8
+ let separatorRow;
9
+ let rows;
10
+ let formattedSummary;
11
+ if (isFormattingRequired) {
12
+ headers = Object.keys(summary[0]);
13
+ headerRow = `| ${headers.join(' | ')} |`;
14
+ separatorRow = `| ${headers.map(() => '---').join(' | ')} |`;
15
+ rows = summary
16
+ .map((item) => `| ${headers.map((header) => item[header] || '').join(' | ')} |`)
17
+ .join('\n');
18
+ formattedSummary = [headerRow, separatorRow, rows].join('\n');
19
+ }
20
+ const summaryMsg = isFormattingRequired
21
+ ? formattedSummary
22
+ : typeof summary === 'object'
23
+ ? JSON.stringify(summary)
24
+ : summary;
25
+ const awsLogUrl = `https://eu-west-1.console.aws.amazon.com/cloudwatch/home?region=eu-west-1#logsV2:log-groups/log-group/${this.logGroupName}/log-events/${logStreamName}`;
26
+ const isPowerAutomate = webhookUrl.includes('powerautomate');
27
+ const alertMessage = isPowerAutomate
28
+ ? {
29
+ attachments: [
30
+ {
31
+ contentType: 'application/vnd.microsoft.card.adaptive',
32
+ content: {
33
+ type: 'AdaptiveCard',
34
+ version: '1.4',
35
+ body: [
36
+ {
37
+ type: 'TextBlock',
38
+ text: `🚨 ${title} 🚨`,
39
+ weight: 'Bolder',
40
+ size: 'Large',
41
+ color: type === 'Error'
42
+ ? 'Attention'
43
+ : type === 'Warning'
44
+ ? 'Warning'
45
+ : 'Good',
46
+ },
47
+ {
48
+ type: 'TextBlock',
49
+ text: `Handler: ${handler}`,
50
+ wrap: true,
51
+ },
52
+ {
53
+ type: 'TextBlock',
54
+ text: `Timestamp: ${timestamp}`,
55
+ wrap: true,
56
+ },
57
+ {
58
+ type: 'TextBlock',
59
+ text: `Type: ${type}`,
60
+ wrap: true,
61
+ },
62
+ {
63
+ type: 'Container',
64
+ items: summary.map((item) => ({
65
+ type: 'Container',
66
+ items: Object.entries(item).map(([key, value]) => ({
67
+ type: 'ColumnSet',
68
+ columns: [
69
+ {
70
+ type: 'Column',
71
+ width: 'auto',
72
+ items: [
73
+ {
74
+ type: 'TextBlock',
75
+ text: key,
76
+ weight: 'Bolder',
77
+ wrap: true,
78
+ },
79
+ ],
80
+ },
81
+ {
82
+ type: 'Column',
83
+ width: 'stretch',
84
+ items: [
85
+ {
86
+ type: 'TextBlock',
87
+ text: typeof value === 'object'
88
+ ? JSON.stringify(value, null, 2)
89
+ : String(value !== null && value !== void 0 ? value : ''),
90
+ wrap: true,
91
+ },
92
+ ],
93
+ },
94
+ ],
95
+ })),
96
+ separator: true,
97
+ })),
98
+ },
99
+ ],
100
+ actions: [
101
+ {
102
+ type: 'Action.OpenUrl',
103
+ title: '🔍 View AWS Logs',
104
+ url: awsLogUrl,
105
+ },
106
+ ],
107
+ },
108
+ },
109
+ ],
110
+ }
111
+ : {
112
+ '@type': 'MessageCard',
113
+ '@context': 'http://schema.org/extensions',
114
+ summary: 'System Alert',
115
+ themeColor: type === 'Error'
116
+ ? 'FF0000'
117
+ : type === 'Warning'
118
+ ? 'FFFF00'
119
+ : '00FF00',
120
+ title: `🚨 ${title} 🚨`,
121
+ sections: [
122
+ {
123
+ facts: [
124
+ { name: 'summary:', value: summaryMsg },
125
+ { name: 'component:', value: handler },
126
+ { name: 'timestamp:', value: timestamp },
127
+ { name: 'type:', value: type },
128
+ {
129
+ name: '',
130
+ value: `[Click here for more details](${awsLogUrl})`,
131
+ },
132
+ ],
133
+ markdown: true,
134
+ },
135
+ ],
136
+ };
137
+ try {
138
+ await axios.post(webhookUrl, alertMessage, {
139
+ headers: {
140
+ 'Content-Type': 'application/json',
141
+ },
142
+ });
143
+ console.log('Message sent successfully');
144
+ }
145
+ catch (error) {
146
+ console.error('Error sending message:', error);
147
+ }
148
+ }
149
+ (async () => {
150
+ await sendNotificationtoTeams('Test Alert', [
151
+ {
152
+ job: 'gus-dlq-alert-job',
153
+ runStatus: 'Started',
154
+ ErrorsCount: 0,
155
+ },
156
+ {
157
+ job: 'kyb-kyc-event-listener',
158
+ totalhrsRun: 24,
159
+ listenerErrorsCount: 0,
160
+ },
161
+ {
162
+ job: 'kyb-kyc-verification-process',
163
+ screeningEnquiryCount: 0,
164
+ screeningEnquiryFeedbackCount: 0,
165
+ sfErrorsCount: 0,
166
+ },
167
+ ], 'ZoomToBoxSyncHandler', 'TestStream123', true, 'Error');
168
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gus-eip/loggers",
3
- "version": "4.2.5",
3
+ "version": "4.2.7",
4
4
  "description": "@gus-eip/loggers is a package designed to provide logging functionality for your Node.js applications.",
5
5
  "author": "gus",
6
6
  "readmeFilename": "README.md",