mblabs-roccato-backend-commons 1.0.57 → 1.0.59

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.
@@ -26,6 +26,11 @@ class CreateAccountSettingsTable1758382227488 {
26
26
  type: 'uuid',
27
27
  isNullable: true,
28
28
  },
29
+ {
30
+ name: 'home',
31
+ type: 'jsonb',
32
+ isNullable: true,
33
+ },
29
34
  {
30
35
  name: 'calendar',
31
36
  type: 'jsonb',
@@ -60,6 +65,7 @@ class CreateAccountSettingsTable1758382227488 {
60
65
  columnNames: [
61
66
  'id',
62
67
  'accountId',
68
+ 'home',
63
69
  'calendar',
64
70
  'favorites',
65
71
  'language',
@@ -25,6 +25,23 @@ export declare namespace AmazonCloudwatch {
25
25
  credentials: Credentials;
26
26
  }
27
27
  }
28
+ namespace CreateMetric {
29
+ interface Request {
30
+ data: {
31
+ namespace: string;
32
+ metric: {
33
+ title: string;
34
+ dimensions: {
35
+ name: string;
36
+ value: string;
37
+ }[];
38
+ value: number;
39
+ unit: 'Count' | 'Percent' | 'Seconds' | 'Microseconds' | 'Milliseconds' | 'None';
40
+ };
41
+ };
42
+ credentials: Credentials;
43
+ }
44
+ }
28
45
  }
29
46
  export declare namespace AmazonPinpoint {
30
47
  namespace SendMail {
@@ -194,6 +211,7 @@ export declare namespace AmazonSQS {
194
211
  }
195
212
  export interface IAmazonCloudwatchService {
196
213
  createLogEvent(req: AmazonCloudwatch.CreateLogEvent.Request): Promise<void>;
214
+ createMetric(req: AmazonCloudwatch.CreateMetric.Request): Promise<void>;
197
215
  }
198
216
  export interface IAmazonPinpointService {
199
217
  sendMail(req: AmazonPinpoint.SendMail.Request): Promise<void>;
@@ -1,5 +1,6 @@
1
1
  import { AmazonCloudwatch, IAmazonCloudwatchService } from '../../interfaces';
2
2
  declare class AmazonCloudwatchService implements IAmazonCloudwatchService {
3
+ createMetric({ credentials, data }: AmazonCloudwatch.CreateMetric.Request): Promise<void>;
3
4
  createLogEvent({ credentials, data }: AmazonCloudwatch.CreateLogEvent.Request): Promise<void>;
4
5
  private getLogGroupByName;
5
6
  private getLogStreamByName;
@@ -1,7 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const client_cloudwatch_1 = require("@aws-sdk/client-cloudwatch");
3
4
  const client_cloudwatch_logs_1 = require("@aws-sdk/client-cloudwatch-logs");
4
5
  class AmazonCloudwatchService {
6
+ async createMetric({ credentials, data }) {
7
+ const client = new client_cloudwatch_1.CloudWatch({
8
+ credentials: {
9
+ accessKeyId: credentials.accessKey,
10
+ secretAccessKey: credentials.secretKey,
11
+ },
12
+ region: credentials.region,
13
+ });
14
+ await client.putMetricData({
15
+ Namespace: data.namespace,
16
+ MetricData: [
17
+ {
18
+ MetricName: data.metric.title,
19
+ Dimensions: data.metric.dimensions.map(dimension => ({
20
+ Name: dimension.name,
21
+ Value: dimension.value,
22
+ })),
23
+ Value: data.metric.value,
24
+ Unit: data.metric.unit,
25
+ },
26
+ ],
27
+ });
28
+ }
5
29
  async createLogEvent({ credentials, data }) {
6
30
  const client = new client_cloudwatch_logs_1.CloudWatchLogs({
7
31
  credentials: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mblabs-roccato-backend-commons",
3
- "version": "1.0.57",
3
+ "version": "1.0.59",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -39,18 +39,21 @@
39
39
  "migration:run": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:run -d src/core/database/provider.ts"
40
40
  },
41
41
  "dependencies": {
42
+ "@aws-sdk/client-cloudwatch": "^3.803.0",
42
43
  "@aws-sdk/client-cloudwatch-logs": "^3.803.0",
43
44
  "@aws-sdk/client-pinpoint": "^3.803.0",
44
45
  "@aws-sdk/client-pinpoint-email": "^3.803.0",
45
46
  "@aws-sdk/client-pinpoint-sms-voice": "^3.803.0",
46
47
  "@aws-sdk/client-s3": "^3.803.0",
47
48
  "@aws-sdk/client-secrets-manager": "^3.803.0",
48
- "@aws-sdk/client-sqs": "^3.826.0",
49
+ "@aws-sdk/client-sqs": "^3.803.0",
49
50
  "@aws-sdk/s3-request-presigner": "^3.803.0",
50
51
  "@azure/communication-email": "^1.0.0",
51
52
  "@azure/communication-sms": "^1.2.0-beta.3",
52
53
  "@azure/identity": "^4.9.1",
53
54
  "@azure/keyvault-secrets": "^4.9.0",
55
+ "@azure/monitor-query": "^1.3.3",
56
+ "@azure/monitor-query-metrics": "^1.0.0",
54
57
  "@azure/msal-node": "^3.8.0",
55
58
  "@azure/storage-blob": "^12.27.0",
56
59
  "@google-cloud/secret-manager": "^6.0.1",
@@ -25,6 +25,11 @@ export class CreateAccountSettingsTable1758382227488 implements MigrationInterfa
25
25
  type: 'uuid',
26
26
  isNullable: true,
27
27
  },
28
+ {
29
+ name: 'home',
30
+ type: 'jsonb',
31
+ isNullable: true,
32
+ },
28
33
  {
29
34
  name: 'calendar',
30
35
  type: 'jsonb',
@@ -59,6 +64,7 @@ export class CreateAccountSettingsTable1758382227488 implements MigrationInterfa
59
64
  columnNames: [
60
65
  'id',
61
66
  'accountId',
67
+ 'home',
62
68
  'calendar',
63
69
  'favorites',
64
70
  'language',
@@ -28,6 +28,30 @@ export namespace AmazonCloudwatch {
28
28
  credentials: Credentials;
29
29
  }
30
30
  }
31
+
32
+ export namespace CreateMetric {
33
+ export interface Request {
34
+ data: {
35
+ namespace: string;
36
+ metric: {
37
+ title: string;
38
+ dimensions: {
39
+ name: string,
40
+ value: string
41
+ }[];
42
+ value: number;
43
+ unit:
44
+ 'Count' |
45
+ 'Percent' |
46
+ 'Seconds' |
47
+ 'Microseconds' |
48
+ 'Milliseconds' |
49
+ 'None';
50
+ };
51
+ };
52
+ credentials: Credentials;
53
+ }
54
+ }
31
55
  }
32
56
 
33
57
  export namespace AmazonPinpoint {
@@ -218,6 +242,7 @@ export namespace AmazonSQS {
218
242
 
219
243
  export interface IAmazonCloudwatchService {
220
244
  createLogEvent(req: AmazonCloudwatch.CreateLogEvent.Request): Promise<void>;
245
+ createMetric(req: AmazonCloudwatch.CreateMetric.Request): Promise<void>;
221
246
  }
222
247
 
223
248
  export interface IAmazonPinpointService {
@@ -1,8 +1,34 @@
1
+ import { CloudWatch } from '@aws-sdk/client-cloudwatch';
1
2
  import { CloudWatchLogs } from '@aws-sdk/client-cloudwatch-logs';
2
3
 
3
4
  import { AmazonCloudwatch, IAmazonCloudwatchService } from '../../interfaces';
4
5
 
5
6
  class AmazonCloudwatchService implements IAmazonCloudwatchService {
7
+ async createMetric ({ credentials, data }: AmazonCloudwatch.CreateMetric.Request): Promise<void> {
8
+ const client: CloudWatch = new CloudWatch({
9
+ credentials: {
10
+ accessKeyId: credentials.accessKey,
11
+ secretAccessKey: credentials.secretKey,
12
+ },
13
+ region: credentials.region,
14
+ });
15
+
16
+ await client.putMetricData({
17
+ Namespace: data.namespace,
18
+ MetricData: [
19
+ {
20
+ MetricName: data.metric.title,
21
+ Dimensions: data.metric.dimensions.map(dimension => ({
22
+ Name: dimension.name,
23
+ Value: dimension.value,
24
+ })),
25
+ Value: data.metric.value,
26
+ Unit: data.metric.unit,
27
+ },
28
+ ],
29
+ });
30
+ }
31
+
6
32
  public async createLogEvent ({ credentials, data }: AmazonCloudwatch.CreateLogEvent.Request): Promise<void> {
7
33
  const client: CloudWatchLogs = new CloudWatchLogs({
8
34
  credentials: {