jimpex 7.0.2 → 8.0.0

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 (388) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/LICENSE +1 -1
  3. package/README.md +446 -434
  4. package/dist/app/index.d.ts +13 -0
  5. package/dist/app/index.js +19 -0
  6. package/dist/app/index.js.map +1 -0
  7. package/dist/app/jimpex.d.ts +13 -0
  8. package/dist/app/jimpex.js +440 -0
  9. package/dist/app/jimpex.js.map +1 -0
  10. package/dist/controllers/common/config.d.ts +78 -0
  11. package/dist/controllers/common/config.js +89 -0
  12. package/dist/controllers/common/config.js.map +1 -0
  13. package/dist/controllers/common/health.d.ts +82 -0
  14. package/dist/controllers/common/health.js +97 -0
  15. package/dist/controllers/common/health.js.map +1 -0
  16. package/dist/controllers/common/index.d.ts +21 -0
  17. package/dist/controllers/common/index.js +21 -0
  18. package/dist/controllers/common/index.js.map +1 -0
  19. package/dist/controllers/common/statics.d.ts +215 -0
  20. package/dist/controllers/common/statics.js +202 -0
  21. package/dist/controllers/common/statics.js.map +1 -0
  22. package/dist/controllers/index.d.ts +24 -0
  23. package/dist/controllers/index.js +20 -0
  24. package/dist/controllers/index.js.map +1 -0
  25. package/dist/controllers/utils/gateway.d.ts +724 -0
  26. package/dist/controllers/utils/gateway.js +425 -0
  27. package/dist/controllers/utils/gateway.js.map +1 -0
  28. package/dist/controllers/utils/index.d.ts +16 -0
  29. package/dist/controllers/utils/index.js +19 -0
  30. package/dist/controllers/utils/index.js.map +1 -0
  31. package/dist/esm/app/index.js +2 -0
  32. package/dist/esm/app/index.js.map +1 -0
  33. package/dist/esm/app/jimpex.js +415 -0
  34. package/dist/esm/app/jimpex.js.map +1 -0
  35. package/dist/esm/chunk-T2T6Q22Z.js +11 -0
  36. package/dist/esm/chunk-T2T6Q22Z.js.map +1 -0
  37. package/dist/esm/controllers/common/config.js +62 -0
  38. package/dist/esm/controllers/common/config.js.map +1 -0
  39. package/dist/esm/controllers/common/health.js +70 -0
  40. package/dist/esm/controllers/common/health.js.map +1 -0
  41. package/dist/esm/controllers/common/index.js +4 -0
  42. package/dist/esm/controllers/common/index.js.map +1 -0
  43. package/dist/esm/controllers/common/statics.js +173 -0
  44. package/dist/esm/controllers/common/statics.js.map +1 -0
  45. package/dist/esm/controllers/index.js +3 -0
  46. package/dist/esm/controllers/index.js.map +1 -0
  47. package/dist/esm/controllers/utils/gateway.js +404 -0
  48. package/dist/esm/controllers/utils/gateway.js.map +1 -0
  49. package/dist/esm/controllers/utils/index.js +2 -0
  50. package/dist/esm/controllers/utils/index.js.map +1 -0
  51. package/dist/esm/index.js +7 -0
  52. package/dist/esm/index.js.map +1 -0
  53. package/dist/esm/middlewares/common/errorHandler.js +92 -0
  54. package/dist/esm/middlewares/common/errorHandler.js.map +1 -0
  55. package/dist/esm/middlewares/common/forceHTTPS.js +41 -0
  56. package/dist/esm/middlewares/common/forceHTTPS.js.map +1 -0
  57. package/dist/esm/middlewares/common/hsts.js +53 -0
  58. package/dist/esm/middlewares/common/hsts.js.map +1 -0
  59. package/dist/esm/middlewares/common/index.js +4 -0
  60. package/dist/esm/middlewares/common/index.js.map +1 -0
  61. package/dist/esm/middlewares/html/fastHTML.js +104 -0
  62. package/dist/esm/middlewares/html/fastHTML.js.map +1 -0
  63. package/dist/esm/middlewares/html/index.js +3 -0
  64. package/dist/esm/middlewares/html/index.js.map +1 -0
  65. package/dist/esm/middlewares/html/showHTML.js +68 -0
  66. package/dist/esm/middlewares/html/showHTML.js.map +1 -0
  67. package/dist/esm/middlewares/index.js +4 -0
  68. package/dist/esm/middlewares/index.js.map +1 -0
  69. package/dist/esm/middlewares/utils/index.js +2 -0
  70. package/dist/esm/middlewares/utils/index.js.map +1 -0
  71. package/dist/esm/middlewares/utils/versionValidator.js +101 -0
  72. package/dist/esm/middlewares/utils/versionValidator.js.map +1 -0
  73. package/dist/esm/services/common/appError.js +52 -0
  74. package/dist/esm/services/common/appError.js.map +1 -0
  75. package/dist/esm/services/common/httpError.js +19 -0
  76. package/dist/esm/services/common/httpError.js.map +1 -0
  77. package/dist/esm/services/common/index.js +17 -0
  78. package/dist/esm/services/common/index.js.map +1 -0
  79. package/dist/esm/services/common/sendFile.js +27 -0
  80. package/dist/esm/services/common/sendFile.js.map +1 -0
  81. package/dist/esm/services/frontend/frontendFs.js +38 -0
  82. package/dist/esm/services/frontend/frontendFs.js.map +1 -0
  83. package/dist/esm/services/frontend/index.js +11 -0
  84. package/dist/esm/services/frontend/index.js.map +1 -0
  85. package/dist/esm/services/html/htmlGenerator.js +144 -0
  86. package/dist/esm/services/html/htmlGenerator.js.map +1 -0
  87. package/dist/esm/services/html/index.js +11 -0
  88. package/dist/esm/services/html/index.js.map +1 -0
  89. package/dist/esm/services/http/apiClient.js +71 -0
  90. package/dist/esm/services/http/apiClient.js.map +1 -0
  91. package/dist/esm/services/http/http.js +125 -0
  92. package/dist/esm/services/http/http.js.map +1 -0
  93. package/dist/esm/services/http/index.js +17 -0
  94. package/dist/esm/services/http/index.js.map +1 -0
  95. package/dist/esm/services/http/responsesBuilder.js +105 -0
  96. package/dist/esm/services/http/responsesBuilder.js.map +1 -0
  97. package/dist/esm/services/index.js +6 -0
  98. package/dist/esm/services/index.js.map +1 -0
  99. package/dist/esm/services/utils/ensureBearerToken.js +78 -0
  100. package/dist/esm/services/utils/ensureBearerToken.js.map +1 -0
  101. package/dist/esm/services/utils/index.js +11 -0
  102. package/dist/esm/services/utils/index.js.map +1 -0
  103. package/dist/esm/types/events.js +1 -0
  104. package/dist/esm/types/events.js.map +1 -0
  105. package/dist/esm/types/express.js +1 -0
  106. package/dist/esm/types/express.js.map +1 -0
  107. package/dist/esm/types/http.js +1 -0
  108. package/dist/esm/types/http.js.map +1 -0
  109. package/dist/esm/types/index.js +7 -0
  110. package/dist/esm/types/index.js.map +1 -0
  111. package/dist/esm/types/options.js +1 -0
  112. package/dist/esm/types/options.js.map +1 -0
  113. package/dist/esm/types/utils.js +1 -0
  114. package/dist/esm/types/utils.js.map +1 -0
  115. package/dist/esm/types/wootils.js +1 -0
  116. package/dist/esm/types/wootils.js.map +1 -0
  117. package/dist/esm/utils/fns/index.js +5 -0
  118. package/dist/esm/utils/fns/index.js.map +1 -0
  119. package/dist/esm/utils/fns/others.js +6 -0
  120. package/dist/esm/utils/fns/others.js.map +1 -0
  121. package/dist/esm/utils/fns/routes.js +25 -0
  122. package/dist/esm/utils/fns/routes.js.map +1 -0
  123. package/dist/esm/utils/fns/statuses.js +6 -0
  124. package/dist/esm/utils/fns/statuses.js.map +1 -0
  125. package/dist/esm/utils/fns/text.js +6 -0
  126. package/dist/esm/utils/fns/text.js.map +1 -0
  127. package/dist/esm/utils/index.js +3 -0
  128. package/dist/esm/utils/index.js.map +1 -0
  129. package/dist/esm/utils/wrappers.js +41 -0
  130. package/dist/esm/utils/wrappers.js.map +1 -0
  131. package/dist/index.d.ts +46 -0
  132. package/dist/index.js +24 -0
  133. package/dist/index.js.map +1 -0
  134. package/dist/jimpex-7eaee271.d.ts +1278 -0
  135. package/dist/middlewares/common/errorHandler.d.ts +131 -0
  136. package/dist/middlewares/common/errorHandler.js +119 -0
  137. package/dist/middlewares/common/errorHandler.js.map +1 -0
  138. package/dist/middlewares/common/forceHTTPS.d.ts +68 -0
  139. package/dist/middlewares/common/forceHTTPS.js +68 -0
  140. package/dist/middlewares/common/forceHTTPS.js.map +1 -0
  141. package/dist/middlewares/common/hsts.d.ts +109 -0
  142. package/dist/middlewares/common/hsts.js +80 -0
  143. package/dist/middlewares/common/hsts.js.map +1 -0
  144. package/dist/middlewares/common/index.d.ts +21 -0
  145. package/dist/middlewares/common/index.js +21 -0
  146. package/dist/middlewares/common/index.js.map +1 -0
  147. package/dist/middlewares/html/fastHTML.d.ts +180 -0
  148. package/dist/middlewares/html/fastHTML.js +131 -0
  149. package/dist/middlewares/html/fastHTML.js.map +1 -0
  150. package/dist/middlewares/html/index.d.ts +21 -0
  151. package/dist/middlewares/html/index.js +20 -0
  152. package/dist/middlewares/html/index.js.map +1 -0
  153. package/dist/middlewares/html/showHTML.d.ts +127 -0
  154. package/dist/middlewares/html/showHTML.js +95 -0
  155. package/dist/middlewares/html/showHTML.js.map +1 -0
  156. package/dist/middlewares/index.d.ts +30 -0
  157. package/dist/middlewares/index.js +21 -0
  158. package/dist/middlewares/index.js.map +1 -0
  159. package/dist/middlewares/utils/index.d.ts +19 -0
  160. package/dist/middlewares/utils/index.js +19 -0
  161. package/dist/middlewares/utils/index.js.map +1 -0
  162. package/dist/middlewares/utils/versionValidator.d.ts +214 -0
  163. package/dist/middlewares/utils/versionValidator.js +128 -0
  164. package/dist/middlewares/utils/versionValidator.js.map +1 -0
  165. package/dist/services/common/appError.d.ts +138 -0
  166. package/dist/services/common/appError.js +80 -0
  167. package/dist/services/common/appError.js.map +1 -0
  168. package/dist/services/common/httpError.d.ts +79 -0
  169. package/dist/services/common/httpError.js +44 -0
  170. package/dist/services/common/httpError.js.map +1 -0
  171. package/dist/services/common/index.d.ts +47 -0
  172. package/dist/services/common/index.js +41 -0
  173. package/dist/services/common/index.js.map +1 -0
  174. package/dist/services/common/sendFile.d.ts +102 -0
  175. package/dist/services/common/sendFile.js +51 -0
  176. package/dist/services/common/sendFile.js.map +1 -0
  177. package/dist/services/frontend/frontendFs.d.ts +96 -0
  178. package/dist/services/frontend/frontendFs.js +71 -0
  179. package/dist/services/frontend/frontendFs.js.map +1 -0
  180. package/dist/services/frontend/index.d.ts +40 -0
  181. package/dist/services/frontend/index.js +35 -0
  182. package/dist/services/frontend/index.js.map +1 -0
  183. package/dist/services/html/htmlGenerator.d.ts +237 -0
  184. package/dist/services/html/htmlGenerator.js +171 -0
  185. package/dist/services/html/htmlGenerator.js.map +1 -0
  186. package/dist/services/html/index.d.ts +43 -0
  187. package/dist/services/html/index.js +35 -0
  188. package/dist/services/html/index.js.map +1 -0
  189. package/dist/services/http/apiClient.d.ts +169 -0
  190. package/dist/services/http/apiClient.js +96 -0
  191. package/dist/services/http/apiClient.js.map +1 -0
  192. package/dist/services/http/http.d.ts +175 -0
  193. package/dist/services/http/http.js +158 -0
  194. package/dist/services/http/http.js.map +1 -0
  195. package/dist/services/http/index.d.ts +50 -0
  196. package/dist/services/http/index.js +41 -0
  197. package/dist/services/http/index.js.map +1 -0
  198. package/dist/services/http/responsesBuilder.d.ts +178 -0
  199. package/dist/services/http/responsesBuilder.js +132 -0
  200. package/dist/services/http/responsesBuilder.js.map +1 -0
  201. package/dist/services/index.d.ts +33 -0
  202. package/dist/services/index.js +23 -0
  203. package/dist/services/index.js.map +1 -0
  204. package/dist/services/utils/ensureBearerToken.d.ts +157 -0
  205. package/dist/services/utils/ensureBearerToken.js +105 -0
  206. package/dist/services/utils/ensureBearerToken.js.map +1 -0
  207. package/dist/services/utils/index.d.ts +43 -0
  208. package/dist/services/utils/index.js +35 -0
  209. package/dist/services/utils/index.js.map +1 -0
  210. package/dist/types/events.d.ts +13 -0
  211. package/dist/types/events.js +17 -0
  212. package/dist/types/events.js.map +1 -0
  213. package/dist/types/express.d.ts +10 -0
  214. package/dist/types/express.js +17 -0
  215. package/dist/types/express.js.map +1 -0
  216. package/dist/types/http.d.ts +79 -0
  217. package/dist/types/http.js +17 -0
  218. package/dist/types/http.js.map +1 -0
  219. package/dist/types/index.d.ts +14 -0
  220. package/dist/types/index.js +24 -0
  221. package/dist/types/index.js.map +1 -0
  222. package/dist/types/options.d.ts +13 -0
  223. package/dist/types/options.js +17 -0
  224. package/dist/types/options.js.map +1 -0
  225. package/dist/types/utils.d.ts +48 -0
  226. package/dist/types/utils.js +17 -0
  227. package/dist/types/utils.js.map +1 -0
  228. package/dist/types/wootils.d.ts +4 -0
  229. package/dist/types/wootils.js +17 -0
  230. package/dist/types/wootils.js.map +1 -0
  231. package/dist/utils/fns/index.d.ts +5 -0
  232. package/dist/utils/fns/index.js +22 -0
  233. package/dist/utils/fns/index.js.map +1 -0
  234. package/dist/utils/fns/others.d.ts +17 -0
  235. package/dist/utils/fns/others.js +29 -0
  236. package/dist/utils/fns/others.js.map +1 -0
  237. package/dist/utils/fns/routes.d.ts +39 -0
  238. package/dist/utils/fns/routes.js +51 -0
  239. package/dist/utils/fns/routes.js.map +1 -0
  240. package/dist/utils/fns/statuses.d.ts +45 -0
  241. package/dist/utils/fns/statuses.js +35 -0
  242. package/dist/utils/fns/statuses.js.map +1 -0
  243. package/dist/utils/fns/text.d.ts +9 -0
  244. package/dist/utils/fns/text.js +29 -0
  245. package/dist/utils/fns/text.js.map +1 -0
  246. package/dist/utils/index.d.ts +18 -0
  247. package/dist/utils/index.js +20 -0
  248. package/dist/utils/index.js.map +1 -0
  249. package/dist/utils/wrappers.d.ts +13 -0
  250. package/dist/utils/wrappers.js +68 -0
  251. package/dist/utils/wrappers.js.map +1 -0
  252. package/examples/basic/404.html +12 -0
  253. package/examples/basic/README.md +30 -0
  254. package/examples/basic/app.ts +18 -0
  255. package/examples/basic/controller.ts +45 -0
  256. package/examples/basic/index.ts +19 -0
  257. package/examples/basic/middleware.ts +13 -0
  258. package/examples/basic/service.ts +11 -0
  259. package/package.json +59 -38
  260. package/src/app/index.ts +1 -0
  261. package/src/app/jimpex.ts +743 -0
  262. package/src/controllers/common/config.ts +115 -0
  263. package/src/controllers/common/health.ts +128 -0
  264. package/src/controllers/common/index.ts +3 -0
  265. package/src/controllers/common/statics.ts +380 -0
  266. package/src/controllers/index.ts +2 -0
  267. package/src/controllers/utils/gateway.ts +1186 -0
  268. package/src/controllers/utils/index.ts +1 -0
  269. package/src/index.ts +6 -0
  270. package/src/middlewares/common/errorHandler.ts +203 -0
  271. package/src/middlewares/common/forceHTTPS.ts +83 -0
  272. package/src/middlewares/common/hsts.ts +135 -0
  273. package/src/middlewares/common/index.ts +3 -0
  274. package/src/middlewares/html/fastHTML.ts +255 -0
  275. package/src/middlewares/html/index.ts +2 -0
  276. package/src/middlewares/html/showHTML.ts +165 -0
  277. package/src/middlewares/index.ts +3 -0
  278. package/src/middlewares/utils/index.ts +1 -0
  279. package/src/middlewares/utils/versionValidator.ts +289 -0
  280. package/src/services/common/appError.ts +158 -0
  281. package/src/services/common/httpError.ts +74 -0
  282. package/src/services/common/index.ts +29 -0
  283. package/src/services/common/sendFile.ts +106 -0
  284. package/src/services/frontend/frontendFs.ts +101 -0
  285. package/src/services/frontend/index.ts +21 -0
  286. package/src/services/html/htmlGenerator.ts +356 -0
  287. package/src/services/html/index.ts +21 -0
  288. package/src/services/http/apiClient.ts +221 -0
  289. package/src/services/http/http.ts +286 -0
  290. package/src/services/http/index.ts +29 -0
  291. package/src/services/http/responsesBuilder.ts +265 -0
  292. package/src/services/index.ts +5 -0
  293. package/src/services/utils/ensureBearerToken.ts +202 -0
  294. package/src/services/utils/index.ts +21 -0
  295. package/src/types/events.ts +303 -0
  296. package/src/types/express.ts +21 -0
  297. package/src/types/http.ts +77 -0
  298. package/src/types/index.ts +6 -0
  299. package/src/types/options.ts +248 -0
  300. package/src/types/utils.ts +52 -0
  301. package/src/types/wootils.ts +4 -0
  302. package/src/utils/fns/index.ts +4 -0
  303. package/src/utils/fns/others.ts +15 -0
  304. package/src/utils/fns/routes.ts +64 -0
  305. package/src/utils/fns/statuses.ts +44 -0
  306. package/src/utils/fns/text.ts +8 -0
  307. package/src/utils/index.ts +2 -0
  308. package/src/utils/wrappers.ts +537 -0
  309. package/tsconfig.json +5 -8
  310. package/tsup.config.ts +10 -0
  311. package/src/app/index.js +0 -692
  312. package/src/constants/eventNames.js +0 -48
  313. package/src/constants/index.js +0 -7
  314. package/src/controllers/common/configuration.js +0 -116
  315. package/src/controllers/common/health.js +0 -79
  316. package/src/controllers/common/index.js +0 -7
  317. package/src/controllers/common/statics.js +0 -336
  318. package/src/controllers/index.js +0 -9
  319. package/src/controllers/utils/gateway.js +0 -1039
  320. package/src/controllers/utils/index.js +0 -3
  321. package/src/index.js +0 -30
  322. package/src/middlewares/common/errorHandler.js +0 -185
  323. package/src/middlewares/common/forceHTTPS.js +0 -80
  324. package/src/middlewares/common/hsts.js +0 -122
  325. package/src/middlewares/common/index.js +0 -7
  326. package/src/middlewares/html/fastHTML.js +0 -298
  327. package/src/middlewares/html/index.js +0 -5
  328. package/src/middlewares/html/showHTML.js +0 -167
  329. package/src/middlewares/index.js +0 -11
  330. package/src/middlewares/utils/index.js +0 -3
  331. package/src/middlewares/utils/versionValidator.js +0 -261
  332. package/src/services/common/appError.js +0 -136
  333. package/src/services/common/httpError.js +0 -60
  334. package/src/services/common/index.js +0 -25
  335. package/src/services/common/sendFile.js +0 -68
  336. package/src/services/frontend/frontendFs.js +0 -85
  337. package/src/services/frontend/index.js +0 -17
  338. package/src/services/html/htmlGenerator.js +0 -391
  339. package/src/services/html/index.js +0 -17
  340. package/src/services/http/apiClient.js +0 -148
  341. package/src/services/http/http.js +0 -256
  342. package/src/services/http/index.js +0 -25
  343. package/src/services/http/responsesBuilder.js +0 -193
  344. package/src/services/index.js +0 -15
  345. package/src/services/utils/ensureBearerToken.js +0 -147
  346. package/src/services/utils/index.js +0 -19
  347. package/src/types.js +0 -377
  348. package/src/utils/functions.js +0 -78
  349. package/src/utils/wrappers.js +0 -131
  350. package/types/app/index.d.ts +0 -417
  351. package/types/constants/eventNames.d.ts +0 -93
  352. package/types/constants/index.d.ts +0 -2
  353. package/types/controllers/common/configuration.d.ts +0 -71
  354. package/types/controllers/common/health.d.ts +0 -55
  355. package/types/controllers/common/index.d.ts +0 -4
  356. package/types/controllers/common/statics.d.ts +0 -271
  357. package/types/controllers/index.d.ts +0 -3
  358. package/types/controllers/utils/gateway.d.ts +0 -947
  359. package/types/controllers/utils/index.d.ts +0 -2
  360. package/types/index.d.ts +0 -15
  361. package/types/middlewares/common/errorHandler.d.ts +0 -143
  362. package/types/middlewares/common/forceHTTPS.d.ts +0 -64
  363. package/types/middlewares/common/hsts.d.ts +0 -111
  364. package/types/middlewares/common/index.d.ts +0 -4
  365. package/types/middlewares/html/fastHTML.d.ts +0 -238
  366. package/types/middlewares/html/index.d.ts +0 -3
  367. package/types/middlewares/html/showHTML.d.ts +0 -128
  368. package/types/middlewares/index.d.ts +0 -4
  369. package/types/middlewares/utils/index.d.ts +0 -2
  370. package/types/middlewares/utils/versionValidator.d.ts +0 -247
  371. package/types/services/common/appError.d.ts +0 -89
  372. package/types/services/common/httpError.d.ts +0 -37
  373. package/types/services/common/index.d.ts +0 -18
  374. package/types/services/common/sendFile.d.ts +0 -56
  375. package/types/services/frontend/frontendFs.d.ts +0 -72
  376. package/types/services/frontend/index.d.ts +0 -3
  377. package/types/services/html/htmlGenerator.d.ts +0 -298
  378. package/types/services/html/index.d.ts +0 -3
  379. package/types/services/http/apiClient.d.ts +0 -141
  380. package/types/services/http/http.d.ts +0 -159
  381. package/types/services/http/index.d.ts +0 -18
  382. package/types/services/http/responsesBuilder.d.ts +0 -140
  383. package/types/services/index.d.ts +0 -6
  384. package/types/services/utils/ensureBearerToken.d.ts +0 -137
  385. package/types/services/utils/index.d.ts +0 -16
  386. package/types/types.d.ts +0 -280
  387. package/types/utils/functions.d.ts +0 -55
  388. package/types/utils/wrappers.d.ts +0 -127
@@ -1,298 +0,0 @@
1
- export type AppConfiguration = import('../../types').AppConfiguration;
2
- export type Logger = import('../../types').Logger;
3
- export type FrontendFs = import('../frontend/frontendFs').FrontendFs;
4
- /**
5
- * <O>
6
- */
7
- export type ProviderCreator<O> = import('../../types').ProviderCreator<O>;
8
- /**
9
- * The options to customize the an `HTMLGenerator` service.
10
- */
11
- export type HTMLGeneratorOptions = {
12
- /**
13
- * The name of the file it should use as
14
- * template.
15
- * Default `'index.tpl.html'`.
16
- */
17
- template: string;
18
- /**
19
- * The name of the generated file. Default
20
- * `'index.html'`.
21
- */
22
- file: string;
23
- /**
24
- * Whether or not to delete the tempalte after
25
- * generating the file. Default `true`.
26
- */
27
- deleteTemplateAfter: boolean;
28
- /**
29
- * The placeholder string where the information
30
- * will be written. Default
31
- * `'{{appConfiguration}}'`.
32
- */
33
- replacePlaceholder: string;
34
- /**
35
- * A regular expression for dynamic placeholders
36
- * that will be replaced by values when the file
37
- * is generated.
38
- * Default `'{{(.*?)}}'`.
39
- */
40
- valuesExpression: RegExp;
41
- /**
42
- * The name of the variable that will have the
43
- * information on the file. Default
44
- * `'appConfiguration'`.
45
- */
46
- variable: string;
47
- /**
48
- * A list of settings from the app configuration
49
- * that will be used as the information to
50
- * inject on the file.
51
- * Default `['features', 'version',
52
- * 'postMessagesPrefix']`.
53
- */
54
- configurationKeys: string[];
55
- };
56
- export type HTMLGeneratorProviderOptions = HTMLGeneratorOptions & HTMLGeneratorProviderOptionsProperties;
57
- export type HTMLGeneratorProviderOptionsProperties = {
58
- /**
59
- * The name that will be used to register the service on the app container. This is to
60
- * allow multiple "instances" of the service to be created.
61
- */
62
- serviceName?: string;
63
- /**
64
- * The name of a service that the generator will use in order to read the values that will
65
- * be injected on the template. If the service is available, the values from
66
- * `configurationKeys`
67
- * will be ignored.
68
- */
69
- valuesService?: string | null;
70
- };
71
- export type HTMLGeneratorValuesServiceGetValues = () => Promise<any>;
72
- /**
73
- * A service to provide the information value to an `HTMLGenerator` service to use on the
74
- * generated file.
75
- */
76
- export type HTMLGeneratorValuesService = {
77
- /**
78
- * This is the method an `HTMLGenerator` service will call in order to retrieve the values
79
- * that should be injected on the generated file.
80
- */
81
- getValues: HTMLGeneratorValuesServiceGetValues;
82
- };
83
- /**
84
- * @typedef {import('../../types').AppConfiguration} AppConfiguration
85
- * @typedef {import('../../types').Logger} Logger
86
- * @typedef {import('../frontend/frontendFs').FrontendFs} FrontendFs
87
- */
88
- /**
89
- * @typedef {import('../../types').ProviderCreator<O>} ProviderCreator<O>
90
- * @template O
91
- */
92
- /**
93
- * The options to customize the an `HTMLGenerator` service.
94
- *
95
- * @typedef {Object} HTMLGeneratorOptions
96
- * @property {string} template The name of the file it should use as
97
- * template.
98
- * Default `'index.tpl.html'`.
99
- * @property {string} file The name of the generated file. Default
100
- * `'index.html'`.
101
- * @property {boolean} deleteTemplateAfter Whether or not to delete the tempalte after
102
- * generating the file. Default `true`.
103
- * @property {string} replacePlaceholder The placeholder string where the information
104
- * will be written. Default
105
- * `'{{appConfiguration}}'`.
106
- * @property {RegExp} valuesExpression A regular expression for dynamic placeholders
107
- * that will be replaced by values when the file
108
- * is generated.
109
- * Default `'{{(.*?)}}'`.
110
- * @property {string} variable The name of the variable that will have the
111
- * information on the file. Default
112
- * `'appConfiguration'`.
113
- * @property {string[]} configurationKeys A list of settings from the app configuration
114
- * that will be used as the information to
115
- * inject on the file.
116
- * Default `['features', 'version',
117
- * 'postMessagesPrefix']`.
118
- * @parent module:services
119
- */
120
- /**
121
- * @typedef {HTMLGeneratorOptions & HTMLGeneratorProviderOptionsProperties} HTMLGeneratorProviderOptions
122
- * @parent module:services
123
- * @prettierignore
124
- */
125
- /**
126
- * @typedef {Object} HTMLGeneratorProviderOptionsProperties
127
- * @property {string} [serviceName='htmlGenerator']
128
- * The name that will be used to register the service on the app container. This is to
129
- * allow multiple "instances" of the service to be created.
130
- * @property {?string} [valuesService='htmlGeneratorValues']
131
- * The name of a service that the generator will use in order to read the values that will
132
- * be injected on the template. If the service is available, the values from
133
- * `configurationKeys`
134
- * will be ignored.
135
- * @parent module:services
136
- */
137
- /**
138
- * @callback HTMLGeneratorValuesServiceGetValues
139
- * @returns {Promise<Object>}
140
- * @parent module:services
141
- */
142
- /**
143
- * A service to provide the information value to an `HTMLGenerator` service to use on the
144
- * generated file.
145
- *
146
- * @typedef {Object} HTMLGeneratorValuesService
147
- * @property {HTMLGeneratorValuesServiceGetValues} getValues
148
- * This is the method an `HTMLGenerator` service will call in order to retrieve the values
149
- * that should be injected on the generated file.
150
- * @parent module:services
151
- */
152
- /**
153
- * This is a utility sever that generates an HTML file with custom information when the
154
- * app server is started.
155
- *
156
- * @parent module:services
157
- */
158
- export class HTMLGenerator {
159
- /**
160
- * @param {AppConfiguration} appConfiguration
161
- * To read the values of the settings that are going to be send to the file.
162
- * @param {Logger} appLogger
163
- * To log messages when the file is generated, when the template is removed, and if it
164
- * happens,
165
- * when an error is thrown.
166
- * @param {FrontendFs} frontendFs
167
- * To read the contents of the template.
168
- * @param {Partial<HTMLGeneratorOptions>} [options={}]
169
- * To customize the service.
170
- * @param {?HTMLGeneratorValuesService} [valuesService=null]
171
- * If specified, instead of getting the values from the app configuration, they'll be
172
- * retrieved from this service `getValues` method.
173
- * @throws {Error}
174
- * If `valuesService` is specified but it doesn't have a `getValues` method.
175
- */
176
- constructor(appConfiguration: AppConfiguration, appLogger: Logger, frontendFs: FrontendFs, options?: Partial<HTMLGeneratorOptions>, valuesService?: HTMLGeneratorValuesService | null);
177
- /**
178
- * The service options.
179
- *
180
- * @type {HTMLGeneratorOptions}
181
- * @access protected
182
- * @ignore
183
- */
184
- _options: HTMLGeneratorOptions;
185
- /**
186
- * A local reference for the `appConfiguration` service.
187
- *
188
- * @type {AppConfiguration}
189
- * @access protected
190
- * @ignore
191
- */
192
- _appConfiguration: AppConfiguration;
193
- /**
194
- * A local reference for the `appLogger` service.
195
- *
196
- * @type {Logger}
197
- * @access protected
198
- * @ignore
199
- */
200
- _appLogger: Logger;
201
- /**
202
- * A local reference for the `frontendFs` service.
203
- *
204
- * @type {FrontendFs}
205
- * @access protected
206
- * @ignore
207
- */
208
- _frontendFs: FrontendFs;
209
- /**
210
- * A local reference for the recieved `valuesService` service.
211
- *
212
- * @type {?HTMLGeneratorValuesService}
213
- * @access protected
214
- * @ignore
215
- */
216
- _valuesService: HTMLGeneratorValuesService | null;
217
- /**
218
- * Whether or not the file has been generated.
219
- *
220
- * @type {boolean}
221
- * @access protected
222
- * @ignore
223
- */
224
- _fileReady: boolean;
225
- /**
226
- * A deferred promise to return when another service asks if the file has been
227
- * generated. Once this sevice finishes generating the file, the promise will be
228
- * resolved.
229
- *
230
- * @type {Object}
231
- * @access protected
232
- * @ignore
233
- */
234
- _fileDeferred: any;
235
- /**
236
- * Generate the HTML file.
237
- *
238
- * @returns {Promise}
239
- */
240
- generateHTML(): Promise<any>;
241
- /**
242
- * Get the name of the file the service generates.
243
- *
244
- * @returns {string}
245
- */
246
- getFile(): string;
247
- /**
248
- * Get the values that are going to be injected on the file.
249
- *
250
- * @returns {Promise<Object>}
251
- */
252
- getValues(): Promise<any>;
253
- /**
254
- * Returns a promise that will be resolved when the file has been generated.
255
- *
256
- * @returns {Promise}
257
- */
258
- whenReady(): Promise<any>;
259
- /**
260
- * The service options.
261
- *
262
- * @type {HTMLGeneratorOptions}
263
- * @todo Remove Object.freeze.
264
- */
265
- get options(): HTMLGeneratorOptions;
266
- /**
267
- * Get a value from an object dictionary using a string _"object path"_
268
- * (`prop.sub.otherProp`).
269
- * If the property doesn't exist or the path is invalid, it will return `null`.
270
- *
271
- * @param {Object} values The dictionary from where the value will be read.
272
- * @param {string} valuePath The path to the value.
273
- * @returns {*}
274
- * @access protected
275
- * @ignore
276
- * @todo Use ObjectUtils.get for this.
277
- */
278
- _getFromValues(values: any, valuePath: string): any;
279
- /**
280
- * Creates the code for the HTML file.
281
- *
282
- * @param {string} template The template code where the values are going to be
283
- * injected.
284
- * @param {Object} values The dictionary of values to inject.
285
- * @returns {string}
286
- * @access protected
287
- * @ignore
288
- */
289
- _processHTML(template: string, values: any): string;
290
- }
291
- /**
292
- * A service that hooks itself to the `after-start` event of the app server in order to
293
- * trigger the generation an the html file when the server starts.
294
- *
295
- * @type {ProviderCreator<HTMLGeneratorProviderOptions>}
296
- * @parent module:services
297
- */
298
- export const htmlGenerator: ProviderCreator<HTMLGeneratorProviderOptions>;
@@ -1,3 +0,0 @@
1
- declare const _exports: Provider;
2
- export = _exports;
3
- export type Provider = import('../../types').Provider;
@@ -1,141 +0,0 @@
1
- export type APIClientBase = import('../../types').APIClientBase;
2
- export type APIClientEndpoints = import('../../types').APIClientEndpoints;
3
- export type HTTP = import('./http').HTTP;
4
- export type HTTPError = import('../common/httpError').HTTPError;
5
- /**
6
- * <O>
7
- */
8
- export type ProviderCreator<O> = import('../../types').ProviderCreator<O>;
9
- /**
10
- * The options to customize how the service gets registered.
11
- */
12
- export type APIClientProviderOptions = {
13
- /**
14
- * The name of the service that will be
15
- * registered into the app. Default
16
- * `'apiClient'`.
17
- */
18
- serviceName: string;
19
- /**
20
- * The name of the configuration
21
- * setting that has the API
22
- * information. Default `'api'`.
23
- */
24
- configurationSetting: string;
25
- /**
26
- * The class the service will
27
- * instantiate. It has to extend from
28
- * {@link APIClient }, which is the
29
- * default value.
30
- */
31
- clientClass: typeof APIClient;
32
- };
33
- /**
34
- * The configuration for the API the client will make requests to.
35
- */
36
- export type APIClientConfiguration = {
37
- /**
38
- * The API entry point.
39
- */
40
- url: string;
41
- /**
42
- * A dictionary of named endpoints relative to
43
- * the API entry point.
44
- */
45
- endpoints: APIClientEndpoints;
46
- };
47
- /**
48
- * @typedef {import('../../types').APIClientBase} APIClientBase
49
- * @typedef {import('../../types').APIClientEndpoints} APIClientEndpoints
50
- * @typedef {import('./http').HTTP} HTTP
51
- * @typedef {import('../common/httpError').HTTPError} HTTPError
52
- */
53
- /**
54
- * @typedef {import('../../types').ProviderCreator<O>} ProviderCreator<O>
55
- * @template O
56
- */
57
- /**
58
- * The options to customize how the service gets registered.
59
- *
60
- * @typedef {Object} APIClientProviderOptions
61
- * @property {string} serviceName The name of the service that will be
62
- * registered into the app. Default
63
- * `'apiClient'`.
64
- * @property {string} configurationSetting The name of the configuration
65
- * setting that has the API
66
- * information. Default `'api'`.
67
- * @property {typeof APIClient} clientClass The class the service will
68
- * instantiate. It has to extend from
69
- * {@link APIClient}, which is the
70
- * default value.
71
- * @parent module:services
72
- */
73
- /**
74
- * The configuration for the API the client will make requests to.
75
- *
76
- * @typedef {Object} APIClientConfiguration
77
- * @property {string} url The API entry point.
78
- * @property {APIClientEndpoints} endpoints A dictionary of named endpoints relative to
79
- * the API entry point.
80
- * @parent module:services
81
- */
82
- /**
83
- * An API client for the app to use. What makes this service special is that its that it
84
- * formats the received errors using the `AppError` service class and as fetch function it
85
- * uses the `http` service, allowing the app to to internally handle all the requests and
86
- * responses.
87
- *
88
- * @augments APIClientBase
89
- * @parent module:services
90
- */
91
- export class APIClient extends APIClientBase {
92
- /**
93
- * @param {APIClientConfiguration} apiConfig The configuration for the API the client
94
- * will make requests to.
95
- * @param {HTTP} http To get the `fetch` function for this
96
- * service to use on all the requests.
97
- * @param {ClassHTTPError} HTTPError To format the received errors.
98
- */
99
- constructor(apiConfig: APIClientConfiguration, http: HTTP, HTTPError: any);
100
- /**
101
- * The configuration for the API the client will make requests to.
102
- *
103
- * @type {APIClientConfiguration}
104
- * @access protected
105
- * @ignore
106
- */
107
- _apiConfig: APIClientConfiguration;
108
- /**
109
- * A local reference for the class the app uses to generate HTTP errors.
110
- *
111
- * @type {ClassHTTPError}
112
- * @access protected
113
- * @ignore
114
- */
115
- _HTTPError: any;
116
- /**
117
- * Helper method that tries to get an error message from a given response.
118
- *
119
- * @param {Object} response A received response from a request.
120
- * @param {string} [fallback='Unexpected error'] A fallback message in case the method
121
- * doesn't found one on the response.
122
- * @returns {string}
123
- */
124
- getErrorMessageFromResponse(response: any, fallback?: string): string;
125
- /**
126
- * The configuration for the API the client will make requests to.
127
- *
128
- * @type {APIClientConfiguration}
129
- * @todo Remove Object.freeze.
130
- */
131
- get apiConfig(): APIClientConfiguration;
132
- }
133
- /**
134
- * An API Client service to make requests to an API using endpoints defined on the app
135
- * configuration.
136
- *
137
- * @type {ProviderCreator<APIClientProviderOptions>}
138
- * @parent module:services
139
- */
140
- export const apiClient: ProviderCreator<APIClientProviderOptions>;
141
- import APIClientBase = require("wootils/shared/apiClient");
@@ -1,159 +0,0 @@
1
- export type Logger = import('../../types').Logger;
2
- export type Provider = import('../../types').Provider;
3
- export type Response = any;
4
- export type ExpressRequest = import('../../types').ExpressRequest;
5
- export type HTTPFetchOptions = {
6
- /**
7
- * The request method.
8
- */
9
- method: string | null;
10
- /**
11
- * The request headers.
12
- */
13
- headers: {
14
- [x: string]: string;
15
- } | null;
16
- /**
17
- * The request body.
18
- */
19
- body: string | null;
20
- /**
21
- * The request query string parameters.
22
- */
23
- qs: {
24
- [x: string]: string;
25
- } | null;
26
- /**
27
- * An Express request object used to get
28
- * extra infromation (like headers and the
29
- * IP).
30
- */
31
- req: ExpressRequest | null;
32
- };
33
- /**
34
- * @typedef {import('../../types').Logger} Logger
35
- * @typedef {import('../../types').Provider} Provider
36
- * @typedef {import('node-fetch').Response} Response
37
- * @typedef {import('../../types').ExpressRequest} ExpressRequest
38
- */
39
- /**
40
- * @typedef {Object} HTTPFetchOptions
41
- * @property {?string} method The request method.
42
- * @property {?Object.<string, string>} headers The request headers.
43
- * @property {?string} body The request body.
44
- * @property {?Object.<string, string>} qs The request query string parameters.
45
- * @property {?ExpressRequest} req An Express request object used to get
46
- * extra infromation (like headers and the
47
- * IP).
48
- * @parent module:services
49
- */
50
- /**
51
- * A set of utilities to work with HTTP requests and responses.
52
- *
53
- * @parent module:services
54
- */
55
- export class HTTP {
56
- /**
57
- * @param {boolean} logRequests Whether or not to log the requests and their responses.
58
- * @param {Logger} appLogger If `logRequests` is `true`, this will be used to log
59
- * the requests and responses information.
60
- */
61
- constructor(logRequests: boolean, appLogger: Logger);
62
- /**
63
- * Whether or not to log the requests and their responses.
64
- *
65
- * @type {boolean}
66
- * @access protected
67
- * @ignore
68
- */
69
- _logRequests: boolean;
70
- /**
71
- * A local reference for the `appLogger` service.
72
- *
73
- * @type {Logger}
74
- * @access protected
75
- * @ignore
76
- */
77
- _appLogger: Logger;
78
- /**
79
- * Make a request.
80
- *
81
- * @param {string} url The request URL.
82
- * @param {Partial<HTTPFetchOptions>} [options={}] The request options.
83
- * @returns {Promise<Response>}
84
- */
85
- fetch(url: string, options?: Partial<HTTPFetchOptions>): Promise<Response>;
86
- /**
87
- * Creates a dictionary with all the custom headers a request has. By custom header it
88
- * means all the headers which name start with `x-`.
89
- * This method doesn't copy `x-forwarded-for` as the `fetch` method generates it by
90
- * calling `getIPFromRequest`.
91
- *
92
- * @param {ExpressRequest} req The request from which it will try to get the headers.
93
- * @returns {Object.<string, string>}
94
- */
95
- getCustomHeadersFromRequest(req: ExpressRequest): {
96
- [x: string]: string;
97
- };
98
- /**
99
- * Try to get the IP from a given request.
100
- *
101
- * @param {ExpressRequest} req The request from which it will try to obtain the IP
102
- * address.
103
- * @returns {?string}
104
- */
105
- getIPFromRequest(req: ExpressRequest): string | null;
106
- /**
107
- * It takes a dictionary of headers and normalize the names so each word will start with
108
- * an upper case character. This is helpful in case you added custom headers and didn't
109
- * care about the casing, or when copying headers from a server request, in which case
110
- * they are all tranformed to lower case.
111
- *
112
- * @param {Object.<string, string>} headers The dictionary of headers to normalize.
113
- * @returns {Object.<string, string>}
114
- */
115
- normalizeHeaders(headers: {
116
- [x: string]: string;
117
- }): {
118
- [x: string]: string;
119
- };
120
- /**
121
- * Whether or not to log the requests and their responses.
122
- *
123
- * @type {boolean}
124
- */
125
- get logRequests(): boolean;
126
- /**
127
- * Log a a request information using the `appLogger` service.
128
- *
129
- * @param {string} url The request URL.
130
- * @param {HTTPFetchOptions} options The options generated by the `fetch` method.
131
- * @access protected
132
- * @ignore
133
- */
134
- _logRequest(url: string, options: HTTPFetchOptions): void;
135
- /**
136
- * Log a a response information using the `appLogger` service.
137
- *
138
- * @param {Response} response The response object returned by `node-fetch`.
139
- * @access protected
140
- * @ignore
141
- */
142
- _logResponse(response: any): void;
143
- }
144
- /**
145
- * The service provider that once registered on the app container will set an instance of
146
- * `HTTP` as the `http` service. The provider also checks the `debug.logRequests` setting
147
- * on the app configuration in order to enable or not the logging of requests.
148
- *
149
- * @type {Provider}
150
- * @example
151
- *
152
- * // Register it on the container
153
- * container.register(http);
154
- * // Getting access to the service instance
155
- * const http = container.get('http');
156
- *
157
- * @parent module:services
158
- */
159
- export const http: Provider;
@@ -1,18 +0,0 @@
1
- export = httpServices;
2
- /**
3
- * @typedef {import('../../types').Provider} Provider
4
- */
5
- /**
6
- * The providers collection for the HTTP services.
7
- *
8
- * @type {Provider}
9
- * @property {Provider} apiClient The provider for {@link APIClient}.
10
- * @property {Provider} http The provider for {@link HTTP}.
11
- * @property {Provider} responsesBuilder The provider for {@link ResponsesBuilder}.
12
- * @parent module:services
13
- */
14
- declare const httpServices: Provider;
15
- declare namespace httpServices {
16
- export { Provider };
17
- }
18
- type Provider = import('../../types').Provider;