Skip to content

Commit

Permalink
Merge branch 'main' into feat/pentests
Browse files Browse the repository at this point in the history
  • Loading branch information
cberg-aot authored Sep 28, 2023
2 parents 7735d65 + 9efb05a commit fb56d89
Show file tree
Hide file tree
Showing 66 changed files with 1,111 additions and 101 deletions.
59 changes: 41 additions & 18 deletions backend/dops/src/modules/common/entities/base.entity.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
import { AutoMap } from '@automapper/classes';
import { ApiProperty } from '@nestjs/swagger';
import {
Column,
CreateDateColumn,
UpdateDateColumn,
VersionColumn,
} from 'typeorm';
import { Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';

export class Base {
@AutoMap()
@ApiProperty({ description: 'Concurrency Control Number' })
@VersionColumn({
name: 'CONCURRENCY_CONTROL_NUMBER',
@ApiProperty({ description: 'Created User Name' })
@Column({
length: 30,
name: 'APP_CREATE_USERID',
nullable: true,
})
concurrencyControlNumber: number;
createdUser: string;

@AutoMap()
@ApiProperty({ description: 'Created User Name' })
@ApiProperty({ description: 'Created User Directory' })
@Column({
length: 30,
name: 'DB_CREATE_USERID',
name: 'APP_CREATE_USER_DIRECTORY',
nullable: true,
})
createdUser: string;
createdUserDirectory: string;

@AutoMap()
@ApiProperty({ description: 'Created User GUID' })
@Column({
length: 32,
name: 'APP_CREATE_USER_GUID',
nullable: true,
})
createdUserGuid: string;

@AutoMap()
@ApiProperty({ description: 'Resource Creation Date' })
@CreateDateColumn({
default: () => 'NOW()',
name: 'DB_CREATE_TIMESTAMP',
default: () => 'GETUTCDATETIME()',
name: 'APP_CREATE_TIMESTAMP',
nullable: true,
})
createdDateTime: Date;
Expand All @@ -38,16 +43,34 @@ export class Base {
@ApiProperty({ description: 'Updated User Name' })
@Column({
length: 30,
name: 'DB_LAST_UPDATE_USERID',
name: 'APP_LAST_UPDATE_USERID',
nullable: true,
})
updatedUser: string;

@AutoMap()
@ApiProperty({ description: 'Updated User Directory' })
@Column({
length: 30,
name: 'APP_LAST_UPDATE_USER_DIRECTORY',
nullable: true,
})
updatedUserDirectory: string;

@AutoMap()
@ApiProperty({ description: 'Updated User GUID' })
@Column({
length: 32,
name: 'APP_LAST_UPDATE_USER_GUID',
nullable: true,
})
updatedUserGuid: string;

@AutoMap()
@ApiProperty({ description: 'Resource Update Date' })
@UpdateDateColumn({
default: () => 'NOW()',
name: 'DB_LAST_UPDATE_TIMESTAMP',
default: () => 'GETUTCDATETIME()',
name: 'APP_LAST_UPDATE_TIMESTAMP',
nullable: true,
})
updatedDateTime: Date;
Expand Down
4 changes: 3 additions & 1 deletion backend/dops/src/modules/dgen/dgen.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { CreateGeneratedReportDto } from './dto/request/create-generated-report.
import puppeteer, { Browser } from 'puppeteer';
import { IFile } from '../../interface/file.interface';
import { ReportTemplate } from '../../enum/report-template.enum';
import { getDirectory } from 'src/helper/auth.helper';

@Injectable()
export class DgenService {
Expand Down Expand Up @@ -119,6 +120,7 @@ export class DgenService {
const dmsObject = await this.dmsService.create(
currentUser,
generatedDocument,
getDirectory(currentUser),
companyId,
);
res.setHeader('x-orbc-dms-id', dmsObject.documentId);
Expand Down Expand Up @@ -259,7 +261,7 @@ export class DgenService {
});
generatedDocument.size = generatedDocument.buffer.length;
} catch (err) {
console.log("error on pup",err);
console.log('error on pup', err);
throw new InternalServerErrorException(err);
} finally {
if (browser) {
Expand Down
11 changes: 10 additions & 1 deletion backend/dops/src/modules/dms/dms.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { IUserJWT } from '../../interface/user-jwt.interface';
import { IDP } from '../../enum/idp.enum';
import { Roles } from '../../decorator/roles.decorator';
import { Role } from '../../enum/roles.enum';
import { getDirectory } from 'src/helper/auth.helper';

@ApiTags('DMS')
@ApiBadRequestResponse({
Expand Down Expand Up @@ -91,6 +92,7 @@ export class DmsController {
file: Express.Multer.File,
): Promise<ReadFileDto> {
const currentUser = request.user as IUserJWT;
const directory = getDirectory(currentUser);
if (currentUser.identity_provider !== IDP.IDIR && !companyId) {
throw new BadRequestException(
'Company Id is manadatory for all IDP but IDIR',
Expand All @@ -100,7 +102,12 @@ export class DmsController {
? createFileDto.fileName
: file.originalname;

return await this.dmsService.create(currentUser, file, companyId);
return await this.dmsService.create(
currentUser,
file,
directory,
companyId,
);
}

@ApiCreatedResponse({
Expand Down Expand Up @@ -136,6 +143,7 @@ export class DmsController {
file: Express.Multer.File,
): Promise<ReadFileDto> {
const currentUser = request.user as IUserJWT;
const directory = getDirectory(currentUser);
if (currentUser.identity_provider !== IDP.IDIR && !companyId) {
throw new BadRequestException(
'Company Id is manadatory for all IDP but IDIR',
Expand All @@ -147,6 +155,7 @@ export class DmsController {

return await this.dmsService.update(
currentUser,
directory,
documentId,
file,
companyId,
Expand Down
15 changes: 15 additions & 0 deletions backend/dops/src/modules/dms/dms.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { S3Service } from '../common/s3.service';
import { Response } from 'express';
import { v4 as uuidv4 } from 'uuid';
import { IDP } from '../../enum/idp.enum';
import { Directory } from 'src/enum/directory.enum';

@Injectable()
export class DmsService {
Expand All @@ -31,6 +32,7 @@ export class DmsService {
async create(
currentUser: IUserJWT,
file: Express.Multer.File | IFile,
directory: Directory,
companyId?: number,
): Promise<ReadFileDto> {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
Expand All @@ -48,6 +50,14 @@ export class DmsService {
fileName: file.filename ? file.filename : file.originalname,
dmsVersionId: dmsVersionId,
companyId: companyId,
createdDateTime: new Date(),
createdUser: currentUser.userName,
createdUserDirectory: directory,
createdUserGuid: currentUser.userGUID,
updatedUser: currentUser.userName,
updatedDateTime: new Date(),
updatedUserGuid: currentUser.userGUID,
updatedUserDirectory: directory,
};

return this.classMapper.mapAsync(
Expand All @@ -59,6 +69,7 @@ export class DmsService {

async update(
currentUser: IUserJWT,
directory: Directory,
documentId: string,
file: Express.Multer.File,
companyId?: number,
Expand Down Expand Up @@ -86,6 +97,10 @@ export class DmsService {
fileName: file.filename,
dmsVersionId: dmsObject.dmsVersionId + 1,
companyId: companyId,
updatedUser: currentUser.userName,
updatedDateTime: new Date(),
updatedUserGuid: currentUser.userGUID,
updatedUserDirectory: directory,
};

return this.classMapper.mapAsync(
Expand Down
29 changes: 25 additions & 4 deletions backend/dops/src/modules/dms/dto/base.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@ import { AutoMap } from '@automapper/classes';
import { ApiProperty } from '@nestjs/swagger';

export class BaseDto {
@AutoMap()
@ApiProperty({ example: '1', description: 'Concurrency Control Number' })
concurrencyControlNumber: number;

@AutoMap()
@ApiProperty({
description: 'Created by',
example: 'user1',
})
createdUser: string;

@AutoMap()
@ApiProperty({ description: 'Created User Directory', example: 'user1' })
createdUserDirectory: string;

@AutoMap()
@ApiProperty({
description: 'Created User GUID',
example: '06267945F2EB4E31B585932F78B76269',
})
createdUserGuid: string;

@AutoMap()
@ApiProperty({
description: 'Created Date and Time',
Expand All @@ -26,6 +33,20 @@ export class BaseDto {
})
updatedUser: string;

@AutoMap()
@ApiProperty({
description: 'Updated User Directory',
example: 'user1',
})
updatedUserDirectory: string;

@AutoMap()
@ApiProperty({
description: 'Updated User GUID',
example: '06267945F2EB4E31B585932F78B76269',
})
updatedUserGuid: string;

@AutoMap()
@ApiProperty({
description: 'Updated Date and Time',
Expand Down
4 changes: 2 additions & 2 deletions backend/vehicles/src/common/helper/paginate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export async function paginate<T, CustomMetaType = IPaginationMeta>(
}

function resolveOptions(
options: IPaginationOptions<any>,
options: IPaginationOptions<unknown>,
): [number, number, PaginationTypeEnum, boolean, TypeORMCacheType] {
const page = resolveNumericOption(options, 'page', DEFAULT_PAGE);
const limit = resolveNumericOption(options, 'limit', DEFAULT_LIMIT);
Expand All @@ -48,7 +48,7 @@ function resolveOptions(
}

function resolveNumericOption(
options: IPaginationOptions<any>,
options: IPaginationOptions<unknown>,
key: 'page' | 'limit',
defaultValue: number,
): number {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export type TypeORMCacheType =
| boolean
| number
| {
id: any;
id: unknown;
milliseconds: number;
};

Expand Down
29 changes: 25 additions & 4 deletions backend/vehicles/src/modules/common/dto/base.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@ import { AutoMap } from '@automapper/classes';
import { ApiProperty } from '@nestjs/swagger';

export class BaseDto {
@AutoMap()
@ApiProperty({ example: '1', description: 'Concurrency Control Number' })
concurrencyControlNumber: number;

@AutoMap()
@ApiProperty({
description: 'Created by',
example: 'user1',
})
createdUser: string;

@AutoMap()
@ApiProperty({ description: 'Created User Directory', example: 'user1' })
createdUserDirectory: string;

@AutoMap()
@ApiProperty({
description: 'Created User GUID',
example: '06267945F2EB4E31B585932F78B76269',
})
createdUserGuid: string;

@AutoMap()
@ApiProperty({
description: 'Created Date and Time',
Expand All @@ -26,6 +33,20 @@ export class BaseDto {
})
updatedUser: string;

@AutoMap()
@ApiProperty({
description: 'Updated User Directory',
example: 'user1',
})
updatedUserDirectory: string;

@AutoMap()
@ApiProperty({
description: 'Updated User GUID',
example: '06267945F2EB4E31B585932F78B76269',
})
updatedUserGuid: string;

@AutoMap()
@ApiProperty({
description: 'Updated Date and Time',
Expand Down
3 changes: 1 addition & 2 deletions backend/vehicles/src/modules/common/dto/country.dto.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { AutoMap } from '@automapper/classes';
import { ApiProperty } from '@nestjs/swagger';
import { BaseDto } from './base.dto';

export class CountryDto extends BaseDto {
export class CountryDto {
@AutoMap()
@ApiProperty({
example: 'CA',
Expand Down
3 changes: 1 addition & 2 deletions backend/vehicles/src/modules/common/dto/province.dto.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { AutoMap } from '@automapper/classes';
import { ApiProperty } from '@nestjs/swagger';
import { BaseDto } from './base.dto';
import { CountryDto } from './country.dto';

export class ProvinceDto extends BaseDto {
export class ProvinceDto {
@AutoMap()
@ApiProperty({ example: 'BC', description: 'Province Code' })
provinceCode: string;
Expand Down
Loading

0 comments on commit fb56d89

Please sign in to comment.