@@ -10,7 +10,6 @@ import { NoQueryParametersDto } from '@common/api/types/no-query-parameters.dto'
1010import { StorageOverviewDto } from '@common/api/types/storage-overview.dto' ;
1111import { UpdateFile } from '@common/api/types/update-file.dto' ;
1212import env from '@common/environment' ;
13- import { FileType } from '@common/frontend_shared/enum' ;
1413import {
1514 Body ,
1615 Controller ,
@@ -30,7 +29,6 @@ import {
3029 QueryOptionalDate ,
3130 QueryOptionalRecord ,
3231 QueryOptionalString ,
33- QueryOptionalStringArray ,
3432 QueryOptionalUUID ,
3533 QuerySkip ,
3634 QuerySortBy ,
@@ -55,6 +53,8 @@ import {
5553
5654import { CancelFileUploadDto } from '@common/api/types/cancel-file-upload.dto' ;
5755import { FileQueryDto } from '@common/api/types/file/file-query.dto' ;
56+ import FileEntity from '@common/entities/file/file.entity' ;
57+ import { HealthStatus } from '@common/frontend_shared/enum' ;
5858
5959@Controller ( [ 'file' , 'files' ] ) // TODO: migrate to 'files'
6060export class FileController {
@@ -66,7 +66,10 @@ export class FileController {
6666 description : 'Many Files' ,
6767 type : FilesDto ,
6868 } )
69- async getMany ( @Query ( ) query : FileQueryDto , @AddUser ( ) auth : AuthHeader ) {
69+ async getMany (
70+ @Query ( ) query : FileQueryDto ,
71+ @AddUser ( ) auth : AuthHeader ,
72+ ) : Promise < FilesDto > {
7073 return await this . fileService . findMany (
7174 query . projectUuids ?? [ ] ,
7275 query . projectPatterns ?? [ ] ,
@@ -110,20 +113,26 @@ export class FileController {
110113 topics : string ,
111114 @QueryOptionalString (
112115 'fileTypes' ,
113- "Filetypes: 'bag' | 'mcap' | 'bag,mcap' " ,
116+ 'File types to filter by (coma separated)' ,
114117 )
115118 fileTypes : string ,
119+ @QueryOptionalString (
120+ 'categories' ,
121+ 'Categories to filter by (coma separated)' ,
122+ )
123+ categories : string ,
116124 @QueryBoolean (
117- 'andOr ' ,
125+ 'matchAllTopics ' ,
118126 'Returned File needs all specified topics (true) or any specified topics (false)' ,
119127 )
120- andOr : boolean ,
128+ matchAllTopics : boolean ,
121129 @QueryOptionalRecord ( 'tags' , 'Dictionary Tagtype name to Tag value' )
122130 tags : Record < string , any > ,
123131 @QuerySkip ( 'skip' ) skip : number ,
124132 @QueryTake ( 'take' ) take : number ,
125133 @QuerySortBy ( 'sort' ) sort : string ,
126134 @QuerySortDirection ( 'sortDirection' ) sortDirection : 'ASC' | 'DESC' ,
135+ @QueryOptionalString ( 'health' , 'File health' ) health : HealthStatus ,
127136 @AddUser ( ) auth : AuthHeader ,
128137 ) : Promise < FilesDto > {
129138 let _missionUUID = missionUUID ;
@@ -137,14 +146,16 @@ export class FileController {
137146 startDate ,
138147 endDate ,
139148 topics ,
140- andOr ,
149+ categories ,
150+ matchAllTopics ,
141151 fileTypes ,
142152 tags , // todo check if this is correct
143153 auth . user . uuid ,
144154 Number . parseInt ( String ( take ) ) , // TODO: fix
145155 Number . parseInt ( String ( skip ) ) , // TODO: fix
146156 sort ,
147157 sortDirection ,
158+ health ,
148159 ) ;
149160 }
150161
@@ -158,7 +169,7 @@ export class FileController {
158169 'Whether the download link should stay valid for on week (false) or 4h (true)' ,
159170 )
160171 expires : boolean ,
161- ) {
172+ ) : Promise < string > {
162173 logger . debug ( `download ${ uuid } : expires=${ expires . toString ( ) } ` ) ;
163174 return this . fileService . generateDownload ( uuid , expires ) ;
164175 }
@@ -176,45 +187,13 @@ export class FileController {
176187 return this . fileService . findOne ( uuid ) ;
177188 }
178189
179- @Get ( 'ofMission' )
180- @CanReadMission ( )
181- @ApiOkResponse ( {
182- description : 'Files of a Mission' ,
183- type : FilesDto ,
184- } )
185- async getFilesOfMission (
186- @QueryUUID ( 'uuid' , 'File UUID' ) uuid : string ,
187- @QuerySkip ( 'skip' ) skip : number ,
188- @QueryTake ( 'take' ) take : number ,
189- @QueryOptionalString ( 'filename' , 'Filename filter' ) filename : string ,
190- @QueryOptionalString ( 'fileType' , 'Filetype filter' ) fileType : string ,
191- @QueryOptionalStringArray (
192- 'categories' ,
193- 'Categories to filter by (logical OR)' ,
194- )
195- categories : string [ ] ,
196- @QuerySortBy ( 'sort' ) sort : string ,
197- @QuerySortDirection ( 'sortDirection' ) sortDirection : 'ASC' | 'DESC' ,
198- @QueryOptionalString ( 'health' , 'File health' ) health : string ,
199- ) : Promise < FilesDto > {
200- return this . fileService . findByMission (
201- uuid ,
202- Number . parseInt ( String ( take ) ) , // TODO: fix
203- Number . parseInt ( String ( skip ) ) , // TODO: fix
204- filename ,
205- // TODO: fix the following, it's ugly
206- fileType === '' ? FileType . ALL : ( fileType as FileType ) ,
207- categories ,
208- sort ,
209- sortDirection ,
210- health ,
211- ) ;
212- }
213-
214190 @Put ( ':uuid' )
215191 @CanWriteFile ( )
216192 @OutputDto ( null ) // TODO: type API response
217- async update ( @ParameterUID ( 'uuid' ) uuid : string , @Body ( ) dto : UpdateFile ) {
193+ async update (
194+ @ParameterUID ( 'uuid' ) uuid : string ,
195+ @Body ( ) dto : UpdateFile ,
196+ ) : Promise < FileEntity | null > {
218197 return this . fileService . update ( uuid , dto ) ;
219198 }
220199
@@ -225,7 +204,7 @@ export class FileController {
225204 @BodyUUIDArray ( 'fileUUIDs' , 'List of File UUID to be moved' )
226205 fileUUIDs : string [ ] ,
227206 @BodyUUID ( 'missionUUID' , 'UUID of target Mission' ) missionUUID : string ,
228- ) {
207+ ) : Promise < void > {
229208 return this . fileService . moveFiles ( fileUUIDs , missionUUID ) ;
230209 }
231210
@@ -235,7 +214,7 @@ export class FileController {
235214 async getOneFileByName (
236215 @QueryUUID ( 'uuid' , 'Mission UUID to search in' ) uuid : string ,
237216 @QueryString ( 'filename' , 'Filename searched for' ) name : string ,
238- ) {
217+ ) : Promise < FileEntity | null > {
239218 return this . fileService . findOneByName ( uuid , name ) ;
240219 }
241220
@@ -328,10 +307,9 @@ export class FileController {
328307 @ApiOkResponse ( {
329308 description : 'Resetting Minio tags completed' ,
330309 } )
331- async resetMinioTags ( ) {
310+ async resetMinioTags ( ) : Promise < void > {
332311 logger . debug ( 'Resetting Minio tags' ) ;
333- await this . fileService . renameTags ( env . MINIO_BAG_BUCKET_NAME ) ;
334- await this . fileService . renameTags ( env . MINIO_MCAP_BUCKET_NAME ) ;
312+ await this . fileService . renameTags ( env . MINIO_DATA_BUCKET_NAME ) ;
335313 logger . debug ( 'Resetting Minio tags done' ) ;
336314 }
337315
@@ -340,7 +318,7 @@ export class FileController {
340318 @ApiOkResponse ( {
341319 description : 'Recomputing file sizes completed' ,
342320 } )
343- async recomputeFileSizes ( ) {
321+ async recomputeFileSizes ( ) : Promise < void > {
344322 logger . debug ( 'Recomputing file sizes' ) ;
345323 await this . fileService . recomputeFileSizes ( ) ;
346324 logger . debug ( 'Recomputing file sizes done' ) ;
0 commit comments