@pawells/nestjs-shared 1.0.0-dev.3052c75

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 (286) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +802 -0
  3. package/build/LICENSE +21 -0
  4. package/build/README.md +802 -0
  5. package/build/common/common.module.d.ts +49 -0
  6. package/build/common/common.module.d.ts.map +1 -0
  7. package/build/common/common.module.js +178 -0
  8. package/build/common/common.module.js.map +1 -0
  9. package/build/common/constants/histogram-buckets.constants.d.ts +12 -0
  10. package/build/common/constants/histogram-buckets.constants.d.ts.map +1 -0
  11. package/build/common/constants/histogram-buckets.constants.js +51 -0
  12. package/build/common/constants/histogram-buckets.constants.js.map +1 -0
  13. package/build/common/constants/http-status.constants.d.ts +27 -0
  14. package/build/common/constants/http-status.constants.d.ts.map +1 -0
  15. package/build/common/constants/http-status.constants.js +27 -0
  16. package/build/common/constants/http-status.constants.js.map +1 -0
  17. package/build/common/constants/timeout.constants.d.ts +29 -0
  18. package/build/common/constants/timeout.constants.d.ts.map +1 -0
  19. package/build/common/constants/timeout.constants.js +45 -0
  20. package/build/common/constants/timeout.constants.js.map +1 -0
  21. package/build/common/controllers/metrics.controller.d.ts +23 -0
  22. package/build/common/controllers/metrics.controller.d.ts.map +1 -0
  23. package/build/common/controllers/metrics.controller.js +66 -0
  24. package/build/common/controllers/metrics.controller.js.map +1 -0
  25. package/build/common/decorators/common-decorators.d.ts +90 -0
  26. package/build/common/decorators/common-decorators.d.ts.map +1 -0
  27. package/build/common/decorators/common-decorators.js +101 -0
  28. package/build/common/decorators/common-decorators.js.map +1 -0
  29. package/build/common/decorators/decorator-factory.d.ts +108 -0
  30. package/build/common/decorators/decorator-factory.d.ts.map +1 -0
  31. package/build/common/decorators/decorator-factory.js +104 -0
  32. package/build/common/decorators/decorator-factory.js.map +1 -0
  33. package/build/common/decorators/guard.decorators.d.ts +48 -0
  34. package/build/common/decorators/guard.decorators.d.ts.map +1 -0
  35. package/build/common/decorators/guard.decorators.js +49 -0
  36. package/build/common/decorators/guard.decorators.js.map +1 -0
  37. package/build/common/decorators/index.d.ts +10 -0
  38. package/build/common/decorators/index.d.ts.map +1 -0
  39. package/build/common/decorators/index.js +11 -0
  40. package/build/common/decorators/index.js.map +1 -0
  41. package/build/common/decorators/instrument.decorator.d.ts +128 -0
  42. package/build/common/decorators/instrument.decorator.d.ts.map +1 -0
  43. package/build/common/decorators/instrument.decorator.js +165 -0
  44. package/build/common/decorators/instrument.decorator.js.map +1 -0
  45. package/build/common/decorators/metric.decorators.d.ts +42 -0
  46. package/build/common/decorators/metric.decorators.d.ts.map +1 -0
  47. package/build/common/decorators/metric.decorators.js +85 -0
  48. package/build/common/decorators/metric.decorators.js.map +1 -0
  49. package/build/common/decorators/request-property.decorator.d.ts +65 -0
  50. package/build/common/decorators/request-property.decorator.d.ts.map +1 -0
  51. package/build/common/decorators/request-property.decorator.js +102 -0
  52. package/build/common/decorators/request-property.decorator.js.map +1 -0
  53. package/build/common/errors/base-application-error.d.ts +98 -0
  54. package/build/common/errors/base-application-error.d.ts.map +1 -0
  55. package/build/common/errors/base-application-error.js +133 -0
  56. package/build/common/errors/base-application-error.js.map +1 -0
  57. package/build/common/errors/error-factory.d.ts +93 -0
  58. package/build/common/errors/error-factory.d.ts.map +1 -0
  59. package/build/common/errors/error-factory.js +105 -0
  60. package/build/common/errors/error-factory.js.map +1 -0
  61. package/build/common/errors/index.d.ts +13 -0
  62. package/build/common/errors/index.d.ts.map +1 -0
  63. package/build/common/errors/index.js +15 -0
  64. package/build/common/errors/index.js.map +1 -0
  65. package/build/common/factories/index.d.ts +5 -0
  66. package/build/common/factories/index.d.ts.map +1 -0
  67. package/build/common/factories/index.js +3 -0
  68. package/build/common/factories/index.js.map +1 -0
  69. package/build/common/factories/module-factory.d.ts +178 -0
  70. package/build/common/factories/module-factory.d.ts.map +1 -0
  71. package/build/common/factories/module-factory.js +253 -0
  72. package/build/common/factories/module-factory.js.map +1 -0
  73. package/build/common/factories/rate-limit-config.factory.d.ts +79 -0
  74. package/build/common/factories/rate-limit-config.factory.d.ts.map +1 -0
  75. package/build/common/factories/rate-limit-config.factory.js +115 -0
  76. package/build/common/factories/rate-limit-config.factory.js.map +1 -0
  77. package/build/common/factories/security-bootstrap.factory.d.ts +77 -0
  78. package/build/common/factories/security-bootstrap.factory.d.ts.map +1 -0
  79. package/build/common/factories/security-bootstrap.factory.js +222 -0
  80. package/build/common/factories/security-bootstrap.factory.js.map +1 -0
  81. package/build/common/filters/global-exception.filter.d.ts +78 -0
  82. package/build/common/filters/global-exception.filter.d.ts.map +1 -0
  83. package/build/common/filters/global-exception.filter.js +192 -0
  84. package/build/common/filters/global-exception.filter.js.map +1 -0
  85. package/build/common/filters/http-exception.filter.d.ts +37 -0
  86. package/build/common/filters/http-exception.filter.d.ts.map +1 -0
  87. package/build/common/filters/http-exception.filter.js +91 -0
  88. package/build/common/filters/http-exception.filter.js.map +1 -0
  89. package/build/common/guards/csrf.guard.d.ts +53 -0
  90. package/build/common/guards/csrf.guard.d.ts.map +1 -0
  91. package/build/common/guards/csrf.guard.js +109 -0
  92. package/build/common/guards/csrf.guard.js.map +1 -0
  93. package/build/common/guards/metrics.guard.d.ts +42 -0
  94. package/build/common/guards/metrics.guard.d.ts.map +1 -0
  95. package/build/common/guards/metrics.guard.js +124 -0
  96. package/build/common/guards/metrics.guard.js.map +1 -0
  97. package/build/common/index.d.ts +43 -0
  98. package/build/common/index.d.ts.map +1 -0
  99. package/build/common/index.js +50 -0
  100. package/build/common/index.js.map +1 -0
  101. package/build/common/interceptors/http-client.interceptor.d.ts +11 -0
  102. package/build/common/interceptors/http-client.interceptor.d.ts.map +1 -0
  103. package/build/common/interceptors/http-client.interceptor.js +69 -0
  104. package/build/common/interceptors/http-client.interceptor.js.map +1 -0
  105. package/build/common/interceptors/http-instrumentation.interceptor.d.ts +64 -0
  106. package/build/common/interceptors/http-instrumentation.interceptor.d.ts.map +1 -0
  107. package/build/common/interceptors/http-instrumentation.interceptor.js +148 -0
  108. package/build/common/interceptors/http-instrumentation.interceptor.js.map +1 -0
  109. package/build/common/interceptors/http-metrics.interceptor.d.ts +46 -0
  110. package/build/common/interceptors/http-metrics.interceptor.d.ts.map +1 -0
  111. package/build/common/interceptors/http-metrics.interceptor.js +120 -0
  112. package/build/common/interceptors/http-metrics.interceptor.js.map +1 -0
  113. package/build/common/interceptors/logging.interceptor.d.ts +22 -0
  114. package/build/common/interceptors/logging.interceptor.d.ts.map +1 -0
  115. package/build/common/interceptors/logging.interceptor.js +67 -0
  116. package/build/common/interceptors/logging.interceptor.js.map +1 -0
  117. package/build/common/interfaces/cache-provider.interface.d.ts +54 -0
  118. package/build/common/interfaces/cache-provider.interface.d.ts.map +1 -0
  119. package/build/common/interfaces/cache-provider.interface.js +6 -0
  120. package/build/common/interfaces/cache-provider.interface.js.map +1 -0
  121. package/build/common/interfaces/index.d.ts +7 -0
  122. package/build/common/interfaces/index.d.ts.map +1 -0
  123. package/build/common/interfaces/index.js +3 -0
  124. package/build/common/interfaces/index.js.map +1 -0
  125. package/build/common/interfaces/log-context.interface.d.ts +77 -0
  126. package/build/common/interfaces/log-context.interface.d.ts.map +1 -0
  127. package/build/common/interfaces/log-context.interface.js +2 -0
  128. package/build/common/interfaces/log-context.interface.js.map +1 -0
  129. package/build/common/interfaces/log-entry.interface.d.ts +26 -0
  130. package/build/common/interfaces/log-entry.interface.d.ts.map +1 -0
  131. package/build/common/interfaces/log-entry.interface.js +33 -0
  132. package/build/common/interfaces/log-entry.interface.js.map +1 -0
  133. package/build/common/interfaces/logger.interface.d.ts +62 -0
  134. package/build/common/interfaces/logger.interface.d.ts.map +1 -0
  135. package/build/common/interfaces/logger.interface.js +2 -0
  136. package/build/common/interfaces/logger.interface.js.map +1 -0
  137. package/build/common/interfaces/metrics-exporter.interface.d.ts +275 -0
  138. package/build/common/interfaces/metrics-exporter.interface.d.ts.map +1 -0
  139. package/build/common/interfaces/metrics-exporter.interface.js +8 -0
  140. package/build/common/interfaces/metrics-exporter.interface.js.map +1 -0
  141. package/build/common/metrics/base-metrics-collector.d.ts +81 -0
  142. package/build/common/metrics/base-metrics-collector.d.ts.map +1 -0
  143. package/build/common/metrics/base-metrics-collector.js +88 -0
  144. package/build/common/metrics/base-metrics-collector.js.map +1 -0
  145. package/build/common/metrics/index.d.ts +2 -0
  146. package/build/common/metrics/index.d.ts.map +1 -0
  147. package/build/common/metrics/index.js +2 -0
  148. package/build/common/metrics/index.js.map +1 -0
  149. package/build/common/metrics.module.d.ts +50 -0
  150. package/build/common/metrics.module.d.ts.map +1 -0
  151. package/build/common/metrics.module.js +77 -0
  152. package/build/common/metrics.module.js.map +1 -0
  153. package/build/common/modules/throttler.module.d.ts +69 -0
  154. package/build/common/modules/throttler.module.d.ts.map +1 -0
  155. package/build/common/modules/throttler.module.js +117 -0
  156. package/build/common/modules/throttler.module.js.map +1 -0
  157. package/build/common/pipes/base-validation.pipe.d.ts +67 -0
  158. package/build/common/pipes/base-validation.pipe.d.ts.map +1 -0
  159. package/build/common/pipes/base-validation.pipe.js +95 -0
  160. package/build/common/pipes/base-validation.pipe.js.map +1 -0
  161. package/build/common/pipes/validation.pipe.d.ts +32 -0
  162. package/build/common/pipes/validation.pipe.d.ts.map +1 -0
  163. package/build/common/pipes/validation.pipe.js +60 -0
  164. package/build/common/pipes/validation.pipe.js.map +1 -0
  165. package/build/common/registry/instrumentation-registry.d.ts +227 -0
  166. package/build/common/registry/instrumentation-registry.d.ts.map +1 -0
  167. package/build/common/registry/instrumentation-registry.js +414 -0
  168. package/build/common/registry/instrumentation-registry.js.map +1 -0
  169. package/build/common/services/audit-logger.service.d.ts +91 -0
  170. package/build/common/services/audit-logger.service.d.ts.map +1 -0
  171. package/build/common/services/audit-logger.service.js +180 -0
  172. package/build/common/services/audit-logger.service.js.map +1 -0
  173. package/build/common/services/csrf.service.d.ts +202 -0
  174. package/build/common/services/csrf.service.d.ts.map +1 -0
  175. package/build/common/services/csrf.service.js +478 -0
  176. package/build/common/services/csrf.service.js.map +1 -0
  177. package/build/common/services/error-categorizer.service.d.ts +82 -0
  178. package/build/common/services/error-categorizer.service.d.ts.map +1 -0
  179. package/build/common/services/error-categorizer.service.js +339 -0
  180. package/build/common/services/error-categorizer.service.js.map +1 -0
  181. package/build/common/services/error-sanitizer.service.d.ts +146 -0
  182. package/build/common/services/error-sanitizer.service.d.ts.map +1 -0
  183. package/build/common/services/error-sanitizer.service.js +287 -0
  184. package/build/common/services/error-sanitizer.service.js.map +1 -0
  185. package/build/common/services/health-check.service.d.ts +86 -0
  186. package/build/common/services/health-check.service.d.ts.map +1 -0
  187. package/build/common/services/health-check.service.js +132 -0
  188. package/build/common/services/health-check.service.js.map +1 -0
  189. package/build/common/services/http-client.service.d.ts +113 -0
  190. package/build/common/services/http-client.service.d.ts.map +1 -0
  191. package/build/common/services/http-client.service.js +294 -0
  192. package/build/common/services/http-client.service.js.map +1 -0
  193. package/build/common/services/logger.service.d.ts +189 -0
  194. package/build/common/services/logger.service.d.ts.map +1 -0
  195. package/build/common/services/logger.service.js +423 -0
  196. package/build/common/services/logger.service.js.map +1 -0
  197. package/build/common/services/metrics-registry.service.d.ts +98 -0
  198. package/build/common/services/metrics-registry.service.d.ts.map +1 -0
  199. package/build/common/services/metrics-registry.service.js +262 -0
  200. package/build/common/services/metrics-registry.service.js.map +1 -0
  201. package/build/common/services/nest-logger-adapter.service.d.ts +62 -0
  202. package/build/common/services/nest-logger-adapter.service.d.ts.map +1 -0
  203. package/build/common/services/nest-logger-adapter.service.js +120 -0
  204. package/build/common/services/nest-logger-adapter.service.js.map +1 -0
  205. package/build/common/utils/error.utils.d.ts +16 -0
  206. package/build/common/utils/error.utils.d.ts.map +1 -0
  207. package/build/common/utils/error.utils.js +26 -0
  208. package/build/common/utils/error.utils.js.map +1 -0
  209. package/build/common/utils/lazy-getter.types.d.ts +190 -0
  210. package/build/common/utils/lazy-getter.types.d.ts.map +1 -0
  211. package/build/common/utils/lazy-getter.types.js +114 -0
  212. package/build/common/utils/lazy-getter.types.js.map +1 -0
  213. package/build/common/utils/module.utils.d.ts +33 -0
  214. package/build/common/utils/module.utils.d.ts.map +1 -0
  215. package/build/common/utils/module.utils.js +48 -0
  216. package/build/common/utils/module.utils.js.map +1 -0
  217. package/build/common/utils/sanitization.utils.d.ts +69 -0
  218. package/build/common/utils/sanitization.utils.d.ts.map +1 -0
  219. package/build/common/utils/sanitization.utils.js +141 -0
  220. package/build/common/utils/sanitization.utils.js.map +1 -0
  221. package/build/config/config.module.d.ts +30 -0
  222. package/build/config/config.module.d.ts.map +1 -0
  223. package/build/config/config.module.js +49 -0
  224. package/build/config/config.module.js.map +1 -0
  225. package/build/config/config.service.d.ts +74 -0
  226. package/build/config/config.service.d.ts.map +1 -0
  227. package/build/config/config.service.js +145 -0
  228. package/build/config/config.service.js.map +1 -0
  229. package/build/config/config.types.d.ts +143 -0
  230. package/build/config/config.types.d.ts.map +1 -0
  231. package/build/config/config.types.js +2 -0
  232. package/build/config/config.types.js.map +1 -0
  233. package/build/config/decorators/config.decorators.d.ts +43 -0
  234. package/build/config/decorators/config.decorators.d.ts.map +1 -0
  235. package/build/config/decorators/config.decorators.js +68 -0
  236. package/build/config/decorators/config.decorators.js.map +1 -0
  237. package/build/config/decorators/index.d.ts +2 -0
  238. package/build/config/decorators/index.d.ts.map +1 -0
  239. package/build/config/decorators/index.js +2 -0
  240. package/build/config/decorators/index.js.map +1 -0
  241. package/build/config/index.d.ts +7 -0
  242. package/build/config/index.d.ts.map +1 -0
  243. package/build/config/index.js +9 -0
  244. package/build/config/index.js.map +1 -0
  245. package/build/config/validation.utils.d.ts +136 -0
  246. package/build/config/validation.utils.d.ts.map +1 -0
  247. package/build/config/validation.utils.js +263 -0
  248. package/build/config/validation.utils.js.map +1 -0
  249. package/build/errors/index.d.ts +9 -0
  250. package/build/errors/index.d.ts.map +1 -0
  251. package/build/errors/index.js +12 -0
  252. package/build/errors/index.js.map +1 -0
  253. package/build/guards/custom-throttle.guard.d.ts +28 -0
  254. package/build/guards/custom-throttle.guard.d.ts.map +1 -0
  255. package/build/guards/custom-throttle.guard.js +52 -0
  256. package/build/guards/custom-throttle.guard.js.map +1 -0
  257. package/build/guards/index.d.ts +2 -0
  258. package/build/guards/index.d.ts.map +1 -0
  259. package/build/guards/index.js +2 -0
  260. package/build/guards/index.js.map +1 -0
  261. package/build/index.d.ts +53 -0
  262. package/build/index.d.ts.map +1 -0
  263. package/build/index.js +61 -0
  264. package/build/index.js.map +1 -0
  265. package/build/logging/index.d.ts +7 -0
  266. package/build/logging/index.d.ts.map +1 -0
  267. package/build/logging/index.js +7 -0
  268. package/build/logging/index.js.map +1 -0
  269. package/build/metrics/index.d.ts +6 -0
  270. package/build/metrics/index.d.ts.map +1 -0
  271. package/build/metrics/index.js +11 -0
  272. package/build/metrics/index.js.map +1 -0
  273. package/build/package.json +72 -0
  274. package/build/security/index.d.ts +8 -0
  275. package/build/security/index.d.ts.map +1 -0
  276. package/build/security/index.js +11 -0
  277. package/build/security/index.js.map +1 -0
  278. package/build/test-setup.d.ts +2 -0
  279. package/build/test-setup.d.ts.map +1 -0
  280. package/build/test-setup.js +40 -0
  281. package/build/test-setup.js.map +1 -0
  282. package/build/validation/index.d.ts +6 -0
  283. package/build/validation/index.d.ts.map +1 -0
  284. package/build/validation/index.js +8 -0
  285. package/build/validation/index.js.map +1 -0
  286. package/package.json +71 -0
@@ -0,0 +1,133 @@
1
+ import { HTTP_STATUS_INTERNAL_SERVER_ERROR } from '../constants/http-status.constants.js';
2
+ /**
3
+ * Base Application Error
4
+ *
5
+ * Provides a standardized error structure for NestJS applications with consistent
6
+ * properties and methods for error handling, serialization, and context management.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * throw new BaseApplicationError('User not found', {
11
+ * code: 'USER_NOT_FOUND',
12
+ * statusCode: 404,
13
+ * context: { userId: '123' }
14
+ * });
15
+ * ```
16
+ */
17
+ export class BaseApplicationError extends Error {
18
+ /**
19
+ * The HTTP status code associated with this error
20
+ */
21
+ statusCode;
22
+ /**
23
+ * The error code for programmatic error identification
24
+ */
25
+ code;
26
+ /**
27
+ * Additional context information for debugging and logging
28
+ */
29
+ context;
30
+ /**
31
+ * Timestamp when the error was created
32
+ */
33
+ timestamp;
34
+ /**
35
+ * Creates a new BaseApplicationError instance
36
+ *
37
+ * @param message - The error message
38
+ * @param options - Configuration options for the error
39
+ * @param options.code - The error code (defaults to 'INTERNAL_SERVER_ERROR')
40
+ * @param options.statusCode - The HTTP status code (defaults to 500)
41
+ * @param options.context - Additional context information (defaults to empty object)
42
+ */
43
+ constructor(message, options = {}) {
44
+ super(message);
45
+ const { code = 'INTERNAL_SERVER_ERROR', statusCode = HTTP_STATUS_INTERNAL_SERVER_ERROR, context = {} } = options;
46
+ this.name = this.constructor.name;
47
+ this.statusCode = statusCode;
48
+ this.code = code;
49
+ this.context = { ...context };
50
+ this.timestamp = new Date();
51
+ // Capture stack trace
52
+ if (Error.captureStackTrace) {
53
+ Error.captureStackTrace(this, this.constructor);
54
+ }
55
+ }
56
+ /**
57
+ * Serializes the error to a plain object for JSON responses or logging
58
+ *
59
+ * @returns A plain object representation of the error
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const error = new BaseApplicationError('Test error');
64
+ * console.log(error.toJSON());
65
+ * // {
66
+ * // name: 'BaseApplicationError',
67
+ * // message: 'Test error',
68
+ * // code: 'INTERNAL_SERVER_ERROR',
69
+ * // statusCode: 500,
70
+ * // context: {},
71
+ * // timestamp: '2023-01-01T00:00:00.000Z'
72
+ * // }
73
+ * ```
74
+ */
75
+ toJSON() {
76
+ return {
77
+ name: this.name,
78
+ message: this.message,
79
+ code: this.code,
80
+ statusCode: this.statusCode,
81
+ context: this.context,
82
+ timestamp: this.timestamp.toISOString(),
83
+ // Include stack trace in development
84
+ ...(process.env['NODE_ENV'] !== 'production' ? { stack: this.stack } : {}),
85
+ };
86
+ }
87
+ /**
88
+ * Creates a new error instance with additional context merged into the existing context.
89
+ * Note: Returns a new instance, not the same instance, so instanceof checks will still work.
90
+ *
91
+ * @param additionalContext - Additional context to merge
92
+ * @returns A new error instance of the same type with merged context
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * const error = new BaseApplicationError('User error', { code: 'USER_ERROR' });
97
+ * const errorWithContext = error.withContext({ userId: '123', action: 'login' });
98
+ * // errorWithContext is a new instance but still instanceof BaseApplicationError
99
+ * // errorWithContext.context = { userId: '123', action: 'login' }
100
+ * ```
101
+ */
102
+ withContext(additionalContext) {
103
+ const mergedContext = { ...this.context, ...additionalContext };
104
+ const Constructor = this.constructor;
105
+ return new Constructor(this.message, {
106
+ code: this.code,
107
+ statusCode: this.statusCode,
108
+ context: mergedContext,
109
+ });
110
+ }
111
+ /**
112
+ * Creates a new error instance with a different message
113
+ *
114
+ * @param newMessage - The new error message
115
+ * @returns A new error instance with the updated message
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * const error = new BaseApplicationError('Generic error');
120
+ * const specificError = error.withMessage('User not found');
121
+ * // specificError.message = 'User not found'
122
+ * ```
123
+ */
124
+ withMessage(newMessage) {
125
+ const Constructor = this.constructor;
126
+ return new Constructor(newMessage, {
127
+ code: this.code,
128
+ statusCode: this.statusCode,
129
+ context: this.context,
130
+ });
131
+ }
132
+ }
133
+ //# sourceMappingURL=base-application-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-application-error.js","sourceRoot":"","sources":["../../../src/common/errors/base-application-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,uCAAuC,CAAC;AAE1F;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC9C;;OAEG;IACa,UAAU,CAAS;IAEnC;;OAEG;IACa,IAAI,CAAS;IAE7B;;OAEG;IACa,OAAO,CAAsB;IAE7C;;OAEG;IACa,SAAS,CAAO;IAEhC;;;;;;;;OAQG;IACH,YACC,OAAe,EACf,UAII,EAAE;QAEN,KAAK,CA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QAEV,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE;YACpC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,OAAO,EAAE,aAAa;SACtB,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;OAYG;IACI,WAAW,CAAC,UAAkB;QACpC,MAAM,WAAW,GAAG,IAAI,CAAC,WAGhB,CAAC;QAEV,OAAO,IAAI,WAAW,CAAC,UAAU,EAAE;YAClC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;SACrB,CAAC,CAAC;IACJ,CAAC;CACD"}
@@ -0,0 +1,93 @@
1
+ import { BaseApplicationError } from './base-application-error.js';
2
+ /**
3
+ * Configuration interface for creating error classes
4
+ */
5
+ export interface ErrorConfig {
6
+ /** The error code for programmatic identification */
7
+ code: string;
8
+ /** The HTTP status code */
9
+ statusCode: number;
10
+ /** Default error message */
11
+ defaultMessage: string;
12
+ /** Optional error class name (defaults to code + 'Error') */
13
+ name?: string;
14
+ }
15
+ /**
16
+ * Factory function to create application error classes
17
+ *
18
+ * This factory eliminates code duplication by generating error classes
19
+ * from configuration objects instead of defining each class individually.
20
+ *
21
+ * @param config - Configuration for the error class
22
+ * @returns An application error class constructor
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * export const NotFoundError = createError({
27
+ * code: 'NOT_FOUND',
28
+ * statusCode: 404,
29
+ * defaultMessage: 'Resource not found'
30
+ * });
31
+ * ```
32
+ */
33
+ export declare function createError(config: ErrorConfig): typeof BaseApplicationError;
34
+ /**
35
+ * Error configurations for all standard HTTP error types
36
+ */
37
+ export declare const ERROR_CONFIGS: {
38
+ readonly BAD_REQUEST: {
39
+ readonly code: "BAD_REQUEST";
40
+ readonly statusCode: 400;
41
+ readonly defaultMessage: "Bad request";
42
+ };
43
+ readonly UNAUTHORIZED: {
44
+ readonly code: "UNAUTHORIZED";
45
+ readonly statusCode: 401;
46
+ readonly defaultMessage: "Unauthorized";
47
+ };
48
+ readonly FORBIDDEN: {
49
+ readonly code: "FORBIDDEN";
50
+ readonly statusCode: 403;
51
+ readonly defaultMessage: "Forbidden";
52
+ };
53
+ readonly NOT_FOUND: {
54
+ readonly code: "NOT_FOUND";
55
+ readonly statusCode: 404;
56
+ readonly defaultMessage: "Not found";
57
+ };
58
+ readonly CONFLICT: {
59
+ readonly code: "CONFLICT";
60
+ readonly statusCode: 409;
61
+ readonly defaultMessage: "Conflict";
62
+ };
63
+ readonly UNPROCESSABLE_ENTITY: {
64
+ readonly code: "UNPROCESSABLE_ENTITY";
65
+ readonly statusCode: 422;
66
+ readonly defaultMessage: "Unprocessable entity";
67
+ };
68
+ readonly INTERNAL_SERVER_ERROR: {
69
+ readonly code: "INTERNAL_SERVER_ERROR";
70
+ readonly statusCode: 500;
71
+ readonly defaultMessage: "Internal server error";
72
+ };
73
+ readonly BAD_GATEWAY: {
74
+ readonly code: "BAD_GATEWAY";
75
+ readonly statusCode: 502;
76
+ readonly defaultMessage: "Bad gateway";
77
+ };
78
+ readonly SERVICE_UNAVAILABLE: {
79
+ readonly code: "SERVICE_UNAVAILABLE";
80
+ readonly statusCode: 503;
81
+ readonly defaultMessage: "Service unavailable";
82
+ };
83
+ readonly GATEWAY_TIMEOUT: {
84
+ readonly code: "GATEWAY_TIMEOUT";
85
+ readonly statusCode: 504;
86
+ readonly defaultMessage: "Gateway timeout";
87
+ };
88
+ };
89
+ /**
90
+ * Type for error configuration keys
91
+ */
92
+ export type ErrorType = keyof typeof ERROR_CONFIGS;
93
+ //# sourceMappingURL=error-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-factory.d.ts","sourceRoot":"","sources":["../../../src/common/errors/error-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,oBAAoB,CAgC5E;AAED;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmDhB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,OAAO,aAAa,CAAC"}
@@ -0,0 +1,105 @@
1
+ import { BaseApplicationError } from './base-application-error.js';
2
+ /**
3
+ * Factory function to create application error classes
4
+ *
5
+ * This factory eliminates code duplication by generating error classes
6
+ * from configuration objects instead of defining each class individually.
7
+ *
8
+ * @param config - Configuration for the error class
9
+ * @returns An application error class constructor
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * export const NotFoundError = createError({
14
+ * code: 'NOT_FOUND',
15
+ * statusCode: 404,
16
+ * defaultMessage: 'Resource not found'
17
+ * });
18
+ * ```
19
+ */
20
+ export function createError(config) {
21
+ const { code, statusCode, defaultMessage, name = `${code}Error` } = config;
22
+ /**
23
+ * Dynamically created application error class
24
+ */
25
+ class GeneratedApplicationError extends BaseApplicationError {
26
+ /**
27
+ * Creates a new error instance
28
+ *
29
+ * @param message - Custom error message (optional)
30
+ * @param context - Additional context information (optional)
31
+ */
32
+ constructor(message = defaultMessage, context) {
33
+ const options = {
34
+ code,
35
+ statusCode,
36
+ };
37
+ if (context !== undefined) {
38
+ options.context = context;
39
+ }
40
+ super(message, options);
41
+ }
42
+ }
43
+ // Set the class name for better debugging and instanceof checks
44
+ Object.defineProperty(GeneratedApplicationError, 'name', {
45
+ value: name,
46
+ writable: false,
47
+ });
48
+ return GeneratedApplicationError;
49
+ }
50
+ /**
51
+ * Error configurations for all standard HTTP error types
52
+ */
53
+ export const ERROR_CONFIGS = {
54
+ BAD_REQUEST: {
55
+ code: 'BAD_REQUEST',
56
+ statusCode: 400,
57
+ defaultMessage: 'Bad request',
58
+ },
59
+ UNAUTHORIZED: {
60
+ code: 'UNAUTHORIZED',
61
+ statusCode: 401,
62
+ defaultMessage: 'Unauthorized',
63
+ },
64
+ FORBIDDEN: {
65
+ code: 'FORBIDDEN',
66
+ statusCode: 403,
67
+ defaultMessage: 'Forbidden',
68
+ },
69
+ NOT_FOUND: {
70
+ code: 'NOT_FOUND',
71
+ statusCode: 404,
72
+ defaultMessage: 'Not found',
73
+ },
74
+ CONFLICT: {
75
+ code: 'CONFLICT',
76
+ statusCode: 409,
77
+ defaultMessage: 'Conflict',
78
+ },
79
+ UNPROCESSABLE_ENTITY: {
80
+ code: 'UNPROCESSABLE_ENTITY',
81
+ statusCode: 422,
82
+ defaultMessage: 'Unprocessable entity',
83
+ },
84
+ INTERNAL_SERVER_ERROR: {
85
+ code: 'INTERNAL_SERVER_ERROR',
86
+ statusCode: 500,
87
+ defaultMessage: 'Internal server error',
88
+ },
89
+ BAD_GATEWAY: {
90
+ code: 'BAD_GATEWAY',
91
+ statusCode: 502,
92
+ defaultMessage: 'Bad gateway',
93
+ },
94
+ SERVICE_UNAVAILABLE: {
95
+ code: 'SERVICE_UNAVAILABLE',
96
+ statusCode: 503,
97
+ defaultMessage: 'Service unavailable',
98
+ },
99
+ GATEWAY_TIMEOUT: {
100
+ code: 'GATEWAY_TIMEOUT',
101
+ statusCode: 504,
102
+ defaultMessage: 'Gateway timeout',
103
+ },
104
+ };
105
+ //# sourceMappingURL=error-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-factory.js","sourceRoot":"","sources":["../../../src/common/errors/error-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,C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;QACrB,IAAI,EAAE,sBAAsB;QAC5B,UAAU,EAAE,GAAG;QACf,cAAc,EAAE,sBAAsB;KACtC;IACD,qBAAqB,EAAE;QACtB,IAAI,EAAE,uBAAuB;QAC7B,UAAU,EAAE,GAAG;QACf,cAAc,EAAE,uBAAuB;KACvC;IACD,WAAW,EAAE;QACZ,IAAI,EAAE,aAAa;QACnB,UAAU,EAAE,GAAG;QACf,cAAc,EAAE,aAAa;KAC7B;IACD,mBAAmB,EAAE;QACpB,IAAI,EAAE,qBAAqB;QAC3B,UAAU,EAAE,GAAG;QACf,cAAc,EAAE,qBAAqB;KACrC;IACD,eAAe,EAAE;QAChB,IAAI,EAAE,iBAAiB;QACvB,UAAU,EAAE,GAAG;QACf,cAAc,EAAE,iBAAiB;KACjC;CACQ,CAAC"}
@@ -0,0 +1,13 @@
1
+ export { BaseApplicationError } from './base-application-error.js';
2
+ export { createError, ERROR_CONFIGS, type ErrorConfig, type ErrorType } from './error-factory.js';
3
+ export declare const BadRequestError: typeof import("./base-application-error.js").BaseApplicationError;
4
+ export declare const UnauthorizedError: typeof import("./base-application-error.js").BaseApplicationError;
5
+ export declare const ForbiddenError: typeof import("./base-application-error.js").BaseApplicationError;
6
+ export declare const NotFoundError: typeof import("./base-application-error.js").BaseApplicationError;
7
+ export declare const ConflictError: typeof import("./base-application-error.js").BaseApplicationError;
8
+ export declare const UnprocessableEntityError: typeof import("./base-application-error.js").BaseApplicationError;
9
+ export declare const InternalServerError: typeof import("./base-application-error.js").BaseApplicationError;
10
+ export declare const BadGatewayError: typeof import("./base-application-error.js").BaseApplicationError;
11
+ export declare const ServiceUnavailableError: typeof import("./base-application-error.js").BaseApplicationError;
12
+ export declare const GatewayTimeoutError: typeof import("./base-application-error.js").BaseApplicationError;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAKlG,eAAO,MAAM,eAAe,mEAAyC,CAAC;AACtE,eAAO,MAAM,iBAAiB,mEAA0C,CAAC;AACzE,eAAO,MAAM,cAAc,mEAAuC,CAAC;AACnE,eAAO,MAAM,aAAa,mEAAuC,CAAC;AAClE,eAAO,MAAM,aAAa,mEAAsC,CAAC;AACjE,eAAO,MAAM,wBAAwB,mEAAkD,CAAC;AACxF,eAAO,MAAM,mBAAmB,mEAAmD,CAAC;AACpF,eAAO,MAAM,eAAe,mEAAyC,CAAC;AACtE,eAAO,MAAM,uBAAuB,mEAAiD,CAAC;AACtF,eAAO,MAAM,mBAAmB,mEAA6C,CAAC"}
@@ -0,0 +1,15 @@
1
+ export { BaseApplicationError } from './base-application-error.js';
2
+ export { createError, ERROR_CONFIGS } from './error-factory.js';
3
+ import { createError, ERROR_CONFIGS } from './error-factory.js';
4
+ // Predefined error classes
5
+ export const BadRequestError = createError(ERROR_CONFIGS.BAD_REQUEST);
6
+ export const UnauthorizedError = createError(ERROR_CONFIGS.UNAUTHORIZED);
7
+ export const ForbiddenError = createError(ERROR_CONFIGS.FORBIDDEN);
8
+ export const NotFoundError = createError(ERROR_CONFIGS.NOT_FOUND);
9
+ export const ConflictError = createError(ERROR_CONFIGS.CONFLICT);
10
+ export const UnprocessableEntityError = createError(ERROR_CONFIGS.UNPROCESSABLE_ENTITY);
11
+ export const InternalServerError = createError(ERROR_CONFIGS.INTERNAL_SERVER_ERROR);
12
+ export const BadGatewayError = createError(ERROR_CONFIGS.BAD_GATEWAY);
13
+ export const ServiceUnavailableError = createError(ERROR_CONFIGS.SERVICE_UNAVAILABLE);
14
+ export const GatewayTimeoutError = createError(ERROR_CONFIGS.GATEWAY_TIMEOUT);
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAoC,MAAM,oBAAoB,CAAC;AAElG,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEhE,2BAA2B;AAC3B,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;AACtE,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;AACzE,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;AACnE,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;AAClE,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;AACjE,MAAM,CAAC,MAAM,wBAAwB,GAAG,WAAW,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC;AACxF,MAAM,CAAC,MAAM,mBAAmB,GAAG,WAAW,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;AACpF,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;AACtE,MAAM,CAAC,MAAM,uBAAuB,GAAG,WAAW,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC;AACtF,MAAM,CAAC,MAAM,mBAAmB,GAAG,WAAW,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { ApplySecurityMiddleware } from './security-bootstrap.factory.js';
2
+ export type { SecurityBootstrapOptions } from './security-bootstrap.factory.js';
3
+ export { CreateRateLimitConfig } from './rate-limit-config.factory.js';
4
+ export type { RateLimitConfig, RateLimitDescriptor } from './rate-limit-config.factory.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/factories/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,YAAY,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { ApplySecurityMiddleware } from './security-bootstrap.factory.js';
2
+ export { CreateRateLimitConfig } from './rate-limit-config.factory.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/factories/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC"}
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Module factory utilities for common NestJS module patterns
3
+ *
4
+ * Provides standardized factory functions for creating modules with consistent
5
+ * structure, providers, exports, and configuration patterns.
6
+ */
7
+ import { DynamicModule } from '@nestjs/common';
8
+ /**
9
+ * Configuration interface for global modules
10
+ */
11
+ export interface GlobalModuleConfig {
12
+ /** Module name for logging */
13
+ name: string;
14
+ /** Providers to include in the module */
15
+ providers?: any[];
16
+ /** Services to export from the module */
17
+ exports?: any[];
18
+ /** Other modules to import */
19
+ imports?: any[];
20
+ /** Whether the module is global (default: true) */
21
+ isGlobal?: boolean;
22
+ }
23
+ /**
24
+ * Configuration interface for feature modules
25
+ */
26
+ export interface FeatureModuleConfig {
27
+ /** Module name for logging */
28
+ name: string;
29
+ /** Providers to include in the module */
30
+ providers?: any[];
31
+ /** Services to export from the module */
32
+ exports?: any[];
33
+ /** Controllers to include */
34
+ controllers?: any[];
35
+ /** Other modules to import */
36
+ imports?: any[];
37
+ }
38
+ /**
39
+ * Configuration interface for service modules
40
+ */
41
+ export interface ServiceModuleConfig {
42
+ /** Module name for logging */
43
+ name: string;
44
+ /** Service providers */
45
+ providers?: any[];
46
+ /** Services to export */
47
+ exports?: any[];
48
+ /** Other modules to import */
49
+ imports?: any[];
50
+ }
51
+ /**
52
+ * Configuration interface for application modules
53
+ */
54
+ export interface ApplicationModuleConfig {
55
+ /** Module name for logging */
56
+ name: string;
57
+ /** Global filters to apply */
58
+ filters?: any[];
59
+ /** Global interceptors to apply */
60
+ interceptors?: any[];
61
+ /** Global pipes to apply */
62
+ pipes?: any[];
63
+ /** Global guards to apply */
64
+ guards?: any[];
65
+ /** Other modules to import */
66
+ imports?: any[];
67
+ }
68
+ /**
69
+ * Creates a global module with standardized configuration
70
+ *
71
+ * @param config - Module configuration
72
+ * @returns DynamicModule
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * @Module({})
77
+ * export class ConfigModule extends createGlobalModule({
78
+ * name: 'ConfigModule',
79
+ * providers: [ConfigService],
80
+ * exports: [ConfigService],
81
+ * }) {}
82
+ * ```
83
+ */
84
+ export declare function CreateGlobalModule(config: GlobalModuleConfig): DynamicModule;
85
+ /**
86
+ * Creates a feature module with standardized configuration
87
+ *
88
+ * @param config - Module configuration
89
+ * @returns DynamicModule
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * @Module({})
94
+ * export class UserModule extends createFeatureModule({
95
+ * name: 'UserModule',
96
+ * controllers: [UserController],
97
+ * providers: [UserService],
98
+ * exports: [UserService],
99
+ * }) {}
100
+ * ```
101
+ */
102
+ export declare function CreateFeatureModule(config: FeatureModuleConfig): DynamicModule;
103
+ /**
104
+ * Creates a service module with standardized configuration
105
+ *
106
+ * @param config - Module configuration
107
+ * @returns DynamicModule
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * @Module({})
112
+ * export class DatabaseModule extends createServiceModule({
113
+ * name: 'DatabaseModule',
114
+ * providers: [DatabaseService, DatabaseConnection],
115
+ * exports: [DatabaseService],
116
+ * }) {}
117
+ * ```
118
+ */
119
+ export declare function CreateServiceModule(config: ServiceModuleConfig): DynamicModule;
120
+ /**
121
+ * Creates an application module with global filters, interceptors, pipes, and guards
122
+ *
123
+ * @param config - Module configuration
124
+ * @returns DynamicModule
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * @Module({})
129
+ * export class AppModule extends createApplicationModule({
130
+ * name: 'AppModule',
131
+ * imports: [UserModule, AuthModule],
132
+ * filters: [HttpExceptionFilter],
133
+ * interceptors: [LoggingInterceptor],
134
+ * pipes: [ValidationPipe],
135
+ * guards: [AuthGuard],
136
+ * }) {}
137
+ * ```
138
+ */
139
+ export declare function CreateApplicationModule(config: ApplicationModuleConfig): DynamicModule;
140
+ /**
141
+ * Creates a module with conditional providers based on configuration
142
+ *
143
+ * @param config - Base module configuration
144
+ * @param conditions - Array of conditional provider configurations
145
+ * @returns DynamicModule
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * @Module({})
150
+ * export class CacheModule extends createConditionalModule(
151
+ * { name: 'CacheModule', imports: [ConfigModule] },
152
+ * [
153
+ * {
154
+ * condition: (config) => config.get('CACHE_ENABLED'),
155
+ * providers: [RedisService],
156
+ * exports: [RedisService],
157
+ * },
158
+ * ]
159
+ * ) {}
160
+ * ```
161
+ */
162
+ export declare function CreateConditionalModule(baseConfig: Partial<GlobalModuleConfig & FeatureModuleConfig & ServiceModuleConfig>, conditions: Array<{
163
+ condition: (config?: any) => boolean;
164
+ providers?: any[];
165
+ exports?: any[];
166
+ imports?: any[];
167
+ controllers?: any[];
168
+ config?: any;
169
+ }>): DynamicModule;
170
+ /**
171
+ * Backwards compatibility aliases - exported functions use PascalCase per project conventions
172
+ */
173
+ export declare const createApplicationModule: typeof CreateApplicationModule;
174
+ export declare const createConditionalModule: typeof CreateConditionalModule;
175
+ export declare const createFeatureModule: typeof CreateFeatureModule;
176
+ export declare const createGlobalModule: typeof CreateGlobalModule;
177
+ export declare const createServiceModule: typeof CreateServiceModule;
178
+ //# sourceMappingURL=module-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-factory.d.ts","sourceRoot":"","sources":["../../../src/common/factories/module-factory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAU,MAAM,gBAAgB,CAAC;AAGvD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC;IAClB,yCAAyC;IACzC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAChB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAChB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC;IAClB,yCAAyC;IACzC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAChB,6BAA6B;IAC7B,WAAW,CAAC,EAAE,GAAG,EAAE,CAAC;IACpB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,wBAAwB;IACxB,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC;IAClB,yBAAyB;IACzB,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAChB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,8BAA8B;IAC9B,IAAI,E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