mblabs-roccato-backend-commons 1.0.66 → 1.0.68

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.
@@ -1,3 +1,4 @@
1
1
  import DATE from './date';
2
2
  import LOCALES from './locales';
3
- export { DATE, LOCALES, };
3
+ import STORAGE from './storage';
4
+ export { DATE, LOCALES, STORAGE, };
@@ -3,8 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.LOCALES = exports.DATE = void 0;
6
+ exports.STORAGE = exports.LOCALES = exports.DATE = void 0;
7
7
  const date_1 = __importDefault(require("./date"));
8
8
  exports.DATE = date_1.default;
9
9
  const locales_1 = __importDefault(require("./locales"));
10
10
  exports.LOCALES = locales_1.default;
11
+ const storage_1 = __importDefault(require("./storage"));
12
+ exports.STORAGE = storage_1.default;
@@ -0,0 +1,8 @@
1
+ declare const STORAGE: {
2
+ KEYS: {
3
+ TRACE: string;
4
+ SESSION: string;
5
+ TENANT: string;
6
+ };
7
+ };
8
+ export default STORAGE;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const KEYS = {
4
+ TRACE: 'trace',
5
+ SESSION: 'session',
6
+ TENANT: 'tenant',
7
+ };
8
+ const STORAGE = {
9
+ KEYS,
10
+ };
11
+ exports.default = STORAGE;
@@ -10,9 +10,10 @@ export default class AccountEntity extends BaseEntity {
10
10
  email?: string;
11
11
  personalDocument?: string;
12
12
  businessDocument?: string;
13
- profile?: Relation<ProfileEntity>;
14
13
  lastAccessAt?: Date;
14
+ metadata?: unknown;
15
15
  accountModules?: Relation<AccountModuleEntity>[];
16
16
  accountGroups?: Relation<AccountGroupEntity>[];
17
+ profile?: Relation<ProfileEntity>;
17
18
  constructor(partial: Partial<AccountEntity>);
18
19
  }
@@ -24,10 +24,11 @@ let AccountEntity = class AccountEntity extends base_1.default {
24
24
  email;
25
25
  personalDocument;
26
26
  businessDocument;
27
- profile;
28
27
  lastAccessAt;
28
+ metadata;
29
29
  accountModules;
30
30
  accountGroups;
31
+ profile;
31
32
  constructor(partial) {
32
33
  super();
33
34
  Object.assign(this, partial);
@@ -57,15 +58,14 @@ __decorate([
57
58
  (0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
58
59
  __metadata("design:type", String)
59
60
  ], AccountEntity.prototype, "businessDocument", void 0);
60
- __decorate([
61
- (0, typeorm_1.ManyToOne)(() => profile_1.default),
62
- (0, typeorm_1.JoinColumn)({ name: 'profileId', referencedColumnName: 'id' }),
63
- __metadata("design:type", Object)
64
- ], AccountEntity.prototype, "profile", void 0);
65
61
  __decorate([
66
62
  (0, typeorm_1.Column)({ type: 'timestamptz', nullable: true }),
67
63
  __metadata("design:type", Date)
68
64
  ], AccountEntity.prototype, "lastAccessAt", void 0);
65
+ __decorate([
66
+ (0, typeorm_1.Column)({ type: 'jsonb', nullable: true }),
67
+ __metadata("design:type", Object)
68
+ ], AccountEntity.prototype, "metadata", void 0);
69
69
  __decorate([
70
70
  (0, typeorm_1.OneToMany)(() => account_module_1.default, am => am.account),
71
71
  __metadata("design:type", Array)
@@ -74,6 +74,11 @@ __decorate([
74
74
  (0, typeorm_1.OneToMany)(() => account_group_1.default, am => am.account),
75
75
  __metadata("design:type", Array)
76
76
  ], AccountEntity.prototype, "accountGroups", void 0);
77
+ __decorate([
78
+ (0, typeorm_1.ManyToOne)(() => profile_1.default),
79
+ (0, typeorm_1.JoinColumn)({ name: 'profileId', referencedColumnName: 'id' }),
80
+ __metadata("design:type", Object)
81
+ ], AccountEntity.prototype, "profile", void 0);
77
82
  AccountEntity = __decorate([
78
83
  (0, typeorm_1.Entity)('account'),
79
84
  __metadata("design:paramtypes", [Object])
@@ -57,8 +57,8 @@ class CreateAccountsTable1748448589934 {
57
57
  isNullable: true,
58
58
  },
59
59
  {
60
- name: 'createdBy',
61
- type: 'varchar',
60
+ name: 'metadata',
61
+ type: 'jsonb',
62
62
  isNullable: true,
63
63
  },
64
64
  {
@@ -66,6 +66,11 @@ class CreateAccountsTable1748448589934 {
66
66
  type: 'timestamptz',
67
67
  isNullable: true,
68
68
  },
69
+ {
70
+ name: 'createdBy',
71
+ type: 'varchar',
72
+ isNullable: true,
73
+ },
69
74
  {
70
75
  name: 'createdAt',
71
76
  type: 'timestamptz',
@@ -105,10 +110,14 @@ class CreateAccountsTable1748448589934 {
105
110
  columnNames: [
106
111
  'id',
107
112
  'tenantId',
113
+ 'chainLinkId',
108
114
  'name',
109
115
  'email',
110
116
  'cellphone',
117
+ 'personalDocument',
118
+ 'businessDocument',
111
119
  'profileId',
120
+ 'lastAccessAt',
112
121
  ],
113
122
  }),
114
123
  ],
@@ -5,7 +5,12 @@ declare class DateService {
5
5
  convertTimestampToDate(inp: string | number): Date;
6
6
  getCurrent(): string;
7
7
  getCurrentDate(): Date;
8
+ diffInMinutes(start: Date, end: Date): number;
9
+ diffInHours(start: Date, end: Date): number;
8
10
  diffInDays(start: Date, end: Date): number;
11
+ diffInWeeks(start: Date, end: Date): number;
12
+ diffInMonths(start: Date, end: Date): number;
13
+ diffInYears(start: Date, end: Date): number;
9
14
  addDays(start: Date, toAdd: number): Date;
10
15
  addHours(start: Date, toAdd: number): Date;
11
16
  addMinutes(start: Date, toAdd: number): Date;
@@ -37,9 +37,24 @@ class DateService {
37
37
  getCurrentDate() {
38
38
  return luxon_1.DateTime.local().toJSDate();
39
39
  }
40
+ diffInMinutes(start, end) {
41
+ return luxon_1.DateTime.fromJSDate(end).diff(luxon_1.DateTime.fromJSDate(start), 'minutes').minutes;
42
+ }
43
+ diffInHours(start, end) {
44
+ return luxon_1.DateTime.fromJSDate(end).diff(luxon_1.DateTime.fromJSDate(start), 'hours').hours;
45
+ }
40
46
  diffInDays(start, end) {
41
47
  return luxon_1.DateTime.fromJSDate(end).diff(luxon_1.DateTime.fromJSDate(start), 'days').days;
42
48
  }
49
+ diffInWeeks(start, end) {
50
+ return luxon_1.DateTime.fromJSDate(end).diff(luxon_1.DateTime.fromJSDate(start), 'weeks').weeks;
51
+ }
52
+ diffInMonths(start, end) {
53
+ return luxon_1.DateTime.fromJSDate(end).diff(luxon_1.DateTime.fromJSDate(start), 'months').months;
54
+ }
55
+ diffInYears(start, end) {
56
+ return luxon_1.DateTime.fromJSDate(end).diff(luxon_1.DateTime.fromJSDate(start), 'years').years;
57
+ }
43
58
  addDays(start, toAdd) {
44
59
  return luxon_1.DateTime.fromJSDate(start).plus({ days: toAdd }).toJSDate();
45
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mblabs-roccato-backend-commons",
3
- "version": "1.0.66",
3
+ "version": "1.0.68",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,7 +1,9 @@
1
1
  import DATE from './date';
2
2
  import LOCALES from './locales';
3
+ import STORAGE from './storage';
3
4
 
4
5
  export {
5
6
  DATE,
6
7
  LOCALES,
8
+ STORAGE,
7
9
  };
@@ -0,0 +1,11 @@
1
+ const KEYS = {
2
+ TRACE: 'trace',
3
+ SESSION: 'session',
4
+ TENANT: 'tenant',
5
+ };
6
+
7
+ const STORAGE = {
8
+ KEYS,
9
+ };
10
+
11
+ export default STORAGE;
@@ -33,19 +33,22 @@ export default class AccountEntity extends BaseEntity {
33
33
  @Column({ type: 'varchar', nullable: true })
34
34
  public businessDocument?: string;
35
35
 
36
- @ManyToOne((): ObjectType<ProfileEntity> => ProfileEntity)
37
- @JoinColumn({ name: 'profileId', referencedColumnName: 'id' })
38
- public profile?: Relation<ProfileEntity>;
39
-
40
36
  @Column({ type: 'timestamptz', nullable: true })
41
37
  public lastAccessAt?: Date;
42
38
 
39
+ @Column({ type: 'jsonb', nullable: true })
40
+ public metadata?: unknown;
41
+
43
42
  @OneToMany(() => AccountModuleEntity, am => am.account)
44
43
  public accountModules?: Relation<AccountModuleEntity>[];
45
44
 
46
45
  @OneToMany(() => AccountGroupEntity, am => am.account)
47
46
  public accountGroups?: Relation<AccountGroupEntity>[];
48
47
 
48
+ @ManyToOne((): ObjectType<ProfileEntity> => ProfileEntity)
49
+ @JoinColumn({ name: 'profileId', referencedColumnName: 'id' })
50
+ public profile?: Relation<ProfileEntity>;
51
+
49
52
  constructor (partial: Partial<AccountEntity>) {
50
53
  super();
51
54
  Object.assign(this, partial);
@@ -56,8 +56,8 @@ export class CreateAccountsTable1748448589934 implements MigrationInterface {
56
56
  isNullable: true,
57
57
  },
58
58
  {
59
- name: 'createdBy',
60
- type: 'varchar',
59
+ name: 'metadata',
60
+ type: 'jsonb',
61
61
  isNullable: true,
62
62
  },
63
63
  {
@@ -65,6 +65,11 @@ export class CreateAccountsTable1748448589934 implements MigrationInterface {
65
65
  type: 'timestamptz',
66
66
  isNullable: true,
67
67
  },
68
+ {
69
+ name: 'createdBy',
70
+ type: 'varchar',
71
+ isNullable: true,
72
+ },
68
73
  {
69
74
  name: 'createdAt',
70
75
  type: 'timestamptz',
@@ -104,10 +109,14 @@ export class CreateAccountsTable1748448589934 implements MigrationInterface {
104
109
  columnNames: [
105
110
  'id',
106
111
  'tenantId',
112
+ 'chainLinkId',
107
113
  'name',
108
114
  'email',
109
115
  'cellphone',
116
+ 'personalDocument',
117
+ 'businessDocument',
110
118
  'profileId',
119
+ 'lastAccessAt',
111
120
  ],
112
121
  }),
113
122
  ],
@@ -48,10 +48,30 @@ class DateService {
48
48
  return DateTime.local().toJSDate();
49
49
  }
50
50
 
51
+ public diffInMinutes (start: Date, end: Date): number {
52
+ return DateTime.fromJSDate(end).diff(DateTime.fromJSDate(start), 'minutes').minutes;
53
+ }
54
+
55
+ public diffInHours (start: Date, end: Date): number {
56
+ return DateTime.fromJSDate(end).diff(DateTime.fromJSDate(start), 'hours').hours;
57
+ }
58
+
51
59
  public diffInDays (start: Date, end: Date): number {
52
60
  return DateTime.fromJSDate(end).diff(DateTime.fromJSDate(start), 'days').days;
53
61
  }
54
62
 
63
+ public diffInWeeks (start: Date, end: Date): number {
64
+ return DateTime.fromJSDate(end).diff(DateTime.fromJSDate(start), 'weeks').weeks;
65
+ }
66
+
67
+ public diffInMonths (start: Date, end: Date): number {
68
+ return DateTime.fromJSDate(end).diff(DateTime.fromJSDate(start), 'months').months;
69
+ }
70
+
71
+ public diffInYears (start: Date, end: Date): number {
72
+ return DateTime.fromJSDate(end).diff(DateTime.fromJSDate(start), 'years').years;
73
+ }
74
+
55
75
  public addDays (start: Date, toAdd: number): Date {
56
76
  return DateTime.fromJSDate(start).plus({ days: toAdd }).toJSDate();
57
77
  }