| 
									
										
										
										
											2025-07-28 15:12:11 +00:00
										 |  |  | import * as types from './types.js'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Abstract Core Request class that defines the interface for all HTTP/HTTPS requests | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2025-08-18 00:21:14 +00:00
										 |  |  | export abstract class CoreRequest< | 
					
						
							|  |  |  |   TOptions extends types.ICoreRequestOptions = types.ICoreRequestOptions, | 
					
						
							|  |  |  |   TResponse = any, | 
					
						
							|  |  |  | > { | 
					
						
							| 
									
										
										
										
											2025-07-28 15:12:11 +00:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * Tests if a URL is a unix socket | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   static isUnixSocket(url: string): boolean { | 
					
						
							|  |  |  |     const unixRegex = /^(http:\/\/|https:\/\/|)unix:/; | 
					
						
							|  |  |  |     return unixRegex.test(url); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /** | 
					
						
							|  |  |  |    * Parses socket path and route from unix socket URL | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   static parseUnixSocketUrl(url: string): { socketPath: string; path: string } { | 
					
						
							|  |  |  |     const parseRegex = /(.*):(.*)/; | 
					
						
							|  |  |  |     const result = parseRegex.exec(url); | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       socketPath: result[1], | 
					
						
							|  |  |  |       path: result[2], | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   protected url: string; | 
					
						
							|  |  |  |   protected options: TOptions; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-28 17:07:24 +00:00
										 |  |  |   constructor(url: string, options?: TOptions) { | 
					
						
							| 
									
										
										
										
											2025-07-28 15:12:11 +00:00
										 |  |  |     this.url = url; | 
					
						
							| 
									
										
										
										
											2025-07-28 17:07:24 +00:00
										 |  |  |     this.options = options || ({} as TOptions); | 
					
						
							| 
									
										
										
										
											2025-07-28 15:12:11 +00:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /** | 
					
						
							|  |  |  |    * Fire the request and return a response | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   abstract fire(): Promise<TResponse>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /** | 
					
						
							|  |  |  |    * Fire the request and return the raw response (platform-specific) | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   abstract fireCore(): Promise<any>; | 
					
						
							| 
									
										
										
										
											2025-08-18 00:21:14 +00:00
										 |  |  | } |