From ad715285c61b2bb59e0fcedebaa027c314a96b90 Mon Sep 17 00:00:00 2001 From: "makabe.t" Date: Wed, 13 Dec 2023 08:27:00 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20613:=20=E5=A4=96=E9=83=A8?= =?UTF-8?q?=E9=80=A3=E6=90=BAAPI=E3=81=AE=E3=83=90=E3=83=AA=E3=83=87?= =?UTF-8?q?=E3=83=BC=E3=82=BF=E8=A6=8B=E7=9B=B4=E3=81=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task3279: files配下APIの対応](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3279) - 外部連携API(以下のAPIが対象)のバリデータを修正しました。 - ~~音声ファイルアップロード要求API~~ - ~~GET /files/audio/upload-location~~ - 音声ファイルアップロード完了API(タスク追加API) - POST /files/audio/upload-finished - タスクチェックアウトAPI - POST /tasks/{audioFileId}/checkout - タスクペンディングAPI - POST /tasks/{audioFileId}/suspend - タスクキャンセルAPI - POST /tasks/{audioFileId}/cancel - タスクチェックインAPI - POST /tasks/{audioFileId}/checkin - 音声ファイルダウンロード先取得API - GET /files/audio/download-location - テンプレートファイルダウンロード先要求API - GET /files/template/download-location - 次ファイル情報取得要求API - GET /tasks/next - 認証情報作成API - POST /auth/token - 通知登録API - POST /notification/register ## レビューポイント - 対象APIに漏れはないでしょうか。 - バリデータの制約は適切でしょうか? ## UIの変更 - なし ## 動作確認状況 - ローカルで確認 --- .../src/features/accounts/types/types.ts | 18 ++++----- .../src/features/auth/types/types.ts | 6 ++- .../src/features/files/types/types.ts | 39 ++++++++++++++++++- .../src/features/notification/types/types.ts | 4 +- .../src/features/tasks/types/types.ts | 3 +- .../src/features/workflows/types/types.ts | 16 ++++---- 6 files changed, 63 insertions(+), 23 deletions(-) diff --git a/dictation_server/src/features/accounts/types/types.ts b/dictation_server/src/features/accounts/types/types.ts index 6e45d8e..c587255 100644 --- a/dictation_server/src/features/accounts/types/types.ts +++ b/dictation_server/src/features/accounts/types/types.ts @@ -184,7 +184,7 @@ export class GetTypistGroupRequest { @ApiProperty() @Type(() => Number) @IsInt() - @Min(0) + @Min(1) typistGroupId: number; } export class GetTypistGroupResponse { @@ -203,7 +203,7 @@ export class CreateTypistGroupRequest { @ArrayMinSize(1) @IsArray() @IsInt({ each: true }) - @Min(0, { each: true }) + @Min(1, { each: true }) @IsUnique() typistIds: number[]; } @@ -219,7 +219,7 @@ export class UpdateTypistGroupRequest { @ArrayMinSize(1) @IsArray() @IsInt({ each: true }) - @Min(0, { each: true }) + @Min(1, { each: true }) @IsUnique() typistIds: number[]; } @@ -227,7 +227,7 @@ export class UpdateTypistGroupRequestParam { @ApiProperty() @Type(() => Number) @IsInt() - @Min(0) + @Min(1) typistGroupId: number; } export class UpdateTypistGroupResponse {} @@ -463,7 +463,7 @@ export class GetOptionItemsRequestParam { @ApiProperty({ description: 'Worktypeの内部ID' }) @Type(() => Number) @IsInt() - @Min(0) + @Min(1) id: number; } @@ -487,7 +487,7 @@ export class UpdateOptionItemsRequestParam { @ApiProperty({ description: 'Worktypeの内部ID' }) @Type(() => Number) @IsInt() - @Min(0) + @Min(1) id: number; } @@ -495,7 +495,7 @@ export class UpdateWorktypeRequestParam { @ApiProperty({ description: 'Worktypeの内部ID' }) @Type(() => Number) @IsInt() - @Min(0) + @Min(1) id: number; } @@ -503,7 +503,7 @@ export class DeleteWorktypeRequestParam { @ApiProperty({ description: 'Worktypeの内部ID' }) @Type(() => Number) @IsInt() - @Min(0) + @Min(1) id: number; } @@ -517,7 +517,7 @@ export class PostActiveWorktypeRequest { @IsOptional() @Type(() => Number) @IsInt() - @Min(0) + @Min(1) id?: number; } diff --git a/dictation_server/src/features/auth/types/types.ts b/dictation_server/src/features/auth/types/types.ts index c031508..023a982 100644 --- a/dictation_server/src/features/auth/types/types.ts +++ b/dictation_server/src/features/auth/types/types.ts @@ -1,10 +1,14 @@ import { ApiProperty } from '@nestjs/swagger'; -import { IsInt } from 'class-validator'; +import { IsIn, IsInt, IsNotEmpty, IsString } from 'class-validator'; export class TokenRequest { @ApiProperty() + @IsString() + @IsNotEmpty() idToken: string; @ApiProperty({ description: 'web or mobile or desktop' }) + @IsIn(['web', 'mobile', 'desktop'], { message: 'invalid type' }) + @IsNotEmpty() type: string; } export class TokenResponse { diff --git a/dictation_server/src/features/files/types/types.ts b/dictation_server/src/features/files/types/types.ts index 2fda838..3545a20 100644 --- a/dictation_server/src/features/files/types/types.ts +++ b/dictation_server/src/features/files/types/types.ts @@ -1,6 +1,17 @@ import { ApiProperty } from '@nestjs/swagger'; import { Type } from 'class-transformer'; -import { IsInt, Min } from 'class-validator'; +import { + ArrayMaxSize, + ArrayMinSize, + IsArray, + IsIn, + IsInt, + IsNotEmpty, + IsNumberString, + MaxLength, + Min, + MinLength, +} from 'class-validator'; export class AudioUploadLocationRequest {} @@ -13,6 +24,9 @@ export class AudioUploadLocationResponse { export class AudioDownloadLocationRequest { @ApiProperty({ description: 'ODMSCloud上で管理する音声ファイルのID' }) + @Type(() => Number) + @Min(1) + @IsInt() audioFileId: number; } @@ -26,7 +40,7 @@ export class AudioDownloadLocationResponse { export class TemplateDownloadLocationRequest { @ApiProperty({ description: '文字起こし対象の音声ファイルID' }) @Type(() => Number) - @Min(0) + @Min(1) @IsInt() audioFileId: number; } @@ -43,40 +57,58 @@ export class TemplateUploadLocationResponse { export class AudioOptionItem { @ApiProperty({ minLength: 1, maxLength: 16 }) + @MinLength(1) + @MaxLength(16) optionItemLabel: string; @ApiProperty({ minLength: 1, maxLength: 20 }) + @MinLength(1) + @MaxLength(20) optionItemValue: string; } export class AudioUploadFinishedRequest { @ApiProperty({ description: 'アップロード先Blob Storage(ファイル名含む)' }) + @IsNotEmpty() url: string; @ApiProperty({ description: '自分自身(ログイン認証)したAuthorID' }) + @IsNotEmpty() authorId: string; @ApiProperty({ description: '音声ファイル名' }) + @IsNotEmpty() fileName: string; @ApiProperty({ description: '音声ファイルの録音時間(ミリ秒の整数値)', }) + @IsNumberString() + @IsNotEmpty() duration: string; @ApiProperty({ description: '音声ファイルの録音作成日時(開始日時)(yyyy-mm-ddThh:mm:ss.sss)', }) + @IsNotEmpty() createdDate: string; @ApiProperty({ description: '音声ファイルの録音作成終了日時(yyyy-mm-ddThh:mm:ss.sss)', }) + @IsNotEmpty() finishedDate: string; @ApiProperty({ description: '音声ファイルのアップロード日時(yyyy-mm-ddThh:mm:ss.sss)', }) + @IsNotEmpty() uploadedDate: string; @ApiProperty({ description: '音声ファイルのファイルサイズ(Byte)' }) + @Type(() => Number) + @IsInt() + @IsNotEmpty() fileSize: number; @ApiProperty({ description: '優先度 "00":Normal / "01":High' }) + @IsIn(['00', '01'], { message: 'invalid priority' }) + @IsNotEmpty() priority: string; @ApiProperty({ description: '録音形式: DSS/DS2(SP)/DS2(QP)' }) + @IsNotEmpty() audioFormat: string; @ApiProperty() comment: string; @@ -88,6 +120,9 @@ export class AudioUploadFinishedRequest { minItems: 10, description: '音声ファイルに紐づくOption Itemの一覧(10個固定)', }) + @IsArray() + @ArrayMinSize(10) + @ArrayMaxSize(10) optionItemList: AudioOptionItem[]; @ApiProperty() isEncrypted: boolean; diff --git a/dictation_server/src/features/notification/types/types.ts b/dictation_server/src/features/notification/types/types.ts index b19bf08..433ea59 100644 --- a/dictation_server/src/features/notification/types/types.ts +++ b/dictation_server/src/features/notification/types/types.ts @@ -1,5 +1,5 @@ import { ApiProperty } from '@nestjs/swagger'; -import { IsIn } from 'class-validator'; +import { IsIn, IsNotEmpty, IsString } from 'class-validator'; import { PNS } from '../../../constants'; export class RegisterRequest { @@ -9,6 +9,8 @@ export class RegisterRequest { }) pns: string; @ApiProperty({ description: 'wnsのチャネルURI or apnsのデバイストークン' }) + @IsString() + @IsNotEmpty() handler: string; } diff --git a/dictation_server/src/features/tasks/types/types.ts b/dictation_server/src/features/tasks/types/types.ts index 80cff57..69b7c1d 100644 --- a/dictation_server/src/features/tasks/types/types.ts +++ b/dictation_server/src/features/tasks/types/types.ts @@ -22,7 +22,6 @@ export class TasksRequest { }) @IsInt() @Min(0) - @Type(() => Number) @IsOptional() @Type(() => Number) limit: number; @@ -35,7 +34,6 @@ export class TasksRequest { }) @IsInt() @Min(0) - @Type(() => Number) @IsOptional() @Type(() => Number) offset: number; @@ -192,6 +190,7 @@ export class AudioNextRequest { @ApiProperty({ description: '文字起こし完了したタスクの音声ファイルID' }) @Type(() => Number) @IsInt() + @Min(1) endedFileId: number; } diff --git a/dictation_server/src/features/workflows/types/types.ts b/dictation_server/src/features/workflows/types/types.ts index 87f77c0..e3e34df 100644 --- a/dictation_server/src/features/workflows/types/types.ts +++ b/dictation_server/src/features/workflows/types/types.ts @@ -53,19 +53,19 @@ export class CreateWorkflowsRequest { @ApiProperty({ description: 'Authorの内部ID' }) @Type(() => Number) @IsInt() - @Min(0) + @Min(1) authorId: number; @ApiProperty({ description: 'Worktypeの内部ID', required: false }) @IsOptional() @Type(() => Number) @IsInt() - @Min(0) + @Min(1) worktypeId?: number; @ApiProperty({ description: 'テンプレートの内部ID', required: false }) @IsOptional() @Type(() => Number) @IsInt() - @Min(0) + @Min(1) templateId?: number; @ApiProperty({ description: 'ルーティング候補のタイピストユーザー/タイピストグループ', @@ -84,7 +84,7 @@ export class UpdateWorkflowRequestParam { @ApiProperty({ description: 'ワークフローの内部ID' }) @Type(() => Number) @IsInt() - @Min(0) + @Min(1) workflowId: number; } @@ -92,19 +92,19 @@ export class UpdateWorkflowRequest { @ApiProperty({ description: 'Authorの内部ID' }) @Type(() => Number) @IsInt() - @Min(0) + @Min(1) authorId: number; @ApiProperty({ description: 'Worktypeの内部ID', required: false }) @IsOptional() @Type(() => Number) @IsInt() - @Min(0) + @Min(1) worktypeId?: number; @ApiProperty({ description: 'テンプレートの内部ID', required: false }) @IsOptional() @Type(() => Number) @IsInt() - @Min(0) + @Min(1) templateId?: number; @ApiProperty({ description: 'ルーティング候補のタイピストユーザー/タイピストグループ', @@ -123,7 +123,7 @@ export class DeleteWorkflowRequestParam { @ApiProperty({ description: 'ワークフローの内部ID' }) @Type(() => Number) @IsInt() - @Min(0) + @Min(1) workflowId: number; }