| 
									
										
										
										
											2024-09-26 11:51:07 +02:00
										 |  |  | import { errors } from '@strapi/utils'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type SortOrder = 'ASC' | 'DESC'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-07 09:29:08 +02:00
										 |  |  | type SortKey = 'createdAt' | 'name' | 'updatedAt'; | 
					
						
							| 
									
										
										
										
											2024-09-26 11:51:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-04 16:57:43 +02:00
										 |  |  | // Abstract type for comparison operators where the keys are generic strings
 | 
					
						
							|  |  |  | type ComparisonOperators<T> = { | 
					
						
							|  |  |  |   [operator: string]: T | T[] | boolean; // Any string can be used as an operator key
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Abstract type for filter conditions with dynamic field names
 | 
					
						
							|  |  |  | export type FilterCondition<T> = { | 
					
						
							|  |  |  |   [field: string]: T | ComparisonOperators<T> | FilterCondition<T>; // Field names are dynamic and values are comparison operators
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Abstract type for filters where the logical operator (like $and) is a generic string
 | 
					
						
							|  |  |  | type Filters<T> = { | 
					
						
							|  |  |  |   [logicOperator: string]: FilterCondition<T>[]; // Logical operator key is a generic string
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type Query = { | 
					
						
							|  |  |  |   _q?: string; | 
					
						
							|  |  |  |   folderPath?: string; | 
					
						
							|  |  |  |   folder?: | 
					
						
							|  |  |  |     | null | 
					
						
							|  |  |  |     | number | 
					
						
							|  |  |  |     | { | 
					
						
							|  |  |  |         id: number; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |   page?: | 
					
						
							|  |  |  |     | string | 
					
						
							|  |  |  |     | number | 
					
						
							|  |  |  |     | { | 
					
						
							|  |  |  |         id: string | number; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |   pageSize?: string | number; | 
					
						
							|  |  |  |   pagination?: { | 
					
						
							|  |  |  |     pageSize: number; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  |   sort?: `${SortKey}:${SortOrder}`; | 
					
						
							|  |  |  |   filters?: Filters<string | number | boolean>; | 
					
						
							|  |  |  |   state?: boolean; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type FileFormat = { | 
					
						
							|  |  |  |   name: string; | 
					
						
							|  |  |  |   hash: string; | 
					
						
							|  |  |  |   ext: string; | 
					
						
							|  |  |  |   mime: string; | 
					
						
							|  |  |  |   path: null | string; | 
					
						
							|  |  |  |   width: number; | 
					
						
							|  |  |  |   height: number; | 
					
						
							|  |  |  |   size: number; | 
					
						
							|  |  |  |   sizeInBytes: number; | 
					
						
							|  |  |  |   url: string; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-26 11:51:07 +02:00
										 |  |  | export interface File { | 
					
						
							|  |  |  |   id: number; | 
					
						
							|  |  |  |   name: string; | 
					
						
							|  |  |  |   alternativeText?: string | null; | 
					
						
							|  |  |  |   caption?: string | null; | 
					
						
							| 
									
										
										
										
											2024-10-31 10:00:13 +01:00
										 |  |  |   width?: number | null; | 
					
						
							|  |  |  |   height?: number | null; | 
					
						
							|  |  |  |   formats?: | 
					
						
							|  |  |  |     | Record<string, FileFormat> | 
					
						
							|  |  |  |     | { | 
					
						
							|  |  |  |         thumbnail: { | 
					
						
							|  |  |  |           url: string; | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     | null; | 
					
						
							| 
									
										
										
										
											2024-09-26 11:51:07 +02:00
										 |  |  |   hash: string; | 
					
						
							|  |  |  |   ext?: string; | 
					
						
							|  |  |  |   mime?: string; | 
					
						
							|  |  |  |   size?: number; | 
					
						
							|  |  |  |   sizeInBytes?: number; | 
					
						
							|  |  |  |   url?: string; | 
					
						
							| 
									
										
										
										
											2024-10-31 10:00:13 +01:00
										 |  |  |   previewUrl?: string | null; | 
					
						
							| 
									
										
										
										
											2024-09-26 11:51:07 +02:00
										 |  |  |   path?: string | null; | 
					
						
							|  |  |  |   provider?: string; | 
					
						
							| 
									
										
										
										
											2024-10-31 10:00:13 +01:00
										 |  |  |   provider_metadata?: Record<string, unknown> | null; | 
					
						
							| 
									
										
										
										
											2024-09-26 11:51:07 +02:00
										 |  |  |   isUrlSigned?: boolean; | 
					
						
							| 
									
										
										
										
											2024-10-31 10:00:13 +01:00
										 |  |  |   folder?: number | string | null; | 
					
						
							| 
									
										
										
										
											2024-09-26 11:51:07 +02:00
										 |  |  |   folderPath?: string; | 
					
						
							|  |  |  |   related?: { | 
					
						
							|  |  |  |     id: string | number; | 
					
						
							|  |  |  |     __type: string; | 
					
						
							|  |  |  |     __pivot: { field: string }; | 
					
						
							|  |  |  |   }[]; | 
					
						
							|  |  |  |   createdAt?: string; | 
					
						
							|  |  |  |   updatedAt?: string; | 
					
						
							|  |  |  |   createdBy?: number; | 
					
						
							| 
									
										
										
										
											2024-10-04 16:57:43 +02:00
										 |  |  |   publishedAt?: string; | 
					
						
							| 
									
										
										
										
											2024-09-26 11:51:07 +02:00
										 |  |  |   updatedBy?: number; | 
					
						
							| 
									
										
										
										
											2024-10-04 16:57:43 +02:00
										 |  |  |   isLocal?: boolean; | 
					
						
							| 
									
										
										
										
											2024-09-26 11:51:07 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export interface RawFile extends Blob { | 
					
						
							|  |  |  |   size: number; | 
					
						
							|  |  |  |   lastModified: number; | 
					
						
							|  |  |  |   name: string; | 
					
						
							|  |  |  |   type: string; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export interface Pagination { | 
					
						
							|  |  |  |   page: number; | 
					
						
							|  |  |  |   pageSize: number; | 
					
						
							|  |  |  |   pageCount: number; | 
					
						
							|  |  |  |   total: number; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-04 16:57:43 +02:00
										 |  |  | /** | 
					
						
							|  |  |  |  * GET /upload/files - Get files | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2024-09-26 11:51:07 +02:00
										 |  |  | export declare namespace GetFiles { | 
					
						
							|  |  |  |   export interface Request { | 
					
						
							|  |  |  |     body: {}; | 
					
						
							|  |  |  |     query: { | 
					
						
							|  |  |  |       page?: string; | 
					
						
							|  |  |  |       pageSize?: string; | 
					
						
							|  |  |  |       folder: number | null; | 
					
						
							|  |  |  |       sort?: `${SortKey}:${SortOrder}`; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   export interface Response { | 
					
						
							|  |  |  |     data: { | 
					
						
							|  |  |  |       results: File[]; | 
					
						
							|  |  |  |       pagination: Pagination; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     error?: errors.ApplicationError | errors.NotFoundError; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * GET /upload/files/:id - Get specific file | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export declare namespace GetFile { | 
					
						
							|  |  |  |   export interface Request { | 
					
						
							|  |  |  |     params: { id: number }; | 
					
						
							|  |  |  |     query: {}; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   export interface Response { | 
					
						
							|  |  |  |     data: File; | 
					
						
							|  |  |  |     error?: errors.ApplicationError | errors.NotFoundError; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * POST /upload/actions/bulk-delete - Delete Files | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export declare namespace BulkDeleteFiles { | 
					
						
							|  |  |  |   export interface Request { | 
					
						
							|  |  |  |     body: { | 
					
						
							|  |  |  |       fileIds: number[]; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   export interface Response { | 
					
						
							|  |  |  |     data: { | 
					
						
							|  |  |  |       data: { | 
					
						
							|  |  |  |         files: File[]; | 
					
						
							|  |  |  |         folders: []; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     error?: errors.ApplicationError | errors.ValidationError; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * POST /upload/actions/bulk-move - Move Files | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export declare namespace BulkMoveFiles { | 
					
						
							|  |  |  |   export interface Request { | 
					
						
							|  |  |  |     body: { | 
					
						
							|  |  |  |       fileIds: number[]; | 
					
						
							|  |  |  |       destinationFolderId: number; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   export interface Response { | 
					
						
							|  |  |  |     data: { | 
					
						
							|  |  |  |       data: { | 
					
						
							|  |  |  |         files: File[]; | 
					
						
							|  |  |  |         folders: []; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     error?: errors.ApplicationError | errors.ValidationError; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * DELETE /upload/files/:id - Delete a specific asset | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export declare namespace DeleteFile { | 
					
						
							|  |  |  |   export interface Request { | 
					
						
							|  |  |  |     params: { id: number }; | 
					
						
							|  |  |  |     query: {}; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   export interface Response { | 
					
						
							|  |  |  |     data: File; | 
					
						
							|  |  |  |     error?: errors.ApplicationError | errors.NotFoundError; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * POST /upload - Create a file | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export declare namespace CreateFile { | 
					
						
							|  |  |  |   export interface Request { | 
					
						
							|  |  |  |     body: FormData; | 
					
						
							|  |  |  |     files: File[]; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   export interface Response { | 
					
						
							|  |  |  |     data: File[]; | 
					
						
							|  |  |  |     error?: errors.ApplicationError | errors.ValidationError; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * POST /upload?id=:id - Update asset | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export declare namespace UpdateFile { | 
					
						
							|  |  |  |   export interface Request { | 
					
						
							|  |  |  |     body: FormData; | 
					
						
							|  |  |  |     params: { id: number }; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   export interface Response { | 
					
						
							|  |  |  |     data: File; | 
					
						
							|  |  |  |     error?: errors.ApplicationError | errors.ValidationError; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |