mblabs-roccato-backend-commons 1.0.63 → 1.0.65

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 (26) hide show
  1. package/dist/database/entities/account-module.d.ts +1 -0
  2. package/dist/database/entities/account-module.js +5 -0
  3. package/dist/database/entities/group-module.d.ts +1 -0
  4. package/dist/database/entities/group-module.js +5 -0
  5. package/dist/database/entities/profile-module.d.ts +1 -0
  6. package/dist/database/entities/profile-module.js +5 -0
  7. package/dist/database/migrations/1759768335075-AddCanAddWidgetToAccountModuleTable.d.ts +5 -0
  8. package/dist/database/migrations/1759768335075-AddCanAddWidgetToAccountModuleTable.js +18 -0
  9. package/dist/database/migrations/1759768342995-AddCanAddWidgetToGroupModuleTable.d.ts +5 -0
  10. package/dist/database/migrations/1759768342995-AddCanAddWidgetToGroupModuleTable.js +18 -0
  11. package/dist/database/migrations/1759768354127-AddCanAddWidgetToProfileModuleTable.d.ts +5 -0
  12. package/dist/database/migrations/1759768354127-AddCanAddWidgetToProfileModuleTable.js +18 -0
  13. package/dist/database/migrations/index.d.ts +6 -0
  14. package/dist/database/migrations/index.js +6 -0
  15. package/dist/interfaces/aws.d.ts +1 -0
  16. package/dist/services/aws/cloudwatch.js +9 -6
  17. package/package.json +1 -1
  18. package/src/database/entities/account-module.ts +3 -0
  19. package/src/database/entities/group-module.ts +3 -0
  20. package/src/database/entities/profile-module.ts +3 -0
  21. package/src/database/migrations/1759768335075-AddCanAddWidgetToAccountModuleTable.ts +17 -0
  22. package/src/database/migrations/1759768342995-AddCanAddWidgetToGroupModuleTable.ts +18 -0
  23. package/src/database/migrations/1759768354127-AddCanAddWidgetToProfileModuleTable.ts +18 -0
  24. package/src/database/migrations/index.ts +7 -1
  25. package/src/interfaces/aws.ts +1 -0
  26. package/src/services/aws/cloudwatch.ts +10 -7
@@ -14,5 +14,6 @@ export default class AccountModuleEntity extends BaseEntity {
14
14
  canDownload?: boolean;
15
15
  canUpload?: boolean;
16
16
  canSupport?: boolean;
17
+ canAddWidget?: boolean;
17
18
  constructor(partial: Partial<AccountModuleEntity>);
18
19
  }
@@ -28,6 +28,7 @@ let AccountModuleEntity = class AccountModuleEntity extends base_1.default {
28
28
  canDownload;
29
29
  canUpload;
30
30
  canSupport;
31
+ canAddWidget;
31
32
  constructor(partial) {
32
33
  super();
33
34
  Object.assign(this, partial);
@@ -82,6 +83,10 @@ __decorate([
82
83
  (0, typeorm_1.Column)({ type: 'boolean', nullable: true }),
83
84
  __metadata("design:type", Boolean)
84
85
  ], AccountModuleEntity.prototype, "canSupport", void 0);
86
+ __decorate([
87
+ (0, typeorm_1.Column)({ type: 'boolean', nullable: true }),
88
+ __metadata("design:type", Boolean)
89
+ ], AccountModuleEntity.prototype, "canAddWidget", void 0);
85
90
  AccountModuleEntity = __decorate([
86
91
  (0, typeorm_1.Entity)('account_module'),
87
92
  __metadata("design:paramtypes", [Object])
@@ -14,5 +14,6 @@ export default class GroupModuleEntity extends BaseEntity {
14
14
  canDownload?: boolean;
15
15
  canUpload?: boolean;
16
16
  canSupport?: boolean;
17
+ canAddWidget?: boolean;
17
18
  constructor(partial: Partial<GroupModuleEntity>);
18
19
  }
@@ -28,6 +28,7 @@ let GroupModuleEntity = class GroupModuleEntity extends base_1.default {
28
28
  canDownload;
29
29
  canUpload;
30
30
  canSupport;
31
+ canAddWidget;
31
32
  constructor(partial) {
32
33
  super();
33
34
  Object.assign(this, partial);
@@ -82,6 +83,10 @@ __decorate([
82
83
  (0, typeorm_1.Column)({ type: 'boolean', nullable: true }),
83
84
  __metadata("design:type", Boolean)
84
85
  ], GroupModuleEntity.prototype, "canSupport", void 0);
86
+ __decorate([
87
+ (0, typeorm_1.Column)({ type: 'boolean', nullable: true }),
88
+ __metadata("design:type", Boolean)
89
+ ], GroupModuleEntity.prototype, "canAddWidget", void 0);
85
90
  GroupModuleEntity = __decorate([
86
91
  (0, typeorm_1.Entity)('group_module'),
87
92
  __metadata("design:paramtypes", [Object])
@@ -14,5 +14,6 @@ export default class ProfileModuleEntity extends BaseEntity {
14
14
  canDownload?: boolean;
15
15
  canUpload?: boolean;
16
16
  canSupport?: boolean;
17
+ canAddWidget?: boolean;
17
18
  constructor(partial: Partial<ProfileModuleEntity>);
18
19
  }
@@ -28,6 +28,7 @@ let ProfileModuleEntity = class ProfileModuleEntity extends base_1.default {
28
28
  canDownload;
29
29
  canUpload;
30
30
  canSupport;
31
+ canAddWidget;
31
32
  constructor(partial) {
32
33
  super();
33
34
  Object.assign(this, partial);
@@ -82,6 +83,10 @@ __decorate([
82
83
  (0, typeorm_1.Column)({ type: 'boolean', nullable: true }),
83
84
  __metadata("design:type", Boolean)
84
85
  ], ProfileModuleEntity.prototype, "canSupport", void 0);
86
+ __decorate([
87
+ (0, typeorm_1.Column)({ type: 'boolean', nullable: true }),
88
+ __metadata("design:type", Boolean)
89
+ ], ProfileModuleEntity.prototype, "canAddWidget", void 0);
85
90
  ProfileModuleEntity = __decorate([
86
91
  (0, typeorm_1.Entity)('profile_module'),
87
92
  __metadata("design:paramtypes", [Object])
@@ -0,0 +1,5 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class AddCanAddWidgetToAccountModuleTable1759768335075 implements MigrationInterface {
3
+ up(queryRunner: QueryRunner): Promise<void>;
4
+ down(queryRunner: QueryRunner): Promise<void>;
5
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AddCanAddWidgetToAccountModuleTable1759768335075 = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ class AddCanAddWidgetToAccountModuleTable1759768335075 {
6
+ async up(queryRunner) {
7
+ await queryRunner.addColumn('account_module', new typeorm_1.TableColumn({
8
+ name: 'canAddWidget',
9
+ type: 'boolean',
10
+ isNullable: true,
11
+ default: false,
12
+ }));
13
+ }
14
+ async down(queryRunner) {
15
+ await queryRunner.dropColumn('account_module', 'canAddWidget');
16
+ }
17
+ }
18
+ exports.AddCanAddWidgetToAccountModuleTable1759768335075 = AddCanAddWidgetToAccountModuleTable1759768335075;
@@ -0,0 +1,5 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class AddCanAddWidgetToGroupModuleTable1759768342995 implements MigrationInterface {
3
+ up(queryRunner: QueryRunner): Promise<void>;
4
+ down(queryRunner: QueryRunner): Promise<void>;
5
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AddCanAddWidgetToGroupModuleTable1759768342995 = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ class AddCanAddWidgetToGroupModuleTable1759768342995 {
6
+ async up(queryRunner) {
7
+ await queryRunner.addColumn('group_module', new typeorm_1.TableColumn({
8
+ name: 'canAddWidget',
9
+ type: 'boolean',
10
+ isNullable: true,
11
+ default: false,
12
+ }));
13
+ }
14
+ async down(queryRunner) {
15
+ await queryRunner.dropColumn('group_module', 'canAddWidget');
16
+ }
17
+ }
18
+ exports.AddCanAddWidgetToGroupModuleTable1759768342995 = AddCanAddWidgetToGroupModuleTable1759768342995;
@@ -0,0 +1,5 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class AddCanAddWidgetToProfileModuleTable1759768354127 implements MigrationInterface {
3
+ up(queryRunner: QueryRunner): Promise<void>;
4
+ down(queryRunner: QueryRunner): Promise<void>;
5
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AddCanAddWidgetToProfileModuleTable1759768354127 = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ class AddCanAddWidgetToProfileModuleTable1759768354127 {
6
+ async up(queryRunner) {
7
+ await queryRunner.addColumn('profile_module', new typeorm_1.TableColumn({
8
+ name: 'canAddWidget',
9
+ type: 'boolean',
10
+ isNullable: true,
11
+ default: false,
12
+ }));
13
+ }
14
+ async down(queryRunner) {
15
+ await queryRunner.dropColumn('profile_module', 'canAddWidget');
16
+ }
17
+ }
18
+ exports.AddCanAddWidgetToProfileModuleTable1759768354127 = AddCanAddWidgetToProfileModuleTable1759768354127;
@@ -13,6 +13,9 @@ import { CreateAccountDetailsTable1750691840822 } from './1750691840822-CreateAc
13
13
  import { CreateProfileModuleTable1751576312683 } from './1751576312683-CreateProfileModuleTable';
14
14
  import { CreateAccountDeviceTable1754426499576 } from './1754426499576-CreateAccountDeviceTable';
15
15
  import { CreateAccountSettingsTable1758382227488 } from './1758382227488-CreateAccountSettingsTable';
16
+ import { AddCanAddWidgetToAccountModuleTable1759768335075 } from './1759768335075-AddCanAddWidgetToAccountModuleTable';
17
+ import { AddCanAddWidgetToGroupModuleTable1759768342995 } from './1759768342995-AddCanAddWidgetToGroupModuleTable';
18
+ import { AddCanAddWidgetToProfileModuleTable1759768354127 } from './1759768354127-AddCanAddWidgetToProfileModuleTable';
16
19
  export declare const Migrations: {
17
20
  Init1748448461165: typeof Init1748448461165;
18
21
  CreateProfilesTable1748448589743: typeof CreateProfilesTable1748448589743;
@@ -29,4 +32,7 @@ export declare const Migrations: {
29
32
  CreateProfileModuleTable1751576312683: typeof CreateProfileModuleTable1751576312683;
30
33
  CreateAccountDeviceTable1754426499576: typeof CreateAccountDeviceTable1754426499576;
31
34
  CreateAccountSettingsTable1758382227488: typeof CreateAccountSettingsTable1758382227488;
35
+ AddCanAddWidgetToAccountModuleTable1759768335075: typeof AddCanAddWidgetToAccountModuleTable1759768335075;
36
+ AddCanAddWidgetToGroupModuleTable1759768342995: typeof AddCanAddWidgetToGroupModuleTable1759768342995;
37
+ AddCanAddWidgetToProfileModuleTable1759768354127: typeof AddCanAddWidgetToProfileModuleTable1759768354127;
32
38
  };
@@ -16,6 +16,9 @@ const _1750691840822_CreateAccountDetailsTable_1 = require("./1750691840822-Crea
16
16
  const _1751576312683_CreateProfileModuleTable_1 = require("./1751576312683-CreateProfileModuleTable");
17
17
  const _1754426499576_CreateAccountDeviceTable_1 = require("./1754426499576-CreateAccountDeviceTable");
18
18
  const _1758382227488_CreateAccountSettingsTable_1 = require("./1758382227488-CreateAccountSettingsTable");
19
+ const _1759768335075_AddCanAddWidgetToAccountModuleTable_1 = require("./1759768335075-AddCanAddWidgetToAccountModuleTable");
20
+ const _1759768342995_AddCanAddWidgetToGroupModuleTable_1 = require("./1759768342995-AddCanAddWidgetToGroupModuleTable");
21
+ const _1759768354127_AddCanAddWidgetToProfileModuleTable_1 = require("./1759768354127-AddCanAddWidgetToProfileModuleTable");
19
22
  exports.Migrations = {
20
23
  Init1748448461165: _1748448461165_Init_1.Init1748448461165,
21
24
  CreateProfilesTable1748448589743: _1748448589743_CreateProfilesTable_1.CreateProfilesTable1748448589743,
@@ -32,4 +35,7 @@ exports.Migrations = {
32
35
  CreateProfileModuleTable1751576312683: _1751576312683_CreateProfileModuleTable_1.CreateProfileModuleTable1751576312683,
33
36
  CreateAccountDeviceTable1754426499576: _1754426499576_CreateAccountDeviceTable_1.CreateAccountDeviceTable1754426499576,
34
37
  CreateAccountSettingsTable1758382227488: _1758382227488_CreateAccountSettingsTable_1.CreateAccountSettingsTable1758382227488,
38
+ AddCanAddWidgetToAccountModuleTable1759768335075: _1759768335075_AddCanAddWidgetToAccountModuleTable_1.AddCanAddWidgetToAccountModuleTable1759768335075,
39
+ AddCanAddWidgetToGroupModuleTable1759768342995: _1759768342995_AddCanAddWidgetToGroupModuleTable_1.AddCanAddWidgetToGroupModuleTable1759768342995,
40
+ AddCanAddWidgetToProfileModuleTable1759768354127: _1759768354127_AddCanAddWidgetToProfileModuleTable_1.AddCanAddWidgetToProfileModuleTable1759768354127,
35
41
  };
@@ -37,6 +37,7 @@ export declare namespace AmazonCloudwatch {
37
37
  }[];
38
38
  value: number;
39
39
  unit: 'time' | 'count' | 'percent' | 'bytes' | 'none';
40
+ timestamp?: Date;
40
41
  };
41
42
  };
42
43
  credentials: Credentials;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  const client_cloudwatch_1 = require("@aws-sdk/client-cloudwatch");
4
7
  const client_cloudwatch_logs_1 = require("@aws-sdk/client-cloudwatch-logs");
8
+ const date_1 = __importDefault(require("../date"));
5
9
  class AmazonCloudwatchService {
6
10
  async createMetric({ credentials, data }) {
7
11
  const client = new client_cloudwatch_1.CloudWatch({
@@ -18,20 +22,19 @@ class AmazonCloudwatchService {
18
22
  bytes: 'Bytes',
19
23
  none: 'None',
20
24
  };
21
- await client.putMetricData({
25
+ const payload = {
22
26
  Namespace: data.namespace,
23
27
  MetricData: [
24
28
  {
25
29
  MetricName: data.metric.title,
26
- Dimensions: data.metric.dimensions.map(dimension => ({
27
- Name: dimension.name,
28
- Value: dimension.value,
29
- })),
30
+ Dimensions: data.metric.dimensions?.map(dimension => ({ Name: dimension.name, Value: dimension.value })) ?? [],
30
31
  Value: data.metric.value,
31
32
  Unit: UnitMap[data.metric.unit] || 'None',
33
+ Timestamp: data.metric.timestamp ?? date_1.default.getCurrentDate(),
32
34
  },
33
35
  ],
34
- });
36
+ };
37
+ await client.send(new client_cloudwatch_1.PutMetricDataCommand(payload));
35
38
  }
36
39
  async createLogEvent({ credentials, data }) {
37
40
  const client = new client_cloudwatch_logs_1.CloudWatchLogs({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mblabs-roccato-backend-commons",
3
- "version": "1.0.63",
3
+ "version": "1.0.65",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -42,6 +42,9 @@ export default class AccountModuleEntity extends BaseEntity {
42
42
  @Column({ type: 'boolean', nullable: true })
43
43
  public canSupport?: boolean;
44
44
 
45
+ @Column({ type: 'boolean', nullable: true })
46
+ public canAddWidget?: boolean;
47
+
45
48
  constructor (partial: Partial<AccountModuleEntity>) {
46
49
  super();
47
50
  Object.assign(this, partial);
@@ -42,6 +42,9 @@ export default class GroupModuleEntity extends BaseEntity {
42
42
  @Column({ type: 'boolean', nullable: true })
43
43
  public canSupport?: boolean;
44
44
 
45
+ @Column({ type: 'boolean', nullable: true })
46
+ public canAddWidget?: boolean;
47
+
45
48
  constructor (partial: Partial<GroupModuleEntity>) {
46
49
  super();
47
50
  Object.assign(this, partial);
@@ -52,6 +52,9 @@ export default class ProfileModuleEntity extends BaseEntity {
52
52
  @Column({ type: 'boolean', nullable: true })
53
53
  public canSupport?: boolean;
54
54
 
55
+ @Column({ type: 'boolean', nullable: true })
56
+ public canAddWidget?: boolean;
57
+
55
58
  constructor (partial: Partial<ProfileModuleEntity>) {
56
59
  super();
57
60
  Object.assign(this, partial);
@@ -0,0 +1,17 @@
1
+ import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';
2
+
3
+ export class AddCanAddWidgetToAccountModuleTable1759768335075 implements MigrationInterface {
4
+
5
+ public async up (queryRunner: QueryRunner): Promise<void> {
6
+ await queryRunner.addColumn('account_module', new TableColumn({
7
+ name: 'canAddWidget',
8
+ type: 'boolean',
9
+ isNullable: true,
10
+ default: false,
11
+ }));
12
+ }
13
+
14
+ public async down (queryRunner: QueryRunner): Promise<void> {
15
+ await queryRunner.dropColumn('account_module', 'canAddWidget');
16
+ }
17
+ }
@@ -0,0 +1,18 @@
1
+ import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';
2
+
3
+ export class AddCanAddWidgetToGroupModuleTable1759768342995 implements MigrationInterface {
4
+
5
+ public async up (queryRunner: QueryRunner): Promise<void> {
6
+ await queryRunner.addColumn('group_module', new TableColumn({
7
+ name: 'canAddWidget',
8
+ type: 'boolean',
9
+ isNullable: true,
10
+ default: false,
11
+ }));
12
+ }
13
+
14
+ public async down (queryRunner: QueryRunner): Promise<void> {
15
+ await queryRunner.dropColumn('group_module', 'canAddWidget');
16
+ }
17
+
18
+ }
@@ -0,0 +1,18 @@
1
+ import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';
2
+
3
+ export class AddCanAddWidgetToProfileModuleTable1759768354127 implements MigrationInterface {
4
+
5
+ public async up (queryRunner: QueryRunner): Promise<void> {
6
+ await queryRunner.addColumn('profile_module', new TableColumn({
7
+ name: 'canAddWidget',
8
+ type: 'boolean',
9
+ isNullable: true,
10
+ default: false,
11
+ }));
12
+ }
13
+
14
+ public async down (queryRunner: QueryRunner): Promise<void> {
15
+ await queryRunner.dropColumn('profile_module', 'canAddWidget');
16
+ }
17
+
18
+ }
@@ -11,8 +11,11 @@ import { CreateAddressTable1750432386920 } from './1750432386920-CreateAddressTa
11
11
  import { CreateAccountAddressTable1750690818577 } from './1750690818577-CreateAccountAddressTable';
12
12
  import { CreateAccountDetailsTable1750691840822 } from './1750691840822-CreateAccountDetailsTable';
13
13
  import { CreateProfileModuleTable1751576312683 } from './1751576312683-CreateProfileModuleTable';
14
- import { CreateAccountDeviceTable1754426499576 } from './1754426499576-CreateAccountDeviceTable';
14
+ import { CreateAccountDeviceTable1754426499576 } from './1754426499576-CreateAccountDeviceTable';
15
15
  import { CreateAccountSettingsTable1758382227488 } from './1758382227488-CreateAccountSettingsTable';
16
+ import { AddCanAddWidgetToAccountModuleTable1759768335075 } from './1759768335075-AddCanAddWidgetToAccountModuleTable';
17
+ import { AddCanAddWidgetToGroupModuleTable1759768342995 } from './1759768342995-AddCanAddWidgetToGroupModuleTable';
18
+ import { AddCanAddWidgetToProfileModuleTable1759768354127 } from './1759768354127-AddCanAddWidgetToProfileModuleTable';
16
19
 
17
20
  export const Migrations = {
18
21
  Init1748448461165,
@@ -30,4 +33,7 @@ export const Migrations = {
30
33
  CreateProfileModuleTable1751576312683,
31
34
  CreateAccountDeviceTable1754426499576,
32
35
  CreateAccountSettingsTable1758382227488,
36
+ AddCanAddWidgetToAccountModuleTable1759768335075,
37
+ AddCanAddWidgetToGroupModuleTable1759768342995,
38
+ AddCanAddWidgetToProfileModuleTable1759768354127,
33
39
  };
@@ -41,6 +41,7 @@ export namespace AmazonCloudwatch {
41
41
  }[];
42
42
  value: number;
43
43
  unit: 'time' | 'count' | 'percent' | 'bytes' | 'none';
44
+ timestamp?: Date;
44
45
  };
45
46
  };
46
47
  credentials: Credentials;
@@ -1,7 +1,8 @@
1
- import { CloudWatch } from '@aws-sdk/client-cloudwatch';
1
+ import { CloudWatch, PutMetricDataCommand } from '@aws-sdk/client-cloudwatch';
2
2
  import { CloudWatchLogs, StandardUnit } from '@aws-sdk/client-cloudwatch-logs';
3
3
 
4
4
  import { AmazonCloudwatch, IAmazonCloudwatchService } from '../../interfaces';
5
+ import DateService from '../date';
5
6
 
6
7
  class AmazonCloudwatchService implements IAmazonCloudwatchService {
7
8
  async createMetric ({ credentials, data }: AmazonCloudwatch.CreateMetric.Request): Promise<void> {
@@ -21,20 +22,22 @@ class AmazonCloudwatchService implements IAmazonCloudwatchService {
21
22
  none: 'None',
22
23
  };
23
24
 
24
- await client.putMetricData({
25
+ const payload = {
25
26
  Namespace: data.namespace,
26
27
  MetricData: [
27
28
  {
28
29
  MetricName: data.metric.title,
29
- Dimensions: data.metric.dimensions.map(dimension => ({
30
- Name: dimension.name,
31
- Value: dimension.value,
32
- })),
30
+ Dimensions: data.metric.dimensions?.map(
31
+ dimension => ({ Name: dimension.name, Value: dimension.value })
32
+ ) ?? [],
33
33
  Value: data.metric.value,
34
34
  Unit: UnitMap[data.metric.unit] || 'None',
35
+ Timestamp: data.metric.timestamp ?? DateService.getCurrentDate(),
35
36
  },
36
37
  ],
37
- });
38
+ };
39
+
40
+ await client.send(new PutMetricDataCommand(payload));
38
41
  }
39
42
 
40
43
  public async createLogEvent ({ credentials, data }: AmazonCloudwatch.CreateLogEvent.Request): Promise<void> {