@navios/core 1.0.0 → 2.0.0-alpha.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 (237) hide show
  1. package/CHANGELOG.md +97 -11
  2. package/README.md +67 -220
  3. package/lib/async-context-6pdlnNLA.d.mts +237 -0
  4. package/lib/async-context-6pdlnNLA.d.mts.map +1 -0
  5. package/lib/async-context-Dqk7pE-D.d.cts +237 -0
  6. package/lib/async-context-Dqk7pE-D.d.cts.map +1 -0
  7. package/lib/attribute-factory-B3VuYnp7.d.cts +70 -0
  8. package/lib/attribute-factory-B3VuYnp7.d.cts.map +1 -0
  9. package/lib/attribute-factory-mKOXoVnV.d.mts +70 -0
  10. package/lib/attribute-factory-mKOXoVnV.d.mts.map +1 -0
  11. package/lib/attribute-value-CjX9ZkLq.cjs +172 -0
  12. package/lib/attribute-value-CjX9ZkLq.cjs.map +1 -0
  13. package/lib/attribute-value-DMEA255r.mjs +119 -0
  14. package/lib/attribute-value-DMEA255r.mjs.map +1 -0
  15. package/lib/basic-execution-context-CeGuhMOz.mjs +246 -0
  16. package/lib/basic-execution-context-CeGuhMOz.mjs.map +1 -0
  17. package/lib/basic-execution-context-DSk5MNtc.cjs +281 -0
  18. package/lib/basic-execution-context-DSk5MNtc.cjs.map +1 -0
  19. package/lib/execution-context-BPD3FeFb.d.mts +71 -0
  20. package/lib/execution-context-BPD3FeFb.d.mts.map +1 -0
  21. package/lib/execution-context-BTJdHhbf.d.cts +71 -0
  22. package/lib/execution-context-BTJdHhbf.d.cts.map +1 -0
  23. package/lib/execution-context-token-BXUKB2hf.cjs +112 -0
  24. package/lib/execution-context-token-BXUKB2hf.cjs.map +1 -0
  25. package/lib/execution-context-token-CrXmTvk2.mjs +77 -0
  26. package/lib/execution-context-token-CrXmTvk2.mjs.map +1 -0
  27. package/lib/index.cjs +1687 -4409
  28. package/lib/index.cjs.map +1 -1
  29. package/lib/index.d.cts +838 -3
  30. package/lib/index.d.cts.map +1 -0
  31. package/lib/index.d.mts +838 -3
  32. package/lib/index.d.mts.map +1 -0
  33. package/lib/index.mjs +1573 -4219
  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-Bha7GER_.mjs +135 -0
  44. package/lib/module-Bha7GER_.mjs.map +1 -0
  45. package/lib/module-DZewk_2r.cjs +164 -0
  46. package/lib/module-DZewk_2r.cjs.map +1 -0
  47. package/lib/module-graph-DCP9MHG0.cjs +147 -0
  48. package/lib/module-graph-DCP9MHG0.cjs.map +1 -0
  49. package/lib/module-graph-xvVEykFM.mjs +142 -0
  50. package/lib/module-graph-xvVEykFM.mjs.map +1 -0
  51. package/lib/module-metadata-C8S92seK.cjs +95 -0
  52. package/lib/module-metadata-C8S92seK.cjs.map +1 -0
  53. package/lib/module-metadata-k3RTt20x.mjs +66 -0
  54. package/lib/module-metadata-k3RTt20x.mjs.map +1 -0
  55. package/lib/module-options-Dmse0gii.d.mts +51 -0
  56. package/lib/module-options-Dmse0gii.d.mts.map +1 -0
  57. package/lib/module-options-IuDO-p8u.d.cts +51 -0
  58. package/lib/module-options-IuDO-p8u.d.cts.map +1 -0
  59. package/lib/testing/index.cjs +96 -414
  60. package/lib/testing/index.cjs.map +1 -1
  61. package/lib/testing/index.d.cts +25 -385
  62. package/lib/testing/index.d.cts.map +1 -1
  63. package/lib/testing/index.d.mts +24 -385
  64. package/lib/testing/index.d.mts.map +1 -1
  65. package/lib/testing/index.mjs +94 -408
  66. package/lib/testing/index.mjs.map +1 -1
  67. package/lib/transport.cjs +25 -0
  68. package/lib/transport.d.cts +190 -0
  69. package/lib/transport.d.cts.map +1 -0
  70. package/lib/transport.d.mts +190 -0
  71. package/lib/transport.d.mts.map +1 -0
  72. package/lib/transport.mjs +7 -0
  73. package/package.json +37 -17
  74. package/docs/README.md +0 -316
  75. package/docs/adapters.md +0 -308
  76. package/docs/application-setup.md +0 -524
  77. package/docs/attributes.md +0 -689
  78. package/docs/controllers.md +0 -373
  79. package/docs/endpoints.md +0 -444
  80. package/docs/exceptions.md +0 -352
  81. package/docs/guards.md +0 -550
  82. package/docs/legacy-compat.md +0 -356
  83. package/docs/modules.md +0 -377
  84. package/docs/quick-start.md +0 -290
  85. package/docs/services.md +0 -427
  86. package/docs/testing.md +0 -827
  87. package/lib/index-C0Sg16Eb.d.cts +0 -3365
  88. package/lib/index-C0Sg16Eb.d.cts.map +0 -1
  89. package/lib/index-DySQ6Dpd.d.mts +0 -3365
  90. package/lib/index-DySQ6Dpd.d.mts.map +0 -1
  91. package/lib/navios.factory-CO5MB_OK.cjs +0 -4125
  92. package/lib/navios.factory-CO5MB_OK.cjs.map +0 -1
  93. package/lib/navios.factory-D6Y94P9B.mjs +0 -3828
  94. package/lib/navios.factory-D6Y94P9B.mjs.map +0 -1
  95. package/lib/tokens-4J9sredA.mjs +0 -100
  96. package/lib/tokens-4J9sredA.mjs.map +0 -1
  97. package/lib/tokens-CWw9kyeD.cjs +0 -196
  98. package/lib/tokens-CWw9kyeD.cjs.map +0 -1
  99. package/lib/use-guards.decorator-BecoQSmE.mjs +0 -339
  100. package/lib/use-guards.decorator-BecoQSmE.mjs.map +0 -1
  101. package/lib/use-guards.decorator-C4ml9XaT.cjs +0 -447
  102. package/lib/use-guards.decorator-C4ml9XaT.cjs.map +0 -1
  103. package/project.json +0 -66
  104. package/src/__tests__/attribute.factory.spec.mts +0 -300
  105. package/src/__tests__/config.service.spec.mts +0 -43
  106. package/src/__tests__/console-logger.service.spec.mts +0 -312
  107. package/src/__tests__/controller-resolver.spec.mts +0 -229
  108. package/src/__tests__/controller.spec.mts +0 -58
  109. package/src/__tests__/guard-runner.service.spec.mts +0 -399
  110. package/src/__tests__/logger.service.spec.mts +0 -147
  111. package/src/__tests__/responders.spec.mts +0 -340
  112. package/src/__tests__/testing-module.spec.mts +0 -459
  113. package/src/__tests__/unit-testing-module.spec.mts +0 -424
  114. package/src/attribute.factory.mts +0 -325
  115. package/src/config/config-service.interface.mts +0 -47
  116. package/src/config/config.provider.mts +0 -69
  117. package/src/config/config.service.mts +0 -176
  118. package/src/config/index.mts +0 -5
  119. package/src/config/types.mts +0 -58
  120. package/src/config/utils/helpers.mts +0 -23
  121. package/src/config/utils/index.mts +0 -1
  122. package/src/decorators/controller.decorator.mts +0 -81
  123. package/src/decorators/endpoint.decorator.mts +0 -181
  124. package/src/decorators/header.decorator.mts +0 -38
  125. package/src/decorators/http-code.decorator.mts +0 -38
  126. package/src/decorators/index.mts +0 -8
  127. package/src/decorators/module.decorator.mts +0 -106
  128. package/src/decorators/multipart.decorator.mts +0 -169
  129. package/src/decorators/stream.decorator.mts +0 -155
  130. package/src/decorators/use-guards.decorator.mts +0 -73
  131. package/src/exceptions/bad-request.exception.mts +0 -28
  132. package/src/exceptions/conflict.exception.mts +0 -31
  133. package/src/exceptions/forbidden.exception.mts +0 -30
  134. package/src/exceptions/http.exception.mts +0 -33
  135. package/src/exceptions/index.mts +0 -7
  136. package/src/exceptions/internal-server-error.exception.mts +0 -33
  137. package/src/exceptions/not-found.exception.mts +0 -33
  138. package/src/exceptions/unauthorized.exception.mts +0 -30
  139. package/src/factories/adapter.factory.mts +0 -20
  140. package/src/factories/endpoint-adapter.factory.mts +0 -21
  141. package/src/factories/http-adapter.factory.mts +0 -20
  142. package/src/factories/index.mts +0 -8
  143. package/src/factories/multipart-adapter.factory.mts +0 -21
  144. package/src/factories/reply.factory.mts +0 -21
  145. package/src/factories/request.factory.mts +0 -21
  146. package/src/factories/stream-adapter.factory.mts +0 -20
  147. package/src/factories/xml-stream-adapter.factory.mts +0 -20
  148. package/src/index.mts +0 -16
  149. package/src/interfaces/abstract-adapter.interface.mts +0 -32
  150. package/src/interfaces/abstract-execution-context.inteface.mts +0 -48
  151. package/src/interfaces/abstract-http-adapter.interface.mts +0 -79
  152. package/src/interfaces/abstract-http-cors-options.interface.mts +0 -59
  153. package/src/interfaces/abstract-http-handler-adapter.interface.mts +0 -127
  154. package/src/interfaces/abstract-http-listen-options.interface.mts +0 -4
  155. package/src/interfaces/adapter-environment.interface.mts +0 -74
  156. package/src/interfaces/can-activate.mts +0 -38
  157. package/src/interfaces/http-header.mts +0 -18
  158. package/src/interfaces/index.mts +0 -11
  159. package/src/interfaces/navios-module.mts +0 -28
  160. package/src/interfaces/plugin.interface.mts +0 -139
  161. package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +0 -521
  162. package/src/legacy-compat/__type-tests__/tsconfig.json +0 -15
  163. package/src/legacy-compat/attribute.factory.mts +0 -351
  164. package/src/legacy-compat/decorators/controller.decorator.mts +0 -31
  165. package/src/legacy-compat/decorators/endpoint.decorator.mts +0 -73
  166. package/src/legacy-compat/decorators/header.decorator.mts +0 -43
  167. package/src/legacy-compat/decorators/http-code.decorator.mts +0 -39
  168. package/src/legacy-compat/decorators/index.mts +0 -11
  169. package/src/legacy-compat/decorators/module.decorator.mts +0 -37
  170. package/src/legacy-compat/decorators/multipart.decorator.mts +0 -72
  171. package/src/legacy-compat/decorators/stream.decorator.mts +0 -89
  172. package/src/legacy-compat/decorators/use-guards.decorator.mts +0 -80
  173. package/src/legacy-compat/index.mts +0 -57
  174. package/src/logger/README.md +0 -3
  175. package/src/logger/console-logger.service.mts +0 -714
  176. package/src/logger/index.mts +0 -6
  177. package/src/logger/log-levels.mts +0 -21
  178. package/src/logger/logger-service.interface.mts +0 -42
  179. package/src/logger/logger.service.mts +0 -113
  180. package/src/logger/logger.tokens.mts +0 -44
  181. package/src/logger/utils/cli-colors.util.mts +0 -17
  182. package/src/logger/utils/filter-log-levelts.util.mts +0 -29
  183. package/src/logger/utils/index.mts +0 -5
  184. package/src/logger/utils/is-log-level-enabled.mts +0 -33
  185. package/src/logger/utils/is-log-level.util.mts +0 -10
  186. package/src/logger/utils/shared.utils.mts +0 -51
  187. package/src/metadata/controller.metadata.mts +0 -72
  188. package/src/metadata/handler.metadata.mts +0 -80
  189. package/src/metadata/index.mts +0 -4
  190. package/src/metadata/module.metadata.mts +0 -108
  191. package/src/metadata/navios-managed.metadata.mts +0 -42
  192. package/src/navios.application.mts +0 -484
  193. package/src/navios.environment.mts +0 -42
  194. package/src/navios.factory.mts +0 -158
  195. package/src/responders/enums/framework-error.enum.mts +0 -38
  196. package/src/responders/enums/index.mts +0 -1
  197. package/src/responders/index.mts +0 -4
  198. package/src/responders/interfaces/error-responder.interface.mts +0 -42
  199. package/src/responders/interfaces/error-response.interface.mts +0 -22
  200. package/src/responders/interfaces/index.mts +0 -3
  201. package/src/responders/interfaces/problem-details.interface.mts +0 -34
  202. package/src/responders/services/error-response-producer.service.mts +0 -143
  203. package/src/responders/services/forbidden-responder.service.mts +0 -77
  204. package/src/responders/services/index.mts +0 -5
  205. package/src/responders/services/internal-server-error-responder.service.mts +0 -57
  206. package/src/responders/services/not-found-responder.service.mts +0 -76
  207. package/src/responders/services/validation-error-responder.service.mts +0 -78
  208. package/src/responders/tokens/index.mts +0 -1
  209. package/src/responders/tokens/responder.tokens.mts +0 -84
  210. package/src/services/abstract-handler-adapter.service.mts +0 -366
  211. package/src/services/guard-runner.service.mts +0 -152
  212. package/src/services/index.mts +0 -4
  213. package/src/services/instance-resolver.service.mts +0 -177
  214. package/src/services/module-loader.service.mts +0 -252
  215. package/src/stores/index.mts +0 -1
  216. package/src/stores/request-id.store.mts +0 -85
  217. package/src/testing/index.mts +0 -3
  218. package/src/testing/testing-module.mts +0 -393
  219. package/src/testing/unit-testing-module.mts +0 -298
  220. package/src/tokens/adapter.token.mts +0 -6
  221. package/src/tokens/endpoint-adapter.token.mts +0 -8
  222. package/src/tokens/execution-context.token.mts +0 -9
  223. package/src/tokens/http-adapter.token.mts +0 -8
  224. package/src/tokens/index.mts +0 -10
  225. package/src/tokens/multipart-adapter.token.mts +0 -8
  226. package/src/tokens/navios-options.token.mts +0 -6
  227. package/src/tokens/reply.token.mts +0 -3
  228. package/src/tokens/request.token.mts +0 -3
  229. package/src/tokens/stream-adapter.token.mts +0 -8
  230. package/src/tokens/xml-stream-adapter.token.mts +0 -8
  231. package/src/utils/adapter-supports.util.mts +0 -47
  232. package/src/utils/index.mts +0 -1
  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,3828 +0,0 @@
1
- import { a as NaviosOptionsToken, d as AdapterToken, p as extractModuleMetadata } from "./tokens-4J9sredA.mjs";
2
- import { Container, Injectable, InjectableScope, InjectionToken, getInjectableToken, inject, optional } from "@navios/di";
3
- import z from "zod/v4";
4
- import { inspect } from "util";
5
- import { AsyncLocalStorage } from "node:async_hooks";
6
-
7
- //#region src/logger/utils/cli-colors.util.mts
8
- const isColorAllowed = () => !process.env.NO_COLOR;
9
- const colorIfAllowed = (colorFn) => (text) => isColorAllowed() ? colorFn(text) : text;
10
- const clc = {
11
- bold: colorIfAllowed((text) => `\x1B[1m${text}\x1B[0m`),
12
- green: colorIfAllowed((text) => `\x1B[32m${text}\x1B[39m`),
13
- yellow: colorIfAllowed((text) => `\x1B[33m${text}\x1B[39m`),
14
- red: colorIfAllowed((text) => `\x1B[31m${text}\x1B[39m`),
15
- magentaBright: colorIfAllowed((text) => `\x1B[95m${text}\x1B[39m`),
16
- cyanBright: colorIfAllowed((text) => `\x1B[96m${text}\x1B[39m`)
17
- };
18
- const yellow = colorIfAllowed((text) => `\x1B[38;5;3m${text}\x1B[39m`);
19
-
20
- //#endregion
21
- //#region src/logger/log-levels.mts
22
- /**
23
- * Available log levels in order of severity (lowest to highest).
24
- */ const LOG_LEVELS = [
25
- "verbose",
26
- "debug",
27
- "log",
28
- "warn",
29
- "error",
30
- "fatal"
31
- ];
32
-
33
- //#endregion
34
- //#region src/logger/utils/is-log-level.util.mts
35
- /**
36
- * @publicApi
37
- */ function isLogLevel(maybeLogLevel) {
38
- return LOG_LEVELS.includes(maybeLogLevel);
39
- }
40
-
41
- //#endregion
42
- //#region src/logger/utils/filter-log-levelts.util.mts
43
- /**
44
- * @publicApi
45
- */ function filterLogLevels(parseableString = "") {
46
- const sanitizedString = parseableString.replaceAll(" ", "").toLowerCase();
47
- if (sanitizedString[0] === ">") {
48
- const orEqual = sanitizedString[1] === "=";
49
- const logLevelIndex = LOG_LEVELS.indexOf(sanitizedString.substring(orEqual ? 2 : 1));
50
- if (logLevelIndex === -1) throw new Error(`parse error (unknown log level): ${sanitizedString}`);
51
- return LOG_LEVELS.slice(orEqual ? logLevelIndex : logLevelIndex + 1);
52
- } else if (sanitizedString.includes(",")) return sanitizedString.split(",").filter(isLogLevel);
53
- return isLogLevel(sanitizedString) ? [sanitizedString] : LOG_LEVELS;
54
- }
55
-
56
- //#endregion
57
- //#region src/logger/utils/is-log-level-enabled.mts
58
- const LOG_LEVEL_VALUES = {
59
- verbose: 0,
60
- debug: 1,
61
- log: 2,
62
- warn: 3,
63
- error: 4,
64
- fatal: 5
65
- };
66
- /**
67
- * Checks if target level is enabled.
68
- * @param targetLevel target level
69
- * @param logLevels array of enabled log levels
70
- */ function isLogLevelEnabled(targetLevel, logLevels) {
71
- if (!logLevels || Array.isArray(logLevels) && logLevels?.length === 0) return false;
72
- if (logLevels.includes(targetLevel)) return true;
73
- const highestLogLevelValue = logLevels.map((level) => LOG_LEVEL_VALUES[level]).sort((a, b) => b - a)?.[0];
74
- return LOG_LEVEL_VALUES[targetLevel] >= highestLogLevelValue;
75
- }
76
-
77
- //#endregion
78
- //#region src/logger/utils/shared.utils.mts
79
- const isUndefined = (obj) => typeof obj === "undefined";
80
- const isObject = (fn) => !isNil(fn) && typeof fn === "object";
81
- const isPlainObject = (fn) => {
82
- if (!isObject(fn)) return false;
83
- const proto = Object.getPrototypeOf(fn);
84
- if (proto === null) return true;
85
- const ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
86
- return typeof ctor === "function" && ctor instanceof ctor && Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object);
87
- };
88
- const addLeadingSlash = (path) => path && typeof path === "string" ? path.charAt(0) !== "/" && path.substring(0, 2) !== "{/" ? "/" + path : path : "";
89
- const normalizePath = (path) => path ? path.startsWith("/") ? ("/" + path.replace(/\/+$/, "")).replace(/\/+/g, "/") : "/" + path.replace(/\/+$/, "") : "/";
90
- const stripEndSlash = (path) => path[path.length - 1] === "/" ? path.slice(0, path.length - 1) : path;
91
- const isFunction = (val) => typeof val === "function";
92
- const isString = (val) => typeof val === "string";
93
- const isNumber = (val) => typeof val === "number";
94
- const isConstructor = (val) => val === "constructor";
95
- const isNil = (val) => isUndefined(val) || val === null;
96
- const isEmpty = (array) => !(array && array.length > 0);
97
- const isSymbol = (val) => typeof val === "symbol";
98
-
99
- //#endregion
100
- //#region src/stores/request-id.store.mts
101
- let requestCounter = 0;
102
- /**
103
- * Generates a simple incremental request ID.
104
- * Much faster than crypto.randomUUID() and sufficient for request tracking.
105
- *
106
- * @returns A unique request ID string (e.g., "req-1", "req-2", ...)
107
- */ function generateRequestId() {
108
- return `req-${++requestCounter}`;
109
- }
110
- /**
111
- * AsyncLocalStorage store for the current request ID.
112
- *
113
- * This allows logging and other services to access the current request ID
114
- * without explicitly passing it through the call stack.
115
- *
116
- * @example
117
- * ```typescript
118
- * import { requestIdStore, runWithRequestId, getRequestId } from '@navios/core'
119
- *
120
- * // Run code with a request ID in context
121
- * runWithRequestId('req-123', () => {
122
- * // Inside this callback, getRequestId() returns 'req-123'
123
- * logger.log('Processing request') // Will include request ID if logger is configured
124
- * })
125
- *
126
- * // Get current request ID (returns undefined if not in a request context)
127
- * const currentId = getRequestId()
128
- * ```
129
- */ let requestIdStore = null;
130
- function getRequestIdStore() {
131
- if (!requestIdStore) requestIdStore = new AsyncLocalStorage();
132
- return requestIdStore;
133
- }
134
- /**
135
- * Whether request ID propagation is enabled.
136
- * When disabled, runWithRequestId is a pass-through for better performance.
137
- */ let requestIdEnabled = false;
138
- /**
139
- * Enables or disables request ID propagation.
140
- * Called by NaviosFactory based on the enableRequestId option.
141
- *
142
- * @param enabled - Whether to enable request ID propagation
143
- */ function setRequestIdEnabled(enabled) {
144
- requestIdEnabled = enabled;
145
- }
146
- /**
147
- * Runs a function with a request ID in the async local storage context.
148
- * If request ID propagation is disabled, the function is called directly
149
- * without AsyncLocalStorage overhead.
150
- *
151
- * @param requestId - The request ID to set for this context
152
- * @param fn - The function to run within this context
153
- * @returns The return value of the function
154
- */ function runWithRequestId(requestId, fn) {
155
- if (!requestIdEnabled) return fn();
156
- return getRequestIdStore().run(requestId, fn);
157
- }
158
- /**
159
- * Gets the current request ID from the async local storage context.
160
- *
161
- * @returns The current request ID, or undefined if not in a request context
162
- */ function getRequestId() {
163
- if (!requestIdEnabled) return;
164
- return getRequestIdStore().getStore();
165
- }
166
-
167
- //#endregion
168
- //#region src/logger/logger.tokens.mts
169
- /**
170
- * Injection token for the logger output service.
171
- *
172
- * This token is used to provide a custom logger implementation.
173
- * By default, it's bound to ConsoleLogger.
174
- */ const LoggerOutput = InjectionToken.create("LoggerOutput");
175
- /**
176
- * Schema for logger options.
177
- */ const loggerOptionsSchema = z.object({ context: z.string().optional() }).optional();
178
- /**
179
- * Injection token for the Logger service.
180
- *
181
- * Use this token to inject a contextualized logger instance.
182
- *
183
- * @example
184
- * ```typescript
185
- * const logger = inject(Logger, { context: 'MyService' })
186
- * logger.log('Hello world') // Logs with context: [MyService]
187
- * ```
188
- */ const Logger = InjectionToken.create("Logger", loggerOptionsSchema);
189
-
190
- //#endregion
191
- //#region src/logger/console-logger.service.mts
192
- function applyDecs2203RFactory$7() {
193
- function createAddInitializerMethod(initializers, decoratorFinishedRef) {
194
- return function addInitializer(initializer) {
195
- assertNotFinished(decoratorFinishedRef, "addInitializer");
196
- assertCallable(initializer, "An initializer");
197
- initializers.push(initializer);
198
- };
199
- }
200
- function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
201
- var kindStr;
202
- switch (kind) {
203
- case 1:
204
- kindStr = "accessor";
205
- break;
206
- case 2:
207
- kindStr = "method";
208
- break;
209
- case 3:
210
- kindStr = "getter";
211
- break;
212
- case 4:
213
- kindStr = "setter";
214
- break;
215
- default: kindStr = "field";
216
- }
217
- var ctx = {
218
- kind: kindStr,
219
- name: isPrivate ? "#" + name : name,
220
- static: isStatic,
221
- private: isPrivate,
222
- metadata
223
- };
224
- var decoratorFinishedRef = { v: false };
225
- ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
226
- var get, set;
227
- if (kind === 0) if (isPrivate) {
228
- get = desc.get;
229
- set = desc.set;
230
- } else {
231
- get = function() {
232
- return this[name];
233
- };
234
- set = function(v) {
235
- this[name] = v;
236
- };
237
- }
238
- else if (kind === 2) get = function() {
239
- return desc.value;
240
- };
241
- else {
242
- if (kind === 1 || kind === 3) get = function() {
243
- return desc.get.call(this);
244
- };
245
- if (kind === 1 || kind === 4) set = function(v) {
246
- desc.set.call(this, v);
247
- };
248
- }
249
- ctx.access = get && set ? {
250
- get,
251
- set
252
- } : get ? { get } : { set };
253
- try {
254
- return dec(value, ctx);
255
- } finally {
256
- decoratorFinishedRef.v = true;
257
- }
258
- }
259
- function assertNotFinished(decoratorFinishedRef, fnName) {
260
- if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
261
- }
262
- function assertCallable(fn, hint) {
263
- if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
264
- }
265
- function assertValidReturnValue(kind, value) {
266
- var type = typeof value;
267
- if (kind === 1) {
268
- if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
269
- if (value.get !== void 0) assertCallable(value.get, "accessor.get");
270
- if (value.set !== void 0) assertCallable(value.set, "accessor.set");
271
- if (value.init !== void 0) assertCallable(value.init, "accessor.init");
272
- } else if (type !== "function") {
273
- var hint;
274
- if (kind === 0) hint = "field";
275
- else if (kind === 10) hint = "class";
276
- else hint = "method";
277
- throw new TypeError(hint + " decorators must return a function or void 0");
278
- }
279
- }
280
- function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
281
- var decs = decInfo[0];
282
- var desc, init, value;
283
- if (isPrivate) if (kind === 0 || kind === 1) desc = {
284
- get: decInfo[3],
285
- set: decInfo[4]
286
- };
287
- else if (kind === 3) desc = { get: decInfo[3] };
288
- else if (kind === 4) desc = { set: decInfo[3] };
289
- else desc = { value: decInfo[3] };
290
- else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
291
- if (kind === 1) value = {
292
- get: desc.get,
293
- set: desc.set
294
- };
295
- else if (kind === 2) value = desc.value;
296
- else if (kind === 3) value = desc.get;
297
- else if (kind === 4) value = desc.set;
298
- var newValue, get, set;
299
- if (typeof decs === "function") {
300
- newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
301
- if (newValue !== void 0) {
302
- assertValidReturnValue(kind, newValue);
303
- if (kind === 0) init = newValue;
304
- else if (kind === 1) {
305
- init = newValue.init;
306
- get = newValue.get || value.get;
307
- set = newValue.set || value.set;
308
- value = {
309
- get,
310
- set
311
- };
312
- } else value = newValue;
313
- }
314
- } else for (var i = decs.length - 1; i >= 0; i--) {
315
- var dec = decs[i];
316
- newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
317
- if (newValue !== void 0) {
318
- assertValidReturnValue(kind, newValue);
319
- var newInit;
320
- if (kind === 0) newInit = newValue;
321
- else if (kind === 1) {
322
- newInit = newValue.init;
323
- get = newValue.get || value.get;
324
- set = newValue.set || value.set;
325
- value = {
326
- get,
327
- set
328
- };
329
- } else value = newValue;
330
- if (newInit !== void 0) if (init === void 0) init = newInit;
331
- else if (typeof init === "function") init = [init, newInit];
332
- else init.push(newInit);
333
- }
334
- }
335
- if (kind === 0 || kind === 1) {
336
- if (init === void 0) init = function(instance, init$1) {
337
- return init$1;
338
- };
339
- else if (typeof init !== "function") {
340
- var ownInitializers = init;
341
- init = function(instance, init$1) {
342
- var value$1 = init$1;
343
- for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
344
- return value$1;
345
- };
346
- } else {
347
- var originalInitializer = init;
348
- init = function(instance, init$1) {
349
- return originalInitializer.call(instance, init$1);
350
- };
351
- }
352
- ret.push(init);
353
- }
354
- if (kind !== 0) {
355
- if (kind === 1) {
356
- desc.get = value.get;
357
- desc.set = value.set;
358
- } else if (kind === 2) desc.value = value;
359
- else if (kind === 3) desc.get = value;
360
- else if (kind === 4) desc.set = value;
361
- if (isPrivate) if (kind === 1) {
362
- ret.push(function(instance, args) {
363
- return value.get.call(instance, args);
364
- });
365
- ret.push(function(instance, args) {
366
- return value.set.call(instance, args);
367
- });
368
- } else if (kind === 2) ret.push(value);
369
- else ret.push(function(instance, args) {
370
- return value.call(instance, args);
371
- });
372
- else Object.defineProperty(base, name, desc);
373
- }
374
- }
375
- function applyMemberDecs(Class, decInfos, metadata) {
376
- var ret = [];
377
- var protoInitializers;
378
- var staticInitializers;
379
- var existingProtoNonFields = /* @__PURE__ */ new Map();
380
- var existingStaticNonFields = /* @__PURE__ */ new Map();
381
- for (var i = 0; i < decInfos.length; i++) {
382
- var decInfo = decInfos[i];
383
- if (!Array.isArray(decInfo)) continue;
384
- var kind = decInfo[1];
385
- var name = decInfo[2];
386
- var isPrivate = decInfo.length > 3;
387
- var isStatic = kind >= 5;
388
- var base;
389
- var initializers;
390
- if (isStatic) {
391
- base = Class;
392
- kind = kind - 5;
393
- staticInitializers = staticInitializers || [];
394
- initializers = staticInitializers;
395
- } else {
396
- base = Class.prototype;
397
- protoInitializers = protoInitializers || [];
398
- initializers = protoInitializers;
399
- }
400
- if (kind !== 0 && !isPrivate) {
401
- var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
402
- var existingKind = existingNonFields.get(name) || 0;
403
- if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
404
- else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
405
- else existingNonFields.set(name, true);
406
- }
407
- applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
408
- }
409
- pushInitializers(ret, protoInitializers);
410
- pushInitializers(ret, staticInitializers);
411
- return ret;
412
- }
413
- function pushInitializers(ret, initializers) {
414
- if (initializers) ret.push(function(instance) {
415
- for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
416
- return instance;
417
- });
418
- }
419
- function applyClassDecs(targetClass, classDecs, metadata) {
420
- if (classDecs.length > 0) {
421
- var initializers = [];
422
- var newClass = targetClass;
423
- var name = targetClass.name;
424
- for (var i = classDecs.length - 1; i >= 0; i--) {
425
- var decoratorFinishedRef = { v: false };
426
- try {
427
- var nextNewClass = classDecs[i](newClass, {
428
- kind: "class",
429
- name,
430
- addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
431
- metadata
432
- });
433
- } finally {
434
- decoratorFinishedRef.v = true;
435
- }
436
- if (nextNewClass !== void 0) {
437
- assertValidReturnValue(10, nextNewClass);
438
- newClass = nextNewClass;
439
- }
440
- }
441
- return [defineMetadata(newClass, metadata), function() {
442
- for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
443
- }];
444
- }
445
- }
446
- function defineMetadata(Class, metadata) {
447
- return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
448
- configurable: true,
449
- enumerable: true,
450
- value: metadata
451
- });
452
- }
453
- return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
454
- if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
455
- var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
456
- var e = applyMemberDecs(targetClass, memberDecs, metadata);
457
- if (!classDecs.length) defineMetadata(targetClass, metadata);
458
- return {
459
- e,
460
- get c() {
461
- return applyClassDecs(targetClass, classDecs, metadata);
462
- }
463
- };
464
- };
465
- }
466
- function _apply_decs_2203_r$7(targetClass, memberDecs, classDecs, parentClass) {
467
- return (_apply_decs_2203_r$7 = applyDecs2203RFactory$7())(targetClass, memberDecs, classDecs, parentClass);
468
- }
469
- function _identity(x) {
470
- return x;
471
- }
472
- var _dec$7, _initClass$7;
473
- const DEFAULT_DEPTH = 5;
474
- const DEFAULT_LOG_LEVELS = [
475
- "log",
476
- "error",
477
- "warn",
478
- "debug",
479
- "verbose",
480
- "fatal"
481
- ];
482
- const dateTimeFormatter = new Intl.DateTimeFormat(void 0, {
483
- year: "numeric",
484
- hour: "numeric",
485
- minute: "numeric",
486
- second: "numeric",
487
- day: "2-digit",
488
- month: "2-digit"
489
- });
490
- let _ConsoleLogger;
491
- _dec$7 = Injectable({ token: LoggerOutput });
492
- new class extends _identity {
493
- constructor() {
494
- super(_ConsoleLogger), _initClass$7();
495
- }
496
- static {
497
- class ConsoleLogger {
498
- static {
499
- ({c: [_ConsoleLogger, _initClass$7]} = _apply_decs_2203_r$7(this, [], [_dec$7]));
500
- }
501
- static create(contextOrOptions, options) {
502
- const logger = new ConsoleLogger();
503
- if (contextOrOptions !== void 0) if (typeof contextOrOptions === "string") logger.setup(contextOrOptions, options ?? {});
504
- else logger.setup(contextOrOptions);
505
- else logger.setup();
506
- return logger;
507
- }
508
- /**
509
- * The options of the logger.
510
- */ options = {};
511
- /**
512
- * The context of the logger (can be set manually or automatically inferred).
513
- */ context;
514
- /**
515
- * The original context of the logger (set in the constructor).
516
- */ originalContext;
517
- /**
518
- * The options used for the "inspect" method.
519
- */ inspectOptions = this.getInspectOptions();
520
- /**
521
- * The last timestamp at which the log message was printed.
522
- */ lastTimestampAt;
523
- setup(contextOrOptions, options) {
524
- let [context, opts] = isString(contextOrOptions) ? [contextOrOptions, options] : options ? [void 0, options] : [contextOrOptions?.context, contextOrOptions];
525
- opts = opts ?? {};
526
- opts.logLevels ??= DEFAULT_LOG_LEVELS;
527
- opts.colors ??= opts.colors ?? (opts.json ? false : true);
528
- opts.prefix ??= "Navios";
529
- this.options = opts;
530
- this.inspectOptions = this.getInspectOptions();
531
- if (context) {
532
- this.context = context;
533
- this.originalContext = context;
534
- }
535
- }
536
- log(message, ...optionalParams) {
537
- if (!this.isLevelEnabled("log")) return;
538
- const { messages, context } = this.getContextAndMessagesToPrint([message, ...optionalParams]);
539
- this.printMessages(messages, context, "log");
540
- }
541
- error(message, ...optionalParams) {
542
- if (!this.isLevelEnabled("error")) return;
543
- const { messages, context, stack } = this.getContextAndStackAndMessagesToPrint([message, ...optionalParams]);
544
- this.printMessages(messages, context, "error", void 0, "stderr", stack);
545
- this.printStackTrace(stack);
546
- }
547
- warn(message, ...optionalParams) {
548
- if (!this.isLevelEnabled("warn")) return;
549
- const { messages, context } = this.getContextAndMessagesToPrint([message, ...optionalParams]);
550
- this.printMessages(messages, context, "warn");
551
- }
552
- debug(message, ...optionalParams) {
553
- if (!this.isLevelEnabled("debug")) return;
554
- const { messages, context } = this.getContextAndMessagesToPrint([message, ...optionalParams]);
555
- this.printMessages(messages, context, "debug");
556
- }
557
- verbose(message, ...optionalParams) {
558
- if (!this.isLevelEnabled("verbose")) return;
559
- const { messages, context } = this.getContextAndMessagesToPrint([message, ...optionalParams]);
560
- this.printMessages(messages, context, "verbose");
561
- }
562
- fatal(message, ...optionalParams) {
563
- if (!this.isLevelEnabled("fatal")) return;
564
- const { messages, context } = this.getContextAndMessagesToPrint([message, ...optionalParams]);
565
- this.printMessages(messages, context, "fatal");
566
- }
567
- /**
568
- * Set log levels
569
- * @param levels log levels
570
- */ setLogLevels(levels) {
571
- if (!this.options) this.options = {};
572
- this.options.logLevels = levels;
573
- }
574
- /**
575
- * Set logger context
576
- * @param context context
577
- */ setContext(context) {
578
- this.context = context;
579
- }
580
- /**
581
- * Resets the logger context to the value that was passed in the constructor.
582
- */ resetContext() {
583
- this.context = this.originalContext;
584
- }
585
- isLevelEnabled(level) {
586
- const logLevels = this.options?.logLevels;
587
- return isLogLevelEnabled(level, logLevels);
588
- }
589
- /**
590
- * Gets the current request ID from the AsyncLocalStorage store.
591
- * Only returns a value if the requestId option is enabled.
592
- */ getCurrentRequestId() {
593
- if (!this.options.requestId) return;
594
- return getRequestId();
595
- }
596
- getTimestamp() {
597
- return dateTimeFormatter.format(Date.now());
598
- }
599
- printMessages(messages, context = "", logLevel = "log", requestId, writeStreamType, errorStack) {
600
- const resolvedRequestId = requestId ?? this.getCurrentRequestId();
601
- messages.forEach((message) => {
602
- if (this.options.json) {
603
- this.printAsJson(message, {
604
- context,
605
- logLevel,
606
- writeStreamType,
607
- errorStack,
608
- requestId: resolvedRequestId
609
- });
610
- return;
611
- }
612
- const pidMessage = this.formatPid(process.pid);
613
- const contextMessage = this.formatContext(context);
614
- const timestampDiff = this.updateAndGetTimestampDiff();
615
- const formattedLogLevel = logLevel.toUpperCase().padStart(7, " ");
616
- const formattedMessage = this.formatMessage(logLevel, message, pidMessage, formattedLogLevel, contextMessage, timestampDiff, resolvedRequestId);
617
- process[writeStreamType ?? "stdout"].write(formattedMessage);
618
- });
619
- }
620
- printAsJson(message, options) {
621
- const logObject = {
622
- level: options.logLevel,
623
- pid: process.pid,
624
- timestamp: Date.now(),
625
- message
626
- };
627
- if (options.context) logObject.context = options.context;
628
- if (options.errorStack) logObject.stack = options.errorStack;
629
- if (this.options.requestId && options.requestId) logObject.requestId = options.requestId;
630
- const formattedMessage = !this.options.colors && this.inspectOptions.compact === true ? JSON.stringify(logObject, this.stringifyReplacer) : inspect(logObject, this.inspectOptions);
631
- process[options.writeStreamType ?? "stdout"].write(`${formattedMessage}\n`);
632
- }
633
- formatPid(pid) {
634
- const showPrefix = this.options.showPrefix ?? true;
635
- const showPid = this.options.showPid ?? true;
636
- if (!showPrefix && !showPid) return "";
637
- const prefix = showPrefix ? `[${this.options.prefix}]` : "";
638
- const pidPart = showPid ? `${pid}` : "";
639
- return `${prefix}${showPrefix && showPid ? " " : ""}${pidPart}${showPrefix || showPid ? " - " : ""}`;
640
- }
641
- formatContext(context) {
642
- const showContext = this.options.showContext ?? true;
643
- if (!context || !showContext) return "";
644
- context = `[${context}] `;
645
- return this.options.colors ? yellow(context) : context;
646
- }
647
- formatMessage(logLevel, message, pidMessage, formattedLogLevel, contextMessage, timestampDiff, requestId) {
648
- const output = this.stringifyMessage(message, logLevel);
649
- const showLogLevel = this.options.showLogLevel ?? true;
650
- const showTimestamp = this.options.showTimestamp ?? true;
651
- pidMessage = this.colorize(pidMessage, logLevel);
652
- formattedLogLevel = showLogLevel ? this.colorize(formattedLogLevel, logLevel) : "";
653
- const timestamp = showTimestamp ? this.getTimestamp() : "";
654
- const requestIdPart = this.getRequestId(requestId);
655
- const parts = [];
656
- if (pidMessage) parts.push(pidMessage.trimEnd());
657
- if (requestIdPart) parts.push(requestIdPart.trimEnd());
658
- if (timestamp) parts.push(timestamp);
659
- if (formattedLogLevel) parts.push(formattedLogLevel);
660
- if (contextMessage) parts.push(contextMessage.trimEnd());
661
- return `${parts.length > 0 ? parts.join(" ") + " " : ""}${output}${timestampDiff}\n`;
662
- }
663
- getRequestId(requestId) {
664
- if (this.options.requestId && requestId) return `(${this.colorize(requestId, "log")}) `;
665
- return "";
666
- }
667
- stringifyMessage(message, logLevel) {
668
- if (isFunction(message)) {
669
- if (Function.prototype.toString.call(message).startsWith("class ")) return this.stringifyMessage(message.name, logLevel);
670
- return this.stringifyMessage(message(), logLevel);
671
- }
672
- if (typeof message === "string") return this.colorize(message, logLevel);
673
- const outputText = inspect(message, this.inspectOptions);
674
- if (isPlainObject(message)) return `Object(${Object.keys(message).length}) ${outputText}`;
675
- if (Array.isArray(message)) return `Array(${message.length}) ${outputText}`;
676
- return outputText;
677
- }
678
- colorize(message, logLevel) {
679
- if (!this.options.colors || this.options.json) return message;
680
- return this.getColorByLogLevel(logLevel)(message);
681
- }
682
- printStackTrace(stack) {
683
- if (!stack || this.options.json) return;
684
- process.stderr.write(`${stack}\n`);
685
- }
686
- updateAndGetTimestampDiff() {
687
- const showTimeDiff = this.options?.showTimeDiff ?? false;
688
- const result = this.lastTimestampAt && showTimeDiff ? this.formatTimestampDiff(Date.now() - this.lastTimestampAt) : "";
689
- this.lastTimestampAt = Date.now();
690
- return result;
691
- }
692
- formatTimestampDiff(timestampDiff) {
693
- const formattedDiff = ` +${timestampDiff}ms`;
694
- return this.options.colors ? yellow(formattedDiff) : formattedDiff;
695
- }
696
- getInspectOptions() {
697
- let breakLength = this.options.breakLength;
698
- if (typeof breakLength === "undefined") breakLength = this.options.colors ? this.options.compact ? Infinity : void 0 : this.options.compact === false ? void 0 : Infinity;
699
- const inspectOptions = {
700
- depth: this.options.depth ?? DEFAULT_DEPTH,
701
- sorted: this.options.sorted,
702
- showHidden: this.options.showHidden,
703
- compact: this.options.compact ?? (this.options.json ? true : false),
704
- colors: this.options.colors,
705
- breakLength
706
- };
707
- if (this.options.maxArrayLength) inspectOptions.maxArrayLength = this.options.maxArrayLength;
708
- if (this.options.maxStringLength) inspectOptions.maxStringLength = this.options.maxStringLength;
709
- return inspectOptions;
710
- }
711
- stringifyReplacer(key, value) {
712
- if (typeof value === "bigint") return value.toString();
713
- if (typeof value === "symbol") return value.toString();
714
- if (value instanceof Map || value instanceof Set || value instanceof Error) return `${inspect(value, this.inspectOptions)}`;
715
- return value;
716
- }
717
- getContextAndMessagesToPrint(args) {
718
- if (args?.length <= 1) return {
719
- messages: args,
720
- context: this.context
721
- };
722
- const lastElement = args[args.length - 1];
723
- if (!isString(lastElement)) return {
724
- messages: args,
725
- context: this.context
726
- };
727
- return {
728
- context: lastElement,
729
- messages: args.slice(0, args.length - 1)
730
- };
731
- }
732
- getContextAndStackAndMessagesToPrint(args) {
733
- if (args.length === 2) return this.isStackFormat(args[1]) ? {
734
- messages: [args[0]],
735
- stack: args[1],
736
- context: this.context
737
- } : {
738
- messages: [args[0]],
739
- context: args[1]
740
- };
741
- const { messages, context } = this.getContextAndMessagesToPrint(args);
742
- if (messages?.length <= 1) return {
743
- messages,
744
- context
745
- };
746
- const lastElement = messages[messages.length - 1];
747
- if (!isString(lastElement) && !isUndefined(lastElement)) return {
748
- messages,
749
- context
750
- };
751
- return {
752
- stack: lastElement,
753
- messages: messages.slice(0, messages.length - 1),
754
- context
755
- };
756
- }
757
- isStackFormat(stack) {
758
- if (!isString(stack) && !isUndefined(stack)) return false;
759
- return /^(.)+\n\s+at .+:\d+:\d+/.test(stack);
760
- }
761
- getColorByLogLevel(level) {
762
- switch (level) {
763
- case "debug": return clc.magentaBright;
764
- case "warn": return clc.yellow;
765
- case "error": return clc.red;
766
- case "verbose": return clc.cyanBright;
767
- case "fatal": return clc.bold;
768
- default: return clc.green;
769
- }
770
- }
771
- }
772
- }
773
- }();
774
-
775
- //#endregion
776
- //#region src/logger/logger.service.mts
777
- function applyDecs2203RFactory$6() {
778
- function createAddInitializerMethod(initializers, decoratorFinishedRef) {
779
- return function addInitializer(initializer) {
780
- assertNotFinished(decoratorFinishedRef, "addInitializer");
781
- assertCallable(initializer, "An initializer");
782
- initializers.push(initializer);
783
- };
784
- }
785
- function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
786
- var kindStr;
787
- switch (kind) {
788
- case 1:
789
- kindStr = "accessor";
790
- break;
791
- case 2:
792
- kindStr = "method";
793
- break;
794
- case 3:
795
- kindStr = "getter";
796
- break;
797
- case 4:
798
- kindStr = "setter";
799
- break;
800
- default: kindStr = "field";
801
- }
802
- var ctx = {
803
- kind: kindStr,
804
- name: isPrivate ? "#" + name : name,
805
- static: isStatic,
806
- private: isPrivate,
807
- metadata
808
- };
809
- var decoratorFinishedRef = { v: false };
810
- ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
811
- var get, set;
812
- if (kind === 0) if (isPrivate) {
813
- get = desc.get;
814
- set = desc.set;
815
- } else {
816
- get = function() {
817
- return this[name];
818
- };
819
- set = function(v) {
820
- this[name] = v;
821
- };
822
- }
823
- else if (kind === 2) get = function() {
824
- return desc.value;
825
- };
826
- else {
827
- if (kind === 1 || kind === 3) get = function() {
828
- return desc.get.call(this);
829
- };
830
- if (kind === 1 || kind === 4) set = function(v) {
831
- desc.set.call(this, v);
832
- };
833
- }
834
- ctx.access = get && set ? {
835
- get,
836
- set
837
- } : get ? { get } : { set };
838
- try {
839
- return dec(value, ctx);
840
- } finally {
841
- decoratorFinishedRef.v = true;
842
- }
843
- }
844
- function assertNotFinished(decoratorFinishedRef, fnName) {
845
- if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
846
- }
847
- function assertCallable(fn, hint) {
848
- if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
849
- }
850
- function assertValidReturnValue(kind, value) {
851
- var type = typeof value;
852
- if (kind === 1) {
853
- if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
854
- if (value.get !== void 0) assertCallable(value.get, "accessor.get");
855
- if (value.set !== void 0) assertCallable(value.set, "accessor.set");
856
- if (value.init !== void 0) assertCallable(value.init, "accessor.init");
857
- } else if (type !== "function") {
858
- var hint;
859
- if (kind === 0) hint = "field";
860
- else if (kind === 10) hint = "class";
861
- else hint = "method";
862
- throw new TypeError(hint + " decorators must return a function or void 0");
863
- }
864
- }
865
- function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
866
- var decs = decInfo[0];
867
- var desc, init, value;
868
- if (isPrivate) if (kind === 0 || kind === 1) desc = {
869
- get: decInfo[3],
870
- set: decInfo[4]
871
- };
872
- else if (kind === 3) desc = { get: decInfo[3] };
873
- else if (kind === 4) desc = { set: decInfo[3] };
874
- else desc = { value: decInfo[3] };
875
- else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
876
- if (kind === 1) value = {
877
- get: desc.get,
878
- set: desc.set
879
- };
880
- else if (kind === 2) value = desc.value;
881
- else if (kind === 3) value = desc.get;
882
- else if (kind === 4) value = desc.set;
883
- var newValue, get, set;
884
- if (typeof decs === "function") {
885
- newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
886
- if (newValue !== void 0) {
887
- assertValidReturnValue(kind, newValue);
888
- if (kind === 0) init = newValue;
889
- else if (kind === 1) {
890
- init = newValue.init;
891
- get = newValue.get || value.get;
892
- set = newValue.set || value.set;
893
- value = {
894
- get,
895
- set
896
- };
897
- } else value = newValue;
898
- }
899
- } else for (var i = decs.length - 1; i >= 0; i--) {
900
- var dec = decs[i];
901
- newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
902
- if (newValue !== void 0) {
903
- assertValidReturnValue(kind, newValue);
904
- var newInit;
905
- if (kind === 0) newInit = newValue;
906
- else if (kind === 1) {
907
- newInit = newValue.init;
908
- get = newValue.get || value.get;
909
- set = newValue.set || value.set;
910
- value = {
911
- get,
912
- set
913
- };
914
- } else value = newValue;
915
- if (newInit !== void 0) if (init === void 0) init = newInit;
916
- else if (typeof init === "function") init = [init, newInit];
917
- else init.push(newInit);
918
- }
919
- }
920
- if (kind === 0 || kind === 1) {
921
- if (init === void 0) init = function(instance, init$1) {
922
- return init$1;
923
- };
924
- else if (typeof init !== "function") {
925
- var ownInitializers = init;
926
- init = function(instance, init$1) {
927
- var value$1 = init$1;
928
- for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
929
- return value$1;
930
- };
931
- } else {
932
- var originalInitializer = init;
933
- init = function(instance, init$1) {
934
- return originalInitializer.call(instance, init$1);
935
- };
936
- }
937
- ret.push(init);
938
- }
939
- if (kind !== 0) {
940
- if (kind === 1) {
941
- desc.get = value.get;
942
- desc.set = value.set;
943
- } else if (kind === 2) desc.value = value;
944
- else if (kind === 3) desc.get = value;
945
- else if (kind === 4) desc.set = value;
946
- if (isPrivate) if (kind === 1) {
947
- ret.push(function(instance, args) {
948
- return value.get.call(instance, args);
949
- });
950
- ret.push(function(instance, args) {
951
- return value.set.call(instance, args);
952
- });
953
- } else if (kind === 2) ret.push(value);
954
- else ret.push(function(instance, args) {
955
- return value.call(instance, args);
956
- });
957
- else Object.defineProperty(base, name, desc);
958
- }
959
- }
960
- function applyMemberDecs(Class, decInfos, metadata) {
961
- var ret = [];
962
- var protoInitializers;
963
- var staticInitializers;
964
- var existingProtoNonFields = /* @__PURE__ */ new Map();
965
- var existingStaticNonFields = /* @__PURE__ */ new Map();
966
- for (var i = 0; i < decInfos.length; i++) {
967
- var decInfo = decInfos[i];
968
- if (!Array.isArray(decInfo)) continue;
969
- var kind = decInfo[1];
970
- var name = decInfo[2];
971
- var isPrivate = decInfo.length > 3;
972
- var isStatic = kind >= 5;
973
- var base;
974
- var initializers;
975
- if (isStatic) {
976
- base = Class;
977
- kind = kind - 5;
978
- staticInitializers = staticInitializers || [];
979
- initializers = staticInitializers;
980
- } else {
981
- base = Class.prototype;
982
- protoInitializers = protoInitializers || [];
983
- initializers = protoInitializers;
984
- }
985
- if (kind !== 0 && !isPrivate) {
986
- var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
987
- var existingKind = existingNonFields.get(name) || 0;
988
- if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
989
- else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
990
- else existingNonFields.set(name, true);
991
- }
992
- applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
993
- }
994
- pushInitializers(ret, protoInitializers);
995
- pushInitializers(ret, staticInitializers);
996
- return ret;
997
- }
998
- function pushInitializers(ret, initializers) {
999
- if (initializers) ret.push(function(instance) {
1000
- for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
1001
- return instance;
1002
- });
1003
- }
1004
- function applyClassDecs(targetClass, classDecs, metadata) {
1005
- if (classDecs.length > 0) {
1006
- var initializers = [];
1007
- var newClass = targetClass;
1008
- var name = targetClass.name;
1009
- for (var i = classDecs.length - 1; i >= 0; i--) {
1010
- var decoratorFinishedRef = { v: false };
1011
- try {
1012
- var nextNewClass = classDecs[i](newClass, {
1013
- kind: "class",
1014
- name,
1015
- addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
1016
- metadata
1017
- });
1018
- } finally {
1019
- decoratorFinishedRef.v = true;
1020
- }
1021
- if (nextNewClass !== void 0) {
1022
- assertValidReturnValue(10, nextNewClass);
1023
- newClass = nextNewClass;
1024
- }
1025
- }
1026
- return [defineMetadata(newClass, metadata), function() {
1027
- for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
1028
- }];
1029
- }
1030
- }
1031
- function defineMetadata(Class, metadata) {
1032
- return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
1033
- configurable: true,
1034
- enumerable: true,
1035
- value: metadata
1036
- });
1037
- }
1038
- return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
1039
- if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
1040
- var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
1041
- var e = applyMemberDecs(targetClass, memberDecs, metadata);
1042
- if (!classDecs.length) defineMetadata(targetClass, metadata);
1043
- return {
1044
- e,
1045
- get c() {
1046
- return applyClassDecs(targetClass, classDecs, metadata);
1047
- }
1048
- };
1049
- };
1050
- }
1051
- function _apply_decs_2203_r$6(targetClass, memberDecs, classDecs, parentClass) {
1052
- return (_apply_decs_2203_r$6 = applyDecs2203RFactory$6())(targetClass, memberDecs, classDecs, parentClass);
1053
- }
1054
- var _dec$6, _initClass$6;
1055
- let _LoggerInstance;
1056
- _dec$6 = Injectable({ token: Logger });
1057
- var LoggerInstance = class {
1058
- static {
1059
- ({c: [_LoggerInstance, _initClass$6]} = _apply_decs_2203_r$6(this, [], [_dec$6]));
1060
- }
1061
- constructor(config = {}) {
1062
- this.context = config.context;
1063
- }
1064
- localInstance = inject(LoggerOutput);
1065
- context;
1066
- error(message, ...optionalParams) {
1067
- optionalParams = this.context ? (optionalParams.length ? optionalParams : [void 0]).concat(this.context) : optionalParams;
1068
- this.localInstance?.error(message, ...optionalParams);
1069
- }
1070
- log(message, ...optionalParams) {
1071
- optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
1072
- this.localInstance?.log(message, ...optionalParams);
1073
- }
1074
- warn(message, ...optionalParams) {
1075
- optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
1076
- this.localInstance?.warn(message, ...optionalParams);
1077
- }
1078
- debug(message, ...optionalParams) {
1079
- optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
1080
- this.localInstance?.debug?.(message, ...optionalParams);
1081
- }
1082
- verbose(message, ...optionalParams) {
1083
- optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
1084
- this.localInstance?.verbose?.(message, ...optionalParams);
1085
- }
1086
- fatal(message, ...optionalParams) {
1087
- optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
1088
- this.localInstance?.fatal?.(message, ...optionalParams);
1089
- }
1090
- static {
1091
- _initClass$6();
1092
- }
1093
- };
1094
-
1095
- //#endregion
1096
- //#region src/exceptions/http.exception.mts
1097
- /**
1098
- * Base exception class for all HTTP exceptions in Navios.
1099
- *
1100
- * All HTTP exception classes extend this base class. When thrown from an endpoint handler,
1101
- * Navios will automatically convert it to an appropriate HTTP response with the specified
1102
- * status code and response body.
1103
- *
1104
- * @example
1105
- * ```typescript
1106
- * @Endpoint(getUserEndpoint)
1107
- * async getUser(request: EndpointParams<typeof getUserEndpoint>) {
1108
- * const user = await this.userService.findById(request.urlParams.userId)
1109
- * if (!user) {
1110
- * throw new HttpException(404, 'User not found')
1111
- * }
1112
- * return user
1113
- * }
1114
- * ```
1115
- */ var HttpException = class {
1116
- statusCode;
1117
- response;
1118
- error;
1119
- /**
1120
- * Creates a new HttpException instance.
1121
- *
1122
- * @param statusCode - HTTP status code (e.g., 400, 404, 500)
1123
- * @param response - Response body (string or object)
1124
- * @param error - Optional underlying error for logging/debugging
1125
- */ constructor(statusCode, response, error) {
1126
- this.statusCode = statusCode;
1127
- this.response = response;
1128
- this.error = error;
1129
- }
1130
- };
1131
-
1132
- //#endregion
1133
- //#region src/responders/enums/framework-error.enum.mts
1134
- /**
1135
- * Enumeration of framework-level error types.
1136
- * Used to explicitly specify which error responder should handle an error.
1137
- *
1138
- * @example
1139
- * ```typescript
1140
- * // In adapter error handling
1141
- * if (error instanceof ZodError) {
1142
- * return errorProducer.respond(FrameworkError.ValidationError, error)
1143
- * }
1144
- * return errorProducer.handleUnknown(error)
1145
- * ```
1146
- */ var FrameworkError = /* @__PURE__ */ function(FrameworkError$1) {
1147
- /**
1148
- * Resource not found (HTTP 404).
1149
- * Use when a requested resource does not exist.
1150
- */ FrameworkError$1["NotFound"] = "NotFound";
1151
- /**
1152
- * Forbidden (HTTP 403).
1153
- * Use when access to a resource is denied (e.g., guard rejection).
1154
- */ FrameworkError$1["Forbidden"] = "Forbidden";
1155
- /**
1156
- * Internal server error (HTTP 500).
1157
- * Use for unexpected errors that don't fit other categories.
1158
- */ FrameworkError$1["InternalServerError"] = "InternalServerError";
1159
- /**
1160
- * Validation error (HTTP 400).
1161
- * Use when request data fails validation (e.g., Zod errors).
1162
- */ FrameworkError$1["ValidationError"] = "ValidationError";
1163
- return FrameworkError$1;
1164
- }({});
1165
-
1166
- //#endregion
1167
- //#region src/responders/tokens/responder.tokens.mts
1168
- /**
1169
- * Injection token for the Internal Server Error responder.
1170
- * Default implementation returns HTTP 500 with RFC 7807 Problem Details.
1171
- *
1172
- * @example Override with custom implementation:
1173
- * ```typescript
1174
- * @Injectable({
1175
- * token: InternalServerErrorResponderToken,
1176
- * priority: 0, // Higher than default -10
1177
- * })
1178
- * export class CustomInternalErrorResponder implements ErrorResponder {
1179
- * getResponse(error: unknown, description?: string): ErrorResponse {
1180
- * // Custom implementation
1181
- * }
1182
- * }
1183
- * ```
1184
- */ const InternalServerErrorResponderToken = InjectionToken.create("InternalServerErrorResponder");
1185
- /**
1186
- * Injection token for the Not Found responder.
1187
- * Default implementation returns HTTP 404 with RFC 7807 Problem Details.
1188
- *
1189
- * @example Override with custom implementation:
1190
- * ```typescript
1191
- * @Injectable({
1192
- * token: NotFoundResponderToken,
1193
- * priority: 0, // Higher than default -10
1194
- * })
1195
- * export class CustomNotFoundResponder implements ErrorResponder {
1196
- * getResponse(error: unknown, description?: string): ErrorResponse {
1197
- * // Custom implementation
1198
- * }
1199
- * }
1200
- * ```
1201
- */ const NotFoundResponderToken = InjectionToken.create("NotFoundResponder");
1202
- /**
1203
- * Injection token for the Validation Error responder.
1204
- * Default implementation returns HTTP 400 with RFC 7807 Problem Details
1205
- * and includes validation errors from ZodError.
1206
- *
1207
- * @example Override with custom implementation:
1208
- * ```typescript
1209
- * @Injectable({
1210
- * token: ValidationErrorResponderToken,
1211
- * priority: 0, // Higher than default -10
1212
- * })
1213
- * export class CustomValidationResponder implements ErrorResponder {
1214
- * getResponse(error: unknown, description?: string): ErrorResponse {
1215
- * // Custom implementation
1216
- * }
1217
- * }
1218
- * ```
1219
- */ const ValidationErrorResponderToken = InjectionToken.create("ValidationErrorResponder");
1220
- /**
1221
- * Injection token for the Forbidden responder.
1222
- * Default implementation returns HTTP 403 with RFC 7807 Problem Details.
1223
- *
1224
- * @example Override with custom implementation:
1225
- * ```typescript
1226
- * @Injectable({
1227
- * token: ForbiddenResponderToken,
1228
- * priority: 0, // Higher than default -10
1229
- * })
1230
- * export class CustomForbiddenResponder implements ErrorResponder {
1231
- * getResponse(error: unknown, description?: string): ErrorResponse {
1232
- * // Custom implementation
1233
- * }
1234
- * }
1235
- * ```
1236
- */ const ForbiddenResponderToken = InjectionToken.create("ForbiddenResponder");
1237
-
1238
- //#endregion
1239
- //#region src/responders/services/error-response-producer.service.mts
1240
- function applyDecs2203RFactory$5() {
1241
- function createAddInitializerMethod(initializers, decoratorFinishedRef) {
1242
- return function addInitializer(initializer) {
1243
- assertNotFinished(decoratorFinishedRef, "addInitializer");
1244
- assertCallable(initializer, "An initializer");
1245
- initializers.push(initializer);
1246
- };
1247
- }
1248
- function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
1249
- var kindStr;
1250
- switch (kind) {
1251
- case 1:
1252
- kindStr = "accessor";
1253
- break;
1254
- case 2:
1255
- kindStr = "method";
1256
- break;
1257
- case 3:
1258
- kindStr = "getter";
1259
- break;
1260
- case 4:
1261
- kindStr = "setter";
1262
- break;
1263
- default: kindStr = "field";
1264
- }
1265
- var ctx = {
1266
- kind: kindStr,
1267
- name: isPrivate ? "#" + name : name,
1268
- static: isStatic,
1269
- private: isPrivate,
1270
- metadata
1271
- };
1272
- var decoratorFinishedRef = { v: false };
1273
- ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
1274
- var get, set;
1275
- if (kind === 0) if (isPrivate) {
1276
- get = desc.get;
1277
- set = desc.set;
1278
- } else {
1279
- get = function() {
1280
- return this[name];
1281
- };
1282
- set = function(v) {
1283
- this[name] = v;
1284
- };
1285
- }
1286
- else if (kind === 2) get = function() {
1287
- return desc.value;
1288
- };
1289
- else {
1290
- if (kind === 1 || kind === 3) get = function() {
1291
- return desc.get.call(this);
1292
- };
1293
- if (kind === 1 || kind === 4) set = function(v) {
1294
- desc.set.call(this, v);
1295
- };
1296
- }
1297
- ctx.access = get && set ? {
1298
- get,
1299
- set
1300
- } : get ? { get } : { set };
1301
- try {
1302
- return dec(value, ctx);
1303
- } finally {
1304
- decoratorFinishedRef.v = true;
1305
- }
1306
- }
1307
- function assertNotFinished(decoratorFinishedRef, fnName) {
1308
- if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
1309
- }
1310
- function assertCallable(fn, hint) {
1311
- if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
1312
- }
1313
- function assertValidReturnValue(kind, value) {
1314
- var type = typeof value;
1315
- if (kind === 1) {
1316
- if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
1317
- if (value.get !== void 0) assertCallable(value.get, "accessor.get");
1318
- if (value.set !== void 0) assertCallable(value.set, "accessor.set");
1319
- if (value.init !== void 0) assertCallable(value.init, "accessor.init");
1320
- } else if (type !== "function") {
1321
- var hint;
1322
- if (kind === 0) hint = "field";
1323
- else if (kind === 10) hint = "class";
1324
- else hint = "method";
1325
- throw new TypeError(hint + " decorators must return a function or void 0");
1326
- }
1327
- }
1328
- function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
1329
- var decs = decInfo[0];
1330
- var desc, init, value;
1331
- if (isPrivate) if (kind === 0 || kind === 1) desc = {
1332
- get: decInfo[3],
1333
- set: decInfo[4]
1334
- };
1335
- else if (kind === 3) desc = { get: decInfo[3] };
1336
- else if (kind === 4) desc = { set: decInfo[3] };
1337
- else desc = { value: decInfo[3] };
1338
- else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
1339
- if (kind === 1) value = {
1340
- get: desc.get,
1341
- set: desc.set
1342
- };
1343
- else if (kind === 2) value = desc.value;
1344
- else if (kind === 3) value = desc.get;
1345
- else if (kind === 4) value = desc.set;
1346
- var newValue, get, set;
1347
- if (typeof decs === "function") {
1348
- newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
1349
- if (newValue !== void 0) {
1350
- assertValidReturnValue(kind, newValue);
1351
- if (kind === 0) init = newValue;
1352
- else if (kind === 1) {
1353
- init = newValue.init;
1354
- get = newValue.get || value.get;
1355
- set = newValue.set || value.set;
1356
- value = {
1357
- get,
1358
- set
1359
- };
1360
- } else value = newValue;
1361
- }
1362
- } else for (var i = decs.length - 1; i >= 0; i--) {
1363
- var dec = decs[i];
1364
- newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
1365
- if (newValue !== void 0) {
1366
- assertValidReturnValue(kind, newValue);
1367
- var newInit;
1368
- if (kind === 0) newInit = newValue;
1369
- else if (kind === 1) {
1370
- newInit = newValue.init;
1371
- get = newValue.get || value.get;
1372
- set = newValue.set || value.set;
1373
- value = {
1374
- get,
1375
- set
1376
- };
1377
- } else value = newValue;
1378
- if (newInit !== void 0) if (init === void 0) init = newInit;
1379
- else if (typeof init === "function") init = [init, newInit];
1380
- else init.push(newInit);
1381
- }
1382
- }
1383
- if (kind === 0 || kind === 1) {
1384
- if (init === void 0) init = function(instance, init$1) {
1385
- return init$1;
1386
- };
1387
- else if (typeof init !== "function") {
1388
- var ownInitializers = init;
1389
- init = function(instance, init$1) {
1390
- var value$1 = init$1;
1391
- for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
1392
- return value$1;
1393
- };
1394
- } else {
1395
- var originalInitializer = init;
1396
- init = function(instance, init$1) {
1397
- return originalInitializer.call(instance, init$1);
1398
- };
1399
- }
1400
- ret.push(init);
1401
- }
1402
- if (kind !== 0) {
1403
- if (kind === 1) {
1404
- desc.get = value.get;
1405
- desc.set = value.set;
1406
- } else if (kind === 2) desc.value = value;
1407
- else if (kind === 3) desc.get = value;
1408
- else if (kind === 4) desc.set = value;
1409
- if (isPrivate) if (kind === 1) {
1410
- ret.push(function(instance, args) {
1411
- return value.get.call(instance, args);
1412
- });
1413
- ret.push(function(instance, args) {
1414
- return value.set.call(instance, args);
1415
- });
1416
- } else if (kind === 2) ret.push(value);
1417
- else ret.push(function(instance, args) {
1418
- return value.call(instance, args);
1419
- });
1420
- else Object.defineProperty(base, name, desc);
1421
- }
1422
- }
1423
- function applyMemberDecs(Class, decInfos, metadata) {
1424
- var ret = [];
1425
- var protoInitializers;
1426
- var staticInitializers;
1427
- var existingProtoNonFields = /* @__PURE__ */ new Map();
1428
- var existingStaticNonFields = /* @__PURE__ */ new Map();
1429
- for (var i = 0; i < decInfos.length; i++) {
1430
- var decInfo = decInfos[i];
1431
- if (!Array.isArray(decInfo)) continue;
1432
- var kind = decInfo[1];
1433
- var name = decInfo[2];
1434
- var isPrivate = decInfo.length > 3;
1435
- var isStatic = kind >= 5;
1436
- var base;
1437
- var initializers;
1438
- if (isStatic) {
1439
- base = Class;
1440
- kind = kind - 5;
1441
- staticInitializers = staticInitializers || [];
1442
- initializers = staticInitializers;
1443
- } else {
1444
- base = Class.prototype;
1445
- protoInitializers = protoInitializers || [];
1446
- initializers = protoInitializers;
1447
- }
1448
- if (kind !== 0 && !isPrivate) {
1449
- var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
1450
- var existingKind = existingNonFields.get(name) || 0;
1451
- if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
1452
- else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
1453
- else existingNonFields.set(name, true);
1454
- }
1455
- applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
1456
- }
1457
- pushInitializers(ret, protoInitializers);
1458
- pushInitializers(ret, staticInitializers);
1459
- return ret;
1460
- }
1461
- function pushInitializers(ret, initializers) {
1462
- if (initializers) ret.push(function(instance) {
1463
- for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
1464
- return instance;
1465
- });
1466
- }
1467
- function applyClassDecs(targetClass, classDecs, metadata) {
1468
- if (classDecs.length > 0) {
1469
- var initializers = [];
1470
- var newClass = targetClass;
1471
- var name = targetClass.name;
1472
- for (var i = classDecs.length - 1; i >= 0; i--) {
1473
- var decoratorFinishedRef = { v: false };
1474
- try {
1475
- var nextNewClass = classDecs[i](newClass, {
1476
- kind: "class",
1477
- name,
1478
- addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
1479
- metadata
1480
- });
1481
- } finally {
1482
- decoratorFinishedRef.v = true;
1483
- }
1484
- if (nextNewClass !== void 0) {
1485
- assertValidReturnValue(10, nextNewClass);
1486
- newClass = nextNewClass;
1487
- }
1488
- }
1489
- return [defineMetadata(newClass, metadata), function() {
1490
- for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
1491
- }];
1492
- }
1493
- }
1494
- function defineMetadata(Class, metadata) {
1495
- return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
1496
- configurable: true,
1497
- enumerable: true,
1498
- value: metadata
1499
- });
1500
- }
1501
- return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
1502
- if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
1503
- var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
1504
- var e = applyMemberDecs(targetClass, memberDecs, metadata);
1505
- if (!classDecs.length) defineMetadata(targetClass, metadata);
1506
- return {
1507
- e,
1508
- get c() {
1509
- return applyClassDecs(targetClass, classDecs, metadata);
1510
- }
1511
- };
1512
- };
1513
- }
1514
- function _apply_decs_2203_r$5(targetClass, memberDecs, classDecs, parentClass) {
1515
- return (_apply_decs_2203_r$5 = applyDecs2203RFactory$5())(targetClass, memberDecs, classDecs, parentClass);
1516
- }
1517
- var _dec$5, _initClass$5;
1518
- let _ErrorResponseProducerService;
1519
- _dec$5 = Injectable();
1520
- var ErrorResponseProducerService = class {
1521
- static {
1522
- ({c: [_ErrorResponseProducerService, _initClass$5]} = _apply_decs_2203_r$5(this, [], [_dec$5]));
1523
- }
1524
- forbiddenResponder = inject(ForbiddenResponderToken);
1525
- internalServerErrorResponder = inject(InternalServerErrorResponderToken);
1526
- notFoundResponder = inject(NotFoundResponderToken);
1527
- validationErrorResponder = inject(ValidationErrorResponderToken);
1528
- /**
1529
- * Produces an error response for a specific framework error type.
1530
- *
1531
- * @param type - The type of framework error (from FrameworkError enum)
1532
- * @param error - The original error that was thrown
1533
- * @param description - Optional custom description to include in the response
1534
- * @returns ErrorResponse with status code, RFC 7807 payload, and headers
1535
- */ respond(type, error, description) {
1536
- switch (type) {
1537
- case FrameworkError.NotFound: return this.notFoundResponder.getResponse(error, description);
1538
- case FrameworkError.Forbidden: return this.forbiddenResponder.getResponse(error, description);
1539
- case FrameworkError.InternalServerError: return this.internalServerErrorResponder.getResponse(error, description);
1540
- case FrameworkError.ValidationError: return this.validationErrorResponder.getResponse(error, description);
1541
- }
1542
- }
1543
- /**
1544
- * Handles unknown errors by producing an Internal Server Error response.
1545
- *
1546
- * Use this as a fallback when the error type is not known or doesn't
1547
- * match any specific framework error type.
1548
- *
1549
- * @param error - The original error that was thrown
1550
- * @param description - Optional custom description to include in the response
1551
- * @returns ErrorResponse with 500 status code
1552
- */ handleUnknown(error, description) {
1553
- return this.internalServerErrorResponder.getResponse(error, description);
1554
- }
1555
- /**
1556
- * Convenience method to produce a Not Found error response.
1557
- *
1558
- * @param error - The original error that was thrown
1559
- * @param description - Optional custom description
1560
- * @returns ErrorResponse with 404 status code
1561
- */ notFound(error, description) {
1562
- return this.notFoundResponder.getResponse(error, description);
1563
- }
1564
- /**
1565
- * Convenience method to produce a Validation Error response.
1566
- *
1567
- * @param error - The original error (typically a ZodError)
1568
- * @param description - Optional custom description
1569
- * @returns ErrorResponse with 400 status code
1570
- */ validationError(error, description) {
1571
- return this.validationErrorResponder.getResponse(error, description);
1572
- }
1573
- /**
1574
- * Convenience method to produce an Internal Server Error response.
1575
- *
1576
- * @param error - The original error
1577
- * @param description - Optional custom description
1578
- * @returns ErrorResponse with 500 status code
1579
- */ internalServerError(error, description) {
1580
- return this.internalServerErrorResponder.getResponse(error, description);
1581
- }
1582
- /**
1583
- * Convenience method to produce a Forbidden error response.
1584
- *
1585
- * @param error - The original error
1586
- * @param description - Optional custom description
1587
- * @returns ErrorResponse with 403 status code
1588
- */ forbidden(error, description) {
1589
- return this.forbiddenResponder.getResponse(error, description);
1590
- }
1591
- static {
1592
- _initClass$5();
1593
- }
1594
- };
1595
-
1596
- //#endregion
1597
- //#region src/services/instance-resolver.service.mts
1598
- function applyDecs2203RFactory$4() {
1599
- function createAddInitializerMethod(initializers, decoratorFinishedRef) {
1600
- return function addInitializer(initializer) {
1601
- assertNotFinished(decoratorFinishedRef, "addInitializer");
1602
- assertCallable(initializer, "An initializer");
1603
- initializers.push(initializer);
1604
- };
1605
- }
1606
- function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
1607
- var kindStr;
1608
- switch (kind) {
1609
- case 1:
1610
- kindStr = "accessor";
1611
- break;
1612
- case 2:
1613
- kindStr = "method";
1614
- break;
1615
- case 3:
1616
- kindStr = "getter";
1617
- break;
1618
- case 4:
1619
- kindStr = "setter";
1620
- break;
1621
- default: kindStr = "field";
1622
- }
1623
- var ctx = {
1624
- kind: kindStr,
1625
- name: isPrivate ? "#" + name : name,
1626
- static: isStatic,
1627
- private: isPrivate,
1628
- metadata
1629
- };
1630
- var decoratorFinishedRef = { v: false };
1631
- ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
1632
- var get, set;
1633
- if (kind === 0) if (isPrivate) {
1634
- get = desc.get;
1635
- set = desc.set;
1636
- } else {
1637
- get = function() {
1638
- return this[name];
1639
- };
1640
- set = function(v) {
1641
- this[name] = v;
1642
- };
1643
- }
1644
- else if (kind === 2) get = function() {
1645
- return desc.value;
1646
- };
1647
- else {
1648
- if (kind === 1 || kind === 3) get = function() {
1649
- return desc.get.call(this);
1650
- };
1651
- if (kind === 1 || kind === 4) set = function(v) {
1652
- desc.set.call(this, v);
1653
- };
1654
- }
1655
- ctx.access = get && set ? {
1656
- get,
1657
- set
1658
- } : get ? { get } : { set };
1659
- try {
1660
- return dec(value, ctx);
1661
- } finally {
1662
- decoratorFinishedRef.v = true;
1663
- }
1664
- }
1665
- function assertNotFinished(decoratorFinishedRef, fnName) {
1666
- if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
1667
- }
1668
- function assertCallable(fn, hint) {
1669
- if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
1670
- }
1671
- function assertValidReturnValue(kind, value) {
1672
- var type = typeof value;
1673
- if (kind === 1) {
1674
- if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
1675
- if (value.get !== void 0) assertCallable(value.get, "accessor.get");
1676
- if (value.set !== void 0) assertCallable(value.set, "accessor.set");
1677
- if (value.init !== void 0) assertCallable(value.init, "accessor.init");
1678
- } else if (type !== "function") {
1679
- var hint;
1680
- if (kind === 0) hint = "field";
1681
- else if (kind === 10) hint = "class";
1682
- else hint = "method";
1683
- throw new TypeError(hint + " decorators must return a function or void 0");
1684
- }
1685
- }
1686
- function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
1687
- var decs = decInfo[0];
1688
- var desc, init, value;
1689
- if (isPrivate) if (kind === 0 || kind === 1) desc = {
1690
- get: decInfo[3],
1691
- set: decInfo[4]
1692
- };
1693
- else if (kind === 3) desc = { get: decInfo[3] };
1694
- else if (kind === 4) desc = { set: decInfo[3] };
1695
- else desc = { value: decInfo[3] };
1696
- else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
1697
- if (kind === 1) value = {
1698
- get: desc.get,
1699
- set: desc.set
1700
- };
1701
- else if (kind === 2) value = desc.value;
1702
- else if (kind === 3) value = desc.get;
1703
- else if (kind === 4) value = desc.set;
1704
- var newValue, get, set;
1705
- if (typeof decs === "function") {
1706
- newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
1707
- if (newValue !== void 0) {
1708
- assertValidReturnValue(kind, newValue);
1709
- if (kind === 0) init = newValue;
1710
- else if (kind === 1) {
1711
- init = newValue.init;
1712
- get = newValue.get || value.get;
1713
- set = newValue.set || value.set;
1714
- value = {
1715
- get,
1716
- set
1717
- };
1718
- } else value = newValue;
1719
- }
1720
- } else for (var i = decs.length - 1; i >= 0; i--) {
1721
- var dec = decs[i];
1722
- newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
1723
- if (newValue !== void 0) {
1724
- assertValidReturnValue(kind, newValue);
1725
- var newInit;
1726
- if (kind === 0) newInit = newValue;
1727
- else if (kind === 1) {
1728
- newInit = newValue.init;
1729
- get = newValue.get || value.get;
1730
- set = newValue.set || value.set;
1731
- value = {
1732
- get,
1733
- set
1734
- };
1735
- } else value = newValue;
1736
- if (newInit !== void 0) if (init === void 0) init = newInit;
1737
- else if (typeof init === "function") init = [init, newInit];
1738
- else init.push(newInit);
1739
- }
1740
- }
1741
- if (kind === 0 || kind === 1) {
1742
- if (init === void 0) init = function(instance, init$1) {
1743
- return init$1;
1744
- };
1745
- else if (typeof init !== "function") {
1746
- var ownInitializers = init;
1747
- init = function(instance, init$1) {
1748
- var value$1 = init$1;
1749
- for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
1750
- return value$1;
1751
- };
1752
- } else {
1753
- var originalInitializer = init;
1754
- init = function(instance, init$1) {
1755
- return originalInitializer.call(instance, init$1);
1756
- };
1757
- }
1758
- ret.push(init);
1759
- }
1760
- if (kind !== 0) {
1761
- if (kind === 1) {
1762
- desc.get = value.get;
1763
- desc.set = value.set;
1764
- } else if (kind === 2) desc.value = value;
1765
- else if (kind === 3) desc.get = value;
1766
- else if (kind === 4) desc.set = value;
1767
- if (isPrivate) if (kind === 1) {
1768
- ret.push(function(instance, args) {
1769
- return value.get.call(instance, args);
1770
- });
1771
- ret.push(function(instance, args) {
1772
- return value.set.call(instance, args);
1773
- });
1774
- } else if (kind === 2) ret.push(value);
1775
- else ret.push(function(instance, args) {
1776
- return value.call(instance, args);
1777
- });
1778
- else Object.defineProperty(base, name, desc);
1779
- }
1780
- }
1781
- function applyMemberDecs(Class, decInfos, metadata) {
1782
- var ret = [];
1783
- var protoInitializers;
1784
- var staticInitializers;
1785
- var existingProtoNonFields = /* @__PURE__ */ new Map();
1786
- var existingStaticNonFields = /* @__PURE__ */ new Map();
1787
- for (var i = 0; i < decInfos.length; i++) {
1788
- var decInfo = decInfos[i];
1789
- if (!Array.isArray(decInfo)) continue;
1790
- var kind = decInfo[1];
1791
- var name = decInfo[2];
1792
- var isPrivate = decInfo.length > 3;
1793
- var isStatic = kind >= 5;
1794
- var base;
1795
- var initializers;
1796
- if (isStatic) {
1797
- base = Class;
1798
- kind = kind - 5;
1799
- staticInitializers = staticInitializers || [];
1800
- initializers = staticInitializers;
1801
- } else {
1802
- base = Class.prototype;
1803
- protoInitializers = protoInitializers || [];
1804
- initializers = protoInitializers;
1805
- }
1806
- if (kind !== 0 && !isPrivate) {
1807
- var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
1808
- var existingKind = existingNonFields.get(name) || 0;
1809
- if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
1810
- else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
1811
- else existingNonFields.set(name, true);
1812
- }
1813
- applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
1814
- }
1815
- pushInitializers(ret, protoInitializers);
1816
- pushInitializers(ret, staticInitializers);
1817
- return ret;
1818
- }
1819
- function pushInitializers(ret, initializers) {
1820
- if (initializers) ret.push(function(instance) {
1821
- for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
1822
- return instance;
1823
- });
1824
- }
1825
- function applyClassDecs(targetClass, classDecs, metadata) {
1826
- if (classDecs.length > 0) {
1827
- var initializers = [];
1828
- var newClass = targetClass;
1829
- var name = targetClass.name;
1830
- for (var i = classDecs.length - 1; i >= 0; i--) {
1831
- var decoratorFinishedRef = { v: false };
1832
- try {
1833
- var nextNewClass = classDecs[i](newClass, {
1834
- kind: "class",
1835
- name,
1836
- addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
1837
- metadata
1838
- });
1839
- } finally {
1840
- decoratorFinishedRef.v = true;
1841
- }
1842
- if (nextNewClass !== void 0) {
1843
- assertValidReturnValue(10, nextNewClass);
1844
- newClass = nextNewClass;
1845
- }
1846
- }
1847
- return [defineMetadata(newClass, metadata), function() {
1848
- for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
1849
- }];
1850
- }
1851
- }
1852
- function defineMetadata(Class, metadata) {
1853
- return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
1854
- configurable: true,
1855
- enumerable: true,
1856
- value: metadata
1857
- });
1858
- }
1859
- return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
1860
- if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
1861
- var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
1862
- var e = applyMemberDecs(targetClass, memberDecs, metadata);
1863
- if (!classDecs.length) defineMetadata(targetClass, metadata);
1864
- return {
1865
- e,
1866
- get c() {
1867
- return applyClassDecs(targetClass, classDecs, metadata);
1868
- }
1869
- };
1870
- };
1871
- }
1872
- function _apply_decs_2203_r$4(targetClass, memberDecs, classDecs, parentClass) {
1873
- return (_apply_decs_2203_r$4 = applyDecs2203RFactory$4())(targetClass, memberDecs, classDecs, parentClass);
1874
- }
1875
- var _dec$4, _initClass$4;
1876
- let _InstanceResolverService;
1877
- _dec$4 = Injectable();
1878
- var InstanceResolverService = class {
1879
- static {
1880
- ({c: [_InstanceResolverService, _initClass$4]} = _apply_decs_2203_r$4(this, [], [_dec$4]));
1881
- }
1882
- container = inject(Container);
1883
- /**
1884
- * Attempts to resolve a class instance, automatically detecting if it needs
1885
- * request scope based on its dependencies.
1886
- *
1887
- * @param classType - The class to resolve
1888
- * @returns A resolution result containing either a cached instance or resolver function
1889
- */ async resolve(classType) {
1890
- let cachedInstance = null;
1891
- try {
1892
- cachedInstance = await this.container.get(classType);
1893
- } catch {
1894
- const token = getInjectableToken(classType);
1895
- this.container.getRegistry().updateScope(token, InjectableScope.Request);
1896
- }
1897
- return {
1898
- cached: cachedInstance !== null,
1899
- instance: cachedInstance,
1900
- resolve: (scoped) => scoped.get(classType)
1901
- };
1902
- }
1903
- /**
1904
- * Attempts to resolve multiple class instances, automatically detecting if any need
1905
- * request scope based on their dependencies.
1906
- *
1907
- * Returns `cached: true` only if ALL classes can be resolved as singletons.
1908
- * If any class has request-scoped dependencies, returns `cached: false`.
1909
- *
1910
- * @param classTypes - The classes to resolve
1911
- * @returns A resolution result containing either all cached instances or resolver function
1912
- */ async resolveMany(classTypes) {
1913
- if (classTypes.length === 0) return {
1914
- cached: true,
1915
- instances: [],
1916
- classTypes: [],
1917
- resolve: async () => []
1918
- };
1919
- const results = await Promise.all(classTypes.map(async (classType) => {
1920
- try {
1921
- return {
1922
- success: true,
1923
- instance: await this.container.get(classType)
1924
- };
1925
- } catch {
1926
- const token = getInjectableToken(classType);
1927
- this.container.getRegistry().updateScope(token, InjectableScope.Request);
1928
- return {
1929
- success: false,
1930
- instance: null
1931
- };
1932
- }
1933
- }));
1934
- const allCached = results.every((r) => r.success);
1935
- return {
1936
- cached: allCached,
1937
- instances: allCached ? results.map((r) => r.instance) : null,
1938
- classTypes,
1939
- resolve: (scoped) => Promise.all(classTypes.map((classType) => scoped.get(classType)))
1940
- };
1941
- }
1942
- static {
1943
- _initClass$4();
1944
- }
1945
- };
1946
-
1947
- //#endregion
1948
- //#region src/services/abstract-handler-adapter.service.mts
1949
- const defaultOptions = {
1950
- adapter: [],
1951
- validateResponses: true,
1952
- enableRequestId: false
1953
- };
1954
- /**
1955
- * Abstract base class for HTTP handler adapter services.
1956
- *
1957
- * Provides shared logic for:
1958
- * - Controller resolution (singleton vs request-scoped)
1959
- * - Argument formatting (sync/async detection)
1960
- * - Handler generation with static/dynamic branching
1961
- * - Standardized error handling
1962
- *
1963
- * Adapters implement abstract methods for framework-specific behavior:
1964
- * - Request parsing (query, body, URL params)
1965
- * - Response creation
1966
- * - Schema provision
1967
- *
1968
- * Supports all adapter types:
1969
- * - Endpoint adapters: JSON request/response with validation
1970
- * - Stream adapters: Streaming responses with extra context
1971
- * - Multipart adapters: Form data parsing (extends endpoint)
1972
- *
1973
- * @typeParam TRequest - Framework request type (BunRequest, FastifyRequest)
1974
- * @typeParam TReply - Framework reply type (void for Bun, FastifyReply)
1975
- * @typeParam TConfig - Endpoint configuration type
1976
- */ var AbstractHandlerAdapterService = class {
1977
- instanceResolver = inject(_InstanceResolverService);
1978
- options = optional(NaviosOptionsToken) ?? defaultOptions;
1979
- /**
1980
- * Prepares argument getters for parsing request data.
1981
- *
1982
- * Public alias for createArgumentGetters to satisfy interface contracts.
1983
- * Subclasses should override createArgumentGetters instead.
1984
- *
1985
- * @param handlerMetadata - Handler metadata with schemas and configuration
1986
- * @returns Array of getter functions
1987
- */ prepareArguments(handlerMetadata) {
1988
- return this.createArgumentGetters(handlerMetadata);
1989
- }
1990
- /**
1991
- * Checks if the handler has any validation schemas defined.
1992
- *
1993
- * Override in subclasses to add additional schema checks
1994
- * (e.g., response schema validation for endpoint adapters).
1995
- *
1996
- * @param handlerMetadata - Handler metadata with configuration
1997
- * @returns true if handler has schemas
1998
- */ hasSchema(handlerMetadata) {
1999
- const config = handlerMetadata.config;
2000
- return !!config.requestSchema || !!config.querySchema;
2001
- }
2002
- /**
2003
- * Provides schema information for the framework's validation system.
2004
- *
2005
- * Override in subclasses for frameworks that support schema registration
2006
- * (e.g., Fastify). Default returns empty object (suitable for Bun).
2007
- *
2008
- * @param handlerMetadata - Handler metadata with configuration
2009
- * @returns Schema object for framework registration
2010
- */ provideSchema(_handlerMetadata) {
2011
- return {};
2012
- }
2013
- /**
2014
- * Creates a request handler function for the endpoint.
2015
- *
2016
- * This method orchestrates the entire handler creation:
2017
- * 1. Prepares argument getters for request parsing
2018
- * 2. Builds optimized formatArguments function (sync/async)
2019
- * 3. Resolves the controller (singleton vs request-scoped)
2020
- * 4. Creates appropriate handler (static or dynamic)
2021
- *
2022
- * @param controller - Controller class containing the handler method
2023
- * @param handlerMetadata - Handler metadata with configuration
2024
- * @returns Handler result (static or dynamic)
2025
- */ async provideHandler(controller, handlerMetadata) {
2026
- const getters = this.createArgumentGetters(handlerMetadata);
2027
- const formatArguments = this.buildFormatArguments(getters);
2028
- const hasArguments = getters.length > 0;
2029
- const context = {
2030
- methodName: handlerMetadata.classMethod,
2031
- statusCode: handlerMetadata.successStatusCode,
2032
- headers: handlerMetadata.headers,
2033
- handlerMetadata,
2034
- hasArguments
2035
- };
2036
- const resolution = await this.instanceResolver.resolve(controller);
2037
- if (resolution.cached) {
2038
- const cachedController = resolution.instance;
2039
- const boundMethod = cachedController[context.methodName].bind(cachedController);
2040
- return this.createStaticHandler(boundMethod, formatArguments, context);
2041
- }
2042
- return this.createDynamicHandler(resolution, formatArguments, context);
2043
- }
2044
- /**
2045
- * Builds a formatArguments function from argument getters.
2046
- *
2047
- * Automatically detects sync vs async getters and optimizes accordingly:
2048
- * - If all getters are sync: returns sync function (no Promise overhead)
2049
- * - If any getter is async: returns async function with Promise.all
2050
- * - If no getters: returns frozen empty object (zero allocation)
2051
- *
2052
- * This method is public to allow composition-based adapters (like XML adapter)
2053
- * to reuse the optimized formatArguments logic without inheritance.
2054
- *
2055
- * @param getters - Array of argument getter functions
2056
- * @returns Function to format arguments from request
2057
- */ buildFormatArguments(getters) {
2058
- if (getters.length === 0) {
2059
- const emptyArgs = Object.freeze({});
2060
- return () => emptyArgs;
2061
- }
2062
- if (getters.some((g) => g.constructor.name === "AsyncFunction")) return async (request) => {
2063
- const argument = {};
2064
- const promises = [];
2065
- for (const getter of getters) {
2066
- const res = getter(argument, request);
2067
- if (res instanceof Promise) promises.push(res);
2068
- }
2069
- await Promise.all(promises);
2070
- return argument;
2071
- };
2072
- return (request) => {
2073
- const argument = {};
2074
- for (const getter of getters) getter(argument, request);
2075
- return argument;
2076
- };
2077
- }
2078
- /**
2079
- * Checks if the URL pattern contains URL parameters.
2080
- *
2081
- * @param config - Endpoint configuration
2082
- * @returns true if URL contains '$' parameter markers
2083
- */ hasUrlParams(config) {
2084
- return config.url.includes("$");
2085
- }
2086
- /**
2087
- * Wraps handler execution with standardized error handling.
2088
- *
2089
- * Re-throws HttpExceptions as-is for framework error handlers.
2090
- * Other errors are re-thrown for global error handling.
2091
- *
2092
- * @param fn - Handler function to wrap
2093
- * @returns Wrapped function with error handling
2094
- */ wrapWithErrorHandling(fn) {
2095
- return async (...args) => {
2096
- try {
2097
- return await fn(...args);
2098
- } catch (error) {
2099
- if (error && typeof error === "object" && "statusCode" in error) throw error;
2100
- throw error;
2101
- }
2102
- };
2103
- }
2104
- };
2105
-
2106
- //#endregion
2107
- //#region src/services/guard-runner.service.mts
2108
- function applyDecs2203RFactory$3() {
2109
- function createAddInitializerMethod(initializers, decoratorFinishedRef) {
2110
- return function addInitializer(initializer) {
2111
- assertNotFinished(decoratorFinishedRef, "addInitializer");
2112
- assertCallable(initializer, "An initializer");
2113
- initializers.push(initializer);
2114
- };
2115
- }
2116
- function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
2117
- var kindStr;
2118
- switch (kind) {
2119
- case 1:
2120
- kindStr = "accessor";
2121
- break;
2122
- case 2:
2123
- kindStr = "method";
2124
- break;
2125
- case 3:
2126
- kindStr = "getter";
2127
- break;
2128
- case 4:
2129
- kindStr = "setter";
2130
- break;
2131
- default: kindStr = "field";
2132
- }
2133
- var ctx = {
2134
- kind: kindStr,
2135
- name: isPrivate ? "#" + name : name,
2136
- static: isStatic,
2137
- private: isPrivate,
2138
- metadata
2139
- };
2140
- var decoratorFinishedRef = { v: false };
2141
- ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
2142
- var get, set;
2143
- if (kind === 0) if (isPrivate) {
2144
- get = desc.get;
2145
- set = desc.set;
2146
- } else {
2147
- get = function() {
2148
- return this[name];
2149
- };
2150
- set = function(v) {
2151
- this[name] = v;
2152
- };
2153
- }
2154
- else if (kind === 2) get = function() {
2155
- return desc.value;
2156
- };
2157
- else {
2158
- if (kind === 1 || kind === 3) get = function() {
2159
- return desc.get.call(this);
2160
- };
2161
- if (kind === 1 || kind === 4) set = function(v) {
2162
- desc.set.call(this, v);
2163
- };
2164
- }
2165
- ctx.access = get && set ? {
2166
- get,
2167
- set
2168
- } : get ? { get } : { set };
2169
- try {
2170
- return dec(value, ctx);
2171
- } finally {
2172
- decoratorFinishedRef.v = true;
2173
- }
2174
- }
2175
- function assertNotFinished(decoratorFinishedRef, fnName) {
2176
- if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
2177
- }
2178
- function assertCallable(fn, hint) {
2179
- if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
2180
- }
2181
- function assertValidReturnValue(kind, value) {
2182
- var type = typeof value;
2183
- if (kind === 1) {
2184
- if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
2185
- if (value.get !== void 0) assertCallable(value.get, "accessor.get");
2186
- if (value.set !== void 0) assertCallable(value.set, "accessor.set");
2187
- if (value.init !== void 0) assertCallable(value.init, "accessor.init");
2188
- } else if (type !== "function") {
2189
- var hint;
2190
- if (kind === 0) hint = "field";
2191
- else if (kind === 10) hint = "class";
2192
- else hint = "method";
2193
- throw new TypeError(hint + " decorators must return a function or void 0");
2194
- }
2195
- }
2196
- function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
2197
- var decs = decInfo[0];
2198
- var desc, init, value;
2199
- if (isPrivate) if (kind === 0 || kind === 1) desc = {
2200
- get: decInfo[3],
2201
- set: decInfo[4]
2202
- };
2203
- else if (kind === 3) desc = { get: decInfo[3] };
2204
- else if (kind === 4) desc = { set: decInfo[3] };
2205
- else desc = { value: decInfo[3] };
2206
- else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
2207
- if (kind === 1) value = {
2208
- get: desc.get,
2209
- set: desc.set
2210
- };
2211
- else if (kind === 2) value = desc.value;
2212
- else if (kind === 3) value = desc.get;
2213
- else if (kind === 4) value = desc.set;
2214
- var newValue, get, set;
2215
- if (typeof decs === "function") {
2216
- newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
2217
- if (newValue !== void 0) {
2218
- assertValidReturnValue(kind, newValue);
2219
- if (kind === 0) init = newValue;
2220
- else if (kind === 1) {
2221
- init = newValue.init;
2222
- get = newValue.get || value.get;
2223
- set = newValue.set || value.set;
2224
- value = {
2225
- get,
2226
- set
2227
- };
2228
- } else value = newValue;
2229
- }
2230
- } else for (var i = decs.length - 1; i >= 0; i--) {
2231
- var dec = decs[i];
2232
- newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
2233
- if (newValue !== void 0) {
2234
- assertValidReturnValue(kind, newValue);
2235
- var newInit;
2236
- if (kind === 0) newInit = newValue;
2237
- else if (kind === 1) {
2238
- newInit = newValue.init;
2239
- get = newValue.get || value.get;
2240
- set = newValue.set || value.set;
2241
- value = {
2242
- get,
2243
- set
2244
- };
2245
- } else value = newValue;
2246
- if (newInit !== void 0) if (init === void 0) init = newInit;
2247
- else if (typeof init === "function") init = [init, newInit];
2248
- else init.push(newInit);
2249
- }
2250
- }
2251
- if (kind === 0 || kind === 1) {
2252
- if (init === void 0) init = function(instance, init$1) {
2253
- return init$1;
2254
- };
2255
- else if (typeof init !== "function") {
2256
- var ownInitializers = init;
2257
- init = function(instance, init$1) {
2258
- var value$1 = init$1;
2259
- for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
2260
- return value$1;
2261
- };
2262
- } else {
2263
- var originalInitializer = init;
2264
- init = function(instance, init$1) {
2265
- return originalInitializer.call(instance, init$1);
2266
- };
2267
- }
2268
- ret.push(init);
2269
- }
2270
- if (kind !== 0) {
2271
- if (kind === 1) {
2272
- desc.get = value.get;
2273
- desc.set = value.set;
2274
- } else if (kind === 2) desc.value = value;
2275
- else if (kind === 3) desc.get = value;
2276
- else if (kind === 4) desc.set = value;
2277
- if (isPrivate) if (kind === 1) {
2278
- ret.push(function(instance, args) {
2279
- return value.get.call(instance, args);
2280
- });
2281
- ret.push(function(instance, args) {
2282
- return value.set.call(instance, args);
2283
- });
2284
- } else if (kind === 2) ret.push(value);
2285
- else ret.push(function(instance, args) {
2286
- return value.call(instance, args);
2287
- });
2288
- else Object.defineProperty(base, name, desc);
2289
- }
2290
- }
2291
- function applyMemberDecs(Class, decInfos, metadata) {
2292
- var ret = [];
2293
- var protoInitializers;
2294
- var staticInitializers;
2295
- var existingProtoNonFields = /* @__PURE__ */ new Map();
2296
- var existingStaticNonFields = /* @__PURE__ */ new Map();
2297
- for (var i = 0; i < decInfos.length; i++) {
2298
- var decInfo = decInfos[i];
2299
- if (!Array.isArray(decInfo)) continue;
2300
- var kind = decInfo[1];
2301
- var name = decInfo[2];
2302
- var isPrivate = decInfo.length > 3;
2303
- var isStatic = kind >= 5;
2304
- var base;
2305
- var initializers;
2306
- if (isStatic) {
2307
- base = Class;
2308
- kind = kind - 5;
2309
- staticInitializers = staticInitializers || [];
2310
- initializers = staticInitializers;
2311
- } else {
2312
- base = Class.prototype;
2313
- protoInitializers = protoInitializers || [];
2314
- initializers = protoInitializers;
2315
- }
2316
- if (kind !== 0 && !isPrivate) {
2317
- var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
2318
- var existingKind = existingNonFields.get(name) || 0;
2319
- if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
2320
- else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
2321
- else existingNonFields.set(name, true);
2322
- }
2323
- applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
2324
- }
2325
- pushInitializers(ret, protoInitializers);
2326
- pushInitializers(ret, staticInitializers);
2327
- return ret;
2328
- }
2329
- function pushInitializers(ret, initializers) {
2330
- if (initializers) ret.push(function(instance) {
2331
- for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
2332
- return instance;
2333
- });
2334
- }
2335
- function applyClassDecs(targetClass, classDecs, metadata) {
2336
- if (classDecs.length > 0) {
2337
- var initializers = [];
2338
- var newClass = targetClass;
2339
- var name = targetClass.name;
2340
- for (var i = classDecs.length - 1; i >= 0; i--) {
2341
- var decoratorFinishedRef = { v: false };
2342
- try {
2343
- var nextNewClass = classDecs[i](newClass, {
2344
- kind: "class",
2345
- name,
2346
- addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
2347
- metadata
2348
- });
2349
- } finally {
2350
- decoratorFinishedRef.v = true;
2351
- }
2352
- if (nextNewClass !== void 0) {
2353
- assertValidReturnValue(10, nextNewClass);
2354
- newClass = nextNewClass;
2355
- }
2356
- }
2357
- return [defineMetadata(newClass, metadata), function() {
2358
- for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
2359
- }];
2360
- }
2361
- }
2362
- function defineMetadata(Class, metadata) {
2363
- return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
2364
- configurable: true,
2365
- enumerable: true,
2366
- value: metadata
2367
- });
2368
- }
2369
- return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
2370
- if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
2371
- var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
2372
- var e = applyMemberDecs(targetClass, memberDecs, metadata);
2373
- if (!classDecs.length) defineMetadata(targetClass, metadata);
2374
- return {
2375
- e,
2376
- get c() {
2377
- return applyClassDecs(targetClass, classDecs, metadata);
2378
- }
2379
- };
2380
- };
2381
- }
2382
- function _apply_decs_2203_r$3(targetClass, memberDecs, classDecs, parentClass) {
2383
- return (_apply_decs_2203_r$3 = applyDecs2203RFactory$3())(targetClass, memberDecs, classDecs, parentClass);
2384
- }
2385
- var _dec$3, _initClass$3;
2386
- let _GuardRunnerService;
2387
- _dec$3 = Injectable();
2388
- var GuardRunnerService = class {
2389
- static {
2390
- ({c: [_GuardRunnerService, _initClass$3]} = _apply_decs_2203_r$3(this, [], [_dec$3]));
2391
- }
2392
- errorProducer = inject(_ErrorResponseProducerService);
2393
- logger = inject(Logger, { context: _GuardRunnerService.name });
2394
- /**
2395
- * Runs guards that need to be resolved from a scoped container.
2396
- * Use this when guards have request-scoped dependencies.
2397
- */ async runGuards(allGuards, executionContext, context) {
2398
- const guardsArray = Array.from(allGuards).reverse();
2399
- const guardInstances = await Promise.all(guardsArray.map(async (guard) => {
2400
- const guardInstance = await context.get(guard);
2401
- if (!guardInstance.canActivate) throw new Error(`[Navios] Guard ${guard.name} does not implement canActivate()`);
2402
- return guardInstance;
2403
- }));
2404
- return this.executeGuards(guardInstances, executionContext);
2405
- }
2406
- /**
2407
- * Runs pre-resolved guard instances.
2408
- * Use this when all guards are singletons and have been pre-resolved at startup.
2409
- */ async runGuardsStatic(guardInstances, executionContext) {
2410
- return this.executeGuards(guardInstances, executionContext);
2411
- }
2412
- /**
2413
- * Shared guard execution logic.
2414
- * Iterates through guard instances and calls canActivate on each.
2415
- */ async executeGuards(guardInstances, executionContext) {
2416
- let canActivate = true;
2417
- for (const guardInstance of guardInstances) try {
2418
- canActivate = await guardInstance.canActivate(executionContext);
2419
- if (!canActivate) break;
2420
- } catch (error) {
2421
- if (error instanceof HttpException) {
2422
- executionContext.getReply().status(error.statusCode).send(error.response);
2423
- return false;
2424
- } else {
2425
- this.logger.error("Error running guard", error);
2426
- const errorResponse = this.errorProducer.respond(FrameworkError.InternalServerError, error);
2427
- executionContext.getReply().status(errorResponse.statusCode).send(errorResponse.payload);
2428
- return false;
2429
- }
2430
- }
2431
- if (!canActivate) {
2432
- const errorResponse = this.errorProducer.respond(FrameworkError.Forbidden, null);
2433
- executionContext.getReply().status(errorResponse.statusCode).send(errorResponse.payload);
2434
- return false;
2435
- }
2436
- return canActivate;
2437
- }
2438
- makeContext(moduleMetadata, controllerMetadata, endpoint) {
2439
- const guards = /* @__PURE__ */ new Set();
2440
- const endpointGuards = endpoint.guards;
2441
- const controllerGuards = controllerMetadata.guards;
2442
- const moduleGuards = moduleMetadata.guards;
2443
- if (endpointGuards.size > 0) for (const guard of endpointGuards) guards.add(guard);
2444
- if (controllerGuards.size > 0) for (const guard of controllerGuards) guards.add(guard);
2445
- if (moduleGuards.size > 0) for (const guard of moduleGuards) guards.add(guard);
2446
- return guards;
2447
- }
2448
- static {
2449
- _initClass$3();
2450
- }
2451
- };
2452
-
2453
- //#endregion
2454
- //#region src/services/module-loader.service.mts
2455
- function applyDecs2203RFactory$2() {
2456
- function createAddInitializerMethod(initializers, decoratorFinishedRef) {
2457
- return function addInitializer(initializer) {
2458
- assertNotFinished(decoratorFinishedRef, "addInitializer");
2459
- assertCallable(initializer, "An initializer");
2460
- initializers.push(initializer);
2461
- };
2462
- }
2463
- function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
2464
- var kindStr;
2465
- switch (kind) {
2466
- case 1:
2467
- kindStr = "accessor";
2468
- break;
2469
- case 2:
2470
- kindStr = "method";
2471
- break;
2472
- case 3:
2473
- kindStr = "getter";
2474
- break;
2475
- case 4:
2476
- kindStr = "setter";
2477
- break;
2478
- default: kindStr = "field";
2479
- }
2480
- var ctx = {
2481
- kind: kindStr,
2482
- name: isPrivate ? "#" + name : name,
2483
- static: isStatic,
2484
- private: isPrivate,
2485
- metadata
2486
- };
2487
- var decoratorFinishedRef = { v: false };
2488
- ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
2489
- var get, set;
2490
- if (kind === 0) if (isPrivate) {
2491
- get = desc.get;
2492
- set = desc.set;
2493
- } else {
2494
- get = function() {
2495
- return this[name];
2496
- };
2497
- set = function(v) {
2498
- this[name] = v;
2499
- };
2500
- }
2501
- else if (kind === 2) get = function() {
2502
- return desc.value;
2503
- };
2504
- else {
2505
- if (kind === 1 || kind === 3) get = function() {
2506
- return desc.get.call(this);
2507
- };
2508
- if (kind === 1 || kind === 4) set = function(v) {
2509
- desc.set.call(this, v);
2510
- };
2511
- }
2512
- ctx.access = get && set ? {
2513
- get,
2514
- set
2515
- } : get ? { get } : { set };
2516
- try {
2517
- return dec(value, ctx);
2518
- } finally {
2519
- decoratorFinishedRef.v = true;
2520
- }
2521
- }
2522
- function assertNotFinished(decoratorFinishedRef, fnName) {
2523
- if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
2524
- }
2525
- function assertCallable(fn, hint) {
2526
- if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
2527
- }
2528
- function assertValidReturnValue(kind, value) {
2529
- var type = typeof value;
2530
- if (kind === 1) {
2531
- if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
2532
- if (value.get !== void 0) assertCallable(value.get, "accessor.get");
2533
- if (value.set !== void 0) assertCallable(value.set, "accessor.set");
2534
- if (value.init !== void 0) assertCallable(value.init, "accessor.init");
2535
- } else if (type !== "function") {
2536
- var hint;
2537
- if (kind === 0) hint = "field";
2538
- else if (kind === 10) hint = "class";
2539
- else hint = "method";
2540
- throw new TypeError(hint + " decorators must return a function or void 0");
2541
- }
2542
- }
2543
- function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
2544
- var decs = decInfo[0];
2545
- var desc, init, value;
2546
- if (isPrivate) if (kind === 0 || kind === 1) desc = {
2547
- get: decInfo[3],
2548
- set: decInfo[4]
2549
- };
2550
- else if (kind === 3) desc = { get: decInfo[3] };
2551
- else if (kind === 4) desc = { set: decInfo[3] };
2552
- else desc = { value: decInfo[3] };
2553
- else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
2554
- if (kind === 1) value = {
2555
- get: desc.get,
2556
- set: desc.set
2557
- };
2558
- else if (kind === 2) value = desc.value;
2559
- else if (kind === 3) value = desc.get;
2560
- else if (kind === 4) value = desc.set;
2561
- var newValue, get, set;
2562
- if (typeof decs === "function") {
2563
- newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
2564
- if (newValue !== void 0) {
2565
- assertValidReturnValue(kind, newValue);
2566
- if (kind === 0) init = newValue;
2567
- else if (kind === 1) {
2568
- init = newValue.init;
2569
- get = newValue.get || value.get;
2570
- set = newValue.set || value.set;
2571
- value = {
2572
- get,
2573
- set
2574
- };
2575
- } else value = newValue;
2576
- }
2577
- } else for (var i = decs.length - 1; i >= 0; i--) {
2578
- var dec = decs[i];
2579
- newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
2580
- if (newValue !== void 0) {
2581
- assertValidReturnValue(kind, newValue);
2582
- var newInit;
2583
- if (kind === 0) newInit = newValue;
2584
- else if (kind === 1) {
2585
- newInit = newValue.init;
2586
- get = newValue.get || value.get;
2587
- set = newValue.set || value.set;
2588
- value = {
2589
- get,
2590
- set
2591
- };
2592
- } else value = newValue;
2593
- if (newInit !== void 0) if (init === void 0) init = newInit;
2594
- else if (typeof init === "function") init = [init, newInit];
2595
- else init.push(newInit);
2596
- }
2597
- }
2598
- if (kind === 0 || kind === 1) {
2599
- if (init === void 0) init = function(instance, init$1) {
2600
- return init$1;
2601
- };
2602
- else if (typeof init !== "function") {
2603
- var ownInitializers = init;
2604
- init = function(instance, init$1) {
2605
- var value$1 = init$1;
2606
- for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
2607
- return value$1;
2608
- };
2609
- } else {
2610
- var originalInitializer = init;
2611
- init = function(instance, init$1) {
2612
- return originalInitializer.call(instance, init$1);
2613
- };
2614
- }
2615
- ret.push(init);
2616
- }
2617
- if (kind !== 0) {
2618
- if (kind === 1) {
2619
- desc.get = value.get;
2620
- desc.set = value.set;
2621
- } else if (kind === 2) desc.value = value;
2622
- else if (kind === 3) desc.get = value;
2623
- else if (kind === 4) desc.set = value;
2624
- if (isPrivate) if (kind === 1) {
2625
- ret.push(function(instance, args) {
2626
- return value.get.call(instance, args);
2627
- });
2628
- ret.push(function(instance, args) {
2629
- return value.set.call(instance, args);
2630
- });
2631
- } else if (kind === 2) ret.push(value);
2632
- else ret.push(function(instance, args) {
2633
- return value.call(instance, args);
2634
- });
2635
- else Object.defineProperty(base, name, desc);
2636
- }
2637
- }
2638
- function applyMemberDecs(Class, decInfos, metadata) {
2639
- var ret = [];
2640
- var protoInitializers;
2641
- var staticInitializers;
2642
- var existingProtoNonFields = /* @__PURE__ */ new Map();
2643
- var existingStaticNonFields = /* @__PURE__ */ new Map();
2644
- for (var i = 0; i < decInfos.length; i++) {
2645
- var decInfo = decInfos[i];
2646
- if (!Array.isArray(decInfo)) continue;
2647
- var kind = decInfo[1];
2648
- var name = decInfo[2];
2649
- var isPrivate = decInfo.length > 3;
2650
- var isStatic = kind >= 5;
2651
- var base;
2652
- var initializers;
2653
- if (isStatic) {
2654
- base = Class;
2655
- kind = kind - 5;
2656
- staticInitializers = staticInitializers || [];
2657
- initializers = staticInitializers;
2658
- } else {
2659
- base = Class.prototype;
2660
- protoInitializers = protoInitializers || [];
2661
- initializers = protoInitializers;
2662
- }
2663
- if (kind !== 0 && !isPrivate) {
2664
- var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
2665
- var existingKind = existingNonFields.get(name) || 0;
2666
- if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
2667
- else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
2668
- else existingNonFields.set(name, true);
2669
- }
2670
- applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
2671
- }
2672
- pushInitializers(ret, protoInitializers);
2673
- pushInitializers(ret, staticInitializers);
2674
- return ret;
2675
- }
2676
- function pushInitializers(ret, initializers) {
2677
- if (initializers) ret.push(function(instance) {
2678
- for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
2679
- return instance;
2680
- });
2681
- }
2682
- function applyClassDecs(targetClass, classDecs, metadata) {
2683
- if (classDecs.length > 0) {
2684
- var initializers = [];
2685
- var newClass = targetClass;
2686
- var name = targetClass.name;
2687
- for (var i = classDecs.length - 1; i >= 0; i--) {
2688
- var decoratorFinishedRef = { v: false };
2689
- try {
2690
- var nextNewClass = classDecs[i](newClass, {
2691
- kind: "class",
2692
- name,
2693
- addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
2694
- metadata
2695
- });
2696
- } finally {
2697
- decoratorFinishedRef.v = true;
2698
- }
2699
- if (nextNewClass !== void 0) {
2700
- assertValidReturnValue(10, nextNewClass);
2701
- newClass = nextNewClass;
2702
- }
2703
- }
2704
- return [defineMetadata(newClass, metadata), function() {
2705
- for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
2706
- }];
2707
- }
2708
- }
2709
- function defineMetadata(Class, metadata) {
2710
- return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
2711
- configurable: true,
2712
- enumerable: true,
2713
- value: metadata
2714
- });
2715
- }
2716
- return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
2717
- if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
2718
- var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
2719
- var e = applyMemberDecs(targetClass, memberDecs, metadata);
2720
- if (!classDecs.length) defineMetadata(targetClass, metadata);
2721
- return {
2722
- e,
2723
- get c() {
2724
- return applyClassDecs(targetClass, classDecs, metadata);
2725
- }
2726
- };
2727
- };
2728
- }
2729
- function _apply_decs_2203_r$2(targetClass, memberDecs, classDecs, parentClass) {
2730
- return (_apply_decs_2203_r$2 = applyDecs2203RFactory$2())(targetClass, memberDecs, classDecs, parentClass);
2731
- }
2732
- var _dec$2, _initClass$2;
2733
- let _ModuleLoaderService;
2734
- _dec$2 = Injectable();
2735
- var ModuleLoaderService = class {
2736
- static {
2737
- ({c: [_ModuleLoaderService, _initClass$2]} = _apply_decs_2203_r$2(this, [], [_dec$2]));
2738
- }
2739
- logger = inject(Logger, { context: _ModuleLoaderService.name });
2740
- container = inject(Container);
2741
- modulesMetadata = /* @__PURE__ */ new Map();
2742
- loadedModules = /* @__PURE__ */ new Map();
2743
- initialized = false;
2744
- async loadModules(appModule) {
2745
- if (this.initialized) return;
2746
- await this.traverseModules(appModule);
2747
- this.initialized = true;
2748
- }
2749
- /**
2750
- * Extends the module tree with additional modules or controllers.
2751
- *
2752
- * This method is designed to be called by plugins during registration,
2753
- * which happens after initial module loading but before route registration.
2754
- *
2755
- * @param extensions - Array of module extensions to add
2756
- * @throws Error if not initialized (loadModules must be called first)
2757
- *
2758
- * @example
2759
- * ```typescript
2760
- * // In plugin registration
2761
- * const moduleLoader = await context.container.get(ModuleLoaderService)
2762
- * await moduleLoader.extendModules([{
2763
- * controllers: [OpenApiJsonController, OpenApiYamlController],
2764
- * moduleName: 'OpenApiBunModule',
2765
- * }])
2766
- * ```
2767
- */ async extendModules(extensions) {
2768
- if (!this.initialized) throw new Error("ModuleLoaderService must be initialized before extending. Call loadModules() first.");
2769
- for (const extension of extensions) if (extension.module) await this.traverseModules(extension.module);
2770
- else if (extension.controllers && extension.moduleName) await this.registerControllers(extension.controllers, extension.moduleName);
2771
- else if (extension.controllers) throw new Error("moduleName is required when providing controllers without a module");
2772
- }
2773
- /**
2774
- * Registers controllers under a synthetic module.
2775
- * Used when plugins want to add controllers without a full module class.
2776
- */ async registerControllers(controllers, moduleName) {
2777
- if (this.modulesMetadata.has(moduleName)) {
2778
- const existing = this.modulesMetadata.get(moduleName);
2779
- for (const controller of controllers) existing.controllers.add(controller);
2780
- this.logger.debug(`Extended module ${moduleName} with ${controllers.length} controllers`);
2781
- } else {
2782
- const metadata = {
2783
- controllers: new Set(controllers),
2784
- imports: /* @__PURE__ */ new Set(),
2785
- guards: /* @__PURE__ */ new Set(),
2786
- overrides: /* @__PURE__ */ new Set(),
2787
- customAttributes: /* @__PURE__ */ new Map(),
2788
- customEntries: /* @__PURE__ */ new Map()
2789
- };
2790
- this.modulesMetadata.set(moduleName, metadata);
2791
- this.logger.debug(`Created module ${moduleName} with ${controllers.length} controllers`);
2792
- }
2793
- }
2794
- async traverseModules(module, parentMetadata) {
2795
- const metadata = extractModuleMetadata(module);
2796
- if (parentMetadata) this.mergeMetadata(metadata, parentMetadata);
2797
- const moduleName = getInjectableToken(module).id;
2798
- if (this.modulesMetadata.has(moduleName)) return;
2799
- try {
2800
- this.modulesMetadata.set(moduleName, metadata);
2801
- const imports = metadata.imports ?? /* @__PURE__ */ new Set();
2802
- const loadingPromises = Array.from(imports).map(async (importedModule) => this.traverseModules(importedModule, metadata));
2803
- await Promise.all(loadingPromises);
2804
- this.validateOverrides(metadata, moduleName);
2805
- const instance = await this.container.get(module);
2806
- if (instance.onModuleInit) await instance.onModuleInit();
2807
- this.logger.debug(`Module ${moduleName} loaded`);
2808
- this.loadedModules.set(moduleName, instance);
2809
- } catch (error) {
2810
- this.logger.error(`Error loading module ${moduleName}`, error);
2811
- throw error;
2812
- }
2813
- }
2814
- validateOverrides(metadata, moduleName) {
2815
- if (!metadata.overrides || metadata.overrides.size === 0) return;
2816
- const registry = this.container.getRegistry();
2817
- for (const overrideClass of metadata.overrides) try {
2818
- const overrideToken = getInjectableToken(overrideClass);
2819
- const allRegistrations = registry.getAll(overrideToken);
2820
- if (allRegistrations.length === 0) {
2821
- this.logger.warn(`[Navios] Override ${overrideClass.name} in module ${moduleName} is not registered. Make sure it has @Injectable decorator.`);
2822
- continue;
2823
- }
2824
- const highestPriorityRegistration = allRegistrations[0];
2825
- if (highestPriorityRegistration.target !== overrideClass) {
2826
- const overrideRegistration = allRegistrations.find((r) => r.target === overrideClass);
2827
- if (!overrideRegistration) this.logger.warn(`[Navios] Override ${overrideClass.name} in module ${moduleName} is registered but not found in registry for token ${overrideToken.toString()}.`);
2828
- else this.logger.warn(`[Navios] Override ${overrideClass.name} in module ${moduleName} is not active. Current active service: ${highestPriorityRegistration.target.name} (priority: ${highestPriorityRegistration.priority}). Override priority: ${overrideRegistration.priority}. Override needs higher priority to take effect.`);
2829
- } else this.logger.debug(`[Navios] Override ${overrideClass.name} in module ${moduleName} is active (priority: ${highestPriorityRegistration.priority})`);
2830
- } catch (error) {
2831
- this.logger.warn(`[Navios] Failed to validate override ${overrideClass.name} in module ${moduleName}: ${error}`);
2832
- }
2833
- }
2834
- mergeMetadata(metadata, parentMetadata) {
2835
- if (parentMetadata.guards) for (const guard of parentMetadata.guards) metadata.guards.add(guard);
2836
- if (parentMetadata.customAttributes) for (const [key, value] of parentMetadata.customAttributes) {
2837
- if (metadata.customAttributes.has(key)) continue;
2838
- metadata.customAttributes.set(key, value);
2839
- }
2840
- }
2841
- getAllModules() {
2842
- return this.modulesMetadata;
2843
- }
2844
- dispose() {
2845
- this.modulesMetadata.clear();
2846
- this.loadedModules.clear();
2847
- this.initialized = false;
2848
- }
2849
- static {
2850
- _initClass$2();
2851
- }
2852
- };
2853
-
2854
- //#endregion
2855
- //#region src/utils/adapter-supports.util.mts
2856
- /**
2857
- * Type guard to check if adapter implements a specific method.
2858
- * Narrows the adapter type to include the method.
2859
- *
2860
- * @example
2861
- * ```typescript
2862
- * if (adapterSupports(adapter, 'getServer')) {
2863
- * const server = adapter.getServer() // TypeScript knows this exists
2864
- * }
2865
- * ```
2866
- */ function adapterSupports(adapter, method) {
2867
- return adapter !== null && typeof adapter[method] === "function";
2868
- }
2869
- /**
2870
- * Asserts adapter supports a method, throws if not.
2871
- * Narrows type after assertion.
2872
- *
2873
- * @example
2874
- * ```typescript
2875
- * assertAdapterSupports(adapter, 'enableCors')
2876
- * adapter.enableCors(options) // TypeScript knows this exists
2877
- * ```
2878
- */ function assertAdapterSupports(adapter, method) {
2879
- if (!adapterSupports(adapter, method)) throw new Error(`Current adapter does not implement '${method}()'`);
2880
- }
2881
-
2882
- //#endregion
2883
- //#region src/navios.environment.mts
2884
- function applyDecs2203RFactory$1() {
2885
- function createAddInitializerMethod(initializers, decoratorFinishedRef) {
2886
- return function addInitializer(initializer) {
2887
- assertNotFinished(decoratorFinishedRef, "addInitializer");
2888
- assertCallable(initializer, "An initializer");
2889
- initializers.push(initializer);
2890
- };
2891
- }
2892
- function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
2893
- var kindStr;
2894
- switch (kind) {
2895
- case 1:
2896
- kindStr = "accessor";
2897
- break;
2898
- case 2:
2899
- kindStr = "method";
2900
- break;
2901
- case 3:
2902
- kindStr = "getter";
2903
- break;
2904
- case 4:
2905
- kindStr = "setter";
2906
- break;
2907
- default: kindStr = "field";
2908
- }
2909
- var ctx = {
2910
- kind: kindStr,
2911
- name: isPrivate ? "#" + name : name,
2912
- static: isStatic,
2913
- private: isPrivate,
2914
- metadata
2915
- };
2916
- var decoratorFinishedRef = { v: false };
2917
- ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
2918
- var get, set;
2919
- if (kind === 0) if (isPrivate) {
2920
- get = desc.get;
2921
- set = desc.set;
2922
- } else {
2923
- get = function() {
2924
- return this[name];
2925
- };
2926
- set = function(v) {
2927
- this[name] = v;
2928
- };
2929
- }
2930
- else if (kind === 2) get = function() {
2931
- return desc.value;
2932
- };
2933
- else {
2934
- if (kind === 1 || kind === 3) get = function() {
2935
- return desc.get.call(this);
2936
- };
2937
- if (kind === 1 || kind === 4) set = function(v) {
2938
- desc.set.call(this, v);
2939
- };
2940
- }
2941
- ctx.access = get && set ? {
2942
- get,
2943
- set
2944
- } : get ? { get } : { set };
2945
- try {
2946
- return dec(value, ctx);
2947
- } finally {
2948
- decoratorFinishedRef.v = true;
2949
- }
2950
- }
2951
- function assertNotFinished(decoratorFinishedRef, fnName) {
2952
- if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
2953
- }
2954
- function assertCallable(fn, hint) {
2955
- if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
2956
- }
2957
- function assertValidReturnValue(kind, value) {
2958
- var type = typeof value;
2959
- if (kind === 1) {
2960
- if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
2961
- if (value.get !== void 0) assertCallable(value.get, "accessor.get");
2962
- if (value.set !== void 0) assertCallable(value.set, "accessor.set");
2963
- if (value.init !== void 0) assertCallable(value.init, "accessor.init");
2964
- } else if (type !== "function") {
2965
- var hint;
2966
- if (kind === 0) hint = "field";
2967
- else if (kind === 10) hint = "class";
2968
- else hint = "method";
2969
- throw new TypeError(hint + " decorators must return a function or void 0");
2970
- }
2971
- }
2972
- function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
2973
- var decs = decInfo[0];
2974
- var desc, init, value;
2975
- if (isPrivate) if (kind === 0 || kind === 1) desc = {
2976
- get: decInfo[3],
2977
- set: decInfo[4]
2978
- };
2979
- else if (kind === 3) desc = { get: decInfo[3] };
2980
- else if (kind === 4) desc = { set: decInfo[3] };
2981
- else desc = { value: decInfo[3] };
2982
- else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
2983
- if (kind === 1) value = {
2984
- get: desc.get,
2985
- set: desc.set
2986
- };
2987
- else if (kind === 2) value = desc.value;
2988
- else if (kind === 3) value = desc.get;
2989
- else if (kind === 4) value = desc.set;
2990
- var newValue, get, set;
2991
- if (typeof decs === "function") {
2992
- newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
2993
- if (newValue !== void 0) {
2994
- assertValidReturnValue(kind, newValue);
2995
- if (kind === 0) init = newValue;
2996
- else if (kind === 1) {
2997
- init = newValue.init;
2998
- get = newValue.get || value.get;
2999
- set = newValue.set || value.set;
3000
- value = {
3001
- get,
3002
- set
3003
- };
3004
- } else value = newValue;
3005
- }
3006
- } else for (var i = decs.length - 1; i >= 0; i--) {
3007
- var dec = decs[i];
3008
- newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
3009
- if (newValue !== void 0) {
3010
- assertValidReturnValue(kind, newValue);
3011
- var newInit;
3012
- if (kind === 0) newInit = newValue;
3013
- else if (kind === 1) {
3014
- newInit = newValue.init;
3015
- get = newValue.get || value.get;
3016
- set = newValue.set || value.set;
3017
- value = {
3018
- get,
3019
- set
3020
- };
3021
- } else value = newValue;
3022
- if (newInit !== void 0) if (init === void 0) init = newInit;
3023
- else if (typeof init === "function") init = [init, newInit];
3024
- else init.push(newInit);
3025
- }
3026
- }
3027
- if (kind === 0 || kind === 1) {
3028
- if (init === void 0) init = function(instance, init$1) {
3029
- return init$1;
3030
- };
3031
- else if (typeof init !== "function") {
3032
- var ownInitializers = init;
3033
- init = function(instance, init$1) {
3034
- var value$1 = init$1;
3035
- for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
3036
- return value$1;
3037
- };
3038
- } else {
3039
- var originalInitializer = init;
3040
- init = function(instance, init$1) {
3041
- return originalInitializer.call(instance, init$1);
3042
- };
3043
- }
3044
- ret.push(init);
3045
- }
3046
- if (kind !== 0) {
3047
- if (kind === 1) {
3048
- desc.get = value.get;
3049
- desc.set = value.set;
3050
- } else if (kind === 2) desc.value = value;
3051
- else if (kind === 3) desc.get = value;
3052
- else if (kind === 4) desc.set = value;
3053
- if (isPrivate) if (kind === 1) {
3054
- ret.push(function(instance, args) {
3055
- return value.get.call(instance, args);
3056
- });
3057
- ret.push(function(instance, args) {
3058
- return value.set.call(instance, args);
3059
- });
3060
- } else if (kind === 2) ret.push(value);
3061
- else ret.push(function(instance, args) {
3062
- return value.call(instance, args);
3063
- });
3064
- else Object.defineProperty(base, name, desc);
3065
- }
3066
- }
3067
- function applyMemberDecs(Class, decInfos, metadata) {
3068
- var ret = [];
3069
- var protoInitializers;
3070
- var staticInitializers;
3071
- var existingProtoNonFields = /* @__PURE__ */ new Map();
3072
- var existingStaticNonFields = /* @__PURE__ */ new Map();
3073
- for (var i = 0; i < decInfos.length; i++) {
3074
- var decInfo = decInfos[i];
3075
- if (!Array.isArray(decInfo)) continue;
3076
- var kind = decInfo[1];
3077
- var name = decInfo[2];
3078
- var isPrivate = decInfo.length > 3;
3079
- var isStatic = kind >= 5;
3080
- var base;
3081
- var initializers;
3082
- if (isStatic) {
3083
- base = Class;
3084
- kind = kind - 5;
3085
- staticInitializers = staticInitializers || [];
3086
- initializers = staticInitializers;
3087
- } else {
3088
- base = Class.prototype;
3089
- protoInitializers = protoInitializers || [];
3090
- initializers = protoInitializers;
3091
- }
3092
- if (kind !== 0 && !isPrivate) {
3093
- var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
3094
- var existingKind = existingNonFields.get(name) || 0;
3095
- if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
3096
- else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
3097
- else existingNonFields.set(name, true);
3098
- }
3099
- applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
3100
- }
3101
- pushInitializers(ret, protoInitializers);
3102
- pushInitializers(ret, staticInitializers);
3103
- return ret;
3104
- }
3105
- function pushInitializers(ret, initializers) {
3106
- if (initializers) ret.push(function(instance) {
3107
- for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
3108
- return instance;
3109
- });
3110
- }
3111
- function applyClassDecs(targetClass, classDecs, metadata) {
3112
- if (classDecs.length > 0) {
3113
- var initializers = [];
3114
- var newClass = targetClass;
3115
- var name = targetClass.name;
3116
- for (var i = classDecs.length - 1; i >= 0; i--) {
3117
- var decoratorFinishedRef = { v: false };
3118
- try {
3119
- var nextNewClass = classDecs[i](newClass, {
3120
- kind: "class",
3121
- name,
3122
- addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
3123
- metadata
3124
- });
3125
- } finally {
3126
- decoratorFinishedRef.v = true;
3127
- }
3128
- if (nextNewClass !== void 0) {
3129
- assertValidReturnValue(10, nextNewClass);
3130
- newClass = nextNewClass;
3131
- }
3132
- }
3133
- return [defineMetadata(newClass, metadata), function() {
3134
- for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
3135
- }];
3136
- }
3137
- }
3138
- function defineMetadata(Class, metadata) {
3139
- return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
3140
- configurable: true,
3141
- enumerable: true,
3142
- value: metadata
3143
- });
3144
- }
3145
- return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
3146
- if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
3147
- var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
3148
- var e = applyMemberDecs(targetClass, memberDecs, metadata);
3149
- if (!classDecs.length) defineMetadata(targetClass, metadata);
3150
- return {
3151
- e,
3152
- get c() {
3153
- return applyClassDecs(targetClass, classDecs, metadata);
3154
- }
3155
- };
3156
- };
3157
- }
3158
- function _apply_decs_2203_r$1(targetClass, memberDecs, classDecs, parentClass) {
3159
- return (_apply_decs_2203_r$1 = applyDecs2203RFactory$1())(targetClass, memberDecs, classDecs, parentClass);
3160
- }
3161
- var _dec$1, _initClass$1;
3162
- let _NaviosEnvironment;
3163
- _dec$1 = Injectable();
3164
- var NaviosEnvironment = class {
3165
- static {
3166
- ({c: [_NaviosEnvironment, _initClass$1]} = _apply_decs_2203_r$1(this, [], [_dec$1]));
3167
- }
3168
- adapterConfigured = false;
3169
- tokens = /* @__PURE__ */ new Map();
3170
- setupEnvironment(tokens) {
3171
- const hasAdapterToken = tokens.has(AdapterToken);
3172
- if (hasAdapterToken && this.adapterConfigured) throw new Error("Adapter already configured. Only one adapter per application.");
3173
- for (const [token, value] of tokens) this.tokens.set(token, value);
3174
- if (hasAdapterToken) this.adapterConfigured = true;
3175
- }
3176
- getToken(token) {
3177
- return this.tokens.get(token);
3178
- }
3179
- hasAdapterSetup() {
3180
- return this.adapterConfigured;
3181
- }
3182
- static {
3183
- _initClass$1();
3184
- }
3185
- };
3186
-
3187
- //#endregion
3188
- //#region src/navios.application.mts
3189
- function applyDecs2203RFactory() {
3190
- function createAddInitializerMethod(initializers, decoratorFinishedRef) {
3191
- return function addInitializer(initializer) {
3192
- assertNotFinished(decoratorFinishedRef, "addInitializer");
3193
- assertCallable(initializer, "An initializer");
3194
- initializers.push(initializer);
3195
- };
3196
- }
3197
- function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
3198
- var kindStr;
3199
- switch (kind) {
3200
- case 1:
3201
- kindStr = "accessor";
3202
- break;
3203
- case 2:
3204
- kindStr = "method";
3205
- break;
3206
- case 3:
3207
- kindStr = "getter";
3208
- break;
3209
- case 4:
3210
- kindStr = "setter";
3211
- break;
3212
- default: kindStr = "field";
3213
- }
3214
- var ctx = {
3215
- kind: kindStr,
3216
- name: isPrivate ? "#" + name : name,
3217
- static: isStatic,
3218
- private: isPrivate,
3219
- metadata
3220
- };
3221
- var decoratorFinishedRef = { v: false };
3222
- ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
3223
- var get, set;
3224
- if (kind === 0) if (isPrivate) {
3225
- get = desc.get;
3226
- set = desc.set;
3227
- } else {
3228
- get = function() {
3229
- return this[name];
3230
- };
3231
- set = function(v) {
3232
- this[name] = v;
3233
- };
3234
- }
3235
- else if (kind === 2) get = function() {
3236
- return desc.value;
3237
- };
3238
- else {
3239
- if (kind === 1 || kind === 3) get = function() {
3240
- return desc.get.call(this);
3241
- };
3242
- if (kind === 1 || kind === 4) set = function(v) {
3243
- desc.set.call(this, v);
3244
- };
3245
- }
3246
- ctx.access = get && set ? {
3247
- get,
3248
- set
3249
- } : get ? { get } : { set };
3250
- try {
3251
- return dec(value, ctx);
3252
- } finally {
3253
- decoratorFinishedRef.v = true;
3254
- }
3255
- }
3256
- function assertNotFinished(decoratorFinishedRef, fnName) {
3257
- if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
3258
- }
3259
- function assertCallable(fn, hint) {
3260
- if (typeof fn !== "function") throw new TypeError(hint + " must be a function");
3261
- }
3262
- function assertValidReturnValue(kind, value) {
3263
- var type = typeof value;
3264
- if (kind === 1) {
3265
- if (type !== "object" || value === null) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
3266
- if (value.get !== void 0) assertCallable(value.get, "accessor.get");
3267
- if (value.set !== void 0) assertCallable(value.set, "accessor.set");
3268
- if (value.init !== void 0) assertCallable(value.init, "accessor.init");
3269
- } else if (type !== "function") {
3270
- var hint;
3271
- if (kind === 0) hint = "field";
3272
- else if (kind === 10) hint = "class";
3273
- else hint = "method";
3274
- throw new TypeError(hint + " decorators must return a function or void 0");
3275
- }
3276
- }
3277
- function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
3278
- var decs = decInfo[0];
3279
- var desc, init, value;
3280
- if (isPrivate) if (kind === 0 || kind === 1) desc = {
3281
- get: decInfo[3],
3282
- set: decInfo[4]
3283
- };
3284
- else if (kind === 3) desc = { get: decInfo[3] };
3285
- else if (kind === 4) desc = { set: decInfo[3] };
3286
- else desc = { value: decInfo[3] };
3287
- else if (kind !== 0) desc = Object.getOwnPropertyDescriptor(base, name);
3288
- if (kind === 1) value = {
3289
- get: desc.get,
3290
- set: desc.set
3291
- };
3292
- else if (kind === 2) value = desc.value;
3293
- else if (kind === 3) value = desc.get;
3294
- else if (kind === 4) value = desc.set;
3295
- var newValue, get, set;
3296
- if (typeof decs === "function") {
3297
- newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
3298
- if (newValue !== void 0) {
3299
- assertValidReturnValue(kind, newValue);
3300
- if (kind === 0) init = newValue;
3301
- else if (kind === 1) {
3302
- init = newValue.init;
3303
- get = newValue.get || value.get;
3304
- set = newValue.set || value.set;
3305
- value = {
3306
- get,
3307
- set
3308
- };
3309
- } else value = newValue;
3310
- }
3311
- } else for (var i = decs.length - 1; i >= 0; i--) {
3312
- var dec = decs[i];
3313
- newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
3314
- if (newValue !== void 0) {
3315
- assertValidReturnValue(kind, newValue);
3316
- var newInit;
3317
- if (kind === 0) newInit = newValue;
3318
- else if (kind === 1) {
3319
- newInit = newValue.init;
3320
- get = newValue.get || value.get;
3321
- set = newValue.set || value.set;
3322
- value = {
3323
- get,
3324
- set
3325
- };
3326
- } else value = newValue;
3327
- if (newInit !== void 0) if (init === void 0) init = newInit;
3328
- else if (typeof init === "function") init = [init, newInit];
3329
- else init.push(newInit);
3330
- }
3331
- }
3332
- if (kind === 0 || kind === 1) {
3333
- if (init === void 0) init = function(instance, init$1) {
3334
- return init$1;
3335
- };
3336
- else if (typeof init !== "function") {
3337
- var ownInitializers = init;
3338
- init = function(instance, init$1) {
3339
- var value$1 = init$1;
3340
- for (var i$1 = 0; i$1 < ownInitializers.length; i$1++) value$1 = ownInitializers[i$1].call(instance, value$1);
3341
- return value$1;
3342
- };
3343
- } else {
3344
- var originalInitializer = init;
3345
- init = function(instance, init$1) {
3346
- return originalInitializer.call(instance, init$1);
3347
- };
3348
- }
3349
- ret.push(init);
3350
- }
3351
- if (kind !== 0) {
3352
- if (kind === 1) {
3353
- desc.get = value.get;
3354
- desc.set = value.set;
3355
- } else if (kind === 2) desc.value = value;
3356
- else if (kind === 3) desc.get = value;
3357
- else if (kind === 4) desc.set = value;
3358
- if (isPrivate) if (kind === 1) {
3359
- ret.push(function(instance, args) {
3360
- return value.get.call(instance, args);
3361
- });
3362
- ret.push(function(instance, args) {
3363
- return value.set.call(instance, args);
3364
- });
3365
- } else if (kind === 2) ret.push(value);
3366
- else ret.push(function(instance, args) {
3367
- return value.call(instance, args);
3368
- });
3369
- else Object.defineProperty(base, name, desc);
3370
- }
3371
- }
3372
- function applyMemberDecs(Class, decInfos, metadata) {
3373
- var ret = [];
3374
- var protoInitializers;
3375
- var staticInitializers;
3376
- var existingProtoNonFields = /* @__PURE__ */ new Map();
3377
- var existingStaticNonFields = /* @__PURE__ */ new Map();
3378
- for (var i = 0; i < decInfos.length; i++) {
3379
- var decInfo = decInfos[i];
3380
- if (!Array.isArray(decInfo)) continue;
3381
- var kind = decInfo[1];
3382
- var name = decInfo[2];
3383
- var isPrivate = decInfo.length > 3;
3384
- var isStatic = kind >= 5;
3385
- var base;
3386
- var initializers;
3387
- if (isStatic) {
3388
- base = Class;
3389
- kind = kind - 5;
3390
- staticInitializers = staticInitializers || [];
3391
- initializers = staticInitializers;
3392
- } else {
3393
- base = Class.prototype;
3394
- protoInitializers = protoInitializers || [];
3395
- initializers = protoInitializers;
3396
- }
3397
- if (kind !== 0 && !isPrivate) {
3398
- var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
3399
- var existingKind = existingNonFields.get(name) || 0;
3400
- if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
3401
- else if (!existingKind && kind > 2) existingNonFields.set(name, kind);
3402
- else existingNonFields.set(name, true);
3403
- }
3404
- applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
3405
- }
3406
- pushInitializers(ret, protoInitializers);
3407
- pushInitializers(ret, staticInitializers);
3408
- return ret;
3409
- }
3410
- function pushInitializers(ret, initializers) {
3411
- if (initializers) ret.push(function(instance) {
3412
- for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
3413
- return instance;
3414
- });
3415
- }
3416
- function applyClassDecs(targetClass, classDecs, metadata) {
3417
- if (classDecs.length > 0) {
3418
- var initializers = [];
3419
- var newClass = targetClass;
3420
- var name = targetClass.name;
3421
- for (var i = classDecs.length - 1; i >= 0; i--) {
3422
- var decoratorFinishedRef = { v: false };
3423
- try {
3424
- var nextNewClass = classDecs[i](newClass, {
3425
- kind: "class",
3426
- name,
3427
- addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
3428
- metadata
3429
- });
3430
- } finally {
3431
- decoratorFinishedRef.v = true;
3432
- }
3433
- if (nextNewClass !== void 0) {
3434
- assertValidReturnValue(10, nextNewClass);
3435
- newClass = nextNewClass;
3436
- }
3437
- }
3438
- return [defineMetadata(newClass, metadata), function() {
3439
- for (var i$1 = 0; i$1 < initializers.length; i$1++) initializers[i$1].call(newClass);
3440
- }];
3441
- }
3442
- }
3443
- function defineMetadata(Class, metadata) {
3444
- return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
3445
- configurable: true,
3446
- enumerable: true,
3447
- value: metadata
3448
- });
3449
- }
3450
- return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
3451
- if (parentClass !== void 0) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
3452
- var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
3453
- var e = applyMemberDecs(targetClass, memberDecs, metadata);
3454
- if (!classDecs.length) defineMetadata(targetClass, metadata);
3455
- return {
3456
- e,
3457
- get c() {
3458
- return applyClassDecs(targetClass, classDecs, metadata);
3459
- }
3460
- };
3461
- };
3462
- }
3463
- function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
3464
- return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
3465
- }
3466
- var _dec, _initClass;
3467
- let _NaviosApplication;
3468
- _dec = Injectable();
3469
- var NaviosApplication = class {
3470
- static {
3471
- ({c: [_NaviosApplication, _initClass]} = _apply_decs_2203_r(this, [], [_dec]));
3472
- }
3473
- environment = inject(_NaviosEnvironment);
3474
- moduleLoader = inject(_ModuleLoaderService);
3475
- adapter = null;
3476
- logger = inject(Logger, { context: _NaviosApplication.name });
3477
- container = inject(Container);
3478
- appModule = null;
3479
- options = { adapter: [] };
3480
- plugins = [];
3481
- /**
3482
- * Indicates whether the application has been initialized.
3483
- * Set to `true` after `init()` completes successfully.
3484
- */ isInitialized = false;
3485
- /**
3486
- * Sets up the application with the provided module and options.
3487
- * This is called automatically by NaviosFactory.create().
3488
- *
3489
- * @param appModule - The root application module
3490
- * @param options - Application configuration options
3491
- * @internal
3492
- */ async setup(appModule, options = { adapter: [] }) {
3493
- this.appModule = appModule;
3494
- this.options = options;
3495
- if (this.environment.hasAdapterSetup()) this.adapter = await this.container.get(AdapterToken);
3496
- }
3497
- /**
3498
- * Gets the dependency injection container used by this application.
3499
- *
3500
- * @returns The Container instance
3501
- */ getContainer() {
3502
- return this.container;
3503
- }
3504
- /**
3505
- * Returns the current adapter instance.
3506
- *
3507
- * @returns The adapter instance
3508
- * @throws Error if adapter is not initialized
3509
- */ getAdapter() {
3510
- if (!this.adapter) throw new Error("Adapter not initialized");
3511
- return this.adapter;
3512
- }
3513
- /**
3514
- * Registers a plugin to be initialized after modules are loaded.
3515
- *
3516
- * Plugins are initialized in the order they are registered,
3517
- * after all modules are loaded but before the server starts listening.
3518
- *
3519
- * @param definition - Plugin definition with options
3520
- * @returns this for method chaining
3521
- *
3522
- * @example
3523
- * ```typescript
3524
- * import { defineOpenApiPlugin } from '@navios/openapi-fastify'
3525
- *
3526
- * app.usePlugin(defineOpenApiPlugin({
3527
- * info: { title: 'My API', version: '1.0.0' },
3528
- * }))
3529
- * ```
3530
- */ usePlugin(definition) {
3531
- this.plugins.push(definition);
3532
- return this;
3533
- }
3534
- /**
3535
- * Initializes the application.
3536
- *
3537
- * This method:
3538
- * - Loads all modules and their dependencies
3539
- * - Sets up the adapter if one is configured
3540
- * - Calls onModuleInit hooks on all modules
3541
- * - Initializes registered plugins
3542
- * - Marks the application as initialized
3543
- *
3544
- * Must be called before `listen()`.
3545
- *
3546
- * @throws Error if app module is not set
3547
- *
3548
- * @example
3549
- * ```typescript
3550
- * const app = await NaviosFactory.create(AppModule, {
3551
- * adapter: defineFastifyEnvironment(),
3552
- * })
3553
- * await app.init()
3554
- * await app.listen({ port: 3000 })
3555
- * ```
3556
- */ async init() {
3557
- if (!this.appModule) throw new Error("App module is not set. Call setAppModule() first.");
3558
- await this.moduleLoader.loadModules(this.appModule);
3559
- if (this.environment.hasAdapterSetup() && this.adapter) await this.adapter.setupAdapter(this.options);
3560
- await this.initPlugins();
3561
- await this.initModules();
3562
- if (this.adapter) await this.adapter.ready();
3563
- this.isInitialized = true;
3564
- this.logger.debug("Navios application initialized");
3565
- }
3566
- async initModules() {
3567
- const modules = this.moduleLoader.getAllModules();
3568
- if (this.adapter) await this.adapter.onModulesInit(modules);
3569
- }
3570
- async initPlugins() {
3571
- if (this.plugins.length === 0) return;
3572
- if (!this.adapter) throw new Error("Cannot initialize plugins without an adapter");
3573
- const context = {
3574
- modules: this.moduleLoader.getAllModules(),
3575
- adapter: this.adapter,
3576
- container: this.container,
3577
- moduleLoader: this.moduleLoader
3578
- };
3579
- for (const { plugin, options } of this.plugins) {
3580
- this.logger.debug(`Initializing plugin: ${plugin.name}`);
3581
- await plugin.register(context, options);
3582
- }
3583
- }
3584
- async get(token, args) {
3585
- return this.container.get(token, args);
3586
- }
3587
- /**
3588
- * Configures the adapter with additional options before initialization.
3589
- *
3590
- * This method allows setting adapter-specific configuration options
3591
- * before the adapter is initialized. Must be called before `init()`.
3592
- *
3593
- * @param options - Adapter-specific configuration options
3594
- * @returns this for method chaining
3595
- * @throws Error if called after init() or if adapter doesn't support configure
3596
- *
3597
- * @example
3598
- * ```typescript
3599
- * // With Fastify adapter
3600
- * app.configure({ trustProxy: true, logger: true })
3601
- *
3602
- * // With Bun adapter
3603
- * app.configure({ development: true })
3604
- * ```
3605
- */ configure(options) {
3606
- if (this.isInitialized) throw new Error("configure() must be called before init()");
3607
- assertAdapterSupports(this.adapter, "configure");
3608
- this.adapter.configure(options);
3609
- return this;
3610
- }
3611
- /**
3612
- * Enables CORS (Cross-Origin Resource Sharing) for the application.
3613
- *
3614
- * @param options - CORS configuration options (adapter-specific)
3615
- * @throws Error if adapter doesn't support enableCors
3616
- *
3617
- * @example
3618
- * ```typescript
3619
- * app.enableCors({
3620
- * origin: ['http://localhost:3000', 'https://example.com'],
3621
- * methods: ['GET', 'POST', 'PUT', 'DELETE'],
3622
- * credentials: true,
3623
- * })
3624
- * ```
3625
- */ enableCors(options) {
3626
- assertAdapterSupports(this.adapter, "enableCors");
3627
- this.adapter.enableCors(options);
3628
- }
3629
- /**
3630
- * Enables multipart/form-data support for file uploads.
3631
- *
3632
- * @param options - Multipart configuration options (adapter-specific)
3633
- * @throws Error if adapter doesn't support enableMultipart
3634
- *
3635
- * @example
3636
- * ```typescript
3637
- * app.enableMultipart({
3638
- * limits: {
3639
- * fileSize: 1024 * 1024 * 10, // 10MB
3640
- * },
3641
- * })
3642
- * ```
3643
- */ enableMultipart(options) {
3644
- assertAdapterSupports(this.adapter, "enableMultipart");
3645
- this.adapter.enableMultipart(options);
3646
- }
3647
- /**
3648
- * Sets a global prefix for all routes.
3649
- *
3650
- * @param prefix - The prefix to prepend to all route URLs (e.g., '/api')
3651
- * @throws Error if adapter doesn't support setGlobalPrefix
3652
- *
3653
- * @example
3654
- * ```typescript
3655
- * app.setGlobalPrefix('/api/v1')
3656
- * // All routes will be prefixed with /api/v1
3657
- * ```
3658
- */ setGlobalPrefix(prefix) {
3659
- assertAdapterSupports(this.adapter, "setGlobalPrefix");
3660
- this.adapter.setGlobalPrefix(prefix);
3661
- }
3662
- /**
3663
- * Gets the underlying HTTP server instance.
3664
- *
3665
- * The type of the returned server depends on the adapter used:
3666
- * - Fastify adapter: Returns FastifyInstance
3667
- * - Bun adapter: Returns Bun.Server
3668
- *
3669
- * @returns The HTTP server instance
3670
- * @throws Error if adapter doesn't support getServer
3671
- *
3672
- * @example
3673
- * ```typescript
3674
- * const server = app.getServer()
3675
- * // Use adapter-specific server methods
3676
- * ```
3677
- */ getServer() {
3678
- assertAdapterSupports(this.adapter, "getServer");
3679
- return this.adapter.getServer();
3680
- }
3681
- /**
3682
- * Starts the HTTP server and begins listening for requests.
3683
- *
3684
- * @param options - Listen options (port, host, etc.)
3685
- * @throws Error if adapter doesn't support listen
3686
- *
3687
- * @example
3688
- * ```typescript
3689
- * await app.listen({ port: 3000, host: '0.0.0.0' })
3690
- * ```
3691
- */ async listen(options) {
3692
- assertAdapterSupports(this.adapter, "listen");
3693
- return this.adapter.listen(options);
3694
- }
3695
- /**
3696
- * Disposes of application resources.
3697
- *
3698
- * Cleans up the adapter and module loader.
3699
- * This method is called automatically by `close()`.
3700
- */ async dispose() {
3701
- if (this.adapter) await this.adapter.dispose();
3702
- if (this.moduleLoader) this.moduleLoader.dispose();
3703
- }
3704
- /**
3705
- * Closes the application and cleans up all resources.
3706
- *
3707
- * This is an alias for `dispose()`.
3708
- *
3709
- * @example
3710
- * ```typescript
3711
- * // Graceful shutdown
3712
- * process.on('SIGTERM', async () => {
3713
- * await app.close()
3714
- * process.exit(0)
3715
- * })
3716
- * ```
3717
- */ async close() {
3718
- await this.dispose();
3719
- }
3720
- static {
3721
- _initClass();
3722
- }
3723
- };
3724
-
3725
- //#endregion
3726
- //#region src/navios.factory.mts
3727
- /**
3728
- * Factory class for creating and configuring Navios applications.
3729
- *
3730
- * This is the main entry point for bootstrapping a Navios application.
3731
- * It handles dependency injection container setup, adapter registration,
3732
- * and logger configuration.
3733
- *
3734
- * @example
3735
- * ```typescript
3736
- * import { NaviosFactory } from '@navios/core'
3737
- * import { defineFastifyEnvironment } from '@navios/adapter-fastify'
3738
- *
3739
- * const app = await NaviosFactory.create(AppModule, {
3740
- * adapter: defineFastifyEnvironment(),
3741
- * logger: ['log', 'error', 'warn'],
3742
- * })
3743
- *
3744
- * await app.init()
3745
- * await app.listen({ port: 3000 })
3746
- * ```
3747
- */ var NaviosFactory = class {
3748
- /**
3749
- * Creates a new Navios application instance.
3750
- *
3751
- * This method sets up the dependency injection container, registers the adapter,
3752
- * configures logging, and initializes the application with the provided module.
3753
- *
3754
- * @typeParam Environment - Adapter environment interface for type-safe access
3755
- * to adapter-specific features. When specified, methods like `getServer()`,
3756
- * `enableCors()`, `listen()`, and `configure()` will have proper types.
3757
- *
3758
- * @param appModule - The root application module class decorated with @Module()
3759
- * @param options - Configuration options for the application
3760
- * @param options.adapter - Adapter environment (required for server functionality)
3761
- * @param options.logger - Logger configuration. Can be:
3762
- * - A LoggerService instance for custom logging
3763
- * - An array of LogLevel strings to enable specific log levels
3764
- * - `false` to disable logging
3765
- * @param options.container - Optional custom dependency injection container (useful for testing)
3766
- * @returns A configured NaviosApplication instance ready to be initialized
3767
- *
3768
- * @example
3769
- * ```typescript
3770
- * // Basic setup with Fastify adapter
3771
- * const app = await NaviosFactory.create(AppModule, {
3772
- * adapter: defineFastifyEnvironment(),
3773
- * })
3774
- *
3775
- * // Type-safe setup with Fastify environment
3776
- * import { FastifyEnvironment } from '@navios/adapter-fastify'
3777
- *
3778
- * const app = await NaviosFactory.create<FastifyEnvironment>(AppModule, {
3779
- * adapter: defineFastifyEnvironment(),
3780
- * })
3781
- * app.configure({ trustProxy: true })
3782
- * const server = app.getServer() // FastifyInstance
3783
- *
3784
- * // With custom logger configuration
3785
- * const app = await NaviosFactory.create(AppModule, {
3786
- * adapter: defineFastifyEnvironment(),
3787
- * logger: ['error', 'warn', 'log'],
3788
- * })
3789
- *
3790
- * // With custom container for testing
3791
- * const container = new Container()
3792
- * const app = await NaviosFactory.create(AppModule, {
3793
- * adapter: defineFastifyEnvironment(),
3794
- * container,
3795
- * })
3796
- * ```
3797
- */ static async create(appModule, options = { adapter: [] }) {
3798
- const container = options.container ?? new Container(options.registry);
3799
- if (options.enableRequestId === true) setRequestIdEnabled(true);
3800
- container.addInstance(NaviosOptionsToken, options);
3801
- await this.registerLoggerConfiguration(container, options);
3802
- const adapters = Array.isArray(options.adapter) ? options.adapter : [options.adapter];
3803
- for (const adapter of adapters) await this.registerEnvironment(container, adapter);
3804
- const app = await container.get(_NaviosApplication);
3805
- await app.setup(appModule, options);
3806
- return app;
3807
- }
3808
- static async registerEnvironment(container, environment = {}) {
3809
- const naviosEnvironment = await container.get(_NaviosEnvironment);
3810
- const { tokens } = environment;
3811
- if (tokens) naviosEnvironment.setupEnvironment(tokens);
3812
- }
3813
- static async registerLoggerConfiguration(container, options) {
3814
- const { logger } = options;
3815
- if (Array.isArray(logger) || isNil(logger) || options.enableRequestId) {
3816
- (await container.get(LoggerOutput))?.setup({
3817
- logLevels: Array.isArray(logger) ? logger : void 0,
3818
- requestId: options.enableRequestId ?? false
3819
- });
3820
- return;
3821
- }
3822
- if (logger !== true && !isNil(logger)) container.addInstance(LoggerOutput, logger);
3823
- }
3824
- };
3825
-
3826
- //#endregion
3827
- export { isNil as A, filterLogLevels as B, getRequestId as C, isConstructor as D, addLeadingSlash as E, isSymbol as F, LOG_LEVELS as H, isUndefined as I, normalizePath as L, isObject as M, isPlainObject as N, isEmpty as O, isString as P, stripEndSlash as R, generateRequestId as S, setRequestIdEnabled as T, clc as U, isLogLevel as V, yellow as W, _LoggerInstance as _, assertAdapterSupports as a, LoggerOutput as b, AbstractHandlerAdapterService as c, ForbiddenResponderToken as d, InternalServerErrorResponderToken as f, HttpException as g, FrameworkError as h, adapterSupports as i, isNumber as j, isFunction as k, _InstanceResolverService as l, ValidationErrorResponderToken as m, _NaviosApplication as n, _ModuleLoaderService as o, NotFoundResponderToken as p, _NaviosEnvironment as r, _GuardRunnerService as s, NaviosFactory as t, _ErrorResponseProducerService as u, _ConsoleLogger as v, runWithRequestId as w, loggerOptionsSchema as x, Logger as y, isLogLevelEnabled as z };
3828
- //# sourceMappingURL=navios.factory-D6Y94P9B.mjs.map