Skip to content

Commit 4dbf0e5

Browse files
committed
WIP dto correctifs
1 parent 92e4d3f commit 4dbf0e5

32 files changed

+147
-93
lines changed

service/src/_common/dto/parts/idfs.part.dto.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import { IsMimeType, IsOptional, IsString } from 'class-validator'
1+
import { IsMimeType, IsNotEmpty, IsOptional, IsString } from 'class-validator'
22
import { IdnamePartDto } from '~/_common/dto/parts/idname.part.dto'
33
import { ApiProperty } from '@nestjs/swagger'
44

55
export class IdfsPartDto extends IdnamePartDto {
66
@IsString()
7+
@IsNotEmpty()
78
@ApiProperty()
89
public namespace: string
910

1011
@IsString()
12+
@IsNotEmpty()
1113
@ApiProperty()
1214
public path: string
1315

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { IsMongoId, IsString } from 'class-validator'
1+
import { IsMongoId, IsNotEmpty, IsString } from 'class-validator'
22
import { ApiProperty } from '@nestjs/swagger'
33

44
export class IdnamePartDto {
55
@IsMongoId()
6-
@IsString()
76
@ApiProperty()
87
public id: string
98

109
@IsString()
10+
@IsNotEmpty()
1111
@ApiProperty()
1212
public name: string
1313
}

service/src/_common/helpers/pick-projection.helper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export function PickProjectionHelper<T, K extends keyof T>(
77
[key in keyof T]?: number | 1 | 0
88
},
99
): Type<Pick<T, (readonly K[])[number]>> {
10+
//TODO: error in PickType to openapi
1011
const keys = Object.keys(projection).filter((key) => projection[key] === 1)
1112
return PickType(classRef, keys as K[])
1213
}

service/src/core/categories/_dto/categories.dto.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import { ApiProperty, PartialType } from '@nestjs/swagger'
2-
import { IsString, IsNumber, IsOptional, IsBoolean, IsMongoId } from 'class-validator'
2+
import { IsString, IsNumber, IsOptional, IsBoolean, IsMongoId, IsNotEmpty } from 'class-validator'
33
import { AbstractCustomFieldsDto } from '~/_common/abstracts/dto/abstract.custom-fields.dto'
44

55
export class CategoriesCreateDto extends AbstractCustomFieldsDto {
66
@IsString()
7+
@IsNotEmpty()
78
@ApiProperty()
89
public name: string
910

1011
@IsString()
1112
@IsOptional()
1213
@ApiProperty()
13-
public description: string
14+
public description?: string
1415

1516
@IsMongoId()
1617
@IsOptional()
@@ -20,17 +21,17 @@ export class CategoriesCreateDto extends AbstractCustomFieldsDto {
2021
@IsNumber()
2122
@IsOptional()
2223
@ApiProperty()
23-
public order: number
24+
public order?: number
2425

2526
@IsBoolean()
2627
@IsOptional()
2728
@ApiProperty()
28-
public selectable: boolean
29+
public selectable?: boolean
2930

3031
@IsBoolean()
3132
@IsOptional()
3233
@ApiProperty()
33-
public disabled: boolean
34+
public disabled?: boolean
3435

3536
@IsString()
3637
@IsOptional()

service/src/core/categories/categories.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ export class CategoriesController extends AbstractController {
2727
protected static readonly projection: PartialProjectionType<CategoriesDto> = {
2828
name: 1,
2929
parentId: 1,
30-
description: 1,
3130
color: 1,
3231
icon: 1,
32+
disabled: 1,
3333
}
3434

3535
constructor(private readonly _service: CategoriesService) {

service/src/core/crontabs/_dto/crontabs.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class CrontabsCreateDto {
2222
@IsArray()
2323
@ValidateNested({ each: true })
2424
@Type(() => Object)
25-
@ApiProperty()
25+
@ApiProperty({ type: [Object] })
2626
public actions: { [key: string]: any }[]
2727

2828
@IsMongoId()

service/src/core/crontabs/crontabs.controller.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class CrontabsController extends AbstractController {
2626
protected static readonly projection: PartialProjectionType<CrontabsDto> = {
2727
name: 1,
2828
interval: 1,
29+
disabled: 1,
2930
}
3031

3132
public constructor(private readonly _service: CrontabsService) {

service/src/core/entities/_dto/entites.dto.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
11
import { ApiProperty, PartialType } from '@nestjs/swagger'
22
import { AbstractCustomFieldsDto } from '~/_common/abstracts/dto/abstract.custom-fields.dto'
33
import { Type } from 'class-transformer'
4-
import { IsMongoId, IsNotEmpty, IsOptional, IsString, ValidateNested } from 'class-validator'
4+
import { IsEmail, IsEnum, IsMongoId, IsNotEmpty, IsOptional, ValidateNested } from 'class-validator'
55
import { ProfilePartDto } from '~/core/entities/_dto/parts/profile.part.dto'
66
import { StatePartDto } from '~/core/entities/_dto/parts/state.part.dto'
7+
import { EntityType, EntityTypeList } from '~/_common/enum/entity-type.enum'
78

89
export class EntitiesCreateDto extends AbstractCustomFieldsDto {
9-
@IsString()
10+
@IsEmail()
1011
@IsNotEmpty()
1112
@ApiProperty()
1213
public publicEmail: string
1314

15+
@IsEnum(EntityTypeList)
16+
@IsNotEmpty()
17+
@ApiProperty({ enum: EntityTypeList })
18+
public type: EntityType
19+
1420
@ValidateNested()
1521
@Type(() => ProfilePartDto)
1622
@IsNotEmpty()
17-
@ApiProperty()
23+
@ApiProperty({ type: ProfilePartDto })
1824
public profile: ProfilePartDto
1925

2026
@ValidateNested()
2127
@Type(() => StatePartDto)
2228
@IsOptional()
23-
@ApiProperty()
29+
@ApiProperty({ type: StatePartDto })
2430
public state?: StatePartDto
2531
}
2632

service/src/core/entities/_dto/parts/phone.part.dto.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export class PhonePartDto {
88
@ApiProperty({ enum: PhoneTypeList })
99
public type: PhoneType
1010

11-
@IsString()
1211
@IsPhoneNumber()
1312
@IsNotEmpty()
1413
@ApiProperty()

service/src/core/entities/_enum/entity-type.enum.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)