| 
									
										
										
										
											2021-08-19 22:27:00 +02:00
										 |  |  | 'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const _ = require('lodash'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-07 13:13:30 +02:00
										 |  |  | // TODO: remove this tmp fix and migrate tests
 | 
					
						
							| 
									
										
										
										
											2021-08-19 22:27:00 +02:00
										 |  |  | let strapiInstance; | 
					
						
							|  |  |  | Object.defineProperty(global, 'strapi', { | 
					
						
							|  |  |  |   get() { | 
					
						
							|  |  |  |     return strapiInstance; | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   set(value) { | 
					
						
							|  |  |  |     strapiInstance = value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-08 23:33:39 +02:00
										 |  |  |     strapiInstance.plugin = (name) => strapiInstance.plugins[name]; | 
					
						
							| 
									
										
										
										
											2022-09-05 15:05:26 +02:00
										 |  |  |     _.mapValues(strapi.plugins, (acc) => { | 
					
						
							|  |  |  |       acc.controller = (name) => acc.controllers[name]; | 
					
						
							|  |  |  |       acc.service = (name) => acc.services[name]; | 
					
						
							|  |  |  |       acc.contentType = (name) => acc.contentTypes[name]; | 
					
						
							|  |  |  |       acc.policy = (name) => acc.policies[name]; | 
					
						
							| 
									
										
										
										
											2021-08-19 22:27:00 +02:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2021-10-07 13:13:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-26 17:14:20 +02:00
										 |  |  |     strapiInstance.service = (name = '') => { | 
					
						
							| 
									
										
										
										
											2021-10-07 13:13:30 +02:00
										 |  |  |       if (name.startsWith('admin::')) { | 
					
						
							|  |  |  |         return strapiInstance.admin.services[name.split('admin::')[1]]; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-08-19 22:27:00 +02:00
										 |  |  |   }, | 
					
						
							|  |  |  | }); |