rez_core 1.0.36 → 1.0.38
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/dist/constant/global.constant.d.ts +1 -0
- package/dist/constant/global.constant.js +2 -1
- package/dist/constant/global.constant.js.map +1 -1
- package/dist/module/enterprise/controller/organization.controller.d.ts +6 -2
- package/dist/module/enterprise/controller/organization.controller.js +10 -3
- package/dist/module/enterprise/controller/organization.controller.js.map +1 -1
- package/dist/module/enterprise/enterprise.module.js +2 -1
- package/dist/module/enterprise/enterprise.module.js.map +1 -1
- package/dist/module/enterprise/service/organization.service.d.ts +1 -0
- package/dist/module/enterprise/service/organization.service.js +3 -0
- package/dist/module/enterprise/service/organization.service.js.map +1 -1
- package/dist/module/meta/controller/media.controller.d.ts +12 -0
- package/dist/module/meta/controller/media.controller.js +51 -0
- package/dist/module/meta/controller/media.controller.js.map +1 -0
- package/dist/module/meta/entity.module.js +2 -1
- package/dist/module/meta/entity.module.js.map +1 -1
- package/dist/module/meta/service/media-data.service.d.ts +18 -3
- package/dist/module/meta/service/media-data.service.js +57 -2
- package/dist/module/meta/service/media-data.service.js.map +1 -1
- package/dist/module/user/service/user.service.js +1 -1
- package/dist/module/user/service/user.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -1
- package/src/constant/global.constant.ts +1 -0
- package/src/module/enterprise/controller/organization.controller.ts +11 -4
- package/src/module/enterprise/enterprise.module.ts +2 -1
- package/src/module/enterprise/service/organization.service.ts +4 -0
- package/src/module/meta/controller/media.controller.ts +45 -0
- package/src/module/meta/entity.module.ts +2 -1
- package/src/module/meta/service/media-data.service.ts +75 -1
- package/src/module/user/service/user.service.ts +1 -1
- package/src/resources/dev.properties.yaml +9 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rez_core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.38",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "",
|
|
6
6
|
"private": false,
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"@nestjs/swagger": "^11.0.3",
|
|
31
31
|
"@nestjs/typeorm": "^11.0.0",
|
|
32
32
|
"250218_nodejs_core": "file:",
|
|
33
|
+
"aws-sdk": "^2.1692.0",
|
|
33
34
|
"bcrypt": "^5.1.1",
|
|
34
35
|
"class-transformer": "^0.5.1",
|
|
35
36
|
"class-validator": "^0.14.1",
|
|
@@ -46,6 +47,7 @@
|
|
|
46
47
|
"reflect-metadata": "^0.2.2",
|
|
47
48
|
"rxjs": "^7.8.1",
|
|
48
49
|
"typeorm": "^0.3.20",
|
|
50
|
+
"uuid": "^11.1.0",
|
|
49
51
|
"winston": "^3.17.0",
|
|
50
52
|
"xlsx": "^0.18.5"
|
|
51
53
|
},
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import { Controller, Get, Req, UseGuards } from '@nestjs/common';
|
|
1
|
+
import { Controller, Get, Inject, Req, UseGuards } from '@nestjs/common';
|
|
2
2
|
import { OrganizationService } from '../service/organization.service';
|
|
3
3
|
import { Request } from 'express';
|
|
4
4
|
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
5
|
+
import { UserService } from 'src/module/user/service/user.service';
|
|
6
|
+
import { ENTITYTYPE_USER } from '../../../constant/global.constant';
|
|
7
|
+
|
|
5
8
|
|
|
6
9
|
@Controller('organization')
|
|
7
10
|
export class OrganizationController {
|
|
8
|
-
constructor(private readonly orgService: OrganizationService
|
|
11
|
+
constructor(private readonly orgService: OrganizationService,
|
|
12
|
+
@Inject('UserService') private readonly userService: UserService
|
|
13
|
+
) {}
|
|
9
14
|
|
|
10
15
|
@UseGuards(JwtAuthGuard)
|
|
11
16
|
@Get('dropdown')
|
|
12
|
-
async getOrganizationDropdown(@Req() req: Request) {
|
|
17
|
+
async getOrganizationDropdown(@Req() req: Request & { user: any }) {
|
|
18
|
+
const userId = req.user.userId;
|
|
19
|
+
const userData = await this.userService.getEntityData(ENTITYTYPE_USER, userId);
|
|
13
20
|
// const enterpriseId = req.user['enterpriseId']; // or adapt based on your user structure
|
|
14
|
-
return this.orgService.
|
|
21
|
+
return this.orgService.findById(userData?.organization_id);
|
|
15
22
|
}
|
|
16
23
|
}
|
|
@@ -3,9 +3,10 @@ import { TypeOrmModule } from '@nestjs/typeorm';
|
|
|
3
3
|
import { OrganizationService } from './service/organization.service';
|
|
4
4
|
import { OrganizationData } from './entity/organization.entity';
|
|
5
5
|
import { OrganizationController } from './controller/organization.controller';
|
|
6
|
+
import { UserModule } from '../user/user.module';
|
|
6
7
|
|
|
7
8
|
@Module({
|
|
8
|
-
imports: [TypeOrmModule.forFeature([OrganizationData])],
|
|
9
|
+
imports: [TypeOrmModule.forFeature([OrganizationData]), UserModule],
|
|
9
10
|
controllers:[OrganizationController],
|
|
10
11
|
providers: [OrganizationService],
|
|
11
12
|
exports: [OrganizationService],
|
|
@@ -46,6 +46,10 @@ export class OrganizationService {
|
|
|
46
46
|
return await repo.findOne({ where: { id } });
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
async findById(id:number | undefined){
|
|
50
|
+
return await this.organizationRepository.find({ where: { id } });
|
|
51
|
+
}
|
|
52
|
+
|
|
49
53
|
async update(
|
|
50
54
|
id: number,
|
|
51
55
|
organizationDto: Partial<OrganizationData>,
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Body,
|
|
3
|
+
Controller,
|
|
4
|
+
HttpStatus,
|
|
5
|
+
Post,
|
|
6
|
+
Res,
|
|
7
|
+
UseGuards,
|
|
8
|
+
} from '@nestjs/common';
|
|
9
|
+
import { MediaDataService } from '../service/media-data.service';
|
|
10
|
+
import { JwtAuthGuard } from '../../auth/guards/jwt.guard';
|
|
11
|
+
import { Response } from 'express';
|
|
12
|
+
|
|
13
|
+
@Controller('media')
|
|
14
|
+
@UseGuards(JwtAuthGuard)
|
|
15
|
+
export class MediaController {
|
|
16
|
+
constructor(private readonly mediaDataService: MediaDataService) {}
|
|
17
|
+
|
|
18
|
+
@Post('initiate-upload')
|
|
19
|
+
async initiateUpload(
|
|
20
|
+
@Body()
|
|
21
|
+
body: {
|
|
22
|
+
file_name: string;
|
|
23
|
+
attribute_key: string;
|
|
24
|
+
mapped_entity_type?: string;
|
|
25
|
+
mapped_entity_id?: number;
|
|
26
|
+
},
|
|
27
|
+
@Res() res: Response,
|
|
28
|
+
) {
|
|
29
|
+
let result = await this.mediaDataService.generateMediaUploadDetails(
|
|
30
|
+
body.file_name,
|
|
31
|
+
body.attribute_key,
|
|
32
|
+
body.mapped_entity_type,
|
|
33
|
+
body.mapped_entity_id,
|
|
34
|
+
);
|
|
35
|
+
if (result) {
|
|
36
|
+
res.status(HttpStatus.OK).json({
|
|
37
|
+
message: 'Upload initiated successfully',
|
|
38
|
+
success: true,
|
|
39
|
+
data: result,
|
|
40
|
+
});
|
|
41
|
+
} else {
|
|
42
|
+
throw new Error('Something went wrong!');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -22,6 +22,7 @@ import { EntityListService } from './service/entity-list.service';
|
|
|
22
22
|
import { MediaData } from './entity/media-data.entity';
|
|
23
23
|
import { MediaDataService } from './service/media-data.service';
|
|
24
24
|
import { MediaDataRepository } from './repository/media-data.repository';
|
|
25
|
+
import { MediaController } from './controller/media.controller';
|
|
25
26
|
|
|
26
27
|
@Module({
|
|
27
28
|
imports: [
|
|
@@ -59,6 +60,6 @@ import { MediaDataRepository } from './repository/media-data.repository';
|
|
|
59
60
|
EntityTableColumnService,
|
|
60
61
|
MediaDataService,
|
|
61
62
|
],
|
|
62
|
-
controllers: [EntityController, MasterController],
|
|
63
|
+
controllers: [EntityController, MasterController, MediaController],
|
|
63
64
|
})
|
|
64
65
|
export class EntityModule {}
|
|
@@ -1,12 +1,76 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { EntityServiceImpl } from './entity-service-impl.service';
|
|
3
3
|
import { MediaDataRepository } from '../repository/media-data.repository';
|
|
4
|
+
import { ConfigService } from '@nestjs/config';
|
|
5
|
+
import { S3 } from 'aws-sdk';
|
|
6
|
+
import { MediaData } from '../entity/media-data.entity';
|
|
7
|
+
import { STATUS_PENDING } from '../../../constant/global.constant';
|
|
8
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
4
9
|
|
|
5
10
|
@Injectable()
|
|
6
11
|
export class MediaDataService extends EntityServiceImpl {
|
|
7
|
-
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
constructor(
|
|
15
|
+
private readonly configService: ConfigService,
|
|
16
|
+
private readonly mediaRepository: MediaDataRepository,
|
|
17
|
+
) {
|
|
8
18
|
super();
|
|
9
19
|
}
|
|
20
|
+
|
|
21
|
+
s3AccessKeyID=this.configService.get('AWS.S3.AWS_ACCESS_KEY_ID')
|
|
22
|
+
s3AccessKeySecret=this.configService.get('AWS.S3.AWS_SECRET_KEY')
|
|
23
|
+
s3Region=this.configService.get('AWS.S3.AWS_REGION')
|
|
24
|
+
bucketName = this.configService.get<string>('AWS.S3.BUCKET_NAME');
|
|
25
|
+
|
|
26
|
+
s3 = new S3({
|
|
27
|
+
accessKeyId: this.s3AccessKeyID,
|
|
28
|
+
secretAccessKey: this.s3AccessKeySecret,
|
|
29
|
+
region: this.s3Region,
|
|
30
|
+
signatureVersion: 'v4',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
async generateMediaUploadDetails(
|
|
35
|
+
fileName: string,
|
|
36
|
+
mappedAttributeKey: string,
|
|
37
|
+
mappedEntityType?: string,
|
|
38
|
+
mappedEntityId?: number,
|
|
39
|
+
) {
|
|
40
|
+
|
|
41
|
+
if (!fileName || !mappedAttributeKey) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const ext = fileName.split('.').pop()?.toLowerCase() ?? '';
|
|
45
|
+
|
|
46
|
+
const id = uuidv4();
|
|
47
|
+
const s3Key = `uploads/${mappedAttributeKey}/${id}.${ext}`;
|
|
48
|
+
console.log(s3Key)
|
|
49
|
+
|
|
50
|
+
const uploadUrl = await this.s3.getSignedUrlPromise('putObject', {
|
|
51
|
+
Bucket: this.bucketName,
|
|
52
|
+
Key: s3Key,
|
|
53
|
+
Expires: 60 * 5, // URL valid for 5 mins
|
|
54
|
+
ContentType: this.getContentType(ext),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
let mediaData = new MediaData();
|
|
58
|
+
mediaData.mapped_attribute_key = mappedAttributeKey;
|
|
59
|
+
mediaData.status = STATUS_PENDING;
|
|
60
|
+
if (mappedEntityType) {
|
|
61
|
+
mediaData.mapped_entity_type = mappedEntityType;
|
|
62
|
+
}
|
|
63
|
+
if (mappedEntityId) {
|
|
64
|
+
mediaData.mapped_entity_id = mappedEntityId;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let savedEntity = await super.createEntity(mediaData, null);
|
|
68
|
+
|
|
69
|
+
if (savedEntity) {
|
|
70
|
+
return { id: savedEntity.id, path: s3Key, uploadUrl };
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
10
74
|
|
|
11
75
|
async findByAttributeKeyAndMappedEntityIdAndMappedEntityType(
|
|
12
76
|
attributeKey: string,
|
|
@@ -41,4 +105,14 @@ export class MediaDataService extends EntityServiceImpl {
|
|
|
41
105
|
mappedEntityType,
|
|
42
106
|
);
|
|
43
107
|
}
|
|
108
|
+
|
|
109
|
+
private getContentType(ext: string): string {
|
|
110
|
+
const map = {
|
|
111
|
+
pdf: 'application/pdf',
|
|
112
|
+
jpg: 'image/jpeg',
|
|
113
|
+
jpeg: 'image/jpeg',
|
|
114
|
+
png: 'image/png',
|
|
115
|
+
};
|
|
116
|
+
return map[ext] || 'application/octet-stream';
|
|
117
|
+
}
|
|
44
118
|
}
|
|
@@ -47,7 +47,7 @@ export class UserService extends EntityServiceImpl {
|
|
|
47
47
|
throw new BadRequestException('User already exists');
|
|
48
48
|
}
|
|
49
49
|
userData.name =
|
|
50
|
-
userData.first_name + userData.last_name ? userData.last_name : '';
|
|
50
|
+
(userData.first_name ? userData.first_name : '') + (userData.last_name ? userData.last_name : '');
|
|
51
51
|
let password;
|
|
52
52
|
if (userData.password) {
|
|
53
53
|
password = EncryptUtilService.encryptGCM(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
DB_HOST: "
|
|
1
|
+
DB_HOST: "13.234.25.234"
|
|
2
2
|
DB_PORT: "3306"
|
|
3
3
|
DB_USER: "root"
|
|
4
|
-
DB_PASS: "
|
|
4
|
+
DB_PASS: "Rezolut@123"
|
|
5
5
|
DB_NAME: "core"
|
|
6
6
|
MASTER_KEY: "0QZ2eRJv5oVILYnyBlC+FbSGVQiWKReh"
|
|
7
7
|
MASTER_IV: "heuUQf5uPVtkotrFAOKUVw=="
|
|
@@ -12,4 +12,10 @@ CALLBACK_URL: "http://localhost:3000/auth/google/callback"
|
|
|
12
12
|
OTP_EXPIRY: "10"
|
|
13
13
|
OTP_LENGTH: "6"
|
|
14
14
|
VERIFY_OTP: "false"
|
|
15
|
-
DEFAULT_OTP: "123456"
|
|
15
|
+
DEFAULT_OTP: "123456"
|
|
16
|
+
AWS:
|
|
17
|
+
S3:
|
|
18
|
+
AWS_ACCESS_KEY_ID: "AKIAYYKIBDDSVJMYCJUV"
|
|
19
|
+
AWS_SECRET_KEY: "BCWF8yIeNP1jbazAi5BftWDu1Ym8fdKvmCbIEJvM"
|
|
20
|
+
AWS_REGION: "ap-south-1"
|
|
21
|
+
BUCKET_NAME: "testether"
|