| 
									
										
										
										
											2023-11-16 16:38:15 +01:00
										 |  |  | import { errors } from '@strapi/utils'; | 
					
						
							| 
									
										
										
										
											2023-11-21 18:12:49 +01:00
										 |  |  | import { Entity } from '@strapi/types'; | 
					
						
							| 
									
										
										
										
											2023-11-16 16:38:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 18:12:49 +01:00
										 |  |  | export type ApiToken = { | 
					
						
							|  |  |  |   accessKey: string; | 
					
						
							|  |  |  |   createdAt: string; | 
					
						
							|  |  |  |   description: string; | 
					
						
							|  |  |  |   expiresAt: string; | 
					
						
							|  |  |  |   id: Entity.ID; | 
					
						
							|  |  |  |   lastUsedAt: string | null; | 
					
						
							| 
									
										
										
										
											2024-02-29 14:32:37 +01:00
										 |  |  |   lifespan: string | number | null; | 
					
						
							| 
									
										
										
										
											2023-11-21 18:12:49 +01:00
										 |  |  |   name: string; | 
					
						
							|  |  |  |   permissions: string[]; | 
					
						
							|  |  |  |   type: 'custom' | 'full-access' | 'read-only'; | 
					
						
							|  |  |  |   updatedAt: string; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2023-11-16 16:38:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 18:12:49 +01:00
										 |  |  | export interface ApiTokenBody extends Pick<ApiToken, 'description' | 'name'> { | 
					
						
							|  |  |  |   lifespan?: ApiToken['lifespan'] | null; | 
					
						
							|  |  |  |   permissions?: ApiToken['permissions'] | null; | 
					
						
							|  |  |  |   type: ApiToken['type'] | undefined; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-11-16 16:38:15 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * POST /api-tokens - Create an api token | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export declare namespace Create { | 
					
						
							|  |  |  |   export interface Request { | 
					
						
							|  |  |  |     body: ApiTokenBody; | 
					
						
							|  |  |  |     query: {}; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   export interface Response { | 
					
						
							|  |  |  |     data: ApiToken; | 
					
						
							|  |  |  |     error?: errors.ApplicationError | errors.YupValidationError; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * GET /api-tokens - List api tokens | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export declare namespace List { | 
					
						
							|  |  |  |   export interface Request { | 
					
						
							|  |  |  |     body: {}; | 
					
						
							|  |  |  |     query: {}; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   export interface Response { | 
					
						
							| 
									
										
										
										
											2023-11-21 18:12:49 +01:00
										 |  |  |     data: ApiToken[]; | 
					
						
							| 
									
										
										
										
											2023-11-16 16:38:15 +01:00
										 |  |  |     error?: errors.ApplicationError; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * DELETE /api-tokens/:id - Delete an API token | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export declare namespace Revoke { | 
					
						
							|  |  |  |   export interface Request { | 
					
						
							|  |  |  |     body: {}; | 
					
						
							|  |  |  |     query: {}; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   export interface Params { | 
					
						
							| 
									
										
										
										
											2024-01-02 17:01:58 +00:00
										 |  |  |     id: Entity.ID; | 
					
						
							| 
									
										
										
										
											2023-11-16 16:38:15 +01:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   export interface Response { | 
					
						
							| 
									
										
										
										
											2023-11-21 18:12:49 +01:00
										 |  |  |     data: ApiToken; | 
					
						
							| 
									
										
										
										
											2023-11-16 16:38:15 +01:00
										 |  |  |     error?: errors.ApplicationError; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * GET /api-tokens/:id - Get an API token | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export declare namespace Get { | 
					
						
							|  |  |  |   export interface Request { | 
					
						
							|  |  |  |     body: {}; | 
					
						
							|  |  |  |     query: {}; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   export interface Params { | 
					
						
							| 
									
										
										
										
											2024-01-02 17:01:58 +00:00
										 |  |  |     id: Entity.ID; | 
					
						
							| 
									
										
										
										
											2023-11-16 16:38:15 +01:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   export interface Response { | 
					
						
							| 
									
										
										
										
											2023-11-21 18:12:49 +01:00
										 |  |  |     data: ApiToken; | 
					
						
							| 
									
										
										
										
											2023-11-16 16:38:15 +01:00
										 |  |  |     error?: errors.ApplicationError; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * POST /api-tokens/:id - Update an API token | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export declare namespace Update { | 
					
						
							|  |  |  |   export interface Request { | 
					
						
							|  |  |  |     body: ApiTokenBody; | 
					
						
							|  |  |  |     query: {}; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   export interface Params { | 
					
						
							| 
									
										
										
										
											2024-01-02 17:01:58 +00:00
										 |  |  |     id: Entity.ID; | 
					
						
							| 
									
										
										
										
											2023-11-16 16:38:15 +01:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   export interface Response { | 
					
						
							| 
									
										
										
										
											2023-11-21 18:12:49 +01:00
										 |  |  |     data: ApiToken; | 
					
						
							| 
									
										
										
										
											2023-11-16 16:38:15 +01:00
										 |  |  |     error?: errors.ApplicationError | errors.YupValidationError; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |