From 95c058265eda1f66fe6b95269d4ecdd528780cba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B9=AF=E6=9C=AC=20=E9=96=8B?= Date: Mon, 25 Dec 2023 05:22:01 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20655:=20=E5=A4=96=E9=83=A8?= =?UTF-8?q?=E9=80=A3=E6=90=BA=E4=BB=A5=E5=A4=96=E3=81=AEAPI=E3=83=90?= =?UTF-8?q?=E3=83=AA=E3=83=87=E3=83=BC=E3=82=BF=E8=A6=8B=E7=9B=B4=E3=81=97?= =?UTF-8?q?(/accounts/*=E4=BB=A5=E5=A4=96)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task3285: 外部連携以外のAPIバリデータ見直し](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3285) - バリデータが不足していた部分について、バリデータを追加 ## レビューポイント - 現行の動きが変更されるようなバリデータが設定されていないか - `AUTHORの時のみ省略不可能` 等のバリデータが設定されているプロパティに関しては、`hogehoge` や `"or ‘1’=’1’"` が設定されたリクエストが来てもバリデータで弾けないが許容可能そうか ## 動作確認状況 - npm run build / npm run test 成功 --- .../src/features/licenses/types/types.ts | 3 +++ .../src/features/tasks/types/types.ts | 1 + .../src/features/users/types/types.ts | 26 ++++++++++++++++++- .../src/features/workflows/types/types.ts | 6 +++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/dictation_server/src/features/licenses/types/types.ts b/dictation_server/src/features/licenses/types/types.ts index e6aced1..39f4f2b 100644 --- a/dictation_server/src/features/licenses/types/types.ts +++ b/dictation_server/src/features/licenses/types/types.ts @@ -6,6 +6,7 @@ import { LICENSE_EXPIRATION_TIME_WITH_TIMEZONE, TRIAL_LICENSE_EXPIRATION_DAYS, } from '../../../constants'; +import { Type } from 'class-transformer'; export class CreateOrdersRequest { @ApiProperty() @@ -13,6 +14,7 @@ export class CreateOrdersRequest { poNumber: string; @ApiProperty() + @Type(() => Number) @IsInt() @Min(1) @Max(9999) @@ -23,6 +25,7 @@ export class CreateOrdersResponse {} export class IssueCardLicensesRequest { @ApiProperty() + @Type(() => Number) @IsInt() @Min(1) @Max(9999) diff --git a/dictation_server/src/features/tasks/types/types.ts b/dictation_server/src/features/tasks/types/types.ts index 69b7c1d..2a6ed96 100644 --- a/dictation_server/src/features/tasks/types/types.ts +++ b/dictation_server/src/features/tasks/types/types.ts @@ -67,6 +67,7 @@ export class TasksRequest { paramName?: string; } +// TODO: RequestでもResponseでも使われているので、Requestに使用される箇所のみバリデータでチェックが行われる状態になっている export class Assignee { @ApiProperty({ required: false, diff --git a/dictation_server/src/features/users/types/types.ts b/dictation_server/src/features/users/types/types.ts index c6bcb75..77ac6c8 100644 --- a/dictation_server/src/features/users/types/types.ts +++ b/dictation_server/src/features/users/types/types.ts @@ -1,5 +1,5 @@ import { ApiProperty } from '@nestjs/swagger'; -import { IsEmail, IsIn } from 'class-validator'; +import { IsBoolean, IsEmail, IsIn, IsInt, MaxLength } from 'class-validator'; import { TASK_LIST_SORTABLE_ATTRIBUTES, USER_LICENSE_STATUS, @@ -10,6 +10,7 @@ import { IsPasswordvalid, } from '../../../common/validators/encryptionPassword.validator'; import { IsRoleAuthorDataValid } from '../../../common/validators/roleAuthor.validator'; +import { Type } from 'class-transformer'; export class ConfirmRequest { @ApiProperty() @@ -92,12 +93,18 @@ export class SignupRequest { email: string; @ApiProperty() + @Type(() => Boolean) + @IsBoolean() autoRenew: boolean; @ApiProperty() + @Type(() => Boolean) + @IsBoolean() licenseAlert: boolean; @ApiProperty() + @Type(() => Boolean) + @IsBoolean() notification: boolean; @ApiProperty({ required: false }) @@ -209,6 +216,8 @@ export class GetSortCriteriaResponse { export class PostUpdateUserRequest { @ApiProperty() + @Type(() => Number) + @IsInt() id: number; @ApiProperty({ description: 'none/author/typist' }) @@ -220,12 +229,18 @@ export class PostUpdateUserRequest { authorId?: string; @ApiProperty() + @Type(() => Boolean) + @IsBoolean() autoRenew: boolean; @ApiProperty() + @Type(() => Boolean) + @IsBoolean() licenseAlart: boolean; @ApiProperty() + @Type(() => Boolean) + @IsBoolean() notification: boolean; @ApiProperty({ required: false }) @@ -245,8 +260,12 @@ export class PostUpdateUserResponse {} export class AllocateLicenseRequest { @ApiProperty({ description: 'ユーザーID' }) + @Type(() => Number) + @IsInt() userId: number; @ApiProperty({ description: '割り当てるライセンスのID' }) + @Type(() => Number) + @IsInt() newLicenseId: number; } @@ -254,6 +273,8 @@ export class AllocateLicenseResponse {} export class DeallocateLicenseRequest { @ApiProperty({ description: 'ユーザーID' }) + @Type(() => Number) + @IsInt() userId: number; } @@ -263,10 +284,13 @@ export class UpdateAcceptedVersionRequest { @ApiProperty({ description: 'IDトークン' }) idToken: string; @ApiProperty({ description: '更新バージョン(EULA)' }) + @MaxLength(255) acceptedEULAVersion: string; @ApiProperty({ description: '更新バージョン(PrivacyNotice)' }) + @MaxLength(255) acceptedPrivacyNoticeVersion: string; @ApiProperty({ description: '更新バージョン(DPA)', required: false }) + @MaxLength(255) acceptedDPAVersion?: string; } diff --git a/dictation_server/src/features/workflows/types/types.ts b/dictation_server/src/features/workflows/types/types.ts index e3e34df..b74056c 100644 --- a/dictation_server/src/features/workflows/types/types.ts +++ b/dictation_server/src/features/workflows/types/types.ts @@ -44,8 +44,14 @@ export class GetWorkflowsResponse { export class WorkflowTypist { @ApiProperty({ description: 'タイピストユーザーの内部ID', required: false }) + @IsOptional() + @IsInt() + @Type(() => Number) typistId?: number; @ApiProperty({ description: 'タイピストグループの内部ID', required: false }) + @IsOptional() + @IsInt() + @Type(() => Number) typistGroupId?: number; }