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
@@ -1,37 +1,15 @@
1
1
  interface Credentials {
2
- clientId: string;
3
2
  realm: string;
3
+ clientId: string;
4
4
  clientSecret: string;
5
5
  grantType: string;
6
6
  }
7
- export interface Roles {
8
- id: string;
9
- name: string;
10
- description: string;
11
- }
12
7
  export declare namespace Keycloak {
13
8
  namespace Authenticate {
14
9
  interface Request {
15
10
  url: string;
16
- data: {
17
- username: string;
18
- password: string;
19
- };
20
- credentials: Credentials;
21
- }
22
- interface Response {
23
- access_token: string;
24
- expires_in: number;
25
- refresh_expires_in: number;
26
- refresh_token: string;
27
- token_type: string;
28
- profileType?: number;
29
- active?: boolean;
30
- }
31
- }
32
- namespace AuthenticateServer {
33
- interface Request {
34
- url: string;
11
+ username: string;
12
+ password: string;
35
13
  credentials: Credentials;
36
14
  }
37
15
  interface Response {
@@ -47,9 +25,7 @@ export declare namespace Keycloak {
47
25
  namespace RefreshAccess {
48
26
  interface Request {
49
27
  url: string;
50
- data: {
51
- refreshToken: string;
52
- };
28
+ refreshToken: string;
53
29
  credentials: Credentials;
54
30
  }
55
31
  interface Response {
@@ -62,152 +38,9 @@ export declare namespace Keycloak {
62
38
  active?: boolean;
63
39
  }
64
40
  }
65
- namespace RevokeAccess {
66
- interface Request {
67
- url: string;
68
- data: {
69
- accessToken: string;
70
- };
71
- credentials: Credentials;
72
- }
73
- }
74
- namespace CreateUser {
75
- interface Request {
76
- url: string;
77
- data: {
78
- username: string;
79
- firstName: string;
80
- lastName?: string;
81
- email: string;
82
- password: string;
83
- isTemporaryPassword?: boolean;
84
- groups: string[];
85
- };
86
- credentials: Credentials;
87
- }
88
- }
89
- namespace UpdateUser {
90
- interface Request {
91
- url: string;
92
- data: {
93
- id: string;
94
- username?: string;
95
- firstName?: string;
96
- lastName?: string;
97
- email?: string;
98
- password?: string;
99
- isTemporaryPassword?: boolean;
100
- groups?: string[];
101
- };
102
- credentials: Credentials;
103
- }
104
- }
105
- namespace GetUser {
106
- interface Request {
107
- url: string;
108
- data: {
109
- id: string;
110
- };
111
- credentials: Credentials;
112
- }
113
- interface Response {
114
- id: string;
115
- sub: string;
116
- firstName: string;
117
- lastName: string;
118
- email: string;
119
- enabled: boolean;
120
- attributes: {
121
- isFirstAccess: boolean;
122
- };
123
- }
124
- }
125
- namespace DeleteUser {
126
- interface Request {
127
- url: string;
128
- data: {
129
- id: string;
130
- };
131
- credentials: Credentials;
132
- }
133
- }
134
- namespace ChangeUserPassword {
135
- interface Request {
136
- url: string;
137
- data: {
138
- id: string;
139
- password: string;
140
- isTemporaryPassword?: boolean;
141
- };
142
- credentials: Credentials;
143
- }
144
- }
145
- namespace AddRealm {
146
- interface Request {
147
- url: string;
148
- data: {
149
- name: string;
150
- enabled: boolean;
151
- };
152
- credentials: Credentials;
153
- }
154
- }
155
- namespace AddRole {
156
- interface Request {
157
- url: string;
158
- data: {
159
- name: string;
160
- description: string;
161
- };
162
- credentials: Credentials;
163
- }
164
- }
165
- namespace AssociateUserRole {
166
- interface Request {
167
- url: string;
168
- data: {
169
- user: string;
170
- role: string;
171
- };
172
- credentials: Credentials;
173
- }
174
- }
175
- namespace GetRoles {
176
- interface Request {
177
- url: string;
178
- data: {
179
- search: string;
180
- };
181
- credentials: Credentials;
182
- }
183
- interface Response {
184
- roles: Roles[];
185
- }
186
- }
187
- namespace DeleteRole {
188
- interface Request {
189
- url: string;
190
- data: {
191
- id: string;
192
- };
193
- credentials: Credentials;
194
- }
195
- }
196
41
  }
197
42
  export interface IKeycloakService {
198
43
  authenticate(req: Keycloak.Authenticate.Request): Promise<Keycloak.Authenticate.Response>;
199
- authenticateServer(req: Keycloak.AuthenticateServer.Request): Promise<Keycloak.AuthenticateServer.Response>;
200
44
  refreshAccess(req: Keycloak.RefreshAccess.Request): Promise<Keycloak.RefreshAccess.Response>;
201
- revokeAccess(req: Keycloak.RevokeAccess.Request): Promise<void>;
202
- createUser(req: Keycloak.CreateUser.Request): Promise<void>;
203
- updateUser(req: Keycloak.UpdateUser.Request): Promise<void>;
204
- getUser(req: Keycloak.GetUser.Request): Promise<Keycloak.GetUser.Response>;
205
- deleteUser(req: Keycloak.DeleteUser.Request): Promise<void>;
206
- changeUserPassword(req: Keycloak.ChangeUserPassword.Request): Promise<void>;
207
- addRealm(req: Keycloak.AddRealm.Request): Promise<void>;
208
- addRole(req: Keycloak.AddRole.Request): Promise<void>;
209
- associateUserRole(req: Keycloak.AssociateUserRole.Request): Promise<void>;
210
- getRoles(req: Keycloak.GetRoles.Request): Promise<Keycloak.GetRoles.Response>;
211
- deleteRole(req: Keycloak.DeleteRole.Request): Promise<void>;
212
45
  }
213
46
  export {};
@@ -10,33 +10,29 @@ interface Credentials {
10
10
  export declare namespace NodeMailer {
11
11
  namespace Send {
12
12
  interface Request {
13
- data: {
14
- from: {
15
- name: string;
16
- address: string;
17
- };
18
- to: string;
19
- subject: string;
20
- text: string;
13
+ from: {
14
+ name: string;
15
+ address: string;
21
16
  };
17
+ to: string;
18
+ subject: string;
19
+ text: string;
22
20
  credentials: Credentials;
23
21
  }
24
22
  }
25
23
  namespace SendWithTemplate {
26
24
  interface Request {
27
- data: {
28
- from: {
29
- name: string;
30
- address: string;
31
- };
32
- to: string;
33
- subject: string;
34
- html: string;
35
- attachments: {
36
- filename: string;
37
- content: Buffer;
38
- }[];
25
+ from: {
26
+ name: string;
27
+ address: string;
39
28
  };
29
+ to: string;
30
+ subject: string;
31
+ html: string;
32
+ attachments: {
33
+ filename: string;
34
+ content: Buffer;
35
+ }[];
40
36
  credentials: Credentials;
41
37
  }
42
38
  }
@@ -1,54 +1,13 @@
1
- interface Credentials {
2
- host: string;
3
- port: number;
4
- password?: string;
5
- }
6
1
  export declare namespace Redis {
7
- namespace Set {
8
- interface Request {
9
- data: {
10
- key: string;
11
- value: unknown;
12
- ttl?: number;
13
- };
14
- credentials: Credentials;
15
- }
16
- }
17
- namespace Get {
18
- interface Request {
19
- data: {
20
- key: string;
21
- };
22
- credentials: Credentials;
23
- }
24
- interface Response<T> {
25
- data: T;
26
- }
27
- }
28
- namespace Del {
29
- interface Request {
30
- data: {
31
- key: string;
32
- };
33
- credentials: Credentials;
34
- }
35
- }
36
- namespace Exists {
37
- interface Request {
38
- data: {
39
- key: string;
40
- };
41
- credentials: Credentials;
42
- }
43
- interface Response {
44
- exists: boolean;
45
- }
2
+ interface Credentials {
3
+ host: string;
4
+ port: number;
5
+ password?: string;
46
6
  }
47
7
  }
48
8
  export interface IRedisService {
49
- set(req: Redis.Set.Request): Promise<void>;
50
- get<T>(req: Redis.Get.Request): Promise<Redis.Get.Response<T>>;
51
- del(req: Redis.Del.Request): Promise<void>;
52
- exists(req: Redis.Exists.Request): Promise<Redis.Exists.Response>;
9
+ set(key: string, value: unknown, ttlInSeconds?: number): Promise<void>;
10
+ get<T>(key: string): Promise<T | null>;
11
+ del(key: string): Promise<void>;
12
+ exists(key: string): Promise<boolean>;
53
13
  }
54
- export {};
@@ -4,21 +4,19 @@ interface Credentials {
4
4
  export declare namespace Sendgrid {
5
5
  namespace SendMail {
6
6
  interface Request {
7
- data: {
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
- }[];
21
- };
7
+ to: string;
8
+ from: string;
9
+ subject?: string;
10
+ text?: string;
11
+ html?: string;
12
+ template?: string;
13
+ substitutions?: Record<string, unknown>;
14
+ attachments?: {
15
+ content: string;
16
+ filename: string;
17
+ type?: string;
18
+ disposition?: string;
19
+ }[];
22
20
  credentials: Credentials;
23
21
  }
24
22
  }
@@ -1,6 +1,6 @@
1
1
  import { AmazonCloudwatch, IAmazonCloudwatchService } from '../../interfaces/aws';
2
2
  declare class AmazonCloudwatchService implements IAmazonCloudwatchService {
3
- createLogEvent({ credentials, data }: AmazonCloudwatch.CreateLogEvent.Request): Promise<void>;
3
+ createLogEvent(req: AmazonCloudwatch.CreateLogEvent.Request): Promise<void>;
4
4
  private getLogGroupByName;
5
5
  private getLogStreamByName;
6
6
  private listApplicationLogGroups;
@@ -2,84 +2,84 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const client_cloudwatch_logs_1 = require("@aws-sdk/client-cloudwatch-logs");
4
4
  class AmazonCloudwatchService {
5
- async createLogEvent({ credentials, data }) {
5
+ async createLogEvent(req) {
6
6
  const client = new client_cloudwatch_logs_1.CloudWatchLogs({
7
7
  credentials: {
8
- accessKeyId: credentials.accessKey,
9
- secretAccessKey: credentials.secretKey,
8
+ accessKeyId: req.credentials.accessKey,
9
+ secretAccessKey: req.credentials.secretKey,
10
10
  },
11
- region: credentials.region,
11
+ region: req.credentials.region,
12
12
  });
13
- await this.createLogGroup({ credentials, data });
14
- await this.createLogStream({ credentials, data });
13
+ await this.createLogGroup(req);
14
+ await this.createLogStream(req);
15
15
  await client.putLogEvents({
16
- logGroupName: data.group,
17
- logStreamName: data.stream,
18
- logEvents: data.events,
16
+ logGroupName: req.group,
17
+ logStreamName: req.stream,
18
+ logEvents: req.events,
19
19
  });
20
20
  }
21
- async getLogGroupByName({ credentials, data }) {
22
- const logGroups = await this.listApplicationLogGroups({ credentials, data });
23
- return logGroups.find((logGroup) => logGroup.logGroupName === data.group);
21
+ async getLogGroupByName(req) {
22
+ const logGroups = await this.listApplicationLogGroups(req);
23
+ return logGroups.find((logGroup) => logGroup.logGroupName === req.group);
24
24
  }
25
- async getLogStreamByName({ credentials, data }) {
26
- const logStreams = await this.listApplicationLogStreams({ credentials, data });
27
- return logStreams.find((logStream) => logStream.logStreamName === data.stream);
25
+ async getLogStreamByName(req) {
26
+ const logStreams = await this.listApplicationLogStreams(req);
27
+ return logStreams.find((logStream) => logStream.logStreamName === req.stream);
28
28
  }
29
- async listApplicationLogGroups({ credentials, data }) {
29
+ async listApplicationLogGroups(req) {
30
30
  const client = new client_cloudwatch_logs_1.CloudWatchLogs({
31
31
  credentials: {
32
- accessKeyId: credentials.accessKey,
33
- secretAccessKey: credentials.secretKey,
32
+ accessKeyId: req.credentials.accessKey,
33
+ secretAccessKey: req.credentials.secretKey,
34
34
  },
35
- region: credentials.region,
35
+ region: req.credentials.region,
36
36
  });
37
37
  const { logGroups } = await client.describeLogGroups({
38
- logGroupNamePrefix: data.application,
38
+ logGroupNamePrefix: req.application,
39
39
  });
40
40
  return logGroups;
41
41
  }
42
- async listApplicationLogStreams({ credentials, data }) {
42
+ async listApplicationLogStreams(req) {
43
43
  const client = new client_cloudwatch_logs_1.CloudWatchLogs({
44
44
  credentials: {
45
- accessKeyId: credentials.accessKey,
46
- secretAccessKey: credentials.secretKey,
45
+ accessKeyId: req.credentials.accessKey,
46
+ secretAccessKey: req.credentials.secretKey,
47
47
  },
48
- region: credentials.region,
48
+ region: req.credentials.region,
49
49
  });
50
50
  const { logStreams } = await client.describeLogStreams({
51
- logGroupName: data.group,
51
+ logGroupName: req.group,
52
52
  });
53
53
  return logStreams;
54
54
  }
55
- async createLogGroup({ credentials, data }) {
56
- const logGroup = await this.getLogGroupByName({ credentials, data });
55
+ async createLogGroup(req) {
56
+ const logGroup = await this.getLogGroupByName(req);
57
57
  if (!logGroup) {
58
58
  const client = new client_cloudwatch_logs_1.CloudWatchLogs({
59
59
  credentials: {
60
- accessKeyId: credentials.accessKey,
61
- secretAccessKey: credentials.secretKey,
60
+ accessKeyId: req.credentials.accessKey,
61
+ secretAccessKey: req.credentials.secretKey,
62
62
  },
63
- region: credentials.region,
63
+ region: req.credentials.region,
64
64
  });
65
65
  await client.createLogGroup({
66
- logGroupName: data.group,
66
+ logGroupName: req.group,
67
67
  });
68
68
  }
69
69
  }
70
- async createLogStream({ credentials, data }) {
71
- const logStream = await this.getLogStreamByName({ credentials, data });
70
+ async createLogStream(req) {
71
+ const logStream = await this.getLogStreamByName(req);
72
72
  if (!logStream) {
73
73
  const client = new client_cloudwatch_logs_1.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
  await client.createLogStream({
81
- logGroupName: data.group,
82
- logStreamName: data.stream,
81
+ logGroupName: req.group,
82
+ logStreamName: req.stream,
83
83
  });
84
84
  }
85
85
  }
@@ -1,8 +1,8 @@
1
1
  import { AmazonPinpoint, IAmazonPinpointService } from '../../interfaces/aws';
2
2
  declare class AmazonPinpointService implements IAmazonPinpointService {
3
- sendMail({ credentials, data }: AmazonPinpoint.SendMail.Request): Promise<void>;
4
- sendTemplateMail({ credentials, data }: AmazonPinpoint.SendTemplateMail.Request): Promise<void>;
5
- sendSMS({ credentials, data }: AmazonPinpoint.SendSMS.Request): Promise<void>;
3
+ sendMail(req: AmazonPinpoint.SendMail.Request): Promise<void>;
4
+ sendTemplateMail(req: AmazonPinpoint.SendTemplateMail.Request): Promise<void>;
5
+ sendSMS(req: AmazonPinpoint.SendSMS.Request): Promise<void>;
6
6
  }
7
7
  declare const _default: AmazonPinpointService;
8
8
  export default _default;
@@ -2,41 +2,41 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const client_pinpoint_1 = require("@aws-sdk/client-pinpoint");
4
4
  class AmazonPinpointService {
5
- async sendMail({ credentials, data }) {
5
+ async sendMail(req) {
6
6
  const client = new client_pinpoint_1.PinpointClient({
7
7
  credentials: {
8
- accessKeyId: credentials.accessKey,
9
- secretAccessKey: credentials.secretKey,
8
+ accessKeyId: req.credentials.accessKey,
9
+ secretAccessKey: req.credentials.secretKey,
10
10
  },
11
- region: credentials.region,
11
+ region: req.credentials.region,
12
12
  });
13
- const recipient = Array.isArray(data.emails) ? data.emails : [data.emails];
13
+ const recipient = Array.isArray(req.emails) ? req.emails : [req.emails];
14
14
  const addresses = recipient.reduce((acc, curr) => ({
15
15
  ...acc,
16
16
  [curr]: {
17
17
  ChannelType: 'EMAIL',
18
18
  },
19
19
  }), {});
20
- const substitutions = Object.entries(data.variables || {}).reduce((acc, [key, value]) => ({
20
+ const substitutions = Object.entries(req.variables || {}).reduce((acc, [key, value]) => ({
21
21
  ...acc,
22
22
  [key]: [value],
23
23
  }), {});
24
24
  const payload = {
25
- ApplicationId: data.application,
25
+ ApplicationId: req.applicationId,
26
26
  MessageRequest: {
27
27
  Addresses: addresses,
28
28
  MessageConfiguration: {
29
29
  EmailMessage: {
30
- FromAddress: data.from,
30
+ FromAddress: req.from,
31
31
  Substitutions: substitutions,
32
32
  SimpleEmail: {
33
33
  Subject: {
34
34
  Charset: 'utf-8',
35
- Data: data.subject,
35
+ Data: req.subject,
36
36
  },
37
37
  TextPart: {
38
38
  Charset: 'utf-8',
39
- Data: data.text,
39
+ Data: req.text,
40
40
  },
41
41
  },
42
42
  },
@@ -45,38 +45,38 @@ class AmazonPinpointService {
45
45
  };
46
46
  await client.send(new client_pinpoint_1.SendMessagesCommand(payload));
47
47
  }
48
- async sendTemplateMail({ credentials, data }) {
48
+ async sendTemplateMail(req) {
49
49
  const client = new client_pinpoint_1.PinpointClient({
50
50
  credentials: {
51
- accessKeyId: credentials.accessKey,
52
- secretAccessKey: credentials.secretKey,
51
+ accessKeyId: req.credentials.accessKey,
52
+ secretAccessKey: req.credentials.secretKey,
53
53
  },
54
- region: credentials.region,
54
+ region: req.credentials.region,
55
55
  });
56
- const recipient = Array.isArray(data.emails) ? data.emails : [data.emails];
56
+ const recipient = Array.isArray(req.emails) ? req.emails : [req.emails];
57
57
  const addresses = recipient.reduce((acc, curr) => ({
58
58
  ...acc,
59
59
  [curr]: {
60
60
  ChannelType: 'EMAIL',
61
61
  },
62
62
  }), {});
63
- const substitutions = Object.entries(data.variables || {}).reduce((acc, [key, value]) => ({
63
+ const substitutions = Object.entries(req.variables || {}).reduce((acc, [key, value]) => ({
64
64
  ...acc,
65
65
  [key]: [value],
66
66
  }), {});
67
67
  const payload = {
68
- ApplicationId: data.application,
68
+ ApplicationId: req.applicationId,
69
69
  MessageRequest: {
70
70
  Addresses: addresses,
71
71
  MessageConfiguration: {
72
72
  EmailMessage: {
73
- FromAddress: data.from,
73
+ FromAddress: req.from,
74
74
  Substitutions: substitutions,
75
75
  },
76
76
  },
77
77
  TemplateConfiguration: {
78
78
  EmailTemplate: {
79
- Name: data.template,
79
+ Name: req.template,
80
80
  Version: 'latest',
81
81
  },
82
82
  },
@@ -84,34 +84,34 @@ class AmazonPinpointService {
84
84
  };
85
85
  await client.send(new client_pinpoint_1.SendMessagesCommand(payload));
86
86
  }
87
- async sendSMS({ credentials, data }) {
87
+ async sendSMS(req) {
88
88
  const client = new client_pinpoint_1.PinpointClient({
89
89
  credentials: {
90
- accessKeyId: credentials.accessKey,
91
- secretAccessKey: credentials.secretKey,
90
+ accessKeyId: req.credentials.accessKey,
91
+ secretAccessKey: req.credentials.secretKey,
92
92
  },
93
- region: credentials.region,
93
+ region: req.credentials.region,
94
94
  });
95
- const recipient = Array.isArray(data.phones) ? data.phones : [data.phones];
95
+ const recipient = Array.isArray(req.phones) ? req.phones : [req.phones];
96
96
  const addresses = recipient.reduce((acc, curr) => ({
97
97
  ...acc,
98
98
  [curr]: {
99
99
  ChannelType: 'SMS',
100
100
  },
101
101
  }), {});
102
- const substitutions = Object.entries(data.variables || {}).reduce((acc, [key, value]) => ({
102
+ const substitutions = Object.entries(req.variables || {}).reduce((acc, [key, value]) => ({
103
103
  ...acc,
104
104
  [key]: [value],
105
105
  }), {});
106
106
  const payload = {
107
- ApplicationId: data.application,
107
+ ApplicationId: req.applicationId,
108
108
  MessageRequest: {
109
109
  Addresses: addresses,
110
110
  MessageConfiguration: {
111
111
  SMSMessage: {
112
- Body: data.text,
113
- MessageType: data.type,
114
- SenderId: data.sender,
112
+ Body: req.text,
113
+ MessageType: req.type,
114
+ SenderId: req.sender,
115
115
  Substitutions: substitutions,
116
116
  },
117
117
  },
@@ -1,10 +1,10 @@
1
1
  import { AmazonS3, IAmazonS3Service } from '../../interfaces/aws';
2
2
  declare class AmazonS3Service implements IAmazonS3Service {
3
- uploadBase64({ credentials, data }: AmazonS3.UploadBase64.Request): Promise<AmazonS3.UploadBase64.Response>;
4
- uploadBuffer({ credentials, data }: AmazonS3.UploadBuffer.Request): Promise<AmazonS3.UploadBuffer.Response>;
5
- deleteFile({ credentials, data }: AmazonS3.DeleteFile.Request): Promise<void>;
6
- listFiles({ credentials, data }: AmazonS3.ListFiles.Request): Promise<AmazonS3.ListFiles.Response>;
7
- getSignedUrl({ credentials, data }: AmazonS3.GetSignedUrl.Request): Promise<AmazonS3.GetSignedUrl.Response>;
3
+ uploadBase64(req: AmazonS3.UploadBase64.Request): Promise<AmazonS3.UploadBase64.Response>;
4
+ uploadBuffer(req: AmazonS3.UploadBuffer.Request): Promise<AmazonS3.UploadBuffer.Response>;
5
+ deleteFile(req: AmazonS3.DeleteFile.Request): Promise<void>;
6
+ listFiles(req: AmazonS3.ListFiles.Request): Promise<AmazonS3.ListFiles.Response>;
7
+ getSignedUrl(req: AmazonS3.GetSignedUrl.Request): Promise<AmazonS3.GetSignedUrl.Response>;
8
8
  private getBucketPath;
9
9
  }
10
10
  declare const _default: AmazonS3Service;