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
package/dist/services/aws/sqs.js
CHANGED
|
@@ -3,29 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const client_sqs_1 = require("@aws-sdk/client-sqs");
|
|
4
4
|
const utils_1 = require("../../utils");
|
|
5
5
|
class AmazonSQSService {
|
|
6
|
-
async publishMessage(
|
|
6
|
+
async publishMessage(req) {
|
|
7
7
|
const client = new client_sqs_1.SQS({
|
|
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 { QueueUrl } = await client.getQueueUrl({ QueueName:
|
|
14
|
+
const { QueueUrl } = await client.getQueueUrl({ QueueName: req.queue });
|
|
15
15
|
await client.sendMessage({
|
|
16
|
-
MessageBody: JSON.stringify(
|
|
16
|
+
MessageBody: JSON.stringify(req.message),
|
|
17
17
|
QueueUrl,
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
async consumeMessage(
|
|
20
|
+
async consumeMessage(req) {
|
|
21
21
|
const client = new client_sqs_1.SQS({
|
|
22
22
|
credentials: {
|
|
23
|
-
accessKeyId: credentials.accessKey,
|
|
24
|
-
secretAccessKey: credentials.secretKey,
|
|
23
|
+
accessKeyId: req.credentials.accessKey,
|
|
24
|
+
secretAccessKey: req.credentials.secretKey,
|
|
25
25
|
},
|
|
26
|
-
region: credentials.region,
|
|
26
|
+
region: req.credentials.region,
|
|
27
27
|
});
|
|
28
|
-
const { QueueUrl } = await client.getQueueUrl({ QueueName:
|
|
28
|
+
const { QueueUrl } = await client.getQueueUrl({ QueueName: req.queue });
|
|
29
29
|
const { Messages } = await client.receiveMessage({
|
|
30
30
|
QueueUrl,
|
|
31
31
|
MaxNumberOfMessages: 1,
|
|
@@ -44,15 +44,15 @@ class AmazonSQSService {
|
|
|
44
44
|
message: {},
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
async consumeMessages(
|
|
47
|
+
async consumeMessages(req) {
|
|
48
48
|
const client = new client_sqs_1.SQS({
|
|
49
49
|
credentials: {
|
|
50
|
-
accessKeyId: credentials.accessKey,
|
|
51
|
-
secretAccessKey: credentials.secretKey,
|
|
50
|
+
accessKeyId: req.credentials.accessKey,
|
|
51
|
+
secretAccessKey: req.credentials.secretKey,
|
|
52
52
|
},
|
|
53
|
-
region: credentials.region,
|
|
53
|
+
region: req.credentials.region,
|
|
54
54
|
});
|
|
55
|
-
const { QueueUrl } = await client.getQueueUrl({ QueueName:
|
|
55
|
+
const { QueueUrl } = await client.getQueueUrl({ QueueName: req.queue });
|
|
56
56
|
const { Messages } = await client.receiveMessage({
|
|
57
57
|
QueueUrl,
|
|
58
58
|
MaxNumberOfMessages: 10,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AzureApplicationInsights, IAzureApplicationInsightsService } from '../../interfaces/azure';
|
|
2
2
|
declare class AzureApplicationInsightsService implements IAzureApplicationInsightsService {
|
|
3
|
-
trackTrace(
|
|
4
|
-
trackEvent(
|
|
5
|
-
trackException(
|
|
6
|
-
trackMetric(
|
|
3
|
+
trackTrace(req: AzureApplicationInsights.TrackTrace.Request): Promise<void>;
|
|
4
|
+
trackEvent(req: AzureApplicationInsights.TrackEvent.Request): Promise<void>;
|
|
5
|
+
trackException(req: AzureApplicationInsights.TrackException.Request): Promise<void>;
|
|
6
|
+
trackMetric(req: AzureApplicationInsights.TrackMetric.Request): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
declare const _default: AzureApplicationInsightsService;
|
|
9
9
|
export default _default;
|
|
@@ -35,21 +35,21 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const ApplicationInsights = __importStar(require("applicationinsights"));
|
|
37
37
|
class AzureApplicationInsightsService {
|
|
38
|
-
async trackTrace(
|
|
39
|
-
const client = new ApplicationInsights.TelemetryClient(credentials.connection);
|
|
40
|
-
client.trackTrace({ message:
|
|
38
|
+
async trackTrace(req) {
|
|
39
|
+
const client = new ApplicationInsights.TelemetryClient(req.credentials.connection);
|
|
40
|
+
client.trackTrace({ message: req.message, severity: req.severity });
|
|
41
41
|
}
|
|
42
|
-
async trackEvent(
|
|
43
|
-
const client = new ApplicationInsights.TelemetryClient(credentials.connection);
|
|
44
|
-
client.trackEvent({ name:
|
|
42
|
+
async trackEvent(req) {
|
|
43
|
+
const client = new ApplicationInsights.TelemetryClient(req.credentials.connection);
|
|
44
|
+
client.trackEvent({ name: req.name, properties: req.properties });
|
|
45
45
|
}
|
|
46
|
-
async trackException(
|
|
47
|
-
const client = new ApplicationInsights.TelemetryClient(credentials.connection);
|
|
48
|
-
client.trackException({ exception:
|
|
46
|
+
async trackException(req) {
|
|
47
|
+
const client = new ApplicationInsights.TelemetryClient(req.credentials.connection);
|
|
48
|
+
client.trackException({ exception: req.error });
|
|
49
49
|
}
|
|
50
|
-
async trackMetric(
|
|
51
|
-
const client = new ApplicationInsights.TelemetryClient(credentials.connection);
|
|
52
|
-
client.trackMetric({ name:
|
|
50
|
+
async trackMetric(req) {
|
|
51
|
+
const client = new ApplicationInsights.TelemetryClient(req.credentials.connection);
|
|
52
|
+
client.trackMetric({ name: req.name, value: req.value });
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
exports.default = new AzureApplicationInsightsService();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AzureCommunication, IAzureCommunicationService } from '../../interfaces/azure';
|
|
2
2
|
declare class AzureCommunicationService implements IAzureCommunicationService {
|
|
3
|
-
sendMail(
|
|
4
|
-
sendTemplateMail(
|
|
5
|
-
sendSMS(
|
|
3
|
+
sendMail(req: AzureCommunication.SendMail.Request): Promise<void>;
|
|
4
|
+
sendTemplateMail(req: AzureCommunication.SendTemplateMail.Request): Promise<void>;
|
|
5
|
+
sendSMS(req: AzureCommunication.SendSMS.Request): Promise<void>;
|
|
6
6
|
}
|
|
7
7
|
declare const _default: AzureCommunicationService;
|
|
8
8
|
export default _default;
|
|
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const communication_email_1 = require("@azure/communication-email");
|
|
4
4
|
const communication_sms_1 = require("@azure/communication-sms");
|
|
5
5
|
class AzureCommunicationService {
|
|
6
|
-
async sendMail(
|
|
7
|
-
const client = new communication_email_1.EmailClient(credentials.connection);
|
|
8
|
-
const recipients = Array.isArray(
|
|
6
|
+
async sendMail(req) {
|
|
7
|
+
const client = new communication_email_1.EmailClient(req.credentials.connection);
|
|
8
|
+
const recipients = Array.isArray(req.emails) ? req.emails : [req.emails];
|
|
9
9
|
const addresses = recipients.map(recipient => ({ address: recipient }));
|
|
10
10
|
const payload = {
|
|
11
|
-
senderAddress:
|
|
11
|
+
senderAddress: req.from,
|
|
12
12
|
content: {
|
|
13
|
-
subject:
|
|
14
|
-
plainText:
|
|
13
|
+
subject: req.subject,
|
|
14
|
+
plainText: req.text,
|
|
15
15
|
},
|
|
16
16
|
recipients: {
|
|
17
17
|
to: addresses,
|
|
@@ -20,15 +20,15 @@ class AzureCommunicationService {
|
|
|
20
20
|
const poller = await client.beginSend(payload);
|
|
21
21
|
await poller.pollUntilDone();
|
|
22
22
|
}
|
|
23
|
-
async sendTemplateMail(
|
|
24
|
-
const client = new communication_email_1.EmailClient(credentials.connection);
|
|
25
|
-
const recipients = Array.isArray(
|
|
23
|
+
async sendTemplateMail(req) {
|
|
24
|
+
const client = new communication_email_1.EmailClient(req.credentials.connection);
|
|
25
|
+
const recipients = Array.isArray(req.emails) ? req.emails : [req.emails];
|
|
26
26
|
const addresses = recipients.map(recipient => ({ address: recipient }));
|
|
27
27
|
const payload = {
|
|
28
|
-
senderAddress:
|
|
28
|
+
senderAddress: req.from,
|
|
29
29
|
content: {
|
|
30
|
-
subject:
|
|
31
|
-
html:
|
|
30
|
+
subject: req.subject,
|
|
31
|
+
html: req.template,
|
|
32
32
|
},
|
|
33
33
|
recipients: {
|
|
34
34
|
to: addresses,
|
|
@@ -37,12 +37,12 @@ class AzureCommunicationService {
|
|
|
37
37
|
const poller = await client.beginSend(payload);
|
|
38
38
|
await poller.pollUntilDone();
|
|
39
39
|
}
|
|
40
|
-
async sendSMS(
|
|
41
|
-
const client = new communication_sms_1.SmsClient(credentials.connection);
|
|
42
|
-
const recipients = Array.isArray(
|
|
40
|
+
async sendSMS(req) {
|
|
41
|
+
const client = new communication_sms_1.SmsClient(req.credentials.connection);
|
|
42
|
+
const recipients = Array.isArray(req.phones) ? req.phones : [req.phones];
|
|
43
43
|
const payload = {
|
|
44
|
-
from:
|
|
45
|
-
message:
|
|
44
|
+
from: req.sender,
|
|
45
|
+
message: req.text,
|
|
46
46
|
to: recipients,
|
|
47
47
|
};
|
|
48
48
|
await client.send(payload);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AzureKeyVault, IAzureKeyVaultService } from '../../interfaces/azure';
|
|
2
2
|
declare class AzureKeyVaultService implements IAzureKeyVaultService {
|
|
3
|
-
getSecret<T>(
|
|
3
|
+
getSecret<T>(req: AzureKeyVault.GetSecret.Request): Promise<AzureKeyVault.GetSecret.Response<T>>;
|
|
4
4
|
}
|
|
5
5
|
declare const _default: AzureKeyVaultService;
|
|
6
6
|
export default _default;
|
|
@@ -4,10 +4,10 @@ const identity_1 = require("@azure/identity");
|
|
|
4
4
|
const keyvault_secrets_1 = require("@azure/keyvault-secrets");
|
|
5
5
|
const parser_1 = require("../../utils/parser");
|
|
6
6
|
class AzureKeyVaultService {
|
|
7
|
-
async getSecret(
|
|
7
|
+
async getSecret(req) {
|
|
8
8
|
const credential = new identity_1.DefaultAzureCredential();
|
|
9
|
-
const client = new keyvault_secrets_1.SecretClient(
|
|
10
|
-
const { value } = await client.getSecret(
|
|
9
|
+
const client = new keyvault_secrets_1.SecretClient(req.vault, credential);
|
|
10
|
+
const { value } = await client.getSecret(req.secretName);
|
|
11
11
|
if (value) {
|
|
12
12
|
const secret = (0, parser_1.parseRecord)(value);
|
|
13
13
|
return {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AzureStorageBlob, IAzureStorageBlobService } from '../../interfaces/azure';
|
|
2
2
|
declare class AzureStorageBlobService implements IAzureStorageBlobService {
|
|
3
|
-
uploadBuffer(
|
|
4
|
-
downloadBuffer(
|
|
5
|
-
getPreSignedUrl(
|
|
3
|
+
uploadBuffer(req: AzureStorageBlob.UploadBuffer.Request): Promise<void>;
|
|
4
|
+
downloadBuffer(req: AzureStorageBlob.DownloadBuffer.Request): Promise<AzureStorageBlob.DownloadBuffer.Response>;
|
|
5
|
+
getPreSignedUrl(req: AzureStorageBlob.GetPreSignedUrl.Request): Promise<AzureStorageBlob.GetPreSignedUrl.Response>;
|
|
6
6
|
}
|
|
7
7
|
declare const _default: AzureStorageBlobService;
|
|
8
8
|
export default _default;
|
|
@@ -7,41 +7,41 @@ const storage_blob_1 = require("@azure/storage-blob");
|
|
|
7
7
|
const date_1 = __importDefault(require("../../services/date"));
|
|
8
8
|
const file_1 = __importDefault(require("../../services/file"));
|
|
9
9
|
class AzureStorageBlobService {
|
|
10
|
-
async uploadBuffer(
|
|
11
|
-
const sharedKeyCredential = new storage_blob_1.StorageSharedKeyCredential(credentials.accountName, credentials.accountKey);
|
|
12
|
-
const client = new storage_blob_1.BlobServiceClient(
|
|
10
|
+
async uploadBuffer(req) {
|
|
11
|
+
const sharedKeyCredential = new storage_blob_1.StorageSharedKeyCredential(req.credentials.accountName, req.credentials.accountKey);
|
|
12
|
+
const client = new storage_blob_1.BlobServiceClient(req.storageUrl, sharedKeyCredential);
|
|
13
13
|
await client
|
|
14
|
-
.getContainerClient(
|
|
15
|
-
.getBlockBlobClient(
|
|
16
|
-
.uploadData(
|
|
14
|
+
.getContainerClient(req.storageContainer)
|
|
15
|
+
.getBlockBlobClient(req.filename)
|
|
16
|
+
.uploadData(req.file);
|
|
17
17
|
}
|
|
18
|
-
async downloadBuffer(
|
|
19
|
-
const sharedKeyCredential = new storage_blob_1.StorageSharedKeyCredential(credentials.accountName, credentials.accountKey);
|
|
20
|
-
const client = new storage_blob_1.BlobServiceClient(
|
|
18
|
+
async downloadBuffer(req) {
|
|
19
|
+
const sharedKeyCredential = new storage_blob_1.StorageSharedKeyCredential(req.credentials.accountName, req.credentials.accountKey);
|
|
20
|
+
const client = new storage_blob_1.BlobServiceClient(req.storageUrl, sharedKeyCredential);
|
|
21
21
|
const { readableStreamBody } = await client
|
|
22
|
-
.getContainerClient(
|
|
23
|
-
.getBlockBlobClient(
|
|
22
|
+
.getContainerClient(req.storageContainer)
|
|
23
|
+
.getBlockBlobClient(req.filename)
|
|
24
24
|
.download(0);
|
|
25
25
|
const buffer = await file_1.default.streamToBuffer(readableStreamBody);
|
|
26
26
|
return {
|
|
27
27
|
file: buffer,
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
async getPreSignedUrl(
|
|
31
|
-
const sharedKeyCredential = new storage_blob_1.StorageSharedKeyCredential(credentials.accountName, credentials.accountKey);
|
|
30
|
+
async getPreSignedUrl(req) {
|
|
31
|
+
const sharedKeyCredential = new storage_blob_1.StorageSharedKeyCredential(req.credentials.accountName, req.credentials.accountKey);
|
|
32
32
|
const payload = {
|
|
33
|
-
containerName:
|
|
34
|
-
blobName:
|
|
35
|
-
version:
|
|
36
|
-
contentEncoding:
|
|
37
|
-
contentType:
|
|
33
|
+
containerName: req.storageContainer,
|
|
34
|
+
blobName: req.filename,
|
|
35
|
+
version: req.options?.version,
|
|
36
|
+
contentEncoding: req.options?.contentEncoding,
|
|
37
|
+
contentType: req.options?.contentType,
|
|
38
38
|
permissions: 'rwac',
|
|
39
|
-
startsOn:
|
|
39
|
+
startsOn: req.options?.hoursToExpire &&
|
|
40
40
|
date_1.default.getCurrentDate(),
|
|
41
|
-
expiresOn:
|
|
42
|
-
date_1.default.addHours(date_1.default.getCurrentDate(), Number(
|
|
41
|
+
expiresOn: req.options?.hoursToExpire &&
|
|
42
|
+
date_1.default.addHours(date_1.default.getCurrentDate(), Number(req.options?.hoursToExpire)),
|
|
43
43
|
};
|
|
44
|
-
const url = `https://${credentials.accountName}.blob.core.windows.net/${
|
|
44
|
+
const url = `https://${req.credentials.accountName}.blob.core.windows.net/${req.storageContainer}/${req.filename}`;
|
|
45
45
|
const token = (0, storage_blob_1.generateBlobSASQueryParameters)(payload, sharedKeyCredential).toString();
|
|
46
46
|
return {
|
|
47
47
|
url: `${url}?${token}`,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Firebase, IFirebaseService } from '../interfaces/firebase';
|
|
2
2
|
declare class FirebaseService implements IFirebaseService {
|
|
3
|
-
publishConfig(
|
|
4
|
-
sendNotification(
|
|
3
|
+
publishConfig(req: Firebase.PublishConfig.Request): Promise<void>;
|
|
4
|
+
sendNotification(req: Firebase.SendNotification.Request): Promise<void>;
|
|
5
5
|
}
|
|
6
6
|
declare const _default: FirebaseService;
|
|
7
7
|
export default _default;
|
|
@@ -5,28 +5,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const firebase_admin_1 = __importDefault(require("firebase-admin"));
|
|
7
7
|
class FirebaseService {
|
|
8
|
-
async publishConfig(
|
|
8
|
+
async publishConfig(req) {
|
|
9
9
|
const client = firebase_admin_1.default.initializeApp({
|
|
10
|
-
credential: firebase_admin_1.default.credential.cert(credentials.cert),
|
|
11
|
-
databaseURL: credentials.database,
|
|
12
|
-
}, credentials.instance);
|
|
10
|
+
credential: firebase_admin_1.default.credential.cert(req.credentials.cert),
|
|
11
|
+
databaseURL: req.credentials.database,
|
|
12
|
+
}, req.credentials.instance);
|
|
13
13
|
const template = client
|
|
14
14
|
.remoteConfig()
|
|
15
|
-
.createTemplateFromJSON(
|
|
15
|
+
.createTemplateFromJSON(req.template);
|
|
16
16
|
await client
|
|
17
17
|
.remoteConfig()
|
|
18
18
|
.publishTemplate(template);
|
|
19
|
-
await client.delete();
|
|
20
19
|
}
|
|
21
|
-
async sendNotification(
|
|
20
|
+
async sendNotification(req) {
|
|
22
21
|
const client = firebase_admin_1.default.initializeApp({
|
|
23
|
-
credential: firebase_admin_1.default.credential.cert(credentials.cert),
|
|
24
|
-
databaseURL: credentials.database,
|
|
25
|
-
}, credentials.instance);
|
|
22
|
+
credential: firebase_admin_1.default.credential.cert(req.credentials.cert),
|
|
23
|
+
databaseURL: req.credentials.database,
|
|
24
|
+
}, req.credentials.instance);
|
|
26
25
|
await client
|
|
27
26
|
.messaging()
|
|
28
|
-
.sendEachForMulticast(
|
|
29
|
-
await client.delete();
|
|
27
|
+
.sendEachForMulticast(req.message, req.isTest);
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
30
|
exports.default = new FirebaseService();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GoogleDrive, IGoogleDriveService } from '../../interfaces/gcp';
|
|
2
2
|
declare class GoogleDriveService implements IGoogleDriveService {
|
|
3
|
-
readFile(
|
|
3
|
+
readFile(req: GoogleDrive.ReadFile.Request): Promise<GoogleDrive.ReadFile.Response>;
|
|
4
4
|
}
|
|
5
5
|
declare const _default: GoogleDriveService;
|
|
6
6
|
export default _default;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const googleapis_1 = require("googleapis");
|
|
4
4
|
class GoogleDriveService {
|
|
5
|
-
async readFile(
|
|
5
|
+
async readFile(req) {
|
|
6
6
|
const instance = googleapis_1.google.drive({
|
|
7
7
|
version: 'v3',
|
|
8
|
-
auth: credentials.apiKey,
|
|
8
|
+
auth: req.credentials.apiKey,
|
|
9
9
|
});
|
|
10
|
-
const { data
|
|
10
|
+
const { data } = await instance.files.get({ fileId: req.fileId });
|
|
11
11
|
return {
|
|
12
|
-
file:
|
|
12
|
+
file: data,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GoogleSecrets, IGoogleSecretsService } from '../../interfaces/gcp';
|
|
2
2
|
declare class GoogleSecretsService implements IGoogleSecretsService {
|
|
3
|
-
getSecret<T>(
|
|
3
|
+
getSecret<T>(req: GoogleSecrets.GetSecret.Request): Promise<GoogleSecrets.GetSecret.Response<T>>;
|
|
4
4
|
}
|
|
5
5
|
declare const _default: GoogleSecretsService;
|
|
6
6
|
export default _default;
|
|
@@ -3,15 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const secret_manager_1 = require("@google-cloud/secret-manager");
|
|
4
4
|
const parser_1 = require("../../utils/parser");
|
|
5
5
|
class GoogleSecretsService {
|
|
6
|
-
async getSecret(
|
|
7
|
-
const
|
|
6
|
+
async getSecret(req) {
|
|
7
|
+
const credentials = JSON.parse(req.credentials.apiKey);
|
|
8
|
+
const client = new secret_manager_1.SecretManagerServiceClient({ credentials });
|
|
8
9
|
const [version] = await client.accessSecretVersion({
|
|
9
|
-
name: `projects/${
|
|
10
|
+
name: `projects/${req.projectId}/secrets/${req.secretId}/versions/latest`,
|
|
10
11
|
});
|
|
11
|
-
const
|
|
12
|
-
const
|
|
12
|
+
const data = (version.payload?.data ?? new Uint8Array());
|
|
13
|
+
const secretData = Buffer.from(data).toString('utf-8');
|
|
14
|
+
const secret = (0, parser_1.parseRecord)(secretData);
|
|
13
15
|
return {
|
|
14
|
-
secret
|
|
16
|
+
secret,
|
|
15
17
|
};
|
|
16
18
|
}
|
|
17
19
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GoogleSheets, IGoogleSheetsService } from '../../interfaces/gcp';
|
|
2
2
|
declare class GoogleSheetsService implements IGoogleSheetsService {
|
|
3
|
-
readSheet(
|
|
3
|
+
readSheet(req: GoogleSheets.ReadSheet.Request): Promise<GoogleSheets.ReadSheet.Response>;
|
|
4
4
|
}
|
|
5
5
|
declare const _default: GoogleSheetsService;
|
|
6
6
|
export default _default;
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const googleapis_1 = require("googleapis");
|
|
4
4
|
class GoogleSheetsService {
|
|
5
|
-
async readSheet(
|
|
5
|
+
async readSheet(req) {
|
|
6
6
|
const instance = googleapis_1.google.sheets({
|
|
7
7
|
version: 'v4',
|
|
8
|
-
auth: credentials.apiKey,
|
|
8
|
+
auth: req.credentials.apiKey,
|
|
9
9
|
});
|
|
10
|
-
const { data
|
|
11
|
-
spreadsheetId:
|
|
12
|
-
ranges:
|
|
10
|
+
const { data } = await instance.spreadsheets.values.batchGet({
|
|
11
|
+
spreadsheetId: req.spreadsheetId,
|
|
12
|
+
ranges: req.tabs,
|
|
13
13
|
});
|
|
14
14
|
return {
|
|
15
|
-
sheet:
|
|
15
|
+
sheet: data,
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Grafana, IGrafanaService } from '../interfaces/grafana';
|
|
2
2
|
declare class GrafanaService implements IGrafanaService {
|
|
3
|
-
getDashboard(
|
|
4
|
-
searchDashboard(
|
|
3
|
+
getDashboard(req: Grafana.GetDashboard.Request): Promise<Grafana.GetDashboard.Response>;
|
|
4
|
+
searchDashboard(req: Grafana.SearchDashboard.Request): Promise<Grafana.SearchDashboard.Response>;
|
|
5
5
|
}
|
|
6
6
|
declare const _default: GrafanaService;
|
|
7
7
|
export default _default;
|
package/dist/services/grafana.js
CHANGED
|
@@ -5,33 +5,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const http_1 = __importDefault(require("./http"));
|
|
7
7
|
class GrafanaService {
|
|
8
|
-
async getDashboard(
|
|
9
|
-
const { data
|
|
8
|
+
async getDashboard(req) {
|
|
9
|
+
const { data } = await http_1.default.request({
|
|
10
10
|
method: 'get',
|
|
11
|
-
baseURL: credentials.url,
|
|
12
|
-
resourcePath: `/api/dashboards/uid/${
|
|
11
|
+
baseURL: req.credentials.url,
|
|
12
|
+
resourcePath: `/api/dashboards/uid/${req.uid}`,
|
|
13
13
|
headers: {
|
|
14
|
-
Authorization: `Bearer ${credentials.apiKey}`,
|
|
14
|
+
Authorization: `Bearer ${req.credentials.apiKey}`,
|
|
15
15
|
},
|
|
16
16
|
});
|
|
17
17
|
return {
|
|
18
|
-
dashboard:
|
|
18
|
+
dashboard: data,
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
async searchDashboard(
|
|
22
|
-
const { data
|
|
21
|
+
async searchDashboard(req) {
|
|
22
|
+
const { data } = await http_1.default.request({
|
|
23
23
|
method: 'get',
|
|
24
|
-
baseURL: credentials.url,
|
|
24
|
+
baseURL: req.credentials.url,
|
|
25
25
|
resourcePath: '/api/search',
|
|
26
26
|
headers: {
|
|
27
|
-
Authorization: `Bearer ${credentials.apiKey}`,
|
|
27
|
+
Authorization: `Bearer ${req.credentials.apiKey}`,
|
|
28
28
|
},
|
|
29
29
|
query: {
|
|
30
|
-
query:
|
|
30
|
+
query: req.query,
|
|
31
31
|
},
|
|
32
32
|
});
|
|
33
33
|
return {
|
|
34
|
-
dashboards:
|
|
34
|
+
dashboards: data,
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import { IKeycloakService, Keycloak } from '../interfaces/keycloak';
|
|
2
2
|
declare class KeycloakService implements IKeycloakService {
|
|
3
|
-
authenticate(
|
|
4
|
-
|
|
5
|
-
refreshAccess({ credentials, data, url, }: Keycloak.RefreshAccess.Request): Promise<Keycloak.RefreshAccess.Response>;
|
|
6
|
-
revokeAccess({ credentials, data, url, }: Keycloak.RevokeAccess.Request): Promise<void>;
|
|
7
|
-
createUser({ credentials, data, url, }: Keycloak.CreateUser.Request): Promise<void>;
|
|
8
|
-
updateUser({ credentials, data, url, }: Keycloak.UpdateUser.Request): Promise<void>;
|
|
9
|
-
getUser({ credentials, data, url, }: Keycloak.GetUser.Request): Promise<Keycloak.GetUser.Response>;
|
|
10
|
-
deleteUser({ credentials, data, url, }: Keycloak.DeleteUser.Request): Promise<void>;
|
|
11
|
-
changeUserPassword({ credentials, data, url, }: Keycloak.ChangeUserPassword.Request): Promise<void>;
|
|
12
|
-
addRealm({ url, data, credentials, }: Keycloak.AddRealm.Request): Promise<void>;
|
|
13
|
-
addRole({ url, data, credentials, }: Keycloak.AddRole.Request): Promise<void>;
|
|
14
|
-
associateUserRole({ url, data, credentials, }: Keycloak.AssociateUserRole.Request): Promise<void>;
|
|
15
|
-
getRoles({ url, data, credentials, }: Keycloak.GetRoles.Request): Promise<Keycloak.GetRoles.Response>;
|
|
16
|
-
deleteRole({ url, data, credentials, }: Keycloak.DeleteRole.Request): Promise<void>;
|
|
3
|
+
authenticate(req: Keycloak.Authenticate.Request): Promise<Keycloak.Authenticate.Response>;
|
|
4
|
+
refreshAccess(req: Keycloak.RefreshAccess.Request): Promise<Keycloak.RefreshAccess.Response>;
|
|
17
5
|
}
|
|
18
6
|
declare const _default: KeycloakService;
|
|
19
7
|
export default _default;
|