@venok/core 1.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 (400) hide show
  1. package/application/config.d.ts +35 -0
  2. package/application/config.js +85 -0
  3. package/application/context.d.ts +198 -0
  4. package/application/context.js +325 -0
  5. package/application/factory.d.ts +43 -0
  6. package/application/factory.js +147 -0
  7. package/constants.d.ts +46 -0
  8. package/constants.js +53 -0
  9. package/context/creator.d.ts +9 -0
  10. package/context/creator.js +32 -0
  11. package/context/execution-host.d.ts +16 -0
  12. package/context/execution-host.js +30 -0
  13. package/context/external/creator.d.ts +63 -0
  14. package/context/external/creator.js +159 -0
  15. package/context/external/proxy.d.ts +5 -0
  16. package/context/external/proxy.js +19 -0
  17. package/decorators/apply.decorator.d.ts +10 -0
  18. package/decorators/apply.decorator.js +24 -0
  19. package/decorators/bind.decorator.d.ts +11 -0
  20. package/decorators/bind.decorator.js +20 -0
  21. package/decorators/catch.decorator.d.ts +17 -0
  22. package/decorators/catch.decorator.js +26 -0
  23. package/decorators/create-param.decorator.d.ts +29 -0
  24. package/decorators/create-param.decorator.js +51 -0
  25. package/decorators/dependencies.decorator.d.ts +6 -0
  26. package/decorators/dependencies.decorator.js +17 -0
  27. package/decorators/exception-filters.decorator.d.ts +21 -0
  28. package/decorators/exception-filters.decorator.js +41 -0
  29. package/decorators/global.decorator.d.ts +10 -0
  30. package/decorators/global.decorator.js +19 -0
  31. package/decorators/index.d.ts +15 -0
  32. package/decorators/index.js +31 -0
  33. package/decorators/inject.decorator.d.ts +26 -0
  34. package/decorators/inject.decorator.js +45 -0
  35. package/decorators/injectable.decorator.d.ts +40 -0
  36. package/decorators/injectable.decorator.js +51 -0
  37. package/decorators/module.decorator.d.ts +14 -0
  38. package/decorators/module.decorator.js +38 -0
  39. package/decorators/optional.decorator.d.ts +14 -0
  40. package/decorators/optional.decorator.js +30 -0
  41. package/decorators/set-metadata.decorator.d.ts +18 -0
  42. package/decorators/set-metadata.decorator.js +30 -0
  43. package/decorators/use-guards.decorator.d.ts +21 -0
  44. package/decorators/use-guards.decorator.js +40 -0
  45. package/decorators/use-interceptors.decorator.d.ts +21 -0
  46. package/decorators/use-interceptors.decorator.js +40 -0
  47. package/decorators/use-pipes.decorator.d.ts +21 -0
  48. package/decorators/use-pipes.decorator.js +39 -0
  49. package/discovery/meta-host-collection.d.ts +32 -0
  50. package/discovery/meta-host-collection.js +79 -0
  51. package/discovery/module.d.ts +5 -0
  52. package/discovery/module.js +24 -0
  53. package/discovery/service.d.ts +68 -0
  54. package/discovery/service.js +90 -0
  55. package/errors/exceptions/circular-dependency.exception.d.ts +4 -0
  56. package/errors/exceptions/circular-dependency.exception.js +11 -0
  57. package/errors/exceptions/index.d.ts +8 -0
  58. package/errors/exceptions/index.js +24 -0
  59. package/errors/exceptions/invalid-class-module.exception.d.ts +4 -0
  60. package/errors/exceptions/invalid-class-module.exception.js +11 -0
  61. package/errors/exceptions/invalid-class-scope.exception.d.ts +5 -0
  62. package/errors/exceptions/invalid-class-scope.exception.js +14 -0
  63. package/errors/exceptions/invalid-class.exception.d.ts +4 -0
  64. package/errors/exceptions/invalid-class.exception.js +11 -0
  65. package/errors/exceptions/invalid-exception-filter.exception.d.ts +4 -0
  66. package/errors/exceptions/invalid-exception-filter.exception.js +11 -0
  67. package/errors/exceptions/invalid-module.exception.d.ts +4 -0
  68. package/errors/exceptions/invalid-module.exception.js +11 -0
  69. package/errors/exceptions/runtime.exception.d.ts +4 -0
  70. package/errors/exceptions/runtime.exception.js +12 -0
  71. package/errors/exceptions/undefined-dependency.exception.d.ts +6 -0
  72. package/errors/exceptions/undefined-dependency.exception.js +11 -0
  73. package/errors/exceptions/undefined-forwardref.exception.d.ts +5 -0
  74. package/errors/exceptions/undefined-forwardref.exception.js +11 -0
  75. package/errors/exceptions/undefined-module.exception.d.ts +4 -0
  76. package/errors/exceptions/undefined-module.exception.js +11 -0
  77. package/errors/exceptions/unknown-dependencies.exception.d.ts +16 -0
  78. package/errors/exceptions/unknown-dependencies.exception.js +15 -0
  79. package/errors/exceptions/unknown-element.exception.d.ts +4 -0
  80. package/errors/exceptions/unknown-element.exception.js +12 -0
  81. package/errors/exceptions/unknown-export.exception.d.ts +4 -0
  82. package/errors/exceptions/unknown-export.exception.js +11 -0
  83. package/errors/exceptions/unknown-module.exception.d.ts +4 -0
  84. package/errors/exceptions/unknown-module.exception.js +10 -0
  85. package/errors/messages.d.ts +15 -0
  86. package/errors/messages.js +126 -0
  87. package/exceptions/external/filter-context.d.ts +10 -0
  88. package/exceptions/external/filter-context.js +37 -0
  89. package/exceptions/external/filter.d.ts +5 -0
  90. package/exceptions/external/filter.js +16 -0
  91. package/exceptions/external/handler.d.ts +9 -0
  92. package/exceptions/external/handler.js +31 -0
  93. package/exceptions/filter-context.d.ts +14 -0
  94. package/exceptions/filter-context.js +55 -0
  95. package/exceptions/select-exception-filter-metadata.d.ts +2 -0
  96. package/exceptions/select-exception-filter-metadata.js +6 -0
  97. package/exceptions/zone/handler.d.ts +5 -0
  98. package/exceptions/zone/handler.js +15 -0
  99. package/exceptions/zone/zone.d.ts +5 -0
  100. package/exceptions/zone/zone.js +32 -0
  101. package/guards/consumer.d.ts +9 -0
  102. package/guards/consumer.js +33 -0
  103. package/guards/context-creator.d.ts +17 -0
  104. package/guards/context-creator.js +69 -0
  105. package/guards/index.d.ts +2 -0
  106. package/guards/index.js +18 -0
  107. package/helpers/color.helper.d.ts +9 -0
  108. package/helpers/color.helper.js +14 -0
  109. package/helpers/context-id-factory.helper.d.ts +2 -0
  110. package/helpers/context-id-factory.helper.js +15 -0
  111. package/helpers/context.helper.d.ts +23 -0
  112. package/helpers/context.helper.js +49 -0
  113. package/helpers/extends-metadata.helper.d.ts +1 -0
  114. package/helpers/extends-metadata.helper.js +9 -0
  115. package/helpers/flatten.helper.d.ts +1 -0
  116. package/helpers/flatten.helper.js +9 -0
  117. package/helpers/messages.helper.d.ts +2 -0
  118. package/helpers/messages.helper.js +7 -0
  119. package/helpers/noop.helper.d.ts +1 -0
  120. package/helpers/noop.helper.js +5 -0
  121. package/helpers/random-string-generator.helper.d.ts +1 -0
  122. package/helpers/random-string-generator.helper.js +6 -0
  123. package/helpers/rethrow.helper.d.ts +1 -0
  124. package/helpers/rethrow.helper.js +7 -0
  125. package/helpers/shared.helper.d.ts +10 -0
  126. package/helpers/shared.helper.js +33 -0
  127. package/helpers/silent.helper.d.ts +10 -0
  128. package/helpers/silent.helper.js +18 -0
  129. package/helpers/transient.helper.d.ts +12 -0
  130. package/helpers/transient.helper.js +26 -0
  131. package/helpers/uuid.helper.d.ts +15 -0
  132. package/helpers/uuid.helper.js +54 -0
  133. package/helpers/validate-each.helper.d.ts +8 -0
  134. package/helpers/validate-each.helper.js +25 -0
  135. package/hooks/before-app-shutdown.hook.d.ts +9 -0
  136. package/hooks/before-app-shutdown.hook.js +45 -0
  137. package/hooks/index.d.ts +5 -0
  138. package/hooks/index.js +21 -0
  139. package/hooks/on-app-bootstrap.hook.d.ts +8 -0
  140. package/hooks/on-app-bootstrap.hook.js +45 -0
  141. package/hooks/on-app-shutdown.hook.d.ts +9 -0
  142. package/hooks/on-app-shutdown.hook.js +46 -0
  143. package/hooks/on-module-destroy.hook.d.ts +8 -0
  144. package/hooks/on-module-destroy.hook.js +45 -0
  145. package/hooks/on-module-init.hook.d.ts +8 -0
  146. package/hooks/on-module-init.hook.js +45 -0
  147. package/index.d.ts +10 -0
  148. package/index.js +32 -0
  149. package/injector/constants.d.ts +2 -0
  150. package/injector/constants.js +7 -0
  151. package/injector/container.d.ts +61 -0
  152. package/injector/container.js +194 -0
  153. package/injector/helpers/class-scope.helper.d.ts +2 -0
  154. package/injector/helpers/class-scope.helper.js +9 -0
  155. package/injector/helpers/classifier.helper.d.ts +4 -0
  156. package/injector/helpers/classifier.helper.js +17 -0
  157. package/injector/helpers/is-durable.helper.d.ts +2 -0
  158. package/injector/helpers/is-durable.helper.js +9 -0
  159. package/injector/index.d.ts +5 -0
  160. package/injector/index.js +20 -0
  161. package/injector/injector.d.ts +87 -0
  162. package/injector/injector.js +452 -0
  163. package/injector/instance/links-host.d.ts +22 -0
  164. package/injector/instance/links-host.js +50 -0
  165. package/injector/instance/loader.d.ts +21 -0
  166. package/injector/instance/loader.js +73 -0
  167. package/injector/instance/resolver.d.ts +16 -0
  168. package/injector/instance/resolver.js +43 -0
  169. package/injector/instance/wrapper.d.ts +90 -0
  170. package/injector/instance/wrapper.js +272 -0
  171. package/injector/internal-core-module/core-providers.d.ts +4 -0
  172. package/injector/internal-core-module/core-providers.js +21 -0
  173. package/injector/internal-core-module/internal-core-module-factory.d.ts +8 -0
  174. package/injector/internal-core-module/internal-core-module-factory.js +42 -0
  175. package/injector/internal-core-module/internal-core-module.d.ts +4 -0
  176. package/injector/internal-core-module/internal-core-module.js +31 -0
  177. package/injector/module/compiler.d.ts +19 -0
  178. package/injector/module/compiler.js +27 -0
  179. package/injector/module/container.d.ts +6 -0
  180. package/injector/module/container.js +24 -0
  181. package/injector/module/lazy/loader.d.ts +21 -0
  182. package/injector/module/lazy/loader.js +49 -0
  183. package/injector/module/lazy/options.d.ts +6 -0
  184. package/injector/module/lazy/options.js +2 -0
  185. package/injector/module/module.d.ts +74 -0
  186. package/injector/module/module.js +383 -0
  187. package/injector/module/ref.d.ts +106 -0
  188. package/injector/module/ref.js +62 -0
  189. package/injector/module/token-factory.d.ts +13 -0
  190. package/injector/module/token-factory.js +71 -0
  191. package/injector/settlement-signal.d.ts +37 -0
  192. package/injector/settlement-signal.js +55 -0
  193. package/inspector/graph-inspector.d.ts +26 -0
  194. package/inspector/graph-inspector.js +163 -0
  195. package/inspector/initialize-on-preview.allowlist.d.ts +6 -0
  196. package/inspector/initialize-on-preview.allowlist.js +13 -0
  197. package/inspector/interfaces/edge.interface.d.ts +28 -0
  198. package/inspector/interfaces/edge.interface.js +2 -0
  199. package/inspector/interfaces/enhancer-metadata-cache-entry.interface.d.ts +12 -0
  200. package/inspector/interfaces/enhancer-metadata-cache-entry.interface.js +2 -0
  201. package/inspector/interfaces/entrypoint.interface.d.ts +10 -0
  202. package/inspector/interfaces/entrypoint.interface.js +2 -0
  203. package/inspector/interfaces/extras.interface.d.ts +18 -0
  204. package/inspector/interfaces/extras.interface.js +2 -0
  205. package/inspector/interfaces/node.interface.d.ts +49 -0
  206. package/inspector/interfaces/node.interface.js +2 -0
  207. package/inspector/interfaces/serialized-graph-json.interface.d.ts +14 -0
  208. package/inspector/interfaces/serialized-graph-json.interface.js +2 -0
  209. package/inspector/interfaces/serialized-graph-metadata.interface.d.ts +10 -0
  210. package/inspector/interfaces/serialized-graph-metadata.interface.js +2 -0
  211. package/inspector/noop-graph-inspector.d.ts +2 -0
  212. package/inspector/noop-graph-inspector.js +8 -0
  213. package/inspector/partial-graph.host.d.ts +7 -0
  214. package/inspector/partial-graph.host.js +15 -0
  215. package/inspector/serialized-graph.d.ts +52 -0
  216. package/inspector/serialized-graph.js +121 -0
  217. package/interceptors/consumer.d.ts +9 -0
  218. package/interceptors/consumer.js +37 -0
  219. package/interceptors/context-creator.d.ts +17 -0
  220. package/interceptors/context-creator.js +67 -0
  221. package/interceptors/index.d.ts +2 -0
  222. package/interceptors/index.js +18 -0
  223. package/interfaces/abstract.interface.d.ts +3 -0
  224. package/interfaces/abstract.interface.js +2 -0
  225. package/interfaces/application/context-options.interface.d.ts +41 -0
  226. package/interfaces/application/context-options.interface.js +9 -0
  227. package/interfaces/application/context.interface.d.ts +162 -0
  228. package/interfaces/application/context.interface.js +2 -0
  229. package/interfaces/application/index.d.ts +1 -0
  230. package/interfaces/application/index.js +17 -0
  231. package/interfaces/context/arguments-host.interface.d.ts +22 -0
  232. package/interfaces/context/arguments-host.interface.js +2 -0
  233. package/interfaces/context/execution.interface.d.ts +18 -0
  234. package/interfaces/context/execution.interface.js +2 -0
  235. package/interfaces/features/exception-filter.interface.d.ts +21 -0
  236. package/interfaces/features/exception-filter.interface.js +2 -0
  237. package/interfaces/features/guards.interface.d.ts +20 -0
  238. package/interfaces/features/guards.interface.js +2 -0
  239. package/interfaces/features/interceptor.interface.d.ts +30 -0
  240. package/interfaces/features/interceptor.interface.js +2 -0
  241. package/interfaces/features/pipes.interface.d.ts +37 -0
  242. package/interfaces/features/pipes.interface.js +2 -0
  243. package/interfaces/helper.interface.d.ts +3 -0
  244. package/interfaces/helper.interface.js +2 -0
  245. package/interfaces/hooks/before-application-shutdown.interface.d.ts +3 -0
  246. package/interfaces/hooks/before-application-shutdown.interface.js +2 -0
  247. package/interfaces/hooks/index.d.ts +5 -0
  248. package/interfaces/hooks/index.js +21 -0
  249. package/interfaces/hooks/on-application-bootstrap.interface.d.ts +9 -0
  250. package/interfaces/hooks/on-application-bootstrap.interface.js +2 -0
  251. package/interfaces/hooks/on-application-shutdown.interface.d.ts +9 -0
  252. package/interfaces/hooks/on-application-shutdown.interface.js +2 -0
  253. package/interfaces/hooks/on-destroy.interface.d.ts +10 -0
  254. package/interfaces/hooks/on-destroy.interface.js +2 -0
  255. package/interfaces/hooks/on-init.interface.d.ts +8 -0
  256. package/interfaces/hooks/on-init.interface.js +2 -0
  257. package/interfaces/index.d.ts +6 -0
  258. package/interfaces/index.js +22 -0
  259. package/interfaces/injectable.interface.d.ts +1 -0
  260. package/interfaces/injectable.interface.js +2 -0
  261. package/interfaces/modules/configurable/async-options.interface.d.ts +42 -0
  262. package/interfaces/modules/configurable/async-options.interface.js +2 -0
  263. package/interfaces/modules/configurable/cls.interface.d.ts +13 -0
  264. package/interfaces/modules/configurable/cls.interface.js +2 -0
  265. package/interfaces/modules/configurable/host.interface.d.ts +62 -0
  266. package/interfaces/modules/configurable/host.interface.js +2 -0
  267. package/interfaces/modules/configurable/index.d.ts +3 -0
  268. package/interfaces/modules/configurable/index.js +19 -0
  269. package/interfaces/modules/definition.interface.d.ts +4 -0
  270. package/interfaces/modules/definition.interface.js +2 -0
  271. package/interfaces/modules/dynamic-module.interface.d.ts +23 -0
  272. package/interfaces/modules/dynamic-module.interface.js +2 -0
  273. package/interfaces/modules/forward-reference.interface.d.ts +3 -0
  274. package/interfaces/modules/forward-reference.interface.js +2 -0
  275. package/interfaces/modules/index.d.ts +9 -0
  276. package/interfaces/modules/index.js +25 -0
  277. package/interfaces/modules/injection-token.interface.d.ts +5 -0
  278. package/interfaces/modules/injection-token.interface.js +2 -0
  279. package/interfaces/modules/introspection-result.interface.d.ts +10 -0
  280. package/interfaces/modules/introspection-result.interface.js +2 -0
  281. package/interfaces/modules/module-metadata.interface.d.ts +24 -0
  282. package/interfaces/modules/module-metadata.interface.js +2 -0
  283. package/interfaces/modules/module.interface.d.ts +2 -0
  284. package/interfaces/modules/module.interface.js +2 -0
  285. package/interfaces/modules/optional-factory-dependency.interface.d.ts +8 -0
  286. package/interfaces/modules/optional-factory-dependency.interface.js +2 -0
  287. package/interfaces/modules/override.interface.d.ts +5 -0
  288. package/interfaces/modules/override.interface.js +2 -0
  289. package/interfaces/modules/provider.interface.d.ts +142 -0
  290. package/interfaces/modules/provider.interface.js +2 -0
  291. package/interfaces/scope.interface.d.ts +35 -0
  292. package/interfaces/scope.interface.js +23 -0
  293. package/interfaces/type.interface.d.ts +3 -0
  294. package/interfaces/type.interface.js +2 -0
  295. package/metadata-scanner.d.ts +4 -0
  296. package/metadata-scanner.js +34 -0
  297. package/module/configurable-module.builder.d.ts +93 -0
  298. package/module/configurable-module.builder.js +204 -0
  299. package/module/constants.d.ts +4 -0
  300. package/module/constants.js +7 -0
  301. package/module/helpers/generate-options-injection-token.helper.d.ts +1 -0
  302. package/module/helpers/generate-options-injection-token.helper.js +9 -0
  303. package/module/helpers/get-injection-providers.helper.d.ts +8 -0
  304. package/module/helpers/get-injection-providers.helper.js +36 -0
  305. package/module/helpers/index.d.ts +2 -0
  306. package/module/helpers/index.js +18 -0
  307. package/module/index.d.ts +2 -0
  308. package/module/index.js +18 -0
  309. package/package.json +35 -0
  310. package/pipes/consumer.d.ts +9 -0
  311. package/pipes/consumer.js +15 -0
  312. package/pipes/context-creator.d.ts +18 -0
  313. package/pipes/context-creator.js +70 -0
  314. package/pipes/index.d.ts +2 -0
  315. package/pipes/index.js +18 -0
  316. package/scanner.d.ts +81 -0
  317. package/scanner.js +374 -0
  318. package/services/console.service.d.ts +86 -0
  319. package/services/console.service.js +233 -0
  320. package/services/index.d.ts +1 -0
  321. package/services/index.js +17 -0
  322. package/services/logger.service.d.ts +157 -0
  323. package/services/logger.service.js +269 -0
  324. package/services/reflector.service.d.ts +110 -0
  325. package/services/reflector.service.js +87 -0
  326. package/test/context/execution-host.spec.d.ts +1 -0
  327. package/test/context/execution-host.spec.js +31 -0
  328. package/test/context/external/creator.spec.d.ts +1 -0
  329. package/test/context/external/creator.spec.js +149 -0
  330. package/test/context/external/proxy.spec.d.ts +1 -0
  331. package/test/context/external/proxy.spec.js +45 -0
  332. package/test/exceptions/external/handler.spec.d.ts +1 -0
  333. package/test/exceptions/external/handler.spec.js +89 -0
  334. package/test/exceptions/filter-context.spec.d.ts +2 -0
  335. package/test/exceptions/filter-context.spec.js +91 -0
  336. package/test/exceptions/messages.spec.d.ts +0 -0
  337. package/test/exceptions/messages.spec.js +201 -0
  338. package/test/exceptions/zona/handler.spec.d.ts +1 -0
  339. package/test/exceptions/zona/handler.spec.js +51 -0
  340. package/test/exceptions/zona/zone.spec.d.ts +1 -0
  341. package/test/exceptions/zona/zone.spec.js +66 -0
  342. package/test/guards/consumer.spec.d.ts +1 -0
  343. package/test/guards/consumer.spec.js +47 -0
  344. package/test/guards/context-creator.spec.d.ts +1 -0
  345. package/test/guards/context-creator.spec.js +138 -0
  346. package/test/helpers/context-id-factory.spec.d.ts +1 -0
  347. package/test/helpers/context-id-factory.spec.js +9 -0
  348. package/test/helpers/shared.spec.d.ts +1 -0
  349. package/test/helpers/shared.spec.js +122 -0
  350. package/test/hooks/before-app-shutdown.hook.spec.d.ts +1 -0
  351. package/test/hooks/before-app-shutdown.hook.spec.js +44 -0
  352. package/test/hooks/on-app-bootstrap.hook.spec.d.ts +1 -0
  353. package/test/hooks/on-app-bootstrap.hook.spec.js +43 -0
  354. package/test/hooks/on-app-shutdown.hook.spec.d.ts +1 -0
  355. package/test/hooks/on-app-shutdown.hook.spec.js +43 -0
  356. package/test/hooks/on-module-destroy.hook.spec.d.ts +1 -0
  357. package/test/hooks/on-module-destroy.hook.spec.js +43 -0
  358. package/test/hooks/on-module-init.hook.spec.d.ts +1 -0
  359. package/test/hooks/on-module-init.hook.spec.js +43 -0
  360. package/test/injector/compiler.spec.d.ts +1 -0
  361. package/test/injector/compiler.spec.js +42 -0
  362. package/test/injector/container.spec.d.ts +1 -0
  363. package/test/injector/container.spec.js +203 -0
  364. package/test/injector/helpers/classifier.spec.d.ts +1 -0
  365. package/test/injector/helpers/classifier.spec.js +102 -0
  366. package/test/injector/injector.spec.d.ts +1 -0
  367. package/test/injector/injector.spec.js +678 -0
  368. package/test/injector/instance/loader.spec.d.ts +1 -0
  369. package/test/injector/instance/loader.spec.js +108 -0
  370. package/test/injector/instance/wrapper.spec.d.ts +1 -0
  371. package/test/injector/instance/wrapper.spec.js +772 -0
  372. package/test/injector/internal-core-module/internal-core-module-factory.spec.d.ts +1 -0
  373. package/test/injector/internal-core-module/internal-core-module-factory.spec.js +27 -0
  374. package/test/injector/module/lazy/loader.spec.d.ts +1 -0
  375. package/test/injector/module/lazy/loader.spec.js +71 -0
  376. package/test/injector/module/module.spec.d.ts +1 -0
  377. package/test/injector/module/module.spec.js +410 -0
  378. package/test/injector/module/token-factory.spec.d.ts +1 -0
  379. package/test/injector/module/token-factory.spec.js +84 -0
  380. package/test/interceptors/consumer.spec.d.ts +1 -0
  381. package/test/interceptors/consumer.spec.js +136 -0
  382. package/test/interceptors/context-creator.spec.d.ts +1 -0
  383. package/test/interceptors/context-creator.spec.js +139 -0
  384. package/test/metadata-scanner.spec.d.ts +1 -0
  385. package/test/metadata-scanner.spec.js +41 -0
  386. package/test/module/configurable-module.builder.spec.d.ts +1 -0
  387. package/test/module/configurable-module.builder.spec.js +102 -0
  388. package/test/module/helpers/get-injection-providers.helper.spec.d.ts +1 -0
  389. package/test/module/helpers/get-injection-providers.helper.spec.js +49 -0
  390. package/test/pipes/consumer.spec.d.ts +1 -0
  391. package/test/pipes/consumer.spec.js +42 -0
  392. package/test/pipes/context-creator.spec.d.ts +1 -0
  393. package/test/pipes/context-creator.spec.js +108 -0
  394. package/test/scanner.spec.d.ts +1 -0
  395. package/test/scanner.spec.js +620 -0
  396. package/test/services/logger.service.spec.d.ts +1 -0
  397. package/test/services/logger.service.spec.js +487 -0
  398. package/test/services/reflector.service.spec.d.ts +1 -0
  399. package/test/services/reflector.service.spec.js +105 -0
  400. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GuardsContextCreator = void 0;
4
+ const creator_1 = require("@venok/core/context/creator");
5
+ const constants_1 = require("@venok/core/injector/constants");
6
+ const constants_2 = require("@venok/core/constants");
7
+ const shared_helper_1 = require("@venok/core/helpers/shared.helper");
8
+ class GuardsContextCreator extends creator_1.ContextCreator {
9
+ constructor(container, config) {
10
+ super();
11
+ this.container = container;
12
+ this.config = config;
13
+ }
14
+ create(instance, callback, module, contextId = constants_1.STATIC_CONTEXT, inquirerId) {
15
+ this.moduleContext = module;
16
+ return this.createContext(instance, callback, constants_2.GUARDS_METADATA, contextId, inquirerId);
17
+ }
18
+ createConcreteContext(metadata, contextId = constants_1.STATIC_CONTEXT, inquirerId) {
19
+ if ((0, shared_helper_1.isEmpty)(metadata)) {
20
+ return [];
21
+ }
22
+ return metadata
23
+ .filter((guard) => guard && (guard.name || guard.canActivate))
24
+ .map((guard) => this.getGuardInstance(guard, contextId, inquirerId))
25
+ .filter((guard) => guard && (0, shared_helper_1.isFunction)(guard.canActivate));
26
+ }
27
+ getGuardInstance(metatype, contextId = constants_1.STATIC_CONTEXT, inquirerId) {
28
+ const isObject = metatype.canActivate;
29
+ // Maybe error
30
+ // @ts-ignore
31
+ if (isObject) {
32
+ return metatype;
33
+ }
34
+ const instanceWrapper = this.getInstanceByMetatype(metatype);
35
+ if (!instanceWrapper) {
36
+ return null;
37
+ }
38
+ const instanceHost = instanceWrapper.getInstanceByContextId(this.getContextId(contextId, instanceWrapper), inquirerId);
39
+ return instanceHost && instanceHost.instance;
40
+ }
41
+ getInstanceByMetatype(metatype) {
42
+ if (!this.moduleContext) {
43
+ return;
44
+ }
45
+ const collection = this.container.getModules();
46
+ const moduleRef = collection.get(this.moduleContext);
47
+ if (!moduleRef) {
48
+ return;
49
+ }
50
+ const injectables = moduleRef.injectables;
51
+ return injectables.get(metatype);
52
+ }
53
+ getGlobalMetadata(contextId = constants_1.STATIC_CONTEXT, inquirerId) {
54
+ if (!this.config) {
55
+ return [];
56
+ }
57
+ const globalGuards = this.config.getGlobalGuards();
58
+ if (contextId === constants_1.STATIC_CONTEXT && !inquirerId) {
59
+ return globalGuards;
60
+ }
61
+ const scopedGuardWrappers = this.config.getGlobalRequestGuards();
62
+ const scopedGuards = scopedGuardWrappers
63
+ .map((wrapper) => wrapper.getInstanceByContextId(this.getContextId(contextId, wrapper), inquirerId))
64
+ .filter((host) => !!host)
65
+ .map((host) => host.instance);
66
+ return globalGuards.concat(scopedGuards);
67
+ }
68
+ }
69
+ exports.GuardsContextCreator = GuardsContextCreator;
@@ -0,0 +1,2 @@
1
+ export * from "./consumer";
2
+ export * from "./context-creator";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./consumer"), exports);
18
+ __exportStar(require("./context-creator"), exports);
@@ -0,0 +1,9 @@
1
+ export declare const colors: {
2
+ bold: (text: string) => string;
3
+ green: (text: string) => string;
4
+ yellow: (text: string) => string;
5
+ red: (text: string) => string;
6
+ magentaBright: (text: string) => string;
7
+ cyanBright: (text: string) => string;
8
+ };
9
+ export declare const yellow: (text: string) => string;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.yellow = exports.colors = void 0;
4
+ const isColorAllowed = () => !process.env.NO_COLOR;
5
+ const colorIfAllowed = (colorFn) => (text) => (isColorAllowed() ? colorFn(text) : text);
6
+ exports.colors = {
7
+ bold: colorIfAllowed((text) => `\x1B[1m${text}\x1B[0m`),
8
+ green: colorIfAllowed((text) => `\x1B[32m${text}\x1B[39m`),
9
+ yellow: colorIfAllowed((text) => `\x1B[33m${text}\x1B[39m`),
10
+ red: colorIfAllowed((text) => `\x1B[31m${text}\x1B[39m`),
11
+ magentaBright: colorIfAllowed((text) => `\x1B[95m${text}\x1B[39m`),
12
+ cyanBright: colorIfAllowed((text) => `\x1B[96m${text}\x1B[39m`),
13
+ };
14
+ exports.yellow = colorIfAllowed((text) => `\x1B[38;5;3m${text}\x1B[39m`);
@@ -0,0 +1,2 @@
1
+ import { ContextId } from "@venok/core/injector/instance/wrapper";
2
+ export declare function createContextId(): ContextId;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createContextId = void 0;
4
+ function createContextId() {
5
+ /**
6
+ * We are generating random identifier to track asynchronous
7
+ * execution context. An identifier does not have to be neither unique
8
+ * nor unpredictable because WeakMap uses objects as keys (reference comparison).
9
+ * Thus, even though identifier number might be equal, WeakMap would properly
10
+ * associate asynchronous context with its internal map values using object reference.
11
+ * Object is automatically removed once request has been processed (closure).
12
+ */
13
+ return { id: Math.random() };
14
+ }
15
+ exports.createContextId = createContextId;
@@ -0,0 +1,23 @@
1
+ import { ParamData } from "@venok/core/decorators/create-param.decorator";
2
+ import { PipeTransform } from "@venok/core/interfaces/features/pipes.interface";
3
+ import { ExecutionContextHost } from "@venok/core/context/execution-host";
4
+ import { ContextType } from "@venok/core/interfaces/context/arguments-host.interface";
5
+ export interface ParamProperties<T = any, IExtractor extends Function = any> {
6
+ index: number;
7
+ type: T | string;
8
+ data: ParamData;
9
+ pipes: PipeTransform[];
10
+ extractValue: IExtractor;
11
+ }
12
+ export declare class ContextUtils {
13
+ mapParamType(key: string): string;
14
+ reflectCallbackParamtypes(instance: object, methodName: string): any[];
15
+ reflectCallbackMetadata<T = any>(instance: object, methodName: string, metadataKey: string): T;
16
+ getArgumentsLength<T>(keys: string[], metadata: T): number;
17
+ createNullArray(length: number): any[];
18
+ mergeParamsMetatypes(paramsProperties: ParamProperties[], paramtypes: any[]): (ParamProperties & {
19
+ metatype?: any;
20
+ })[];
21
+ getCustomFactory(factory: (...args: unknown[]) => void, data: unknown, contextFactory: (args: unknown[]) => ExecutionContextHost): (...args: unknown[]) => unknown;
22
+ getContextFactory<TContext extends string = ContextType>(contextType: TContext, instance?: object, callback?: Function): (args: unknown[]) => ExecutionContextHost;
23
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContextUtils = void 0;
4
+ const constants_1 = require("@venok/core/constants");
5
+ const execution_host_1 = require("@venok/core/context/execution-host");
6
+ const shared_helper_1 = require("@venok/core/helpers/shared.helper");
7
+ class ContextUtils {
8
+ mapParamType(key) {
9
+ const keyPair = key.split(":");
10
+ return keyPair[0];
11
+ }
12
+ reflectCallbackParamtypes(instance, methodName) {
13
+ return Reflect.getMetadata(constants_1.PARAMTYPES_METADATA, instance, methodName);
14
+ }
15
+ reflectCallbackMetadata(instance, methodName, metadataKey) {
16
+ return Reflect.getMetadata(metadataKey, instance.constructor, methodName);
17
+ }
18
+ getArgumentsLength(keys, metadata) {
19
+ // Maybe Error
20
+ // @ts-ignore
21
+ return keys.length ? Math.max(...keys.map((key) => metadata[key].index)) + 1 : 0;
22
+ }
23
+ createNullArray(length) {
24
+ const a = new Array(length);
25
+ for (let i = 0; i < length; ++i)
26
+ a[i] = undefined;
27
+ return a;
28
+ }
29
+ mergeParamsMetatypes(paramsProperties, paramtypes) {
30
+ if (!paramtypes) {
31
+ return paramsProperties;
32
+ }
33
+ return paramsProperties.map((param) => ({
34
+ ...param,
35
+ metatype: paramtypes[param.index],
36
+ }));
37
+ }
38
+ getCustomFactory(factory, data, contextFactory) {
39
+ return (0, shared_helper_1.isFunction)(factory) ? (...args) => factory(data, contextFactory(args)) : () => null;
40
+ }
41
+ getContextFactory(contextType, instance, callback) {
42
+ return (args) => {
43
+ const ctx = new execution_host_1.ExecutionContextHost(args, instance && instance.constructor, callback);
44
+ ctx.setType(contextType);
45
+ return ctx;
46
+ };
47
+ }
48
+ }
49
+ exports.ContextUtils = ContextUtils;
@@ -0,0 +1 @@
1
+ export declare function extendArrayMetadata<T extends Array<unknown>>(key: string, metadata: T, target: Function): void;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extendArrayMetadata = void 0;
4
+ function extendArrayMetadata(key, metadata, target) {
5
+ const previousValue = Reflect.getMetadata(key, target) || [];
6
+ const value = [...previousValue, ...metadata];
7
+ Reflect.defineMetadata(key, value, target);
8
+ }
9
+ exports.extendArrayMetadata = extendArrayMetadata;
@@ -0,0 +1 @@
1
+ export declare function flatten<T extends Array<unknown> = any>(arr: T): T extends Array<infer R> ? R : never;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.flatten = void 0;
4
+ function flatten(arr) {
5
+ // @ts-ignore
6
+ const flat = [].concat(...arr);
7
+ return flat.some(Array.isArray) ? flatten(flat) : flat;
8
+ }
9
+ exports.flatten = flatten;
@@ -0,0 +1,2 @@
1
+ export declare const MODULE_INIT_MESSAGE: (text: TemplateStringsArray, module: string) => string;
2
+ export declare const INVALID_EXECUTION_CONTEXT: (methodName: string, currentContext: string) => string;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.INVALID_EXECUTION_CONTEXT = exports.MODULE_INIT_MESSAGE = void 0;
4
+ const MODULE_INIT_MESSAGE = (text, module) => `${module} dependencies initialized`;
5
+ exports.MODULE_INIT_MESSAGE = MODULE_INIT_MESSAGE;
6
+ const INVALID_EXECUTION_CONTEXT = (methodName, currentContext) => `Calling ${methodName} is not allowed in this context. Your current execution context is "${currentContext}".`;
7
+ exports.INVALID_EXECUTION_CONTEXT = INVALID_EXECUTION_CONTEXT;
@@ -0,0 +1 @@
1
+ export declare const noop: () => void;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.noop = void 0;
4
+ const noop = () => { };
5
+ exports.noop = noop;
@@ -0,0 +1 @@
1
+ export declare const randomStringGenerator: () => string;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.randomStringGenerator = void 0;
4
+ const uid_1 = require("uid");
5
+ const randomStringGenerator = () => (0, uid_1.uid)(21);
6
+ exports.randomStringGenerator = randomStringGenerator;
@@ -0,0 +1 @@
1
+ export declare const rethrow: (err: unknown) => never;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rethrow = void 0;
4
+ const rethrow = (err) => {
5
+ throw err;
6
+ };
7
+ exports.rethrow = rethrow;
@@ -0,0 +1,10 @@
1
+ export declare const isUndefined: (obj: any) => obj is undefined;
2
+ export declare const isNull: (val: any) => val is null | undefined;
3
+ export declare const isObject: (fn: any) => fn is object;
4
+ export declare const isFunction: (val: any) => val is Function;
5
+ export declare const isString: (val: any) => val is string;
6
+ export declare const isNumber: (val: any) => val is number;
7
+ export declare const isConstructor: (val: any) => boolean;
8
+ export declare const isEmpty: (array: any) => boolean;
9
+ export declare const isSymbol: (val: any) => val is symbol;
10
+ export declare const isPlainObject: (fn: any) => fn is object;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPlainObject = exports.isSymbol = exports.isEmpty = exports.isConstructor = exports.isNumber = exports.isString = exports.isFunction = exports.isObject = exports.isNull = exports.isUndefined = void 0;
4
+ const isUndefined = (obj) => typeof obj === "undefined";
5
+ exports.isUndefined = isUndefined;
6
+ const isNull = (val) => (0, exports.isUndefined)(val) || val === null;
7
+ exports.isNull = isNull;
8
+ const isObject = (fn) => !(0, exports.isNull)(fn) && typeof fn === "object";
9
+ exports.isObject = isObject;
10
+ const isFunction = (val) => typeof val === "function";
11
+ exports.isFunction = isFunction;
12
+ const isString = (val) => typeof val === "string";
13
+ exports.isString = isString;
14
+ const isNumber = (val) => typeof val === "number";
15
+ exports.isNumber = isNumber;
16
+ const isConstructor = (val) => val === "constructor";
17
+ exports.isConstructor = isConstructor;
18
+ const isEmpty = (array) => !(array && array.length > 0);
19
+ exports.isEmpty = isEmpty;
20
+ const isSymbol = (val) => typeof val === "symbol";
21
+ exports.isSymbol = isSymbol;
22
+ const isPlainObject = (fn) => {
23
+ if (!(0, exports.isObject)(fn))
24
+ return false;
25
+ const proto = Object.getPrototypeOf(fn);
26
+ if (proto === null)
27
+ return true;
28
+ const ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
29
+ return (typeof ctor === "function" &&
30
+ ctor instanceof ctor &&
31
+ Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object));
32
+ };
33
+ exports.isPlainObject = isPlainObject;
@@ -0,0 +1,10 @@
1
+ import { Logger } from "@venok/core/services/logger.service";
2
+ export declare class SilentLogger extends Logger {
3
+ log: () => void;
4
+ error: () => void;
5
+ warn: () => void;
6
+ debug: () => void;
7
+ verbose: () => void;
8
+ fatal: () => void;
9
+ setLogLevels: () => void;
10
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SilentLogger = void 0;
4
+ const logger_service_1 = require("@venok/core/services/logger.service");
5
+ const noop_helper_1 = require("@venok/core/helpers/noop.helper");
6
+ class SilentLogger extends logger_service_1.Logger {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.log = noop_helper_1.noop;
10
+ this.error = noop_helper_1.noop;
11
+ this.warn = noop_helper_1.noop;
12
+ this.debug = noop_helper_1.noop;
13
+ this.verbose = noop_helper_1.noop;
14
+ this.fatal = noop_helper_1.noop;
15
+ this.setLogLevels = noop_helper_1.noop;
16
+ }
17
+ }
18
+ exports.SilentLogger = SilentLogger;
@@ -0,0 +1,12 @@
1
+ import { InjectionToken } from "@venok/core/interfaces";
2
+ import { InstanceWrapper } from "@venok/core/injector/instance/wrapper";
3
+ /**
4
+ * Returns the instances which are transient
5
+ * @param instances The instances which should be checked whether they are transient
6
+ */
7
+ export declare function getTransientInstances(instances: [InjectionToken, InstanceWrapper][]): InstanceWrapper[];
8
+ /**
9
+ * Returns the instances which are not transient
10
+ * @param instances The instances which should be checked whether they are transient
11
+ */
12
+ export declare function getNonTransientInstances(instances: [InjectionToken, InstanceWrapper][]): InstanceWrapper[];
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNonTransientInstances = exports.getTransientInstances = void 0;
4
+ const flatten_helper_1 = require("@venok/core/helpers/flatten.helper");
5
+ /**
6
+ * Returns the instances which are transient
7
+ * @param instances The instances which should be checked whether they are transient
8
+ */
9
+ function getTransientInstances(instances) {
10
+ return (0, flatten_helper_1.flatten)(instances
11
+ .filter(([_, wrapper]) => wrapper.isDependencyTreeStatic())
12
+ .map(([_, wrapper]) => wrapper.getStaticTransientInstances()))
13
+ .filter(Boolean)
14
+ .map(({ instance }) => instance);
15
+ }
16
+ exports.getTransientInstances = getTransientInstances;
17
+ /**
18
+ * Returns the instances which are not transient
19
+ * @param instances The instances which should be checked whether they are transient
20
+ */
21
+ function getNonTransientInstances(instances) {
22
+ return instances
23
+ .filter(([key, wrapper]) => wrapper.isDependencyTreeStatic() && !wrapper.isTransient)
24
+ .map(([key, { instance }]) => instance);
25
+ }
26
+ exports.getNonTransientInstances = getNonTransientInstances;
@@ -0,0 +1,15 @@
1
+ export declare enum UuidFactoryMode {
2
+ Random = "random",
3
+ Deterministic = "deterministic"
4
+ }
5
+ export declare class DeterministicUuidRegistry {
6
+ private static readonly registry;
7
+ static get(str: string, inc?: number): string;
8
+ static clear(): void;
9
+ private static hashCode;
10
+ }
11
+ export declare class UuidFactory {
12
+ #private;
13
+ static set mode(value: UuidFactoryMode);
14
+ static get(key?: string): string;
15
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _a, _UuidFactory_mode;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.UuidFactory = exports.DeterministicUuidRegistry = exports.UuidFactoryMode = void 0;
16
+ const random_string_generator_helper_1 = require("@venok/core/helpers/random-string-generator.helper");
17
+ var UuidFactoryMode;
18
+ (function (UuidFactoryMode) {
19
+ UuidFactoryMode["Random"] = "random";
20
+ UuidFactoryMode["Deterministic"] = "deterministic";
21
+ })(UuidFactoryMode || (exports.UuidFactoryMode = UuidFactoryMode = {}));
22
+ class DeterministicUuidRegistry {
23
+ static get(str, inc = 0) {
24
+ const id = inc ? this.hashCode(`${str}_${inc}`) : this.hashCode(str);
25
+ if (this.registry.has(id))
26
+ return this.get(str, inc + 1);
27
+ this.registry.set(id, true);
28
+ return id;
29
+ }
30
+ static clear() {
31
+ this.registry.clear();
32
+ }
33
+ static hashCode(s) {
34
+ let h = 0;
35
+ for (let i = 0; i < s.length; i++)
36
+ h = (Math.imul(31, h) + s.charCodeAt(i)) | 0;
37
+ return h.toString();
38
+ }
39
+ }
40
+ exports.DeterministicUuidRegistry = DeterministicUuidRegistry;
41
+ DeterministicUuidRegistry.registry = new Map();
42
+ class UuidFactory {
43
+ static set mode(value) {
44
+ __classPrivateFieldSet(_a, _a, value, "f", _UuidFactory_mode);
45
+ }
46
+ static get(key = "") {
47
+ return __classPrivateFieldGet(_a, _a, "f", _UuidFactory_mode) === UuidFactoryMode.Deterministic
48
+ ? DeterministicUuidRegistry.get(key)
49
+ : (0, random_string_generator_helper_1.randomStringGenerator)();
50
+ }
51
+ }
52
+ exports.UuidFactory = UuidFactory;
53
+ _a = UuidFactory;
54
+ _UuidFactory_mode = { value: UuidFactoryMode.Random };
@@ -0,0 +1,8 @@
1
+ export declare class InvalidDecoratorItemException extends Error {
2
+ private readonly msg;
3
+ constructor(decorator: string, item: string, context: string);
4
+ what(): string;
5
+ }
6
+ export declare function validateEach(context: {
7
+ name: string;
8
+ }, arr: any[], predicate: Function, decorator: string, item: string): boolean;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateEach = exports.InvalidDecoratorItemException = void 0;
4
+ class InvalidDecoratorItemException extends Error {
5
+ constructor(decorator, item, context) {
6
+ const message = `Invalid ${item} passed to ${decorator}() decorator (${context}).`;
7
+ super(message);
8
+ this.msg = message;
9
+ }
10
+ what() {
11
+ return this.msg;
12
+ }
13
+ }
14
+ exports.InvalidDecoratorItemException = InvalidDecoratorItemException;
15
+ function validateEach(context, arr, predicate, decorator, item) {
16
+ if (!context || !context.name) {
17
+ return true;
18
+ }
19
+ const errors = arr.some((str) => !predicate(str));
20
+ if (errors) {
21
+ throw new InvalidDecoratorItemException(decorator, item, context.name);
22
+ }
23
+ return true;
24
+ }
25
+ exports.validateEach = validateEach;
@@ -0,0 +1,9 @@
1
+ import { Module } from "@venok/core/injector/module/module";
2
+ /**
3
+ * Calls the `beforeApplicationShutdown` function on the module and its children
4
+ * (providers / controllers).
5
+ *
6
+ * @param module The module which will be initialized
7
+ * @param signal The signal which caused the shutdown
8
+ */
9
+ export declare function callBeforeAppShutdownHook(module: Module, signal?: string): Promise<void>;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.callBeforeAppShutdownHook = void 0;
4
+ const shared_helper_1 = require("@venok/core/helpers/shared.helper");
5
+ const transient_helper_1 = require("@venok/core/helpers/transient.helper");
6
+ /**
7
+ * Checks if the given instance has the `beforeApplicationShutdown` function
8
+ *
9
+ * @param instance The instance which should be checked
10
+ */
11
+ function hasBeforeApplicationShutdownHook(instance) {
12
+ return (0, shared_helper_1.isFunction)(instance.beforeApplicationShutdown);
13
+ }
14
+ /**
15
+ * Calls the given instances
16
+ */
17
+ function callOperator(instances, signal) {
18
+ return instances
19
+ .filter((instance) => !(0, shared_helper_1.isNull)(instance))
20
+ .filter(hasBeforeApplicationShutdownHook)
21
+ .map(async (instance) => instance.beforeApplicationShutdown(signal));
22
+ }
23
+ /**
24
+ * Calls the `beforeApplicationShutdown` function on the module and its children
25
+ * (providers / controllers).
26
+ *
27
+ * @param module The module which will be initialized
28
+ * @param signal The signal which caused the shutdown
29
+ */
30
+ async function callBeforeAppShutdownHook(module, signal) {
31
+ const providers = module.getNonAliasProviders();
32
+ const [_, moduleClassHost] = providers.shift();
33
+ const instances = [...providers, ...module.injectables];
34
+ const nonTransientInstances = (0, transient_helper_1.getNonTransientInstances)(instances);
35
+ await Promise.all(callOperator(nonTransientInstances, signal));
36
+ const transientInstances = (0, transient_helper_1.getTransientInstances)(instances);
37
+ await Promise.all(callOperator(transientInstances, signal));
38
+ const moduleClassInstance = moduleClassHost.instance;
39
+ if (moduleClassInstance &&
40
+ hasBeforeApplicationShutdownHook(moduleClassInstance) &&
41
+ moduleClassHost.isDependencyTreeStatic()) {
42
+ await moduleClassInstance.beforeApplicationShutdown(signal);
43
+ }
44
+ }
45
+ exports.callBeforeAppShutdownHook = callBeforeAppShutdownHook;
@@ -0,0 +1,5 @@
1
+ export * from './on-app-bootstrap.hook';
2
+ export * from './on-app-shutdown.hook';
3
+ export * from './on-module-destroy.hook';
4
+ export * from './on-module-init.hook';
5
+ export * from './before-app-shutdown.hook';
package/hooks/index.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./on-app-bootstrap.hook"), exports);
18
+ __exportStar(require("./on-app-shutdown.hook"), exports);
19
+ __exportStar(require("./on-module-destroy.hook"), exports);
20
+ __exportStar(require("./on-module-init.hook"), exports);
21
+ __exportStar(require("./before-app-shutdown.hook"), exports);
@@ -0,0 +1,8 @@
1
+ import { Module } from "@venok/core/injector/module/module";
2
+ /**
3
+ * Calls the `onApplicationBootstrap` function on the module and its children
4
+ * (providers / controllers).
5
+ *
6
+ * @param module The module which will be initialized
7
+ */
8
+ export declare function callModuleBootstrapHook(module: Module): Promise<any>;