@geniehr/utilities 1.0.14 → 1.0.16

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.
@@ -2,10 +2,10 @@ export declare class ConductorClient {
2
2
  private client;
3
3
  private workers;
4
4
  constructor(serviceName?: string);
5
- startWorkflow(name: string, version: number, input: any, correlationId?: string): Promise<any>;
5
+ startWorkflow(name: string, input: any, correlationId?: string, version?: number): Promise<any>;
6
6
  registerWorker(taskType: string, execute: (input: any) => Promise<any>, pollInterval?: number, domain?: string): Promise<void>;
7
7
  private poll;
8
8
  updateTask(taskId: string, workflowInstanceId: string, status: string, outputData: any, reasonForIncompletion?: string): Promise<void>;
9
- getWorkflowByCorrelationId(name: string, correlationId: string): Promise<any>;
10
9
  getTask(workflowInstanceId: string, taskReferenceName: string): Promise<any>;
10
+ getWorkflow(workflowInstanceId: string, includeTasks?: boolean): Promise<any>;
11
11
  }
@@ -12,14 +12,17 @@ export class ConductorClient {
12
12
  });
13
13
  console.log(`ConductorClient initialized for ${serviceName}`);
14
14
  }
15
- async startWorkflow(name, version, input, correlationId) {
15
+ async startWorkflow(name, input, correlationId, version) {
16
16
  try {
17
- const response = await this.client.post('/workflow', {
17
+ const payload = {
18
18
  name,
19
- version,
20
19
  input,
21
20
  correlationId
22
- });
21
+ };
22
+ if (version) {
23
+ payload.version = version;
24
+ }
25
+ const response = await this.client.post('/workflow', payload);
23
26
  console.log(`Started workflow ${name} v${version}: ${JSON.stringify(response.data)}`);
24
27
  return response.data;
25
28
  }
@@ -90,25 +93,6 @@ export class ConductorClient {
90
93
  console.error(`Failed to update task ${taskId}:`, error.message);
91
94
  }
92
95
  }
93
- async getWorkflowByCorrelationId(name, correlationId) {
94
- try {
95
- // Search for running workflows with the given correlationId
96
- const response = await this.client.get('/workflow/search', {
97
- params: {
98
- query: `correlationId='${correlationId}' AND status='RUNNING'`
99
- }
100
- });
101
- if (response.data.results && response.data.results.length > 0) {
102
- // Return the first match (assuming one active workflow per claim)
103
- return response.data.results[0];
104
- }
105
- return null;
106
- }
107
- catch (error) {
108
- console.error(`Error searching workflow:`, error.message);
109
- return null;
110
- }
111
- }
112
96
  async getTask(workflowInstanceId, taskReferenceName) {
113
97
  try {
114
98
  const response = await this.client.get(`/workflow/${workflowInstanceId}`);
@@ -123,4 +107,14 @@ export class ConductorClient {
123
107
  return null;
124
108
  }
125
109
  }
110
+ async getWorkflow(workflowInstanceId, includeTasks = true) {
111
+ try {
112
+ const response = await this.client.get(`/workflow/${workflowInstanceId}?includeTasks=${includeTasks}`);
113
+ return response.data;
114
+ }
115
+ catch (error) {
116
+ console.error(`Error getting workflow:`, error.message);
117
+ throw error;
118
+ }
119
+ }
126
120
  }
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export { getContext, setExtras, setContext } from './shared/context/index.js';
4
4
  export { LoggerService as Logger } from './logger/LoggerService.js';
5
5
  export { HttpStatusCode } from './shared/enums/HttpStatusCodes.js';
6
6
  export { InvalidRequestException, InvalidEnvironmentException, AppException } from './shared/exceptions/index.js';
7
- export { getAWSParameters, matchFace, registerFace, generatePresignedUrl, getCustomAttribute, updateCustomAttribute, executeS3Action } from './secrets/aws.js';
7
+ export { getAWSParameters, matchFace, registerFace, generatePresignedUrl, getCustomAttribute, updateCustomAttribute, executeS3Action, sendEmail } from './secrets/aws.js';
8
8
  export { CognitoUserService } from './secrets/CognitoUserService.js';
9
9
  export { HttpClient, GraphQLClient } from './apiUtils/httpUtils.js';
10
10
  export { sendResponse } from './apiUtils/api.js';
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ export { getContext, setExtras, setContext } from './shared/context/index.js';
4
4
  export { LoggerService as Logger } from './logger/LoggerService.js';
5
5
  export { HttpStatusCode } from './shared/enums/HttpStatusCodes.js';
6
6
  export { InvalidRequestException, InvalidEnvironmentException, AppException } from './shared/exceptions/index.js';
7
- export { getAWSParameters, matchFace, registerFace, generatePresignedUrl, getCustomAttribute, updateCustomAttribute, executeS3Action } from './secrets/aws.js';
7
+ export { getAWSParameters, matchFace, registerFace, generatePresignedUrl, getCustomAttribute, updateCustomAttribute, executeS3Action, sendEmail } from './secrets/aws.js';
8
8
  export { CognitoUserService } from './secrets/CognitoUserService.js';
9
9
  export { HttpClient, GraphQLClient } from './apiUtils/httpUtils.js';
10
10
  export { sendResponse } from './apiUtils/api.js';
@@ -17,3 +17,4 @@ export declare function getCustomAttribute(username: string, userPoolId: string,
17
17
  value?: string;
18
18
  message: string;
19
19
  }>;
20
+ export declare function sendEmail(fromAddress: string, to: string[], displayName: string, cc: string[] | undefined, bcc: string[] | undefined, subject: string, htmlBody: string, metaData?: Record<string, any>): Promise<import("@aws-sdk/client-ses").SendEmailCommandOutput>;
@@ -4,6 +4,7 @@ import { AppException } from '../shared/exceptions/index.js';
4
4
  import { S3Client, PutObjectCommand, GetObjectCommand } from '@aws-sdk/client-s3';
5
5
  import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
6
6
  import { CognitoIdentityProviderClient, AdminUpdateUserAttributesCommand, AdminGetUserCommand } from '@aws-sdk/client-cognito-identity-provider';
7
+ import { SESClient, SendEmailCommand } from "@aws-sdk/client-ses";
7
8
  let ssm;
8
9
  let rand = Math.random().toString();
9
10
  const env = process.env.NODE_ENV || rand;
@@ -21,6 +22,10 @@ const client = new CognitoIdentityProviderClient({
21
22
  region: 'ap-south-1',
22
23
  credentials: env === 'local' ? fromIni({ profile: 'ghr-aws-dev-profile' }) : undefined
23
24
  });
25
+ const ses = new SESClient({
26
+ region: 'ap-south-1',
27
+ credentials: env === 'local' ? fromIni({ profile: 'ghr-aws-dev-profile' }) : undefined
28
+ });
24
29
  /**
25
30
  * Fetch a single parameter or all parameters under a prefix.
26
31
  * @param nameOrPrefix Full name (e.g. /dev/mysql/person) or prefix (e.g. /dev/mysql/)
@@ -219,3 +224,32 @@ export async function getCustomAttribute(username, userPoolId, attributeName) {
219
224
  };
220
225
  }
221
226
  }
227
+ export async function sendEmail(fromAddress, to, displayName, cc = [], bcc = [], subject, htmlBody, metaData = {}) {
228
+ try {
229
+ const command = new SendEmailCommand({
230
+ Source: displayName ? `"${displayName}" <${fromAddress}>` : fromAddress,
231
+ Destination: {
232
+ ToAddresses: to,
233
+ CcAddresses: cc,
234
+ BccAddresses: bcc,
235
+ },
236
+ Message: {
237
+ Subject: {
238
+ Data: subject,
239
+ Charset: "UTF-8",
240
+ },
241
+ Body: {
242
+ Html: {
243
+ Data: htmlBody,
244
+ Charset: "UTF-8",
245
+ },
246
+ },
247
+ },
248
+ });
249
+ const result = await ses.send(command);
250
+ return result;
251
+ }
252
+ catch (error) {
253
+ throw new AppException(`Failed to send email: ${error instanceof Error ? error.message : "Unknown error"}`, "E-Send-Email-Failed");
254
+ }
255
+ }
@@ -11,7 +11,8 @@ export const services = {
11
11
  'external-ms': 'http://localhost:3008',
12
12
  'cache-ms': 'http://localhost:3009',
13
13
  'migration-ms': 'http://localhost:3010',
14
- 'search-ms': 'http://localhost:3011'
14
+ 'search-ms': 'http://localhost:3011',
15
+ 'notifications-ms': 'http://localhost:3012'
15
16
  },
16
17
  'dev': {
17
18
  'bff-ms': 'http://bff-ms-dev:3000',
@@ -25,7 +26,8 @@ export const services = {
25
26
  'external-ms': 'http://external-ms-dev:3008',
26
27
  'cache-ms': 'http://cache-ms-dev:3009',
27
28
  'migration-ms': 'http://migration-ms-dev:3010',
28
- 'search-ms': 'http://search-ms-dev:3011'
29
+ 'search-ms': 'http://search-ms-dev:3011',
30
+ 'notifications-ms': 'http://notifications-ms-dev:3012'
29
31
  },
30
32
  'uat': {}
31
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geniehr/utilities",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/Genie-HR/ghr-utilities#readme",
6
6
  "bugs": {
@@ -31,6 +31,7 @@
31
31
  "@aws-sdk/client-cognito-identity-provider": "^3.859.0",
32
32
  "@aws-sdk/client-rekognition": "^3.846.0",
33
33
  "@aws-sdk/client-s3": "^3.848.0",
34
+ "@aws-sdk/client-ses": "^3.986.0",
34
35
  "@aws-sdk/client-ssm": "^3.839.0",
35
36
  "@aws-sdk/credential-providers": "^3.839.0",
36
37
  "@aws-sdk/s3-request-presigner": "^3.848.0",