| 
									
										
										
										
											2023-11-16 16:38:15 +01:00
										 |  |  | import type { errors } from '@strapi/utils'; | 
					
						
							| 
									
										
										
										
											2024-01-02 17:01:58 +00:00
										 |  |  | import { Entity, Permission } from './shared'; | 
					
						
							| 
									
										
										
										
											2023-11-16 16:38:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 11:40:51 +00:00
										 |  |  | export interface Action { | 
					
						
							|  |  |  |   actionId: string; | 
					
						
							|  |  |  |   applyToProperties: string[]; | 
					
						
							|  |  |  |   label: string; | 
					
						
							|  |  |  |   subjects: string[]; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export interface SubjectProperty { | 
					
						
							|  |  |  |   children?: SubjectProperty[]; | 
					
						
							|  |  |  |   label: string; | 
					
						
							|  |  |  |   required?: boolean; | 
					
						
							|  |  |  |   value: string; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export interface Subject { | 
					
						
							|  |  |  |   label: string; | 
					
						
							|  |  |  |   properties: SubjectProperty[]; | 
					
						
							|  |  |  |   uid: string; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export interface ContentPermission { | 
					
						
							|  |  |  |   actions: Action[]; | 
					
						
							|  |  |  |   subjects: Subject[]; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export interface SettingPermission { | 
					
						
							|  |  |  |   action: string; | 
					
						
							|  |  |  |   displayName: string; | 
					
						
							|  |  |  |   category: string; | 
					
						
							|  |  |  |   subCategory: string; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export interface PluginPermission { | 
					
						
							|  |  |  |   action: string; | 
					
						
							|  |  |  |   displayName: string; | 
					
						
							|  |  |  |   plugin: string; | 
					
						
							|  |  |  |   subCategory: string; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export interface Condition { | 
					
						
							|  |  |  |   id: string; | 
					
						
							|  |  |  |   displayName: string; | 
					
						
							|  |  |  |   category: string; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-16 16:38:15 +01:00
										 |  |  | /** | 
					
						
							|  |  |  |  * GET /permission - List all permissions | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export declare namespace GetAll { | 
					
						
							|  |  |  |   export interface Request { | 
					
						
							|  |  |  |     query: {}; | 
					
						
							|  |  |  |     body: {}; | 
					
						
							| 
									
										
										
										
											2024-01-02 17:01:58 +00:00
										 |  |  |     params: { | 
					
						
							|  |  |  |       role: Entity['id']; | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2023-11-16 16:38:15 +01:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   export interface Response { | 
					
						
							|  |  |  |     data: { | 
					
						
							| 
									
										
										
										
											2023-11-21 11:40:51 +00:00
										 |  |  |       conditions: Condition[]; | 
					
						
							|  |  |  |       sections: { | 
					
						
							|  |  |  |         collectionTypes: ContentPermission; | 
					
						
							|  |  |  |         plugins: PluginPermission[]; | 
					
						
							|  |  |  |         settings: SettingPermission[]; | 
					
						
							|  |  |  |         singleTypes: ContentPermission; | 
					
						
							| 
									
										
										
										
											2023-11-16 16:38:15 +01:00
										 |  |  |       }; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     error?: errors.ApplicationError; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * POST /permission/check - Check if the current user has the given permissions | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export declare namespace Check { | 
					
						
							|  |  |  |   export interface Request { | 
					
						
							|  |  |  |     query: {}; | 
					
						
							|  |  |  |     body: { | 
					
						
							|  |  |  |       permissions: (Pick<Permission, 'action' | 'subject'> & { field?: string })[]; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   export interface Response { | 
					
						
							|  |  |  |     data: boolean[]; | 
					
						
							|  |  |  |     error?: errors.ApplicationError | errors.YupValidationError; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |