@navios/core 0.5.1 → 0.7.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 (277) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +18 -1
  3. package/docs/README.md +1 -0
  4. package/docs/legacy-compat.md +320 -0
  5. package/docs/testing.md +140 -17
  6. package/lib/index-BFwNx9WQ.d.cts +1951 -0
  7. package/lib/index-BFwNx9WQ.d.cts.map +1 -0
  8. package/lib/index-D657ijFO.d.mts +1951 -0
  9. package/lib/index-D657ijFO.d.mts.map +1 -0
  10. package/lib/index.cjs +157 -0
  11. package/lib/index.d.cts +3 -0
  12. package/lib/index.d.mts +3 -188
  13. package/lib/index.mjs +4 -1439
  14. package/lib/legacy-compat/index.cjs +315 -0
  15. package/lib/legacy-compat/index.cjs.map +1 -0
  16. package/lib/legacy-compat/index.d.cts +219 -0
  17. package/lib/legacy-compat/index.d.cts.map +1 -0
  18. package/lib/legacy-compat/index.d.mts +219 -0
  19. package/lib/legacy-compat/index.d.mts.map +1 -0
  20. package/lib/legacy-compat/index.mjs +308 -0
  21. package/lib/legacy-compat/index.mjs.map +1 -0
  22. package/lib/src-Cb1aTjl0.cjs +5710 -0
  23. package/lib/src-Cb1aTjl0.cjs.map +1 -0
  24. package/lib/src-DzPY5s6d.mjs +5353 -0
  25. package/lib/src-DzPY5s6d.mjs.map +1 -0
  26. package/lib/testing/index.cjs +106 -0
  27. package/lib/testing/index.cjs.map +1 -0
  28. package/lib/testing/index.d.cts +156 -0
  29. package/lib/testing/index.d.cts.map +1 -0
  30. package/lib/testing/index.d.mts +156 -0
  31. package/lib/testing/index.d.mts.map +1 -0
  32. package/lib/testing/index.mjs +100 -0
  33. package/lib/testing/index.mjs.map +1 -0
  34. package/lib/use-guards.decorator-DdvUhB03.cjs +622 -0
  35. package/lib/use-guards.decorator-DdvUhB03.cjs.map +1 -0
  36. package/lib/use-guards.decorator-kZ3lNK8v.mjs +454 -0
  37. package/lib/use-guards.decorator-kZ3lNK8v.mjs.map +1 -0
  38. package/package.json +26 -6
  39. package/project.json +2 -2
  40. package/src/attribute.factory.d.mts +175 -0
  41. package/src/attribute.factory.d.mts.map +1 -0
  42. package/src/attribute.factory.mts +154 -0
  43. package/src/config/config-service.interface.d.mts +39 -0
  44. package/src/config/config-service.interface.d.mts.map +1 -0
  45. package/src/config/config-service.interface.mts +31 -0
  46. package/src/config/config.provider.d.mts +46 -0
  47. package/src/config/config.provider.d.mts.map +1 -0
  48. package/src/config/config.provider.mts +36 -0
  49. package/src/config/config.service.d.mts +108 -0
  50. package/src/config/config.service.d.mts.map +1 -0
  51. package/src/config/config.service.mts +94 -4
  52. package/src/config/index.d.mts +6 -0
  53. package/src/config/index.d.mts.map +1 -0
  54. package/src/config/types.d.mts +13 -0
  55. package/src/config/types.d.mts.map +1 -0
  56. package/src/config/utils/helpers.d.mts +3 -0
  57. package/src/config/utils/helpers.d.mts.map +1 -0
  58. package/src/config/utils/index.d.mts +2 -0
  59. package/src/config/utils/index.d.mts.map +1 -0
  60. package/src/decorators/controller.decorator.d.mts +33 -0
  61. package/src/decorators/controller.decorator.d.mts.map +1 -0
  62. package/src/decorators/controller.decorator.mts +28 -0
  63. package/src/decorators/endpoint.decorator.d.mts +89 -0
  64. package/src/decorators/endpoint.decorator.d.mts.map +1 -0
  65. package/src/decorators/endpoint.decorator.mts +76 -0
  66. package/src/decorators/header.decorator.d.mts +22 -0
  67. package/src/decorators/header.decorator.d.mts.map +1 -0
  68. package/src/decorators/header.decorator.mts +19 -0
  69. package/src/decorators/http-code.decorator.d.mts +22 -0
  70. package/src/decorators/http-code.decorator.d.mts.map +1 -0
  71. package/src/decorators/http-code.decorator.mts +20 -0
  72. package/src/decorators/index.d.mts +9 -0
  73. package/src/decorators/index.d.mts.map +1 -0
  74. package/src/decorators/module.decorator.d.mts +42 -0
  75. package/src/decorators/module.decorator.d.mts.map +1 -0
  76. package/src/decorators/module.decorator.mts +34 -0
  77. package/src/decorators/multipart.decorator.d.mts +54 -0
  78. package/src/decorators/multipart.decorator.d.mts.map +1 -0
  79. package/src/decorators/multipart.decorator.mts +41 -0
  80. package/src/decorators/stream.decorator.d.mts +42 -0
  81. package/src/decorators/stream.decorator.d.mts.map +1 -0
  82. package/src/decorators/stream.decorator.mts +33 -0
  83. package/src/decorators/use-guards.decorator.d.mts +33 -0
  84. package/src/decorators/use-guards.decorator.d.mts.map +1 -0
  85. package/src/decorators/use-guards.decorator.mts +29 -0
  86. package/src/exceptions/bad-request.exception.d.mts +26 -0
  87. package/src/exceptions/bad-request.exception.d.mts.map +1 -0
  88. package/src/exceptions/bad-request.exception.mts +21 -0
  89. package/src/exceptions/conflict.exception.d.mts +29 -0
  90. package/src/exceptions/conflict.exception.d.mts.map +1 -0
  91. package/src/exceptions/conflict.exception.mts +24 -0
  92. package/src/exceptions/forbidden.exception.d.mts +28 -0
  93. package/src/exceptions/forbidden.exception.d.mts.map +1 -0
  94. package/src/exceptions/forbidden.exception.mts +23 -0
  95. package/src/exceptions/http.exception.d.mts +33 -0
  96. package/src/exceptions/http.exception.d.mts.map +1 -0
  97. package/src/exceptions/http.exception.mts +26 -0
  98. package/src/exceptions/index.d.mts +8 -0
  99. package/src/exceptions/index.d.mts.map +1 -0
  100. package/src/exceptions/internal-server-error.exception.d.mts +31 -0
  101. package/src/exceptions/internal-server-error.exception.d.mts.map +1 -0
  102. package/src/exceptions/internal-server-error.exception.mts +26 -0
  103. package/src/exceptions/not-found.exception.d.mts +30 -0
  104. package/src/exceptions/not-found.exception.d.mts.map +1 -0
  105. package/src/exceptions/not-found.exception.mts +23 -0
  106. package/src/exceptions/unauthorized.exception.d.mts +28 -0
  107. package/src/exceptions/unauthorized.exception.d.mts.map +1 -0
  108. package/src/exceptions/unauthorized.exception.mts +23 -0
  109. package/src/factories/endpoint-adapter.factory.d.mts +6 -0
  110. package/src/factories/endpoint-adapter.factory.d.mts.map +1 -0
  111. package/src/factories/http-adapter.factory.d.mts +6 -0
  112. package/src/factories/http-adapter.factory.d.mts.map +1 -0
  113. package/src/factories/index.d.mts +8 -0
  114. package/src/factories/index.d.mts.map +1 -0
  115. package/src/factories/index.mts +1 -0
  116. package/src/factories/multipart-adapter.factory.d.mts +6 -0
  117. package/src/factories/multipart-adapter.factory.d.mts.map +1 -0
  118. package/src/factories/reply.factory.d.mts +6 -0
  119. package/src/factories/reply.factory.d.mts.map +1 -0
  120. package/src/factories/request.factory.d.mts +6 -0
  121. package/src/factories/request.factory.d.mts.map +1 -0
  122. package/src/factories/stream-adapter.factory.d.mts +6 -0
  123. package/src/factories/stream-adapter.factory.d.mts.map +1 -0
  124. package/src/factories/xml-stream-adapter.factory.d.mts +6 -0
  125. package/src/factories/xml-stream-adapter.factory.d.mts.map +1 -0
  126. package/src/factories/xml-stream-adapter.factory.mts +20 -0
  127. package/src/index.d.mts +15 -0
  128. package/src/index.d.mts.map +1 -0
  129. package/src/index.mts +1 -0
  130. package/src/interfaces/abstract-execution-context.inteface.d.mts +44 -0
  131. package/src/interfaces/abstract-execution-context.inteface.d.mts.map +1 -0
  132. package/src/interfaces/abstract-execution-context.inteface.mts +35 -0
  133. package/src/interfaces/abstract-http-adapter.interface.d.mts +15 -0
  134. package/src/interfaces/abstract-http-adapter.interface.d.mts.map +1 -0
  135. package/src/interfaces/abstract-http-cors-options.interface.d.mts +58 -0
  136. package/src/interfaces/abstract-http-cors-options.interface.d.mts.map +1 -0
  137. package/src/interfaces/abstract-http-handler-adapter.interface.d.mts +7 -0
  138. package/src/interfaces/abstract-http-handler-adapter.interface.d.mts.map +1 -0
  139. package/src/interfaces/abstract-http-handler-adapter.interface.mts +2 -2
  140. package/src/interfaces/abstract-http-listen-options.interface.d.mts +5 -0
  141. package/src/interfaces/abstract-http-listen-options.interface.d.mts.map +1 -0
  142. package/src/interfaces/can-activate.d.mts +36 -0
  143. package/src/interfaces/can-activate.d.mts.map +1 -0
  144. package/src/interfaces/can-activate.mts +31 -0
  145. package/src/interfaces/http-header.d.mts +10 -0
  146. package/src/interfaces/http-header.d.mts.map +1 -0
  147. package/src/interfaces/index.d.mts +9 -0
  148. package/src/interfaces/index.d.mts.map +1 -0
  149. package/src/interfaces/navios-module.d.mts +29 -0
  150. package/src/interfaces/navios-module.d.mts.map +1 -0
  151. package/src/interfaces/navios-module.mts +25 -0
  152. package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +420 -0
  153. package/src/legacy-compat/__type-tests__/tsconfig.json +15 -0
  154. package/src/legacy-compat/context-compat.d.mts +19 -0
  155. package/src/legacy-compat/context-compat.d.mts.map +1 -0
  156. package/src/legacy-compat/context-compat.mts +93 -0
  157. package/src/legacy-compat/decorators/controller.decorator.d.mts +21 -0
  158. package/src/legacy-compat/decorators/controller.decorator.d.mts.map +1 -0
  159. package/src/legacy-compat/decorators/controller.decorator.mts +31 -0
  160. package/src/legacy-compat/decorators/endpoint.decorator.d.mts +33 -0
  161. package/src/legacy-compat/decorators/endpoint.decorator.d.mts.map +1 -0
  162. package/src/legacy-compat/decorators/endpoint.decorator.mts +99 -0
  163. package/src/legacy-compat/decorators/header.decorator.d.mts +24 -0
  164. package/src/legacy-compat/decorators/header.decorator.d.mts.map +1 -0
  165. package/src/legacy-compat/decorators/header.decorator.mts +42 -0
  166. package/src/legacy-compat/decorators/http-code.decorator.d.mts +22 -0
  167. package/src/legacy-compat/decorators/http-code.decorator.d.mts.map +1 -0
  168. package/src/legacy-compat/decorators/http-code.decorator.mts +38 -0
  169. package/src/legacy-compat/decorators/index.d.mts +9 -0
  170. package/src/legacy-compat/decorators/index.d.mts.map +1 -0
  171. package/src/legacy-compat/decorators/index.mts +9 -0
  172. package/src/legacy-compat/decorators/module.decorator.d.mts +22 -0
  173. package/src/legacy-compat/decorators/module.decorator.d.mts.map +1 -0
  174. package/src/legacy-compat/decorators/module.decorator.mts +37 -0
  175. package/src/legacy-compat/decorators/multipart.decorator.d.mts +34 -0
  176. package/src/legacy-compat/decorators/multipart.decorator.d.mts.map +1 -0
  177. package/src/legacy-compat/decorators/multipart.decorator.mts +93 -0
  178. package/src/legacy-compat/decorators/stream.decorator.d.mts +34 -0
  179. package/src/legacy-compat/decorators/stream.decorator.d.mts.map +1 -0
  180. package/src/legacy-compat/decorators/stream.decorator.mts +76 -0
  181. package/src/legacy-compat/decorators/use-guards.decorator.d.mts +29 -0
  182. package/src/legacy-compat/decorators/use-guards.decorator.d.mts.map +1 -0
  183. package/src/legacy-compat/decorators/use-guards.decorator.mts +80 -0
  184. package/src/legacy-compat/index.d.mts +19 -0
  185. package/src/legacy-compat/index.d.mts.map +1 -0
  186. package/src/legacy-compat/index.mts +40 -0
  187. package/src/logger/console-logger.service.d.mts +196 -0
  188. package/src/logger/console-logger.service.d.mts.map +1 -0
  189. package/src/logger/console-logger.service.mts +15 -2
  190. package/src/logger/index.d.mts +7 -0
  191. package/src/logger/index.d.mts.map +1 -0
  192. package/src/logger/log-levels.d.mts +14 -0
  193. package/src/logger/log-levels.d.mts.map +1 -0
  194. package/src/logger/log-levels.mts +9 -0
  195. package/src/logger/logger-service.interface.d.mts +36 -0
  196. package/src/logger/logger-service.interface.d.mts.map +1 -0
  197. package/src/logger/logger.service.d.mts +57 -0
  198. package/src/logger/logger.service.d.mts.map +1 -0
  199. package/src/logger/logger.service.mts +19 -0
  200. package/src/logger/logger.tokens.d.mts +36 -0
  201. package/src/logger/logger.tokens.d.mts.map +1 -0
  202. package/src/logger/logger.tokens.mts +23 -0
  203. package/src/logger/utils/cli-colors.util.d.mts +10 -0
  204. package/src/logger/utils/cli-colors.util.d.mts.map +1 -0
  205. package/src/logger/utils/filter-log-levelts.util.d.mts +6 -0
  206. package/src/logger/utils/filter-log-levelts.util.d.mts.map +1 -0
  207. package/src/logger/utils/index.d.mts +6 -0
  208. package/src/logger/utils/index.d.mts.map +1 -0
  209. package/src/logger/utils/is-log-level-enabled.d.mts +8 -0
  210. package/src/logger/utils/is-log-level-enabled.d.mts.map +1 -0
  211. package/src/logger/utils/is-log-level.util.d.mts +6 -0
  212. package/src/logger/utils/is-log-level.util.d.mts.map +1 -0
  213. package/src/logger/utils/shared.utils.d.mts +14 -0
  214. package/src/logger/utils/shared.utils.d.mts.map +1 -0
  215. package/src/metadata/controller.metadata.d.mts +13 -0
  216. package/src/metadata/controller.metadata.d.mts.map +1 -0
  217. package/src/metadata/handler.metadata.d.mts +18 -0
  218. package/src/metadata/handler.metadata.d.mts.map +1 -0
  219. package/src/metadata/index.d.mts +4 -0
  220. package/src/metadata/index.d.mts.map +1 -0
  221. package/src/metadata/module.metadata.d.mts +13 -0
  222. package/src/metadata/module.metadata.d.mts.map +1 -0
  223. package/src/navios.application.d.mts +210 -0
  224. package/src/navios.application.d.mts.map +1 -0
  225. package/src/navios.application.mts +176 -2
  226. package/src/navios.environment.d.mts +11 -0
  227. package/src/navios.environment.d.mts.map +1 -0
  228. package/src/navios.factory.d.mts +68 -0
  229. package/src/navios.factory.d.mts.map +1 -0
  230. package/src/navios.factory.mts +59 -1
  231. package/src/services/guard-runner.service.d.mts +10 -0
  232. package/src/services/guard-runner.service.d.mts.map +1 -0
  233. package/src/services/guard-runner.service.mts +12 -11
  234. package/src/services/index.d.mts +3 -0
  235. package/src/services/index.d.mts.map +1 -0
  236. package/src/services/module-loader.service.d.mts +17 -0
  237. package/src/services/module-loader.service.d.mts.map +1 -0
  238. package/src/services/module-loader.service.mts +16 -11
  239. package/src/stores/index.d.mts +2 -0
  240. package/src/stores/index.d.mts.map +1 -0
  241. package/src/stores/index.mts +1 -0
  242. package/src/stores/request-id.store.d.mts +37 -0
  243. package/src/stores/request-id.store.d.mts.map +1 -0
  244. package/src/stores/request-id.store.mts +43 -0
  245. package/src/testing/index.mts +2 -0
  246. package/src/testing/testing-module.mts +231 -0
  247. package/src/tokens/endpoint-adapter.token.d.mts +4 -0
  248. package/src/tokens/endpoint-adapter.token.d.mts.map +1 -0
  249. package/src/tokens/execution-context.token.d.mts +5 -0
  250. package/src/tokens/execution-context.token.d.mts.map +1 -0
  251. package/src/tokens/http-adapter.token.d.mts +4 -0
  252. package/src/tokens/http-adapter.token.d.mts.map +1 -0
  253. package/src/tokens/index.d.mts +9 -0
  254. package/src/tokens/index.d.mts.map +1 -0
  255. package/src/tokens/index.mts +1 -0
  256. package/src/tokens/multipart-adapter.token.d.mts +4 -0
  257. package/src/tokens/multipart-adapter.token.d.mts.map +1 -0
  258. package/src/tokens/reply.token.d.mts +3 -0
  259. package/src/tokens/reply.token.d.mts.map +1 -0
  260. package/src/tokens/request.token.d.mts +3 -0
  261. package/src/tokens/request.token.d.mts.map +1 -0
  262. package/src/tokens/stream-adapter.token.d.mts +4 -0
  263. package/src/tokens/stream-adapter.token.d.mts.map +1 -0
  264. package/src/tokens/xml-stream-adapter.token.d.mts +4 -0
  265. package/src/tokens/xml-stream-adapter.token.d.mts.map +1 -0
  266. package/src/tokens/xml-stream-adapter.token.mts +8 -0
  267. package/tsconfig.lib.json +1 -1
  268. package/tsconfig.spec.json +3 -0
  269. package/tsdown.config.mts +35 -0
  270. package/vitest.config.mts +6 -0
  271. package/lib/_tsup-dts-rollup.d.mts +0 -1352
  272. package/lib/_tsup-dts-rollup.d.ts +0 -1352
  273. package/lib/index.d.ts +0 -188
  274. package/lib/index.js +0 -1519
  275. package/lib/index.js.map +0 -1
  276. package/lib/index.mjs.map +0 -1
  277. package/tsup.config.mts +0 -13
@@ -0,0 +1,156 @@
1
+ import { K as NaviosModule, i as NaviosApplicationOptions, n as NaviosApplication } from "../index-D657ijFO.mjs";
2
+ import { ClassType, ClassTypeWithInstance, InjectionToken } from "@navios/di";
3
+ import { TestContainer } from "@navios/di/testing";
4
+ export * from "@navios/di/testing";
5
+
6
+ //#region src/testing/testing-module.d.mts
7
+
8
+ /**
9
+ * Configuration for overriding a provider in the testing module.
10
+ *
11
+ * @typeParam T - The type of the provider being overridden
12
+ */
13
+ interface TestingModuleOverride<T = any> {
14
+ /**
15
+ * The injection token or class to override.
16
+ */
17
+ token: ClassType | InjectionToken<T, any>;
18
+ /**
19
+ * Value to use instead of the original provider.
20
+ */
21
+ useValue?: T;
22
+ /**
23
+ * Class to use instead of the original provider.
24
+ */
25
+ useClass?: ClassType;
26
+ }
27
+ /**
28
+ * Options for creating a testing module.
29
+ *
30
+ * Extends NaviosApplicationOptions but excludes the container option,
31
+ * as TestingModule manages its own TestContainer.
32
+ */
33
+ interface TestingModuleOptions extends Omit<NaviosApplicationOptions, 'container'> {
34
+ /**
35
+ * Initial provider overrides to apply when creating the testing module.
36
+ *
37
+ * You can also use `overrideProvider()` method for a fluent API.
38
+ */
39
+ overrides?: TestingModuleOverride[];
40
+ }
41
+ /**
42
+ * A testing-optimized wrapper around NaviosApplication.
43
+ * Provides utilities for setting up test environments with mock dependencies.
44
+ */
45
+ declare class TestingModule {
46
+ private readonly appModule;
47
+ private readonly container;
48
+ private readonly options;
49
+ private app;
50
+ constructor(appModule: ClassTypeWithInstance<NaviosModule>, container: TestContainer, options: TestingModuleOptions);
51
+ /**
52
+ * Compiles the testing module and returns the NaviosApplication.
53
+ * Call this after setting up all overrides.
54
+ */
55
+ compile(): Promise<NaviosApplication>;
56
+ /**
57
+ * Initializes the application (loads modules, sets up HTTP if configured).
58
+ * This is equivalent to calling app.init() on the compiled application.
59
+ */
60
+ init(): Promise<NaviosApplication>;
61
+ /**
62
+ * Gets the underlying TestContainer for direct manipulation.
63
+ */
64
+ getContainer(): TestContainer;
65
+ /**
66
+ * Gets the compiled application. Throws if not yet compiled.
67
+ */
68
+ getApplication(): NaviosApplication;
69
+ /**
70
+ * Override a provider with a mock value.
71
+ */
72
+ overrideProvider<T>(token: ClassType | InjectionToken<T, any>): {
73
+ useValue: (value: T) => TestingModule;
74
+ useClass: (target: ClassType) => TestingModule;
75
+ };
76
+ /**
77
+ * Gets an instance from the container.
78
+ */
79
+ get<T>(token: ClassTypeWithInstance<T> | InjectionToken<T, any>): Promise<T>;
80
+ /**
81
+ * Disposes the testing module and cleans up resources.
82
+ */
83
+ close(): Promise<void>;
84
+ }
85
+ /**
86
+ * Fluent builder interface for TestingModule.
87
+ *
88
+ * Provides a chainable API for configuring and using a testing module.
89
+ */
90
+ interface TestingModuleBuilder {
91
+ /**
92
+ * Override a provider with a mock value or class.
93
+ *
94
+ * @param token - The injection token or class to override
95
+ * @returns An object with `useValue` and `useClass` methods for chaining
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * const testingModule = await createTestingModule(AppModule)
100
+ * .overrideProvider(DatabaseService)
101
+ * .useValue(mockDatabaseService)
102
+ * .compile()
103
+ * ```
104
+ */
105
+ overrideProvider<T>(token: ClassType | InjectionToken<T, any>): {
106
+ useValue: (value: T) => TestingModuleBuilder;
107
+ useClass: (target: ClassType) => TestingModuleBuilder;
108
+ };
109
+ /**
110
+ * Compiles the testing module and returns the NaviosApplication.
111
+ *
112
+ * This creates the application instance but does not initialize it.
113
+ * Call `init()` if you need the application to be fully initialized.
114
+ */
115
+ compile(): Promise<NaviosApplication>;
116
+ /**
117
+ * Initializes the application (loads modules, sets up HTTP if configured).
118
+ *
119
+ * This is equivalent to calling `compile()` followed by `app.init()`.
120
+ */
121
+ init(): Promise<NaviosApplication>;
122
+ /**
123
+ * Gets the underlying TestContainer for direct manipulation.
124
+ */
125
+ getContainer(): TestContainer;
126
+ /**
127
+ * Gets an instance from the container.
128
+ *
129
+ * @typeParam T - The type of the instance to retrieve
130
+ * @param token - The injection token or class
131
+ * @returns The resolved instance
132
+ */
133
+ get<T>(token: ClassTypeWithInstance<T> | InjectionToken<T, any>): Promise<T>;
134
+ /**
135
+ * Disposes the testing module and cleans up resources.
136
+ */
137
+ close(): Promise<void>;
138
+ }
139
+ /**
140
+ * Creates a testing module for the given app module.
141
+ * This is the main entry point for setting up tests.
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * const testingModule = await createTestingModule(AppModule, {
146
+ * adapter: [],
147
+ * })
148
+ * .overrideProvider(DatabaseService)
149
+ * .useValue(mockDatabaseService)
150
+ * .compile()
151
+ * ```
152
+ */
153
+ declare function createTestingModule(appModule: ClassTypeWithInstance<NaviosModule>, options?: TestingModuleOptions): TestingModule;
154
+ //#endregion
155
+ export { TestingModule, TestingModuleBuilder, TestingModuleOptions, TestingModuleOverride, createTestingModule };
156
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/testing/testing-module.mts"],"sourcesContent":[],"mappings":";;;;;;;;;AAcA;;;AAIqB,UAJJ,qBAII,CAAA,IAAA,GAAA,CAAA,CAAA;EAIR;;;EAaI,KAAA,EAjBR,SAiBQ,GAjBI,cAkBnB,CAlBkC,CAkBlC,EAAA,GAAA,CAAA;EAAa;;;EAAD,QAAA,CAAA,EAdD,CAcC;EAaD;;;EAKmB,QAAA,CAAA,EA5BnB,SA4BmB;;;;;;;;AAkDH,UArEZ,oBAAA,SACP,IAoEmB,CApEd,wBAoEc,EAAA,WAAA,CAAA,CAAA;EAA2B;;;;;EAEnB,SAAA,CAAA,EAhEvB,qBAgEuB,EAAA;;;;;;AAiBqC,cA1E7D,aAAA,CA0E6D;EAOzD,iBAAA,SAAA;EAAO,iBAAA,SAAA;EAaP,iBAAA,OAAoB;EAeR,QAAA,GAAA;EAA2B,WAAA,CAAA,SAAA,EAzGxB,qBAyGwB,CAzGF,YAyGE,CAAA,EAAA,SAAA,EAxGxB,aAwGwB,EAAA,OAAA,EAvG1B,oBAuG0B;EAAf;;;;EAEJ,OAAA,CAAA,CAAA,EAlGlB,OAkGkB,CAlGV,iBAkGU,CAAA;EAShB;;;;EAYH,IAAA,CAAA,CAAA,EA3GF,OA2GE,CA3GM,iBA2GN,CAAA;EASoB;;;EAAK,YAAA,CAAA,CAAA,EAzGzB,aAyGyB;EAAiC;;;EAK1D,cAAA,CAAA,CAAA,EAvGE,iBAuGF;EAiBF;;;EAEL,gBAAA,CAAA,CAAA,CAAA,CAAA,KAAA,EA9GkB,SA8GlB,GA9G8B,cA8G9B,CA9G6C,CA8G7C,EAAA,GAAA,CAAA,CAAA,EAAA;IACR,QAAA,EAAA,CAAA,KAAA,EA9GmB,CA8GnB,EAAA,GA9GyB,aA8GzB;IAAa,QAAA,EAAA,CAAA,MAAA,EA7GO,SA6GP,EAAA,GA7GqB,aA6GrB;;;;;gBA5FM,sBAAsB,KAAK,eAAe,UAAU,QAAQ;;;;WAOjE;;;;;;;UAaA,oBAAA;;;;;;;;;;;;;;;6BAeY,YAAY,eAAe;sBAClC,MAAM;uBACL,cAAc;;;;;;;;aASxB,QAAQ;;;;;;UAOX,QAAQ;;;;kBAKA;;;;;;;;gBASF,sBAAsB,KAAK,eAAe,UAAU,QAAQ;;;;WAKjE;;;;;;;;;;;;;;;;iBAiBK,mBAAA,YACH,sBAAsB,yBACxB,uBACR"}
@@ -0,0 +1,100 @@
1
+ import { t as NaviosFactory } from "../src-DzPY5s6d.mjs";
2
+ import "../use-guards.decorator-kZ3lNK8v.mjs";
3
+ import { TestContainer } from "@navios/di/testing";
4
+
5
+ export * from "@navios/di/testing"
6
+
7
+ //#region src/testing/testing-module.mts
8
+ /**
9
+ * A testing-optimized wrapper around NaviosApplication.
10
+ * Provides utilities for setting up test environments with mock dependencies.
11
+ */ var TestingModule = class {
12
+ appModule;
13
+ container;
14
+ options;
15
+ app = null;
16
+ constructor(appModule, container, options) {
17
+ this.appModule = appModule;
18
+ this.container = container;
19
+ this.options = options;
20
+ }
21
+ /**
22
+ * Compiles the testing module and returns the NaviosApplication.
23
+ * Call this after setting up all overrides.
24
+ */ async compile() {
25
+ this.app = await NaviosFactory.create(this.appModule, {
26
+ ...this.options,
27
+ container: this.container
28
+ });
29
+ return this.app;
30
+ }
31
+ /**
32
+ * Initializes the application (loads modules, sets up HTTP if configured).
33
+ * This is equivalent to calling app.init() on the compiled application.
34
+ */ async init() {
35
+ if (!this.app) await this.compile();
36
+ await this.app.init();
37
+ return this.app;
38
+ }
39
+ /**
40
+ * Gets the underlying TestContainer for direct manipulation.
41
+ */ getContainer() {
42
+ return this.container;
43
+ }
44
+ /**
45
+ * Gets the compiled application. Throws if not yet compiled.
46
+ */ getApplication() {
47
+ if (!this.app) throw new Error("TestingModule not compiled. Call compile() or init() first.");
48
+ return this.app;
49
+ }
50
+ /**
51
+ * Override a provider with a mock value.
52
+ */ overrideProvider(token) {
53
+ return {
54
+ useValue: (value) => {
55
+ this.container.bind(token).toValue(value);
56
+ return this;
57
+ },
58
+ useClass: (target) => {
59
+ this.container.bind(token).toClass(target);
60
+ return this;
61
+ }
62
+ };
63
+ }
64
+ /**
65
+ * Gets an instance from the container.
66
+ */ async get(token) {
67
+ return this.container.get(token);
68
+ }
69
+ /**
70
+ * Disposes the testing module and cleans up resources.
71
+ */ async close() {
72
+ if (this.app) await this.app.close();
73
+ await this.container.dispose();
74
+ }
75
+ };
76
+ /**
77
+ * Creates a testing module for the given app module.
78
+ * This is the main entry point for setting up tests.
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * const testingModule = await createTestingModule(AppModule, {
83
+ * adapter: [],
84
+ * })
85
+ * .overrideProvider(DatabaseService)
86
+ * .useValue(mockDatabaseService)
87
+ * .compile()
88
+ * ```
89
+ */ function createTestingModule(appModule, options = { adapter: [] }) {
90
+ const container = new TestContainer();
91
+ if (options.overrides) {
92
+ for (const override of options.overrides) if (override.useValue !== void 0) container.bind(override.token).toValue(override.useValue);
93
+ else if (override.useClass) container.bind(override.token).toClass(override.useClass);
94
+ }
95
+ return new TestingModule(appModule, container, options);
96
+ }
97
+
98
+ //#endregion
99
+ export { TestingModule, createTestingModule };
100
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["TestContainer","NaviosFactory","TestingModule","app","appModule","container","options","compile","create","init","getContainer","getApplication","Error","overrideProvider","token","useValue","value","bind","toValue","useClass","target","toClass","get","close","dispose","createTestingModule","adapter","overrides","override","undefined"],"sources":["../../src/testing/testing-module.mts"],"sourcesContent":["import type { ClassType, ClassTypeWithInstance, InjectionToken } from '@navios/di'\nimport type { NaviosModule } from '../interfaces/index.mjs'\nimport type { NaviosApplicationOptions } from '../navios.application.mjs'\n\nimport { TestContainer } from '@navios/di/testing'\n\nimport { NaviosApplication } from '../navios.application.mjs'\nimport { NaviosFactory } from '../navios.factory.mjs'\n\n/**\n * Configuration for overriding a provider in the testing module.\n * \n * @typeParam T - The type of the provider being overridden\n */\nexport interface TestingModuleOverride<T = any> {\n /**\n * The injection token or class to override.\n */\n token: ClassType | InjectionToken<T, any>\n /**\n * Value to use instead of the original provider.\n */\n useValue?: T\n /**\n * Class to use instead of the original provider.\n */\n useClass?: ClassType\n}\n\n/**\n * Options for creating a testing module.\n * \n * Extends NaviosApplicationOptions but excludes the container option,\n * as TestingModule manages its own TestContainer.\n */\nexport interface TestingModuleOptions\n extends Omit<NaviosApplicationOptions, 'container'> {\n /**\n * Initial provider overrides to apply when creating the testing module.\n * \n * You can also use `overrideProvider()` method for a fluent API.\n */\n overrides?: TestingModuleOverride[]\n}\n\n/**\n * A testing-optimized wrapper around NaviosApplication.\n * Provides utilities for setting up test environments with mock dependencies.\n */\nexport class TestingModule {\n private app: NaviosApplication | null = null\n\n constructor(\n private readonly appModule: ClassTypeWithInstance<NaviosModule>,\n private readonly container: TestContainer,\n private readonly options: TestingModuleOptions,\n ) {}\n\n /**\n * Compiles the testing module and returns the NaviosApplication.\n * Call this after setting up all overrides.\n */\n async compile(): Promise<NaviosApplication> {\n this.app = await NaviosFactory.create(this.appModule, {\n ...this.options,\n container: this.container,\n })\n return this.app\n }\n\n /**\n * Initializes the application (loads modules, sets up HTTP if configured).\n * This is equivalent to calling app.init() on the compiled application.\n */\n async init(): Promise<NaviosApplication> {\n if (!this.app) {\n await this.compile()\n }\n await this.app!.init()\n return this.app!\n }\n\n /**\n * Gets the underlying TestContainer for direct manipulation.\n */\n getContainer(): TestContainer {\n return this.container\n }\n\n /**\n * Gets the compiled application. Throws if not yet compiled.\n */\n getApplication(): NaviosApplication {\n if (!this.app) {\n throw new Error(\n 'TestingModule not compiled. Call compile() or init() first.',\n )\n }\n return this.app\n }\n\n /**\n * Override a provider with a mock value.\n */\n overrideProvider<T>(token: ClassType | InjectionToken<T, any>): {\n useValue: (value: T) => TestingModule\n useClass: (target: ClassType) => TestingModule\n } {\n return {\n useValue: (value: T) => {\n this.container.bind(token as any).toValue(value)\n return this\n },\n useClass: (target: ClassType) => {\n this.container.bind(token as any).toClass(target)\n return this\n },\n }\n }\n\n /**\n * Gets an instance from the container.\n */\n async get<T>(token: ClassTypeWithInstance<T> | InjectionToken<T, any>): Promise<T> {\n return this.container.get(token as any)\n }\n\n /**\n * Disposes the testing module and cleans up resources.\n */\n async close(): Promise<void> {\n if (this.app) {\n await this.app.close()\n }\n await this.container.dispose()\n }\n}\n\n/**\n * Fluent builder interface for TestingModule.\n * \n * Provides a chainable API for configuring and using a testing module.\n */\nexport interface TestingModuleBuilder {\n /**\n * Override a provider with a mock value or class.\n * \n * @param token - The injection token or class to override\n * @returns An object with `useValue` and `useClass` methods for chaining\n * \n * @example\n * ```typescript\n * const testingModule = await createTestingModule(AppModule)\n * .overrideProvider(DatabaseService)\n * .useValue(mockDatabaseService)\n * .compile()\n * ```\n */\n overrideProvider<T>(token: ClassType | InjectionToken<T, any>): {\n useValue: (value: T) => TestingModuleBuilder\n useClass: (target: ClassType) => TestingModuleBuilder\n }\n\n /**\n * Compiles the testing module and returns the NaviosApplication.\n * \n * This creates the application instance but does not initialize it.\n * Call `init()` if you need the application to be fully initialized.\n */\n compile(): Promise<NaviosApplication>\n\n /**\n * Initializes the application (loads modules, sets up HTTP if configured).\n * \n * This is equivalent to calling `compile()` followed by `app.init()`.\n */\n init(): Promise<NaviosApplication>\n\n /**\n * Gets the underlying TestContainer for direct manipulation.\n */\n getContainer(): TestContainer\n\n /**\n * Gets an instance from the container.\n * \n * @typeParam T - The type of the instance to retrieve\n * @param token - The injection token or class\n * @returns The resolved instance\n */\n get<T>(token: ClassTypeWithInstance<T> | InjectionToken<T, any>): Promise<T>\n\n /**\n * Disposes the testing module and cleans up resources.\n */\n close(): Promise<void>\n}\n\n/**\n * Creates a testing module for the given app module.\n * This is the main entry point for setting up tests.\n *\n * @example\n * ```typescript\n * const testingModule = await createTestingModule(AppModule, {\n * adapter: [],\n * })\n * .overrideProvider(DatabaseService)\n * .useValue(mockDatabaseService)\n * .compile()\n * ```\n */\nexport function createTestingModule(\n appModule: ClassTypeWithInstance<NaviosModule>,\n options: TestingModuleOptions = { adapter: [] },\n): TestingModule {\n const container = new TestContainer()\n\n // Apply initial overrides if provided\n if (options.overrides) {\n for (const override of options.overrides) {\n if (override.useValue !== undefined) {\n container.bind(override.token as any).toValue(override.useValue)\n } else if (override.useClass) {\n container.bind(override.token as any).toClass(override.useClass)\n }\n }\n }\n\n return new TestingModule(appModule, container, options)\n}\n"],"mappings":";;;;;;;;;;GAiDA,IAAaE,gBAAb,MAAaA;;;;CACHC,MAAgC;CAExC,YACE,WACA,WACA,SACA;OAHiBC,YAAAA;OACAC,YAAAA;OACAC,UAAAA;;;;;IAOnB,MAAMC,UAAsC;AAC1C,OAAKJ,MAAM,MAAMF,cAAcO,OAAO,KAAKJ,WAAW;GACpD,GAAG,KAAKE;GACRD,WAAW,KAAKA;GAClB,CAAA;AACA,SAAO,KAAKF;;;;;IAOd,MAAMM,OAAmC;AACvC,MAAI,CAAC,KAAKN,IACR,OAAM,KAAKI,SAAO;AAEpB,QAAM,KAAKJ,IAAKM,MAAI;AACpB,SAAO,KAAKN;;;;IAMdO,eAA8B;AAC5B,SAAO,KAAKL;;;;IAMdM,iBAAoC;AAClC,MAAI,CAAC,KAAKR,IACR,OAAM,IAAIS,MACR,8DAAA;AAGJ,SAAO,KAAKT;;;;IAMdU,iBAAoBC,OAGlB;AACA,SAAO;GACLC,WAAWC,UAAAA;AACT,SAAKX,UAAUY,KAAKH,MAAAA,CAAcI,QAAQF,MAAAA;AAC1C,WAAO;;GAETG,WAAWC,WAAAA;AACT,SAAKf,UAAUY,KAAKH,MAAAA,CAAcO,QAAQD,OAAAA;AAC1C,WAAO;;GAEX;;;;IAMF,MAAME,IAAOR,OAAsE;AACjF,SAAO,KAAKT,UAAUiB,IAAIR,MAAAA;;;;IAM5B,MAAMS,QAAuB;AAC3B,MAAI,KAAKpB,IACP,OAAM,KAAKA,IAAIoB,OAAK;AAEtB,QAAM,KAAKlB,UAAUmB,SAAO;;;;;;;;;;;;;;;;GA8EhC,SAAgBC,oBACdrB,WACAE,UAAgC,EAAEoB,SAAS,EAAE,EAAE,EAAA;CAE/C,MAAMrB,YAAY,IAAIL,eAAAA;AAGtB,KAAIM,QAAQqB,WACV;OAAK,MAAMC,YAAYtB,QAAQqB,UAC7B,KAAIC,SAASb,aAAac,OACxBxB,WAAUY,KAAKW,SAASd,MAAK,CAASI,QAAQU,SAASb,SAAQ;WACtDa,SAAST,SAClBd,WAAUY,KAAKW,SAASd,MAAK,CAASO,QAAQO,SAAST,SAAQ;;AAKrE,QAAO,IAAIjB,cAAcE,WAAWC,WAAWC,QAAAA"}