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
|
@@ -3,28 +3,28 @@ import * as ApplicationInsights from 'applicationinsights';
|
|
|
3
3
|
import { AzureApplicationInsights, IAzureApplicationInsightsService } from '../../interfaces/azure';
|
|
4
4
|
|
|
5
5
|
class AzureApplicationInsightsService implements IAzureApplicationInsightsService {
|
|
6
|
-
async trackTrace (
|
|
7
|
-
const client = new ApplicationInsights.TelemetryClient(credentials.connection!);
|
|
6
|
+
async trackTrace (req: AzureApplicationInsights.TrackTrace.Request) {
|
|
7
|
+
const client = new ApplicationInsights.TelemetryClient(req.credentials.connection!);
|
|
8
8
|
|
|
9
|
-
client.trackTrace({ message:
|
|
9
|
+
client.trackTrace({ message: req.message, severity: req.severity });
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
async trackEvent (
|
|
13
|
-
const client = new ApplicationInsights.TelemetryClient(credentials.connection!);
|
|
12
|
+
async trackEvent (req: AzureApplicationInsights.TrackEvent.Request) {
|
|
13
|
+
const client = new ApplicationInsights.TelemetryClient(req.credentials.connection!);
|
|
14
14
|
|
|
15
|
-
client.trackEvent({ name:
|
|
15
|
+
client.trackEvent({ name: req.name, properties: req.properties });
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
async trackException (
|
|
19
|
-
const client = new ApplicationInsights.TelemetryClient(credentials.connection!);
|
|
18
|
+
async trackException (req: AzureApplicationInsights.TrackException.Request) {
|
|
19
|
+
const client = new ApplicationInsights.TelemetryClient(req.credentials.connection!);
|
|
20
20
|
|
|
21
|
-
client.trackException({ exception:
|
|
21
|
+
client.trackException({ exception: req.error });
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
async trackMetric (
|
|
25
|
-
const client = new ApplicationInsights.TelemetryClient(credentials.connection!);
|
|
24
|
+
async trackMetric (req: AzureApplicationInsights.TrackMetric.Request) {
|
|
25
|
+
const client = new ApplicationInsights.TelemetryClient(req.credentials.connection!);
|
|
26
26
|
|
|
27
|
-
client.trackMetric({ name:
|
|
27
|
+
client.trackMetric({ name: req.name, value: req.value });
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -4,17 +4,17 @@ import { SmsClient, SmsSendRequest } from '@azure/communication-sms';
|
|
|
4
4
|
import { AzureCommunication, IAzureCommunicationService } from '../../interfaces/azure';
|
|
5
5
|
|
|
6
6
|
class AzureCommunicationService implements IAzureCommunicationService {
|
|
7
|
-
async sendMail (
|
|
8
|
-
const client = new EmailClient(credentials.connection!);
|
|
7
|
+
async sendMail (req: AzureCommunication.SendMail.Request): Promise<void> {
|
|
8
|
+
const client = new EmailClient(req.credentials.connection!);
|
|
9
9
|
|
|
10
|
-
const recipients = Array.isArray(
|
|
10
|
+
const recipients = Array.isArray(req.emails) ? req.emails : [ req.emails ];
|
|
11
11
|
const addresses = recipients.map(recipient => ({ address: recipient }));
|
|
12
12
|
|
|
13
13
|
const payload: EmailMessage = {
|
|
14
|
-
senderAddress:
|
|
14
|
+
senderAddress: req.from,
|
|
15
15
|
content: {
|
|
16
|
-
subject:
|
|
17
|
-
plainText:
|
|
16
|
+
subject: req.subject,
|
|
17
|
+
plainText: req.text,
|
|
18
18
|
},
|
|
19
19
|
recipients: {
|
|
20
20
|
to: addresses,
|
|
@@ -25,17 +25,17 @@ class AzureCommunicationService implements IAzureCommunicationService {
|
|
|
25
25
|
await poller.pollUntilDone();
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
async sendTemplateMail (
|
|
29
|
-
const client = new EmailClient(credentials.connection!);
|
|
28
|
+
async sendTemplateMail (req: AzureCommunication.SendTemplateMail.Request): Promise<void> {
|
|
29
|
+
const client = new EmailClient(req.credentials.connection!);
|
|
30
30
|
|
|
31
|
-
const recipients = Array.isArray(
|
|
31
|
+
const recipients = Array.isArray(req.emails) ? req.emails : [ req.emails ];
|
|
32
32
|
const addresses = recipients.map(recipient => ({ address: recipient }));
|
|
33
33
|
|
|
34
34
|
const payload: EmailMessage = {
|
|
35
|
-
senderAddress:
|
|
35
|
+
senderAddress: req.from,
|
|
36
36
|
content: {
|
|
37
|
-
subject:
|
|
38
|
-
html:
|
|
37
|
+
subject: req.subject,
|
|
38
|
+
html: req.template,
|
|
39
39
|
},
|
|
40
40
|
recipients: {
|
|
41
41
|
to: addresses,
|
|
@@ -46,14 +46,14 @@ class AzureCommunicationService implements IAzureCommunicationService {
|
|
|
46
46
|
await poller.pollUntilDone();
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
async sendSMS (
|
|
50
|
-
const client = new SmsClient(credentials.connection!);
|
|
49
|
+
async sendSMS (req: AzureCommunication.SendSMS.Request): Promise<void> {
|
|
50
|
+
const client = new SmsClient(req.credentials.connection!);
|
|
51
51
|
|
|
52
|
-
const recipients = Array.isArray(
|
|
52
|
+
const recipients = Array.isArray(req.phones) ? req.phones : [ req.phones ];
|
|
53
53
|
|
|
54
54
|
const payload: SmsSendRequest = {
|
|
55
|
-
from:
|
|
56
|
-
message:
|
|
55
|
+
from: req.sender,
|
|
56
|
+
message: req.text,
|
|
57
57
|
to: recipients,
|
|
58
58
|
};
|
|
59
59
|
|
|
@@ -61,4 +61,4 @@ class AzureCommunicationService implements IAzureCommunicationService {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export default new AzureCommunicationService();
|
|
64
|
+
export default new AzureCommunicationService();
|
|
@@ -5,11 +5,11 @@ import { AzureKeyVault, IAzureKeyVaultService } from '../../interfaces/azure';
|
|
|
5
5
|
import { parseRecord } from '../../utils/parser';
|
|
6
6
|
|
|
7
7
|
class AzureKeyVaultService implements IAzureKeyVaultService {
|
|
8
|
-
async getSecret<T> (
|
|
8
|
+
async getSecret<T> (req: AzureKeyVault.GetSecret.Request): Promise<AzureKeyVault.GetSecret.Response<T>> {
|
|
9
9
|
const credential = new DefaultAzureCredential();
|
|
10
|
-
const client = new SecretClient(
|
|
10
|
+
const client = new SecretClient(req.vault, credential);
|
|
11
11
|
|
|
12
|
-
const { value } = await client.getSecret(
|
|
12
|
+
const { value } = await client.getSecret(req.secretName);
|
|
13
13
|
|
|
14
14
|
if (value) {
|
|
15
15
|
const secret = parseRecord(value) as T;
|
|
@@ -11,37 +11,34 @@ import DateService from '../../services/date';
|
|
|
11
11
|
import FileService from '../../services/file';
|
|
12
12
|
|
|
13
13
|
class AzureStorageBlobService implements IAzureStorageBlobService {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
data,
|
|
17
|
-
}: AzureStorageBlob.UploadBuffer.Request): Promise<void> {
|
|
14
|
+
|
|
15
|
+
async uploadBuffer (req: AzureStorageBlob.UploadBuffer.Request): Promise<void> {
|
|
18
16
|
const sharedKeyCredential = new StorageSharedKeyCredential(
|
|
19
|
-
credentials.accountName!,
|
|
20
|
-
credentials.accountKey!
|
|
17
|
+
req.credentials.accountName!,
|
|
18
|
+
req.credentials.accountKey!
|
|
21
19
|
);
|
|
22
20
|
|
|
23
|
-
const client = new BlobServiceClient(
|
|
21
|
+
const client = new BlobServiceClient(req.storageUrl, sharedKeyCredential);
|
|
24
22
|
|
|
25
23
|
await client
|
|
26
|
-
.getContainerClient(
|
|
27
|
-
.getBlockBlobClient(
|
|
28
|
-
.uploadData(
|
|
24
|
+
.getContainerClient(req.storageContainer)
|
|
25
|
+
.getBlockBlobClient(req.filename)
|
|
26
|
+
.uploadData(req.file);
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
async downloadBuffer (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}: AzureStorageBlob.DownloadBuffer.Request): Promise<AzureStorageBlob.DownloadBuffer.Response> {
|
|
29
|
+
async downloadBuffer (
|
|
30
|
+
req: AzureStorageBlob.DownloadBuffer.Request
|
|
31
|
+
): Promise<AzureStorageBlob.DownloadBuffer.Response> {
|
|
35
32
|
const sharedKeyCredential = new StorageSharedKeyCredential(
|
|
36
|
-
credentials.accountName!,
|
|
37
|
-
credentials.accountKey!
|
|
33
|
+
req.credentials.accountName!,
|
|
34
|
+
req.credentials.accountKey!
|
|
38
35
|
);
|
|
39
36
|
|
|
40
|
-
const client = new BlobServiceClient(
|
|
37
|
+
const client = new BlobServiceClient(req.storageUrl, sharedKeyCredential);
|
|
41
38
|
|
|
42
39
|
const { readableStreamBody } = await client
|
|
43
|
-
.getContainerClient(
|
|
44
|
-
.getBlockBlobClient(
|
|
40
|
+
.getContainerClient(req.storageContainer)
|
|
41
|
+
.getBlockBlobClient(req.filename)
|
|
45
42
|
.download(0);
|
|
46
43
|
|
|
47
44
|
const buffer = await FileService.streamToBuffer(readableStreamBody);
|
|
@@ -51,31 +48,30 @@ class AzureStorageBlobService implements IAzureStorageBlobService {
|
|
|
51
48
|
};
|
|
52
49
|
}
|
|
53
50
|
|
|
54
|
-
async getPreSignedUrl (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}: AzureStorageBlob.GetPreSignedUrl.Request): Promise<AzureStorageBlob.GetPreSignedUrl.Response> {
|
|
51
|
+
async getPreSignedUrl (
|
|
52
|
+
req: AzureStorageBlob.GetPreSignedUrl.Request
|
|
53
|
+
): Promise<AzureStorageBlob.GetPreSignedUrl.Response> {
|
|
58
54
|
const sharedKeyCredential = new StorageSharedKeyCredential(
|
|
59
|
-
credentials.accountName!,
|
|
60
|
-
credentials.accountKey!
|
|
55
|
+
req.credentials.accountName!,
|
|
56
|
+
req.credentials.accountKey!
|
|
61
57
|
);
|
|
62
58
|
|
|
63
59
|
const payload: BlobSASSignatureValues = {
|
|
64
|
-
containerName:
|
|
65
|
-
blobName:
|
|
66
|
-
version:
|
|
67
|
-
contentEncoding:
|
|
68
|
-
contentType:
|
|
60
|
+
containerName: req.storageContainer,
|
|
61
|
+
blobName: req.filename,
|
|
62
|
+
version: req.options?.version,
|
|
63
|
+
contentEncoding: req.options?.contentEncoding,
|
|
64
|
+
contentType: req.options?.contentType,
|
|
69
65
|
permissions: 'rwac' as unknown as BlobSASPermissions,
|
|
70
66
|
startsOn:
|
|
71
|
-
|
|
67
|
+
req.options?.hoursToExpire &&
|
|
72
68
|
DateService.getCurrentDate(),
|
|
73
69
|
expiresOn:
|
|
74
|
-
|
|
75
|
-
DateService.addHours(DateService.getCurrentDate(), Number(
|
|
70
|
+
req.options?.hoursToExpire &&
|
|
71
|
+
DateService.addHours(DateService.getCurrentDate(), Number(req.options?.hoursToExpire)),
|
|
76
72
|
};
|
|
77
73
|
|
|
78
|
-
const url = `https://${credentials.accountName!}.blob.core.windows.net/${
|
|
74
|
+
const url = `https://${req.credentials.accountName!}.blob.core.windows.net/${req.storageContainer}/${req.filename}`;
|
|
79
75
|
const token = generateBlobSASQueryParameters(payload, sharedKeyCredential).toString();
|
|
80
76
|
|
|
81
77
|
return {
|
package/src/services/firebase.ts
CHANGED
|
@@ -3,41 +3,31 @@ import FirebaseAdmin from 'firebase-admin';
|
|
|
3
3
|
import { Firebase, IFirebaseService } from '../interfaces/firebase';
|
|
4
4
|
|
|
5
5
|
class FirebaseService implements IFirebaseService {
|
|
6
|
-
async publishConfig ({
|
|
7
|
-
credentials,
|
|
8
|
-
data,
|
|
9
|
-
}: Firebase.PublishConfig.Request): Promise<void> {
|
|
6
|
+
async publishConfig (req: Firebase.PublishConfig.Request): Promise<void> {
|
|
10
7
|
const client = FirebaseAdmin.initializeApp({
|
|
11
|
-
credential: FirebaseAdmin.credential.cert(credentials.cert),
|
|
12
|
-
databaseURL: credentials.database,
|
|
13
|
-
}, credentials.instance);
|
|
8
|
+
credential: FirebaseAdmin.credential.cert(req.credentials.cert),
|
|
9
|
+
databaseURL: req.credentials.database,
|
|
10
|
+
}, req.credentials.instance);
|
|
14
11
|
|
|
15
12
|
const template = client
|
|
16
13
|
.remoteConfig()
|
|
17
|
-
.createTemplateFromJSON(
|
|
14
|
+
.createTemplateFromJSON(req.template);
|
|
18
15
|
|
|
19
16
|
await client
|
|
20
17
|
.remoteConfig()
|
|
21
18
|
.publishTemplate(template);
|
|
22
|
-
|
|
23
|
-
await client.delete();
|
|
24
19
|
}
|
|
25
20
|
|
|
26
|
-
async sendNotification ({
|
|
27
|
-
credentials,
|
|
28
|
-
data,
|
|
29
|
-
}: Firebase.SendNotification.Request): Promise<void> {
|
|
21
|
+
async sendNotification (req: Firebase.SendNotification.Request): Promise<void> {
|
|
30
22
|
const client = FirebaseAdmin.initializeApp({
|
|
31
|
-
credential: FirebaseAdmin.credential.cert(credentials.cert),
|
|
32
|
-
databaseURL: credentials.database,
|
|
33
|
-
}, credentials.instance);
|
|
23
|
+
credential: FirebaseAdmin.credential.cert(req.credentials.cert),
|
|
24
|
+
databaseURL: req.credentials.database,
|
|
25
|
+
}, req.credentials.instance);
|
|
34
26
|
|
|
35
27
|
await client
|
|
36
28
|
.messaging()
|
|
37
|
-
.sendEachForMulticast(
|
|
38
|
-
|
|
39
|
-
await client.delete();
|
|
29
|
+
.sendEachForMulticast(req.message, req.isTest);
|
|
40
30
|
}
|
|
41
31
|
}
|
|
42
32
|
|
|
43
|
-
export default new FirebaseService();
|
|
33
|
+
export default new FirebaseService();
|
|
@@ -3,21 +3,18 @@ import { google } from 'googleapis';
|
|
|
3
3
|
import { GoogleDrive, IGoogleDriveService } from '../../interfaces/gcp';
|
|
4
4
|
|
|
5
5
|
class GoogleDriveService implements IGoogleDriveService {
|
|
6
|
-
public async readFile ({
|
|
7
|
-
credentials,
|
|
8
|
-
data,
|
|
9
|
-
}: GoogleDrive.ReadFile.Request): Promise<GoogleDrive.ReadFile.Response> {
|
|
6
|
+
public async readFile (req: GoogleDrive.ReadFile.Request): Promise<GoogleDrive.ReadFile.Response> {
|
|
10
7
|
const instance = google.drive({
|
|
11
8
|
version: 'v3',
|
|
12
|
-
auth: credentials.apiKey,
|
|
9
|
+
auth: req.credentials.apiKey,
|
|
13
10
|
});
|
|
14
11
|
|
|
15
|
-
const { data
|
|
12
|
+
const { data } = await instance.files.get({ fileId: req.fileId });
|
|
16
13
|
|
|
17
14
|
return {
|
|
18
|
-
file:
|
|
15
|
+
file: data,
|
|
19
16
|
};
|
|
20
17
|
}
|
|
21
18
|
}
|
|
22
19
|
|
|
23
|
-
export default new GoogleDriveService();
|
|
20
|
+
export default new GoogleDriveService();
|
|
@@ -4,21 +4,22 @@ import { GoogleSecrets, IGoogleSecretsService } from '../../interfaces/gcp';
|
|
|
4
4
|
import { parseRecord } from '../../utils/parser';
|
|
5
5
|
|
|
6
6
|
class GoogleSecretsService implements IGoogleSecretsService {
|
|
7
|
-
public async getSecret<T> ({
|
|
8
|
-
credentials
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const client = new SecretManagerServiceClient({ apiKey: credentials.apiKey });
|
|
7
|
+
public async getSecret<T> (req: GoogleSecrets.GetSecret.Request): Promise<GoogleSecrets.GetSecret.Response<T>> {
|
|
8
|
+
const credentials = JSON.parse(req.credentials.apiKey);
|
|
9
|
+
|
|
10
|
+
const client = new SecretManagerServiceClient({ credentials });
|
|
12
11
|
|
|
13
12
|
const [ version ] = await client.accessSecretVersion({
|
|
14
|
-
name: `projects/${
|
|
13
|
+
name: `projects/${req.projectId}/secrets/${req.secretId}/versions/latest`,
|
|
15
14
|
});
|
|
16
15
|
|
|
17
|
-
const
|
|
18
|
-
const
|
|
16
|
+
const data = (version.payload?.data ?? new Uint8Array()) as Uint8Array;
|
|
17
|
+
const secretData = Buffer.from(data).toString('utf-8');
|
|
18
|
+
|
|
19
|
+
const secret = parseRecord(secretData) as T;
|
|
19
20
|
|
|
20
21
|
return {
|
|
21
|
-
secret
|
|
22
|
+
secret,
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
}
|
|
@@ -3,24 +3,21 @@ import { google } from 'googleapis';
|
|
|
3
3
|
import { GoogleSheets, IGoogleSheetsService } from '../../interfaces/gcp';
|
|
4
4
|
|
|
5
5
|
class GoogleSheetsService implements IGoogleSheetsService {
|
|
6
|
-
public async readSheet ({
|
|
7
|
-
credentials,
|
|
8
|
-
data,
|
|
9
|
-
}: GoogleSheets.ReadSheet.Request): Promise<GoogleSheets.ReadSheet.Response> {
|
|
6
|
+
public async readSheet (req: GoogleSheets.ReadSheet.Request): Promise<GoogleSheets.ReadSheet.Response> {
|
|
10
7
|
const instance = google.sheets({
|
|
11
8
|
version: 'v4',
|
|
12
|
-
auth: credentials.apiKey,
|
|
9
|
+
auth: req.credentials.apiKey,
|
|
13
10
|
});
|
|
14
11
|
|
|
15
|
-
const { data
|
|
16
|
-
spreadsheetId:
|
|
17
|
-
ranges:
|
|
12
|
+
const { data } = await instance.spreadsheets.values.batchGet({
|
|
13
|
+
spreadsheetId: req.spreadsheetId,
|
|
14
|
+
ranges: req.tabs,
|
|
18
15
|
});
|
|
19
16
|
|
|
20
17
|
return {
|
|
21
|
-
sheet:
|
|
18
|
+
sheet: data,
|
|
22
19
|
};
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
22
|
|
|
26
|
-
export default new GoogleSheetsService();
|
|
23
|
+
export default new GoogleSheetsService();
|
package/src/services/grafana.ts
CHANGED
|
@@ -2,42 +2,36 @@ import { Grafana, IGrafanaService } from '../interfaces/grafana';
|
|
|
2
2
|
import HttpService from './http';
|
|
3
3
|
|
|
4
4
|
class GrafanaService implements IGrafanaService {
|
|
5
|
-
async getDashboard ({
|
|
6
|
-
|
|
7
|
-
data,
|
|
8
|
-
}: Grafana.GetDashboard.Request): Promise<Grafana.GetDashboard.Response> {
|
|
9
|
-
const { data: response } = await HttpService.request<unknown>({
|
|
5
|
+
async getDashboard (req: Grafana.GetDashboard.Request): Promise<Grafana.GetDashboard.Response> {
|
|
6
|
+
const { data } = await HttpService.request<unknown>({
|
|
10
7
|
method: 'get',
|
|
11
|
-
baseURL: credentials.url,
|
|
12
|
-
resourcePath: `/api/dashboards/uid/${
|
|
8
|
+
baseURL: req.credentials.url,
|
|
9
|
+
resourcePath: `/api/dashboards/uid/${req.uid}`,
|
|
13
10
|
headers: {
|
|
14
|
-
Authorization: `Bearer ${credentials.apiKey}`,
|
|
11
|
+
Authorization: `Bearer ${req.credentials.apiKey}`,
|
|
15
12
|
},
|
|
16
13
|
});
|
|
17
14
|
|
|
18
15
|
return {
|
|
19
|
-
dashboard:
|
|
16
|
+
dashboard: data,
|
|
20
17
|
};
|
|
21
18
|
}
|
|
22
19
|
|
|
23
|
-
async searchDashboard ({
|
|
24
|
-
|
|
25
|
-
data,
|
|
26
|
-
}: Grafana.SearchDashboard.Request): Promise<Grafana.SearchDashboard.Response> {
|
|
27
|
-
const { data: response } = await HttpService.request<unknown>({
|
|
20
|
+
async searchDashboard (req: Grafana.SearchDashboard.Request): Promise<Grafana.SearchDashboard.Response> {
|
|
21
|
+
const { data } = await HttpService.request<unknown>({
|
|
28
22
|
method: 'get',
|
|
29
|
-
baseURL: credentials.url,
|
|
23
|
+
baseURL: req.credentials.url,
|
|
30
24
|
resourcePath: '/api/search',
|
|
31
25
|
headers: {
|
|
32
|
-
Authorization: `Bearer ${credentials.apiKey}`,
|
|
26
|
+
Authorization: `Bearer ${req.credentials.apiKey}`,
|
|
33
27
|
},
|
|
34
28
|
query: {
|
|
35
|
-
query:
|
|
29
|
+
query: req.query,
|
|
36
30
|
},
|
|
37
31
|
});
|
|
38
32
|
|
|
39
33
|
return {
|
|
40
|
-
dashboards:
|
|
34
|
+
dashboards: data as unknown[],
|
|
41
35
|
};
|
|
42
36
|
}
|
|
43
37
|
}
|