@spytecgps/nova-orm 1.4.79 → 1.4.81

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,5 +1,5 @@
1
1
  import { MigrationInterface, QueryRunner } from 'typeorm';
2
- export declare class createUserAuthorizedDeviceSecurityViewV21684483706000 implements MigrationInterface {
2
+ export declare class updateSecurityUserViews1684483705000 implements MigrationInterface {
3
3
  up(queryRunner: QueryRunner): Promise<void>;
4
4
  down(queryRunner: QueryRunner): Promise<void>;
5
5
  }
@@ -0,0 +1,137 @@
1
+ 'use strict';
2
+
3
+ class updateSecurityUserViews1684483705000 {
4
+ async up(queryRunner) {
5
+ await queryRunner.query(`
6
+ CREATE OR REPLACE VIEW \`user_authorized_device_security_view\` AS
7
+ (
8
+ SELECT
9
+ d.clientId AS clientId,
10
+ d.imei AS imei,
11
+ usr.userId AS userId
12
+ FROM userSecurityRole usr
13
+ JOIN device d
14
+ ON d.clientId = usr.clientId
15
+ WHERE usr.access = 'full'
16
+ AND NOT EXISTS (
17
+ SELECT 1
18
+ FROM entityTag ut
19
+ WHERE ut.userId = usr.userId
20
+ AND ut.entityType = 'User'
21
+ AND ut.isSecurityGroup = 1
22
+ )
23
+ )
24
+ UNION
25
+ (
26
+ SELECT
27
+ d.clientId AS clientId,
28
+ d.imei AS imei,
29
+ usr.userId AS userId
30
+ FROM entityTag ut
31
+ JOIN entityTag rt
32
+ ON rt.tagId = ut.tagId
33
+ AND rt.entityType = 'Device'
34
+ AND rt.isSecurityGroup = 1
35
+ JOIN device d
36
+ ON d.imei = rt.imei
37
+ JOIN userSecurityRole usr
38
+ ON usr.userId = ut.userId
39
+ AND usr.clientId = d.clientId
40
+ WHERE ut.entityType = 'User'
41
+ AND ut.isSecurityGroup = 1
42
+ )
43
+ UNION (
44
+ SELECT
45
+ uad.clientId AS clientId,
46
+ uad.imei AS imei,
47
+ uad.userId AS userId
48
+ FROM userAuthorizedDevice uad
49
+ WHERE NOT EXISTS (
50
+ SELECT 1
51
+ FROM userSecurityRole usr
52
+ WHERE usr.clientId = uad.clientId
53
+ AND usr.userId = uad.userId
54
+ AND usr.access = 'full'
55
+ )
56
+ AND NOT EXISTS (
57
+ SELECT 1
58
+ FROM entityTag ut
59
+ WHERE ut.clientId = uad.clientId
60
+ AND ut.userId = uad.userId
61
+ AND ut.entityType = 'User'
62
+ AND ut.isSecurityGroup = 1
63
+ )
64
+ );
65
+ `);
66
+ await queryRunner.query(`
67
+ CREATE OR REPLACE VIEW \`user_authorized_boundary_security_view\` AS
68
+ (
69
+ SELECT
70
+ b.clientId AS clientId,
71
+ usr.userId AS userId,
72
+ b.id AS boundaryId
73
+ FROM userSecurityRole usr
74
+ JOIN boundary b
75
+ ON b.clientId = usr.clientId
76
+ WHERE usr.boundariesAccess = 'full'
77
+ AND NOT EXISTS (
78
+ SELECT 1
79
+ FROM entityTag ut
80
+ WHERE ut.userId = usr.userId
81
+ AND ut.entityType = 'User'
82
+ AND ut.isSecurityGroup = 1
83
+ )
84
+ )
85
+ UNION
86
+ (
87
+ SELECT
88
+ b.clientId AS clientId,
89
+ usr.userId AS userId,
90
+ b.id AS boundaryId
91
+ FROM entityTag ut
92
+ JOIN entityTag rt
93
+ ON rt.tagId = ut.tagId
94
+ AND rt.entityType = 'Boundary'
95
+ AND rt.isSecurityGroup = 1
96
+ JOIN boundary b
97
+ ON b.id = rt.entityId
98
+ JOIN userSecurityRole usr
99
+ ON usr.userId = ut.userId
100
+ AND usr.clientId = b.clientId
101
+ WHERE ut.entityType = 'User'
102
+ AND ut.isSecurityGroup = 1
103
+ )
104
+ UNION
105
+ (
106
+ SELECT
107
+ uab.clientId AS clientId,
108
+ uab.userId AS userId,
109
+ uab.boundaryId AS boundaryId
110
+ FROM userAuthorizedBoundary uab
111
+ WHERE NOT EXISTS (
112
+ SELECT 1
113
+ FROM userSecurityRole usr
114
+ WHERE usr.clientId = uab.clientId
115
+ AND usr.userId = uab.userId
116
+ AND usr.boundariesAccess = 'full'
117
+ )
118
+ AND NOT EXISTS (
119
+ SELECT 1
120
+ FROM entityTag ut
121
+ WHERE ut.clientId = uab.clientId
122
+ AND ut.userId = uab.userId
123
+ AND ut.entityType = 'User'
124
+ AND ut.isSecurityGroup = 1
125
+ )
126
+ );
127
+ `);
128
+ }
129
+ async down(queryRunner) {
130
+ await queryRunner.query(`DROP VIEW IF EXISTS \`user_authorized_device_security_view\`;`);
131
+ await queryRunner.query(`
132
+ DROP VIEW IF EXISTS \`user_authorized_boundary_security_view\`;
133
+ `);
134
+ }
135
+ }
136
+
137
+ exports.updateSecurityUserViews1684483705000 = updateSecurityUserViews1684483705000;
@@ -1,11 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var _1684483706000CreateUserAuthorizedDeviceSecurityViewV2 = require('../1684483706000-createUserAuthorizedDeviceSecurityViewV2.js');
4
3
  var _1684483704434AddLowerCaseIndex = require('../1684483704434-addLowerCaseIndex.js');
5
- var _1684483705000CreateUserAuthorizedBoundarySecurityViewV2 = require('../1684483705000-createUserAuthorizedBoundarySecurityViewV2.js');
4
+ var _1684483705000UpdateSecurityUserViews = require('../1684483705000-updateSecurityUserViews.js');
6
5
 
7
6
 
8
7
 
9
- exports.createUserAuthorizedDeviceSecurityViewV21684483706000 = _1684483706000CreateUserAuthorizedDeviceSecurityViewV2.createUserAuthorizedDeviceSecurityViewV21684483706000;
10
8
  exports.addLowerCaseIndex1684483704434 = _1684483704434AddLowerCaseIndex.addLowerCaseIndex1684483704434;
11
- exports.createUserAuthorizedBoundarySecurityViewV21684483705000 = _1684483705000CreateUserAuthorizedBoundarySecurityViewV2.createUserAuthorizedBoundarySecurityViewV21684483705000;
9
+ exports.updateSecurityUserViews1684483705000 = _1684483705000UpdateSecurityUserViews.updateSecurityUserViews1684483705000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spytecgps/nova-orm",
3
- "version": "1.4.79",
3
+ "version": "1.4.81",
4
4
  "description": "ORM with PlanetScale",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,5 +0,0 @@
1
- export declare class UserAuthorizedBoundarySecurityViewV2 {
2
- clientId: number;
3
- userId: string;
4
- boundaryId: number;
5
- }
@@ -1,5 +0,0 @@
1
- export declare class UserAuthorizedDeviceSecurityViewV2 {
2
- clientId: number;
3
- imei: string;
4
- userId: string;
5
- }
@@ -1,5 +0,0 @@
1
- import { MigrationInterface, QueryRunner } from 'typeorm';
2
- export declare class createUserAuthorizedBoundarySecurityViewV21684483705000 implements MigrationInterface {
3
- up(queryRunner: QueryRunner): Promise<void>;
4
- down(queryRunner: QueryRunner): Promise<void>;
5
- }
@@ -1,75 +0,0 @@
1
- 'use strict';
2
-
3
- class createUserAuthorizedBoundarySecurityViewV21684483705000 {
4
- async up(queryRunner) {
5
- await queryRunner.query(`
6
- CREATE OR REPLACE VIEW \`user_authorized_boundary_security_view_v2\` AS
7
- (
8
- SELECT
9
- b.clientId AS clientId,
10
- usr.userId AS userId,
11
- b.id AS boundaryId
12
- FROM userSecurityRole usr
13
- JOIN boundary b
14
- ON b.clientId = usr.clientId
15
- WHERE usr.boundariesAccess = 'full'
16
- AND NOT EXISTS (
17
- SELECT 1
18
- FROM entityTag ut
19
- WHERE ut.userId = usr.userId
20
- AND ut.entityType = 'User'
21
- AND ut.isSecurityGroup = 1
22
- )
23
- )
24
- UNION
25
- (
26
- SELECT
27
- b.clientId AS clientId,
28
- usr.userId AS userId,
29
- b.id AS boundaryId
30
- FROM entityTag ut
31
- JOIN entityTag rt
32
- ON rt.tagId = ut.tagId
33
- AND rt.entityType = 'Boundary'
34
- AND rt.isSecurityGroup = 1
35
- JOIN boundary b
36
- ON b.id = rt.entityId
37
- JOIN userSecurityRole usr
38
- ON usr.userId = ut.userId
39
- AND usr.clientId = b.clientId
40
- WHERE ut.entityType = 'User'
41
- AND ut.isSecurityGroup = 1
42
- )
43
- UNION
44
- (
45
- SELECT
46
- uab.clientId AS clientId,
47
- uab.userId AS userId,
48
- uab.boundaryId AS boundaryId
49
- FROM userAuthorizedBoundary uab
50
- WHERE NOT EXISTS (
51
- SELECT 1
52
- FROM userSecurityRole usr
53
- WHERE usr.clientId = uab.clientId
54
- AND usr.userId = uab.userId
55
- AND usr.boundariesAccess = 'full'
56
- )
57
- AND NOT EXISTS (
58
- SELECT 1
59
- FROM entityTag ut
60
- JOIN userSecurityRole usr
61
- ON usr.userId = ut.userId
62
- WHERE ut.entityType = 'User'
63
- AND ut.isSecurityGroup = 1
64
- )
65
- );
66
- `);
67
- }
68
- async down(queryRunner) {
69
- await queryRunner.query(`
70
- DROP VIEW IF EXISTS \`user_authorized_boundary_security_view_v2\`;
71
- `);
72
- }
73
- }
74
-
75
- exports.createUserAuthorizedBoundarySecurityViewV21684483705000 = createUserAuthorizedBoundarySecurityViewV21684483705000;
@@ -1,72 +0,0 @@
1
- 'use strict';
2
-
3
- class createUserAuthorizedDeviceSecurityViewV21684483706000 {
4
- async up(queryRunner) {
5
- await queryRunner.query(`
6
- CREATE OR REPLACE VIEW \`user_authorized_device_security_view_v2\` AS
7
- (
8
- SELECT
9
- d.clientId AS clientId,
10
- d.imei AS imei,
11
- usr.userId AS userId
12
- FROM userSecurityRole usr
13
- JOIN device d
14
- ON d.clientId = usr.clientId
15
- WHERE usr.access = 'full'
16
- AND NOT EXISTS (
17
- SELECT 1
18
- FROM entityTag ut
19
- WHERE ut.userId = usr.userId
20
- AND ut.entityType = 'User'
21
- AND ut.isSecurityGroup = 1
22
- )
23
- )
24
- UNION
25
- (
26
- SELECT
27
- d.clientId AS clientId,
28
- d.imei AS imei,
29
- usr.userId AS userId
30
- FROM entityTag ut
31
- JOIN entityTag rt
32
- ON rt.tagId = ut.tagId
33
- AND rt.entityType = 'Device'
34
- AND rt.isSecurityGroup = 1
35
- JOIN device d
36
- ON d.imei = rt.imei
37
- JOIN userSecurityRole usr
38
- ON usr.userId = ut.userId
39
- AND usr.clientId = d.clientId
40
- WHERE ut.entityType = 'User'
41
- AND ut.isSecurityGroup = 1
42
- )
43
- UNION (
44
- SELECT
45
- uad.clientId AS clientId,
46
- uad.imei AS imei,
47
- uad.userId AS userId
48
- FROM userAuthorizedDevice uad
49
- WHERE NOT EXISTS (
50
- SELECT 1
51
- FROM userSecurityRole usr
52
- WHERE usr.clientId = uad.clientId
53
- AND usr.userId = uad.userId
54
- AND usr.access = 'full'
55
- )
56
- AND NOT EXISTS (
57
- SELECT 1
58
- FROM entityTag ut
59
- JOIN userSecurityRole usr
60
- ON usr.userId = ut.userId
61
- WHERE ut.entityType = 'User'
62
- AND ut.isSecurityGroup = 1
63
- )
64
- );
65
- `);
66
- }
67
- async down(queryRunner) {
68
- await queryRunner.query(`DROP VIEW IF EXISTS \`user_authorized_device_security_view_v2\`;`);
69
- }
70
- }
71
-
72
- exports.createUserAuthorizedDeviceSecurityViewV21684483706000 = createUserAuthorizedDeviceSecurityViewV21684483706000;