@adaas/a-server 0.0.22 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (516) hide show
  1. package/.conf/tsconfig.base.json +79 -0
  2. package/.conf/tsconfig.browser.json +32 -0
  3. package/.conf/tsconfig.node.json +33 -0
  4. package/LICENSE +10 -19
  5. package/dist/browser/index.d.mts +1669 -0
  6. package/dist/browser/index.mjs +2869 -0
  7. package/dist/browser/index.mjs.map +1 -0
  8. package/dist/node/A-Request.entity-8_9MCXT2.d.ts +533 -0
  9. package/dist/node/A-Request.entity-r905O60G.d.mts +533 -0
  10. package/dist/node/A-Response.entity-BVYAc6-8.d.mts +318 -0
  11. package/dist/node/A-Response.entity-CRc-t-vr.d.ts +318 -0
  12. package/dist/node/channels/A-Http/A-Http.channel.constants.d.mts +9 -0
  13. package/dist/node/channels/A-Http/A-Http.channel.constants.d.ts +9 -0
  14. package/dist/node/channels/A-Http/A-Http.channel.constants.js +13 -0
  15. package/dist/node/channels/A-Http/A-Http.channel.constants.js.map +1 -0
  16. package/dist/node/channels/A-Http/A-Http.channel.constants.mjs +12 -0
  17. package/dist/node/channels/A-Http/A-Http.channel.constants.mjs.map +1 -0
  18. package/dist/node/channels/A-Http/A-Http.channel.d.mts +23 -0
  19. package/dist/node/channels/A-Http/A-Http.channel.d.ts +23 -0
  20. package/dist/node/channels/A-Http/A-Http.channel.error.d.mts +7 -0
  21. package/dist/node/channels/A-Http/A-Http.channel.error.d.ts +7 -0
  22. package/dist/node/channels/A-Http/A-Http.channel.error.js +11 -0
  23. package/dist/node/channels/A-Http/A-Http.channel.error.js.map +1 -0
  24. package/dist/node/channels/A-Http/A-Http.channel.error.mjs +10 -0
  25. package/dist/node/channels/A-Http/A-Http.channel.error.mjs.map +1 -0
  26. package/dist/node/channels/A-Http/A-Http.channel.js +122 -0
  27. package/dist/node/channels/A-Http/A-Http.channel.js.map +1 -0
  28. package/dist/node/channels/A-Http/A-Http.channel.mjs +110 -0
  29. package/dist/node/channels/A-Http/A-Http.channel.mjs.map +1 -0
  30. package/dist/node/channels/A-Http/A-Http.channel.types.d.mts +67 -0
  31. package/dist/node/channels/A-Http/A-Http.channel.types.d.ts +67 -0
  32. package/dist/node/channels/A-Http/A-Http.channel.types.js +4 -0
  33. package/dist/node/channels/A-Http/A-Http.channel.types.js.map +1 -0
  34. package/dist/node/channels/A-Http/A-Http.channel.types.mjs +3 -0
  35. package/dist/node/channels/A-Http/A-Http.channel.types.mjs.map +1 -0
  36. package/dist/node/channels/A-Websockets/A-Websockets.channel.d.mts +7 -0
  37. package/dist/node/channels/A-Websockets/A-Websockets.channel.d.ts +7 -0
  38. package/dist/node/channels/A-Websockets/A-Websockets.channel.js +13 -0
  39. package/dist/node/channels/A-Websockets/A-Websockets.channel.js.map +1 -0
  40. package/dist/node/channels/A-Websockets/A-Websockets.channel.mjs +12 -0
  41. package/dist/node/channels/A-Websockets/A-Websockets.channel.mjs.map +1 -0
  42. package/dist/node/chunk-EQQGB2QZ.mjs +15 -0
  43. package/dist/node/chunk-EQQGB2QZ.mjs.map +1 -0
  44. package/dist/node/constants/env.constants.d.mts +12 -0
  45. package/dist/node/constants/env.constants.d.ts +12 -0
  46. package/dist/node/constants/env.constants.js +23 -0
  47. package/dist/node/constants/env.constants.js.map +1 -0
  48. package/dist/node/constants/env.constants.mjs +22 -0
  49. package/dist/node/constants/env.constants.mjs.map +1 -0
  50. package/dist/node/controllers/A-CommandController/A-CommandController.component.d.mts +29 -0
  51. package/dist/node/controllers/A-CommandController/A-CommandController.component.d.ts +29 -0
  52. package/dist/node/controllers/A-CommandController/A-CommandController.component.js +55 -0
  53. package/dist/node/controllers/A-CommandController/A-CommandController.component.js.map +1 -0
  54. package/dist/node/controllers/A-CommandController/A-CommandController.component.mjs +43 -0
  55. package/dist/node/controllers/A-CommandController/A-CommandController.component.mjs.map +1 -0
  56. package/dist/node/controllers/A-EntityController/A-EntityController.component.d.mts +44 -0
  57. package/dist/node/controllers/A-EntityController/A-EntityController.component.d.ts +44 -0
  58. package/dist/node/controllers/A-EntityController/A-EntityController.component.js +189 -0
  59. package/dist/node/controllers/A-EntityController/A-EntityController.component.js.map +1 -0
  60. package/dist/node/controllers/A-EntityController/A-EntityController.component.mjs +177 -0
  61. package/dist/node/controllers/A-EntityController/A-EntityController.component.mjs.map +1 -0
  62. package/dist/node/controllers/A-EntityController/A-EntityController.component.types.d.mts +2 -0
  63. package/dist/node/controllers/A-EntityController/A-EntityController.component.types.d.ts +2 -0
  64. package/dist/node/controllers/A-EntityController/A-EntityController.component.types.js +4 -0
  65. package/dist/node/controllers/A-EntityController/A-EntityController.component.types.js.map +1 -0
  66. package/dist/node/controllers/A-EntityController/A-EntityController.component.types.mjs +3 -0
  67. package/dist/node/controllers/A-EntityController/A-EntityController.component.types.mjs.map +1 -0
  68. package/dist/node/controllers/A-ListingController/A-ListingController.component.d.mts +28 -0
  69. package/dist/node/controllers/A-ListingController/A-ListingController.component.d.ts +28 -0
  70. package/dist/node/controllers/A-ListingController/A-ListingController.component.js +59 -0
  71. package/dist/node/controllers/A-ListingController/A-ListingController.component.js.map +1 -0
  72. package/dist/node/controllers/A-ListingController/A-ListingController.component.mjs +47 -0
  73. package/dist/node/controllers/A-ListingController/A-ListingController.component.mjs.map +1 -0
  74. package/dist/node/controllers/A-ListingController/A-ListingController.types.d.mts +2 -0
  75. package/dist/node/controllers/A-ListingController/A-ListingController.types.d.ts +2 -0
  76. package/dist/node/controllers/A-ListingController/A-ListingController.types.js +4 -0
  77. package/dist/node/controllers/A-ListingController/A-ListingController.types.js.map +1 -0
  78. package/dist/node/controllers/A-ListingController/A-ListingController.types.mjs +3 -0
  79. package/dist/node/controllers/A-ListingController/A-ListingController.types.mjs.map +1 -0
  80. package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.d.mts +30 -0
  81. package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.d.ts +30 -0
  82. package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.js +46 -0
  83. package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.js.map +1 -0
  84. package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.mjs +34 -0
  85. package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.mjs.map +1 -0
  86. package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.d.mts +2 -0
  87. package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.d.ts +2 -0
  88. package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.js +4 -0
  89. package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.js.map +1 -0
  90. package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.mjs +3 -0
  91. package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.mjs.map +1 -0
  92. package/dist/node/index.d.mts +51 -0
  93. package/dist/node/index.d.ts +51 -0
  94. package/dist/node/index.js +320 -0
  95. package/dist/node/index.js.map +1 -0
  96. package/dist/node/index.mjs +48 -0
  97. package/dist/node/index.mjs.map +1 -0
  98. package/dist/node/lib/A-Request/A-HttpRequestData.context.d.mts +12 -0
  99. package/dist/node/lib/A-Request/A-HttpRequestData.context.d.ts +12 -0
  100. package/dist/node/lib/A-Request/A-HttpRequestData.context.js +25 -0
  101. package/dist/node/lib/A-Request/A-HttpRequestData.context.js.map +1 -0
  102. package/dist/node/lib/A-Request/A-HttpRequestData.context.mjs +24 -0
  103. package/dist/node/lib/A-Request/A-HttpRequestData.context.mjs.map +1 -0
  104. package/dist/node/lib/A-Request/A-HttpServerRequest.context.d.mts +39 -0
  105. package/dist/node/lib/A-Request/A-HttpServerRequest.context.d.ts +39 -0
  106. package/dist/node/lib/A-Request/A-HttpServerRequest.context.js +56 -0
  107. package/dist/node/lib/A-Request/A-HttpServerRequest.context.js.map +1 -0
  108. package/dist/node/lib/A-Request/A-HttpServerRequest.context.mjs +55 -0
  109. package/dist/node/lib/A-Request/A-HttpServerRequest.context.mjs.map +1 -0
  110. package/dist/node/lib/A-Request/A-Request.constants.d.mts +18 -0
  111. package/dist/node/lib/A-Request/A-Request.constants.d.ts +18 -0
  112. package/dist/node/lib/A-Request/A-Request.constants.js +22 -0
  113. package/dist/node/lib/A-Request/A-Request.constants.js.map +1 -0
  114. package/dist/node/lib/A-Request/A-Request.constants.mjs +22 -0
  115. package/dist/node/lib/A-Request/A-Request.constants.mjs.map +1 -0
  116. package/dist/node/lib/A-Request/A-Request.entity.d.mts +17 -0
  117. package/dist/node/lib/A-Request/A-Request.entity.d.ts +17 -0
  118. package/dist/node/lib/A-Request/A-Request.entity.js +651 -0
  119. package/dist/node/lib/A-Request/A-Request.entity.js.map +1 -0
  120. package/dist/node/lib/A-Request/A-Request.entity.mjs +639 -0
  121. package/dist/node/lib/A-Request/A-Request.entity.mjs.map +1 -0
  122. package/dist/node/lib/A-Request/A-Request.env.d.mts +37 -0
  123. package/dist/node/lib/A-Request/A-Request.env.d.ts +37 -0
  124. package/dist/node/lib/A-Request/A-Request.env.js +39 -0
  125. package/dist/node/lib/A-Request/A-Request.env.js.map +1 -0
  126. package/dist/node/lib/A-Request/A-Request.env.mjs +38 -0
  127. package/dist/node/lib/A-Request/A-Request.env.mjs.map +1 -0
  128. package/dist/node/lib/A-Request/A-Request.error.d.mts +11 -0
  129. package/dist/node/lib/A-Request/A-Request.error.d.ts +11 -0
  130. package/dist/node/lib/A-Request/A-Request.error.js +15 -0
  131. package/dist/node/lib/A-Request/A-Request.error.js.map +1 -0
  132. package/dist/node/lib/A-Request/A-Request.error.mjs +14 -0
  133. package/dist/node/lib/A-Request/A-Request.error.mjs.map +1 -0
  134. package/dist/node/lib/A-Request/A-Request.helper.d.mts +105 -0
  135. package/dist/node/lib/A-Request/A-Request.helper.d.ts +105 -0
  136. package/dist/node/lib/A-Request/A-Request.helper.js +181 -0
  137. package/dist/node/lib/A-Request/A-Request.helper.js.map +1 -0
  138. package/dist/node/lib/A-Request/A-Request.helper.mjs +180 -0
  139. package/dist/node/lib/A-Request/A-Request.helper.mjs.map +1 -0
  140. package/dist/node/lib/A-Request/A-Request.types.d.mts +17 -0
  141. package/dist/node/lib/A-Request/A-Request.types.d.ts +17 -0
  142. package/dist/node/lib/A-Request/A-Request.types.js +14 -0
  143. package/dist/node/lib/A-Request/A-Request.types.js.map +1 -0
  144. package/dist/node/lib/A-Request/A-Request.types.mjs +14 -0
  145. package/dist/node/lib/A-Request/A-Request.types.mjs.map +1 -0
  146. package/dist/node/lib/A-Response/A-Response.constants.d.mts +24 -0
  147. package/dist/node/lib/A-Response/A-Response.constants.d.ts +24 -0
  148. package/dist/node/lib/A-Response/A-Response.constants.js +28 -0
  149. package/dist/node/lib/A-Response/A-Response.constants.js.map +1 -0
  150. package/dist/node/lib/A-Response/A-Response.constants.mjs +28 -0
  151. package/dist/node/lib/A-Response/A-Response.constants.mjs.map +1 -0
  152. package/dist/node/lib/A-Response/A-Response.entity.d.mts +20 -0
  153. package/dist/node/lib/A-Response/A-Response.entity.d.ts +20 -0
  154. package/dist/node/lib/A-Response/A-Response.entity.js +544 -0
  155. package/dist/node/lib/A-Response/A-Response.entity.js.map +1 -0
  156. package/dist/node/lib/A-Response/A-Response.entity.mjs +532 -0
  157. package/dist/node/lib/A-Response/A-Response.entity.mjs.map +1 -0
  158. package/dist/node/lib/A-Response/A-Response.env.d.mts +2 -0
  159. package/dist/node/lib/A-Response/A-Response.env.d.ts +2 -0
  160. package/dist/node/lib/A-Response/A-Response.env.js +4 -0
  161. package/dist/node/lib/A-Response/A-Response.env.js.map +1 -0
  162. package/dist/node/lib/A-Response/A-Response.env.mjs +3 -0
  163. package/dist/node/lib/A-Response/A-Response.env.mjs.map +1 -0
  164. package/dist/node/lib/A-Response/A-Response.error.d.mts +6 -0
  165. package/dist/node/lib/A-Response/A-Response.error.d.ts +6 -0
  166. package/dist/node/lib/A-Response/A-Response.error.js +10 -0
  167. package/dist/node/lib/A-Response/A-Response.error.js.map +1 -0
  168. package/dist/node/lib/A-Response/A-Response.error.mjs +9 -0
  169. package/dist/node/lib/A-Response/A-Response.error.mjs.map +1 -0
  170. package/dist/node/lib/A-Response/A-Response.types.d.mts +20 -0
  171. package/dist/node/lib/A-Response/A-Response.types.d.ts +20 -0
  172. package/dist/node/lib/A-Response/A-Response.types.js +4 -0
  173. package/dist/node/lib/A-Response/A-Response.types.js.map +1 -0
  174. package/dist/node/lib/A-Response/A-Response.types.mjs +3 -0
  175. package/dist/node/lib/A-Response/A-Response.types.mjs.map +1 -0
  176. package/dist/node/lib/A-Server/A-HttpServer.constants.d.mts +7 -0
  177. package/dist/node/lib/A-Server/A-HttpServer.constants.d.ts +7 -0
  178. package/dist/node/lib/A-Server/A-HttpServer.constants.js +11 -0
  179. package/dist/node/lib/A-Server/A-HttpServer.constants.js.map +1 -0
  180. package/dist/node/lib/A-Server/A-HttpServer.constants.mjs +11 -0
  181. package/dist/node/lib/A-Server/A-HttpServer.constants.mjs.map +1 -0
  182. package/dist/node/lib/A-Server/A-HttpServer.container.d.mts +50 -0
  183. package/dist/node/lib/A-Server/A-HttpServer.container.d.ts +50 -0
  184. package/dist/node/lib/A-Server/A-HttpServer.container.js +194 -0
  185. package/dist/node/lib/A-Server/A-HttpServer.container.js.map +1 -0
  186. package/dist/node/lib/A-Server/A-HttpServer.container.mjs +182 -0
  187. package/dist/node/lib/A-Server/A-HttpServer.container.mjs.map +1 -0
  188. package/dist/node/lib/A-Server/A-HttpServer.error.d.mts +54 -0
  189. package/dist/node/lib/A-Server/A-HttpServer.error.d.ts +54 -0
  190. package/dist/node/lib/A-Server/A-HttpServer.error.js +118 -0
  191. package/dist/node/lib/A-Server/A-HttpServer.error.js.map +1 -0
  192. package/dist/node/lib/A-Server/A-HttpServer.error.mjs +117 -0
  193. package/dist/node/lib/A-Server/A-HttpServer.error.mjs.map +1 -0
  194. package/dist/node/lib/A-Server/A-HttpServer.types.d.mts +19 -0
  195. package/dist/node/lib/A-Server/A-HttpServer.types.d.ts +19 -0
  196. package/dist/node/lib/A-Server/A-HttpServer.types.js +4 -0
  197. package/dist/node/lib/A-Server/A-HttpServer.types.js.map +1 -0
  198. package/dist/node/lib/A-Server/A-HttpServer.types.mjs +3 -0
  199. package/dist/node/lib/A-Server/A-HttpServer.types.mjs.map +1 -0
  200. package/dist/node/lib/A-Server/A-Server.context.d.mts +22 -0
  201. package/dist/node/lib/A-Server/A-Server.context.d.ts +22 -0
  202. package/dist/node/lib/A-Server/A-Server.context.js +24 -0
  203. package/dist/node/lib/A-Server/A-Server.context.js.map +1 -0
  204. package/dist/node/lib/A-Server/A-Server.context.mjs +23 -0
  205. package/dist/node/lib/A-Server/A-Server.context.mjs.map +1 -0
  206. package/dist/node/lib/A-Server/A-Server.error.d.mts +14 -0
  207. package/dist/node/lib/A-Server/A-Server.error.d.ts +14 -0
  208. package/dist/node/lib/A-Server/A-Server.error.js +26 -0
  209. package/dist/node/lib/A-Server/A-Server.error.js.map +1 -0
  210. package/dist/node/lib/A-Server/A-Server.error.mjs +25 -0
  211. package/dist/node/lib/A-Server/A-Server.error.mjs.map +1 -0
  212. package/dist/node/lib/A-Server/A-Server.types.d.mts +26 -0
  213. package/dist/node/lib/A-Server/A-Server.types.d.ts +26 -0
  214. package/dist/node/lib/A-Server/A-Server.types.js +4 -0
  215. package/dist/node/lib/A-Server/A-Server.types.js.map +1 -0
  216. package/dist/node/lib/A-Server/A-Server.types.mjs +3 -0
  217. package/dist/node/lib/A-Server/A-Server.types.mjs.map +1 -0
  218. package/dist/node/lib/A-ServerController/A-ServerController.component.d.mts +29 -0
  219. package/dist/node/lib/A-ServerController/A-ServerController.component.d.ts +29 -0
  220. package/dist/node/lib/A-ServerController/A-ServerController.component.js +49 -0
  221. package/dist/node/lib/A-ServerController/A-ServerController.component.js.map +1 -0
  222. package/dist/node/lib/A-ServerController/A-ServerController.component.mjs +37 -0
  223. package/dist/node/lib/A-ServerController/A-ServerController.component.mjs.map +1 -0
  224. package/dist/node/lib/A-ServerController/A-ServerController.types.d.mts +2 -0
  225. package/dist/node/lib/A-ServerController/A-ServerController.types.d.ts +2 -0
  226. package/dist/node/lib/A-ServerController/A-ServerController.types.js +4 -0
  227. package/dist/node/lib/A-ServerController/A-ServerController.types.js.map +1 -0
  228. package/dist/node/lib/A-ServerController/A-ServerController.types.mjs +3 -0
  229. package/dist/node/lib/A-ServerController/A-ServerController.types.mjs.map +1 -0
  230. package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.d.mts +49 -0
  231. package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.d.ts +49 -0
  232. package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.js +91 -0
  233. package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.js.map +1 -0
  234. package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.mjs +90 -0
  235. package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.mjs.map +1 -0
  236. package/dist/node/lib/A-ServerEntityList/A-EntityList.types.d.mts +22 -0
  237. package/dist/node/lib/A-ServerEntityList/A-EntityList.types.d.ts +22 -0
  238. package/dist/node/lib/A-ServerEntityList/A-EntityList.types.js +10 -0
  239. package/dist/node/lib/A-ServerEntityList/A-EntityList.types.js.map +1 -0
  240. package/dist/node/lib/A-ServerEntityList/A-EntityList.types.mjs +10 -0
  241. package/dist/node/lib/A-ServerEntityList/A-EntityList.types.mjs.map +1 -0
  242. package/dist/node/lib/A-ServerListQuery/A-ServerListQueryFilter.context.d.mts +13 -0
  243. package/dist/node/lib/A-ServerListQuery/A-ServerListQueryFilter.context.d.ts +13 -0
  244. package/dist/node/lib/A-ServerListQuery/A-ServerListQueryFilter.context.js +32 -0
  245. package/dist/node/lib/A-ServerListQuery/A-ServerListQueryFilter.context.js.map +1 -0
  246. package/dist/node/lib/A-ServerListQuery/A-ServerListQueryFilter.context.mjs +31 -0
  247. package/dist/node/lib/A-ServerListQuery/A-ServerListQueryFilter.context.mjs.map +1 -0
  248. package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.d.mts +48 -0
  249. package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.d.ts +48 -0
  250. package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.js +88 -0
  251. package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.js.map +1 -0
  252. package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.mjs +76 -0
  253. package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.mjs.map +1 -0
  254. package/dist/node/lib/A-ServerLogger/A-ServerLogger.constants.d.mts +24 -0
  255. package/dist/node/lib/A-ServerLogger/A-ServerLogger.constants.d.ts +24 -0
  256. package/dist/node/lib/A-ServerLogger/A-ServerLogger.constants.js +33 -0
  257. package/dist/node/lib/A-ServerLogger/A-ServerLogger.constants.js.map +1 -0
  258. package/dist/node/lib/A-ServerLogger/A-ServerLogger.constants.mjs +33 -0
  259. package/dist/node/lib/A-ServerLogger/A-ServerLogger.constants.mjs.map +1 -0
  260. package/dist/node/lib/A-ServerLogger/A-ServerLogger.types.d.mts +12 -0
  261. package/dist/node/lib/A-ServerLogger/A-ServerLogger.types.d.ts +12 -0
  262. package/dist/node/lib/A-ServerLogger/A-ServerLogger.types.js +4 -0
  263. package/dist/node/lib/A-ServerLogger/A-ServerLogger.types.js.map +1 -0
  264. package/dist/node/lib/A-ServerLogger/A-ServerLogger.types.mjs +3 -0
  265. package/dist/node/lib/A-ServerLogger/A-ServerLogger.types.mjs.map +1 -0
  266. package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.component.d.mts +6 -0
  267. package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.component.d.ts +6 -0
  268. package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.component.js +18 -0
  269. package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.component.js.map +1 -0
  270. package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.component.mjs +17 -0
  271. package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.component.mjs.map +1 -0
  272. package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.constants.d.mts +2 -0
  273. package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.constants.d.ts +2 -0
  274. package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.constants.js +4 -0
  275. package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.constants.js.map +1 -0
  276. package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.constants.mjs +3 -0
  277. package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.constants.mjs.map +1 -0
  278. package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.types.d.mts +2 -0
  279. package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.types.d.ts +2 -0
  280. package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.types.js +4 -0
  281. package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.types.js.map +1 -0
  282. package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.types.mjs +3 -0
  283. package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.types.mjs.map +1 -0
  284. package/dist/node/lib/A-ServerProxy/A-ServerProxy.component.d.mts +31 -0
  285. package/dist/node/lib/A-ServerProxy/A-ServerProxy.component.d.ts +31 -0
  286. package/dist/node/lib/A-ServerProxy/A-ServerProxy.component.js +90 -0
  287. package/dist/node/lib/A-ServerProxy/A-ServerProxy.component.js.map +1 -0
  288. package/dist/node/lib/A-ServerProxy/A-ServerProxy.component.mjs +78 -0
  289. package/dist/node/lib/A-ServerProxy/A-ServerProxy.component.mjs.map +1 -0
  290. package/dist/node/lib/A-ServerProxy/A-ServerProxy.constants.d.mts +9 -0
  291. package/dist/node/lib/A-ServerProxy/A-ServerProxy.constants.d.ts +9 -0
  292. package/dist/node/lib/A-ServerProxy/A-ServerProxy.constants.js +14 -0
  293. package/dist/node/lib/A-ServerProxy/A-ServerProxy.constants.js.map +1 -0
  294. package/dist/node/lib/A-ServerProxy/A-ServerProxy.constants.mjs +14 -0
  295. package/dist/node/lib/A-ServerProxy/A-ServerProxy.constants.mjs.map +1 -0
  296. package/dist/node/lib/A-ServerProxy/A-ServerProxy.context.d.mts +36 -0
  297. package/dist/node/lib/A-ServerProxy/A-ServerProxy.context.d.ts +36 -0
  298. package/dist/node/lib/A-ServerProxy/A-ServerProxy.context.js +60 -0
  299. package/dist/node/lib/A-ServerProxy/A-ServerProxy.context.js.map +1 -0
  300. package/dist/node/lib/A-ServerProxy/A-ServerProxy.context.mjs +59 -0
  301. package/dist/node/lib/A-ServerProxy/A-ServerProxy.context.mjs.map +1 -0
  302. package/dist/node/lib/A-ServerProxy/A-ServerProxy.types.d.mts +23 -0
  303. package/dist/node/lib/A-ServerProxy/A-ServerProxy.types.d.ts +23 -0
  304. package/dist/node/lib/A-ServerProxy/A-ServerProxy.types.js +4 -0
  305. package/dist/node/lib/A-ServerProxy/A-ServerProxy.types.js.map +1 -0
  306. package/dist/node/lib/A-ServerProxy/A-ServerProxy.types.mjs +3 -0
  307. package/dist/node/lib/A-ServerProxy/A-ServerProxy.types.mjs.map +1 -0
  308. package/dist/node/lib/A-ServerRoute/A-ServerRoute.constants.d.mts +20 -0
  309. package/dist/node/lib/A-ServerRoute/A-ServerRoute.constants.d.ts +20 -0
  310. package/dist/node/lib/A-ServerRoute/A-ServerRoute.constants.js +25 -0
  311. package/dist/node/lib/A-ServerRoute/A-ServerRoute.constants.js.map +1 -0
  312. package/dist/node/lib/A-ServerRoute/A-ServerRoute.constants.mjs +24 -0
  313. package/dist/node/lib/A-ServerRoute/A-ServerRoute.constants.mjs.map +1 -0
  314. package/dist/node/lib/A-ServerRoute/A-ServerRoute.entity.d.mts +15 -0
  315. package/dist/node/lib/A-ServerRoute/A-ServerRoute.entity.d.ts +15 -0
  316. package/dist/node/lib/A-ServerRoute/A-ServerRoute.entity.js +24 -0
  317. package/dist/node/lib/A-ServerRoute/A-ServerRoute.entity.js.map +1 -0
  318. package/dist/node/lib/A-ServerRoute/A-ServerRoute.entity.mjs +23 -0
  319. package/dist/node/lib/A-ServerRoute/A-ServerRoute.entity.mjs.map +1 -0
  320. package/dist/node/lib/A-ServerRoute/A-ServerRoute.types.d.mts +6 -0
  321. package/dist/node/lib/A-ServerRoute/A-ServerRoute.types.d.ts +6 -0
  322. package/dist/node/lib/A-ServerRoute/A-ServerRoute.types.js +4 -0
  323. package/dist/node/lib/A-ServerRoute/A-ServerRoute.types.js.map +1 -0
  324. package/dist/node/lib/A-ServerRoute/A-ServerRoute.types.mjs +3 -0
  325. package/dist/node/lib/A-ServerRoute/A-ServerRoute.types.mjs.map +1 -0
  326. package/dist/node/lib/A-ServerRouter/A-ServerRouter.component.d.mts +84 -0
  327. package/dist/node/lib/A-ServerRouter/A-ServerRouter.component.d.ts +84 -0
  328. package/dist/node/lib/A-ServerRouter/A-ServerRouter.component.js +194 -0
  329. package/dist/node/lib/A-ServerRouter/A-ServerRouter.component.js.map +1 -0
  330. package/dist/node/lib/A-ServerRouter/A-ServerRouter.component.mjs +184 -0
  331. package/dist/node/lib/A-ServerRouter/A-ServerRouter.component.mjs.map +1 -0
  332. package/dist/node/lib/A-ServerRouter/A-ServerRouter.constants.d.mts +6 -0
  333. package/dist/node/lib/A-ServerRouter/A-ServerRouter.constants.d.ts +6 -0
  334. package/dist/node/lib/A-ServerRouter/A-ServerRouter.constants.js +10 -0
  335. package/dist/node/lib/A-ServerRouter/A-ServerRouter.constants.js.map +1 -0
  336. package/dist/node/lib/A-ServerRouter/A-ServerRouter.constants.mjs +10 -0
  337. package/dist/node/lib/A-ServerRouter/A-ServerRouter.constants.mjs.map +1 -0
  338. package/dist/node/lib/A-ServerRouter/A-ServerRouter.meta.d.mts +16 -0
  339. package/dist/node/lib/A-ServerRouter/A-ServerRouter.meta.d.ts +16 -0
  340. package/dist/node/lib/A-ServerRouter/A-ServerRouter.meta.js +40 -0
  341. package/dist/node/lib/A-ServerRouter/A-ServerRouter.meta.js.map +1 -0
  342. package/dist/node/lib/A-ServerRouter/A-ServerRouter.meta.mjs +39 -0
  343. package/dist/node/lib/A-ServerRouter/A-ServerRouter.meta.mjs.map +1 -0
  344. package/dist/node/lib/A-ServerRouter/A-ServerRouter.types.d.mts +24 -0
  345. package/dist/node/lib/A-ServerRouter/A-ServerRouter.types.d.ts +24 -0
  346. package/dist/node/lib/A-ServerRouter/A-ServerRouter.types.js +4 -0
  347. package/dist/node/lib/A-ServerRouter/A-ServerRouter.types.js.map +1 -0
  348. package/dist/node/lib/A-ServerRouter/A-ServerRouter.types.mjs +3 -0
  349. package/dist/node/lib/A-ServerRouter/A-ServerRouter.types.mjs.map +1 -0
  350. package/dist/node/lib/A-ServerRouter/A-ServerRouterDefine.decorator.d.mts +16 -0
  351. package/dist/node/lib/A-ServerRouter/A-ServerRouterDefine.decorator.d.ts +16 -0
  352. package/dist/node/lib/A-ServerRouter/A-ServerRouterDefine.decorator.js +25 -0
  353. package/dist/node/lib/A-ServerRouter/A-ServerRouterDefine.decorator.js.map +1 -0
  354. package/dist/node/lib/A-ServerRouter/A-ServerRouterDefine.decorator.mjs +24 -0
  355. package/dist/node/lib/A-ServerRouter/A-ServerRouterDefine.decorator.mjs.map +1 -0
  356. package/dist/node/lib/A-ServerStatic/A-ServerStatic.component.d.mts +65 -0
  357. package/dist/node/lib/A-ServerStatic/A-ServerStatic.component.d.ts +65 -0
  358. package/dist/node/lib/A-ServerStatic/A-ServerStatic.component.js +260 -0
  359. package/dist/node/lib/A-ServerStatic/A-ServerStatic.component.js.map +1 -0
  360. package/dist/node/lib/A-ServerStatic/A-ServerStatic.component.mjs +248 -0
  361. package/dist/node/lib/A-ServerStatic/A-ServerStatic.component.mjs.map +1 -0
  362. package/dist/node/lib/A-ServerStatic/A-ServerStatic.context.d.mts +110 -0
  363. package/dist/node/lib/A-ServerStatic/A-ServerStatic.context.d.ts +110 -0
  364. package/dist/node/lib/A-ServerStatic/A-ServerStatic.context.js +180 -0
  365. package/dist/node/lib/A-ServerStatic/A-ServerStatic.context.js.map +1 -0
  366. package/dist/node/lib/A-ServerStatic/A-ServerStatic.context.mjs +179 -0
  367. package/dist/node/lib/A-ServerStatic/A-ServerStatic.context.mjs.map +1 -0
  368. package/dist/node/lib/A-ServerStatic/A-ServerStatic.types.d.mts +8 -0
  369. package/dist/node/lib/A-ServerStatic/A-ServerStatic.types.d.ts +8 -0
  370. package/dist/node/lib/A-ServerStatic/A-ServerStatic.types.js +4 -0
  371. package/dist/node/lib/A-ServerStatic/A-ServerStatic.types.js.map +1 -0
  372. package/dist/node/lib/A-ServerStatic/A-ServerStatic.types.mjs +3 -0
  373. package/dist/node/lib/A-ServerStatic/A-ServerStatic.types.mjs.map +1 -0
  374. package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.d.mts +29 -0
  375. package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.d.ts +29 -0
  376. package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.js +62 -0
  377. package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.js.map +1 -0
  378. package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.mjs +50 -0
  379. package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.mjs.map +1 -0
  380. package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.constants.d.mts +5 -0
  381. package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.constants.d.ts +5 -0
  382. package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.constants.js +14 -0
  383. package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.constants.js.map +1 -0
  384. package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.constants.mjs +14 -0
  385. package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.constants.mjs.map +1 -0
  386. package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.types.d.mts +9 -0
  387. package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.types.d.ts +9 -0
  388. package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.types.js +4 -0
  389. package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.types.js.map +1 -0
  390. package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.types.mjs +3 -0
  391. package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.types.mjs.map +1 -0
  392. package/dist/node/repositories/A-EntityRepository/A-EntityRepository.component.d.mts +24 -0
  393. package/dist/node/repositories/A-EntityRepository/A-EntityRepository.component.d.ts +24 -0
  394. package/dist/node/repositories/A-EntityRepository/A-EntityRepository.component.js +94 -0
  395. package/dist/node/repositories/A-EntityRepository/A-EntityRepository.component.js.map +1 -0
  396. package/dist/node/repositories/A-EntityRepository/A-EntityRepository.component.mjs +82 -0
  397. package/dist/node/repositories/A-EntityRepository/A-EntityRepository.component.mjs.map +1 -0
  398. package/dist/node/repositories/A-EntityRepository/A-EntityRepository.error.d.mts +2 -0
  399. package/dist/node/repositories/A-EntityRepository/A-EntityRepository.error.d.ts +2 -0
  400. package/dist/node/repositories/A-EntityRepository/A-EntityRepository.error.js +4 -0
  401. package/dist/node/repositories/A-EntityRepository/A-EntityRepository.error.js.map +1 -0
  402. package/dist/node/repositories/A-EntityRepository/A-EntityRepository.error.mjs +3 -0
  403. package/dist/node/repositories/A-EntityRepository/A-EntityRepository.error.mjs.map +1 -0
  404. package/dist/node/repositories/A-EntityRepository/A-EntityRepository.types.d.mts +2 -0
  405. package/dist/node/repositories/A-EntityRepository/A-EntityRepository.types.d.ts +2 -0
  406. package/dist/node/repositories/A-EntityRepository/A-EntityRepository.types.js +4 -0
  407. package/dist/node/repositories/A-EntityRepository/A-EntityRepository.types.js.map +1 -0
  408. package/dist/node/repositories/A-EntityRepository/A-EntityRepository.types.mjs +3 -0
  409. package/dist/node/repositories/A-EntityRepository/A-EntityRepository.types.mjs.map +1 -0
  410. package/examples/simple-server/commands/SignIn.command.ts +17 -1
  411. package/examples/simple-server/components/Test.controller.ts +8 -7
  412. package/examples/simple-server/components/Users.repository.ts +28 -26
  413. package/examples/simple-server/concept.ts +56 -66
  414. package/examples/simple-server/entities/User/User.entity.ts +17 -7
  415. package/jest.config.ts +24 -10
  416. package/package.json +267 -25
  417. package/src/channels/A-Http/A-Http.channel.constants.ts +6 -7
  418. package/src/channels/A-Http/A-Http.channel.error.ts +2 -2
  419. package/src/channels/A-Http/A-Http.channel.ts +76 -125
  420. package/src/channels/A-Http/A-Http.channel.types.ts +6 -3
  421. package/src/channels/A-Websockets/A-Websockets.channel.ts +1 -1
  422. package/src/{components → controllers}/A-CommandController/A-CommandController.component.ts +16 -10
  423. package/src/{components → controllers}/A-EntityController/A-EntityController.component.ts +24 -28
  424. package/src/{components → controllers}/A-ListingController/A-ListingController.component.ts +10 -12
  425. package/src/{components → controllers}/A-ServerHealthMonitor/A-ServerHealthMonitor.component.ts +11 -11
  426. package/src/index.ts +58 -63
  427. package/src/lib/A-Request/A-HttpRequestData.context.ts +30 -0
  428. package/src/lib/A-Request/A-HttpServerRequest.context.ts +103 -0
  429. package/src/lib/A-Request/A-Request.constants.ts +30 -0
  430. package/src/lib/A-Request/A-Request.entity.ts +844 -0
  431. package/src/lib/A-Request/A-Request.env.ts +50 -0
  432. package/src/lib/A-Request/A-Request.error.ts +11 -0
  433. package/src/lib/A-Request/A-Request.helper.ts +276 -0
  434. package/src/lib/A-Request/A-Request.types.ts +284 -0
  435. package/src/lib/A-Request/README.md +567 -0
  436. package/src/lib/A-Response/A-Response.constants.ts +24 -0
  437. package/src/lib/A-Response/A-Response.entity.ts +689 -0
  438. package/src/lib/A-Response/A-Response.error.ts +6 -0
  439. package/src/lib/A-Response/A-Response.types.ts +127 -0
  440. package/src/lib/A-Response/README.md +793 -0
  441. package/src/lib/A-Server/A-HttpServer.constants.ts +9 -0
  442. package/src/lib/A-Server/A-HttpServer.container.ts +251 -0
  443. package/src/lib/A-Server/A-HttpServer.error.ts +165 -0
  444. package/src/lib/A-Server/A-HttpServer.types.ts +37 -0
  445. package/src/{context/A-Server/A_Server.context.ts → lib/A-Server/A-Server.context.ts} +6 -7
  446. package/src/lib/A-Server/A-Server.error.ts +26 -0
  447. package/src/{components/A-ServerError/A-ServerError.types.ts → lib/A-Server/A-Server.types.ts} +8 -0
  448. package/src/{components/A-Controller/A-Controller.component.ts → lib/A-ServerController/A-ServerController.component.ts} +5 -5
  449. package/src/{entities/A_EntityList/A_EntityList.entity.ts → lib/A-ServerEntityList/A-EntityList.entity.ts} +2 -2
  450. package/src/{entities/A_EntityList/A_EntityList.entity.types.ts → lib/A-ServerEntityList/A-EntityList.types.ts} +2 -2
  451. package/src/{context/A-ListQueryFilter/A_ListQueryFilter.context.ts → lib/A-ServerListQuery/A-ServerListQueryFilter.context.ts} +1 -1
  452. package/src/lib/A-ServerLogger/A-ServerLogger.component.ts +121 -0
  453. package/src/lib/A-ServerLogger/A-ServerLogger.types.ts +13 -0
  454. package/src/lib/A-ServerMiddleware/A-ServerMiddleware.component.ts +17 -0
  455. package/src/{components → lib}/A-ServerProxy/A-ServerProxy.component.ts +17 -12
  456. package/src/{context/A-ProxyConfig/A_ProxyConfig.constants.ts → lib/A-ServerProxy/A-ServerProxy.constants.ts} +1 -1
  457. package/src/{context/A-ProxyConfig/A_ProxyConfig.context.ts → lib/A-ServerProxy/A-ServerProxy.context.ts} +4 -4
  458. package/src/{context/A-ProxyConfig/A_ProxyConfig.types.ts → lib/A-ServerProxy/A-ServerProxy.types.ts} +4 -4
  459. package/src/lib/A-ServerRoute/A-ServerRoute.constants.ts +20 -0
  460. package/src/lib/A-ServerRoute/A-ServerRoute.entity.ts +48 -0
  461. package/src/lib/A-ServerRoute/A-ServerRoute.types.ts +6 -0
  462. package/src/{components/A-Router/A-Router.component.ts → lib/A-ServerRouter/A-ServerRouter.component.ts} +77 -97
  463. package/src/lib/A-ServerRouter/A-ServerRouter.constants.ts +8 -0
  464. package/src/lib/A-ServerRouter/A-ServerRouter.meta.ts +48 -0
  465. package/src/lib/A-ServerRouter/A-ServerRouter.types.ts +27 -0
  466. package/src/lib/A-ServerRouter/A-ServerRouterDefine.decorator.ts +37 -0
  467. package/src/{components/A-StaticLoader/A-StaticLoader.component.ts → lib/A-ServerStatic/A-ServerStatic.component.ts} +73 -54
  468. package/src/{context/A-StaticConfig/A-StaticConfig.context.ts → lib/A-ServerStatic/A-ServerStatic.context.ts} +16 -6
  469. package/src/{components → middlewares}/A-ServerCORS/A_ServerCORS.component.ts +16 -13
  470. package/src/{components/A-ServerCORS/A_ServerCORS.component.defaults.ts → middlewares/A-ServerCORS/A_ServerCORS.constants.ts} +2 -2
  471. package/src/{components → repositories}/A-EntityRepository/A-EntityRepository.component.ts +39 -30
  472. package/tests/A-HttpChannel.test.ts +41 -48
  473. package/tests/A-HttpServerError.test.ts +204 -0
  474. package/tests/A-Request.test.ts +351 -0
  475. package/tsconfig.json +40 -50
  476. package/tsup.config.ts +111 -13
  477. package/dist/index.d.mts +0 -855
  478. package/dist/index.d.ts +0 -855
  479. package/dist/index.js +0 -2179
  480. package/dist/index.js.map +0 -1
  481. package/dist/index.mjs +0 -2144
  482. package/dist/index.mjs.map +0 -1
  483. package/examples/microservices-server/components/controllers/Statistics.controller.ts +0 -18
  484. package/examples/microservices-server/components/repositories/Memory.repository.ts +0 -66
  485. package/examples/microservices-server/concept.ts +0 -43
  486. package/examples/microservices-server/context/MemoryStore.context.ts +0 -31
  487. package/examples/microservices-server/entities/Order.entity.ts +0 -7
  488. package/examples/microservices-server/entities/User.entity.ts +0 -8
  489. package/src/components/A-Router/A-Router.component.types.ts +0 -38
  490. package/src/components/A-ServerError/A-ServerError.class.ts +0 -98
  491. package/src/components/A-ServerLogger/A_ServerLogger.component.ts +0 -194
  492. package/src/components/A-ServerLogger/A_ServerLogger.component.types.ts +0 -14
  493. package/src/containers/A-Service/A-Service.container.ts +0 -218
  494. package/src/containers/A-Service/A-Service.container.types.ts +0 -46
  495. package/src/context/A-EntityFactory/A-EntityFactory.context.ts +0 -163
  496. package/src/context/A-EntityFactory/A-EntityFactory.context.types.ts +0 -11
  497. package/src/context/A-HttpChannel/A-HttpChannel.context.ts +0 -36
  498. package/src/context/A-Server/A_Server.context.types.ts +0 -9
  499. package/src/entities/A-Request/A-Request.entity.ts +0 -163
  500. package/src/entities/A-Request/A-Request.entity.types.ts +0 -41
  501. package/src/entities/A-Response/A-Response.entity.ts +0 -194
  502. package/src/entities/A-Response/A-Response.entity.types.ts +0 -26
  503. package/src/entities/A-Route/A-Route.entity.ts +0 -117
  504. package/tests/A-Service.test.ts +0 -18
  505. /package/src/{components → controllers}/A-EntityController/A-EntityController.component.types.ts +0 -0
  506. /package/src/{components/A-Controller/A-Controller.component.types.ts → controllers/A-ListingController/A-ListingController.types.ts} +0 -0
  507. /package/src/{components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.types.ts → controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.ts} +0 -0
  508. /package/src/{components/A-EntityRepository/A-EntityRepository.error.ts → lib/A-Response/A-Response.env.ts} +0 -0
  509. /package/src/{components/A-EntityRepository/A-EntityRepository.types.ts → lib/A-ServerController/A-ServerController.types.ts} +0 -0
  510. /package/src/{components → lib}/A-ServerLogger/A-ServerLogger.constants.ts +0 -0
  511. /package/src/{components/A-ListingController/A-ListingController.component.types.ts → lib/A-ServerMiddleware/A-ServerMiddleware.constants.ts} +0 -0
  512. /package/src/{components/A-ServerError/A-ServerError.constants.ts → lib/A-ServerMiddleware/A-ServerMiddleware.types.ts} +0 -0
  513. /package/src/{components/A-StaticLoader/A-StaticLoader.component.types.ts → lib/A-ServerStatic/A-ServerStatic.types.ts} +0 -0
  514. /package/src/{components/A-ServerCORS/A_ServerCORS.component.types.ts → middlewares/A-ServerCORS/A_ServerCORS.types.ts} +0 -0
  515. /package/src/{context/A-StaticConfig/A-StaticConfig.context.types.ts → repositories/A-EntityRepository/A-EntityRepository.error.ts} +0 -0
  516. /package/src/{entities/A-Route/A-Route.entity.types.ts → repositories/A-EntityRepository/A-EntityRepository.types.ts} +0 -0
package/dist/index.mjs DELETED
@@ -1,2144 +0,0 @@
1
- import { A_Feature, A_Inject, A_Container, A_Scope, A_Error, A_IdentityHelper, A_Concept, A_Caller, A_Entity, ASEID, A_Context, A_Fragment, A_Component, A_Feature_Define, A_Feature_Extend, A_TypeGuards } from '@adaas/a-concept';
2
- import { A_Polyfill, A_Config, A_Logger, A_Channel, A_Manifest } from '@adaas/a-utils';
3
- import { A_TYPES__EntityFeatures } from '@adaas/a-concept/dist/src/global/A-Entity/A-Entity.constants';
4
-
5
- var __defProp = Object.defineProperty;
6
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __decorateClass = (decorators, target, key, kind) => {
8
- var result = __getOwnPropDesc(target, key) ;
9
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
10
- if (decorator = decorators[i])
11
- result = (decorator(target, key, result) ) || result;
12
- if (result) __defProp(target, key, result);
13
- return result;
14
- };
15
- var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
16
-
17
- // src/containers/A-Service/A-Service.container.types.ts
18
- var A_SERVER_TYPES__ServerFeature = /* @__PURE__ */ ((A_SERVER_TYPES__ServerFeature2) => {
19
- A_SERVER_TYPES__ServerFeature2["beforeStart"] = "beforeStart";
20
- A_SERVER_TYPES__ServerFeature2["afterStart"] = "afterStart";
21
- A_SERVER_TYPES__ServerFeature2["beforeStop"] = "beforeStop";
22
- A_SERVER_TYPES__ServerFeature2["afterStop"] = "afterStop";
23
- A_SERVER_TYPES__ServerFeature2["beforeRequest"] = "beforeRequest";
24
- A_SERVER_TYPES__ServerFeature2["onRequest"] = "onRequest";
25
- A_SERVER_TYPES__ServerFeature2["afterRequest"] = "afterRequest";
26
- return A_SERVER_TYPES__ServerFeature2;
27
- })(A_SERVER_TYPES__ServerFeature || {});
28
- var A_SERVER_TYPES__ServerMethod = /* @__PURE__ */ ((A_SERVER_TYPES__ServerMethod2) => {
29
- A_SERVER_TYPES__ServerMethod2["GET"] = "GET";
30
- A_SERVER_TYPES__ServerMethod2["POST"] = "POST";
31
- A_SERVER_TYPES__ServerMethod2["PUT"] = "PUT";
32
- A_SERVER_TYPES__ServerMethod2["DELETE"] = "DELETE";
33
- A_SERVER_TYPES__ServerMethod2["PATCH"] = "PATCH";
34
- A_SERVER_TYPES__ServerMethod2["OPTIONS"] = "OPTIONS";
35
- A_SERVER_TYPES__ServerMethod2["HEAD"] = "HEAD";
36
- A_SERVER_TYPES__ServerMethod2["CONNECT"] = "CONNECT";
37
- A_SERVER_TYPES__ServerMethod2["TRACE"] = "TRACE";
38
- A_SERVER_TYPES__ServerMethod2["DEFAULT"] = "DEFAULT";
39
- return A_SERVER_TYPES__ServerMethod2;
40
- })(A_SERVER_TYPES__ServerMethod || {});
41
- var A_HTTPChannel_RequestContext = class extends A_Fragment {
42
- constructor(params) {
43
- super();
44
- const {
45
- method,
46
- url,
47
- data,
48
- config
49
- } = params;
50
- this.url = url;
51
- this.method = method;
52
- this.data = data;
53
- this.config = config;
54
- }
55
- };
56
-
57
- // src/channels/A-Http/A-Http.channel.constants.ts
58
- var A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle = /* @__PURE__ */ ((A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle2) => {
59
- A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle2["onAfterRequest"] = "onAfterHttpChannelRequest";
60
- A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle2["onError"] = "onHttpChannelError";
61
- A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle2["onBeforeRequest"] = "onBeforeHttpChannelRequest";
62
- return A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle2;
63
- })(A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle || {});
64
- var A_ServerError = class extends A_Error {
65
- constructor() {
66
- super(...arguments);
67
- this.status = 500;
68
- }
69
- // constructor(
70
- // /**
71
- // * A_Error Constructor params
72
- // */
73
- // params: A_SERVER_TYPES__ServerError_Init
74
- // )
75
- // constructor(
76
- // /**
77
- // * HTTP Status Code of the error
78
- // */
79
- // status: number,
80
- // /**
81
- // * Error message
82
- // */
83
- // message: string
84
- // )
85
- // constructor(
86
- // /**
87
- // * Original JS Error
88
- // */
89
- // error: Error
90
- // )
91
- // constructor(
92
- // /**
93
- // * HTTP Status Code of the error
94
- // */
95
- // status: number,
96
- // /**
97
- // * Error message
98
- // */
99
- // title: string,
100
- // /**
101
- // * Detailed description of the error
102
- // */
103
- // description: string
104
- // )
105
- // constructor(
106
- // param1: A_SERVER_TYPES__ServerError_Init | Error | string | A_Error | number,
107
- // param2?: string | A_Error,
108
- // param3?: string
109
- // ) {
110
- // switch (true) {
111
- // case typeof param1 === 'number':
112
- // if (typeof param2 === 'string' && param3) {
113
- // super({
114
- // title: param2,
115
- // description: param3
116
- // });
117
- // }
118
- // else if (param2 instanceof A_Error) {
119
- // super(param2);
120
- // }
121
- // else {
122
- // super();
123
- // }
124
- // this.status = param1;
125
- // break;
126
- // case param1 instanceof A_Error:
127
- // super (param1);
128
- // break;
129
- // case param1 instanceof Error:
130
- // super (param1);
131
- // break;
132
- // default:
133
- // break;
134
- // }
135
- // }
136
- fromConstructor(params) {
137
- super.fromConstructor(params);
138
- if (params.status) {
139
- this.status = params.status;
140
- }
141
- }
142
- toJSON() {
143
- return {
144
- ...super.toJSON(),
145
- status: this.status
146
- };
147
- }
148
- };
149
- var A_HTTPChannelError = class extends A_Error {
150
- };
151
- A_HTTPChannelError.HttpRequestError = "HTTP Channel Request Error";
152
-
153
- // src/channels/A-Http/A-Http.channel.ts
154
- var A_HTTPChannel = class extends A_Channel {
155
- async connect() {
156
- return;
157
- }
158
- /**
159
- * Allows to send an HTTP request without expecting a response
160
- *
161
- * @param params
162
- */
163
- async send(params) {
164
- this.request(params);
165
- }
166
- /**
167
- * Makes an HTTP request
168
- *
169
- * @param params
170
- * @returns
171
- */
172
- async request(params) {
173
- const { method, url, data, config } = params;
174
- await this.initialize;
175
- this._processing = true;
176
- const fullUrl = this.buildURL(url, config?.params);
177
- const requestScope = new A_Scope({ name: `a-http-channel-request-scope-${method}-${url}-${Date.now()}` });
178
- const context = new A_HTTPChannel_RequestContext({
179
- method,
180
- url,
181
- data,
182
- config
183
- });
184
- requestScope.inherit(A_Context.scope(this));
185
- requestScope.register(context);
186
- try {
187
- await this.call("onBeforeHttpChannelRequest" /* onBeforeRequest */, requestScope);
188
- const headers = {
189
- "Content-Type": "application/json",
190
- ...config?.headers
191
- };
192
- const options = {
193
- method,
194
- headers
195
- };
196
- if (data && method !== "GET" /* GET */) {
197
- options.body = JSON.stringify(data);
198
- }
199
- const response = await fetch(fullUrl, options);
200
- if (!response.ok) {
201
- throw new A_ServerError({
202
- status: response.status,
203
- title: response.statusText,
204
- description: `HTTP request to ${fullUrl} failed with status ${response.status}`
205
- });
206
- }
207
- context.result = config?.params?.responseType === "text" ? await response.text() : config?.params?.responseType === "blob" ? await response.blob() : await response.json();
208
- await this.call("onAfterHttpChannelRequest" /* onAfterRequest */, requestScope);
209
- this._processing = false;
210
- return context;
211
- } catch (error) {
212
- this._processing = false;
213
- context.error = error;
214
- await this.call("onHttpChannelError" /* onError */, requestScope);
215
- if (config?.throwOnError === false)
216
- return context;
217
- else
218
- throw error;
219
- }
220
- }
221
- async post(url, body, config) {
222
- return this.request(
223
- {
224
- method: "POST" /* POST */,
225
- url,
226
- data: body,
227
- config
228
- }
229
- );
230
- }
231
- async get(url, params, config) {
232
- return this.request(
233
- {
234
- method: "GET" /* GET */,
235
- url,
236
- config: {
237
- ...config,
238
- params
239
- }
240
- }
241
- );
242
- }
243
- async put(url, body, config) {
244
- return this.request({
245
- method: "PUT" /* PUT */,
246
- url,
247
- data: body,
248
- config
249
- });
250
- }
251
- async delete(url, params, config) {
252
- return this.request({
253
- method: "DELETE" /* DELETE */,
254
- url,
255
- data: params,
256
- config
257
- });
258
- }
259
- buildURL(path = "", params = {}) {
260
- if (!this.baseUrl)
261
- throw new A_HTTPChannelError(
262
- A_HTTPChannelError.HttpRequestError,
263
- "Base URL is not set for HTTP Channel"
264
- );
265
- const url = new URL(`${this.baseUrl}${path.startsWith("/") ? path : `/${path}`}`);
266
- Object.keys(params).forEach((key) => {
267
- if (params[key] !== void 0 && params[key] !== null) {
268
- url.searchParams.append(key, params[key]);
269
- }
270
- });
271
- return url.toString();
272
- }
273
- };
274
-
275
- // src/constants/env.constants.ts
276
- var A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES = {
277
- // ----------------------------------------------------------
278
- // A-Server Environment Variables
279
- // ----------------------------------------------------------
280
- // These environment variables are used by A-Server to configure the application
281
- // ----------------------------------------------------------
282
- /**
283
- * Port for the server to listen on
284
- * [!] Default is 3000
285
- * @default 3000
286
- */
287
- A_SERVER_PORT: "A_SERVER_PORT"
288
- };
289
- var A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY = [
290
- A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES.A_SERVER_PORT
291
- ];
292
- var A_Server = class extends A_Fragment {
293
- constructor(params) {
294
- super(params);
295
- this._routes = [];
296
- this.port = params.port;
297
- this.name = params.name;
298
- this.version = params.version || "v1";
299
- this._routes = params.routes || this._routes;
300
- }
301
- /**
302
- * A list of routes that the server will listen to
303
- */
304
- get routes() {
305
- return this._routes;
306
- }
307
- };
308
-
309
- // src/entities/A-Request/A-Request.entity.types.ts
310
- var A_SERVER_TYPES__RequestEvent = /* @__PURE__ */ ((A_SERVER_TYPES__RequestEvent2) => {
311
- A_SERVER_TYPES__RequestEvent2["Error"] = "error";
312
- A_SERVER_TYPES__RequestEvent2["Finish"] = "finish";
313
- A_SERVER_TYPES__RequestEvent2["Data"] = "data";
314
- A_SERVER_TYPES__RequestEvent2["End"] = "end";
315
- A_SERVER_TYPES__RequestEvent2["Close"] = "close";
316
- return A_SERVER_TYPES__RequestEvent2;
317
- })(A_SERVER_TYPES__RequestEvent || {});
318
-
319
- // src/entities/A-Route/A-Route.entity.ts
320
- var A_Route = class {
321
- constructor(param1, param2) {
322
- this.url = param1 instanceof RegExp ? param1.source : param1;
323
- this.method = param2 || "GET";
324
- }
325
- /**
326
- * returns path only without query and hash
327
- */
328
- get path() {
329
- const p = this.url.split("?")[0].split("#")[0];
330
- return p.endsWith("/") ? p.slice(0, -1) : p;
331
- }
332
- get params() {
333
- return this.path.match(/:([^\/]+)/g)?.map((param) => param.slice(1)) || [];
334
- }
335
- extractParams(url) {
336
- const cleanUrl = url.split("?")[0];
337
- const urlSegments = cleanUrl.split("/").filter(Boolean);
338
- const maskSegments = this.path.split("/").filter(Boolean);
339
- const params = {};
340
- for (let i = 0; i < maskSegments.length; i++) {
341
- const maskSegment = maskSegments[i];
342
- const urlSegment = urlSegments[i];
343
- if (maskSegment.startsWith(":")) {
344
- const paramName = maskSegment.slice(1);
345
- params[paramName] = urlSegment;
346
- } else if (maskSegment !== urlSegment) {
347
- return {};
348
- }
349
- }
350
- return params;
351
- }
352
- extractQuery(url) {
353
- const query = {};
354
- const queryString = url.split("?")[1];
355
- if (!queryString) return query;
356
- const cleanQuery = queryString.split("#")[0];
357
- for (const pair of cleanQuery.split("&")) {
358
- if (!pair) continue;
359
- const [key, value = ""] = pair.split("=");
360
- query[decodeURIComponent(key)] = decodeURIComponent(value);
361
- }
362
- return query;
363
- }
364
- toString() {
365
- return `${this.method}::${this.path}`;
366
- }
367
- toRegExp() {
368
- return new RegExp(`^${this.method}::${this.path.replace(/\/:([^\/]+)/g, "/([^/]+)")}$`);
369
- }
370
- toAFeatureExtension(extensionScope = []) {
371
- return new RegExp(`^${extensionScope.length ? `(${extensionScope.join("|")})` : ".*"}\\.${this.method}::${this.path.replace(/\/:([^\/]+)/g, "/([^/]+)")}$`);
372
- }
373
- };
374
-
375
- // src/entities/A-Request/A-Request.entity.ts
376
- var A_Request = class extends A_Entity {
377
- constructor() {
378
- super(...arguments);
379
- this.body = {};
380
- this.params = {};
381
- this.query = {};
382
- /**
383
- * Duration of the request in milliseconds
384
- */
385
- this.duration = 0;
386
- }
387
- static get namespace() {
388
- return "a-server";
389
- }
390
- fromNew(newEntity) {
391
- this.req = newEntity.request;
392
- this.aseid = new ASEID({
393
- concept: A_Context.root.name,
394
- scope: newEntity.scope,
395
- entity: this.constructor.entity,
396
- id: newEntity.id
397
- });
398
- }
399
- get startedAt() {
400
- const timeId = A_IdentityHelper.parseTimeId(this.aseid.id.split("-")[0]);
401
- return timeId ? new Date(timeId.timestamp) : void 0;
402
- }
403
- // Getter for request URL
404
- get url() {
405
- return this.req.url;
406
- }
407
- // Getter for request method
408
- get method() {
409
- return String(this.req.method).toUpperCase() || "DEFAULT";
410
- }
411
- get headers() {
412
- return this.req.headers;
413
- }
414
- get route() {
415
- return new A_Route(this.url, this.method);
416
- }
417
- pipe(destination, options) {
418
- return this.req.pipe(destination, options);
419
- }
420
- async init() {
421
- this.req.on("error", async (err) => {
422
- this.error = new A_ServerError(err);
423
- await this.call("error" /* Error */);
424
- });
425
- this.params = this.extractParams(this.url);
426
- this.query = this.extractQuery(this.url);
427
- }
428
- extractParams(url) {
429
- const cleanUrl = url.split("?")[0];
430
- const urlSegments = cleanUrl.split("/").filter(Boolean);
431
- const maskSegments = this.url.split("/").filter(Boolean);
432
- const params = {};
433
- for (let i = 0; i < maskSegments.length; i++) {
434
- const maskSegment = maskSegments[i];
435
- const urlSegment = urlSegments[i];
436
- if (maskSegment.startsWith(":")) {
437
- const paramName = maskSegment.slice(1);
438
- params[paramName] = urlSegment;
439
- } else if (maskSegment !== urlSegment) {
440
- return {};
441
- }
442
- }
443
- return params;
444
- }
445
- extractQuery(url) {
446
- const query = {};
447
- const queryString = url.split("?")[1];
448
- if (!queryString) return query;
449
- const cleanQuery = queryString.split("#")[0];
450
- for (const pair of cleanQuery.split("&")) {
451
- if (!pair) continue;
452
- const [key, value = ""] = pair.split("=");
453
- query[decodeURIComponent(key)] = decodeURIComponent(value);
454
- }
455
- return query;
456
- }
457
- parseBody() {
458
- return new Promise((resolve, reject) => {
459
- let body = "";
460
- this.req.on("data", (chunk) => body += chunk);
461
- this.req.on("end", () => {
462
- try {
463
- resolve(JSON.parse(body));
464
- } catch (err) {
465
- reject(err);
466
- }
467
- });
468
- this.req.on("error", reject);
469
- });
470
- }
471
- };
472
-
473
- // src/entities/A-Response/A-Response.entity.types.ts
474
- var A_SERVER_TYPES__ResponseEvent = /* @__PURE__ */ ((A_SERVER_TYPES__ResponseEvent2) => {
475
- A_SERVER_TYPES__ResponseEvent2["Error"] = "error";
476
- A_SERVER_TYPES__ResponseEvent2["Finish"] = "finish";
477
- A_SERVER_TYPES__ResponseEvent2["Data"] = "data";
478
- A_SERVER_TYPES__ResponseEvent2["End"] = "end";
479
- A_SERVER_TYPES__ResponseEvent2["Close"] = "close";
480
- return A_SERVER_TYPES__ResponseEvent2;
481
- })(A_SERVER_TYPES__ResponseEvent || {});
482
- var A_Response = class extends A_Entity {
483
- constructor() {
484
- super(...arguments);
485
- /**
486
- * Duration of the request in milliseconds
487
- */
488
- this.duration = 0;
489
- this.data = /* @__PURE__ */ new Map();
490
- }
491
- fromNew(newEntity) {
492
- this.res = newEntity.response;
493
- this.aseid = new ASEID({
494
- concept: A_Context.root.name,
495
- scope: newEntity.scope,
496
- entity: this.constructor.entity,
497
- id: newEntity.id
498
- });
499
- }
500
- get headersSent() {
501
- return this.res.headersSent;
502
- }
503
- get original() {
504
- return this.res;
505
- }
506
- get statusCode() {
507
- return this.res.statusCode;
508
- }
509
- async init() {
510
- const startTime = process.hrtime();
511
- this.res.on("finish", async () => {
512
- const elapsedTime = process.hrtime(startTime);
513
- const elapsedMilliseconds = elapsedTime[0] * 1e3 + elapsedTime[1] / 1e6;
514
- this.duration = elapsedMilliseconds;
515
- await this.call("finish" /* Finish */);
516
- });
517
- this.res.on("close", async () => {
518
- await this.call("close" /* Close */);
519
- });
520
- }
521
- failed(error) {
522
- switch (true) {
523
- case error instanceof A_ServerError:
524
- this.error = error;
525
- break;
526
- case error instanceof A_Error:
527
- this.error = new A_ServerError(error);
528
- break;
529
- default:
530
- this.error = new A_ServerError(error);
531
- break;
532
- }
533
- return this.status(this.error.status).json(this.error);
534
- }
535
- // Send a plain text or JSON response
536
- send(data = this.toResponse()) {
537
- const logger = A_Context.scope(this).resolve(A_Logger);
538
- if (this.headersSent) {
539
- logger.warning("Response headers already sent, cannot send response again.");
540
- return;
541
- }
542
- try {
543
- switch (true) {
544
- case (!!data && typeof data === "object"):
545
- return this.json(data);
546
- case (!!data && typeof data === "string"):
547
- this.res.setHeader("Content-Type", "text/plain");
548
- this.res.writeHead(this.statusCode);
549
- this.res.end(data);
550
- return;
551
- default:
552
- this.res.writeHead(this.statusCode);
553
- this.res.end(data);
554
- return;
555
- }
556
- } catch (error) {
557
- logger.warning("Response send error:", error);
558
- }
559
- }
560
- destroy(error, scope) {
561
- this.res.end();
562
- return super.destroy(scope);
563
- }
564
- // Explicit JSON response
565
- json(data = this.toResponse()) {
566
- const logger = A_Context.scope(this).resolve(A_Logger);
567
- if (this.headersSent) {
568
- logger.warning("Response headers already sent, cannot send response again.");
569
- return;
570
- }
571
- this.res.setHeader("Content-Type", "application/json");
572
- this.res.writeHead(this.statusCode);
573
- this.res.end(JSON.stringify(data));
574
- }
575
- // Set HTTP status code
576
- status(code) {
577
- this.res.statusCode = code;
578
- return this;
579
- }
580
- writeHead(statusCode, headers) {
581
- this.res.writeHead(statusCode, headers);
582
- }
583
- setHeader(key, value) {
584
- this.res.setHeader(key, value);
585
- }
586
- getHeader(key) {
587
- return this.res.getHeader(key);
588
- }
589
- add(key, data) {
590
- this.data.set(key, data);
591
- }
592
- toResponse() {
593
- return Array.from(this.data.entries()).reduce((acc, [key, value]) => {
594
- if (value instanceof A_Entity)
595
- acc[key] = value.toJSON();
596
- else
597
- acc[key] = value;
598
- return acc;
599
- }, {});
600
- }
601
- };
602
- var A_ServerLogger = class extends A_Logger {
603
- async onRequestEnd(request, response) {
604
- this.route({
605
- method: request.method,
606
- url: request.url,
607
- status: response.statusCode,
608
- responseTime: response.duration
609
- });
610
- }
611
- async onRequestError(request) {
612
- }
613
- logStart(container) {
614
- this.serverReady({
615
- port: container.port,
616
- app: {
617
- name: container.name
618
- }
619
- });
620
- }
621
- logStop(server) {
622
- this.log("red", `Server ${server.name} stopped`);
623
- }
624
- metrics() {
625
- }
626
- routes(routes) {
627
- const time = this.getTime();
628
- console.log(`\x1B[36m[${this.scope.name}] |${time}| Exposed Routes:
629
- ${" ".repeat(this.scopeLength + 3)}|-------------------------------
630
- ${routes.map((route) => `${" ".repeat(this.scopeLength + 3)}| [${route.method.toUpperCase()}]${" ".repeat(7 - route.method.length)} ${route.path}`).join("\n")}
631
- ${" ".repeat(this.scopeLength + 3)}|-------------------------------\x1B[0m`);
632
- }
633
- /**
634
- * Logs the route information based on status code
635
- *
636
- * @param route
637
- */
638
- route(route) {
639
- switch (route.status) {
640
- case 200:
641
- this.log200(route);
642
- break;
643
- case 404:
644
- this.log404(route);
645
- break;
646
- case 500:
647
- this.log500(route);
648
- break;
649
- case 400:
650
- this.log400(route);
651
- break;
652
- default:
653
- this.logDefault(route);
654
- break;
655
- }
656
- }
657
- log200(route) {
658
- if (this.config.get("SERVER_IGNORE_LOG_200"))
659
- return;
660
- console.log(`\x1B[32m[${this.scope.name}] |${this.getTime()}| ${route.status} | [${route.method.toUpperCase()}]${" ".repeat(7 - route.method.length)} ${route.url} | ${route.responseTime}ms\x1B[0m`);
661
- }
662
- log404(route) {
663
- if (this.config.get("SERVER_IGNORE_LOG_404"))
664
- return;
665
- console.log(`\x1B[33m[${this.scope.name}] |${this.getTime()}| ${route.status} | [${route.method.toUpperCase()}]${" ".repeat(7 - route.method.length)} ${route.url} | ${route.responseTime}ms\x1B[0m`);
666
- }
667
- log500(route) {
668
- if (this.config.get("SERVER_IGNORE_LOG_500"))
669
- return;
670
- console.log(`\x1B[31m[${this.scope.name}] |${this.getTime()}| ${route.status} | [${route.method.toUpperCase()}]${" ".repeat(7 - route.method.length)} ${route.url} | ${route.responseTime}ms\x1B[0m`);
671
- }
672
- log400(route) {
673
- if (this.config.get("SERVER_IGNORE_LOG_400"))
674
- return;
675
- console.log(`\x1B[33m[${this.scope.name}] |${this.getTime()}| ${route.status} | [${route.method.toUpperCase()}]${" ".repeat(7 - route.method.length)} ${route.url} | ${route.responseTime}ms\x1B[0m`);
676
- }
677
- logDefault(route) {
678
- if (this.config.get("SERVER_IGNORE_LOG_DEFAULT"))
679
- return;
680
- console.log(`\x1B[36m[${this.scope.name}] |${this.getTime()}| ${route.status} | [${route.method.toUpperCase()}]${" ".repeat(7 - route.method.length)} ${route.url} | ${route.responseTime}ms\x1B[0m`);
681
- }
682
- serverReady(params) {
683
- const processId = process.pid;
684
- console.log(`\x1B[36m[${this.scope.name}] |${this.getTime()}| Server Ready:
685
- ${" ".repeat(this.scopeLength + 3)}|-------------------------------
686
- ${" ".repeat(this.scopeLength + 3)}| ${params.app.name} v${params.app.version || "0.0.1"} is running on port ${params.port}
687
- ${" ".repeat(this.scopeLength + 3)}| Process ID: ${processId}
688
- ${" ".repeat(this.scopeLength + 3)}|-------------------------------
689
- ${" ".repeat(this.scopeLength + 3)}| ==============================
690
- ${" ".repeat(this.scopeLength + 3)}| LISTENING...
691
- ${" ".repeat(this.scopeLength + 3)}| ==============================
692
- \x1B[0m`);
693
- }
694
- /**
695
- * Displays a proxy routes
696
- *
697
- * @param params
698
- */
699
- proxy(params) {
700
- console.log(`\x1B[35m[${this.scope.name}] |${this.getTime()}| Proxy:
701
- ${" ".repeat(this.scopeLength + 3)}| ${params.original} -> ${params.destination}
702
- ${" ".repeat(this.scopeLength + 3)}|-------------------------------\x1B[0m`);
703
- }
704
- };
705
- __decorateClass([
706
- A_Feature.Extend({
707
- name: "finish" /* Finish */,
708
- scope: [A_Response]
709
- }),
710
- __decorateParam(0, A_Inject(A_Request)),
711
- __decorateParam(1, A_Inject(A_Response))
712
- ], A_ServerLogger.prototype, "onRequestEnd");
713
- __decorateClass([
714
- A_Feature.Extend({
715
- name: "error" /* Error */
716
- }),
717
- __decorateParam(0, A_Inject(A_Request))
718
- ], A_ServerLogger.prototype, "onRequestError");
719
- __decorateClass([
720
- A_Feature.Extend({
721
- name: "afterStart" /* afterStart */,
722
- scope: [A_Service]
723
- }),
724
- __decorateParam(0, A_Inject(A_Service))
725
- ], A_ServerLogger.prototype, "logStart");
726
- __decorateClass([
727
- A_Feature.Extend({
728
- name: "afterStop" /* afterStop */,
729
- scope: [A_Service]
730
- }),
731
- __decorateParam(0, A_Inject(A_Server))
732
- ], A_ServerLogger.prototype, "logStop");
733
-
734
- // src/containers/A-Service/A-Service.container.ts
735
- var A_Service = class extends A_Container {
736
- async load() {
737
- if (!this.scope.has(A_ServerLogger))
738
- this.scope.register(A_ServerLogger);
739
- this.scope.resolve(A_ServerLogger);
740
- let polyfill;
741
- if (!this.scope.has(A_Polyfill))
742
- this.scope.register(A_Polyfill);
743
- polyfill = this.scope.resolve(A_Polyfill);
744
- let config;
745
- if (!this.scope.has(A_Config)) {
746
- const config2 = new A_Config({
747
- variables: [...Array.from(A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY)],
748
- defaults: {
749
- A_SERVER_PORT: 3e3
750
- }
751
- });
752
- this.scope.register(config2);
753
- }
754
- config = this.scope.resolve(A_Config);
755
- if (!this.scope.has(A_Server)) {
756
- new A_Server({
757
- port: config.get("A_SERVER_PORT"),
758
- name: this.name,
759
- version: "v1"
760
- });
761
- }
762
- this.port = config.get("A_SERVER_PORT");
763
- const http = await polyfill.http();
764
- this.server = http.createServer(this.onRequest.bind(this));
765
- }
766
- listen() {
767
- return new Promise((resolve, reject) => {
768
- this.server.listen(this.port, () => {
769
- resolve();
770
- });
771
- });
772
- }
773
- close() {
774
- return new Promise((resolve, reject) => {
775
- this.server.close(() => {
776
- resolve();
777
- });
778
- });
779
- }
780
- /**
781
- * Start the server
782
- */
783
- async start() {
784
- await this.beforeStart();
785
- await this.listen();
786
- await this.afterStart();
787
- }
788
- async beforeStart() {
789
- }
790
- async afterStart() {
791
- }
792
- /**
793
- * Stop service
794
- */
795
- async stop() {
796
- await this.call("beforeStop" /* beforeStop */);
797
- await this.server.close();
798
- await this.call("afterStop" /* afterStop */);
799
- }
800
- async beforeRequest(scope) {
801
- }
802
- async afterRequest(scope) {
803
- }
804
- async onRequest(request, response) {
805
- const scope = new A_Scope({
806
- name: `a-server-request::${Date.now()}`
807
- });
808
- const { req, res } = await this.convertToAServer(request, response);
809
- try {
810
- scope.register(req);
811
- scope.register(res);
812
- scope.inherit(this.scope);
813
- await this.beforeRequest(scope);
814
- await this.call("onRequest" /* onRequest */, scope);
815
- await this.afterRequest(scope);
816
- await res.status(200).send();
817
- } catch (error) {
818
- const logger = this.scope.resolve(A_Logger);
819
- logger.error(error);
820
- return res.failed(error);
821
- }
822
- }
823
- async convertToAServer(request, response) {
824
- if (!request.method || !request.url)
825
- throw new A_Error("Request method or url is missing");
826
- const id = await this.generateRequestId(request.method, request.url);
827
- const req = new A_Request({ id, request, scope: this.scope.name });
828
- const res = new A_Response({ id, response, scope: this.scope.name });
829
- await req.init();
830
- await res.init();
831
- return { req, res };
832
- }
833
- async generateRequestId(method, url) {
834
- const crypto = await this.scope.resolve(A_Polyfill).crypto();
835
- const timeId = A_IdentityHelper.generateTimeId();
836
- const randomValue = Math.random().toString();
837
- const hash = await crypto.createTextHash(`${timeId}-${method}-${url}-${randomValue}`, "sha256");
838
- return `${timeId}-${hash}`;
839
- }
840
- async beforeStop() {
841
- }
842
- async afterStop() {
843
- }
844
- };
845
- __decorateClass([
846
- A_Concept.Load()
847
- ], A_Service.prototype, "load");
848
- __decorateClass([
849
- A_Concept.Start()
850
- ], A_Service.prototype, "start");
851
- __decorateClass([
852
- A_Feature.Define({ invoke: true })
853
- ], A_Service.prototype, "beforeStart");
854
- __decorateClass([
855
- A_Feature.Define({ invoke: true })
856
- ], A_Service.prototype, "afterStart");
857
- __decorateClass([
858
- A_Concept.Stop()
859
- ], A_Service.prototype, "stop");
860
- __decorateClass([
861
- A_Feature.Define({
862
- name: "beforeRequest" /* beforeRequest */,
863
- invoke: true
864
- })
865
- ], A_Service.prototype, "beforeRequest");
866
- __decorateClass([
867
- A_Feature.Define({
868
- name: "beforeRequest" /* beforeRequest */,
869
- invoke: true
870
- })
871
- ], A_Service.prototype, "afterRequest");
872
- __decorateClass([
873
- A_Feature.Define({
874
- name: "onRequest" /* onRequest */,
875
- invoke: false
876
- })
877
- ], A_Service.prototype, "onRequest");
878
- __decorateClass([
879
- A_Feature.Define({ invoke: true })
880
- ], A_Service.prototype, "beforeStop");
881
- __decorateClass([
882
- A_Feature.Define({ invoke: true })
883
- ], A_Service.prototype, "afterStop");
884
-
885
- // src/context/A-ProxyConfig/A_ProxyConfig.constants.ts
886
- var PROXY_CONFIG_DEFAULTS = {
887
- path: "/",
888
- hostname: "localhost",
889
- port: 80,
890
- method: "GET",
891
- headers: {},
892
- protocol: "http"
893
- };
894
-
895
- // src/context/A-ProxyConfig/A_ProxyConfig.context.ts
896
- var A_ProxyConfig = class extends A_Fragment {
897
- constructor(configs = {}) {
898
- super();
899
- this._configs = Object.entries(configs).map(([path, config]) => {
900
- const targetUrl = new URL(typeof config === "string" ? config : config.hostname || "");
901
- const port = targetUrl.port || (targetUrl.protocol === "https:" ? "443" : "80");
902
- const prepared = {
903
- ...PROXY_CONFIG_DEFAULTS,
904
- ...typeof config === "string" ? {
905
- path,
906
- port: parseInt(port),
907
- protocol: targetUrl.protocol,
908
- hostname: targetUrl.hostname
909
- } : config
910
- };
911
- return {
912
- route: new A_Route(prepared.path, prepared.method),
913
- hostname: prepared.hostname,
914
- port: prepared.port,
915
- headers: prepared.headers,
916
- protocol: prepared.protocol
917
- };
918
- });
919
- }
920
- /**
921
- * Returns all configured proxy configs
922
- *
923
- */
924
- get configs() {
925
- return this._configs;
926
- }
927
- /**
928
- * Checks if a given path is configured in the proxy
929
- *
930
- * @param path
931
- * @returns
932
- */
933
- has(path) {
934
- return this._configs.some((route) => route.route.toRegExp().test(path));
935
- }
936
- /**
937
- * Returns the proxy configuration for a given path, if exists
938
- *
939
- * @param path
940
- * @returns
941
- */
942
- config(path) {
943
- return this._configs.find((route) => route.route.toRegExp().test(path));
944
- }
945
- };
946
- var A_StaticConfig = class extends A_Fragment {
947
- constructor(directories = [], directoryConfigs = []) {
948
- super();
949
- this._aliases = /* @__PURE__ */ new Map();
950
- this._directoryConfigs = [];
951
- this.directories = directories;
952
- this._directoryConfigs = directoryConfigs;
953
- this.initializeDefaultAliases();
954
- this.initializeCustomAliases();
955
- }
956
- initializeDefaultAliases() {
957
- this.directories.forEach((dir, index) => {
958
- const alias = {
959
- alias: `/static${index > 0 ? index : ""}`,
960
- path: `/static${index > 0 ? index : ""}`,
961
- directory: dir,
962
- enabled: true
963
- };
964
- this._aliases.set(alias.path, alias);
965
- });
966
- }
967
- initializeCustomAliases() {
968
- this._directoryConfigs.forEach((config) => {
969
- const alias = {
970
- alias: config.alias || config.path,
971
- path: config.path,
972
- directory: config.directory,
973
- enabled: true
974
- };
975
- this._aliases.set(alias.path, alias);
976
- });
977
- }
978
- /**
979
- * Add a custom static file alias
980
- * @param alias - The URL path alias (e.g., '/assets')
981
- * @param directory - The local directory path
982
- * @param path - Optional custom path (defaults to alias)
983
- */
984
- addAlias(alias, directory, path) {
985
- const staticAlias = {
986
- alias,
987
- path: path || alias,
988
- directory,
989
- enabled: true
990
- };
991
- this._aliases.set(staticAlias.path, staticAlias);
992
- }
993
- /**
994
- * Remove a static file alias
995
- * @param aliasPath - The path of the alias to remove
996
- */
997
- removeAlias(aliasPath) {
998
- return this._aliases.delete(aliasPath);
999
- }
1000
- /**
1001
- * Enable or disable an alias
1002
- * @param aliasPath - The path of the alias
1003
- * @param enabled - Whether to enable or disable
1004
- */
1005
- setAliasEnabled(aliasPath, enabled) {
1006
- const alias = this._aliases.get(aliasPath);
1007
- if (alias) {
1008
- alias.enabled = enabled;
1009
- return true;
1010
- }
1011
- return false;
1012
- }
1013
- /**
1014
- * Get all configured aliases
1015
- */
1016
- getAliases() {
1017
- return Array.from(this._aliases.values());
1018
- }
1019
- /**
1020
- * Get enabled aliases only
1021
- */
1022
- getEnabledAliases() {
1023
- return Array.from(this._aliases.values()).filter((alias) => alias.enabled !== false);
1024
- }
1025
- /**
1026
- * Find the best matching alias for a given request path
1027
- * @param requestPath - The request path to match
1028
- */
1029
- findMatchingAlias(requestPath) {
1030
- let bestMatch = null;
1031
- let longestMatch = 0;
1032
- for (const alias of this.getEnabledAliases()) {
1033
- if (requestPath.startsWith(alias.path) && alias.path.length > longestMatch) {
1034
- bestMatch = alias;
1035
- longestMatch = alias.path.length;
1036
- }
1037
- }
1038
- return bestMatch;
1039
- }
1040
- /**
1041
- * Check if an alias exists
1042
- * @param aliasPath - The path to check
1043
- */
1044
- hasAlias(aliasPath) {
1045
- return this._aliases.has(aliasPath);
1046
- }
1047
- /**
1048
- * Get a specific alias by path
1049
- * @param aliasPath - The path of the alias
1050
- */
1051
- getAlias(aliasPath) {
1052
- return this._aliases.get(aliasPath);
1053
- }
1054
- /**
1055
- * Add multiple aliases at once
1056
- * @param aliases - Array of alias configurations
1057
- */
1058
- addAliases(aliases) {
1059
- aliases.forEach((config) => {
1060
- this.addAlias(config.alias || config.path, config.directory, config.path);
1061
- });
1062
- }
1063
- /**
1064
- * Clear all aliases
1065
- */
1066
- clearAliases() {
1067
- this._aliases.clear();
1068
- }
1069
- /**
1070
- * Update an existing alias
1071
- * @param aliasPath - The path of the alias to update
1072
- * @param updates - Partial updates to apply
1073
- */
1074
- updateAlias(aliasPath, updates) {
1075
- const alias = this._aliases.get(aliasPath);
1076
- if (alias) {
1077
- Object.assign(alias, updates);
1078
- return true;
1079
- }
1080
- return false;
1081
- }
1082
- /**
1083
- * Get statistics about configured aliases
1084
- */
1085
- getStats() {
1086
- const aliases = this.getAliases();
1087
- const enabled = aliases.filter((a) => a.enabled !== false);
1088
- const disabled = aliases.filter((a) => a.enabled === false);
1089
- const directories = [...new Set(aliases.map((a) => a.directory))];
1090
- return {
1091
- total: aliases.length,
1092
- enabled: enabled.length,
1093
- disabled: disabled.length,
1094
- directories
1095
- };
1096
- }
1097
- /**
1098
- * Checks if a given path is configured in the proxy (legacy method)
1099
- * @deprecated Use findMatchingAlias instead
1100
- * @param path
1101
- * @returns
1102
- */
1103
- has(path) {
1104
- const alias = this.findMatchingAlias(path);
1105
- return alias ? alias.directory : false;
1106
- }
1107
- };
1108
- var A_ListQueryFilter = class extends A_Fragment {
1109
- constructor(_query = {}, defaults = {}) {
1110
- super();
1111
- this._query = _query;
1112
- this.defaults = defaults;
1113
- this.parsedQuery = this.parseQueryString(_query);
1114
- }
1115
- get query() {
1116
- return this._query;
1117
- }
1118
- get(property, defaultValue = "") {
1119
- return this.parsedQuery[property] || this.defaults[property] || defaultValue;
1120
- }
1121
- parseQueryString(value = {}) {
1122
- if (typeof value === "string") {
1123
- return value.split("&").reduce((acc, part) => {
1124
- const [key, val] = part.split("=");
1125
- acc[decodeURIComponent(key)] = decodeURIComponent(val || "");
1126
- return acc;
1127
- }, {});
1128
- }
1129
- return value;
1130
- }
1131
- };
1132
- var A_EntityFactory = class extends A_Fragment {
1133
- constructor(param1, param2) {
1134
- super();
1135
- this._entities = /* @__PURE__ */ new Map();
1136
- this._setEntities(param1);
1137
- this._setEntities(param2);
1138
- }
1139
- _setEntities(entities = []) {
1140
- if (Array.isArray(entities)) {
1141
- entities.forEach((entity) => {
1142
- this._entities.set(entity.entity, entity);
1143
- });
1144
- } else {
1145
- Object.keys(entities).forEach((key) => {
1146
- this._entities.set(key, entities[key]);
1147
- });
1148
- }
1149
- }
1150
- add(param1, param2) {
1151
- switch (true) {
1152
- case (typeof param1 === "string" && !!param2):
1153
- this._entities.set(param1, param2);
1154
- break;
1155
- case typeof param1 !== "string":
1156
- this._entities.set(param1.entity, param1);
1157
- break;
1158
- }
1159
- }
1160
- has(param1) {
1161
- let name;
1162
- switch (true) {
1163
- case param1 instanceof ASEID:
1164
- name = param1.entity;
1165
- break;
1166
- case (!(param1 instanceof ASEID) && ASEID.isASEID(param1)):
1167
- name = new ASEID(param1).entity;
1168
- break;
1169
- default:
1170
- name = param1;
1171
- break;
1172
- }
1173
- return this._entities.has(name);
1174
- }
1175
- resolve(param1) {
1176
- let name;
1177
- switch (true) {
1178
- case param1 instanceof ASEID:
1179
- name = param1.entity;
1180
- break;
1181
- case (typeof param1 === "string" && ASEID.isASEID(param1)):
1182
- name = new ASEID(param1).entity;
1183
- break;
1184
- default:
1185
- name = param1;
1186
- break;
1187
- }
1188
- return this._entities.get(name);
1189
- }
1190
- resolveByName(name) {
1191
- return this._entities.get(name);
1192
- }
1193
- };
1194
- var A_EntityList = class extends A_Entity {
1195
- constructor() {
1196
- super(...arguments);
1197
- this._items = [];
1198
- this._pagination = {
1199
- total: 0,
1200
- page: 1,
1201
- pageSize: 10
1202
- };
1203
- }
1204
- static get scope() {
1205
- return "a-server";
1206
- }
1207
- /**
1208
- * Returns the entity constructor used for the list
1209
- */
1210
- get entityConstructor() {
1211
- return this._entityConstructor;
1212
- }
1213
- /**
1214
- * Returns the list of items contained in the entity list
1215
- */
1216
- get items() {
1217
- return this._items;
1218
- }
1219
- /**
1220
- * Returns pagination information about the entity list
1221
- */
1222
- get pagination() {
1223
- return this._pagination;
1224
- }
1225
- /**
1226
- * Creates a new instance of A_EntityList
1227
- *
1228
- * @param newEntity
1229
- */
1230
- fromNew(newEntity) {
1231
- this.aseid = new ASEID({
1232
- concept: A_Context.root.name,
1233
- scope: "default",
1234
- entity: "a-list" + (newEntity.name ? `.${newEntity.name}` : ""),
1235
- id: (/* @__PURE__ */ new Date()).getTime().toString()
1236
- });
1237
- this._entityConstructor = newEntity.constructor;
1238
- }
1239
- /**
1240
- * Allows to convert Repository Response data to EntityList instance
1241
- *
1242
- * [!] This method does not load the data from the repository, it only converts the data to the EntityList instance
1243
- *
1244
- * @param items
1245
- * @param pagination
1246
- */
1247
- fromList(items, pagination) {
1248
- this._items = items.map((item) => {
1249
- if (item instanceof A_Entity) {
1250
- return item;
1251
- } else {
1252
- const entity = new this._entityConstructor(item);
1253
- return entity;
1254
- }
1255
- });
1256
- if (pagination) {
1257
- this._pagination = {
1258
- total: pagination.total,
1259
- page: pagination.page,
1260
- pageSize: pagination.pageSize
1261
- };
1262
- }
1263
- }
1264
- /**
1265
- * Serializes the EntityList to a JSON object
1266
- *
1267
- * @returns
1268
- */
1269
- toJSON() {
1270
- return {
1271
- ...super.toJSON(),
1272
- items: this._items.map((i) => i.toJSON()),
1273
- pagination: this._pagination
1274
- };
1275
- }
1276
- };
1277
-
1278
- // src/components/A-Router/A-Router.component.types.ts
1279
- var A_SERVER_TYPES__RouterMethod = /* @__PURE__ */ ((A_SERVER_TYPES__RouterMethod2) => {
1280
- A_SERVER_TYPES__RouterMethod2["POST"] = "POST";
1281
- A_SERVER_TYPES__RouterMethod2["GET"] = "GET";
1282
- A_SERVER_TYPES__RouterMethod2["PUT"] = "PUT";
1283
- A_SERVER_TYPES__RouterMethod2["DELETE"] = "DELETE";
1284
- A_SERVER_TYPES__RouterMethod2["PATCH"] = "PATCH";
1285
- A_SERVER_TYPES__RouterMethod2["DEFAULT"] = "DEFAULT";
1286
- return A_SERVER_TYPES__RouterMethod2;
1287
- })(A_SERVER_TYPES__RouterMethod || {});
1288
- var A_SERVER_TYPES__ARouterComponentMetaKey = /* @__PURE__ */ ((A_SERVER_TYPES__ARouterComponentMetaKey2) => {
1289
- A_SERVER_TYPES__ARouterComponentMetaKey2["ROUTES"] = "ROUTES";
1290
- return A_SERVER_TYPES__ARouterComponentMetaKey2;
1291
- })(A_SERVER_TYPES__ARouterComponentMetaKey || {});
1292
- var _A_Router = class _A_Router extends A_Component {
1293
- // =======================================================
1294
- // ================ Method Definition=====================
1295
- // =======================================================
1296
- /**
1297
- * Allows to define a custom route for POST requests
1298
- *
1299
- * @param path
1300
- * @returns
1301
- */
1302
- static Post(path) {
1303
- return this.defineRoute({
1304
- method: "POST" /* POST */,
1305
- path: typeof path === "object" && "path" in path ? path.path : path,
1306
- version: typeof path === "object" && "version" in path && path.version ? path.version : "v1",
1307
- prefix: typeof path === "object" && "prefix" in path && path.prefix ? path.prefix : "api"
1308
- });
1309
- }
1310
- /**
1311
- * Allows to define a custom route for GET requests
1312
- *
1313
- * @param path
1314
- * @returns
1315
- */
1316
- static Get(path) {
1317
- return this.defineRoute({
1318
- method: "GET" /* GET */,
1319
- path: typeof path === "object" && "path" in path ? path.path : path,
1320
- version: typeof path === "object" && "version" in path && path.version ? path.version : "v1",
1321
- prefix: typeof path === "object" && "prefix" in path && path.prefix ? path.prefix : "api"
1322
- });
1323
- }
1324
- /**
1325
- * Allows to define a custom route for PUT requests
1326
- *
1327
- * @param path
1328
- * @returns
1329
- */
1330
- static Put(path) {
1331
- return this.defineRoute({
1332
- method: "PUT" /* PUT */,
1333
- path: typeof path === "object" && "path" in path ? path.path : path,
1334
- version: typeof path === "object" && "version" in path && path.version ? path.version : "v1",
1335
- prefix: typeof path === "object" && "prefix" in path && path.prefix ? path.prefix : "api"
1336
- });
1337
- }
1338
- /**
1339
- * Allows to define a custom route for DELETE requests
1340
- *
1341
- * @param path
1342
- * @returns
1343
- */
1344
- static Delete(path) {
1345
- return this.defineRoute({
1346
- method: "DELETE" /* DELETE */,
1347
- path: typeof path === "object" && "path" in path ? path.path : path,
1348
- version: typeof path === "object" && "version" in path && path.version ? path.version : "v1",
1349
- prefix: typeof path === "object" && "prefix" in path && path.prefix ? path.prefix : "api"
1350
- });
1351
- }
1352
- /**
1353
- * Allows to define a custom route for PATCH requests
1354
- *
1355
- * @param path
1356
- * @returns
1357
- */
1358
- static Patch(path) {
1359
- return this.defineRoute({
1360
- method: "PATCH" /* PATCH */,
1361
- path: typeof path === "object" && "path" in path ? path.path : path,
1362
- version: typeof path === "object" && "version" in path && path.version ? path.version : "v1",
1363
- prefix: typeof path === "object" && "prefix" in path && path.prefix ? path.prefix : "api"
1364
- });
1365
- }
1366
- /**
1367
- * Allows to define a custom route for DEFAULT requests
1368
- *
1369
- * @param path
1370
- * @returns
1371
- */
1372
- static Default(path) {
1373
- return this.defineRoute({
1374
- method: "DEFAULT" /* DEFAULT */,
1375
- path: typeof path === "object" && "path" in path ? path.path : path,
1376
- version: typeof path === "object" && "version" in path && path.version ? path.version : "v1",
1377
- prefix: typeof path === "object" && "prefix" in path && path.prefix ? path.prefix : "api"
1378
- });
1379
- }
1380
- /**
1381
- * Private method to have the same signature for all route methods
1382
- *
1383
- * @param method
1384
- * @param path
1385
- * @returns
1386
- */
1387
- static defineRoute(config) {
1388
- const route = typeof config.path === "string" || config.path instanceof RegExp ? new A_Route(
1389
- `/${config.prefix}/${config.version}${config.path instanceof RegExp ? config.path.source : config.path.startsWith("/") ? config.path : `/${config.path}`}`,
1390
- config.method
1391
- ) : config.path;
1392
- this.routes.push(route);
1393
- return function decorator(target, propertyKey, descriptor) {
1394
- const meta = A_Context.meta(target);
1395
- const routes = meta.get("ROUTES" /* ROUTES */) || /* @__PURE__ */ new Map();
1396
- const searchKey = route.toAFeatureExtension(["A_Router", "A_Service"]);
1397
- routes.set(searchKey.source, {
1398
- component: target,
1399
- handler: propertyKey,
1400
- route
1401
- });
1402
- meta.set("ROUTES" /* ROUTES */, routes);
1403
- A_Feature_Define({
1404
- name: searchKey.source,
1405
- invoke: false
1406
- })(target, propertyKey, descriptor);
1407
- return A_Feature_Extend(searchKey)(target, propertyKey, descriptor);
1408
- };
1409
- }
1410
- async load(logger) {
1411
- logger.routes(_A_Router.routes);
1412
- }
1413
- async identifyRoute(request, response, scope, config, logger) {
1414
- const route = request.route;
1415
- if (config.get("A_CONCEPT_ENVIRONMENT") === "development") {
1416
- logger.log(`Incoming request: ${request.method} ${request.url}`);
1417
- logger.log(`Identified route: ${route.toString()}`);
1418
- }
1419
- const feature = new A_Feature({
1420
- name: route.toString(),
1421
- component: this
1422
- });
1423
- for (const stage of feature) {
1424
- if (A_TypeGuards.isComponentConstructor(stage.definition.component)) {
1425
- const meta = A_Context.meta(stage.definition.component);
1426
- const routes = meta.get("ROUTES" /* ROUTES */);
1427
- if (routes) {
1428
- const currentRoute = routes.get(stage.definition.name || "");
1429
- if (currentRoute) {
1430
- request.params = {
1431
- ...request.params,
1432
- ...currentRoute.route.extractParams(request.url)
1433
- };
1434
- }
1435
- }
1436
- }
1437
- const stageScope = new A_Scope({
1438
- name: `a-route--${A_IdentityHelper.generateTimeId()}`,
1439
- entities: [request]
1440
- }, {
1441
- parent: scope
1442
- });
1443
- await stage.process(stageScope);
1444
- }
1445
- console.log("Finished processing route for request:", request.method, request.url);
1446
- }
1447
- };
1448
- _A_Router.routes = [];
1449
- __decorateClass([
1450
- A_Concept.Load(),
1451
- __decorateParam(0, A_Inject(A_ServerLogger))
1452
- ], _A_Router.prototype, "load");
1453
- __decorateClass([
1454
- A_Feature.Extend({
1455
- name: "onRequest" /* onRequest */,
1456
- scope: [A_Service]
1457
- }),
1458
- __decorateParam(0, A_Inject(A_Request)),
1459
- __decorateParam(1, A_Inject(A_Response)),
1460
- __decorateParam(2, A_Inject(A_Scope)),
1461
- __decorateParam(3, A_Inject(A_Config)),
1462
- __decorateParam(4, A_Inject(A_Logger))
1463
- ], _A_Router.prototype, "identifyRoute");
1464
- var A_Router = _A_Router;
1465
- var A_EntityController = class extends A_Component {
1466
- async list(request, response, factory, scope, config) {
1467
- const constructor = factory.resolveByName(request.params.type);
1468
- if (constructor) {
1469
- const entityList = new A_EntityList({
1470
- name: request.params.type,
1471
- scope: scope.name,
1472
- constructor
1473
- });
1474
- scope.register(entityList);
1475
- const queryFilter = new A_ListQueryFilter(request.query, {
1476
- itemsPerPage: String(config.get("A_LIST_ITEMS_PER_PAGE") || "10"),
1477
- page: String(config.get("A_LIST_PAGE") || "1")
1478
- });
1479
- const queryScope = new A_Scope({
1480
- fragments: [queryFilter]
1481
- }).inherit(scope);
1482
- await entityList.load(queryScope);
1483
- response.add("items", entityList.items);
1484
- response.add("pagination", entityList.pagination);
1485
- }
1486
- }
1487
- async load(request, response, scope) {
1488
- if (!ASEID.isASEID(request.params.aseid)) {
1489
- response.add("A_EntityController.load", "Invalid ASEID");
1490
- return;
1491
- }
1492
- const aseid = new ASEID(request.params.aseid);
1493
- const constructor = scope.resolveConstructor(aseid.entity);
1494
- if (constructor) {
1495
- const entity = new constructor(request.params.aseid);
1496
- scope.register(entity);
1497
- await entity.load();
1498
- return response.status(200).json(entity.toJSON());
1499
- } else
1500
- throw new A_ServerError({
1501
- title: "Entity Not Found",
1502
- description: `Entity constructor for ASEID ${request.params.aseid} not found`,
1503
- status: 404
1504
- });
1505
- }
1506
- async create(request, factory, scope) {
1507
- const constructor = factory.resolve(request.params.aseid);
1508
- if (constructor) {
1509
- const entity = new constructor(request.body);
1510
- scope.register(entity);
1511
- await entity.save();
1512
- }
1513
- }
1514
- async update(request, response, factory, scope) {
1515
- if (!ASEID.isASEID(request.params.aseid)) {
1516
- response.add("A_EntityController.update", "Invalid ASEID");
1517
- return;
1518
- }
1519
- const constructor = factory.resolve(request.params.aseid);
1520
- if (constructor) {
1521
- const entity = new constructor(request.body);
1522
- scope.register(entity);
1523
- await entity.save();
1524
- }
1525
- }
1526
- async delete(request, response, factory, scope) {
1527
- if (!ASEID.isASEID(request.params.aseid)) {
1528
- response.add("A_EntityController.delete", "Invalid ASEID");
1529
- return;
1530
- }
1531
- const constructor = factory.resolve(request.params.aseid);
1532
- if (constructor) {
1533
- const entity = new constructor(request.params.aseid);
1534
- scope.register(entity);
1535
- await entity.destroy();
1536
- }
1537
- }
1538
- async callEntity(request, response, factory, scope) {
1539
- if (!ASEID.isASEID(request.params.aseid)) {
1540
- response.add("A_EntityController.callEntity", "Invalid ASEID");
1541
- return;
1542
- }
1543
- const constructor = factory.resolve(request.params.aseid);
1544
- if (!constructor) {
1545
- response.add("A_EntityController.callEntity", "Entity not found");
1546
- return;
1547
- }
1548
- const meta = A_Context.meta(constructor);
1549
- const targetFeature = meta.features().find((f) => f.name === `${constructor.name}.${request.params.action}`);
1550
- if (!targetFeature) {
1551
- response.add("A_EntityController.callEntity", "Feature not found");
1552
- return;
1553
- }
1554
- const entity = new constructor(request.params.aseid);
1555
- scope.register(entity);
1556
- await entity.load(scope);
1557
- await entity[targetFeature.handler](scope);
1558
- response.add("result", scope.toJSON());
1559
- response.add("entity", entity);
1560
- response.add("type", entity.aseid.entity);
1561
- }
1562
- };
1563
- __decorateClass([
1564
- A_Router.Get({
1565
- path: "/:type",
1566
- version: "v1",
1567
- prefix: "a-list"
1568
- }),
1569
- __decorateParam(0, A_Inject(A_Request)),
1570
- __decorateParam(1, A_Inject(A_Response)),
1571
- __decorateParam(2, A_Inject(A_EntityFactory)),
1572
- __decorateParam(3, A_Inject(A_Scope)),
1573
- __decorateParam(4, A_Inject(A_Config))
1574
- ], A_EntityController.prototype, "list");
1575
- __decorateClass([
1576
- A_Feature.Define({
1577
- name: "getEntity",
1578
- invoke: false
1579
- }),
1580
- A_Router.Get({
1581
- path: "/:aseid",
1582
- version: "v1",
1583
- prefix: "a-entity"
1584
- }),
1585
- __decorateParam(0, A_Inject(A_Request)),
1586
- __decorateParam(1, A_Inject(A_Response)),
1587
- __decorateParam(2, A_Inject(A_Scope))
1588
- ], A_EntityController.prototype, "load");
1589
- __decorateClass([
1590
- A_Router.Post({
1591
- path: "/",
1592
- version: "v1",
1593
- prefix: "a-entity"
1594
- }),
1595
- __decorateParam(0, A_Inject(A_Request)),
1596
- __decorateParam(1, A_Inject(A_EntityFactory)),
1597
- __decorateParam(2, A_Inject(A_Scope))
1598
- ], A_EntityController.prototype, "create");
1599
- __decorateClass([
1600
- A_Router.Put({
1601
- path: "/:aseid",
1602
- version: "v1",
1603
- prefix: "a-entity"
1604
- }),
1605
- __decorateParam(0, A_Inject(A_Request)),
1606
- __decorateParam(1, A_Inject(A_Response)),
1607
- __decorateParam(2, A_Inject(A_EntityFactory)),
1608
- __decorateParam(3, A_Inject(A_Scope))
1609
- ], A_EntityController.prototype, "update");
1610
- __decorateClass([
1611
- A_Router.Delete({
1612
- path: "/:aseid",
1613
- version: "v1",
1614
- prefix: "a-entity"
1615
- }),
1616
- __decorateParam(0, A_Inject(A_Request)),
1617
- __decorateParam(1, A_Inject(A_Response)),
1618
- __decorateParam(2, A_Inject(A_EntityFactory)),
1619
- __decorateParam(3, A_Inject(A_Scope))
1620
- ], A_EntityController.prototype, "delete");
1621
- __decorateClass([
1622
- A_Router.Post({
1623
- path: "/:aseid/:action",
1624
- version: "v1",
1625
- prefix: "a-entity"
1626
- }),
1627
- __decorateParam(0, A_Inject(A_Request)),
1628
- __decorateParam(1, A_Inject(A_Response)),
1629
- __decorateParam(2, A_Inject(A_EntityFactory)),
1630
- __decorateParam(3, A_Inject(A_Scope))
1631
- ], A_EntityController.prototype, "callEntity");
1632
- var A_ServerHealthMonitor = class extends A_Component {
1633
- async get(config, request, response, logger) {
1634
- logger.log("Health check requested", config.get("A_CONCEPT_ROOT_FOLDER"));
1635
- const packageJSON = await import(`${config.get("A_CONCEPT_ROOT_FOLDER")}/package.json`);
1636
- const exposedProperties = config.get("EXPOSED_PROPERTIES")?.split(",") || [
1637
- "name",
1638
- "version",
1639
- "description"
1640
- ];
1641
- exposedProperties.forEach((prop) => response.add(prop, packageJSON[prop]));
1642
- console.log(`Health check accessed: ${request.method} ${request.url}`);
1643
- }
1644
- };
1645
- __decorateClass([
1646
- A_Router.Get({
1647
- path: "/",
1648
- prefix: "health",
1649
- version: "v1"
1650
- }),
1651
- __decorateParam(0, A_Inject(A_Config)),
1652
- __decorateParam(1, A_Inject(A_Request)),
1653
- __decorateParam(2, A_Inject(A_Response)),
1654
- __decorateParam(3, A_Inject(A_Logger))
1655
- ], A_ServerHealthMonitor.prototype, "get");
1656
- var A_ServerProxy = class extends A_Component {
1657
- async load(logger, config) {
1658
- logger.log(
1659
- "pink",
1660
- `Proxy routes configured:`,
1661
- config.configs.map((c) => c.route).join("\n")
1662
- );
1663
- }
1664
- async onRequest(req, res, proxyConfig, logger, polyfill) {
1665
- return new Promise(async (resolve, reject) => {
1666
- const { method, url } = req;
1667
- const route = new A_Route(url, method);
1668
- const config = proxyConfig.config(route.toString());
1669
- if (!config) {
1670
- return resolve();
1671
- }
1672
- logger.log(
1673
- "yellow",
1674
- `Proxying request ${method} ${url} to ${config.hostname}`,
1675
- config
1676
- );
1677
- const client = await (config.protocol === "https:" ? polyfill.https() : polyfill.http());
1678
- const proxyReq = client.request(
1679
- {
1680
- method: config.route.method,
1681
- hostname: config.hostname,
1682
- port: config.port,
1683
- headers: config.headers,
1684
- path: route.path
1685
- },
1686
- (proxyRes) => {
1687
- if (!res.headersSent) {
1688
- res.writeHead(proxyRes.statusCode || 200, proxyRes.headers);
1689
- }
1690
- proxyRes.on("end", () => {
1691
- logger.log("green", `Proxy request to ${config?.hostname} completed`);
1692
- resolve();
1693
- });
1694
- proxyRes.pipe(res.original);
1695
- }
1696
- );
1697
- proxyReq.on("error", (err) => reject(err));
1698
- req.pipe(proxyReq);
1699
- });
1700
- }
1701
- };
1702
- __decorateClass([
1703
- A_Concept.Load(),
1704
- __decorateParam(0, A_Inject(A_Logger)),
1705
- __decorateParam(1, A_Inject(A_ProxyConfig))
1706
- ], A_ServerProxy.prototype, "load");
1707
- __decorateClass([
1708
- A_Feature.Extend({
1709
- name: "onRequest" /* onRequest */
1710
- }),
1711
- __decorateParam(0, A_Inject(A_Request)),
1712
- __decorateParam(1, A_Inject(A_Response)),
1713
- __decorateParam(2, A_Inject(A_ProxyConfig)),
1714
- __decorateParam(3, A_Inject(A_Logger)),
1715
- __decorateParam(4, A_Inject(A_Polyfill))
1716
- ], A_ServerProxy.prototype, "onRequest");
1717
-
1718
- // src/components/A-ServerCORS/A_ServerCORS.component.defaults.ts
1719
- var A_SERVER_DEFAULTS__CorsConfig = {
1720
- origin: "*",
1721
- // Default to allow all origins
1722
- methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
1723
- headers: ["Content-Type"],
1724
- credentials: false,
1725
- maxAge: 0
1726
- };
1727
- var A_ServerCORS = class extends A_Component {
1728
- async init(config) {
1729
- this.config = {
1730
- origin: config.get("ORIGIN") || A_SERVER_DEFAULTS__CorsConfig.origin,
1731
- methods: config.get("METHODS") || A_SERVER_DEFAULTS__CorsConfig.methods,
1732
- headers: config.get("HEADERS") || A_SERVER_DEFAULTS__CorsConfig.headers,
1733
- credentials: config.get("CREDENTIALS") || A_SERVER_DEFAULTS__CorsConfig.credentials,
1734
- maxAge: config.get("MAX_AGE") || A_SERVER_DEFAULTS__CorsConfig.maxAge
1735
- };
1736
- }
1737
- apply(aReq, aRes) {
1738
- aRes.setHeader("Access-Control-Allow-Origin", this.config.origin);
1739
- aRes.setHeader("Access-Control-Allow-Methods", this.config.methods.join(", "));
1740
- aRes.setHeader("Access-Control-Allow-Headers", this.config.headers.join(", "));
1741
- if (this.config.credentials) {
1742
- aRes.setHeader("Access-Control-Allow-Credentials", "true");
1743
- }
1744
- if (this.config.maxAge) {
1745
- aRes.setHeader("Access-Control-Max-Age", this.config.maxAge.toString());
1746
- }
1747
- if (aReq.req.method === "OPTIONS") {
1748
- aRes.status(204).send();
1749
- }
1750
- }
1751
- };
1752
- __decorateClass([
1753
- A_Feature.Extend({
1754
- name: "beforeStart" /* beforeStart */
1755
- }),
1756
- __decorateParam(0, A_Inject(A_Config))
1757
- ], A_ServerCORS.prototype, "init");
1758
- __decorateClass([
1759
- A_Feature.Extend({
1760
- name: "beforeRequest" /* beforeRequest */
1761
- }),
1762
- __decorateParam(0, A_Inject(A_Request)),
1763
- __decorateParam(1, A_Inject(A_Response))
1764
- ], A_ServerCORS.prototype, "apply");
1765
- var A_StaticLoader = class extends A_Component {
1766
- async load(logger, config, polyfill) {
1767
- this._fsPolyfill = await polyfill.fs();
1768
- this._pathPolyfill = await polyfill.path();
1769
- const aliases = config.getEnabledAliases();
1770
- logger.log(
1771
- "pink",
1772
- `Static aliases configured:`,
1773
- aliases.map((alias) => `${alias.alias} -> ${alias.directory}`).join("\n")
1774
- );
1775
- }
1776
- async onRequest(req, res, logger, config, polyfill) {
1777
- if (req.method !== "GET" && req.method !== "HEAD") {
1778
- return;
1779
- }
1780
- const { method, url } = req;
1781
- const route = new A_Route(url, method);
1782
- const alias = config.findMatchingAlias(route.path);
1783
- if (!alias) {
1784
- return;
1785
- }
1786
- try {
1787
- const fs = this._fsPolyfill || await polyfill.fs();
1788
- const path = this._pathPolyfill || await polyfill.path();
1789
- const staticDir = path.resolve(process.cwd(), alias.directory);
1790
- if (!fs.existsSync(staticDir)) {
1791
- logger.log("red", `Static directory ${staticDir} does not exist.`);
1792
- return;
1793
- }
1794
- const relativePath = route.path.replace(alias.path, "");
1795
- const safePath = this.safeFilePath(staticDir, relativePath, req.headers?.host, path, fs);
1796
- await this.serveFile(safePath, res, logger, fs, path);
1797
- } catch (error) {
1798
- logger.error(`Static file serving error: ${error.message}`);
1799
- res.writeHead(404, { "Content-Type": "text/plain" });
1800
- res.send("File not found");
1801
- }
1802
- }
1803
- /**
1804
- * Add a custom static file alias through the config
1805
- * @param alias - The URL path alias (e.g., '/assets')
1806
- * @param directory - The local directory path
1807
- * @param path - Optional custom path (defaults to alias)
1808
- * @param config - Static config instance
1809
- * @param logger - Logger instance for logging
1810
- */
1811
- addAlias(alias, directory, config, logger, path) {
1812
- config.addAlias(alias, directory, path);
1813
- if (logger) {
1814
- logger.log("cyan", `Static alias added: ${alias} -> ${directory}`);
1815
- }
1816
- }
1817
- /**
1818
- * Remove a static file alias through the config
1819
- * @param aliasPath - The path of the alias to remove
1820
- * @param config - Static config instance
1821
- * @param logger - Logger instance for logging
1822
- */
1823
- removeAlias(aliasPath, config, logger) {
1824
- const removed = config.removeAlias(aliasPath);
1825
- if (removed && logger) {
1826
- logger.log("yellow", `Static alias removed: ${aliasPath}`);
1827
- }
1828
- return removed;
1829
- }
1830
- /**
1831
- * Get all configured aliases from config
1832
- * @param config - Static config instance
1833
- */
1834
- getAliases(config) {
1835
- return config.getAliases();
1836
- }
1837
- /**
1838
- * Enable or disable an alias
1839
- * @param aliasPath - The path of the alias
1840
- * @param enabled - Whether to enable or disable
1841
- * @param config - Static config instance
1842
- * @param logger - Logger instance for logging
1843
- */
1844
- setAliasEnabled(aliasPath, enabled, config, logger) {
1845
- const result = config.setAliasEnabled(aliasPath, enabled);
1846
- if (result && logger) {
1847
- logger.log("blue", `Static alias ${enabled ? "enabled" : "disabled"}: ${aliasPath}`);
1848
- }
1849
- return result;
1850
- }
1851
- getMimeType(ext) {
1852
- const mimeTypes = {
1853
- // Text
1854
- ".html": "text/html",
1855
- ".htm": "text/html",
1856
- ".css": "text/css",
1857
- ".txt": "text/plain",
1858
- ".md": "text/markdown",
1859
- ".xml": "application/xml",
1860
- // JavaScript
1861
- ".js": "application/javascript",
1862
- ".mjs": "application/javascript",
1863
- ".jsx": "application/javascript",
1864
- ".ts": "application/typescript",
1865
- ".tsx": "application/typescript",
1866
- // JSON
1867
- ".json": "application/json",
1868
- ".jsonld": "application/ld+json",
1869
- // Images
1870
- ".png": "image/png",
1871
- ".jpg": "image/jpeg",
1872
- ".jpeg": "image/jpeg",
1873
- ".gif": "image/gif",
1874
- ".svg": "image/svg+xml",
1875
- ".ico": "image/x-icon",
1876
- ".webp": "image/webp",
1877
- ".bmp": "image/bmp",
1878
- ".tiff": "image/tiff",
1879
- // Fonts
1880
- ".woff": "font/woff",
1881
- ".woff2": "font/woff2",
1882
- ".ttf": "font/ttf",
1883
- ".otf": "font/otf",
1884
- ".eot": "application/vnd.ms-fontobject",
1885
- // Audio/Video
1886
- ".mp3": "audio/mpeg",
1887
- ".wav": "audio/wav",
1888
- ".mp4": "video/mp4",
1889
- ".webm": "video/webm",
1890
- ".ogg": "application/ogg",
1891
- // Archives
1892
- ".zip": "application/zip",
1893
- ".tar": "application/x-tar",
1894
- ".gz": "application/gzip",
1895
- // Documents
1896
- ".pdf": "application/pdf",
1897
- ".doc": "application/msword",
1898
- ".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
1899
- ".xls": "application/vnd.ms-excel",
1900
- ".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
1901
- };
1902
- return mimeTypes[ext.toLowerCase()] || "application/octet-stream";
1903
- }
1904
- safeFilePath(staticDir, reqUrl, host = "localhost", pathPolyfill, fsPolyfill) {
1905
- const parsedUrl = new URL(reqUrl || "/", `http://${host}`);
1906
- let pathname = decodeURIComponent(parsedUrl.pathname);
1907
- pathname = pathname.replace(/\.\.[\/\\]/g, "");
1908
- let filePath = pathPolyfill.join(staticDir, pathname);
1909
- if (!fsPolyfill.existsSync(filePath)) {
1910
- throw new Error(`File not found: ${filePath}`);
1911
- }
1912
- return filePath;
1913
- }
1914
- serveFile(filePath, res, logger, fsPolyfill, pathPolyfill) {
1915
- return new Promise((resolve, reject) => {
1916
- try {
1917
- if (fsPolyfill.existsSync(filePath)) {
1918
- const ext = pathPolyfill.extname(filePath);
1919
- const contentType = this.getMimeType(ext);
1920
- const headers = {
1921
- "Content-Type": contentType,
1922
- "Cache-Control": this.getCacheControl(ext),
1923
- "X-Content-Type-Options": "nosniff"
1924
- };
1925
- res.writeHead(200, headers);
1926
- const stream = fsPolyfill.createReadStream(filePath);
1927
- if (stream && res.original) {
1928
- stream.pipe(res.original);
1929
- stream.on("end", () => {
1930
- logger.log("green", `Successfully served: ${filePath}`);
1931
- resolve();
1932
- });
1933
- stream.on("error", (err) => {
1934
- logger.error(`File stream error: ${err.message}`);
1935
- reject(new Error(`File stream error: ${err.message}`));
1936
- });
1937
- } else {
1938
- res.writeHead(500, { "Content-Type": "text/plain" });
1939
- res.send("Internal server error");
1940
- reject(new Error("Failed to create file stream"));
1941
- }
1942
- } else {
1943
- res.writeHead(404, { "Content-Type": "text/plain" });
1944
- res.send("File not found");
1945
- reject(new Error(`File not found: ${filePath}`));
1946
- }
1947
- } catch (error) {
1948
- logger.error(`Error serving file: ${error.message}`);
1949
- res.writeHead(500, { "Content-Type": "text/plain" });
1950
- res.send("Internal server error");
1951
- reject(error);
1952
- }
1953
- });
1954
- }
1955
- getCacheControl(ext) {
1956
- const staticAssets = [".css", ".js", ".png", ".jpg", ".jpeg", ".gif", ".svg", ".ico", ".woff", ".woff2", ".ttf", ".otf"];
1957
- const dynamicContent = [".html", ".htm"];
1958
- if (staticAssets.includes(ext.toLowerCase())) {
1959
- return "public, max-age=31536000";
1960
- } else if (dynamicContent.includes(ext.toLowerCase())) {
1961
- return "public, max-age=3600";
1962
- } else {
1963
- return "public, max-age=86400";
1964
- }
1965
- }
1966
- };
1967
- __decorateClass([
1968
- A_Concept.Load(),
1969
- __decorateParam(0, A_Inject(A_Logger)),
1970
- __decorateParam(1, A_Inject(A_StaticConfig)),
1971
- __decorateParam(2, A_Inject(A_Polyfill))
1972
- ], A_StaticLoader.prototype, "load");
1973
- __decorateClass([
1974
- A_Feature.Extend({
1975
- name: "onRequest" /* onRequest */
1976
- }),
1977
- __decorateParam(0, A_Inject(A_Request)),
1978
- __decorateParam(1, A_Inject(A_Response)),
1979
- __decorateParam(2, A_Inject(A_Logger)),
1980
- __decorateParam(3, A_Inject(A_StaticConfig)),
1981
- __decorateParam(4, A_Inject(A_Polyfill))
1982
- ], A_StaticLoader.prototype, "onRequest");
1983
- var A_Controller = class extends A_Component {
1984
- async callEntityMethod(request, response, scope) {
1985
- if (!scope.has(request.params.component))
1986
- return;
1987
- if (!request.params.operation || typeof request.params.operation !== "string")
1988
- return;
1989
- const possibleComponent = scope.resolve(request.params.component);
1990
- if (!possibleComponent || ![A_Component, A_Container].some((c) => possibleComponent instanceof c))
1991
- return;
1992
- const component = possibleComponent;
1993
- const meta = A_Context.meta(component);
1994
- const targetFeature = meta.features().find((f) => f.name === `${component.constructor.name}.${request.params.operation}`);
1995
- if (!targetFeature)
1996
- return;
1997
- await component.call(request.params.operation, scope);
1998
- }
1999
- };
2000
- __decorateClass([
2001
- A_Router.Post({
2002
- path: "/:component/:operation",
2003
- version: "v1",
2004
- prefix: "a-component"
2005
- }),
2006
- __decorateParam(0, A_Inject(A_Request)),
2007
- __decorateParam(1, A_Inject(A_Response)),
2008
- __decorateParam(2, A_Inject(A_Scope))
2009
- ], A_Controller.prototype, "callEntityMethod");
2010
- var A_ListingController = class extends A_Component {
2011
- async list(request, response, factory, scope, config) {
2012
- const constructor = factory.resolveByName(request.params.type);
2013
- if (constructor) {
2014
- const entityList = new A_EntityList({
2015
- name: request.params.type,
2016
- scope: scope.name,
2017
- constructor
2018
- });
2019
- scope.register(entityList);
2020
- const queryFilter = new A_ListQueryFilter(request.query, {
2021
- itemsPerPage: String(config.get("A_LIST_ITEMS_PER_PAGE") || "10"),
2022
- page: String(config.get("A_LIST_PAGE") || "1")
2023
- });
2024
- const queryScope = new A_Scope({
2025
- fragments: [queryFilter]
2026
- }).inherit(scope);
2027
- await entityList.load(queryScope);
2028
- response.add("items", entityList.items);
2029
- response.add("pagination", entityList.pagination);
2030
- }
2031
- }
2032
- };
2033
- __decorateClass([
2034
- A_Router.Get({
2035
- path: "/:type",
2036
- version: "v1",
2037
- prefix: "a-list"
2038
- }),
2039
- __decorateParam(0, A_Inject(A_Request)),
2040
- __decorateParam(1, A_Inject(A_Response)),
2041
- __decorateParam(2, A_Inject(A_EntityFactory)),
2042
- __decorateParam(3, A_Inject(A_Scope)),
2043
- __decorateParam(4, A_Inject(A_Config))
2044
- ], A_ListingController.prototype, "list");
2045
- var A_CommandController = class extends A_Component {
2046
- async handleCommand(req, res, scope, container) {
2047
- const commandName = req.params.command;
2048
- const CommandConstructor = scope.resolveConstructor(commandName);
2049
- if (!CommandConstructor) {
2050
- res.status(404);
2051
- throw new Error(`Command ${commandName} not found`);
2052
- }
2053
- const command = new CommandConstructor(req.body);
2054
- container.scope.register(command);
2055
- await command.execute();
2056
- const serialized = command.toJSON();
2057
- return res.status(200).json(serialized);
2058
- }
2059
- };
2060
- __decorateClass([
2061
- A_Router.Get({
2062
- path: "/:command/execute",
2063
- version: "v1",
2064
- prefix: "a-command"
2065
- }),
2066
- __decorateParam(0, A_Inject(A_Request)),
2067
- __decorateParam(1, A_Inject(A_Response)),
2068
- __decorateParam(2, A_Inject(A_Scope)),
2069
- __decorateParam(3, A_Inject(A_Container))
2070
- ], A_CommandController.prototype, "handleCommand");
2071
- var A_EntityRepository = class extends A_Component {
2072
- async list(channel, entity, scope) {
2073
- if (scope.has(A_Manifest) && !scope.resolve(A_Manifest).isAllowed(entity.constructor, "load").for(entity.constructor))
2074
- return;
2075
- const response = await channel.get(`/a-list/${entity.aseid.entity}`);
2076
- entity.fromJSON(response.data);
2077
- }
2078
- async load(channel, entity, scope) {
2079
- if (scope.has(A_Manifest) && !scope.resolve(A_Manifest).isAllowed(entity.constructor, "load").for(entity.constructor))
2080
- return;
2081
- const response = await channel.get(`/a-entity/${entity.aseid.toString()}`);
2082
- entity.fromJSON(response.data);
2083
- }
2084
- async save(channel, entity, scope) {
2085
- if (scope.has(A_Manifest) && !scope.resolve(A_Manifest).isAllowed(entity.constructor, "save").for(entity.constructor))
2086
- return;
2087
- const response = await channel.post(`/a-entity/${entity.aseid.toString()}`, entity.toJSON());
2088
- entity.fromJSON(response.data);
2089
- }
2090
- async destroy(channel, entity, scope) {
2091
- if (scope.has(A_Manifest) && !scope.resolve(A_Manifest).isAllowed(entity.constructor, "destroy").for(entity.constructor))
2092
- return;
2093
- const response = await channel.delete(`/a-entity/${entity.aseid.toString()}`);
2094
- entity.fromJSON(response.data);
2095
- }
2096
- };
2097
- __decorateClass([
2098
- A_Feature.Extend({
2099
- name: A_TYPES__EntityFeatures.LOAD,
2100
- scope: {
2101
- include: [A_EntityList]
2102
- }
2103
- }),
2104
- __decorateParam(0, A_Inject(A_HTTPChannel)),
2105
- __decorateParam(1, A_Inject(A_Caller)),
2106
- __decorateParam(2, A_Inject(A_Scope))
2107
- ], A_EntityRepository.prototype, "list");
2108
- __decorateClass([
2109
- A_Feature.Extend({
2110
- name: A_TYPES__EntityFeatures.LOAD,
2111
- scope: {
2112
- exclude: [A_EntityList]
2113
- }
2114
- }),
2115
- __decorateParam(0, A_Inject(A_HTTPChannel)),
2116
- __decorateParam(1, A_Inject(A_Caller)),
2117
- __decorateParam(2, A_Inject(A_Scope))
2118
- ], A_EntityRepository.prototype, "load");
2119
- __decorateClass([
2120
- A_Feature.Extend({
2121
- name: A_TYPES__EntityFeatures.SAVE,
2122
- scope: {
2123
- exclude: [A_EntityList]
2124
- }
2125
- }),
2126
- __decorateParam(0, A_Inject(A_HTTPChannel)),
2127
- __decorateParam(1, A_Inject(A_Caller)),
2128
- __decorateParam(2, A_Inject(A_Scope))
2129
- ], A_EntityRepository.prototype, "save");
2130
- __decorateClass([
2131
- A_Feature.Extend({
2132
- name: A_TYPES__EntityFeatures.DESTROY,
2133
- scope: {
2134
- exclude: [A_EntityList]
2135
- }
2136
- }),
2137
- __decorateParam(0, A_Inject(A_HTTPChannel)),
2138
- __decorateParam(1, A_Inject(A_Caller)),
2139
- __decorateParam(2, A_Inject(A_Scope))
2140
- ], A_EntityRepository.prototype, "destroy");
2141
-
2142
- export { A_CommandController, A_Controller, A_EntityController, A_EntityFactory, A_EntityList, A_EntityRepository, A_HTTPChannel, A_HTTPChannelError, A_HTTPChannel_RequestContext, A_ListQueryFilter, A_ListingController, A_ProxyConfig, A_Request, A_Response, A_Route, A_Router, A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle, A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES, A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY, A_SERVER_TYPES__ARouterComponentMetaKey, A_SERVER_TYPES__RequestEvent, A_SERVER_TYPES__ResponseEvent, A_SERVER_TYPES__RouterMethod, A_SERVER_TYPES__ServerFeature, A_SERVER_TYPES__ServerMethod, A_Server, A_ServerCORS, A_ServerError, A_ServerHealthMonitor, A_ServerLogger, A_ServerProxy, A_Service, A_StaticConfig, A_StaticLoader };
2143
- //# sourceMappingURL=index.mjs.map
2144
- //# sourceMappingURL=index.mjs.map