@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,80 @@
1
+ import type {
2
+ ClassType,
3
+ ClassTypeWithInstance,
4
+ InjectionToken,
5
+ } from '@navios/di'
6
+
7
+ import type { CanActivate } from '../../interfaces/index.mjs'
8
+
9
+ import { UseGuards as OriginalUseGuards } from '../../decorators/use-guards.decorator.mjs'
10
+ import { createClassContext, createMethodContext } from '../context-compat.mjs'
11
+
12
+ /**
13
+ * Legacy-compatible UseGuards decorator.
14
+ *
15
+ * Works with TypeScript experimental decorators (legacy API).
16
+ * Can be applied to classes or methods.
17
+ *
18
+ * @param guards - Guard classes or injection tokens to apply
19
+ * @returns A class or method decorator compatible with legacy decorator API
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * // Apply to a controller
24
+ * @Controller()
25
+ * @UseGuards(AuthGuard, RoleGuard)
26
+ * export class UserController { }
27
+ *
28
+ * // Apply to a specific endpoint
29
+ * @Controller()
30
+ * export class UserController {
31
+ * @Endpoint(getUserEndpoint)
32
+ * @UseGuards(AuthGuard)
33
+ * async getUser() { }
34
+ * }
35
+ * ```
36
+ */
37
+ export function UseGuards(
38
+ ...guards: (
39
+ | ClassTypeWithInstance<CanActivate>
40
+ | InjectionToken<CanActivate, undefined>
41
+ )[]
42
+ ) {
43
+ // Create the decorator function
44
+ // Note: TypeScript's legacy decorator system has strict type checking for decorators
45
+ // We use a flexible implementation that works for both class and method decorators
46
+ function decoratorImpl(
47
+ target: ClassType | Function,
48
+ propertyKey?: string | symbol,
49
+ descriptor?: PropertyDescriptor,
50
+ ): any {
51
+ // Determine if this is a class or method decorator
52
+ if (propertyKey !== undefined && descriptor !== undefined) {
53
+ // Method decorator
54
+ const context = createMethodContext(
55
+ target as Function,
56
+ propertyKey,
57
+ descriptor,
58
+ )
59
+ const originalDecorator = OriginalUseGuards(...guards)
60
+ const result = originalDecorator(descriptor.value, context)
61
+ if (result !== descriptor.value) {
62
+ descriptor.value = result
63
+ }
64
+ return descriptor
65
+ } else {
66
+ // Class decorator
67
+ const context = createClassContext(target as ClassType)
68
+ const originalDecorator = OriginalUseGuards(...guards)
69
+ return originalDecorator(target as ClassType, context)
70
+ }
71
+ }
72
+
73
+ // Return with 'any' type to work around TypeScript's strict decorator checking
74
+ // TypeScript's legacy decorator system cannot properly type-check decorators
75
+ // that work as both class and method decorators. The runtime behavior is correct.
76
+ // When used as a class decorator, it returns the class (preserving type at runtime)
77
+ // When used as a method decorator, it returns the PropertyDescriptor
78
+ // @ts-ignore - TypeScript limitation with dual-purpose legacy decorators
79
+ return decoratorImpl as any
80
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Legacy-compatible decorators for projects that cannot use Stage 3 decorators.
3
+ *
4
+ * These decorators use the TypeScript experimental decorator API and convert
5
+ * the arguments to Stage 3 format internally.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { Module, Controller, Endpoint } from '@navios/core/legacy-compat'
10
+ *
11
+ * @Module({
12
+ * controllers: [UserController],
13
+ * })
14
+ * export class AppModule {}
15
+ * ```
16
+ */
17
+ export type { ModuleOptions, ControllerOptions, EndpointParams, EndpointResult, MultipartParams, MultipartResult, StreamParams, } from '../decorators/index.mjs';
18
+ export { Module, Controller, Endpoint, UseGuards, Header, HttpCode, Multipart, Stream, } from './decorators/index.mjs';
19
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["index.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,EACf,YAAY,GACb,MAAM,yBAAyB,CAAA;AAGhC,OAAO,EACL,MAAM,EACN,UAAU,EACV,QAAQ,EACR,SAAS,EACT,MAAM,EACN,QAAQ,EACR,SAAS,EACT,MAAM,GACP,MAAM,wBAAwB,CAAA"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Legacy-compatible decorators for projects that cannot use Stage 3 decorators.
3
+ *
4
+ * These decorators use the TypeScript experimental decorator API and convert
5
+ * the arguments to Stage 3 format internally.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { Module, Controller, Endpoint } from '@navios/core/legacy-compat'
10
+ *
11
+ * @Module({
12
+ * controllers: [UserController],
13
+ * })
14
+ * export class AppModule {}
15
+ * ```
16
+ */
17
+
18
+ // Re-export types
19
+ export type {
20
+ ModuleOptions,
21
+ ControllerOptions,
22
+ EndpointParams,
23
+ EndpointResult,
24
+ MultipartParams,
25
+ MultipartResult,
26
+ StreamParams,
27
+ } from '../decorators/index.mjs'
28
+
29
+ // Export legacy-compatible decorators
30
+ export {
31
+ Module,
32
+ Controller,
33
+ Endpoint,
34
+ UseGuards,
35
+ Header,
36
+ HttpCode,
37
+ Multipart,
38
+ Stream,
39
+ } from './decorators/index.mjs'
40
+
@@ -0,0 +1,196 @@
1
+ import type { InspectOptions } from 'util';
2
+ import type { LogLevel } from './log-levels.mjs';
3
+ import type { LoggerService } from './logger-service.interface.mjs';
4
+ /**
5
+ * @publicApi
6
+ */
7
+ export interface ConsoleLoggerOptions {
8
+ /**
9
+ * Enabled log levels.
10
+ */
11
+ logLevels?: LogLevel[];
12
+ /**
13
+ * If enabled, will print timestamp (time difference) between current and previous log message.
14
+ * Note: This option is not used when `json` is enabled.
15
+ */
16
+ timestamp?: boolean;
17
+ /**
18
+ * A prefix to be used for each log message.
19
+ * Note: This option is not used when `json` is enabled.
20
+ */
21
+ prefix?: string;
22
+ /**
23
+ * If enabled, will add a request ID to the log message.
24
+ */
25
+ requestId?: boolean;
26
+ /**
27
+ * If enabled, will print the log message in JSON format.
28
+ */
29
+ json?: boolean;
30
+ /**
31
+ * If enabled, will print the log message in color.
32
+ * Default true if json is disabled, false otherwise
33
+ */
34
+ colors?: boolean;
35
+ /**
36
+ * The context of the logger.
37
+ */
38
+ context?: string;
39
+ /**
40
+ * If enabled, will print the log message in a single line, even if it is an object with multiple properties.
41
+ * If set to a number, the most n inner elements are united on a single line as long as all properties fit into breakLength. Short array elements are also grouped together.
42
+ * Default true when `json` is enabled, false otherwise.
43
+ */
44
+ compact?: boolean | number;
45
+ /**
46
+ * Specifies the maximum number of Array, TypedArray, Map, Set, WeakMap, and WeakSet elements to include when formatting.
47
+ * Set to null or Infinity to show all elements. Set to 0 or negative to show no elements.
48
+ * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
49
+ * @default 100
50
+ */
51
+ maxArrayLength?: number;
52
+ /**
53
+ * Specifies the maximum number of characters to include when formatting.
54
+ * Set to null or Infinity to show all elements. Set to 0 or negative to show no characters.
55
+ * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
56
+ * @default 10000.
57
+ */
58
+ maxStringLength?: number;
59
+ /**
60
+ * If enabled, will sort keys while formatting objects.
61
+ * Can also be a custom sorting function.
62
+ * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
63
+ * @default false
64
+ */
65
+ sorted?: boolean | ((a: string, b: string) => number);
66
+ /**
67
+ * Specifies the number of times to recurse while formatting object. T
68
+ * This is useful for inspecting large objects. To recurse up to the maximum call stack size pass Infinity or null.
69
+ * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
70
+ * @default 5
71
+ */
72
+ depth?: number;
73
+ /**
74
+ * If true, object's non-enumerable symbols and properties are included in the formatted result.
75
+ * WeakMap and WeakSet entries are also included as well as user defined prototype properties
76
+ * @default false
77
+ */
78
+ showHidden?: boolean;
79
+ /**
80
+ * The length at which input values are split across multiple lines. Set to Infinity to format the input as a single line (in combination with "compact" set to true).
81
+ * Default Infinity when "compact" is true, 80 otherwise.
82
+ * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
83
+ */
84
+ breakLength?: number;
85
+ }
86
+ /**
87
+ * @publicApi
88
+ */
89
+ export declare class ConsoleLogger implements LoggerService {
90
+ /**
91
+ * The options of the logger.
92
+ */
93
+ protected options: ConsoleLoggerOptions;
94
+ /**
95
+ * The context of the logger (can be set manually or automatically inferred).
96
+ */
97
+ protected context?: string;
98
+ /**
99
+ * The original context of the logger (set in the constructor).
100
+ */
101
+ protected originalContext?: string;
102
+ /**
103
+ * The options used for the "inspect" method.
104
+ */
105
+ protected inspectOptions: InspectOptions;
106
+ /**
107
+ * The last timestamp at which the log message was printed.
108
+ */
109
+ protected lastTimestampAt?: number;
110
+ setup(): void;
111
+ setup(context: string): void;
112
+ setup(options: ConsoleLoggerOptions): void;
113
+ setup(context: string, options: ConsoleLoggerOptions): void;
114
+ /**
115
+ * Write a 'log' level log, if the configured level allows for it.
116
+ * Prints to `stdout` with newline.
117
+ */
118
+ log(message: any, context?: string): void;
119
+ log(message: any, ...optionalParams: [...any, string?]): void;
120
+ /**
121
+ * Write an 'error' level log, if the configured level allows for it.
122
+ * Prints to `stderr` with newline.
123
+ */
124
+ error(message: any, stackOrContext?: string): void;
125
+ error(message: any, stack?: string, context?: string): void;
126
+ error(message: any, ...optionalParams: [...any, string?, string?]): void;
127
+ /**
128
+ * Write a 'warn' level log, if the configured level allows for it.
129
+ * Prints to `stdout` with newline.
130
+ */
131
+ warn(message: any, context?: string): void;
132
+ warn(message: any, ...optionalParams: [...any, string?]): void;
133
+ /**
134
+ * Write a 'debug' level log, if the configured level allows for it.
135
+ * Prints to `stdout` with newline.
136
+ */
137
+ debug(message: any, context?: string): void;
138
+ debug(message: any, ...optionalParams: [...any, string?]): void;
139
+ /**
140
+ * Write a 'verbose' level log, if the configured level allows for it.
141
+ * Prints to `stdout` with newline.
142
+ */
143
+ verbose(message: any, context?: string): void;
144
+ verbose(message: any, ...optionalParams: [...any, string?]): void;
145
+ /**
146
+ * Write a 'fatal' level log, if the configured level allows for it.
147
+ * Prints to `stdout` with newline.
148
+ */
149
+ fatal(message: any, context?: string): void;
150
+ fatal(message: any, ...optionalParams: [...any, string?]): void;
151
+ /**
152
+ * Set log levels
153
+ * @param levels log levels
154
+ */
155
+ setLogLevels(levels: LogLevel[]): void;
156
+ /**
157
+ * Set logger context
158
+ * @param context context
159
+ */
160
+ setContext(context: string): void;
161
+ /**
162
+ * Resets the logger context to the value that was passed in the constructor.
163
+ */
164
+ resetContext(): void;
165
+ isLevelEnabled(level: LogLevel): boolean;
166
+ /**
167
+ * Gets the current request ID from the AsyncLocalStorage store.
168
+ * Only returns a value if the requestId option is enabled.
169
+ */
170
+ protected getCurrentRequestId(): string | undefined;
171
+ protected getTimestamp(): string;
172
+ protected printMessages(messages: unknown[], context?: string, logLevel?: LogLevel, requestId?: string, writeStreamType?: 'stdout' | 'stderr', errorStack?: unknown): void;
173
+ protected printAsJson(message: unknown, options: {
174
+ context: string;
175
+ logLevel: LogLevel;
176
+ writeStreamType?: 'stdout' | 'stderr';
177
+ errorStack?: unknown;
178
+ requestId?: string;
179
+ }): void;
180
+ protected formatPid(pid: number): string;
181
+ protected formatContext(context: string): string;
182
+ protected formatMessage(logLevel: LogLevel, message: unknown, pidMessage: string, formattedLogLevel: string, contextMessage: string, timestampDiff: string, requestId?: string): string;
183
+ protected getRequestId(requestId?: string): string;
184
+ protected stringifyMessage(message: unknown, logLevel: LogLevel): string;
185
+ protected colorize(message: string, logLevel: LogLevel): string;
186
+ protected printStackTrace(stack: string): void;
187
+ protected updateAndGetTimestampDiff(): string;
188
+ protected formatTimestampDiff(timestampDiff: number): string;
189
+ protected getInspectOptions(): InspectOptions;
190
+ protected stringifyReplacer(key: string, value: unknown): unknown;
191
+ private getContextAndMessagesToPrint;
192
+ private getContextAndStackAndMessagesToPrint;
193
+ private isStackFormat;
194
+ private getColorByLogLevel;
195
+ }
196
+ //# sourceMappingURL=console-logger.service.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console-logger.service.d.mts","sourceRoot":"","sources":["console-logger.service.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAA;AAM1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAgBnE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAA;IACtB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IACd;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB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Q;IAQtD,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM;IAOvC,SAAS,CAAC,yBAAyB,IAAI,MAAM;IAS7C,SAAS,CAAC,mBAAmB,CAAC,aAAa,EAAE,MAAM;IAKnD,SAAS,CAAC,iBAAiB;IA+B3B,SAAS,CAAC,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;IAmBvD,OAAO,CAAC,4BAA4B;IAepC,OAAO,CAAC,oCAAoC;IA+B5C,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,kBAAkB;CAgB3B"}
@@ -7,6 +7,7 @@ import { Injectable } from '@navios/di'
7
7
  import type { LogLevel } from './log-levels.mjs'
8
8
  import type { LoggerService } from './logger-service.interface.mjs'
9
9
 
10
+ import { getRequestId } from '../stores/request-id.store.mjs'
10
11
  import { LoggerOutput } from './logger.tokens.mjs'
11
12
  import {
12
13
  clc,
@@ -312,6 +313,17 @@ export class ConsoleLogger implements LoggerService {
312
313
  return isLogLevelEnabled(level, logLevels)
313
314
  }
314
315
 
316
+ /**
317
+ * Gets the current request ID from the AsyncLocalStorage store.
318
+ * Only returns a value if the requestId option is enabled.
319
+ */
320
+ protected getCurrentRequestId(): string | undefined {
321
+ if (!this.options.requestId) {
322
+ return undefined
323
+ }
324
+ return getRequestId()
325
+ }
326
+
315
327
  protected getTimestamp(): string {
316
328
  return dateTimeFormatter.format(Date.now())
317
329
  }
@@ -324,6 +336,7 @@ export class ConsoleLogger implements LoggerService {
324
336
  writeStreamType?: 'stdout' | 'stderr',
325
337
  errorStack?: unknown,
326
338
  ) {
339
+ const resolvedRequestId = requestId ?? this.getCurrentRequestId()
327
340
  messages.forEach((message) => {
328
341
  if (this.options.json) {
329
342
  this.printAsJson(message, {
@@ -331,7 +344,7 @@ export class ConsoleLogger implements LoggerService {
331
344
  logLevel,
332
345
  writeStreamType,
333
346
  errorStack,
334
- requestId,
347
+ requestId: resolvedRequestId,
335
348
  })
336
349
  return
337
350
  }
@@ -346,7 +359,7 @@ export class ConsoleLogger implements LoggerService {
346
359
  formattedLogLevel,
347
360
  contextMessage,
348
361
  timestampDiff,
349
- requestId,
362
+ resolvedRequestId,
350
363
  )
351
364
 
352
365
  process[writeStreamType ?? 'stdout'].write(formattedMessage)
@@ -0,0 +1,7 @@
1
+ export * from './utils/index.mjs';
2
+ export * from './console-logger.service.mjs';
3
+ export * from './log-levels.mjs';
4
+ export * from './logger.tokens.mjs';
5
+ export * from './logger.service.mjs';
6
+ export * from './logger-service.interface.mjs';
7
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["index.mts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,gCAAgC,CAAA"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Available log levels in order of severity (lowest to highest).
3
+ */
4
+ export declare const LOG_LEVELS: ["verbose", "debug", "log", "warn", "error", "fatal"];
5
+ /**
6
+ * Log level type.
7
+ *
8
+ * Represents the severity level of a log message.
9
+ * Levels are: 'verbose', 'debug', 'log', 'warn', 'error', 'fatal'
10
+ *
11
+ * @publicApi
12
+ */
13
+ export type LogLevel = (typeof LOG_LEVELS)[number];
14
+ //# sourceMappingURL=log-levels.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-levels.d.mts","sourceRoot":"","sources":["log-levels.mts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,UAAU,uDAOM,CAAA;AAE7B;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAA"}
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Available log levels in order of severity (lowest to highest).
3
+ */
1
4
  export const LOG_LEVELS = [
2
5
  'verbose',
3
6
  'debug',
@@ -6,7 +9,13 @@ export const LOG_LEVELS = [
6
9
  'error',
7
10
  'fatal',
8
11
  ] as const satisfies string[]
12
+
9
13
  /**
14
+ * Log level type.
15
+ *
16
+ * Represents the severity level of a log message.
17
+ * Levels are: 'verbose', 'debug', 'log', 'warn', 'error', 'fatal'
18
+ *
10
19
  * @publicApi
11
20
  */
12
21
  export type LogLevel = (typeof LOG_LEVELS)[number]
@@ -0,0 +1,36 @@
1
+ import type { LogLevel } from './log-levels.mjs';
2
+ /**
3
+ * @publicApi
4
+ */
5
+ export interface LoggerService {
6
+ /**
7
+ * Write a 'log' level log.
8
+ */
9
+ log(message: any, ...optionalParams: any[]): any;
10
+ /**
11
+ * Write an 'error' level log.
12
+ */
13
+ error(message: any, ...optionalParams: any[]): any;
14
+ /**
15
+ * Write a 'warn' level log.
16
+ */
17
+ warn(message: any, ...optionalParams: any[]): any;
18
+ /**
19
+ * Write a 'debug' level log.
20
+ */
21
+ debug?(message: any, ...optionalParams: any[]): any;
22
+ /**
23
+ * Write a 'verbose' level log.
24
+ */
25
+ verbose?(message: any, ...optionalParams: any[]): any;
26
+ /**
27
+ * Write a 'fatal' level log.
28
+ */
29
+ fatal?(message: any, ...optionalParams: any[]): any;
30
+ /**
31
+ * Set log levels.
32
+ * @param levels log levels
33
+ */
34
+ setLogLevels?(levels: LogLevel[]): any;
35
+ }
36
+ //# sourceMappingURL=logger-service.interface.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger-service.interface.d.mts","sourceRoot":"","sources":["logger-service.interface.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEhD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IAEhD;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IAElD;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IAEjD;;OAEG;IACH,KAAK,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IAEnD;;OAEG;IACH,OAAO,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IAErD;;OAEG;IACH,KAAK,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IAEnD;;;OAGG;IACH,YAAY,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAA;CACvC"}
@@ -0,0 +1,57 @@
1
+ import type { LoggerService } from './logger-service.interface.mjs';
2
+ import type { LoggerOptions } from './logger.tokens.mjs';
3
+ /**
4
+ * Logger service instance that can be injected into services and controllers.
5
+ *
6
+ * Provides contextualized logging with automatic context injection.
7
+ * The context is set when the logger is injected using the `inject` function.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * @Injectable()
12
+ * export class UserService {
13
+ * private logger = inject(Logger, { context: UserService.name })
14
+ *
15
+ * async findUser(id: string) {
16
+ * this.logger.log(`Finding user ${id}`)
17
+ * // Logs with context: [UserService]
18
+ * }
19
+ * }
20
+ * ```
21
+ */
22
+ export declare class LoggerInstance implements LoggerService {
23
+ protected localInstance: LoggerService;
24
+ protected context?: string;
25
+ constructor(config?: LoggerOptions);
26
+ /**
27
+ * Write an 'error' level log.
28
+ */
29
+ error(message: any, stack?: string, context?: string): void;
30
+ error(message: any, ...optionalParams: [...any, string?, string?]): void;
31
+ /**
32
+ * Write a 'log' level log.
33
+ */
34
+ log(message: any, context?: string): void;
35
+ log(message: any, ...optionalParams: [...any, string?]): void;
36
+ /**
37
+ * Write a 'warn' level log.
38
+ */
39
+ warn(message: any, context?: string): void;
40
+ warn(message: any, ...optionalParams: [...any, string?]): void;
41
+ /**
42
+ * Write a 'debug' level log.
43
+ */
44
+ debug(message: any, context?: string): void;
45
+ debug(message: any, ...optionalParams: [...any, string?]): void;
46
+ /**
47
+ * Write a 'verbose' level log.
48
+ */
49
+ verbose(message: any, context?: string): void;
50
+ verbose(message: any, ...optionalParams: [...any, string?]): void;
51
+ /**
52
+ * Write a 'fatal' level log.
53
+ */
54
+ fatal(message: any, context?: string): void;
55
+ fatal(message: any, ...optionalParams: [...any, string?]): void;
56
+ }
57
+ //# sourceMappingURL=logger.service.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.service.d.mts","sourceRoot":"","sources":["logger.service.mts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAIxD;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAGa,cAAe,YAAW,aAAa;IAClD,SAAS,CAAC,aAAa,gBAAuB;IAE9C,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;gBAEd,MAAM,GAAE,aAAkB;IAItC;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAC3D,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,CAAC,GAAG,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI;IAWxE;;OAEG;IACH,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IACzC,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,CAAC,GAAG,GAAG,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI;IAQ7D;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAC1C,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,CAAC,GAAG,GAAG,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI;IAQ9D;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAC3C,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,CAAC,GAAG,GAAG,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI;IAQ/D;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAC7C,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,CAAC,GAAG,GAAG,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI;IAQjE;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAC3C,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,CAAC,GAAG,GAAG,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI;CAOhE"}
@@ -5,6 +5,25 @@ import type { LoggerOptions } from './logger.tokens.mjs'
5
5
 
6
6
  import { Logger, LoggerOutput } from './logger.tokens.mjs'
7
7
 
8
+ /**
9
+ * Logger service instance that can be injected into services and controllers.
10
+ *
11
+ * Provides contextualized logging with automatic context injection.
12
+ * The context is set when the logger is injected using the `inject` function.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * @Injectable()
17
+ * export class UserService {
18
+ * private logger = inject(Logger, { context: UserService.name })
19
+ *
20
+ * async findUser(id: string) {
21
+ * this.logger.log(`Finding user ${id}`)
22
+ * // Logs with context: [UserService]
23
+ * }
24
+ * }
25
+ * ```
26
+ */
8
27
  @Injectable({
9
28
  token: Logger,
10
29
  })
@@ -0,0 +1,36 @@
1
+ import { InjectionToken } from '@navios/di';
2
+ import z from 'zod/v4';
3
+ import type { LoggerService } from './logger-service.interface.mjs';
4
+ import type { LoggerInstance } from './logger.service.mjs';
5
+ /**
6
+ * Injection token for the logger output service.
7
+ *
8
+ * This token is used to provide a custom logger implementation.
9
+ * By default, it's bound to ConsoleLogger.
10
+ */
11
+ export declare const LoggerOutput: InjectionToken<LoggerService, undefined, false>;
12
+ /**
13
+ * Schema for logger options.
14
+ */
15
+ export declare const loggerOptionsSchema: z.ZodOptional<z.ZodObject<{
16
+ context: z.ZodOptional<z.ZodString>;
17
+ }, z.core.$strip>>;
18
+ /**
19
+ * Options for creating a logger instance.
20
+ */
21
+ export type LoggerOptions = z.infer<typeof loggerOptionsSchema>;
22
+ /**
23
+ * Injection token for the Logger service.
24
+ *
25
+ * Use this token to inject a contextualized logger instance.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const logger = inject(Logger, { context: 'MyService' })
30
+ * logger.log('Hello world') // Logs with context: [MyService]
31
+ * ```
32
+ */
33
+ export declare const Logger: InjectionToken<LoggerInstance, z.ZodOptional<z.ZodObject<{
34
+ context: z.ZodOptional<z.ZodString>;
35
+ }, z.core.$strip>>, false>;
36
+ //# sourceMappingURL=logger.tokens.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.tokens.d.mts","sourceRoot":"","sources":["logger.tokens.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAE3C,OAAO,CAAC,MAAM,QAAQ,CAAA;AAEtB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,YAAY,iDAAuD,CAAA;AAEhF;;GAEG;AACH,eAAO,MAAM,mBAAmB;;kBAInB,CAAA;AAEb;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE/D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM;;0BAGa,CAAA"}
@@ -5,16 +5,39 @@ import z from 'zod/v4'
5
5
  import type { LoggerService } from './logger-service.interface.mjs'
6
6
  import type { LoggerInstance } from './logger.service.mjs'
7
7
 
8
+ /**
9
+ * Injection token for the logger output service.
10
+ *
11
+ * This token is used to provide a custom logger implementation.
12
+ * By default, it's bound to ConsoleLogger.
13
+ */
8
14
  export const LoggerOutput = InjectionToken.create<LoggerService>('LoggerOutput')
9
15
 
16
+ /**
17
+ * Schema for logger options.
18
+ */
10
19
  export const loggerOptionsSchema = z
11
20
  .object({
12
21
  context: z.string().optional(),
13
22
  })
14
23
  .optional()
15
24
 
25
+ /**
26
+ * Options for creating a logger instance.
27
+ */
16
28
  export type LoggerOptions = z.infer<typeof loggerOptionsSchema>
17
29
 
30
+ /**
31
+ * Injection token for the Logger service.
32
+ *
33
+ * Use this token to inject a contextualized logger instance.
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const logger = inject(Logger, { context: 'MyService' })
38
+ * logger.log('Hello world') // Logs with context: [MyService]
39
+ * ```
40
+ */
18
41
  export const Logger = InjectionToken.create<
19
42
  LoggerInstance,
20
43
  typeof loggerOptionsSchema