-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: quick refactor for soft removal entities
- Loading branch information
1 parent
611f6f2
commit 423a8ca
Showing
20 changed files
with
234 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,45 @@ | ||
import { ApiPropertyOptional } from "@nestjs/swagger"; | ||
import { IsEnum, IsOptional } from "class-validator"; | ||
import { ITimeLogFilters, TimeLogSourceEnum, TimeLogType } from "@gauzy/contracts"; | ||
import { IsBetweenActivty } from "./../../shared/validators"; | ||
import { ApiPropertyOptional } from '@nestjs/swagger'; | ||
import { Type } from 'class-transformer'; | ||
import { IsEnum, IsOptional } from 'class-validator'; | ||
import { ITimeLogFilters, TimeLogSourceEnum, TimeLogType } from '@gauzy/contracts'; | ||
import { IsBetweenActivty } from './../../shared/validators'; | ||
|
||
/** | ||
* Get filters common request DTO validation | ||
* Data Transfer Object for filtering time logs based on source, log type, and activity level. | ||
* This DTO provides optional filters to refine time log queries. | ||
*/ | ||
export class FiltersQueryDTO implements ITimeLogFilters { | ||
/** | ||
* Filters time logs by their source. | ||
* Can include multiple sources like Desktop, Web, or Mobile. | ||
* If not provided, no filtering by source will be applied. | ||
*/ | ||
@ApiPropertyOptional({ enum: TimeLogSourceEnum }) | ||
@IsOptional() | ||
@IsEnum(TimeLogSourceEnum, { each: true }) | ||
source: TimeLogSourceEnum[]; | ||
|
||
@ApiPropertyOptional({ enum: TimeLogSourceEnum }) | ||
@IsOptional() | ||
@IsEnum(TimeLogSourceEnum, { each: true }) | ||
readonly source: TimeLogSourceEnum[]; | ||
/** | ||
* Filters time logs by their log type (Manual, Tracked, etc.). | ||
* Multiple log types can be specified. | ||
* If not provided, no filtering by log type will be applied. | ||
*/ | ||
@ApiPropertyOptional({ enum: TimeLogType }) | ||
@IsOptional() | ||
@IsEnum(TimeLogType, { each: true }) | ||
logType: TimeLogType[]; | ||
|
||
@ApiPropertyOptional({ enum: TimeLogType }) | ||
@IsOptional() | ||
@IsEnum(TimeLogType, { each: true }) | ||
readonly logType: TimeLogType[]; | ||
|
||
@ApiPropertyOptional({ type: () => 'object' }) | ||
@IsOptional() | ||
@IsBetweenActivty(FiltersQueryDTO, (it) => it.activityLevel) | ||
readonly activityLevel: { | ||
start: number; | ||
end: number; | ||
}; | ||
/** | ||
* Filters time logs by activity level, specifying a range between `start` and `end`. | ||
* This filter limits logs to a specific activity range (e.g., from 10% to 90% activity). | ||
* If not provided, no filtering by activity level will be applied. | ||
*/ | ||
@ApiPropertyOptional({ type: () => Object }) | ||
@IsOptional() | ||
@IsBetweenActivty(FiltersQueryDTO, (it) => it.activityLevel) | ||
@Type(() => Object) | ||
activityLevel: { | ||
start: number; | ||
end: number; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
import { ApiPropertyOptional } from "@nestjs/swagger"; | ||
import { Transform, TransformFnParams } from "class-transformer"; | ||
import { IsArray, IsOptional } from "class-validator"; | ||
import { IBaseRelationsEntityModel } from "@gauzy/contracts"; | ||
import { ApiPropertyOptional } from '@nestjs/swagger'; | ||
import { Transform, TransformFnParams } from 'class-transformer'; | ||
import { IsArray, IsOptional } from 'class-validator'; | ||
import { IBaseRelationsEntityModel } from '@gauzy/contracts'; | ||
|
||
/** | ||
* Get relations request DTO validation | ||
*/ | ||
export class RelationsQueryDTO implements IBaseRelationsEntityModel { | ||
|
||
@ApiPropertyOptional({ type: () => Array, isArray: true }) | ||
@IsOptional() | ||
@IsArray() | ||
@Transform(({ value }: TransformFnParams) => (value) ? value.map((element: string) => element.trim()) : []) | ||
readonly relations: string[] = []; | ||
@ApiPropertyOptional({ type: () => Array, isArray: true }) | ||
@IsOptional() | ||
@IsArray() | ||
@Transform(({ value }: TransformFnParams) => (value ? value.map((element: string) => element.trim()) : [])) | ||
readonly relations: string[] = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,42 @@ | ||
import { ApiPropertyOptional } from '@nestjs/swagger'; | ||
import { IsOptional, IsArray } from 'class-validator'; | ||
import { ITimeLogFilters } from '@gauzy/contracts'; | ||
import { ID, ITimeLogFilters } from '@gauzy/contracts'; | ||
import { DateRangeQueryDTO } from './date-range-query.dto'; | ||
|
||
/** | ||
* Get selectors common request DTO validation. | ||
* Extends DateRangeQueryDTO to include date range filters. | ||
*/ | ||
export class SelectorsQueryDTO extends DateRangeQueryDTO implements ITimeLogFilters { | ||
/** | ||
* An array of employee IDs for filtering time logs. | ||
*/ | ||
@ApiPropertyOptional({ type: () => Array, isArray: true }) | ||
@IsOptional() | ||
@IsArray() | ||
employeeIds: ID[]; | ||
|
||
/** | ||
* An array of employee IDs for filtering time logs. | ||
*/ | ||
@ApiPropertyOptional({ type: () => Array, isArray: true }) | ||
@IsOptional() | ||
@IsArray() | ||
readonly employeeIds: string[]; | ||
/** | ||
* An array of project IDs for filtering time logs. | ||
*/ | ||
@ApiPropertyOptional({ type: () => Array, isArray: true }) | ||
@IsOptional() | ||
@IsArray() | ||
projectIds: ID[]; | ||
|
||
/** | ||
* An array of project IDs for filtering time logs. | ||
*/ | ||
@ApiPropertyOptional({ type: () => Array, isArray: true }) | ||
@IsOptional() | ||
@IsArray() | ||
readonly projectIds: string[]; | ||
/** | ||
* An array of task IDs for filtering time logs. | ||
*/ | ||
@ApiPropertyOptional({ type: () => Array, isArray: true }) | ||
@IsOptional() | ||
@IsArray() | ||
taskIds: ID[]; | ||
|
||
/** | ||
* An array of task IDs for filtering time logs. | ||
*/ | ||
@ApiPropertyOptional({ type: () => Array, isArray: true }) | ||
@IsOptional() | ||
@IsArray() | ||
readonly taskIds: string[]; | ||
|
||
/** | ||
* An array of team IDs for filtering time logs. | ||
*/ | ||
@ApiPropertyOptional({ type: () => Array, isArray: true }) | ||
@IsOptional() | ||
@IsArray() | ||
readonly teamIds: string[]; | ||
/** | ||
* An array of team IDs for filtering time logs. | ||
*/ | ||
@ApiPropertyOptional({ type: () => Array, isArray: true }) | ||
@IsOptional() | ||
@IsArray() | ||
teamIds: ID[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from './create-time-log.dto'; | ||
export * from './delete-time-log.dto'; | ||
export * from './update-time-log.dto'; | ||
export * from './create-time-log.dto'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 2 additions & 5 deletions
7
packages/core/src/time-tracking/time-slot/commands/update-time-slot-minutes.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
import { ICommand } from '@nestjs/cqrs'; | ||
import { ITimeSlotMinute } from '@gauzy/contracts'; | ||
import { ID, ITimeSlotMinute } from '@gauzy/contracts'; | ||
|
||
export class UpdateTimeSlotMinutesCommand implements ICommand { | ||
static readonly type = '[TimeSlotMinutes] update'; | ||
|
||
constructor( | ||
public readonly id: string, | ||
public readonly input: ITimeSlotMinute | ||
) {} | ||
constructor(public readonly id: ID, public readonly input: ITimeSlotMinute) {} | ||
} |
7 changes: 2 additions & 5 deletions
7
packages/core/src/time-tracking/time-slot/commands/update-time-slot.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
import { ICommand } from '@nestjs/cqrs'; | ||
import { ITimeSlot } from '@gauzy/contracts'; | ||
import { ID, ITimeSlot } from '@gauzy/contracts'; | ||
|
||
export class UpdateTimeSlotCommand implements ICommand { | ||
static readonly type = '[TimeSlot] update'; | ||
|
||
constructor( | ||
public readonly id: string, | ||
public readonly input: ITimeSlot | ||
) {} | ||
constructor(public readonly id: ID, public readonly input: ITimeSlot) {} | ||
} |
19 changes: 5 additions & 14 deletions
19
packages/core/src/time-tracking/time-slot/dto/delete-time-slot.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,15 @@ | ||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; | ||
import { ArrayNotEmpty, IsBoolean, IsOptional } from 'class-validator'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { ArrayNotEmpty } from 'class-validator'; | ||
import { ID, IDeleteTimeSlot } from '@gauzy/contracts'; | ||
import { TenantOrganizationBaseDTO } from '../../../core/dto'; | ||
import { ForceDeleteDTO } from '../../dto/force-delete.dto'; | ||
import { TimeSlot } from '../time-slot.entity'; | ||
|
||
export class DeleteTimeSlotDTO extends TenantOrganizationBaseDTO implements IDeleteTimeSlot { | ||
export class DeleteTimeSlotDTO extends ForceDeleteDTO<TimeSlot> implements IDeleteTimeSlot { | ||
/** | ||
* An array of IDs representing the time slots to be deleted. | ||
* This array must not be empty and ensures that at least one time slot is selected for deletion. | ||
*/ | ||
@ApiProperty({ type: () => Array }) | ||
@ArrayNotEmpty() | ||
readonly ids: ID[] = []; | ||
|
||
/** | ||
* A flag to determine whether to force delete the time logs. | ||
* If `true`, a hard delete will be performed; otherwise, a soft delete is used. | ||
* This field is optional and defaults to `false`. | ||
*/ | ||
@ApiPropertyOptional({ type: () => Boolean }) | ||
@IsOptional() | ||
@IsBoolean() | ||
readonly forceDelete: boolean = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { DeleteTimeSlotDTO } from './delete-time-slot.dto'; | ||
export * from './time-slot-query.dto'; | ||
export * from './delete-time-slot.dto'; |
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
packages/core/src/time-tracking/time-slot/dto/query/time-slot-query.dto.ts
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
packages/core/src/time-tracking/time-slot/dto/time-slot-query.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { IntersectionType } from '@nestjs/swagger'; | ||
import { IGetTimeSlotInput } from '@gauzy/contracts'; | ||
import { FiltersQueryDTO, RelationsQueryDTO, SelectorsQueryDTO } from '../../../shared/dto'; | ||
|
||
/** | ||
* Get time slot request DTO validation | ||
*/ | ||
export class TimeSlotQueryDTO | ||
extends IntersectionType(FiltersQueryDTO, IntersectionType(RelationsQueryDTO, SelectorsQueryDTO)) | ||
implements IGetTimeSlotInput {} |
Oops, something went wrong.