@navios/core 1.1.0 → 2.0.0-alpha.1

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 (237) hide show
  1. package/CHANGELOG.md +85 -13
  2. package/README.md +69 -220
  3. package/lib/async-context-BAdt7bno.d.mts +239 -0
  4. package/lib/async-context-BAdt7bno.d.mts.map +1 -0
  5. package/lib/async-context-RsWmy2Hi.d.cts +239 -0
  6. package/lib/async-context-RsWmy2Hi.d.cts.map +1 -0
  7. package/lib/attribute-factory-BW1kgBqf.d.mts +70 -0
  8. package/lib/attribute-factory-BW1kgBqf.d.mts.map +1 -0
  9. package/lib/attribute-factory-DqN4x5XM.d.cts +70 -0
  10. package/lib/attribute-factory-DqN4x5XM.d.cts.map +1 -0
  11. package/lib/attribute-value-BNiJjxl1.mjs +225 -0
  12. package/lib/attribute-value-BNiJjxl1.mjs.map +1 -0
  13. package/lib/attribute-value-Cux5HhOL.cjs +314 -0
  14. package/lib/attribute-value-Cux5HhOL.cjs.map +1 -0
  15. package/lib/basic-execution-context-5uq2DvEA.cjs +318 -0
  16. package/lib/basic-execution-context-5uq2DvEA.cjs.map +1 -0
  17. package/lib/basic-execution-context-u1VktGoM.mjs +277 -0
  18. package/lib/basic-execution-context-u1VktGoM.mjs.map +1 -0
  19. package/lib/execution-context-BVSmLkYp.d.cts +71 -0
  20. package/lib/execution-context-BVSmLkYp.d.cts.map +1 -0
  21. package/lib/execution-context-C5F9rojO.d.mts +71 -0
  22. package/lib/execution-context-C5F9rojO.d.mts.map +1 -0
  23. package/lib/execution-context-token--cKS4cJv.cjs +270 -0
  24. package/lib/execution-context-token--cKS4cJv.cjs.map +1 -0
  25. package/lib/execution-context-token-Cb3M3Ao0.mjs +223 -0
  26. package/lib/execution-context-token-Cb3M3Ao0.mjs.map +1 -0
  27. package/lib/index.cjs +1672 -4426
  28. package/lib/index.cjs.map +1 -1
  29. package/lib/index.d.cts +842 -3
  30. package/lib/index.d.cts.map +1 -0
  31. package/lib/index.d.mts +842 -3
  32. package/lib/index.d.mts.map +1 -0
  33. package/lib/index.mjs +1559 -4221
  34. package/lib/index.mjs.map +1 -1
  35. package/lib/legacy-compat/index.cjs +72 -371
  36. package/lib/legacy-compat/index.cjs.map +1 -1
  37. package/lib/legacy-compat/index.d.cts +42 -382
  38. package/lib/legacy-compat/index.d.cts.map +1 -1
  39. package/lib/legacy-compat/index.d.mts +41 -382
  40. package/lib/legacy-compat/index.d.mts.map +1 -1
  41. package/lib/legacy-compat/index.mjs +51 -345
  42. package/lib/legacy-compat/index.mjs.map +1 -1
  43. package/lib/module-Bz83ZnJ5.cjs +173 -0
  44. package/lib/module-Bz83ZnJ5.cjs.map +1 -0
  45. package/lib/module-options-CSqQUSTm.d.mts +51 -0
  46. package/lib/module-options-CSqQUSTm.d.mts.map +1 -0
  47. package/lib/module-options-DSRBri4J.d.cts +51 -0
  48. package/lib/module-options-DSRBri4J.d.cts.map +1 -0
  49. package/lib/module-zPXwR2qp.mjs +138 -0
  50. package/lib/module-zPXwR2qp.mjs.map +1 -0
  51. package/lib/settled-within-B6gpu2XW.cjs +32 -0
  52. package/lib/settled-within-B6gpu2XW.cjs.map +1 -0
  53. package/lib/settled-within-Bc2pj8WB.mjs +21 -0
  54. package/lib/settled-within-Bc2pj8WB.mjs.map +1 -0
  55. package/lib/testing/index.cjs +74 -414
  56. package/lib/testing/index.cjs.map +1 -1
  57. package/lib/testing/index.d.cts +25 -385
  58. package/lib/testing/index.d.cts.map +1 -1
  59. package/lib/testing/index.d.mts +24 -385
  60. package/lib/testing/index.d.mts.map +1 -1
  61. package/lib/testing/index.mjs +72 -408
  62. package/lib/testing/index.mjs.map +1 -1
  63. package/lib/transport.cjs +36 -0
  64. package/lib/transport.d.cts +254 -0
  65. package/lib/transport.d.cts.map +1 -0
  66. package/lib/transport.d.mts +254 -0
  67. package/lib/transport.d.mts.map +1 -0
  68. package/lib/transport.mjs +6 -0
  69. package/package.json +37 -17
  70. package/docs/README.md +0 -316
  71. package/docs/adapters.md +0 -308
  72. package/docs/application-setup.md +0 -524
  73. package/docs/attributes.md +0 -689
  74. package/docs/controllers.md +0 -373
  75. package/docs/endpoints.md +0 -444
  76. package/docs/exceptions.md +0 -352
  77. package/docs/guards.md +0 -550
  78. package/docs/legacy-compat.md +0 -356
  79. package/docs/modules.md +0 -377
  80. package/docs/quick-start.md +0 -290
  81. package/docs/services.md +0 -427
  82. package/docs/testing.md +0 -827
  83. package/lib/index-3LcTrbxz.d.mts +0 -3804
  84. package/lib/index-3LcTrbxz.d.mts.map +0 -1
  85. package/lib/index-B14SekVb.d.cts +0 -3804
  86. package/lib/index-B14SekVb.d.cts.map +0 -1
  87. package/lib/navios.factory-CUrO_p6K.cjs +0 -4538
  88. package/lib/navios.factory-CUrO_p6K.cjs.map +0 -1
  89. package/lib/navios.factory-DjUOOVVL.mjs +0 -4151
  90. package/lib/navios.factory-DjUOOVVL.mjs.map +0 -1
  91. package/lib/tokens-BEuBMGGX.cjs +0 -193
  92. package/lib/tokens-BEuBMGGX.cjs.map +0 -1
  93. package/lib/tokens-COyNGV1I.mjs +0 -97
  94. package/lib/tokens-COyNGV1I.mjs.map +0 -1
  95. package/lib/use-guards.decorator-DLmRl2CV.mjs +0 -336
  96. package/lib/use-guards.decorator-DLmRl2CV.mjs.map +0 -1
  97. package/lib/use-guards.decorator-DhumFTk3.cjs +0 -444
  98. package/lib/use-guards.decorator-DhumFTk3.cjs.map +0 -1
  99. package/project.json +0 -66
  100. package/src/__tests__/attribute.factory.spec.mts +0 -300
  101. package/src/__tests__/config.service.spec.mts +0 -43
  102. package/src/__tests__/console-logger.service.spec.mts +0 -312
  103. package/src/__tests__/controller-resolver.spec.mts +0 -229
  104. package/src/__tests__/controller.spec.mts +0 -58
  105. package/src/__tests__/guard-runner.service.spec.mts +0 -399
  106. package/src/__tests__/logger.service.spec.mts +0 -147
  107. package/src/__tests__/responders.spec.mts +0 -340
  108. package/src/__tests__/testing-module.spec.mts +0 -459
  109. package/src/__tests__/unit-testing-module.spec.mts +0 -424
  110. package/src/attribute.factory.mts +0 -325
  111. package/src/config/config-service.interface.mts +0 -47
  112. package/src/config/config.provider.mts +0 -69
  113. package/src/config/config.service.mts +0 -176
  114. package/src/config/index.mts +0 -5
  115. package/src/config/types.mts +0 -58
  116. package/src/config/utils/helpers.mts +0 -23
  117. package/src/config/utils/index.mts +0 -1
  118. package/src/decorators/controller.decorator.mts +0 -81
  119. package/src/decorators/endpoint.decorator.mts +0 -181
  120. package/src/decorators/header.decorator.mts +0 -38
  121. package/src/decorators/http-code.decorator.mts +0 -38
  122. package/src/decorators/index.mts +0 -8
  123. package/src/decorators/module.decorator.mts +0 -106
  124. package/src/decorators/multipart.decorator.mts +0 -169
  125. package/src/decorators/stream.decorator.mts +0 -155
  126. package/src/decorators/use-guards.decorator.mts +0 -73
  127. package/src/exceptions/bad-request.exception.mts +0 -28
  128. package/src/exceptions/conflict.exception.mts +0 -31
  129. package/src/exceptions/forbidden.exception.mts +0 -30
  130. package/src/exceptions/http.exception.mts +0 -33
  131. package/src/exceptions/index.mts +0 -7
  132. package/src/exceptions/internal-server-error.exception.mts +0 -33
  133. package/src/exceptions/not-found.exception.mts +0 -33
  134. package/src/exceptions/unauthorized.exception.mts +0 -30
  135. package/src/factories/adapter.factory.mts +0 -20
  136. package/src/factories/endpoint-adapter.factory.mts +0 -21
  137. package/src/factories/http-adapter.factory.mts +0 -20
  138. package/src/factories/index.mts +0 -8
  139. package/src/factories/multipart-adapter.factory.mts +0 -21
  140. package/src/factories/reply.factory.mts +0 -21
  141. package/src/factories/request.factory.mts +0 -21
  142. package/src/factories/stream-adapter.factory.mts +0 -20
  143. package/src/factories/xml-stream-adapter.factory.mts +0 -20
  144. package/src/index.mts +0 -16
  145. package/src/interfaces/abstract-adapter.interface.mts +0 -32
  146. package/src/interfaces/abstract-execution-context.inteface.mts +0 -48
  147. package/src/interfaces/abstract-http-adapter.interface.mts +0 -79
  148. package/src/interfaces/abstract-http-cors-options.interface.mts +0 -59
  149. package/src/interfaces/abstract-http-handler-adapter.interface.mts +0 -127
  150. package/src/interfaces/abstract-http-listen-options.interface.mts +0 -4
  151. package/src/interfaces/adapter-environment.interface.mts +0 -74
  152. package/src/interfaces/can-activate.mts +0 -38
  153. package/src/interfaces/http-header.mts +0 -18
  154. package/src/interfaces/index.mts +0 -14
  155. package/src/interfaces/navios-module.mts +0 -28
  156. package/src/interfaces/plugin-context.mts +0 -104
  157. package/src/interfaces/plugin-stage.mts +0 -62
  158. package/src/interfaces/plugin.interface.mts +0 -119
  159. package/src/interfaces/staged-plugin.interface.mts +0 -209
  160. package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +0 -521
  161. package/src/legacy-compat/__type-tests__/tsconfig.json +0 -15
  162. package/src/legacy-compat/attribute.factory.mts +0 -351
  163. package/src/legacy-compat/decorators/controller.decorator.mts +0 -31
  164. package/src/legacy-compat/decorators/endpoint.decorator.mts +0 -73
  165. package/src/legacy-compat/decorators/header.decorator.mts +0 -43
  166. package/src/legacy-compat/decorators/http-code.decorator.mts +0 -39
  167. package/src/legacy-compat/decorators/index.mts +0 -11
  168. package/src/legacy-compat/decorators/module.decorator.mts +0 -37
  169. package/src/legacy-compat/decorators/multipart.decorator.mts +0 -72
  170. package/src/legacy-compat/decorators/stream.decorator.mts +0 -89
  171. package/src/legacy-compat/decorators/use-guards.decorator.mts +0 -80
  172. package/src/legacy-compat/index.mts +0 -57
  173. package/src/logger/README.md +0 -3
  174. package/src/logger/console-logger.service.mts +0 -714
  175. package/src/logger/index.mts +0 -6
  176. package/src/logger/log-levels.mts +0 -21
  177. package/src/logger/logger-service.interface.mts +0 -42
  178. package/src/logger/logger.service.mts +0 -113
  179. package/src/logger/logger.tokens.mts +0 -44
  180. package/src/logger/utils/cli-colors.util.mts +0 -17
  181. package/src/logger/utils/filter-log-levelts.util.mts +0 -29
  182. package/src/logger/utils/index.mts +0 -5
  183. package/src/logger/utils/is-log-level-enabled.mts +0 -33
  184. package/src/logger/utils/is-log-level.util.mts +0 -10
  185. package/src/logger/utils/shared.utils.mts +0 -51
  186. package/src/metadata/controller.metadata.mts +0 -79
  187. package/src/metadata/handler.metadata.mts +0 -80
  188. package/src/metadata/index.mts +0 -4
  189. package/src/metadata/module.metadata.mts +0 -116
  190. package/src/metadata/navios-managed.metadata.mts +0 -42
  191. package/src/navios.application.mts +0 -678
  192. package/src/navios.environment.mts +0 -42
  193. package/src/navios.factory.mts +0 -158
  194. package/src/responders/enums/framework-error.enum.mts +0 -38
  195. package/src/responders/enums/index.mts +0 -1
  196. package/src/responders/index.mts +0 -4
  197. package/src/responders/interfaces/error-responder.interface.mts +0 -42
  198. package/src/responders/interfaces/error-response.interface.mts +0 -22
  199. package/src/responders/interfaces/index.mts +0 -3
  200. package/src/responders/interfaces/problem-details.interface.mts +0 -34
  201. package/src/responders/services/error-response-producer.service.mts +0 -143
  202. package/src/responders/services/forbidden-responder.service.mts +0 -77
  203. package/src/responders/services/index.mts +0 -5
  204. package/src/responders/services/internal-server-error-responder.service.mts +0 -57
  205. package/src/responders/services/not-found-responder.service.mts +0 -76
  206. package/src/responders/services/validation-error-responder.service.mts +0 -78
  207. package/src/responders/tokens/index.mts +0 -1
  208. package/src/responders/tokens/responder.tokens.mts +0 -84
  209. package/src/services/abstract-handler-adapter.service.mts +0 -366
  210. package/src/services/guard-runner.service.mts +0 -152
  211. package/src/services/index.mts +0 -4
  212. package/src/services/instance-resolver.service.mts +0 -177
  213. package/src/services/module-loader.service.mts +0 -255
  214. package/src/stores/index.mts +0 -1
  215. package/src/stores/request-id.store.mts +0 -85
  216. package/src/testing/index.mts +0 -3
  217. package/src/testing/testing-module.mts +0 -393
  218. package/src/testing/unit-testing-module.mts +0 -298
  219. package/src/tokens/adapter.token.mts +0 -6
  220. package/src/tokens/endpoint-adapter.token.mts +0 -8
  221. package/src/tokens/execution-context.token.mts +0 -9
  222. package/src/tokens/http-adapter.token.mts +0 -8
  223. package/src/tokens/index.mts +0 -10
  224. package/src/tokens/multipart-adapter.token.mts +0 -8
  225. package/src/tokens/navios-options.token.mts +0 -6
  226. package/src/tokens/reply.token.mts +0 -3
  227. package/src/tokens/request.token.mts +0 -3
  228. package/src/tokens/stream-adapter.token.mts +0 -8
  229. package/src/tokens/xml-stream-adapter.token.mts +0 -8
  230. package/src/utils/adapter-supports.util.mts +0 -47
  231. package/src/utils/define-plugin.mts +0 -251
  232. package/src/utils/index.mts +0 -2
  233. package/tsconfig.json +0 -21
  234. package/tsconfig.lib.json +0 -8
  235. package/tsconfig.spec.json +0 -15
  236. package/tsdown.config.mts +0 -35
  237. package/vitest.config.mts +0 -15
@@ -1,392 +1,32 @@
1
- import { X as NaviosApplication, Z as NaviosApplicationOptions, rn as NaviosModule } from "../index-B14SekVb.cjs";
2
- import { ClassType, ClassTypeWithInstance, InjectionToken, ScopedContainer } from "@navios/di";
3
- import * as _navios_di_testing0 from "@navios/di/testing";
4
- import { MethodCallRecord, MockServiceStats, ProviderConfig, TestContainer, UnitTestContainer } from "@navios/di/testing";
5
- export * from "@navios/di/testing";
6
-
7
- //#region src/testing/testing-module.d.mts
8
-
9
- /**
10
- * Configuration for overriding a provider in the testing module.
11
- *
12
- * @typeParam T - The type of the provider being overridden
13
- */
14
- interface TestingModuleOverride<T = any> {
15
- /**
16
- * The injection token or class to override.
17
- */
18
- token: ClassType | InjectionToken<T, any>;
19
- /**
20
- * Value to use instead of the original provider.
21
- */
22
- useValue?: T;
23
- /**
24
- * Class to use instead of the original provider.
25
- */
26
- useClass?: ClassType;
1
+ import "../execution-context-BVSmLkYp.cjs";
2
+ import { i as Transport, m as createContextHost, n as enableAsyncContext, o as TransportFactory, p as ContextHost } from "../async-context-RsWmy2Hi.cjs";
3
+ import { ClassType } from "@navios/di";
4
+ interface FakeTransportOptions {
5
+ /** The `kind` of the contexts this transport creates. */
6
+ kind: string;
7
+ /** The `@Module` option this transport reads its handler classes from. */
8
+ entry: string;
9
+ /** Receives `<kind>:create`, `:setup`, `:start` and `:stop`. */
10
+ log: string[];
11
+ failSetup?: boolean;
12
+ failStart?: boolean;
13
+ failStop?: boolean;
27
14
  }
28
- /**
29
- * Options for creating a testing module.
30
- *
31
- * Extends NaviosApplicationOptions but excludes the container option,
32
- * as TestingModule manages its own TestContainer.
33
- */
34
- interface TestingModuleOptions extends Omit<NaviosApplicationOptions, 'container'> {
35
- /**
36
- * Initial provider overrides to apply when creating the testing module.
37
- *
38
- * You can also use `overrideProvider()` method for a fluent API.
39
- */
40
- overrides?: TestingModuleOverride[];
15
+ interface FakeTransport extends Transport {
16
+ /** The handler classes found in the graph, in graph order. */
17
+ readonly handlers: ClassType[];
41
18
  /**
42
- * Container to use for the testing module.
43
- * If not provided, a new TestContainer will be created.
19
+ * Runs what applies to a handler class, as a transport runs it for a handler
20
+ * that does nothing: the application's interceptors, the guards, the
21
+ * interceptors of the module and the class. Resolves to whether every guard
22
+ * allowed it.
44
23
  */
45
- container?: TestContainer;
24
+ run(handler: ClassType): Promise<boolean>;
46
25
  }
47
26
  /**
48
- * A testing-optimized wrapper around NaviosApplication.
49
- * Provides utilities for setting up test environments with mock dependencies.
50
- *
51
- * When `init()` is called, a request scope is automatically started.
52
- * This means `get()` calls will resolve request-scoped services correctly,
53
- * simulating a real HTTP request context.
54
- *
55
- * @example
56
- * ```typescript
57
- * const module = await TestingModule.create(AppModule)
58
- * .overrideProvider(DatabaseService)
59
- * .useValue(mockDatabase)
60
- * .init()
61
- *
62
- * const userService = await module.get(UserService)
63
- * // ... run tests ...
64
- *
65
- * await module.close()
66
- * ```
67
- */
68
- declare class TestingModule {
69
- private readonly appModule;
70
- private readonly container;
71
- private readonly options;
72
- private app;
73
- private scopedContainer;
74
- private requestId;
75
- private constructor();
76
- /**
77
- * Creates a new TestingModule for the given app module.
78
- * This is the main entry point for setting up integration tests.
79
- *
80
- * @example
81
- * ```typescript
82
- * const module = await TestingModule.create(AppModule)
83
- * .overrideProvider(DatabaseService)
84
- * .useValue(mockDatabase)
85
- * .init()
86
- * ```
87
- */
88
- static create(appModule: ClassTypeWithInstance<NaviosModule>, options?: TestingModuleOptions): TestingModule;
89
- /**
90
- * Compiles the testing module without initializing it.
91
- * Call this if you need to access the app before initialization.
92
- *
93
- * @returns this for chaining
94
- */
95
- compile(): Promise<this>;
96
- /**
97
- * Initializes the application and starts a request scope.
98
- *
99
- * This is equivalent to calling `compile()` followed by `app.init()`,
100
- * plus starting a request context for proper request-scoped service resolution.
101
- *
102
- * @returns this for chaining
103
- */
104
- init(): Promise<this>;
105
- /**
106
- * Gets the compiled application.
107
- *
108
- * @throws Error if the module has not been compiled yet
109
- */
110
- getApp(): NaviosApplication;
111
- /**
112
- * Gets the underlying TestContainer for direct manipulation.
113
- */
114
- getContainer(): TestContainer;
115
- /**
116
- * Gets the scoped container for the current test request.
117
- * Only available after calling `init()`.
118
- *
119
- * @throws Error if init() has not been called
120
- */
121
- getScopedContainer(): ScopedContainer;
122
- /**
123
- * Override a provider with a mock value or class.
124
- * Must be called before `compile()` or `init()`.
125
- */
126
- overrideProvider<T>(token: ClassType | InjectionToken<T, any>): {
127
- useValue: (value: T) => TestingModule;
128
- useClass: (target: ClassType) => TestingModule;
129
- };
130
- /**
131
- * Gets an instance from the container.
132
- *
133
- * If `init()` has been called, this uses the scoped container
134
- * which properly resolves request-scoped services.
135
- *
136
- * If only `compile()` was called, this uses the root container
137
- * and request-scoped services will throw.
138
- */
139
- get<T>(token: ClassTypeWithInstance<T> | InjectionToken<T, any>): Promise<T>;
140
- /**
141
- * Disposes the testing module and cleans up all resources.
142
- *
143
- * This will:
144
- * 1. End the request scope (if started)
145
- * 2. Close the application (if initialized)
146
- * 3. Dispose the container
147
- */
148
- close(): Promise<void>;
149
- /**
150
- * Asserts that a service has been resolved at least once.
151
- */
152
- expectResolved(token: ClassType | InjectionToken<any, any>): void;
153
- /**
154
- * Asserts that a service has NOT been resolved.
155
- */
156
- expectNotResolved(token: ClassType | InjectionToken<any, any>): void;
157
- /**
158
- * Asserts that a service is registered as singleton scope.
159
- */
160
- expectSingleton(token: ClassType | InjectionToken<any, any>): void;
161
- /**
162
- * Asserts that a service is registered as transient scope.
163
- */
164
- expectTransient(token: ClassType | InjectionToken<any, any>): void;
165
- /**
166
- * Asserts that a service is registered as request scope.
167
- */
168
- expectRequestScoped(token: ClassType | InjectionToken<any, any>): void;
169
- /**
170
- * Asserts that a method was called on a service.
171
- * Note: You must use `recordMethodCall()` in your mocks for this to work.
172
- */
173
- expectCalled(token: ClassType | InjectionToken<any, any>, method: string): void;
174
- /**
175
- * Asserts that a method was called with specific arguments.
176
- * Note: You must use `recordMethodCall()` in your mocks for this to work.
177
- */
178
- expectCalledWith(token: ClassType | InjectionToken<any, any>, method: string, expectedArgs: unknown[]): void;
179
- /**
180
- * Asserts that a method was called a specific number of times.
181
- * Note: You must use `recordMethodCall()` in your mocks for this to work.
182
- */
183
- expectCallCount(token: ClassType | InjectionToken<any, any>, method: string, count: number): void;
184
- /**
185
- * Records a method call for tracking.
186
- * Call this from your mock implementations to enable call assertions.
187
- */
188
- recordMethodCall(token: ClassType | InjectionToken<any, any>, method: string, args: unknown[], result?: unknown, error?: Error): void;
189
- /**
190
- * Gets all recorded method calls for a service.
191
- */
192
- getMethodCalls(token: ClassType | InjectionToken<any, any>): _navios_di_testing0.MethodCallRecord[];
193
- /**
194
- * Gets the dependency graph for debugging or snapshot testing.
195
- */
196
- getDependencyGraph(): _navios_di_testing0.DependencyGraph;
197
- /**
198
- * Gets a simplified dependency graph showing only token relationships.
199
- */
200
- getSimplifiedDependencyGraph(): Record<string, string[]>;
201
- }
202
- /**
203
- * Creates a testing module for the given app module.
204
- *
205
- * @deprecated Use `TestingModule.create()` instead.
206
- *
207
- * @example
208
- * ```typescript
209
- * // Old way (deprecated)
210
- * const module = createTestingModule(AppModule)
211
- *
212
- * // New way
213
- * const module = TestingModule.create(AppModule)
214
- * ```
215
- */
216
- declare function createTestingModule(appModule: ClassTypeWithInstance<NaviosModule>, options?: TestingModuleOptions): TestingModule;
217
- //#endregion
218
- //#region src/testing/unit-testing-module.d.mts
219
- /**
220
- * Options for creating a UnitTestingModule.
27
+ * A transport for tests: it records its lifecycle and can run the guards and
28
+ * interceptors of a handler class with a context of its own kind.
221
29
  */
222
- interface UnitTestingModuleOptions {
223
- /**
224
- * List of providers to register. Only these services can be resolved.
225
- */
226
- providers: ProviderConfig[];
227
- /**
228
- * If true, unregistered dependencies will be auto-mocked instead of throwing.
229
- * Default: false (throws on unregistered dependencies)
230
- */
231
- allowUnregistered?: boolean;
232
- /**
233
- * Logger for debugging.
234
- */
235
- logger?: Console | null;
236
- /**
237
- * Container to use for the testing module.
238
- * If not provided, a new UnitTestContainer will be created.
239
- */
240
- container?: UnitTestContainer;
241
- }
242
- /**
243
- * A lightweight testing module for isolated unit tests.
244
- *
245
- * Unlike `TestingModule`, this does NOT load Navios modules or create an application.
246
- * It uses `UnitTestContainer` which:
247
- * - Only allows explicitly provided services
248
- * - Automatically tracks all method calls via proxies
249
- * - Can auto-mock unregistered dependencies
250
- *
251
- * This is ideal for testing services in isolation without the overhead
252
- * of full module loading.
253
- *
254
- * @example
255
- * ```typescript
256
- * const module = UnitTestingModule.create({
257
- * providers: [
258
- * { token: UserService, useClass: UserService },
259
- * { token: DatabaseService, useValue: mockDatabase },
260
- * ],
261
- * })
262
- *
263
- * const userService = await module.get(UserService)
264
- * await userService.findUser('123')
265
- *
266
- * // Method calls are automatically tracked
267
- * module.expectCalled(UserService, 'findUser')
268
- * module.expectCalledWith(UserService, 'findUser', ['123'])
269
- *
270
- * await module.close()
271
- * ```
272
- */
273
- declare class UnitTestingModule {
274
- private readonly container;
275
- private constructor();
276
- /**
277
- * Creates a new UnitTestingModule with the given providers.
278
- *
279
- * @example
280
- * ```typescript
281
- * const module = UnitTestingModule.create({
282
- * providers: [
283
- * { token: UserService, useClass: UserService },
284
- * { token: ConfigToken, useValue: { apiUrl: 'test' } },
285
- * ],
286
- * })
287
- * ```
288
- */
289
- static create(options: UnitTestingModuleOptions): UnitTestingModule;
290
- /**
291
- * Gets the underlying UnitTestContainer for direct manipulation.
292
- */
293
- getContainer(): UnitTestContainer;
294
- /**
295
- * Gets an instance from the container.
296
- *
297
- * All resolved instances are wrapped in tracking proxies,
298
- * so method calls are automatically recorded.
299
- *
300
- * @throws Error if the token is not in the providers list
301
- * and `allowUnregistered` is false
302
- */
303
- get<T>(token: ClassTypeWithInstance<T> | InjectionToken<T, any>): Promise<T>;
304
- /**
305
- * Disposes the module and cleans up all resources.
306
- */
307
- close(): Promise<void>;
308
- /**
309
- * Enables auto-mocking for unregistered dependencies.
310
- * Unregistered services will return a proxy that throws on method access.
311
- */
312
- enableAutoMocking(): this;
313
- /**
314
- * Disables auto-mocking (strict mode).
315
- * Unregistered dependencies will throw immediately on resolution.
316
- */
317
- disableAutoMocking(): this;
318
- /**
319
- * Asserts that a service has been resolved at least once.
320
- */
321
- expectResolved(token: ClassType | InjectionToken<any, any>): void;
322
- /**
323
- * Asserts that a service has NOT been resolved.
324
- */
325
- expectNotResolved(token: ClassType | InjectionToken<any, any>): void;
326
- /**
327
- * Asserts that a service was auto-mocked (not in providers list).
328
- */
329
- expectAutoMocked(token: ClassType | InjectionToken<any, any>): void;
330
- /**
331
- * Asserts that a service was NOT auto-mocked (is in providers list).
332
- */
333
- expectNotAutoMocked(token: ClassType | InjectionToken<any, any>): void;
334
- /**
335
- * Asserts that a method was called on a service.
336
- * Method calls are automatically tracked via proxy.
337
- */
338
- expectCalled(token: ClassType | InjectionToken<any, any>, method: string): void;
339
- /**
340
- * Asserts that a method was NOT called on a service.
341
- */
342
- expectNotCalled(token: ClassType | InjectionToken<any, any>, method: string): void;
343
- /**
344
- * Asserts that a method was called with specific arguments.
345
- */
346
- expectCalledWith(token: ClassType | InjectionToken<any, any>, method: string, expectedArgs: unknown[]): void;
347
- /**
348
- * Asserts that a method was called a specific number of times.
349
- */
350
- expectCallCount(token: ClassType | InjectionToken<any, any>, method: string, count: number): void;
351
- /**
352
- * Gets all recorded method calls for a service.
353
- */
354
- getMethodCalls(token: ClassType | InjectionToken<any, any>): MethodCallRecord[];
355
- /**
356
- * Gets statistics about a service (instance count, method calls, lifecycle events).
357
- */
358
- getServiceStats(token: ClassType | InjectionToken<any, any>): MockServiceStats;
359
- /**
360
- * Clears all recorded method calls.
361
- * Useful for resetting state between test assertions.
362
- */
363
- clearMethodCalls(): void;
364
- /**
365
- * Gets list of all registered provider token IDs.
366
- */
367
- getRegisteredTokenIds(): ReadonlySet<string>;
368
- /**
369
- * Gets list of all auto-mocked token IDs.
370
- */
371
- getAutoMockedTokenIds(): ReadonlySet<string>;
372
- /**
373
- * Asserts that a service's onServiceInit was called.
374
- */
375
- expectInitialized(token: ClassType | InjectionToken<any, any>): void;
376
- /**
377
- * Asserts that a service's onServiceDestroy was called.
378
- */
379
- expectDestroyed(token: ClassType | InjectionToken<any, any>): void;
380
- /**
381
- * Asserts that a service has NOT been destroyed.
382
- */
383
- expectNotDestroyed(token: ClassType | InjectionToken<any, any>): void;
384
- /**
385
- * Records a lifecycle event for tracking.
386
- * Call this from your mock implementations if needed.
387
- */
388
- recordLifecycleEvent(token: ClassType | InjectionToken<any, any>, event: 'created' | 'initialized' | 'destroyed', instanceName: string): void;
389
- }
390
- //#endregion
391
- export { TestingModule, TestingModuleOptions, TestingModuleOverride, UnitTestingModule, UnitTestingModuleOptions, createTestingModule };
30
+ export declare const fakeTransport: TransportFactory<FakeTransportOptions, FakeTransport>;
31
+ export { type ContextHost, type FakeTransport, type FakeTransportOptions, createContextHost, enableAsyncContext };
392
32
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/testing/testing-module.mts","../../src/testing/unit-testing-module.mts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AAoBA;;AAIoC,UAJnB,qBAImB,CAAA,IAAA,GAAA,CAAA,CAAA;EAAf;;;EAQC,KAAA,EARb,SAQa,GARD,cAQC,CARc,CAQd,EAAA,GAAA,CAAA;EASL;;;E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