mblabs-roccato-backend-commons 1.0.7 → 1.1.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.
Files changed (95) hide show
  1. package/bitbucket-pipelines.yml +6 -48
  2. package/dist/database/entities/account.d.ts +1 -2
  3. package/dist/database/entities/account.js +2 -7
  4. package/dist/database/entities/address.d.ts +2 -1
  5. package/dist/database/entities/address.js +6 -5
  6. package/dist/database/entities/company-address.d.ts +2 -0
  7. package/dist/database/entities/company-address.js +7 -0
  8. package/dist/database/migrations/1748448589934-CreateAccountsTable.js +1 -6
  9. package/dist/database/migrations/1750432386920-CreateAddressTable.js +0 -5
  10. package/dist/database/migrations/index.js +0 -4
  11. package/dist/interfaces/aws.d.ts +41 -67
  12. package/dist/interfaces/azure.d.ts +38 -61
  13. package/dist/interfaces/firebase.d.ts +3 -7
  14. package/dist/interfaces/gcp.d.ts +5 -11
  15. package/dist/interfaces/grafana.d.ts +2 -6
  16. package/dist/interfaces/keycloak.d.ts +4 -171
  17. package/dist/interfaces/nodemailer.d.ts +16 -20
  18. package/dist/interfaces/redis.d.ts +8 -49
  19. package/dist/interfaces/sendgrid.d.ts +13 -15
  20. package/dist/services/aws/cloudwatch.d.ts +1 -1
  21. package/dist/services/aws/cloudwatch.js +38 -38
  22. package/dist/services/aws/pinpoint.d.ts +3 -3
  23. package/dist/services/aws/pinpoint.js +29 -29
  24. package/dist/services/aws/s3.d.ts +5 -5
  25. package/dist/services/aws/s3.js +55 -59
  26. package/dist/services/aws/secret-manager.d.ts +1 -1
  27. package/dist/services/aws/secret-manager.js +5 -5
  28. package/dist/services/aws/sqs.d.ts +3 -3
  29. package/dist/services/aws/sqs.js +16 -16
  30. package/dist/services/azure/application-insights.d.ts +4 -4
  31. package/dist/services/azure/application-insights.js +12 -12
  32. package/dist/services/azure/communication.d.ts +3 -3
  33. package/dist/services/azure/communication.js +17 -17
  34. package/dist/services/azure/keyvault.d.ts +1 -1
  35. package/dist/services/azure/keyvault.js +3 -3
  36. package/dist/services/azure/storage-blob.d.ts +3 -3
  37. package/dist/services/azure/storage-blob.js +22 -22
  38. package/dist/services/firebase.d.ts +2 -2
  39. package/dist/services/firebase.js +10 -12
  40. package/dist/services/gcp/drive.d.ts +1 -1
  41. package/dist/services/gcp/drive.js +4 -4
  42. package/dist/services/gcp/secrets.d.ts +1 -1
  43. package/dist/services/gcp/secrets.js +8 -6
  44. package/dist/services/gcp/sheets.d.ts +1 -1
  45. package/dist/services/gcp/sheets.js +6 -6
  46. package/dist/services/grafana.d.ts +2 -2
  47. package/dist/services/grafana.js +12 -12
  48. package/dist/services/keycloak.d.ts +2 -14
  49. package/dist/services/keycloak.js +24 -300
  50. package/dist/services/nodemailer.d.ts +2 -2
  51. package/dist/services/nodemailer.js +109 -19
  52. package/dist/services/redis.d.ts +8 -6
  53. package/dist/services/redis.js +24 -53
  54. package/dist/services/sendgrid.d.ts +1 -1
  55. package/dist/services/sendgrid.js +10 -10
  56. package/package.json +1 -1
  57. package/src/database/entities/account.ts +3 -5
  58. package/src/database/entities/address.ts +7 -4
  59. package/src/database/entities/company-address.ts +5 -0
  60. package/src/database/migrations/1748448589934-CreateAccountsTable.ts +1 -6
  61. package/src/database/migrations/1750432386920-CreateAddressTable.ts +0 -5
  62. package/src/database/migrations/index.ts +0 -4
  63. package/src/interfaces/aws.ts +55 -81
  64. package/src/interfaces/azure.ts +50 -71
  65. package/src/interfaces/firebase.ts +6 -10
  66. package/src/interfaces/gcp.ts +8 -14
  67. package/src/interfaces/grafana.ts +5 -9
  68. package/src/interfaces/keycloak.ts +7 -190
  69. package/src/interfaces/nodemailer.ts +18 -22
  70. package/src/interfaces/redis.ts +8 -54
  71. package/src/interfaces/sendgrid.ts +14 -16
  72. package/src/services/aws/cloudwatch.ts +39 -39
  73. package/src/services/aws/pinpoint.ts +30 -30
  74. package/src/services/aws/s3.ts +55 -59
  75. package/src/services/aws/secret-manager.ts +7 -8
  76. package/src/services/aws/sqs.ts +17 -23
  77. package/src/services/azure/application-insights.ts +12 -12
  78. package/src/services/azure/communication.ts +18 -18
  79. package/src/services/azure/keyvault.ts +3 -3
  80. package/src/services/azure/storage-blob.ts +30 -34
  81. package/src/services/firebase.ts +11 -21
  82. package/src/services/gcp/drive.ts +5 -8
  83. package/src/services/gcp/secrets.ts +10 -9
  84. package/src/services/gcp/sheets.ts +7 -10
  85. package/src/services/grafana.ts +12 -18
  86. package/src/services/keycloak.ts +25 -381
  87. package/src/services/nodemailer.ts +110 -19
  88. package/src/services/redis.ts +22 -58
  89. package/src/services/sendgrid.ts +11 -11
  90. package/dist/database/migrations/1750690818577-CreateAccountAddressTable.d.ts +0 -5
  91. package/dist/database/migrations/1750690818577-CreateAccountAddressTable.js +0 -94
  92. package/dist/database/migrations/1750691840822-CreateAccountDetailsTable.d.ts +0 -5
  93. package/dist/database/migrations/1750691840822-CreateAccountDetailsTable.js +0 -99
  94. package/src/database/migrations/1750690818577-CreateAccountAddressTable.ts +0 -98
  95. package/src/database/migrations/1750691840822-CreateAccountDetailsTable.ts +0 -99
@@ -5,26 +5,24 @@ interface Credentials {
5
5
  export namespace Sendgrid {
6
6
  export namespace SendMail {
7
7
  export interface Request {
8
- data: {
9
- to: string;
10
- from: string;
11
- subject?: string;
12
- text?: string;
13
- html?: string;
14
- template?: string;
15
- substitutions?: Record<string, unknown>;
16
- attachments?: {
17
- content: string;
18
- filename: string;
19
- type?: string;
20
- disposition?: string;
21
- }[];
22
- };
8
+ to: string;
9
+ from: string;
10
+ subject?: string;
11
+ text?: string;
12
+ html?: string;
13
+ template?: string;
14
+ substitutions?: Record<string, unknown>;
15
+ attachments?: {
16
+ content: string;
17
+ filename: string;
18
+ type?: string;
19
+ disposition?: string;
20
+ }[];
23
21
  credentials: Credentials;
24
22
  }
25
23
  }
26
24
  }
27
25
 
28
26
  export interface ISendgridService {
29
- sendMail(req: Sendgrid.SendMail.Request): Promise<void>;
27
+ sendMail (req: Sendgrid.SendMail.Request): Promise<void>;
30
28
  }
@@ -3,105 +3,105 @@ import { CloudWatchLogs } from '@aws-sdk/client-cloudwatch-logs';
3
3
  import { AmazonCloudwatch, IAmazonCloudwatchService } from '../../interfaces/aws';
4
4
 
5
5
  class AmazonCloudwatchService implements IAmazonCloudwatchService {
6
- public async createLogEvent ({ credentials, data }: AmazonCloudwatch.CreateLogEvent.Request): Promise<void> {
6
+ public async createLogEvent (req: AmazonCloudwatch.CreateLogEvent.Request): Promise<void> {
7
7
  const client: CloudWatchLogs = new CloudWatchLogs({
8
8
  credentials: {
9
- accessKeyId: credentials.accessKey,
10
- secretAccessKey: credentials.secretKey,
9
+ accessKeyId: req.credentials.accessKey,
10
+ secretAccessKey: req.credentials.secretKey,
11
11
  },
12
- region: credentials.region,
12
+ region: req.credentials.region,
13
13
  });
14
14
 
15
- await this.createLogGroup({ credentials, data });
16
- await this.createLogStream({ credentials, data });
15
+ await this.createLogGroup(req);
16
+ await this.createLogStream(req);
17
17
 
18
18
  await client.putLogEvents({
19
- logGroupName: data.group,
20
- logStreamName: data.stream,
21
- logEvents: data.events,
19
+ logGroupName: req.group,
20
+ logStreamName: req.stream,
21
+ logEvents: req.events,
22
22
  });
23
23
  }
24
24
 
25
- private async getLogGroupByName ({ credentials, data }: AmazonCloudwatch.CreateLogEvent.Request) {
26
- const logGroups = await this.listApplicationLogGroups({ credentials, data });
25
+ private async getLogGroupByName (req: AmazonCloudwatch.CreateLogEvent.Request) {
26
+ const logGroups = await this.listApplicationLogGroups(req);
27
27
 
28
- return logGroups.find((logGroup) => logGroup.logGroupName === data.group);
28
+ return logGroups.find((logGroup) => logGroup.logGroupName === req.group);
29
29
  }
30
30
 
31
- private async getLogStreamByName ({ credentials, data }: AmazonCloudwatch.CreateLogEvent.Request) {
32
- const logStreams = await this.listApplicationLogStreams({ credentials, data });
31
+ private async getLogStreamByName (req: AmazonCloudwatch.CreateLogEvent.Request) {
32
+ const logStreams = await this.listApplicationLogStreams(req);
33
33
 
34
- return logStreams.find((logStream) => logStream.logStreamName === data.stream);
34
+ return logStreams.find((logStream) => logStream.logStreamName === req.stream);
35
35
  }
36
36
 
37
- private async listApplicationLogGroups ({ credentials, data }: AmazonCloudwatch.CreateLogEvent.Request) {
37
+ private async listApplicationLogGroups (req: AmazonCloudwatch.CreateLogEvent.Request) {
38
38
  const client: CloudWatchLogs = new CloudWatchLogs({
39
39
  credentials: {
40
- accessKeyId: credentials.accessKey,
41
- secretAccessKey: credentials.secretKey,
40
+ accessKeyId: req.credentials.accessKey,
41
+ secretAccessKey: req.credentials.secretKey,
42
42
  },
43
- region: credentials.region,
43
+ region: req.credentials.region,
44
44
  });
45
45
 
46
46
  const { logGroups } = await client.describeLogGroups({
47
- logGroupNamePrefix: data.application,
47
+ logGroupNamePrefix: req.application,
48
48
  });
49
49
 
50
50
  return logGroups;
51
51
  }
52
52
 
53
- private async listApplicationLogStreams ({ credentials, data }: AmazonCloudwatch.CreateLogEvent.Request) {
53
+ private async listApplicationLogStreams (req: AmazonCloudwatch.CreateLogEvent.Request) {
54
54
  const client: CloudWatchLogs = new CloudWatchLogs({
55
55
  credentials: {
56
- accessKeyId: credentials.accessKey,
57
- secretAccessKey: credentials.secretKey,
56
+ accessKeyId: req.credentials.accessKey,
57
+ secretAccessKey: req.credentials.secretKey,
58
58
  },
59
- region: credentials.region,
59
+ region: req.credentials.region,
60
60
  });
61
61
 
62
62
  const { logStreams } = await client.describeLogStreams({
63
- logGroupName: data.group,
63
+ logGroupName: req.group,
64
64
  });
65
65
 
66
66
  return logStreams;
67
67
  }
68
68
 
69
- private async createLogGroup ({ credentials, data }: AmazonCloudwatch.CreateLogEvent.Request) {
70
- const logGroup = await this.getLogGroupByName({ credentials, data });
69
+ private async createLogGroup (req: AmazonCloudwatch.CreateLogEvent.Request) {
70
+ const logGroup = await this.getLogGroupByName(req);
71
71
 
72
72
  if (!logGroup) {
73
73
  const client: CloudWatchLogs = new CloudWatchLogs({
74
74
  credentials: {
75
- accessKeyId: credentials.accessKey,
76
- secretAccessKey: credentials.secretKey,
75
+ accessKeyId: req.credentials.accessKey,
76
+ secretAccessKey: req.credentials.secretKey,
77
77
  },
78
- region: credentials.region,
78
+ region: req.credentials.region,
79
79
  });
80
80
 
81
81
  await client.createLogGroup({
82
- logGroupName: data.group,
82
+ logGroupName: req.group,
83
83
  });
84
84
  }
85
85
  }
86
86
 
87
- private async createLogStream ({ credentials, data }: AmazonCloudwatch.CreateLogEvent.Request) {
88
- const logStream = await this.getLogStreamByName({ credentials, data });
87
+ private async createLogStream (req: AmazonCloudwatch.CreateLogEvent.Request) {
88
+ const logStream = await this.getLogStreamByName(req);
89
89
 
90
90
  if (!logStream) {
91
91
  const client: CloudWatchLogs = new CloudWatchLogs({
92
92
  credentials: {
93
- accessKeyId: credentials.accessKey,
94
- secretAccessKey: credentials.secretKey,
93
+ accessKeyId: req.credentials.accessKey,
94
+ secretAccessKey: req.credentials.secretKey,
95
95
  },
96
- region: credentials.region,
96
+ region: req.credentials.region,
97
97
  });
98
98
 
99
99
  await client.createLogStream({
100
- logGroupName: data.group,
101
- logStreamName: data.stream,
100
+ logGroupName: req.group,
101
+ logStreamName: req.stream,
102
102
  });
103
103
  }
104
104
  }
105
105
  }
106
106
 
107
- export default new AmazonCloudwatchService();
107
+ export default new AmazonCloudwatchService();
@@ -3,16 +3,16 @@ import { PinpointClient, SendMessagesCommand, SendMessagesCommandInput } from '@
3
3
  import { AmazonPinpoint, IAmazonPinpointService } from '../../interfaces/aws';
4
4
 
5
5
  class AmazonPinpointService implements IAmazonPinpointService {
6
- async sendMail ({ credentials, data }: AmazonPinpoint.SendMail.Request): Promise<void> {
6
+ async sendMail (req: AmazonPinpoint.SendMail.Request): Promise<void> {
7
7
  const client = new PinpointClient({
8
8
  credentials: {
9
- accessKeyId: credentials.accessKey,
10
- secretAccessKey: credentials.secretKey,
9
+ accessKeyId: req.credentials.accessKey,
10
+ secretAccessKey: req.credentials.secretKey,
11
11
  },
12
- region: credentials.region,
12
+ region: req.credentials.region,
13
13
  });
14
14
 
15
- const recipient = Array.isArray(data.emails) ? data.emails : [ data.emails ];
15
+ const recipient = Array.isArray(req.emails) ? req.emails : [ req.emails ];
16
16
 
17
17
  const addresses = recipient.reduce(
18
18
  (acc, curr) => ({
@@ -24,7 +24,7 @@ class AmazonPinpointService implements IAmazonPinpointService {
24
24
  {}
25
25
  );
26
26
 
27
- const substitutions = Object.entries(data.variables || {}).reduce(
27
+ const substitutions = Object.entries(req.variables || {}).reduce(
28
28
  (acc, [ key, value ]) => ({
29
29
  ...acc,
30
30
  [key]: [ value ],
@@ -33,21 +33,21 @@ class AmazonPinpointService implements IAmazonPinpointService {
33
33
  );
34
34
 
35
35
  const payload: SendMessagesCommandInput = {
36
- ApplicationId: data.application,
36
+ ApplicationId: req.applicationId,
37
37
  MessageRequest: {
38
38
  Addresses: addresses,
39
39
  MessageConfiguration: {
40
40
  EmailMessage: {
41
- FromAddress: data.from,
41
+ FromAddress: req.from,
42
42
  Substitutions: substitutions,
43
43
  SimpleEmail: {
44
44
  Subject: {
45
45
  Charset: 'utf-8',
46
- Data: data.subject,
46
+ Data: req.subject,
47
47
  },
48
48
  TextPart: {
49
49
  Charset: 'utf-8',
50
- Data: data.text,
50
+ Data: req.text,
51
51
  },
52
52
  },
53
53
  },
@@ -58,16 +58,16 @@ class AmazonPinpointService implements IAmazonPinpointService {
58
58
  await client.send(new SendMessagesCommand(payload));
59
59
  }
60
60
 
61
- async sendTemplateMail ({ credentials, data }: AmazonPinpoint.SendTemplateMail.Request): Promise<void> {
61
+ async sendTemplateMail (req: AmazonPinpoint.SendTemplateMail.Request): Promise<void> {
62
62
  const client = new PinpointClient({
63
63
  credentials: {
64
- accessKeyId: credentials.accessKey,
65
- secretAccessKey: credentials.secretKey,
64
+ accessKeyId: req.credentials.accessKey,
65
+ secretAccessKey: req.credentials.secretKey,
66
66
  },
67
- region: credentials.region,
67
+ region: req.credentials.region,
68
68
  });
69
69
 
70
- const recipient = Array.isArray(data.emails) ? data.emails : [ data.emails ];
70
+ const recipient = Array.isArray(req.emails) ? req.emails : [ req.emails ];
71
71
 
72
72
  const addresses = recipient.reduce(
73
73
  (acc, curr) => ({
@@ -79,7 +79,7 @@ class AmazonPinpointService implements IAmazonPinpointService {
79
79
  {}
80
80
  );
81
81
 
82
- const substitutions = Object.entries(data.variables || {}).reduce(
82
+ const substitutions = Object.entries(req.variables || {}).reduce(
83
83
  (acc, [ key, value ]) => ({
84
84
  ...acc,
85
85
  [key]: [ value ],
@@ -88,18 +88,18 @@ class AmazonPinpointService implements IAmazonPinpointService {
88
88
  );
89
89
 
90
90
  const payload: SendMessagesCommandInput = {
91
- ApplicationId: data.application,
91
+ ApplicationId: req.applicationId,
92
92
  MessageRequest: {
93
93
  Addresses: addresses,
94
94
  MessageConfiguration: {
95
95
  EmailMessage: {
96
- FromAddress: data.from,
96
+ FromAddress: req.from,
97
97
  Substitutions: substitutions,
98
98
  },
99
99
  },
100
100
  TemplateConfiguration: {
101
101
  EmailTemplate: {
102
- Name: data.template,
102
+ Name: req.template,
103
103
  Version: 'latest',
104
104
  },
105
105
  },
@@ -109,16 +109,16 @@ class AmazonPinpointService implements IAmazonPinpointService {
109
109
  await client.send(new SendMessagesCommand(payload));
110
110
  }
111
111
 
112
- async sendSMS ({ credentials, data }: AmazonPinpoint.SendSMS.Request): Promise<void> {
112
+ async sendSMS (req: AmazonPinpoint.SendSMS.Request): Promise<void> {
113
113
  const client = new PinpointClient({
114
114
  credentials: {
115
- accessKeyId: credentials.accessKey,
116
- secretAccessKey: credentials.secretKey,
115
+ accessKeyId: req.credentials.accessKey,
116
+ secretAccessKey: req.credentials.secretKey,
117
117
  },
118
- region: credentials.region,
118
+ region: req.credentials.region,
119
119
  });
120
120
 
121
- const recipient = Array.isArray(data.phones) ? data.phones : [ data.phones ];
121
+ const recipient = Array.isArray(req.phones) ? req.phones : [ req.phones ];
122
122
 
123
123
  const addresses = recipient.reduce(
124
124
  (acc, curr) => ({
@@ -130,7 +130,7 @@ class AmazonPinpointService implements IAmazonPinpointService {
130
130
  {}
131
131
  );
132
132
 
133
- const substitutions = Object.entries(data.variables || {}).reduce(
133
+ const substitutions = Object.entries(req.variables || {}).reduce(
134
134
  (acc, [ key, value ]) => ({
135
135
  ...acc,
136
136
  [key]: [ value ],
@@ -139,14 +139,14 @@ class AmazonPinpointService implements IAmazonPinpointService {
139
139
  );
140
140
 
141
141
  const payload: SendMessagesCommandInput = {
142
- ApplicationId: data.application,
142
+ ApplicationId: req.applicationId,
143
143
  MessageRequest: {
144
144
  Addresses: addresses,
145
145
  MessageConfiguration: {
146
146
  SMSMessage: {
147
- Body: data.text,
148
- MessageType: data.type,
149
- SenderId: data.sender,
147
+ Body: req.text,
148
+ MessageType: req.type,
149
+ SenderId: req.sender,
150
150
  Substitutions: substitutions,
151
151
  },
152
152
  },
@@ -157,4 +157,4 @@ class AmazonPinpointService implements IAmazonPinpointService {
157
157
  }
158
158
  }
159
159
 
160
- export default new AmazonPinpointService();
160
+ export default new AmazonPinpointService();
@@ -11,119 +11,115 @@ import { AmazonS3, IAmazonS3Service } from '../../interfaces/aws';
11
11
  import FileService from '../../services/file';
12
12
 
13
13
  class AmazonS3Service implements IAmazonS3Service {
14
- async uploadBase64 ({ credentials, data }: AmazonS3.UploadBase64.Request): Promise<AmazonS3.UploadBase64.Response> {
14
+ async uploadBase64 (req: AmazonS3.UploadBase64.Request): Promise<AmazonS3.UploadBase64.Response> {
15
15
  const client = new S3({
16
16
  credentials: {
17
- accessKeyId: credentials.accessKey,
18
- secretAccessKey: credentials.secretKey,
17
+ accessKeyId: req.credentials.accessKey,
18
+ secretAccessKey: req.credentials.secretKey,
19
19
  },
20
- region: credentials.region,
20
+ region: req.credentials.region,
21
21
  });
22
22
 
23
- const { buffer, extension } = FileService.getBase64Metadata(data.file);
23
+ const { buffer, extension } = FileService.getBase64Metadata(req.file);
24
24
 
25
- const key = data.options?.filename
26
- ? data.options?.filename
25
+ const key = req.options?.filename
26
+ ? req.options?.filename
27
27
  : FileService.getUniqueFilename(extension);
28
28
 
29
29
  const payload: PutObjectCommandInput = {
30
- Key: this.getBucketPath(key, data.options?.folder),
30
+ Key: this.getBucketPath(key, req.options?.folder),
31
31
  Body: buffer,
32
- ContentEncoding: data.options?.contentEncoding,
33
- ContentType: data.options?.contentType,
34
- Bucket: data.bucket,
35
- ACL: data.options?.isPrivate ? 'private' : 'public-read',
32
+ ContentEncoding: req.options?.contentEncoding,
33
+ ContentType: req.options?.contentType,
34
+ Bucket: req.bucket,
35
+ ACL: req.options?.isPrivate ? 'private' : 'public-read',
36
36
  };
37
37
 
38
38
  await client.putObject(payload);
39
39
 
40
40
  const { url } = await this.getSignedUrl({
41
- data: {
42
- bucket: data.bucket,
43
- filename: key,
44
- folder: data.options?.folder,
45
- isUpload: false,
46
- },
47
- credentials,
41
+ bucket: req.bucket,
42
+ credentials: req.credentials,
43
+ filename: key,
44
+ folder: req.options?.folder,
45
+ isUpload: false,
48
46
  });
49
47
 
50
48
  return {
51
49
  key: payload.Key,
52
- bucket: data.bucket,
50
+ bucket: req.bucket,
53
51
  url,
54
52
  };
55
53
  }
56
54
 
57
- async uploadBuffer ({ credentials, data }: AmazonS3.UploadBuffer.Request): Promise<AmazonS3.UploadBuffer.Response> {
55
+ async uploadBuffer (req: AmazonS3.UploadBuffer.Request): Promise<AmazonS3.UploadBuffer.Response> {
58
56
  const client = new S3({
59
57
  credentials: {
60
- accessKeyId: credentials.accessKey,
61
- secretAccessKey: credentials.secretKey,
58
+ accessKeyId: req.credentials.accessKey,
59
+ secretAccessKey: req.credentials.secretKey,
62
60
  },
63
- region: credentials.region,
61
+ region: req.credentials.region,
64
62
  });
65
63
 
66
- const key = data.options?.filename
67
- ? data.options?.filename
64
+ const key = req.options?.filename
65
+ ? req.options?.filename
68
66
  : FileService.getUniqueFilename('');
69
67
 
70
68
  const payload: PutObjectCommandInput = {
71
- Key: this.getBucketPath(key, data.options?.folder),
72
- Body: data.file,
73
- ContentEncoding: data.options?.contentEncoding,
74
- ContentType: data.options?.contentType,
75
- Bucket: data.bucket,
76
- ACL: data.options?.isPrivate ? 'private' : 'public-read',
69
+ Key: this.getBucketPath(key, req.options?.folder),
70
+ Body: req.file,
71
+ ContentEncoding: req.options?.contentEncoding,
72
+ ContentType: req.options?.contentType,
73
+ Bucket: req.bucket,
74
+ ACL: req.options?.isPrivate ? 'private' : 'public-read',
77
75
  };
78
76
 
79
77
  await client.putObject(payload);
80
78
 
81
79
  const { url } = await this.getSignedUrl({
82
- data: {
83
- bucket: data.bucket,
84
- filename: key,
85
- folder: data.options?.folder,
86
- isUpload: false,
87
- },
88
- credentials,
80
+ bucket: req.bucket,
81
+ credentials: req.credentials,
82
+ filename: key,
83
+ folder: req.options?.folder,
84
+ isUpload: false,
89
85
  });
90
86
 
91
87
  return {
92
88
  key: payload.Key,
93
- bucket: data.bucket,
89
+ bucket: req.bucket,
94
90
  url,
95
91
  };
96
92
  }
97
93
 
98
- async deleteFile ({ credentials, data }: AmazonS3.DeleteFile.Request): Promise<void> {
94
+ async deleteFile (req: AmazonS3.DeleteFile.Request): Promise<void> {
99
95
  const client = new S3({
100
96
  credentials: {
101
- accessKeyId: credentials.accessKey,
102
- secretAccessKey: credentials.secretKey,
97
+ accessKeyId: req.credentials.accessKey,
98
+ secretAccessKey: req.credentials.secretKey,
103
99
  },
104
- region: credentials.region,
100
+ region: req.credentials.region,
105
101
  });
106
102
 
107
103
  const payload: DeleteObjectCommandInput = {
108
- Key: this.getBucketPath(data.filename, data.folder),
109
- Bucket: data.bucket,
104
+ Key: this.getBucketPath(req.filename, req.folder),
105
+ Bucket: req.bucket,
110
106
  };
111
107
 
112
108
  await client.deleteObject(payload);
113
109
  }
114
110
 
115
- async listFiles ({ credentials, data }: AmazonS3.ListFiles.Request): Promise<AmazonS3.ListFiles.Response> {
111
+ async listFiles (req: AmazonS3.ListFiles.Request): Promise<AmazonS3.ListFiles.Response> {
116
112
  const client = new S3({
117
113
  credentials: {
118
- accessKeyId: credentials.accessKey,
119
- secretAccessKey: credentials.secretKey,
114
+ accessKeyId: req.credentials.accessKey,
115
+ secretAccessKey: req.credentials.secretKey,
120
116
  },
121
- region: credentials.region,
117
+ region: req.credentials.region,
122
118
  });
123
119
 
124
120
  const { Contents } = await client.listObjectsV2({
125
- Bucket: data.bucket,
126
- Prefix: data.folder,
121
+ Bucket: req.bucket,
122
+ Prefix: req.folder,
127
123
  });
128
124
 
129
125
  return {
@@ -131,21 +127,21 @@ class AmazonS3Service implements IAmazonS3Service {
131
127
  };
132
128
  }
133
129
 
134
- async getSignedUrl ({ credentials, data }: AmazonS3.GetSignedUrl.Request): Promise<AmazonS3.GetSignedUrl.Response> {
130
+ async getSignedUrl (req: AmazonS3.GetSignedUrl.Request): Promise<AmazonS3.GetSignedUrl.Response> {
135
131
  const client = new S3({
136
132
  credentials: {
137
- accessKeyId: credentials.accessKey,
138
- secretAccessKey: credentials.secretKey,
133
+ accessKeyId: req.credentials.accessKey,
134
+ secretAccessKey: req.credentials.secretKey,
139
135
  },
140
- region: credentials.region,
136
+ region: req.credentials.region,
141
137
  });
142
138
 
143
139
  const payload = {
144
- Key: this.getBucketPath(data.filename, data.folder),
145
- Bucket: data.bucket,
140
+ Key: this.getBucketPath(req.filename, req.folder),
141
+ Bucket: req.bucket,
146
142
  };
147
143
 
148
- const method = data.isUpload
144
+ const method = req.isUpload
149
145
  ? new PutObjectCommand(payload)
150
146
  : new GetObjectCommand(payload);
151
147
 
@@ -4,19 +4,18 @@ import { AmazonSecretManager, IAmazonSecretManagerService } from '../../interfac
4
4
  import { parseRecord } from '../../utils/parser';
5
5
 
6
6
  class AmazonSecretManagerService implements IAmazonSecretManagerService {
7
- public async getSecret<T> ({
8
- credentials,
9
- data,
10
- }: AmazonSecretManager.GetSecret.Request): Promise<AmazonSecretManager.GetSecret.Response<T>> {
7
+ public async getSecret<T> (
8
+ req: AmazonSecretManager.GetSecret.Request
9
+ ): Promise<AmazonSecretManager.GetSecret.Response<T>> {
11
10
  const client: SecretsManager = new SecretsManager({
12
11
  credentials: {
13
- accessKeyId: credentials.accessKey,
14
- secretAccessKey: credentials.secretKey,
12
+ accessKeyId: req.credentials.accessKey,
13
+ secretAccessKey: req.credentials.secretKey,
15
14
  },
16
- region: credentials.region,
15
+ region: req.credentials.region,
17
16
  });
18
17
 
19
- const { SecretString, SecretBinary } = await client.getSecretValue({ SecretId: data.secret });
18
+ const { SecretString, SecretBinary } = await client.getSecretValue({ SecretId: req.secretId });
20
19
 
21
20
  if (SecretString) {
22
21
  const secret = parseRecord(SecretString) as T;
@@ -4,36 +4,33 @@ import { AmazonSQS, IAmazonSQSService } from '../../interfaces/aws';
4
4
  import { parseRecord } from '../../utils';
5
5
 
6
6
  class AmazonSQSService implements IAmazonSQSService {
7
- async publishMessage ({ credentials, data }: AmazonSQS.PublishMessage.Request): Promise<void> {
7
+ async publishMessage (req: AmazonSQS.PublishMessage.Request): Promise<void> {
8
8
  const client: SQS = new SQS({
9
9
  credentials: {
10
- accessKeyId: credentials.accessKey,
11
- secretAccessKey: credentials.secretKey,
10
+ accessKeyId: req.credentials.accessKey,
11
+ secretAccessKey: req.credentials.secretKey,
12
12
  },
13
- region: credentials.region,
13
+ region: req.credentials.region,
14
14
  });
15
15
 
16
- const { QueueUrl } = await client.getQueueUrl({ QueueName: data.queue });
16
+ const { QueueUrl } = await client.getQueueUrl({ QueueName: req.queue });
17
17
 
18
18
  await client.sendMessage({
19
- MessageBody: JSON.stringify(data.message),
19
+ MessageBody: JSON.stringify(req.message),
20
20
  QueueUrl,
21
21
  });
22
22
  }
23
23
 
24
- async consumeMessage<T> ({
25
- credentials,
26
- data,
27
- }: AmazonSQS.ConsumeMessage.Request): Promise<AmazonSQS.ConsumeMessage.Response<T>> {
24
+ async consumeMessage<T> (req: AmazonSQS.ConsumeMessage.Request): Promise<AmazonSQS.ConsumeMessage.Response<T>> {
28
25
  const client: SQS = new SQS({
29
26
  credentials: {
30
- accessKeyId: credentials.accessKey,
31
- secretAccessKey: credentials.secretKey,
27
+ accessKeyId: req.credentials.accessKey,
28
+ secretAccessKey: req.credentials.secretKey,
32
29
  },
33
- region: credentials.region,
30
+ region: req.credentials.region,
34
31
  });
35
32
 
36
- const { QueueUrl } = await client.getQueueUrl({ QueueName: data.queue });
33
+ const { QueueUrl } = await client.getQueueUrl({ QueueName: req.queue });
37
34
 
38
35
  const { Messages } = await client.receiveMessage({
39
36
  QueueUrl,
@@ -60,19 +57,16 @@ class AmazonSQSService implements IAmazonSQSService {
60
57
  };
61
58
  }
62
59
 
63
- async consumeMessages<T> ({
64
- credentials,
65
- data,
66
- }: AmazonSQS.ConsumeMessages.Request): Promise<AmazonSQS.ConsumeMessages.Response<T>> {
60
+ async consumeMessages<T> (req: AmazonSQS.ConsumeMessages.Request): Promise<AmazonSQS.ConsumeMessages.Response<T>> {
67
61
  const client: SQS = new SQS({
68
62
  credentials: {
69
- accessKeyId: credentials.accessKey,
70
- secretAccessKey: credentials.secretKey,
63
+ accessKeyId: req.credentials.accessKey,
64
+ secretAccessKey: req.credentials.secretKey,
71
65
  },
72
- region: credentials.region,
66
+ region: req.credentials.region,
73
67
  });
74
68
 
75
- const { QueueUrl } = await client.getQueueUrl({ QueueName: data.queue });
69
+ const { QueueUrl } = await client.getQueueUrl({ QueueName: req.queue });
76
70
 
77
71
  const { Messages } = await client.receiveMessage({
78
72
  QueueUrl,
@@ -104,4 +98,4 @@ class AmazonSQSService implements IAmazonSQSService {
104
98
  }
105
99
  }
106
100
 
107
- export default new AmazonSQSService();
101
+ export default new AmazonSQSService();