@gus-eip/loggers 3.8.8 → 3.9.0

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.
@@ -21,5 +21,6 @@ export declare class CloudWatchLoggerService implements ILogger {
21
21
  source: string;
22
22
  destination: string;
23
23
  }>;
24
+ getUsecase(usecase: string): Promise<string>;
24
25
  logAlert(correlationId: string, timestamp: string, component: string, source: string, destination: string, event: string, usecase: string, sourcePayload: any, destinationPayload: any, logMessage: any, brand: any, secondaryKey: string, logStreamName: string, isAlertFormattingRequired?: boolean, type?: 'INFO' | 'Error', destinationObjectType?: string, destinationObjectId?: string, sourceObjectType?: string, sourceObjectId?: string, destinationResponse?: any): Promise<any>;
25
26
  }
@@ -17,6 +17,7 @@ const axios_1 = require("axios");
17
17
  const source_destination_mapping_1 = require("./mappings/source-destination-mapping");
18
18
  const enum_1 = require("./enum");
19
19
  const ssm_utils_1 = require("./ssm-utils");
20
+ const usecase_mapping_1 = require("./mappings/usecase-mapping");
20
21
  let CloudWatchLoggerService = class CloudWatchLoggerService {
21
22
  constructor(region, logGroupName, teamWebhookUrl, isAlertNeeded) {
22
23
  this.loggerEnum = new enum_1.LoggerEnum();
@@ -151,17 +152,28 @@ let CloudWatchLoggerService = class CloudWatchLoggerService {
151
152
  entityKey: fullLogObject.entityKey || '',
152
153
  event: fullLogObject.event || '',
153
154
  status,
155
+ message: fullLogObject.logMessage || '',
154
156
  };
155
157
  const sqsUrl = await ssm_utils_1.ssmUtils.getSqsUrl();
156
- const results = await Promise.allSettled([
157
- this.logToCloudWatch(type, fullLogObject, logStreamName),
158
- this.sendToSQS(logEvent, sqsUrl),
159
- ]);
160
- results.forEach((result, index) => {
161
- if (result.status === 'rejected') {
162
- console.error(`Error in ${index === 0 ? 'logToCloudWatch' : 'sendToSQS'}:`, result.reason);
158
+ if (status === 'IN_PROGRESS' || !sqsUrl) {
159
+ try {
160
+ await this.logToCloudWatch(type, fullLogObject, logStreamName);
163
161
  }
164
- });
162
+ catch (error) {
163
+ console.error('Error logging to CloudWatch:', error);
164
+ }
165
+ }
166
+ else {
167
+ const results = await Promise.allSettled([
168
+ this.logToCloudWatch(type, fullLogObject, logStreamName),
169
+ this.sendToSQS(logEvent, sqsUrl),
170
+ ]);
171
+ results.forEach((result, index) => {
172
+ if (result.status === 'rejected') {
173
+ console.error(`Error in ${index === 0 ? 'logToCloudWatch' : 'sendToSQS'}:`, result.reason);
174
+ }
175
+ });
176
+ }
165
177
  }
166
178
  async sendNotificationtoTeams(title, summary, handler, logStreamName, isFormattingRequired = true, type) {
167
179
  console.log('Notification summary', summary);
@@ -255,7 +267,9 @@ let CloudWatchLoggerService = class CloudWatchLoggerService {
255
267
  sourceObjectId,
256
268
  destinationResponse,
257
269
  };
258
- const status = event === this.loggerEnum.Event.OPERATION_COMPLETED ? 'COMPLETED' : 'IN_PROGRESS';
270
+ const status = event === this.loggerEnum.Event.OPERATION_COMPLETED
271
+ ? 'COMPLETED'
272
+ : 'IN_PROGRESS';
259
273
  await this.processLog('info', logStreamName, logObject, status);
260
274
  }
261
275
  async error(correlationId, timestamp, component, source, destination, event, usecase, sourcePayload, destinationPayload, errorMessage, brand, secondaryKey, logStreamName, entityKeyField, entityKey, destinationObjectType, destinationObjectId, sourceObjectType, sourceObjectId, destinationResponse) {
@@ -295,7 +309,6 @@ let CloudWatchLoggerService = class CloudWatchLoggerService {
295
309
  };
296
310
  try {
297
311
  await sqs.sendMessage(params).promise();
298
- console.log('Log event successfully sent to SQS:', logEvent);
299
312
  }
300
313
  catch (error) {
301
314
  console.error('Failed to send log event to SQS:', error);
@@ -307,6 +320,9 @@ let CloudWatchLoggerService = class CloudWatchLoggerService {
307
320
  ? { source: mapping.source, destination: mapping.destination }
308
321
  : null;
309
322
  }
323
+ async getUsecase(usecase) {
324
+ return usecase_mapping_1.UsecaseMapping[usecase] || '';
325
+ }
310
326
  async logAlert(correlationId, timestamp, component, source, destination, event, usecase, sourcePayload, destinationPayload, logMessage, brand, secondaryKey, logStreamName, isAlertFormattingRequired, type, destinationObjectType, destinationObjectId, sourceObjectType, sourceObjectId, destinationResponse) {
311
327
  const logObject = {
312
328
  correlationId,
@@ -8,4 +8,5 @@ export interface LogEvent {
8
8
  entityKey: string;
9
9
  event: any;
10
10
  status: string;
11
+ message: string;
11
12
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BRAND_USECASE_MAPPING = void 0;
4
4
  exports.BRAND_USECASE_MAPPING = [
5
5
  {
6
- brands: ['LIM', 'HZU', 'IBAT', 'LSBFMYR'],
6
+ brands: ['LIM College', 'HZU', 'IBAT', 'LSBFMYR'],
7
7
  usecase: 'SAVE_BASIC_DETAILS',
8
8
  source: 'OAP',
9
9
  destination: 'GUS Salesforce',
@@ -27,13 +27,13 @@ exports.BRAND_USECASE_MAPPING = [
27
27
  destination: 'GUS Salesforce',
28
28
  },
29
29
  {
30
- brands: ['LIM', 'HZU', 'IBAT'],
30
+ brands: ['LIM College', 'HZU', 'IBAT'],
31
31
  usecase: 'SAVE_ADDITIONAL_INFORMATION',
32
32
  source: 'OAP',
33
33
  destination: 'GUS Salesforce',
34
34
  },
35
35
  {
36
- brands: ['LIM', 'HZU'],
36
+ brands: ['LIM College', 'HZU'],
37
37
  usecase: 'SAVE_ACADEMIC_INFORMATION',
38
38
  source: 'OAP',
39
39
  destination: 'GUS Salesforce',
@@ -45,7 +45,7 @@ exports.BRAND_USECASE_MAPPING = [
45
45
  destination: 'GUS Salesforce',
46
46
  },
47
47
  {
48
- brands: ['LIM', 'HZU', 'IBAT', 'LSBFMYR'],
48
+ brands: ['LIM College', 'HZU', 'IBAT', 'LSBFMYR'],
49
49
  usecase: 'SAVE_PERSONAL_DETAILS',
50
50
  source: 'OAP',
51
51
  destination: 'GUS Salesforce',
@@ -57,19 +57,19 @@ exports.BRAND_USECASE_MAPPING = [
57
57
  destination: 'GUS Salesforce',
58
58
  },
59
59
  {
60
- brands: ['LIM', 'HZU', 'IBAT', 'LSBFMYR', 'UNFC'],
60
+ brands: ['LIM College', 'HZU', 'IBAT', 'LSBFMYR', 'UNFC'],
61
61
  usecase: 'SUBMIT_APPLICATION',
62
62
  source: 'OAP',
63
63
  destination: 'GUS Salesforce',
64
64
  },
65
65
  {
66
- brands: ['LIM', 'HZU', 'IBAT', 'LSBFMYR', 'UNFC'],
66
+ brands: ['LIM College', 'HZU', 'IBAT', 'LSBFMYR', 'UNFC'],
67
67
  usecase: 'UPLOAD_DOCUMENT',
68
68
  source: 'OAP',
69
69
  destination: 'GUS Salesforce',
70
70
  },
71
71
  {
72
- brands: ['LIM', 'HZU', 'IBAT', 'LSBFMYR', 'UNFC'],
72
+ brands: ['LIM College', 'HZU', 'IBAT', 'LSBFMYR', 'UNFC'],
73
73
  usecase: 'GUS_SALESFORCE_OPERATION',
74
74
  source: 'OAP',
75
75
  destination: 'GUS Salesforce',
@@ -93,7 +93,7 @@ exports.BRAND_USECASE_MAPPING = [
93
93
  destination: 'GUS Salesforce',
94
94
  },
95
95
  {
96
- brands: ['UCW', 'LIM'],
96
+ brands: ['UCW', 'LIM College'],
97
97
  usecase: 'SAVE_EMPLOYMENT_HISTORY_DETAILS',
98
98
  source: 'OAP',
99
99
  destination: 'GUS Salesforce',
@@ -111,7 +111,7 @@ exports.BRAND_USECASE_MAPPING = [
111
111
  destination: 'GUS Salesforce',
112
112
  },
113
113
  {
114
- brands: ['LIM', 'HZU', 'IBAT', 'LSBFMYR', 'UNFC'],
114
+ brands: ['LIM College', 'HZU', 'IBAT', 'LSBFMYR', 'UNFC'],
115
115
  usecase: 'SAVE_PROGRAMME_DETAILS',
116
116
  source: 'OAP',
117
117
  destination: 'GUS Salesforce',
@@ -123,25 +123,25 @@ exports.BRAND_USECASE_MAPPING = [
123
123
  destination: 'GUS Salesforce',
124
124
  },
125
125
  {
126
- brands: ['LIM'],
126
+ brands: ['LIM College'],
127
127
  usecase: 'SAVE_PRIVACY_PROTECTION_POLICY_DETAILS',
128
128
  source: 'OAP',
129
129
  destination: 'GUS Salesforce',
130
130
  },
131
131
  {
132
- brands: ['LIM', 'IBAT', 'LSBFMYR'],
132
+ brands: ['LIM College', 'IBAT', 'LSBFMYR'],
133
133
  usecase: 'SAVE_DECLARATION_DETAILS',
134
134
  source: 'OAP',
135
135
  destination: 'GUS Salesforce',
136
136
  },
137
137
  {
138
- brands: ['LIM', 'LSBFMYR'],
138
+ brands: ['LIM College', 'LSBFMYR'],
139
139
  usecase: 'SAVE_TEST_INFORMATION',
140
140
  source: 'OAP',
141
141
  destination: 'GUS Salesforce',
142
142
  },
143
143
  {
144
- brands: ['HZU', 'LIM'],
144
+ brands: ['HZU', 'LIM College'],
145
145
  usecase: 'SAVE_FINANCIAL_DOCUMENT',
146
146
  source: 'OAP',
147
147
  destination: 'GUS Salesforce',
@@ -153,13 +153,13 @@ exports.BRAND_USECASE_MAPPING = [
153
153
  destination: 'GUS Salesforce',
154
154
  },
155
155
  {
156
- brands: ['LIM'],
156
+ brands: ['LIM College'],
157
157
  usecase: 'SAVE_ADMISSION_RECOMMENDATION_LETTER_DETAILS',
158
158
  source: 'OAP',
159
159
  destination: 'GUS Salesforce',
160
160
  },
161
161
  {
162
- brands: ['LIM'],
162
+ brands: ['LIM College'],
163
163
  usecase: 'SAVE_REQUIRED_ESSAY_RESUME_DETAILS',
164
164
  source: 'OAP',
165
165
  destination: 'GUS Salesforce',
@@ -171,13 +171,13 @@ exports.BRAND_USECASE_MAPPING = [
171
171
  destination: 'GUS Salesforce',
172
172
  },
173
173
  {
174
- brands: ['LIM'],
174
+ brands: ['LIM College'],
175
175
  usecase: 'SAVE_HONESTY_STATEMENT_DETAILS',
176
176
  source: 'OAP',
177
177
  destination: 'GUS Salesforce',
178
178
  },
179
179
  {
180
- brands: ['LIM'],
180
+ brands: ['LIM College'],
181
181
  usecase: 'SAVE_LEGAL_NOTICE_DETAILS',
182
182
  source: 'OAP',
183
183
  destination: 'GUS Salesforce',
@@ -0,0 +1,55 @@
1
+ export declare enum UsecaseMapping {
2
+ SAVE_PROGRAMME_DETAILS = "Save Programme Details",
3
+ SAVE_APPLICANT_INFO = "Save Applicant Information",
4
+ SAVE_EMERGENCY_CONTACT_DETAILS = "Save Emergency Contact Details",
5
+ SAVE_BASIC_DETAILS = "Save Basic Details",
6
+ SAVE_ADDITIONAL_INFORMATION = "Save Additional Information",
7
+ SAVE_CONTACT_INFO = "Save Contact Information",
8
+ SAVE_ACADEMIC_INFORMATION = "Save Academic Information",
9
+ SAVE_PERSONAL_DETAILS = "Save Personal Details",
10
+ SAVE_TERMS_AND_CONDITIONS = "Save Terms and Conditions",
11
+ SUBMIT_APPLICATION = "Application Submitted",
12
+ UPLOAD_DOCUMENT = "Document Uploaded",
13
+ SAVE_COURSE_SELECTION_DETAILS = "Save Course Selection Details",
14
+ SAVE_EDUCATION_HISTORY_DETAILS = "Save Education History Details",
15
+ SAVE_STANDARDIZED_TESTS_DETAILS = "Save Standardized Test Details",
16
+ SAVE_EMPLOYMENT_HISTORY_DETAILS = "Save Employment History Details",
17
+ SAVE_ADDITIONAL_DOCUMENTS_DETAILS = "Save Additional Documents",
18
+ SAVE_TRANSFER_CREDITS_DETAILS = "Save Transfer Credits Details",
19
+ SAVE_AWARDS_DETAILS = "Save Awards Details",
20
+ SAVE_PRIVACY_PROTECTION_POLICY_DETAILS = "Save Privacy Policy Details",
21
+ SAVE_DECLARATION_DETAILS = "Save Declaration Details",
22
+ SAVE_TEST_INFORMATION = "Save Test Information",
23
+ SAVE_FINANCIAL_DOCUMENT = "Save Financial Document",
24
+ SAVE_ADDITIONAL_SERVICES_INFORMATION = "Save Additional Services Information",
25
+ SAVE_ADMISSION_RECOMMENDATION_LETTER_DETAILS = "Save Admission Recommendation Letter",
26
+ SAVE_REQUIRED_ESSAY_RESUME_DETAILS = "Save Required Essay or Resume",
27
+ SAVE_INTERNATIONAL_STUDENT_CONSENT_FORM_DETAILS = "Save International Student Consent Form",
28
+ SAVE_HONESTY_STATEMENT_DETAILS = "Save Honesty Statement",
29
+ SAVE_LEGAL_NOTICE_DETAILS = "Save Legal Notice",
30
+ GUS_NEW_APPLICATION = "Application sync",
31
+ DOCUMENT_CHECKLIST_CREATED = "Document checklist item creation",
32
+ GUS_DOCUMENT_UPDATE = "Document sync",
33
+ SYNC_GUS_TO_HZU = "Application sync",
34
+ OPPORTUNITY_VISA_APPROVED = "Application visa approval",
35
+ CONDITIONAL_OFFER = "Offer letter issued",
36
+ OPPORTUNITY_REVOKED_CLOSED_LOST = "Application reopened",
37
+ OPPORTUNITY_CLOSED_LOST = "Institutional withdrawal",
38
+ OPPORTUNITY_CLOSED_WON = "Application enrolment",
39
+ Payment = "Deposit payment",
40
+ REJECTED_DOCUMENT_TASK = "Document rejection",
41
+ I_20 = "I20 issued",
42
+ GUS_NEW_DOCUMENT = "Document sync",
43
+ GUS_CLARIFICATION_SUBMITTED = "Clarification submission",
44
+ UCW_OFFERED = "Offer letter issued",
45
+ UCW_DOCUMENT_ISSUED = "Admission document issued",
46
+ UCW_VISA_APPROVED = "Application visa approval",
47
+ UCW_ENROLLED = "Application enrolment",
48
+ UCW_FOLLOWUP_TASK = "Institutional comment",
49
+ UCW_REJECT_APPLICATION = "Institutional rejection",
50
+ UCW_WITHDRAW_OFFER = "Offer withdrawn",
51
+ UCW_WITHDRAW_APPLICATION = "Application withdrawn",
52
+ UCW_REJECT_APPLICATION_VS = "Application visa rejection",
53
+ UCW_REJECT_DOCUMENT = "Document rejection",
54
+ UCW_APPLICATION_DEFERRED = "Application deferred"
55
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UsecaseMapping = void 0;
4
+ var UsecaseMapping;
5
+ (function (UsecaseMapping) {
6
+ UsecaseMapping["SAVE_PROGRAMME_DETAILS"] = "Save Programme Details";
7
+ UsecaseMapping["SAVE_APPLICANT_INFO"] = "Save Applicant Information";
8
+ UsecaseMapping["SAVE_EMERGENCY_CONTACT_DETAILS"] = "Save Emergency Contact Details";
9
+ UsecaseMapping["SAVE_BASIC_DETAILS"] = "Save Basic Details";
10
+ UsecaseMapping["SAVE_ADDITIONAL_INFORMATION"] = "Save Additional Information";
11
+ UsecaseMapping["SAVE_CONTACT_INFO"] = "Save Contact Information";
12
+ UsecaseMapping["SAVE_ACADEMIC_INFORMATION"] = "Save Academic Information";
13
+ UsecaseMapping["SAVE_PERSONAL_DETAILS"] = "Save Personal Details";
14
+ UsecaseMapping["SAVE_TERMS_AND_CONDITIONS"] = "Save Terms and Conditions";
15
+ UsecaseMapping["SUBMIT_APPLICATION"] = "Application Submitted";
16
+ UsecaseMapping["UPLOAD_DOCUMENT"] = "Document Uploaded";
17
+ UsecaseMapping["SAVE_COURSE_SELECTION_DETAILS"] = "Save Course Selection Details";
18
+ UsecaseMapping["SAVE_EDUCATION_HISTORY_DETAILS"] = "Save Education History Details";
19
+ UsecaseMapping["SAVE_STANDARDIZED_TESTS_DETAILS"] = "Save Standardized Test Details";
20
+ UsecaseMapping["SAVE_EMPLOYMENT_HISTORY_DETAILS"] = "Save Employment History Details";
21
+ UsecaseMapping["SAVE_ADDITIONAL_DOCUMENTS_DETAILS"] = "Save Additional Documents";
22
+ UsecaseMapping["SAVE_TRANSFER_CREDITS_DETAILS"] = "Save Transfer Credits Details";
23
+ UsecaseMapping["SAVE_AWARDS_DETAILS"] = "Save Awards Details";
24
+ UsecaseMapping["SAVE_PRIVACY_PROTECTION_POLICY_DETAILS"] = "Save Privacy Policy Details";
25
+ UsecaseMapping["SAVE_DECLARATION_DETAILS"] = "Save Declaration Details";
26
+ UsecaseMapping["SAVE_TEST_INFORMATION"] = "Save Test Information";
27
+ UsecaseMapping["SAVE_FINANCIAL_DOCUMENT"] = "Save Financial Document";
28
+ UsecaseMapping["SAVE_ADDITIONAL_SERVICES_INFORMATION"] = "Save Additional Services Information";
29
+ UsecaseMapping["SAVE_ADMISSION_RECOMMENDATION_LETTER_DETAILS"] = "Save Admission Recommendation Letter";
30
+ UsecaseMapping["SAVE_REQUIRED_ESSAY_RESUME_DETAILS"] = "Save Required Essay or Resume";
31
+ UsecaseMapping["SAVE_INTERNATIONAL_STUDENT_CONSENT_FORM_DETAILS"] = "Save International Student Consent Form";
32
+ UsecaseMapping["SAVE_HONESTY_STATEMENT_DETAILS"] = "Save Honesty Statement";
33
+ UsecaseMapping["SAVE_LEGAL_NOTICE_DETAILS"] = "Save Legal Notice";
34
+ UsecaseMapping["GUS_NEW_APPLICATION"] = "Application sync";
35
+ UsecaseMapping["DOCUMENT_CHECKLIST_CREATED"] = "Document checklist item creation";
36
+ UsecaseMapping["GUS_DOCUMENT_UPDATE"] = "Document sync";
37
+ UsecaseMapping["SYNC_GUS_TO_HZU"] = "Application sync";
38
+ UsecaseMapping["OPPORTUNITY_VISA_APPROVED"] = "Application visa approval";
39
+ UsecaseMapping["CONDITIONAL_OFFER"] = "Offer letter issued";
40
+ UsecaseMapping["OPPORTUNITY_REVOKED_CLOSED_LOST"] = "Application reopened";
41
+ UsecaseMapping["OPPORTUNITY_CLOSED_LOST"] = "Institutional withdrawal";
42
+ UsecaseMapping["OPPORTUNITY_CLOSED_WON"] = "Application enrolment";
43
+ UsecaseMapping["Payment"] = "Deposit payment";
44
+ UsecaseMapping["REJECTED_DOCUMENT_TASK"] = "Document rejection";
45
+ UsecaseMapping["I_20"] = "I20 issued";
46
+ UsecaseMapping["GUS_NEW_DOCUMENT"] = "Document sync";
47
+ UsecaseMapping["GUS_CLARIFICATION_SUBMITTED"] = "Clarification submission";
48
+ UsecaseMapping["UCW_OFFERED"] = "Offer letter issued";
49
+ UsecaseMapping["UCW_DOCUMENT_ISSUED"] = "Admission document issued";
50
+ UsecaseMapping["UCW_VISA_APPROVED"] = "Application visa approval";
51
+ UsecaseMapping["UCW_ENROLLED"] = "Application enrolment";
52
+ UsecaseMapping["UCW_FOLLOWUP_TASK"] = "Institutional comment";
53
+ UsecaseMapping["UCW_REJECT_APPLICATION"] = "Institutional rejection";
54
+ UsecaseMapping["UCW_WITHDRAW_OFFER"] = "Offer withdrawn";
55
+ UsecaseMapping["UCW_WITHDRAW_APPLICATION"] = "Application withdrawn";
56
+ UsecaseMapping["UCW_REJECT_APPLICATION_VS"] = "Application visa rejection";
57
+ UsecaseMapping["UCW_REJECT_DOCUMENT"] = "Document rejection";
58
+ UsecaseMapping["UCW_APPLICATION_DEFERRED"] = "Application deferred";
59
+ })(UsecaseMapping || (exports.UsecaseMapping = UsecaseMapping = {}));
package/dist/ssm-utils.js CHANGED
@@ -26,7 +26,6 @@ class SsmUtils {
26
26
  return this.cachedSqsUrl;
27
27
  }
28
28
  catch (error) {
29
- console.error('Error fetching SQS URL from SSM:', error);
30
29
  return "";
31
30
  }
32
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gus-eip/loggers",
3
- "version": "3.8.8",
3
+ "version": "3.9.0",
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",