@depup/nestjs__core 11.1.17-depup.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 (371) hide show
  1. package/LICENSE +22 -0
  2. package/PACKAGE.md +1 -0
  3. package/README.md +25 -0
  4. package/Readme.md +146 -0
  5. package/adapters/http-adapter.d.ts +80 -0
  6. package/adapters/http-adapter.js +90 -0
  7. package/adapters/index.d.ts +1 -0
  8. package/adapters/index.js +4 -0
  9. package/application-config.d.ts +47 -0
  10. package/application-config.js +107 -0
  11. package/changes.json +5 -0
  12. package/constants.d.ts +14 -0
  13. package/constants.js +21 -0
  14. package/discovery/discoverable-meta-host-collection.d.ts +46 -0
  15. package/discovery/discoverable-meta-host-collection.js +98 -0
  16. package/discovery/discovery-module.d.ts +5 -0
  17. package/discovery/discovery-module.js +19 -0
  18. package/discovery/discovery-service.d.ts +76 -0
  19. package/discovery/discovery-service.js +98 -0
  20. package/discovery/index.d.ts +2 -0
  21. package/discovery/index.js +5 -0
  22. package/errors/exception-handler.d.ts +4 -0
  23. package/errors/exception-handler.js +11 -0
  24. package/errors/exceptions/circular-dependency.exception.d.ts +4 -0
  25. package/errors/exceptions/circular-dependency.exception.js +11 -0
  26. package/errors/exceptions/index.d.ts +8 -0
  27. package/errors/exceptions/index.js +11 -0
  28. package/errors/exceptions/invalid-class-module.exception.d.ts +4 -0
  29. package/errors/exceptions/invalid-class-module.exception.js +11 -0
  30. package/errors/exceptions/invalid-class-scope.exception.d.ts +5 -0
  31. package/errors/exceptions/invalid-class-scope.exception.js +16 -0
  32. package/errors/exceptions/invalid-class.exception.d.ts +4 -0
  33. package/errors/exceptions/invalid-class.exception.js +11 -0
  34. package/errors/exceptions/invalid-exception-filter.exception.d.ts +4 -0
  35. package/errors/exceptions/invalid-exception-filter.exception.js +11 -0
  36. package/errors/exceptions/invalid-middleware-configuration.exception.d.ts +4 -0
  37. package/errors/exceptions/invalid-middleware-configuration.exception.js +11 -0
  38. package/errors/exceptions/invalid-middleware.exception.d.ts +4 -0
  39. package/errors/exceptions/invalid-middleware.exception.js +11 -0
  40. package/errors/exceptions/invalid-module.exception.d.ts +4 -0
  41. package/errors/exceptions/invalid-module.exception.js +11 -0
  42. package/errors/exceptions/runtime.exception.d.ts +4 -0
  43. package/errors/exceptions/runtime.exception.js +12 -0
  44. package/errors/exceptions/undefined-dependency.exception.d.ts +6 -0
  45. package/errors/exceptions/undefined-dependency.exception.js +11 -0
  46. package/errors/exceptions/undefined-forwardref.exception.d.ts +5 -0
  47. package/errors/exceptions/undefined-forwardref.exception.js +11 -0
  48. package/errors/exceptions/undefined-module.exception.d.ts +4 -0
  49. package/errors/exceptions/undefined-module.exception.js +11 -0
  50. package/errors/exceptions/unknown-dependencies.exception.d.ts +16 -0
  51. package/errors/exceptions/unknown-dependencies.exception.js +15 -0
  52. package/errors/exceptions/unknown-element.exception.d.ts +4 -0
  53. package/errors/exceptions/unknown-element.exception.js +11 -0
  54. package/errors/exceptions/unknown-export.exception.d.ts +4 -0
  55. package/errors/exceptions/unknown-export.exception.js +11 -0
  56. package/errors/exceptions/unknown-module.exception.d.ts +4 -0
  57. package/errors/exceptions/unknown-module.exception.js +10 -0
  58. package/errors/exceptions/unknown-request-mapping.exception.d.ts +5 -0
  59. package/errors/exceptions/unknown-request-mapping.exception.js +11 -0
  60. package/errors/exceptions-zone.d.ts +5 -0
  61. package/errors/exceptions-zone.js +34 -0
  62. package/errors/messages.d.ts +17 -0
  63. package/errors/messages.js +174 -0
  64. package/exceptions/base-exception-filter-context.d.ts +14 -0
  65. package/exceptions/base-exception-filter-context.js +56 -0
  66. package/exceptions/base-exception-filter.d.ts +20 -0
  67. package/exceptions/base-exception-filter.js +72 -0
  68. package/exceptions/exceptions-handler.d.ts +10 -0
  69. package/exceptions/exceptions-handler.js +34 -0
  70. package/exceptions/external-exception-filter-context.d.ts +12 -0
  71. package/exceptions/external-exception-filter-context.js +42 -0
  72. package/exceptions/external-exception-filter.d.ts +5 -0
  73. package/exceptions/external-exception-filter.js +15 -0
  74. package/exceptions/external-exceptions-handler.d.ts +9 -0
  75. package/exceptions/external-exceptions-handler.js +34 -0
  76. package/exceptions/index.d.ts +1 -0
  77. package/exceptions/index.js +4 -0
  78. package/guards/constants.d.ts +1 -0
  79. package/guards/constants.js +4 -0
  80. package/guards/guards-consumer.d.ts +9 -0
  81. package/guards/guards-consumer.js +39 -0
  82. package/guards/guards-context-creator.d.ts +17 -0
  83. package/guards/guards-context-creator.js +70 -0
  84. package/guards/index.d.ts +3 -0
  85. package/guards/index.js +6 -0
  86. package/helpers/barrier.d.ts +30 -0
  87. package/helpers/barrier.js +46 -0
  88. package/helpers/context-creator.d.ts +10 -0
  89. package/helpers/context-creator.js +33 -0
  90. package/helpers/context-id-factory.d.ts +41 -0
  91. package/helpers/context-id-factory.js +67 -0
  92. package/helpers/context-utils.d.ts +23 -0
  93. package/helpers/context-utils.js +55 -0
  94. package/helpers/execution-context-host.d.ts +19 -0
  95. package/helpers/execution-context-host.js +50 -0
  96. package/helpers/external-context-creator.d.ts +51 -0
  97. package/helpers/external-context-creator.js +166 -0
  98. package/helpers/external-proxy.d.ts +5 -0
  99. package/helpers/external-proxy.js +19 -0
  100. package/helpers/get-class-scope.d.ts +3 -0
  101. package/helpers/get-class-scope.js +8 -0
  102. package/helpers/handler-metadata-storage.d.ts +27 -0
  103. package/helpers/handler-metadata-storage.js +26 -0
  104. package/helpers/http-adapter-host.d.ts +51 -0
  105. package/helpers/http-adapter-host.js +73 -0
  106. package/helpers/index.d.ts +3 -0
  107. package/helpers/index.js +6 -0
  108. package/helpers/interfaces/external-handler-metadata.interface.d.ts +11 -0
  109. package/helpers/interfaces/external-handler-metadata.interface.js +2 -0
  110. package/helpers/interfaces/index.d.ts +2 -0
  111. package/helpers/interfaces/index.js +5 -0
  112. package/helpers/interfaces/params-metadata.interface.d.ts +6 -0
  113. package/helpers/interfaces/params-metadata.interface.js +2 -0
  114. package/helpers/is-durable.d.ts +2 -0
  115. package/helpers/is-durable.js +8 -0
  116. package/helpers/load-adapter.d.ts +1 -0
  117. package/helpers/load-adapter.js +15 -0
  118. package/helpers/messages.d.ts +7 -0
  119. package/helpers/messages.js +29 -0
  120. package/helpers/optional-require.d.ts +1 -0
  121. package/helpers/optional-require.js +11 -0
  122. package/helpers/rethrow.d.ts +1 -0
  123. package/helpers/rethrow.js +7 -0
  124. package/helpers/router-method-factory.d.ts +23 -0
  125. package/helpers/router-method-factory.js +33 -0
  126. package/hooks/before-app-shutdown.hook.d.ts +9 -0
  127. package/hooks/before-app-shutdown.hook.js +51 -0
  128. package/hooks/index.d.ts +5 -0
  129. package/hooks/index.js +8 -0
  130. package/hooks/on-app-bootstrap.hook.d.ts +8 -0
  131. package/hooks/on-app-bootstrap.hook.js +53 -0
  132. package/hooks/on-app-shutdown.hook.d.ts +9 -0
  133. package/hooks/on-app-shutdown.hook.js +54 -0
  134. package/hooks/on-module-destroy.hook.d.ts +8 -0
  135. package/hooks/on-module-destroy.hook.js +53 -0
  136. package/hooks/on-module-init.hook.d.ts +8 -0
  137. package/hooks/on-module-init.hook.js +53 -0
  138. package/hooks/utils/get-instances-grouped-by-hierarchy-level.d.ts +3 -0
  139. package/hooks/utils/get-instances-grouped-by-hierarchy-level.js +27 -0
  140. package/hooks/utils/get-sorted-hierarchy-levels.d.ts +1 -0
  141. package/hooks/utils/get-sorted-hierarchy-levels.js +7 -0
  142. package/index.d.ts +17 -0
  143. package/index.js +32 -0
  144. package/injector/abstract-instance-resolver.d.ts +16 -0
  145. package/injector/abstract-instance-resolver.js +49 -0
  146. package/injector/compiler.d.ts +18 -0
  147. package/injector/compiler.js +35 -0
  148. package/injector/constants.d.ts +3 -0
  149. package/injector/constants.js +8 -0
  150. package/injector/container.d.ts +67 -0
  151. package/injector/container.js +233 -0
  152. package/injector/helpers/provider-classifier.d.ts +4 -0
  153. package/injector/helpers/provider-classifier.js +16 -0
  154. package/injector/helpers/silent-logger.d.ts +10 -0
  155. package/injector/helpers/silent-logger.js +18 -0
  156. package/injector/helpers/transient-instances.d.ts +12 -0
  157. package/injector/helpers/transient-instances.js +28 -0
  158. package/injector/index.d.ts +6 -0
  159. package/injector/index.js +8 -0
  160. package/injector/injector.d.ts +104 -0
  161. package/injector/injector.js +554 -0
  162. package/injector/inquirer/index.d.ts +1 -0
  163. package/injector/inquirer/index.js +4 -0
  164. package/injector/inquirer/inquirer-constants.d.ts +1 -0
  165. package/injector/inquirer/inquirer-constants.js +4 -0
  166. package/injector/inquirer/inquirer-providers.d.ts +2 -0
  167. package/injector/inquirer/inquirer-providers.js +11 -0
  168. package/injector/instance-links-host.d.ts +22 -0
  169. package/injector/instance-links-host.js +56 -0
  170. package/injector/instance-loader.d.ts +23 -0
  171. package/injector/instance-loader.js +88 -0
  172. package/injector/instance-wrapper.d.ts +99 -0
  173. package/injector/instance-wrapper.js +350 -0
  174. package/injector/internal-core-module/index.d.ts +1 -0
  175. package/injector/internal-core-module/index.js +4 -0
  176. package/injector/internal-core-module/internal-core-module-factory.d.ts +9 -0
  177. package/injector/internal-core-module/internal-core-module-factory.js +52 -0
  178. package/injector/internal-core-module/internal-core-module.d.ts +5 -0
  179. package/injector/internal-core-module/internal-core-module.js +40 -0
  180. package/injector/internal-providers-storage.d.ts +9 -0
  181. package/injector/internal-providers-storage.js +19 -0
  182. package/injector/lazy-module-loader/lazy-module-loader-options.interface.d.ts +6 -0
  183. package/injector/lazy-module-loader/lazy-module-loader-options.interface.js +2 -0
  184. package/injector/lazy-module-loader/lazy-module-loader.d.ts +20 -0
  185. package/injector/lazy-module-loader/lazy-module-loader.js +49 -0
  186. package/injector/module-ref.d.ts +106 -0
  187. package/injector/module-ref.js +66 -0
  188. package/injector/module.d.ts +82 -0
  189. package/injector/module.js +432 -0
  190. package/injector/modules-container.d.ts +27 -0
  191. package/injector/modules-container.js +42 -0
  192. package/injector/opaque-key-factory/by-reference-module-opaque-key-factory.d.ts +15 -0
  193. package/injector/opaque-key-factory/by-reference-module-opaque-key-factory.js +41 -0
  194. package/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.d.ts +15 -0
  195. package/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.js +83 -0
  196. package/injector/opaque-key-factory/interfaces/module-opaque-key-factory.interface.d.ts +18 -0
  197. package/injector/opaque-key-factory/interfaces/module-opaque-key-factory.interface.js +2 -0
  198. package/injector/settlement-signal.d.ts +37 -0
  199. package/injector/settlement-signal.js +55 -0
  200. package/injector/topology-tree/topology-tree.d.ts +8 -0
  201. package/injector/topology-tree/topology-tree.js +51 -0
  202. package/injector/topology-tree/tree-node.d.ts +14 -0
  203. package/injector/topology-tree/tree-node.js +54 -0
  204. package/inspector/deterministic-uuid-registry.d.ts +6 -0
  205. package/inspector/deterministic-uuid-registry.js +24 -0
  206. package/inspector/graph-inspector.d.ts +26 -0
  207. package/inspector/graph-inspector.js +166 -0
  208. package/inspector/index.d.ts +4 -0
  209. package/inspector/index.js +7 -0
  210. package/inspector/initialize-on-preview.allowlist.d.ts +6 -0
  211. package/inspector/initialize-on-preview.allowlist.js +13 -0
  212. package/inspector/interfaces/edge.interface.d.ts +28 -0
  213. package/inspector/interfaces/edge.interface.js +2 -0
  214. package/inspector/interfaces/enhancer-metadata-cache-entry.interface.d.ts +12 -0
  215. package/inspector/interfaces/enhancer-metadata-cache-entry.interface.js +2 -0
  216. package/inspector/interfaces/entrypoint.interface.d.ts +23 -0
  217. package/inspector/interfaces/entrypoint.interface.js +2 -0
  218. package/inspector/interfaces/extras.interface.d.ts +18 -0
  219. package/inspector/interfaces/extras.interface.js +2 -0
  220. package/inspector/interfaces/node.interface.d.ts +48 -0
  221. package/inspector/interfaces/node.interface.js +2 -0
  222. package/inspector/interfaces/serialized-graph-json.interface.d.ts +14 -0
  223. package/inspector/interfaces/serialized-graph-json.interface.js +2 -0
  224. package/inspector/interfaces/serialized-graph-metadata.interface.d.ts +10 -0
  225. package/inspector/interfaces/serialized-graph-metadata.interface.js +2 -0
  226. package/inspector/noop-graph-inspector.d.ts +2 -0
  227. package/inspector/noop-graph-inspector.js +8 -0
  228. package/inspector/partial-graph.host.d.ts +7 -0
  229. package/inspector/partial-graph.host.js +15 -0
  230. package/inspector/serialized-graph.d.ts +52 -0
  231. package/inspector/serialized-graph.js +124 -0
  232. package/inspector/uuid-factory.d.ts +9 -0
  233. package/inspector/uuid-factory.js +22 -0
  234. package/interceptors/index.d.ts +2 -0
  235. package/interceptors/index.js +5 -0
  236. package/interceptors/interceptors-consumer.d.ts +9 -0
  237. package/interceptors/interceptors-consumer.js +37 -0
  238. package/interceptors/interceptors-context-creator.d.ts +16 -0
  239. package/interceptors/interceptors-context-creator.js +69 -0
  240. package/interfaces/index.d.ts +2 -0
  241. package/interfaces/index.js +2 -0
  242. package/interfaces/module-definition.interface.d.ts +3 -0
  243. package/interfaces/module-definition.interface.js +2 -0
  244. package/interfaces/module-override.interface.d.ts +5 -0
  245. package/interfaces/module-override.interface.js +2 -0
  246. package/internal.d.ts +38 -0
  247. package/internal.js +46 -0
  248. package/metadata-scanner.d.ts +17 -0
  249. package/metadata-scanner.js +83 -0
  250. package/middleware/builder.d.ts +15 -0
  251. package/middleware/builder.js +91 -0
  252. package/middleware/container.d.ts +14 -0
  253. package/middleware/container.js +49 -0
  254. package/middleware/index.d.ts +1 -0
  255. package/middleware/index.js +4 -0
  256. package/middleware/middleware-module.d.ts +33 -0
  257. package/middleware/middleware-module.js +208 -0
  258. package/middleware/resolver.d.ts +10 -0
  259. package/middleware/resolver.js +18 -0
  260. package/middleware/route-info-path-extractor.d.ts +15 -0
  261. package/middleware/route-info-path-extractor.js +81 -0
  262. package/middleware/routes-mapper.d.ts +19 -0
  263. package/middleware/routes-mapper.js +117 -0
  264. package/middleware/utils.d.ts +8 -0
  265. package/middleware/utils.js +106 -0
  266. package/nest-application-context.d.ts +173 -0
  267. package/nest-application-context.js +327 -0
  268. package/nest-application.d.ts +64 -0
  269. package/nest-application.js +328 -0
  270. package/nest-factory.d.ts +83 -0
  271. package/nest-factory.js +232 -0
  272. package/package.json +73 -0
  273. package/pipes/index.d.ts +3 -0
  274. package/pipes/index.js +6 -0
  275. package/pipes/params-token-factory.d.ts +5 -0
  276. package/pipes/params-token-factory.js +19 -0
  277. package/pipes/pipes-consumer.d.ts +10 -0
  278. package/pipes/pipes-consumer.js +21 -0
  279. package/pipes/pipes-context-creator.d.ts +17 -0
  280. package/pipes/pipes-context-creator.js +72 -0
  281. package/repl/assign-to-object.util.d.ts +5 -0
  282. package/repl/assign-to-object.util.js +14 -0
  283. package/repl/constants.d.ts +1 -0
  284. package/repl/constants.js +4 -0
  285. package/repl/index.d.ts +1 -0
  286. package/repl/index.js +4 -0
  287. package/repl/native-functions/debug-repl-fn.d.ts +9 -0
  288. package/repl/native-functions/debug-repl-fn.js +46 -0
  289. package/repl/native-functions/get-repl-fn.d.ts +7 -0
  290. package/repl/native-functions/get-repl-fn.js +19 -0
  291. package/repl/native-functions/help-repl-fn.d.ts +7 -0
  292. package/repl/native-functions/help-repl-fn.js +29 -0
  293. package/repl/native-functions/index.d.ts +6 -0
  294. package/repl/native-functions/index.js +9 -0
  295. package/repl/native-functions/methods-repl-fn.d.ts +8 -0
  296. package/repl/native-functions/methods-repl-fn.js +28 -0
  297. package/repl/native-functions/resolve-repl-fn.d.ts +7 -0
  298. package/repl/native-functions/resolve-repl-fn.js +18 -0
  299. package/repl/native-functions/select-relp-fn.d.ts +7 -0
  300. package/repl/native-functions/select-relp-fn.js +18 -0
  301. package/repl/repl-context.d.ts +26 -0
  302. package/repl/repl-context.js +126 -0
  303. package/repl/repl-function.d.ts +18 -0
  304. package/repl/repl-function.js +19 -0
  305. package/repl/repl-logger.d.ts +5 -0
  306. package/repl/repl-logger.js +22 -0
  307. package/repl/repl-native-commands.d.ts +2 -0
  308. package/repl/repl-native-commands.js +46 -0
  309. package/repl/repl.d.ts +3 -0
  310. package/repl/repl.interfaces.d.ts +16 -0
  311. package/repl/repl.interfaces.js +2 -0
  312. package/repl/repl.js +32 -0
  313. package/router/index.d.ts +3 -0
  314. package/router/index.js +8 -0
  315. package/router/interfaces/exceptions-filter.interface.d.ts +6 -0
  316. package/router/interfaces/exceptions-filter.interface.js +2 -0
  317. package/router/interfaces/exclude-route-metadata.interface.d.ts +15 -0
  318. package/router/interfaces/exclude-route-metadata.interface.js +2 -0
  319. package/router/interfaces/index.d.ts +1 -0
  320. package/router/interfaces/index.js +4 -0
  321. package/router/interfaces/resolver.interface.d.ts +5 -0
  322. package/router/interfaces/resolver.interface.js +2 -0
  323. package/router/interfaces/route-params-factory.interface.d.ts +8 -0
  324. package/router/interfaces/route-params-factory.interface.js +2 -0
  325. package/router/interfaces/route-path-metadata.interface.d.ts +32 -0
  326. package/router/interfaces/route-path-metadata.interface.js +2 -0
  327. package/router/interfaces/routes.interface.d.ts +7 -0
  328. package/router/interfaces/routes.interface.js +2 -0
  329. package/router/legacy-route-converter.d.ts +16 -0
  330. package/router/legacy-route-converter.js +61 -0
  331. package/router/paths-explorer.d.ts +18 -0
  332. package/router/paths-explorer.js +45 -0
  333. package/router/request/index.d.ts +1 -0
  334. package/router/request/index.js +5 -0
  335. package/router/request/request-constants.d.ts +2 -0
  336. package/router/request/request-constants.js +5 -0
  337. package/router/request/request-providers.d.ts +2 -0
  338. package/router/request/request-providers.js +11 -0
  339. package/router/route-params-factory.d.ts +9 -0
  340. package/router/route-params-factory.js +41 -0
  341. package/router/route-path-factory.d.ts +14 -0
  342. package/router/route-path-factory.js +101 -0
  343. package/router/router-exception-filters.d.ts +14 -0
  344. package/router/router-exception-filters.js +40 -0
  345. package/router/router-execution-context.d.ts +54 -0
  346. package/router/router-execution-context.js +186 -0
  347. package/router/router-explorer.d.ts +47 -0
  348. package/router/router-explorer.js +234 -0
  349. package/router/router-module.d.ts +19 -0
  350. package/router/router-module.js +80 -0
  351. package/router/router-proxy.d.ts +6 -0
  352. package/router/router-proxy.js +31 -0
  353. package/router/router-response-controller.d.ts +28 -0
  354. package/router/router-response-controller.js +98 -0
  355. package/router/routes-resolver.d.ts +27 -0
  356. package/router/routes-resolver.js +129 -0
  357. package/router/sse-stream.d.ts +43 -0
  358. package/router/sse-stream.js +83 -0
  359. package/router/utils/exclude-route.util.d.ts +4 -0
  360. package/router/utils/exclude-route.util.js +19 -0
  361. package/router/utils/flatten-route-paths.util.d.ts +6 -0
  362. package/router/utils/flatten-route-paths.util.js +25 -0
  363. package/router/utils/index.d.ts +2 -0
  364. package/router/utils/index.js +5 -0
  365. package/scanner.d.ts +89 -0
  366. package/scanner.js +416 -0
  367. package/services/index.d.ts +1 -0
  368. package/services/index.js +4 -0
  369. package/services/reflector.service.d.ts +111 -0
  370. package/services/reflector.service.js +100 -0
  371. package/tsconfig.build.json +21 -0
@@ -0,0 +1,4 @@
1
+ import { RuntimeException } from './runtime.exception';
2
+ export declare class UnknownExportException extends RuntimeException {
3
+ constructor(token: string | symbol, moduleName: string);
4
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnknownExportException = void 0;
4
+ const messages_1 = require("../messages");
5
+ const runtime_exception_1 = require("./runtime.exception");
6
+ class UnknownExportException extends runtime_exception_1.RuntimeException {
7
+ constructor(token, moduleName) {
8
+ super((0, messages_1.UNKNOWN_EXPORT_MESSAGE)(token, moduleName));
9
+ }
10
+ }
11
+ exports.UnknownExportException = UnknownExportException;
@@ -0,0 +1,4 @@
1
+ import { RuntimeException } from './runtime.exception';
2
+ export declare class UnknownModuleException extends RuntimeException {
3
+ constructor(moduleName?: string);
4
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnknownModuleException = void 0;
4
+ const runtime_exception_1 = require("./runtime.exception");
5
+ class UnknownModuleException extends runtime_exception_1.RuntimeException {
6
+ constructor(moduleName) {
7
+ super(`Nest could not select the given module (${moduleName ? `"${moduleName}"` : 'it'} does not exist in current context).`);
8
+ }
9
+ }
10
+ exports.UnknownModuleException = UnknownModuleException;
@@ -0,0 +1,5 @@
1
+ import type { Type } from '@nestjs/common';
2
+ import { RuntimeException } from './runtime.exception';
3
+ export declare class UnknownRequestMappingException extends RuntimeException {
4
+ constructor(metatype: Type);
5
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnknownRequestMappingException = void 0;
4
+ const runtime_exception_1 = require("./runtime.exception");
5
+ const messages_1 = require("../messages");
6
+ class UnknownRequestMappingException extends runtime_exception_1.RuntimeException {
7
+ constructor(metatype) {
8
+ super((0, messages_1.UNKNOWN_REQUEST_MAPPING)(metatype));
9
+ }
10
+ }
11
+ exports.UnknownRequestMappingException = UnknownRequestMappingException;
@@ -0,0 +1,5 @@
1
+ export declare class ExceptionsZone {
2
+ private static readonly exceptionHandler;
3
+ static run(callback: () => void, teardown: ((err: any) => void) | undefined, autoFlushLogs: boolean): void;
4
+ static asyncRun(callback: () => Promise<void>, teardown: ((err: any) => void) | undefined, autoFlushLogs: boolean): Promise<void>;
5
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExceptionsZone = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const exception_handler_1 = require("./exception-handler");
6
+ const DEFAULT_TEARDOWN = () => process.exit(1);
7
+ class ExceptionsZone {
8
+ static run(callback, teardown = DEFAULT_TEARDOWN, autoFlushLogs) {
9
+ try {
10
+ callback();
11
+ }
12
+ catch (e) {
13
+ this.exceptionHandler.handle(e);
14
+ if (autoFlushLogs) {
15
+ common_1.Logger.flush();
16
+ }
17
+ teardown(e);
18
+ }
19
+ }
20
+ static async asyncRun(callback, teardown = DEFAULT_TEARDOWN, autoFlushLogs) {
21
+ try {
22
+ await callback();
23
+ }
24
+ catch (e) {
25
+ this.exceptionHandler.handle(e);
26
+ if (autoFlushLogs) {
27
+ common_1.Logger.flush();
28
+ }
29
+ teardown(e);
30
+ }
31
+ }
32
+ }
33
+ exports.ExceptionsZone = ExceptionsZone;
34
+ ExceptionsZone.exceptionHandler = new exception_handler_1.ExceptionHandler();
@@ -0,0 +1,17 @@
1
+ import type { ForwardReference, Type } from '@nestjs/common';
2
+ import { InjectorDependencyContext } from '../injector/injector';
3
+ import { Module } from '../injector/module';
4
+ export declare const UNKNOWN_DEPENDENCIES_MESSAGE: (type: string | symbol, unknownDependencyContext: InjectorDependencyContext, moduleRef: Module | undefined) => string;
5
+ export declare const INVALID_MIDDLEWARE_MESSAGE: (text: TemplateStringsArray, name: string) => string;
6
+ export declare const UNDEFINED_FORWARDREF_MESSAGE: (scope: Type<any>[]) => string;
7
+ export declare const INVALID_MODULE_MESSAGE: (parentModule: any, index: number, scope: any[]) => string;
8
+ export declare const USING_INVALID_CLASS_AS_A_MODULE_MESSAGE: (metatypeUsedAsAModule: Type | ForwardReference, scope: any[]) => string;
9
+ export declare const UNDEFINED_MODULE_MESSAGE: (parentModule: any, index: number, scope: any[]) => string;
10
+ export declare const UNKNOWN_EXPORT_MESSAGE: (token: string | symbol | undefined, module: string) => string;
11
+ export declare const INVALID_CLASS_MESSAGE: (text: TemplateStringsArray, value: any) => string;
12
+ export declare const INVALID_CLASS_SCOPE_MESSAGE: (text: TemplateStringsArray, name: string | undefined) => string;
13
+ export declare const UNKNOWN_REQUEST_MAPPING: (metatype: Type) => string;
14
+ export declare const INVALID_MIDDLEWARE_CONFIGURATION = "An invalid middleware configuration has been passed inside the module 'configure()' method.";
15
+ export declare const UNHANDLED_RUNTIME_EXCEPTION = "Unhandled Runtime Exception.";
16
+ export declare const INVALID_EXCEPTION_FILTER = "Invalid exception filters (@UseFilters()).";
17
+ export declare const MICROSERVICES_PACKAGE_NOT_FOUND_EXCEPTION = "Unable to load @nestjs/microservices package. (Please make sure that it's already installed.)";
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MICROSERVICES_PACKAGE_NOT_FOUND_EXCEPTION = exports.INVALID_EXCEPTION_FILTER = exports.UNHANDLED_RUNTIME_EXCEPTION = exports.INVALID_MIDDLEWARE_CONFIGURATION = exports.UNKNOWN_REQUEST_MAPPING = exports.INVALID_CLASS_SCOPE_MESSAGE = exports.INVALID_CLASS_MESSAGE = exports.UNKNOWN_EXPORT_MESSAGE = exports.UNDEFINED_MODULE_MESSAGE = exports.USING_INVALID_CLASS_AS_A_MODULE_MESSAGE = exports.INVALID_MODULE_MESSAGE = exports.UNDEFINED_FORWARDREF_MESSAGE = exports.INVALID_MIDDLEWARE_MESSAGE = exports.UNKNOWN_DEPENDENCIES_MESSAGE = void 0;
4
+ const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
5
+ /**
6
+ * Returns the name of an instance or `undefined`
7
+ * @param instance The instance which should get the name from
8
+ */
9
+ const getInstanceName = (instance) => {
10
+ if (instance?.forwardRef) {
11
+ return instance.forwardRef()?.name;
12
+ }
13
+ if (instance?.module) {
14
+ return instance.module?.name;
15
+ }
16
+ return instance?.name;
17
+ };
18
+ /**
19
+ * Returns the name of the dependency.
20
+ * Tries to get the class name, otherwise the string value
21
+ * (= injection token). As fallback to any falsy value for `dependency`, it
22
+ * returns `fallbackValue`
23
+ * @param dependency The name of the dependency to be displayed
24
+ * @param fallbackValue The fallback value if the dependency is falsy
25
+ * @param disambiguated Whether dependency's name is disambiguated with double quotes
26
+ */
27
+ const getDependencyName = (dependency, fallbackValue, disambiguated = true) =>
28
+ // use class name
29
+ getInstanceName(dependency) ||
30
+ // use injection token (symbol)
31
+ ((0, shared_utils_1.isSymbol)(dependency) && dependency.toString()) ||
32
+ // use string directly
33
+ (dependency
34
+ ? disambiguated
35
+ ? `"${dependency}"`
36
+ : dependency
37
+ : undefined) ||
38
+ // otherwise
39
+ fallbackValue;
40
+ /**
41
+ * Returns the name of the module
42
+ * Tries to get the class name. As fallback it returns 'current'.
43
+ * @param module The module which should get displayed
44
+ */
45
+ const getModuleName = (module) => (module && getInstanceName(module.metatype)) || 'current';
46
+ const stringifyScope = (scope) => (scope || []).map(getInstanceName).join(' -> ');
47
+ const UNKNOWN_DEPENDENCIES_MESSAGE = (type, unknownDependencyContext, moduleRef) => {
48
+ const { index, name, dependencies, key } = unknownDependencyContext;
49
+ const moduleName = getModuleName(moduleRef);
50
+ const dependencyName = getDependencyName(name, 'dependency');
51
+ const isImportTypeIssue = !(0, shared_utils_1.isNil)(index) &&
52
+ dependencies &&
53
+ (dependencies[index] === undefined ||
54
+ dependencies[index] === Object ||
55
+ (typeof dependencies[index] === 'function' &&
56
+ dependencies[index].name === 'Object'));
57
+ let potentialSolutions;
58
+ if (isImportTypeIssue) {
59
+ potentialSolutions = `\n
60
+ Potential solutions:
61
+ - The dependency at index [${index}] appears to be undefined at runtime
62
+ - This commonly occurs when using 'import type' instead of 'import' for injectable classes
63
+ - Check your imports and change:
64
+ ❌ import type { SomeService } from './some.service';
65
+ ✅ import { SomeService } from './some.service';
66
+ - Ensure the imported class is decorated with @Injectable() or is a valid provider
67
+ - If using dynamic imports, ensure the class is available at runtime, not just for type checking
68
+
69
+ For more common dependency resolution issues, see: https://docs.nestjs.com/faq/common-errors`;
70
+ }
71
+ else {
72
+ potentialSolutions =
73
+ // If module's name is well defined
74
+ moduleName !== 'current'
75
+ ? `\n
76
+ Potential solutions:
77
+ - Is ${moduleName} a valid NestJS module?
78
+ - If ${dependencyName} is a provider, is it part of the current ${moduleName}?
79
+ - If ${dependencyName} is exported from a separate @Module, is that module imported within ${moduleName}?
80
+ @Module({
81
+ imports: [ /* the Module containing ${dependencyName} */ ]
82
+ })
83
+
84
+ For more common dependency resolution issues, see: https://docs.nestjs.com/faq/common-errors`
85
+ : `\n
86
+ Potential solutions:
87
+ - If ${dependencyName} is a provider, is it part of the current Module?
88
+ - If ${dependencyName} is exported from a separate @Module, is that module imported within Module?
89
+ @Module({
90
+ imports: [ /* the Module containing ${dependencyName} */ ]
91
+ })
92
+
93
+ For more common dependency resolution issues, see: https://docs.nestjs.com/faq/common-errors`;
94
+ }
95
+ let message = `Nest can't resolve dependencies of the ${type.toString()}`;
96
+ if ((0, shared_utils_1.isNil)(index)) {
97
+ message += `. Please make sure that the "${key.toString()}" property is available in the current context.${potentialSolutions}`;
98
+ return message;
99
+ }
100
+ const dependenciesName = (dependencies || []).map(dependencyName => getDependencyName(dependencyName, '+', false));
101
+ dependenciesName[index] = '?';
102
+ const tokenFragment = !isImportTypeIssue && name !== undefined ? ` ${dependencyName}` : '';
103
+ const contextLabel = isImportTypeIssue ? 'current' : moduleName;
104
+ message += ` (`;
105
+ message += dependenciesName.join(', ');
106
+ message += `). Please make sure that the argument${tokenFragment} at index [${index}]`;
107
+ message += ` is available in the ${contextLabel} module.`;
108
+ message += potentialSolutions;
109
+ return message;
110
+ };
111
+ exports.UNKNOWN_DEPENDENCIES_MESSAGE = UNKNOWN_DEPENDENCIES_MESSAGE;
112
+ const INVALID_MIDDLEWARE_MESSAGE = (text, name) => `The middleware doesn't provide the 'use' method (${name})`;
113
+ exports.INVALID_MIDDLEWARE_MESSAGE = INVALID_MIDDLEWARE_MESSAGE;
114
+ const UNDEFINED_FORWARDREF_MESSAGE = (scope) => `Nest cannot create the module instance. Often, this is because of a circular dependency between modules. Use forwardRef() to avoid it.
115
+
116
+ (Read more: https://docs.nestjs.com/fundamentals/circular-dependency)
117
+ Scope [${stringifyScope(scope)}]
118
+ `;
119
+ exports.UNDEFINED_FORWARDREF_MESSAGE = UNDEFINED_FORWARDREF_MESSAGE;
120
+ const INVALID_MODULE_MESSAGE = (parentModule, index, scope) => {
121
+ const parentModuleName = parentModule?.name || 'module';
122
+ return `Nest cannot create the ${parentModuleName} instance.
123
+ Received an unexpected value at index [${index}] of the ${parentModuleName} "imports" array.
124
+
125
+ Scope [${stringifyScope(scope)}]`;
126
+ };
127
+ exports.INVALID_MODULE_MESSAGE = INVALID_MODULE_MESSAGE;
128
+ const USING_INVALID_CLASS_AS_A_MODULE_MESSAGE = (metatypeUsedAsAModule, scope) => {
129
+ const metatypeNameQuote = `"${getInstanceName(metatypeUsedAsAModule)}"`;
130
+ return `Classes annotated with @Injectable(), @Catch(), and @Controller() decorators must not appear in the "imports" array of a module.
131
+ Please remove ${metatypeNameQuote} (including forwarded occurrences, if any) from all of the "imports" arrays.
132
+
133
+ Scope [${stringifyScope(scope)}]
134
+ `;
135
+ };
136
+ exports.USING_INVALID_CLASS_AS_A_MODULE_MESSAGE = USING_INVALID_CLASS_AS_A_MODULE_MESSAGE;
137
+ const UNDEFINED_MODULE_MESSAGE = (parentModule, index, scope) => {
138
+ const parentModuleName = parentModule?.name || 'module';
139
+ return `Nest cannot create the ${parentModuleName} instance.
140
+ The module at index [${index}] of the ${parentModuleName} "imports" array is undefined.
141
+
142
+ Potential causes:
143
+ - A circular dependency between modules. Use forwardRef() to avoid it. Read more: https://docs.nestjs.com/fundamentals/circular-dependency
144
+ - The module at index [${index}] is of type "undefined". Check your import statements and the type of the module.
145
+
146
+ Scope [${stringifyScope(scope)}]`;
147
+ };
148
+ exports.UNDEFINED_MODULE_MESSAGE = UNDEFINED_MODULE_MESSAGE;
149
+ const UNKNOWN_EXPORT_MESSAGE = (token = 'item', module) => {
150
+ token = (0, shared_utils_1.isSymbol)(token) ? token.toString() : token;
151
+ return `Nest cannot export a provider/module that is not a part of the currently processed module (${module}). Please verify whether the exported ${token} is available in this particular context.
152
+
153
+ Possible Solutions:
154
+ - Is ${token} part of the relevant providers/imports within ${module}?
155
+
156
+ For more common dependency resolution issues, see: https://docs.nestjs.com/faq/common-errors
157
+ `;
158
+ };
159
+ exports.UNKNOWN_EXPORT_MESSAGE = UNKNOWN_EXPORT_MESSAGE;
160
+ const INVALID_CLASS_MESSAGE = (text, value) => `ModuleRef cannot instantiate class (${value} is not constructable).`;
161
+ exports.INVALID_CLASS_MESSAGE = INVALID_CLASS_MESSAGE;
162
+ const INVALID_CLASS_SCOPE_MESSAGE = (text, name) => `${name || 'This class'} is marked as a scoped provider. Request and transient-scoped providers can't be used in combination with "get()" method. Please, use "resolve()" instead.`;
163
+ exports.INVALID_CLASS_SCOPE_MESSAGE = INVALID_CLASS_SCOPE_MESSAGE;
164
+ const UNKNOWN_REQUEST_MAPPING = (metatype) => {
165
+ const className = metatype.name;
166
+ return className
167
+ ? `An invalid controller has been detected. "${className}" does not have the @Controller() decorator but it is being listed in the "controllers" array of some module.`
168
+ : `An invalid controller has been detected. Perhaps, one of your controllers is missing the @Controller() decorator.`;
169
+ };
170
+ exports.UNKNOWN_REQUEST_MAPPING = UNKNOWN_REQUEST_MAPPING;
171
+ exports.INVALID_MIDDLEWARE_CONFIGURATION = `An invalid middleware configuration has been passed inside the module 'configure()' method.`;
172
+ exports.UNHANDLED_RUNTIME_EXCEPTION = `Unhandled Runtime Exception.`;
173
+ exports.INVALID_EXCEPTION_FILTER = `Invalid exception filters (@UseFilters()).`;
174
+ exports.MICROSERVICES_PACKAGE_NOT_FOUND_EXCEPTION = `Unable to load @nestjs/microservices package. (Please make sure that it's already installed.)`;
@@ -0,0 +1,14 @@
1
+ import { Type } from '@nestjs/common/interfaces';
2
+ import { ExceptionFilter } from '@nestjs/common/interfaces/exceptions/exception-filter.interface';
3
+ import { ContextCreator } from '../helpers/context-creator';
4
+ import { NestContainer } from '../injector/container';
5
+ import { InstanceWrapper } from '../injector/instance-wrapper';
6
+ export declare class BaseExceptionFilterContext extends ContextCreator {
7
+ private readonly container;
8
+ protected moduleContext: string;
9
+ constructor(container: NestContainer);
10
+ createConcreteContext<T extends any[], R extends any[]>(metadata: T, contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): R;
11
+ getFilterInstance(filter: Function | ExceptionFilter, contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): ExceptionFilter | null;
12
+ getInstanceByMetatype(metatype: Type<unknown>): InstanceWrapper | undefined;
13
+ reflectCatchExceptions(instance: ExceptionFilter): Type<any>[];
14
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseExceptionFilterContext = void 0;
4
+ const constants_1 = require("@nestjs/common/constants");
5
+ const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
6
+ const iterare_1 = require("iterare");
7
+ const context_creator_1 = require("../helpers/context-creator");
8
+ const constants_2 = require("../injector/constants");
9
+ class BaseExceptionFilterContext extends context_creator_1.ContextCreator {
10
+ constructor(container) {
11
+ super();
12
+ this.container = container;
13
+ }
14
+ createConcreteContext(metadata, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
15
+ if ((0, shared_utils_1.isEmpty)(metadata)) {
16
+ return [];
17
+ }
18
+ return (0, iterare_1.iterate)(metadata)
19
+ .filter(instance => instance && ((0, shared_utils_1.isFunction)(instance.catch) || instance.name))
20
+ .map(filter => this.getFilterInstance(filter, contextId, inquirerId))
21
+ .filter(item => !!item)
22
+ .map(instance => ({
23
+ func: instance.catch.bind(instance),
24
+ exceptionMetatypes: this.reflectCatchExceptions(instance),
25
+ }))
26
+ .toArray();
27
+ }
28
+ getFilterInstance(filter, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
29
+ const isObject = !!filter.catch;
30
+ if (isObject) {
31
+ return filter;
32
+ }
33
+ const instanceWrapper = this.getInstanceByMetatype(filter);
34
+ if (!instanceWrapper) {
35
+ return null;
36
+ }
37
+ const instanceHost = instanceWrapper.getInstanceByContextId(this.getContextId(contextId, instanceWrapper), inquirerId);
38
+ return instanceHost && instanceHost.instance;
39
+ }
40
+ getInstanceByMetatype(metatype) {
41
+ if (!this.moduleContext) {
42
+ return;
43
+ }
44
+ const collection = this.container.getModules();
45
+ const moduleRef = collection.get(this.moduleContext);
46
+ if (!moduleRef) {
47
+ return;
48
+ }
49
+ return moduleRef.injectables.get(metatype);
50
+ }
51
+ reflectCatchExceptions(instance) {
52
+ const prototype = Object.getPrototypeOf(instance);
53
+ return (Reflect.getMetadata(constants_1.FILTER_CATCH_EXCEPTIONS, prototype.constructor) || []);
54
+ }
55
+ }
56
+ exports.BaseExceptionFilterContext = BaseExceptionFilterContext;
@@ -0,0 +1,20 @@
1
+ import { ArgumentsHost, ExceptionFilter, HttpServer } from '@nestjs/common';
2
+ import { AbstractHttpAdapter } from '../adapters';
3
+ import { HttpAdapterHost } from '../helpers/http-adapter-host';
4
+ export declare class BaseExceptionFilter<T = any> implements ExceptionFilter<T> {
5
+ protected readonly applicationRef?: HttpServer | undefined;
6
+ private static readonly logger;
7
+ protected readonly httpAdapterHost?: HttpAdapterHost;
8
+ constructor(applicationRef?: HttpServer | undefined);
9
+ catch(exception: T, host: ArgumentsHost): void;
10
+ handleUnknownError(exception: T, host: ArgumentsHost, applicationRef: AbstractHttpAdapter | HttpServer): void;
11
+ isExceptionObject(err: any): err is Error;
12
+ /**
13
+ * Checks if the thrown error comes from the "http-errors" library.
14
+ * @param err error object
15
+ */
16
+ isHttpError(err: any): err is {
17
+ statusCode: number;
18
+ message: string;
19
+ };
20
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseExceptionFilter = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
7
+ const constants_1 = require("../constants");
8
+ const http_adapter_host_1 = require("../helpers/http-adapter-host");
9
+ class BaseExceptionFilter {
10
+ constructor(applicationRef) {
11
+ this.applicationRef = applicationRef;
12
+ }
13
+ catch(exception, host) {
14
+ const applicationRef = this.applicationRef ||
15
+ (this.httpAdapterHost && this.httpAdapterHost.httpAdapter);
16
+ if (!(exception instanceof common_1.HttpException)) {
17
+ return this.handleUnknownError(exception, host, applicationRef);
18
+ }
19
+ const res = exception.getResponse();
20
+ const message = (0, shared_utils_1.isObject)(res)
21
+ ? res
22
+ : {
23
+ statusCode: exception.getStatus(),
24
+ message: res,
25
+ };
26
+ const response = host.getArgByIndex(1);
27
+ if (!applicationRef.isHeadersSent(response)) {
28
+ applicationRef.reply(response, message, exception.getStatus());
29
+ }
30
+ else {
31
+ applicationRef.end(response);
32
+ }
33
+ }
34
+ handleUnknownError(exception, host, applicationRef) {
35
+ const body = this.isHttpError(exception)
36
+ ? {
37
+ statusCode: exception.statusCode,
38
+ message: exception.message,
39
+ }
40
+ : {
41
+ statusCode: common_1.HttpStatus.INTERNAL_SERVER_ERROR,
42
+ message: constants_1.MESSAGES.UNKNOWN_EXCEPTION_MESSAGE,
43
+ };
44
+ const response = host.getArgByIndex(1);
45
+ if (!applicationRef.isHeadersSent(response)) {
46
+ applicationRef.reply(response, body, body.statusCode);
47
+ }
48
+ else {
49
+ applicationRef.end(response);
50
+ }
51
+ if (!(exception instanceof common_1.IntrinsicException)) {
52
+ BaseExceptionFilter.logger.error(exception);
53
+ }
54
+ }
55
+ isExceptionObject(err) {
56
+ return (0, shared_utils_1.isObject)(err) && !!err.message;
57
+ }
58
+ /**
59
+ * Checks if the thrown error comes from the "http-errors" library.
60
+ * @param err error object
61
+ */
62
+ isHttpError(err) {
63
+ return err?.statusCode && err?.message;
64
+ }
65
+ }
66
+ exports.BaseExceptionFilter = BaseExceptionFilter;
67
+ BaseExceptionFilter.logger = new common_1.Logger('ExceptionsHandler');
68
+ tslib_1.__decorate([
69
+ (0, common_1.Optional)(),
70
+ (0, common_1.Inject)(),
71
+ tslib_1.__metadata("design:type", http_adapter_host_1.HttpAdapterHost)
72
+ ], BaseExceptionFilter.prototype, "httpAdapterHost", void 0);
@@ -0,0 +1,10 @@
1
+ import { HttpException } from '@nestjs/common';
2
+ import { ExceptionFilterMetadata } from '@nestjs/common/interfaces/exceptions/exception-filter-metadata.interface';
3
+ import { ArgumentsHost } from '@nestjs/common/interfaces/features/arguments-host.interface';
4
+ import { BaseExceptionFilter } from './base-exception-filter';
5
+ export declare class ExceptionsHandler extends BaseExceptionFilter {
6
+ private filters;
7
+ next(exception: Error | HttpException, ctx: ArgumentsHost): void;
8
+ setCustomFilters(filters: ExceptionFilterMetadata[]): void;
9
+ invokeCustomFilters<T = any>(exception: T, ctx: ArgumentsHost): boolean;
10
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExceptionsHandler = void 0;
4
+ const select_exception_filter_metadata_util_1 = require("@nestjs/common/utils/select-exception-filter-metadata.util");
5
+ const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
6
+ const invalid_exception_filter_exception_1 = require("../errors/exceptions/invalid-exception-filter.exception");
7
+ const base_exception_filter_1 = require("./base-exception-filter");
8
+ class ExceptionsHandler extends base_exception_filter_1.BaseExceptionFilter {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.filters = [];
12
+ }
13
+ next(exception, ctx) {
14
+ if (this.invokeCustomFilters(exception, ctx)) {
15
+ return;
16
+ }
17
+ super.catch(exception, ctx);
18
+ }
19
+ setCustomFilters(filters) {
20
+ if (!Array.isArray(filters)) {
21
+ throw new invalid_exception_filter_exception_1.InvalidExceptionFilterException();
22
+ }
23
+ this.filters = filters;
24
+ }
25
+ invokeCustomFilters(exception, ctx) {
26
+ if ((0, shared_utils_1.isEmpty)(this.filters)) {
27
+ return false;
28
+ }
29
+ const filter = (0, select_exception_filter_metadata_util_1.selectExceptionFilterMetadata)(this.filters, exception);
30
+ filter && filter.func(exception, ctx);
31
+ return !!filter;
32
+ }
33
+ }
34
+ exports.ExceptionsHandler = ExceptionsHandler;
@@ -0,0 +1,12 @@
1
+ import { Controller } from '@nestjs/common/interfaces';
2
+ import { ApplicationConfig } from '../application-config';
3
+ import { NestContainer } from '../injector/container';
4
+ import { RouterProxyCallback } from '../router/router-proxy';
5
+ import { BaseExceptionFilterContext } from './base-exception-filter-context';
6
+ import { ExternalExceptionsHandler } from './external-exceptions-handler';
7
+ export declare class ExternalExceptionFilterContext extends BaseExceptionFilterContext {
8
+ private readonly config?;
9
+ constructor(container: NestContainer, config?: ApplicationConfig | undefined);
10
+ create(instance: Controller, callback: RouterProxyCallback, module: string, contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): ExternalExceptionsHandler;
11
+ getGlobalMetadata<T extends any[]>(contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): T;
12
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExternalExceptionFilterContext = void 0;
4
+ const constants_1 = require("@nestjs/common/constants");
5
+ const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
6
+ const iterare_1 = require("iterare");
7
+ const constants_2 = require("../injector/constants");
8
+ const base_exception_filter_context_1 = require("./base-exception-filter-context");
9
+ const external_exceptions_handler_1 = require("./external-exceptions-handler");
10
+ class ExternalExceptionFilterContext extends base_exception_filter_context_1.BaseExceptionFilterContext {
11
+ constructor(container, config) {
12
+ super(container);
13
+ this.config = config;
14
+ }
15
+ create(instance, callback, module, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
16
+ this.moduleContext = module;
17
+ const exceptionHandler = new external_exceptions_handler_1.ExternalExceptionsHandler();
18
+ const filters = this.createContext(instance, callback, constants_1.EXCEPTION_FILTERS_METADATA, contextId, inquirerId);
19
+ if ((0, shared_utils_1.isEmpty)(filters)) {
20
+ return exceptionHandler;
21
+ }
22
+ exceptionHandler.setCustomFilters(filters.reverse());
23
+ return exceptionHandler;
24
+ }
25
+ getGlobalMetadata(contextId = constants_2.STATIC_CONTEXT, inquirerId) {
26
+ if (!this.config) {
27
+ return [];
28
+ }
29
+ const globalFilters = this.config.getGlobalFilters();
30
+ if (contextId === constants_2.STATIC_CONTEXT && !inquirerId) {
31
+ return globalFilters;
32
+ }
33
+ const scopedFilterWrappers = this.config.getGlobalRequestFilters();
34
+ const scopedFilters = (0, iterare_1.iterate)(scopedFilterWrappers)
35
+ .map(wrapper => wrapper.getInstanceByContextId(contextId, inquirerId))
36
+ .filter(host => !!host)
37
+ .map(host => host.instance)
38
+ .toArray();
39
+ return globalFilters.concat(scopedFilters);
40
+ }
41
+ }
42
+ exports.ExternalExceptionFilterContext = ExternalExceptionFilterContext;
@@ -0,0 +1,5 @@
1
+ import { ArgumentsHost } from '@nestjs/common';
2
+ export declare class ExternalExceptionFilter<T = any, R = any> {
3
+ private static readonly logger;
4
+ catch(exception: T, host: ArgumentsHost): R | Promise<R>;
5
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExternalExceptionFilter = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ class ExternalExceptionFilter {
6
+ catch(exception, host) {
7
+ if (exception instanceof Error &&
8
+ !(exception instanceof common_1.IntrinsicException)) {
9
+ ExternalExceptionFilter.logger.error(exception);
10
+ }
11
+ throw exception;
12
+ }
13
+ }
14
+ exports.ExternalExceptionFilter = ExternalExceptionFilter;
15
+ ExternalExceptionFilter.logger = new common_1.Logger('ExceptionsHandler');
@@ -0,0 +1,9 @@
1
+ import { ExceptionFilterMetadata } from '@nestjs/common/interfaces/exceptions';
2
+ import { ArgumentsHost } from '@nestjs/common/interfaces/features/arguments-host.interface';
3
+ import { ExternalExceptionFilter } from './external-exception-filter';
4
+ export declare class ExternalExceptionsHandler extends ExternalExceptionFilter {
5
+ private filters;
6
+ next(exception: Error, host: ArgumentsHost): Promise<any>;
7
+ setCustomFilters(filters: ExceptionFilterMetadata[]): void;
8
+ invokeCustomFilters<T = any>(exception: T, host: ArgumentsHost): Promise<any> | null;
9
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExternalExceptionsHandler = void 0;
4
+ const select_exception_filter_metadata_util_1 = require("@nestjs/common/utils/select-exception-filter-metadata.util");
5
+ const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
6
+ const invalid_exception_filter_exception_1 = require("../errors/exceptions/invalid-exception-filter.exception");
7
+ const external_exception_filter_1 = require("./external-exception-filter");
8
+ class ExternalExceptionsHandler extends external_exception_filter_1.ExternalExceptionFilter {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.filters = [];
12
+ }
13
+ next(exception, host) {
14
+ const result = this.invokeCustomFilters(exception, host);
15
+ if (result) {
16
+ return result;
17
+ }
18
+ return super.catch(exception, host);
19
+ }
20
+ setCustomFilters(filters) {
21
+ if (!Array.isArray(filters)) {
22
+ throw new invalid_exception_filter_exception_1.InvalidExceptionFilterException();
23
+ }
24
+ this.filters = filters;
25
+ }
26
+ invokeCustomFilters(exception, host) {
27
+ if ((0, shared_utils_1.isEmpty)(this.filters)) {
28
+ return null;
29
+ }
30
+ const filter = (0, select_exception_filter_metadata_util_1.selectExceptionFilterMetadata)(this.filters, exception);
31
+ return filter ? filter.func(exception, host) : null;
32
+ }
33
+ }
34
+ exports.ExternalExceptionsHandler = ExternalExceptionsHandler;
@@ -0,0 +1 @@
1
+ export * from './base-exception-filter';
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./base-exception-filter"), exports);
@@ -0,0 +1 @@
1
+ export declare const FORBIDDEN_MESSAGE = "Forbidden resource";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FORBIDDEN_MESSAGE = void 0;
4
+ exports.FORBIDDEN_MESSAGE = 'Forbidden resource';