@qrvey/assets-sharing 0.3.4-dev.2092 → 0.3.4-dev.2153

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 (150) hide show
  1. package/dist/cjs/common/common.type.js +3 -0
  2. package/dist/cjs/common/common.type.js.map +1 -0
  3. package/dist/cjs/common/constants.js +56 -0
  4. package/dist/cjs/common/constants.js.map +1 -0
  5. package/dist/cjs/common/persistence/base.js +15 -0
  6. package/dist/cjs/common/persistence/base.js.map +1 -0
  7. package/dist/cjs/common/persistence/poolClient.js +11 -0
  8. package/dist/cjs/common/persistence/poolClient.js.map +1 -0
  9. package/dist/cjs/common/util.js +12 -0
  10. package/dist/cjs/common/util.js.map +1 -0
  11. package/dist/cjs/context.js +22 -0
  12. package/dist/cjs/context.js.map +1 -0
  13. package/dist/cjs/index.js +43 -0
  14. package/dist/cjs/index.js.map +1 -0
  15. package/dist/cjs/quser/entities/types/user.type.js +3 -0
  16. package/dist/cjs/quser/entities/types/user.type.js.map +1 -0
  17. package/dist/cjs/quser/entities/user.js +25 -0
  18. package/dist/cjs/quser/entities/user.js.map +1 -0
  19. package/dist/cjs/quser/implementations/group.model.js +19 -0
  20. package/dist/cjs/quser/implementations/group.model.js.map +1 -0
  21. package/dist/cjs/quser/implementations/group.repository.js +19 -0
  22. package/dist/cjs/quser/implementations/group.repository.js.map +1 -0
  23. package/dist/cjs/quser/implementations/user.model.js +24 -0
  24. package/dist/cjs/quser/implementations/user.model.js.map +1 -0
  25. package/dist/cjs/quser/implementations/user.repository.js +29 -0
  26. package/dist/cjs/quser/implementations/user.repository.js.map +1 -0
  27. package/dist/cjs/quser/interfaces/rolesRepository.interface.js +3 -0
  28. package/dist/cjs/quser/interfaces/rolesRepository.interface.js.map +1 -0
  29. package/dist/cjs/quser/interfaces/userRepository.interface.js +3 -0
  30. package/dist/cjs/quser/interfaces/userRepository.interface.js.map +1 -0
  31. package/dist/cjs/quser/services/fromTokenToUser.js +52 -0
  32. package/dist/cjs/quser/services/fromTokenToUser.js.map +1 -0
  33. package/dist/cjs/quser/services/hasAdminRole.js +48 -0
  34. package/dist/cjs/quser/services/hasAdminRole.js.map +1 -0
  35. package/{src/sharing/entities/details.ts → dist/cjs/sharing/entities/details.js} +29 -65
  36. package/dist/cjs/sharing/entities/details.js.map +1 -0
  37. package/{src/sharing/entities/sharing.ts → dist/cjs/sharing/entities/sharing.js} +16 -37
  38. package/dist/cjs/sharing/entities/sharing.js.map +1 -0
  39. package/dist/cjs/sharing/entities/types/details.type.js +3 -0
  40. package/dist/cjs/sharing/entities/types/details.type.js.map +1 -0
  41. package/dist/cjs/sharing/entities/types/orgTreeResult.js +3 -0
  42. package/dist/cjs/sharing/entities/types/orgTreeResult.js.map +1 -0
  43. package/dist/cjs/sharing/entities/types/organization.type.js +3 -0
  44. package/dist/cjs/sharing/entities/types/organization.type.js.map +1 -0
  45. package/dist/cjs/sharing/entities/types/sharing.type.js +3 -0
  46. package/dist/cjs/sharing/entities/types/sharing.type.js.map +1 -0
  47. package/dist/cjs/sharing/implementations/admin.repository.js +47 -0
  48. package/dist/cjs/sharing/implementations/admin.repository.js.map +1 -0
  49. package/dist/cjs/sharing/implementations/details.model.js +93 -0
  50. package/dist/cjs/sharing/implementations/details.model.js.map +1 -0
  51. package/dist/cjs/sharing/implementations/details.repository.js +114 -0
  52. package/dist/cjs/sharing/implementations/details.repository.js.map +1 -0
  53. package/dist/cjs/sharing/implementations/dm.model.js +22 -0
  54. package/dist/cjs/sharing/implementations/dm.model.js.map +1 -0
  55. package/dist/cjs/sharing/implementations/dm.repository.js +20 -0
  56. package/dist/cjs/sharing/implementations/dm.repository.js.map +1 -0
  57. package/dist/cjs/sharing/implementations/dx.model.js +30 -0
  58. package/dist/cjs/sharing/implementations/dx.model.js.map +1 -0
  59. package/dist/cjs/sharing/implementations/dx.repository.js +21 -0
  60. package/dist/cjs/sharing/implementations/dx.repository.js.map +1 -0
  61. package/dist/cjs/sharing/implementations/organization.model.js +31 -0
  62. package/dist/cjs/sharing/implementations/organization.model.js.map +1 -0
  63. package/dist/cjs/sharing/implementations/organization.repository.js +66 -0
  64. package/dist/cjs/sharing/implementations/organization.repository.js.map +1 -0
  65. package/dist/cjs/sharing/implementations/sharing.model.js +33 -0
  66. package/dist/cjs/sharing/implementations/sharing.model.js.map +1 -0
  67. package/dist/cjs/sharing/implementations/sharing.repository.js +31 -0
  68. package/dist/cjs/sharing/implementations/sharing.repository.js.map +1 -0
  69. package/dist/cjs/sharing/interfaces/adminRepository.interface.js +3 -0
  70. package/dist/cjs/sharing/interfaces/adminRepository.interface.js.map +1 -0
  71. package/dist/cjs/sharing/interfaces/dashboardRepository.interface.js +3 -0
  72. package/dist/cjs/sharing/interfaces/dashboardRepository.interface.js.map +1 -0
  73. package/dist/cjs/sharing/interfaces/detailsRepository.interface.js +3 -0
  74. package/dist/cjs/sharing/interfaces/detailsRepository.interface.js.map +1 -0
  75. package/dist/cjs/sharing/interfaces/downloadManagerRepository.interface.js +3 -0
  76. package/dist/cjs/sharing/interfaces/downloadManagerRepository.interface.js.map +1 -0
  77. package/dist/cjs/sharing/interfaces/organizationRepository.interface.js +3 -0
  78. package/dist/cjs/sharing/interfaces/organizationRepository.interface.js.map +1 -0
  79. package/dist/cjs/sharing/interfaces/sharingRepository.interface.js +3 -0
  80. package/dist/cjs/sharing/interfaces/sharingRepository.interface.js.map +1 -0
  81. package/dist/cjs/sharing/services/checkAppPermissions.js +45 -0
  82. package/dist/cjs/sharing/services/checkAppPermissions.js.map +1 -0
  83. package/dist/cjs/sharing/services/checkOrgPermissions.js +32 -0
  84. package/dist/cjs/sharing/services/checkOrgPermissions.js.map +1 -0
  85. package/dist/cjs/sharing/services/checkUserAccessLevel.js +58 -0
  86. package/dist/cjs/sharing/services/checkUserAccessLevel.js.map +1 -0
  87. package/dist/cjs/sharing/services/delete.js +32 -0
  88. package/dist/cjs/sharing/services/delete.js.map +1 -0
  89. package/dist/cjs/sharing/services/getOrgTree.js +26 -0
  90. package/dist/cjs/sharing/services/getOrgTree.js.map +1 -0
  91. package/dist/cjs/sharing/services/list.js +44 -0
  92. package/dist/cjs/sharing/services/list.js.map +1 -0
  93. package/dist/cjs/sharing/services/upsert.js +135 -0
  94. package/dist/cjs/sharing/services/upsert.js.map +1 -0
  95. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
  96. package/dist/esm/index.mjs +1198 -0
  97. package/dist/esm/index.mjs.map +1 -0
  98. package/dist/types/index.d.ts +167 -0
  99. package/package.json +7 -2
  100. package/.eslintrc +0 -88
  101. package/__test__/hasAdminRole.test.ts +0 -299
  102. package/jest.config.ts +0 -15
  103. package/src/common/common.type.ts +0 -33
  104. package/src/common/constants.ts +0 -64
  105. package/src/common/persistence/base.ts +0 -13
  106. package/src/common/persistence/poolClient.ts +0 -7
  107. package/src/common/util.ts +0 -8
  108. package/src/context.ts +0 -47
  109. package/src/index.ts +0 -48
  110. package/src/quser/entities/types/user.type.ts +0 -14
  111. package/src/quser/entities/user.ts +0 -31
  112. package/src/quser/implementations/group.model.ts +0 -18
  113. package/src/quser/implementations/group.repository.ts +0 -20
  114. package/src/quser/implementations/user.model.ts +0 -23
  115. package/src/quser/implementations/user.repository.ts +0 -35
  116. package/src/quser/interfaces/rolesRepository.interface.ts +0 -3
  117. package/src/quser/interfaces/userRepository.interface.ts +0 -10
  118. package/src/quser/services/fromTokenToUser.ts +0 -49
  119. package/src/quser/services/hasAdminRole.ts +0 -52
  120. package/src/sharing/entities/types/details.type.ts +0 -58
  121. package/src/sharing/entities/types/organization.type.ts +0 -10
  122. package/src/sharing/entities/types/sharing.type.ts +0 -24
  123. package/src/sharing/implementations/admin.repository.ts +0 -66
  124. package/src/sharing/implementations/details.model.ts +0 -93
  125. package/src/sharing/implementations/details.repository.ts +0 -154
  126. package/src/sharing/implementations/dm.model.ts +0 -21
  127. package/src/sharing/implementations/dm.repository.ts +0 -23
  128. package/src/sharing/implementations/dx.model.ts +0 -30
  129. package/src/sharing/implementations/dx.repository.ts +0 -22
  130. package/src/sharing/implementations/organization.model.ts +0 -32
  131. package/src/sharing/implementations/organization.repository.ts +0 -21
  132. package/src/sharing/implementations/sharing.model.ts +0 -33
  133. package/src/sharing/implementations/sharing.repository.ts +0 -36
  134. package/src/sharing/interfaces/adminRepository.interface.ts +0 -13
  135. package/src/sharing/interfaces/dashboardRepository.interface.ts +0 -3
  136. package/src/sharing/interfaces/detailsRepository.interface.ts +0 -60
  137. package/src/sharing/interfaces/downloadManagerRepository.interface.ts +0 -3
  138. package/src/sharing/interfaces/organizationRepository.interface.ts +0 -5
  139. package/src/sharing/interfaces/sharingRepository.interface.ts +0 -32
  140. package/src/sharing/services/checkAppPermissions.ts +0 -47
  141. package/src/sharing/services/checkOrgPermissions.ts +0 -29
  142. package/src/sharing/services/checkUserAccessLevel.ts +0 -63
  143. package/src/sharing/services/delete.ts +0 -24
  144. package/src/sharing/services/list.ts +0 -53
  145. package/src/sharing/services/upsert.ts +0 -197
  146. package/tsconfig.cjs.json +0 -7
  147. package/tsconfig.json +0 -27
  148. package/tsup.config.cjs.ts +0 -19
  149. package/tsup.config.esm.ts +0 -12
  150. package/tsup.config.types.ts +0 -9
@@ -1,299 +0,0 @@
1
- import { ORGANIZATION_QRVEY, hasAdminRole } from '../src';
2
- import { UserRepository } from '../src/quser/implementations/user.repository';
3
-
4
- const loginType = 'qrveyLogin';
5
-
6
- describe('Check if has admin role.', () => {
7
- beforeEach(() => {
8
- // User Exist
9
- jest.spyOn(UserRepository.prototype, 'getOne').mockResolvedValue(
10
- {} as any,
11
- );
12
-
13
- // User has no admin role
14
- jest.spyOn(UserRepository.prototype, 'getList').mockResolvedValue({
15
- count: 0,
16
- items: [],
17
- } as any);
18
- });
19
-
20
- test('Does not have access when: Only API Key', async () => {
21
- const body = {
22
- apiKey: 'api-key',
23
- };
24
- const result = await hasAdminRole(body);
25
- expect(result).toBe(false);
26
- });
27
-
28
- test('Does not have access when: API Key and Non existing userId', async () => {
29
- jest.spyOn(UserRepository.prototype, 'getOne').mockResolvedValue(null);
30
-
31
- const body = {
32
- apiKey: 'api-key',
33
- userId: 'non-existing-user',
34
- };
35
- const result = await hasAdminRole(body);
36
- expect(result).toBe(false);
37
- });
38
-
39
- test('Has access when: API Key and Existing userId', async () => {
40
- const body = {
41
- apiKey: 'api-key',
42
- userId: 'existing-user',
43
- };
44
- const result = await hasAdminRole(body);
45
- expect(result).toBe(true);
46
- });
47
-
48
- test('Has access when: API Key, org:0 and Existing userId', async () => {
49
- const body = {
50
- apiKey: 'api-key',
51
- userId: 'existing-user',
52
- orgId: ORGANIZATION_QRVEY,
53
- };
54
- const result = await hasAdminRole(body);
55
- expect(result).toBe(true);
56
- });
57
-
58
- test('Does not have access when: API Key, Existing userId and Non existing clientId', async () => {
59
- const body = {
60
- apiKey: 'api-key',
61
- userId: 'existing-user',
62
- clientId: 'non-existing-user',
63
- };
64
- const result = await hasAdminRole(body);
65
- expect(result).toBe(false);
66
- });
67
-
68
- test('Has access when: API Key, Existing userId and existing clientId', async () => {
69
- const body = {
70
- apiKey: 'api-key',
71
- userId: 'existing-user',
72
- clientId: 'existing-user',
73
- };
74
- const result = await hasAdminRole(body);
75
- expect(result).toBe(true);
76
- });
77
-
78
- test('Has access when: API Key, no Admin userId and admin clientId', async () => {
79
- jest.spyOn(UserRepository.prototype, 'getList').mockResolvedValue({
80
- count: 1,
81
- items: [{}],
82
- } as any);
83
-
84
- const body = {
85
- apiKey: 'api-key',
86
- userId: 'existing-user',
87
- clientId: 'admin-user',
88
- };
89
- const result = await hasAdminRole(body);
90
- expect(result).toBe(true);
91
- });
92
-
93
- test('Does not have access when: API Key, org:0 and Existing userId', async () => {
94
- const body = {
95
- apiKey: 'api-key',
96
- userId: 'existing-user',
97
- orgId: 'another-org',
98
- };
99
- const result = await hasAdminRole(body);
100
- expect(result).toBe(false);
101
- });
102
-
103
- test('Does not have access when: InComposer only (need userId)', async () => {
104
- const body = {
105
- loginType,
106
- };
107
- const result = await hasAdminRole(body);
108
- expect(result).toBe(false);
109
- });
110
-
111
- test('Has access when: InComposer, org:0 and Admin userId', async () => {
112
- jest.spyOn(UserRepository.prototype, 'getList').mockResolvedValue({
113
- count: 1,
114
- items: [{}],
115
- } as any);
116
-
117
- const body = {
118
- loginType,
119
- userId: 'admin-user',
120
- orgId: ORGANIZATION_QRVEY,
121
- };
122
- const result = await hasAdminRole(body);
123
- expect(result).toBe(true);
124
- });
125
-
126
- test('Does not have access when: InComposer, org:0 and non Admin userId', async () => {
127
- const body = {
128
- loginType,
129
- userId: 'non-admin-user',
130
- orgId: ORGANIZATION_QRVEY,
131
- };
132
- const result = await hasAdminRole(body);
133
- expect(result).toBe(false);
134
- });
135
-
136
- test('Does not have access when: org:0 and Admin userId only', async () => {
137
- jest.spyOn(UserRepository.prototype, 'getList').mockResolvedValue({
138
- count: 1,
139
- items: [{}],
140
- } as any);
141
-
142
- const body = {
143
- userId: 'admin-user',
144
- orgId: ORGANIZATION_QRVEY,
145
- };
146
- const result = await hasAdminRole(body);
147
- expect(result).toBe(false);
148
- });
149
-
150
- test('Has access when: org:0, Admin userId and Admin ClientId (same as userId)', async () => {
151
- jest.spyOn(UserRepository.prototype, 'getList').mockResolvedValue({
152
- count: 1,
153
- items: [{}],
154
- } as any);
155
-
156
- const body = {
157
- userId: 'admin-user',
158
- clientId: 'admin-user',
159
- orgId: ORGANIZATION_QRVEY,
160
- };
161
- const result = await hasAdminRole(body);
162
- expect(result).toBe(true);
163
- });
164
-
165
- test('Has access when: org:0, Admin userId and Another Admin ClientId', async () => {
166
- jest.spyOn(UserRepository.prototype, 'getList').mockResolvedValue({
167
- count: 1,
168
- items: [{}],
169
- } as any);
170
-
171
- const body = {
172
- userId: 'admin-user',
173
- clientId: 'another-admin-user',
174
- orgId: ORGANIZATION_QRVEY,
175
- };
176
- const result = await hasAdminRole(body);
177
- expect(result).toBe(true);
178
- });
179
-
180
- test('Does not have access when: org:0, Admin userId and Non Admin ClientId', async () => {
181
- const body = {
182
- userId: 'admin-user',
183
- clientId: 'non-admin-user',
184
- orgId: ORGANIZATION_QRVEY,
185
- };
186
- const result = await hasAdminRole(body);
187
- expect(result).toBe(false);
188
- });
189
-
190
- test('Has access when: org:0, non Admin userId and Admin ClientId', async () => {
191
- jest.spyOn(UserRepository.prototype, 'getList').mockResolvedValue({
192
- count: 1,
193
- items: [{}],
194
- } as any);
195
-
196
- const body = {
197
- userId: 'non-admin-user',
198
- clientId: 'admin-user',
199
- orgId: ORGANIZATION_QRVEY,
200
- };
201
- const result = await hasAdminRole(body);
202
- expect(result).toBe(true);
203
- });
204
-
205
- test('Does not have access when: org:0, non Admin userId and non Admin ClientId', async () => {
206
- const body = {
207
- userId: 'non-admin-user',
208
- clientId: 'another-non-admin-user',
209
- orgId: ORGANIZATION_QRVEY,
210
- };
211
- const result = await hasAdminRole(body);
212
- expect(result).toBe(false);
213
- });
214
-
215
- test('Does not have access when: InComposer, Another org, Admin userId', async () => {
216
- jest.spyOn(UserRepository.prototype, 'getList').mockResolvedValue({
217
- count: 1,
218
- items: [{}],
219
- } as any);
220
-
221
- const body = {
222
- userId: 'admin-user',
223
- orgId: 'another-org',
224
- loginType,
225
- };
226
- const result = await hasAdminRole(body);
227
- expect(result).toBe(false);
228
- });
229
-
230
- test('Does not have access when: InComposer, Another org, non Admin userId', async () => {
231
- const body = {
232
- userId: 'non-admin-user',
233
- orgId: 'another-org',
234
- loginType,
235
- };
236
- const result = await hasAdminRole(body);
237
- expect(result).toBe(false);
238
- });
239
-
240
- test('Does not have access when: Another org, Admin userId and Admin clientId', async () => {
241
- jest.spyOn(UserRepository.prototype, 'getList').mockResolvedValue({
242
- count: 1,
243
- items: [{}],
244
- } as any);
245
-
246
- const body = {
247
- userId: 'admin-user',
248
- clientId: 'admin-user',
249
- orgId: 'another-org',
250
- };
251
- const result = await hasAdminRole(body);
252
- expect(result).toBe(false);
253
- });
254
-
255
- test('Does not have access when: Another org, Admin userId and another Admin clientId', async () => {
256
- jest.spyOn(UserRepository.prototype, 'getList').mockResolvedValue({
257
- count: 1,
258
- items: [{}],
259
- } as any);
260
-
261
- const body = {
262
- userId: 'admin-user',
263
- clientId: 'another-admin-user',
264
- orgId: 'another-org',
265
- };
266
- const result = await hasAdminRole(body);
267
- expect(result).toBe(false);
268
- });
269
-
270
- test('Does not have access when: Another org, Admin userId and non Admin clientId', async () => {
271
- const body = {
272
- userId: 'admin-user',
273
- clientId: 'non-admin-user',
274
- orgId: 'another-org',
275
- };
276
- const result = await hasAdminRole(body);
277
- expect(result).toBe(false);
278
- });
279
-
280
- test('Does not have access when: Another org, non Admin userId and Admin clientId', async () => {
281
- const body = {
282
- userId: 'non-admin-user',
283
- clientId: 'admin-user',
284
- orgId: 'another-org',
285
- };
286
- const result = await hasAdminRole(body);
287
- expect(result).toBe(false);
288
- });
289
-
290
- test('Does not have access when: Another org, non Admin userId and non Admin clientId', async () => {
291
- const body = {
292
- userId: 'non-admin-user',
293
- clientId: 'another-non-admin-user',
294
- orgId: 'another-org',
295
- };
296
- const result = await hasAdminRole(body);
297
- expect(result).toBe(false);
298
- });
299
- });
package/jest.config.ts DELETED
@@ -1,15 +0,0 @@
1
- export default {
2
- preset: 'ts-jest',
3
- testEnvironment: 'node',
4
- collectCoverageFrom: [
5
- 'src/**/*.ts',
6
- '!src/**/*.test.ts',
7
- '!src/**/*.spec.ts',
8
- '!src/types/**/*',
9
- '!src/interfaces/**/*',
10
- ],
11
- testPathIgnorePatterns: [
12
- '<rootDir>/node_modules/',
13
- '<rootDir>/__tests__/__mocks__/',
14
- ],
15
- };
@@ -1,33 +0,0 @@
1
- export interface Pagination {
2
- limit: number;
3
- from?: number;
4
- }
5
-
6
- export interface Filter {
7
- column: string;
8
- value: string;
9
- }
10
-
11
- export interface ParamsFromTokenToUser {
12
- userId: string;
13
- roles: string[];
14
- orgId: string;
15
- }
16
-
17
- export interface Sorting {
18
- column: string;
19
- direction: 'ASC' | 'DESC';
20
- }
21
-
22
- export interface ListInput<T> {
23
- data: T;
24
- pagination?: Pagination;
25
- filters?: Array<Filter>;
26
- sorting?: Array<Sorting>;
27
- }
28
-
29
- export interface ListOutput<T> {
30
- count: number;
31
- items: T[];
32
- pagination: Pagination;
33
- }
@@ -1,64 +0,0 @@
1
- export const ENVIRONMENT = {
2
- SERVER_PREFIX: process.env.SERVER_PREFIX,
3
- TABLE_PREFIX: process.env.TABLE_PREFIX,
4
- DOMAIN: process.env.DOMAIN,
5
- API_KEY: process.env.API_KEY,
6
- };
7
-
8
- export const DATABASE_INFO = {
9
- DATA_PERSISTENCE_SCHEMA: 'admin',
10
- SERVER_PREFIX: ENVIRONMENT.SERVER_PREFIX,
11
- TABLE_PREFIX: ENVIRONMENT.TABLE_PREFIX,
12
- };
13
-
14
- export const ORGANIZATION_QRVEY = 'org:0';
15
-
16
- export enum ASSET_TYPE {
17
- DX = 'DX', // DASHBOARD X (Next Gen)
18
- DM = 'DM', // DOWNLOAD MANAGER
19
- }
20
-
21
- export enum SHARED_ORIGIN {
22
- INTERNAL = 'INTERNAL', // for org:0
23
- EXTERNAL = 'EXTERNAL', // for orgs different that 0
24
- UNKNOWN = 'UNKNOWN', // without orgId
25
- }
26
-
27
- export enum SHARE_TYPE {
28
- USER = 'USER',
29
- ROLE = 'ROLE',
30
- ORGANIZATION = 'ORGANIZATION',
31
- }
32
-
33
- /**
34
- * Access levels for assets.
35
- * Those are calculated with Base 2, so:
36
- * - NONE = 0 (undefined)
37
- * - CAN_USE = 1 (2^0)
38
- * - CAN_EDIT = 2 (2^1)
39
- * - ADMIN = 4 (2^2)
40
- * - (Future) SUPER = 8 (2^3)
41
- */
42
- export enum ACCESS_LEVEL {
43
- NONE = 0,
44
- CAN_USE = 1,
45
- CAN_EDIT = 2,
46
- ADMIN = 4,
47
- }
48
-
49
- export enum AppSharingStatus {
50
- PUBLIC = 'public',
51
- PRIVATE = 'private',
52
- }
53
-
54
- export interface AppPermissionResponse {
55
- privacy: AppSharingStatus;
56
- }
57
-
58
- export interface AppOwner {
59
- userId: string;
60
- appId: string;
61
- userEmail?: string;
62
- }
63
-
64
- export const LIMIT_PER_PAGE = 10;
@@ -1,13 +0,0 @@
1
- import { CrudService, buildFilter } from '@qrvey/data-persistence';
2
-
3
- import { getPoolClient } from './poolClient';
4
-
5
- export class BaseRepository extends CrudService<any> {
6
- constructor(schema: any) {
7
- super(schema, getPoolClient());
8
- }
9
-
10
- filter(attribute: string, value: any, operator?: string) {
11
- return buildFilter(attribute, value, operator);
12
- }
13
- }
@@ -1,7 +0,0 @@
1
- import { getDbPool } from '@qrvey/data-persistence';
2
-
3
- let poolClient: any;
4
- export function getPoolClient() {
5
- if (!poolClient) poolClient = getDbPool();
6
- return poolClient;
7
- }
@@ -1,8 +0,0 @@
1
- enum LOGIN_TYPES {
2
- composer = 'qrveyLogin',
3
- openIdComposer = 'OPENID_CREATORS',
4
- }
5
-
6
- export function isComposer(type: string): boolean {
7
- return type === LOGIN_TYPES.composer || type === LOGIN_TYPES.openIdComposer;
8
- }
package/src/context.ts DELETED
@@ -1,47 +0,0 @@
1
- import { container } from 'tsyringe';
2
-
3
- import { GroupRepository } from './quser/implementations/group.repository';
4
- import { UserRepository } from './quser/implementations/user.repository';
5
- import { type RoleRepositoryInterface } from './quser/interfaces/rolesRepository.interface';
6
- import { type UserRepositoryInterface } from './quser/interfaces/userRepository.interface';
7
- import { AdminRepository } from './sharing/implementations/admin.repository';
8
- import { SharingDetailsRepository } from './sharing/implementations/details.repository';
9
- import { DownloadManagerRepository } from './sharing/implementations/dm.repository';
10
- import { DashboardRepository } from './sharing/implementations/dx.repository';
11
- import { OrganizationRepository } from './sharing/implementations/organization.repository';
12
- import { SharingRepository } from './sharing/implementations/sharing.repository';
13
- import { AdminRepositoryInterface } from './sharing/interfaces/adminRepository.interface';
14
- import { type DashboardRepositoryInterface } from './sharing/interfaces/dashboardRepository.interface';
15
- import { type SharingDetailsRepositoryInterface } from './sharing/interfaces/detailsRepository.interface';
16
- import { type DownloadManagerRepositoryInterface } from './sharing/interfaces/downloadManagerRepository.interface';
17
- import { OrganizationRepositoryInterface } from './sharing/interfaces/organizationRepository.interface';
18
- import { type SharingRepositoryInterface } from './sharing/interfaces/sharingRepository.interface';
19
-
20
- container.register<SharingRepositoryInterface>(
21
- 'SharingRepository',
22
- SharingRepository,
23
- );
24
- container.register<SharingDetailsRepositoryInterface>(
25
- 'SharingDetailsRepository',
26
- SharingDetailsRepository,
27
- );
28
- container.register<UserRepositoryInterface>('UserRepository', UserRepository);
29
- container.register<RoleRepositoryInterface>('RoleRepository', GroupRepository);
30
- container.register<DashboardRepositoryInterface>(
31
- 'dxRepository',
32
- DashboardRepository,
33
- );
34
- container.register<DownloadManagerRepositoryInterface>(
35
- 'dmRepository',
36
- DownloadManagerRepository,
37
- );
38
- container.register<OrganizationRepositoryInterface>(
39
- 'OrganizationRepository',
40
- OrganizationRepository,
41
- );
42
- container.register<AdminRepositoryInterface>(
43
- 'AdminRepository',
44
- AdminRepository,
45
- );
46
-
47
- export const Context = container;
package/src/index.ts DELETED
@@ -1,48 +0,0 @@
1
- import 'reflect-metadata';
2
- import { Context } from './context';
3
- import { FromTokenToUser } from './quser/services/fromTokenToUser';
4
- import { HasAdminRole } from './quser/services/hasAdminRole';
5
- import CheckAppPermissions from './sharing/services/checkAppPermissions';
6
- import CheckOrgPermissions from './sharing/services/checkOrgPermissions';
7
- import { CheckUserAccessLevel } from './sharing/services/checkUserAccessLevel';
8
- import { DeleteSharing } from './sharing/services/delete';
9
- import { ListSharing } from './sharing/services/list';
10
- import { UpsertSharing } from './sharing/services/upsert';
11
-
12
- export const api = {
13
- upsert: (...args: Parameters<UpsertSharing['execute']>) =>
14
- Context.resolve(UpsertSharing).execute(...args),
15
- list: (...args: Parameters<ListSharing['execute']>) =>
16
- Context.resolve(ListSharing).execute(...args),
17
- delete: (...args: Parameters<DeleteSharing['execute']>) =>
18
- Context.resolve(DeleteSharing).execute(...args),
19
- };
20
-
21
- export const checkUserAccessLevel = (
22
- ...args: Parameters<CheckUserAccessLevel['execute']>
23
- ) => Context.resolve(CheckUserAccessLevel).execute(...args);
24
-
25
- export const checkAppPermissions = (
26
- ...args: Parameters<CheckAppPermissions['execute']>
27
- ) => Context.resolve(CheckAppPermissions).execute(...args);
28
-
29
- export const checkOrgPermissions = (
30
- ...args: Parameters<CheckOrgPermissions['execute']>
31
- ) => Context.resolve(CheckOrgPermissions).execute(...args);
32
-
33
- export const fromTokenToUser = (
34
- ...args: Parameters<FromTokenToUser['execute']>
35
- ) => Context.resolve(FromTokenToUser).execute(...args);
36
-
37
- export const hasAdminRole = (...args: Parameters<HasAdminRole['execute']>) =>
38
- Context.resolve(HasAdminRole).execute(...args);
39
-
40
- export {
41
- ACCESS_LEVEL,
42
- ASSET_TYPE,
43
- ORGANIZATION_QRVEY,
44
- SHARED_ORIGIN,
45
- SHARE_TYPE,
46
- } from './common/constants';
47
-
48
- export { GetSharingList } from './sharing/entities/types/details.type';
@@ -1,14 +0,0 @@
1
- export interface BaseUser {
2
- userid: string;
3
- email: string;
4
- groups: string[];
5
- organization: string;
6
- }
7
-
8
- export interface UserToken {
9
- userId: string;
10
- clientId?: string;
11
- roles?: string[];
12
- orgId?: string;
13
- loginType?: string;
14
- }
@@ -1,31 +0,0 @@
1
- import { BaseUser } from './types/user.type';
2
-
3
- export class User {
4
- private userId: string;
5
- private email: string;
6
- private groups: string[];
7
- private organization: string;
8
-
9
- constructor(params: BaseUser) {
10
- this.userId = params.userid;
11
- this.email = params.email;
12
- this.groups = params.groups;
13
- this.organization = params.organization;
14
- }
15
-
16
- public get getUserId(): string {
17
- return this.userId;
18
- }
19
-
20
- public get getEmail(): string {
21
- return this.email;
22
- }
23
-
24
- public get getGroups(): string[] {
25
- return this.groups;
26
- }
27
-
28
- public get getOrganization(): string {
29
- return this.organization;
30
- }
31
- }
@@ -1,18 +0,0 @@
1
- import { CrudSchema } from '@qrvey/data-persistence';
2
-
3
- import { DATABASE_INFO } from '../../common/constants';
4
-
5
- export class GroupModel extends CrudSchema {
6
- static table = {
7
- name: `${DATABASE_INFO.SERVER_PREFIX}Groups`,
8
- alias: 'qv_groups',
9
- };
10
-
11
- static columns = {
12
- groupid: {
13
- type: 'string',
14
- },
15
- };
16
-
17
- static schema = DATABASE_INFO.DATA_PERSISTENCE_SCHEMA;
18
- }
@@ -1,20 +0,0 @@
1
- import { GroupModel } from './group.model';
2
- import { BaseRepository } from '../../common/persistence/base';
3
- import { RoleRepositoryInterface } from '../interfaces/rolesRepository.interface';
4
-
5
- export class GroupRepository
6
- extends BaseRepository
7
- implements RoleRepositoryInterface
8
- {
9
- constructor() {
10
- super(GroupModel);
11
- }
12
-
13
- async getOne(identifier: string): Promise<{ groupid: string } | null> {
14
- const params = {
15
- filters: [this.filter('groupid', identifier)],
16
- };
17
- const response = await super.findItem(params);
18
- return response as { groupid: string };
19
- }
20
- }
@@ -1,23 +0,0 @@
1
- import { CrudSchema } from '@qrvey/data-persistence';
2
-
3
- import { DATABASE_INFO } from '../../common/constants';
4
-
5
- export class UserModel extends CrudSchema {
6
- static table = {
7
- name: `${DATABASE_INFO.SERVER_PREFIX}Users`,
8
- alias: 'qv_users',
9
- };
10
-
11
- static columns = {
12
- userid: {
13
- type: 'string',
14
- primary: true,
15
- columnId: true,
16
- },
17
- groups: {
18
- type: 'array',
19
- },
20
- };
21
-
22
- static schema = DATABASE_INFO.DATA_PERSISTENCE_SCHEMA;
23
- }
@@ -1,35 +0,0 @@
1
- import { UserModel } from './user.model';
2
- import { ListInput, ListOutput } from '../../common/common.type';
3
- import { BaseRepository } from '../../common/persistence/base';
4
- import { BaseUser } from '../entities/types/user.type';
5
- import { UserRepositoryInterface } from '../interfaces/userRepository.interface';
6
-
7
- export class UserRepository
8
- extends BaseRepository
9
- implements UserRepositoryInterface
10
- {
11
- constructor() {
12
- super(UserModel);
13
- }
14
-
15
- async getOne(identifier: string): Promise<BaseUser | null> {
16
- const params = {
17
- filters: [this.filter('userid', identifier)],
18
- };
19
- const response = await super.findItem(params);
20
- return response as BaseUser;
21
- }
22
-
23
- async getList(
24
- options: ListInput<{ identifier: string; role?: string }>,
25
- ): Promise<ListOutput<BaseUser>> {
26
- const params = {
27
- filters: [
28
- this.filter('userid', options.data.identifier),
29
- this.filter('groups', options.data.role, 'CONTAINS'),
30
- ],
31
- };
32
- const response = await super.find(params);
33
- return response as ListOutput<BaseUser>;
34
- }
35
- }