Merged PR 613: 外部連携APIのバリデータ見直し

## 概要
[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の変更
- なし

## 動作確認状況
- ローカルで確認
This commit is contained in:
makabe.t 2023-12-13 08:27:00 +00:00
parent 63892bad83
commit ad715285c6
6 changed files with 63 additions and 23 deletions

View File

@ -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;
}

View File

@ -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 {

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}