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

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/assets-sharing",
3
- "version": "0.3.4-dev.2086",
3
+ "version": "0.3.4-dev.2092",
4
4
  "types": "dist/types/index.d.ts",
5
5
  "main": "dist/cjs/index.js",
6
6
  "exports": {
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@qrvey/data-persistence": "0.5.1-bundled.1",
30
- "@qrvey/id-generator": "workspace:*",
30
+ "@qrvey/id-generator": "^1.0.1",
31
31
  "@qrvey/utils": "1.15.0-30",
32
32
  "reflect-metadata": "0.2.2",
33
33
  "tsyringe": "4.8.0"
package/src/context.ts CHANGED
@@ -4,18 +4,18 @@ import { GroupRepository } from './quser/implementations/group.repository';
4
4
  import { UserRepository } from './quser/implementations/user.repository';
5
5
  import { type RoleRepositoryInterface } from './quser/interfaces/rolesRepository.interface';
6
6
  import { type UserRepositoryInterface } from './quser/interfaces/userRepository.interface';
7
+ import { AdminRepository } from './sharing/implementations/admin.repository';
7
8
  import { SharingDetailsRepository } from './sharing/implementations/details.repository';
8
9
  import { DownloadManagerRepository } from './sharing/implementations/dm.repository';
9
10
  import { DashboardRepository } from './sharing/implementations/dx.repository';
11
+ import { OrganizationRepository } from './sharing/implementations/organization.repository';
10
12
  import { SharingRepository } from './sharing/implementations/sharing.repository';
13
+ import { AdminRepositoryInterface } from './sharing/interfaces/adminRepository.interface';
11
14
  import { type DashboardRepositoryInterface } from './sharing/interfaces/dashboardRepository.interface';
12
15
  import { type SharingDetailsRepositoryInterface } from './sharing/interfaces/detailsRepository.interface';
13
16
  import { type DownloadManagerRepositoryInterface } from './sharing/interfaces/downloadManagerRepository.interface';
14
- import { type SharingRepositoryInterface } from './sharing/interfaces/sharingRepository.interface';
15
17
  import { OrganizationRepositoryInterface } from './sharing/interfaces/organizationRepository.interface';
16
- import { OrganizationRepository } from './sharing/implementations/organization.repository';
17
- import { AdminRepositoryInterface } from './sharing/interfaces/adminRepository.interface';
18
- import { AdminRepository } from './sharing/implementations/admin.repository';
18
+ import { type SharingRepositoryInterface } from './sharing/interfaces/sharingRepository.interface';
19
19
 
20
20
  container.register<SharingRepositoryInterface>(
21
21
  'SharingRepository',
package/src/index.ts CHANGED
@@ -2,12 +2,12 @@ import 'reflect-metadata';
2
2
  import { Context } from './context';
3
3
  import { FromTokenToUser } from './quser/services/fromTokenToUser';
4
4
  import { HasAdminRole } from './quser/services/hasAdminRole';
5
+ import CheckAppPermissions from './sharing/services/checkAppPermissions';
6
+ import CheckOrgPermissions from './sharing/services/checkOrgPermissions';
5
7
  import { CheckUserAccessLevel } from './sharing/services/checkUserAccessLevel';
6
8
  import { DeleteSharing } from './sharing/services/delete';
7
9
  import { ListSharing } from './sharing/services/list';
8
10
  import { UpsertSharing } from './sharing/services/upsert';
9
- import CheckAppPermissions from './sharing/services/checkAppPermissions';
10
- import CheckOrgPermissions from './sharing/services/checkOrgPermissions';
11
11
 
12
12
  export const api = {
13
13
  upsert: (...args: Parameters<UpsertSharing['execute']>) =>
@@ -52,6 +52,7 @@ export class SharingDetail {
52
52
  createdAt: now,
53
53
  updatedAt: now,
54
54
  };
55
+
55
56
  return new SharingDetail(obj);
56
57
  }
57
58
 
@@ -1,10 +1,10 @@
1
1
  export interface OrganizationType {
2
- orgid: string;
3
- name: string;
4
- parentorgid: string | null;
5
- org_path: string;
6
- contentprivacy: boolean;
7
- effectivecontentprivacy: boolean;
8
- createdat: string;
9
- updatedat: string;
2
+ org_id: string;
3
+ name: string;
4
+ parent_org_id: string | null;
5
+ org_path: string;
6
+ content_privacy: boolean;
7
+ effective_content_privacy: boolean;
8
+ created_at: string;
9
+ updated_at: string;
10
10
  }
@@ -1,8 +1,9 @@
1
- import { AdminRepositoryInterface } from '../interfaces/adminRepository.interface';
2
- import { ENVIRONMENT } from '../../common/constants';
3
1
  import { getAttribute } from '@qrvey/utils';
4
2
 
5
- export class AdminRepository implements AdminRepositoryInterface{
3
+ import { ENVIRONMENT } from '../../common/constants';
4
+ import { AdminRepositoryInterface } from '../interfaces/adminRepository.interface';
5
+
6
+ export class AdminRepository implements AdminRepositoryInterface {
6
7
  async getApplicationInfo(body: { appId: string; userId: string }) {
7
8
  const url = `${ENVIRONMENT.DOMAIN}/devapi/v4/user/${body.userId}/app/${body.appId}`;
8
9
 
@@ -33,7 +34,7 @@ export class AdminRepository implements AdminRepositoryInterface{
33
34
  };
34
35
  }
35
36
 
36
- async getPlatformConfiguration(): Promise<{
37
+ async getPlatformConfiguration(): Promise<{
37
38
  status: number;
38
39
  legacyMode: boolean;
39
40
  }> {
@@ -62,5 +63,4 @@ export class AdminRepository implements AdminRepositoryInterface{
62
63
  legacyMode: data?.Item?.settings?.legacyMode ?? true,
63
64
  };
64
65
  }
65
-
66
66
  }
@@ -1,28 +1,32 @@
1
1
  import { CrudSchema } from '@qrvey/data-persistence';
2
+
2
3
  import { DATABASE_INFO } from '../../common/constants';
3
4
 
4
5
  export default class OrganizationModel extends CrudSchema {
5
- static readonly table = {
6
- name: 'qv_organization',
7
- alias: `${DATABASE_INFO.TABLE_PREFIX}_organization`,
8
- };
6
+ static readonly table = {
7
+ name: 'qv_organization',
8
+ alias: `${DATABASE_INFO.TABLE_PREFIX}_organization`,
9
+ };
9
10
 
10
- static readonly columns = {
11
- orgid: { type: 'string', primary: true },
12
- name: { type: 'string' },
13
- parentorgid: { type: 'string' },
14
- org_path: { type: 'string' },
15
- contentprivacy: { type: 'boolean' },
16
- effectivecontentprivacy: { type: 'boolean' },
17
- createdat: { type: 'string' },
18
- updatedat: { type: 'string' },
19
- };
11
+ static readonly columns = {
12
+ org_id: { type: 'string', primary: true },
13
+ name: { type: 'string' },
14
+ parent_org_id: { type: 'string' },
15
+ org_path: { type: 'string' },
16
+ content_privacy: { type: 'boolean' },
17
+ effective_content_privacy: { type: 'boolean' },
18
+ created_at: { type: 'string' },
19
+ updated_at: { type: 'string' },
20
+ };
20
21
 
21
- static readonly indexes = {
22
- org_path: { name: 'idx_qv_orgs_org_path_gist', columns: ['org_path'] },
23
- parentorgid: { name: 'idx_qv_orgs_parent', columns: ['parentorgid'] },
24
- };
22
+ static readonly indexes = {
23
+ org_path: { name: 'idx_qv_orgs_org_path_gist', columns: ['org_path'] },
24
+ parent_org_id: {
25
+ name: 'idx_qv_orgs_parent',
26
+ columns: ['parent_org_id'],
27
+ },
28
+ };
25
29
 
26
- static readonly schema = DATABASE_INFO.DATA_PERSISTENCE_SCHEMA;
27
- static readonly usePool = true;
30
+ static readonly schema = DATABASE_INFO.DATA_PERSISTENCE_SCHEMA;
31
+ static readonly usePool = true;
28
32
  }
@@ -1,35 +1,21 @@
1
- import { BaseRepository } from '../../common/persistence/base';
2
1
  import OrganizationModel from './organization.model';
3
- import { OrganizationRepositoryInterface } from '../interfaces/organizationRepository.interface';
2
+ import { BaseRepository } from '../../common/persistence/base';
4
3
  import { OrganizationType } from '../entities/types/organization.type';
4
+ import { OrganizationRepositoryInterface } from '../interfaces/organizationRepository.interface';
5
5
 
6
6
  export class OrganizationRepository
7
- extends BaseRepository
8
- implements OrganizationRepositoryInterface
7
+ extends BaseRepository
8
+ implements OrganizationRepositoryInterface
9
9
  {
10
- constructor() {
11
- super(OrganizationModel);
12
- }
13
-
14
- async getOne(orgId: string): Promise<OrganizationType | null> {
15
- const params = {
16
- filters: [this.filter('orgid', orgId)],
17
- };
18
- const response = await super.findItem(params);
19
- return response as OrganizationType;
20
- }
21
-
22
- async create(org: OrganizationType): Promise<OrganizationType> {
23
- return (await super.create(org)) as OrganizationType;
24
- }
25
-
26
- async patch(orgId: string, org: OrganizationType): Promise<boolean> {
27
- await super.update([this.filter('orgid', orgId)], org);
28
- return true;
29
- }
10
+ constructor() {
11
+ super(OrganizationModel);
12
+ }
30
13
 
31
- async delete(orgId: string): Promise<boolean> {
32
- await super.remove([this.filter('orgid', orgId)]);
33
- return true;
34
- }
14
+ async getOne(orgId: string): Promise<OrganizationType | null> {
15
+ const params = {
16
+ filters: [this.filter('org_id', orgId)],
17
+ };
18
+ const response = await super.findItem(params);
19
+ return response as OrganizationType;
20
+ }
35
21
  }
@@ -1,8 +1,5 @@
1
1
  import { OrganizationType } from '../entities/types/organization.type';
2
2
 
3
3
  export interface OrganizationRepositoryInterface {
4
- getOne(orgId: string): Promise<OrganizationType | null>;
5
- create(org: OrganizationType): Promise<OrganizationType>;
6
- patch(orgId: string, org: OrganizationType): Promise<boolean>;
7
- delete(orgId: string): Promise<boolean>;
4
+ getOne(orgId: string): Promise<OrganizationType | null>;
8
5
  }
@@ -1,31 +1,34 @@
1
1
  import { inject, injectable } from 'tsyringe';
2
- import { AppPermissionResponse, AppSharingStatus } from '../../common/constants';
3
- import { AdminRepositoryInterface } from '../interfaces/adminRepository.interface';
4
2
 
3
+ import {
4
+ AppPermissionResponse,
5
+ AppSharingStatus,
6
+ } from '../../common/constants';
7
+ import { AdminRepositoryInterface } from '../interfaces/adminRepository.interface';
5
8
 
6
9
  @injectable()
7
10
  export default class CheckAppPermissions {
8
-
9
- constructor(@inject('AdminRepository') private readonly adminRepository: AdminRepositoryInterface) {
10
- }
11
+ constructor(
12
+ @inject('AdminRepository')
13
+ private readonly adminRepository: AdminRepositoryInterface,
14
+ ) {}
11
15
 
12
16
  //TODO Need Test
13
- async execute(
14
- {
15
- appId,
16
- userId,
17
- }:
18
- {
19
- appId: string;
20
- userId: string;
21
- },
22
- ): Promise<AppPermissionResponse> {
23
-
17
+ async execute({
18
+ appId,
19
+ userId,
20
+ }: {
21
+ appId: string;
22
+ userId: string;
23
+ }): Promise<AppPermissionResponse> {
24
24
  // If no user is available, block access by default
25
25
  if (!userId) return { privacy: AppSharingStatus.PRIVATE };
26
26
 
27
27
  // Fetch application status and global platform configuration in parallel
28
- const appInfo = await this.adminRepository.getApplicationInfo({ appId, userId });
28
+ const appInfo = await this.adminRepository.getApplicationInfo({
29
+ appId,
30
+ userId,
31
+ });
29
32
  const platform = await this.adminRepository.getPlatformConfiguration();
30
33
 
31
34
  // Check if the application is shared with the current user
@@ -41,4 +44,4 @@ export default class CheckAppPermissions {
41
44
 
42
45
  return { privacy };
43
46
  }
44
- };
47
+ }
@@ -1,29 +1,29 @@
1
1
  import { inject, injectable } from 'tsyringe';
2
- import { AppPermissionResponse, AppSharingStatus } from '../../common/constants';
3
- import { OrganizationRepositoryInterface } from '../interfaces/organizationRepository.interface';
4
2
 
3
+ import {
4
+ AppPermissionResponse,
5
+ AppSharingStatus,
6
+ } from '../../common/constants';
7
+ import { OrganizationRepositoryInterface } from '../interfaces/organizationRepository.interface';
5
8
 
6
9
  @injectable()
7
10
  export default class CheckOrgPermissions {
8
-
9
- constructor(@inject('OrganizationRepository') private readonly organizationRepository: OrganizationRepositoryInterface) {
10
- }
11
-
11
+ constructor(
12
+ @inject('OrganizationRepository')
13
+ private readonly organizationRepository: OrganizationRepositoryInterface,
14
+ ) {}
12
15
 
13
16
  //TODO Need Tes
14
- async execute(
15
- {
16
- orgId }:
17
- {
18
- orgId: string;
19
- },
20
- ): Promise<AppPermissionResponse> {
21
-
22
- const hasPublicAccess = await this.organizationRepository.getOne(orgId)
23
- const privacy = hasPublicAccess?.effectivecontentprivacy
17
+ async execute({
18
+ orgId,
19
+ }: {
20
+ orgId: string;
21
+ }): Promise<AppPermissionResponse> {
22
+ const hasPublicAccess = await this.organizationRepository.getOne(orgId);
23
+ const privacy = hasPublicAccess?.effective_content_privacy
24
24
  ? AppSharingStatus.PRIVATE
25
- : AppSharingStatus.PUBLIC
25
+ : AppSharingStatus.PUBLIC;
26
26
 
27
27
  return { privacy };
28
28
  }
29
- };
29
+ }