mblabs-roccato-backend-commons 1.0.8 → 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.
- package/bitbucket-pipelines.yml +6 -48
- package/dist/database/entities/account.d.ts +1 -2
- package/dist/database/entities/account.js +2 -7
- package/dist/database/entities/address.d.ts +2 -1
- package/dist/database/entities/address.js +6 -5
- package/dist/database/entities/company-address.d.ts +10 -0
- package/dist/database/entities/company-address.js +51 -0
- package/dist/database/entities/company.d.ts +13 -0
- package/dist/database/entities/company.js +68 -0
- package/dist/database/entities/index.d.ts +3 -1
- package/dist/database/entities/index.js +5 -1
- package/dist/database/migrations/1748448589934-CreateAccountsTable.js +1 -6
- package/dist/database/migrations/1750432386920-CreateAddressTable.js +0 -5
- package/dist/database/migrations/{1750691840822-CreateAccountDetailsTable.d.ts → 1750437883213-CreateCompanyTable.d.ts} +1 -1
- package/dist/database/migrations/{1750691840822-CreateAccountDetailsTable.js → 1750437883213-CreateCompanyTable.js} +35 -23
- package/dist/database/migrations/{1750690818577-CreateAccountAddressTable.d.ts → 1750440116105-CreateCompanyAddressTable.d.ts} +1 -1
- package/dist/database/migrations/{1750690818577-CreateAccountAddressTable.js → 1750440116105-CreateCompanyAddressTable.js} +14 -21
- package/dist/database/migrations/index.d.ts +1 -29
- package/dist/database/migrations/index.js +18 -18
- package/dist/interfaces/aws.d.ts +41 -67
- package/dist/interfaces/azure.d.ts +38 -61
- package/dist/interfaces/firebase.d.ts +3 -7
- package/dist/interfaces/gcp.d.ts +5 -11
- package/dist/interfaces/grafana.d.ts +2 -6
- package/dist/interfaces/keycloak.d.ts +4 -171
- package/dist/interfaces/nodemailer.d.ts +16 -20
- package/dist/interfaces/redis.d.ts +8 -49
- package/dist/interfaces/sendgrid.d.ts +13 -15
- package/dist/services/aws/cloudwatch.d.ts +1 -1
- package/dist/services/aws/cloudwatch.js +38 -38
- package/dist/services/aws/pinpoint.d.ts +3 -3
- package/dist/services/aws/pinpoint.js +29 -29
- package/dist/services/aws/s3.d.ts +5 -5
- package/dist/services/aws/s3.js +55 -59
- package/dist/services/aws/secret-manager.d.ts +1 -1
- package/dist/services/aws/secret-manager.js +5 -5
- package/dist/services/aws/sqs.d.ts +3 -3
- package/dist/services/aws/sqs.js +16 -16
- package/dist/services/azure/application-insights.d.ts +4 -4
- package/dist/services/azure/application-insights.js +12 -12
- package/dist/services/azure/communication.d.ts +3 -3
- package/dist/services/azure/communication.js +17 -17
- package/dist/services/azure/keyvault.d.ts +1 -1
- package/dist/services/azure/keyvault.js +3 -3
- package/dist/services/azure/storage-blob.d.ts +3 -3
- package/dist/services/azure/storage-blob.js +22 -22
- package/dist/services/firebase.d.ts +2 -2
- package/dist/services/firebase.js +10 -12
- package/dist/services/gcp/drive.d.ts +1 -1
- package/dist/services/gcp/drive.js +4 -4
- package/dist/services/gcp/secrets.d.ts +1 -1
- package/dist/services/gcp/secrets.js +8 -6
- package/dist/services/gcp/sheets.d.ts +1 -1
- package/dist/services/gcp/sheets.js +6 -6
- package/dist/services/grafana.d.ts +2 -2
- package/dist/services/grafana.js +12 -12
- package/dist/services/keycloak.d.ts +2 -14
- package/dist/services/keycloak.js +24 -300
- package/dist/services/nodemailer.d.ts +2 -2
- package/dist/services/nodemailer.js +109 -19
- package/dist/services/redis.d.ts +8 -6
- package/dist/services/redis.js +24 -53
- package/dist/services/sendgrid.d.ts +1 -1
- package/dist/services/sendgrid.js +10 -10
- package/package.json +1 -1
- package/src/database/entities/account.ts +3 -5
- package/src/database/entities/address.ts +7 -4
- package/src/database/entities/company-address.ts +27 -0
- package/src/database/entities/company.ts +36 -0
- package/src/database/entities/index.ts +4 -0
- package/src/database/migrations/1748448589934-CreateAccountsTable.ts +1 -6
- package/src/database/migrations/1750432386920-CreateAddressTable.ts +0 -5
- package/src/database/migrations/{1750691840822-CreateAccountDetailsTable.ts → 1750437883213-CreateCompanyTable.ts} +35 -21
- package/src/database/migrations/{1750690818577-CreateAccountAddressTable.ts → 1750440116105-CreateCompanyAddressTable.ts} +14 -24
- package/src/database/migrations/index.ts +6 -6
- package/src/interfaces/aws.ts +55 -81
- package/src/interfaces/azure.ts +50 -71
- package/src/interfaces/firebase.ts +6 -10
- package/src/interfaces/gcp.ts +8 -14
- package/src/interfaces/grafana.ts +5 -9
- package/src/interfaces/keycloak.ts +7 -190
- package/src/interfaces/nodemailer.ts +18 -22
- package/src/interfaces/redis.ts +8 -54
- package/src/interfaces/sendgrid.ts +14 -16
- package/src/services/aws/cloudwatch.ts +39 -39
- package/src/services/aws/pinpoint.ts +30 -30
- package/src/services/aws/s3.ts +55 -59
- package/src/services/aws/secret-manager.ts +7 -8
- package/src/services/aws/sqs.ts +17 -23
- package/src/services/azure/application-insights.ts +12 -12
- package/src/services/azure/communication.ts +18 -18
- package/src/services/azure/keyvault.ts +3 -3
- package/src/services/azure/storage-blob.ts +30 -34
- package/src/services/firebase.ts +11 -21
- package/src/services/gcp/drive.ts +5 -8
- package/src/services/gcp/secrets.ts +10 -9
- package/src/services/gcp/sheets.ts +7 -10
- package/src/services/grafana.ts +12 -18
- package/src/services/keycloak.ts +25 -381
- package/src/services/nodemailer.ts +110 -19
- package/src/services/redis.ts +22 -58
- package/src/services/sendgrid.ts +11 -11
|
@@ -1,54 +1,13 @@
|
|
|
1
|
-
interface Credentials {
|
|
2
|
-
host: string;
|
|
3
|
-
port: number;
|
|
4
|
-
password?: string;
|
|
5
|
-
}
|
|
6
1
|
export declare namespace Redis {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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(
|
|
50
|
-
get<T>(
|
|
51
|
-
del(
|
|
52
|
-
exists(
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
14
|
-
await this.createLogStream(
|
|
13
|
+
await this.createLogGroup(req);
|
|
14
|
+
await this.createLogStream(req);
|
|
15
15
|
await client.putLogEvents({
|
|
16
|
-
logGroupName:
|
|
17
|
-
logStreamName:
|
|
18
|
-
logEvents:
|
|
16
|
+
logGroupName: req.group,
|
|
17
|
+
logStreamName: req.stream,
|
|
18
|
+
logEvents: req.events,
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
async getLogGroupByName(
|
|
22
|
-
const logGroups = await this.listApplicationLogGroups(
|
|
23
|
-
return logGroups.find((logGroup) => logGroup.logGroupName ===
|
|
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(
|
|
26
|
-
const logStreams = await this.listApplicationLogStreams(
|
|
27
|
-
return logStreams.find((logStream) => logStream.logStreamName ===
|
|
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(
|
|
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:
|
|
38
|
+
logGroupNamePrefix: req.application,
|
|
39
39
|
});
|
|
40
40
|
return logGroups;
|
|
41
41
|
}
|
|
42
|
-
async listApplicationLogStreams(
|
|
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:
|
|
51
|
+
logGroupName: req.group,
|
|
52
52
|
});
|
|
53
53
|
return logStreams;
|
|
54
54
|
}
|
|
55
|
-
async createLogGroup(
|
|
56
|
-
const logGroup = await this.getLogGroupByName(
|
|
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:
|
|
66
|
+
logGroupName: req.group,
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
async createLogStream(
|
|
71
|
-
const logStream = await this.getLogStreamByName(
|
|
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:
|
|
82
|
-
logStreamName:
|
|
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(
|
|
4
|
-
sendTemplateMail(
|
|
5
|
-
sendSMS(
|
|
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(
|
|
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(
|
|
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(
|
|
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:
|
|
25
|
+
ApplicationId: req.applicationId,
|
|
26
26
|
MessageRequest: {
|
|
27
27
|
Addresses: addresses,
|
|
28
28
|
MessageConfiguration: {
|
|
29
29
|
EmailMessage: {
|
|
30
|
-
FromAddress:
|
|
30
|
+
FromAddress: req.from,
|
|
31
31
|
Substitutions: substitutions,
|
|
32
32
|
SimpleEmail: {
|
|
33
33
|
Subject: {
|
|
34
34
|
Charset: 'utf-8',
|
|
35
|
-
Data:
|
|
35
|
+
Data: req.subject,
|
|
36
36
|
},
|
|
37
37
|
TextPart: {
|
|
38
38
|
Charset: 'utf-8',
|
|
39
|
-
Data:
|
|
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(
|
|
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(
|
|
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(
|
|
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:
|
|
68
|
+
ApplicationId: req.applicationId,
|
|
69
69
|
MessageRequest: {
|
|
70
70
|
Addresses: addresses,
|
|
71
71
|
MessageConfiguration: {
|
|
72
72
|
EmailMessage: {
|
|
73
|
-
FromAddress:
|
|
73
|
+
FromAddress: req.from,
|
|
74
74
|
Substitutions: substitutions,
|
|
75
75
|
},
|
|
76
76
|
},
|
|
77
77
|
TemplateConfiguration: {
|
|
78
78
|
EmailTemplate: {
|
|
79
|
-
Name:
|
|
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(
|
|
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(
|
|
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(
|
|
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:
|
|
107
|
+
ApplicationId: req.applicationId,
|
|
108
108
|
MessageRequest: {
|
|
109
109
|
Addresses: addresses,
|
|
110
110
|
MessageConfiguration: {
|
|
111
111
|
SMSMessage: {
|
|
112
|
-
Body:
|
|
113
|
-
MessageType:
|
|
114
|
-
SenderId:
|
|
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(
|
|
4
|
-
uploadBuffer(
|
|
5
|
-
deleteFile(
|
|
6
|
-
listFiles(
|
|
7
|
-
getSignedUrl(
|
|
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;
|
package/dist/services/aws/s3.js
CHANGED
|
@@ -7,120 +7,116 @@ const client_s3_1 = require("@aws-sdk/client-s3");
|
|
|
7
7
|
const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
|
|
8
8
|
const file_1 = __importDefault(require("../../services/file"));
|
|
9
9
|
class AmazonS3Service {
|
|
10
|
-
async uploadBase64(
|
|
10
|
+
async uploadBase64(req) {
|
|
11
11
|
const client = new client_s3_1.S3({
|
|
12
12
|
credentials: {
|
|
13
|
-
accessKeyId: credentials.accessKey,
|
|
14
|
-
secretAccessKey: credentials.secretKey,
|
|
13
|
+
accessKeyId: req.credentials.accessKey,
|
|
14
|
+
secretAccessKey: req.credentials.secretKey,
|
|
15
15
|
},
|
|
16
|
-
region: credentials.region,
|
|
16
|
+
region: req.credentials.region,
|
|
17
17
|
});
|
|
18
|
-
const { buffer, extension } = file_1.default.getBase64Metadata(
|
|
19
|
-
const key =
|
|
20
|
-
?
|
|
18
|
+
const { buffer, extension } = file_1.default.getBase64Metadata(req.file);
|
|
19
|
+
const key = req.options?.filename
|
|
20
|
+
? req.options?.filename
|
|
21
21
|
: file_1.default.getUniqueFilename(extension);
|
|
22
22
|
const payload = {
|
|
23
|
-
Key: this.getBucketPath(key,
|
|
23
|
+
Key: this.getBucketPath(key, req.options?.folder),
|
|
24
24
|
Body: buffer,
|
|
25
|
-
ContentEncoding:
|
|
26
|
-
ContentType:
|
|
27
|
-
Bucket:
|
|
28
|
-
ACL:
|
|
25
|
+
ContentEncoding: req.options?.contentEncoding,
|
|
26
|
+
ContentType: req.options?.contentType,
|
|
27
|
+
Bucket: req.bucket,
|
|
28
|
+
ACL: req.options?.isPrivate ? 'private' : 'public-read',
|
|
29
29
|
};
|
|
30
30
|
await client.putObject(payload);
|
|
31
31
|
const { url } = await this.getSignedUrl({
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
credentials,
|
|
32
|
+
bucket: req.bucket,
|
|
33
|
+
credentials: req.credentials,
|
|
34
|
+
filename: key,
|
|
35
|
+
folder: req.options?.folder,
|
|
36
|
+
isUpload: false,
|
|
39
37
|
});
|
|
40
38
|
return {
|
|
41
39
|
key: payload.Key,
|
|
42
|
-
bucket:
|
|
40
|
+
bucket: req.bucket,
|
|
43
41
|
url,
|
|
44
42
|
};
|
|
45
43
|
}
|
|
46
|
-
async uploadBuffer(
|
|
44
|
+
async uploadBuffer(req) {
|
|
47
45
|
const client = new client_s3_1.S3({
|
|
48
46
|
credentials: {
|
|
49
|
-
accessKeyId: credentials.accessKey,
|
|
50
|
-
secretAccessKey: credentials.secretKey,
|
|
47
|
+
accessKeyId: req.credentials.accessKey,
|
|
48
|
+
secretAccessKey: req.credentials.secretKey,
|
|
51
49
|
},
|
|
52
|
-
region: credentials.region,
|
|
50
|
+
region: req.credentials.region,
|
|
53
51
|
});
|
|
54
|
-
const key =
|
|
55
|
-
?
|
|
52
|
+
const key = req.options?.filename
|
|
53
|
+
? req.options?.filename
|
|
56
54
|
: file_1.default.getUniqueFilename('');
|
|
57
55
|
const payload = {
|
|
58
|
-
Key: this.getBucketPath(key,
|
|
59
|
-
Body:
|
|
60
|
-
ContentEncoding:
|
|
61
|
-
ContentType:
|
|
62
|
-
Bucket:
|
|
63
|
-
ACL:
|
|
56
|
+
Key: this.getBucketPath(key, req.options?.folder),
|
|
57
|
+
Body: req.file,
|
|
58
|
+
ContentEncoding: req.options?.contentEncoding,
|
|
59
|
+
ContentType: req.options?.contentType,
|
|
60
|
+
Bucket: req.bucket,
|
|
61
|
+
ACL: req.options?.isPrivate ? 'private' : 'public-read',
|
|
64
62
|
};
|
|
65
63
|
await client.putObject(payload);
|
|
66
64
|
const { url } = await this.getSignedUrl({
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
},
|
|
73
|
-
credentials,
|
|
65
|
+
bucket: req.bucket,
|
|
66
|
+
credentials: req.credentials,
|
|
67
|
+
filename: key,
|
|
68
|
+
folder: req.options?.folder,
|
|
69
|
+
isUpload: false,
|
|
74
70
|
});
|
|
75
71
|
return {
|
|
76
72
|
key: payload.Key,
|
|
77
|
-
bucket:
|
|
73
|
+
bucket: req.bucket,
|
|
78
74
|
url,
|
|
79
75
|
};
|
|
80
76
|
}
|
|
81
|
-
async deleteFile(
|
|
77
|
+
async deleteFile(req) {
|
|
82
78
|
const client = new client_s3_1.S3({
|
|
83
79
|
credentials: {
|
|
84
|
-
accessKeyId: credentials.accessKey,
|
|
85
|
-
secretAccessKey: credentials.secretKey,
|
|
80
|
+
accessKeyId: req.credentials.accessKey,
|
|
81
|
+
secretAccessKey: req.credentials.secretKey,
|
|
86
82
|
},
|
|
87
|
-
region: credentials.region,
|
|
83
|
+
region: req.credentials.region,
|
|
88
84
|
});
|
|
89
85
|
const payload = {
|
|
90
|
-
Key: this.getBucketPath(
|
|
91
|
-
Bucket:
|
|
86
|
+
Key: this.getBucketPath(req.filename, req.folder),
|
|
87
|
+
Bucket: req.bucket,
|
|
92
88
|
};
|
|
93
89
|
await client.deleteObject(payload);
|
|
94
90
|
}
|
|
95
|
-
async listFiles(
|
|
91
|
+
async listFiles(req) {
|
|
96
92
|
const client = new client_s3_1.S3({
|
|
97
93
|
credentials: {
|
|
98
|
-
accessKeyId: credentials.accessKey,
|
|
99
|
-
secretAccessKey: credentials.secretKey,
|
|
94
|
+
accessKeyId: req.credentials.accessKey,
|
|
95
|
+
secretAccessKey: req.credentials.secretKey,
|
|
100
96
|
},
|
|
101
|
-
region: credentials.region,
|
|
97
|
+
region: req.credentials.region,
|
|
102
98
|
});
|
|
103
99
|
const { Contents } = await client.listObjectsV2({
|
|
104
|
-
Bucket:
|
|
105
|
-
Prefix:
|
|
100
|
+
Bucket: req.bucket,
|
|
101
|
+
Prefix: req.folder,
|
|
106
102
|
});
|
|
107
103
|
return {
|
|
108
104
|
files: Contents ?? [],
|
|
109
105
|
};
|
|
110
106
|
}
|
|
111
|
-
async getSignedUrl(
|
|
107
|
+
async getSignedUrl(req) {
|
|
112
108
|
const client = new client_s3_1.S3({
|
|
113
109
|
credentials: {
|
|
114
|
-
accessKeyId: credentials.accessKey,
|
|
115
|
-
secretAccessKey: credentials.secretKey,
|
|
110
|
+
accessKeyId: req.credentials.accessKey,
|
|
111
|
+
secretAccessKey: req.credentials.secretKey,
|
|
116
112
|
},
|
|
117
|
-
region: credentials.region,
|
|
113
|
+
region: req.credentials.region,
|
|
118
114
|
});
|
|
119
115
|
const payload = {
|
|
120
|
-
Key: this.getBucketPath(
|
|
121
|
-
Bucket:
|
|
116
|
+
Key: this.getBucketPath(req.filename, req.folder),
|
|
117
|
+
Bucket: req.bucket,
|
|
122
118
|
};
|
|
123
|
-
const method =
|
|
119
|
+
const method = req.isUpload
|
|
124
120
|
? new client_s3_1.PutObjectCommand(payload)
|
|
125
121
|
: new client_s3_1.GetObjectCommand(payload);
|
|
126
122
|
const url = await (0, s3_request_presigner_1.getSignedUrl)(client, method);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AmazonSecretManager, IAmazonSecretManagerService } from '../../interfaces/aws';
|
|
2
2
|
declare class AmazonSecretManagerService implements IAmazonSecretManagerService {
|
|
3
|
-
getSecret<T>(
|
|
3
|
+
getSecret<T>(req: AmazonSecretManager.GetSecret.Request): Promise<AmazonSecretManager.GetSecret.Response<T>>;
|
|
4
4
|
}
|
|
5
5
|
declare const _default: AmazonSecretManagerService;
|
|
6
6
|
export default _default;
|
|
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const client_secrets_manager_1 = require("@aws-sdk/client-secrets-manager");
|
|
4
4
|
const parser_1 = require("../../utils/parser");
|
|
5
5
|
class AmazonSecretManagerService {
|
|
6
|
-
async getSecret(
|
|
6
|
+
async getSecret(req) {
|
|
7
7
|
const client = new client_secrets_manager_1.SecretsManager({
|
|
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
|
-
const { SecretString, SecretBinary } = await client.getSecretValue({ SecretId:
|
|
14
|
+
const { SecretString, SecretBinary } = await client.getSecretValue({ SecretId: req.secretId });
|
|
15
15
|
if (SecretString) {
|
|
16
16
|
const secret = (0, parser_1.parseRecord)(SecretString);
|
|
17
17
|
return {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AmazonSQS, IAmazonSQSService } from '../../interfaces/aws';
|
|
2
2
|
declare class AmazonSQSService implements IAmazonSQSService {
|
|
3
|
-
publishMessage(
|
|
4
|
-
consumeMessage<T>(
|
|
5
|
-
consumeMessages<T>(
|
|
3
|
+
publishMessage(req: AmazonSQS.PublishMessage.Request): Promise<void>;
|
|
4
|
+
consumeMessage<T>(req: AmazonSQS.ConsumeMessage.Request): Promise<AmazonSQS.ConsumeMessage.Response<T>>;
|
|
5
|
+
consumeMessages<T>(req: AmazonSQS.ConsumeMessages.Request): Promise<AmazonSQS.ConsumeMessages.Response<T>>;
|
|
6
6
|
}
|
|
7
7
|
declare const _default: AmazonSQSService;
|
|
8
8
|
export default _default;
|